@veevarts/design-system 1.12.0-alpha.3 → 1.12.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +11 -11
- package/dist/index.js +4343 -3669
- package/dist/patterns/CatalogItemCard/CatalogItemCard.d.ts +7 -0
- package/dist/patterns/CatalogItemCard/index.d.ts +2 -0
- package/dist/patterns/CatalogItemCard/type.d.ts +82 -0
- package/dist/patterns/EventDetails/EventDetails.d.ts +3 -1
- package/dist/patterns/FeedbackState/FeedbackState.d.ts +23 -0
- package/dist/patterns/FeedbackState/index.d.ts +2 -0
- package/dist/patterns/FeedbackState/type.d.ts +40 -0
- package/dist/patterns/FilterPopover/FilterPopover.d.ts +6 -0
- package/dist/patterns/FilterPopover/index.d.ts +2 -0
- package/dist/patterns/FilterPopover/type.d.ts +85 -0
- package/dist/patterns/ItemCard/type.d.ts +52 -0
- package/dist/patterns/OfferCard/OfferCard.d.ts +1 -1
- package/dist/patterns/OfferCard/types.d.ts +93 -2
- package/dist/patterns/OfferCard/variants/OfferCardList.d.ts +2 -2
- package/dist/patterns/SessionTimeline/SessionTimeline.d.ts +7 -0
- package/dist/patterns/SessionTimeline/index.d.ts +2 -0
- package/dist/patterns/SessionTimeline/type.d.ts +76 -0
- package/dist/patterns/index.d.ts +8 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),h=require("@heroui/react"),y=require("react"),U=require("lucide-react"),Le=require("framer-motion"),Rr=require("@tiptap/react"),z=require("@tiptap/core"),go=require("@tiptap/extension-underline"),xo=require("@tiptap/extension-color"),yo=require("@tiptap/extension-highlight"),bo=require("@tiptap/extension-link"),vo=require("@tiptap/extension-task-list"),wo=require("@tiptap/extension-task-item"),ko=require("@tiptap/extension-text-align");function No({children:e}){return o.jsx(h.HeroUIProvider,{children:e})}const W=y.forwardRef(({color:e="primary",radius:t="full",testId:n="veevart-button",...r},s)=>o.jsx(h.Button,{ref:s,color:e,radius:t,"data-testid":n,...r}));W.displayName="Button";function So(e){const t=e?.closest('[role="dialog"]');return t?.parentElement??t??void 0}const pt=y.forwardRef(({popoverProps:e,...t},n)=>{const r=y.useRef(null),[s,i]=y.useState(void 0),a={...e,disableDialogFocus:e?.disableDialogFocus??(s?!0:void 0),portalContainer:e?.portalContainer??s};return y.useEffect(()=>{i(So(r.current))},[]),o.jsx("span",{ref:r,className:"contents",children:o.jsx(h.Select,{ref:n,...t,popoverProps:a})})});pt.displayName="Select";const Co={login:"Login",logout:"Logout",selectLanguage:"Select your language"};function jo({languages:e,selectedLanguage:t,onLanguageChange:n,label:r}){const s=e.find(i=>i.code===t);return o.jsx("div",{className:"flex items-center",children:o.jsxs("div",{className:"relative flex items-center",children:[o.jsx(pt,{"data-testid":"language-select-desktop",variant:"bordered","aria-label":r,selectedKeys:t?[t]:[],onSelectionChange:i=>{const a=Array.from(i)[0]||t;n?.(a)},className:"min-w-36 hidden md:inline-flex",isDisabled:e.length===0,placeholder:r,startContent:o.jsx(U.Globe,{className:"w-5 h-5 text-black"}),renderValue:()=>o.jsx("span",{children:s?.label||r}),size:"md",radius:"full",children:e.map(i=>o.jsx(h.SelectItem,{textValue:i.label,"data-testid":`language-select-option-${i.code}`,children:i.label},i.code))}),o.jsx(pt,{"aria-label":r,"data-testid":"language-select-mobile",variant:"bordered",selectedKeys:t?[t]:[],onSelectionChange:i=>{const a=Array.from(i)[0]||t;n?.(a)},className:"w-24 inline-flex md:hidden",isDisabled:e.length===0,placeholder:"",startContent:o.jsx(U.Globe,{className:"w-6 h-6 text-black"}),renderValue:()=>o.jsx("span",{children:s?.code.toUpperCase()||""}),size:"md",radius:"full",children:e.map(i=>o.jsx(h.SelectItem,{textValue:i.code.toUpperCase(),"data-testid":`language-select-option-mobile-${i.code}`,children:i.code.toUpperCase()},i.code))})]})})}function Ao({isLoggedIn:e,onLogin:t,onLogout:n,labels:r}){return e?o.jsxs(W,{"data-testid":"navbar-auth-button",className:"px-2 py-1 w-1 min-w-12 md:min-w-24 rounded-full bg-black text-white text-sm flex items-center",onPress:n,size:"md",children:[o.jsx(U.User,{className:"inline w-5 h-5"}),o.jsx("span",{className:"hidden md:inline",children:r.logout})]}):o.jsxs(W,{"data-testid":"navbar-auth-button",className:"px-2 py-1 min-w-12 md:min-w-24 rounded-full bg-black text-white text-sm flex items-center",onPress:t,size:"md",children:[o.jsx(U.User,{className:"inline w-5 h-5"}),o.jsx("span",{className:"hidden md:inline",children:r.login})]})}function Mo({logo:e,languages:t=[],selectedLanguage:n,onLanguageChange:r,isLoggedIn:s,onLogin:i,onLogout:a,hasLanguages:l,hasAuth:c,labels:d={},className:u}){const f={...Co,...d};return o.jsxs("nav",{"data-testid":"navbar",className:h.cn("w-full px-4 md:px-8 py-3 bg-white border-b border-zinc-100 flex items-center justify-between",u),children:[o.jsx("div",{className:"flex items-center min-w-10",children:e&&o.jsx("a",{href:"/",className:"block",children:o.jsx("img",{"data-testid":"navbar-logo",src:e,alt:"Logo",className:"h-8 w-auto max-w-28 md:max-w-40 object-contain"})})}),o.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[(l||t.length>0)&&o.jsx(jo,{languages:t,selectedLanguage:n,onLanguageChange:r,label:f.selectLanguage}),c&&o.jsx(Ao,{isLoggedIn:s,onLogin:i,onLogout:a,labels:f})]})]})}function Eo(e){return o.jsx("div",{className:"min-h-screen flex flex-col",children:o.jsx("div",{className:"flex-1 flex items-center justify-center p-12",children:o.jsx(h.Alert,{description:"This template combines Navbar, Footer, and a confirmation Card. Include title, message, confirmation number, details list, icon, and action buttons. Use Card for the confirmation content.",title:"TODO: Implement ConfirmationPageTemplate",variant:"faded",className:"max-w-2xl"})})})}var Un;const To=typeof document<"u"?(Un=y.useInsertionEffect)!==null&&Un!==void 0?Un:y.useLayoutEffect:()=>{};function zr(e,t,n){let[r,s]=y.useState(e||t),i=y.useRef(r),a=y.useRef(e!==void 0),l=e!==void 0;y.useEffect(()=>{let f=a.current;f!==l&&process.env.NODE_ENV!=="production"&&console.warn(`WARN: A component changed from ${f?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}.`),a.current=l},[l]);let c=l?e:r;To(()=>{i.current=c});let[,d]=y.useReducer(()=>({}),{}),u=y.useCallback((f,...p)=>{let m=typeof f=="function"?f(i.current):f;Object.is(i.current,m)||(i.current=m,s(m),d(),n?.(m,...p))},[n]);return[c,u]}function Do(e){return o.jsx("svg",{...e,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:o.jsx(Le.m.path,{animate:{pathLength:1},d:"M5 13l4 4L19 7",initial:{pathLength:0},strokeLinecap:"round",strokeLinejoin:"round",transition:{delay:.2,type:"tween",ease:"easeOut",duration:.3}})})}const _i=y.forwardRef(({color:e="primary",stepsCount:t=3,defaultStep:n=0,label:r,onStepChange:s,currentStep:i,hideProgressBars:a=!1,stepClassName:l,className:c,isDisabled:d=!1,...u},f)=>{const[p,m]=zr(i,n,s),v=y.useMemo(()=>{let b,x;const w=["[--active-fg-color:hsl(var(--step-fg-color))]","[--active-border-color:hsl(var(--step-color))]","[--active-color:hsl(var(--step-color))]","[--complete-background-color:hsl(var(--step-color))]","[--complete-border-color:hsl(var(--step-color))]","[--inactive-border-color:hsl(var(--heroui-default-300))]","[--inactive-color:hsl(var(--heroui-default-300))]"];switch(e){case"primary":b="[--step-color:var(--heroui-primary)]",x="[--step-fg-color:var(--heroui-primary-foreground)]";break;case"secondary":b="[--step-color:var(--heroui-secondary)]",x="[--step-fg-color:var(--heroui-secondary-foreground)]";break;case"success":b="[--step-color:var(--heroui-success)]",x="[--step-fg-color:var(--heroui-success-foreground)]";break;case"warning":b="[--step-color:var(--heroui-warning)]",x="[--step-fg-color:var(--heroui-warning-foreground)]";break;case"danger":b="[--step-color:var(--heroui-danger)]",x="[--step-fg-color:var(--heroui-danger-foreground)]";break;case"default":b="[--step-color:var(--heroui-default)]",x="[--step-fg-color:var(--heroui-default-foreground)]";break;default:b="[--step-color:var(--heroui-primary)]",x="[--step-fg-color:var(--heroui-primary-foreground)]";break}return w.unshift(x),w.unshift(b),w},[e]);return o.jsxs("nav",{ref:f,"aria-label":"Progress",className:h.cn("flex max-w-fit items-center overflow-x-auto",c),"data-testid":"stepper-root",...u,children:[r&&o.jsx("label",{className:"text-small text-default-foreground lg:text-medium font-light whitespace-nowrap me-3","data-testid":"stepper-label",children:r}),o.jsx("ol",{className:h.cn("flex flex-row flex-nowrap gap-x-3",v,c),"data-testid":"stepper-list",children:Array.from({length:t})?.map((b,x)=>{const w=p===x?"active":p<x?"inactive":"complete";return o.jsx("li",{className:"relative flex shrink-0 items-center pr-12","data-testid":`stepper-step-${x}`,children:o.jsxs("button",{"aria-current":w==="active"?"step":void 0,className:h.cn("group rounded-large flex w-full cursor-pointer flex-row items-center justify-center gap-x-3 py-2.5",{"cursor-not-allowed opacity-50":d},l),onClick:()=>!d&&m(x),disabled:d,"data-testid":`stepper-step-btn-${x}`,children:[o.jsx("div",{className:"h-full relative flex items-center",children:o.jsx(Le.LazyMotion,{features:Le.domAnimation,children:o.jsx(Le.m.div,{animate:w,className:"relative",children:o.jsx(Le.m.div,{animate:w,className:h.cn("border-medium text-large text-default-foreground relative flex h-[26px] w-[26px] items-center justify-center rounded-full font-semibold",{"shadow-lg":w==="complete"}),initial:!1,transition:{duration:.25},variants:{inactive:{backgroundColor:"transparent",borderColor:"var(--inactive-border-color)",color:"var(--inactive-color)"},active:{backgroundColor:"transparent",borderColor:"var(--active-border-color)",color:"var(--active-color)"},complete:{backgroundColor:"var(--complete-background-color)",borderColor:"var(--complete-border-color)",color:"var(--active-fg-color)"}},children:o.jsx("div",{className:"flex items-center justify-center",children:w==="complete"?o.jsx(Do,{className:"h-5 w-5 text-(--active-fg-color)","data-testid":`stepper-step-check-${x}`}):o.jsx("span",{})})})})})}),x<t-1&&!a&&o.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 left-[26px] w-[calc(100%-13px)] flex-none items-center",style:{"--idx":x},children:o.jsx("div",{className:h.cn("bg-default-200 relative h-0.5 w-full transition-colors duration-300","after:absolute after:block after:h-full after:w-0 after:bg-(--active-border-color) after:transition-[width] after:duration-300 after:content-['']",{"after:w-full":x<p})})})]},x)},x)})})]})});_i.displayName="Stepper";function Io(e){return o.jsx("div",{className:"min-h-screen flex flex-col",children:o.jsx("div",{className:"flex-1 flex items-center justify-center p-12",children:o.jsx(h.Alert,{description:"This template combines Navbar, Stepper, Footer, and an event details Card. Include event image, category/spots chips, tags, details grid, and action buttons. Use Card, CardHeader, CardBody for content structure.",title:"TODO: Implement EventDetailsTemplate",variant:"faded",className:"max-w-2xl"})})})}function tt(e,t="en-US",n="USD"){try{return new Intl.NumberFormat(t,{style:"currency",currency:n}).format(e)}catch{return`${n} ${e.toFixed(2)}`}}function Br(e,t="en-US"){try{const n=new Intl.NumberFormat(t,{style:"currency",currency:e}).resolvedOptions();return typeof n.maximumFractionDigits=="number"?n.maximumFractionDigits:2}catch{return 2}}function Vi(e,t,n="en-US"){const r=Br(t,n),s=Math.pow(10,r);return Math.round(e*s)/s}function pr(e,t,n,r){return Vi(e-t,n,r)}function $o(){return o.jsxs("footer",{"data-testid":"footer",className:"fixed left-0 bottom-0 w-full text-left p-4 bg-white font-inter font-light text-base text-zinc-500",children:["Powered by Veevart ® ",new Date().getFullYear()]})}const Oo=e=>{const t=y.useMemo(()=>JSON.stringify({allItems:e.allItems,selected:e.selected}),[e.allItems,e.selected]);return o.jsx(Lo,{...e},t)},Lo=({allItems:e,selected:t,onSelectedChange:n,titleLeft:r,titleRight:s})=>{const[i,a]=y.useState([]),[l,c]=y.useState([]),[d,u]=y.useState(null),[f,p]=y.useState(null),m=y.useMemo(()=>new Set(t),[t]),v=y.useMemo(()=>new Set(e),[e]),b=y.useMemo(()=>e.filter(E=>!m.has(E)),[e,m]),x=E=>{if(E.length===0)return;const T=Array.from(new Set([...t,...E]));n(T)},w=E=>{if(E.length===0)return;const T=new Set(E);n(t.filter(O=>!T.has(O)))},N=()=>{i.length!==0&&(x(i),a([]))},A=()=>{l.length!==0&&(w(l),c([]))},S=()=>{b.length!==0&&(x(b),a([]))},j=()=>{t.length!==0&&(n([]),c([]))},M=(E,T,O)=>{const F=Math.min(T,O),K=Math.max(T,O);return E.slice(F,K+1)},I=(E,T,O)=>{if(O&&d!==null){a(M(b,d,T)),c([]),u(T);return}const F=i.includes(E);a(F?i.filter(K=>K!==E):[...i,E]),c([]),u(T)},B=(E,T,O)=>{if(O&&f!==null){c(M(t,f,T)),a([]),p(T);return}const F=l.includes(E);c(F?l.filter(K=>K!==E):[...l,E]),a([]),p(T)},R=(E,T,O)=>{const F=O==="available"?i.includes(T)?i:[T]:l.includes(T)?l:[T];E.dataTransfer.setData("text/plain",JSON.stringify({source:O,items:F})),E.dataTransfer.effectAllowed="move"},_=(E,T)=>{E.preventDefault();const O=E.dataTransfer.getData("text/plain");if(O)try{const F=JSON.parse(O),K=(F.items||[]).filter(X=>v.has(X));if(K.length===0||F.source===T)return;T==="selected"?(x(K),a([])):(w(K),c([]))}catch{return}};return o.jsxs("div",{className:"flex flex-col gap-6 md:flex-row md:items-start md:justify-between",children:[o.jsxs("div",{className:"flex w-full flex-col gap-3 md:w-2/5",children:[o.jsx("h2",{className:"text-sm font-medium text-gray-700",children:r}),o.jsx(h.Card,{className:"w-full border border-gray-200 shadow-none",children:o.jsx(h.CardBody,{className:"h-60 gap-2 overflow-y-auto",onDragOver:E=>E.preventDefault(),onDrop:E=>_(E,"available"),children:b.map((E,T)=>{const O=i.includes(E);return o.jsx("button",{type:"button",onClick:F=>{I(E,T,F.shiftKey)},onMouseDown:F=>{F.shiftKey&&F.preventDefault()},draggable:!0,onDragStart:F=>R(F,E,"available"),className:`rounded-md px-3 py-2 text-left text-sm transition ${O?"bg-[#E4571E]/10 text-[#E4571E]":"text-gray-700 hover:bg-gray-100"}`,children:E},E)})})})]}),o.jsxs("div",{className:"flex flex-row items-center justify-center gap-3 md:flex-col md:pt-6",children:[o.jsx(W,{variant:"light",className:"h-10 w-10 min-w-0 text-2xl font-semibold text-[#E4571E] hover:bg-[#E4571E]/10",isIconOnly:!0,"data-testid":"move-selected-to-available",onPress:N,isDisabled:i.length===0,"aria-label":"Move selected to right",children:"›"}),o.jsx(W,{variant:"light",className:"h-10 w-10 min-w-0 text-2xl font-semibold text-[#E4571E] hover:bg-[#E4571E]/10",isIconOnly:!0,"data-testid":"move-selected-to-available",onPress:A,isDisabled:l.length===0,"aria-label":"Move selected to left",children:"‹"}),o.jsx(W,{variant:"light",className:"h-10 w-10 min-w-0 text-2xl font-semibold text-[#E4571E] hover:bg-[#E4571E]/10",isIconOnly:!0,"data-testid":"move-all-to-selected",onPress:S,isDisabled:b.length===0,"aria-label":"Move all to right",children:"»"}),o.jsx(W,{variant:"light",className:"h-10 w-10 min-w-0 text-2xl font-semibold text-[#E4571E] hover:bg-[#E4571E]/10",isIconOnly:!0,onPress:j,"data-testid":"move-all-to-available",isDisabled:t.length===0,"aria-label":"Move all to left",children:"«"})]}),o.jsxs("div",{className:"flex w-full flex-col gap-3 md:w-2/5",children:[o.jsx("h2",{className:"text-sm font-medium text-gray-700",children:s}),o.jsx(h.Card,{className:"w-full border border-gray-200 shadow-none",children:o.jsx(h.CardBody,{className:"h-60 gap-2 overflow-y-auto",onDragOver:E=>E.preventDefault(),onDrop:E=>_(E,"selected"),children:t.map((E,T)=>{const O=l.includes(E);return o.jsx("button",{type:"button",onClick:F=>{B(E,T,F.shiftKey)},onMouseDown:F=>{F.shiftKey&&F.preventDefault()},draggable:!0,onDragStart:F=>R(F,E,"selected"),className:`rounded-md px-3 py-2 text-left text-sm transition ${O?"bg-[#E4571E]/10 text-[#E4571E]":"text-gray-700 hover:bg-gray-100"}`,children:E},E)})})})]})]})};function Bt(e){return typeof e=="string"?e:e.type}function it({className:e}){return o.jsx("div",{className:`flex items-center h-6 ${e||""}`,children:o.jsx(h.Divider,{orientation:"vertical"})})}function at({icon:e,label:t,isActive:n=!1,isDisabled:r=!1,onClick:s,shortcut:i,iconSize:a=16,className:l}){const c=i?`${t} (${i})`:t;return o.jsx(h.Tooltip,{content:c,placement:"top",offset:10,children:o.jsx(W,{size:"sm",radius:"sm",color:n?"primary":"default",variant:n?"solid":"bordered",isIconOnly:!0,isDisabled:r,onPress:s,"aria-label":t,className:l,children:o.jsx(e,{size:a})})})}const We={bold:{execute:({editor:e})=>e.chain().focus().toggleBold().run(),canExecute:e=>e.can().chain().focus().toggleBold().run(),isActive:e=>e.isActive("bold"),shortcut:"Mod-b",label:"Bold"},italic:{execute:({editor:e})=>e.chain().focus().toggleItalic().run(),canExecute:e=>e.can().chain().focus().toggleItalic().run(),isActive:e=>e.isActive("italic"),shortcut:"Mod-i",label:"Italic"},strike:{execute:({editor:e})=>e.chain().focus().toggleStrike().run(),canExecute:e=>e.can().chain().focus().toggleStrike().run(),isActive:e=>e.isActive("strike"),shortcut:"Mod-Shift-x",label:"Strikethrough"},underline:{execute:({editor:e})=>e.chain().focus().toggleUnderline().run(),canExecute:e=>e.can().chain().focus().toggleUnderline().run(),isActive:e=>e.isActive("underline"),shortcut:"Mod-u",label:"Underline"},code:{execute:({editor:e})=>e.chain().focus().toggleCode().run(),canExecute:e=>e.can().chain().focus().toggleCode().run(),isActive:e=>e.isActive("code"),shortcut:"Mod-e",label:"Inline code"},textColor:{execute:({editor:e,config:t})=>{const n=t?.type==="textColor"?t.color:"";n?e.chain().focus().setColor(n).run():e.chain().focus().unsetColor().run()},canExecute:()=>!0,isActive:e=>e.isActive("textStyle"),label:"Text color"},highlight:{execute:({editor:e,config:t})=>{const n=t?.type==="highlight"?t.color:"";n?e.chain().focus().setHighlight({color:n}).run():e.chain().focus().unsetHighlight().run()},canExecute:()=>!0,isActive:e=>e.isActive("highlight"),label:"Highlight"},link:{execute:({editor:e,config:t})=>{const n=t?.type==="link"?t.href:"";if(n){const r=t?.type==="link"?t.target:void 0,s=t?.type==="link"?t.rel:void 0;e.chain().focus().setLink({href:n,target:r,rel:s}).run()}else e.chain().focus().unsetLink().run()},canExecute:()=>!0,isActive:e=>e.isActive("link"),shortcut:"Mod-k",label:"Link"},paragraph:{execute:({editor:e})=>e.chain().focus().setParagraph().run(),canExecute:e=>e.can().chain().focus().setParagraph().run(),isActive:e=>e.isActive("paragraph"),shortcut:"Mod-Alt-0",label:"Paragraph"},heading:{execute:({editor:e,config:t})=>{const n=t?.type==="heading"?t.level:1;e.chain().focus().toggleHeading({level:n}).run()},canExecute:(e,t)=>{const n=t?.type==="heading"?t.level:1;return e.can().chain().focus().toggleHeading({level:n}).run()},isActive:(e,t)=>t?.type==="heading"?e.isActive("heading",{level:t.level}):e.isActive("heading"),label:"Heading"},bulletList:{execute:({editor:e})=>e.chain().focus().toggleBulletList().run(),canExecute:e=>e.can().chain().focus().toggleBulletList().run(),isActive:e=>e.isActive("bulletList"),shortcut:"Mod-Shift-8",label:"Bullet list"},orderedList:{execute:({editor:e})=>e.chain().focus().toggleOrderedList().run(),canExecute:e=>e.can().chain().focus().toggleOrderedList().run(),isActive:e=>e.isActive("orderedList"),shortcut:"Mod-Shift-7",label:"Numbered list"},taskList:{execute:({editor:e})=>e.chain().focus().toggleTaskList().run(),canExecute:e=>e.can().chain().focus().toggleTaskList().run(),isActive:e=>e.isActive("taskList"),label:"Task list"},codeBlock:{execute:({editor:e})=>e.chain().focus().toggleCodeBlock().run(),canExecute:e=>e.can().chain().focus().toggleCodeBlock().run(),isActive:e=>e.isActive("codeBlock"),shortcut:"Mod-Alt-c",label:"Code block"},blockquote:{execute:({editor:e})=>e.chain().focus().toggleBlockquote().run(),canExecute:e=>e.can().chain().focus().toggleBlockquote().run(),isActive:e=>e.isActive("blockquote"),shortcut:"Mod-Shift-b",label:"Blockquote"},horizontalRule:{execute:({editor:e})=>e.chain().focus().setHorizontalRule().run(),canExecute:e=>e.can().chain().focus().setHorizontalRule().run(),isActive:()=>!1,label:"Horizontal rule"},hardBreak:{execute:({editor:e})=>e.chain().focus().setHardBreak().run(),canExecute:e=>e.can().chain().focus().setHardBreak().run(),isActive:()=>!1,shortcut:"Mod-Enter",label:"Line break"},textAlign:{execute:({editor:e,config:t})=>{const n=t?.type==="textAlign"?t.alignment:"left";e.chain().focus().setTextAlign(n).run()},canExecute:()=>!0,isActive:(e,t)=>t?.type==="textAlign"?e.isActive({textAlign:t.alignment}):!1,label:"Text alignment"},clearMarks:{execute:({editor:e})=>e.chain().focus().unsetAllMarks().run(),canExecute:e=>e.can().chain().focus().unsetAllMarks().run(),isActive:()=>!1,label:"Clear formatting"},clearNodes:{execute:({editor:e})=>e.chain().focus().clearNodes().run(),canExecute:e=>e.can().chain().focus().clearNodes().run(),isActive:()=>!1,label:"Clear nodes"},undo:{execute:({editor:e})=>e.chain().focus().undo().run(),canExecute:e=>e.can().chain().focus().undo().run(),isActive:()=>!1,shortcut:"Mod-z",label:"Undo"},redo:{execute:({editor:e})=>e.chain().focus().redo().run(),canExecute:e=>e.can().chain().focus().redo().run(),isActive:()=>!1,shortcut:"Mod-Shift-z",label:"Redo"}},Fo={1:"Heading 1",2:"Heading 2",3:"Heading 3",4:"Heading 4",5:"Heading 5",6:"Heading 6"};function Po({editor:e,levels:t=[1,2,3,4,5,6],isDisabled:n=!1}){const[,r]=y.useState(0);y.useEffect(()=>{const a=()=>r(l=>l+1);return e.on("selectionUpdate",a),e.on("transaction",a),()=>{e.off("selectionUpdate",a),e.off("transaction",a)}},[e]);const s=t.find(a=>e.isActive("heading",{level:a})),i=a=>{const l=Number(a),c=We.heading;c&&c.execute({editor:e,config:{type:"heading",level:l}})};return o.jsxs(h.Dropdown,{placement:"top-start",offset:10,children:[o.jsx(h.DropdownTrigger,{children:o.jsx(W,{size:"sm",radius:"sm",variant:s?"solid":"bordered",color:s?"primary":"default",isDisabled:n,startContent:o.jsx(U.Heading,{size:16}),"aria-label":"Select heading level",children:s?`H${s}`:"H"})}),o.jsx(h.DropdownMenu,{"aria-label":"Heading levels",selectionMode:"single",selectedKeys:s?new Set([String(s)]):new Set,onAction:i,children:t.map(a=>o.jsx(h.DropdownItem,{startContent:e.isActive("heading",{level:a})?o.jsx(U.Check,{size:16}):o.jsx("div",{className:"w-4"}),children:Fo[a]},a))})]})}const qn={bulletList:{label:"Bullet List",icon:U.List},orderedList:{label:"Numbered List",icon:U.ListOrdered},taskList:{label:"Task List",icon:U.ListTodo}};function Ro({editor:e,types:t=["bulletList","orderedList","taskList"],isDisabled:n=!1}){const[,r]=y.useState(0);y.useEffect(()=>{const l=()=>r(c=>c+1);return e.on("selectionUpdate",l),e.on("transaction",l),()=>{e.off("selectionUpdate",l),e.off("transaction",l)}},[e]);const s=t.find(l=>e.isActive(l)),i=s?qn[s].icon:U.List,a=l=>{const d=We[l];d&&d.execute({editor:e})};return o.jsxs(h.Dropdown,{placement:"top-start",offset:10,children:[o.jsx(h.DropdownTrigger,{children:o.jsx(W,{size:"sm",radius:"sm",variant:s?"solid":"bordered",color:s?"primary":"default",isDisabled:n,isIconOnly:!0,"aria-label":"Select list type",children:o.jsx(i,{size:16})})}),o.jsx(h.DropdownMenu,{"aria-label":"List types",selectionMode:"single",selectedKeys:s?new Set([s]):new Set,onAction:a,children:t.map(l=>{const c=qn[l].icon;return o.jsx(h.DropdownItem,{startContent:o.jsx(c,{size:16}),children:qn[l].label},l)})})]})}function zo({colors:e,selectedColor:t,onColorSelect:n,columns:r=4}){return o.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:`repeat(${r}, minmax(0, 1fr))`},children:e.map(s=>{const i=t===s;return o.jsx("button",{type:"button",onClick:()=>n(s),className:`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),f=require("@heroui/react"),y=require("react"),J=require("lucide-react"),Pe=require("framer-motion"),Jr=require("@tiptap/react"),V=require("@tiptap/core"),Eo=require("@tiptap/extension-underline"),To=require("@tiptap/extension-color"),Do=require("@tiptap/extension-highlight"),Io=require("@tiptap/extension-link"),$o=require("@tiptap/extension-task-list"),Oo=require("@tiptap/extension-task-item"),Lo=require("@tiptap/extension-text-align");function Fo({children:e}){return l.jsx(f.HeroUIProvider,{children:e})}const K=y.forwardRef(({color:e="primary",radius:t="full",testId:n="veevart-button",...r},s)=>l.jsx(f.Button,{ref:s,color:e,radius:t,"data-testid":n,...r}));K.displayName="Button";function Po(e){const t=e?.closest('[role="dialog"]');return t?.parentElement??t??void 0}const yt=y.forwardRef(({popoverProps:e,...t},n)=>{const r=y.useRef(null),[s,i]=y.useState(void 0),a={...e,disableDialogFocus:e?.disableDialogFocus??(s?!0:void 0),portalContainer:e?.portalContainer??s};return y.useEffect(()=>{i(Po(r.current))},[]),l.jsx("span",{ref:r,className:"contents",children:l.jsx(f.Select,{ref:n,...t,popoverProps:a})})});yt.displayName="Select";const Ro={login:"Login",logout:"Logout",selectLanguage:"Select your language"};function zo({languages:e,selectedLanguage:t,onLanguageChange:n,label:r}){const s=e.find(i=>i.code===t);return l.jsx("div",{className:"flex items-center",children:l.jsxs("div",{className:"relative flex items-center",children:[l.jsx(yt,{"data-testid":"language-select-desktop",variant:"bordered","aria-label":r,selectedKeys:t?[t]:[],onSelectionChange:i=>{const a=Array.from(i)[0]||t;n?.(a)},className:"min-w-36 hidden md:inline-flex",isDisabled:e.length===0,placeholder:r,startContent:l.jsx(J.Globe,{className:"w-5 h-5 text-black"}),renderValue:()=>l.jsx("span",{children:s?.label||r}),size:"md",radius:"full",children:e.map(i=>l.jsx(f.SelectItem,{textValue:i.label,"data-testid":`language-select-option-${i.code}`,children:i.label},i.code))}),l.jsx(yt,{"aria-label":r,"data-testid":"language-select-mobile",variant:"bordered",selectedKeys:t?[t]:[],onSelectionChange:i=>{const a=Array.from(i)[0]||t;n?.(a)},className:"w-24 inline-flex md:hidden",isDisabled:e.length===0,placeholder:"",startContent:l.jsx(J.Globe,{className:"w-6 h-6 text-black"}),renderValue:()=>l.jsx("span",{children:s?.code.toUpperCase()||""}),size:"md",radius:"full",children:e.map(i=>l.jsx(f.SelectItem,{textValue:i.code.toUpperCase(),"data-testid":`language-select-option-mobile-${i.code}`,children:i.code.toUpperCase()},i.code))})]})})}function Bo({isLoggedIn:e,onLogin:t,onLogout:n,labels:r}){return e?l.jsxs(K,{"data-testid":"navbar-auth-button",className:"px-2 py-1 w-1 min-w-12 md:min-w-24 rounded-full bg-black text-white text-sm flex items-center",onPress:n,size:"md",children:[l.jsx(J.User,{className:"inline w-5 h-5"}),l.jsx("span",{className:"hidden md:inline",children:r.logout})]}):l.jsxs(K,{"data-testid":"navbar-auth-button",className:"px-2 py-1 min-w-12 md:min-w-24 rounded-full bg-black text-white text-sm flex items-center",onPress:t,size:"md",children:[l.jsx(J.User,{className:"inline w-5 h-5"}),l.jsx("span",{className:"hidden md:inline",children:r.login})]})}function _o({logo:e,languages:t=[],selectedLanguage:n,onLanguageChange:r,isLoggedIn:s,onLogin:i,onLogout:a,hasLanguages:o,hasAuth:c,labels:d={},className:u}){const h={...Ro,...d};return l.jsxs("nav",{"data-testid":"navbar",className:f.cn("w-full px-4 md:px-8 py-3 bg-white border-b border-zinc-100 flex items-center justify-between",u),children:[l.jsx("div",{className:"flex items-center min-w-10",children:e&&l.jsx("a",{href:"/",className:"block",children:l.jsx("img",{"data-testid":"navbar-logo",src:e,alt:"Logo",className:"h-8 w-auto max-w-28 md:max-w-40 object-contain"})})}),l.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[(o||t.length>0)&&l.jsx(zo,{languages:t,selectedLanguage:n,onLanguageChange:r,label:h.selectLanguage}),c&&l.jsx(Bo,{isLoggedIn:s,onLogin:i,onLogout:a,labels:h})]})]})}function Vo(e){return l.jsx("div",{className:"min-h-screen flex flex-col",children:l.jsx("div",{className:"flex-1 flex items-center justify-center p-12",children:l.jsx(f.Alert,{description:"This template combines Navbar, Footer, and a confirmation Card. Include title, message, confirmation number, details list, icon, and action buttons. Use Card for the confirmation content.",title:"TODO: Implement ConfirmationPageTemplate",variant:"faded",className:"max-w-2xl"})})})}var Zn;const Ho=typeof document<"u"?(Zn=y.useInsertionEffect)!==null&&Zn!==void 0?Zn:y.useLayoutEffect:()=>{};function Yr(e,t,n){let[r,s]=y.useState(e||t),i=y.useRef(r),a=y.useRef(e!==void 0),o=e!==void 0;y.useEffect(()=>{let h=a.current;h!==o&&process.env.NODE_ENV!=="production"&&console.warn(`WARN: A component changed from ${h?"controlled":"uncontrolled"} to ${o?"controlled":"uncontrolled"}.`),a.current=o},[o]);let c=o?e:r;Ho(()=>{i.current=c});let[,d]=y.useReducer(()=>({}),{}),u=y.useCallback((h,...p)=>{let m=typeof h=="function"?h(i.current):h;Object.is(i.current,m)||(i.current=m,s(m),d(),n?.(m,...p))},[n]);return[c,u]}function Uo(e){return l.jsx("svg",{...e,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:l.jsx(Pe.m.path,{animate:{pathLength:1},d:"M5 13l4 4L19 7",initial:{pathLength:0},strokeLinecap:"round",strokeLinejoin:"round",transition:{delay:.2,type:"tween",ease:"easeOut",duration:.3}})})}const Yi=y.forwardRef(({color:e="primary",stepsCount:t=3,defaultStep:n=0,label:r,onStepChange:s,currentStep:i,hideProgressBars:a=!1,stepClassName:o,className:c,isDisabled:d=!1,...u},h)=>{const[p,m]=Yr(i,n,s),v=y.useMemo(()=>{let b,x;const w=["[--active-fg-color:hsl(var(--step-fg-color))]","[--active-border-color:hsl(var(--step-color))]","[--active-color:hsl(var(--step-color))]","[--complete-background-color:hsl(var(--step-color))]","[--complete-border-color:hsl(var(--step-color))]","[--inactive-border-color:hsl(var(--heroui-default-300))]","[--inactive-color:hsl(var(--heroui-default-300))]"];switch(e){case"primary":b="[--step-color:var(--heroui-primary)]",x="[--step-fg-color:var(--heroui-primary-foreground)]";break;case"secondary":b="[--step-color:var(--heroui-secondary)]",x="[--step-fg-color:var(--heroui-secondary-foreground)]";break;case"success":b="[--step-color:var(--heroui-success)]",x="[--step-fg-color:var(--heroui-success-foreground)]";break;case"warning":b="[--step-color:var(--heroui-warning)]",x="[--step-fg-color:var(--heroui-warning-foreground)]";break;case"danger":b="[--step-color:var(--heroui-danger)]",x="[--step-fg-color:var(--heroui-danger-foreground)]";break;case"default":b="[--step-color:var(--heroui-default)]",x="[--step-fg-color:var(--heroui-default-foreground)]";break;default:b="[--step-color:var(--heroui-primary)]",x="[--step-fg-color:var(--heroui-primary-foreground)]";break}return w.unshift(x),w.unshift(b),w},[e]);return l.jsxs("nav",{ref:h,"aria-label":"Progress",className:f.cn("flex max-w-fit items-center overflow-x-auto",c),"data-testid":"stepper-root",...u,children:[r&&l.jsx("label",{className:"text-small text-default-foreground lg:text-medium font-light whitespace-nowrap me-3","data-testid":"stepper-label",children:r}),l.jsx("ol",{className:f.cn("flex flex-row flex-nowrap gap-x-3",v,c),"data-testid":"stepper-list",children:Array.from({length:t})?.map((b,x)=>{const w=p===x?"active":p<x?"inactive":"complete";return l.jsx("li",{className:"relative flex shrink-0 items-center pr-12","data-testid":`stepper-step-${x}`,children:l.jsxs("button",{"aria-current":w==="active"?"step":void 0,className:f.cn("group rounded-large flex w-full cursor-pointer flex-row items-center justify-center gap-x-3 py-2.5",{"cursor-not-allowed opacity-50":d},o),onClick:()=>!d&&m(x),disabled:d,"data-testid":`stepper-step-btn-${x}`,children:[l.jsx("div",{className:"h-full relative flex items-center",children:l.jsx(Pe.LazyMotion,{features:Pe.domAnimation,children:l.jsx(Pe.m.div,{animate:w,className:"relative",children:l.jsx(Pe.m.div,{animate:w,className:f.cn("border-medium text-large text-default-foreground relative flex h-[26px] w-[26px] items-center justify-center rounded-full font-semibold",{"shadow-lg":w==="complete"}),initial:!1,transition:{duration:.25},variants:{inactive:{backgroundColor:"transparent",borderColor:"var(--inactive-border-color)",color:"var(--inactive-color)"},active:{backgroundColor:"transparent",borderColor:"var(--active-border-color)",color:"var(--active-color)"},complete:{backgroundColor:"var(--complete-background-color)",borderColor:"var(--complete-border-color)",color:"var(--active-fg-color)"}},children:l.jsx("div",{className:"flex items-center justify-center",children:w==="complete"?l.jsx(Uo,{className:"h-5 w-5 text-(--active-fg-color)","data-testid":`stepper-step-check-${x}`}):l.jsx("span",{})})})})})}),x<t-1&&!a&&l.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 left-[26px] w-[calc(100%-13px)] flex-none items-center",style:{"--idx":x},children:l.jsx("div",{className:f.cn("bg-default-200 relative h-0.5 w-full transition-colors duration-300","after:absolute after:block after:h-full after:w-0 after:bg-(--active-border-color) after:transition-[width] after:duration-300 after:content-['']",{"after:w-full":x<p})})})]},x)},x)})})]})});Yi.displayName="Stepper";function qo(e){return l.jsx("div",{className:"min-h-screen flex flex-col",children:l.jsx("div",{className:"flex-1 flex items-center justify-center p-12",children:l.jsx(f.Alert,{description:"This template combines Navbar, Stepper, Footer, and an event details Card. Include event image, category/spots chips, tags, details grid, and action buttons. Use Card, CardHeader, CardBody for content structure.",title:"TODO: Implement EventDetailsTemplate",variant:"faded",className:"max-w-2xl"})})})}function rt(e,t="en-US",n="USD"){try{return new Intl.NumberFormat(t,{style:"currency",currency:n}).format(e)}catch{return`${n} ${e.toFixed(2)}`}}function Gr(e,t="en-US"){try{const n=new Intl.NumberFormat(t,{style:"currency",currency:e}).resolvedOptions();return typeof n.maximumFractionDigits=="number"?n.maximumFractionDigits:2}catch{return 2}}function Gi(e,t,n="en-US"){const r=Gr(t,n),s=Math.pow(10,r);return Math.round(e*s)/s}function Cr(e,t,n,r){return Gi(e-t,n,r)}function Wo(){return l.jsxs("footer",{"data-testid":"footer",className:"fixed left-0 bottom-0 w-full text-left p-4 bg-white font-inter font-light text-base text-zinc-500",children:["Powered by Veevart ® ",new Date().getFullYear()]})}const Ko=e=>{const t=y.useMemo(()=>JSON.stringify({allItems:e.allItems,selected:e.selected}),[e.allItems,e.selected]);return l.jsx(Jo,{...e},t)},Jo=({allItems:e,selected:t,onSelectedChange:n,titleLeft:r,titleRight:s})=>{const[i,a]=y.useState([]),[o,c]=y.useState([]),[d,u]=y.useState(null),[h,p]=y.useState(null),m=y.useMemo(()=>new Set(t),[t]),v=y.useMemo(()=>new Set(e),[e]),b=y.useMemo(()=>e.filter(E=>!m.has(E)),[e,m]),x=E=>{if(E.length===0)return;const C=Array.from(new Set([...t,...E]));n(C)},w=E=>{if(E.length===0)return;const C=new Set(E);n(t.filter(I=>!C.has(I)))},S=()=>{i.length!==0&&(x(i),a([]))},M=()=>{o.length!==0&&(w(o),c([]))},N=()=>{b.length!==0&&(x(b),a([]))},j=()=>{t.length!==0&&(n([]),c([]))},T=(E,C,I)=>{const F=Math.min(C,I),H=Math.max(C,I);return E.slice(F,H+1)},$=(E,C,I)=>{if(I&&d!==null){a(T(b,d,C)),c([]),u(C);return}const F=i.includes(E);a(F?i.filter(H=>H!==E):[...i,E]),c([]),u(C)},W=(E,C,I)=>{if(I&&h!==null){c(T(t,h,C)),a([]),p(C);return}const F=o.includes(E);c(F?o.filter(H=>H!==E):[...o,E]),a([]),p(C)},D=(E,C,I)=>{const F=I==="available"?i.includes(C)?i:[C]:o.includes(C)?o:[C];E.dataTransfer.setData("text/plain",JSON.stringify({source:I,items:F})),E.dataTransfer.effectAllowed="move"},R=(E,C)=>{E.preventDefault();const I=E.dataTransfer.getData("text/plain");if(I)try{const F=JSON.parse(I),H=(F.items||[]).filter(Q=>v.has(Q));if(H.length===0||F.source===C)return;C==="selected"?(x(H),a([])):(w(H),c([]))}catch{return}};return l.jsxs("div",{className:"flex flex-col gap-6 md:flex-row md:items-start md:justify-between",children:[l.jsxs("div",{className:"flex w-full flex-col gap-3 md:w-2/5",children:[l.jsx("h2",{className:"text-sm font-medium text-gray-700",children:r}),l.jsx(f.Card,{className:"w-full border border-gray-200 shadow-none",children:l.jsx(f.CardBody,{className:"h-60 gap-2 overflow-y-auto",onDragOver:E=>E.preventDefault(),onDrop:E=>R(E,"available"),children:b.map((E,C)=>{const I=i.includes(E);return l.jsx("button",{type:"button",onClick:F=>{$(E,C,F.shiftKey)},onMouseDown:F=>{F.shiftKey&&F.preventDefault()},draggable:!0,onDragStart:F=>D(F,E,"available"),className:`rounded-md px-3 py-2 text-left text-sm transition ${I?"bg-[#E4571E]/10 text-[#E4571E]":"text-gray-700 hover:bg-gray-100"}`,children:E},E)})})})]}),l.jsxs("div",{className:"flex flex-row items-center justify-center gap-3 md:flex-col md:pt-6",children:[l.jsx(K,{variant:"light",className:"h-10 w-10 min-w-0 text-2xl font-semibold text-[#E4571E] hover:bg-[#E4571E]/10",isIconOnly:!0,"data-testid":"move-selected-to-available",onPress:S,isDisabled:i.length===0,"aria-label":"Move selected to right",children:"›"}),l.jsx(K,{variant:"light",className:"h-10 w-10 min-w-0 text-2xl font-semibold text-[#E4571E] hover:bg-[#E4571E]/10",isIconOnly:!0,"data-testid":"move-selected-to-available",onPress:M,isDisabled:o.length===0,"aria-label":"Move selected to left",children:"‹"}),l.jsx(K,{variant:"light",className:"h-10 w-10 min-w-0 text-2xl font-semibold text-[#E4571E] hover:bg-[#E4571E]/10",isIconOnly:!0,"data-testid":"move-all-to-selected",onPress:N,isDisabled:b.length===0,"aria-label":"Move all to right",children:"»"}),l.jsx(K,{variant:"light",className:"h-10 w-10 min-w-0 text-2xl font-semibold text-[#E4571E] hover:bg-[#E4571E]/10",isIconOnly:!0,onPress:j,"data-testid":"move-all-to-available",isDisabled:t.length===0,"aria-label":"Move all to left",children:"«"})]}),l.jsxs("div",{className:"flex w-full flex-col gap-3 md:w-2/5",children:[l.jsx("h2",{className:"text-sm font-medium text-gray-700",children:s}),l.jsx(f.Card,{className:"w-full border border-gray-200 shadow-none",children:l.jsx(f.CardBody,{className:"h-60 gap-2 overflow-y-auto",onDragOver:E=>E.preventDefault(),onDrop:E=>R(E,"selected"),children:t.map((E,C)=>{const I=o.includes(E);return l.jsx("button",{type:"button",onClick:F=>{W(E,C,F.shiftKey)},onMouseDown:F=>{F.shiftKey&&F.preventDefault()},draggable:!0,onDragStart:F=>D(F,E,"selected"),className:`rounded-md px-3 py-2 text-left text-sm transition ${I?"bg-[#E4571E]/10 text-[#E4571E]":"text-gray-700 hover:bg-gray-100"}`,children:E},E)})})})]})]})};function Yt(e){return typeof e=="string"?e:e.type}function ot({className:e}){return l.jsx("div",{className:`flex items-center h-6 ${e||""}`,children:l.jsx(f.Divider,{orientation:"vertical"})})}function ct({icon:e,label:t,isActive:n=!1,isDisabled:r=!1,onClick:s,shortcut:i,iconSize:a=16,className:o}){const c=i?`${t} (${i})`:t;return l.jsx(f.Tooltip,{content:c,placement:"top",offset:10,children:l.jsx(K,{size:"sm",radius:"sm",color:n?"primary":"default",variant:n?"solid":"bordered",isIconOnly:!0,isDisabled:r,onPress:s,"aria-label":t,className:o,children:l.jsx(e,{size:a})})})}const Je={bold:{execute:({editor:e})=>e.chain().focus().toggleBold().run(),canExecute:e=>e.can().chain().focus().toggleBold().run(),isActive:e=>e.isActive("bold"),shortcut:"Mod-b",label:"Bold"},italic:{execute:({editor:e})=>e.chain().focus().toggleItalic().run(),canExecute:e=>e.can().chain().focus().toggleItalic().run(),isActive:e=>e.isActive("italic"),shortcut:"Mod-i",label:"Italic"},strike:{execute:({editor:e})=>e.chain().focus().toggleStrike().run(),canExecute:e=>e.can().chain().focus().toggleStrike().run(),isActive:e=>e.isActive("strike"),shortcut:"Mod-Shift-x",label:"Strikethrough"},underline:{execute:({editor:e})=>e.chain().focus().toggleUnderline().run(),canExecute:e=>e.can().chain().focus().toggleUnderline().run(),isActive:e=>e.isActive("underline"),shortcut:"Mod-u",label:"Underline"},code:{execute:({editor:e})=>e.chain().focus().toggleCode().run(),canExecute:e=>e.can().chain().focus().toggleCode().run(),isActive:e=>e.isActive("code"),shortcut:"Mod-e",label:"Inline code"},textColor:{execute:({editor:e,config:t})=>{const n=t?.type==="textColor"?t.color:"";n?e.chain().focus().setColor(n).run():e.chain().focus().unsetColor().run()},canExecute:()=>!0,isActive:e=>e.isActive("textStyle"),label:"Text color"},highlight:{execute:({editor:e,config:t})=>{const n=t?.type==="highlight"?t.color:"";n?e.chain().focus().setHighlight({color:n}).run():e.chain().focus().unsetHighlight().run()},canExecute:()=>!0,isActive:e=>e.isActive("highlight"),label:"Highlight"},link:{execute:({editor:e,config:t})=>{const n=t?.type==="link"?t.href:"";if(n){const r=t?.type==="link"?t.target:void 0,s=t?.type==="link"?t.rel:void 0;e.chain().focus().setLink({href:n,target:r,rel:s}).run()}else e.chain().focus().unsetLink().run()},canExecute:()=>!0,isActive:e=>e.isActive("link"),shortcut:"Mod-k",label:"Link"},paragraph:{execute:({editor:e})=>e.chain().focus().setParagraph().run(),canExecute:e=>e.can().chain().focus().setParagraph().run(),isActive:e=>e.isActive("paragraph"),shortcut:"Mod-Alt-0",label:"Paragraph"},heading:{execute:({editor:e,config:t})=>{const n=t?.type==="heading"?t.level:1;e.chain().focus().toggleHeading({level:n}).run()},canExecute:(e,t)=>{const n=t?.type==="heading"?t.level:1;return e.can().chain().focus().toggleHeading({level:n}).run()},isActive:(e,t)=>t?.type==="heading"?e.isActive("heading",{level:t.level}):e.isActive("heading"),label:"Heading"},bulletList:{execute:({editor:e})=>e.chain().focus().toggleBulletList().run(),canExecute:e=>e.can().chain().focus().toggleBulletList().run(),isActive:e=>e.isActive("bulletList"),shortcut:"Mod-Shift-8",label:"Bullet list"},orderedList:{execute:({editor:e})=>e.chain().focus().toggleOrderedList().run(),canExecute:e=>e.can().chain().focus().toggleOrderedList().run(),isActive:e=>e.isActive("orderedList"),shortcut:"Mod-Shift-7",label:"Numbered list"},taskList:{execute:({editor:e})=>e.chain().focus().toggleTaskList().run(),canExecute:e=>e.can().chain().focus().toggleTaskList().run(),isActive:e=>e.isActive("taskList"),label:"Task list"},codeBlock:{execute:({editor:e})=>e.chain().focus().toggleCodeBlock().run(),canExecute:e=>e.can().chain().focus().toggleCodeBlock().run(),isActive:e=>e.isActive("codeBlock"),shortcut:"Mod-Alt-c",label:"Code block"},blockquote:{execute:({editor:e})=>e.chain().focus().toggleBlockquote().run(),canExecute:e=>e.can().chain().focus().toggleBlockquote().run(),isActive:e=>e.isActive("blockquote"),shortcut:"Mod-Shift-b",label:"Blockquote"},horizontalRule:{execute:({editor:e})=>e.chain().focus().setHorizontalRule().run(),canExecute:e=>e.can().chain().focus().setHorizontalRule().run(),isActive:()=>!1,label:"Horizontal rule"},hardBreak:{execute:({editor:e})=>e.chain().focus().setHardBreak().run(),canExecute:e=>e.can().chain().focus().setHardBreak().run(),isActive:()=>!1,shortcut:"Mod-Enter",label:"Line break"},textAlign:{execute:({editor:e,config:t})=>{const n=t?.type==="textAlign"?t.alignment:"left";e.chain().focus().setTextAlign(n).run()},canExecute:()=>!0,isActive:(e,t)=>t?.type==="textAlign"?e.isActive({textAlign:t.alignment}):!1,label:"Text alignment"},clearMarks:{execute:({editor:e})=>e.chain().focus().unsetAllMarks().run(),canExecute:e=>e.can().chain().focus().unsetAllMarks().run(),isActive:()=>!1,label:"Clear formatting"},clearNodes:{execute:({editor:e})=>e.chain().focus().clearNodes().run(),canExecute:e=>e.can().chain().focus().clearNodes().run(),isActive:()=>!1,label:"Clear nodes"},undo:{execute:({editor:e})=>e.chain().focus().undo().run(),canExecute:e=>e.can().chain().focus().undo().run(),isActive:()=>!1,shortcut:"Mod-z",label:"Undo"},redo:{execute:({editor:e})=>e.chain().focus().redo().run(),canExecute:e=>e.can().chain().focus().redo().run(),isActive:()=>!1,shortcut:"Mod-Shift-z",label:"Redo"}},Yo={1:"Heading 1",2:"Heading 2",3:"Heading 3",4:"Heading 4",5:"Heading 5",6:"Heading 6"};function Go({editor:e,levels:t=[1,2,3,4,5,6],isDisabled:n=!1}){const[,r]=y.useState(0);y.useEffect(()=>{const a=()=>r(o=>o+1);return e.on("selectionUpdate",a),e.on("transaction",a),()=>{e.off("selectionUpdate",a),e.off("transaction",a)}},[e]);const s=t.find(a=>e.isActive("heading",{level:a})),i=a=>{const o=Number(a),c=Je.heading;c&&c.execute({editor:e,config:{type:"heading",level:o}})};return l.jsxs(f.Dropdown,{placement:"top-start",offset:10,children:[l.jsx(f.DropdownTrigger,{children:l.jsx(K,{size:"sm",radius:"sm",variant:s?"solid":"bordered",color:s?"primary":"default",isDisabled:n,startContent:l.jsx(J.Heading,{size:16}),"aria-label":"Select heading level",children:s?`H${s}`:"H"})}),l.jsx(f.DropdownMenu,{"aria-label":"Heading levels",selectionMode:"single",selectedKeys:s?new Set([String(s)]):new Set,onAction:i,children:t.map(a=>l.jsx(f.DropdownItem,{startContent:e.isActive("heading",{level:a})?l.jsx(J.Check,{size:16}):l.jsx("div",{className:"w-4"}),children:Yo[a]},a))})]})}const Xn={bulletList:{label:"Bullet List",icon:J.List},orderedList:{label:"Numbered List",icon:J.ListOrdered},taskList:{label:"Task List",icon:J.ListTodo}};function Qo({editor:e,types:t=["bulletList","orderedList","taskList"],isDisabled:n=!1}){const[,r]=y.useState(0);y.useEffect(()=>{const o=()=>r(c=>c+1);return e.on("selectionUpdate",o),e.on("transaction",o),()=>{e.off("selectionUpdate",o),e.off("transaction",o)}},[e]);const s=t.find(o=>e.isActive(o)),i=s?Xn[s].icon:J.List,a=o=>{const d=Je[o];d&&d.execute({editor:e})};return l.jsxs(f.Dropdown,{placement:"top-start",offset:10,children:[l.jsx(f.DropdownTrigger,{children:l.jsx(K,{size:"sm",radius:"sm",variant:s?"solid":"bordered",color:s?"primary":"default",isDisabled:n,isIconOnly:!0,"aria-label":"Select list type",children:l.jsx(i,{size:16})})}),l.jsx(f.DropdownMenu,{"aria-label":"List types",selectionMode:"single",selectedKeys:s?new Set([s]):new Set,onAction:a,children:t.map(o=>{const c=Xn[o].icon;return l.jsx(f.DropdownItem,{startContent:l.jsx(c,{size:16}),children:Xn[o].label},o)})})]})}function Zo({colors:e,selectedColor:t,onColorSelect:n,columns:r=4}){return l.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:`repeat(${r}, minmax(0, 1fr))`},children:e.map(s=>{const i=t===s;return l.jsx("button",{type:"button",onClick:()=>n(s),className:`
|
|
2
2
|
w-8 h-8 rounded-full border-2 cursor-pointer
|
|
3
3
|
transition-all duration-200
|
|
4
4
|
hover:scale-110 hover:shadow-md
|
|
5
5
|
focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2
|
|
6
6
|
${i?"border-primary ring-2 ring-primary ring-offset-2 scale-110":"border-divider"}
|
|
7
|
-
`,style:{backgroundColor:s},"aria-label":`Select color ${s}`,title:s},s)})})}const
|
|
7
|
+
`,style:{backgroundColor:s},"aria-label":`Select color ${s}`,title:s},s)})})}const Xo=["#000000","#374151","#6B7280","#EF4444","#F59E0B","#10B981","#3B82F6","#8B5CF6","#EC4899","#14B8A6","#F97316","#A855F7"],ec=["#FEF3C7","#DBEAFE","#D1FAE5","#FCE7F3","#E0E7FF","#FED7AA","#F3E8FF","#CCFBF1","#FEE2E2","#E5E7EB","#FAE8FF","#BFDBFE"];function er(e){return/^#([0-9A-F]{3}){1,2}$/i.test(e)}const ke={min:50,max:200,step:10,default:100},Ts={lineHeight:24,toolbarHeight:60},tc={bold:J.Bold,italic:J.Italic,strike:J.Strikethrough,underline:J.Underline,code:J.Code,textColor:J.Palette,highlight:J.Highlighter,link:J.Link2,paragraph:J.FileText,heading:J.Heading,bulletList:J.List,orderedList:J.ListOrdered,taskList:J.ListTodo,codeBlock:J.CodeSquare,blockquote:J.Quote,horizontalRule:J.Minus,clearMarks:J.Eraser,clearNodes:J.Eraser,undo:J.Undo2,redo:J.Redo2,hardBreak:J.CornerDownLeft,textAlign:J.AlignLeft},nc={left:J.AlignLeft,center:J.AlignCenter,right:J.AlignRight,justify:J.AlignJustify};function St(e){return tc[e]}function rc({value:e,onChange:t,onApply:n,placeholder:r="#000000"}){const[s,i]=y.useState(""),a=d=>{const u=d.target.value;t(u),s&&i("")},o=()=>{if(!e){i("Please enter a color");return}if(!er(e)){i("Invalid hex color (e.g., #FF0000)");return}i(""),n(e)},c=d=>{d.key==="Enter"&&(d.preventDefault(),o())};return l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsx(f.Input,{type:"text",value:e,onChange:a,onKeyDown:c,placeholder:r,size:"sm",variant:"bordered","aria-label":"Custom color hex code",isInvalid:!!s,errorMessage:s,startContent:l.jsx("div",{className:"w-4 h-4 rounded border border-divider",style:{backgroundColor:er(e)?e:"transparent"}})}),l.jsx(K,{size:"sm",color:"primary",variant:"flat",isIconOnly:!0,onPress:o,"aria-label":"Apply custom color",isDisabled:!e||!er(e),children:l.jsx(J.Check,{size:16})})]}),l.jsx("p",{className:"text-xs text-default-500",children:"Enter a hex color code (e.g., #FF0000)"})]})}function Ds({editor:e,type:t,allowCustomColor:n=!0,label:r,isDisabled:s=!1}){const[i,a]=y.useState(!1),[o,c]=y.useState(""),d=t==="textColor"?Xo:ec,u=b=>{const x=Je[t];x&&x.execute({editor:e,config:{type:t,color:b}}),a(!1),c("")},h=b=>{u(b)},p=()=>{const b=Je[t];b&&b.execute({editor:e,config:{type:t,color:""}}),a(!1)},m=t==="textColor"?e.isActive("textStyle"):e.isActive("highlight"),v=t==="textColor"?J.Palette:J.Highlighter;return l.jsxs(f.Popover,{isOpen:i,onOpenChange:a,placement:"top",offset:10,showArrow:!0,children:[l.jsx(f.PopoverTrigger,{children:l.jsx(K,{size:"sm",radius:"sm",variant:m?"solid":"bordered",color:m?"primary":"default",isIconOnly:!0,isDisabled:s,"aria-label":r,children:l.jsx(v,{size:16})})}),l.jsx(f.PopoverContent,{className:"w-64",children:l.jsxs("div",{className:"px-2 py-3 space-y-3",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm font-semibold",children:r}),l.jsx(K,{size:"sm",variant:"light",isIconOnly:!0,onPress:p,"aria-label":"Clear color",children:l.jsx(J.X,{size:16})})]}),l.jsx(Zo,{colors:d,onColorSelect:u}),n&&l.jsxs(l.Fragment,{children:[l.jsx(f.Divider,{}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs font-semibold mb-2 text-default-700",children:"Custom Color"}),l.jsx(rc,{value:o,onChange:c,onApply:h})]})]})]})})]})}function sc({zoom:e,onZoomChange:t,min:n=ke.min,max:r=ke.max,step:s=ke.step}){const i=()=>{const h=Math.max(n,e-s);t(h)},a=()=>{const h=Math.min(r,e+s);t(h)},o=()=>{t(ke.default)},c=e<=n,d=e>=r,u=e===ke.default;return l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(f.Tooltip,{content:"Zoom out",placement:"top",offset:10,children:l.jsx(K,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:c,onPress:i,"aria-label":"Zoom out",children:l.jsx(J.ZoomOut,{size:16})})}),l.jsx(f.Tooltip,{content:u?"Zoom percentage":"Click to reset zoom",placement:"top",offset:10,children:l.jsxs("button",{type:"button",onClick:o,disabled:u,className:`
|
|
8
8
|
text-xs text-default-500 min-w-[3ch] text-center px-2
|
|
9
9
|
${u?"cursor-default":"cursor-pointer hover:text-primary"}
|
|
10
|
-
`,"aria-label":`Zoom level ${e}%`,children:[e,"%"]})}),o.jsx(h.Tooltip,{content:"Zoom in",placement:"top",offset:10,children:o.jsx(W,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:d,onPress:a,"aria-label":"Zoom in",children:o.jsx(U.ZoomIn,{size:16})})})]})}function Wo({editor:e,isDisabled:t=!1}){const[n,r]=y.useState(!1),[s,i]=y.useState(""),[a,l]=y.useState(""),[c,d]=y.useState(!1),u=e.isActive("link"),f=m=>{if(m){const{from:v,to:b}=e.state.selection,x=e.isActive("link");let w="";if(x){const A=e.schema.marks.link,S=e.state.doc.resolve(v),j=z.getMarkRange(S,A);j&&(w=e.state.doc.textBetween(j.from,j.to,""))}else w=e.state.doc.textBetween(v,b,"");const N=e.getAttributes("link").href||"";i(w),l(N),d(x)}r(m)},p=()=>{if(a.trim()){const{from:m,to:v}=e.state.selection,b=e.schema.marks.link,x=e.state.doc.resolve(m),w=z.getMarkRange(x,b),N=w?.from??m,A=w?.to??v,S=e.state.doc.textBetween(N,A,"");s.trim()&&s!==S?e.chain().focus().setTextSelection({from:N,to:A}).deleteSelection().insertContent(`<a href="${a.trim()}">${s.trim()}</a>`).run():e.chain().focus().extendMarkRange("link").updateAttributes("link",{href:a.trim()}).run()}r(!1)};return o.jsxs(h.Popover,{isOpen:n,onOpenChange:f,placement:"bottom",children:[o.jsx(h.PopoverTrigger,{children:o.jsx(W,{size:"sm",radius:"sm",variant:u?"solid":"bordered",color:u?"primary":"default",isIconOnly:!0,isDisabled:t,"aria-label":"Link",children:o.jsx(U.Link,{size:16})})}),o.jsx(h.PopoverContent,{children:o.jsxs("div",{className:"flex flex-col gap-3 p-3 w-72",children:[o.jsx(h.Input,{size:"sm",variant:"bordered",label:"Name",labelPlacement:"outside",placeholder:"Link text",value:s,onChange:m=>i(m.target.value),classNames:{inputWrapper:"focus-within:border-default-400"}}),o.jsx(h.Input,{size:"sm",variant:"bordered",label:"Link",labelPlacement:"outside",placeholder:"https://example.com",value:a,onChange:m=>l(m.target.value),onKeyDown:m=>m.key==="Enter"&&p(),classNames:{inputWrapper:"focus-within:border-default-400"}}),o.jsx(W,{size:"sm",color:"primary",onPress:p,isDisabled:!a.trim(),children:c?"Update":"Apply"})]})})]})}function Ko({children:e,id:t,label:n,className:r,useButtonGroup:s=!0}){return s?o.jsx(h.ButtonGroup,{size:"sm",id:t,"aria-label":n,className:r,children:e}):o.jsx("div",{id:t,role:"group","aria-label":n,className:`flex items-center gap-2 ${r||""}`,children:e})}function Hi(e,t){const n=y.useMemo(()=>{if(!e)return{};const i={};return Array.from(new Set(t.map(l=>Bt(l)))).forEach(l=>{const c=We[l];if(c)try{const d=c.canExecute?.(e)??!0,u=c.isActive?.(e)??!1;i[l]={isActive:u,isDisabled:!d,canExecute:d}}catch(d){console.warn(`Extension not available for modifier: ${l}`,d),i[l]={isActive:!1,isDisabled:!0,canExecute:!1}}}),i},[e,t]),[r,s]=y.useState(n);return y.useEffect(()=>{if(!e)return;const i=()=>{const a={};Array.from(new Set(t.map(c=>Bt(c)))).forEach(c=>{const d=We[c];if(d)try{const u=d.canExecute?.(e)??!0,f=d.isActive?.(e)??!1;a[c]={isActive:f,isDisabled:!u,canExecute:u}}catch(u){console.warn(`Extension not available for modifier: ${c}`,u),a[c]={isActive:!1,isDisabled:!0,canExecute:!1}}}),s(a)};return e.on("selectionUpdate",i),e.on("transaction",i),()=>{e.off("selectionUpdate",i),e.off("transaction",i)}},[e,t,n]),r}function Ui(e,t){const n=y.useCallback((a,l)=>{if(!e)return;const c=We[a];if(c)try{c.execute({editor:e,config:l}),t?.({type:"toggle",modifier:a})}catch(d){console.warn(`Failed to execute command for modifier: ${a}`,d)}},[e,t]),r=y.useCallback(a=>{n(a)},[n]),s=y.useCallback((a,l)=>{if(!e)return!1;const c=We[a];try{return c?.canExecute?.(e,l)??!1}catch(d){return console.warn(`Failed to check canExecute for modifier: ${a}`,d),!1}},[e]),i=y.useCallback((a,l)=>{if(!e)return!1;const c=We[a];try{return c?.isActive?.(e,l)??!1}catch(d){return console.warn(`Failed to check isActive for modifier: ${a}`,d),!1}},[e]);return{executeCommand:n,toggleModifier:r,canExecute:s,isActive:i}}function Jo(e=we.default){const[t,n]=y.useState(e),r=y.useCallback((l=we.step)=>{n(c=>Math.min(we.max,c+l))},[]),s=y.useCallback((l=we.step)=>{n(c=>Math.max(we.min,c-l))},[]),i=y.useCallback(()=>{n(we.default)},[]),a=y.useCallback(l=>{const c=Math.max(we.min,Math.min(we.max,l));n(c)},[]);return{zoom:t,setZoom:a,zoomIn:r,zoomOut:s,resetZoom:i,isMinZoom:t<=we.min,isMaxZoom:t>=we.max,isDefaultZoom:t===we.default}}const Yo=["bold","italic","strike","underline","code"];function Go({editor:e,modifiers:t,onToolbarAction:n}){const r=Hi(e,t),{toggleModifier:s}=Ui(e,n);if(!e)return null;const i=t.map(a=>Bt(a)).filter(a=>Yo.includes(a));return i.length===0?null:o.jsx(Ko,{id:"text-formatting",label:"Text formatting",children:i.map(a=>{const l=r[a],c=vt(a);return o.jsx(at,{icon:c,label:a.charAt(0).toUpperCase()+a.slice(1),isActive:l?.isActive,isDisabled:l?.isDisabled,onClick:()=>s(a)},a)})})}function Qo({editor:e,modifiers:t,zoom:n=100,onZoomChange:r,sticky:s=!0,className:i,onToolbarAction:a}){const l=Hi(e,t),{toggleModifier:c,executeCommand:d}=Ui(e,a);if(!e)return null;const u=t.map(I=>Bt(I)),f=u.some(I=>["bold","italic","strike","underline","code"].includes(I)),p=u.some(I=>["textColor","highlight"].includes(I)),m=u.includes("heading"),v=u.includes("textAlign"),b=u.some(I=>["bulletList","orderedList","taskList"].includes(I)),x=u.includes("blockquote"),w=u.includes("codeBlock"),N=u.includes("link"),A=u.includes("horizontalRule"),S=u.some(I=>["undo","redo"].includes(I)),j=n!==void 0&&r!==void 0,M=s?"sticky top-0 z-10":"";return o.jsx("div",{className:`w-full p-2 bg-background border-b border-divider ${M} ${i||""}`,children:o.jsxs("div",{className:"flex flex-row flex-wrap gap-2 w-full items-center",children:[f&&o.jsxs(o.Fragment,{children:[o.jsx(Go,{editor:e,modifiers:t,onToolbarAction:a}),(p||m||v||b||x||w||N||A||S||j)&&o.jsx(it,{})]}),p&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-center gap-1",children:[u.includes("textColor")&&o.jsx(js,{editor:e,type:"textColor",label:"Text color",isDisabled:l.textColor?.isDisabled}),u.includes("highlight")&&o.jsx(js,{editor:e,type:"highlight",label:"Highlight",isDisabled:l.highlight?.isDisabled})]}),(m||v||b||x||w||N||A||S||j)&&o.jsx(it,{})]}),m&&o.jsxs(o.Fragment,{children:[o.jsx(Po,{editor:e}),(v||b||x||w||N||A||S||j)&&o.jsx(it,{})]}),v&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"flex items-center gap-1",children:["left","center","right","justify"].map(I=>{const B=Ho[I],R=e.isActive({textAlign:I});return o.jsx(at,{icon:B,label:`Align ${I}`,isActive:R,onClick:()=>d("textAlign",{type:"textAlign",alignment:I})},I)})}),(b||x||w||N||A||S||j)&&o.jsx(it,{})]}),b&&o.jsxs(o.Fragment,{children:[o.jsx(Ro,{editor:e,types:u.filter(I=>["bulletList","orderedList","taskList"].includes(I))}),(x||w||N||A||S||j)&&o.jsx(it,{})]}),(x||w||N||A)&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-center gap-1",children:[x&&o.jsx(at,{icon:vt("blockquote"),label:"Blockquote",isActive:l.blockquote?.isActive,isDisabled:l.blockquote?.isDisabled,onClick:()=>c("blockquote")}),w&&o.jsx(at,{icon:vt("codeBlock"),label:"Code block",isActive:l.codeBlock?.isActive,isDisabled:l.codeBlock?.isDisabled,onClick:()=>c("codeBlock")}),N&&o.jsx(Wo,{editor:e,isDisabled:l.link?.isDisabled}),A&&o.jsx(at,{icon:vt("horizontalRule"),label:"Horizontal rule",onClick:()=>c("horizontalRule")})]}),(S||j)&&o.jsx(it,{})]}),S&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-center gap-1",children:[u.includes("undo")&&o.jsx(at,{icon:vt("undo"),label:"Undo",isDisabled:l.undo?.isDisabled,onClick:()=>c("undo")}),u.includes("redo")&&o.jsx(at,{icon:vt("redo"),label:"Redo",isDisabled:l.redo?.isDisabled,onClick:()=>c("redo")})]}),j&&o.jsx(it,{})]}),j&&o.jsx(qo,{zoom:n,onZoomChange:I=>{r?.(I),a?.({type:"zoom",modifier:`${I}%`})}})]})})}const Zo=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Xo=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,ec=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,tc=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,nc=z.Mark.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:e=>e.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:e=>e.type.name===this.name},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return["strong",z.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[z.markInputRule({find:Zo,type:this.type}),z.markInputRule({find:ec,type:this.type})]},addPasteRules(){return[z.markPasteRule({find:Xo,type:this.type}),z.markPasteRule({find:tc,type:this.type})]}}),rc=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,sc=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,ic=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,ac=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,lc=z.Mark.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:e=>e.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:e=>e.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:e}){return["em",z.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[z.markInputRule({find:rc,type:this.type}),z.markInputRule({find:ic,type:this.type})]},addPasteRules(){return[z.markPasteRule({find:sc,type:this.type}),z.markPasteRule({find:ac,type:this.type})]}}),oc=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,cc=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,dc=z.Mark.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:e=>e.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["s",z.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[z.markInputRule({find:oc,type:this.type})]},addPasteRules(){return[z.markPasteRule({find:cc,type:this.type})]}}),uc=/(^|[^`])`([^`]+)`(?!`)/,fc=/(^|[^`])`([^`]+)`(?!`)/g,hc=z.Mark.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:e}){return["code",z.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[z.markInputRule({find:uc,type:this.type})]},addPasteRules(){return[z.markPasteRule({find:fc,type:this.type})]}}),mc=e=>{if(!e.children.length)return;const t=e.querySelectorAll("span");t&&t.forEach(n=>{var r,s;const i=n.getAttribute("style"),a=(s=(r=n.parentElement)===null||r===void 0?void 0:r.closest("span"))===null||s===void 0?void 0:s.getAttribute("style");n.setAttribute("style",`${a};${i}`)})},pc=z.Mark.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:e=>e.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&mc(e),{}):!1}]},renderHTML({HTMLAttributes:e}){return["span",z.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{removeEmptyTextStyle:()=>({tr:e})=>{const{selection:t}=e;return e.doc.nodesBetween(t.from,t.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(s=>s.type===this.type).some(s=>Object.values(s.attrs).some(i=>!!i))||e.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),gc=z.Node.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,z.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,"paragraph",e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>z.textblockTypeInputRule({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),xc=z.Node.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",z.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),yc="listItem",As="textStyle",Ms=/^\s*([-+*])\s$/,bc=z.Node.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:e}){return["ul",z.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(yc,this.editor.getAttributes(As)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=z.wrappingInputRule({find:Ms,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=z.wrappingInputRule({find:Ms,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(As),editor:this.editor})),[e]}}),vc="listItem",Es="textStyle",Ts=/^(\d+)\.\s$/,wc=z.Node.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:e=>e.hasAttribute("start")?parseInt(e.getAttribute("start")||"",10):1},type:{default:null,parseHTML:e=>e.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:e}){const{start:t,...n}=e;return t===1?["ol",z.mergeAttributes(this.options.HTMLAttributes,n),0]:["ol",z.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(vc,this.editor.getAttributes(Es)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=z.wrappingInputRule({find:Ts,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:(t,n)=>n.childCount+n.attrs.start===+t[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=z.wrappingInputRule({find:Ts,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(Es)}),joinPredicate:(t,n)=>n.childCount+n.attrs.start===+t[1],editor:this.editor})),[e]}}),kc=z.Node.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:e}){return["li",z.mergeAttributes(this.options.HTMLAttributes,e),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}});function qi(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let s=e.child(r),i=t.child(r);if(s==i){n+=s.nodeSize;continue}if(!s.sameMarkup(i))return n;if(s.isText&&s.text!=i.text){for(let a=0;s.text[a]==i.text[a];a++)n++;return n}if(s.content.size||i.content.size){let a=qi(s.content,i.content,n+1);if(a!=null)return a}n+=s.nodeSize}}function Wi(e,t,n,r){for(let s=e.childCount,i=t.childCount;;){if(s==0||i==0)return s==i?null:{a:n,b:r};let a=e.child(--s),l=t.child(--i),c=a.nodeSize;if(a==l){n-=c,r-=c;continue}if(!a.sameMarkup(l))return{a:n,b:r};if(a.isText&&a.text!=l.text){let d=0,u=Math.min(a.text.length,l.text.length);for(;d<u&&a.text[a.text.length-d-1]==l.text[l.text.length-d-1];)d++,n--,r--;return{a:n,b:r}}if(a.content.size||l.content.size){let d=Wi(a.content,l.content,n-1,r-1);if(d)return d}n-=c,r-=c}}class G{constructor(t,n){if(this.content=t,this.size=n||0,n==null)for(let r=0;r<t.length;r++)this.size+=t[r].nodeSize}nodesBetween(t,n,r,s=0,i){for(let a=0,l=0;l<n;a++){let c=this.content[a],d=l+c.nodeSize;if(d>t&&r(c,s+l,i||null,a)!==!1&&c.content.size){let u=l+1;c.nodesBetween(Math.max(0,t-u),Math.min(c.content.size,n-u),r,s+u)}l=d}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,n,r,s){let i="",a=!0;return this.nodesBetween(t,n,(l,c)=>{let d=l.isText?l.text.slice(Math.max(t,c)-c,n-c):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&d||l.isTextblock)&&r&&(a?a=!1:i+=r),i+=d},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,s=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),i=1);i<t.content.length;i++)s.push(t.content[i]);return new G(s,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],s=0;if(n>t)for(let i=0,a=0;a<n;i++){let l=this.content[i],c=a+l.nodeSize;c>t&&((a<t||c>n)&&(l.isText?l=l.cut(Math.max(0,t-a),Math.min(l.text.length,n-a)):l=l.cut(Math.max(0,t-a-1),Math.min(l.content.size,n-a-1))),r.push(l),s+=l.nodeSize),a=c}return new G(r,s)}cutByIndex(t,n){return t==n?G.empty:t==0&&n==this.content.length?this:new G(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let s=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return s[t]=n,new G(s,i)}addToStart(t){return new G([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new G(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(t.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let n=this.content[t];if(!n)throw new RangeError("Index "+t+" out of range for "+this);return n}maybeChild(t){return this.content[t]||null}forEach(t){for(let n=0,r=0;n<this.content.length;n++){let s=this.content[n];t(s,r,n),r+=s.nodeSize}}findDiffStart(t,n=0){return qi(this,t,n)}findDiffEnd(t,n=this.size,r=t.size){return Wi(this,t,n,r)}findIndex(t){if(t==0)return Zt(0,t);if(t==this.size)return Zt(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let n=0,r=0;;n++){let s=this.child(n),i=r+s.nodeSize;if(i>=t)return i==t?Zt(n+1,i):Zt(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(t=>t.toJSON()):null}static fromJSON(t,n){if(!n)return G.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new G(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return G.empty;let n,r=0;for(let s=0;s<t.length;s++){let i=t[s];r+=i.nodeSize,s&&i.isText&&t[s-1].sameMarkup(i)?(n||(n=t.slice(0,s)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new G(n||t,r)}static from(t){if(!t)return G.empty;if(t instanceof G)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new G([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}G.empty=new G([],0);const Kn={index:0,offset:0};function Zt(e,t){return Kn.index=e,Kn.offset=t,Kn}function gr(e,t){if(e===t)return!0;if(!(e&&typeof e=="object")||!(t&&typeof t=="object"))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!gr(e[r],t[r]))return!1}else{for(let r in e)if(!(r in t)||!gr(e[r],t[r]))return!1;for(let r in t)if(!(r in e))return!1}return!0}class Oe{constructor(t,n){this.type=t,this.attrs=n}addToSet(t){let n,r=!1;for(let s=0;s<t.length;s++){let i=t[s];if(this.eq(i))return t;if(this.type.excludes(i.type))n||(n=t.slice(0,s));else{if(i.type.excludes(this.type))return t;!r&&i.type.rank>this.type.rank&&(n||(n=t.slice(0,s)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=t.slice()),r||n.push(this),n}removeFromSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return t.slice(0,n).concat(t.slice(n+1));return t}isInSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return!0;return!1}eq(t){return this==t||this.type==t.type&&gr(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=t.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let s=r.create(n.attrs);return r.checkAttrs(s.attrs),s}static sameSet(t,n){if(t==n)return!0;if(t.length!=n.length)return!1;for(let r=0;r<t.length;r++)if(!t[r].eq(n[r]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return Oe.none;if(t instanceof Oe)return[t];let n=t.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}}Oe.none=[];class Nc extends Error{}class Q{constructor(t,n,r){this.content=t,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=Ji(this.content,t+this.openStart,n);return r&&new Q(r,this.openStart,this.openEnd)}removeBetween(t,n){return new Q(Ki(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,n){if(!n)return Q.empty;let r=n.openStart||0,s=n.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Q(G.fromJSON(t,n.content),r,s)}static maxOpen(t,n=!0){let r=0,s=0;for(let i=t.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=t.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)s++;return new Q(t,r,s)}}Q.empty=new Q(G.empty,0,0);function Ki(e,t,n){let{index:r,offset:s}=e.findIndex(t),i=e.maybeChild(r),{index:a,offset:l}=e.findIndex(n);if(s==t||i.isText){if(l!=n&&!e.child(a).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(r!=a)throw new RangeError("Removing non-flat range");return e.replaceChild(r,i.copy(Ki(i.content,t-s-1,n-s-1)))}function Ji(e,t,n,r){let{index:s,offset:i}=e.findIndex(t),a=e.maybeChild(s);if(i==t||a.isText)return r&&!r.canReplace(s,s,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=Ji(a.content,t-i-1,n,a);return l&&e.replaceChild(s,a.copy(l))}function Sc(e){return e.tag!=null}function Cc(e){return e.style!=null}class fn{constructor(t,n){this.schema=t,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(Sc(s))this.tags.push(s);else if(Cc(s)){let i=/[^=]*/.exec(s.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=t.nodes[s.node];return i.contentMatch.matchType(i)})}parse(t,n={}){let r=new Is(this,n,!1);return r.addAll(t,Oe.none,n.from,n.to),r.finish()}parseSlice(t,n={}){let r=new Is(this,n,!0);return r.addAll(t,Oe.none,n.from,n.to),Q.maxOpen(r.finish())}matchTag(t,n,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(Mc(t,i.tag)&&(i.namespace===void 0||t.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let a=i.getAttrs(t);if(a===!1)continue;i.attrs=a||void 0}return i}}}matchStyle(t,n,r,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let a=this.styles[i],l=a.style;if(!(l.indexOf(t)!=0||a.context&&!r.matchesContext(a.context)||l.length>t.length&&(l.charCodeAt(t.length)!=61||l.slice(t.length+1)!=n))){if(a.getAttrs){let c=a.getAttrs(n);if(c===!1)continue;a.attrs=c||void 0}return a}}}static schemaRules(t){let n=[];function r(s){let i=s.priority==null?50:s.priority,a=0;for(;a<n.length;a++){let l=n[a];if((l.priority==null?50:l.priority)<i)break}n.splice(a,0,s)}for(let s in t.marks){let i=t.marks[s].spec.parseDOM;i&&i.forEach(a=>{r(a=$s(a)),a.mark||a.ignore||a.clearMark||(a.mark=s)})}for(let s in t.nodes){let i=t.nodes[s].spec.parseDOM;i&&i.forEach(a=>{r(a=$s(a)),a.node||a.ignore||a.mark||(a.node=s)})}return n}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new fn(t,fn.schemaRules(t)))}}const Yi={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},jc={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Gi={ol:!0,ul:!0},_t=1,xr=2,Ot=4;function Ds(e,t,n){return t!=null?(t?_t:0)|(t==="full"?xr:0):e&&e.whitespace=="pre"?_t|xr:n&~Ot}class Xt{constructor(t,n,r,s,i,a){this.type=t,this.attrs=n,this.marks=r,this.solid=s,this.options=a,this.content=[],this.activeMarks=Oe.none,this.match=i||(a&Ot?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(G.from(t));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(t.type))?(this.match=r,s):null}}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&_t)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let n=G.from(this.content);return!t&&this.match&&(n=n.append(this.match.fillBefore(G.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!Yi.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class Is{constructor(t,n,r){this.parser=t,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=n.topNode,i,a=Ds(null,n.preserveWhitespace,0)|(r?Ot:0);s?i=new Xt(s.type,s.attrs,Oe.none,!0,n.topMatch||s.type.contentMatch,a):r?i=new Xt(null,null,Oe.none,!0,null,a):i=new Xt(t.schema.topNodeType,null,Oe.none,!0,null,a),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t,n){t.nodeType==3?this.addTextNode(t,n):t.nodeType==1&&this.addElement(t,n)}addTextNode(t,n){let r=t.nodeValue,s=this.top,i=s.options&xr?"full":this.localPreserveWS||(s.options&_t)>0,{schema:a}=this.parser;if(i==="full"||s.inlineContext(t)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
|
|
11
|
-
`);else if(a.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(a.linebreakReplacement.create())){let
|
|
12
|
-
`),n)}ignoreFallback(t,n){t.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(t,n){let r=t.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],a=r.getPropertyValue(i);if(a)for(let l=void 0;;){let c=this.parser.matchStyle(i,a,this,l);if(!c)break;if(c.ignore)return null;if(c.clearMark?n=n.filter(d=>!c.clearMark(d)):n=n.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)l=c;else break}}return n}addElementByRule(t,n,r,s){let i,a;if(n.node)if(a=this.parser.schema.nodes[n.node],a.isLeaf)this.insertNode(a.create(n.attrs),r,t.nodeName=="BR")||this.leafFallback(t,r);else{let c=this.enter(a,n.attrs||null,r,n.preserveWhitespace);c&&(i=!0,r=c)}else{let c=this.parser.schema.marks[n.mark];r=r.concat(c.create(n.attrs))}let l=this.top;if(a&&a.isLeaf)this.findInside(t);else if(s)this.addElement(t,r,s);else if(n.getContent)this.findInside(t),n.getContent(t,this.parser.schema).forEach(c=>this.insertNode(c,r,!1));else{let c=t;typeof n.contentElement=="string"?c=t.querySelector(n.contentElement):typeof n.contentElement=="function"?c=n.contentElement(t):n.contentElement&&(c=n.contentElement),this.findAround(t,c,!0),this.addAll(c,r),this.findAround(t,c,!1)}i&&this.sync(l)&&this.open--}addAll(t,n,r,s){let i=r||0;for(let a=r?t.childNodes[r]:t.firstChild,l=s==null?null:t.childNodes[s];a!=l;a=a.nextSibling,++i)this.findAtPoint(t,i),this.addDOM(a,n);this.findAtPoint(t,i)}findPlace(t,n,r){let s,i;for(let a=this.open,l=0;a>=0;a--){let c=this.nodes[a],d=c.findWrapping(t);if(d&&(!s||s.length>d.length+l)&&(s=d,i=c,!d.length))break;if(c.solid){if(r)break;l+=2}}if(!s)return null;this.sync(i);for(let a=0;a<s.length;a++)n=this.enterInner(s[a],null,n,!1);return n}insertNode(t,n,r){if(t.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let s=this.findPlace(t,n,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(t.type));let a=Oe.none;for(let l of s.concat(t.marks))(i.type?i.type.allowsMarkType(l.type):Os(l.type,t.type))&&(a=l.addToSet(a));return i.content.push(t.mark(a)),!0}return!1}enter(t,n,r,s){let i=this.findPlace(t.create(n),r,!1);return i&&(i=this.enterInner(t,n,r,!0,s)),i}enterInner(t,n,r,s=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(t);let l=Ds(t,i,a.options);a.options&Ot&&a.content.length==0&&(l|=Ot);let c=Oe.none;return r=r.filter(d=>(a.type?a.type.allowsMarkType(d.type):Os(d.type,t))?(c=d.addToSet(c),!1):!0),this.nodes.push(new Xt(t,n,c,s,null,l)),this.open++,r}closeExtra(t=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(t));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(t){for(let n=this.open;n>=0;n--){if(this.nodes[n]==t)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=_t)}return!1}get currentPos(){this.closeExtra();let t=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let s=r.length-1;s>=0;s--)t+=r[s].nodeSize;n&&t++}return t}findAtPoint(t,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==t&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&t.nodeType==1&&t.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(t,n,r){if(t!=n&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&t.nodeType==1&&t.contains(this.find[s].node)&&n.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==t&&(this.find[n].pos=this.currentPos-(t.nodeValue.length-this.find[n].offset))}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let n=t.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(s?0:1),a=(l,c)=>{for(;l>=0;l--){let d=n[l];if(d==""){if(l==n.length-1||l==0)continue;for(;c>=i;c--)if(a(l-1,c))return!0;return!1}else{let u=c>0||c==0&&s?this.nodes[c].type:r&&c>=i?r.node(c-i).type:null;if(!u||u.name!=d&&!u.isInGroup(d))return!1;c--}}return!0};return a(n.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function Ac(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let r=t.nodeType==1?t.nodeName.toLowerCase():null;r&&Gi.hasOwnProperty(r)&&n?(n.appendChild(t),t=n):r=="li"?n=t:r&&(n=null)}}function Mc(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function $s(e){let t={};for(let n in e)t[n]=e[n];return t}function Os(e,t){let n=t.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(e))continue;let i=[],a=l=>{i.push(l);for(let c=0;c<l.edgeCount;c++){let{type:d,next:u}=l.edge(c);if(d==t||i.indexOf(u)<0&&a(u))return!0}};if(a(s.contentMatch))return!0}}class Tn{constructor(t,n){this.nodes=t,this.marks=n}serializeFragment(t,n={},r){r||(r=Jn(n).createDocumentFragment());let s=r,i=[];return t.forEach(a=>{if(i.length||a.marks.length){let l=0,c=0;for(;l<i.length&&c<a.marks.length;){let d=a.marks[c];if(!this.marks[d.type.name]){c++;continue}if(!d.eq(i[l][0])||d.type.spec.spanning===!1)break;l++,c++}for(;l<i.length;)s=i.pop()[1];for(;c<a.marks.length;){let d=a.marks[c++],u=this.serializeMark(d,a.isInline,n);u&&(i.push([d,s]),s.appendChild(u.dom),s=u.contentDOM||u.dom)}}s.appendChild(this.serializeNodeInner(a,n))}),r}serializeNodeInner(t,n){let{dom:r,contentDOM:s}=an(Jn(n),this.nodes[t.type.name](t),null,t.attrs);if(s){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,n,s)}return r}serializeNode(t,n={}){let r=this.serializeNodeInner(t,n);for(let s=t.marks.length-1;s>=0;s--){let i=this.serializeMark(t.marks[s],t.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(t,n,r={}){let s=this.marks[t.type.name];return s&&an(Jn(r),s(t,n),null,t.attrs)}static renderSpec(t,n,r=null,s){return an(t,n,r,s)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new Tn(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let n=Ls(t.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(t){return Ls(t.marks)}}function Ls(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function Jn(e){return e.document||window.document}const Fs=new WeakMap;function Ec(e){let t=Fs.get(e);return t===void 0&&Fs.set(e,t=Tc(e)),t}function Tc(e){let t=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")t||(t=[]),t.push(r);else for(let s=0;s<r.length;s++)n(r[s]);else for(let s in r)n(r[s])}return n(e),t}function an(e,t,n,r){if(typeof t=="string")return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let s=t[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=Ec(r))&&i.indexOf(t)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let a=s.indexOf(" ");a>0&&(n=s.slice(0,a),s=s.slice(a+1));let l,c=n?e.createElementNS(n,s):e.createElement(s),d=t[1],u=1;if(d&&typeof d=="object"&&d.nodeType==null&&!Array.isArray(d)){u=2;for(let f in d)if(d[f]!=null){let p=f.indexOf(" ");p>0?c.setAttributeNS(f.slice(0,p),f.slice(p+1),d[f]):f=="style"&&c.style?c.style.cssText=d[f]:c.setAttribute(f,d[f])}}for(let f=u;f<t.length;f++){let p=t[f];if(p===0){if(f<t.length-1||f>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else{let{dom:m,contentDOM:v}=an(e,p,n,r);if(c.appendChild(m),v){if(l)throw new RangeError("Multiple content holes");l=v}}}return{dom:c,contentDOM:l}}const Qi=65535,Zi=Math.pow(2,16);function Dc(e,t){return e+t*Zi}function Ps(e){return e&Qi}function Ic(e){return(e-(e&Qi))/Zi}const Xi=1,ea=2,ln=4,ta=8;class yr{constructor(t,n,r){this.pos=t,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&ta)>0}get deletedBefore(){return(this.delInfo&(Xi|ln))>0}get deletedAfter(){return(this.delInfo&(ea|ln))>0}get deletedAcross(){return(this.delInfo&ln)>0}}class Te{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&Te.empty)return Te.empty}recover(t){let n=0,r=Ps(t);if(!this.inverted)for(let s=0;s<r;s++)n+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+n+Ic(t)}mapResult(t,n=1){return this._map(t,n,!1)}map(t,n=1){return this._map(t,n,!0)}_map(t,n,r){let s=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?s:0);if(c>t)break;let d=this.ranges[l+i],u=this.ranges[l+a],f=c+d;if(t<=f){let p=d?t==c?-1:t==f?1:n:n,m=c+s+(p<0?0:u);if(r)return m;let v=t==(n<0?c:f)?null:Dc(l/3,t-c),b=t==c?ea:t==f?Xi:ln;return(n<0?t!=c:t!=f)&&(b|=ta),new yr(m,b,v)}s+=u-d}return r?t+s:new yr(t+s,0,null)}touches(t,n){let r=0,s=Ps(n),i=this.inverted?2:1,a=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?r:0);if(c>t)break;let d=this.ranges[l+i],u=c+d;if(t<=u&&l==s*3)return!0;r+=this.ranges[l+a]-d}return!1}forEach(t){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let a=this.ranges[s],l=a-(this.inverted?i:0),c=a+(this.inverted?0:i),d=this.ranges[s+n],u=this.ranges[s+r];t(l,l+d,c,c+u),i+=u-d}}invert(){return new Te(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return t==0?Te.empty:new Te(t<0?[0,-t,0]:[0,0,t])}}Te.empty=new Te([]);class hn{constructor(t,n,r=0,s=t?t.length:0){this.mirror=n,this.from=r,this.to=s,this._maps=t||[],this.ownData=!(t||n)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new hn(this._maps,this.mirror,t,n)}appendMap(t,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(t),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(t){for(let n=0,r=this._maps.length;n<t._maps.length;n++){let s=t.getMirror(n);this.appendMap(t._maps[n],s!=null&&s<n?r+s:void 0)}}getMirror(t){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==t)return this.mirror[n+(n%2?-1:1)]}}setMirror(t,n){this.mirror||(this.mirror=[]),this.mirror.push(t,n)}appendMappingInverted(t){for(let n=t.maps.length-1,r=this._maps.length+t._maps.length;n>=0;n--){let s=t.getMirror(n);this.appendMap(t._maps[n].invert(),s!=null&&s>n?r-s-1:void 0)}}invert(){let t=new hn;return t.appendMappingInverted(this),t}map(t,n=1){if(this.mirror)return this._map(t,n,!0);for(let r=this.from;r<this.to;r++)t=this._maps[r].map(t,n);return t}mapResult(t,n=1){return this._map(t,n,!1)}_map(t,n,r){let s=0;for(let i=this.from;i<this.to;i++){let a=this._maps[i],l=a.mapResult(t,n);if(l.recover!=null){let c=this.getMirror(i);if(c!=null&&c>i&&c<this.to){i=c,t=this._maps[c].recover(l.recover);continue}}s|=l.delInfo,t=l.pos}return r?t:new yr(t,s,null)}}const Yn=Object.create(null);class ke{getMap(){return Te.empty}merge(t){return null}static fromJSON(t,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Yn[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(t,n)}static jsonID(t,n){if(t in Yn)throw new RangeError("Duplicate use of step JSON ID "+t);return Yn[t]=n,n.prototype.jsonID=t,n}}class ge{constructor(t,n){this.doc=t,this.failed=n}static ok(t){return new ge(t,null)}static fail(t){return new ge(null,t)}static fromReplace(t,n,r,s){try{return ge.ok(t.replace(n,r,s))}catch(i){if(i instanceof Nc)return ge.fail(i.message);throw i}}}function _r(e,t,n){let r=[];for(let s=0;s<e.childCount;s++){let i=e.child(s);i.content.size&&(i=i.copy(_r(i.content,t,i))),i.isInline&&(i=t(i,n,s)),r.push(i)}return G.fromArray(r)}class ot extends ke{constructor(t,n,r){super(),this.from=t,this.to=n,this.mark=r}apply(t){let n=t.slice(this.from,this.to),r=t.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new Q(_r(n.content,(a,l)=>!a.isAtom||!l.type.allowsMarkType(this.mark.type)?a:a.mark(this.mark.addToSet(a.marks)),s),n.openStart,n.openEnd);return ge.fromReplace(t,this.from,this.to,i)}invert(){return new ct(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new ot(n.pos,r.pos,this.mark)}merge(t){return t instanceof ot&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new ot(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new ot(n.from,n.to,t.markFromJSON(n.mark))}}ke.jsonID("addMark",ot);class ct extends ke{constructor(t,n,r){super(),this.from=t,this.to=n,this.mark=r}apply(t){let n=t.slice(this.from,this.to),r=new Q(_r(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),t),n.openStart,n.openEnd);return ge.fromReplace(t,this.from,this.to,r)}invert(){return new ot(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new ct(n.pos,r.pos,this.mark)}merge(t){return t instanceof ct&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new ct(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new ct(n.from,n.to,t.markFromJSON(n.mark))}}ke.jsonID("removeMark",ct);class dt extends ke{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return ge.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ge.fromReplace(t,this.pos,this.pos+1,new Q(G.from(r),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let s=0;s<n.marks.length;s++)if(!n.marks[s].isInSet(r))return new dt(this.pos,n.marks[s]);return new dt(this.pos,this.mark)}}return new Vt(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new dt(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new dt(n.pos,t.markFromJSON(n.mark))}}ke.jsonID("addNodeMark",dt);class Vt extends ke{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return ge.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return ge.fromReplace(t,this.pos,this.pos+1,new Q(G.from(r),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new dt(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new Vt(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Vt(n.pos,t.markFromJSON(n.mark))}}ke.jsonID("removeNodeMark",Vt);class qe extends ke{constructor(t,n,r,s=!1){super(),this.from=t,this.to=n,this.slice=r,this.structure=s}apply(t){return this.structure&&br(t,this.from,this.to)?ge.fail("Structure replace would overwrite content"):ge.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new Te([this.from,this.to-this.from,this.slice.size])}invert(t){return new qe(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new qe(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(t){if(!(t instanceof qe)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?Q.empty:new Q(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new qe(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?Q.empty:new Q(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new qe(t.from,this.to,n,this.structure)}else return null}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new qe(n.from,n.to,Q.fromJSON(t,n.slice),!!n.structure)}}ke.jsonID("replace",qe);class St extends ke{constructor(t,n,r,s,i,a,l=!1){super(),this.from=t,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=a,this.structure=l}apply(t){if(this.structure&&(br(t,this.from,this.gapFrom)||br(t,this.gapTo,this.to)))return ge.fail("Structure gap-replace would overwrite content");let n=t.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return ge.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?ge.fromReplace(t,this.from,this.to,r):ge.fail("Content does not fit in gap")}getMap(){return new Te([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new St(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||i>r.pos?null:new St(n.pos,r.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new St(n.from,n.to,n.gapFrom,n.gapTo,Q.fromJSON(t,n.slice),n.insert,!!n.structure)}}ke.jsonID("replaceAround",St);function br(e,t,n){let r=e.resolve(t),s=n-t,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let a=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!a||a.isLeaf)return!0;a=a.firstChild,s--}}return!1}function na(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let s=n.content;for(let i=0;i<n.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.size?2:1);i++)for(let a=r.depth;a>=0;a--){let l=a==r.depth?0:r.pos<=(r.start(a+1)+r.end(a+1))/2?-1:1,c=r.index(a)+(l>0?1:0),d=r.node(a),u=!1;if(i==1)u=d.canReplace(c,c,s);else{let f=d.contentMatchAt(c).findWrapping(s.firstChild.type);u=f&&d.canReplaceWith(c,c,f[0])}if(u)return l==0?r.pos:l<0?r.before(a+1):r.after(a+1)}return null}class Lt extends ke{constructor(t,n,r){super(),this.pos=t,this.attr=n,this.value=r}apply(t){let n=t.nodeAt(this.pos);if(!n)return ge.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return ge.fromReplace(t,this.pos,this.pos+1,new Q(G.from(s),0,n.isLeaf?0:1))}getMap(){return Te.empty}invert(t){return new Lt(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new Lt(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Lt(n.pos,n.attr,n.value)}}ke.jsonID("attr",Lt);class mn extends ke{constructor(t,n){super(),this.attr=t,this.value=n}apply(t){let n=Object.create(null);for(let s in t.attrs)n[s]=t.attrs[s];n[this.attr]=this.value;let r=t.type.create(n,t.content,t.marks);return ge.ok(r)}getMap(){return Te.empty}invert(t){return new mn(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new mn(n.attr,n.value)}}ke.jsonID("docAttr",mn);let Ht=class extends Error{};Ht=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n};Ht.prototype=Object.create(Error.prototype);Ht.prototype.constructor=Ht;Ht.prototype.name="TransformError";const Gn=Object.create(null);class re{constructor(t,n,r){this.$anchor=t,this.$head=n,this.ranges=r||[new $c(t.min(n),t.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let t=this.ranges;for(let n=0;n<t.length;n++)if(t[n].$from.pos!=t[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,n=Q.empty){let r=n.content.lastChild,s=null;for(let l=0;l<n.openEnd;l++)s=r,r=r.lastChild;let i=t.steps.length,a=this.ranges;for(let l=0;l<a.length;l++){let{$from:c,$to:d}=a[l],u=t.mapping.slice(i);t.replaceRange(u.map(c.pos),u.map(d.pos),l?Q.empty:n),l==0&&Bs(t,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(t,n){let r=t.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:a,$to:l}=s[i],c=t.mapping.slice(r),d=c.map(a.pos),u=c.map(l.pos);i?t.deleteRange(d,u):(t.replaceRangeWith(d,u,n),Bs(t,r,n.isInline?-1:1))}}static findFrom(t,n,r=!1){let s=t.parent.inlineContent?new ne(t):wt(t.node(0),t.parent,t.pos,t.index(),n,r);if(s)return s;for(let i=t.depth-1;i>=0;i--){let a=n<0?wt(t.node(0),t.node(i),t.before(i+1),t.index(i),n,r):wt(t.node(0),t.node(i),t.after(i+1),t.index(i)+1,n,r);if(a)return a}return null}static near(t,n=1){return this.findFrom(t,n)||this.findFrom(t,-n)||new Ve(t.node(0))}static atStart(t){return wt(t,t,0,0,1)||new Ve(t)}static atEnd(t){return wt(t,t,t.content.size,t.childCount,-1)||new Ve(t)}static fromJSON(t,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Gn[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(t,n)}static jsonID(t,n){if(t in Gn)throw new RangeError("Duplicate use of selection JSON ID "+t);return Gn[t]=n,n.prototype.jsonID=t,n}getBookmark(){return ne.between(this.$anchor,this.$head).getBookmark()}}re.prototype.visible=!0;class $c{constructor(t,n){this.$from=t,this.$to=n}}let Rs=!1;function zs(e){!Rs&&!e.parent.inlineContent&&(Rs=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class ne extends re{constructor(t,n=t){zs(t),zs(n),super(t,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return re.near(r);let s=t.resolve(n.map(this.anchor));return new ne(s.parent.inlineContent?s:r,r)}replace(t,n=Q.empty){if(super.replace(t,n),n==Q.empty){let r=this.$from.marksAcross(this.$to);r&&t.ensureMarks(r)}}eq(t){return t instanceof ne&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new Dn(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new ne(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){let s=t.resolve(n);return new this(s,r==n?s:t.resolve(r))}static between(t,n,r){let s=t.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let i=re.findFrom(n,r,!0)||re.findFrom(n,-r,!0);if(i)n=i.$head;else return re.near(n,r)}return t.parent.inlineContent||(s==0?t=n:(t=(re.findFrom(t,-r,!0)||re.findFrom(t,r,!0)).$anchor,t.pos<n.pos!=s<0&&(t=n))),new ne(t,n)}}re.jsonID("text",ne);class Dn{constructor(t,n){this.anchor=t,this.head=n}map(t){return new Dn(t.map(this.anchor),t.map(this.head))}resolve(t){return ne.between(t.resolve(this.anchor),t.resolve(this.head))}}class Z extends re{constructor(t){let n=t.nodeAfter,r=t.node(0).resolve(t.pos+n.nodeSize);super(t,r),this.node=n}map(t,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),i=t.resolve(s);return r?re.near(i):new Z(i)}content(){return new Q(G.from(this.node),0,0)}eq(t){return t instanceof Z&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Vr(this.anchor)}static fromJSON(t,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Z(t.resolve(n.anchor))}static create(t,n){return new Z(t.resolve(n))}static isSelectable(t){return!t.isText&&t.type.spec.selectable!==!1}}Z.prototype.visible=!1;re.jsonID("node",Z);class Vr{constructor(t){this.anchor=t}map(t){let{deleted:n,pos:r}=t.mapResult(this.anchor);return n?new Dn(r,r):new Vr(r)}resolve(t){let n=t.resolve(this.anchor),r=n.nodeAfter;return r&&Z.isSelectable(r)?new Z(n):re.near(n)}}class Ve extends re{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,n=Q.empty){if(n==Q.empty){t.delete(0,t.doc.content.size);let r=re.atStart(t.doc);r.eq(t.selection)||t.setSelection(r)}else super.replace(t,n)}toJSON(){return{type:"all"}}static fromJSON(t){return new Ve(t)}map(t){return new Ve(t)}eq(t){return t instanceof Ve}getBookmark(){return Oc}}re.jsonID("all",Ve);const Oc={map(){return this},resolve(e){return new Ve(e)}};function wt(e,t,n,r,s,i=!1){if(t.inlineContent)return ne.create(e,n);for(let a=r-(s>0?0:1);s>0?a<t.childCount:a>=0;a+=s){let l=t.child(a);if(l.isAtom){if(!i&&Z.isSelectable(l))return Z.create(e,n-(s<0?l.nodeSize:0))}else{let c=wt(e,l,n+s,s<0?l.childCount:0,s,i);if(c)return c}n+=l.nodeSize*s}return null}function Bs(e,t,n){let r=e.steps.length-1;if(r<t)return;let s=e.steps[r];if(!(s instanceof qe||s instanceof St))return;let i=e.mapping.maps[r],a;i.forEach((l,c,d,u)=>{a==null&&(a=u)}),e.setSelection(re.near(e.doc.resolve(a),n))}function _s(e,t){return!t||!e?e:e.bind(t)}class en{constructor(t,n,r){this.name=t,this.init=_s(n.init,r),this.apply=_s(n.apply,r)}}new en("doc",{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new en("selection",{init(e,t){return e.selection||re.atStart(t.doc)},apply(e){return e.selection}}),new en("storedMarks",{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new en("scrollToSelection",{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}});function ra(e,t,n){for(let r in e){let s=e[r];s instanceof Function?s=s.bind(t):r=="handleDOMEvents"&&(s=ra(s,t,{})),n[r]=s}return n}class In{constructor(t){this.spec=t,this.props={},t.props&&ra(t.props,this,this.props),this.key=t.key?t.key.key:sa("plugin")}getState(t){return t[this.key]}}const Qn=Object.create(null);function sa(e){return e in Qn?e+"$"+ ++Qn[e]:(Qn[e]=0,e+"$")}class Hr{constructor(t="key"){this.key=sa(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const Lc=/^```([a-z]+)?[\s\n]$/,Fc=/^~~~([a-z]+)?[\s\n]$/,Pc=z.Node.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{var t;const{languageClassPrefix:n}=this.options,i=[...((t=e.firstElementChild)===null||t===void 0?void 0:t.classList)||[]].filter(a=>a.startsWith(n)).map(a=>a.replace(n,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:e,HTMLAttributes:t}){return["pre",z.mergeAttributes(this.options.HTMLAttributes,t),["code",{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:e,$anchor:t}=this.editor.state.selection,n=t.pos===1;return!e||t.parent.type.name!==this.name?!1:n||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:t}=e,{selection:n}=t,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,a=r.parent.textContent.endsWith(`
|
|
10
|
+
`,"aria-label":`Zoom level ${e}%`,children:[e,"%"]})}),l.jsx(f.Tooltip,{content:"Zoom in",placement:"top",offset:10,children:l.jsx(K,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:d,onPress:a,"aria-label":"Zoom in",children:l.jsx(J.ZoomIn,{size:16})})})]})}function ic({editor:e,isDisabled:t=!1}){const[n,r]=y.useState(!1),[s,i]=y.useState(""),[a,o]=y.useState(""),[c,d]=y.useState(!1),u=e.isActive("link"),h=m=>{if(m){const{from:v,to:b}=e.state.selection,x=e.isActive("link");let w="";if(x){const M=e.schema.marks.link,N=e.state.doc.resolve(v),j=V.getMarkRange(N,M);j&&(w=e.state.doc.textBetween(j.from,j.to,""))}else w=e.state.doc.textBetween(v,b,"");const S=e.getAttributes("link").href||"";i(w),o(S),d(x)}r(m)},p=()=>{if(a.trim()){const{from:m,to:v}=e.state.selection,b=e.schema.marks.link,x=e.state.doc.resolve(m),w=V.getMarkRange(x,b),S=w?.from??m,M=w?.to??v,N=e.state.doc.textBetween(S,M,"");s.trim()&&s!==N?e.chain().focus().setTextSelection({from:S,to:M}).deleteSelection().insertContent(`<a href="${a.trim()}">${s.trim()}</a>`).run():e.chain().focus().extendMarkRange("link").updateAttributes("link",{href:a.trim()}).run()}r(!1)};return l.jsxs(f.Popover,{isOpen:n,onOpenChange:h,placement:"bottom",children:[l.jsx(f.PopoverTrigger,{children:l.jsx(K,{size:"sm",radius:"sm",variant:u?"solid":"bordered",color:u?"primary":"default",isIconOnly:!0,isDisabled:t,"aria-label":"Link",children:l.jsx(J.Link,{size:16})})}),l.jsx(f.PopoverContent,{children:l.jsxs("div",{className:"flex flex-col gap-3 p-3 w-72",children:[l.jsx(f.Input,{size:"sm",variant:"bordered",label:"Name",labelPlacement:"outside",placeholder:"Link text",value:s,onChange:m=>i(m.target.value),classNames:{inputWrapper:"focus-within:border-default-400"}}),l.jsx(f.Input,{size:"sm",variant:"bordered",label:"Link",labelPlacement:"outside",placeholder:"https://example.com",value:a,onChange:m=>o(m.target.value),onKeyDown:m=>m.key==="Enter"&&p(),classNames:{inputWrapper:"focus-within:border-default-400"}}),l.jsx(K,{size:"sm",color:"primary",onPress:p,isDisabled:!a.trim(),children:c?"Update":"Apply"})]})})]})}function ac({children:e,id:t,label:n,className:r,useButtonGroup:s=!0}){return s?l.jsx(f.ButtonGroup,{size:"sm",id:t,"aria-label":n,className:r,children:e}):l.jsx("div",{id:t,role:"group","aria-label":n,className:`flex items-center gap-2 ${r||""}`,children:e})}function Qi(e,t){const n=y.useMemo(()=>{if(!e)return{};const i={};return Array.from(new Set(t.map(o=>Yt(o)))).forEach(o=>{const c=Je[o];if(c)try{const d=c.canExecute?.(e)??!0,u=c.isActive?.(e)??!1;i[o]={isActive:u,isDisabled:!d,canExecute:d}}catch(d){console.warn(`Extension not available for modifier: ${o}`,d),i[o]={isActive:!1,isDisabled:!0,canExecute:!1}}}),i},[e,t]),[r,s]=y.useState(n);return y.useEffect(()=>{if(!e)return;const i=()=>{const a={};Array.from(new Set(t.map(c=>Yt(c)))).forEach(c=>{const d=Je[c];if(d)try{const u=d.canExecute?.(e)??!0,h=d.isActive?.(e)??!1;a[c]={isActive:h,isDisabled:!u,canExecute:u}}catch(u){console.warn(`Extension not available for modifier: ${c}`,u),a[c]={isActive:!1,isDisabled:!0,canExecute:!1}}}),s(a)};return e.on("selectionUpdate",i),e.on("transaction",i),()=>{e.off("selectionUpdate",i),e.off("transaction",i)}},[e,t,n]),r}function Zi(e,t){const n=y.useCallback((a,o)=>{if(!e)return;const c=Je[a];if(c)try{c.execute({editor:e,config:o}),t?.({type:"toggle",modifier:a})}catch(d){console.warn(`Failed to execute command for modifier: ${a}`,d)}},[e,t]),r=y.useCallback(a=>{n(a)},[n]),s=y.useCallback((a,o)=>{if(!e)return!1;const c=Je[a];try{return c?.canExecute?.(e,o)??!1}catch(d){return console.warn(`Failed to check canExecute for modifier: ${a}`,d),!1}},[e]),i=y.useCallback((a,o)=>{if(!e)return!1;const c=Je[a];try{return c?.isActive?.(e,o)??!1}catch(d){return console.warn(`Failed to check isActive for modifier: ${a}`,d),!1}},[e]);return{executeCommand:n,toggleModifier:r,canExecute:s,isActive:i}}function lc(e=ke.default){const[t,n]=y.useState(e),r=y.useCallback((o=ke.step)=>{n(c=>Math.min(ke.max,c+o))},[]),s=y.useCallback((o=ke.step)=>{n(c=>Math.max(ke.min,c-o))},[]),i=y.useCallback(()=>{n(ke.default)},[]),a=y.useCallback(o=>{const c=Math.max(ke.min,Math.min(ke.max,o));n(c)},[]);return{zoom:t,setZoom:a,zoomIn:r,zoomOut:s,resetZoom:i,isMinZoom:t<=ke.min,isMaxZoom:t>=ke.max,isDefaultZoom:t===ke.default}}const oc=["bold","italic","strike","underline","code"];function cc({editor:e,modifiers:t,onToolbarAction:n}){const r=Qi(e,t),{toggleModifier:s}=Zi(e,n);if(!e)return null;const i=t.map(a=>Yt(a)).filter(a=>oc.includes(a));return i.length===0?null:l.jsx(ac,{id:"text-formatting",label:"Text formatting",children:i.map(a=>{const o=r[a],c=St(a);return l.jsx(ct,{icon:c,label:a.charAt(0).toUpperCase()+a.slice(1),isActive:o?.isActive,isDisabled:o?.isDisabled,onClick:()=>s(a)},a)})})}function dc({editor:e,modifiers:t,zoom:n=100,onZoomChange:r,sticky:s=!0,className:i,onToolbarAction:a}){const o=Qi(e,t),{toggleModifier:c,executeCommand:d}=Zi(e,a);if(!e)return null;const u=t.map($=>Yt($)),h=u.some($=>["bold","italic","strike","underline","code"].includes($)),p=u.some($=>["textColor","highlight"].includes($)),m=u.includes("heading"),v=u.includes("textAlign"),b=u.some($=>["bulletList","orderedList","taskList"].includes($)),x=u.includes("blockquote"),w=u.includes("codeBlock"),S=u.includes("link"),M=u.includes("horizontalRule"),N=u.some($=>["undo","redo"].includes($)),j=n!==void 0&&r!==void 0,T=s?"sticky top-0 z-10":"";return l.jsx("div",{className:`w-full p-2 bg-background border-b border-divider ${T} ${i||""}`,children:l.jsxs("div",{className:"flex flex-row flex-wrap gap-2 w-full items-center",children:[h&&l.jsxs(l.Fragment,{children:[l.jsx(cc,{editor:e,modifiers:t,onToolbarAction:a}),(p||m||v||b||x||w||S||M||N||j)&&l.jsx(ot,{})]}),p&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex items-center gap-1",children:[u.includes("textColor")&&l.jsx(Ds,{editor:e,type:"textColor",label:"Text color",isDisabled:o.textColor?.isDisabled}),u.includes("highlight")&&l.jsx(Ds,{editor:e,type:"highlight",label:"Highlight",isDisabled:o.highlight?.isDisabled})]}),(m||v||b||x||w||S||M||N||j)&&l.jsx(ot,{})]}),m&&l.jsxs(l.Fragment,{children:[l.jsx(Go,{editor:e}),(v||b||x||w||S||M||N||j)&&l.jsx(ot,{})]}),v&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"flex items-center gap-1",children:["left","center","right","justify"].map($=>{const W=nc[$],D=e.isActive({textAlign:$});return l.jsx(ct,{icon:W,label:`Align ${$}`,isActive:D,onClick:()=>d("textAlign",{type:"textAlign",alignment:$})},$)})}),(b||x||w||S||M||N||j)&&l.jsx(ot,{})]}),b&&l.jsxs(l.Fragment,{children:[l.jsx(Qo,{editor:e,types:u.filter($=>["bulletList","orderedList","taskList"].includes($))}),(x||w||S||M||N||j)&&l.jsx(ot,{})]}),(x||w||S||M)&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex items-center gap-1",children:[x&&l.jsx(ct,{icon:St("blockquote"),label:"Blockquote",isActive:o.blockquote?.isActive,isDisabled:o.blockquote?.isDisabled,onClick:()=>c("blockquote")}),w&&l.jsx(ct,{icon:St("codeBlock"),label:"Code block",isActive:o.codeBlock?.isActive,isDisabled:o.codeBlock?.isDisabled,onClick:()=>c("codeBlock")}),S&&l.jsx(ic,{editor:e,isDisabled:o.link?.isDisabled}),M&&l.jsx(ct,{icon:St("horizontalRule"),label:"Horizontal rule",onClick:()=>c("horizontalRule")})]}),(N||j)&&l.jsx(ot,{})]}),N&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex items-center gap-1",children:[u.includes("undo")&&l.jsx(ct,{icon:St("undo"),label:"Undo",isDisabled:o.undo?.isDisabled,onClick:()=>c("undo")}),u.includes("redo")&&l.jsx(ct,{icon:St("redo"),label:"Redo",isDisabled:o.redo?.isDisabled,onClick:()=>c("redo")})]}),j&&l.jsx(ot,{})]}),j&&l.jsx(sc,{zoom:n,onZoomChange:$=>{r?.($),a?.({type:"zoom",modifier:`${$}%`})}})]})})}const uc=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,fc=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,hc=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,mc=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,pc=V.Mark.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:e=>e.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:e=>e.type.name===this.name},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return["strong",V.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[V.markInputRule({find:uc,type:this.type}),V.markInputRule({find:hc,type:this.type})]},addPasteRules(){return[V.markPasteRule({find:fc,type:this.type}),V.markPasteRule({find:mc,type:this.type})]}}),gc=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,xc=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,yc=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,bc=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,vc=V.Mark.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:e=>e.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:e=>e.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:e}){return["em",V.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[V.markInputRule({find:gc,type:this.type}),V.markInputRule({find:yc,type:this.type})]},addPasteRules(){return[V.markPasteRule({find:xc,type:this.type}),V.markPasteRule({find:bc,type:this.type})]}}),wc=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,kc=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Nc=V.Mark.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:e=>e.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["s",V.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[V.markInputRule({find:wc,type:this.type})]},addPasteRules(){return[V.markPasteRule({find:kc,type:this.type})]}}),Sc=/(^|[^`])`([^`]+)`(?!`)/,Cc=/(^|[^`])`([^`]+)`(?!`)/g,jc=V.Mark.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:e}){return["code",V.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[V.markInputRule({find:Sc,type:this.type})]},addPasteRules(){return[V.markPasteRule({find:Cc,type:this.type})]}}),Ac=e=>{if(!e.children.length)return;const t=e.querySelectorAll("span");t&&t.forEach(n=>{var r,s;const i=n.getAttribute("style"),a=(s=(r=n.parentElement)===null||r===void 0?void 0:r.closest("span"))===null||s===void 0?void 0:s.getAttribute("style");n.setAttribute("style",`${a};${i}`)})},Mc=V.Mark.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:e=>e.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&Ac(e),{}):!1}]},renderHTML({HTMLAttributes:e}){return["span",V.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{removeEmptyTextStyle:()=>({tr:e})=>{const{selection:t}=e;return e.doc.nodesBetween(t.from,t.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(s=>s.type===this.type).some(s=>Object.values(s.attrs).some(i=>!!i))||e.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),Ec=V.Node.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,V.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,"paragraph",e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>V.textblockTypeInputRule({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),Tc=V.Node.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",V.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Dc="listItem",Is="textStyle",$s=/^\s*([-+*])\s$/,Ic=V.Node.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:e}){return["ul",V.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Dc,this.editor.getAttributes(Is)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=V.wrappingInputRule({find:$s,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=V.wrappingInputRule({find:$s,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Is),editor:this.editor})),[e]}}),$c="listItem",Os="textStyle",Ls=/^(\d+)\.\s$/,Oc=V.Node.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:e=>e.hasAttribute("start")?parseInt(e.getAttribute("start")||"",10):1},type:{default:null,parseHTML:e=>e.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:e}){const{start:t,...n}=e;return t===1?["ol",V.mergeAttributes(this.options.HTMLAttributes,n),0]:["ol",V.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes($c,this.editor.getAttributes(Os)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=V.wrappingInputRule({find:Ls,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:(t,n)=>n.childCount+n.attrs.start===+t[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=V.wrappingInputRule({find:Ls,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(Os)}),joinPredicate:(t,n)=>n.childCount+n.attrs.start===+t[1],editor:this.editor})),[e]}}),Lc=V.Node.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:e}){return["li",V.mergeAttributes(this.options.HTMLAttributes,e),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}});function Xi(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let s=e.child(r),i=t.child(r);if(s==i){n+=s.nodeSize;continue}if(!s.sameMarkup(i))return n;if(s.isText&&s.text!=i.text){for(let a=0;s.text[a]==i.text[a];a++)n++;return n}if(s.content.size||i.content.size){let a=Xi(s.content,i.content,n+1);if(a!=null)return a}n+=s.nodeSize}}function ea(e,t,n,r){for(let s=e.childCount,i=t.childCount;;){if(s==0||i==0)return s==i?null:{a:n,b:r};let a=e.child(--s),o=t.child(--i),c=a.nodeSize;if(a==o){n-=c,r-=c;continue}if(!a.sameMarkup(o))return{a:n,b:r};if(a.isText&&a.text!=o.text){let d=0,u=Math.min(a.text.length,o.text.length);for(;d<u&&a.text[a.text.length-d-1]==o.text[o.text.length-d-1];)d++,n--,r--;return{a:n,b:r}}if(a.content.size||o.content.size){let d=ea(a.content,o.content,n-1,r-1);if(d)return d}n-=c,r-=c}}class Z{constructor(t,n){if(this.content=t,this.size=n||0,n==null)for(let r=0;r<t.length;r++)this.size+=t[r].nodeSize}nodesBetween(t,n,r,s=0,i){for(let a=0,o=0;o<n;a++){let c=this.content[a],d=o+c.nodeSize;if(d>t&&r(c,s+o,i||null,a)!==!1&&c.content.size){let u=o+1;c.nodesBetween(Math.max(0,t-u),Math.min(c.content.size,n-u),r,s+u)}o=d}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,n,r,s){let i="",a=!0;return this.nodesBetween(t,n,(o,c)=>{let d=o.isText?o.text.slice(Math.max(t,c)-c,n-c):o.isLeaf?s?typeof s=="function"?s(o):s:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&d||o.isTextblock)&&r&&(a?a=!1:i+=r),i+=d},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,s=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),i=1);i<t.content.length;i++)s.push(t.content[i]);return new Z(s,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],s=0;if(n>t)for(let i=0,a=0;a<n;i++){let o=this.content[i],c=a+o.nodeSize;c>t&&((a<t||c>n)&&(o.isText?o=o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o=o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),s+=o.nodeSize),a=c}return new Z(r,s)}cutByIndex(t,n){return t==n?Z.empty:t==0&&n==this.content.length?this:new Z(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let s=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return s[t]=n,new Z(s,i)}addToStart(t){return new Z([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new Z(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(t.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let n=this.content[t];if(!n)throw new RangeError("Index "+t+" out of range for "+this);return n}maybeChild(t){return this.content[t]||null}forEach(t){for(let n=0,r=0;n<this.content.length;n++){let s=this.content[n];t(s,r,n),r+=s.nodeSize}}findDiffStart(t,n=0){return Xi(this,t,n)}findDiffEnd(t,n=this.size,r=t.size){return ea(this,t,n,r)}findIndex(t){if(t==0)return dn(0,t);if(t==this.size)return dn(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let n=0,r=0;;n++){let s=this.child(n),i=r+s.nodeSize;if(i>=t)return i==t?dn(n+1,i):dn(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(t=>t.toJSON()):null}static fromJSON(t,n){if(!n)return Z.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new Z(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return Z.empty;let n,r=0;for(let s=0;s<t.length;s++){let i=t[s];r+=i.nodeSize,s&&i.isText&&t[s-1].sameMarkup(i)?(n||(n=t.slice(0,s)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new Z(n||t,r)}static from(t){if(!t)return Z.empty;if(t instanceof Z)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new Z([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}Z.empty=new Z([],0);const tr={index:0,offset:0};function dn(e,t){return tr.index=e,tr.offset=t,tr}function jr(e,t){if(e===t)return!0;if(!(e&&typeof e=="object")||!(t&&typeof t=="object"))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!jr(e[r],t[r]))return!1}else{for(let r in e)if(!(r in t)||!jr(e[r],t[r]))return!1;for(let r in t)if(!(r in e))return!1}return!0}class Fe{constructor(t,n){this.type=t,this.attrs=n}addToSet(t){let n,r=!1;for(let s=0;s<t.length;s++){let i=t[s];if(this.eq(i))return t;if(this.type.excludes(i.type))n||(n=t.slice(0,s));else{if(i.type.excludes(this.type))return t;!r&&i.type.rank>this.type.rank&&(n||(n=t.slice(0,s)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=t.slice()),r||n.push(this),n}removeFromSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return t.slice(0,n).concat(t.slice(n+1));return t}isInSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return!0;return!1}eq(t){return this==t||this.type==t.type&&jr(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=t.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let s=r.create(n.attrs);return r.checkAttrs(s.attrs),s}static sameSet(t,n){if(t==n)return!0;if(t.length!=n.length)return!1;for(let r=0;r<t.length;r++)if(!t[r].eq(n[r]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return Fe.none;if(t instanceof Fe)return[t];let n=t.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}}Fe.none=[];class Fc extends Error{}class X{constructor(t,n,r){this.content=t,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=na(this.content,t+this.openStart,n);return r&&new X(r,this.openStart,this.openEnd)}removeBetween(t,n){return new X(ta(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,n){if(!n)return X.empty;let r=n.openStart||0,s=n.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new X(Z.fromJSON(t,n.content),r,s)}static maxOpen(t,n=!0){let r=0,s=0;for(let i=t.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=t.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)s++;return new X(t,r,s)}}X.empty=new X(Z.empty,0,0);function ta(e,t,n){let{index:r,offset:s}=e.findIndex(t),i=e.maybeChild(r),{index:a,offset:o}=e.findIndex(n);if(s==t||i.isText){if(o!=n&&!e.child(a).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(r!=a)throw new RangeError("Removing non-flat range");return e.replaceChild(r,i.copy(ta(i.content,t-s-1,n-s-1)))}function na(e,t,n,r){let{index:s,offset:i}=e.findIndex(t),a=e.maybeChild(s);if(i==t||a.isText)return r&&!r.canReplace(s,s,n)?null:e.cut(0,t).append(n).append(e.cut(t));let o=na(a.content,t-i-1,n,a);return o&&e.replaceChild(s,a.copy(o))}function Pc(e){return e.tag!=null}function Rc(e){return e.style!=null}class Nn{constructor(t,n){this.schema=t,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(Pc(s))this.tags.push(s);else if(Rc(s)){let i=/[^=]*/.exec(s.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=t.nodes[s.node];return i.contentMatch.matchType(i)})}parse(t,n={}){let r=new Ps(this,n,!1);return r.addAll(t,Fe.none,n.from,n.to),r.finish()}parseSlice(t,n={}){let r=new Ps(this,n,!0);return r.addAll(t,Fe.none,n.from,n.to),X.maxOpen(r.finish())}matchTag(t,n,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(_c(t,i.tag)&&(i.namespace===void 0||t.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let a=i.getAttrs(t);if(a===!1)continue;i.attrs=a||void 0}return i}}}matchStyle(t,n,r,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let a=this.styles[i],o=a.style;if(!(o.indexOf(t)!=0||a.context&&!r.matchesContext(a.context)||o.length>t.length&&(o.charCodeAt(t.length)!=61||o.slice(t.length+1)!=n))){if(a.getAttrs){let c=a.getAttrs(n);if(c===!1)continue;a.attrs=c||void 0}return a}}}static schemaRules(t){let n=[];function r(s){let i=s.priority==null?50:s.priority,a=0;for(;a<n.length;a++){let o=n[a];if((o.priority==null?50:o.priority)<i)break}n.splice(a,0,s)}for(let s in t.marks){let i=t.marks[s].spec.parseDOM;i&&i.forEach(a=>{r(a=Rs(a)),a.mark||a.ignore||a.clearMark||(a.mark=s)})}for(let s in t.nodes){let i=t.nodes[s].spec.parseDOM;i&&i.forEach(a=>{r(a=Rs(a)),a.node||a.ignore||a.mark||(a.node=s)})}return n}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new Nn(t,Nn.schemaRules(t)))}}const ra={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},zc={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},sa={ol:!0,ul:!0},Gt=1,Ar=2,Ht=4;function Fs(e,t,n){return t!=null?(t?Gt:0)|(t==="full"?Ar:0):e&&e.whitespace=="pre"?Gt|Ar:n&~Ht}class un{constructor(t,n,r,s,i,a){this.type=t,this.attrs=n,this.marks=r,this.solid=s,this.options=a,this.content=[],this.activeMarks=Fe.none,this.match=i||(a&Ht?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(Z.from(t));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(t.type))?(this.match=r,s):null}}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&Gt)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let n=Z.from(this.content);return!t&&this.match&&(n=n.append(this.match.fillBefore(Z.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!ra.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class Ps{constructor(t,n,r){this.parser=t,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=n.topNode,i,a=Fs(null,n.preserveWhitespace,0)|(r?Ht:0);s?i=new un(s.type,s.attrs,Fe.none,!0,n.topMatch||s.type.contentMatch,a):r?i=new un(null,null,Fe.none,!0,null,a):i=new un(t.schema.topNodeType,null,Fe.none,!0,null,a),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t,n){t.nodeType==3?this.addTextNode(t,n):t.nodeType==1&&this.addElement(t,n)}addTextNode(t,n){let r=t.nodeValue,s=this.top,i=s.options&Ar?"full":this.localPreserveWS||(s.options&Gt)>0,{schema:a}=this.parser;if(i==="full"||s.inlineContext(t)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
|
|
11
|
+
`);else if(a.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(a.linebreakReplacement.create())){let o=r.split(/\r?\n|\r/);for(let c=0;c<o.length;c++)c&&this.insertNode(a.linebreakReplacement.create(),n,!0),o[c]&&this.insertNode(a.text(o[c]),n,!/\S/.test(o[c]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let o=s.content[s.content.length-1],c=t.previousSibling;(!o||c&&c.nodeName=="BR"||o.isText&&/[ \t\r\n\u000c]$/.test(o.text))&&(r=r.slice(1))}r&&this.insertNode(a.text(r),n,!/\S/.test(r)),this.findInText(t)}else this.findInside(t)}addElement(t,n,r){let s=this.localPreserveWS,i=this.top;(t.tagName=="PRE"||/pre/.test(t.style&&t.style.whiteSpace))&&(this.localPreserveWS=!0);let a=t.nodeName.toLowerCase(),o;sa.hasOwnProperty(a)&&this.parser.normalizeLists&&Bc(t);let c=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(o=this.parser.matchTag(t,this,r));e:if(c?c.ignore:zc.hasOwnProperty(a))this.findInside(t),this.ignoreFallback(t,n);else if(!c||c.skip||c.closeParent){c&&c.closeParent?this.open=Math.max(0,this.open-1):c&&c.skip.nodeType&&(t=c.skip);let d,u=this.needsBlock;if(ra.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),d=!0,i.type||(this.needsBlock=!0);else if(!t.firstChild){this.leafFallback(t,n);break e}let h=c&&c.skip?n:this.readStyles(t,n);h&&this.addAll(t,h),d&&this.sync(i),this.needsBlock=u}else{let d=this.readStyles(t,n);d&&this.addElementByRule(t,c,d,c.consuming===!1?o:void 0)}this.localPreserveWS=s}leafFallback(t,n){t.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode(`
|
|
12
|
+
`),n)}ignoreFallback(t,n){t.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(t,n){let r=t.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],a=r.getPropertyValue(i);if(a)for(let o=void 0;;){let c=this.parser.matchStyle(i,a,this,o);if(!c)break;if(c.ignore)return null;if(c.clearMark?n=n.filter(d=>!c.clearMark(d)):n=n.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)o=c;else break}}return n}addElementByRule(t,n,r,s){let i,a;if(n.node)if(a=this.parser.schema.nodes[n.node],a.isLeaf)this.insertNode(a.create(n.attrs),r,t.nodeName=="BR")||this.leafFallback(t,r);else{let c=this.enter(a,n.attrs||null,r,n.preserveWhitespace);c&&(i=!0,r=c)}else{let c=this.parser.schema.marks[n.mark];r=r.concat(c.create(n.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(t);else if(s)this.addElement(t,r,s);else if(n.getContent)this.findInside(t),n.getContent(t,this.parser.schema).forEach(c=>this.insertNode(c,r,!1));else{let c=t;typeof n.contentElement=="string"?c=t.querySelector(n.contentElement):typeof n.contentElement=="function"?c=n.contentElement(t):n.contentElement&&(c=n.contentElement),this.findAround(t,c,!0),this.addAll(c,r),this.findAround(t,c,!1)}i&&this.sync(o)&&this.open--}addAll(t,n,r,s){let i=r||0;for(let a=r?t.childNodes[r]:t.firstChild,o=s==null?null:t.childNodes[s];a!=o;a=a.nextSibling,++i)this.findAtPoint(t,i),this.addDOM(a,n);this.findAtPoint(t,i)}findPlace(t,n,r){let s,i;for(let a=this.open,o=0;a>=0;a--){let c=this.nodes[a],d=c.findWrapping(t);if(d&&(!s||s.length>d.length+o)&&(s=d,i=c,!d.length))break;if(c.solid){if(r)break;o+=2}}if(!s)return null;this.sync(i);for(let a=0;a<s.length;a++)n=this.enterInner(s[a],null,n,!1);return n}insertNode(t,n,r){if(t.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let s=this.findPlace(t,n,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(t.type));let a=Fe.none;for(let o of s.concat(t.marks))(i.type?i.type.allowsMarkType(o.type):zs(o.type,t.type))&&(a=o.addToSet(a));return i.content.push(t.mark(a)),!0}return!1}enter(t,n,r,s){let i=this.findPlace(t.create(n),r,!1);return i&&(i=this.enterInner(t,n,r,!0,s)),i}enterInner(t,n,r,s=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(t);let o=Fs(t,i,a.options);a.options&Ht&&a.content.length==0&&(o|=Ht);let c=Fe.none;return r=r.filter(d=>(a.type?a.type.allowsMarkType(d.type):zs(d.type,t))?(c=d.addToSet(c),!1):!0),this.nodes.push(new un(t,n,c,s,null,o)),this.open++,r}closeExtra(t=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(t));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(t){for(let n=this.open;n>=0;n--){if(this.nodes[n]==t)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Gt)}return!1}get currentPos(){this.closeExtra();let t=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let s=r.length-1;s>=0;s--)t+=r[s].nodeSize;n&&t++}return t}findAtPoint(t,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==t&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&t.nodeType==1&&t.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(t,n,r){if(t!=n&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&t.nodeType==1&&t.contains(this.find[s].node)&&n.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==t&&(this.find[n].pos=this.currentPos-(t.nodeValue.length-this.find[n].offset))}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let n=t.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(s?0:1),a=(o,c)=>{for(;o>=0;o--){let d=n[o];if(d==""){if(o==n.length-1||o==0)continue;for(;c>=i;c--)if(a(o-1,c))return!0;return!1}else{let u=c>0||c==0&&s?this.nodes[c].type:r&&c>=i?r.node(c-i).type:null;if(!u||u.name!=d&&!u.isInGroup(d))return!1;c--}}return!0};return a(n.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function Bc(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let r=t.nodeType==1?t.nodeName.toLowerCase():null;r&&sa.hasOwnProperty(r)&&n?(n.appendChild(t),t=n):r=="li"?n=t:r&&(n=null)}}function _c(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Rs(e){let t={};for(let n in e)t[n]=e[n];return t}function zs(e,t){let n=t.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(e))continue;let i=[],a=o=>{i.push(o);for(let c=0;c<o.edgeCount;c++){let{type:d,next:u}=o.edge(c);if(d==t||i.indexOf(u)<0&&a(u))return!0}};if(a(s.contentMatch))return!0}}class Vn{constructor(t,n){this.nodes=t,this.marks=n}serializeFragment(t,n={},r){r||(r=nr(n).createDocumentFragment());let s=r,i=[];return t.forEach(a=>{if(i.length||a.marks.length){let o=0,c=0;for(;o<i.length&&c<a.marks.length;){let d=a.marks[c];if(!this.marks[d.type.name]){c++;continue}if(!d.eq(i[o][0])||d.type.spec.spanning===!1)break;o++,c++}for(;o<i.length;)s=i.pop()[1];for(;c<a.marks.length;){let d=a.marks[c++],u=this.serializeMark(d,a.isInline,n);u&&(i.push([d,s]),s.appendChild(u.dom),s=u.contentDOM||u.dom)}}s.appendChild(this.serializeNodeInner(a,n))}),r}serializeNodeInner(t,n){let{dom:r,contentDOM:s}=xn(nr(n),this.nodes[t.type.name](t),null,t.attrs);if(s){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,n,s)}return r}serializeNode(t,n={}){let r=this.serializeNodeInner(t,n);for(let s=t.marks.length-1;s>=0;s--){let i=this.serializeMark(t.marks[s],t.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(t,n,r={}){let s=this.marks[t.type.name];return s&&xn(nr(r),s(t,n),null,t.attrs)}static renderSpec(t,n,r=null,s){return xn(t,n,r,s)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new Vn(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let n=Bs(t.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(t){return Bs(t.marks)}}function Bs(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function nr(e){return e.document||window.document}const _s=new WeakMap;function Vc(e){let t=_s.get(e);return t===void 0&&_s.set(e,t=Hc(e)),t}function Hc(e){let t=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")t||(t=[]),t.push(r);else for(let s=0;s<r.length;s++)n(r[s]);else for(let s in r)n(r[s])}return n(e),t}function xn(e,t,n,r){if(typeof t=="string")return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let s=t[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=Vc(r))&&i.indexOf(t)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let a=s.indexOf(" ");a>0&&(n=s.slice(0,a),s=s.slice(a+1));let o,c=n?e.createElementNS(n,s):e.createElement(s),d=t[1],u=1;if(d&&typeof d=="object"&&d.nodeType==null&&!Array.isArray(d)){u=2;for(let h in d)if(d[h]!=null){let p=h.indexOf(" ");p>0?c.setAttributeNS(h.slice(0,p),h.slice(p+1),d[h]):h=="style"&&c.style?c.style.cssText=d[h]:c.setAttribute(h,d[h])}}for(let h=u;h<t.length;h++){let p=t[h];if(p===0){if(h<t.length-1||h>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else{let{dom:m,contentDOM:v}=xn(e,p,n,r);if(c.appendChild(m),v){if(o)throw new RangeError("Multiple content holes");o=v}}}return{dom:c,contentDOM:o}}const ia=65535,aa=Math.pow(2,16);function Uc(e,t){return e+t*aa}function Vs(e){return e&ia}function qc(e){return(e-(e&ia))/aa}const la=1,oa=2,yn=4,ca=8;class Mr{constructor(t,n,r){this.pos=t,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&ca)>0}get deletedBefore(){return(this.delInfo&(la|yn))>0}get deletedAfter(){return(this.delInfo&(oa|yn))>0}get deletedAcross(){return(this.delInfo&yn)>0}}class Ie{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&Ie.empty)return Ie.empty}recover(t){let n=0,r=Vs(t);if(!this.inverted)for(let s=0;s<r;s++)n+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+n+qc(t)}mapResult(t,n=1){return this._map(t,n,!1)}map(t,n=1){return this._map(t,n,!0)}_map(t,n,r){let s=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let c=this.ranges[o]-(this.inverted?s:0);if(c>t)break;let d=this.ranges[o+i],u=this.ranges[o+a],h=c+d;if(t<=h){let p=d?t==c?-1:t==h?1:n:n,m=c+s+(p<0?0:u);if(r)return m;let v=t==(n<0?c:h)?null:Uc(o/3,t-c),b=t==c?oa:t==h?la:yn;return(n<0?t!=c:t!=h)&&(b|=ca),new Mr(m,b,v)}s+=u-d}return r?t+s:new Mr(t+s,0,null)}touches(t,n){let r=0,s=Vs(n),i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let c=this.ranges[o]-(this.inverted?r:0);if(c>t)break;let d=this.ranges[o+i],u=c+d;if(t<=u&&o==s*3)return!0;r+=this.ranges[o+a]-d}return!1}forEach(t){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let a=this.ranges[s],o=a-(this.inverted?i:0),c=a+(this.inverted?0:i),d=this.ranges[s+n],u=this.ranges[s+r];t(o,o+d,c,c+u),i+=u-d}}invert(){return new Ie(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return t==0?Ie.empty:new Ie(t<0?[0,-t,0]:[0,0,t])}}Ie.empty=new Ie([]);class Sn{constructor(t,n,r=0,s=t?t.length:0){this.mirror=n,this.from=r,this.to=s,this._maps=t||[],this.ownData=!(t||n)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new Sn(this._maps,this.mirror,t,n)}appendMap(t,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(t),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(t){for(let n=0,r=this._maps.length;n<t._maps.length;n++){let s=t.getMirror(n);this.appendMap(t._maps[n],s!=null&&s<n?r+s:void 0)}}getMirror(t){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==t)return this.mirror[n+(n%2?-1:1)]}}setMirror(t,n){this.mirror||(this.mirror=[]),this.mirror.push(t,n)}appendMappingInverted(t){for(let n=t.maps.length-1,r=this._maps.length+t._maps.length;n>=0;n--){let s=t.getMirror(n);this.appendMap(t._maps[n].invert(),s!=null&&s>n?r-s-1:void 0)}}invert(){let t=new Sn;return t.appendMappingInverted(this),t}map(t,n=1){if(this.mirror)return this._map(t,n,!0);for(let r=this.from;r<this.to;r++)t=this._maps[r].map(t,n);return t}mapResult(t,n=1){return this._map(t,n,!1)}_map(t,n,r){let s=0;for(let i=this.from;i<this.to;i++){let a=this._maps[i],o=a.mapResult(t,n);if(o.recover!=null){let c=this.getMirror(i);if(c!=null&&c>i&&c<this.to){i=c,t=this._maps[c].recover(o.recover);continue}}s|=o.delInfo,t=o.pos}return r?t:new Mr(t,s,null)}}const rr=Object.create(null);class Ne{getMap(){return Ie.empty}merge(t){return null}static fromJSON(t,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=rr[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(t,n)}static jsonID(t,n){if(t in rr)throw new RangeError("Duplicate use of step JSON ID "+t);return rr[t]=n,n.prototype.jsonID=t,n}}class xe{constructor(t,n){this.doc=t,this.failed=n}static ok(t){return new xe(t,null)}static fail(t){return new xe(null,t)}static fromReplace(t,n,r,s){try{return xe.ok(t.replace(n,r,s))}catch(i){if(i instanceof Fc)return xe.fail(i.message);throw i}}}function Qr(e,t,n){let r=[];for(let s=0;s<e.childCount;s++){let i=e.child(s);i.content.size&&(i=i.copy(Qr(i.content,t,i))),i.isInline&&(i=t(i,n,s)),r.push(i)}return Z.fromArray(r)}class ut extends Ne{constructor(t,n,r){super(),this.from=t,this.to=n,this.mark=r}apply(t){let n=t.slice(this.from,this.to),r=t.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new X(Qr(n.content,(a,o)=>!a.isAtom||!o.type.allowsMarkType(this.mark.type)?a:a.mark(this.mark.addToSet(a.marks)),s),n.openStart,n.openEnd);return xe.fromReplace(t,this.from,this.to,i)}invert(){return new ft(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new ut(n.pos,r.pos,this.mark)}merge(t){return t instanceof ut&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new ut(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new ut(n.from,n.to,t.markFromJSON(n.mark))}}Ne.jsonID("addMark",ut);class ft extends Ne{constructor(t,n,r){super(),this.from=t,this.to=n,this.mark=r}apply(t){let n=t.slice(this.from,this.to),r=new X(Qr(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),t),n.openStart,n.openEnd);return xe.fromReplace(t,this.from,this.to,r)}invert(){return new ut(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new ft(n.pos,r.pos,this.mark)}merge(t){return t instanceof ft&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new ft(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new ft(n.from,n.to,t.markFromJSON(n.mark))}}Ne.jsonID("removeMark",ft);class ht extends Ne{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return xe.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return xe.fromReplace(t,this.pos,this.pos+1,new X(Z.from(r),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let s=0;s<n.marks.length;s++)if(!n.marks[s].isInSet(r))return new ht(this.pos,n.marks[s]);return new ht(this.pos,this.mark)}}return new Qt(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new ht(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new ht(n.pos,t.markFromJSON(n.mark))}}Ne.jsonID("addNodeMark",ht);class Qt extends Ne{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return xe.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return xe.fromReplace(t,this.pos,this.pos+1,new X(Z.from(r),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new ht(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new Qt(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Qt(n.pos,t.markFromJSON(n.mark))}}Ne.jsonID("removeNodeMark",Qt);class Ke extends Ne{constructor(t,n,r,s=!1){super(),this.from=t,this.to=n,this.slice=r,this.structure=s}apply(t){return this.structure&&Er(t,this.from,this.to)?xe.fail("Structure replace would overwrite content"):xe.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new Ie([this.from,this.to-this.from,this.slice.size])}invert(t){return new Ke(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new Ke(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(t){if(!(t instanceof Ke)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?X.empty:new X(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new Ke(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?X.empty:new X(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new Ke(t.from,this.to,n,this.structure)}else return null}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Ke(n.from,n.to,X.fromJSON(t,n.slice),!!n.structure)}}Ne.jsonID("replace",Ke);class Mt extends Ne{constructor(t,n,r,s,i,a,o=!1){super(),this.from=t,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=a,this.structure=o}apply(t){if(this.structure&&(Er(t,this.from,this.gapFrom)||Er(t,this.gapTo,this.to)))return xe.fail("Structure gap-replace would overwrite content");let n=t.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return xe.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?xe.fromReplace(t,this.from,this.to,r):xe.fail("Content does not fit in gap")}getMap(){return new Ie([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new Mt(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||i>r.pos?null:new Mt(n.pos,r.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Mt(n.from,n.to,n.gapFrom,n.gapTo,X.fromJSON(t,n.slice),n.insert,!!n.structure)}}Ne.jsonID("replaceAround",Mt);function Er(e,t,n){let r=e.resolve(t),s=n-t,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let a=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!a||a.isLeaf)return!0;a=a.firstChild,s--}}return!1}function da(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let s=n.content;for(let i=0;i<n.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.size?2:1);i++)for(let a=r.depth;a>=0;a--){let o=a==r.depth?0:r.pos<=(r.start(a+1)+r.end(a+1))/2?-1:1,c=r.index(a)+(o>0?1:0),d=r.node(a),u=!1;if(i==1)u=d.canReplace(c,c,s);else{let h=d.contentMatchAt(c).findWrapping(s.firstChild.type);u=h&&d.canReplaceWith(c,c,h[0])}if(u)return o==0?r.pos:o<0?r.before(a+1):r.after(a+1)}return null}class Ut extends Ne{constructor(t,n,r){super(),this.pos=t,this.attr=n,this.value=r}apply(t){let n=t.nodeAt(this.pos);if(!n)return xe.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return xe.fromReplace(t,this.pos,this.pos+1,new X(Z.from(s),0,n.isLeaf?0:1))}getMap(){return Ie.empty}invert(t){return new Ut(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new Ut(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Ut(n.pos,n.attr,n.value)}}Ne.jsonID("attr",Ut);class Cn extends Ne{constructor(t,n){super(),this.attr=t,this.value=n}apply(t){let n=Object.create(null);for(let s in t.attrs)n[s]=t.attrs[s];n[this.attr]=this.value;let r=t.type.create(n,t.content,t.marks);return xe.ok(r)}getMap(){return Ie.empty}invert(t){return new Cn(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Cn(n.attr,n.value)}}Ne.jsonID("docAttr",Cn);let Zt=class extends Error{};Zt=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n};Zt.prototype=Object.create(Error.prototype);Zt.prototype.constructor=Zt;Zt.prototype.name="TransformError";const sr=Object.create(null);class ae{constructor(t,n,r){this.$anchor=t,this.$head=n,this.ranges=r||[new Wc(t.min(n),t.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let t=this.ranges;for(let n=0;n<t.length;n++)if(t[n].$from.pos!=t[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,n=X.empty){let r=n.content.lastChild,s=null;for(let o=0;o<n.openEnd;o++)s=r,r=r.lastChild;let i=t.steps.length,a=this.ranges;for(let o=0;o<a.length;o++){let{$from:c,$to:d}=a[o],u=t.mapping.slice(i);t.replaceRange(u.map(c.pos),u.map(d.pos),o?X.empty:n),o==0&&qs(t,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(t,n){let r=t.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:a,$to:o}=s[i],c=t.mapping.slice(r),d=c.map(a.pos),u=c.map(o.pos);i?t.deleteRange(d,u):(t.replaceRangeWith(d,u,n),qs(t,r,n.isInline?-1:1))}}static findFrom(t,n,r=!1){let s=t.parent.inlineContent?new ie(t):Ct(t.node(0),t.parent,t.pos,t.index(),n,r);if(s)return s;for(let i=t.depth-1;i>=0;i--){let a=n<0?Ct(t.node(0),t.node(i),t.before(i+1),t.index(i),n,r):Ct(t.node(0),t.node(i),t.after(i+1),t.index(i)+1,n,r);if(a)return a}return null}static near(t,n=1){return this.findFrom(t,n)||this.findFrom(t,-n)||new Ue(t.node(0))}static atStart(t){return Ct(t,t,0,0,1)||new Ue(t)}static atEnd(t){return Ct(t,t,t.content.size,t.childCount,-1)||new Ue(t)}static fromJSON(t,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=sr[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(t,n)}static jsonID(t,n){if(t in sr)throw new RangeError("Duplicate use of selection JSON ID "+t);return sr[t]=n,n.prototype.jsonID=t,n}getBookmark(){return ie.between(this.$anchor,this.$head).getBookmark()}}ae.prototype.visible=!0;class Wc{constructor(t,n){this.$from=t,this.$to=n}}let Hs=!1;function Us(e){!Hs&&!e.parent.inlineContent&&(Hs=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class ie extends ae{constructor(t,n=t){Us(t),Us(n),super(t,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return ae.near(r);let s=t.resolve(n.map(this.anchor));return new ie(s.parent.inlineContent?s:r,r)}replace(t,n=X.empty){if(super.replace(t,n),n==X.empty){let r=this.$from.marksAcross(this.$to);r&&t.ensureMarks(r)}}eq(t){return t instanceof ie&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new Hn(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new ie(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){let s=t.resolve(n);return new this(s,r==n?s:t.resolve(r))}static between(t,n,r){let s=t.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let i=ae.findFrom(n,r,!0)||ae.findFrom(n,-r,!0);if(i)n=i.$head;else return ae.near(n,r)}return t.parent.inlineContent||(s==0?t=n:(t=(ae.findFrom(t,-r,!0)||ae.findFrom(t,r,!0)).$anchor,t.pos<n.pos!=s<0&&(t=n))),new ie(t,n)}}ae.jsonID("text",ie);class Hn{constructor(t,n){this.anchor=t,this.head=n}map(t){return new Hn(t.map(this.anchor),t.map(this.head))}resolve(t){return ie.between(t.resolve(this.anchor),t.resolve(this.head))}}class ee extends ae{constructor(t){let n=t.nodeAfter,r=t.node(0).resolve(t.pos+n.nodeSize);super(t,r),this.node=n}map(t,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),i=t.resolve(s);return r?ae.near(i):new ee(i)}content(){return new X(Z.from(this.node),0,0)}eq(t){return t instanceof ee&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Zr(this.anchor)}static fromJSON(t,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new ee(t.resolve(n.anchor))}static create(t,n){return new ee(t.resolve(n))}static isSelectable(t){return!t.isText&&t.type.spec.selectable!==!1}}ee.prototype.visible=!1;ae.jsonID("node",ee);class Zr{constructor(t){this.anchor=t}map(t){let{deleted:n,pos:r}=t.mapResult(this.anchor);return n?new Hn(r,r):new Zr(r)}resolve(t){let n=t.resolve(this.anchor),r=n.nodeAfter;return r&&ee.isSelectable(r)?new ee(n):ae.near(n)}}class Ue extends ae{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,n=X.empty){if(n==X.empty){t.delete(0,t.doc.content.size);let r=ae.atStart(t.doc);r.eq(t.selection)||t.setSelection(r)}else super.replace(t,n)}toJSON(){return{type:"all"}}static fromJSON(t){return new Ue(t)}map(t){return new Ue(t)}eq(t){return t instanceof Ue}getBookmark(){return Kc}}ae.jsonID("all",Ue);const Kc={map(){return this},resolve(e){return new Ue(e)}};function Ct(e,t,n,r,s,i=!1){if(t.inlineContent)return ie.create(e,n);for(let a=r-(s>0?0:1);s>0?a<t.childCount:a>=0;a+=s){let o=t.child(a);if(o.isAtom){if(!i&&ee.isSelectable(o))return ee.create(e,n-(s<0?o.nodeSize:0))}else{let c=Ct(e,o,n+s,s<0?o.childCount:0,s,i);if(c)return c}n+=o.nodeSize*s}return null}function qs(e,t,n){let r=e.steps.length-1;if(r<t)return;let s=e.steps[r];if(!(s instanceof Ke||s instanceof Mt))return;let i=e.mapping.maps[r],a;i.forEach((o,c,d,u)=>{a==null&&(a=u)}),e.setSelection(ae.near(e.doc.resolve(a),n))}function Ws(e,t){return!t||!e?e:e.bind(t)}class fn{constructor(t,n,r){this.name=t,this.init=Ws(n.init,r),this.apply=Ws(n.apply,r)}}new fn("doc",{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new fn("selection",{init(e,t){return e.selection||ae.atStart(t.doc)},apply(e){return e.selection}}),new fn("storedMarks",{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new fn("scrollToSelection",{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}});function ua(e,t,n){for(let r in e){let s=e[r];s instanceof Function?s=s.bind(t):r=="handleDOMEvents"&&(s=ua(s,t,{})),n[r]=s}return n}class Un{constructor(t){this.spec=t,this.props={},t.props&&ua(t.props,this,this.props),this.key=t.key?t.key.key:fa("plugin")}getState(t){return t[this.key]}}const ir=Object.create(null);function fa(e){return e in ir?e+"$"+ ++ir[e]:(ir[e]=0,e+"$")}class Xr{constructor(t="key"){this.key=fa(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const Jc=/^```([a-z]+)?[\s\n]$/,Yc=/^~~~([a-z]+)?[\s\n]$/,Gc=V.Node.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{var t;const{languageClassPrefix:n}=this.options,i=[...((t=e.firstElementChild)===null||t===void 0?void 0:t.classList)||[]].filter(a=>a.startsWith(n)).map(a=>a.replace(n,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:e,HTMLAttributes:t}){return["pre",V.mergeAttributes(this.options.HTMLAttributes,t),["code",{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:e,$anchor:t}=this.editor.state.selection,n=t.pos===1;return!e||t.parent.type.name!==this.name?!1:n||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:t}=e,{selection:n}=t,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,a=r.parent.textContent.endsWith(`
|
|
13
13
|
|
|
14
|
-
`);return!i||!a?!1:e.chain().command(({tr:
|
|
15
|
-
`));return a.replaceSelectionWith(this.type.create({language:i},c)),a.selection.$from.parent.type!==this.type&&a.setSelection(
|
|
16
|
-
`},addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{const{selection:s,storedMarks:i}=n;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:a}=this.options,{splittableMarks:l}=r.extensionManager,c=i||s.$to.parentOffset&&s.$from.marks();return t().insertContent({type:this.name}).command(({tr:d,dispatch:u})=>{if(u&&c&&a){const f=c.filter(p=>l.includes(p.type.name));d.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var pn=200,be=function(){};be.prototype.append=function(t){return t.length?(t=be.from(t),!this.length&&t||t.length<pn&&this.leafAppend(t)||this.length<pn&&t.leafPrepend(this)||this.appendInner(t)):this};be.prototype.prepend=function(t){return t.length?be.from(t).append(this):this};be.prototype.appendInner=function(t){return new Vc(this,t)};be.prototype.slice=function(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.length),t>=n?be.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,n))};be.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)};be.prototype.forEach=function(t,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(t,n,r,0):this.forEachInvertedInner(t,n,r,0)};be.prototype.map=function(t,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,a){return s.push(t(i,a))},n,r),s};be.from=function(t){return t instanceof be?t:t&&t.length?new ia(t):be.empty};var ia=(function(e){function t(r){e.call(this),this.values=r}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(s,i){return s==0&&i==this.length?this:new t(this.values.slice(s,i))},t.prototype.getInner=function(s){return this.values[s]},t.prototype.forEachInner=function(s,i,a,l){for(var c=i;c<a;c++)if(s(this.values[c],l+c)===!1)return!1},t.prototype.forEachInvertedInner=function(s,i,a,l){for(var c=i-1;c>=a;c--)if(s(this.values[c],l+c)===!1)return!1},t.prototype.leafAppend=function(s){if(this.length+s.length<=pn)return new t(this.values.concat(s.flatten()))},t.prototype.leafPrepend=function(s){if(this.length+s.length<=pn)return new t(s.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t})(be);be.empty=new ia([]);var Vc=(function(e){function t(n,r){e.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},t.prototype.forEachInner=function(r,s,i,a){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(i,l),a)===!1||i>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,i)-l,a+l)===!1)return!1},t.prototype.forEachInvertedInner=function(r,s,i,a){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(i,l)-l,a+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(s,l),i,a)===!1)return!1},t.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(r,s):r>=i?this.right.slice(r-i,s-i):this.left.slice(r,i).append(this.right.slice(0,s-i))},t.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new t(this.left,s)},t.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new t(s,this.right)},t.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new t(this.left,new t(this.right,r)):new t(this,r)},t})(be);const Hc=500;class Fe{constructor(t,n){this.items=t,this.eventCount=n}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,i;n&&(s=this.remapping(r,this.items.length),i=s.maps.length);let a=t.tr,l,c,d=[],u=[];return this.items.forEach((f,p)=>{if(!f.step){s||(s=this.remapping(r,p+1),i=s.maps.length),i--,u.push(f);return}if(s){u.push(new Be(f.map));let m=f.step.map(s.slice(i)),v;m&&a.maybeStep(m).doc&&(v=a.mapping.maps[a.mapping.maps.length-1],d.push(new Be(v,void 0,void 0,d.length+u.length))),i--,v&&s.appendMap(v,i)}else a.maybeStep(f.step);if(f.selection)return l=s?f.selection.map(s.slice(i)):f.selection,c=new Fe(this.items.slice(0,r).append(u.reverse().concat(d)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:a,selection:l}}addTransform(t,n,r,s){let i=[],a=this.eventCount,l=this.items,c=!s&&l.length?l.get(l.length-1):null;for(let u=0;u<t.steps.length;u++){let f=t.steps[u].invert(t.docs[u]),p=new Be(t.mapping.maps[u],f,n),m;(m=c&&c.merge(p))&&(p=m,u?i.pop():l=l.slice(0,l.length-1)),i.push(p),n&&(a++,n=void 0),s||(c=p)}let d=a-r.depth;return d>qc&&(l=Uc(l,d),a-=d),new Fe(l.append(i),a)}remapping(t,n){let r=new hn;return this.items.forEach((s,i)=>{let a=s.mirrorOffset!=null&&i-s.mirrorOffset>=t?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,a)},t,n),r}addMaps(t){return this.eventCount==0?this:new Fe(this.items.append(t.map(n=>new Be(n))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-n),i=t.mapping,a=t.steps.length,l=this.eventCount;this.items.forEach(p=>{p.selection&&l--},s);let c=n;this.items.forEach(p=>{let m=i.getMirror(--c);if(m==null)return;a=Math.min(a,m);let v=i.maps[m];if(p.step){let b=t.steps[m].invert(t.docs[m]),x=p.selection&&p.selection.map(i.slice(c+1,m));x&&l++,r.push(new Be(v,b,x))}else r.push(new Be(v))},s);let d=[];for(let p=n;p<a;p++)d.push(new Be(i.maps[p]));let u=this.items.slice(0,s).append(d).append(r),f=new Fe(u,l);return f.emptyItemCount()>Hc&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let t=0;return this.items.forEach(n=>{n.step||t++}),t}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,s=[],i=0;return this.items.forEach((a,l)=>{if(l>=t)s.push(a),a.selection&&i++;else if(a.step){let c=a.step.map(n.slice(r)),d=c&&c.getMap();if(r--,d&&n.appendMap(d,r),c){let u=a.selection&&a.selection.map(n.slice(r));u&&i++;let f=new Be(d.invert(),c,u),p,m=s.length-1;(p=s.length&&s[m].merge(f))?s[m]=p:s.push(f)}}else a.map&&r--},this.items.length,0),new Fe(be.from(s.reverse()),i)}}Fe.empty=new Fe(be.empty,0);function Uc(e,t){let n;return e.forEach((r,s)=>{if(r.selection&&t--==0)return n=s,!1}),e.slice(n)}class Be{constructor(t,n,r,s){this.map=t,this.step=n,this.selection=r,this.mirrorOffset=s}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new Be(n.getMap().invert(),n,this.selection)}}}class Ge{constructor(t,n,r,s,i){this.done=t,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const qc=20;function Wc(e,t,n,r){let s=n.getMeta(ft),i;if(s)return s.historyState;n.getMeta(Yc)&&(e=new Ge(e.done,e.undone,null,0,-1));let a=n.getMeta("appendedTransaction");if(n.steps.length==0)return e;if(a&&a.getMeta(ft))return a.getMeta(ft).redo?new Ge(e.done.addTransform(n,void 0,r,on(t)),e.undone,Vs(n.mapping.maps),e.prevTime,e.prevComposition):new Ge(e.done,e.undone.addTransform(n,void 0,r,on(t)),null,e.prevTime,e.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(a&&a.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),c=e.prevTime==0||!a&&e.prevComposition!=l&&(e.prevTime<(n.time||0)-r.newGroupDelay||!Kc(n,e.prevRanges)),d=a?Zn(e.prevRanges,n.mapping):Vs(n.mapping.maps);return new Ge(e.done.addTransform(n,c?t.selection.getBookmark():void 0,r,on(t)),Fe.empty,d,n.time,l??e.prevComposition)}else return(i=n.getMeta("rebased"))?new Ge(e.done.rebased(n,i),e.undone.rebased(n,i),Zn(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new Ge(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),Zn(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function Kc(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<t.length;i+=2)r<=t[i+1]&&s>=t[i]&&(n=!0)}),n}function Vs(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((r,s,i,a)=>t.push(i,a));return t}function Zn(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let s=t.map(e[r],1),i=t.map(e[r+1],-1);s<=i&&n.push(s,i)}return n}function Jc(e,t,n){let r=on(t),s=ft.get(t).spec.config,i=(n?e.undone:e.done).popEvent(t,r);if(!i)return null;let a=i.selection.resolve(i.transform.doc),l=(n?e.done:e.undone).addTransform(i.transform,t.selection.getBookmark(),s,r),c=new Ge(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(a).setMeta(ft,{redo:n,historyState:c})}let Xn=!1,Hs=null;function on(e){let t=e.plugins;if(Hs!=t){Xn=!1,Hs=t;for(let n=0;n<t.length;n++)if(t[n].spec.historyPreserveItems){Xn=!0;break}}return Xn}const ft=new Hr("history"),Yc=new Hr("closeHistory");function Gc(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new In({key:ft,state:{init(){return new Ge(Fe.empty,Fe.empty,null,0,-1)},apply(t,n,r){return Wc(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(t,n){let r=n.inputType,s=r=="historyUndo"?la:r=="historyRedo"?oa:null;return!s||!t.editable?!1:(n.preventDefault(),s(t.state,t.dispatch))}}}})}function aa(e,t){return(n,r)=>{let s=ft.getState(n);if(!s||(e?s.undone:s.done).eventCount==0)return!1;if(r){let i=Jc(s,n,e);i&&r(t?i.scrollIntoView():i)}return!0}}const la=aa(!1,!0),oa=aa(!0,!0),Us=z.Extension.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>la(e,t),redo:()=>({state:e,dispatch:t})=>oa(e,t)}},addProseMirrorPlugins(){return[Gc(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),Qc=z.Node.create({name:"doc",topNode:!0,content:"block+"}),Zc=z.Node.create({name:"text",group:"inline"});function Xc(e={}){return new In({view(t){return new ed(t,e)}})}class ed{constructor(t,n){var r;this.editorView=t,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let i=a=>{this[s](a)};return t.dom.addEventListener(s,i),{name:s,handler:i}})}destroy(){this.handlers.forEach(({name:t,handler:n})=>this.editorView.dom.removeEventListener(t,n))}update(t,n){this.cursorPos!=null&&n.doc!=t.state.doc&&(this.cursorPos>t.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(t){t!=this.cursorPos&&(this.cursorPos=t,t==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let t=this.editorView.state.doc.resolve(this.cursorPos),n=!t.parent.inlineContent,r,s=this.editorView.dom,i=s.getBoundingClientRect(),a=i.width/s.offsetWidth,l=i.height/s.offsetHeight;if(n){let f=t.nodeBefore,p=t.nodeAfter;if(f||p){let m=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(m){let v=m.getBoundingClientRect(),b=f?v.bottom:v.top;f&&p&&(b=(b+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let x=this.width/2*l;r={left:v.left,right:v.right,top:b-x,bottom:b+x}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*a;r={left:f.left-p,right:f.left+p,top:f.top,bottom:f.bottom}}let c=this.editorView.dom.offsetParent;this.element||(this.element=c.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let d,u;if(!c||c==document.body&&getComputedStyle(c).position=="static")d=-pageXOffset,u=-pageYOffset;else{let f=c.getBoundingClientRect(),p=f.width/c.offsetWidth,m=f.height/c.offsetHeight;d=f.left-c.scrollLeft*p,u=f.top-c.scrollTop*m}this.element.style.left=(r.left-d)/a+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/a+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(t){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),t)}dragover(t){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:t.clientX,top:t.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),s=r&&r.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,n,t):s;if(n&&!i){let a=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=na(this.editorView.state.doc,a,this.editorView.dragging.slice);l!=null&&(a=l)}this.setCursor(a),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){this.editorView.dom.contains(t.relatedTarget)||this.setCursor(null)}}const td=z.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Xc(this.options)]}});var nt={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},gn={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},nd=typeof navigator<"u"&&/Mac/.test(navigator.platform),rd=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ve=0;ve<10;ve++)nt[48+ve]=nt[96+ve]=String(ve);for(var ve=1;ve<=24;ve++)nt[ve+111]="F"+ve;for(var ve=65;ve<=90;ve++)nt[ve]=String.fromCharCode(ve+32),gn[ve]=String.fromCharCode(ve);for(var er in nt)gn.hasOwnProperty(er)||(gn[er]=nt[er]);function sd(e){var t=nd&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||rd&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",n=!t&&e.key||(e.shiftKey?gn:nt)[e.keyCode]||e.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const id=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),ad=typeof navigator<"u"&&/Win/.test(navigator.platform);function ld(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n=="Space"&&(n=" ");let r,s,i,a;for(let l=0;l<t.length-1;l++){let c=t[l];if(/^(cmd|meta|m)$/i.test(c))a=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))s=!0;else if(/^s(hift)?$/i.test(c))i=!0;else if(/^mod$/i.test(c))id?a=!0:s=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),a&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function od(e){let t=Object.create(null);for(let n in e)t[ld(n)]=e[n];return t}function tr(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function cd(e){let t=od(e);return function(n,r){let s=sd(r),i,a=t[tr(s,r)];if(a&&a(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=t[tr(s,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(ad&&r.ctrlKey&&r.altKey)&&(i=nt[r.keyCode])&&i!=s){let l=t[tr(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}const gt=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},ca=function(e,t,n,r){return n&&(qs(e,t,n,r,-1)||qs(e,t,n,r,1))},dd=/^(img|br|input|textarea|hr)$/i;function qs(e,t,n,r,s){for(var i;;){if(e==n&&t==r)return!0;if(t==(s<0?0:xn(e))){let a=e.parentNode;if(!a||a.nodeType!=1||Ur(e)||dd.test(e.nodeName)||e.contentEditable=="false")return!1;t=gt(e)+(s<0?0:1),e=a}else if(e.nodeType==1){let a=e.childNodes[t+(s<0?-1:0)];if(a.nodeType==1&&a.contentEditable=="false")if(!((i=a.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)t+=s;else return!1;else e=a,t=s<0?xn(e):0}else return!1}}function xn(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function ud(e,t,n){for(let r=t==0,s=t==xn(e);r||s;){if(e==n)return!0;let i=gt(e);if(e=e.parentNode,!e)return!1;r=r&&i==0,s=s&&i==xn(e)}}function Ur(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const da=function(e){return e.focusNode&&ca(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function ua(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}const He=typeof navigator<"u"?navigator:null,Ws=typeof document<"u"?document:null,rt=He&&He.userAgent||"",vr=/Edge\/(\d+)/.exec(rt),fa=/MSIE \d/.exec(rt),wr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(rt),Jt=!!(fa||wr||vr),ha=fa?document.documentMode:wr?+wr[1]:vr?+vr[1]:0,$n=!Jt&&/gecko\/(\d+)/i.test(rt);$n&&+(/Firefox\/(\d+)/.exec(rt)||[0,0])[1];const kr=!Jt&&/Chrome\/(\d+)/.exec(rt),Ke=!!kr,ma=kr?+kr[1]:0,xt=!Jt&&!!He&&/Apple Computer/.test(He.vendor),qr=xt&&(/Mobile\/\w+/.test(rt)||!!He&&He.maxTouchPoints>2),$e=qr||(He?/Mac/.test(He.platform):!1),pa=He?/Win/.test(He.platform):!1,Yt=/Android \d/.test(rt),Wr=!!Ws&&"webkitFontSmoothing"in Ws.documentElement.style,fd=Wr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function hd(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let s=e.docView.nearestDesc(n.focusNode),i=s&&s.size==0,a=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(a<0)return null;let l=r.resolve(a),c,d;if(da(n)){for(c=a;s&&!s.node;)s=s.parent;let f=s.node;if(s&&f.isAtom&&Z.isSelectable(f)&&s.parent&&!(f.isInline&&ud(n.focusNode,n.focusOffset,s.dom))){let p=s.posBefore;d=new Z(a==p?l:r.resolve(p))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=a,p=a;for(let m=0;m<n.rangeCount;m++){let v=n.getRangeAt(m);f=Math.min(f,e.docView.posFromDOM(v.startContainer,v.startOffset,1)),p=Math.max(p,e.docView.posFromDOM(v.endContainer,v.endOffset,-1))}if(f<0)return null;[c,a]=p==e.state.selection.anchor?[p,f]:[f,p],l=r.resolve(a)}else c=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let u=r.resolve(c);if(!d){let f=t=="pointer"||e.state.selection.head<l.pos&&!i?1:-1;d=xa(e,u,l,f)}return d}function ga(e){return e.editable?e.hasFocus():xd(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function Kr(e,t=!1){let n=e.state.selection;if(gd(e,n),!!ga(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&Ke){let r=e.domSelectionRange(),s=e.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&ca(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){e.input.mouseDown.delayedSelectionSync=!0,e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)pd(e);else{let{anchor:r,head:s}=n,i,a;Ks&&!(n instanceof ne)&&(n.$from.parent.inlineContent||(i=Js(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(a=Js(e,n.to))),e.docView.setSelection(r,s,e,t),Ks&&(i&&Ys(i),a&&Ys(a)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&md(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}const Ks=xt||Ke&&ma<63;function Js(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),s=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(xt&&s&&s.contentEditable=="false")return nr(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return nr(s);if(i)return nr(i)}}function nr(e){return e.contentEditable="true",xt&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function Ys(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function md(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,s=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=s)&&(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!ga(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}function pd(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName=="IMG";r?t.collapse(n.parentNode,gt(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&Jt&&ha<=11&&(n.disabled=!0,n.disabled=!1)}function gd(e,t){if(t instanceof Z){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(Gs(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else Gs(e)}function Gs(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function xa(e,t,n,r){return e.someProp("createSelectionBetween",s=>s(e,t,n))||ne.between(t,n,r)}function xd(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function Nr(e,t){let{$anchor:n,$head:r}=e.selection,s=t>0?n.max(r):n.min(r),i=s.parent.inlineContent?s.depth?e.doc.resolve(t>0?s.after():s.before()):null:s;return i&&re.findFrom(i,t)}function Qe(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Qs(e,t,n){let r=e.state.selection;if(r instanceof ne)if(n.indexOf("s")>-1){let{$head:s}=r,i=s.textOffset?null:t<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let a=e.state.doc.resolve(s.pos+i.nodeSize*(t<0?-1:1));return Qe(e,new ne(r.$anchor,a))}else if(r.empty){if(e.endOfTextblock(t>0?"forward":"backward")){let s=Nr(e.state,t);return s&&s instanceof Z?Qe(e,s):!1}else if(!($e&&n.indexOf("m")>-1)){let s=r.$head,i=s.textOffset?null:t<0?s.nodeBefore:s.nodeAfter,a;if(!i||i.isText)return!1;let l=t<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(a=e.docView.descAt(l))&&!a.contentDOM?Z.isSelectable(i)?Qe(e,new Z(t<0?e.state.doc.resolve(s.pos-i.nodeSize):s)):Wr?Qe(e,new ne(e.state.doc.resolve(t<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Z&&r.node.isInline)return Qe(e,new ne(t>0?r.$to:r.$from));{let s=Nr(e.state,t);return s?Qe(e,s):!1}}}function yn(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function Ft(e,t){let n=e.pmViewDesc;return n&&n.size==0&&(t<0||e.nextSibling||e.nodeName!="BR")}function yt(e,t){return t<0?yd(e):bd(e)}function yd(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let s,i,a=!1;for($n&&n.nodeType==1&&r<yn(n)&&Ft(n.childNodes[r],-1)&&(a=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(Ft(l,-1))s=n,i=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(ya(n))break;{let l=n.previousSibling;for(;l&&Ft(l,-1);)s=n.parentNode,i=gt(l),l=l.previousSibling;if(l)n=l,r=yn(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}a?Sr(e,n,r):s&&Sr(e,s,i)}function bd(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let s=yn(n),i,a;for(;;)if(r<s){if(n.nodeType!=1)break;let l=n.childNodes[r];if(Ft(l,1))i=n,a=++r;else break}else{if(ya(n))break;{let l=n.nextSibling;for(;l&&Ft(l,1);)i=l.parentNode,a=gt(l)+1,l=l.nextSibling;if(l)n=l,r=0,s=yn(n);else{if(n=n.parentNode,n==e.dom)break;r=s=0}}}i&&Sr(e,i,a)}function ya(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function vd(e,t){for(;e&&t==e.childNodes.length&&!Ur(e);)t=gt(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;e=n,t=0}}function wd(e,t){for(;e&&!t&&!Ur(e);)t=gt(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;e=n,t=e.childNodes.length}}function Sr(e,t,n){if(t.nodeType!=3){let i,a;(a=vd(t,n))?(t=a,n=0):(i=wd(t,n))&&(t=i,n=i.nodeValue.length)}let r=e.domSelection();if(!r)return;if(da(r)){let i=document.createRange();i.setEnd(t,n),i.setStart(t,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:s}=e;setTimeout(()=>{e.state==s&&Kr(e)},50)}function Zs(e,t){let n=e.state.doc.resolve(t);if(!(Ke||pa)&&n.parent.inlineContent){let s=e.coordsAtPos(t);if(t>n.start()){let i=e.coordsAtPos(t-1),a=(i.top+i.bottom)/2;if(a>s.top&&a<s.bottom&&Math.abs(i.left-s.left)>1)return i.left<s.left?"ltr":"rtl"}if(t<n.end()){let i=e.coordsAtPos(t+1),a=(i.top+i.bottom)/2;if(a>s.top&&a<s.bottom&&Math.abs(i.left-s.left)>1)return i.left>s.left?"ltr":"rtl"}}return getComputedStyle(e.dom).direction=="rtl"?"rtl":"ltr"}function Xs(e,t,n){let r=e.state.selection;if(r instanceof ne&&!r.empty||n.indexOf("s")>-1||$e&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let a=Nr(e.state,t);if(a&&a instanceof Z)return Qe(e,a)}if(!s.parent.inlineContent){let a=t<0?s:i,l=r instanceof Ve?re.near(a,t):re.findFrom(a,t);return l?Qe(e,l):!1}return!1}function ei(e,t){if(!(e.state.selection instanceof ne))return!0;let{$head:n,$anchor:r,empty:s}=e.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let i=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let a=e.state.tr;return t<0?a.delete(n.pos-i.nodeSize,n.pos):a.delete(n.pos,n.pos+i.nodeSize),e.dispatch(a),!0}return!1}function ti(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function kd(e){if(!xt||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&t.nodeType==1&&n==0&&t.firstChild&&t.firstChild.contentEditable=="false"){let r=t.firstChild;ti(e,r,"true"),setTimeout(()=>ti(e,r,"false"),20)}return!1}function Nd(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}function Sd(e,t){let n=t.keyCode,r=Nd(t);if(n==8||$e&&n==72&&r=="c")return ei(e,-1)||yt(e,-1);if(n==46&&!t.shiftKey||$e&&n==68&&r=="c")return ei(e,1)||yt(e,1);if(n==13||n==27)return!0;if(n==37||$e&&n==66&&r=="c"){let s=n==37?Zs(e,e.state.selection.from)=="ltr"?-1:1:-1;return Qs(e,s,r)||yt(e,s)}else if(n==39||$e&&n==70&&r=="c"){let s=n==39?Zs(e,e.state.selection.from)=="ltr"?1:-1:1;return Qs(e,s,r)||yt(e,s)}else{if(n==38||$e&&n==80&&r=="c")return Xs(e,-1,r)||yt(e,-1);if(n==40||$e&&n==78&&r=="c")return kd(e)||Xs(e,1,r)||yt(e,1);if(r==($e?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function ba(e,t){e.someProp("transformCopied",m=>{t=m(t,e)});let n=[],{content:r,openStart:s,openEnd:i}=t;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let m=r.firstChild;n.push(m.type.name,m.attrs!=m.type.defaultAttrs?m.attrs:null),r=m.content}let a=e.someProp("clipboardSerializer")||Tn.fromSchema(e.state.schema),l=Ca(),c=l.createElement("div");c.appendChild(a.serializeFragment(r,{document:l}));let d=c.firstChild,u,f=0;for(;d&&d.nodeType==1&&(u=Sa[d.nodeName.toLowerCase()]);){for(let m=u.length-1;m>=0;m--){let v=l.createElement(u[m]);for(;c.firstChild;)v.appendChild(c.firstChild);c.appendChild(v),f++}d=c.firstChild}d&&d.nodeType==1&&d.setAttribute("data-pm-slice",`${s} ${i}${f?` -${f}`:""} ${JSON.stringify(n)}`);let p=e.someProp("clipboardTextSerializer",m=>m(t,e))||t.content.textBetween(0,t.content.size,`
|
|
14
|
+
`);return!i||!a?!1:e.chain().command(({tr:o})=>(o.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;const{state:t}=e,{selection:n,doc:r}=t,{$from:s,empty:i}=n;if(!i||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const o=s.after();return o===void 0?!1:r.nodeAt(o)?e.commands.command(({tr:d})=>(d.setSelection(ae.near(r.resolve(o))),!0)):e.commands.exitCode()}}},addInputRules(){return[V.textblockTypeInputRule({find:Jc,type:this.type,getAttributes:e=>({language:e[1]})}),V.textblockTypeInputRule({find:Yc,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new Un({key:new Xr("codeBlockVSCodeHandler"),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;const n=t.clipboardData.getData("text/plain"),r=t.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s?.mode;if(!n||!i)return!1;const{tr:a,schema:o}=e.state,c=o.text(n.replace(/\r\n?/g,`
|
|
15
|
+
`));return a.replaceSelectionWith(this.type.create({language:i},c)),a.selection.$from.parent.type!==this.type&&a.setSelection(ie.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta("paste",!0),e.dispatch(a),!0}}})]}}),Qc=/^\s*>\s$/,Zc=V.Node.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return["blockquote",V.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[V.wrappingInputRule({find:Qc,type:this.type})]}}),Xc=V.Node.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:e}){return["hr",V.mergeAttributes(this.options.HTMLAttributes,e)]},addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!V.canInsertNode(t,t.schema.nodes[this.name]))return!1;const{selection:n}=t,{$from:r,$to:s}=n,i=e();return r.parentOffset===0?i.insertContentAt({from:Math.max(r.pos-1,0),to:s.pos},{type:this.name}):V.isNodeSelection(n)?i.insertContentAt(s.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({tr:a,dispatch:o})=>{var c;if(o){const{$to:d}=a.selection,u=d.end();if(d.nodeAfter)d.nodeAfter.isTextblock?a.setSelection(ie.create(a.doc,d.pos+1)):d.nodeAfter.isBlock?a.setSelection(ee.create(a.doc,d.pos)):a.setSelection(ie.create(a.doc,d.pos));else{const h=(c=d.parent.type.contentMatch.defaultType)===null||c===void 0?void 0:c.create();h&&(a.insert(u,h),a.setSelection(ie.create(a.doc,u+1)))}a.scrollIntoView()}return!0}).run()}}},addInputRules(){return[V.nodeInputRule({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),ed=V.Node.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:e}){return["br",V.mergeAttributes(this.options.HTMLAttributes,e)]},renderText(){return`
|
|
16
|
+
`},addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{const{selection:s,storedMarks:i}=n;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:a}=this.options,{splittableMarks:o}=r.extensionManager,c=i||s.$to.parentOffset&&s.$from.marks();return t().insertContent({type:this.name}).command(({tr:d,dispatch:u})=>{if(u&&c&&a){const h=c.filter(p=>o.includes(p.type.name));d.ensureMarks(h)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var jn=200,ve=function(){};ve.prototype.append=function(t){return t.length?(t=ve.from(t),!this.length&&t||t.length<jn&&this.leafAppend(t)||this.length<jn&&t.leafPrepend(this)||this.appendInner(t)):this};ve.prototype.prepend=function(t){return t.length?ve.from(t).append(this):this};ve.prototype.appendInner=function(t){return new td(this,t)};ve.prototype.slice=function(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.length),t>=n?ve.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,n))};ve.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)};ve.prototype.forEach=function(t,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(t,n,r,0):this.forEachInvertedInner(t,n,r,0)};ve.prototype.map=function(t,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,a){return s.push(t(i,a))},n,r),s};ve.from=function(t){return t instanceof ve?t:t&&t.length?new ha(t):ve.empty};var ha=(function(e){function t(r){e.call(this),this.values=r}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(s,i){return s==0&&i==this.length?this:new t(this.values.slice(s,i))},t.prototype.getInner=function(s){return this.values[s]},t.prototype.forEachInner=function(s,i,a,o){for(var c=i;c<a;c++)if(s(this.values[c],o+c)===!1)return!1},t.prototype.forEachInvertedInner=function(s,i,a,o){for(var c=i-1;c>=a;c--)if(s(this.values[c],o+c)===!1)return!1},t.prototype.leafAppend=function(s){if(this.length+s.length<=jn)return new t(this.values.concat(s.flatten()))},t.prototype.leafPrepend=function(s){if(this.length+s.length<=jn)return new t(s.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t})(ve);ve.empty=new ha([]);var td=(function(e){function t(n,r){e.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},t.prototype.forEachInner=function(r,s,i,a){var o=this.left.length;if(s<o&&this.left.forEachInner(r,s,Math.min(i,o),a)===!1||i>o&&this.right.forEachInner(r,Math.max(s-o,0),Math.min(this.length,i)-o,a+o)===!1)return!1},t.prototype.forEachInvertedInner=function(r,s,i,a){var o=this.left.length;if(s>o&&this.right.forEachInvertedInner(r,s-o,Math.max(i,o)-o,a+o)===!1||i<o&&this.left.forEachInvertedInner(r,Math.min(s,o),i,a)===!1)return!1},t.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(r,s):r>=i?this.right.slice(r-i,s-i):this.left.slice(r,i).append(this.right.slice(0,s-i))},t.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new t(this.left,s)},t.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new t(s,this.right)},t.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new t(this.left,new t(this.right,r)):new t(this,r)},t})(ve);const nd=500;class Re{constructor(t,n){this.items=t,this.eventCount=n}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,i;n&&(s=this.remapping(r,this.items.length),i=s.maps.length);let a=t.tr,o,c,d=[],u=[];return this.items.forEach((h,p)=>{if(!h.step){s||(s=this.remapping(r,p+1),i=s.maps.length),i--,u.push(h);return}if(s){u.push(new Ve(h.map));let m=h.step.map(s.slice(i)),v;m&&a.maybeStep(m).doc&&(v=a.mapping.maps[a.mapping.maps.length-1],d.push(new Ve(v,void 0,void 0,d.length+u.length))),i--,v&&s.appendMap(v,i)}else a.maybeStep(h.step);if(h.selection)return o=s?h.selection.map(s.slice(i)):h.selection,c=new Re(this.items.slice(0,r).append(u.reverse().concat(d)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:a,selection:o}}addTransform(t,n,r,s){let i=[],a=this.eventCount,o=this.items,c=!s&&o.length?o.get(o.length-1):null;for(let u=0;u<t.steps.length;u++){let h=t.steps[u].invert(t.docs[u]),p=new Ve(t.mapping.maps[u],h,n),m;(m=c&&c.merge(p))&&(p=m,u?i.pop():o=o.slice(0,o.length-1)),i.push(p),n&&(a++,n=void 0),s||(c=p)}let d=a-r.depth;return d>sd&&(o=rd(o,d),a-=d),new Re(o.append(i),a)}remapping(t,n){let r=new Sn;return this.items.forEach((s,i)=>{let a=s.mirrorOffset!=null&&i-s.mirrorOffset>=t?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,a)},t,n),r}addMaps(t){return this.eventCount==0?this:new Re(this.items.append(t.map(n=>new Ve(n))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-n),i=t.mapping,a=t.steps.length,o=this.eventCount;this.items.forEach(p=>{p.selection&&o--},s);let c=n;this.items.forEach(p=>{let m=i.getMirror(--c);if(m==null)return;a=Math.min(a,m);let v=i.maps[m];if(p.step){let b=t.steps[m].invert(t.docs[m]),x=p.selection&&p.selection.map(i.slice(c+1,m));x&&o++,r.push(new Ve(v,b,x))}else r.push(new Ve(v))},s);let d=[];for(let p=n;p<a;p++)d.push(new Ve(i.maps[p]));let u=this.items.slice(0,s).append(d).append(r),h=new Re(u,o);return h.emptyItemCount()>nd&&(h=h.compress(this.items.length-r.length)),h}emptyItemCount(){let t=0;return this.items.forEach(n=>{n.step||t++}),t}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,s=[],i=0;return this.items.forEach((a,o)=>{if(o>=t)s.push(a),a.selection&&i++;else if(a.step){let c=a.step.map(n.slice(r)),d=c&&c.getMap();if(r--,d&&n.appendMap(d,r),c){let u=a.selection&&a.selection.map(n.slice(r));u&&i++;let h=new Ve(d.invert(),c,u),p,m=s.length-1;(p=s.length&&s[m].merge(h))?s[m]=p:s.push(h)}}else a.map&&r--},this.items.length,0),new Re(ve.from(s.reverse()),i)}}Re.empty=new Re(ve.empty,0);function rd(e,t){let n;return e.forEach((r,s)=>{if(r.selection&&t--==0)return n=s,!1}),e.slice(n)}class Ve{constructor(t,n,r,s){this.map=t,this.step=n,this.selection=r,this.mirrorOffset=s}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new Ve(n.getMap().invert(),n,this.selection)}}}class Ze{constructor(t,n,r,s,i){this.done=t,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const sd=20;function id(e,t,n,r){let s=n.getMeta(pt),i;if(s)return s.historyState;n.getMeta(od)&&(e=new Ze(e.done,e.undone,null,0,-1));let a=n.getMeta("appendedTransaction");if(n.steps.length==0)return e;if(a&&a.getMeta(pt))return a.getMeta(pt).redo?new Ze(e.done.addTransform(n,void 0,r,bn(t)),e.undone,Ks(n.mapping.maps),e.prevTime,e.prevComposition):new Ze(e.done,e.undone.addTransform(n,void 0,r,bn(t)),null,e.prevTime,e.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(a&&a.getMeta("addToHistory")===!1)){let o=n.getMeta("composition"),c=e.prevTime==0||!a&&e.prevComposition!=o&&(e.prevTime<(n.time||0)-r.newGroupDelay||!ad(n,e.prevRanges)),d=a?ar(e.prevRanges,n.mapping):Ks(n.mapping.maps);return new Ze(e.done.addTransform(n,c?t.selection.getBookmark():void 0,r,bn(t)),Re.empty,d,n.time,o??e.prevComposition)}else return(i=n.getMeta("rebased"))?new Ze(e.done.rebased(n,i),e.undone.rebased(n,i),ar(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new Ze(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),ar(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function ad(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<t.length;i+=2)r<=t[i+1]&&s>=t[i]&&(n=!0)}),n}function Ks(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((r,s,i,a)=>t.push(i,a));return t}function ar(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let s=t.map(e[r],1),i=t.map(e[r+1],-1);s<=i&&n.push(s,i)}return n}function ld(e,t,n){let r=bn(t),s=pt.get(t).spec.config,i=(n?e.undone:e.done).popEvent(t,r);if(!i)return null;let a=i.selection.resolve(i.transform.doc),o=(n?e.done:e.undone).addTransform(i.transform,t.selection.getBookmark(),s,r),c=new Ze(n?o:i.remaining,n?i.remaining:o,null,0,-1);return i.transform.setSelection(a).setMeta(pt,{redo:n,historyState:c})}let lr=!1,Js=null;function bn(e){let t=e.plugins;if(Js!=t){lr=!1,Js=t;for(let n=0;n<t.length;n++)if(t[n].spec.historyPreserveItems){lr=!0;break}}return lr}const pt=new Xr("history"),od=new Xr("closeHistory");function cd(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new Un({key:pt,state:{init(){return new Ze(Re.empty,Re.empty,null,0,-1)},apply(t,n,r){return id(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(t,n){let r=n.inputType,s=r=="historyUndo"?pa:r=="historyRedo"?ga:null;return!s||!t.editable?!1:(n.preventDefault(),s(t.state,t.dispatch))}}}})}function ma(e,t){return(n,r)=>{let s=pt.getState(n);if(!s||(e?s.undone:s.done).eventCount==0)return!1;if(r){let i=ld(s,n,e);i&&r(t?i.scrollIntoView():i)}return!0}}const pa=ma(!1,!0),ga=ma(!0,!0),Ys=V.Extension.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>pa(e,t),redo:()=>({state:e,dispatch:t})=>ga(e,t)}},addProseMirrorPlugins(){return[cd(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),dd=V.Node.create({name:"doc",topNode:!0,content:"block+"}),ud=V.Node.create({name:"text",group:"inline"});function fd(e={}){return new Un({view(t){return new hd(t,e)}})}class hd{constructor(t,n){var r;this.editorView=t,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let i=a=>{this[s](a)};return t.dom.addEventListener(s,i),{name:s,handler:i}})}destroy(){this.handlers.forEach(({name:t,handler:n})=>this.editorView.dom.removeEventListener(t,n))}update(t,n){this.cursorPos!=null&&n.doc!=t.state.doc&&(this.cursorPos>t.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(t){t!=this.cursorPos&&(this.cursorPos=t,t==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let t=this.editorView.state.doc.resolve(this.cursorPos),n=!t.parent.inlineContent,r,s=this.editorView.dom,i=s.getBoundingClientRect(),a=i.width/s.offsetWidth,o=i.height/s.offsetHeight;if(n){let h=t.nodeBefore,p=t.nodeAfter;if(h||p){let m=this.editorView.nodeDOM(this.cursorPos-(h?h.nodeSize:0));if(m){let v=m.getBoundingClientRect(),b=h?v.bottom:v.top;h&&p&&(b=(b+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let x=this.width/2*o;r={left:v.left,right:v.right,top:b-x,bottom:b+x}}}}if(!r){let h=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*a;r={left:h.left-p,right:h.left+p,top:h.top,bottom:h.bottom}}let c=this.editorView.dom.offsetParent;this.element||(this.element=c.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let d,u;if(!c||c==document.body&&getComputedStyle(c).position=="static")d=-pageXOffset,u=-pageYOffset;else{let h=c.getBoundingClientRect(),p=h.width/c.offsetWidth,m=h.height/c.offsetHeight;d=h.left-c.scrollLeft*p,u=h.top-c.scrollTop*m}this.element.style.left=(r.left-d)/a+"px",this.element.style.top=(r.top-u)/o+"px",this.element.style.width=(r.right-r.left)/a+"px",this.element.style.height=(r.bottom-r.top)/o+"px"}scheduleRemoval(t){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),t)}dragover(t){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:t.clientX,top:t.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),s=r&&r.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,n,t):s;if(n&&!i){let a=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let o=da(this.editorView.state.doc,a,this.editorView.dragging.slice);o!=null&&(a=o)}this.setCursor(a),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){this.editorView.dom.contains(t.relatedTarget)||this.setCursor(null)}}const md=V.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[fd(this.options)]}});var st={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},An={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},pd=typeof navigator<"u"&&/Mac/.test(navigator.platform),gd=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var we=0;we<10;we++)st[48+we]=st[96+we]=String(we);for(var we=1;we<=24;we++)st[we+111]="F"+we;for(var we=65;we<=90;we++)st[we]=String.fromCharCode(we+32),An[we]=String.fromCharCode(we);for(var or in st)An.hasOwnProperty(or)||(An[or]=st[or]);function xd(e){var t=pd&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||gd&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",n=!t&&e.key||(e.shiftKey?An:st)[e.keyCode]||e.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const yd=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),bd=typeof navigator<"u"&&/Win/.test(navigator.platform);function vd(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n=="Space"&&(n=" ");let r,s,i,a;for(let o=0;o<t.length-1;o++){let c=t[o];if(/^(cmd|meta|m)$/i.test(c))a=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))s=!0;else if(/^s(hift)?$/i.test(c))i=!0;else if(/^mod$/i.test(c))yd?a=!0:s=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),a&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function wd(e){let t=Object.create(null);for(let n in e)t[vd(n)]=e[n];return t}function cr(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function kd(e){let t=wd(e);return function(n,r){let s=xd(r),i,a=t[cr(s,r)];if(a&&a(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let o=t[cr(s,r,!1)];if(o&&o(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(bd&&r.ctrlKey&&r.altKey)&&(i=st[r.keyCode])&&i!=s){let o=t[cr(i,r)];if(o&&o(n.state,n.dispatch,n))return!0}}return!1}}const bt=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},xa=function(e,t,n,r){return n&&(Gs(e,t,n,r,-1)||Gs(e,t,n,r,1))},Nd=/^(img|br|input|textarea|hr)$/i;function Gs(e,t,n,r,s){for(var i;;){if(e==n&&t==r)return!0;if(t==(s<0?0:Mn(e))){let a=e.parentNode;if(!a||a.nodeType!=1||es(e)||Nd.test(e.nodeName)||e.contentEditable=="false")return!1;t=bt(e)+(s<0?0:1),e=a}else if(e.nodeType==1){let a=e.childNodes[t+(s<0?-1:0)];if(a.nodeType==1&&a.contentEditable=="false")if(!((i=a.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)t+=s;else return!1;else e=a,t=s<0?Mn(e):0}else return!1}}function Mn(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function Sd(e,t,n){for(let r=t==0,s=t==Mn(e);r||s;){if(e==n)return!0;let i=bt(e);if(e=e.parentNode,!e)return!1;r=r&&i==0,s=s&&i==Mn(e)}}function es(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const ya=function(e){return e.focusNode&&xa(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function ba(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}const qe=typeof navigator<"u"?navigator:null,Qs=typeof document<"u"?document:null,it=qe&&qe.userAgent||"",Tr=/Edge\/(\d+)/.exec(it),va=/MSIE \d/.exec(it),Dr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(it),rn=!!(va||Dr||Tr),wa=va?document.documentMode:Dr?+Dr[1]:Tr?+Tr[1]:0,qn=!rn&&/gecko\/(\d+)/i.test(it);qn&&+(/Firefox\/(\d+)/.exec(it)||[0,0])[1];const Ir=!rn&&/Chrome\/(\d+)/.exec(it),Ye=!!Ir,ka=Ir?+Ir[1]:0,vt=!rn&&!!qe&&/Apple Computer/.test(qe.vendor),ts=vt&&(/Mobile\/\w+/.test(it)||!!qe&&qe.maxTouchPoints>2),Le=ts||(qe?/Mac/.test(qe.platform):!1),Na=qe?/Win/.test(qe.platform):!1,sn=/Android \d/.test(it),ns=!!Qs&&"webkitFontSmoothing"in Qs.documentElement.style,Cd=ns?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function jd(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let s=e.docView.nearestDesc(n.focusNode),i=s&&s.size==0,a=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(a<0)return null;let o=r.resolve(a),c,d;if(ya(n)){for(c=a;s&&!s.node;)s=s.parent;let h=s.node;if(s&&h.isAtom&&ee.isSelectable(h)&&s.parent&&!(h.isInline&&Sd(n.focusNode,n.focusOffset,s.dom))){let p=s.posBefore;d=new ee(a==p?o:r.resolve(p))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let h=a,p=a;for(let m=0;m<n.rangeCount;m++){let v=n.getRangeAt(m);h=Math.min(h,e.docView.posFromDOM(v.startContainer,v.startOffset,1)),p=Math.max(p,e.docView.posFromDOM(v.endContainer,v.endOffset,-1))}if(h<0)return null;[c,a]=p==e.state.selection.anchor?[p,h]:[h,p],o=r.resolve(a)}else c=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let u=r.resolve(c);if(!d){let h=t=="pointer"||e.state.selection.head<o.pos&&!i?1:-1;d=Ca(e,u,o,h)}return d}function Sa(e){return e.editable?e.hasFocus():Td(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function rs(e,t=!1){let n=e.state.selection;if(Ed(e,n),!!Sa(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&Ye){let r=e.domSelectionRange(),s=e.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&xa(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){e.input.mouseDown.delayedSelectionSync=!0,e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)Md(e);else{let{anchor:r,head:s}=n,i,a;Zs&&!(n instanceof ie)&&(n.$from.parent.inlineContent||(i=Xs(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(a=Xs(e,n.to))),e.docView.setSelection(r,s,e,t),Zs&&(i&&ei(i),a&&ei(a)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Ad(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}const Zs=vt||Ye&&ka<63;function Xs(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),s=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(vt&&s&&s.contentEditable=="false")return dr(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return dr(s);if(i)return dr(i)}}function dr(e){return e.contentEditable="true",vt&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function ei(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function Ad(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,s=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=s)&&(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!Sa(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}function Md(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName=="IMG";r?t.collapse(n.parentNode,bt(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&rn&&wa<=11&&(n.disabled=!0,n.disabled=!1)}function Ed(e,t){if(t instanceof ee){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(ti(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else ti(e)}function ti(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function Ca(e,t,n,r){return e.someProp("createSelectionBetween",s=>s(e,t,n))||ie.between(t,n,r)}function Td(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function $r(e,t){let{$anchor:n,$head:r}=e.selection,s=t>0?n.max(r):n.min(r),i=s.parent.inlineContent?s.depth?e.doc.resolve(t>0?s.after():s.before()):null:s;return i&&ae.findFrom(i,t)}function Xe(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function ni(e,t,n){let r=e.state.selection;if(r instanceof ie)if(n.indexOf("s")>-1){let{$head:s}=r,i=s.textOffset?null:t<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let a=e.state.doc.resolve(s.pos+i.nodeSize*(t<0?-1:1));return Xe(e,new ie(r.$anchor,a))}else if(r.empty){if(e.endOfTextblock(t>0?"forward":"backward")){let s=$r(e.state,t);return s&&s instanceof ee?Xe(e,s):!1}else if(!(Le&&n.indexOf("m")>-1)){let s=r.$head,i=s.textOffset?null:t<0?s.nodeBefore:s.nodeAfter,a;if(!i||i.isText)return!1;let o=t<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(a=e.docView.descAt(o))&&!a.contentDOM?ee.isSelectable(i)?Xe(e,new ee(t<0?e.state.doc.resolve(s.pos-i.nodeSize):s)):ns?Xe(e,new ie(e.state.doc.resolve(t<0?o:o+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof ee&&r.node.isInline)return Xe(e,new ie(t>0?r.$to:r.$from));{let s=$r(e.state,t);return s?Xe(e,s):!1}}}function En(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function qt(e,t){let n=e.pmViewDesc;return n&&n.size==0&&(t<0||e.nextSibling||e.nodeName!="BR")}function kt(e,t){return t<0?Dd(e):Id(e)}function Dd(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let s,i,a=!1;for(qn&&n.nodeType==1&&r<En(n)&&qt(n.childNodes[r],-1)&&(a=!0);;)if(r>0){if(n.nodeType!=1)break;{let o=n.childNodes[r-1];if(qt(o,-1))s=n,i=--r;else if(o.nodeType==3)n=o,r=n.nodeValue.length;else break}}else{if(ja(n))break;{let o=n.previousSibling;for(;o&&qt(o,-1);)s=n.parentNode,i=bt(o),o=o.previousSibling;if(o)n=o,r=En(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}a?Or(e,n,r):s&&Or(e,s,i)}function Id(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let s=En(n),i,a;for(;;)if(r<s){if(n.nodeType!=1)break;let o=n.childNodes[r];if(qt(o,1))i=n,a=++r;else break}else{if(ja(n))break;{let o=n.nextSibling;for(;o&&qt(o,1);)i=o.parentNode,a=bt(o)+1,o=o.nextSibling;if(o)n=o,r=0,s=En(n);else{if(n=n.parentNode,n==e.dom)break;r=s=0}}}i&&Or(e,i,a)}function ja(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function $d(e,t){for(;e&&t==e.childNodes.length&&!es(e);)t=bt(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;e=n,t=0}}function Od(e,t){for(;e&&!t&&!es(e);)t=bt(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;e=n,t=e.childNodes.length}}function Or(e,t,n){if(t.nodeType!=3){let i,a;(a=$d(t,n))?(t=a,n=0):(i=Od(t,n))&&(t=i,n=i.nodeValue.length)}let r=e.domSelection();if(!r)return;if(ya(r)){let i=document.createRange();i.setEnd(t,n),i.setStart(t,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:s}=e;setTimeout(()=>{e.state==s&&rs(e)},50)}function ri(e,t){let n=e.state.doc.resolve(t);if(!(Ye||Na)&&n.parent.inlineContent){let s=e.coordsAtPos(t);if(t>n.start()){let i=e.coordsAtPos(t-1),a=(i.top+i.bottom)/2;if(a>s.top&&a<s.bottom&&Math.abs(i.left-s.left)>1)return i.left<s.left?"ltr":"rtl"}if(t<n.end()){let i=e.coordsAtPos(t+1),a=(i.top+i.bottom)/2;if(a>s.top&&a<s.bottom&&Math.abs(i.left-s.left)>1)return i.left>s.left?"ltr":"rtl"}}return getComputedStyle(e.dom).direction=="rtl"?"rtl":"ltr"}function si(e,t,n){let r=e.state.selection;if(r instanceof ie&&!r.empty||n.indexOf("s")>-1||Le&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let a=$r(e.state,t);if(a&&a instanceof ee)return Xe(e,a)}if(!s.parent.inlineContent){let a=t<0?s:i,o=r instanceof Ue?ae.near(a,t):ae.findFrom(a,t);return o?Xe(e,o):!1}return!1}function ii(e,t){if(!(e.state.selection instanceof ie))return!0;let{$head:n,$anchor:r,empty:s}=e.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let i=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let a=e.state.tr;return t<0?a.delete(n.pos-i.nodeSize,n.pos):a.delete(n.pos,n.pos+i.nodeSize),e.dispatch(a),!0}return!1}function ai(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Ld(e){if(!vt||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&t.nodeType==1&&n==0&&t.firstChild&&t.firstChild.contentEditable=="false"){let r=t.firstChild;ai(e,r,"true"),setTimeout(()=>ai(e,r,"false"),20)}return!1}function Fd(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}function Pd(e,t){let n=t.keyCode,r=Fd(t);if(n==8||Le&&n==72&&r=="c")return ii(e,-1)||kt(e,-1);if(n==46&&!t.shiftKey||Le&&n==68&&r=="c")return ii(e,1)||kt(e,1);if(n==13||n==27)return!0;if(n==37||Le&&n==66&&r=="c"){let s=n==37?ri(e,e.state.selection.from)=="ltr"?-1:1:-1;return ni(e,s,r)||kt(e,s)}else if(n==39||Le&&n==70&&r=="c"){let s=n==39?ri(e,e.state.selection.from)=="ltr"?1:-1:1;return ni(e,s,r)||kt(e,s)}else{if(n==38||Le&&n==80&&r=="c")return si(e,-1,r)||kt(e,-1);if(n==40||Le&&n==78&&r=="c")return Ld(e)||si(e,1,r)||kt(e,1);if(r==(Le?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Aa(e,t){e.someProp("transformCopied",m=>{t=m(t,e)});let n=[],{content:r,openStart:s,openEnd:i}=t;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let m=r.firstChild;n.push(m.type.name,m.attrs!=m.type.defaultAttrs?m.attrs:null),r=m.content}let a=e.someProp("clipboardSerializer")||Vn.fromSchema(e.state.schema),o=$a(),c=o.createElement("div");c.appendChild(a.serializeFragment(r,{document:o}));let d=c.firstChild,u,h=0;for(;d&&d.nodeType==1&&(u=Ia[d.nodeName.toLowerCase()]);){for(let m=u.length-1;m>=0;m--){let v=o.createElement(u[m]);for(;c.firstChild;)v.appendChild(c.firstChild);c.appendChild(v),h++}d=c.firstChild}d&&d.nodeType==1&&d.setAttribute("data-pm-slice",`${s} ${i}${h?` -${h}`:""} ${JSON.stringify(n)}`);let p=e.someProp("clipboardTextSerializer",m=>m(t,e))||t.content.textBetween(0,t.content.size,`
|
|
17
17
|
|
|
18
|
-
`);return{dom:c,text:p,slice:t}}function
|
|
19
|
-
`))),0,0),e.someProp("transformPasted",p=>{l=p(l,e,!0)}),l;let f=e.someProp("clipboardTextParser",p=>p(t,s,r,e));if(f)l=f;else{let p=s.marks(),{schema:m}=e.state,v=Tn.fromSchema(m);a=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(b=>{let x=a.appendChild(document.createElement("p"));b&&x.appendChild(v.serializeNode(m.text(b,p)))})}}else e.someProp("transformPastedHTML",f=>{n=f(n,e)}),a=Md(n),Wr&&Ed(a);let d=a&&a.querySelector("[data-pm-slice]"),u=d&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(d.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let f=+u[3];f>0;f--){let p=a.firstChild;for(;p&&p.nodeType!=1;)p=p.nextSibling;if(!p)break;a=p}if(l||(l=(e.someProp("clipboardParser")||e.someProp("domParser")||fn.fromSchema(e.state.schema)).parseSlice(a,{preserveWhitespace:!!(c||u),context:s,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!Cd.test(p.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Td(ni(l,+u[1],+u[2]),u[4]);else if(l=Q.maxOpen(jd(l.content,s),!0),l.openStart||l.openEnd){let f=0,p=0;for(let m=l.content.firstChild;f<l.openStart&&!m.type.spec.isolating;f++,m=m.firstChild);for(let m=l.content.lastChild;p<l.openEnd&&!m.type.spec.isolating;p++,m=m.lastChild);l=ni(l,f,p)}return e.someProp("transformPasted",f=>{l=f(l,e,c)}),l}const Cd=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function jd(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let s=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(l=>{if(!a)return;let c=s.findWrapping(l.type),d;if(!c)return a=null;if(d=a.length&&i.length&&ka(c,i,l,a[a.length-1],0))a[a.length-1]=d;else{a.length&&(a[a.length-1]=Na(a[a.length-1],i.length));let u=wa(l,c);a.push(u),s=s.matchType(u.type),i=c}}),a)return G.from(a)}return e}function wa(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,G.from(e));return e}function ka(e,t,n,r,s){if(s<e.length&&s<t.length&&e[s]==t[s]){let i=ka(e,t,n,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==e.length-1?n.type:e[s+1]))return r.copy(r.content.append(G.from(wa(n,e,s+1))))}}function Na(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,Na(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(G.empty,!0);return e.copy(n.append(r))}function Cr(e,t,n,r,s,i){let a=t<0?e.firstChild:e.lastChild,l=a.content;return e.childCount>1&&(i=0),s<r-1&&(l=Cr(l,t,n,r,s+1,i)),s>=n&&(l=t<0?a.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(a.contentMatchAt(a.childCount).fillBefore(G.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,a.copy(l))}function ni(e,t,n){return t<e.openStart&&(e=new Q(Cr(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new Q(Cr(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const Sa={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let ri=null;function Ca(){return ri||(ri=document.implementation.createHTMLDocument("title"))}let rr=null;function Ad(e){let t=window.trustedTypes;return t?(rr||(rr=t.defaultPolicy||t.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),rr.createHTML(e)):e}function Md(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=Ca().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(e),s;if((s=r&&Sa[r[1].toLowerCase()])&&(e=s.map(i=>"<"+i+">").join("")+e+s.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=Ad(e),s)for(let i=0;i<s.length;i++)n=n.querySelector(s[i])||n;return n}function Ed(e){let t=e.querySelectorAll(Ke?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}function Td(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:s,openStart:i,openEnd:a}=e;for(let l=r.length-2;l>=0;l-=2){let c=n.nodes[r[l]];if(!c||c.hasRequiredAttrs())break;s=G.from(c.create(r[l+1],s)),i++,a++}return new Q(s,i,a)}const ze={},Ie={};function Ze(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}Ie.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!Aa(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(Yt&&Ke&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),qr&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();e.input.lastIOSEnter=r,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==r&&(e.someProp("handleKeyDown",s=>s(e,ua(13,"Enter"))),e.input.lastIOSEnter=0)},200)}else e.someProp("handleKeyDown",r=>r(e,n))||Sd(e,n)?n.preventDefault():Ze(e,"key")};Ie.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)};Ie.keypress=(e,t)=>{let n=t;if(Aa(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||$e&&n.metaKey)return;if(e.someProp("handleKeyPress",s=>s(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof ne)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!e.someProp("handleTextInput",a=>a(e,r.$from.pos,r.$to.pos,s,i))&&e.dispatch(i()),n.preventDefault()}};function On(e){return{left:e.clientX,top:e.clientY}}function Dd(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function Jr(e,t,n,r,s){if(r==-1)return!1;let i=e.state.doc.resolve(r);for(let a=i.depth+1;a>0;a--)if(e.someProp(t,l=>a>i.depth?l(e,n,i.nodeAfter,i.before(a),s,!0):l(e,n,i.node(a),i.before(a),s,!1)))return!0;return!1}function Ct(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);r.setMeta("pointer",!0),e.dispatch(r)}function Id(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&Z.isSelectable(r)?(Ct(e,new Z(n)),!0):!1}function $d(e,t){if(t==-1)return!1;let n=e.state.selection,r,s;n instanceof Z&&(r=n.node);let i=e.state.doc.resolve(t);for(let a=i.depth+1;a>0;a--){let l=a>i.depth?i.nodeAfter:i.node(a);if(Z.isSelectable(l)){r&&n.$from.depth>0&&a>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?s=i.before(n.$from.depth):s=i.before(a);break}}return s!=null?(Ct(e,Z.create(e.state.doc,s)),!0):!1}function Od(e,t,n,r,s){return Jr(e,"handleClickOn",t,n,r)||e.someProp("handleClick",i=>i(e,t,r))||(s?$d(e,n):Id(e,n))}function Ld(e,t,n,r){return Jr(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",s=>s(e,t,r))}function Fd(e,t,n,r){return Jr(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",s=>s(e,t,r))||Pd(e,n,r)}function Pd(e,t,n){if(n.button!=0)return!1;let r=e.state.doc;if(t==-1)return r.inlineContent?(Ct(e,ne.create(r,0,r.content.size)),!0):!1;let s=r.resolve(t);for(let i=s.depth+1;i>0;i--){let a=i>s.depth?s.nodeAfter:s.node(i),l=s.before(i);if(a.inlineContent)Ct(e,ne.create(r,l+1,l+1+a.content.size));else if(Z.isSelectable(a))Ct(e,Z.create(r,l));else continue;return!0}}function Yr(e){return bn(e)}const ja=$e?"metaKey":"ctrlKey";ze.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=Yr(e),s=Date.now(),i="singleClick";s-e.input.lastClick.time<500&&Dd(n,e.input.lastClick)&&!n[ja]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type=="singleClick"?i="doubleClick":e.input.lastClick.type=="doubleClick"&&(i="tripleClick")),e.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:i,button:n.button};let a=e.posAtCoords(On(n));a&&(i=="singleClick"?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new Rd(e,a,n,!!r)):(i=="doubleClick"?Ld:Fd)(e,a.pos,a.inside,n)?n.preventDefault():Ze(e,"pointer"))};class Rd{constructor(t,n,r,s){this.view=t,this.pos=n,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!r[ja],this.allowDefault=r.shiftKey;let i,a;if(n.inside>-1)i=t.state.doc.nodeAt(n.inside),a=n.inside;else{let u=t.state.doc.resolve(n.pos);i=u.parent,a=u.depth?u.before():0}const l=s?null:r.target,c=l?t.docView.nearestDesc(l,!0):null;this.target=c&&c.nodeDOM.nodeType==1?c.nodeDOM:null;let{selection:d}=t.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||d instanceof Z&&d.from<=a&&d.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&$n&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),Ze(t,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Kr(this.view)),this.view.input.mouseDown=null}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(On(t))),this.updateAllowDefault(t),this.allowDefault||!n?Ze(this.view,"pointer"):Od(this.view,n.pos,n.inside,t,this.selectNode)?t.preventDefault():t.button==0&&(this.flushed||xt&&this.mightDrag&&!this.mightDrag.node.isAtom||Ke&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Ct(this.view,re.near(this.view.state.doc.resolve(n.pos))),t.preventDefault()):Ze(this.view,"pointer")}move(t){this.updateAllowDefault(t),Ze(this.view,"pointer"),t.buttons==0&&this.done()}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}}ze.touchstart=e=>{e.input.lastTouch=Date.now(),Yr(e),Ze(e,"pointer")};ze.touchmove=e=>{e.input.lastTouch=Date.now(),Ze(e,"pointer")};ze.contextmenu=e=>Yr(e);function Aa(e,t){return e.composing?!0:xt&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}const zd=Yt?5e3:-1;Ie.compositionstart=Ie.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof ne&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Ke&&pa&&Bd(e)))e.markCursor=e.state.storedMarks||n.marks(),bn(e,!0),e.markCursor=null;else if(bn(e,!t.selection.empty),$n&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=e.domSelectionRange();for(let s=r.focusNode,i=r.focusOffset;s&&s.nodeType==1&&i!=0;){let a=i<0?s.lastChild:s.childNodes[i-1];if(!a)break;if(a.nodeType==3){let l=e.domSelection();l&&l.collapse(a,a.nodeValue.length);break}else s=a,i=-1}}e.input.composing=!0}Ma(e,zd)};function Bd(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||t.nodeType!=1||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}Ie.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,Ma(e,20))};function Ma(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>bn(e),t))}function _d(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Vd());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function Vd(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}function bn(e,t=!1){if(!(Yt&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),_d(e),t||e.docView&&e.docView.dirty){let n=hd(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function Hd(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}const Ut=Jt&&ha<15||qr&&fd<604;ze.copy=Ie.cut=(e,t)=>{let n=t,r=e.state.selection,s=n.type=="cut";if(r.empty)return;let i=Ut?null:n.clipboardData,a=r.content(),{dom:l,text:c}=ba(e,a);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",c)):Hd(e,l),s&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Ud(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function qd(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?jr(e,r.value,null,s,t):jr(e,r.textContent,r.innerHTML,s,t)},50)}function jr(e,t,n,r,s){let i=va(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",c=>c(e,s,i||Q.empty)))return!0;if(!i)return!1;let a=Ud(i),l=a?e.state.tr.replaceSelectionWith(a,r):e.state.tr.replaceSelection(i);return e.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Ea(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Ie.paste=(e,t)=>{let n=t;if(e.composing&&!Yt)return;let r=Ut?null:n.clipboardData,s=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&jr(e,Ea(r),r.getData("text/html"),s,n)?n.preventDefault():qd(e,n)};class Wd{constructor(t,n,r){this.slice=t,this.move=n,this.node=r}}const Kd=$e?"altKey":"ctrlKey";function Ta(e,t){let n=e.someProp("dragCopies",r=>!r(t));return n??!t[Kd]}ze.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=e.state.selection,i=s.empty?null:e.posAtCoords(On(n)),a;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof Z?s.to-1:s.to))){if(r&&r.mightDrag)a=Z.create(e.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let f=e.docView.nearestDesc(n.target,!0);f&&f.node.type.spec.draggable&&f!=e.docView&&(a=Z.create(e.state.doc,f.posBefore))}}let l=(a||e.state.selection).content(),{dom:c,text:d,slice:u}=ba(e,l);(!n.dataTransfer.files.length||!Ke||ma>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Ut?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",Ut||n.dataTransfer.setData("text/plain",d),e.dragging=new Wd(u,Ta(e,n),a)};ze.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)};Ie.dragover=Ie.dragenter=(e,t)=>t.preventDefault();Ie.drop=(e,t)=>{try{Jd(e,t,e.dragging)}finally{e.dragging=null}};function Jd(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(On(t));if(!r)return;let s=e.state.doc.resolve(r.pos),i=n&&n.slice;i?e.someProp("transformPasted",m=>{i=m(i,e,!1)}):i=va(e,Ea(t.dataTransfer),Ut?null:t.dataTransfer.getData("text/html"),!1,s);let a=!!(n&&Ta(e,t));if(e.someProp("handleDrop",m=>m(e,t,i||Q.empty,a))){t.preventDefault();return}if(!i)return;t.preventDefault();let l=i?na(e.state.doc,s.pos,i):s.pos;l==null&&(l=s.pos);let c=e.state.tr;if(a){let{node:m}=n;m?m.replace(c):c.deleteSelection()}let d=c.mapping.map(l),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,f=c.doc;if(u?c.replaceRangeWith(d,d,i.content.firstChild):c.replaceRange(d,d,i),c.doc.eq(f))return;let p=c.doc.resolve(d);if(u&&Z.isSelectable(i.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new Z(p));else{let m=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((v,b,x,w)=>m=w),c.setSelection(xa(e,p,c.doc.resolve(m)))}e.focus(),e.dispatch(c.setMeta("uiEvent","drop"))}ze.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&Kr(e)},20))};ze.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)};ze.beforeinput=(e,t)=>{if(Ke&&Yt&&t.inputType=="deleteContentBackward"){e.domObserver.flushSoon();let{domChangeCount:r}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=r||(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",i=>i(e,ua(8,"Backspace")))))return;let{$cursor:s}=e.state.selection;s&&s.pos>0&&e.dispatch(e.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let e in Ie)ze[e]=Ie[e];function qt(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class vn{constructor(t,n){this.toDOM=t,this.spec=n||ht,this.side=this.spec.side||0}map(t,n,r,s){let{pos:i,deleted:a}=t.mapResult(n.from+s,this.side<0?-1:1);return a?null:new _e(i-r,i-r,this)}valid(){return!0}eq(t){return this==t||t instanceof vn&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&qt(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}}class et{constructor(t,n){this.attrs=t,this.spec=n||ht}map(t,n,r,s){let i=t.map(n.from+s,this.spec.inclusiveStart?-1:1)-r,a=t.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=a?null:new _e(i,a,this)}valid(t,n){return n.from<n.to}eq(t){return this==t||t instanceof et&&qt(this.attrs,t.attrs)&&qt(this.spec,t.spec)}static is(t){return t.type instanceof et}destroy(){}}class Gr{constructor(t,n){this.attrs=t,this.spec=n||ht}map(t,n,r,s){let i=t.mapResult(n.from+s,1);if(i.deleted)return null;let a=t.mapResult(n.to+s,-1);return a.deleted||a.pos<=i.pos?null:new _e(i.pos-r,a.pos-r,this)}valid(t,n){let{index:r,offset:s}=t.content.findIndex(n.from),i;return s==n.from&&!(i=t.child(r)).isText&&s+i.nodeSize==n.to}eq(t){return this==t||t instanceof Gr&&qt(this.attrs,t.attrs)&&qt(this.spec,t.spec)}destroy(){}}class _e{constructor(t,n,r){this.from=t,this.to=n,this.type=r}copy(t,n){return new _e(t,n,this.type)}eq(t,n=0){return this.type.eq(t.type)&&this.from+n==t.from&&this.to+n==t.to}map(t,n,r){return this.type.map(t,this,n,r)}static widget(t,n,r){return new _e(t,t,new vn(n,r))}static inline(t,n,r,s){return new _e(t,n,new et(r,s))}static node(t,n,r,s){return new _e(t,n,new Gr(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof et}get widget(){return this.type instanceof vn}}const kt=[],ht={};class ye{constructor(t,n){this.local=t.length?t:kt,this.children=n.length?n:kt}static create(t,n){return n.length?wn(n,t,0,ht):Ce}find(t,n,r){let s=[];return this.findInner(t??0,n??1e9,s,0,r),s}findInner(t,n,r,s,i){for(let a=0;a<this.local.length;a++){let l=this.local[a];l.from<=n&&l.to>=t&&(!i||i(l.spec))&&r.push(l.copy(l.from+s,l.to+s))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<n&&this.children[a+1]>t){let l=this.children[a]+1;this.children[a+2].findInner(t-l,n-l,r,s+l,i)}}map(t,n,r){return this==Ce||t.maps.length==0?this:this.mapInner(t,n,0,0,r||ht)}mapInner(t,n,r,s,i){let a;for(let l=0;l<this.local.length;l++){let c=this.local[l].map(t,r,s);c&&c.type.valid(n,c)?(a||(a=[])).push(c):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?Yd(this.children,a||[],t,n,r,s,i):a?new ye(a.sort(mt),kt):Ce}add(t,n){return n.length?this==Ce?ye.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let s,i=0;t.forEach((l,c)=>{let d=c+r,u;if(u=Ia(n,l,d)){for(s||(s=this.children.slice());i<s.length&&s[i]<c;)i+=3;s[i]==c?s[i+2]=s[i+2].addInner(l,u,d+1):s.splice(i,0,c,c+l.nodeSize,wn(u,l,d+1,ht)),i+=3}});let a=Da(i?$a(n):n,-r);for(let l=0;l<a.length;l++)a[l].type.valid(t,a[l])||a.splice(l--,1);return new ye(a.length?this.local.concat(a).sort(mt):this.local,s||this.children)}remove(t){return t.length==0||this==Ce?this:this.removeInner(t,0)}removeInner(t,n){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let a,l=r[i]+n,c=r[i+1]+n;for(let u=0,f;u<t.length;u++)(f=t[u])&&f.from>l&&f.to<c&&(t[u]=null,(a||(a=[])).push(f));if(!a)continue;r==this.children&&(r=this.children.slice());let d=r[i+2].removeInner(a,l+1);d!=Ce?r[i+2]=d:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,a;i<t.length;i++)if(a=t[i])for(let l=0;l<s.length;l++)s[l].eq(a,n)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new ye(s,r):Ce}forChild(t,n){if(this==Ce)return this;if(n.isLeaf)return ye.empty;let r,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=t){this.children[l]==t&&(r=this.children[l+2]);break}let i=t+1,a=i+n.content.size;for(let l=0;l<this.local.length;l++){let c=this.local[l];if(c.from<a&&c.to>i&&c.type instanceof et){let d=Math.max(i,c.from)-i,u=Math.min(a,c.to)-i;d<u&&(s||(s=[])).push(c.copy(d,u))}}if(s){let l=new ye(s.sort(mt),kt);return r?new lt([l,r]):l}return r||Ce}eq(t){if(this==t)return!0;if(!(t instanceof ye)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(t.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=t.children[n]||this.children[n+1]!=t.children[n+1]||!this.children[n+2].eq(t.children[n+2]))return!1;return!0}locals(t){return Qr(this.localsInner(t))}localsInner(t){if(this==Ce)return kt;if(t.inlineContent||!this.local.some(et.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof et||n.push(this.local[r]);return n}forEachSet(t){t(this)}}ye.empty=new ye([],[]);ye.removeOverlap=Qr;const Ce=ye.empty;class lt{constructor(t){this.members=t}map(t,n){const r=this.members.map(s=>s.map(t,n,ht));return lt.from(r)}forChild(t,n){if(n.isLeaf)return ye.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(t,n);i!=Ce&&(i instanceof lt?r=r.concat(i.members):r.push(i))}return lt.from(r)}eq(t){if(!(t instanceof lt)||t.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(t.members[n]))return!1;return!0}locals(t){let n,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(t);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let a=0;a<i.length;a++)n.push(i[a])}}return n?Qr(r?n:n.sort(mt)):kt}static from(t){switch(t.length){case 0:return Ce;case 1:return t[0];default:return new lt(t.every(n=>n instanceof ye)?t:t.reduce((n,r)=>n.concat(r instanceof ye?r:r.members),[]))}}forEachSet(t){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(t)}}function Yd(e,t,n,r,s,i,a){let l=e.slice();for(let d=0,u=i;d<n.maps.length;d++){let f=0;n.maps[d].forEach((p,m,v,b)=>{let x=b-v-(m-p);for(let w=0;w<l.length;w+=3){let N=l[w+1];if(N<0||p>N+u-f)continue;let A=l[w]+u-f;m>=A?l[w+1]=p<=A?-2:-1:p>=u&&x&&(l[w]+=x,l[w+1]+=x)}f+=x}),u=n.maps[d].map(u,-1)}let c=!1;for(let d=0;d<l.length;d+=3)if(l[d+1]<0){if(l[d+1]==-2){c=!0,l[d+1]=-1;continue}let u=n.map(e[d]+i),f=u-s;if(f<0||f>=r.content.size){c=!0;continue}let p=n.map(e[d+1]+i,-1),m=p-s,{index:v,offset:b}=r.content.findIndex(f),x=r.maybeChild(v);if(x&&b==f&&b+x.nodeSize==m){let w=l[d+2].mapInner(n,x,u+1,e[d]+i+1,a);w!=Ce?(l[d]=f,l[d+1]=m,l[d+2]=w):(l[d+1]=-2,c=!0)}else c=!0}if(c){let d=Gd(l,e,t,n,s,i,a),u=wn(d,r,0,a);t=u.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,p=0;f<u.children.length;f+=3){let m=u.children[f];for(;p<l.length&&l[p]<m;)p+=3;l.splice(p,0,u.children[f],u.children[f+1],u.children[f+2])}}return new ye(t.sort(mt),l)}function Da(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let s=e[r];n.push(new _e(s.from+t,s.to+t,s.type))}return n}function Gd(e,t,n,r,s,i,a){function l(c,d){for(let u=0;u<c.local.length;u++){let f=c.local[u].map(r,s,d);f?n.push(f):a.onRemove&&a.onRemove(c.local[u].spec)}for(let u=0;u<c.children.length;u+=3)l(c.children[u+2],c.children[u]+d+1)}for(let c=0;c<e.length;c+=3)e[c+1]==-1&&l(e[c+2],t[c]+i+1);return n}function Ia(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,s=null;for(let i=0,a;i<e.length;i++)(a=e[i])&&a.from>n&&a.to<r&&((s||(s=[])).push(a),e[i]=null);return s}function $a(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function wn(e,t,n,r){let s=[],i=!1;t.forEach((l,c)=>{let d=Ia(e,l,c+n);if(d){i=!0;let u=wn(d,l,n+c+1,r);u!=Ce&&s.push(c,c+l.nodeSize,u)}});let a=Da(i?$a(e):e,-n).sort(mt);for(let l=0;l<a.length;l++)a[l].type.valid(t,a[l])||(r.onRemove&&r.onRemove(a[l].spec),a.splice(l--,1));return a.length||s.length?new ye(a,s):Ce}function mt(e,t){return e.from-t.from||e.to-t.to}function Qr(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let s=n+1;s<t.length;s++){let i=t[s];if(i.from==r.from){i.to!=r.to&&(t==e&&(t=e.slice()),t[s]=i.copy(i.from,r.to),si(t,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,i.from),si(t,s,r.copy(i.from,r.to)));break}}}return t}function si(e,t,n){for(;t<e.length&&mt(n,e[t])>0;)t++;e.splice(t,0,n)}class he extends re{constructor(t){super(t,t)}map(t,n){let r=t.resolve(n.map(this.head));return he.valid(r)?new he(r):re.near(r)}content(){return Q.empty}eq(t){return t instanceof he&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new he(t.resolve(n.pos))}getBookmark(){return new Zr(this.anchor)}static valid(t){let n=t.parent;if(n.isTextblock||!Qd(t)||!Zd(t))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let s=n.contentMatchAt(t.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(t,n,r=!1){e:for(;;){if(!r&&he.valid(t))return t;let s=t.pos,i=null;for(let a=t.depth;;a--){let l=t.node(a);if(n>0?t.indexAfter(a)<l.childCount:t.index(a)>0){i=l.child(n>0?t.indexAfter(a):t.index(a)-1);break}else if(a==0)return null;s+=n;let c=t.doc.resolve(s);if(he.valid(c))return c}for(;;){let a=n>0?i.firstChild:i.lastChild;if(!a){if(i.isAtom&&!i.isText&&!Z.isSelectable(i)){t=t.doc.resolve(s+i.nodeSize*n),r=!1;continue e}break}i=a,s+=n;let l=t.doc.resolve(s);if(he.valid(l))return l}return null}}}he.prototype.visible=!1;he.findFrom=he.findGapCursorFrom;re.jsonID("gapcursor",he);class Zr{constructor(t){this.pos=t}map(t){return new Zr(t.map(this.pos))}resolve(t){let n=t.resolve(this.pos);return he.valid(n)?new he(n):re.near(n)}}function Oa(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function Qd(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||Oa(s.type))return!0;if(s.inlineContent)return!1}}return!0}function Zd(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||Oa(s.type))return!0;if(s.inlineContent)return!1}}return!0}function Xd(){return new In({props:{decorations:ru,createSelectionBetween(e,t,n){return t.pos==n.pos&&he.valid(n)?new he(n):null},handleClick:tu,handleKeyDown:eu,handleDOMEvents:{beforeinput:nu}}})}const eu=cd({ArrowLeft:tn("horiz",-1),ArrowRight:tn("horiz",1),ArrowUp:tn("vert",-1),ArrowDown:tn("vert",1)});function tn(e,t){const n=e=="vert"?t>0?"down":"up":t>0?"right":"left";return function(r,s,i){let a=r.selection,l=t>0?a.$to:a.$from,c=a.empty;if(a instanceof ne){if(!i.endOfTextblock(n)||l.depth==0)return!1;c=!1,l=r.doc.resolve(t>0?l.after():l.before())}let d=he.findGapCursorFrom(l,t,c);return d?(s&&s(r.tr.setSelection(new he(d))),!0):!1}}function tu(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!he.valid(r))return!1;let s=e.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&Z.isSelectable(e.state.doc.nodeAt(s.inside))?!1:(e.dispatch(e.state.tr.setSelection(new he(r))),!0)}function nu(e,t){if(t.inputType!="insertCompositionText"||!(e.state.selection instanceof he))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let s=G.empty;for(let a=r.length-1;a>=0;a--)s=G.from(r[a].createAndFill(null,s));let i=e.state.tr.replace(n.pos,n.pos,new Q(s,0,0));return i.setSelection(ne.near(i.doc.resolve(n.pos+1))),e.dispatch(i),!1}function ru(e){if(!(e.selection instanceof he))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",ye.create(e.doc,[_e.widget(e.selection.head,t,{key:"gapcursor"})])}const su=z.Extension.create({name:"gapCursor",addProseMirrorPlugins(){return[Xd()]},extendNodeSchema(e){var t;const n={name:e.name,options:e.options,storage:e.storage};return{allowGapCursor:(t=z.callOrReturn(z.getExtensionField(e,"allowGapCursor",n)))!==null&&t!==void 0?t:null}}}),Et={bold:{category:"mark",extension:nc,priority:100},italic:{category:"mark",extension:lc,priority:100},strike:{category:"mark",extension:dc,priority:100},underline:{category:"mark",extension:go.Underline,priority:100},code:{category:"mark",extension:hc,priority:100},textColor:{category:"mark",extension:xo.Color,defaultOptions:{types:["textStyle","heading","paragraph","listItem","taskItem","blockquote"]},priority:90},highlight:{category:"mark",extension:yo.Highlight,defaultOptions:{multicolor:!0},priority:90},link:{category:"mark",extension:bo.Link,defaultOptions:{autolink:!0,linkOnPaste:!0,openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}},priority:100},heading:{category:"node",extension:gc,defaultOptions:{levels:[1,2,3,4,5,6]},priority:100},bulletList:{category:"node",extension:bc,defaultOptions:{HTMLAttributes:{class:"list-disc"}},priority:90},orderedList:{category:"node",extension:wc,defaultOptions:{HTMLAttributes:{class:"list-decimal"}},priority:90},taskList:{category:"node",extension:vo.TaskList,defaultOptions:{HTMLAttributes:{class:"task-list"}},priority:90},codeBlock:{category:"node",extension:Pc,priority:100},blockquote:{category:"node",extension:zc,priority:100},horizontalRule:{category:"node",extension:Bc,priority:100},hardBreak:{category:"node",extension:_c,priority:100},undo:{category:"extension",extension:Us,priority:50},redo:{category:"extension",extension:Us,priority:50},textAlign:{category:"extension",extension:ko.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}},iu=[Qc,Zc,xc,pc.configure({HTMLAttributes:{}}),kc.configure({HTMLAttributes:{}}),wo.TaskItem.configure({nested:!0}),td,su];function au(e){const t=[],n=new Set,r=new Set;iu.forEach(l=>{l&&(t.push(l),r.add(l.name))});const s=e.map(l=>Bt(l)),i=new Set;return s.forEach(l=>{const c=Et[l];c?.requiredExtensions&&c.requiredExtensions.forEach(d=>{i.add(d)})}),i.forEach(l=>{if(n.has(l))return;const c=Et[l];if(!c||c.extension===null)return;const d=c.extension.name;if(r.has(d)){n.add(l);return}const u=c.defaultOptions?c.extension.configure(c.defaultOptions):c.extension;t.push(u),n.add(l),r.add(d)}),s.forEach(l=>{if(n.has(l))return;const c=Et[l];if(!c){console.warn(`Extension config not found for modifier: ${l}`);return}if(c.extension===null){n.add(l);return}const d=c.extension.name;if(r.has(d)){n.add(l);return}const u=c.defaultOptions?c.extension.configure(c.defaultOptions):c.extension;t.push(u),n.add(l),r.add(d)}),t.sort((l,c)=>{const d=Object.values(Et).find(m=>m?.extension?.name===l.name),u=Object.values(Et).find(m=>m?.extension?.name===c.name),f=d?.priority??100;return(u?.priority??100)-f})}const La={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"]},ue={fontFamily:{mono:'"JetBrains Mono", Consolas, monospace'},fontSize:{sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","4xl":"2.25rem"},fontWeight:{semibold:"600",bold:"700"},lineHeight:{tight:"1.25",normal:"1.5"}},Ye={brand:{primary:{DEFAULT:"#C14615"}},neutral:{gray:{100:"#F3F4F6",200:"#E5E7EB",300:"#D1D5DB",500:"#6B7280",800:"#1F2937"}},palettes:{warning:{200:"#fde68a"}}},ce={xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem"},lu={h1:`font-size: ${ue.fontSize["4xl"]}; font-weight: ${ue.fontWeight.semibold}; line-height: ${ue.lineHeight.tight}; margin: ${ce.md} 0 ${ce.sm} 0;`,h2:`font-size: ${ue.fontSize["2xl"]}; font-weight: ${ue.fontWeight.semibold}; line-height: ${ue.lineHeight.tight}; margin: ${ce.md} 0 ${ce.sm} 0;`,h3:`font-size: ${ue.fontSize.xl}; font-weight: ${ue.fontWeight.semibold}; line-height: ${ue.lineHeight.tight}; margin: ${ce.md} 0 ${ce.sm} 0;`,h4:`font-size: ${ue.fontSize.lg}; font-weight: ${ue.fontWeight.semibold}; line-height: ${ue.lineHeight.tight}; margin: ${ce.md} 0 ${ce.sm} 0;`,h5:`font-size: ${ue.fontSize.base}; font-weight: ${ue.fontWeight.semibold}; line-height: ${ue.lineHeight.tight}; margin: ${ce.md} 0 ${ce.sm} 0;`,h6:`font-size: ${ue.fontSize.sm}; font-weight: ${ue.fontWeight.semibold}; line-height: ${ue.lineHeight.tight}; margin: ${ce.md} 0 ${ce.sm} 0;`,p:`min-height: ${ue.lineHeight.normal}em; margin: 0;`,ul:`list-style-type: disc; list-style-position: outside; padding-left: ${ce.xl}; margin: ${ce.md} 0;`,ol:`list-style-type: decimal; list-style-position: outside; padding-left: ${ce.xl}; margin: ${ce.md} 0;`,li:`display: list-item; margin: ${ce.xs} 0;`,strong:`font-weight: ${ue.fontWeight.bold};`,em:"font-style: italic;",s:"text-decoration: line-through;",u:"text-decoration: underline;",code:`background-color: ${Ye.neutral.gray[100]}; border-radius: 0.4rem; font-size: ${ue.fontSize.sm}; padding: 0.25em 0.3em; font-family: ${ue.fontFamily.mono};`,pre:`background: ${Ye.neutral.gray[800]}; border-radius: ${ce.sm}; color: ${Ye.neutral.gray[100]}; font-family: ${ue.fontFamily.mono}; margin: ${ce.lg} 0; padding: 0.75rem ${ce.md}; overflow-x: auto;`,blockquote:`border-left: 3px solid ${Ye.neutral.gray[300]}; margin: ${ce.lg} 0; padding-left: ${ce.md}; color: ${Ye.neutral.gray[500]};`,hr:`border: none; border-top: 1px solid ${Ye.neutral.gray[200]}; margin: ${ce.xl} 0;`,a:`color: ${Ye.brand.primary.DEFAULT}; text-decoration: underline; cursor: pointer;`,mark:`background-color: ${Ye.palettes.warning[200]}; border-radius: ${ce.xs}; padding: 0 0.125rem;`,label:`display: flex; align-items: center; gap: ${ce.sm}; cursor: pointer;`,input:"cursor: pointer; margin: 0;"},ou={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 cu(e){if(!e)return e;let t=e;for(const[n,r]of Object.entries(ou)){const s=new RegExp(`(<(?:ul|li)[^>]*data-type="${n}"[^>]*)>`,"gi");t=t.replace(s,(i,a)=>i.includes('style="')?i.replace(/style="([^"]*)"/,`style="$1 ${r}"`):`${a} style="${r}">`)}for(const[n,r]of Object.entries(lu)){const s=new RegExp(`<${n}(\\s[^>]*)?>`,"gi");t=t.replace(s,i=>{if(i.includes('data-type="taskList"')||i.includes('data-type="taskItem"'))return i;if(i.includes('style="'))return i.replace(/style="([^"]*)"/,`style="$1 ${r}"`);if(i.includes("style='"))return i.replace(/style='([^']*)'/,`style='$1 ${r}'`);{const a=i.indexOf(">");return`${i.slice(0,a)} style="${r}"${i.slice(a)}`}})}return t}const du=({modifiers:e,zoom:t,onZoomChange:n,onToolbarAction:r})=>{const{editor:s}=Rr.useCurrentEditor();return o.jsx(Qo,{editor:s,modifiers:e,zoom:t,onZoomChange:n,onToolbarAction:r})},uu=({showCharacterCount:e,showWordCount:t})=>{const{editor:n}=Rr.useCurrentEditor();if(!n||!e&&!t)return null;const r=n.getText(),s=r.length,i=r.split(/\s+/).filter(a=>a.length>0).length;return o.jsxs("div",{className:"flex gap-4 text-xs text-default-500 px-2 pb-1",children:[e&&o.jsxs("span",{children:[s," characters"]}),t&&o.jsxs("span",{children:[i," words"]})]})},Ar=y.forwardRef((e,t)=>{const{minRows:n=10,maxRows:r=30,disableAutosize:s=!1,showCharacterCount:i=!1,showWordCount:a=!1,showToolbar:l=!0,modifiers:c=La.full,variant:d="bordered",initialContent:u,content:f,onContentChange:p,onUpdate:m,onToolbarAction:v,isReadOnly:b=!1,isDisabled:x=!1,includeInlineStyles:w=!0,...N}=e,{zoom:A,setZoom:S}=Jo(),j=Cs.lineHeight,M=n*j,I=s?void 0:r*j,B=y.useMemo(()=>au(c),[c]),{Component:R,label:_,shouldLabelBeOutside:E,getBaseProps:T,getLabelProps:O,getInputWrapperProps:F}=h.useInput({...N,variant:d,ref:t,isMultiline:!0}),K=_?o.jsx("label",{...O(),children:_}):null,X=y.useCallback(({editor:J})=>{const se=J.getHTML(),ie=w?cu(se):se,fe=J.getJSON(),Y=J.getText(),q=Y.length,ae=Y.split(/\s+/).filter(Me=>Me.length>0).length,le={html:ie,json:fe,text:Y,characters:q,words:ae};if(p?.(le),m?.(le),"onChange"in N&&typeof N.onChange=="function"){const Me={target:{value:ie},currentTarget:{value:ie}};N.onChange(Me)}},[p,m,N,w]);return o.jsxs(R,{...T(),children:[E?K:null,o.jsx("div",{...F(),className:h.cn(F().className,"flex flex-col w-full p-0 gap-0 rich-text-editor"),style:{maxHeight:I?`${I+Cs.toolbarHeight}px`:void 0,overflow:I?"auto":void 0},children:o.jsx(Rr.EditorProvider,{editable:!b&&!x,slotBefore:l?o.jsx(du,{modifiers:c,zoom:A,onZoomChange:S,onToolbarAction:v}):void 0,slotAfter:o.jsx(uu,{showCharacterCount:i,showWordCount:a}),editorContainerProps:{className:"w-full flex-1 outline-none",style:{minHeight:`${M}px`,fontSize:`${A}%`,display:"flex",flexDirection:"column"}},editorProps:{attributes:{class:"focus:outline-none w-full h-full"}},extensions:B,content:f||u||e.defaultValue||"",onUpdate:X})})]})});Ar.displayName="TipTapEditor";const Fa=y.forwardRef((e,t)=>{const{adapter:n="tiptap",variant:r="bordered",...s}=e;return n==="tiptap"?o.jsx(Ar,{...s,variant:r,ref:t}):(console.warn(`Adapter "${n}" is not supported. Using TipTap.`),o.jsx(Ar,{...s,variant:r,ref:t}))});Fa.displayName="RichTextArea";function fu(e,t="en-US",n="USD"){try{return new Intl.NumberFormat(t,{style:"currency",currency:n,minimumFractionDigits:0,maximumFractionDigits:2}).format(e)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${e.toFixed(2)}`}}const ii=[{id:"100",amount:100},{id:"250",amount:250},{id:"500",amount:500},{id:"1000",amount:1e3},{id:"2000",amount:2e3}],hu={title:"Donation Amount",customAmountPlaceholder:"Custom donation amount",customAmountAriaLabel:"Custom donation amount",addDonationButton:"Add Donation"},Pa=({presetAmounts:e=ii,selectedDonation:t,defaultSelectedDonation:n=null,onChange:r,onAddDonation:s,currency:i="USD",locale:a="en-US",showCustomAmount:l=!0,minCustomAmount:c=.5,maxCustomAmount:d=1e6,labels:u,mobileColumns:f=2,desktopColumns:p=3,isDisabled:m=!1,buttonVariant:v="bordered",buttonColor:b="default",inputVariant:x="bordered",size:w="md",className:N="",showCard:A=!0})=>{const S={...hu,...u},j=Array.isArray(e)?e:ii,M={2:"grid-cols-2",3:"grid-cols-3"},I={3:"sm:grid-cols-3",4:"sm:grid-cols-4",5:"sm:grid-cols-5",6:"sm:grid-cols-6"},B=`${M[f]} ${I[p]}`,[R,_]=zr(t,n,r),[E,T]=y.useState(""),[O,F]=y.useState(!1),[K,X]=y.useState(0),J=y.useCallback(q=>{if(m)return;const ae={amount:q.amount,isCustom:!1,presetId:q.id};_(ae),T(""),F(!1),X(le=>le+1),s?.(ae)},[m,_,s]),se=y.useCallback(q=>{if(m)return;if(T(q!==void 0?String(q):""),s){_(null);return}if(q===void 0||isNaN(q)){_(null);return}_({amount:q,isCustom:!0})},[m,_,s]),ie=y.useCallback(()=>{if(m)return;const q=E!==""?parseFloat(E):void 0;q===void 0||isNaN(q)||s?.({amount:q,isCustom:!0})},[m,E,s]),fe=y.useMemo(()=>({style:"currency",currency:i,currencyDisplay:"symbol"}),[i]),Y=o.jsxs("div",{className:"space-y-4","data-testid":"donation-amounts-root",children:[S.title&&o.jsx("h2",{className:"text-base font-semibold","data-testid":"donation-amounts-title",children:S.title}),j.length>0&&o.jsx("div",{className:h.cn("grid gap-3",B),"data-testid":"donation-amounts-presets",children:j.map(q=>{const ae=R!==null&&!R.isCustom&&R.presetId===q.id;return o.jsx(W,{color:ae?"primary":b,variant:ae?"solid":v,className:"w-full",onPress:()=>J(q),isDisabled:m,"data-testid":`donation-amounts-preset-${q.id}`,children:q.label||fu(q.amount,a,i)},q.id)})}),l&&o.jsxs("div",{className:"flex gap-3 items-start",children:[o.jsx(h.NumberInput,{placeholder:S.customAmountPlaceholder,"aria-label":S.customAmountAriaLabel,onInput:s?()=>{_(null),F(!0)}:void 0,variant:x,radius:"full",size:w,minValue:c,maxValue:d,step:.01,formatOptions:fe,value:E!==""?parseFloat(E):void 0,onValueChange:se,isDisabled:m,className:"flex-1 [&_[data-slot=input-wrapper]]:!h-10 [&_[data-slot=input-wrapper]]:!min-h-10","data-testid":"donation-amounts-custom-input",hideStepper:!0},s?`custom-${K}`:R?.isCustom===!1?R.presetId:"custom"),s&&o.jsx(W,{color:"primary",variant:"solid",radius:"full",size:w,className:"shrink-0",onPress:ie,isDisabled:m||!O,"data-testid":"donation-amounts-add-button",children:S.addDonationButton})]})]});return A?o.jsx(h.Card,{className:h.cn("w-full",N),"data-testid":"donation-amounts-card",children:o.jsx(h.CardBody,{children:Y})}):o.jsx("div",{className:h.cn("w-full",N),"data-testid":"donation-amounts-plain",children:Y})};Pa.displayName="DonationAmounts";const mu=e=>{const t=Math.max(0,e),n=Math.floor(t/60).toString().padStart(2,"0"),r=(t%60).toString().padStart(2,"0");return`${n}:${r} minutes`},pu=e=>{switch(e){case"warning":return U.Clock;case"error":return U.AlertCircle;case"success":return U.CheckCircle;default:return U.Clock}},gu=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"}},Ra=y.forwardRef(({timeLeft:e,defaultTimeLeft:t=1200,onTimeChange:n,onExpire:r,variant:s="info",color:i="primary",message:a="Your cart expires in:",showIcon:l=!0,icon:c,position:d="fixed",autoStart:u=!0,formatTime:f=mu,className:p,...m},v)=>{const[b,x]=zr(e!==void 0?Math.max(0,e):void 0,Math.max(0,t),n),w=y.useRef(null),N=y.useRef(!1);y.useEffect(()=>()=>{w.current&&clearInterval(w.current)},[]),y.useEffect(()=>{if(!u||b<=0){w.current&&(clearInterval(w.current),w.current=null);return}return w.current=setInterval(()=>{x(M=>M<=1?(w.current&&(clearInterval(w.current),w.current=null),N.current||(N.current=!0,r?.()),0):M-1)},1e3),()=>{w.current&&(clearInterval(w.current),w.current=null)}},[u,b,x,r]),y.useEffect(()=>{b>0&&(N.current=!1)},[b]);const A=c||pu(s),S=gu(i),j={fixed:"fixed top-0 left-0",sticky:"sticky top-0",static:"static"};return o.jsx("div",{ref:v,role:"banner","aria-live":"polite","aria-label":`${a} ${f(b)}`,"data-testid":"expire-cart-timer",className:h.cn("w-full text-white z-50",S,j[d],p),...m,children:o.jsx("div",{className:"container mx-auto px-4 py-3 sm:py-2.5","data-testid":"expire-cart-timer-container",children:o.jsxs("div",{className:"flex items-center justify-between gap-3 sm:gap-4",children:[o.jsxs("div",{className:"flex items-center gap-3 sm:gap-2.5 flex-1 min-w-0","data-testid":"expire-cart-timer-left",children:[l&&o.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:o.jsx(A,{className:"text-primary-500 sm:text-primary-600","aria-hidden":"true",size:14,"data-testid":"expire-cart-timer-icon"})}),o.jsx("p",{className:"text-sm sm:text-base font-medium text-white","data-testid":"expire-cart-timer-message",children:a})]}),o.jsx("div",{className:"flex-shrink-0","data-testid":"expire-cart-timer-right",children:o.jsx("span",{className:"text-sm sm:text-base font-semibold text-white","aria-label":`Time remaining: ${f(b)}`,"data-testid":"expire-cart-timer-value",children:f(b)})})]})})})});Ra.displayName="ExpireCartTimer";function xu(e,t){const n=e.icons,r=e.aliases||Object.create(null),s=Object.create(null);function i(a){if(n[a])return s[a]=[];if(!(a in s)){s[a]=null;const l=r[a]&&r[a].parent,c=l&&i(l);c&&(s[a]=[l].concat(c))}return s[a]}return Object.keys(n).concat(Object.keys(r)).forEach(i),s}const za=Object.freeze({left:0,top:0,width:16,height:16}),kn=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),Xr=Object.freeze({...za,...kn}),Mr=Object.freeze({...Xr,body:"",hidden:!1});function yu(e,t){const n={};!e.hFlip!=!t.hFlip&&(n.hFlip=!0),!e.vFlip!=!t.vFlip&&(n.vFlip=!0);const r=((e.rotate||0)+(t.rotate||0))%4;return r&&(n.rotate=r),n}function ai(e,t){const n=yu(e,t);for(const r in Mr)r in kn?r in e&&!(r in n)&&(n[r]=kn[r]):r in t?n[r]=t[r]:r in e&&(n[r]=e[r]);return n}function bu(e,t,n){const r=e.icons,s=e.aliases||Object.create(null);let i={};function a(l){i=ai(r[l]||s[l],i)}return a(t),n.forEach(a),ai(e,i)}function Ba(e,t){const n=[];if(typeof e!="object"||typeof e.icons!="object")return n;e.not_found instanceof Array&&e.not_found.forEach(s=>{t(s,null),n.push(s)});const r=xu(e);for(const s in r){const i=r[s];i&&(t(s,bu(e,s,i)),n.push(s))}return n}const vu={provider:"",aliases:{},not_found:{},...za};function sr(e,t){for(const n in t)if(n in e&&typeof e[n]!=typeof t[n])return!1;return!0}function _a(e){if(typeof e!="object"||e===null)return null;const t=e;if(typeof t.prefix!="string"||!e.icons||typeof e.icons!="object"||!sr(e,vu))return null;const n=t.icons;for(const s in n){const i=n[s];if(!s||typeof i.body!="string"||!sr(i,Mr))return null}const r=t.aliases||Object.create(null);for(const s in r){const i=r[s],a=i.parent;if(!s||typeof a!="string"||!n[a]&&!r[a]||!sr(i,Mr))return null}return t}const li=Object.create(null);function wu(e,t){return{provider:e,prefix:t,icons:Object.create(null),missing:new Set}}function jt(e,t){const n=li[e]||(li[e]=Object.create(null));return n[t]||(n[t]=wu(e,t))}function Va(e,t){return _a(t)?Ba(t,(n,r)=>{r?e.icons[n]=r:e.missing.add(n)}):[]}function ku(e,t,n){try{if(typeof n.body=="string")return e.icons[t]={...n},!0}catch{}return!1}const Ha=/^[a-z0-9]+(-[a-z0-9]+)*$/,Ln=(e,t,n,r="")=>{const s=e.split(":");if(e.slice(0,1)==="@"){if(s.length<2||s.length>3)return null;r=s.shift().slice(1)}if(s.length>3||!s.length)return null;if(s.length>1){const l=s.pop(),c=s.pop(),d={provider:s.length>0?s[0]:r,prefix:c,name:l};return t&&!cn(d)?null:d}const i=s[0],a=i.split("-");if(a.length>1){const l={provider:r,prefix:a.shift(),name:a.join("-")};return t&&!cn(l)?null:l}if(n&&r===""){const l={provider:r,prefix:"",name:i};return t&&!cn(l,n)?null:l}return null},cn=(e,t)=>e?!!((t&&e.prefix===""||e.prefix)&&e.name):!1;let Wt=!1;function Ua(e){return typeof e=="boolean"&&(Wt=e),Wt}function oi(e){const t=typeof e=="string"?Ln(e,!0,Wt):e;if(t){const n=jt(t.provider,t.prefix),r=t.name;return n.icons[r]||(n.missing.has(r)?null:void 0)}}function Nu(e,t){const n=Ln(e,!0,Wt);if(!n)return!1;const r=jt(n.provider,n.prefix);return t?ku(r,n.name,t):(r.missing.add(n.name),!0)}function Su(e,t){if(typeof e!="object")return!1;if(typeof t!="string"&&(t=e.provider||""),Wt&&!t&&!e.prefix){let s=!1;return _a(e)&&(e.prefix="",Ba(e,(i,a)=>{Nu(i,a)&&(s=!0)})),s}const n=e.prefix;if(!cn({prefix:n,name:"a"}))return!1;const r=jt(t,n);return!!Va(r,e)}const qa=Object.freeze({width:null,height:null}),Wa=Object.freeze({...qa,...kn}),Cu=/(-?[0-9.]*[0-9]+[0-9.]*)/g,ju=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function ci(e,t,n){if(t===1)return e;if(n=n||100,typeof e=="number")return Math.ceil(e*t*n)/n;if(typeof e!="string")return e;const r=e.split(Cu);if(r===null||!r.length)return e;const s=[];let i=r.shift(),a=ju.test(i);for(;;){if(a){const l=parseFloat(i);isNaN(l)?s.push(i):s.push(Math.ceil(l*t*n)/n)}else s.push(i);if(i=r.shift(),i===void 0)return s.join("");a=!a}}function Au(e,t="defs"){let n="";const r=e.indexOf("<"+t);for(;r>=0;){const s=e.indexOf(">",r),i=e.indexOf("</"+t);if(s===-1||i===-1)break;const a=e.indexOf(">",i);if(a===-1)break;n+=e.slice(s+1,i).trim(),e=e.slice(0,r).trim()+e.slice(a+1)}return{defs:n,content:e}}function Mu(e,t){return e?"<defs>"+e+"</defs>"+t:t}function Eu(e,t,n){const r=Au(e);return Mu(r.defs,t+r.content+n)}const Tu=e=>e==="unset"||e==="undefined"||e==="none";function Du(e,t){const n={...Xr,...e},r={...Wa,...t},s={left:n.left,top:n.top,width:n.width,height:n.height};let i=n.body;[n,r].forEach(b=>{const x=[],w=b.hFlip,N=b.vFlip;let A=b.rotate;w?N?A+=2:(x.push("translate("+(s.width+s.left).toString()+" "+(0-s.top).toString()+")"),x.push("scale(-1 1)"),s.top=s.left=0):N&&(x.push("translate("+(0-s.left).toString()+" "+(s.height+s.top).toString()+")"),x.push("scale(1 -1)"),s.top=s.left=0);let S;switch(A<0&&(A-=Math.floor(A/4)*4),A=A%4,A){case 1:S=s.height/2+s.top,x.unshift("rotate(90 "+S.toString()+" "+S.toString()+")");break;case 2:x.unshift("rotate(180 "+(s.width/2+s.left).toString()+" "+(s.height/2+s.top).toString()+")");break;case 3:S=s.width/2+s.left,x.unshift("rotate(-90 "+S.toString()+" "+S.toString()+")");break}A%2===1&&(s.left!==s.top&&(S=s.left,s.left=s.top,s.top=S),s.width!==s.height&&(S=s.width,s.width=s.height,s.height=S)),x.length&&(i=Eu(i,'<g transform="'+x.join(" ")+'">',"</g>"))});const a=r.width,l=r.height,c=s.width,d=s.height;let u,f;a===null?(f=l===null?"1em":l==="auto"?d:l,u=ci(f,c/d)):(u=a==="auto"?c:a,f=l===null?ci(u,d/c):l==="auto"?d:l);const p={},m=(b,x)=>{Tu(x)||(p[b]=x.toString())};m("width",u),m("height",f);const v=[s.left,s.top,c,d];return p.viewBox=v.join(" "),{attributes:p,viewBox:v,body:i}}const Iu=/\sid="(\S+)"/g,$u="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let Ou=0;function Lu(e,t=$u){const n=[];let r;for(;r=Iu.exec(e);)n.push(r[1]);if(!n.length)return e;const s="suffix"+(Math.random()*16777216|Date.now()).toString(16);return n.forEach(i=>{const a=typeof t=="function"?t(i):t+(Ou++).toString(),l=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e=e.replace(new RegExp('([#;"])('+l+')([")]|\\.[a-z])',"g"),"$1"+a+s+"$3")}),e=e.replace(new RegExp(s,"g"),""),e}const Er=Object.create(null);function Fu(e,t){Er[e]=t}function Tr(e){return Er[e]||Er[""]}function es(e){let t;if(typeof e.resources=="string")t=[e.resources];else if(t=e.resources,!(t instanceof Array)||!t.length)return null;return{resources:t,path:e.path||"/",maxURL:e.maxURL||500,rotate:e.rotate||750,timeout:e.timeout||5e3,random:e.random===!0,index:e.index||0,dataAfterTimeout:e.dataAfterTimeout!==!1}}const ts=Object.create(null),Tt=["https://api.simplesvg.com","https://api.unisvg.com"],dn=[];for(;Tt.length>0;)Tt.length===1||Math.random()>.5?dn.push(Tt.shift()):dn.push(Tt.pop());ts[""]=es({resources:["https://api.iconify.design"].concat(dn)});function Pu(e,t){const n=es(t);return n===null?!1:(ts[e]=n,!0)}function ns(e){return ts[e]}const Ru=()=>{let e;try{if(e=fetch,typeof e=="function")return e}catch{}};let di=Ru();function zu(e,t){const n=ns(e);if(!n)return 0;let r;if(!n.maxURL)r=0;else{let s=0;n.resources.forEach(a=>{s=Math.max(s,a.length)});const i=t+".json?icons=";r=n.maxURL-s-n.path.length-i.length}return r}function Bu(e){return e===404}const _u=(e,t,n)=>{const r=[],s=zu(e,t),i="icons";let a={type:i,provider:e,prefix:t,icons:[]},l=0;return n.forEach((c,d)=>{l+=c.length+1,l>=s&&d>0&&(r.push(a),a={type:i,provider:e,prefix:t,icons:[]},l=c.length),a.icons.push(c)}),r.push(a),r};function Vu(e){if(typeof e=="string"){const t=ns(e);if(t)return t.path}return"/"}const Hu=(e,t,n)=>{if(!di){n("abort",424);return}let r=Vu(t.provider);switch(t.type){case"icons":{const i=t.prefix,l=t.icons.join(","),c=new URLSearchParams({icons:l});r+=i+".json?"+c.toString();break}case"custom":{const i=t.uri;r+=i.slice(0,1)==="/"?i.slice(1):i;break}default:n("abort",400);return}let s=503;di(e+r).then(i=>{const a=i.status;if(a!==200){setTimeout(()=>{n(Bu(a)?"abort":"next",a)});return}return s=501,i.json()}).then(i=>{if(typeof i!="object"||i===null){setTimeout(()=>{i===404?n("abort",i):n("next",s)});return}setTimeout(()=>{n("success",i)})}).catch(()=>{n("next",s)})},Uu={prepare:_u,send:Hu};function Ka(e,t){e.forEach(n=>{const r=n.loaderCallbacks;r&&(n.loaderCallbacks=r.filter(s=>s.id!==t))})}function qu(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout(()=>{e.pendingCallbacksFlag=!1;const t=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!t.length)return;let n=!1;const r=e.provider,s=e.prefix;t.forEach(i=>{const a=i.icons,l=a.pending.length;a.pending=a.pending.filter(c=>{if(c.prefix!==s)return!0;const d=c.name;if(e.icons[d])a.loaded.push({provider:r,prefix:s,name:d});else if(e.missing.has(d))a.missing.push({provider:r,prefix:s,name:d});else return n=!0,!0;return!1}),a.pending.length!==l&&(n||Ka([e],i.id),i.callback(a.loaded.slice(0),a.missing.slice(0),a.pending.slice(0),i.abort))})}))}let Wu=0;function Ku(e,t,n){const r=Wu++,s=Ka.bind(null,n,r);if(!t.pending.length)return s;const i={id:r,icons:t,callback:e,abort:s};return n.forEach(a=>{(a.loaderCallbacks||(a.loaderCallbacks=[])).push(i)}),s}function Ju(e){const t={loaded:[],missing:[],pending:[]},n=Object.create(null);e.sort((s,i)=>s.provider!==i.provider?s.provider.localeCompare(i.provider):s.prefix!==i.prefix?s.prefix.localeCompare(i.prefix):s.name.localeCompare(i.name));let r={provider:"",prefix:"",name:""};return e.forEach(s=>{if(r.name===s.name&&r.prefix===s.prefix&&r.provider===s.provider)return;r=s;const i=s.provider,a=s.prefix,l=s.name,c=n[i]||(n[i]=Object.create(null)),d=c[a]||(c[a]=jt(i,a));let u;l in d.icons?u=t.loaded:a===""||d.missing.has(l)?u=t.missing:u=t.pending;const f={provider:i,prefix:a,name:l};u.push(f)}),t}function Yu(e,t=!0,n=!1){const r=[];return e.forEach(s=>{const i=typeof s=="string"?Ln(s,t,n):s;i&&r.push(i)}),r}const Gu={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function Qu(e,t,n,r){const s=e.resources.length,i=e.random?Math.floor(Math.random()*s):e.index;let a;if(e.random){let M=e.resources.slice(0);for(a=[];M.length>1;){const I=Math.floor(Math.random()*M.length);a.push(M[I]),M=M.slice(0,I).concat(M.slice(I+1))}a=a.concat(M)}else a=e.resources.slice(i).concat(e.resources.slice(0,i));const l=Date.now();let c="pending",d=0,u,f=null,p=[],m=[];typeof r=="function"&&m.push(r);function v(){f&&(clearTimeout(f),f=null)}function b(){c==="pending"&&(c="aborted"),v(),p.forEach(M=>{M.status==="pending"&&(M.status="aborted")}),p=[]}function x(M,I){I&&(m=[]),typeof M=="function"&&m.push(M)}function w(){return{startTime:l,payload:t,status:c,queriesSent:d,queriesPending:p.length,subscribe:x,abort:b}}function N(){c="failed",m.forEach(M=>{M(void 0,u)})}function A(){p.forEach(M=>{M.status==="pending"&&(M.status="aborted")}),p=[]}function S(M,I,B){const R=I!=="success";switch(p=p.filter(_=>_!==M),c){case"pending":break;case"failed":if(R||!e.dataAfterTimeout)return;break;default:return}if(I==="abort"){u=B,N();return}if(R){u=B,p.length||(a.length?j():N());return}if(v(),A(),!e.random){const _=e.resources.indexOf(M.resource);_!==-1&&_!==e.index&&(e.index=_)}c="completed",m.forEach(_=>{_(B)})}function j(){if(c!=="pending")return;v();const M=a.shift();if(M===void 0){if(p.length){f=setTimeout(()=>{v(),c==="pending"&&(A(),N())},e.timeout);return}N();return}const I={status:"pending",resource:M,callback:(B,R)=>{S(I,B,R)}};p.push(I),d++,f=setTimeout(j,e.rotate),n(M,t,I.callback)}return setTimeout(j),w}function Ja(e){const t={...Gu,...e};let n=[];function r(){n=n.filter(l=>l().status==="pending")}function s(l,c,d){const u=Qu(t,l,c,(f,p)=>{r(),d&&d(f,p)});return n.push(u),u}function i(l){return n.find(c=>l(c))||null}return{query:s,find:i,setIndex:l=>{t.index=l},getIndex:()=>t.index,cleanup:r}}function ui(){}const ir=Object.create(null);function Zu(e){if(!ir[e]){const t=ns(e);if(!t)return;const n=Ja(t),r={config:t,redundancy:n};ir[e]=r}return ir[e]}function Xu(e,t,n){let r,s;if(typeof e=="string"){const i=Tr(e);if(!i)return n(void 0,424),ui;s=i.send;const a=Zu(e);a&&(r=a.redundancy)}else{const i=es(e);if(i){r=Ja(i);const a=e.resources?e.resources[0]:"",l=Tr(a);l&&(s=l.send)}}return!r||!s?(n(void 0,424),ui):r.query(t,s,n)().abort}function fi(){}function ef(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout(()=>{e.iconsLoaderFlag=!1,qu(e)}))}function tf(e){const t=[],n=[];return e.forEach(r=>{(r.match(Ha)?t:n).push(r)}),{valid:t,invalid:n}}function Dt(e,t,n){function r(){const s=e.pendingIcons;t.forEach(i=>{s&&s.delete(i),e.icons[i]||e.missing.add(i)})}if(n&&typeof n=="object")try{if(!Va(e,n).length){r();return}}catch(s){console.error(s)}r(),ef(e)}function hi(e,t){e instanceof Promise?e.then(n=>{t(n)}).catch(()=>{t(null)}):t(e)}function nf(e,t){e.iconsToLoad?e.iconsToLoad=e.iconsToLoad.concat(t).sort():e.iconsToLoad=t,e.iconsQueueFlag||(e.iconsQueueFlag=!0,setTimeout(()=>{e.iconsQueueFlag=!1;const{provider:n,prefix:r}=e,s=e.iconsToLoad;if(delete e.iconsToLoad,!s||!s.length)return;const i=e.loadIcon;if(e.loadIcons&&(s.length>1||!i)){hi(e.loadIcons(s,r,n),u=>{Dt(e,s,u)});return}if(i){s.forEach(u=>{const f=i(u,r,n);hi(f,p=>{const m=p?{prefix:r,icons:{[u]:p}}:null;Dt(e,[u],m)})});return}const{valid:a,invalid:l}=tf(s);if(l.length&&Dt(e,l,null),!a.length)return;const c=r.match(Ha)?Tr(n):null;if(!c){Dt(e,a,null);return}c.prepare(n,r,a).forEach(u=>{Xu(n,u,f=>{Dt(e,u.icons,f)})})}))}const rf=(e,t)=>{const n=Yu(e,!0,Ua()),r=Ju(n);if(!r.pending.length){let c=!0;return t&&setTimeout(()=>{c&&t(r.loaded,r.missing,r.pending,fi)}),()=>{c=!1}}const s=Object.create(null),i=[];let a,l;return r.pending.forEach(c=>{const{provider:d,prefix:u}=c;if(u===l&&d===a)return;a=d,l=u,i.push(jt(d,u));const f=s[d]||(s[d]=Object.create(null));f[u]||(f[u]=[])}),r.pending.forEach(c=>{const{provider:d,prefix:u,name:f}=c,p=jt(d,u),m=p.pendingIcons||(p.pendingIcons=new Set);m.has(f)||(m.add(f),s[d][u].push(f))}),i.forEach(c=>{const d=s[c.provider][c.prefix];d.length&&nf(c,d)}),t?Ku(t,r,i):fi};function sf(e,t){const n={...e};for(const r in t){const s=t[r],i=typeof s;r in qa?(s===null||s&&(i==="string"||i==="number"))&&(n[r]=s):i===typeof n[r]&&(n[r]=r==="rotate"?s%4:s)}return n}const af=/[\s,]+/;function lf(e,t){t.split(af).forEach(n=>{switch(n.trim()){case"horizontal":e.hFlip=!0;break;case"vertical":e.vFlip=!0;break}})}function of(e,t=0){const n=e.replace(/^-?[0-9.]*/,"");function r(s){for(;s<0;)s+=4;return s%4}if(n===""){const s=parseInt(e);return isNaN(s)?0:r(s)}else if(n!==e){let s=0;switch(n){case"%":s=25;break;case"deg":s=90}if(s){let i=parseFloat(e.slice(0,e.length-n.length));return isNaN(i)?0:(i=i/s,i%1===0?r(i):0)}}return t}function cf(e,t){let n=e.indexOf("xlink:")===-1?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const r in t)n+=" "+r+'="'+t[r]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+n+">"+e+"</svg>"}function df(e){return e.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function uf(e){return"data:image/svg+xml,"+df(e)}function ff(e){return'url("'+uf(e)+'")'}let Pt;function hf(){try{Pt=window.trustedTypes.createPolicy("iconify",{createHTML:e=>e})}catch{Pt=null}}function mf(e){return Pt===void 0&&hf(),Pt?Pt.createHTML(e):e}const Ya={...Wa,inline:!1},pf={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},gf={display:"inline-block"},Dr={backgroundColor:"currentColor"},Ga={backgroundColor:"transparent"},mi={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},pi={WebkitMask:Dr,mask:Dr,background:Ga};for(const e in pi){const t=pi[e];for(const n in mi)t[e+n]=mi[n]}const xf={...Ya,inline:!0};function gi(e){return e+(e.match(/^[-0-9.]+$/)?"px":"")}const yf=(e,t,n)=>{const r=t.inline?xf:Ya,s=sf(r,t),i=t.mode||"svg",a={},l=t.style||{},c={...i==="svg"?pf:{}};if(n){const x=Ln(n,!1,!0);if(x){const w=["iconify"],N=["provider","prefix"];for(const A of N)x[A]&&w.push("iconify--"+x[A]);c.className=w.join(" ")}}for(let x in t){const w=t[x];if(w!==void 0)switch(x){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":c.ref=w;break;case"className":c[x]=(c[x]?c[x]+" ":"")+w;break;case"inline":case"hFlip":case"vFlip":s[x]=w===!0||w==="true"||w===1;break;case"flip":typeof w=="string"&&lf(s,w);break;case"color":a.color=w;break;case"rotate":typeof w=="string"?s[x]=of(w):typeof w=="number"&&(s[x]=w);break;case"ariaHidden":case"aria-hidden":w!==!0&&w!=="true"&&delete c["aria-hidden"];break;default:r[x]===void 0&&(c[x]=w)}}const d=Du(e,s),u=d.attributes;if(s.inline&&(a.verticalAlign="-0.125em"),i==="svg"){c.style={...a,...l},Object.assign(c,u);let x=0,w=t.id;return typeof w=="string"&&(w=w.replace(/-/g,"_")),c.dangerouslySetInnerHTML={__html:mf(Lu(d.body,w?()=>w+"ID"+x++:"iconifyReact"))},y.createElement("svg",c)}const{body:f,width:p,height:m}=e,v=i==="mask"||(i==="bg"?!1:f.indexOf("currentColor")!==-1),b=cf(f,{...u,width:p+"",height:m+""});return c.style={...a,"--svg":ff(b),width:gi(u.width),height:gi(u.height),...gf,...v?Dr:Ga,...l},y.createElement("span",c)};Ua(!0);Fu("",Uu);if(typeof document<"u"&&typeof window<"u"){const e=window;if(e.IconifyPreload!==void 0){const t=e.IconifyPreload,n="Invalid IconifyPreload syntax.";typeof t=="object"&&t!==null&&(t instanceof Array?t:[t]).forEach(r=>{try{(typeof r!="object"||r===null||r instanceof Array||typeof r.icons!="object"||typeof r.prefix!="string"||!Su(r))&&console.error(n)}catch{console.error(n)}})}if(e.IconifyProviders!==void 0){const t=e.IconifyProviders;if(typeof t=="object"&&t!==null)for(let n in t){const r="IconifyProviders["+n+"] is invalid.";try{const s=t[n];if(typeof s!="object"||!s||s.resources===void 0)continue;Pu(n,s)||console.error(r)}catch{console.error(r)}}}}function Qa(e){const[t,n]=y.useState(!!e.ssr),[r,s]=y.useState({});function i(m){if(m){const v=e.icon;if(typeof v=="object")return{name:"",data:v};const b=oi(v);if(b)return{name:v,data:b}}return{name:""}}const[a,l]=y.useState(i(!!e.ssr));function c(){const m=r.callback;m&&(m(),s({}))}function d(m){if(JSON.stringify(a)!==JSON.stringify(m))return c(),l(m),!0}function u(){var m;const v=e.icon;if(typeof v=="object"){d({name:"",data:v});return}const b=oi(v);if(d({name:v,data:b}))if(b===void 0){const x=rf([v],u);s({callback:x})}else b&&((m=e.onLoad)===null||m===void 0||m.call(e,v))}y.useEffect(()=>(n(!0),c),[]),y.useEffect(()=>{t&&u()},[e.icon,t]);const{name:f,data:p}=a;return p?yf({...Xr,...p},e,f):e.children?e.children:e.fallback?e.fallback:y.createElement("span",{})}const H=y.forwardRef((e,t)=>Qa({...e,_ref:t}));y.forwardRef((e,t)=>Qa({inline:!0,...e,_ref:t}));const ar=({icon:e,children:t,testId:n})=>o.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600","data-testid":n,children:[o.jsx(H,{icon:e,width:20,className:"text-default-500"}),o.jsx("span",{children:t})]}),bf=({classes:e="",name:t,imageUrl:n,eventDate:r,eventTime:s,location:i,description:a,showImage:l=!1,imageLoading:c="eager",showMoreButtonClassName:d,labels:u})=>{const[f,p]=y.useState(!1),[m,v]=y.useState(!1),b=y.useRef(null);return y.useEffect(()=>{const x=()=>{if(b.current){const w=b.current.scrollHeight>b.current.clientHeight;v(w)}};return x(),window.addEventListener("resize",x),()=>window.removeEventListener("resize",x)},[a]),o.jsxs(h.Card,{className:h.cn("border-0 shadow-none",e),"data-testid":"event-details-root",children:[o.jsxs(h.CardHeader,{className:"pt-2 pb-0 flex-col items-start space-y-2","data-testid":"event-details-header",children:[l&&n&&o.jsx("div",{className:"w-full aspect-[3/1] overflow-hidden rounded-xl","data-testid":"event-details-image-wrapper",children:o.jsx(h.Image,{removeWrapper:!0,loading:c,alt:`Event image for ${t}`,className:"w-full h-full object-cover object-center",src:n,"data-testid":"event-details-image"})}),o.jsx("h2",{className:"font-semibold text-xl text-gray-800","data-testid":"event-details-title",children:t})]}),o.jsxs(h.CardBody,{className:"py-3 space-y-3","data-testid":"event-details-body",children:[o.jsx("h3",{className:"font-semibold text-base text-gray-700","data-testid":"event-details-info-label",children:u.eventInformation}),o.jsxs("div",{className:"flex flex-wrap gap-4","data-testid":"event-details-info",children:[r&&o.jsx(ar,{icon:"solar:calendar-minimalistic-linear",testId:"event-details-date",children:r}),s&&o.jsx(ar,{icon:"solar:clock-circle-linear",testId:"event-details-time",children:s}),i&&o.jsx(ar,{icon:"solar:map-point-linear",testId:"event-details-location",children:i})]}),a&&o.jsxs("div",{className:"relative","data-testid":"event-details-description-wrapper",children:[o.jsxs("div",{className:"relative",children:[o.jsx("div",{ref:b,className:h.cn("text-sm text-gray-700 leading-relaxed transition-all",!f&&"line-clamp-3"),"data-testid":"event-details-description",dangerouslySetInnerHTML:{__html:a}}),!f&&m&&o.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"})]}),(m||f)&&o.jsx("div",{className:"flex justify-end mt-1",children:o.jsx(W,{onPress:()=>p(!f),variant:"light",className:h.cn("text-primary",d),startContent:o.jsx(H,{icon:f?"solar:eye-closed-linear":"solar:eye-linear",width:20}),"data-testid":"event-details-toggle-description",children:f?u.showLess||"Hide":u.showMore||"Show"})})]})]})]})};function Za(e,t="en-US",n="USD"){try{return new Intl.NumberFormat(t,{style:"currency",currency:n,minimumFractionDigits:2,maximumFractionDigits:2}).format(e)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${e.toFixed(2)}`}}function vf(e){const t=e.replace(/[^\d.,-]/g,""),n=t.match(/,\d{1,2}$/);let r;n?r=t.replace(/\./g,"").replace(",","."):r=t.replace(/,/g,"");const s=parseFloat(r);return isNaN(s)?null:s}const wf={person:"Person",people:"People",tickets:"Tickets:",soldOut:"Sold Out",maxReached:"Maximum number of tickets allowed reached"},nn=e=>typeof e=="number"&&!isNaN(e),rs=({offer:e,quantity:t,defaultQuantity:n=0,onQuantityChange:r,currency:s="USD",locale:i="en-US",labels:a,slots:l,isDisabled:c=!1,buttonVariant:d="bordered",buttonColor:u="default",showCard:f=!0,showDescription:p=!0,showPeopleCount:m=!0,showPrice:v=!0,classNames:b={},"data-testid":x,selectedColor:w="default"})=>{const N={...wf,...a},[A,S]=y.useState(n),j=t!==void 0?t:A,M=ie=>{if(c)return;const fe=Math.max(0,j+ie);t===void 0&&S(fe),r?.(e.id,fe)},I=y.useMemo(()=>!nn(e.totalTicketsSold)||!nn(e.ticketsAllowed)?!1:e.totalTicketsSold>=e.ticketsAllowed,[e.totalTicketsSold,e.ticketsAllowed]),B=y.useMemo(()=>I||!nn(e.ticketsAllowed)?!1:j>=e.ticketsAllowed-(e.totalTicketsSold??0),[I,e.ticketsAllowed,e.totalTicketsSold,j]),R=Za(e.price,i,s),_=()=>l?.renderName?l.renderName(e.name,e):o.jsx("h2",{"data-testid":"offer-card-name",className:h.cn("text-base font-medium",b.name),children:e.name}),E=()=>v?l?.renderPrice?l.renderPrice(e.price,R,e):o.jsx("p",{"data-testid":"offer-card-price",className:h.cn("text-primary text-base mt-1",b.price),children:R}):null,T=()=>!p||!e.description?null:l?.renderDescription?l.renderDescription(e.description,e):o.jsx("p",{"data-testid":"offer-card-description",className:h.cn("mb-4 text-sm text-gray-700 leading-relaxed",b.description),children:e.description}),O=()=>{if(!m||!nn(e.numberOfPeople)||e.numberOfPeople<=0)return null;const ie=e.numberOfPeople===1?N.person:N.people;return l?.renderPeopleCount?l.renderPeopleCount(e.numberOfPeople,ie,e):o.jsxs("p",{"data-testid":"offer-card-people-count",className:h.cn("text-sm text-gray-600 flex items-center mt-2",b.peopleCount),children:[o.jsx(H,{icon:e.numberOfPeople<=1?"solar:user-rounded-outline":"solar:users-group-rounded-outline",width:20,className:"mr-1"}),e.numberOfPeople," ",ie]})},F=()=>{const ie=j===0||c,fe=B||c;return l?.renderQuantitySelector?l.renderQuantitySelector({quantity:j,onIncrement:()=>M(1),onDecrement:()=>M(-1),isDecrementDisabled:ie,isIncrementDisabled:fe,isDisabled:c}):o.jsxs("div",{className:h.cn("flex items-center gap-2",b.quantitySelector),children:[o.jsx(W,{"data-testid":"offer-card-decrement-button",onPress:()=>M(-1),isDisabled:ie,variant:d,color:j>0?w:u,radius:"full",isIconOnly:!0,size:"sm","aria-label":"Decrease quantity",children:o.jsx(H,{icon:"gravity-ui:minus",width:16})}),o.jsx("span",{"data-testid":"offer-card-quantity",className:h.cn("min-w-[2rem] text-center font-medium"),children:j}),o.jsx(W,{"data-testid":"offer-card-increment-button",onPress:()=>M(1),isDisabled:fe,variant:d,color:j>0?w:u,radius:"full",isIconOnly:!0,size:"sm","aria-label":"Increase quantity",children:o.jsx(H,{icon:"gravity-ui:plus",width:16})})]})},K=()=>l?.renderSoldOut?l.renderSoldOut(N.soldOut):o.jsx(h.Chip,{"data-testid":"offer-card-sold-out-chip",color:"danger",className:h.cn("gap-2 px-4 h-8",b.soldOut),startContent:o.jsx(H,{icon:"gravity-ui:circle-info-fill",width:14}),children:o.jsx("span",{className:"font-medium text-sm",children:N.soldOut})}),X=()=>l?.renderMaxReachedAlert?l.renderMaxReachedAlert(N.maxReached):o.jsx(h.Chip,{"data-testid":"offer-card-max-reached-chip",variant:"flat",color:"warning",classNames:{base:"gap-2 px-4 h-10",content:"text-black"},className:h.cn(" text-black! gap-2 px-4 h-10",b.maxReachedAlert),startContent:o.jsx(H,{icon:"gravity-ui:triangle-exclamation-fill",className:"text-black",width:16}),children:o.jsx("span",{className:"font-medium text-sm",children:N.maxReached})}),J=o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-1 xl:grid-cols-3 lg:grid-cols-3 gap-2 items-start",children:[o.jsxs("div",{className:h.cn("h-full col-span-2",I?"opacity-50 pointer-events-none select-none":""),children:[_(),E(),o.jsxs("div",{className:h.cn("md:col-span-1 xl:col-span-2 lg:col-span-1 mb-2",I?"opacity-50 pointer-events-none select-none":""),children:[O(),T()]})]}),o.jsx("div",{className:"space-x-2 pt-0 pb-2 md:p-2 h-full flex items-center justify-start md:justify-start lg:justify-end",children:I?K():F()})]}),se=B&&!I&&o.jsx(Le.motion.div,{className:"w-full sm:max-w-[60%] md:max-w-[60%] lg:max-w-[60%]",initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.3},children:X()});return f?o.jsxs(h.Card,{className:h.cn("w-full",b.base),"data-testid":x||`offer-card-${e.id}`,children:[o.jsx(h.CardBody,{className:h.cn("pt-1 pb-0",b.body),children:J}),o.jsx(Le.AnimatePresence,{children:se&&o.jsx(h.CardFooter,{className:h.cn("w-full mt-0 pt-0",b.footer),children:se})})]}):o.jsxs("div",{className:h.cn("w-full",b.base),"data-testid":x||`offer-card-${e.id}`,children:[o.jsx("div",{className:h.cn("pt-1 pb-0",b.body),children:J}),o.jsx(Le.AnimatePresence,{children:se&&o.jsx("div",{className:h.cn("w-full mt-0 pt-0",b.footer),children:se})})]})};rs.displayName="OfferCard";const Xa=({message:e="No offers available.",icon:t="solar:ticket-sale-outline",iconSize:n=48,showCard:r=!0,classNames:s={},renderEmpty:i})=>{if(i){const l=i();return r?o.jsx(h.Card,{"data-testid":"offer-card-empty",className:h.cn("w-full",s.base),children:o.jsx(h.CardBody,{"data-testid":"offer-card-empty-body",children:l})}):o.jsx("div",{"data-testid":"offer-card-empty",className:h.cn("w-full",s.base),children:l})}const a=o.jsxs("div",{"data-testid":"offer-card-empty-content",className:h.cn("flex flex-col items-center justify-center p-8 text-center text-gray-500",s.content),children:[o.jsx(H,{"data-testid":"offer-card-empty-icon",icon:t,width:n,className:h.cn("mb-4",s.icon)}),o.jsx("h3",{"data-testid":"offer-card-empty-message",className:h.cn("text-lg",s.message),children:e})]});return r?o.jsx(h.Card,{"data-testid":"offer-card-empty",className:h.cn("w-full",s.base),children:o.jsx(h.CardBody,{"data-testid":"offer-card-empty-body",children:a})}):o.jsx("div",{"data-testid":"offer-card-empty",className:h.cn("w-full",s.base),children:a})};Xa.displayName="OfferCardEmpty";const kf={title:"Error Fetching Offers",description:"An error occurred while fetching offers."},el=({error:e,labels:t,showCard:n=!0,color:r="danger",classNames:s={}})=>{const i={...kf,...t},a=o.jsx(h.Alert,{"data-testid":"offer-card-error-alert",color:r,title:i.title,description:e||i.description,className:s.alert});return n?o.jsx(h.Card,{"data-testid":"offer-card-error",className:h.cn("w-full",s.base),children:o.jsx(h.CardBody,{"data-testid":"offer-card-error-body",children:a})}):o.jsx("div",{"data-testid":"offer-card-error",className:h.cn("w-full",s.base),children:a})};el.displayName="OfferCardError";const Nf={1:"space-y-1",2:"space-y-2",3:"space-y-3",4:"space-y-4",5:"space-y-5",6:"space-y-6"},tl=({quantity:e=2,gap:t=4,classNames:n={}})=>{const r=Nf[t];return o.jsx("div",{"data-testid":"offer-card-skeleton-container",className:h.cn(r,n.base),children:Array.from({length:e}).map((s,i)=>o.jsxs(h.Card,{"data-testid":`offer-card-skeleton-${i}`,className:h.cn("w-full",n.card),children:[o.jsx(h.CardHeader,{"data-testid":`offer-card-skeleton-header-${i}`,className:"flex justify-between items-start pb-0",children:o.jsxs("div",{className:"space-y-2 w-full",children:[o.jsx(h.Skeleton,{"data-testid":`offer-card-skeleton-title-${i}`,className:"w-1/3 rounded-lg",children:o.jsx("div",{className:"h-4 bg-default-200 rounded-lg"})}),o.jsx(h.Skeleton,{"data-testid":`offer-card-skeleton-subtitle-${i}`,className:"w-1/4 rounded-lg",children:o.jsx("div",{className:"h-3 bg-default-300 rounded-lg"})})]})}),o.jsx(h.CardBody,{"data-testid":`offer-card-skeleton-body-${i}`,className:"pt-2 pb-0",children:o.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-2 items-start",children:[o.jsxs("div",{className:"xl:col-span-2 space-y-2",children:[o.jsx(h.Skeleton,{"data-testid":`offer-card-skeleton-people-${i}`,className:"w-1/4 rounded-lg",children:o.jsx("div",{className:"h-4 bg-default-300 rounded-lg"})}),o.jsx(h.Skeleton,{"data-testid":`offer-card-skeleton-description-${i}`,className:"w-3/4 rounded-lg",children:o.jsx("div",{className:"h-4 bg-default-200 rounded-lg"})})]}),o.jsx("div",{className:"flex items-start justify-end",children:o.jsxs("div",{"data-testid":`offer-card-skeleton-controls-${i}`,className:"flex items-center justify-end gap-2 w-full px-4 py-2",children:[o.jsx(h.Skeleton,{"data-testid":`offer-card-skeleton-label-${i}`,className:"w-24 h-4 rounded-md bg-default-200"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(h.Skeleton,{"data-testid":`offer-card-skeleton-btn-dec-${i}`,className:"w-8 h-8 rounded-md bg-default-300"}),o.jsx(h.Skeleton,{"data-testid":`offer-card-skeleton-btn-qty-${i}`,className:"w-8 h-8 rounded-md bg-default-200"}),o.jsx(h.Skeleton,{"data-testid":`offer-card-skeleton-btn-inc-${i}`,className:"w-8 h-8 rounded-md bg-default-300"})]})]})})]})})]},i))})};tl.displayName="OfferCardSkeleton";const nl={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.15,delayChildren:.1}}},rl={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"}}},Sf={1:"gap-1",2:"gap-2",3:"gap-3",4:"gap-4",5:"gap-5",6:"gap-6"},sl=({offers:e=[],selection:t,defaultSelection:n={},onSelectionChange:r,onQuantityChange:s,currency:i="USD",locale:a="en-US",labels:l,slots:c,isDisabled:d=!1,buttonVariant:u="bordered",buttonColor:f="default",showCard:p=!0,animated:m=!0,gap:v=2,classNames:b={}})=>{const[x,w]=y.useState(n),N=t!==void 0?t:x,A=y.useCallback((B,R)=>{const _={...N,[B]:Math.max(0,R)};t===void 0&&w(_),r?.(_),s?.(B,_[B])},[N,t,r,s]),S=[...e].sort((B,R)=>(B.position??0)-(R.position??0)),j=Sf[v],M=h.cn("grid mx-auto pt-2",j,b.base),I=B=>o.jsx(rs,{offer:B,quantity:N[B.id]||0,onQuantityChange:A,currency:i,locale:a,labels:l,slots:c,isDisabled:d,buttonVariant:u,buttonColor:f,showCard:p,classNames:b.card},B.id);return m?o.jsx(Le.motion.div,{"data-testid":"offer-card-list",className:M,variants:nl,initial:"hidden",animate:"show",children:o.jsx(Le.AnimatePresence,{children:S.map(B=>o.jsx(Le.motion.div,{"data-testid":`offer-card-list-item-${B.id}`,className:b.cardWrapper,variants:rl,exit:{opacity:0,y:-20},transition:{duration:.3},children:I(B)},B.id))})}):o.jsx("div",{"data-testid":"offer-card-list",className:M,children:S.map(I)})};sl.displayName="OfferCardList";var Gt=e=>e.type==="checkbox",ut=e=>e instanceof Date,Ae=e=>e==null;const il=e=>typeof e=="object";var xe=e=>!Ae(e)&&!Array.isArray(e)&&il(e)&&!ut(e),al=e=>xe(e)&&e.target?Gt(e.target)?e.target.checked:e.target.value:e,Cf=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,ll=(e,t)=>e.has(Cf(t)),jf=e=>{const t=e.constructor&&e.constructor.prototype;return xe(t)&&t.hasOwnProperty("isPrototypeOf")},ss=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function me(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(ss&&(e instanceof Blob||t))return e;const n=Array.isArray(e);if(!n&&!(xe(e)&&jf(e)))return e;const r=n?[]:Object.create(Object.getPrototypeOf(e));for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r[s]=me(e[s]));return r}var Fn=e=>/^\w*$/.test(e),de=e=>e===void 0,is=e=>Array.isArray(e)?e.filter(Boolean):[],as=e=>is(e.replace(/["|']|\]/g,"").split(/\.|\[/)),L=(e,t,n)=>{if(!t||!xe(e))return n;const r=(Fn(t)?[t]:as(t)).reduce((s,i)=>Ae(s)?s:s[i],e);return de(r)||r===e?de(e[t])?n:e[t]:r},Ee=e=>typeof e=="boolean",je=e=>typeof e=="function",oe=(e,t,n)=>{let r=-1;const s=Fn(t)?[t]:as(t),i=s.length,a=i-1;for(;++r<i;){const l=s[r];let c=n;if(r!==a){const d=e[l];c=xe(d)||Array.isArray(d)?d:isNaN(+s[r+1])?{}:[]}if(l==="__proto__"||l==="constructor"||l==="prototype")return;e[l]=c,e=e[l]}};const Nn={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},Pe={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Ue={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},ol=y.createContext(null);ol.displayName="HookFormControlContext";const ls=()=>y.useContext(ol);var cl=(e,t,n,r=!0)=>{const s={defaultValues:t._defaultValues};for(const i in e)Object.defineProperty(s,i,{get:()=>{const a=i;return t._proxyFormState[a]!==Pe.all&&(t._proxyFormState[a]=!r||Pe.all),n&&(n[a]=!0),e[a]}});return s};const os=typeof window<"u"?y.useLayoutEffect:y.useEffect;function Af(e){const t=ls(),{control:n=t,disabled:r,name:s,exact:i}=e||{},[a,l]=y.useState(n._formState),c=y.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return os(()=>n._subscribe({name:s,formState:c.current,exact:i,callback:d=>{!r&&l({...n._formState,...d})}}),[s,r,i]),y.useEffect(()=>{c.current.isValid&&n._setValid(!0)},[n]),y.useMemo(()=>cl(a,n,c.current,!1),[a,n])}var De=e=>typeof e=="string",Ir=(e,t,n,r,s)=>De(e)?(r&&t.watch.add(e),L(n,e,s)):Array.isArray(e)?e.map(i=>(r&&t.watch.add(i),L(n,i))):(r&&(t.watchAll=!0),n),$r=e=>Ae(e)||!il(e);function Re(e,t,n=new WeakSet){if($r(e)||$r(t))return Object.is(e,t);if(ut(e)&&ut(t))return Object.is(e.getTime(),t.getTime());const r=Object.keys(e),s=Object.keys(t);if(r.length!==s.length)return!1;if(n.has(e)||n.has(t))return!0;n.add(e),n.add(t);for(const i of r){const a=e[i];if(!s.includes(i))return!1;if(i!=="ref"){const l=t[i];if(ut(a)&&ut(l)||xe(a)&&xe(l)||Array.isArray(a)&&Array.isArray(l)?!Re(a,l,n):!Object.is(a,l))return!1}}return!0}function Mf(e){const t=ls(),{control:n=t,name:r,defaultValue:s,disabled:i,exact:a,compute:l}=e||{},c=y.useRef(s),d=y.useRef(l),u=y.useRef(void 0),f=y.useRef(n),p=y.useRef(r);d.current=l;const[m,v]=y.useState(()=>{const S=n._getWatch(r,c.current);return d.current?d.current(S):S}),b=y.useCallback(S=>{const j=Ir(r,n._names,S||n._formValues,!1,c.current);return d.current?d.current(j):j},[n._formValues,n._names,r]),x=y.useCallback(S=>{if(!i){const j=Ir(r,n._names,S||n._formValues,!1,c.current);if(d.current){const M=d.current(j);Re(M,u.current)||(v(M),u.current=M)}else v(j)}},[n._formValues,n._names,i,r]);os(()=>((f.current!==n||!Re(p.current,r))&&(f.current=n,p.current=r,x()),n._subscribe({name:r,formState:{values:!0},exact:a,callback:S=>{x(S.values)}})),[n,a,r,x]),y.useEffect(()=>n._removeUnmounted());const w=f.current!==n,N=p.current,A=y.useMemo(()=>{if(i)return null;const S=!w&&!Re(N,r);return w||S?b():null},[i,w,r,N,b]);return A!==null?A:m}function Ef(e){const t=ls(),{name:n,disabled:r,control:s=t,shouldUnregister:i,defaultValue:a,exact:l=!0}=e,c=ll(s._names.array,n),d=y.useMemo(()=>L(s._formValues,n,L(s._defaultValues,n,a)),[s,n,a]),u=Mf({control:s,name:n,defaultValue:d,exact:l}),f=Af({control:s,name:n,exact:l}),p=y.useRef(e),m=y.useRef(void 0),v=y.useRef(s.register(n,{...e.rules,value:u,...Ee(e.disabled)?{disabled:e.disabled}:{}}));p.current=e;const b=y.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!L(f.errors,n)},isDirty:{enumerable:!0,get:()=>!!L(f.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!L(f.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!L(f.validatingFields,n)},error:{enumerable:!0,get:()=>L(f.errors,n)}}),[f,n]),x=y.useCallback(S=>v.current.onChange({target:{value:al(S),name:n},type:Nn.CHANGE}),[n]),w=y.useCallback(()=>v.current.onBlur({target:{value:L(s._formValues,n),name:n},type:Nn.BLUR}),[n,s._formValues]),N=y.useCallback(S=>{const j=L(s._fields,n);j&&j._f&&S&&(j._f.ref={focus:()=>je(S.focus)&&S.focus(),select:()=>je(S.select)&&S.select(),setCustomValidity:M=>je(S.setCustomValidity)&&S.setCustomValidity(M),reportValidity:()=>je(S.reportValidity)&&S.reportValidity()})},[s._fields,n]),A=y.useMemo(()=>({name:n,value:u,...Ee(r)||f.disabled?{disabled:f.disabled||r}:{},onChange:x,onBlur:w,ref:N}),[n,r,f.disabled,x,w,N,u]);return y.useEffect(()=>{const S=s._options.shouldUnregister||i,j=m.current;j&&j!==n&&!c&&s.unregister(j),s.register(n,{...p.current.rules,...Ee(p.current.disabled)?{disabled:p.current.disabled}:{}});const M=(I,B)=>{const R=L(s._fields,I);R&&R._f&&(R._f.mount=B)};if(M(n,!0),S){const I=me(L(s._options.defaultValues,n,p.current.defaultValue));oe(s._defaultValues,n,I),de(L(s._formValues,n))&&oe(s._formValues,n,I)}return!c&&s.register(n),m.current=n,()=>{(c?S&&!s._state.action:S)?s.unregister(n):M(n,!1)}},[n,s,c,i]),y.useEffect(()=>{s._setDisabledField({disabled:r,name:n})},[r,n,s]),y.useMemo(()=>({field:A,formState:f,fieldState:b}),[A,f,b])}const Tf=y.createContext(null);Tf.displayName="HookFormContext";var Df=(e,t,n,r,s)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:s||!0}}:{},Rt=e=>Array.isArray(e)?e:[e],xi=()=>{let e=[];return{get observers(){return e},next:s=>{for(const i of e)i.next&&i.next(s)},subscribe:s=>(e.push(s),{unsubscribe:()=>{e=e.filter(i=>i!==s)}}),unsubscribe:()=>{e=[]}}};function dl(e,t){const n={};for(const r in e)if(e.hasOwnProperty(r)){const s=e[r],i=t[r];if(s&&xe(s)&&i){const a=dl(s,i);xe(a)&&(n[r]=a)}else e[r]&&(n[r]=i)}return n}var Se=e=>xe(e)&&!Object.keys(e).length,cs=e=>e.type==="file",Sn=e=>{if(!ss)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},ul=e=>e.type==="select-multiple",ds=e=>e.type==="radio",If=e=>ds(e)||Gt(e),lr=e=>Sn(e)&&e.isConnected;function $f(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=de(e)?r++:e[t[r++]];return e}function Of(e){for(const t in e)if(e.hasOwnProperty(t)&&!de(e[t]))return!1;return!0}function pe(e,t){const n=Array.isArray(t)?t:Fn(t)?[t]:as(t),r=n.length===1?e:$f(e,n),s=n.length-1,i=n[s];return r&&delete r[i],s!==0&&(xe(r)&&Se(r)||Array.isArray(r)&&Of(r))&&pe(e,n.slice(0,-1)),e}var Lf=e=>{for(const t in e)if(je(e[t]))return!0;return!1};function fl(e){return Array.isArray(e)||xe(e)&&!Lf(e)}function Or(e,t={}){for(const n in e){const r=e[n];fl(r)?(t[n]=Array.isArray(r)?[]:{},Or(r,t[n])):de(r)||(t[n]=!0)}return t}function Nt(e,t,n){n||(n=Or(t));for(const r in e){const s=e[r];if(fl(s))de(t)||$r(n[r])?n[r]=Or(s,Array.isArray(s)?[]:{}):Nt(s,Ae(t)?{}:t[r],n[r]);else{const i=t[r];n[r]=!Re(s,i)}}return n}const yi={value:!1,isValid:!1},bi={value:!0,isValid:!0};var hl=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!de(e[0].attributes.value)?de(e[0].value)||e[0].value===""?bi:{value:e[0].value,isValid:!0}:bi:yi}return yi},ml=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>de(e)?e:t?e===""?NaN:e&&+e:n&&De(e)?new Date(e):r?r(e):e;const vi={isValid:!1,value:null};var pl=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,vi):vi;function wi(e){const t=e.ref;return cs(t)?t.files:ds(t)?pl(e.refs).value:ul(t)?[...t.selectedOptions].map(({value:n})=>n):Gt(t)?hl(e.refs).value:ml(de(t.value)?e.ref.value:t.value,e)}var Ff=(e,t,n,r)=>{const s={};for(const i of e){const a=L(t,i);a&&oe(s,i,a._f)}return{criteriaMode:n,names:[...e],fields:s,shouldUseNativeValidation:r}},Cn=e=>e instanceof RegExp,It=e=>de(e)?e:Cn(e)?e.source:xe(e)?Cn(e.value)?e.value.source:e.value:e,ki=e=>({isOnSubmit:!e||e===Pe.onSubmit,isOnBlur:e===Pe.onBlur,isOnChange:e===Pe.onChange,isOnAll:e===Pe.all,isOnTouch:e===Pe.onTouched});const Ni="AsyncFunction";var Pf=e=>!!e&&!!e.validate&&!!(je(e.validate)&&e.validate.constructor.name===Ni||xe(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===Ni)),Rf=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),Si=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const zt=(e,t,n,r)=>{for(const s of n||Object.keys(e)){const i=L(e,s);if(i){const{_f:a,...l}=i;if(a){if(a.refs&&a.refs[0]&&t(a.refs[0],s)&&!r)return!0;if(a.ref&&t(a.ref,a.name)&&!r)return!0;if(zt(l,t))break}else if(xe(l)&&zt(l,t))break}}};function Ci(e,t,n){const r=L(e,n);if(r||Fn(n))return{error:r,name:n};const s=n.split(".");for(;s.length;){const i=s.join("."),a=L(t,i),l=L(e,i);if(a&&!Array.isArray(a)&&n!==i)return{name:n};if(l&&l.type)return{name:i,error:l};if(l&&l.root&&l.root.type)return{name:`${i}.root`,error:l.root};s.pop()}return{name:n}}var zf=(e,t,n,r)=>{n(e);const{name:s,...i}=e;return Se(i)||Object.keys(i).length>=Object.keys(t).length||Object.keys(i).find(a=>t[a]===(!r||Pe.all))},Bf=(e,t,n)=>!e||!t||e===t||Rt(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r))),_f=(e,t,n,r,s)=>s.isOnAll?!1:!n&&s.isOnTouch?!(t||e):(n?r.isOnBlur:s.isOnBlur)?!e:(n?r.isOnChange:s.isOnChange)?e:!0,Vf=(e,t)=>!is(L(e,t)).length&&pe(e,t),Hf=(e,t,n)=>{const r=Rt(L(e,n));return oe(r,"root",t[n]),oe(e,n,r),e};function ji(e,t,n="validate"){if(De(e)||Array.isArray(e)&&e.every(De)||Ee(e)&&!e)return{type:n,message:De(e)?e:"",ref:t}}var bt=e=>xe(e)&&!Cn(e)?e:{value:e,message:""},Ai=async(e,t,n,r,s,i)=>{const{ref:a,refs:l,required:c,maxLength:d,minLength:u,min:f,max:p,pattern:m,validate:v,name:b,valueAsNumber:x,mount:w}=e._f,N=L(n,b);if(!w||t.has(b))return{};const A=l?l[0]:a,S=T=>{s&&A.reportValidity&&(A.setCustomValidity(Ee(T)?"":T||""),A.reportValidity())},j={},M=ds(a),I=Gt(a),B=M||I,R=(x||cs(a))&&de(a.value)&&de(N)||Sn(a)&&a.value===""||N===""||Array.isArray(N)&&!N.length,_=Df.bind(null,b,r,j),E=(T,O,F,K=Ue.maxLength,X=Ue.minLength)=>{const J=T?O:F;j[b]={type:T?K:X,message:J,ref:a,..._(T?K:X,J)}};if(i?!Array.isArray(N)||!N.length:c&&(!B&&(R||Ae(N))||Ee(N)&&!N||I&&!hl(l).isValid||M&&!pl(l).isValid)){const{value:T,message:O}=De(c)?{value:!!c,message:c}:bt(c);if(T&&(j[b]={type:Ue.required,message:O,ref:A,..._(Ue.required,O)},!r))return S(O),j}if(!R&&(!Ae(f)||!Ae(p))){let T,O;const F=bt(p),K=bt(f);if(!Ae(N)&&!isNaN(N)){const X=a.valueAsNumber||N&&+N;Ae(F.value)||(T=X>F.value),Ae(K.value)||(O=X<K.value)}else{const X=a.valueAsDate||new Date(N),J=fe=>new Date(new Date().toDateString()+" "+fe),se=a.type=="time",ie=a.type=="week";De(F.value)&&N&&(T=se?J(N)>J(F.value):ie?N>F.value:X>new Date(F.value)),De(K.value)&&N&&(O=se?J(N)<J(K.value):ie?N<K.value:X<new Date(K.value))}if((T||O)&&(E(!!T,F.message,K.message,Ue.max,Ue.min),!r))return S(j[b].message),j}if((d||u)&&!R&&(De(N)||i&&Array.isArray(N))){const T=bt(d),O=bt(u),F=!Ae(T.value)&&N.length>+T.value,K=!Ae(O.value)&&N.length<+O.value;if((F||K)&&(E(F,T.message,O.message),!r))return S(j[b].message),j}if(m&&!R&&De(N)){const{value:T,message:O}=bt(m);if(Cn(T)&&!N.match(T)&&(j[b]={type:Ue.pattern,message:O,ref:a,..._(Ue.pattern,O)},!r))return S(O),j}if(v){if(je(v)){const T=await v(N,n),O=ji(T,A);if(O&&(j[b]={...O,..._(Ue.validate,O.message)},!r))return S(O.message),j}else if(xe(v)){let T={};for(const O in v){if(!Se(T)&&!r)break;const F=ji(await v[O](N,n),A,O);F&&(T={...F,..._(O,F.message)},S(F.message),r&&(j[b]=T))}if(!Se(T)&&(j[b]={ref:A,...T},!r))return j}}return S(!0),j};const Uf={mode:Pe.onSubmit,reValidateMode:Pe.onChange,shouldFocusError:!0};function qf(e={}){let t={...Uf,...e},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:je(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},s=xe(t.defaultValues)||xe(t.values)?me(t.defaultValues||t.values)||{}:{},i=t.shouldUnregister?{}:me(s),a={action:!1,mount:!1,watch:!1,keepIsValid:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},c,d=0;const u={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},f={...u};let p={...f};const m={array:xi(),state:xi()},v=t.criteriaMode===Pe.all,b=g=>k=>{clearTimeout(d),d=setTimeout(g,k)},x=async g=>{if(!a.keepIsValid&&!t.disabled&&(f.isValid||p.isValid||g)){let k;t.resolver?(k=Se((await B()).errors),w()):k=await _(r,!0),k!==n.isValid&&m.state.next({isValid:k})}},w=(g,k)=>{!t.disabled&&(f.isValidating||f.validatingFields||p.isValidating||p.validatingFields)&&((g||Array.from(l.mount)).forEach(C=>{C&&(k?oe(n.validatingFields,C,k):pe(n.validatingFields,C))}),m.state.next({validatingFields:n.validatingFields,isValidating:!Se(n.validatingFields)}))},N=(g,k=[],C,P,$=!0,D=!0)=>{if(P&&C&&!t.disabled){if(a.action=!0,D&&Array.isArray(L(r,g))){const V=C(L(r,g),P.argA,P.argB);$&&oe(r,g,V)}if(D&&Array.isArray(L(n.errors,g))){const V=C(L(n.errors,g),P.argA,P.argB);$&&oe(n.errors,g,V),Vf(n.errors,g)}if((f.touchedFields||p.touchedFields)&&D&&Array.isArray(L(n.touchedFields,g))){const V=C(L(n.touchedFields,g),P.argA,P.argB);$&&oe(n.touchedFields,g,V)}(f.dirtyFields||p.dirtyFields)&&(n.dirtyFields=Nt(s,i)),m.state.next({name:g,isDirty:T(g,k),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else oe(i,g,k)},A=(g,k)=>{oe(n.errors,g,k),m.state.next({errors:n.errors})},S=g=>{n.errors=g,m.state.next({errors:n.errors,isValid:!1})},j=(g,k,C,P)=>{const $=L(r,g);if($){const D=L(i,g,de(C)?L(s,g):C);de(D)||P&&P.defaultChecked||k?oe(i,g,k?D:wi($._f)):K(g,D),a.mount&&!a.action&&x()}},M=(g,k,C,P,$)=>{let D=!1,V=!1;const ee={name:g};if(!t.disabled){if(!C||P){(f.isDirty||p.isDirty)&&(V=n.isDirty,n.isDirty=ee.isDirty=T(),D=V!==ee.isDirty);const te=Re(L(s,g),k);V=!!L(n.dirtyFields,g),te?pe(n.dirtyFields,g):oe(n.dirtyFields,g,!0),ee.dirtyFields=n.dirtyFields,D=D||(f.dirtyFields||p.dirtyFields)&&V!==!te}if(C){const te=L(n.touchedFields,g);te||(oe(n.touchedFields,g,C),ee.touchedFields=n.touchedFields,D=D||(f.touchedFields||p.touchedFields)&&te!==C)}D&&$&&m.state.next(ee)}return D?ee:{}},I=(g,k,C,P)=>{const $=L(n.errors,g),D=(f.isValid||p.isValid)&&Ee(k)&&n.isValid!==k;if(t.delayError&&C?(c=b(()=>A(g,C)),c(t.delayError)):(clearTimeout(d),c=null,C?oe(n.errors,g,C):pe(n.errors,g)),(C?!Re($,C):$)||!Se(P)||D){const V={...P,...D&&Ee(k)?{isValid:k}:{},errors:n.errors,name:g};n={...n,...V},m.state.next(V)}},B=async g=>(w(g,!0),await t.resolver(i,t.context,Ff(g||l.mount,r,t.criteriaMode,t.shouldUseNativeValidation))),R=async g=>{const{errors:k}=await B(g);if(w(g),g)for(const C of g){const P=L(k,C);P?oe(n.errors,C,P):pe(n.errors,C)}else n.errors=k;return k},_=async(g,k,C={valid:!0})=>{for(const P in g){const $=g[P];if($){const{_f:D,...V}=$;if(D){const ee=l.array.has(D.name),te=$._f&&Pf($._f);te&&f.validatingFields&&w([D.name],!0);const Ne=await Ai($,l.disabled,i,v,t.shouldUseNativeValidation&&!k,ee);if(te&&f.validatingFields&&w([D.name]),Ne[D.name]&&(C.valid=!1,k||e.shouldUseNativeValidation))break;!k&&(L(Ne,D.name)?ee?Hf(n.errors,Ne,D.name):oe(n.errors,D.name,Ne[D.name]):pe(n.errors,D.name))}!Se(V)&&await _(V,k,C)}}return C.valid},E=()=>{for(const g of l.unMount){const k=L(r,g);k&&(k._f.refs?k._f.refs.every(C=>!lr(C)):!lr(k._f.ref))&&zn(g)}l.unMount=new Set},T=(g,k)=>!t.disabled&&(g&&k&&oe(i,g,k),!Re(Y(),s)),O=(g,k,C)=>Ir(g,l,{...a.mount?i:de(k)?s:De(g)?{[g]:k}:k},C,k),F=g=>is(L(a.mount?i:s,g,t.shouldUnregister?L(s,g,[]):[])),K=(g,k,C={})=>{const P=L(r,g);let $=k;if(P){const D=P._f;D&&(!D.disabled&&oe(i,g,ml(k,D)),$=Sn(D.ref)&&Ae(k)?"":k,ul(D.ref)?[...D.ref.options].forEach(V=>V.selected=$.includes(V.value)):D.refs?Gt(D.ref)?D.refs.forEach(V=>{(!V.defaultChecked||!V.disabled)&&(Array.isArray($)?V.checked=!!$.find(ee=>ee===V.value):V.checked=$===V.value||!!$)}):D.refs.forEach(V=>V.checked=V.value===$):cs(D.ref)?D.ref.value="":(D.ref.value=$,D.ref.type||m.state.next({name:g,values:me(i)})))}(C.shouldDirty||C.shouldTouch)&&M(g,$,C.shouldTouch,C.shouldDirty,!0),C.shouldValidate&&fe(g)},X=(g,k,C)=>{for(const P in k){if(!k.hasOwnProperty(P))return;const $=k[P],D=g+"."+P,V=L(r,D);(l.array.has(g)||xe($)||V&&!V._f)&&!ut($)?X(D,$,C):K(D,$,C)}},J=(g,k,C={})=>{const P=L(r,g),$=l.array.has(g),D=me(k);oe(i,g,D),$?(m.array.next({name:g,values:me(i)}),(f.isDirty||f.dirtyFields||p.isDirty||p.dirtyFields)&&C.shouldDirty&&m.state.next({name:g,dirtyFields:Nt(s,i),isDirty:T(g,D)})):P&&!P._f&&!Ae(D)?X(g,D,C):K(g,D,C),Si(g,l)?m.state.next({...n,name:g,values:me(i)}):m.state.next({name:a.mount?g:void 0,values:me(i)})},se=async g=>{a.mount=!0;const k=g.target;let C=k.name,P=!0;const $=L(r,C),D=te=>{P=Number.isNaN(te)||ut(te)&&isNaN(te.getTime())||Re(te,L(i,C,te))},V=ki(t.mode),ee=ki(t.reValidateMode);if($){let te,Ne;const st=k.type?wi($._f):al(g),Je=g.type===Nn.BLUR||g.type===Nn.FOCUS_OUT,ho=!Rf($._f)&&!t.resolver&&!L(n.errors,C)&&!$._f.deps||_f(Je,L(n.touchedFields,C),n.isSubmitted,ee,V),Vn=Si(C,l,Je);oe(i,C,st),Je?(!k||!k.readOnly)&&($._f.onBlur&&$._f.onBlur(g),c&&c(0)):$._f.onChange&&$._f.onChange(g);const Hn=M(C,st,Je),mo=!Se(Hn)||Vn;if(!Je&&m.state.next({name:C,type:g.type,values:me(i)}),ho)return(f.isValid||p.isValid)&&(t.mode==="onBlur"?Je&&x():Je||x()),mo&&m.state.next({name:C,...Vn?{}:Hn});if(!Je&&Vn&&m.state.next({...n}),t.resolver){const{errors:Ns}=await B([C]);if(w([C]),D(st),P){const po=Ci(n.errors,r,C),Ss=Ci(Ns,r,po.name||C);te=Ss.error,C=Ss.name,Ne=Se(Ns)}}else w([C],!0),te=(await Ai($,l.disabled,i,v,t.shouldUseNativeValidation))[C],w([C]),D(st),P&&(te?Ne=!1:(f.isValid||p.isValid)&&(Ne=await _(r,!0)));P&&($._f.deps&&(!Array.isArray($._f.deps)||$._f.deps.length>0)&&fe($._f.deps),I(C,Ne,te,Hn))}},ie=(g,k)=>{if(L(n.errors,k)&&g.focus)return g.focus(),1},fe=async(g,k={})=>{let C,P;const $=Rt(g);if(t.resolver){const D=await R(de(g)?g:$);C=Se(D),P=g?!$.some(V=>L(D,V)):C}else g?(P=(await Promise.all($.map(async D=>{const V=L(r,D);return await _(V&&V._f?{[D]:V}:V)}))).every(Boolean),!(!P&&!n.isValid)&&x()):P=C=await _(r);return m.state.next({...!De(g)||(f.isValid||p.isValid)&&C!==n.isValid?{}:{name:g},...t.resolver||!g?{isValid:C}:{},errors:n.errors}),k.shouldFocus&&!P&&zt(r,ie,g?$:l.mount),P},Y=(g,k)=>{let C={...a.mount?i:s};return k&&(C=dl(k.dirtyFields?n.dirtyFields:n.touchedFields,C)),de(g)?C:De(g)?L(C,g):g.map(P=>L(C,P))},q=(g,k)=>({invalid:!!L((k||n).errors,g),isDirty:!!L((k||n).dirtyFields,g),error:L((k||n).errors,g),isValidating:!!L(n.validatingFields,g),isTouched:!!L((k||n).touchedFields,g)}),ae=g=>{g&&Rt(g).forEach(k=>pe(n.errors,k)),m.state.next({errors:g?n.errors:{}})},le=(g,k,C)=>{const P=(L(r,g,{_f:{}})._f||{}).ref,$=L(n.errors,g)||{},{ref:D,message:V,type:ee,...te}=$;oe(n.errors,g,{...te,...k,ref:P}),m.state.next({name:g,errors:n.errors,isValid:!1}),C&&C.shouldFocus&&P&&P.focus&&P.focus()},Me=(g,k)=>je(g)?m.state.subscribe({next:C=>"values"in C&&g(O(void 0,k),C)}):O(g,k,!0),Mt=g=>m.state.subscribe({next:k=>{Bf(g.name,k.name,g.exact)&&zf(k,g.formState||f,fo,g.reRenderRoot)&&g.callback({values:{...i},...n,...k,defaultValues:s})}}).unsubscribe,Rn=g=>(a.mount=!0,p={...p,...g.formState},Mt({...g,formState:{...u,...g.formState}})),zn=(g,k={})=>{for(const C of g?Rt(g):l.mount)l.mount.delete(C),l.array.delete(C),k.keepValue||(pe(r,C),pe(i,C)),!k.keepError&&pe(n.errors,C),!k.keepDirty&&pe(n.dirtyFields,C),!k.keepTouched&&pe(n.touchedFields,C),!k.keepIsValidating&&pe(n.validatingFields,C),!t.shouldUnregister&&!k.keepDefaultValue&&pe(s,C);m.state.next({values:me(i)}),m.state.next({...n,...k.keepDirty?{isDirty:T()}:{}}),!k.keepIsValid&&x()},ys=({disabled:g,name:k})=>{if(Ee(g)&&a.mount||g||l.disabled.has(k)){const $=l.disabled.has(k)!==!!g;g?l.disabled.add(k):l.disabled.delete(k),$&&a.mount&&!a.action&&x()}},Bn=(g,k={})=>{let C=L(r,g);const P=Ee(k.disabled)||Ee(t.disabled);return oe(r,g,{...C||{},_f:{...C&&C._f?C._f:{ref:{name:g}},name:g,mount:!0,...k}}),l.mount.add(g),C?ys({disabled:Ee(k.disabled)?k.disabled:t.disabled,name:g}):j(g,!0,k.value),{...P?{disabled:k.disabled||t.disabled}:{},...t.progressive?{required:!!k.required,min:It(k.min),max:It(k.max),minLength:It(k.minLength),maxLength:It(k.maxLength),pattern:It(k.pattern)}:{},name:g,onChange:se,onBlur:se,ref:$=>{if($){Bn(g,k),C=L(r,g);const D=de($.value)&&$.querySelectorAll&&$.querySelectorAll("input,select,textarea")[0]||$,V=If(D),ee=C._f.refs||[];if(V?ee.find(te=>te===D):D===C._f.ref)return;oe(r,g,{_f:{...C._f,...V?{refs:[...ee.filter(lr),D,...Array.isArray(L(s,g))?[{}]:[]],ref:{type:D.type,name:g}}:{ref:D}}}),j(g,!1,void 0,D)}else C=L(r,g,{}),C._f&&(C._f.mount=!1),(t.shouldUnregister||k.shouldUnregister)&&!(ll(l.array,g)&&a.action)&&l.unMount.add(g)}}},_n=()=>t.shouldFocusError&&zt(r,ie,l.mount),oo=g=>{Ee(g)&&(m.state.next({disabled:g}),zt(r,(k,C)=>{const P=L(r,C);P&&(k.disabled=P._f.disabled||g,Array.isArray(P._f.refs)&&P._f.refs.forEach($=>{$.disabled=P._f.disabled||g}))},0,!1))},bs=(g,k)=>async C=>{let P;C&&(C.preventDefault&&C.preventDefault(),C.persist&&C.persist());let $=me(i);if(m.state.next({isSubmitting:!0}),t.resolver){const{errors:D,values:V}=await B();w(),n.errors=D,$=me(V)}else await _(r);if(l.disabled.size)for(const D of l.disabled)pe($,D);if(pe(n.errors,"root"),Se(n.errors)){m.state.next({errors:{}});try{await g($,C)}catch(D){P=D}}else k&&await k({...n.errors},C),_n(),setTimeout(_n);if(m.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Se(n.errors)&&!P,submitCount:n.submitCount+1,errors:n.errors}),P)throw P},co=(g,k={})=>{L(r,g)&&(de(k.defaultValue)?J(g,me(L(s,g))):(J(g,k.defaultValue),oe(s,g,me(k.defaultValue))),k.keepTouched||pe(n.touchedFields,g),k.keepDirty||(pe(n.dirtyFields,g),n.isDirty=k.defaultValue?T(g,me(L(s,g))):T()),k.keepError||(pe(n.errors,g),f.isValid&&x()),m.state.next({...n}))},vs=(g,k={})=>{const C=g?me(g):s,P=me(C),$=Se(g),D=$?s:P;if(k.keepDefaultValues||(s=C),!k.keepValues){if(k.keepDirtyValues){const V=new Set([...l.mount,...Object.keys(Nt(s,i))]);for(const ee of Array.from(V)){const te=L(n.dirtyFields,ee),Ne=L(i,ee),st=L(D,ee);te&&!de(Ne)?oe(D,ee,Ne):!te&&!de(st)&&J(ee,st)}}else{if(ss&&de(g))for(const V of l.mount){const ee=L(r,V);if(ee&&ee._f){const te=Array.isArray(ee._f.refs)?ee._f.refs[0]:ee._f.ref;if(Sn(te)){const Ne=te.closest("form");if(Ne){Ne.reset();break}}}}if(k.keepFieldsRef)for(const V of l.mount)J(V,L(D,V));else r={}}i=t.shouldUnregister?k.keepDefaultValues?me(s):{}:me(D),m.array.next({values:{...D}}),m.state.next({values:{...D}})}l={mount:k.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},a.mount=!f.isValid||!!k.keepIsValid||!!k.keepDirtyValues||!t.shouldUnregister&&!Se(D),a.watch=!!t.shouldUnregister,a.keepIsValid=!!k.keepIsValid,a.action=!1,k.keepErrors||(n.errors={}),m.state.next({submitCount:k.keepSubmitCount?n.submitCount:0,isDirty:$?!1:k.keepDirty?n.isDirty:!!(k.keepDefaultValues&&!Re(g,s)),isSubmitted:k.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:$?{}:k.keepDirtyValues?k.keepDefaultValues&&i?Nt(s,i):n.dirtyFields:k.keepDefaultValues&&g?Nt(s,g):k.keepDirty?n.dirtyFields:{},touchedFields:k.keepTouched?n.touchedFields:{},errors:k.keepErrors?n.errors:{},isSubmitSuccessful:k.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:s})},ws=(g,k)=>vs(je(g)?g(i):g,{...t.resetOptions,...k}),uo=(g,k={})=>{const C=L(r,g),P=C&&C._f;if(P){const $=P.refs?P.refs[0]:P.ref;$.focus&&setTimeout(()=>{$.focus(),k.shouldSelect&&je($.select)&&$.select()})}},fo=g=>{n={...n,...g}},ks={control:{register:Bn,unregister:zn,getFieldState:q,handleSubmit:bs,setError:le,_subscribe:Mt,_runSchema:B,_updateIsValidating:w,_focusError:_n,_getWatch:O,_getDirty:T,_setValid:x,_setFieldArray:N,_setDisabledField:ys,_setErrors:S,_getFieldArray:F,_reset:vs,_resetDefaultValues:()=>je(t.defaultValues)&&t.defaultValues().then(g=>{ws(g,t.resetOptions),m.state.next({isLoading:!1})}),_removeUnmounted:E,_disableForm:oo,_subjects:m,_proxyFormState:f,get _fields(){return r},get _formValues(){return i},get _state(){return a},set _state(g){a=g},get _defaultValues(){return s},get _names(){return l},set _names(g){l=g},get _formState(){return n},get _options(){return t},set _options(g){t={...t,...g}}},subscribe:Rn,trigger:fe,register:Bn,handleSubmit:bs,watch:Me,setValue:J,getValues:Y,reset:ws,resetField:co,clearErrors:ae,unregister:zn,setError:le,setFocus:uo,getFieldState:q};return{...ks,formControl:ks}}function Wf(e={}){const t=y.useRef(void 0),n=y.useRef(void 0),[r,s]=y.useState({isDirty:!1,isValidating:!1,isLoading:je(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:je(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:r},e.defaultValues&&!je(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:a,...l}=qf(e);t.current={...l,formState:r}}const i=t.current.control;return i._options=e,os(()=>{const a=i._subscribe({formState:i._proxyFormState,callback:()=>s({...i._formState}),reRenderRoot:!0});return s(l=>({...l,isReady:!0})),i._formState.isReady=!0,a},[i]),y.useEffect(()=>i._disableForm(e.disabled),[i,e.disabled]),y.useEffect(()=>{e.mode&&(i._options.mode=e.mode),e.reValidateMode&&(i._options.reValidateMode=e.reValidateMode)},[i,e.mode,e.reValidateMode]),y.useEffect(()=>{e.errors&&(i._setErrors(e.errors),i._focusError())},[i,e.errors]),y.useEffect(()=>{e.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,e.shouldUnregister]),y.useEffect(()=>{if(i._proxyFormState.isDirty){const a=i._getDirty();a!==r.isDirty&&i._subjects.state.next({isDirty:a})}},[i,r.isDirty]),y.useEffect(()=>{var a;e.values&&!Re(e.values,n.current)?(i._reset(e.values,{keepFieldsRef:!0,...i._options.resetOptions}),!((a=i._options.resetOptions)===null||a===void 0)&&a.keepIsValid||i._setValid(),n.current=e.values,s(l=>({...l}))):i._resetDefaultValues()},[i,e.values]),y.useEffect(()=>{i._state.mount||(i._setValid(),i._state.mount=!0),i._state.watch&&(i._state.watch=!1,i._subjects.state.next({...i._formState})),i._removeUnmounted()}),t.current.formState=y.useMemo(()=>cl(r,i),[i,r]),t.current}function Kf(e,t=3){return e%1===0?e.toString():e.toFixed(t).replace(/\.?0+$/,"")}function Jf(e,t="en-US",n="USD"){try{return new Intl.NumberFormat(t,{style:"currency",currency:n,minimumFractionDigits:2,maximumFractionDigits:2}).format(e)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${e.toFixed(2)}`}}function Yf(e="USD",t="en-US"){try{return new Intl.NumberFormat(t,{style:"currency",currency:e}).formatToParts(0).find(i=>i.type==="currency")?.value??"$"}catch{return"$"}}function Gf(e){const t=e.replace(/[^\d.,-]/g,""),n=t.match(/,\d{1,2}$/);let r;n?r=t.replace(/\./g,"").replace(",","."):r=t.replace(/,/g,"");const s=parseFloat(r);return isNaN(s)?null:s}function Qf(e,t,n=.001){const r=e-t,s=Math.abs(r)<=n;return{difference:r,isBalanced:s,isUnderAllocated:!s&&r>0,isOverAllocated:!s&&r<0}}function us(){return`dist-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}us();const Zf={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:"$"},or=()=>({id:us(),amount:0,glAccount:null,isTaxDeductible:!1}),gl=({distribution:e,defaultDistribution:t,glAccounts:n=[],isLoadingGlAccounts:r=!1,onSearchGlAccounts:s,onDistributionChange:i,onAmountChange:a,onGlAccountChange:l,onTaxDeductibleChange:c,onDelete:d,canDelete:u=!0,canEditTaxDeductible:f=!0,isDisabled:p=!1,labels:m,classNames:v={},"data-testid":b,control:x,name:w,rules:N})=>{const A={...Zf,...m},S=x!==void 0&&w!==void 0,j=Wf({defaultValues:{_internal:t||or()}}),M=Ef({control:S?x:j.control,name:S?w:"_internal",rules:S?N:void 0}),[I,B]=y.useState(t||or()),R=S?M.field.value??or():e??I,_=S&&!!M.fieldState?.error,E=S&&(M.fieldState?.isTouched??!1),T=_||E,O=T&&(!R.amount||R.amount<=0),F=T&&!R.glAccount,[K,X]=y.useState(R.glAccount?.name||""),J=y.useCallback(le=>{const Me={...R,...le};S&&M.field.onChange(Me),!S&&e===void 0&&B(Me),i?.(Me)},[R,e,i,S,M]),se=y.useCallback(le=>{const Me=le||0;J({amount:Me}),a?.(Me)},[J,a]),ie=y.useCallback(le=>{X(le),s?.(le)},[s]),fe=y.useCallback(le=>{if(le===null){J({glAccount:null}),l?.(null);return}const Mt=n.find(Rn=>String(Rn.id)===String(le))||null;J({glAccount:Mt}),l?.(Mt)},[n,J,l]),Y=y.useCallback(()=>{X(""),J({glAccount:null}),l?.(null)},[J,l]),q=y.useCallback(le=>{J({isTaxDeductible:le}),c?.(le)},[J,c]),ae=y.useCallback(()=>{d?.()},[d]);return o.jsx(h.Card,{radius:"md",shadow:"sm","data-testid":b||"revenue-distribution-card",className:h.cn(v.base),children:o.jsxs(h.CardBody,{className:h.cn("flex flex-row flex-nowrap items-start gap-4",v.body),children:[o.jsx("div",{className:h.cn("shrink-0",v.amountContainer),children:o.jsx(h.NumberInput,{"data-testid":`${b||"revenue-distribution-card"}-amount-input`,label:o.jsxs("span",{className:"flex items-center gap-1",children:[A.amount,o.jsx(h.Tooltip,{content:A.amountTooltip,children:o.jsx(H,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),value:R.amount||void 0,onValueChange:se,labelPlacement:"outside",placeholder:A.amountPlaceholder,isWheelDisabled:!0,hideStepper:!0,variant:"bordered",isDisabled:p,isInvalid:O,errorMessage:O?"Amount is required":void 0,minValue:0,step:.01,className:v.amountInput,startContent:o.jsx("div",{className:"pointer-events-none flex items-center",children:o.jsx("span",{className:"text-default-400 text-small",children:A.currencySymbol})})})}),o.jsx("div",{className:h.cn("grow",v.glAccountContainer),children:o.jsx(h.Autocomplete,{"data-testid":`${b||"revenue-distribution-card"}-gl-account-input`,label:o.jsxs("span",{className:"flex items-center gap-1",children:[A.glAccount,o.jsx(h.Tooltip,{content:A.glAccountTooltip,children:o.jsx(H,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),isLoading:r,isClearable:!0,labelPlacement:"outside",variant:"bordered",items:n,menuTrigger:"input",inputValue:R.glAccount?.name??K,selectedKey:R.glAccount?.id??null,isDisabled:p,isInvalid:F,errorMessage:F?"GL Account is required":void 0,listboxProps:{emptyContent:r?A.searching:A.noGlAccountsFound},placeholder:A.glAccountPlaceholder,onInputChange:ie,onSelectionChange:fe,onClear:Y,className:v.glAccountInput,children:le=>o.jsx(h.AutocompleteItem,{textValue:le.name,children:o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{children:le.name}),le.code&&o.jsx("span",{className:"text-xs text-default-400",children:le.code})]})},le.id)})}),o.jsx("div",{className:h.cn("shrink-0 pt-6 flex items-center",v.taxDeductibleContainer),children:o.jsx(h.Checkbox,{radius:"full","data-testid":`${b||"revenue-distribution-card"}-tax-deductible`,isSelected:R.isTaxDeductible,onValueChange:q,isDisabled:p||!f,className:v.taxDeductibleCheckbox,children:A.taxDeductible})}),o.jsx("div",{className:h.cn("shrink-0 pt-6",v.deleteContainer),children:o.jsx(W,{"data-testid":`${b||"revenue-distribution-card"}-delete-button`,size:"sm",color:"danger",variant:"flat",isDisabled:p||!u,onPress:ae,startContent:o.jsx(H,{icon:"solar:trash-bin-trash-linear",width:16}),className:h.cn("text-danger",v.deleteButton),children:A.deleteButton})})]})})};gl.displayName="RevenueDistributionCard";const xl=({message:e="No distributions configured",icon:t="solar:document-text-outline",iconSize:n=48,showCard:r=!0,classNames:s={},renderEmpty:i})=>{if(i)return o.jsx(o.Fragment,{children:i()});const a=o.jsxs("div",{className:h.cn("flex flex-col items-center justify-center py-8",s.content),children:[o.jsx(H,{icon:t,width:n,className:h.cn("text-default-300 mb-4",s.icon)}),o.jsx("p",{className:h.cn("text-default-500 text-sm text-center",s.message),children:e})]});return r?o.jsx(h.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-empty",className:h.cn("w-full",s.base),children:o.jsx(h.CardBody,{children:a})}):o.jsx("div",{"data-testid":"revenue-distribution-empty",className:h.cn("w-full",s.base),children:a})};xl.displayName="RevenueDistributionEmpty";const Xf={title:"Error Loading Distributions",description:"An error occurred while loading the distribution configuration. Please try again."},yl=({error:e,labels:t,showCard:n=!0,color:r="danger",classNames:s={}})=>{const i={...Xf,...t},a=o.jsx(h.Alert,{"data-testid":"revenue-distribution-error-alert",color:r,title:i.title,description:e||i.description,className:s.alert});return n?o.jsx(h.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-error",className:h.cn("w-full",s.base),children:o.jsx(h.CardBody,{children:a})}):o.jsx("div",{"data-testid":"revenue-distribution-error",className:h.cn("w-full",s.base),children:a})};yl.displayName="RevenueDistributionError";const bl=({rows:e=1,showCard:t=!0,classNames:n={}})=>{const r=Array.from({length:e},(i,a)=>a),s=i=>o.jsxs("div",{className:h.cn("flex flex-row flex-nowrap items-end gap-4",n.row),children:[o.jsxs("div",{className:"shrink-0 flex flex-col gap-1",children:[o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(h.Skeleton,{className:"h-4 w-14 rounded-md"}),o.jsx(h.Skeleton,{className:"h-4 w-4 rounded-full"})]}),o.jsx(h.Skeleton,{className:"h-10 w-32 rounded-lg"})]}),o.jsxs("div",{className:"grow flex flex-col gap-1",children:[o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(h.Skeleton,{className:"h-4 w-20 rounded-md"}),o.jsx(h.Skeleton,{className:"h-4 w-4 rounded-full"})]}),o.jsx(h.Skeleton,{className:"h-10 w-full rounded-lg"})]}),o.jsxs("div",{className:"shrink-0 pb-2 flex items-center gap-2",children:[o.jsx(h.Skeleton,{className:"h-5 w-5 rounded-full"}),o.jsx(h.Skeleton,{className:"h-4 w-24 rounded-md"})]}),o.jsx("div",{className:"shrink-0 pb-2",children:o.jsx(h.Skeleton,{className:"h-8 w-20 rounded-lg"})})]},i);return t?o.jsx("div",{className:h.cn("flex flex-col gap-3",n.base),children:r.map(i=>o.jsx(h.Card,{radius:"md",shadow:"sm","data-testid":`revenue-distribution-skeleton-${i}`,children:o.jsx(h.CardBody,{children:s(i)})},i))}):o.jsx("div",{"data-testid":"revenue-distribution-skeleton",className:h.cn("flex flex-col gap-3",n.base),children:r.map(i=>s(i))})};bl.displayName="RevenueDistributionSkeleton";function jn({isOpen:e,labels:t,icon:n,isConfirming:r=!1,confirmColor:s="danger",iconTone:i="danger",onClose:a,onConfirm:l}){return o.jsx(h.Modal,{isOpen:e,size:"md",placement:"center",classNames:{base:"max-w-[440px] rounded-3xl",closeButton:"right-5 top-5 text-zinc-500"},onOpenChange:c=>!c&&a(),children:o.jsxs(h.ModalContent,{children:[o.jsxs(h.ModalHeader,{className:"flex flex-col items-start gap-4 px-7 pb-0 pt-7",children:[n&&o.jsx("span",{className:h.cn("flex h-12 w-12 shrink-0 items-center justify-center rounded-full",i==="warning"?"bg-brand/15 text-brand":"bg-danger-100 text-danger-600"),children:n}),o.jsx("span",{className:"text-lg font-semibold leading-6 text-zinc-950",children:t.title})]}),o.jsx(h.ModalBody,{className:"px-7 pb-3 pt-4",children:o.jsx("div",{className:"text-sm leading-6 text-zinc-500",children:t.description})}),o.jsxs(h.ModalFooter,{className:"grid grid-cols-2 gap-3 px-7 pb-7 pt-3",children:[o.jsx(W,{type:"button",variant:"bordered",radius:"full",className:"h-10 border-zinc-200 bg-white text-sm font-normal text-zinc-900",onPress:a,children:t.cancel}),o.jsx(W,{type:"button",color:s,radius:"full",className:h.cn("h-10 text-sm font-normal text-white",s==="danger"?"bg-danger-600":"bg-brand"),isLoading:r,onPress:l,children:t.confirm})]})]})})}const eh={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 at least two funds and assign percentages that total 100%",selectedFund:"Selected fund",percentage:"Percentage",total:"Total",totalError:"Percentages must 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"},vl={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"},$t={...vl,base:"min-h-11 rounded-2xl px-4 py-2 shadow-none",title:"text-sm font-medium"},th={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"},Mi=()=>({id:crypto.randomUUID(),fund:null,percentage:0}),nh=e=>Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e*100)/100)):0,rh=e=>e.fund!==null;function sh({mode:e,assignments:t,funds:n,labels:r,classNames:s,isSaving:i=!1,hasSavedAssignments:a=!1,isFundPickerOpen:l=!1,activeAssignmentId:c=null,footer:d,onModeChange:u,onAssignmentsChange:f,onOpenFundPicker:p,onCloseFundPicker:m,onCollapseChange:v,onSave:b}){const x={...eh,...r},w=t.filter(rh),N=w.length>0,A=y.useMemo(()=>t.reduce((Y,q)=>Y+Number(q.percentage||0),0),[t]),S=Math.round(A*100)/100,j=e==="split"&&t.some(Y=>!Y.fund||Number(Y.percentage||0)<=0),M=e==="split"&&N&&(S!==100||j),I=e==="split"&&N&&S>=100,B=e==="split"||!N,[R,_]=y.useState(null),[E,T]=y.useState(!1),O=Y=>{if(Y!==e){if(Y==="single"){const q=w[0]?.fund??null;f([{id:t[0]?.id??crypto.randomUUID(),fund:q,percentage:q?100:0}])}else{const q=w[0];f([{id:q?.id??crypto.randomUUID(),fund:q?.fund??null,percentage:q?.fund?50:0},Mi()])}u(Y)}},F=(Y,q)=>{f(t.map(ae=>ae.id===Y?{...ae,...q}:ae))},K=()=>{I||f([...t,Mi()])},X=Y=>{if(!(t.length<=2)){if(!a){f(t.filter(q=>q.id!==Y));return}_(Y)}},J=()=>{if(!R||t.length<=2){_(null);return}f(t.filter(Y=>Y.id!==R)),_(null)},se=()=>{if(!i){if(!a){b();return}T(!0)}},ie=()=>{T(!1),b()},fe=Y=>{const q=c??t.find(ae=>!ae.fund)?.id??t[0]?.id;q&&(f(t.map(ae=>ae.id===q?{...ae,fund:Y,percentage:e==="single"?100:ae.percentage}:ae)),m())};return o.jsxs("div",{className:h.cn("vvt-pa font-sans text-zinc-900",s?.root),children:[o.jsx(h.Accordion,{variant:"splitted",defaultSelectedKeys:["installment-fund-assignment"],className:h.cn("w-full gap-0 px-0",s?.panel),itemClasses:{base:"w-full rounded-2xl border border-zinc-200 bg-white p-0 shadow-sm",trigger:h.cn("px-4 py-4",s?.header),title:"text-xl font-semibold leading-8 text-zinc-900",content:"w-full px-4 pb-4 pt-0",indicator:"text-zinc-500"},onSelectionChange:Y=>v?.(!(Y==="all"||Array.from(Y).length>0)),children:o.jsx(h.AccordionItem,{"aria-label":x.title,title:x.title,children:o.jsxs("div",{className:h.cn("flex w-full flex-col gap-4",s?.content),children:[o.jsxs("div",{className:"flex w-full items-center justify-between gap-6",children:[o.jsx(ih,{mode:e,labels:x,onModeChange:O,className:s?.tabs}),o.jsx(W,{type:"button",size:"sm",color:"primary",radius:"full",className:"ml-auto h-9 min-w-40 bg-brand px-4 text-sm font-medium text-white",startContent:o.jsx(H,{icon:"solar:cloud-upload-outline",className:"size-4"}),isLoading:i,onPress:se,children:x.saveAssignment})]}),o.jsxs("div",{className:"flex w-full flex-col gap-4",children:[!N&&o.jsx(h.Alert,{icon:o.jsx(H,{icon:"solar:info-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,classNames:vl,color:"default",variant:"flat",title:e==="single"?x.emptySingle:x.emptySplit}),N&&o.jsx(ah,{mode:e,assignments:t,labels:x,total:A,hasTotalError:M,onSelectFund:Y=>p(Y),onRemoveFund:X,onPercentageChange:(Y,q)=>F(Y,{percentage:nh(q)})}),B&&o.jsx("div",{className:"flex flex-wrap gap-3",children:o.jsx(W,{type:"button",color:"default",radius:"full",className:"h-11 bg-zinc-950 px-4 text-base font-normal text-white disabled:opacity-50",startContent:o.jsx(U.Plus,{className:"size-5",strokeWidth:2}),isDisabled:I,onPress:()=>e==="split"&&N?K():p(),children:e==="split"&&N?x.addFund:x.assignSpecificFund})})]}),d]})},"installment-fund-assignment")}),l&&o.jsx(lh,{funds:n,labels:x,selectedFundIds:t.map(Y=>Y.fund?.id).filter(Boolean),onSelect:fe,onClose:m}),o.jsx(jn,{isOpen:E,labels:{title:x.modifyAssignedFundsTitle,description:o.jsxs(o.Fragment,{children:[o.jsx("p",{children:x.modifyAssignedFundsDescription}),o.jsx("p",{className:"mt-3",children:x.modifyAssignedFundsWarning})]}),cancel:x.modifyAssignedFundsCancel,confirm:x.modifyAssignedFundsConfirm},icon:o.jsx(H,{icon:"solar:info-circle-outline",className:"size-7"}),iconTone:"warning",confirmColor:"primary",onClose:()=>T(!1),onConfirm:ie}),o.jsx(jn,{isOpen:R!==null,labels:{title:x.modifyAssignedFundsTitle,description:o.jsxs(o.Fragment,{children:[o.jsx("p",{children:x.modifyAssignedFundsDescription}),o.jsx("p",{className:"mt-3",children:x.modifyAssignedFundsWarning})]}),cancel:x.modifyAssignedFundsCancel,confirm:x.modifyAssignedFundsConfirm},icon:o.jsx(H,{icon:"solar:info-circle-outline",className:"size-7"}),iconTone:"warning",confirmColor:"primary",onClose:()=>_(null),onConfirm:J})]})}function ih({mode:e,labels:t,className:n,onModeChange:r}){return o.jsxs(h.Tabs,{"aria-label":t.title,selectedKey:e,radius:"full",size:"sm",variant:"light",className:h.cn("w-fit",n),classNames:{base:"w-fit",tabList:"h-10 w-fit rounded-full bg-zinc-200 p-1",tab:"h-8 w-auto rounded-full px-5 text-sm font-normal",cursor:"rounded-full bg-white shadow-sm",tabContent:"text-zinc-500 group-data-[selected=true]:text-zinc-900",panel:"hidden"},onSelectionChange:s=>r(s),children:[o.jsx(h.Tab,{title:t.singleFund},"single"),o.jsx(h.Tab,{title:t.splitFunds},"split")]})}function ah({mode:e,assignments:t,labels:n,total:r,hasTotalError:s,onSelectFund:i,onRemoveFund:a,onPercentageChange:l}){return o.jsxs("div",{className:"flex flex-col gap-3",children:[t.map((c,d)=>o.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:[o.jsx("div",{className:h.cn("flex min-h-11 min-w-0 flex-1 items-center",c.fund&&e==="single"?"justify-between":"gap-4"),children:c.fund?o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"rounded-full bg-zinc-100 px-4 py-1.5 text-sm text-zinc-950",children:[c.fund.glCode," - ",c.fund.accountName]}),o.jsx(W,{type:"button",variant:"light",radius:"full",className:"px-2 text-sm font-normal text-brand",onPress:()=>i(c.id),children:"Replace"})]}):o.jsx(W,{type:"button",variant:"light",radius:"full",className:"justify-start px-4 text-base font-normal text-zinc-900",startContent:o.jsx(U.Plus,{className:"size-5",strokeWidth:2}),onPress:()=>i(c.id),children:n.assignSpecificFund})}),e==="split"&&o.jsx("label",{className:"flex w-48 flex-none items-center",children:o.jsx(h.Input,{variant:"bordered",type:"number",min:0,max:100,step:.01,value:String(c.percentage||""),onChange:u=>l(c.id,Number(u.target.value)),endContent:o.jsx("span",{className:"text-sm text-zinc-500",children:"%"}),classNames:th})}),e==="split"&&t.length>2&&o.jsx(W,{type:"button",isIconOnly:!0,variant:"flat",radius:"full",className:h.cn("h-10 w-10 flex-none p-0",d<2?"bg-danger-100 text-danger-500 opacity-60":"bg-danger-600 text-white"),style:{height:40,minWidth:40,width:40},isDisabled:d<2,onPress:()=>a(c.id),"aria-label":n.removeFund,children:o.jsx(H,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"})})]},c.id)),e==="split"&&o.jsx(h.Alert,{icon:o.jsx(H,{icon:s?"solar:info-circle-outline":"solar:check-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,color:s?"warning":"success",variant:"flat",classNames:{...$t,base:h.cn($t.base,s?"bg-warning-50 text-warning-700":"bg-success-50 text-success-700"),iconWrapper:h.cn($t.iconWrapper,s?"text-warning-700":"text-success-700"),alertIcon:h.cn($t.alertIcon,s?"text-warning-700":"text-success-700"),title:h.cn($t.title,s?"text-warning-700":"text-success-700")},title:s?`${n.totalError} (${n.total} ${Number(r.toFixed(2))}%)`:`${n.total} ${Number(r.toFixed(2))}%`})]})}function lh({funds:e,labels:t,selectedFundIds:n,onSelect:r,onClose:s}){const[i,a]=y.useState(""),l=e.filter(c=>{const d=i.trim().toLowerCase();return d?`${c.glCode} ${c.accountName} ${c.type}`.toLowerCase().includes(d):!0});return o.jsx(h.Modal,{isOpen:!0,size:"3xl",placement:"center",scrollBehavior:"inside",classNames:{base:"max-w-3xl rounded-3xl",closeButton:"right-6 top-6 text-zinc-500"},onOpenChange:c=>!c&&s(),children:o.jsxs(h.ModalContent,{children:[o.jsx(h.ModalHeader,{className:"px-6 pt-6 text-xl font-semibold leading-7 text-zinc-950",children:t.modalTitle}),o.jsxs(h.ModalBody,{className:"px-6 pb-6",children:[o.jsx(h.Input,{variant:"bordered","aria-label":t.searchPlaceholder,value:i,placeholder:t.searchPlaceholder,onChange:c=>a(c.target.value),startContent:o.jsx(H,{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"}}),o.jsxs("div",{className:"mt-4 overflow-auto",children:[o.jsxs("div",{className:"grid grid-cols-[1fr_1.1fr_0.55fr_0.6fr] gap-5 border-b border-zinc-200 px-3 pb-3 text-sm font-medium leading-5 text-zinc-900",children:[o.jsx("span",{children:t.glCode}),o.jsx("span",{children:t.accountName}),o.jsx("span",{children:t.type}),o.jsx("span",{children:t.actions})]}),l.length===0&&o.jsx("div",{className:"p-4 text-sm text-zinc-500",children:t.noFunds}),l.map(c=>{const d=n.includes(c.id);return o.jsxs("div",{className:"grid grid-cols-[1fr_1.1fr_0.55fr_0.6fr] items-center gap-5 px-3 py-2.5 text-sm leading-5 text-zinc-900",children:[o.jsx("span",{children:c.glCode}),o.jsx("span",{children:c.accountName}),c.type?o.jsx("span",{className:"w-fit rounded-full bg-warning-50 px-3 py-1 text-sm font-medium text-warning-500",children:c.type}):o.jsx("span",{className:"text-sm text-zinc-400",children:"-"}),o.jsx(W,{type:"button",variant:"bordered",radius:"full",className:"h-9 min-w-24 border-zinc-200 bg-white text-sm font-medium text-zinc-900",isDisabled:d,onPress:()=>r(c),children:t.select})]},c.id)})]})]})]})})}function oh(){return o.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:[o.jsxs("div",{className:"flex items-start justify-between gap-3",children:[o.jsx(h.Skeleton,{className:"h-7 w-56 rounded-lg"}),o.jsx(h.Skeleton,{className:"size-8 rounded-full"})]}),o.jsxs("div",{className:"flex items-center justify-between gap-3",children:[o.jsx(h.Skeleton,{className:"h-10 w-72 rounded-full"}),o.jsx(h.Skeleton,{className:"h-10 w-40 rounded-full"})]}),o.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_160px] items-center gap-4 rounded-2xl border border-zinc-100 p-3",children:[o.jsx(h.Skeleton,{className:"h-8 w-full max-w-xs rounded-full"}),o.jsx(h.Skeleton,{className:"h-8 w-full rounded-xl"})]}),o.jsx(h.Skeleton,{className:"h-11 w-40 rounded-full"})]})}const ch={totalAmount:"Total Amount:",remainingBalance:"Remaining Balance",amountReceived:"Amount Received:"};function dh({totalAmount:e,remainingBalance:t,amountReceived:n,currency:r="USD",locale:s="en-US",labels:i,className:a}){const l={...ch,...i},c=new Intl.NumberFormat(s,{style:"currency",currency:r});return o.jsx("div",{className:h.cn("w-full rounded-2xl border border-zinc-200 bg-white px-4 py-2.5 font-sans text-base leading-6",a),children:o.jsxs("div",{className:"flex w-full flex-wrap items-center gap-x-5 gap-y-2",children:[o.jsx(cr,{label:l.totalAmount,value:c.format(e)}),o.jsx(cr,{label:l.remainingBalance,value:c.format(t)}),o.jsx(cr,{label:l.amountReceived,value:c.format(n)})]})})}function cr({label:e,value:t}){return o.jsxs("div",{className:"flex items-center gap-3 whitespace-nowrap",children:[o.jsx("span",{className:"font-medium text-zinc-700",children:e}),o.jsx("span",{className:"font-normal text-zinc-950",children:t})]})}function dr(e,t){return e-t*Math.floor(e/t)}const wl=1721426;function rn(e,t,n,r){t=fs(e,t);let s=t-1,i=-2;return n<=2?i=0:un(t)&&(i=-1),wl-1+365*s+Math.floor(s/4)-Math.floor(s/100)+Math.floor(s/400)+Math.floor((367*n-362)/12+i+r)}function un(e){return e%4===0&&(e%100!==0||e%400===0)}function fs(e,t){return e==="BC"?1-t:t}function uh(e){let t="AD";return e<=0&&(t="BC",e=1-e),[t,e]}const fh={standard:[31,28,31,30,31,30,31,31,30,31,30,31],leapyear:[31,29,31,30,31,30,31,31,30,31,30,31]};class Pn{fromJulianDay(t){let n=t,r=n-wl,s=Math.floor(r/146097),i=dr(r,146097),a=Math.floor(i/36524),l=dr(i,36524),c=Math.floor(l/1461),d=dr(l,1461),u=Math.floor(d/365),f=s*400+a*100+c*4+u+(a!==4&&u!==4?1:0),[p,m]=uh(f),v=n-rn(p,m,1,1),b=2;n<rn(p,m,3,1)?b=0:un(m)&&(b=1);let x=Math.floor(((v+b)*12+373)/367),w=n-rn(p,m,x,1)+1;return new Kt(p,m,x,w)}toJulianDay(t){return rn(t.era,t.year,t.month,t.day)}getDaysInMonth(t){return fh[un(t.year)?"leapyear":"standard"][t.month-1]}getMonthsInYear(t){return 12}getDaysInYear(t){return un(t.year)?366:365}getMaximumMonthsInYear(){return 12}getMaximumDaysInMonth(){return 31}getYearsInEra(t){return 9999}getEras(){return["BC","AD"]}isInverseEra(t){return t.era==="BC"}balanceDate(t){t.year<=0&&(t.era=t.era==="BC"?"AD":"BC",t.year=1-t.year)}constructor(){this.identifier="gregory"}}function hh(e,t){var n,r,s,i;return(i=(s=(n=e.isEqual)===null||n===void 0?void 0:n.call(e,t))!==null&&s!==void 0?s:(r=t.isEqual)===null||r===void 0?void 0:r.call(t,e))!==null&&i!==void 0?i:e.identifier===t.identifier}function kl(e,t){return e.calendar.toJulianDay(e)-t.calendar.toJulianDay(t)}function mh(e,t){return Ei(e)-Ei(t)}function Ei(e){return e.hour*36e5+e.minute*6e4+e.second*1e3+e.millisecond}let ur=null;function Nl(){return ur==null&&(ur=new Intl.DateTimeFormat().resolvedOptions().timeZone),ur}function Ti(e){e=hs(e,new Pn);let t=fs(e.era,e.year);return Sl(t,e.month,e.day,e.hour,e.minute,e.second,e.millisecond)}function Sl(e,t,n,r,s,i,a){let l=new Date;return l.setUTCHours(r,s,i,a),l.setUTCFullYear(e,t-1,n),l.getTime()}function Di(e,t){if(t==="UTC")return 0;if(e>0&&t===Nl())return new Date(e).getTimezoneOffset()*-6e4;let{year:n,month:r,day:s,hour:i,minute:a,second:l}=Cl(e,t);return Sl(n,r,s,i,a,l,0)-Math.floor(e/1e3)*1e3}const Ii=new Map;function Cl(e,t){let n=Ii.get(t);n||(n=new Intl.DateTimeFormat("en-US",{timeZone:t,hour12:!1,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}),Ii.set(t,n));let r=n.formatToParts(new Date(e)),s={};for(let i of r)i.type!=="literal"&&(s[i.type]=i.value);return{year:s.era==="BC"||s.era==="B"?-s.year+1:+s.year,month:+s.month,day:+s.day,hour:s.hour==="24"?0:+s.hour,minute:+s.minute,second:+s.second}}const $i=864e5;function ph(e,t,n,r){return(n===r?[n]:[n,r]).filter(i=>gh(e,t,i))}function gh(e,t,n){let r=Cl(n,t);return e.year===r.year&&e.month===r.month&&e.day===r.day&&e.hour===r.hour&&e.minute===r.minute&&e.second===r.second}function xh(e,t,n="compatible"){let r=Al(e);if(t==="UTC")return Ti(r);if(t===Nl()&&n==="compatible"){r=hs(r,new Pn);let c=new Date,d=fs(r.era,r.year);return c.setFullYear(d,r.month-1,r.day),c.setHours(r.hour,r.minute,r.second,r.millisecond),c.getTime()}let s=Ti(r),i=Di(s-$i,t),a=Di(s+$i,t),l=ph(r,t,s-i,s-a);if(l.length===1)return l[0];if(l.length>1)switch(n){case"compatible":case"earlier":return l[0];case"later":return l[l.length-1];case"reject":throw new RangeError("Multiple possible absolute times found")}switch(n){case"earlier":return Math.min(s-i,s-a);case"compatible":case"later":return Math.max(s-i,s-a);case"reject":throw new RangeError("No such absolute time found")}}function jl(e,t,n="compatible"){return new Date(xh(e,t,n))}function Al(e,t){let n=0,r=0,s=0,i=0;if("timeZone"in e)({hour:n,minute:r,second:s,millisecond:i}=e);else if("hour"in e&&!t)return e;return t&&({hour:n,minute:r,second:s,millisecond:i}=t),new An(e.calendar,e.era,e.year,e.month,e.day,n,r,s,i)}function hs(e,t){if(hh(e.calendar,t))return e;let n=t.fromJulianDay(e.calendar.toJulianDay(e)),r=e.copy();return r.calendar=t,r.era=n.era,r.year=n.year,r.month=n.month,r.day=n.day,At(r),r}function ms(e,t){let n=e.copy(),r="hour"in n?Nh(n,t):0;Lr(n,t.years||0),n.calendar.balanceYearMonth&&n.calendar.balanceYearMonth(n,e),n.month+=t.months||0,Fr(n),Ml(n),n.day+=(t.weeks||0)*7,n.day+=t.days||0,n.day+=r,yh(n),n.calendar.balanceDate&&n.calendar.balanceDate(n),n.year<1&&(n.year=1,n.month=1,n.day=1);let s=n.calendar.getYearsInEra(n);if(n.year>s){var i,a;let c=(i=(a=n.calendar).isInverseEra)===null||i===void 0?void 0:i.call(a,n);n.year=s,n.month=c?1:n.calendar.getMonthsInYear(n),n.day=c?1:n.calendar.getDaysInMonth(n)}n.month<1&&(n.month=1,n.day=1);let l=n.calendar.getMonthsInYear(n);return n.month>l&&(n.month=l,n.day=n.calendar.getDaysInMonth(n)),n.day=Math.max(1,Math.min(n.calendar.getDaysInMonth(n),n.day)),n}function Lr(e,t){var n,r;!((n=(r=e.calendar).isInverseEra)===null||n===void 0)&&n.call(r,e)&&(t=-t),e.year+=t}function Fr(e){for(;e.month<1;)Lr(e,-1),e.month+=e.calendar.getMonthsInYear(e);let t=0;for(;e.month>(t=e.calendar.getMonthsInYear(e));)e.month-=t,Lr(e,1)}function yh(e){for(;e.day<1;)e.month--,Fr(e),e.day+=e.calendar.getDaysInMonth(e);for(;e.day>e.calendar.getDaysInMonth(e);)e.day-=e.calendar.getDaysInMonth(e),e.month++,Fr(e)}function Ml(e){e.month=Math.max(1,Math.min(e.calendar.getMonthsInYear(e),e.month)),e.day=Math.max(1,Math.min(e.calendar.getDaysInMonth(e),e.day))}function At(e){e.calendar.constrainDate&&e.calendar.constrainDate(e),e.year=Math.max(1,Math.min(e.calendar.getYearsInEra(e),e.year)),Ml(e)}function bh(e){let t={};for(let n in e)typeof e[n]=="number"&&(t[n]=-e[n]);return t}function El(e,t){return ms(e,bh(t))}function Tl(e,t){let n=e.copy();return t.era!=null&&(n.era=t.era),t.year!=null&&(n.year=t.year),t.month!=null&&(n.month=t.month),t.day!=null&&(n.day=t.day),At(n),n}function vh(e,t){let n=e.copy();return t.hour!=null&&(n.hour=t.hour),t.minute!=null&&(n.minute=t.minute),t.second!=null&&(n.second=t.second),t.millisecond!=null&&(n.millisecond=t.millisecond),kh(n),n}function wh(e){e.second+=Math.floor(e.millisecond/1e3),e.millisecond=sn(e.millisecond,1e3),e.minute+=Math.floor(e.second/60),e.second=sn(e.second,60),e.hour+=Math.floor(e.minute/60),e.minute=sn(e.minute,60);let t=Math.floor(e.hour/24);return e.hour=sn(e.hour,24),t}function kh(e){e.millisecond=Math.max(0,Math.min(e.millisecond,1e3)),e.second=Math.max(0,Math.min(e.second,59)),e.minute=Math.max(0,Math.min(e.minute,59)),e.hour=Math.max(0,Math.min(e.hour,23))}function sn(e,t){let n=e%t;return n<0&&(n+=t),n}function Nh(e,t){return e.hour+=t.hours||0,e.minute+=t.minutes||0,e.second+=t.seconds||0,e.millisecond+=t.milliseconds||0,wh(e)}function Dl(e,t,n,r){let s=e.copy();switch(t){case"era":{let l=e.calendar.getEras(),c=l.indexOf(e.era);if(c<0)throw new Error("Invalid era: "+e.era);c=Xe(c,n,0,l.length-1,r?.round),s.era=l[c],At(s);break}case"year":var i,a;!((i=(a=s.calendar).isInverseEra)===null||i===void 0)&&i.call(a,s)&&(n=-n),s.year=Xe(e.year,n,-1/0,9999,r?.round),s.year===-1/0&&(s.year=1),s.calendar.balanceYearMonth&&s.calendar.balanceYearMonth(s,e);break;case"month":s.month=Xe(e.month,n,1,e.calendar.getMonthsInYear(e),r?.round);break;case"day":s.day=Xe(e.day,n,1,e.calendar.getDaysInMonth(e),r?.round);break;default:throw new Error("Unsupported field "+t)}return e.calendar.balanceDate&&e.calendar.balanceDate(s),At(s),s}function Sh(e,t,n,r){let s=e.copy();switch(t){case"hour":{let i=e.hour,a=0,l=23;if(r?.hourCycle===12){let c=i>=12;a=c?12:0,l=c?23:11}s.hour=Xe(i,n,a,l,r?.round);break}case"minute":s.minute=Xe(e.minute,n,0,59,r?.round);break;case"second":s.second=Xe(e.second,n,0,59,r?.round);break;case"millisecond":s.millisecond=Xe(e.millisecond,n,0,999,r?.round);break;default:throw new Error("Unsupported field "+t)}return s}function Xe(e,t,n,r,s=!1){if(s){e+=Math.sign(t),e<n&&(e=r);let i=Math.abs(t);t>0?e=Math.ceil(e/i)*i:e=Math.floor(e/i)*i,e>r&&(e=n)}else e+=t,e<n?e=r-(n-e-1):e>r&&(e=n+(e-r-1));return e}const Ch=/^([+-]\d{6}|\d{4})-(\d{2})-(\d{2})$/,jh=/^([+-]\d{6}|\d{4})-(\d{2})-(\d{2})(?:T(\d{2}))?(?::(\d{2}))?(?::(\d{2}))?(\.\d+)?(?:(?:([+-]\d{2})(?::?(\d{2}))?)|Z)$/;function Ah(e){let t=e.match(Ch);if(!t)throw jh.test(e)?new Error(`Invalid ISO 8601 date string: ${e}. Use parseAbsolute() instead.`):new Error("Invalid ISO 8601 date string: "+e);let n=new Kt(fr(t[1],0,9999),fr(t[2],1,12),1);return n.day=fr(t[3],1,n.calendar.getDaysInMonth(n)),n}function fr(e,t,n){let r=Number(e);if(r<t||r>n)throw new RangeError(`Value out of range: ${t} <= ${r} <= ${n}`);return r}function Mh(e){return`${String(e.hour).padStart(2,"0")}:${String(e.minute).padStart(2,"0")}:${String(e.second).padStart(2,"0")}${e.millisecond?String(e.millisecond/1e3).slice(1):""}`}function Il(e){let t=hs(e,new Pn),n;return t.era==="BC"?n=t.year===1?"0000":"-"+String(Math.abs(1-t.year)).padStart(6,"00"):n=String(t.year).padStart(4,"0"),`${n}-${String(t.month).padStart(2,"0")}-${String(t.day).padStart(2,"0")}`}function Eh(e){return`${Il(e)}T${Mh(e)}`}function Th(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function $l(e,t,n){Th(e,t),t.set(e,n)}function Ol(e){let t=typeof e[0]=="object"?e.shift():new Pn,n;if(typeof e[0]=="string")n=e.shift();else{let a=t.getEras();n=a[a.length-1]}let r=e.shift(),s=e.shift(),i=e.shift();return[t,n,r,s,i]}var Dh=new WeakMap;class Kt{copy(){return this.era?new Kt(this.calendar,this.era,this.year,this.month,this.day):new Kt(this.calendar,this.year,this.month,this.day)}add(t){return ms(this,t)}subtract(t){return El(this,t)}set(t){return Tl(this,t)}cycle(t,n,r){return Dl(this,t,n,r)}toDate(t){return jl(this,t)}toString(){return Il(this)}compare(t){return kl(this,t)}constructor(...t){$l(this,Dh,{writable:!0,value:void 0});let[n,r,s,i,a]=Ol(t);this.calendar=n,this.era=r,this.year=s,this.month=i,this.day=a,At(this)}}var Ih=new WeakMap;class An{copy(){return this.era?new An(this.calendar,this.era,this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond):new An(this.calendar,this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond)}add(t){return ms(this,t)}subtract(t){return El(this,t)}set(t){return Tl(vh(this,t),t)}cycle(t,n,r){switch(t){case"era":case"year":case"month":case"day":return Dl(this,t,n,r);default:return Sh(this,t,n,r)}}toDate(t,n){return jl(this,t,n)}toString(){return Eh(this)}compare(t){let n=kl(this,t);return n===0?mh(this,Al(t)):n}constructor(...t){$l(this,Ih,{writable:!0,value:void 0});let[n,r,s,i,a]=Ol(t);this.calendar=n,this.era=r,this.year=s,this.month=i,this.day=a,this.hour=t.shift()||0,this.minute=t.shift()||0,this.second=t.shift()||0,this.millisecond=t.shift()||0,At(this)}}const $h={monthly:1,quarterly:3,annual:12};function Ll(e,t){const n=Math.max(1,Math.floor(t.numberOfInstallments||1)),r=Math.floor(e*100/n),i=Math.round(e*100)-r*n,a=new Date(`${t.firstInstallmentDate}T00:00:00`),l=$h[t.frequency];return Array.from({length:n},(c,d)=>{const u=new Date(a);return u.setMonth(a.getMonth()+d*l),{id:crypto.randomUUID(),dueDate:u.toISOString().slice(0,10),amount:(r+(d<i?1:0))/100}})}const Oh={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",firstInstallmentDate:"First payment date",installment:"Payment",dueDate:"Due date",amount:"Amount",total:"Total",remaining:"Remaining",deleteInstallment:"Delete installment",monthly:"Monthly",quarterly:"Quarterly",annual:"Annual",totalError:"Payment total must equal donation amount"},Lh=["monthly","quarterly","annual"],Fl={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-950"},Mn={label:"text-sm font-normal text-zinc-950",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"},Fh={label:"text-sm font-normal text-zinc-950",trigger:"h-9 rounded-xl border border-zinc-200 bg-white shadow-none hover:border-zinc-300 data-[hover=true]:border-zinc-300 data-[focus=true]:border-zinc-400 data-[focus-visible=true]:ring-0"},Oi=()=>({id:crypto.randomUUID(),dueDate:new Date().toISOString().slice(0,10),amount:0}),Pr=e=>Math.round(e*100)/100,Ph=(e,t)=>{const n=new Date(`${e}T00:00:00`);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(t,{month:"short",day:"numeric",year:"numeric"}).format(n)},Pl=e=>{if(!e)return null;try{return Ah(e)}catch{return null}};function Rh({mode:e,donationAmount:t,currency:n="USD",locale:r="en-US",installments:s,automaticSettings:i,labels:a,classNames:l,isSaving:c=!1,isModeSwitchDisabled:d=!1,onModeChange:u,onAutomaticSettingsChange:f,onInstallmentsChange:p,onSave:m}){const v={...Oh,...a},b=y.useMemo(()=>new Intl.NumberFormat(r,{style:"currency",currency:n}),[n,r]),x=e==="automatic"?Ll(t,i):s,w=y.useMemo(()=>Pr(x.reduce((M,I)=>M+Number(I.amount||0),0)),[x]),N=M=>{M!==e&&(u(M),M==="manual"&&s.length===0&&p([Oi()]))},A=(M,I)=>{s.find(R=>R.id===M)?.status!=="paid"&&p(s.map(R=>R.id===M?{...R,...I}:R))},S=()=>{p([...s,Oi()])},j=M=>{s.find(B=>B.id===M)?.status!=="paid"&&p(s.filter(B=>B.id!==M))};return o.jsx("div",{className:h.cn("vvt-ps font-sans text-zinc-900",l?.root),children:o.jsx(h.Accordion,{variant:"splitted",defaultSelectedKeys:["installment-schedule"],className:h.cn("w-full gap-0 px-0",l?.panel),itemClasses:{base:"w-full rounded-2xl border border-zinc-200 bg-white p-0 shadow-sm",trigger:h.cn("px-4 py-4",l?.header),title:"text-xl font-semibold leading-8 text-zinc-900",content:"w-full px-4 pb-4 pt-0",indicator:"text-zinc-500"},children:o.jsx(h.AccordionItem,{"aria-label":v.title,title:v.title,children:o.jsxs("div",{className:h.cn("flex w-full flex-col gap-4",l?.content),children:[o.jsxs("div",{className:"flex w-full items-center justify-between gap-6",children:[o.jsx(zh,{mode:e,labels:v,onModeChange:N,isDisabled:d,className:l?.tabs}),o.jsx(W,{type:"button",size:"sm",color:"primary",radius:"full",className:"ml-auto h-9 min-w-36 bg-brand px-4 text-sm font-medium text-white",startContent:o.jsx(H,{icon:"solar:cloud-upload-outline",className:"size-4"}),isLoading:c,onPress:m,children:v.saveInstallments})]}),o.jsxs("div",{className:"flex w-full flex-col gap-4",children:[e==="automatic"&&o.jsx(Bh,{settings:i,labels:v,onSettingsChange:f}),x.length===0&&o.jsx(h.Alert,{icon:o.jsx(H,{icon:"solar:info-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,classNames:Fl,color:"default",variant:"flat",title:e==="automatic"?v.emptyAutomatic:v.emptyManual}),x.length>0&&o.jsx(_h,{mode:e,installments:x,labels:v,formatter:b,locale:r,onUpdateInstallment:A,onRemoveInstallment:j}),e==="manual"&&o.jsx("div",{className:"flex flex-wrap gap-3",children:o.jsx(W,{type:"button",variant:"bordered",radius:"full",className:"h-9 border-zinc-200 bg-white px-4 text-sm font-normal text-zinc-900",startContent:o.jsx(U.Plus,{className:"size-5",strokeWidth:2}),onPress:S,children:v.addInstallment})}),o.jsx(Hh,{total:w,donationAmount:t,difference:Pr(t-w),hasTotalError:e==="manual"&&Math.abs(t-w)>.009,mode:e,installmentCount:x.length,formatter:b})]})]})},"installment-schedule")})})}function zh({mode:e,labels:t,className:n,isDisabled:r=!1,onModeChange:s}){return o.jsxs(h.Tabs,{"aria-label":t.title,selectedKey:e,isDisabled:r,radius:"full",size:"sm",variant:"light",className:h.cn("w-fit",n),classNames:{base:"w-fit",tabList:"h-10 w-fit rounded-full bg-zinc-200 p-1",tab:"h-8 w-auto rounded-full px-5 text-sm font-normal",cursor:"rounded-full bg-white shadow-sm",tabContent:"text-zinc-500 group-data-[selected=true]:text-zinc-900",panel:"hidden"},onSelectionChange:i=>s(i),children:[o.jsx(h.Tab,{title:t.automaticMode},"automatic"),o.jsx(h.Tab,{title:t.manualMode},"manual")]})}function Bh({settings:e,labels:t,onSettingsChange:n}){return o.jsxs("div",{className:"grid gap-4",style:{gridTemplateColumns:"repeat(3, minmax(0, 1fr))"},children:[o.jsx("div",{className:"min-w-0",children:o.jsx(h.Input,{variant:"bordered",label:t.numberOfInstallments,labelPlacement:"outside",type:"number",min:1,step:1,value:e.numberOfInstallments>0?String(e.numberOfInstallments):"",onWheel:r=>r.currentTarget.blur(),onChange:r=>{const s=r.target.value;n({...e,numberOfInstallments:s===""?0:Math.max(1,Number(s))})},classNames:Mn})}),o.jsx("div",{className:"min-w-0",children:o.jsx(pt,{variant:"bordered",label:t.frequency,labelPlacement:"outside",selectedKeys:[e.frequency],onSelectionChange:r=>{const s=Array.from(r)[0];typeof s=="string"&&n({...e,frequency:s})},classNames:Fh,children:Lh.map(r=>o.jsx(h.SelectItem,{textValue:t[r],children:t[r]},r))})}),o.jsx("div",{className:"min-w-0",children:o.jsx(h.DatePicker,{variant:"bordered",label:t.firstInstallmentDate,labelPlacement:"outside",value:Pl(e.firstInstallmentDate),onChange:r=>n({...e,firstInstallmentDate:r?r.toString():""}),startContent:o.jsx(H,{icon:"solar:calendar-outline",className:"size-4 text-zinc-500"}),classNames:Mn})})]})}function _h({mode:e,installments:t,labels:n,formatter:r,locale:s,onUpdateInstallment:i,onRemoveInstallment:a}){return e==="automatic"?o.jsx("div",{className:"rounded-2xl border border-zinc-200 bg-zinc-50 p-4",children:o.jsx("div",{className:h.cn("flex flex-col gap-3",t.length>5&&"max-h-[264px] overflow-y-auto pr-2"),children:t.map((l,c)=>o.jsxs("div",{className:h.cn("flex min-h-10 items-center justify-between rounded-xl px-4 py-2 text-base",c===0&&"border border-brand/25 bg-brand/5 text-brand"),children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("span",{children:["#",c+1]}),o.jsx("span",{children:"▪"}),o.jsx("span",{children:Ph(l.dueDate,s)}),c===0&&o.jsx(h.Chip,{size:"sm",radius:"full",className:"h-6 bg-brand px-2 text-xs font-semibold text-white",children:"First charge"})]}),o.jsx("span",{className:"text-zinc-950",children:r.format(l.amount)})]},l.id))})}):o.jsx("div",{className:"flex flex-col gap-2",children:t.map((l,c)=>o.jsxs("div",{className:"flex w-full items-center gap-4",children:[o.jsx("div",{className:"min-w-0 flex-1",children:o.jsx(h.DatePicker,{variant:"bordered","aria-label":`${n.dueDate} ${c+1}`,isDisabled:l.status==="paid",value:Pl(l.dueDate),onChange:d=>i(l.id,{dueDate:d?d.toString():""}),classNames:Mn})}),o.jsx("div",{className:"min-w-0 flex-1",children:o.jsx(h.Input,{variant:"bordered",type:"number",min:0,step:.01,isDisabled:l.status==="paid",value:String(l.amount||""),onChange:d=>i(l.id,{amount:Pr(Number(d.target.value||0))}),startContent:o.jsx("span",{className:"text-zinc-900",children:"$"}),classNames:Mn})}),o.jsx(Vh,{isDisabled:t.length<=1,isPaid:l.status==="paid",label:n.deleteInstallment,onRemove:()=>a(l.id)})]},l.id))})}function Vh({isDisabled:e,isPaid:t,label:n,onRemove:r}){const s=o.jsx(W,{type:"button",isIconOnly:!0,variant:"flat",radius:"full",className:"h-9 w-9 flex-none bg-danger-100 p-0 text-danger-600",style:{height:36,minWidth:36,width:36},isDisabled:e||t,onPress:r,"aria-label":n,children:o.jsx(H,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"})});return t?o.jsx(h.Tooltip,{content:"This payment cannot be edited or deleted because it has already been paid.",placement:"top",children:o.jsx("span",{className:"inline-flex",children:s})}):s}function Hh({total:e,donationAmount:t,difference:n,hasTotalError:r,mode:s,installmentCount:i,formatter:a}){const l=i>0?e/i:0,c=s==="automatic"?o.jsxs("span",{children:["Saving will create ",o.jsx("strong",{children:i})," scheduled payment records of"," ",o.jsx("strong",{children:a.format(l)})," each."]}):o.jsxs("span",{children:["Total scheduled: ",o.jsx("strong",{children:a.format(e)})," /"," ",o.jsx("strong",{children:a.format(t)}),"."]}),d=s==="automatic"?`Total: ${a.format(e)}`:r?`Missing: ${a.format(n)}`:`Remaining: ${a.format(0)}`;return o.jsx(h.Alert,{icon:o.jsx(H,{icon:"solar:info-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,color:"default",variant:"flat",classNames:Fl,endContent:o.jsx("span",{className:"whitespace-nowrap",children:d}),title:c})}function Uh(){return o.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:[o.jsxs("div",{className:"flex items-start justify-between gap-3",children:[o.jsx(h.Skeleton,{className:"h-7 w-56 rounded-lg"}),o.jsx(h.Skeleton,{className:"size-8 rounded-full"})]}),o.jsxs("div",{className:"flex items-center justify-between gap-3",children:[o.jsx(h.Skeleton,{className:"h-10 w-72 rounded-full"}),o.jsx(h.Skeleton,{className:"h-10 w-40 rounded-full"})]}),o.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[o.jsxs("div",{className:"flex w-full max-w-[280px] flex-col gap-2",children:[o.jsx(h.Skeleton,{className:"h-4 w-36 rounded-md"}),o.jsx(h.Skeleton,{className:"h-9 w-full rounded-xl"})]}),o.jsx(h.Skeleton,{className:"h-9 w-36 rounded-full"})]}),o.jsx("div",{className:"flex flex-col gap-3",children:Array.from({length:4}).map((e,t)=>o.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_160px] items-center gap-4 rounded-2xl border border-zinc-100 p-3",children:[o.jsx(h.Skeleton,{className:"h-8 w-full max-w-xs rounded-full"}),o.jsx(h.Skeleton,{className:"h-8 w-full rounded-xl"})]},t))})]})}const Li={paid:"bg-emerald-50 text-emerald-700",fulfilled:"bg-emerald-50 text-emerald-700",scheduled:"bg-blue-50 text-blue-700",failed:"bg-red-50 text-red-700",cancelled:"bg-zinc-100 text-zinc-600",refunded:"bg-zinc-100 text-zinc-600"},Fi={paid:"Paid",fulfilled:"Paid",scheduled:"Scheduled",failed:"Failed",cancelled:"Cancelled",refunded:"Refunded"},qh={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:o.jsxs(o.Fragment,{children:["Are you sure you want to delete this payment? ",o.jsx("strong",{children:"This action cannot be undone."})]}),deleteInstallmentConfirmationCancel:"Cancel",deleteInstallmentConfirmationConfirm:"Confirm",noInstallmentsFound:"No payments found."};function Wh({installments:e,currency:t,locale:n="en-US",labels:r,isSaving:s=!1,onEditInstallments:i,onPayInstallment:a,onDeleteInstallment:l}){const c={...qh,...r},[d,u]=y.useState(""),f=new Intl.NumberFormat(n,{style:"currency",currency:t}),p=y.useMemo(()=>{const m=d.trim().toLowerCase();return m?e.filter(v=>{const b=v.status??"scheduled";return[v.id,v.amount,v.dueDate,Pi(v.dueDate,n),b,Fi[b]??b].join(" ").toLowerCase().includes(m)}):e},[n,e,d]);return o.jsx("div",{className:"vvt-ps w-full font-sans text-zinc-900",children:o.jsx(h.Accordion,{variant:"splitted",defaultSelectedKeys:["installment-table"],className:"w-full gap-0 px-0",itemClasses:{base:"w-full rounded-2xl border border-zinc-200 bg-white p-0 shadow-sm",trigger:"px-4 py-4",title:"text-xl font-semibold leading-8 text-zinc-900",content:"w-full px-4 pb-4 pt-0",indicator:"text-zinc-500"},children:o.jsx(h.AccordionItem,{"aria-label":c.title,title:c.title,children:o.jsxs("div",{className:"flex w-full flex-col gap-4",children:[o.jsxs("div",{className:"flex w-full items-end justify-between gap-6",children:[o.jsxs("div",{className:"w-full max-w-[280px]",children:[o.jsx("label",{className:"mb-1 block text-sm font-normal text-zinc-950",children:c.searchLabel}),o.jsx(h.Input,{variant:"bordered",size:"sm",value:d,placeholder:c.searchPlaceholder,onChange:m=>u(m.target.value),startContent:o.jsx(H,{icon:"solar:magnifer-outline",className:"size-4 text-zinc-500"}),classNames:{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"}})]}),o.jsx(W,{type:"button",variant:"bordered",radius:"full",size:"sm",className:"h-8 border-zinc-200 bg-white px-3 text-sm font-normal text-zinc-900",startContent:o.jsx(H,{icon:"solar:pen-outline",className:"size-4"}),isLoading:s,onPress:i,children:c.editInstallments})]}),o.jsx("div",{className:"w-full overflow-hidden",children:o.jsxs("table",{className:"w-full table-fixed border-collapse text-left text-sm",children:[o.jsxs("colgroup",{children:[o.jsx("col",{className:"w-[6%]"}),o.jsx("col",{className:"w-[25%]"}),o.jsx("col",{className:"w-[12%]"}),o.jsx("col",{className:"w-[16%]"}),o.jsx("col",{className:"w-[17%]"}),o.jsx("col",{className:"w-[24%]"})]}),o.jsx("thead",{children:o.jsxs("tr",{className:"border-b border-zinc-200 text-zinc-900",children:[o.jsx("th",{className:"w-14 px-2 py-3 font-medium",children:"#"}),o.jsx("th",{className:"px-2 py-3 font-medium",children:c.installmentId}),o.jsx("th",{className:"px-2 py-3 font-medium",children:c.amount}),o.jsx("th",{className:"px-2 py-3 font-medium",children:c.scheduledDate}),o.jsx("th",{className:"px-2 py-3 font-medium",children:c.status}),o.jsx("th",{className:"px-2 py-3 font-medium",children:c.actions})]})}),o.jsxs("tbody",{children:[p.map((m,v)=>{const b=m.status??"scheduled";return o.jsxs("tr",{className:"text-zinc-500",children:[o.jsx("td",{className:"px-2 py-3",children:v+1}),o.jsx("td",{className:"px-2 py-3",children:o.jsx("span",{className:"block max-w-full truncate",children:m.id||`PMT-${v+1}`})}),o.jsx("td",{className:"px-2 py-3",children:f.format(m.amount)}),o.jsx("td",{className:"px-2 py-3",children:Pi(m.dueDate,n)}),o.jsx("td",{className:"px-2 py-3",children:o.jsx(h.Chip,{size:"sm",radius:"full",className:h.cn("h-8 min-w-[118px] justify-center px-4 text-sm font-normal",Li[b]??Li.scheduled),startContent:o.jsx(Jh,{status:b}),children:Fi[b]??b})}),o.jsx("td",{className:"px-2 py-3",children:o.jsxs("div",{className:"flex min-w-[154px] items-center justify-start gap-2",children:[o.jsx(W,{type:"button",size:"sm",radius:"full",className:"h-9 min-w-[104px] shrink-0 bg-brand px-3 text-sm font-medium text-white disabled:opacity-50",isDisabled:b==="paid"||b==="fulfilled",startContent:o.jsx(H,{icon:"solar:dollar-minimalistic-outline",className:"size-4"}),onPress:()=>a?.(m),children:c.payNow}),o.jsx(Kh,{isPaid:b==="paid"||b==="fulfilled",labels:c,onDelete:()=>l(m.id)})]})})]},m.id)}),p.length===0&&o.jsx("tr",{children:o.jsx("td",{colSpan:6,className:"px-2 py-6 text-center text-zinc-500",children:c.noInstallmentsFound})})]})]})})]})},"installment-table")})})}function Kh({isPaid:e,labels:t,onDelete:n}){const[r,s]=y.useState(!1);return o.jsxs(o.Fragment,{children:[o.jsxs(h.Dropdown,{placement:"bottom-end",radius:"lg",children:[o.jsx(h.DropdownTrigger,{children:o.jsx(W,{type:"button",isIconOnly:!0,size:"sm",variant:"light",className:"text-zinc-900","aria-label":"More actions",children:o.jsx(H,{icon:"solar:menu-dots-bold",className:"size-4"})})}),o.jsxs(h.DropdownMenu,{"aria-label":"Installment actions",disabledKeys:e?["delete"]:[],className:"w-72 p-2",onAction:i=>{i==="delete"&&!e&&s(!0)},children:[o.jsx(h.DropdownSection,{title:"Actions",showDivider:!0,children:o.jsx(h.DropdownItem,{textValue:t.sendLink,description:t.sendLinkDescription,startContent:o.jsx(H,{icon:"solar:link-outline",className:"size-5 text-zinc-500"}),children:t.sendLink},"send-link")}),o.jsx(h.DropdownSection,{title:t.dangerZone,children:o.jsx(h.DropdownItem,{textValue:t.deleteInstallment,className:"text-danger-600",color:"danger",description:t.deleteInstallmentDescription,startContent:o.jsx(H,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"}),children:t.deleteInstallment},"delete")})]})]}),o.jsx(jn,{isOpen:r,labels:{title:t.deleteInstallmentConfirmationTitle,description:t.deleteInstallmentConfirmationDescription,cancel:t.deleteInstallmentConfirmationCancel,confirm:t.deleteInstallmentConfirmationConfirm},icon:o.jsx(H,{icon:"solar:danger-triangle-outline",className:"size-7"}),confirmColor:"danger",onClose:()=>s(!1),onConfirm:()=>{s(!1),n()}})]})}function Jh({status:e}){return e==="paid"||e==="fulfilled"?o.jsx(H,{icon:"solar:check-circle-bold",className:"size-3"}):e==="failed"?o.jsx(H,{icon:"solar:close-circle-bold",className:"size-3"}):o.jsx(H,{icon:"solar:calendar-outline",className:"size-3"})}function Pi(e,t){const n=new Date(`${e}T00:00:00`);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(t,{month:"short",day:"numeric",year:"numeric"}).format(n)}const Yh={title:"Select Membership",renewalTitle:"Automatic Renewal",renewalDescription:"Membership will automatically renew at the end of each period"},Gh=({cards:e,locale:t,currency:n,listHeightClassName:r="",labels:s,showRenewal:i=!0,defaultRenewalValue:a=!1,initialSelectedMembershipId:l=null,allowReselect:c=!0,onRenewalChange:d,onCardSelect:u,className:f=""})=>{const p=Array.isArray(e)?e:[],[m,v]=y.useState(l),[b,x]=y.useState(a),w={...Yh,...s};y.useEffect(()=>{v(l)},[l]);const N=S=>{if(S===m){c&&u?.(S);return}v(S),u?.(S)},A=S=>{x(S),d?.(S)};return o.jsxs("div",{className:h.cn("w-full flex flex-col gap-4 items-start p-4 h-svh",f),"data-testid":"membership-select-cards",children:[o.jsx("span",{className:"hidden","data-testid":"membership-select-cards-selected-id",children:m??""}),o.jsx("p",{className:"text-2xl font-semibold text-left","data-testid":"membership-select-cards-title",children:w.title}),i&&o.jsx(zl,{title:w.renewalTitle,description:w.renewalDescription,value:b,onValueChange:A}),o.jsx("div",{className:h.cn("w-full min-h-0 flex flex-col gap-4 overflow-y-auto",r===""?"flex-1":h.cn("shrink-0",r)),"data-testid":"membership-select-cards-list",children:p.map(S=>o.jsx(Rl,{itemKey:S.id,name:S.name,type:S.type,price:S.price,locale:t,currency:n,isSelected:m===S.id,onSelect:N},S.id))})]})},Rl=({itemKey:e,name:t,type:n,price:r,locale:s="en-US",currency:i="USD",isSelected:a=!1,onSelect:l,className:c=""})=>{const d=new Intl.NumberFormat(s,{style:"currency",currency:i,minimumFractionDigits:0,maximumFractionDigits:2}).format(r);return o.jsx(h.Card,{shadow:"none",isPressable:!!l,onPress:()=>l?.(e),className:h.cn("w-full min-h-fit border rounded-3xl",a?"border-primary bg-primary/5":"border-default",c),"data-testid":"item-card","data-selected":a,children:o.jsxs("div",{className:"px-4 py-8 flex gap-6 items-center justify-between",children:[o.jsxs("div",{className:"w-max flex flex-col gap-1 items-start",children:[o.jsx("p",{className:"text-xl font-semibold text-left","data-testid":"item-card-name",children:t}),n&&o.jsx("div",{"data-testid":"item-card-type",className:"w-fit bg-default-300 px-4 py-2 text-sm rounded-xl",children:o.jsx("p",{className:"text-center",children:n})})]}),o.jsx("p",{className:"text-2xl font-semibold","data-testid":"item-card-price",children:d})]})})},zl=({title:e,value:t,description:n,onValueChange:r,className:s=""})=>{const i=y.useId();return o.jsxs("div",{className:h.cn("w-full flex flex-row items-center",e||n?"justify-between gap-6":"justify-start",s),"data-testid":"toggle",children:[o.jsxs("div",{className:"flex flex-col items-start",children:[e&&o.jsx("label",{htmlFor:i,className:"font-medium text-left","data-testid":"toggle-title",children:e}),n&&o.jsx("p",{className:"text-left text-gray-500","data-testid":"toggle-description",children:n})]}),o.jsx(h.Switch,{id:i,isSelected:t,onValueChange:r,"data-testid":"toggle-switch"})]})},Qh={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"},Zh=(e,t)=>new Intl.NumberFormat(e,{style:"currency",currency:t}),Bl=e=>Object.values(e).reduce((t,n)=>t+Object.values(n).reduce((r,s)=>r+Object.values(s).reduce((i,a)=>i+a.selectedQuantity,0),0),0),Xh=e=>e.reduce((t,n)=>t+n.dates.reduce((r,s)=>r+s.tickets.reduce((i,a)=>i+a.max,0),0),0),ps=e=>e.flatMap(t=>t.dates.flatMap(n=>n.tickets.map(r=>({exhibition:t,dateGroup:n,ticket:r})))),Ri=(e,t,n)=>{const r={};let s=n?t??Xh(e):0;for(const{exhibition:i,dateGroup:a,ticket:l}of ps(e)){r[i.id]??={},r[i.id][a.id]??={};const c=n?Math.min(l.max,s):0;r[i.id][a.id][l.id]={id:l.id,selectedQuantity:c,originalPrice:l.originalPrice,discountedPrice:l.price},s-=c}return r},zi=(e,t,n)=>`${e}::${t}::${n}`,em=(e,t,n)=>{const r=Bl(t);for(const{exhibition:s,dateGroup:i,ticket:a}of ps(e)){const l=t[s.id]?.[i.id]?.[a.id]?.selectedQuantity??0,c=n===void 0?a.max:Math.min(a.max,n-(r-l));if(c>0&&l<c)return!1}return!0},tm=({initialQuantity:e=1,minQuantity:t=1,maxQuantity:n=10,onChange:r,disabled:s=!1})=>{const i=Math.max(t,Math.min(n,e)),[a,l]=y.useState(()=>String(i)),[c,d]=y.useState(!1),u=c?a:String(i),f=()=>{s||i>=n||r?.(i+1)},p=()=>{s||i<=t||r?.(i-1)},m=S=>{if(s)return;l(S.target.value);const j=parseInt(S.target.value,10);isNaN(j)||r?.(Math.max(t,Math.min(n,j)))},v=S=>{const j=parseInt(S.target.value,10);if(d(!1),isNaN(j)){r?.(t);return}const M=Math.max(t,Math.min(n,j));M!==j?r?.(M):l(String(M))},b=i<=t,x=i>=n,w="w-10 h-10 flex items-center justify-center border-0 rounded-full cursor-pointer transition-colors duration-150 text-white text-2xl font-regular",N="bg-primary hover:bg-primary/80",A="bg-primary/40 cursor-not-allowed";return o.jsxs("div",{className:"flex items-center gap-4","data-testid":"quantity-selector",children:[o.jsx("button",{type:"button",onClick:p,disabled:s||b,className:h.cn(w,s||b?A:N),"aria-label":"Decrement quantity","data-testid":"quantity-decrement",children:"-"}),o.jsx("input",{type:"number",value:u,onChange:m,onFocus:()=>d(!0),onBlur:v,disabled:s,min:t,max:n,step:"1",className:"w-12 h-10 rounded-md border-0 bg-zinc-100 text-center text-2xl font-medium text-zinc-900 [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none","aria-label":`Selected quantity: ${i}`,"data-testid":"quantity-input"}),o.jsx("button",{type:"button",onClick:f,disabled:s||x,className:h.cn(w,s||x?A:N),"aria-label":"Increment quantity","data-testid":"quantity-increment",children:"+"})]})},nm=({label:e,checked:t=!1,onChange:n,disabled:r=!1})=>{const s=()=>{r||n?.(!t)};return o.jsxs("button",{type:"button",onClick:s,disabled:r,role:"checkbox","aria-checked":t,"data-testid":"checkbox-button","data-checked":t,className:h.cn("flex items-center gap-1.5 px-4 py-3 border-0 rounded-full cursor-pointer text-sm min-h-[30px]","outline-none select-none transition-colors bg-zinc-100 hover:bg-zinc-200 text-primary",r&&"cursor-not-allowed opacity-60"),children:[o.jsxs("span",{className:"relative flex items-center justify-center w-5 h-5 flex-shrink-0",children:[o.jsx("input",{type:"checkbox",checked:t,onChange:()=>{},disabled:r,className:"absolute opacity-0 w-0 h-0 pointer-events-none",tabIndex:-1,readOnly:!0}),o.jsx("span",{className:h.cn("block w-3.5 h-3.5 rounded-sm relative",t?"bg-primary":"bg-white ring-1 ring-zinc-300"),children:t&&o.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"})})]}),o.jsx("p",{className:"flex-1 m-0 text-left leading-snug",children:e})]})},rm=({item:e,quantity:t,onChange:n,getTotalSelectedTickets:r,userMaxLimit:s,settings:i,labels:a})=>{const l=()=>{if(!r||s===void 0)return e.max;const f=r();return Math.min(e.max,s-(f-t))},c=i?.locale??"en-US",d=i?.currency??"USD",u=Zh(c,d);return o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between bg-white px-3 py-2.5 gap-8","data-testid":"upgrade-ticket-item",children:[o.jsxs("div",{className:"min-w-0 flex flex-1 flex-col gap-2",children:[o.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[o.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?o.jsx("span",{"data-testid":"ticket-purchased-quantity",children:` x${e.purchasedQuantity}`}):null]}),o.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[o.jsx("h3",{className:"line-through text-zinc-500 text-[0.9rem] font-normal m-0","data-testid":"ticket-original-price",children:u.format(e.originalPrice)}),o.jsx("h3",{className:"text-base font-semibold text-zinc-900 m-0","data-testid":"ticket-discounted-price",children:u.format(e.price)})]})]}),e.membershipName?o.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:o.jsx("p",{className:"max-w-full truncate text-center",children:e.membershipName})}):null,o.jsx("div",{className:"text-sm text-zinc-500",children:o.jsxs("p",{className:"m-0","data-testid":"ticket-max",children:[a.ticketsAllowedToRedeem," ",e.max]})})]}),o.jsx(tm,{initialQuantity:t,minQuantity:0,maxQuantity:l(),onChange:n})]}),e.membershipAlert?o.jsx(h.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:o.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]})},sm=({exhibitionId:e,dateGroup:t,isLast:n=!1,onQuantityChange:r,getTicketQuantity:s,getTotalSelectedTickets:i,userMaxLimit:a,settings:l,labels:c})=>o.jsxs("div",{className:h.cn("flex flex-col gap-2 pb-3",!n&&"border-b border-zinc-200"),"data-testid":"upgrade-ticket-date-group",children:[o.jsx("p",{className:"m-0 text-sm text-left text-zinc-500","data-testid":"upgrade-ticket-date",children:t.date}),t.tickets.map((d,u)=>o.jsxs("div",{children:[o.jsx(rm,{item:d,quantity:s(e,t.id,d.id),onChange:f=>r(e,t.id,d.id,f),getTotalSelectedTickets:i,userMaxLimit:a,settings:l,labels:c}),u<t.tickets.length-1?o.jsx(h.Divider,{className:"bg-zinc-200","data-testid":"upgrade-ticket-divider"}):null]},d.id))]}),im=({title:e,exhibition:t,onQuantityChange:n,getTicketQuantity:r,getTotalSelectedTickets:s,userMaxLimit:i,settings:a,labels:l,initialExpanded:c=!1})=>{const[d,u]=y.useState(c),f=t.dates.reduce((m,v)=>m+v.tickets.reduce((b,x)=>b+r(t.id,v.id,x.id),0),0),p=t.dates.some(m=>m.tickets.length>0);return o.jsxs("div",{className:"w-full overflow-hidden border-b border-zinc-200","data-testid":"upgrade-ticket-header",children:[o.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:()=>u(!d),"aria-expanded":d,"aria-controls":`upgrade-items-${t.id}`,"data-testid":"upgrade-ticket-header-button",children:o.jsxs("div",{className:"flex justify-between items-center w-full gap-6",children:[o.jsx("h4",{className:"m-0 text-base font-semibold text-left text-zinc-900","data-testid":"upgrade-ticket-header-title",children:e}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs("p",{className:"m-0 text-sm text-right text-zinc-500","data-testid":"upgrade-ticket-header-count",children:[f," ",l.ticketsSelectedToRedeem]}),o.jsx("span",{className:h.cn("inline-flex items-center justify-center text-zinc-500 text-xl transition-transform duration-200",d&&"rotate-180"),"aria-hidden":"true",children:o.jsx(H,{icon:"mdi:chevron-down"})})]})]})}),o.jsx("div",{id:`upgrade-items-${t.id}`,className:h.cn("transition-all duration-300 overflow-hidden",d?"max-h-[1000px] opacity-100":"max-h-0 opacity-0"),"aria-hidden":!d,children:d&&o.jsx("div",{className:"px-5 flex flex-col gap-6","data-testid":"upgrade-ticket-items",children:p?t.dates.map((m,v)=>o.jsx(sm,{exhibitionId:t.id,dateGroup:m,isLast:v===t.dates.length-1,onQuantityChange:n,getTicketQuantity:r,getTotalSelectedTickets:s,userMaxLimit:i,settings:a,labels:l},m.id)):o.jsx("div",{className:"px-5 py-10 text-center",children:o.jsx("p",{className:"m-0 text-zinc-500 italic",children:l.noUpgradeTicketsAvailable})})})})]})},am=({initialExpanded:e=!1,userMaxLimit:t,labels:n,settings:r,ticketSelectionData:s,className:i="",onSelectionChange:a})=>{const l=y.useMemo(()=>s??[],[s]),c={...Qh,...n},[d,u]=y.useState(()=>Ri(l,t,!0)),f=y.useRef(!1),p=y.useMemo(()=>{const N=ps(l).map(({exhibition:A,dateGroup:S,ticket:j})=>[zi(A.id,S.id,j.id),j]);return new Map(N)},[l]),m=em(l,d,t),v=(N,A,S)=>d[N]?.[A]?.[S]?.selectedQuantity??0,b=()=>Bl(d),x=(N,A,S,j)=>{const M=v(N,A,S),I=b()-M;if(t!==void 0&&I+j>t)return;const B=p.get(zi(N,A,S));if(!B)return;const R={...d,[N]:{...d[N],[A]:{...d[N]?.[A],[S]:{id:S,selectedQuantity:j,originalPrice:B.originalPrice,discountedPrice:B.price}}}};u(R),a?.(R)},w=N=>{const A=Ri(l,t,N);u(A),a?.(A)};return y.useEffect(()=>{!f.current&&m&&(a?.(d),f.current=!0)},[m,d,a]),o.jsxs("div",{className:h.cn("flex flex-col w-full font-sans",i),"data-testid":"ticket-selection",children:[o.jsxs("div",{className:"flex items-center justify-between py-2 gap-4","data-testid":"ticket-selection-header",children:[o.jsx("h3",{className:"text-xl font-semibold m-0","data-testid":"ticket-selection-title",children:c.ticketSelectionTitle}),o.jsx(nm,{label:c.selectAllButtonLabel,checked:m,onChange:w})]}),l.map(N=>o.jsx(im,{title:N.exhibitionName,exhibition:N,onQuantityChange:x,getTicketQuantity:v,getTotalSelectedTickets:b,userMaxLimit:t,settings:r,labels:c,initialExpanded:e},N.id))]})},lm=350,om={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}"},hr=(e,t)=>Object.entries(t).reduce((n,[r,s])=>n.replace(`{${r}}`,s),e),cm=({dueAmount:e,received:t,defaultReceived:n=null,onChange:r,locale:s="en-US",labels:i,isDisabled:a=!1,maxAmount:l,autoFocus:c=!1,className:d,"data-testid":u="cash-tender-form"})=>{const f={...om,...i},p=Br(e.currency,s),m=t!==void 0,[v,b]=y.useState(n??null),x=m?t:v,w=y.useMemo(()=>{const O=typeof x=="number"&&Number.isFinite(x)?x:0,F=pr(O,e.value,e.currency,s);return{received:O,change:F>0?F:0,isValid:O>=e.value&&O>0}},[x,e.value,e.currency,s]),N=y.useCallback(O=>{const F=O.currentTarget;requestAnimationFrame(()=>{F.isConnected&&F.select()})},[]),A=y.useCallback(O=>{if(a)return;const F=O.replace(/[^\d.,]/g,"").replace(",","."),K=F===""?null:Number.parseFloat(F),X=K===null||Number.isNaN(K)?null:K;if(X!==null&&l!==void 0&&X>l)return;m||b(X);const J=typeof X=="number"&&Number.isFinite(X)?X:0,se=pr(J,e.value,e.currency,s);r?.({received:J,change:se>0?se:0,isValid:J>=e.value&&J>0})},[m,a,e.value,e.currency,s,r,l]),S=x==null?"":String(x),j=w.isValid&&w.change>0,M=!w.isValid&&w.received>0,I=tt(w.change,s,e.currency),B=tt(e.value,s,e.currency),[R,_]=y.useState(""),E=y.useRef(null);y.useEffect(()=>{E.current&&clearTimeout(E.current);const O=j?hr(f.changeMessageTemplate,{change:I}):"",F=j?lm:0;return E.current=setTimeout(()=>_(O),F),()=>{E.current&&clearTimeout(E.current)}},[j,I,f.changeMessageTemplate]);const T=`${u}-received`;return o.jsxs("div",{className:h.cn("flex flex-col gap-3",d),"data-testid":u,children:[o.jsx(h.Input,{id:T,label:f.receivedLabel,labelPlacement:"outside",type:"text",inputMode:p===0?"numeric":"decimal",pattern:p===0?"[0-9]*":"[0-9]*[.,]?[0-9]*",value:S,onChange:O=>A(O.target.value),onFocus:N,placeholder:f.receivedPlaceholder,isDisabled:a,isInvalid:M,errorMessage:M?hr(f.insufficientMessageTemplate,{due:B}):void 0,variant:"bordered",radius:"lg",autoFocus:c,"data-testid":`${u}-received-input`}),j&&o.jsx(h.Alert,{"data-testid":`${u}-change-alert`,color:"primary",variant:"flat",radius:"lg",title:f.changeLabel,description:hr(f.changeMessageTemplate,{change:I}),icon:o.jsx(H,{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"}}),o.jsx("span",{role:"status","aria-live":"polite",className:"sr-only",children:R})]})},dm={checkNumberLabel:"Check Number",checkNumberPlaceholder:"e.g. 11234",bankNameLabel:"Bank Name",bankNamePlaceholder:"e.g. Chase Bank",dateLabel:"Date",checkNumberRequiredMessage:"Check number is required"},Bi=()=>{const e=new Date,t=n=>String(n).padStart(2,"0");return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`},_l=({dueAmount:e,value:t,defaultValue:n,onChange:r,labels:s,hideDate:i=!1,hideBankName:a=!1,isDisabled:l=!1,checkNumberMaxLength:c=34,bankNameMaxLength:d=100,autoFocus:u=!1,className:f,"data-testid":p="check-tender-form"})=>{const m={...dm,...s},v=t!==void 0,[b,x]=y.useState({checkNumber:n?.checkNumber??"",bankName:n?.bankName??"",date:n?.date??Bi()}),[w,N]=y.useState(!!n?.checkNumber),A=y.useMemo(()=>v?{checkNumber:t?.checkNumber??"",bankName:t?.bankName??"",date:t?.date??Bi()}:b,[v,t,b]),S=y.useCallback(E=>{v||x(E);const T=E.checkNumber.trim(),O={amount:e.value,checkNumber:T,bankName:E.bankName.trim()||void 0,date:i?void 0:E.date,isValid:T.length>0&&e.value>0};r?.(O)},[v,e.value,i,r]),j=y.useCallback(E=>T=>{l||(E==="checkNumber"&&T.length>0&&N(!0),S({...A,[E]:T}))},[A,S,l]),M=y.useCallback(()=>{l||N(!0)},[l]),I=w&&A.checkNumber.trim()==="",B=`${p}-check-number`,R=`${p}-bank-name`,_=`${p}-date`;return o.jsxs("div",{className:h.cn("grid grid-cols-1 sm:grid-cols-2 gap-4",f),"data-testid":p,children:[o.jsx(h.Input,{id:B,label:m.checkNumberLabel,labelPlacement:"outside",type:"text",value:A.checkNumber,onChange:E=>j("checkNumber")(E.target.value),onBlur:M,placeholder:m.checkNumberPlaceholder,maxLength:c,isRequired:!0,isInvalid:I,errorMessage:I?m.checkNumberRequiredMessage:void 0,isDisabled:l,variant:"bordered",radius:"lg",autoFocus:u,"data-testid":`${p}-check-number-input`}),!a&&o.jsx(h.Input,{id:R,label:m.bankNameLabel,labelPlacement:"outside",type:"text",value:A.bankName,onChange:E=>j("bankName")(E.target.value),placeholder:m.bankNamePlaceholder,maxLength:d,isDisabled:l,variant:"bordered",radius:"lg","data-testid":`${p}-bank-name-input`}),!i&&o.jsx(h.Input,{id:_,label:m.dateLabel,labelPlacement:"outside",type:"date",value:A.date,onChange:E=>j("date")(E.target.value),isDisabled:l,variant:"bordered",radius:"lg","data-testid":`${p}-date-input`,className:"sm:col-span-2"})]})};_l.displayName="CheckTenderForm";const um={methodLabel:"Method",methodPlaceholder:"Select a payment method",referenceLabel:"Reference",referencePlaceholder:"e.g. Voucher #1234",methodRequiredMessage:"Method is required"},fm=[{value:"ach",label:"ACH"},{value:"wire",label:"Wire"},{value:"gift_card",label:"Gift Card"},{value:"voucher",label:"Voucher"},{value:"other",label:"Other"}],Vl=({dueAmount:e,methodOptions:t=fm,value:n,defaultValue:r,onChange:s,labels:i,showReference:a=!1,isDisabled:l=!1,className:c,"data-testid":d="other-tender-form"})=>{const u={...um,...i},f=n!==void 0,[p,m]=y.useState({method:r?.method??"",reference:r?.reference??""}),v=y.useMemo(()=>f?{method:n?.method??"",reference:n?.reference??""}:p,[f,n,p]),b=y.useCallback(j=>t.find(M=>M.value===j)?.label??"",[t]),x=y.useCallback(j=>{f||m(j);const M=b(j.method),I={amount:e.value,method:j.method,description:M,reference:j.reference.trim()||void 0,isValid:j.method!==""};s?.(I)},[f,e.value,s,b]),w=y.useCallback(j=>{if(l)return;const M=typeof j=="string"?j:Array.from(j)[0]?.toString()??"";x({...v,method:M})},[v,x,l]),N=y.useCallback(j=>{l||x({...v,reference:j})},[v,x,l]),A=`${d}-method`,S=`${d}-reference`;return o.jsxs("div",{className:h.cn("flex flex-col gap-3",c),"data-testid":d,children:[o.jsx(pt,{id:A,label:u.methodLabel,labelPlacement:"outside",placeholder:u.methodPlaceholder,selectedKeys:v.method?[v.method]:[],onSelectionChange:w,isDisabled:l,isRequired:!0,variant:"bordered",radius:"lg","data-testid":`${d}-method-select`,popoverProps:{placement:"bottom-start",classNames:{content:"bg-white border border-default-200 shadow-lg rounded-xl p-1"}},listboxProps:{classNames:{list:"max-h-[var(--popover-available-height,40vh)] overflow-y-auto"},itemClasses:{base:["rounded-lg","px-3 py-2","text-default-800","data-[hover=true]:bg-default-100","data-[selectable=true]:focus:bg-default-100","data-[selected=true]:bg-primary-50","data-[selected=true]:text-primary","data-[selected=true]:font-medium"]}},children:t.map(j=>o.jsx(h.SelectItem,{"data-testid":`${d}-method-option-${j.value}`,children:j.label},j.value))}),a&&o.jsx(h.Input,{id:S,label:u.referenceLabel,labelPlacement:"outside",type:"text",value:v.reference,onChange:j=>N(j.target.value),placeholder:u.referencePlaceholder,isDisabled:l,variant:"bordered",radius:"lg","data-testid":`${d}-reference-input`})]})};Vl.displayName="OtherTenderForm";const hm={collectedHeading:"Collected",remainingLabel:"Remaining:",completeLabel:"Complete",removeAriaLabel:"Remove this tender",removeTooltipForRecorded:"Already recorded",statusPending:"Pending",statusRecorded:"Approved",statusFailed:"Failed"},mm={card:"lucide:credit-card",cash:"lucide:dollar-sign",check:"lucide:edit-3",other:"lucide:more-horizontal"},pm={pending:"warning",recorded:"success",failed:"danger"},gm=e=>e==="pending"||e==="recorded",xm=e=>`#${e+1}`,Hl=({total:e,tenders:t,onRemove:n,locale:r="en-US",labels:s,hideCollectedList:i=!1,className:a,"data-testid":l="split-payment-summary"})=>{const c={...hm,...s},{collected:d,remaining:u,isComplete:f}=y.useMemo(()=>{const m=t.reduce((b,x)=>gm(x.status)?b+x.amount:b,0),v=Math.max(e.value-m,0);return{collected:m,remaining:v,isComplete:m>=e.value&&e.value>0}},[t,e.value]),p=m=>m==="pending"?c.statusPending:m==="recorded"?c.statusRecorded:c.statusFailed;return o.jsxs("div",{className:h.cn("flex flex-col gap-4",a),"data-testid":l,children:[o.jsxs("div",{className:"rounded-2xl bg-default-100 px-6 py-5 text-center","data-testid":`${l}-remaining-banner`,children:[o.jsx("div",{className:"text-sm text-default-600",children:f?c.completeLabel:c.remainingLabel}),o.jsx("div",{className:"mt-1 text-4xl font-bold tracking-tight","data-testid":`${l}-remaining-amount`,children:tt(f?d:u,r,e.currency)})]}),!i&&t.length>0&&o.jsxs("div",{className:"flex flex-col gap-2","data-testid":`${l}-collected-list`,children:[o.jsx("h3",{className:"text-base font-semibold",children:c.collectedHeading}),t.map((m,v)=>o.jsx(ym,{index:v,tender:m,locale:r,currency:e.currency,removable:!!n&&m.status!=="recorded",onRemove:n?()=>n(m.id):void 0,statusLabel:p(m.status),removeAriaLabel:c.removeAriaLabel,recordedTooltip:c.removeTooltipForRecorded,dataTestId:`${l}-row-${v}`},m.id))]})]})};Hl.displayName="SplitPaymentSummary";const ym=({index:e,tender:t,locale:n,currency:r,removable:s,onRemove:i,statusLabel:a,removeAriaLabel:l,recordedTooltip:c,dataTestId:d})=>{const u=i?o.jsx(W,{isIconOnly:!0,variant:"light",radius:"full",size:"sm",onPress:i,isDisabled:!s,"aria-label":l,"data-testid":`${d}-remove`,className:h.cn(s?"text-default-700 hover:bg-default-200":"text-default-300"),children:o.jsx(H,{icon:"lucide:x",width:18,height:18,"aria-hidden":"true"})}):null;return o.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":d,children:[o.jsx("span",{className:"text-sm font-medium text-default-500 w-6 shrink-0",children:xm(e)}),o.jsx(H,{icon:mm[t.type],width:20,height:20,className:"text-default-700 shrink-0","aria-hidden":"true"}),o.jsx("span",{className:"flex-1 truncate","data-testid":`${d}-label`,children:t.label}),o.jsx("span",{className:"font-semibold tabular-nums","data-testid":`${d}-amount`,children:tt(t.amount,n,r)}),o.jsx(h.Chip,{size:"sm",radius:"full",variant:"flat",color:pm[t.status],startContent:t.status==="recorded"?o.jsx(H,{icon:"lucide:check-circle",width:14,height:14,"aria-hidden":"true"}):t.status==="failed"?o.jsx(H,{icon:"lucide:alert-circle",width:14,height:14,"aria-hidden":"true"}):void 0,"data-testid":`${d}-status`,children:a}),u&&(s?u:o.jsx(h.Tooltip,{content:c,placement:"left",children:o.jsx("span",{tabIndex:0,"aria-label":c,children:u})}))]})},bm=`
|
|
18
|
+
`);return{dom:c,text:p,slice:t}}function Ma(e,t,n,r,s){let i=s.parent.type.spec.code,a,o;if(!n&&!t)return null;let c=!!t&&(r||i||!n);if(c){if(e.someProp("transformPastedText",p=>{t=p(t,i||r,e)}),i)return o=new X(Z.from(e.state.schema.text(t.replace(/\r\n?/g,`
|
|
19
|
+
`))),0,0),e.someProp("transformPasted",p=>{o=p(o,e,!0)}),o;let h=e.someProp("clipboardTextParser",p=>p(t,s,r,e));if(h)o=h;else{let p=s.marks(),{schema:m}=e.state,v=Vn.fromSchema(m);a=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(b=>{let x=a.appendChild(document.createElement("p"));b&&x.appendChild(v.serializeNode(m.text(b,p)))})}}else e.someProp("transformPastedHTML",h=>{n=h(n,e)}),a=_d(n),ns&&Vd(a);let d=a&&a.querySelector("[data-pm-slice]"),u=d&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(d.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let h=+u[3];h>0;h--){let p=a.firstChild;for(;p&&p.nodeType!=1;)p=p.nextSibling;if(!p)break;a=p}if(o||(o=(e.someProp("clipboardParser")||e.someProp("domParser")||Nn.fromSchema(e.state.schema)).parseSlice(a,{preserveWhitespace:!!(c||u),context:s,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!Rd.test(p.parentNode.nodeName)?{ignore:!0}:null}})),u)o=Hd(li(o,+u[1],+u[2]),u[4]);else if(o=X.maxOpen(zd(o.content,s),!0),o.openStart||o.openEnd){let h=0,p=0;for(let m=o.content.firstChild;h<o.openStart&&!m.type.spec.isolating;h++,m=m.firstChild);for(let m=o.content.lastChild;p<o.openEnd&&!m.type.spec.isolating;p++,m=m.lastChild);o=li(o,h,p)}return e.someProp("transformPasted",h=>{o=h(o,e,c)}),o}const Rd=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function zd(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let s=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(o=>{if(!a)return;let c=s.findWrapping(o.type),d;if(!c)return a=null;if(d=a.length&&i.length&&Ta(c,i,o,a[a.length-1],0))a[a.length-1]=d;else{a.length&&(a[a.length-1]=Da(a[a.length-1],i.length));let u=Ea(o,c);a.push(u),s=s.matchType(u.type),i=c}}),a)return Z.from(a)}return e}function Ea(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,Z.from(e));return e}function Ta(e,t,n,r,s){if(s<e.length&&s<t.length&&e[s]==t[s]){let i=Ta(e,t,n,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==e.length-1?n.type:e[s+1]))return r.copy(r.content.append(Z.from(Ea(n,e,s+1))))}}function Da(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,Da(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(Z.empty,!0);return e.copy(n.append(r))}function Lr(e,t,n,r,s,i){let a=t<0?e.firstChild:e.lastChild,o=a.content;return e.childCount>1&&(i=0),s<r-1&&(o=Lr(o,t,n,r,s+1,i)),s>=n&&(o=t<0?a.contentMatchAt(0).fillBefore(o,i<=s).append(o):o.append(a.contentMatchAt(a.childCount).fillBefore(Z.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,a.copy(o))}function li(e,t,n){return t<e.openStart&&(e=new X(Lr(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new X(Lr(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const Ia={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let oi=null;function $a(){return oi||(oi=document.implementation.createHTMLDocument("title"))}let ur=null;function Bd(e){let t=window.trustedTypes;return t?(ur||(ur=t.defaultPolicy||t.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),ur.createHTML(e)):e}function _d(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=$a().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(e),s;if((s=r&&Ia[r[1].toLowerCase()])&&(e=s.map(i=>"<"+i+">").join("")+e+s.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=Bd(e),s)for(let i=0;i<s.length;i++)n=n.querySelector(s[i])||n;return n}function Vd(e){let t=e.querySelectorAll(Ye?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}function Hd(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:s,openStart:i,openEnd:a}=e;for(let o=r.length-2;o>=0;o-=2){let c=n.nodes[r[o]];if(!c||c.hasRequiredAttrs())break;s=Z.from(c.create(r[o+1],s)),i++,a++}return new X(s,i,a)}const _e={},Oe={};function et(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}Oe.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!La(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(sn&&Ye&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),ts&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();e.input.lastIOSEnter=r,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==r&&(e.someProp("handleKeyDown",s=>s(e,ba(13,"Enter"))),e.input.lastIOSEnter=0)},200)}else e.someProp("handleKeyDown",r=>r(e,n))||Pd(e,n)?n.preventDefault():et(e,"key")};Oe.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)};Oe.keypress=(e,t)=>{let n=t;if(La(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||Le&&n.metaKey)return;if(e.someProp("handleKeyPress",s=>s(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof ie)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!e.someProp("handleTextInput",a=>a(e,r.$from.pos,r.$to.pos,s,i))&&e.dispatch(i()),n.preventDefault()}};function Wn(e){return{left:e.clientX,top:e.clientY}}function Ud(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function ss(e,t,n,r,s){if(r==-1)return!1;let i=e.state.doc.resolve(r);for(let a=i.depth+1;a>0;a--)if(e.someProp(t,o=>a>i.depth?o(e,n,i.nodeAfter,i.before(a),s,!0):o(e,n,i.node(a),i.before(a),s,!1)))return!0;return!1}function Et(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);r.setMeta("pointer",!0),e.dispatch(r)}function qd(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&ee.isSelectable(r)?(Et(e,new ee(n)),!0):!1}function Wd(e,t){if(t==-1)return!1;let n=e.state.selection,r,s;n instanceof ee&&(r=n.node);let i=e.state.doc.resolve(t);for(let a=i.depth+1;a>0;a--){let o=a>i.depth?i.nodeAfter:i.node(a);if(ee.isSelectable(o)){r&&n.$from.depth>0&&a>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?s=i.before(n.$from.depth):s=i.before(a);break}}return s!=null?(Et(e,ee.create(e.state.doc,s)),!0):!1}function Kd(e,t,n,r,s){return ss(e,"handleClickOn",t,n,r)||e.someProp("handleClick",i=>i(e,t,r))||(s?Wd(e,n):qd(e,n))}function Jd(e,t,n,r){return ss(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",s=>s(e,t,r))}function Yd(e,t,n,r){return ss(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",s=>s(e,t,r))||Gd(e,n,r)}function Gd(e,t,n){if(n.button!=0)return!1;let r=e.state.doc;if(t==-1)return r.inlineContent?(Et(e,ie.create(r,0,r.content.size)),!0):!1;let s=r.resolve(t);for(let i=s.depth+1;i>0;i--){let a=i>s.depth?s.nodeAfter:s.node(i),o=s.before(i);if(a.inlineContent)Et(e,ie.create(r,o+1,o+1+a.content.size));else if(ee.isSelectable(a))Et(e,ee.create(r,o));else continue;return!0}}function is(e){return Tn(e)}const Oa=Le?"metaKey":"ctrlKey";_e.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=is(e),s=Date.now(),i="singleClick";s-e.input.lastClick.time<500&&Ud(n,e.input.lastClick)&&!n[Oa]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type=="singleClick"?i="doubleClick":e.input.lastClick.type=="doubleClick"&&(i="tripleClick")),e.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:i,button:n.button};let a=e.posAtCoords(Wn(n));a&&(i=="singleClick"?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new Qd(e,a,n,!!r)):(i=="doubleClick"?Jd:Yd)(e,a.pos,a.inside,n)?n.preventDefault():et(e,"pointer"))};class Qd{constructor(t,n,r,s){this.view=t,this.pos=n,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!r[Oa],this.allowDefault=r.shiftKey;let i,a;if(n.inside>-1)i=t.state.doc.nodeAt(n.inside),a=n.inside;else{let u=t.state.doc.resolve(n.pos);i=u.parent,a=u.depth?u.before():0}const o=s?null:r.target,c=o?t.docView.nearestDesc(o,!0):null;this.target=c&&c.nodeDOM.nodeType==1?c.nodeDOM:null;let{selection:d}=t.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||d instanceof ee&&d.from<=a&&d.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&qn&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),et(t,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>rs(this.view)),this.view.input.mouseDown=null}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(Wn(t))),this.updateAllowDefault(t),this.allowDefault||!n?et(this.view,"pointer"):Kd(this.view,n.pos,n.inside,t,this.selectNode)?t.preventDefault():t.button==0&&(this.flushed||vt&&this.mightDrag&&!this.mightDrag.node.isAtom||Ye&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Et(this.view,ae.near(this.view.state.doc.resolve(n.pos))),t.preventDefault()):et(this.view,"pointer")}move(t){this.updateAllowDefault(t),et(this.view,"pointer"),t.buttons==0&&this.done()}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}}_e.touchstart=e=>{e.input.lastTouch=Date.now(),is(e),et(e,"pointer")};_e.touchmove=e=>{e.input.lastTouch=Date.now(),et(e,"pointer")};_e.contextmenu=e=>is(e);function La(e,t){return e.composing?!0:vt&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}const Zd=sn?5e3:-1;Oe.compositionstart=Oe.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof ie&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Ye&&Na&&Xd(e)))e.markCursor=e.state.storedMarks||n.marks(),Tn(e,!0),e.markCursor=null;else if(Tn(e,!t.selection.empty),qn&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=e.domSelectionRange();for(let s=r.focusNode,i=r.focusOffset;s&&s.nodeType==1&&i!=0;){let a=i<0?s.lastChild:s.childNodes[i-1];if(!a)break;if(a.nodeType==3){let o=e.domSelection();o&&o.collapse(a,a.nodeValue.length);break}else s=a,i=-1}}e.input.composing=!0}Fa(e,Zd)};function Xd(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||t.nodeType!=1||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}Oe.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,Fa(e,20))};function Fa(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Tn(e),t))}function eu(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=tu());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function tu(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}function Tn(e,t=!1){if(!(sn&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),eu(e),t||e.docView&&e.docView.dirty){let n=jd(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function nu(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}const Xt=rn&&wa<15||ts&&Cd<604;_e.copy=Oe.cut=(e,t)=>{let n=t,r=e.state.selection,s=n.type=="cut";if(r.empty)return;let i=Xt?null:n.clipboardData,a=r.content(),{dom:o,text:c}=Aa(e,a);i?(n.preventDefault(),i.clearData(),i.setData("text/html",o.innerHTML),i.setData("text/plain",c)):nu(e,o),s&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function ru(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function su(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Fr(e,r.value,null,s,t):Fr(e,r.textContent,r.innerHTML,s,t)},50)}function Fr(e,t,n,r,s){let i=Ma(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",c=>c(e,s,i||X.empty)))return!0;if(!i)return!1;let a=ru(i),o=a?e.state.tr.replaceSelectionWith(a,r):e.state.tr.replaceSelection(i);return e.dispatch(o.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Pa(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Oe.paste=(e,t)=>{let n=t;if(e.composing&&!sn)return;let r=Xt?null:n.clipboardData,s=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&Fr(e,Pa(r),r.getData("text/html"),s,n)?n.preventDefault():su(e,n)};class iu{constructor(t,n,r){this.slice=t,this.move=n,this.node=r}}const au=Le?"altKey":"ctrlKey";function Ra(e,t){let n=e.someProp("dragCopies",r=>!r(t));return n??!t[au]}_e.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=e.state.selection,i=s.empty?null:e.posAtCoords(Wn(n)),a;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof ee?s.to-1:s.to))){if(r&&r.mightDrag)a=ee.create(e.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let h=e.docView.nearestDesc(n.target,!0);h&&h.node.type.spec.draggable&&h!=e.docView&&(a=ee.create(e.state.doc,h.posBefore))}}let o=(a||e.state.selection).content(),{dom:c,text:d,slice:u}=Aa(e,o);(!n.dataTransfer.files.length||!Ye||ka>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Xt?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",Xt||n.dataTransfer.setData("text/plain",d),e.dragging=new iu(u,Ra(e,n),a)};_e.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)};Oe.dragover=Oe.dragenter=(e,t)=>t.preventDefault();Oe.drop=(e,t)=>{try{lu(e,t,e.dragging)}finally{e.dragging=null}};function lu(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(Wn(t));if(!r)return;let s=e.state.doc.resolve(r.pos),i=n&&n.slice;i?e.someProp("transformPasted",m=>{i=m(i,e,!1)}):i=Ma(e,Pa(t.dataTransfer),Xt?null:t.dataTransfer.getData("text/html"),!1,s);let a=!!(n&&Ra(e,t));if(e.someProp("handleDrop",m=>m(e,t,i||X.empty,a))){t.preventDefault();return}if(!i)return;t.preventDefault();let o=i?da(e.state.doc,s.pos,i):s.pos;o==null&&(o=s.pos);let c=e.state.tr;if(a){let{node:m}=n;m?m.replace(c):c.deleteSelection()}let d=c.mapping.map(o),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,h=c.doc;if(u?c.replaceRangeWith(d,d,i.content.firstChild):c.replaceRange(d,d,i),c.doc.eq(h))return;let p=c.doc.resolve(d);if(u&&ee.isSelectable(i.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new ee(p));else{let m=c.mapping.map(o);c.mapping.maps[c.mapping.maps.length-1].forEach((v,b,x,w)=>m=w),c.setSelection(Ca(e,p,c.doc.resolve(m)))}e.focus(),e.dispatch(c.setMeta("uiEvent","drop"))}_e.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&rs(e)},20))};_e.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)};_e.beforeinput=(e,t)=>{if(Ye&&sn&&t.inputType=="deleteContentBackward"){e.domObserver.flushSoon();let{domChangeCount:r}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=r||(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",i=>i(e,ba(8,"Backspace")))))return;let{$cursor:s}=e.state.selection;s&&s.pos>0&&e.dispatch(e.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let e in Oe)_e[e]=Oe[e];function en(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class Dn{constructor(t,n){this.toDOM=t,this.spec=n||gt,this.side=this.spec.side||0}map(t,n,r,s){let{pos:i,deleted:a}=t.mapResult(n.from+s,this.side<0?-1:1);return a?null:new He(i-r,i-r,this)}valid(){return!0}eq(t){return this==t||t instanceof Dn&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&en(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}}class nt{constructor(t,n){this.attrs=t,this.spec=n||gt}map(t,n,r,s){let i=t.map(n.from+s,this.spec.inclusiveStart?-1:1)-r,a=t.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=a?null:new He(i,a,this)}valid(t,n){return n.from<n.to}eq(t){return this==t||t instanceof nt&&en(this.attrs,t.attrs)&&en(this.spec,t.spec)}static is(t){return t.type instanceof nt}destroy(){}}class as{constructor(t,n){this.attrs=t,this.spec=n||gt}map(t,n,r,s){let i=t.mapResult(n.from+s,1);if(i.deleted)return null;let a=t.mapResult(n.to+s,-1);return a.deleted||a.pos<=i.pos?null:new He(i.pos-r,a.pos-r,this)}valid(t,n){let{index:r,offset:s}=t.content.findIndex(n.from),i;return s==n.from&&!(i=t.child(r)).isText&&s+i.nodeSize==n.to}eq(t){return this==t||t instanceof as&&en(this.attrs,t.attrs)&&en(this.spec,t.spec)}destroy(){}}class He{constructor(t,n,r){this.from=t,this.to=n,this.type=r}copy(t,n){return new He(t,n,this.type)}eq(t,n=0){return this.type.eq(t.type)&&this.from+n==t.from&&this.to+n==t.to}map(t,n,r){return this.type.map(t,this,n,r)}static widget(t,n,r){return new He(t,t,new Dn(n,r))}static inline(t,n,r,s){return new He(t,n,new nt(r,s))}static node(t,n,r,s){return new He(t,n,new as(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof nt}get widget(){return this.type instanceof Dn}}const jt=[],gt={};class be{constructor(t,n){this.local=t.length?t:jt,this.children=n.length?n:jt}static create(t,n){return n.length?In(n,t,0,gt):Ae}find(t,n,r){let s=[];return this.findInner(t??0,n??1e9,s,0,r),s}findInner(t,n,r,s,i){for(let a=0;a<this.local.length;a++){let o=this.local[a];o.from<=n&&o.to>=t&&(!i||i(o.spec))&&r.push(o.copy(o.from+s,o.to+s))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<n&&this.children[a+1]>t){let o=this.children[a]+1;this.children[a+2].findInner(t-o,n-o,r,s+o,i)}}map(t,n,r){return this==Ae||t.maps.length==0?this:this.mapInner(t,n,0,0,r||gt)}mapInner(t,n,r,s,i){let a;for(let o=0;o<this.local.length;o++){let c=this.local[o].map(t,r,s);c&&c.type.valid(n,c)?(a||(a=[])).push(c):i.onRemove&&i.onRemove(this.local[o].spec)}return this.children.length?ou(this.children,a||[],t,n,r,s,i):a?new be(a.sort(xt),jt):Ae}add(t,n){return n.length?this==Ae?be.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let s,i=0;t.forEach((o,c)=>{let d=c+r,u;if(u=Ba(n,o,d)){for(s||(s=this.children.slice());i<s.length&&s[i]<c;)i+=3;s[i]==c?s[i+2]=s[i+2].addInner(o,u,d+1):s.splice(i,0,c,c+o.nodeSize,In(u,o,d+1,gt)),i+=3}});let a=za(i?_a(n):n,-r);for(let o=0;o<a.length;o++)a[o].type.valid(t,a[o])||a.splice(o--,1);return new be(a.length?this.local.concat(a).sort(xt):this.local,s||this.children)}remove(t){return t.length==0||this==Ae?this:this.removeInner(t,0)}removeInner(t,n){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let a,o=r[i]+n,c=r[i+1]+n;for(let u=0,h;u<t.length;u++)(h=t[u])&&h.from>o&&h.to<c&&(t[u]=null,(a||(a=[])).push(h));if(!a)continue;r==this.children&&(r=this.children.slice());let d=r[i+2].removeInner(a,o+1);d!=Ae?r[i+2]=d:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,a;i<t.length;i++)if(a=t[i])for(let o=0;o<s.length;o++)s[o].eq(a,n)&&(s==this.local&&(s=this.local.slice()),s.splice(o--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new be(s,r):Ae}forChild(t,n){if(this==Ae)return this;if(n.isLeaf)return be.empty;let r,s;for(let o=0;o<this.children.length;o+=3)if(this.children[o]>=t){this.children[o]==t&&(r=this.children[o+2]);break}let i=t+1,a=i+n.content.size;for(let o=0;o<this.local.length;o++){let c=this.local[o];if(c.from<a&&c.to>i&&c.type instanceof nt){let d=Math.max(i,c.from)-i,u=Math.min(a,c.to)-i;d<u&&(s||(s=[])).push(c.copy(d,u))}}if(s){let o=new be(s.sort(xt),jt);return r?new dt([o,r]):o}return r||Ae}eq(t){if(this==t)return!0;if(!(t instanceof be)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(t.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=t.children[n]||this.children[n+1]!=t.children[n+1]||!this.children[n+2].eq(t.children[n+2]))return!1;return!0}locals(t){return ls(this.localsInner(t))}localsInner(t){if(this==Ae)return jt;if(t.inlineContent||!this.local.some(nt.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof nt||n.push(this.local[r]);return n}forEachSet(t){t(this)}}be.empty=new be([],[]);be.removeOverlap=ls;const Ae=be.empty;class dt{constructor(t){this.members=t}map(t,n){const r=this.members.map(s=>s.map(t,n,gt));return dt.from(r)}forChild(t,n){if(n.isLeaf)return be.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(t,n);i!=Ae&&(i instanceof dt?r=r.concat(i.members):r.push(i))}return dt.from(r)}eq(t){if(!(t instanceof dt)||t.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(t.members[n]))return!1;return!0}locals(t){let n,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(t);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let a=0;a<i.length;a++)n.push(i[a])}}return n?ls(r?n:n.sort(xt)):jt}static from(t){switch(t.length){case 0:return Ae;case 1:return t[0];default:return new dt(t.every(n=>n instanceof be)?t:t.reduce((n,r)=>n.concat(r instanceof be?r:r.members),[]))}}forEachSet(t){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(t)}}function ou(e,t,n,r,s,i,a){let o=e.slice();for(let d=0,u=i;d<n.maps.length;d++){let h=0;n.maps[d].forEach((p,m,v,b)=>{let x=b-v-(m-p);for(let w=0;w<o.length;w+=3){let S=o[w+1];if(S<0||p>S+u-h)continue;let M=o[w]+u-h;m>=M?o[w+1]=p<=M?-2:-1:p>=u&&x&&(o[w]+=x,o[w+1]+=x)}h+=x}),u=n.maps[d].map(u,-1)}let c=!1;for(let d=0;d<o.length;d+=3)if(o[d+1]<0){if(o[d+1]==-2){c=!0,o[d+1]=-1;continue}let u=n.map(e[d]+i),h=u-s;if(h<0||h>=r.content.size){c=!0;continue}let p=n.map(e[d+1]+i,-1),m=p-s,{index:v,offset:b}=r.content.findIndex(h),x=r.maybeChild(v);if(x&&b==h&&b+x.nodeSize==m){let w=o[d+2].mapInner(n,x,u+1,e[d]+i+1,a);w!=Ae?(o[d]=h,o[d+1]=m,o[d+2]=w):(o[d+1]=-2,c=!0)}else c=!0}if(c){let d=cu(o,e,t,n,s,i,a),u=In(d,r,0,a);t=u.local;for(let h=0;h<o.length;h+=3)o[h+1]<0&&(o.splice(h,3),h-=3);for(let h=0,p=0;h<u.children.length;h+=3){let m=u.children[h];for(;p<o.length&&o[p]<m;)p+=3;o.splice(p,0,u.children[h],u.children[h+1],u.children[h+2])}}return new be(t.sort(xt),o)}function za(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let s=e[r];n.push(new He(s.from+t,s.to+t,s.type))}return n}function cu(e,t,n,r,s,i,a){function o(c,d){for(let u=0;u<c.local.length;u++){let h=c.local[u].map(r,s,d);h?n.push(h):a.onRemove&&a.onRemove(c.local[u].spec)}for(let u=0;u<c.children.length;u+=3)o(c.children[u+2],c.children[u]+d+1)}for(let c=0;c<e.length;c+=3)e[c+1]==-1&&o(e[c+2],t[c]+i+1);return n}function Ba(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,s=null;for(let i=0,a;i<e.length;i++)(a=e[i])&&a.from>n&&a.to<r&&((s||(s=[])).push(a),e[i]=null);return s}function _a(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function In(e,t,n,r){let s=[],i=!1;t.forEach((o,c)=>{let d=Ba(e,o,c+n);if(d){i=!0;let u=In(d,o,n+c+1,r);u!=Ae&&s.push(c,c+o.nodeSize,u)}});let a=za(i?_a(e):e,-n).sort(xt);for(let o=0;o<a.length;o++)a[o].type.valid(t,a[o])||(r.onRemove&&r.onRemove(a[o].spec),a.splice(o--,1));return a.length||s.length?new be(a,s):Ae}function xt(e,t){return e.from-t.from||e.to-t.to}function ls(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let s=n+1;s<t.length;s++){let i=t[s];if(i.from==r.from){i.to!=r.to&&(t==e&&(t=e.slice()),t[s]=i.copy(i.from,r.to),ci(t,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,i.from),ci(t,s,r.copy(i.from,r.to)));break}}}return t}function ci(e,t,n){for(;t<e.length&&xt(n,e[t])>0;)t++;e.splice(t,0,n)}class me extends ae{constructor(t){super(t,t)}map(t,n){let r=t.resolve(n.map(this.head));return me.valid(r)?new me(r):ae.near(r)}content(){return X.empty}eq(t){return t instanceof me&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new me(t.resolve(n.pos))}getBookmark(){return new os(this.anchor)}static valid(t){let n=t.parent;if(n.isTextblock||!du(t)||!uu(t))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let s=n.contentMatchAt(t.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(t,n,r=!1){e:for(;;){if(!r&&me.valid(t))return t;let s=t.pos,i=null;for(let a=t.depth;;a--){let o=t.node(a);if(n>0?t.indexAfter(a)<o.childCount:t.index(a)>0){i=o.child(n>0?t.indexAfter(a):t.index(a)-1);break}else if(a==0)return null;s+=n;let c=t.doc.resolve(s);if(me.valid(c))return c}for(;;){let a=n>0?i.firstChild:i.lastChild;if(!a){if(i.isAtom&&!i.isText&&!ee.isSelectable(i)){t=t.doc.resolve(s+i.nodeSize*n),r=!1;continue e}break}i=a,s+=n;let o=t.doc.resolve(s);if(me.valid(o))return o}return null}}}me.prototype.visible=!1;me.findFrom=me.findGapCursorFrom;ae.jsonID("gapcursor",me);class os{constructor(t){this.pos=t}map(t){return new os(t.map(this.pos))}resolve(t){let n=t.resolve(this.pos);return me.valid(n)?new me(n):ae.near(n)}}function Va(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function du(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||Va(s.type))return!0;if(s.inlineContent)return!1}}return!0}function uu(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||Va(s.type))return!0;if(s.inlineContent)return!1}}return!0}function fu(){return new Un({props:{decorations:gu,createSelectionBetween(e,t,n){return t.pos==n.pos&&me.valid(n)?new me(n):null},handleClick:mu,handleKeyDown:hu,handleDOMEvents:{beforeinput:pu}}})}const hu=kd({ArrowLeft:hn("horiz",-1),ArrowRight:hn("horiz",1),ArrowUp:hn("vert",-1),ArrowDown:hn("vert",1)});function hn(e,t){const n=e=="vert"?t>0?"down":"up":t>0?"right":"left";return function(r,s,i){let a=r.selection,o=t>0?a.$to:a.$from,c=a.empty;if(a instanceof ie){if(!i.endOfTextblock(n)||o.depth==0)return!1;c=!1,o=r.doc.resolve(t>0?o.after():o.before())}let d=me.findGapCursorFrom(o,t,c);return d?(s&&s(r.tr.setSelection(new me(d))),!0):!1}}function mu(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!me.valid(r))return!1;let s=e.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&ee.isSelectable(e.state.doc.nodeAt(s.inside))?!1:(e.dispatch(e.state.tr.setSelection(new me(r))),!0)}function pu(e,t){if(t.inputType!="insertCompositionText"||!(e.state.selection instanceof me))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let s=Z.empty;for(let a=r.length-1;a>=0;a--)s=Z.from(r[a].createAndFill(null,s));let i=e.state.tr.replace(n.pos,n.pos,new X(s,0,0));return i.setSelection(ie.near(i.doc.resolve(n.pos+1))),e.dispatch(i),!1}function gu(e){if(!(e.selection instanceof me))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",be.create(e.doc,[He.widget(e.selection.head,t,{key:"gapcursor"})])}const xu=V.Extension.create({name:"gapCursor",addProseMirrorPlugins(){return[fu()]},extendNodeSchema(e){var t;const n={name:e.name,options:e.options,storage:e.storage};return{allowGapCursor:(t=V.callOrReturn(V.getExtensionField(e,"allowGapCursor",n)))!==null&&t!==void 0?t:null}}}),Rt={bold:{category:"mark",extension:pc,priority:100},italic:{category:"mark",extension:vc,priority:100},strike:{category:"mark",extension:Nc,priority:100},underline:{category:"mark",extension:Eo.Underline,priority:100},code:{category:"mark",extension:jc,priority:100},textColor:{category:"mark",extension:To.Color,defaultOptions:{types:["textStyle","heading","paragraph","listItem","taskItem","blockquote"]},priority:90},highlight:{category:"mark",extension:Do.Highlight,defaultOptions:{multicolor:!0},priority:90},link:{category:"mark",extension:Io.Link,defaultOptions:{autolink:!0,linkOnPaste:!0,openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}},priority:100},heading:{category:"node",extension:Ec,defaultOptions:{levels:[1,2,3,4,5,6]},priority:100},bulletList:{category:"node",extension:Ic,defaultOptions:{HTMLAttributes:{class:"list-disc"}},priority:90},orderedList:{category:"node",extension:Oc,defaultOptions:{HTMLAttributes:{class:"list-decimal"}},priority:90},taskList:{category:"node",extension:$o.TaskList,defaultOptions:{HTMLAttributes:{class:"task-list"}},priority:90},codeBlock:{category:"node",extension:Gc,priority:100},blockquote:{category:"node",extension:Zc,priority:100},horizontalRule:{category:"node",extension:Xc,priority:100},hardBreak:{category:"node",extension:ed,priority:100},undo:{category:"extension",extension:Ys,priority:50},redo:{category:"extension",extension:Ys,priority:50},textAlign:{category:"extension",extension:Lo.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}},yu=[dd,ud,Tc,Mc.configure({HTMLAttributes:{}}),Lc.configure({HTMLAttributes:{}}),Oo.TaskItem.configure({nested:!0}),md,xu];function bu(e){const t=[],n=new Set,r=new Set;yu.forEach(o=>{o&&(t.push(o),r.add(o.name))});const s=e.map(o=>Yt(o)),i=new Set;return s.forEach(o=>{const c=Rt[o];c?.requiredExtensions&&c.requiredExtensions.forEach(d=>{i.add(d)})}),i.forEach(o=>{if(n.has(o))return;const c=Rt[o];if(!c||c.extension===null)return;const d=c.extension.name;if(r.has(d)){n.add(o);return}const u=c.defaultOptions?c.extension.configure(c.defaultOptions):c.extension;t.push(u),n.add(o),r.add(d)}),s.forEach(o=>{if(n.has(o))return;const c=Rt[o];if(!c){console.warn(`Extension config not found for modifier: ${o}`);return}if(c.extension===null){n.add(o);return}const d=c.extension.name;if(r.has(d)){n.add(o);return}const u=c.defaultOptions?c.extension.configure(c.defaultOptions):c.extension;t.push(u),n.add(o),r.add(d)}),t.sort((o,c)=>{const d=Object.values(Rt).find(m=>m?.extension?.name===o.name),u=Object.values(Rt).find(m=>m?.extension?.name===c.name),h=d?.priority??100;return(u?.priority??100)-h})}const Ha={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"]},he={fontFamily:{mono:'"JetBrains Mono", Consolas, monospace'},fontSize:{sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","4xl":"2.25rem"},fontWeight:{semibold:"600",bold:"700"},lineHeight:{tight:"1.25",normal:"1.5"}},Qe={brand:{primary:{DEFAULT:"#C14615"}},neutral:{gray:{100:"#F3F4F6",200:"#E5E7EB",300:"#D1D5DB",500:"#6B7280",800:"#1F2937"}},palettes:{warning:{200:"#fde68a"}}},de={xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem"},vu={h1:`font-size: ${he.fontSize["4xl"]}; font-weight: ${he.fontWeight.semibold}; line-height: ${he.lineHeight.tight}; margin: ${de.md} 0 ${de.sm} 0;`,h2:`font-size: ${he.fontSize["2xl"]}; font-weight: ${he.fontWeight.semibold}; line-height: ${he.lineHeight.tight}; margin: ${de.md} 0 ${de.sm} 0;`,h3:`font-size: ${he.fontSize.xl}; font-weight: ${he.fontWeight.semibold}; line-height: ${he.lineHeight.tight}; margin: ${de.md} 0 ${de.sm} 0;`,h4:`font-size: ${he.fontSize.lg}; font-weight: ${he.fontWeight.semibold}; line-height: ${he.lineHeight.tight}; margin: ${de.md} 0 ${de.sm} 0;`,h5:`font-size: ${he.fontSize.base}; font-weight: ${he.fontWeight.semibold}; line-height: ${he.lineHeight.tight}; margin: ${de.md} 0 ${de.sm} 0;`,h6:`font-size: ${he.fontSize.sm}; font-weight: ${he.fontWeight.semibold}; line-height: ${he.lineHeight.tight}; margin: ${de.md} 0 ${de.sm} 0;`,p:`min-height: ${he.lineHeight.normal}em; margin: 0;`,ul:`list-style-type: disc; list-style-position: outside; padding-left: ${de.xl}; margin: ${de.md} 0;`,ol:`list-style-type: decimal; list-style-position: outside; padding-left: ${de.xl}; margin: ${de.md} 0;`,li:`display: list-item; margin: ${de.xs} 0;`,strong:`font-weight: ${he.fontWeight.bold};`,em:"font-style: italic;",s:"text-decoration: line-through;",u:"text-decoration: underline;",code:`background-color: ${Qe.neutral.gray[100]}; border-radius: 0.4rem; font-size: ${he.fontSize.sm}; padding: 0.25em 0.3em; font-family: ${he.fontFamily.mono};`,pre:`background: ${Qe.neutral.gray[800]}; border-radius: ${de.sm}; color: ${Qe.neutral.gray[100]}; font-family: ${he.fontFamily.mono}; margin: ${de.lg} 0; padding: 0.75rem ${de.md}; overflow-x: auto;`,blockquote:`border-left: 3px solid ${Qe.neutral.gray[300]}; margin: ${de.lg} 0; padding-left: ${de.md}; color: ${Qe.neutral.gray[500]};`,hr:`border: none; border-top: 1px solid ${Qe.neutral.gray[200]}; margin: ${de.xl} 0;`,a:`color: ${Qe.brand.primary.DEFAULT}; text-decoration: underline; cursor: pointer;`,mark:`background-color: ${Qe.palettes.warning[200]}; border-radius: ${de.xs}; padding: 0 0.125rem;`,label:`display: flex; align-items: center; gap: ${de.sm}; cursor: pointer;`,input:"cursor: pointer; margin: 0;"},wu={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 ku(e){if(!e)return e;let t=e;for(const[n,r]of Object.entries(wu)){const s=new RegExp(`(<(?:ul|li)[^>]*data-type="${n}"[^>]*)>`,"gi");t=t.replace(s,(i,a)=>i.includes('style="')?i.replace(/style="([^"]*)"/,`style="$1 ${r}"`):`${a} style="${r}">`)}for(const[n,r]of Object.entries(vu)){const s=new RegExp(`<${n}(\\s[^>]*)?>`,"gi");t=t.replace(s,i=>{if(i.includes('data-type="taskList"')||i.includes('data-type="taskItem"'))return i;if(i.includes('style="'))return i.replace(/style="([^"]*)"/,`style="$1 ${r}"`);if(i.includes("style='"))return i.replace(/style='([^']*)'/,`style='$1 ${r}'`);{const a=i.indexOf(">");return`${i.slice(0,a)} style="${r}"${i.slice(a)}`}})}return t}const Nu=({modifiers:e,zoom:t,onZoomChange:n,onToolbarAction:r})=>{const{editor:s}=Jr.useCurrentEditor();return l.jsx(dc,{editor:s,modifiers:e,zoom:t,onZoomChange:n,onToolbarAction:r})},Su=({showCharacterCount:e,showWordCount:t})=>{const{editor:n}=Jr.useCurrentEditor();if(!n||!e&&!t)return null;const r=n.getText(),s=r.length,i=r.split(/\s+/).filter(a=>a.length>0).length;return l.jsxs("div",{className:"flex gap-4 text-xs text-default-500 px-2 pb-1",children:[e&&l.jsxs("span",{children:[s," characters"]}),t&&l.jsxs("span",{children:[i," words"]})]})},Pr=y.forwardRef((e,t)=>{const{minRows:n=10,maxRows:r=30,disableAutosize:s=!1,showCharacterCount:i=!1,showWordCount:a=!1,showToolbar:o=!0,modifiers:c=Ha.full,variant:d="bordered",initialContent:u,content:h,onContentChange:p,onUpdate:m,onToolbarAction:v,isReadOnly:b=!1,isDisabled:x=!1,includeInlineStyles:w=!0,...S}=e,{zoom:M,setZoom:N}=lc(),j=Ts.lineHeight,T=n*j,$=s?void 0:r*j,W=y.useMemo(()=>bu(c),[c]),{Component:D,label:R,shouldLabelBeOutside:E,getBaseProps:C,getLabelProps:I,getInputWrapperProps:F}=f.useInput({...S,variant:d,ref:t,isMultiline:!0}),H=R?l.jsx("label",{...I(),children:R}):null,Q=y.useCallback(({editor:Y})=>{const te=Y.getHTML(),oe=w?ku(te):te,ce=Y.getJSON(),P=Y.getText(),_=P.length,G=P.split(/\s+/).filter(Se=>Se.length>0).length,ne={html:oe,json:ce,text:P,characters:_,words:G};if(p?.(ne),m?.(ne),"onChange"in S&&typeof S.onChange=="function"){const Se={target:{value:oe},currentTarget:{value:oe}};S.onChange(Se)}},[p,m,S,w]);return l.jsxs(D,{...C(),children:[E?H:null,l.jsx("div",{...F(),className:f.cn(F().className,"flex flex-col w-full p-0 gap-0 rich-text-editor"),style:{maxHeight:$?`${$+Ts.toolbarHeight}px`:void 0,overflow:$?"auto":void 0},children:l.jsx(Jr.EditorProvider,{editable:!b&&!x,slotBefore:o?l.jsx(Nu,{modifiers:c,zoom:M,onZoomChange:N,onToolbarAction:v}):void 0,slotAfter:l.jsx(Su,{showCharacterCount:i,showWordCount:a}),editorContainerProps:{className:"w-full flex-1 outline-none",style:{minHeight:`${T}px`,fontSize:`${M}%`,display:"flex",flexDirection:"column"}},editorProps:{attributes:{class:"focus:outline-none w-full h-full"}},extensions:W,content:h||u||e.defaultValue||"",onUpdate:Q})})]})});Pr.displayName="TipTapEditor";const Ua=y.forwardRef((e,t)=>{const{adapter:n="tiptap",variant:r="bordered",...s}=e;return n==="tiptap"?l.jsx(Pr,{...s,variant:r,ref:t}):(console.warn(`Adapter "${n}" is not supported. Using TipTap.`),l.jsx(Pr,{...s,variant:r,ref:t}))});Ua.displayName="RichTextArea";function Cu(e,t="en-US",n="USD"){try{return new Intl.NumberFormat(t,{style:"currency",currency:n,minimumFractionDigits:0,maximumFractionDigits:2}).format(e)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${e.toFixed(2)}`}}const di=[{id:"100",amount:100},{id:"250",amount:250},{id:"500",amount:500},{id:"1000",amount:1e3},{id:"2000",amount:2e3}],ju={title:"Donation Amount",customAmountPlaceholder:"Custom donation amount",customAmountAriaLabel:"Custom donation amount",addDonationButton:"Add Donation"},qa=({presetAmounts:e=di,selectedDonation:t,defaultSelectedDonation:n=null,onChange:r,onAddDonation:s,currency:i="USD",locale:a="en-US",showCustomAmount:o=!0,minCustomAmount:c=.5,maxCustomAmount:d=1e6,labels:u,mobileColumns:h=2,desktopColumns:p=3,isDisabled:m=!1,buttonVariant:v="bordered",buttonColor:b="default",inputVariant:x="bordered",size:w="md",className:S="",showCard:M=!0})=>{const N={...ju,...u},j=Array.isArray(e)?e:di,T={2:"grid-cols-2",3:"grid-cols-3"},$={3:"sm:grid-cols-3",4:"sm:grid-cols-4",5:"sm:grid-cols-5",6:"sm:grid-cols-6"},W=`${T[h]} ${$[p]}`,[D,R]=Yr(t,n,r),[E,C]=y.useState(""),[I,F]=y.useState(!1),[H,Q]=y.useState(0),Y=y.useCallback(_=>{if(m)return;const G={amount:_.amount,isCustom:!1,presetId:_.id};R(G),C(""),F(!1),Q(ne=>ne+1),s?.(G)},[m,R,s]),te=y.useCallback(_=>{if(m)return;if(C(_!==void 0?String(_):""),s){R(null);return}if(_===void 0||isNaN(_)){R(null);return}R({amount:_,isCustom:!0})},[m,R,s]),oe=y.useCallback(()=>{if(m)return;const _=E!==""?parseFloat(E):void 0;_===void 0||isNaN(_)||s?.({amount:_,isCustom:!0})},[m,E,s]),ce=y.useMemo(()=>({style:"currency",currency:i,currencyDisplay:"symbol"}),[i]),P=l.jsxs("div",{className:"space-y-4","data-testid":"donation-amounts-root",children:[N.title&&l.jsx("h2",{className:"text-base font-semibold","data-testid":"donation-amounts-title",children:N.title}),j.length>0&&l.jsx("div",{className:f.cn("grid gap-3",W),"data-testid":"donation-amounts-presets",children:j.map(_=>{const G=D!==null&&!D.isCustom&&D.presetId===_.id;return l.jsx(K,{color:G?"primary":b,variant:G?"solid":v,className:"w-full",onPress:()=>Y(_),isDisabled:m,"data-testid":`donation-amounts-preset-${_.id}`,children:_.label||Cu(_.amount,a,i)},_.id)})}),o&&l.jsxs("div",{className:"flex gap-3 items-start",children:[l.jsx(f.NumberInput,{placeholder:N.customAmountPlaceholder,"aria-label":N.customAmountAriaLabel,onInput:s?()=>{R(null),F(!0)}:void 0,variant:x,radius:"full",size:w,minValue:c,maxValue:d,step:.01,formatOptions:ce,value:E!==""?parseFloat(E):void 0,onValueChange:te,isDisabled:m,className:"flex-1 [&_[data-slot=input-wrapper]]:!h-10 [&_[data-slot=input-wrapper]]:!min-h-10","data-testid":"donation-amounts-custom-input",hideStepper:!0},s?`custom-${H}`:D?.isCustom===!1?D.presetId:"custom"),s&&l.jsx(K,{color:"primary",variant:"solid",radius:"full",size:w,className:"shrink-0",onPress:oe,isDisabled:m||!I,"data-testid":"donation-amounts-add-button",children:N.addDonationButton})]})]});return M?l.jsx(f.Card,{className:f.cn("w-full",S),"data-testid":"donation-amounts-card",children:l.jsx(f.CardBody,{children:P})}):l.jsx("div",{className:f.cn("w-full",S),"data-testid":"donation-amounts-plain",children:P})};qa.displayName="DonationAmounts";const Au=e=>{const t=Math.max(0,e),n=Math.floor(t/60).toString().padStart(2,"0"),r=(t%60).toString().padStart(2,"0");return`${n}:${r} minutes`},Mu=e=>{switch(e){case"warning":return J.Clock;case"error":return J.AlertCircle;case"success":return J.CheckCircle;default:return J.Clock}},Eu=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"}},Wa=y.forwardRef(({timeLeft:e,defaultTimeLeft:t=1200,onTimeChange:n,onExpire:r,variant:s="info",color:i="primary",message:a="Your cart expires in:",showIcon:o=!0,icon:c,position:d="fixed",autoStart:u=!0,formatTime:h=Au,className:p,...m},v)=>{const[b,x]=Yr(e!==void 0?Math.max(0,e):void 0,Math.max(0,t),n),w=y.useRef(null),S=y.useRef(!1);y.useEffect(()=>()=>{w.current&&clearInterval(w.current)},[]),y.useEffect(()=>{if(!u||b<=0){w.current&&(clearInterval(w.current),w.current=null);return}return w.current=setInterval(()=>{x(T=>T<=1?(w.current&&(clearInterval(w.current),w.current=null),S.current||(S.current=!0,r?.()),0):T-1)},1e3),()=>{w.current&&(clearInterval(w.current),w.current=null)}},[u,b,x,r]),y.useEffect(()=>{b>0&&(S.current=!1)},[b]);const M=c||Mu(s),N=Eu(i),j={fixed:"fixed top-0 left-0",sticky:"sticky top-0",static:"static"};return l.jsx("div",{ref:v,role:"banner","aria-live":"polite","aria-label":`${a} ${h(b)}`,"data-testid":"expire-cart-timer",className:f.cn("w-full text-white z-50",N,j[d],p),...m,children:l.jsx("div",{className:"container mx-auto px-4 py-3 sm:py-2.5","data-testid":"expire-cart-timer-container",children:l.jsxs("div",{className:"flex items-center justify-between gap-3 sm:gap-4",children:[l.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&&l.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:l.jsx(M,{className:"text-primary-500 sm:text-primary-600","aria-hidden":"true",size:14,"data-testid":"expire-cart-timer-icon"})}),l.jsx("p",{className:"text-sm sm:text-base font-medium text-white","data-testid":"expire-cart-timer-message",children:a})]}),l.jsx("div",{className:"flex-shrink-0","data-testid":"expire-cart-timer-right",children:l.jsx("span",{className:"text-sm sm:text-base font-semibold text-white","aria-label":`Time remaining: ${h(b)}`,"data-testid":"expire-cart-timer-value",children:h(b)})})]})})})});Wa.displayName="ExpireCartTimer";function Tu(e,t){const n=e.icons,r=e.aliases||Object.create(null),s=Object.create(null);function i(a){if(n[a])return s[a]=[];if(!(a in s)){s[a]=null;const o=r[a]&&r[a].parent,c=o&&i(o);c&&(s[a]=[o].concat(c))}return s[a]}return Object.keys(n).concat(Object.keys(r)).forEach(i),s}const Ka=Object.freeze({left:0,top:0,width:16,height:16}),$n=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),cs=Object.freeze({...Ka,...$n}),Rr=Object.freeze({...cs,body:"",hidden:!1});function Du(e,t){const n={};!e.hFlip!=!t.hFlip&&(n.hFlip=!0),!e.vFlip!=!t.vFlip&&(n.vFlip=!0);const r=((e.rotate||0)+(t.rotate||0))%4;return r&&(n.rotate=r),n}function ui(e,t){const n=Du(e,t);for(const r in Rr)r in $n?r in e&&!(r in n)&&(n[r]=$n[r]):r in t?n[r]=t[r]:r in e&&(n[r]=e[r]);return n}function Iu(e,t,n){const r=e.icons,s=e.aliases||Object.create(null);let i={};function a(o){i=ui(r[o]||s[o],i)}return a(t),n.forEach(a),ui(e,i)}function Ja(e,t){const n=[];if(typeof e!="object"||typeof e.icons!="object")return n;e.not_found instanceof Array&&e.not_found.forEach(s=>{t(s,null),n.push(s)});const r=Tu(e);for(const s in r){const i=r[s];i&&(t(s,Iu(e,s,i)),n.push(s))}return n}const $u={provider:"",aliases:{},not_found:{},...Ka};function fr(e,t){for(const n in t)if(n in e&&typeof e[n]!=typeof t[n])return!1;return!0}function Ya(e){if(typeof e!="object"||e===null)return null;const t=e;if(typeof t.prefix!="string"||!e.icons||typeof e.icons!="object"||!fr(e,$u))return null;const n=t.icons;for(const s in n){const i=n[s];if(!s||typeof i.body!="string"||!fr(i,Rr))return null}const r=t.aliases||Object.create(null);for(const s in r){const i=r[s],a=i.parent;if(!s||typeof a!="string"||!n[a]&&!r[a]||!fr(i,Rr))return null}return t}const fi=Object.create(null);function Ou(e,t){return{provider:e,prefix:t,icons:Object.create(null),missing:new Set}}function Tt(e,t){const n=fi[e]||(fi[e]=Object.create(null));return n[t]||(n[t]=Ou(e,t))}function Ga(e,t){return Ya(t)?Ja(t,(n,r)=>{r?e.icons[n]=r:e.missing.add(n)}):[]}function Lu(e,t,n){try{if(typeof n.body=="string")return e.icons[t]={...n},!0}catch{}return!1}const Qa=/^[a-z0-9]+(-[a-z0-9]+)*$/,Kn=(e,t,n,r="")=>{const s=e.split(":");if(e.slice(0,1)==="@"){if(s.length<2||s.length>3)return null;r=s.shift().slice(1)}if(s.length>3||!s.length)return null;if(s.length>1){const o=s.pop(),c=s.pop(),d={provider:s.length>0?s[0]:r,prefix:c,name:o};return t&&!vn(d)?null:d}const i=s[0],a=i.split("-");if(a.length>1){const o={provider:r,prefix:a.shift(),name:a.join("-")};return t&&!vn(o)?null:o}if(n&&r===""){const o={provider:r,prefix:"",name:i};return t&&!vn(o,n)?null:o}return null},vn=(e,t)=>e?!!((t&&e.prefix===""||e.prefix)&&e.name):!1;let tn=!1;function Za(e){return typeof e=="boolean"&&(tn=e),tn}function hi(e){const t=typeof e=="string"?Kn(e,!0,tn):e;if(t){const n=Tt(t.provider,t.prefix),r=t.name;return n.icons[r]||(n.missing.has(r)?null:void 0)}}function Fu(e,t){const n=Kn(e,!0,tn);if(!n)return!1;const r=Tt(n.provider,n.prefix);return t?Lu(r,n.name,t):(r.missing.add(n.name),!0)}function Pu(e,t){if(typeof e!="object")return!1;if(typeof t!="string"&&(t=e.provider||""),tn&&!t&&!e.prefix){let s=!1;return Ya(e)&&(e.prefix="",Ja(e,(i,a)=>{Fu(i,a)&&(s=!0)})),s}const n=e.prefix;if(!vn({prefix:n,name:"a"}))return!1;const r=Tt(t,n);return!!Ga(r,e)}const Xa=Object.freeze({width:null,height:null}),el=Object.freeze({...Xa,...$n}),Ru=/(-?[0-9.]*[0-9]+[0-9.]*)/g,zu=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function mi(e,t,n){if(t===1)return e;if(n=n||100,typeof e=="number")return Math.ceil(e*t*n)/n;if(typeof e!="string")return e;const r=e.split(Ru);if(r===null||!r.length)return e;const s=[];let i=r.shift(),a=zu.test(i);for(;;){if(a){const o=parseFloat(i);isNaN(o)?s.push(i):s.push(Math.ceil(o*t*n)/n)}else s.push(i);if(i=r.shift(),i===void 0)return s.join("");a=!a}}function Bu(e,t="defs"){let n="";const r=e.indexOf("<"+t);for(;r>=0;){const s=e.indexOf(">",r),i=e.indexOf("</"+t);if(s===-1||i===-1)break;const a=e.indexOf(">",i);if(a===-1)break;n+=e.slice(s+1,i).trim(),e=e.slice(0,r).trim()+e.slice(a+1)}return{defs:n,content:e}}function _u(e,t){return e?"<defs>"+e+"</defs>"+t:t}function Vu(e,t,n){const r=Bu(e);return _u(r.defs,t+r.content+n)}const Hu=e=>e==="unset"||e==="undefined"||e==="none";function Uu(e,t){const n={...cs,...e},r={...el,...t},s={left:n.left,top:n.top,width:n.width,height:n.height};let i=n.body;[n,r].forEach(b=>{const x=[],w=b.hFlip,S=b.vFlip;let M=b.rotate;w?S?M+=2:(x.push("translate("+(s.width+s.left).toString()+" "+(0-s.top).toString()+")"),x.push("scale(-1 1)"),s.top=s.left=0):S&&(x.push("translate("+(0-s.left).toString()+" "+(s.height+s.top).toString()+")"),x.push("scale(1 -1)"),s.top=s.left=0);let N;switch(M<0&&(M-=Math.floor(M/4)*4),M=M%4,M){case 1:N=s.height/2+s.top,x.unshift("rotate(90 "+N.toString()+" "+N.toString()+")");break;case 2:x.unshift("rotate(180 "+(s.width/2+s.left).toString()+" "+(s.height/2+s.top).toString()+")");break;case 3:N=s.width/2+s.left,x.unshift("rotate(-90 "+N.toString()+" "+N.toString()+")");break}M%2===1&&(s.left!==s.top&&(N=s.left,s.left=s.top,s.top=N),s.width!==s.height&&(N=s.width,s.width=s.height,s.height=N)),x.length&&(i=Vu(i,'<g transform="'+x.join(" ")+'">',"</g>"))});const a=r.width,o=r.height,c=s.width,d=s.height;let u,h;a===null?(h=o===null?"1em":o==="auto"?d:o,u=mi(h,c/d)):(u=a==="auto"?c:a,h=o===null?mi(u,d/c):o==="auto"?d:o);const p={},m=(b,x)=>{Hu(x)||(p[b]=x.toString())};m("width",u),m("height",h);const v=[s.left,s.top,c,d];return p.viewBox=v.join(" "),{attributes:p,viewBox:v,body:i}}const qu=/\sid="(\S+)"/g,Wu="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let Ku=0;function Ju(e,t=Wu){const n=[];let r;for(;r=qu.exec(e);)n.push(r[1]);if(!n.length)return e;const s="suffix"+(Math.random()*16777216|Date.now()).toString(16);return n.forEach(i=>{const a=typeof t=="function"?t(i):t+(Ku++).toString(),o=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e=e.replace(new RegExp('([#;"])('+o+')([")]|\\.[a-z])',"g"),"$1"+a+s+"$3")}),e=e.replace(new RegExp(s,"g"),""),e}const zr=Object.create(null);function Yu(e,t){zr[e]=t}function Br(e){return zr[e]||zr[""]}function ds(e){let t;if(typeof e.resources=="string")t=[e.resources];else if(t=e.resources,!(t instanceof Array)||!t.length)return null;return{resources:t,path:e.path||"/",maxURL:e.maxURL||500,rotate:e.rotate||750,timeout:e.timeout||5e3,random:e.random===!0,index:e.index||0,dataAfterTimeout:e.dataAfterTimeout!==!1}}const us=Object.create(null),zt=["https://api.simplesvg.com","https://api.unisvg.com"],wn=[];for(;zt.length>0;)zt.length===1||Math.random()>.5?wn.push(zt.shift()):wn.push(zt.pop());us[""]=ds({resources:["https://api.iconify.design"].concat(wn)});function Gu(e,t){const n=ds(t);return n===null?!1:(us[e]=n,!0)}function fs(e){return us[e]}const Qu=()=>{let e;try{if(e=fetch,typeof e=="function")return e}catch{}};let pi=Qu();function Zu(e,t){const n=fs(e);if(!n)return 0;let r;if(!n.maxURL)r=0;else{let s=0;n.resources.forEach(a=>{s=Math.max(s,a.length)});const i=t+".json?icons=";r=n.maxURL-s-n.path.length-i.length}return r}function Xu(e){return e===404}const ef=(e,t,n)=>{const r=[],s=Zu(e,t),i="icons";let a={type:i,provider:e,prefix:t,icons:[]},o=0;return n.forEach((c,d)=>{o+=c.length+1,o>=s&&d>0&&(r.push(a),a={type:i,provider:e,prefix:t,icons:[]},o=c.length),a.icons.push(c)}),r.push(a),r};function tf(e){if(typeof e=="string"){const t=fs(e);if(t)return t.path}return"/"}const nf=(e,t,n)=>{if(!pi){n("abort",424);return}let r=tf(t.provider);switch(t.type){case"icons":{const i=t.prefix,o=t.icons.join(","),c=new URLSearchParams({icons:o});r+=i+".json?"+c.toString();break}case"custom":{const i=t.uri;r+=i.slice(0,1)==="/"?i.slice(1):i;break}default:n("abort",400);return}let s=503;pi(e+r).then(i=>{const a=i.status;if(a!==200){setTimeout(()=>{n(Xu(a)?"abort":"next",a)});return}return s=501,i.json()}).then(i=>{if(typeof i!="object"||i===null){setTimeout(()=>{i===404?n("abort",i):n("next",s)});return}setTimeout(()=>{n("success",i)})}).catch(()=>{n("next",s)})},rf={prepare:ef,send:nf};function tl(e,t){e.forEach(n=>{const r=n.loaderCallbacks;r&&(n.loaderCallbacks=r.filter(s=>s.id!==t))})}function sf(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout(()=>{e.pendingCallbacksFlag=!1;const t=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!t.length)return;let n=!1;const r=e.provider,s=e.prefix;t.forEach(i=>{const a=i.icons,o=a.pending.length;a.pending=a.pending.filter(c=>{if(c.prefix!==s)return!0;const d=c.name;if(e.icons[d])a.loaded.push({provider:r,prefix:s,name:d});else if(e.missing.has(d))a.missing.push({provider:r,prefix:s,name:d});else return n=!0,!0;return!1}),a.pending.length!==o&&(n||tl([e],i.id),i.callback(a.loaded.slice(0),a.missing.slice(0),a.pending.slice(0),i.abort))})}))}let af=0;function lf(e,t,n){const r=af++,s=tl.bind(null,n,r);if(!t.pending.length)return s;const i={id:r,icons:t,callback:e,abort:s};return n.forEach(a=>{(a.loaderCallbacks||(a.loaderCallbacks=[])).push(i)}),s}function of(e){const t={loaded:[],missing:[],pending:[]},n=Object.create(null);e.sort((s,i)=>s.provider!==i.provider?s.provider.localeCompare(i.provider):s.prefix!==i.prefix?s.prefix.localeCompare(i.prefix):s.name.localeCompare(i.name));let r={provider:"",prefix:"",name:""};return e.forEach(s=>{if(r.name===s.name&&r.prefix===s.prefix&&r.provider===s.provider)return;r=s;const i=s.provider,a=s.prefix,o=s.name,c=n[i]||(n[i]=Object.create(null)),d=c[a]||(c[a]=Tt(i,a));let u;o in d.icons?u=t.loaded:a===""||d.missing.has(o)?u=t.missing:u=t.pending;const h={provider:i,prefix:a,name:o};u.push(h)}),t}function cf(e,t=!0,n=!1){const r=[];return e.forEach(s=>{const i=typeof s=="string"?Kn(s,t,n):s;i&&r.push(i)}),r}const df={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function uf(e,t,n,r){const s=e.resources.length,i=e.random?Math.floor(Math.random()*s):e.index;let a;if(e.random){let T=e.resources.slice(0);for(a=[];T.length>1;){const $=Math.floor(Math.random()*T.length);a.push(T[$]),T=T.slice(0,$).concat(T.slice($+1))}a=a.concat(T)}else a=e.resources.slice(i).concat(e.resources.slice(0,i));const o=Date.now();let c="pending",d=0,u,h=null,p=[],m=[];typeof r=="function"&&m.push(r);function v(){h&&(clearTimeout(h),h=null)}function b(){c==="pending"&&(c="aborted"),v(),p.forEach(T=>{T.status==="pending"&&(T.status="aborted")}),p=[]}function x(T,$){$&&(m=[]),typeof T=="function"&&m.push(T)}function w(){return{startTime:o,payload:t,status:c,queriesSent:d,queriesPending:p.length,subscribe:x,abort:b}}function S(){c="failed",m.forEach(T=>{T(void 0,u)})}function M(){p.forEach(T=>{T.status==="pending"&&(T.status="aborted")}),p=[]}function N(T,$,W){const D=$!=="success";switch(p=p.filter(R=>R!==T),c){case"pending":break;case"failed":if(D||!e.dataAfterTimeout)return;break;default:return}if($==="abort"){u=W,S();return}if(D){u=W,p.length||(a.length?j():S());return}if(v(),M(),!e.random){const R=e.resources.indexOf(T.resource);R!==-1&&R!==e.index&&(e.index=R)}c="completed",m.forEach(R=>{R(W)})}function j(){if(c!=="pending")return;v();const T=a.shift();if(T===void 0){if(p.length){h=setTimeout(()=>{v(),c==="pending"&&(M(),S())},e.timeout);return}S();return}const $={status:"pending",resource:T,callback:(W,D)=>{N($,W,D)}};p.push($),d++,h=setTimeout(j,e.rotate),n(T,t,$.callback)}return setTimeout(j),w}function nl(e){const t={...df,...e};let n=[];function r(){n=n.filter(o=>o().status==="pending")}function s(o,c,d){const u=uf(t,o,c,(h,p)=>{r(),d&&d(h,p)});return n.push(u),u}function i(o){return n.find(c=>o(c))||null}return{query:s,find:i,setIndex:o=>{t.index=o},getIndex:()=>t.index,cleanup:r}}function gi(){}const hr=Object.create(null);function ff(e){if(!hr[e]){const t=fs(e);if(!t)return;const n=nl(t),r={config:t,redundancy:n};hr[e]=r}return hr[e]}function hf(e,t,n){let r,s;if(typeof e=="string"){const i=Br(e);if(!i)return n(void 0,424),gi;s=i.send;const a=ff(e);a&&(r=a.redundancy)}else{const i=ds(e);if(i){r=nl(i);const a=e.resources?e.resources[0]:"",o=Br(a);o&&(s=o.send)}}return!r||!s?(n(void 0,424),gi):r.query(t,s,n)().abort}function xi(){}function mf(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout(()=>{e.iconsLoaderFlag=!1,sf(e)}))}function pf(e){const t=[],n=[];return e.forEach(r=>{(r.match(Qa)?t:n).push(r)}),{valid:t,invalid:n}}function Bt(e,t,n){function r(){const s=e.pendingIcons;t.forEach(i=>{s&&s.delete(i),e.icons[i]||e.missing.add(i)})}if(n&&typeof n=="object")try{if(!Ga(e,n).length){r();return}}catch(s){console.error(s)}r(),mf(e)}function yi(e,t){e instanceof Promise?e.then(n=>{t(n)}).catch(()=>{t(null)}):t(e)}function gf(e,t){e.iconsToLoad?e.iconsToLoad=e.iconsToLoad.concat(t).sort():e.iconsToLoad=t,e.iconsQueueFlag||(e.iconsQueueFlag=!0,setTimeout(()=>{e.iconsQueueFlag=!1;const{provider:n,prefix:r}=e,s=e.iconsToLoad;if(delete e.iconsToLoad,!s||!s.length)return;const i=e.loadIcon;if(e.loadIcons&&(s.length>1||!i)){yi(e.loadIcons(s,r,n),u=>{Bt(e,s,u)});return}if(i){s.forEach(u=>{const h=i(u,r,n);yi(h,p=>{const m=p?{prefix:r,icons:{[u]:p}}:null;Bt(e,[u],m)})});return}const{valid:a,invalid:o}=pf(s);if(o.length&&Bt(e,o,null),!a.length)return;const c=r.match(Qa)?Br(n):null;if(!c){Bt(e,a,null);return}c.prepare(n,r,a).forEach(u=>{hf(n,u,h=>{Bt(e,u.icons,h)})})}))}const xf=(e,t)=>{const n=cf(e,!0,Za()),r=of(n);if(!r.pending.length){let c=!0;return t&&setTimeout(()=>{c&&t(r.loaded,r.missing,r.pending,xi)}),()=>{c=!1}}const s=Object.create(null),i=[];let a,o;return r.pending.forEach(c=>{const{provider:d,prefix:u}=c;if(u===o&&d===a)return;a=d,o=u,i.push(Tt(d,u));const h=s[d]||(s[d]=Object.create(null));h[u]||(h[u]=[])}),r.pending.forEach(c=>{const{provider:d,prefix:u,name:h}=c,p=Tt(d,u),m=p.pendingIcons||(p.pendingIcons=new Set);m.has(h)||(m.add(h),s[d][u].push(h))}),i.forEach(c=>{const d=s[c.provider][c.prefix];d.length&&gf(c,d)}),t?lf(t,r,i):xi};function yf(e,t){const n={...e};for(const r in t){const s=t[r],i=typeof s;r in Xa?(s===null||s&&(i==="string"||i==="number"))&&(n[r]=s):i===typeof n[r]&&(n[r]=r==="rotate"?s%4:s)}return n}const bf=/[\s,]+/;function vf(e,t){t.split(bf).forEach(n=>{switch(n.trim()){case"horizontal":e.hFlip=!0;break;case"vertical":e.vFlip=!0;break}})}function wf(e,t=0){const n=e.replace(/^-?[0-9.]*/,"");function r(s){for(;s<0;)s+=4;return s%4}if(n===""){const s=parseInt(e);return isNaN(s)?0:r(s)}else if(n!==e){let s=0;switch(n){case"%":s=25;break;case"deg":s=90}if(s){let i=parseFloat(e.slice(0,e.length-n.length));return isNaN(i)?0:(i=i/s,i%1===0?r(i):0)}}return t}function kf(e,t){let n=e.indexOf("xlink:")===-1?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const r in t)n+=" "+r+'="'+t[r]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+n+">"+e+"</svg>"}function Nf(e){return e.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function Sf(e){return"data:image/svg+xml,"+Nf(e)}function Cf(e){return'url("'+Sf(e)+'")'}let Wt;function jf(){try{Wt=window.trustedTypes.createPolicy("iconify",{createHTML:e=>e})}catch{Wt=null}}function Af(e){return Wt===void 0&&jf(),Wt?Wt.createHTML(e):e}const rl={...el,inline:!1},Mf={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},Ef={display:"inline-block"},_r={backgroundColor:"currentColor"},sl={backgroundColor:"transparent"},bi={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},vi={WebkitMask:_r,mask:_r,background:sl};for(const e in vi){const t=vi[e];for(const n in bi)t[e+n]=bi[n]}const Tf={...rl,inline:!0};function wi(e){return e+(e.match(/^[-0-9.]+$/)?"px":"")}const Df=(e,t,n)=>{const r=t.inline?Tf:rl,s=yf(r,t),i=t.mode||"svg",a={},o=t.style||{},c={...i==="svg"?Mf:{}};if(n){const x=Kn(n,!1,!0);if(x){const w=["iconify"],S=["provider","prefix"];for(const M of S)x[M]&&w.push("iconify--"+x[M]);c.className=w.join(" ")}}for(let x in t){const w=t[x];if(w!==void 0)switch(x){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":c.ref=w;break;case"className":c[x]=(c[x]?c[x]+" ":"")+w;break;case"inline":case"hFlip":case"vFlip":s[x]=w===!0||w==="true"||w===1;break;case"flip":typeof w=="string"&&vf(s,w);break;case"color":a.color=w;break;case"rotate":typeof w=="string"?s[x]=wf(w):typeof w=="number"&&(s[x]=w);break;case"ariaHidden":case"aria-hidden":w!==!0&&w!=="true"&&delete c["aria-hidden"];break;default:r[x]===void 0&&(c[x]=w)}}const d=Uu(e,s),u=d.attributes;if(s.inline&&(a.verticalAlign="-0.125em"),i==="svg"){c.style={...a,...o},Object.assign(c,u);let x=0,w=t.id;return typeof w=="string"&&(w=w.replace(/-/g,"_")),c.dangerouslySetInnerHTML={__html:Af(Ju(d.body,w?()=>w+"ID"+x++:"iconifyReact"))},y.createElement("svg",c)}const{body:h,width:p,height:m}=e,v=i==="mask"||(i==="bg"?!1:h.indexOf("currentColor")!==-1),b=kf(h,{...u,width:p+"",height:m+""});return c.style={...a,"--svg":Cf(b),width:wi(u.width),height:wi(u.height),...Ef,...v?_r:sl,...o},y.createElement("span",c)};Za(!0);Yu("",rf);if(typeof document<"u"&&typeof window<"u"){const e=window;if(e.IconifyPreload!==void 0){const t=e.IconifyPreload,n="Invalid IconifyPreload syntax.";typeof t=="object"&&t!==null&&(t instanceof Array?t:[t]).forEach(r=>{try{(typeof r!="object"||r===null||r instanceof Array||typeof r.icons!="object"||typeof r.prefix!="string"||!Pu(r))&&console.error(n)}catch{console.error(n)}})}if(e.IconifyProviders!==void 0){const t=e.IconifyProviders;if(typeof t=="object"&&t!==null)for(let n in t){const r="IconifyProviders["+n+"] is invalid.";try{const s=t[n];if(typeof s!="object"||!s||s.resources===void 0)continue;Gu(n,s)||console.error(r)}catch{console.error(r)}}}}function il(e){const[t,n]=y.useState(!!e.ssr),[r,s]=y.useState({});function i(m){if(m){const v=e.icon;if(typeof v=="object")return{name:"",data:v};const b=hi(v);if(b)return{name:v,data:b}}return{name:""}}const[a,o]=y.useState(i(!!e.ssr));function c(){const m=r.callback;m&&(m(),s({}))}function d(m){if(JSON.stringify(a)!==JSON.stringify(m))return c(),o(m),!0}function u(){var m;const v=e.icon;if(typeof v=="object"){d({name:"",data:v});return}const b=hi(v);if(d({name:v,data:b}))if(b===void 0){const x=xf([v],u);s({callback:x})}else b&&((m=e.onLoad)===null||m===void 0||m.call(e,v))}y.useEffect(()=>(n(!0),c),[]),y.useEffect(()=>{t&&u()},[e.icon,t]);const{name:h,data:p}=a;return p?Df({...cs,...p},e,h):e.children?e.children:e.fallback?e.fallback:y.createElement("span",{})}const U=y.forwardRef((e,t)=>il({...e,_ref:t}));y.forwardRef((e,t)=>il({inline:!0,...e,_ref:t}));const mr=({icon:e,children:t,testId:n})=>l.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600","data-testid":n,children:[l.jsx(U,{icon:e,width:20,className:"text-default-500"}),l.jsx("span",{children:t})]}),If=({classes:e="",name:t,imageUrl:n,eventDate:r,eventTime:s,location:i,description:a,showImage:o=!1,compact:c=!1,imageLoading:d="eager",showMoreButtonClassName:u,labels:h})=>{const[p,m]=y.useState(!1),[v,b]=y.useState(!1),x=y.useRef(null);return y.useEffect(()=>{const w=()=>{if(x.current){const S=x.current.scrollHeight>x.current.clientHeight;b(S)}};return w(),window.addEventListener("resize",w),()=>window.removeEventListener("resize",w)},[a]),l.jsxs(f.Card,{className:f.cn("border-0 shadow-none",e),"data-testid":"event-details-root",children:[l.jsxs(f.CardHeader,{className:f.cn("pt-2 pb-0 flex-col items-start",c?"space-y-1":"space-y-2"),"data-testid":"event-details-header",children:[o&&n&&l.jsx("div",{className:f.cn("w-full overflow-hidden rounded-xl","aspect-[3/1]"),"data-testid":"event-details-image-wrapper",children:l.jsx(f.Image,{removeWrapper:!0,loading:d,alt:`Event image for ${t}`,className:"w-full h-full object-cover object-center",src:n,"data-testid":"event-details-image"})}),l.jsx("h2",{className:f.cn("font-semibold text-gray-800",c?"text-base":"text-xl"),"data-testid":"event-details-title",children:t})]}),l.jsxs(f.CardBody,{className:f.cn("space-y-3",c?"py-1 space-y-2":"py-3"),"data-testid":"event-details-body",children:[l.jsx("h3",{className:f.cn("font-semibold text-base text-gray-700",c?"text-sm":""),"data-testid":"event-details-info-label",children:h.eventInformation}),l.jsxs("div",{className:"flex flex-wrap gap-4","data-testid":"event-details-info",children:[r&&l.jsx(mr,{icon:"solar:calendar-minimalistic-linear",testId:"event-details-date",children:r}),s&&l.jsx(mr,{icon:"solar:clock-circle-linear",testId:"event-details-time",children:s}),i&&l.jsx(mr,{icon:"solar:map-point-linear",testId:"event-details-location",children:i})]}),a&&l.jsxs("div",{className:"relative","data-testid":"event-details-description-wrapper",children:[l.jsxs("div",{className:"relative",children:[l.jsx("div",{ref:x,className:f.cn("text-sm text-gray-700 leading-relaxed transition-all",c?"text-xs":"",!p&&"line-clamp-3"),"data-testid":"event-details-description",dangerouslySetInnerHTML:{__html:a}}),!p&&v&&l.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"})]}),(v||p)&&l.jsx("div",{className:"flex justify-end mt-1",children:l.jsx(K,{onPress:()=>m(!p),variant:"light",className:f.cn("text-primary",u),size:c?"sm":"md",startContent:l.jsx(U,{icon:p?"solar:eye-closed-linear":"solar:eye-linear",width:c?16:20}),"data-testid":"event-details-toggle-description",children:p?h.showLess||"Hide":h.showMore||"Show"})})]})]})]})};function al(e,t="en-US",n="USD"){try{return new Intl.NumberFormat(t,{style:"currency",currency:n,minimumFractionDigits:2,maximumFractionDigits:2}).format(e)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${e.toFixed(2)}`}}function $f(e){const t=e.replace(/[^\d.,-]/g,""),n=t.match(/,\d{1,2}$/);let r;n?r=t.replace(/\./g,"").replace(",","."):r=t.replace(/,/g,"");const s=parseFloat(r);return isNaN(s)?null:s}const Of={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"},mn=e=>typeof e=="number"&&!isNaN(e),On=({offer:e,quantity:t,defaultQuantity:n=0,onQuantityChange:r,currency:s="USD",locale:i="en-US",labels:a,slots:o,isDisabled:c=!1,buttonVariant:d="bordered",buttonColor:u="default",showCard:h=!0,showDescription:p=!0,showPeopleCount:m=!0,showPrice:v=!0,classNames:b={},"data-testid":x,selectedColor:w="default",compact:S=!1,isSoldOut:M,isMaxReached:N,isRuleBlocked:j,statusTone:T="default",statusLabel:$,disabledReason:W,disabled:D})=>{const R=y.useMemo(()=>({...Of,...a}),[a]),[E,C]=y.useState(n),I=t!==void 0?t:E,F=!!(c||D),H=S||!!e.compact,Q=y.useMemo(()=>typeof M=="boolean"?M:typeof e.isSoldOut=="boolean"?e.isSoldOut:!mn(e.totalTicketsSold)||!mn(e.ticketsAllowed)?!1:e.totalTicketsSold>=e.ticketsAllowed,[M,e.isSoldOut,e.totalTicketsSold,e.ticketsAllowed]),Y=y.useMemo(()=>typeof N=="boolean"?N:typeof e.isMaxReached=="boolean"?e.isMaxReached:Q||!mn(e.ticketsAllowed)?!1:I>=e.ticketsAllowed-(e.totalTicketsSold??0),[N,e.isMaxReached,Q,e.ticketsAllowed,e.totalTicketsSold,I]),te=y.useMemo(()=>typeof j=="boolean"?j:typeof e.isRuleBlocked=="boolean"?e.isRuleBlocked:!1,[j,e.isRuleBlocked]),oe=W||e.disabledReason,ce=F||Q||te,P=ue=>{if(ce||ue>0&&Y)return;const Te=Math.max(0,I+ue);t===void 0&&C(Te),r?.(e.id,Te)},_=y.useMemo(()=>{if(Q)return"soldOut";if(te)return"ruleBlocked";if(F)return"disabled"},[Q,te,F]),G=y.useMemo(()=>T||(Q||te?"danger":Y?"warning":"default"),[T,Q,te,Y]),ne=y.useMemo(()=>{if(_)return _==="ruleBlocked"?$||oe||R.ruleBlocked:_==="soldOut"?$||oe||R.soldOut:_==="disabled"?$||oe||R.disabled:$||R.maxReached},[_,$,oe,R]),Se={soldOut:"danger",ruleBlocked:G,disabled:"default",maxReached:"warning"},at={soldOut:"offer-card-sold-out-chip",maxReached:"offer-card-max-reached-chip",ruleBlocked:"offer-card-ruleBlocked-chip",disabled:"offer-card-disabled-chip"},$t=()=>o?.renderName?o.renderName(e.name,e):l.jsx("h2",{"data-testid":"offer-card-name",className:f.cn("text-base font-medium",H&&"text-sm",b.name),children:e.name}),Ot=()=>{if(!v)return null;const ue=al(e.price,i,s);return o?.renderPrice?o.renderPrice(e.price,ue,e):l.jsx("p",{"data-testid":"offer-card-price",className:f.cn("text-primary text-base mt-1",H&&"text-sm mt-0.5",b.price),children:ue})},on=()=>!p||!e.description?null:o?.renderDescription?o.renderDescription(e.description,e):l.jsx("p",{"data-testid":"offer-card-description",className:f.cn("mb-4 text-sm text-gray-700 leading-relaxed",H&&"mb-2 text-xs text-gray-600",b.description),children:e.description}),Lt=()=>{if(!m||!mn(e.numberOfPeople)||e.numberOfPeople<=0)return null;const ue=e.numberOfPeople===1?R.person:R.people;return o?.renderPeopleCount?o.renderPeopleCount(e.numberOfPeople,ue,e):l.jsxs("p",{"data-testid":"offer-card-people-count",className:f.cn("text-sm text-gray-600 flex items-center mt-2",H&&"mt-1 text-xs",b.peopleCount),children:[l.jsx(U,{icon:e.numberOfPeople<=1?"solar:user-rounded-outline":"solar:users-group-rounded-outline",width:20,className:"mr-1"}),e.numberOfPeople," ",ue]})},Ft=()=>{const ue=I===0||ce,Te=Y||ce;return o?.renderQuantitySelector?o.renderQuantitySelector({quantity:I,onIncrement:()=>P(1),onDecrement:()=>P(-1),isDecrementDisabled:ue,isIncrementDisabled:Te,isDisabled:ce}):l.jsxs("div",{className:f.cn("flex items-center gap-2",b.quantitySelector),children:[l.jsx(K,{"data-testid":"offer-card-decrement-button",onPress:()=>P(-1),isDisabled:ue,variant:d,color:I>0?w:u,radius:"full",isIconOnly:!0,size:H?"md":"sm","aria-label":"Decrease quantity",children:l.jsx(U,{icon:"gravity-ui:minus",width:16})}),l.jsx("span",{"data-testid":"offer-card-quantity",className:f.cn("min-w-[2rem] text-center font-medium",H&&"text-sm"),children:I}),l.jsx(K,{"data-testid":"offer-card-increment-button",onPress:()=>P(1),isDisabled:Te,variant:d,color:I>0?w:u,radius:"full",isIconOnly:!0,size:H?"md":"sm","aria-label":"Increase quantity",children:l.jsx(U,{icon:"gravity-ui:plus",width:16})})]})},cn=(ue,Te)=>o?.renderDisabledState?o.renderDisabledState(ue,Te):ue==="soldOut"&&o?.renderSoldOut?o.renderSoldOut(Te):ue==="maxReached"&&o?.renderMaxReachedAlert?o.renderMaxReachedAlert(Te):l.jsx(f.Chip,{"data-testid":at[ue],color:Se[ue],variant:ue==="maxReached"?"flat":"solid",className:f.cn("gap-2 px-4",ue==="maxReached"?"h-8":"h-10",ue==="soldOut"&&b.soldOut,ue==="maxReached"&&b.maxReachedAlert,H&&"h-8"),startContent:l.jsx(U,{icon:"gravity-ui:triangle-exclamation-fill",width:14}),children:l.jsx("span",{className:"font-medium text-sm",children:Te})}),Pt=l.jsxs("div",{className:f.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:[l.jsxs("div",{className:f.cn("h-full col-span-2",ce||Y?"opacity-50 pointer-events-none select-none":""),children:[$t(),Ot(),l.jsxs("div",{className:f.cn("md:col-span-1 xl:col-span-2 lg:col-span-1",H?"mb-1":"mb-2"),children:[Lt(),on()]})]}),l.jsx("div",{className:f.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",b.compactFooter),children:_&&ne?cn(_,ne):Ft()})]}),wt=Y&&!Q&&!te&&!F?l.jsx(Pe.motion.div,{className:f.cn("w-full sm:max-w-[60%] md:max-w-[60%] lg:max-w-[60%]",b.compactFooter),initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.3},children:cn("maxReached",ne||R.maxReached)}):null;return h?l.jsxs(f.Card,{className:f.cn("w-full",H&&b.compact,b.base),"data-testid":x||`offer-card-${e.id}`,children:[l.jsx(f.CardBody,{className:f.cn("pt-1 pb-0",H?"pb-0.5":"",b.body),children:Pt}),l.jsx(Pe.AnimatePresence,{children:wt&&l.jsx(f.CardFooter,{className:f.cn("w-full mt-0 pt-0",H?"pt-1":"",b.footer),children:wt})})]}):l.jsxs("div",{className:f.cn("w-full",H&&b.compact,b.base),"data-testid":x||`offer-card-${e.id}`,children:[l.jsx("div",{className:f.cn("pt-1 pb-0",H?"pb-0.5":"",b.body),children:Pt}),l.jsx(Pe.AnimatePresence,{children:wt&&l.jsx("div",{className:f.cn("w-full mt-0 pt-0",H?"pt-1":"",b.footer),children:wt})})]})};On.displayName="OfferCard";const ll=({message:e="No offers available.",icon:t="solar:ticket-sale-outline",iconSize:n=48,showCard:r=!0,classNames:s={},renderEmpty:i})=>{if(i){const o=i();return r?l.jsx(f.Card,{"data-testid":"offer-card-empty",className:f.cn("w-full",s.base),children:l.jsx(f.CardBody,{"data-testid":"offer-card-empty-body",children:o})}):l.jsx("div",{"data-testid":"offer-card-empty",className:f.cn("w-full",s.base),children:o})}const a=l.jsxs("div",{"data-testid":"offer-card-empty-content",className:f.cn("flex flex-col items-center justify-center p-8 text-center text-gray-500",s.content),children:[l.jsx(U,{"data-testid":"offer-card-empty-icon",icon:t,width:n,className:f.cn("mb-4",s.icon)}),l.jsx("h3",{"data-testid":"offer-card-empty-message",className:f.cn("text-lg",s.message),children:e})]});return r?l.jsx(f.Card,{"data-testid":"offer-card-empty",className:f.cn("w-full",s.base),children:l.jsx(f.CardBody,{"data-testid":"offer-card-empty-body",children:a})}):l.jsx("div",{"data-testid":"offer-card-empty",className:f.cn("w-full",s.base),children:a})};ll.displayName="OfferCardEmpty";const Lf={title:"Error Fetching Offers",description:"An error occurred while fetching offers."},ol=({error:e,labels:t,showCard:n=!0,color:r="danger",classNames:s={}})=>{const i={...Lf,...t},a=l.jsx(f.Alert,{"data-testid":"offer-card-error-alert",color:r,title:i.title,description:e||i.description,className:s.alert});return n?l.jsx(f.Card,{"data-testid":"offer-card-error",className:f.cn("w-full",s.base),children:l.jsx(f.CardBody,{"data-testid":"offer-card-error-body",children:a})}):l.jsx("div",{"data-testid":"offer-card-error",className:f.cn("w-full",s.base),children:a})};ol.displayName="OfferCardError";const Ff={1:"space-y-1",2:"space-y-2",3:"space-y-3",4:"space-y-4",5:"space-y-5",6:"space-y-6"},cl=({quantity:e=2,gap:t=4,classNames:n={}})=>{const r=Ff[t];return l.jsx("div",{"data-testid":"offer-card-skeleton-container",className:f.cn(r,n.base),children:Array.from({length:e}).map((s,i)=>l.jsxs(f.Card,{"data-testid":`offer-card-skeleton-${i}`,className:f.cn("w-full",n.card),children:[l.jsx(f.CardHeader,{"data-testid":`offer-card-skeleton-header-${i}`,className:"flex justify-between items-start pb-0",children:l.jsxs("div",{className:"space-y-2 w-full",children:[l.jsx(f.Skeleton,{"data-testid":`offer-card-skeleton-title-${i}`,className:"w-1/3 rounded-lg",children:l.jsx("div",{className:"h-4 bg-default-200 rounded-lg"})}),l.jsx(f.Skeleton,{"data-testid":`offer-card-skeleton-subtitle-${i}`,className:"w-1/4 rounded-lg",children:l.jsx("div",{className:"h-3 bg-default-300 rounded-lg"})})]})}),l.jsx(f.CardBody,{"data-testid":`offer-card-skeleton-body-${i}`,className:"pt-2 pb-0",children:l.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-2 items-start",children:[l.jsxs("div",{className:"xl:col-span-2 space-y-2",children:[l.jsx(f.Skeleton,{"data-testid":`offer-card-skeleton-people-${i}`,className:"w-1/4 rounded-lg",children:l.jsx("div",{className:"h-4 bg-default-300 rounded-lg"})}),l.jsx(f.Skeleton,{"data-testid":`offer-card-skeleton-description-${i}`,className:"w-3/4 rounded-lg",children:l.jsx("div",{className:"h-4 bg-default-200 rounded-lg"})})]}),l.jsx("div",{className:"flex items-start justify-end",children:l.jsxs("div",{"data-testid":`offer-card-skeleton-controls-${i}`,className:"flex items-center justify-end gap-2 w-full px-4 py-2",children:[l.jsx(f.Skeleton,{"data-testid":`offer-card-skeleton-label-${i}`,className:"w-24 h-4 rounded-md bg-default-200"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(f.Skeleton,{"data-testid":`offer-card-skeleton-btn-dec-${i}`,className:"w-8 h-8 rounded-md bg-default-300"}),l.jsx(f.Skeleton,{"data-testid":`offer-card-skeleton-btn-qty-${i}`,className:"w-8 h-8 rounded-md bg-default-200"}),l.jsx(f.Skeleton,{"data-testid":`offer-card-skeleton-btn-inc-${i}`,className:"w-8 h-8 rounded-md bg-default-300"})]})]})})]})})]},i))})};cl.displayName="OfferCardSkeleton";const dl={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.15,delayChildren:.1}}},ul={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"}}},Pf={1:"gap-1",2:"gap-2",3:"gap-3",4:"gap-4",5:"gap-5",6:"gap-6"},fl=({offers:e=[],mapOffer:t,selection:n,defaultSelection:r={},onSelectionChange:s,onQuantityChange:i,currency:a="USD",locale:o="en-US",labels:c,slots:d,isDisabled:u=!1,buttonVariant:h="bordered",buttonColor:p="default",showCard:m=!0,animated:v=!0,gap:b=2,compact:x=!1,classNames:w={}})=>{const[S,M]=y.useState(r),N=n!==void 0?n:S,j=y.useCallback((E,C)=>{const I={...N,[E]:Math.max(0,C)};n===void 0&&M(I),s?.(I),i?.(E,I[E])},[N,n,s,i]),T=[...e].sort((E,C)=>(E.position??0)-(C.position??0)),$=E=>{const C=t?t(E):E,I=(N??{})[C.id]||0;return{offer:C,quantity:I,onQuantityChange:j,currency:a,locale:o,labels:c,slots:d,isDisabled:u,buttonVariant:h,buttonColor:p,showCard:m,compact:x}},W=Pf[b],D=f.cn("grid mx-auto pt-2",W,w.base),R=E=>{const C=$(E);return l.jsx(On,{offer:C.offer,quantity:C.quantity,onQuantityChange:C.onQuantityChange,currency:C.currency,locale:C.locale,labels:C.labels,slots:C.slots,isDisabled:C.isDisabled,buttonVariant:C.buttonVariant,buttonColor:C.buttonColor,showCard:C.showCard,compact:C.compact,classNames:w.card},C.offer.id)};return v?l.jsx(Pe.motion.div,{"data-testid":"offer-card-list",className:D,variants:dl,initial:"hidden",animate:"show",children:l.jsx(Pe.AnimatePresence,{children:T.map(E=>{const C=$(E);return l.jsx(Pe.motion.div,{"data-testid":`offer-card-list-item-${C.offer.id}`,className:w.cardWrapper,variants:ul,exit:{opacity:0,y:-20},transition:{duration:.3},children:l.jsx(On,{offer:C.offer,quantity:C.quantity,onQuantityChange:j,currency:a,locale:o,labels:c,slots:d,isDisabled:u,buttonVariant:h,buttonColor:p,showCard:m,compact:x||C.offer.compact,classNames:w.card})},C.offer.id)})})}):l.jsx("div",{"data-testid":"offer-card-list",className:D,children:T.map(R)})};fl.displayName="OfferCardList";var an=e=>e.type==="checkbox",mt=e=>e instanceof Date,Ee=e=>e==null;const hl=e=>typeof e=="object";var ye=e=>!Ee(e)&&!Array.isArray(e)&&hl(e)&&!mt(e),ml=e=>ye(e)&&e.target?an(e.target)?e.target.checked:e.target.value:e,Rf=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,pl=(e,t)=>e.has(Rf(t)),zf=e=>{const t=e.constructor&&e.constructor.prototype;return ye(t)&&t.hasOwnProperty("isPrototypeOf")},hs=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function pe(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(hs&&(e instanceof Blob||t))return e;const n=Array.isArray(e);if(!n&&!(ye(e)&&zf(e)))return e;const r=n?[]:Object.create(Object.getPrototypeOf(e));for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r[s]=pe(e[s]));return r}var Jn=e=>/^\w*$/.test(e),fe=e=>e===void 0,ms=e=>Array.isArray(e)?e.filter(Boolean):[],ps=e=>ms(e.replace(/["|']|\]/g,"").split(/\.|\[/)),z=(e,t,n)=>{if(!t||!ye(e))return n;const r=(Jn(t)?[t]:ps(t)).reduce((s,i)=>Ee(s)?s:s[i],e);return fe(r)||r===e?fe(e[t])?n:e[t]:r},De=e=>typeof e=="boolean",Me=e=>typeof e=="function",le=(e,t,n)=>{let r=-1;const s=Jn(t)?[t]:ps(t),i=s.length,a=i-1;for(;++r<i;){const o=s[r];let c=n;if(r!==a){const d=e[o];c=ye(d)||Array.isArray(d)?d:isNaN(+s[r+1])?{}:[]}if(o==="__proto__"||o==="constructor"||o==="prototype")return;e[o]=c,e=e[o]}};const Ln={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},ze={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},We={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},gl=y.createContext(null);gl.displayName="HookFormControlContext";const gs=()=>y.useContext(gl);var xl=(e,t,n,r=!0)=>{const s={defaultValues:t._defaultValues};for(const i in e)Object.defineProperty(s,i,{get:()=>{const a=i;return t._proxyFormState[a]!==ze.all&&(t._proxyFormState[a]=!r||ze.all),n&&(n[a]=!0),e[a]}});return s};const xs=typeof window<"u"?y.useLayoutEffect:y.useEffect;function Bf(e){const t=gs(),{control:n=t,disabled:r,name:s,exact:i}=e||{},[a,o]=y.useState(n._formState),c=y.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return xs(()=>n._subscribe({name:s,formState:c.current,exact:i,callback:d=>{!r&&o({...n._formState,...d})}}),[s,r,i]),y.useEffect(()=>{c.current.isValid&&n._setValid(!0)},[n]),y.useMemo(()=>xl(a,n,c.current,!1),[a,n])}var $e=e=>typeof e=="string",Vr=(e,t,n,r,s)=>$e(e)?(r&&t.watch.add(e),z(n,e,s)):Array.isArray(e)?e.map(i=>(r&&t.watch.add(i),z(n,i))):(r&&(t.watchAll=!0),n),Hr=e=>Ee(e)||!hl(e);function Be(e,t,n=new WeakSet){if(Hr(e)||Hr(t))return Object.is(e,t);if(mt(e)&&mt(t))return Object.is(e.getTime(),t.getTime());const r=Object.keys(e),s=Object.keys(t);if(r.length!==s.length)return!1;if(n.has(e)||n.has(t))return!0;n.add(e),n.add(t);for(const i of r){const a=e[i];if(!s.includes(i))return!1;if(i!=="ref"){const o=t[i];if(mt(a)&&mt(o)||ye(a)&&ye(o)||Array.isArray(a)&&Array.isArray(o)?!Be(a,o,n):!Object.is(a,o))return!1}}return!0}function _f(e){const t=gs(),{control:n=t,name:r,defaultValue:s,disabled:i,exact:a,compute:o}=e||{},c=y.useRef(s),d=y.useRef(o),u=y.useRef(void 0),h=y.useRef(n),p=y.useRef(r);d.current=o;const[m,v]=y.useState(()=>{const N=n._getWatch(r,c.current);return d.current?d.current(N):N}),b=y.useCallback(N=>{const j=Vr(r,n._names,N||n._formValues,!1,c.current);return d.current?d.current(j):j},[n._formValues,n._names,r]),x=y.useCallback(N=>{if(!i){const j=Vr(r,n._names,N||n._formValues,!1,c.current);if(d.current){const T=d.current(j);Be(T,u.current)||(v(T),u.current=T)}else v(j)}},[n._formValues,n._names,i,r]);xs(()=>((h.current!==n||!Be(p.current,r))&&(h.current=n,p.current=r,x()),n._subscribe({name:r,formState:{values:!0},exact:a,callback:N=>{x(N.values)}})),[n,a,r,x]),y.useEffect(()=>n._removeUnmounted());const w=h.current!==n,S=p.current,M=y.useMemo(()=>{if(i)return null;const N=!w&&!Be(S,r);return w||N?b():null},[i,w,r,S,b]);return M!==null?M:m}function Vf(e){const t=gs(),{name:n,disabled:r,control:s=t,shouldUnregister:i,defaultValue:a,exact:o=!0}=e,c=pl(s._names.array,n),d=y.useMemo(()=>z(s._formValues,n,z(s._defaultValues,n,a)),[s,n,a]),u=_f({control:s,name:n,defaultValue:d,exact:o}),h=Bf({control:s,name:n,exact:o}),p=y.useRef(e),m=y.useRef(void 0),v=y.useRef(s.register(n,{...e.rules,value:u,...De(e.disabled)?{disabled:e.disabled}:{}}));p.current=e;const b=y.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!z(h.errors,n)},isDirty:{enumerable:!0,get:()=>!!z(h.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!z(h.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!z(h.validatingFields,n)},error:{enumerable:!0,get:()=>z(h.errors,n)}}),[h,n]),x=y.useCallback(N=>v.current.onChange({target:{value:ml(N),name:n},type:Ln.CHANGE}),[n]),w=y.useCallback(()=>v.current.onBlur({target:{value:z(s._formValues,n),name:n},type:Ln.BLUR}),[n,s._formValues]),S=y.useCallback(N=>{const j=z(s._fields,n);j&&j._f&&N&&(j._f.ref={focus:()=>Me(N.focus)&&N.focus(),select:()=>Me(N.select)&&N.select(),setCustomValidity:T=>Me(N.setCustomValidity)&&N.setCustomValidity(T),reportValidity:()=>Me(N.reportValidity)&&N.reportValidity()})},[s._fields,n]),M=y.useMemo(()=>({name:n,value:u,...De(r)||h.disabled?{disabled:h.disabled||r}:{},onChange:x,onBlur:w,ref:S}),[n,r,h.disabled,x,w,S,u]);return y.useEffect(()=>{const N=s._options.shouldUnregister||i,j=m.current;j&&j!==n&&!c&&s.unregister(j),s.register(n,{...p.current.rules,...De(p.current.disabled)?{disabled:p.current.disabled}:{}});const T=($,W)=>{const D=z(s._fields,$);D&&D._f&&(D._f.mount=W)};if(T(n,!0),N){const $=pe(z(s._options.defaultValues,n,p.current.defaultValue));le(s._defaultValues,n,$),fe(z(s._formValues,n))&&le(s._formValues,n,$)}return!c&&s.register(n),m.current=n,()=>{(c?N&&!s._state.action:N)?s.unregister(n):T(n,!1)}},[n,s,c,i]),y.useEffect(()=>{s._setDisabledField({disabled:r,name:n})},[r,n,s]),y.useMemo(()=>({field:M,formState:h,fieldState:b}),[M,h,b])}const Hf=y.createContext(null);Hf.displayName="HookFormContext";var Uf=(e,t,n,r,s)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:s||!0}}:{},Kt=e=>Array.isArray(e)?e:[e],ki=()=>{let e=[];return{get observers(){return e},next:s=>{for(const i of e)i.next&&i.next(s)},subscribe:s=>(e.push(s),{unsubscribe:()=>{e=e.filter(i=>i!==s)}}),unsubscribe:()=>{e=[]}}};function yl(e,t){const n={};for(const r in e)if(e.hasOwnProperty(r)){const s=e[r],i=t[r];if(s&&ye(s)&&i){const a=yl(s,i);ye(a)&&(n[r]=a)}else e[r]&&(n[r]=i)}return n}var je=e=>ye(e)&&!Object.keys(e).length,ys=e=>e.type==="file",Fn=e=>{if(!hs)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},bl=e=>e.type==="select-multiple",bs=e=>e.type==="radio",qf=e=>bs(e)||an(e),pr=e=>Fn(e)&&e.isConnected;function Wf(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=fe(e)?r++:e[t[r++]];return e}function Kf(e){for(const t in e)if(e.hasOwnProperty(t)&&!fe(e[t]))return!1;return!0}function ge(e,t){const n=Array.isArray(t)?t:Jn(t)?[t]:ps(t),r=n.length===1?e:Wf(e,n),s=n.length-1,i=n[s];return r&&delete r[i],s!==0&&(ye(r)&&je(r)||Array.isArray(r)&&Kf(r))&&ge(e,n.slice(0,-1)),e}var Jf=e=>{for(const t in e)if(Me(e[t]))return!0;return!1};function vl(e){return Array.isArray(e)||ye(e)&&!Jf(e)}function Ur(e,t={}){for(const n in e){const r=e[n];vl(r)?(t[n]=Array.isArray(r)?[]:{},Ur(r,t[n])):fe(r)||(t[n]=!0)}return t}function At(e,t,n){n||(n=Ur(t));for(const r in e){const s=e[r];if(vl(s))fe(t)||Hr(n[r])?n[r]=Ur(s,Array.isArray(s)?[]:{}):At(s,Ee(t)?{}:t[r],n[r]);else{const i=t[r];n[r]=!Be(s,i)}}return n}const Ni={value:!1,isValid:!1},Si={value:!0,isValid:!0};var wl=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!fe(e[0].attributes.value)?fe(e[0].value)||e[0].value===""?Si:{value:e[0].value,isValid:!0}:Si:Ni}return Ni},kl=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>fe(e)?e:t?e===""?NaN:e&&+e:n&&$e(e)?new Date(e):r?r(e):e;const Ci={isValid:!1,value:null};var Nl=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,Ci):Ci;function ji(e){const t=e.ref;return ys(t)?t.files:bs(t)?Nl(e.refs).value:bl(t)?[...t.selectedOptions].map(({value:n})=>n):an(t)?wl(e.refs).value:kl(fe(t.value)?e.ref.value:t.value,e)}var Yf=(e,t,n,r)=>{const s={};for(const i of e){const a=z(t,i);a&&le(s,i,a._f)}return{criteriaMode:n,names:[...e],fields:s,shouldUseNativeValidation:r}},Pn=e=>e instanceof RegExp,_t=e=>fe(e)?e:Pn(e)?e.source:ye(e)?Pn(e.value)?e.value.source:e.value:e,Ai=e=>({isOnSubmit:!e||e===ze.onSubmit,isOnBlur:e===ze.onBlur,isOnChange:e===ze.onChange,isOnAll:e===ze.all,isOnTouch:e===ze.onTouched});const Mi="AsyncFunction";var Gf=e=>!!e&&!!e.validate&&!!(Me(e.validate)&&e.validate.constructor.name===Mi||ye(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===Mi)),Qf=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),Ei=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const Jt=(e,t,n,r)=>{for(const s of n||Object.keys(e)){const i=z(e,s);if(i){const{_f:a,...o}=i;if(a){if(a.refs&&a.refs[0]&&t(a.refs[0],s)&&!r)return!0;if(a.ref&&t(a.ref,a.name)&&!r)return!0;if(Jt(o,t))break}else if(ye(o)&&Jt(o,t))break}}};function Ti(e,t,n){const r=z(e,n);if(r||Jn(n))return{error:r,name:n};const s=n.split(".");for(;s.length;){const i=s.join("."),a=z(t,i),o=z(e,i);if(a&&!Array.isArray(a)&&n!==i)return{name:n};if(o&&o.type)return{name:i,error:o};if(o&&o.root&&o.root.type)return{name:`${i}.root`,error:o.root};s.pop()}return{name:n}}var Zf=(e,t,n,r)=>{n(e);const{name:s,...i}=e;return je(i)||Object.keys(i).length>=Object.keys(t).length||Object.keys(i).find(a=>t[a]===(!r||ze.all))},Xf=(e,t,n)=>!e||!t||e===t||Kt(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r))),eh=(e,t,n,r,s)=>s.isOnAll?!1:!n&&s.isOnTouch?!(t||e):(n?r.isOnBlur:s.isOnBlur)?!e:(n?r.isOnChange:s.isOnChange)?e:!0,th=(e,t)=>!ms(z(e,t)).length&&ge(e,t),nh=(e,t,n)=>{const r=Kt(z(e,n));return le(r,"root",t[n]),le(e,n,r),e};function Di(e,t,n="validate"){if($e(e)||Array.isArray(e)&&e.every($e)||De(e)&&!e)return{type:n,message:$e(e)?e:"",ref:t}}var Nt=e=>ye(e)&&!Pn(e)?e:{value:e,message:""},Ii=async(e,t,n,r,s,i)=>{const{ref:a,refs:o,required:c,maxLength:d,minLength:u,min:h,max:p,pattern:m,validate:v,name:b,valueAsNumber:x,mount:w}=e._f,S=z(n,b);if(!w||t.has(b))return{};const M=o?o[0]:a,N=C=>{s&&M.reportValidity&&(M.setCustomValidity(De(C)?"":C||""),M.reportValidity())},j={},T=bs(a),$=an(a),W=T||$,D=(x||ys(a))&&fe(a.value)&&fe(S)||Fn(a)&&a.value===""||S===""||Array.isArray(S)&&!S.length,R=Uf.bind(null,b,r,j),E=(C,I,F,H=We.maxLength,Q=We.minLength)=>{const Y=C?I:F;j[b]={type:C?H:Q,message:Y,ref:a,...R(C?H:Q,Y)}};if(i?!Array.isArray(S)||!S.length:c&&(!W&&(D||Ee(S))||De(S)&&!S||$&&!wl(o).isValid||T&&!Nl(o).isValid)){const{value:C,message:I}=$e(c)?{value:!!c,message:c}:Nt(c);if(C&&(j[b]={type:We.required,message:I,ref:M,...R(We.required,I)},!r))return N(I),j}if(!D&&(!Ee(h)||!Ee(p))){let C,I;const F=Nt(p),H=Nt(h);if(!Ee(S)&&!isNaN(S)){const Q=a.valueAsNumber||S&&+S;Ee(F.value)||(C=Q>F.value),Ee(H.value)||(I=Q<H.value)}else{const Q=a.valueAsDate||new Date(S),Y=ce=>new Date(new Date().toDateString()+" "+ce),te=a.type=="time",oe=a.type=="week";$e(F.value)&&S&&(C=te?Y(S)>Y(F.value):oe?S>F.value:Q>new Date(F.value)),$e(H.value)&&S&&(I=te?Y(S)<Y(H.value):oe?S<H.value:Q<new Date(H.value))}if((C||I)&&(E(!!C,F.message,H.message,We.max,We.min),!r))return N(j[b].message),j}if((d||u)&&!D&&($e(S)||i&&Array.isArray(S))){const C=Nt(d),I=Nt(u),F=!Ee(C.value)&&S.length>+C.value,H=!Ee(I.value)&&S.length<+I.value;if((F||H)&&(E(F,C.message,I.message),!r))return N(j[b].message),j}if(m&&!D&&$e(S)){const{value:C,message:I}=Nt(m);if(Pn(C)&&!S.match(C)&&(j[b]={type:We.pattern,message:I,ref:a,...R(We.pattern,I)},!r))return N(I),j}if(v){if(Me(v)){const C=await v(S,n),I=Di(C,M);if(I&&(j[b]={...I,...R(We.validate,I.message)},!r))return N(I.message),j}else if(ye(v)){let C={};for(const I in v){if(!je(C)&&!r)break;const F=Di(await v[I](S,n),M,I);F&&(C={...F,...R(I,F.message)},N(F.message),r&&(j[b]=C))}if(!je(C)&&(j[b]={ref:M,...C},!r))return j}}return N(!0),j};const rh={mode:ze.onSubmit,reValidateMode:ze.onChange,shouldFocusError:!0};function sh(e={}){let t={...rh,...e},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:Me(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},s=ye(t.defaultValues)||ye(t.values)?pe(t.defaultValues||t.values)||{}:{},i=t.shouldUnregister?{}:pe(s),a={action:!1,mount:!1,watch:!1,keepIsValid:!1},o={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},c,d=0;const u={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},h={...u};let p={...h};const m={array:ki(),state:ki()},v=t.criteriaMode===ze.all,b=g=>k=>{clearTimeout(d),d=setTimeout(g,k)},x=async g=>{if(!a.keepIsValid&&!t.disabled&&(h.isValid||p.isValid||g)){let k;t.resolver?(k=je((await W()).errors),w()):k=await R(r,!0),k!==n.isValid&&m.state.next({isValid:k})}},w=(g,k)=>{!t.disabled&&(h.isValidating||h.validatingFields||p.isValidating||p.validatingFields)&&((g||Array.from(o.mount)).forEach(A=>{A&&(k?le(n.validatingFields,A,k):ge(n.validatingFields,A))}),m.state.next({validatingFields:n.validatingFields,isValidating:!je(n.validatingFields)}))},S=(g,k=[],A,B,L=!0,O=!0)=>{if(B&&A&&!t.disabled){if(a.action=!0,O&&Array.isArray(z(r,g))){const q=A(z(r,g),B.argA,B.argB);L&&le(r,g,q)}if(O&&Array.isArray(z(n.errors,g))){const q=A(z(n.errors,g),B.argA,B.argB);L&&le(n.errors,g,q),th(n.errors,g)}if((h.touchedFields||p.touchedFields)&&O&&Array.isArray(z(n.touchedFields,g))){const q=A(z(n.touchedFields,g),B.argA,B.argB);L&&le(n.touchedFields,g,q)}(h.dirtyFields||p.dirtyFields)&&(n.dirtyFields=At(s,i)),m.state.next({name:g,isDirty:C(g,k),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else le(i,g,k)},M=(g,k)=>{le(n.errors,g,k),m.state.next({errors:n.errors})},N=g=>{n.errors=g,m.state.next({errors:n.errors,isValid:!1})},j=(g,k,A,B)=>{const L=z(r,g);if(L){const O=z(i,g,fe(A)?z(s,g):A);fe(O)||B&&B.defaultChecked||k?le(i,g,k?O:ji(L._f)):H(g,O),a.mount&&!a.action&&x()}},T=(g,k,A,B,L)=>{let O=!1,q=!1;const re={name:g};if(!t.disabled){if(!A||B){(h.isDirty||p.isDirty)&&(q=n.isDirty,n.isDirty=re.isDirty=C(),O=q!==re.isDirty);const se=Be(z(s,g),k);q=!!z(n.dirtyFields,g),se?ge(n.dirtyFields,g):le(n.dirtyFields,g,!0),re.dirtyFields=n.dirtyFields,O=O||(h.dirtyFields||p.dirtyFields)&&q!==!se}if(A){const se=z(n.touchedFields,g);se||(le(n.touchedFields,g,A),re.touchedFields=n.touchedFields,O=O||(h.touchedFields||p.touchedFields)&&se!==A)}O&&L&&m.state.next(re)}return O?re:{}},$=(g,k,A,B)=>{const L=z(n.errors,g),O=(h.isValid||p.isValid)&&De(k)&&n.isValid!==k;if(t.delayError&&A?(c=b(()=>M(g,A)),c(t.delayError)):(clearTimeout(d),c=null,A?le(n.errors,g,A):ge(n.errors,g)),(A?!Be(L,A):L)||!je(B)||O){const q={...B,...O&&De(k)?{isValid:k}:{},errors:n.errors,name:g};n={...n,...q},m.state.next(q)}},W=async g=>(w(g,!0),await t.resolver(i,t.context,Yf(g||o.mount,r,t.criteriaMode,t.shouldUseNativeValidation))),D=async g=>{const{errors:k}=await W(g);if(w(g),g)for(const A of g){const B=z(k,A);B?le(n.errors,A,B):ge(n.errors,A)}else n.errors=k;return k},R=async(g,k,A={valid:!0})=>{for(const B in g){const L=g[B];if(L){const{_f:O,...q}=L;if(O){const re=o.array.has(O.name),se=L._f&&Gf(L._f);se&&h.validatingFields&&w([O.name],!0);const Ce=await Ii(L,o.disabled,i,v,t.shouldUseNativeValidation&&!k,re);if(se&&h.validatingFields&&w([O.name]),Ce[O.name]&&(A.valid=!1,k||e.shouldUseNativeValidation))break;!k&&(z(Ce,O.name)?re?nh(n.errors,Ce,O.name):le(n.errors,O.name,Ce[O.name]):ge(n.errors,O.name))}!je(q)&&await R(q,k,A)}}return A.valid},E=()=>{for(const g of o.unMount){const k=z(r,g);k&&(k._f.refs?k._f.refs.every(A=>!pr(A)):!pr(k._f.ref))&&Ot(g)}o.unMount=new Set},C=(g,k)=>!t.disabled&&(g&&k&&le(i,g,k),!Be(P(),s)),I=(g,k,A)=>Vr(g,o,{...a.mount?i:fe(k)?s:$e(g)?{[g]:k}:k},A,k),F=g=>ms(z(a.mount?i:s,g,t.shouldUnregister?z(s,g,[]):[])),H=(g,k,A={})=>{const B=z(r,g);let L=k;if(B){const O=B._f;O&&(!O.disabled&&le(i,g,kl(k,O)),L=Fn(O.ref)&&Ee(k)?"":k,bl(O.ref)?[...O.ref.options].forEach(q=>q.selected=L.includes(q.value)):O.refs?an(O.ref)?O.refs.forEach(q=>{(!q.defaultChecked||!q.disabled)&&(Array.isArray(L)?q.checked=!!L.find(re=>re===q.value):q.checked=L===q.value||!!L)}):O.refs.forEach(q=>q.checked=q.value===L):ys(O.ref)?O.ref.value="":(O.ref.value=L,O.ref.type||m.state.next({name:g,values:pe(i)})))}(A.shouldDirty||A.shouldTouch)&&T(g,L,A.shouldTouch,A.shouldDirty,!0),A.shouldValidate&&ce(g)},Q=(g,k,A)=>{for(const B in k){if(!k.hasOwnProperty(B))return;const L=k[B],O=g+"."+B,q=z(r,O);(o.array.has(g)||ye(L)||q&&!q._f)&&!mt(L)?Q(O,L,A):H(O,L,A)}},Y=(g,k,A={})=>{const B=z(r,g),L=o.array.has(g),O=pe(k);le(i,g,O),L?(m.array.next({name:g,values:pe(i)}),(h.isDirty||h.dirtyFields||p.isDirty||p.dirtyFields)&&A.shouldDirty&&m.state.next({name:g,dirtyFields:At(s,i),isDirty:C(g,O)})):B&&!B._f&&!Ee(O)?Q(g,O,A):H(g,O,A),Ei(g,o)?m.state.next({...n,name:g,values:pe(i)}):m.state.next({name:a.mount?g:void 0,values:pe(i)})},te=async g=>{a.mount=!0;const k=g.target;let A=k.name,B=!0;const L=z(r,A),O=se=>{B=Number.isNaN(se)||mt(se)&&isNaN(se.getTime())||Be(se,z(i,A,se))},q=Ai(t.mode),re=Ai(t.reValidateMode);if(L){let se,Ce;const lt=k.type?ji(L._f):ml(g),Ge=g.type===Ln.BLUR||g.type===Ln.FOCUS_OUT,jo=!Qf(L._f)&&!t.resolver&&!z(n.errors,A)&&!L._f.deps||eh(Ge,z(n.touchedFields,A),n.isSubmitted,re,q),Gn=Ei(A,o,Ge);le(i,A,lt),Ge?(!k||!k.readOnly)&&(L._f.onBlur&&L._f.onBlur(g),c&&c(0)):L._f.onChange&&L._f.onChange(g);const Qn=T(A,lt,Ge),Ao=!je(Qn)||Gn;if(!Ge&&m.state.next({name:A,type:g.type,values:pe(i)}),jo)return(h.isValid||p.isValid)&&(t.mode==="onBlur"?Ge&&x():Ge||x()),Ao&&m.state.next({name:A,...Gn?{}:Qn});if(!Ge&&Gn&&m.state.next({...n}),t.resolver){const{errors:Ms}=await W([A]);if(w([A]),O(lt),B){const Mo=Ti(n.errors,r,A),Es=Ti(Ms,r,Mo.name||A);se=Es.error,A=Es.name,Ce=je(Ms)}}else w([A],!0),se=(await Ii(L,o.disabled,i,v,t.shouldUseNativeValidation))[A],w([A]),O(lt),B&&(se?Ce=!1:(h.isValid||p.isValid)&&(Ce=await R(r,!0)));B&&(L._f.deps&&(!Array.isArray(L._f.deps)||L._f.deps.length>0)&&ce(L._f.deps),$(A,Ce,se,Qn))}},oe=(g,k)=>{if(z(n.errors,k)&&g.focus)return g.focus(),1},ce=async(g,k={})=>{let A,B;const L=Kt(g);if(t.resolver){const O=await D(fe(g)?g:L);A=je(O),B=g?!L.some(q=>z(O,q)):A}else g?(B=(await Promise.all(L.map(async O=>{const q=z(r,O);return await R(q&&q._f?{[O]:q}:q)}))).every(Boolean),!(!B&&!n.isValid)&&x()):B=A=await R(r);return m.state.next({...!$e(g)||(h.isValid||p.isValid)&&A!==n.isValid?{}:{name:g},...t.resolver||!g?{isValid:A}:{},errors:n.errors}),k.shouldFocus&&!B&&Jt(r,oe,g?L:o.mount),B},P=(g,k)=>{let A={...a.mount?i:s};return k&&(A=yl(k.dirtyFields?n.dirtyFields:n.touchedFields,A)),fe(g)?A:$e(g)?z(A,g):g.map(B=>z(A,B))},_=(g,k)=>({invalid:!!z((k||n).errors,g),isDirty:!!z((k||n).dirtyFields,g),error:z((k||n).errors,g),isValidating:!!z(n.validatingFields,g),isTouched:!!z((k||n).touchedFields,g)}),G=g=>{g&&Kt(g).forEach(k=>ge(n.errors,k)),m.state.next({errors:g?n.errors:{}})},ne=(g,k,A)=>{const B=(z(r,g,{_f:{}})._f||{}).ref,L=z(n.errors,g)||{},{ref:O,message:q,type:re,...se}=L;le(n.errors,g,{...se,...k,ref:B}),m.state.next({name:g,errors:n.errors,isValid:!1}),A&&A.shouldFocus&&B&&B.focus&&B.focus()},Se=(g,k)=>Me(g)?m.state.subscribe({next:A=>"values"in A&&g(I(void 0,k),A)}):I(g,k,!0),at=g=>m.state.subscribe({next:k=>{Xf(g.name,k.name,g.exact)&&Zf(k,g.formState||h,Co,g.reRenderRoot)&&g.callback({values:{...i},...n,...k,defaultValues:s})}}).unsubscribe,$t=g=>(a.mount=!0,p={...p,...g.formState},at({...g,formState:{...u,...g.formState}})),Ot=(g,k={})=>{for(const A of g?Kt(g):o.mount)o.mount.delete(A),o.array.delete(A),k.keepValue||(ge(r,A),ge(i,A)),!k.keepError&&ge(n.errors,A),!k.keepDirty&&ge(n.dirtyFields,A),!k.keepTouched&&ge(n.touchedFields,A),!k.keepIsValidating&&ge(n.validatingFields,A),!t.shouldUnregister&&!k.keepDefaultValue&&ge(s,A);m.state.next({values:pe(i)}),m.state.next({...n,...k.keepDirty?{isDirty:C()}:{}}),!k.keepIsValid&&x()},on=({disabled:g,name:k})=>{if(De(g)&&a.mount||g||o.disabled.has(k)){const L=o.disabled.has(k)!==!!g;g?o.disabled.add(k):o.disabled.delete(k),L&&a.mount&&!a.action&&x()}},Lt=(g,k={})=>{let A=z(r,g);const B=De(k.disabled)||De(t.disabled);return le(r,g,{...A||{},_f:{...A&&A._f?A._f:{ref:{name:g}},name:g,mount:!0,...k}}),o.mount.add(g),A?on({disabled:De(k.disabled)?k.disabled:t.disabled,name:g}):j(g,!0,k.value),{...B?{disabled:k.disabled||t.disabled}:{},...t.progressive?{required:!!k.required,min:_t(k.min),max:_t(k.max),minLength:_t(k.minLength),maxLength:_t(k.maxLength),pattern:_t(k.pattern)}:{},name:g,onChange:te,onBlur:te,ref:L=>{if(L){Lt(g,k),A=z(r,g);const O=fe(L.value)&&L.querySelectorAll&&L.querySelectorAll("input,select,textarea")[0]||L,q=qf(O),re=A._f.refs||[];if(q?re.find(se=>se===O):O===A._f.ref)return;le(r,g,{_f:{...A._f,...q?{refs:[...re.filter(pr),O,...Array.isArray(z(s,g))?[{}]:[]],ref:{type:O.type,name:g}}:{ref:O}}}),j(g,!1,void 0,O)}else A=z(r,g,{}),A._f&&(A._f.mount=!1),(t.shouldUnregister||k.shouldUnregister)&&!(pl(o.array,g)&&a.action)&&o.unMount.add(g)}}},Ft=()=>t.shouldFocusError&&Jt(r,oe,o.mount),cn=g=>{De(g)&&(m.state.next({disabled:g}),Jt(r,(k,A)=>{const B=z(r,A);B&&(k.disabled=B._f.disabled||g,Array.isArray(B._f.refs)&&B._f.refs.forEach(L=>{L.disabled=B._f.disabled||g}))},0,!1))},Pt=(g,k)=>async A=>{let B;A&&(A.preventDefault&&A.preventDefault(),A.persist&&A.persist());let L=pe(i);if(m.state.next({isSubmitting:!0}),t.resolver){const{errors:O,values:q}=await W();w(),n.errors=O,L=pe(q)}else await R(r);if(o.disabled.size)for(const O of o.disabled)ge(L,O);if(ge(n.errors,"root"),je(n.errors)){m.state.next({errors:{}});try{await g(L,A)}catch(O){B=O}}else k&&await k({...n.errors},A),Ft(),setTimeout(Ft);if(m.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:je(n.errors)&&!B,submitCount:n.submitCount+1,errors:n.errors}),B)throw B},wt=(g,k={})=>{z(r,g)&&(fe(k.defaultValue)?Y(g,pe(z(s,g))):(Y(g,k.defaultValue),le(s,g,pe(k.defaultValue))),k.keepTouched||ge(n.touchedFields,g),k.keepDirty||(ge(n.dirtyFields,g),n.isDirty=k.defaultValue?C(g,pe(z(s,g))):C()),k.keepError||(ge(n.errors,g),h.isValid&&x()),m.state.next({...n}))},ue=(g,k={})=>{const A=g?pe(g):s,B=pe(A),L=je(g),O=L?s:B;if(k.keepDefaultValues||(s=A),!k.keepValues){if(k.keepDirtyValues){const q=new Set([...o.mount,...Object.keys(At(s,i))]);for(const re of Array.from(q)){const se=z(n.dirtyFields,re),Ce=z(i,re),lt=z(O,re);se&&!fe(Ce)?le(O,re,Ce):!se&&!fe(lt)&&Y(re,lt)}}else{if(hs&&fe(g))for(const q of o.mount){const re=z(r,q);if(re&&re._f){const se=Array.isArray(re._f.refs)?re._f.refs[0]:re._f.ref;if(Fn(se)){const Ce=se.closest("form");if(Ce){Ce.reset();break}}}}if(k.keepFieldsRef)for(const q of o.mount)Y(q,z(O,q));else r={}}i=t.shouldUnregister?k.keepDefaultValues?pe(s):{}:pe(O),m.array.next({values:{...O}}),m.state.next({values:{...O}})}o={mount:k.keepDirtyValues?o.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},a.mount=!h.isValid||!!k.keepIsValid||!!k.keepDirtyValues||!t.shouldUnregister&&!je(O),a.watch=!!t.shouldUnregister,a.keepIsValid=!!k.keepIsValid,a.action=!1,k.keepErrors||(n.errors={}),m.state.next({submitCount:k.keepSubmitCount?n.submitCount:0,isDirty:L?!1:k.keepDirty?n.isDirty:!!(k.keepDefaultValues&&!Be(g,s)),isSubmitted:k.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:L?{}:k.keepDirtyValues?k.keepDefaultValues&&i?At(s,i):n.dirtyFields:k.keepDefaultValues&&g?At(s,g):k.keepDirty?n.dirtyFields:{},touchedFields:k.keepTouched?n.touchedFields:{},errors:k.keepErrors?n.errors:{},isSubmitSuccessful:k.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:s})},Te=(g,k)=>ue(Me(g)?g(i):g,{...t.resetOptions,...k}),So=(g,k={})=>{const A=z(r,g),B=A&&A._f;if(B){const L=B.refs?B.refs[0]:B.ref;L.focus&&setTimeout(()=>{L.focus(),k.shouldSelect&&Me(L.select)&&L.select()})}},Co=g=>{n={...n,...g}},As={control:{register:Lt,unregister:Ot,getFieldState:_,handleSubmit:Pt,setError:ne,_subscribe:at,_runSchema:W,_updateIsValidating:w,_focusError:Ft,_getWatch:I,_getDirty:C,_setValid:x,_setFieldArray:S,_setDisabledField:on,_setErrors:N,_getFieldArray:F,_reset:ue,_resetDefaultValues:()=>Me(t.defaultValues)&&t.defaultValues().then(g=>{Te(g,t.resetOptions),m.state.next({isLoading:!1})}),_removeUnmounted:E,_disableForm:cn,_subjects:m,_proxyFormState:h,get _fields(){return r},get _formValues(){return i},get _state(){return a},set _state(g){a=g},get _defaultValues(){return s},get _names(){return o},set _names(g){o=g},get _formState(){return n},get _options(){return t},set _options(g){t={...t,...g}}},subscribe:$t,trigger:ce,register:Lt,handleSubmit:Pt,watch:Se,setValue:Y,getValues:P,reset:Te,resetField:wt,clearErrors:G,unregister:Ot,setError:ne,setFocus:So,getFieldState:_};return{...As,formControl:As}}function ih(e={}){const t=y.useRef(void 0),n=y.useRef(void 0),[r,s]=y.useState({isDirty:!1,isValidating:!1,isLoading:Me(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:Me(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:r},e.defaultValues&&!Me(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:a,...o}=sh(e);t.current={...o,formState:r}}const i=t.current.control;return i._options=e,xs(()=>{const a=i._subscribe({formState:i._proxyFormState,callback:()=>s({...i._formState}),reRenderRoot:!0});return s(o=>({...o,isReady:!0})),i._formState.isReady=!0,a},[i]),y.useEffect(()=>i._disableForm(e.disabled),[i,e.disabled]),y.useEffect(()=>{e.mode&&(i._options.mode=e.mode),e.reValidateMode&&(i._options.reValidateMode=e.reValidateMode)},[i,e.mode,e.reValidateMode]),y.useEffect(()=>{e.errors&&(i._setErrors(e.errors),i._focusError())},[i,e.errors]),y.useEffect(()=>{e.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,e.shouldUnregister]),y.useEffect(()=>{if(i._proxyFormState.isDirty){const a=i._getDirty();a!==r.isDirty&&i._subjects.state.next({isDirty:a})}},[i,r.isDirty]),y.useEffect(()=>{var a;e.values&&!Be(e.values,n.current)?(i._reset(e.values,{keepFieldsRef:!0,...i._options.resetOptions}),!((a=i._options.resetOptions)===null||a===void 0)&&a.keepIsValid||i._setValid(),n.current=e.values,s(o=>({...o}))):i._resetDefaultValues()},[i,e.values]),y.useEffect(()=>{i._state.mount||(i._setValid(),i._state.mount=!0),i._state.watch&&(i._state.watch=!1,i._subjects.state.next({...i._formState})),i._removeUnmounted()}),t.current.formState=y.useMemo(()=>xl(r,i),[i,r]),t.current}function ah(e,t=3){return e%1===0?e.toString():e.toFixed(t).replace(/\.?0+$/,"")}function lh(e,t="en-US",n="USD"){try{return new Intl.NumberFormat(t,{style:"currency",currency:n,minimumFractionDigits:2,maximumFractionDigits:2}).format(e)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${e.toFixed(2)}`}}function oh(e="USD",t="en-US"){try{return new Intl.NumberFormat(t,{style:"currency",currency:e}).formatToParts(0).find(i=>i.type==="currency")?.value??"$"}catch{return"$"}}function ch(e){const t=e.replace(/[^\d.,-]/g,""),n=t.match(/,\d{1,2}$/);let r;n?r=t.replace(/\./g,"").replace(",","."):r=t.replace(/,/g,"");const s=parseFloat(r);return isNaN(s)?null:s}function dh(e,t,n=.001){const r=e-t,s=Math.abs(r)<=n;return{difference:r,isBalanced:s,isUnderAllocated:!s&&r>0,isOverAllocated:!s&&r<0}}function vs(){return`dist-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}vs();const uh={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:"$"},gr=()=>({id:vs(),amount:0,glAccount:null,isTaxDeductible:!1}),Sl=({distribution:e,defaultDistribution:t,glAccounts:n=[],isLoadingGlAccounts:r=!1,onSearchGlAccounts:s,onDistributionChange:i,onAmountChange:a,onGlAccountChange:o,onTaxDeductibleChange:c,onDelete:d,canDelete:u=!0,canEditTaxDeductible:h=!0,isDisabled:p=!1,labels:m,classNames:v={},"data-testid":b,control:x,name:w,rules:S})=>{const M={...uh,...m},N=x!==void 0&&w!==void 0,j=ih({defaultValues:{_internal:t||gr()}}),T=Vf({control:N?x:j.control,name:N?w:"_internal",rules:N?S:void 0}),[$,W]=y.useState(t||gr()),D=N?T.field.value??gr():e??$,R=N&&!!T.fieldState?.error,E=N&&(T.fieldState?.isTouched??!1),C=R||E,I=C&&(!D.amount||D.amount<=0),F=C&&!D.glAccount,[H,Q]=y.useState(D.glAccount?.name||""),Y=y.useCallback(ne=>{const Se={...D,...ne};N&&T.field.onChange(Se),!N&&e===void 0&&W(Se),i?.(Se)},[D,e,i,N,T]),te=y.useCallback(ne=>{const Se=ne||0;Y({amount:Se}),a?.(Se)},[Y,a]),oe=y.useCallback(ne=>{Q(ne),s?.(ne)},[s]),ce=y.useCallback(ne=>{if(ne===null){Y({glAccount:null}),o?.(null);return}const at=n.find($t=>String($t.id)===String(ne))||null;Y({glAccount:at}),o?.(at)},[n,Y,o]),P=y.useCallback(()=>{Q(""),Y({glAccount:null}),o?.(null)},[Y,o]),_=y.useCallback(ne=>{Y({isTaxDeductible:ne}),c?.(ne)},[Y,c]),G=y.useCallback(()=>{d?.()},[d]);return l.jsx(f.Card,{radius:"md",shadow:"sm","data-testid":b||"revenue-distribution-card",className:f.cn(v.base),children:l.jsxs(f.CardBody,{className:f.cn("flex flex-row flex-nowrap items-start gap-4",v.body),children:[l.jsx("div",{className:f.cn("shrink-0",v.amountContainer),children:l.jsx(f.NumberInput,{"data-testid":`${b||"revenue-distribution-card"}-amount-input`,label:l.jsxs("span",{className:"flex items-center gap-1",children:[M.amount,l.jsx(f.Tooltip,{content:M.amountTooltip,children:l.jsx(U,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),value:D.amount||void 0,onValueChange:te,labelPlacement:"outside",placeholder:M.amountPlaceholder,isWheelDisabled:!0,hideStepper:!0,variant:"bordered",isDisabled:p,isInvalid:I,errorMessage:I?"Amount is required":void 0,minValue:0,step:.01,className:v.amountInput,startContent:l.jsx("div",{className:"pointer-events-none flex items-center",children:l.jsx("span",{className:"text-default-400 text-small",children:M.currencySymbol})})})}),l.jsx("div",{className:f.cn("grow",v.glAccountContainer),children:l.jsx(f.Autocomplete,{"data-testid":`${b||"revenue-distribution-card"}-gl-account-input`,label:l.jsxs("span",{className:"flex items-center gap-1",children:[M.glAccount,l.jsx(f.Tooltip,{content:M.glAccountTooltip,children:l.jsx(U,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),isLoading:r,isClearable:!0,labelPlacement:"outside",variant:"bordered",items:n,menuTrigger:"input",inputValue:D.glAccount?.name??H,selectedKey:D.glAccount?.id??null,isDisabled:p,isInvalid:F,errorMessage:F?"GL Account is required":void 0,listboxProps:{emptyContent:r?M.searching:M.noGlAccountsFound},placeholder:M.glAccountPlaceholder,onInputChange:oe,onSelectionChange:ce,onClear:P,className:v.glAccountInput,children:ne=>l.jsx(f.AutocompleteItem,{textValue:ne.name,children:l.jsxs("div",{className:"flex flex-col",children:[l.jsx("span",{children:ne.name}),ne.code&&l.jsx("span",{className:"text-xs text-default-400",children:ne.code})]})},ne.id)})}),l.jsx("div",{className:f.cn("shrink-0 pt-6 flex items-center",v.taxDeductibleContainer),children:l.jsx(f.Checkbox,{radius:"full","data-testid":`${b||"revenue-distribution-card"}-tax-deductible`,isSelected:D.isTaxDeductible,onValueChange:_,isDisabled:p||!h,className:v.taxDeductibleCheckbox,children:M.taxDeductible})}),l.jsx("div",{className:f.cn("shrink-0 pt-6",v.deleteContainer),children:l.jsx(K,{"data-testid":`${b||"revenue-distribution-card"}-delete-button`,size:"sm",color:"danger",variant:"flat",isDisabled:p||!u,onPress:G,startContent:l.jsx(U,{icon:"solar:trash-bin-trash-linear",width:16}),className:f.cn("text-danger",v.deleteButton),children:M.deleteButton})})]})})};Sl.displayName="RevenueDistributionCard";const Cl=({message:e="No distributions configured",icon:t="solar:document-text-outline",iconSize:n=48,showCard:r=!0,classNames:s={},renderEmpty:i})=>{if(i)return l.jsx(l.Fragment,{children:i()});const a=l.jsxs("div",{className:f.cn("flex flex-col items-center justify-center py-8",s.content),children:[l.jsx(U,{icon:t,width:n,className:f.cn("text-default-300 mb-4",s.icon)}),l.jsx("p",{className:f.cn("text-default-500 text-sm text-center",s.message),children:e})]});return r?l.jsx(f.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-empty",className:f.cn("w-full",s.base),children:l.jsx(f.CardBody,{children:a})}):l.jsx("div",{"data-testid":"revenue-distribution-empty",className:f.cn("w-full",s.base),children:a})};Cl.displayName="RevenueDistributionEmpty";const fh={title:"Error Loading Distributions",description:"An error occurred while loading the distribution configuration. Please try again."},jl=({error:e,labels:t,showCard:n=!0,color:r="danger",classNames:s={}})=>{const i={...fh,...t},a=l.jsx(f.Alert,{"data-testid":"revenue-distribution-error-alert",color:r,title:i.title,description:e||i.description,className:s.alert});return n?l.jsx(f.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-error",className:f.cn("w-full",s.base),children:l.jsx(f.CardBody,{children:a})}):l.jsx("div",{"data-testid":"revenue-distribution-error",className:f.cn("w-full",s.base),children:a})};jl.displayName="RevenueDistributionError";const Al=({rows:e=1,showCard:t=!0,classNames:n={}})=>{const r=Array.from({length:e},(i,a)=>a),s=i=>l.jsxs("div",{className:f.cn("flex flex-row flex-nowrap items-end gap-4",n.row),children:[l.jsxs("div",{className:"shrink-0 flex flex-col gap-1",children:[l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(f.Skeleton,{className:"h-4 w-14 rounded-md"}),l.jsx(f.Skeleton,{className:"h-4 w-4 rounded-full"})]}),l.jsx(f.Skeleton,{className:"h-10 w-32 rounded-lg"})]}),l.jsxs("div",{className:"grow flex flex-col gap-1",children:[l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(f.Skeleton,{className:"h-4 w-20 rounded-md"}),l.jsx(f.Skeleton,{className:"h-4 w-4 rounded-full"})]}),l.jsx(f.Skeleton,{className:"h-10 w-full rounded-lg"})]}),l.jsxs("div",{className:"shrink-0 pb-2 flex items-center gap-2",children:[l.jsx(f.Skeleton,{className:"h-5 w-5 rounded-full"}),l.jsx(f.Skeleton,{className:"h-4 w-24 rounded-md"})]}),l.jsx("div",{className:"shrink-0 pb-2",children:l.jsx(f.Skeleton,{className:"h-8 w-20 rounded-lg"})})]},i);return t?l.jsx("div",{className:f.cn("flex flex-col gap-3",n.base),children:r.map(i=>l.jsx(f.Card,{radius:"md",shadow:"sm","data-testid":`revenue-distribution-skeleton-${i}`,children:l.jsx(f.CardBody,{children:s(i)})},i))}):l.jsx("div",{"data-testid":"revenue-distribution-skeleton",className:f.cn("flex flex-col gap-3",n.base),children:r.map(i=>s(i))})};Al.displayName="RevenueDistributionSkeleton";function Rn({isOpen:e,labels:t,icon:n,isConfirming:r=!1,confirmColor:s="danger",iconTone:i="danger",onClose:a,onConfirm:o}){return l.jsx(f.Modal,{isOpen:e,size:"md",placement:"center",classNames:{base:"max-w-[440px] rounded-3xl",closeButton:"right-5 top-5 text-zinc-500"},onOpenChange:c=>!c&&a(),children:l.jsxs(f.ModalContent,{children:[l.jsxs(f.ModalHeader,{className:"flex flex-col items-start gap-4 px-7 pb-0 pt-7",children:[n&&l.jsx("span",{className:f.cn("flex h-12 w-12 shrink-0 items-center justify-center rounded-full",i==="warning"?"bg-brand/15 text-brand":"bg-danger-100 text-danger-600"),children:n}),l.jsx("span",{className:"text-lg font-semibold leading-6 text-zinc-950",children:t.title})]}),l.jsx(f.ModalBody,{className:"px-7 pb-3 pt-4",children:l.jsx("div",{className:"text-sm leading-6 text-zinc-500",children:t.description})}),l.jsxs(f.ModalFooter,{className:"grid grid-cols-2 gap-3 px-7 pb-7 pt-3",children:[l.jsx(K,{type:"button",variant:"bordered",radius:"full",className:"h-10 border-zinc-200 bg-white text-sm font-normal text-zinc-900",onPress:a,children:t.cancel}),l.jsx(K,{type:"button",color:s,radius:"full",className:f.cn("h-10 text-sm font-normal text-white",s==="danger"?"bg-danger-600":"bg-brand"),isLoading:r,onPress:o,children:t.confirm})]})]})})}const hh={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 at least two funds and assign percentages that total 100%",selectedFund:"Selected fund",percentage:"Percentage",total:"Total",totalError:"Percentages must 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"},Ml={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"},Vt={...Ml,base:"min-h-11 rounded-2xl px-4 py-2 shadow-none",title:"text-sm font-medium"},mh={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"},$i=()=>({id:crypto.randomUUID(),fund:null,percentage:0}),ph=e=>Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e*100)/100)):0,gh=e=>e.fund!==null;function xh({mode:e,assignments:t,funds:n,labels:r,classNames:s,isSaving:i=!1,hasSavedAssignments:a=!1,isFundPickerOpen:o=!1,activeAssignmentId:c=null,footer:d,onModeChange:u,onAssignmentsChange:h,onOpenFundPicker:p,onCloseFundPicker:m,onCollapseChange:v,onSave:b}){const x={...hh,...r},w=t.filter(gh),S=w.length>0,M=y.useMemo(()=>t.reduce((P,_)=>P+Number(_.percentage||0),0),[t]),N=Math.round(M*100)/100,j=e==="split"&&t.some(P=>!P.fund||Number(P.percentage||0)<=0),T=e==="split"&&S&&(N!==100||j),$=e==="split"&&S&&N>=100,W=e==="split"||!S,[D,R]=y.useState(null),[E,C]=y.useState(!1),I=P=>{if(P!==e){if(P==="single"){const _=w[0]?.fund??null;h([{id:t[0]?.id??crypto.randomUUID(),fund:_,percentage:_?100:0}])}else{const _=w[0];h([{id:_?.id??crypto.randomUUID(),fund:_?.fund??null,percentage:_?.fund?50:0},$i()])}u(P)}},F=(P,_)=>{h(t.map(G=>G.id===P?{...G,..._}:G))},H=()=>{$||h([...t,$i()])},Q=P=>{if(!(t.length<=2)){if(!a){h(t.filter(_=>_.id!==P));return}R(P)}},Y=()=>{if(!D||t.length<=2){R(null);return}h(t.filter(P=>P.id!==D)),R(null)},te=()=>{if(!i){if(!a){b();return}C(!0)}},oe=()=>{C(!1),b()},ce=P=>{const _=c??t.find(G=>!G.fund)?.id??t[0]?.id;_&&(h(t.map(G=>G.id===_?{...G,fund:P,percentage:e==="single"?100:G.percentage}:G)),m())};return l.jsxs("div",{className:f.cn("vvt-pa font-sans text-zinc-900",s?.root),children:[l.jsx(f.Accordion,{variant:"splitted",defaultSelectedKeys:["installment-fund-assignment"],className:f.cn("w-full gap-0 px-0",s?.panel),itemClasses:{base:"w-full rounded-2xl border border-zinc-200 bg-white p-0 shadow-sm",trigger:f.cn("px-4 py-4",s?.header),title:"text-xl font-semibold leading-8 text-zinc-900",content:"w-full px-4 pb-4 pt-0",indicator:"text-zinc-500"},onSelectionChange:P=>v?.(!(P==="all"||Array.from(P).length>0)),children:l.jsx(f.AccordionItem,{"aria-label":x.title,title:x.title,children:l.jsxs("div",{className:f.cn("flex w-full flex-col gap-4",s?.content),children:[l.jsxs("div",{className:"flex w-full items-center justify-between gap-6",children:[l.jsx(yh,{mode:e,labels:x,onModeChange:I,className:s?.tabs}),l.jsx(K,{type:"button",size:"sm",color:"primary",radius:"full",className:"ml-auto h-9 min-w-40 bg-brand px-4 text-sm font-medium text-white",startContent:l.jsx(U,{icon:"solar:cloud-upload-outline",className:"size-4"}),isLoading:i,onPress:te,children:x.saveAssignment})]}),l.jsxs("div",{className:"flex w-full flex-col gap-4",children:[!S&&l.jsx(f.Alert,{icon:l.jsx(U,{icon:"solar:info-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,classNames:Ml,color:"default",variant:"flat",title:e==="single"?x.emptySingle:x.emptySplit}),S&&l.jsx(bh,{mode:e,assignments:t,labels:x,total:M,hasTotalError:T,onSelectFund:P=>p(P),onRemoveFund:Q,onPercentageChange:(P,_)=>F(P,{percentage:ph(_)})}),W&&l.jsx("div",{className:"flex flex-wrap gap-3",children:l.jsx(K,{type:"button",color:"default",radius:"full",className:"h-11 bg-zinc-950 px-4 text-base font-normal text-white disabled:opacity-50",startContent:l.jsx(J.Plus,{className:"size-5",strokeWidth:2}),isDisabled:$,onPress:()=>e==="split"&&S?H():p(),children:e==="split"&&S?x.addFund:x.assignSpecificFund})})]}),d]})},"installment-fund-assignment")}),o&&l.jsx(vh,{funds:n,labels:x,selectedFundIds:t.map(P=>P.fund?.id).filter(Boolean),onSelect:ce,onClose:m}),l.jsx(Rn,{isOpen:E,labels:{title:x.modifyAssignedFundsTitle,description:l.jsxs(l.Fragment,{children:[l.jsx("p",{children:x.modifyAssignedFundsDescription}),l.jsx("p",{className:"mt-3",children:x.modifyAssignedFundsWarning})]}),cancel:x.modifyAssignedFundsCancel,confirm:x.modifyAssignedFundsConfirm},icon:l.jsx(U,{icon:"solar:info-circle-outline",className:"size-7"}),iconTone:"warning",confirmColor:"primary",onClose:()=>C(!1),onConfirm:oe}),l.jsx(Rn,{isOpen:D!==null,labels:{title:x.modifyAssignedFundsTitle,description:l.jsxs(l.Fragment,{children:[l.jsx("p",{children:x.modifyAssignedFundsDescription}),l.jsx("p",{className:"mt-3",children:x.modifyAssignedFundsWarning})]}),cancel:x.modifyAssignedFundsCancel,confirm:x.modifyAssignedFundsConfirm},icon:l.jsx(U,{icon:"solar:info-circle-outline",className:"size-7"}),iconTone:"warning",confirmColor:"primary",onClose:()=>R(null),onConfirm:Y})]})}function yh({mode:e,labels:t,className:n,onModeChange:r}){return l.jsxs(f.Tabs,{"aria-label":t.title,selectedKey:e,radius:"full",size:"sm",variant:"light",className:f.cn("w-fit",n),classNames:{base:"w-fit",tabList:"h-10 w-fit rounded-full bg-zinc-200 p-1",tab:"h-8 w-auto rounded-full px-5 text-sm font-normal",cursor:"rounded-full bg-white shadow-sm",tabContent:"text-zinc-500 group-data-[selected=true]:text-zinc-900",panel:"hidden"},onSelectionChange:s=>r(s),children:[l.jsx(f.Tab,{title:t.singleFund},"single"),l.jsx(f.Tab,{title:t.splitFunds},"split")]})}function bh({mode:e,assignments:t,labels:n,total:r,hasTotalError:s,onSelectFund:i,onRemoveFund:a,onPercentageChange:o}){return l.jsxs("div",{className:"flex flex-col gap-3",children:[t.map((c,d)=>l.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:[l.jsx("div",{className:f.cn("flex min-h-11 min-w-0 flex-1 items-center",c.fund&&e==="single"?"justify-between":"gap-4"),children:c.fund?l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:"rounded-full bg-zinc-100 px-4 py-1.5 text-sm text-zinc-950",children:[c.fund.glCode," - ",c.fund.accountName]}),l.jsx(K,{type:"button",variant:"light",radius:"full",className:"px-2 text-sm font-normal text-brand",onPress:()=>i(c.id),children:"Replace"})]}):l.jsx(K,{type:"button",variant:"light",radius:"full",className:"justify-start px-4 text-base font-normal text-zinc-900",startContent:l.jsx(J.Plus,{className:"size-5",strokeWidth:2}),onPress:()=>i(c.id),children:n.assignSpecificFund})}),e==="split"&&l.jsx("label",{className:"flex w-48 flex-none items-center",children:l.jsx(f.Input,{variant:"bordered",type:"number",min:0,max:100,step:.01,value:String(c.percentage||""),onChange:u=>o(c.id,Number(u.target.value)),endContent:l.jsx("span",{className:"text-sm text-zinc-500",children:"%"}),classNames:mh})}),e==="split"&&t.length>2&&l.jsx(K,{type:"button",isIconOnly:!0,variant:"flat",radius:"full",className:f.cn("h-10 w-10 flex-none p-0",d<2?"bg-danger-100 text-danger-500 opacity-60":"bg-danger-600 text-white"),style:{height:40,minWidth:40,width:40},isDisabled:d<2,onPress:()=>a(c.id),"aria-label":n.removeFund,children:l.jsx(U,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"})})]},c.id)),e==="split"&&l.jsx(f.Alert,{icon:l.jsx(U,{icon:s?"solar:info-circle-outline":"solar:check-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,color:s?"warning":"success",variant:"flat",classNames:{...Vt,base:f.cn(Vt.base,s?"bg-warning-50 text-warning-700":"bg-success-50 text-success-700"),iconWrapper:f.cn(Vt.iconWrapper,s?"text-warning-700":"text-success-700"),alertIcon:f.cn(Vt.alertIcon,s?"text-warning-700":"text-success-700"),title:f.cn(Vt.title,s?"text-warning-700":"text-success-700")},title:s?`${n.totalError} (${n.total} ${Number(r.toFixed(2))}%)`:`${n.total} ${Number(r.toFixed(2))}%`})]})}function vh({funds:e,labels:t,selectedFundIds:n,onSelect:r,onClose:s}){const[i,a]=y.useState(""),o=e.filter(c=>{const d=i.trim().toLowerCase();return d?`${c.glCode} ${c.accountName} ${c.type}`.toLowerCase().includes(d):!0});return l.jsx(f.Modal,{isOpen:!0,size:"3xl",placement:"center",scrollBehavior:"inside",classNames:{base:"max-w-3xl rounded-3xl",closeButton:"right-6 top-6 text-zinc-500"},onOpenChange:c=>!c&&s(),children:l.jsxs(f.ModalContent,{children:[l.jsx(f.ModalHeader,{className:"px-6 pt-6 text-xl font-semibold leading-7 text-zinc-950",children:t.modalTitle}),l.jsxs(f.ModalBody,{className:"px-6 pb-6",children:[l.jsx(f.Input,{variant:"bordered","aria-label":t.searchPlaceholder,value:i,placeholder:t.searchPlaceholder,onChange:c=>a(c.target.value),startContent:l.jsx(U,{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"}}),l.jsxs("div",{className:"mt-4 overflow-auto",children:[l.jsxs("div",{className:"grid grid-cols-[1fr_1.1fr_0.55fr_0.6fr] gap-5 border-b border-zinc-200 px-3 pb-3 text-sm font-medium leading-5 text-zinc-900",children:[l.jsx("span",{children:t.glCode}),l.jsx("span",{children:t.accountName}),l.jsx("span",{children:t.type}),l.jsx("span",{children:t.actions})]}),o.length===0&&l.jsx("div",{className:"p-4 text-sm text-zinc-500",children:t.noFunds}),o.map(c=>{const d=n.includes(c.id);return l.jsxs("div",{className:"grid grid-cols-[1fr_1.1fr_0.55fr_0.6fr] items-center gap-5 px-3 py-2.5 text-sm leading-5 text-zinc-900",children:[l.jsx("span",{children:c.glCode}),l.jsx("span",{children:c.accountName}),c.type?l.jsx("span",{className:"w-fit rounded-full bg-warning-50 px-3 py-1 text-sm font-medium text-warning-500",children:c.type}):l.jsx("span",{className:"text-sm text-zinc-400",children:"-"}),l.jsx(K,{type:"button",variant:"bordered",radius:"full",className:"h-9 min-w-24 border-zinc-200 bg-white text-sm font-medium text-zinc-900",isDisabled:d,onPress:()=>r(c),children:t.select})]},c.id)})]})]})]})})}function wh(){return l.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:[l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsx(f.Skeleton,{className:"h-7 w-56 rounded-lg"}),l.jsx(f.Skeleton,{className:"size-8 rounded-full"})]}),l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsx(f.Skeleton,{className:"h-10 w-72 rounded-full"}),l.jsx(f.Skeleton,{className:"h-10 w-40 rounded-full"})]}),l.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_160px] items-center gap-4 rounded-2xl border border-zinc-100 p-3",children:[l.jsx(f.Skeleton,{className:"h-8 w-full max-w-xs rounded-full"}),l.jsx(f.Skeleton,{className:"h-8 w-full rounded-xl"})]}),l.jsx(f.Skeleton,{className:"h-11 w-40 rounded-full"})]})}const kh={totalAmount:"Total Amount:",remainingBalance:"Remaining Balance",amountReceived:"Amount Received:"};function Nh({totalAmount:e,remainingBalance:t,amountReceived:n,currency:r="USD",locale:s="en-US",labels:i,className:a}){const o={...kh,...i},c=new Intl.NumberFormat(s,{style:"currency",currency:r});return l.jsx("div",{className:f.cn("w-full rounded-2xl border border-zinc-200 bg-white px-4 py-2.5 font-sans text-base leading-6",a),children:l.jsxs("div",{className:"flex w-full flex-wrap items-center gap-x-5 gap-y-2",children:[l.jsx(xr,{label:o.totalAmount,value:c.format(e)}),l.jsx(xr,{label:o.remainingBalance,value:c.format(t)}),l.jsx(xr,{label:o.amountReceived,value:c.format(n)})]})})}function xr({label:e,value:t}){return l.jsxs("div",{className:"flex items-center gap-3 whitespace-nowrap",children:[l.jsx("span",{className:"font-medium text-zinc-700",children:e}),l.jsx("span",{className:"font-normal text-zinc-950",children:t})]})}function yr(e,t){return e-t*Math.floor(e/t)}const El=1721426;function pn(e,t,n,r){t=ws(e,t);let s=t-1,i=-2;return n<=2?i=0:kn(t)&&(i=-1),El-1+365*s+Math.floor(s/4)-Math.floor(s/100)+Math.floor(s/400)+Math.floor((367*n-362)/12+i+r)}function kn(e){return e%4===0&&(e%100!==0||e%400===0)}function ws(e,t){return e==="BC"?1-t:t}function Sh(e){let t="AD";return e<=0&&(t="BC",e=1-e),[t,e]}const Ch={standard:[31,28,31,30,31,30,31,31,30,31,30,31],leapyear:[31,29,31,30,31,30,31,31,30,31,30,31]};class Yn{fromJulianDay(t){let n=t,r=n-El,s=Math.floor(r/146097),i=yr(r,146097),a=Math.floor(i/36524),o=yr(i,36524),c=Math.floor(o/1461),d=yr(o,1461),u=Math.floor(d/365),h=s*400+a*100+c*4+u+(a!==4&&u!==4?1:0),[p,m]=Sh(h),v=n-pn(p,m,1,1),b=2;n<pn(p,m,3,1)?b=0:kn(m)&&(b=1);let x=Math.floor(((v+b)*12+373)/367),w=n-pn(p,m,x,1)+1;return new nn(p,m,x,w)}toJulianDay(t){return pn(t.era,t.year,t.month,t.day)}getDaysInMonth(t){return Ch[kn(t.year)?"leapyear":"standard"][t.month-1]}getMonthsInYear(t){return 12}getDaysInYear(t){return kn(t.year)?366:365}getMaximumMonthsInYear(){return 12}getMaximumDaysInMonth(){return 31}getYearsInEra(t){return 9999}getEras(){return["BC","AD"]}isInverseEra(t){return t.era==="BC"}balanceDate(t){t.year<=0&&(t.era=t.era==="BC"?"AD":"BC",t.year=1-t.year)}constructor(){this.identifier="gregory"}}function jh(e,t){var n,r,s,i;return(i=(s=(n=e.isEqual)===null||n===void 0?void 0:n.call(e,t))!==null&&s!==void 0?s:(r=t.isEqual)===null||r===void 0?void 0:r.call(t,e))!==null&&i!==void 0?i:e.identifier===t.identifier}function Tl(e,t){return e.calendar.toJulianDay(e)-t.calendar.toJulianDay(t)}function Ah(e,t){return Oi(e)-Oi(t)}function Oi(e){return e.hour*36e5+e.minute*6e4+e.second*1e3+e.millisecond}let br=null;function Dl(){return br==null&&(br=new Intl.DateTimeFormat().resolvedOptions().timeZone),br}function Li(e){e=ks(e,new Yn);let t=ws(e.era,e.year);return Il(t,e.month,e.day,e.hour,e.minute,e.second,e.millisecond)}function Il(e,t,n,r,s,i,a){let o=new Date;return o.setUTCHours(r,s,i,a),o.setUTCFullYear(e,t-1,n),o.getTime()}function Fi(e,t){if(t==="UTC")return 0;if(e>0&&t===Dl())return new Date(e).getTimezoneOffset()*-6e4;let{year:n,month:r,day:s,hour:i,minute:a,second:o}=$l(e,t);return Il(n,r,s,i,a,o,0)-Math.floor(e/1e3)*1e3}const Pi=new Map;function $l(e,t){let n=Pi.get(t);n||(n=new Intl.DateTimeFormat("en-US",{timeZone:t,hour12:!1,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}),Pi.set(t,n));let r=n.formatToParts(new Date(e)),s={};for(let i of r)i.type!=="literal"&&(s[i.type]=i.value);return{year:s.era==="BC"||s.era==="B"?-s.year+1:+s.year,month:+s.month,day:+s.day,hour:s.hour==="24"?0:+s.hour,minute:+s.minute,second:+s.second}}const Ri=864e5;function Mh(e,t,n,r){return(n===r?[n]:[n,r]).filter(i=>Eh(e,t,i))}function Eh(e,t,n){let r=$l(n,t);return e.year===r.year&&e.month===r.month&&e.day===r.day&&e.hour===r.hour&&e.minute===r.minute&&e.second===r.second}function Th(e,t,n="compatible"){let r=Ll(e);if(t==="UTC")return Li(r);if(t===Dl()&&n==="compatible"){r=ks(r,new Yn);let c=new Date,d=ws(r.era,r.year);return c.setFullYear(d,r.month-1,r.day),c.setHours(r.hour,r.minute,r.second,r.millisecond),c.getTime()}let s=Li(r),i=Fi(s-Ri,t),a=Fi(s+Ri,t),o=Mh(r,t,s-i,s-a);if(o.length===1)return o[0];if(o.length>1)switch(n){case"compatible":case"earlier":return o[0];case"later":return o[o.length-1];case"reject":throw new RangeError("Multiple possible absolute times found")}switch(n){case"earlier":return Math.min(s-i,s-a);case"compatible":case"later":return Math.max(s-i,s-a);case"reject":throw new RangeError("No such absolute time found")}}function Ol(e,t,n="compatible"){return new Date(Th(e,t,n))}function Ll(e,t){let n=0,r=0,s=0,i=0;if("timeZone"in e)({hour:n,minute:r,second:s,millisecond:i}=e);else if("hour"in e&&!t)return e;return t&&({hour:n,minute:r,second:s,millisecond:i}=t),new zn(e.calendar,e.era,e.year,e.month,e.day,n,r,s,i)}function ks(e,t){if(jh(e.calendar,t))return e;let n=t.fromJulianDay(e.calendar.toJulianDay(e)),r=e.copy();return r.calendar=t,r.era=n.era,r.year=n.year,r.month=n.month,r.day=n.day,Dt(r),r}function Ns(e,t){let n=e.copy(),r="hour"in n?Fh(n,t):0;qr(n,t.years||0),n.calendar.balanceYearMonth&&n.calendar.balanceYearMonth(n,e),n.month+=t.months||0,Wr(n),Fl(n),n.day+=(t.weeks||0)*7,n.day+=t.days||0,n.day+=r,Dh(n),n.calendar.balanceDate&&n.calendar.balanceDate(n),n.year<1&&(n.year=1,n.month=1,n.day=1);let s=n.calendar.getYearsInEra(n);if(n.year>s){var i,a;let c=(i=(a=n.calendar).isInverseEra)===null||i===void 0?void 0:i.call(a,n);n.year=s,n.month=c?1:n.calendar.getMonthsInYear(n),n.day=c?1:n.calendar.getDaysInMonth(n)}n.month<1&&(n.month=1,n.day=1);let o=n.calendar.getMonthsInYear(n);return n.month>o&&(n.month=o,n.day=n.calendar.getDaysInMonth(n)),n.day=Math.max(1,Math.min(n.calendar.getDaysInMonth(n),n.day)),n}function qr(e,t){var n,r;!((n=(r=e.calendar).isInverseEra)===null||n===void 0)&&n.call(r,e)&&(t=-t),e.year+=t}function Wr(e){for(;e.month<1;)qr(e,-1),e.month+=e.calendar.getMonthsInYear(e);let t=0;for(;e.month>(t=e.calendar.getMonthsInYear(e));)e.month-=t,qr(e,1)}function Dh(e){for(;e.day<1;)e.month--,Wr(e),e.day+=e.calendar.getDaysInMonth(e);for(;e.day>e.calendar.getDaysInMonth(e);)e.day-=e.calendar.getDaysInMonth(e),e.month++,Wr(e)}function Fl(e){e.month=Math.max(1,Math.min(e.calendar.getMonthsInYear(e),e.month)),e.day=Math.max(1,Math.min(e.calendar.getDaysInMonth(e),e.day))}function Dt(e){e.calendar.constrainDate&&e.calendar.constrainDate(e),e.year=Math.max(1,Math.min(e.calendar.getYearsInEra(e),e.year)),Fl(e)}function Ih(e){let t={};for(let n in e)typeof e[n]=="number"&&(t[n]=-e[n]);return t}function Pl(e,t){return Ns(e,Ih(t))}function Rl(e,t){let n=e.copy();return t.era!=null&&(n.era=t.era),t.year!=null&&(n.year=t.year),t.month!=null&&(n.month=t.month),t.day!=null&&(n.day=t.day),Dt(n),n}function $h(e,t){let n=e.copy();return t.hour!=null&&(n.hour=t.hour),t.minute!=null&&(n.minute=t.minute),t.second!=null&&(n.second=t.second),t.millisecond!=null&&(n.millisecond=t.millisecond),Lh(n),n}function Oh(e){e.second+=Math.floor(e.millisecond/1e3),e.millisecond=gn(e.millisecond,1e3),e.minute+=Math.floor(e.second/60),e.second=gn(e.second,60),e.hour+=Math.floor(e.minute/60),e.minute=gn(e.minute,60);let t=Math.floor(e.hour/24);return e.hour=gn(e.hour,24),t}function Lh(e){e.millisecond=Math.max(0,Math.min(e.millisecond,1e3)),e.second=Math.max(0,Math.min(e.second,59)),e.minute=Math.max(0,Math.min(e.minute,59)),e.hour=Math.max(0,Math.min(e.hour,23))}function gn(e,t){let n=e%t;return n<0&&(n+=t),n}function Fh(e,t){return e.hour+=t.hours||0,e.minute+=t.minutes||0,e.second+=t.seconds||0,e.millisecond+=t.milliseconds||0,Oh(e)}function zl(e,t,n,r){let s=e.copy();switch(t){case"era":{let o=e.calendar.getEras(),c=o.indexOf(e.era);if(c<0)throw new Error("Invalid era: "+e.era);c=tt(c,n,0,o.length-1,r?.round),s.era=o[c],Dt(s);break}case"year":var i,a;!((i=(a=s.calendar).isInverseEra)===null||i===void 0)&&i.call(a,s)&&(n=-n),s.year=tt(e.year,n,-1/0,9999,r?.round),s.year===-1/0&&(s.year=1),s.calendar.balanceYearMonth&&s.calendar.balanceYearMonth(s,e);break;case"month":s.month=tt(e.month,n,1,e.calendar.getMonthsInYear(e),r?.round);break;case"day":s.day=tt(e.day,n,1,e.calendar.getDaysInMonth(e),r?.round);break;default:throw new Error("Unsupported field "+t)}return e.calendar.balanceDate&&e.calendar.balanceDate(s),Dt(s),s}function Ph(e,t,n,r){let s=e.copy();switch(t){case"hour":{let i=e.hour,a=0,o=23;if(r?.hourCycle===12){let c=i>=12;a=c?12:0,o=c?23:11}s.hour=tt(i,n,a,o,r?.round);break}case"minute":s.minute=tt(e.minute,n,0,59,r?.round);break;case"second":s.second=tt(e.second,n,0,59,r?.round);break;case"millisecond":s.millisecond=tt(e.millisecond,n,0,999,r?.round);break;default:throw new Error("Unsupported field "+t)}return s}function tt(e,t,n,r,s=!1){if(s){e+=Math.sign(t),e<n&&(e=r);let i=Math.abs(t);t>0?e=Math.ceil(e/i)*i:e=Math.floor(e/i)*i,e>r&&(e=n)}else e+=t,e<n?e=r-(n-e-1):e>r&&(e=n+(e-r-1));return e}const Rh=/^([+-]\d{6}|\d{4})-(\d{2})-(\d{2})$/,zh=/^([+-]\d{6}|\d{4})-(\d{2})-(\d{2})(?:T(\d{2}))?(?::(\d{2}))?(?::(\d{2}))?(\.\d+)?(?:(?:([+-]\d{2})(?::?(\d{2}))?)|Z)$/;function Bh(e){let t=e.match(Rh);if(!t)throw zh.test(e)?new Error(`Invalid ISO 8601 date string: ${e}. Use parseAbsolute() instead.`):new Error("Invalid ISO 8601 date string: "+e);let n=new nn(vr(t[1],0,9999),vr(t[2],1,12),1);return n.day=vr(t[3],1,n.calendar.getDaysInMonth(n)),n}function vr(e,t,n){let r=Number(e);if(r<t||r>n)throw new RangeError(`Value out of range: ${t} <= ${r} <= ${n}`);return r}function _h(e){return`${String(e.hour).padStart(2,"0")}:${String(e.minute).padStart(2,"0")}:${String(e.second).padStart(2,"0")}${e.millisecond?String(e.millisecond/1e3).slice(1):""}`}function Bl(e){let t=ks(e,new Yn),n;return t.era==="BC"?n=t.year===1?"0000":"-"+String(Math.abs(1-t.year)).padStart(6,"00"):n=String(t.year).padStart(4,"0"),`${n}-${String(t.month).padStart(2,"0")}-${String(t.day).padStart(2,"0")}`}function Vh(e){return`${Bl(e)}T${_h(e)}`}function Hh(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function _l(e,t,n){Hh(e,t),t.set(e,n)}function Vl(e){let t=typeof e[0]=="object"?e.shift():new Yn,n;if(typeof e[0]=="string")n=e.shift();else{let a=t.getEras();n=a[a.length-1]}let r=e.shift(),s=e.shift(),i=e.shift();return[t,n,r,s,i]}var Uh=new WeakMap;class nn{copy(){return this.era?new nn(this.calendar,this.era,this.year,this.month,this.day):new nn(this.calendar,this.year,this.month,this.day)}add(t){return Ns(this,t)}subtract(t){return Pl(this,t)}set(t){return Rl(this,t)}cycle(t,n,r){return zl(this,t,n,r)}toDate(t){return Ol(this,t)}toString(){return Bl(this)}compare(t){return Tl(this,t)}constructor(...t){_l(this,Uh,{writable:!0,value:void 0});let[n,r,s,i,a]=Vl(t);this.calendar=n,this.era=r,this.year=s,this.month=i,this.day=a,Dt(this)}}var qh=new WeakMap;class zn{copy(){return this.era?new zn(this.calendar,this.era,this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond):new zn(this.calendar,this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond)}add(t){return Ns(this,t)}subtract(t){return Pl(this,t)}set(t){return Rl($h(this,t),t)}cycle(t,n,r){switch(t){case"era":case"year":case"month":case"day":return zl(this,t,n,r);default:return Ph(this,t,n,r)}}toDate(t,n){return Ol(this,t,n)}toString(){return Vh(this)}compare(t){let n=Tl(this,t);return n===0?Ah(this,Ll(t)):n}constructor(...t){_l(this,qh,{writable:!0,value:void 0});let[n,r,s,i,a]=Vl(t);this.calendar=n,this.era=r,this.year=s,this.month=i,this.day=a,this.hour=t.shift()||0,this.minute=t.shift()||0,this.second=t.shift()||0,this.millisecond=t.shift()||0,Dt(this)}}const Wh={monthly:1,quarterly:3,annual:12};function Hl(e,t){const n=Math.max(1,Math.floor(t.numberOfInstallments||1)),r=Math.floor(e*100/n),i=Math.round(e*100)-r*n,a=new Date(`${t.firstInstallmentDate}T00:00:00`),o=Wh[t.frequency];return Array.from({length:n},(c,d)=>{const u=new Date(a);return u.setMonth(a.getMonth()+d*o),{id:crypto.randomUUID(),dueDate:u.toISOString().slice(0,10),amount:(r+(d<i?1:0))/100}})}const Kh={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",firstInstallmentDate:"First payment date",installment:"Payment",dueDate:"Due date",amount:"Amount",total:"Total",remaining:"Remaining",deleteInstallment:"Delete installment",monthly:"Monthly",quarterly:"Quarterly",annual:"Annual",totalError:"Payment total must equal donation amount"},Jh=["monthly","quarterly","annual"],Ul={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-950"},Bn={label:"text-sm font-normal text-zinc-950",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"},Yh={label:"text-sm font-normal text-zinc-950",trigger:"h-9 rounded-xl border border-zinc-200 bg-white shadow-none hover:border-zinc-300 data-[hover=true]:border-zinc-300 data-[focus=true]:border-zinc-400 data-[focus-visible=true]:ring-0"},zi=()=>({id:crypto.randomUUID(),dueDate:new Date().toISOString().slice(0,10),amount:0}),Kr=e=>Math.round(e*100)/100,Gh=(e,t)=>{const n=new Date(`${e}T00:00:00`);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(t,{month:"short",day:"numeric",year:"numeric"}).format(n)},ql=e=>{if(!e)return null;try{return Bh(e)}catch{return null}};function Qh({mode:e,donationAmount:t,currency:n="USD",locale:r="en-US",installments:s,automaticSettings:i,labels:a,classNames:o,isSaving:c=!1,isModeSwitchDisabled:d=!1,onModeChange:u,onAutomaticSettingsChange:h,onInstallmentsChange:p,onSave:m}){const v={...Kh,...a},b=y.useMemo(()=>new Intl.NumberFormat(r,{style:"currency",currency:n}),[n,r]),x=e==="automatic"?Hl(t,i):s,w=y.useMemo(()=>Kr(x.reduce((T,$)=>T+Number($.amount||0),0)),[x]),S=T=>{T!==e&&(u(T),T==="manual"&&s.length===0&&p([zi()]))},M=(T,$)=>{s.find(D=>D.id===T)?.status!=="paid"&&p(s.map(D=>D.id===T?{...D,...$}:D))},N=()=>{p([...s,zi()])},j=T=>{s.find(W=>W.id===T)?.status!=="paid"&&p(s.filter(W=>W.id!==T))};return l.jsx("div",{className:f.cn("vvt-ps font-sans text-zinc-900",o?.root),children:l.jsx(f.Accordion,{variant:"splitted",defaultSelectedKeys:["installment-schedule"],className:f.cn("w-full gap-0 px-0",o?.panel),itemClasses:{base:"w-full rounded-2xl border border-zinc-200 bg-white p-0 shadow-sm",trigger:f.cn("px-4 py-4",o?.header),title:"text-xl font-semibold leading-8 text-zinc-900",content:"w-full px-4 pb-4 pt-0",indicator:"text-zinc-500"},children:l.jsx(f.AccordionItem,{"aria-label":v.title,title:v.title,children:l.jsxs("div",{className:f.cn("flex w-full flex-col gap-4",o?.content),children:[l.jsxs("div",{className:"flex w-full items-center justify-between gap-6",children:[l.jsx(Zh,{mode:e,labels:v,onModeChange:S,isDisabled:d,className:o?.tabs}),l.jsx(K,{type:"button",size:"sm",color:"primary",radius:"full",className:"ml-auto h-9 min-w-36 bg-brand px-4 text-sm font-medium text-white",startContent:l.jsx(U,{icon:"solar:cloud-upload-outline",className:"size-4"}),isLoading:c,onPress:m,children:v.saveInstallments})]}),l.jsxs("div",{className:"flex w-full flex-col gap-4",children:[e==="automatic"&&l.jsx(Xh,{settings:i,labels:v,onSettingsChange:h}),x.length===0&&l.jsx(f.Alert,{icon:l.jsx(U,{icon:"solar:info-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,classNames:Ul,color:"default",variant:"flat",title:e==="automatic"?v.emptyAutomatic:v.emptyManual}),x.length>0&&l.jsx(em,{mode:e,installments:x,labels:v,formatter:b,locale:r,onUpdateInstallment:M,onRemoveInstallment:j}),e==="manual"&&l.jsx("div",{className:"flex flex-wrap gap-3",children:l.jsx(K,{type:"button",variant:"bordered",radius:"full",className:"h-9 border-zinc-200 bg-white px-4 text-sm font-normal text-zinc-900",startContent:l.jsx(J.Plus,{className:"size-5",strokeWidth:2}),onPress:N,children:v.addInstallment})}),l.jsx(nm,{total:w,donationAmount:t,difference:Kr(t-w),hasTotalError:e==="manual"&&Math.abs(t-w)>.009,mode:e,installmentCount:x.length,formatter:b})]})]})},"installment-schedule")})})}function Zh({mode:e,labels:t,className:n,isDisabled:r=!1,onModeChange:s}){return l.jsxs(f.Tabs,{"aria-label":t.title,selectedKey:e,isDisabled:r,radius:"full",size:"sm",variant:"light",className:f.cn("w-fit",n),classNames:{base:"w-fit",tabList:"h-10 w-fit rounded-full bg-zinc-200 p-1",tab:"h-8 w-auto rounded-full px-5 text-sm font-normal",cursor:"rounded-full bg-white shadow-sm",tabContent:"text-zinc-500 group-data-[selected=true]:text-zinc-900",panel:"hidden"},onSelectionChange:i=>s(i),children:[l.jsx(f.Tab,{title:t.automaticMode},"automatic"),l.jsx(f.Tab,{title:t.manualMode},"manual")]})}function Xh({settings:e,labels:t,onSettingsChange:n}){return l.jsxs("div",{className:"grid gap-4",style:{gridTemplateColumns:"repeat(3, minmax(0, 1fr))"},children:[l.jsx("div",{className:"min-w-0",children:l.jsx(f.Input,{variant:"bordered",label:t.numberOfInstallments,labelPlacement:"outside",type:"number",min:1,step:1,value:e.numberOfInstallments>0?String(e.numberOfInstallments):"",onWheel:r=>r.currentTarget.blur(),onChange:r=>{const s=r.target.value;n({...e,numberOfInstallments:s===""?0:Math.max(1,Number(s))})},classNames:Bn})}),l.jsx("div",{className:"min-w-0",children:l.jsx(yt,{variant:"bordered",label:t.frequency,labelPlacement:"outside",selectedKeys:[e.frequency],onSelectionChange:r=>{const s=Array.from(r)[0];typeof s=="string"&&n({...e,frequency:s})},classNames:Yh,children:Jh.map(r=>l.jsx(f.SelectItem,{textValue:t[r],children:t[r]},r))})}),l.jsx("div",{className:"min-w-0",children:l.jsx(f.DatePicker,{variant:"bordered",label:t.firstInstallmentDate,labelPlacement:"outside",value:ql(e.firstInstallmentDate),onChange:r=>n({...e,firstInstallmentDate:r?r.toString():""}),startContent:l.jsx(U,{icon:"solar:calendar-outline",className:"size-4 text-zinc-500"}),classNames:Bn})})]})}function em({mode:e,installments:t,labels:n,formatter:r,locale:s,onUpdateInstallment:i,onRemoveInstallment:a}){return e==="automatic"?l.jsx("div",{className:"rounded-2xl border border-zinc-200 bg-zinc-50 p-4",children:l.jsx("div",{className:f.cn("flex flex-col gap-3",t.length>5&&"max-h-[264px] overflow-y-auto pr-2"),children:t.map((o,c)=>l.jsxs("div",{className:f.cn("flex min-h-10 items-center justify-between rounded-xl px-4 py-2 text-base",c===0&&"border border-brand/25 bg-brand/5 text-brand"),children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("span",{children:["#",c+1]}),l.jsx("span",{children:"▪"}),l.jsx("span",{children:Gh(o.dueDate,s)}),c===0&&l.jsx(f.Chip,{size:"sm",radius:"full",className:"h-6 bg-brand px-2 text-xs font-semibold text-white",children:"First charge"})]}),l.jsx("span",{className:"text-zinc-950",children:r.format(o.amount)})]},o.id))})}):l.jsx("div",{className:"flex flex-col gap-2",children:t.map((o,c)=>l.jsxs("div",{className:"flex w-full items-center gap-4",children:[l.jsx("div",{className:"min-w-0 flex-1",children:l.jsx(f.DatePicker,{variant:"bordered","aria-label":`${n.dueDate} ${c+1}`,isDisabled:o.status==="paid",value:ql(o.dueDate),onChange:d=>i(o.id,{dueDate:d?d.toString():""}),classNames:Bn})}),l.jsx("div",{className:"min-w-0 flex-1",children:l.jsx(f.Input,{variant:"bordered",type:"number",min:0,step:.01,isDisabled:o.status==="paid",value:String(o.amount||""),onChange:d=>i(o.id,{amount:Kr(Number(d.target.value||0))}),startContent:l.jsx("span",{className:"text-zinc-900",children:"$"}),classNames:Bn})}),l.jsx(tm,{isDisabled:t.length<=1,isPaid:o.status==="paid",label:n.deleteInstallment,onRemove:()=>a(o.id)})]},o.id))})}function tm({isDisabled:e,isPaid:t,label:n,onRemove:r}){const s=l.jsx(K,{type:"button",isIconOnly:!0,variant:"flat",radius:"full",className:"h-9 w-9 flex-none bg-danger-100 p-0 text-danger-600",style:{height:36,minWidth:36,width:36},isDisabled:e||t,onPress:r,"aria-label":n,children:l.jsx(U,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"})});return t?l.jsx(f.Tooltip,{content:"This payment cannot be edited or deleted because it has already been paid.",placement:"top",children:l.jsx("span",{className:"inline-flex",children:s})}):s}function nm({total:e,donationAmount:t,difference:n,hasTotalError:r,mode:s,installmentCount:i,formatter:a}){const o=i>0?e/i:0,c=s==="automatic"?l.jsxs("span",{children:["Saving will create ",l.jsx("strong",{children:i})," scheduled payment records of"," ",l.jsx("strong",{children:a.format(o)})," each."]}):l.jsxs("span",{children:["Total scheduled: ",l.jsx("strong",{children:a.format(e)})," /"," ",l.jsx("strong",{children:a.format(t)}),"."]}),d=s==="automatic"?`Total: ${a.format(e)}`:r?`Missing: ${a.format(n)}`:`Remaining: ${a.format(0)}`;return l.jsx(f.Alert,{icon:l.jsx(U,{icon:"solar:info-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,color:"default",variant:"flat",classNames:Ul,endContent:l.jsx("span",{className:"whitespace-nowrap",children:d}),title:c})}function rm(){return l.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:[l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsx(f.Skeleton,{className:"h-7 w-56 rounded-lg"}),l.jsx(f.Skeleton,{className:"size-8 rounded-full"})]}),l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsx(f.Skeleton,{className:"h-10 w-72 rounded-full"}),l.jsx(f.Skeleton,{className:"h-10 w-40 rounded-full"})]}),l.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[l.jsxs("div",{className:"flex w-full max-w-[280px] flex-col gap-2",children:[l.jsx(f.Skeleton,{className:"h-4 w-36 rounded-md"}),l.jsx(f.Skeleton,{className:"h-9 w-full rounded-xl"})]}),l.jsx(f.Skeleton,{className:"h-9 w-36 rounded-full"})]}),l.jsx("div",{className:"flex flex-col gap-3",children:Array.from({length:4}).map((e,t)=>l.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_160px] items-center gap-4 rounded-2xl border border-zinc-100 p-3",children:[l.jsx(f.Skeleton,{className:"h-8 w-full max-w-xs rounded-full"}),l.jsx(f.Skeleton,{className:"h-8 w-full rounded-xl"})]},t))})]})}const Bi={paid:"bg-emerald-50 text-emerald-700",fulfilled:"bg-emerald-50 text-emerald-700",scheduled:"bg-blue-50 text-blue-700",failed:"bg-red-50 text-red-700",cancelled:"bg-zinc-100 text-zinc-600",refunded:"bg-zinc-100 text-zinc-600"},_i={paid:"Paid",fulfilled:"Paid",scheduled:"Scheduled",failed:"Failed",cancelled:"Cancelled",refunded:"Refunded"},sm={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:l.jsxs(l.Fragment,{children:["Are you sure you want to delete this payment? ",l.jsx("strong",{children:"This action cannot be undone."})]}),deleteInstallmentConfirmationCancel:"Cancel",deleteInstallmentConfirmationConfirm:"Confirm",noInstallmentsFound:"No payments found."};function im({installments:e,currency:t,locale:n="en-US",labels:r,isSaving:s=!1,onEditInstallments:i,onPayInstallment:a,onDeleteInstallment:o}){const c={...sm,...r},[d,u]=y.useState(""),h=new Intl.NumberFormat(n,{style:"currency",currency:t}),p=y.useMemo(()=>{const m=d.trim().toLowerCase();return m?e.filter(v=>{const b=v.status??"scheduled";return[v.id,v.amount,v.dueDate,Vi(v.dueDate,n),b,_i[b]??b].join(" ").toLowerCase().includes(m)}):e},[n,e,d]);return l.jsx("div",{className:"vvt-ps w-full font-sans text-zinc-900",children:l.jsx(f.Accordion,{variant:"splitted",defaultSelectedKeys:["installment-table"],className:"w-full gap-0 px-0",itemClasses:{base:"w-full rounded-2xl border border-zinc-200 bg-white p-0 shadow-sm",trigger:"px-4 py-4",title:"text-xl font-semibold leading-8 text-zinc-900",content:"w-full px-4 pb-4 pt-0",indicator:"text-zinc-500"},children:l.jsx(f.AccordionItem,{"aria-label":c.title,title:c.title,children:l.jsxs("div",{className:"flex w-full flex-col gap-4",children:[l.jsxs("div",{className:"flex w-full items-end justify-between gap-6",children:[l.jsxs("div",{className:"w-full max-w-[280px]",children:[l.jsx("label",{className:"mb-1 block text-sm font-normal text-zinc-950",children:c.searchLabel}),l.jsx(f.Input,{variant:"bordered",size:"sm",value:d,placeholder:c.searchPlaceholder,onChange:m=>u(m.target.value),startContent:l.jsx(U,{icon:"solar:magnifer-outline",className:"size-4 text-zinc-500"}),classNames:{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"}})]}),l.jsx(K,{type:"button",variant:"bordered",radius:"full",size:"sm",className:"h-8 border-zinc-200 bg-white px-3 text-sm font-normal text-zinc-900",startContent:l.jsx(U,{icon:"solar:pen-outline",className:"size-4"}),isLoading:s,onPress:i,children:c.editInstallments})]}),l.jsx("div",{className:"w-full overflow-hidden",children:l.jsxs("table",{className:"w-full table-fixed border-collapse text-left text-sm",children:[l.jsxs("colgroup",{children:[l.jsx("col",{className:"w-[6%]"}),l.jsx("col",{className:"w-[25%]"}),l.jsx("col",{className:"w-[12%]"}),l.jsx("col",{className:"w-[16%]"}),l.jsx("col",{className:"w-[17%]"}),l.jsx("col",{className:"w-[24%]"})]}),l.jsx("thead",{children:l.jsxs("tr",{className:"border-b border-zinc-200 text-zinc-900",children:[l.jsx("th",{className:"w-14 px-2 py-3 font-medium",children:"#"}),l.jsx("th",{className:"px-2 py-3 font-medium",children:c.installmentId}),l.jsx("th",{className:"px-2 py-3 font-medium",children:c.amount}),l.jsx("th",{className:"px-2 py-3 font-medium",children:c.scheduledDate}),l.jsx("th",{className:"px-2 py-3 font-medium",children:c.status}),l.jsx("th",{className:"px-2 py-3 font-medium",children:c.actions})]})}),l.jsxs("tbody",{children:[p.map((m,v)=>{const b=m.status??"scheduled";return l.jsxs("tr",{className:"text-zinc-500",children:[l.jsx("td",{className:"px-2 py-3",children:v+1}),l.jsx("td",{className:"px-2 py-3",children:l.jsx("span",{className:"block max-w-full truncate",children:m.id||`PMT-${v+1}`})}),l.jsx("td",{className:"px-2 py-3",children:h.format(m.amount)}),l.jsx("td",{className:"px-2 py-3",children:Vi(m.dueDate,n)}),l.jsx("td",{className:"px-2 py-3",children:l.jsx(f.Chip,{size:"sm",radius:"full",className:f.cn("h-8 min-w-[118px] justify-center px-4 text-sm font-normal",Bi[b]??Bi.scheduled),startContent:l.jsx(lm,{status:b}),children:_i[b]??b})}),l.jsx("td",{className:"px-2 py-3",children:l.jsxs("div",{className:"flex min-w-[154px] items-center justify-start gap-2",children:[l.jsx(K,{type:"button",size:"sm",radius:"full",className:"h-9 min-w-[104px] shrink-0 bg-brand px-3 text-sm font-medium text-white disabled:opacity-50",isDisabled:b==="paid"||b==="fulfilled",startContent:l.jsx(U,{icon:"solar:dollar-minimalistic-outline",className:"size-4"}),onPress:()=>a?.(m),children:c.payNow}),l.jsx(am,{isPaid:b==="paid"||b==="fulfilled",labels:c,onDelete:()=>o(m.id)})]})})]},m.id)}),p.length===0&&l.jsx("tr",{children:l.jsx("td",{colSpan:6,className:"px-2 py-6 text-center text-zinc-500",children:c.noInstallmentsFound})})]})]})})]})},"installment-table")})})}function am({isPaid:e,labels:t,onDelete:n}){const[r,s]=y.useState(!1);return l.jsxs(l.Fragment,{children:[l.jsxs(f.Dropdown,{placement:"bottom-end",radius:"lg",children:[l.jsx(f.DropdownTrigger,{children:l.jsx(K,{type:"button",isIconOnly:!0,size:"sm",variant:"light",className:"text-zinc-900","aria-label":"More actions",children:l.jsx(U,{icon:"solar:menu-dots-bold",className:"size-4"})})}),l.jsxs(f.DropdownMenu,{"aria-label":"Installment actions",disabledKeys:e?["delete"]:[],className:"w-72 p-2",onAction:i=>{i==="delete"&&!e&&s(!0)},children:[l.jsx(f.DropdownSection,{title:"Actions",showDivider:!0,children:l.jsx(f.DropdownItem,{textValue:t.sendLink,description:t.sendLinkDescription,startContent:l.jsx(U,{icon:"solar:link-outline",className:"size-5 text-zinc-500"}),children:t.sendLink},"send-link")}),l.jsx(f.DropdownSection,{title:t.dangerZone,children:l.jsx(f.DropdownItem,{textValue:t.deleteInstallment,className:"text-danger-600",color:"danger",description:t.deleteInstallmentDescription,startContent:l.jsx(U,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"}),children:t.deleteInstallment},"delete")})]})]}),l.jsx(Rn,{isOpen:r,labels:{title:t.deleteInstallmentConfirmationTitle,description:t.deleteInstallmentConfirmationDescription,cancel:t.deleteInstallmentConfirmationCancel,confirm:t.deleteInstallmentConfirmationConfirm},icon:l.jsx(U,{icon:"solar:danger-triangle-outline",className:"size-7"}),confirmColor:"danger",onClose:()=>s(!1),onConfirm:()=>{s(!1),n()}})]})}function lm({status:e}){return e==="paid"||e==="fulfilled"?l.jsx(U,{icon:"solar:check-circle-bold",className:"size-3"}):e==="failed"?l.jsx(U,{icon:"solar:close-circle-bold",className:"size-3"}):l.jsx(U,{icon:"solar:calendar-outline",className:"size-3"})}function Vi(e,t){const n=new Date(`${e}T00:00:00`);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(t,{month:"short",day:"numeric",year:"numeric"}).format(n)}const om={title:"Select Membership",renewalTitle:"Automatic Renewal",renewalDescription:"Membership will automatically renew at the end of each period"},cm=({cards:e,locale:t,currency:n,listHeightClassName:r="",labels:s,showRenewal:i=!0,defaultRenewalValue:a=!1,initialSelectedMembershipId:o=null,allowReselect:c=!0,onRenewalChange:d,onCardSelect:u,className:h=""})=>{const p=Array.isArray(e)?e:[],[m,v]=y.useState(o),[b,x]=y.useState(a),w={...om,...s};y.useEffect(()=>{v(o)},[o]);const S=N=>{if(N===m){c&&u?.(N);return}v(N),u?.(N)},M=N=>{x(N),d?.(N)};return l.jsxs("div",{className:f.cn("w-full flex flex-col gap-4 items-start p-4 h-svh",h),"data-testid":"membership-select-cards",children:[l.jsx("span",{className:"hidden","data-testid":"membership-select-cards-selected-id",children:m??""}),l.jsx("p",{className:"text-2xl font-semibold text-left","data-testid":"membership-select-cards-title",children:w.title}),i&&l.jsx(Zl,{title:w.renewalTitle,description:w.renewalDescription,value:b,onValueChange:M}),l.jsx("div",{className:f.cn("w-full min-h-0 flex flex-col gap-4 overflow-y-auto",r===""?"flex-1":f.cn("shrink-0",r)),"data-testid":"membership-select-cards-list",children:p.map(N=>l.jsx(Wl,{itemKey:N.id,name:N.name,type:N.type,price:N.price,locale:t,currency:n,isSelected:m===N.id,onSelect:S},N.id))})]})},Wl=({itemKey:e,name:t,type:n,price:r,locale:s="en-US",currency:i="USD",showPrice:a=!0,isSelected:o=!1,onSelect:c,compact:d=!1,isDisabled:u=!1,disabledReason:h,statusLabel:p,statusTone:m="default",className:v=""})=>{const b=new Intl.NumberFormat(s,{style:"currency",currency:i,minimumFractionDigits:0,maximumFractionDigits:2}).format(r),x=!!c&&!u,w=h||p,S=()=>{x&&c?.(e)};return l.jsx(f.Card,{shadow:"none",isPressable:!!c,onPress:S,className:f.cn("w-full min-h-fit border rounded-3xl",o?"border-primary bg-primary/5":"border-default",u?"opacity-60":"",d?"rounded-2xl":"",v),"data-testid":"item-card","data-selected":o,isDisabled:u,children:l.jsxs("div",{className:f.cn("px-4 py-8 flex gap-6 items-center justify-between",d&&"px-3 py-3 gap-4"),children:[l.jsxs("div",{className:"w-max flex flex-col gap-1 items-start",children:[l.jsx("p",{className:f.cn("font-semibold text-left",d?"text-sm":"text-xl"),"data-testid":"item-card-name",children:t}),n&&l.jsx("div",{"data-testid":"item-card-type",className:"w-fit bg-default-300 px-4 py-2 text-sm rounded-xl",children:l.jsx("p",{className:"text-center",children:n})}),w&&l.jsx(f.Chip,{"data-testid":"item-card-status",color:m,size:"sm",variant:"flat",className:"px-2",children:w})]}),a&&l.jsx("p",{className:f.cn("font-semibold text-right",d?"text-lg":"text-2xl"),"data-testid":"item-card-price",children:b})]})})},Hi="w-full bg-gray-100",Ui={variant:"light",color:"default"},Kl=({id:e,title:t,media:n,imageUrl:r,imageAlt:s,imageClassName:i="",imageAspect:a="aspect-[4/3]",meta:o=[],price:c,action:d,footer:u,onPress:h,isPressable:p=!1,isDisabled:m=!1,compact:v=!1,className:b="",bodyClassName:x="",footerClassName:w="",dataTestId:S})=>{const M=!!(c&&c.value),N=!!d?.label,j=p&&!!h&&!N,T=!j,$=N?{variant:d?.variant??Ui.variant,color:d?.color??Ui.color,size:d?.size??"sm",isDisabled:m||d?.isDisabled,startContent:d?.icon?l.jsx(U,{icon:d.icon,width:16}):void 0}:null,W=n??(r?l.jsx("div",{className:f.cn("relative overflow-hidden rounded-xl",a,Hi,i),children:l.jsx(f.Image,{removeWrapper:!0,src:r,alt:s||t,className:"size-full object-cover",classNames:{wrapper:"absolute inset-0"}})}):l.jsx("div",{className:f.cn("relative overflow-hidden rounded-xl",a,Hi,"grid place-items-center",i),"data-testid":`catalog-item-card-${e??"media"}-fallback`,children:l.jsx(U,{icon:"solar:ticket-outline",width:48,className:"text-default-400"})}));return l.jsxs(f.Card,{"data-testid":S||`catalog-item-card-${e??"item"}`,className:f.cn("w-full overflow-hidden",b),isPressable:j,onPress:h,isDisabled:m,shadow:"sm",radius:"lg",children:[l.jsx("div",{children:W}),l.jsxs(f.CardBody,{className:f.cn("gap-3",v?"p-3":"p-4",x),children:[l.jsx("h3",{"data-testid":`catalog-item-card-title-${e??""}`,className:f.cn("line-clamp-2 text-base font-semibold text-gray-900",v?"text-sm":""),children:t}),o.length>0?l.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,R)=>l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx(U,{icon:D.icon,className:"size-4 text-gray-400",width:16}),l.jsx("span",{children:D.label})]},`${D.label}-${R}`))}):null,(M||N)&&l.jsxs("div",{className:f.cn("flex items-center justify-end gap-2 pt-1 text-sm",v?"pt-0.5":"",w),children:[M?l.jsxs("span",{className:f.cn("mr-auto text-gray-500",v?"text-xs":""),"data-testid":`catalog-item-card-price-${e??""}`,children:[c?.label&&l.jsxs("span",{children:[c.label," "]}),l.jsx("span",{className:"font-semibold text-brand",children:c?.value})]}):l.jsx("span",{className:"ml-auto","aria-hidden":!0}),N&&T?l.jsx(K,{className:f.cn("rounded-full",d?.className),onPress:d?.onPress,variant:$?.variant,color:$?.color,size:$?.size,startContent:$?.startContent,isDisabled:$?.isDisabled,"aria-label":d?.ariaLabel||d?.label,children:d?.label}):null]}),u?l.jsx("div",{className:"pt-1",children:u}):null]})]})};Kl.displayName="CatalogItemCard";const dm={empty:"solar:inbox-line-duotone",error:"solar:danger-triangle-outline",success:"solar:check-circle-bold"},um={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"},fm={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"},hm={empty:"status",error:"alert",success:"status",loading:"status"},mm={empty:"polite",error:"assertive",success:"polite",loading:"polite"};function pm(e,t,n,r){if(t===!1)return null;if(e==="loading"&&t===void 0)return l.jsx(f.Spinner,{size:"lg",color:"primary",className:r.spinner});if(y.isValidElement(t))return l.jsx(l.Fragment,{children:t});const s=typeof t=="string"?t:dm[e];return s?l.jsx(U,{icon:s,width:n,height:n,"aria-hidden":"true",className:r.icon}):null}function It({variant:e="empty",title:t,titleAs:n="p",description:r,icon:s,actions:i,role:a=hm[e],ariaLive:o=mm[e],iconSize:c=24,className:d,classNames:u={},"data-testid":h="feedback-state"}){const p=pm(e,s,c,u);return l.jsxs("div",{role:a,"aria-live":o,"data-variant":e,"data-testid":h,className:f.cn("flex flex-col items-center justify-center gap-3 rounded-xl border border-dashed px-6 py-12 text-center",um[e],d,u.base),children:[p?l.jsx("span",{"aria-hidden":"true","data-testid":`${h}-icon`,className:f.cn("inline-flex size-12 items-center justify-center rounded-2xl",e==="success"&&"rounded-full",fm[e],u.iconWrapper),children:p}):null,l.jsxs("div",{className:"flex flex-col items-center gap-1",children:[l.jsx(n,{"data-testid":`${h}-title`,className:f.cn("text-base font-medium text-default-900",u.title),children:t}),r?l.jsx("p",{"data-testid":`${h}-description`,className:f.cn("max-w-sm text-sm text-default-600",u.description),children:r}):null]}),i?l.jsx("div",{"data-testid":`${h}-actions`,className:f.cn("mt-1 flex flex-wrap items-center justify-center gap-2",u.actions),children:i}):null]})}function Jl(e){return l.jsx(It,{...e,variant:"empty"})}function Yl(e){return l.jsx(It,{...e,variant:"error"})}function Gl(e){return l.jsx(It,{...e,variant:"loading"})}function Ql(e){return l.jsx(It,{...e,variant:"success"})}It.displayName="FeedbackState";Jl.displayName="EmptyState";Yl.displayName="ErrorState";Gl.displayName="LoadingState";Ql.displayName="SuccessState";const Zl=({title:e,value:t,description:n,onValueChange:r,className:s=""})=>{const i=y.useId();return l.jsxs("div",{className:f.cn("w-full flex flex-row items-center",e||n?"justify-between gap-6":"justify-start",s),"data-testid":"toggle",children:[l.jsxs("div",{className:"flex flex-col items-start",children:[e&&l.jsx("label",{htmlFor:i,className:"font-medium text-left","data-testid":"toggle-title",children:e}),n&&l.jsx("p",{className:"text-left text-gray-500","data-testid":"toggle-description",children:n})]}),l.jsx(f.Switch,{id:i,isSelected:t,onValueChange:r,"data-testid":"toggle-switch"})]})},gm={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"},xm=(e,t)=>new Intl.NumberFormat(e,{style:"currency",currency:t}),Xl=e=>Object.values(e).reduce((t,n)=>t+Object.values(n).reduce((r,s)=>r+Object.values(s).reduce((i,a)=>i+a.selectedQuantity,0),0),0),ym=e=>e.reduce((t,n)=>t+n.dates.reduce((r,s)=>r+s.tickets.reduce((i,a)=>i+a.max,0),0),0),Ss=e=>e.flatMap(t=>t.dates.flatMap(n=>n.tickets.map(r=>({exhibition:t,dateGroup:n,ticket:r})))),qi=(e,t,n)=>{const r={};let s=n?t??ym(e):0;for(const{exhibition:i,dateGroup:a,ticket:o}of Ss(e)){r[i.id]??={},r[i.id][a.id]??={};const c=n?Math.min(o.max,s):0;r[i.id][a.id][o.id]={id:o.id,selectedQuantity:c,originalPrice:o.originalPrice,discountedPrice:o.price},s-=c}return r},Wi=(e,t,n)=>`${e}::${t}::${n}`,bm=(e,t,n)=>{const r=Xl(t);for(const{exhibition:s,dateGroup:i,ticket:a}of Ss(e)){const o=t[s.id]?.[i.id]?.[a.id]?.selectedQuantity??0,c=n===void 0?a.max:Math.min(a.max,n-(r-o));if(c>0&&o<c)return!1}return!0},vm=({initialQuantity:e=1,minQuantity:t=1,maxQuantity:n=10,onChange:r,disabled:s=!1})=>{const i=Math.max(t,Math.min(n,e)),[a,o]=y.useState(()=>String(i)),[c,d]=y.useState(!1),u=c?a:String(i),h=()=>{s||i>=n||r?.(i+1)},p=()=>{s||i<=t||r?.(i-1)},m=N=>{if(s)return;o(N.target.value);const j=parseInt(N.target.value,10);isNaN(j)||r?.(Math.max(t,Math.min(n,j)))},v=N=>{const j=parseInt(N.target.value,10);if(d(!1),isNaN(j)){r?.(t);return}const T=Math.max(t,Math.min(n,j));T!==j?r?.(T):o(String(T))},b=i<=t,x=i>=n,w="w-10 h-10 flex items-center justify-center border-0 rounded-full cursor-pointer transition-colors duration-150 text-white text-2xl font-regular",S="bg-primary hover:bg-primary/80",M="bg-primary/40 cursor-not-allowed";return l.jsxs("div",{className:"flex items-center gap-4","data-testid":"quantity-selector",children:[l.jsx("button",{type:"button",onClick:p,disabled:s||b,className:f.cn(w,s||b?M:S),"aria-label":"Decrement quantity","data-testid":"quantity-decrement",children:"-"}),l.jsx("input",{type:"number",value:u,onChange:m,onFocus:()=>d(!0),onBlur:v,disabled:s,min:t,max:n,step:"1",className:"w-12 h-10 rounded-md border-0 bg-zinc-100 text-center text-2xl font-medium text-zinc-900 [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none","aria-label":`Selected quantity: ${i}`,"data-testid":"quantity-input"}),l.jsx("button",{type:"button",onClick:h,disabled:s||x,className:f.cn(w,s||x?M:S),"aria-label":"Increment quantity","data-testid":"quantity-increment",children:"+"})]})},wm=({label:e,checked:t=!1,onChange:n,disabled:r=!1})=>{const s=()=>{r||n?.(!t)};return l.jsxs("button",{type:"button",onClick:s,disabled:r,role:"checkbox","aria-checked":t,"data-testid":"checkbox-button","data-checked":t,className:f.cn("flex items-center gap-1.5 px-4 py-3 border-0 rounded-full cursor-pointer text-sm min-h-[30px]","outline-none select-none transition-colors bg-zinc-100 hover:bg-zinc-200 text-primary",r&&"cursor-not-allowed opacity-60"),children:[l.jsxs("span",{className:"relative flex items-center justify-center w-5 h-5 flex-shrink-0",children:[l.jsx("input",{type:"checkbox",checked:t,onChange:()=>{},disabled:r,className:"absolute opacity-0 w-0 h-0 pointer-events-none",tabIndex:-1,readOnly:!0}),l.jsx("span",{className:f.cn("block w-3.5 h-3.5 rounded-sm relative",t?"bg-primary":"bg-white ring-1 ring-zinc-300"),children:t&&l.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"})})]}),l.jsx("p",{className:"flex-1 m-0 text-left leading-snug",children:e})]})},km=({item:e,quantity:t,onChange:n,getTotalSelectedTickets:r,userMaxLimit:s,settings:i,labels:a})=>{const o=()=>{if(!r||s===void 0)return e.max;const h=r();return Math.min(e.max,s-(h-t))},c=i?.locale??"en-US",d=i?.currency??"USD",u=xm(c,d);return l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between bg-white px-3 py-2.5 gap-8","data-testid":"upgrade-ticket-item",children:[l.jsxs("div",{className:"min-w-0 flex flex-1 flex-col gap-2",children:[l.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[l.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?l.jsx("span",{"data-testid":"ticket-purchased-quantity",children:` x${e.purchasedQuantity}`}):null]}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[l.jsx("h3",{className:"line-through text-zinc-500 text-[0.9rem] font-normal m-0","data-testid":"ticket-original-price",children:u.format(e.originalPrice)}),l.jsx("h3",{className:"text-base font-semibold text-zinc-900 m-0","data-testid":"ticket-discounted-price",children:u.format(e.price)})]})]}),e.membershipName?l.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:l.jsx("p",{className:"max-w-full truncate text-center",children:e.membershipName})}):null,l.jsx("div",{className:"text-sm text-zinc-500",children:l.jsxs("p",{className:"m-0","data-testid":"ticket-max",children:[a.ticketsAllowedToRedeem," ",e.max]})})]}),l.jsx(vm,{initialQuantity:t,minQuantity:0,maxQuantity:o(),onChange:n})]}),e.membershipAlert?l.jsx(f.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:l.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]})},Nm=({exhibitionId:e,dateGroup:t,isLast:n=!1,onQuantityChange:r,getTicketQuantity:s,getTotalSelectedTickets:i,userMaxLimit:a,settings:o,labels:c})=>l.jsxs("div",{className:f.cn("flex flex-col gap-2 pb-3",!n&&"border-b border-zinc-200"),"data-testid":"upgrade-ticket-date-group",children:[l.jsx("p",{className:"m-0 text-sm text-left text-zinc-500","data-testid":"upgrade-ticket-date",children:t.date}),t.tickets.map((d,u)=>l.jsxs("div",{children:[l.jsx(km,{item:d,quantity:s(e,t.id,d.id),onChange:h=>r(e,t.id,d.id,h),getTotalSelectedTickets:i,userMaxLimit:a,settings:o,labels:c}),u<t.tickets.length-1?l.jsx(f.Divider,{className:"bg-zinc-200","data-testid":"upgrade-ticket-divider"}):null]},d.id))]}),Sm=({title:e,exhibition:t,onQuantityChange:n,getTicketQuantity:r,getTotalSelectedTickets:s,userMaxLimit:i,settings:a,labels:o,initialExpanded:c=!1})=>{const[d,u]=y.useState(c),h=t.dates.reduce((m,v)=>m+v.tickets.reduce((b,x)=>b+r(t.id,v.id,x.id),0),0),p=t.dates.some(m=>m.tickets.length>0);return l.jsxs("div",{className:"w-full overflow-hidden border-b border-zinc-200","data-testid":"upgrade-ticket-header",children:[l.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:()=>u(!d),"aria-expanded":d,"aria-controls":`upgrade-items-${t.id}`,"data-testid":"upgrade-ticket-header-button",children:l.jsxs("div",{className:"flex justify-between items-center w-full gap-6",children:[l.jsx("h4",{className:"m-0 text-base font-semibold text-left text-zinc-900","data-testid":"upgrade-ticket-header-title",children:e}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("p",{className:"m-0 text-sm text-right text-zinc-500","data-testid":"upgrade-ticket-header-count",children:[h," ",o.ticketsSelectedToRedeem]}),l.jsx("span",{className:f.cn("inline-flex items-center justify-center text-zinc-500 text-xl transition-transform duration-200",d&&"rotate-180"),"aria-hidden":"true",children:l.jsx(U,{icon:"mdi:chevron-down"})})]})]})}),l.jsx("div",{id:`upgrade-items-${t.id}`,className:f.cn("transition-all duration-300 overflow-hidden",d?"max-h-[1000px] opacity-100":"max-h-0 opacity-0"),"aria-hidden":!d,children:d&&l.jsx("div",{className:"px-5 flex flex-col gap-6","data-testid":"upgrade-ticket-items",children:p?t.dates.map((m,v)=>l.jsx(Nm,{exhibitionId:t.id,dateGroup:m,isLast:v===t.dates.length-1,onQuantityChange:n,getTicketQuantity:r,getTotalSelectedTickets:s,userMaxLimit:i,settings:a,labels:o},m.id)):l.jsx("div",{className:"px-5 py-10 text-center",children:l.jsx("p",{className:"m-0 text-zinc-500 italic",children:o.noUpgradeTicketsAvailable})})})})]})},Cm=({initialExpanded:e=!1,userMaxLimit:t,labels:n,settings:r,ticketSelectionData:s,className:i="",onSelectionChange:a})=>{const o=y.useMemo(()=>s??[],[s]),c={...gm,...n},[d,u]=y.useState(()=>qi(o,t,!0)),h=y.useRef(!1),p=y.useMemo(()=>{const S=Ss(o).map(({exhibition:M,dateGroup:N,ticket:j})=>[Wi(M.id,N.id,j.id),j]);return new Map(S)},[o]),m=bm(o,d,t),v=(S,M,N)=>d[S]?.[M]?.[N]?.selectedQuantity??0,b=()=>Xl(d),x=(S,M,N,j)=>{const T=v(S,M,N),$=b()-T;if(t!==void 0&&$+j>t)return;const W=p.get(Wi(S,M,N));if(!W)return;const D={...d,[S]:{...d[S],[M]:{...d[S]?.[M],[N]:{id:N,selectedQuantity:j,originalPrice:W.originalPrice,discountedPrice:W.price}}}};u(D),a?.(D)},w=S=>{const M=qi(o,t,S);u(M),a?.(M)};return y.useEffect(()=>{!h.current&&m&&(a?.(d),h.current=!0)},[m,d,a]),l.jsxs("div",{className:f.cn("flex flex-col w-full font-sans",i),"data-testid":"ticket-selection",children:[l.jsxs("div",{className:"flex items-center justify-between py-2 gap-4","data-testid":"ticket-selection-header",children:[l.jsx("h3",{className:"text-xl font-semibold m-0","data-testid":"ticket-selection-title",children:c.ticketSelectionTitle}),l.jsx(wm,{label:c.selectAllButtonLabel,checked:m,onChange:w})]}),o.map(S=>l.jsx(Sm,{title:S.exhibitionName,exhibition:S,onQuantityChange:x,getTicketQuantity:v,getTotalSelectedTickets:b,userMaxLimit:t,settings:r,labels:c,initialExpanded:e},S.id))]})},wr={confirm:"Confirm",clear:"Clear",noLabel:"Filters"},kr=e=>{const t={};for(const n of e)n.type==="checkbox"?t[n.id]=[...n.selectedValues]:t[n.id]=n.selectedValue?[n.selectedValue]:[];return t},jm=(e,t)=>{const n={};for(const r of t){if(r.type==="checkbox"){n[r.id]=e[r.id]??[...r.selectedValues];continue}const s=e[r.id]??[];n[r.id]=s.length>0?s[0]:null}return n},Am=e=>e.type==="checkbox"?e.selectedValues.length>0:e.selectedValue!==null,eo=({triggerLabel:e,triggerAriaLabel:t,triggerIcon:n="solar:tuning-square-outline",triggerVariant:r="bordered",triggerColor:s="default",triggerSize:i="sm",triggerClassName:a,popoverClassName:o,className:c,sections:d,onConfirm:u,onClear:h,appliedCount:p,countAriaLabel:m,countDisplay:v="badge",confirmLabel:b=wr.confirm,clearLabel:x=wr.clear,isOpen:w,defaultOpen:S=!1,onOpenChange:M,isDisabled:N=!1,closeOnConfirm:j=!0,keepOpenAfterClear:T=!1})=>{const[$,W]=y.useState(S),[D,R]=y.useState(()=>kr(d)),E=w??$,C=p??d.filter(P=>Am(P)).length,I=P=>{P&&R(kr(d)),w||W(P),M?.(P)},F=(P,_)=>{R(G=>({...G,[P.id]:_}))},H=(P,_)=>{R(G=>({...G,[P.id]:_?[_]:[]}))},Q=async()=>{R(kr(d.map(P=>P.type==="checkbox"?{...P,selectedValues:[]}:{...P,selectedValue:null}))),await h(),T||I(!1)},Y=async()=>{const P=jm(D,d);await u(P),j&&I(!1)},te=P=>{if(P.type==="checkbox")return l.jsx(f.CheckboxGroup,{label:P.label,value:D[P.id]??[],onValueChange:G=>F(P,G),children:P.options.map(G=>l.jsx(f.Checkbox,{value:G.value,isDisabled:G.isDisabled,children:G.label},G.value))},P.id);const _=D[P.id]?.[0]??"";return l.jsx(f.RadioGroup,{label:P.label,value:_,onValueChange:G=>H(P,G||null),children:P.options.map(G=>l.jsx(f.Radio,{value:G.value,isDisabled:G.isDisabled,children:G.label},G.value))},P.id)},oe=y.useMemo(()=>C>0?m?.(C)||`${C} filters applied`:void 0,[m,C]),ce=y.useMemo(()=>C===0?e||wr.noLabel:m?m(C):`${e} (${C})`,[C,e,m]);return l.jsx("div",{className:c,children:l.jsxs(f.Popover,{isOpen:E,onOpenChange:I,placement:"bottom-end",children:[l.jsx(f.PopoverTrigger,{children:l.jsxs(K,{isDisabled:N,variant:r,color:s,size:i,className:a,"aria-label":t,"aria-haspopup":"dialog","aria-expanded":E,children:[l.jsx(U,{icon:n,width:16}),l.jsx("span",{children:e}),v==="badge"&&C>0?l.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":oe,children:C}):v==="summary"&&ce!==e?l.jsx("span",{className:"text-xs",children:ce}):null]})}),l.jsx(f.PopoverContent,{className:o,children:l.jsxs("div",{className:"flex w-full flex-col gap-5 px-4 py-4",children:[d.map(P=>te(P)),l.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-gray-200 pt-3",children:[l.jsx(K,{variant:"light",color:"default",size:"sm",onPress:Q,children:x}),l.jsx(K,{color:"primary",size:"sm",onPress:Y,children:b})]})]})})]})})};eo.displayName="FilterPopover";const Mm="No sessions available for this date",Em=e=>e==="sold-out"||e==="closed"?"danger":"success",Tm=e=>{const t=e.seatsRemaining;return e.status==="sold-out"||e.status==="closed"?"Sold out":e.status==="limited"?typeof t=="number"?`${t} left`:"Limited":typeof t=="number"?`${t} seats available`:"Available"},Ki=e=>e.isDisabled?!0:e.status==="sold-out"||e.status==="closed",Dm=(e,t)=>t&&e.some(n=>n.date===t)?t:e[0]?.date??null,to=({heading:e,subheading:t,days:n,selectedDate:r,onDateSelect:s,quickDates:i,selectedSessionId:a=null,onSessionSelect:o,emptyStateMessage:c=Mm,statusLabel:d,statusTone:u,sessionAriaLabel:h,dayButtonClassName:p,calendarSlot:m,dayGroupAriaLabel:v,sessionGridAriaLabel:b,className:x,headingClassName:w,subheadingClassName:S})=>{const M=Dm(n,r),N=n.find(D=>D.date===M),j=i??n.map(D=>({date:D.date,label:D.label})),T=N?.sessions??[],$=D=>D===M?"solid":"bordered",W=D=>{if(!Ki(D)){if(D.id===a){o(null);return}o(D.id)}};return l.jsxs("section",{className:f.cn("flex flex-col gap-4 rounded-xl bg-white p-3 sm:p-4",x),"data-testid":"session-timeline-root",children:[l.jsxs("header",{className:"flex flex-col gap-1",children:[l.jsx("h2",{className:f.cn("text-base font-semibold text-gray-900",w),children:e}),t?l.jsx("p",{className:f.cn("text-sm text-gray-700",S),children:t}):null]}),l.jsxs("div",{className:"flex flex-wrap items-center gap-2",role:"group","aria-label":v||"Session days",children:[j.map(D=>l.jsx(K,{size:"sm",variant:$(D.date),color:"default",className:f.cn("rounded-full",p),isDisabled:D.isDisabled,onPress:()=>{s(D.date)},children:l.jsx("span",{children:D.label})},D.date)),m?l.jsx("div",{children:m}):null]}),l.jsxs("ul",{className:"grid grid-cols-1 gap-2 sm:grid-cols-3","aria-label":b||"Sessions",children:[T.length===0?l.jsx("li",{className:"rounded-lg bg-white px-4 py-6 text-center text-sm text-gray-600 sm:col-span-3",children:c}):null,T.map(D=>{const R=Ki(D),E=D.id===a;return l.jsx("li",{className:"rounded-xl",children:l.jsx(f.Card,{shadow:"sm",radius:"lg",isPressable:!R,onPress:()=>{W(D)},"aria-disabled":R,"aria-pressed":R?void 0:E,className:f.cn("w-full",R?"bg-gray-100 opacity-70":"",E?"w-full ring-2 ring-gray-900":""),"aria-label":h?h(D,{isSelected:E,isUnavailable:R}):R?`${D.startTime} ${D.endTime} sold out`:`${D.startTime} ${D.endTime} available`,children:l.jsxs(f.CardBody,{className:"flex flex-col items-center gap-3 p-4 text-center",children:[l.jsxs("span",{className:"text-sm font-semibold text-gray-900",children:[D.startTime," – ",D.endTime]}),l.jsx(f.Chip,{size:"sm",color:u?u(D):Em(D.status),variant:"flat",children:d?d(D):Tm(D)})]})})},D.id)})]})]})};to.displayName="SessionTimeline";const Im=350,$m={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}"},Nr=(e,t)=>Object.entries(t).reduce((n,[r,s])=>n.replace(`{${r}}`,s),e),Om=({dueAmount:e,received:t,defaultReceived:n=null,onChange:r,locale:s="en-US",labels:i,isDisabled:a=!1,maxAmount:o,autoFocus:c=!1,className:d,"data-testid":u="cash-tender-form"})=>{const h={...$m,...i},p=Gr(e.currency,s),m=t!==void 0,[v,b]=y.useState(n??null),x=m?t:v,w=y.useMemo(()=>{const I=typeof x=="number"&&Number.isFinite(x)?x:0,F=Cr(I,e.value,e.currency,s);return{received:I,change:F>0?F:0,isValid:I>=e.value&&I>0}},[x,e.value,e.currency,s]),S=y.useCallback(I=>{const F=I.currentTarget;requestAnimationFrame(()=>{F.isConnected&&F.select()})},[]),M=y.useCallback(I=>{if(a)return;const F=I.replace(/[^\d.,]/g,"").replace(",","."),H=F===""?null:Number.parseFloat(F),Q=H===null||Number.isNaN(H)?null:H;if(Q!==null&&o!==void 0&&Q>o)return;m||b(Q);const Y=typeof Q=="number"&&Number.isFinite(Q)?Q:0,te=Cr(Y,e.value,e.currency,s);r?.({received:Y,change:te>0?te:0,isValid:Y>=e.value&&Y>0})},[m,a,e.value,e.currency,s,r,o]),N=x==null?"":String(x),j=w.isValid&&w.change>0,T=!w.isValid&&w.received>0,$=rt(w.change,s,e.currency),W=rt(e.value,s,e.currency),[D,R]=y.useState(""),E=y.useRef(null);y.useEffect(()=>{E.current&&clearTimeout(E.current);const I=j?Nr(h.changeMessageTemplate,{change:$}):"",F=j?Im:0;return E.current=setTimeout(()=>R(I),F),()=>{E.current&&clearTimeout(E.current)}},[j,$,h.changeMessageTemplate]);const C=`${u}-received`;return l.jsxs("div",{className:f.cn("flex flex-col gap-3",d),"data-testid":u,children:[l.jsx(f.Input,{id:C,label:h.receivedLabel,labelPlacement:"outside",type:"text",inputMode:p===0?"numeric":"decimal",pattern:p===0?"[0-9]*":"[0-9]*[.,]?[0-9]*",value:N,onChange:I=>M(I.target.value),onFocus:S,placeholder:h.receivedPlaceholder,isDisabled:a,isInvalid:T,errorMessage:T?Nr(h.insufficientMessageTemplate,{due:W}):void 0,variant:"bordered",radius:"lg",autoFocus:c,"data-testid":`${u}-received-input`}),j&&l.jsx(f.Alert,{"data-testid":`${u}-change-alert`,color:"primary",variant:"flat",radius:"lg",title:h.changeLabel,description:Nr(h.changeMessageTemplate,{change:$}),icon:l.jsx(U,{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"}}),l.jsx("span",{role:"status","aria-live":"polite",className:"sr-only",children:D})]})},Lm={checkNumberLabel:"Check Number",checkNumberPlaceholder:"e.g. 11234",bankNameLabel:"Bank Name",bankNamePlaceholder:"e.g. Chase Bank",dateLabel:"Date",checkNumberRequiredMessage:"Check number is required"},Ji=()=>{const e=new Date,t=n=>String(n).padStart(2,"0");return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`},no=({dueAmount:e,value:t,defaultValue:n,onChange:r,labels:s,hideDate:i=!1,hideBankName:a=!1,isDisabled:o=!1,checkNumberMaxLength:c=34,bankNameMaxLength:d=100,autoFocus:u=!1,className:h,"data-testid":p="check-tender-form"})=>{const m={...Lm,...s},v=t!==void 0,[b,x]=y.useState({checkNumber:n?.checkNumber??"",bankName:n?.bankName??"",date:n?.date??Ji()}),[w,S]=y.useState(!!n?.checkNumber),M=y.useMemo(()=>v?{checkNumber:t?.checkNumber??"",bankName:t?.bankName??"",date:t?.date??Ji()}:b,[v,t,b]),N=y.useCallback(E=>{v||x(E);const C=E.checkNumber.trim(),I={amount:e.value,checkNumber:C,bankName:E.bankName.trim()||void 0,date:i?void 0:E.date,isValid:C.length>0&&e.value>0};r?.(I)},[v,e.value,i,r]),j=y.useCallback(E=>C=>{o||(E==="checkNumber"&&C.length>0&&S(!0),N({...M,[E]:C}))},[M,N,o]),T=y.useCallback(()=>{o||S(!0)},[o]),$=w&&M.checkNumber.trim()==="",W=`${p}-check-number`,D=`${p}-bank-name`,R=`${p}-date`;return l.jsxs("div",{className:f.cn("grid grid-cols-1 sm:grid-cols-2 gap-4",h),"data-testid":p,children:[l.jsx(f.Input,{id:W,label:m.checkNumberLabel,labelPlacement:"outside",type:"text",value:M.checkNumber,onChange:E=>j("checkNumber")(E.target.value),onBlur:T,placeholder:m.checkNumberPlaceholder,maxLength:c,isRequired:!0,isInvalid:$,errorMessage:$?m.checkNumberRequiredMessage:void 0,isDisabled:o,variant:"bordered",radius:"lg",autoFocus:u,"data-testid":`${p}-check-number-input`}),!a&&l.jsx(f.Input,{id:D,label:m.bankNameLabel,labelPlacement:"outside",type:"text",value:M.bankName,onChange:E=>j("bankName")(E.target.value),placeholder:m.bankNamePlaceholder,maxLength:d,isDisabled:o,variant:"bordered",radius:"lg","data-testid":`${p}-bank-name-input`}),!i&&l.jsx(f.Input,{id:R,label:m.dateLabel,labelPlacement:"outside",type:"date",value:M.date,onChange:E=>j("date")(E.target.value),isDisabled:o,variant:"bordered",radius:"lg","data-testid":`${p}-date-input`,className:"sm:col-span-2"})]})};no.displayName="CheckTenderForm";const Fm={methodLabel:"Method",methodPlaceholder:"Select a payment method",referenceLabel:"Reference",referencePlaceholder:"e.g. Voucher #1234",methodRequiredMessage:"Method is required"},Pm=[{value:"ach",label:"ACH"},{value:"wire",label:"Wire"},{value:"gift_card",label:"Gift Card"},{value:"voucher",label:"Voucher"},{value:"other",label:"Other"}],ro=({dueAmount:e,methodOptions:t=Pm,value:n,defaultValue:r,onChange:s,labels:i,showReference:a=!1,isDisabled:o=!1,className:c,"data-testid":d="other-tender-form"})=>{const u={...Fm,...i},h=n!==void 0,[p,m]=y.useState({method:r?.method??"",reference:r?.reference??""}),v=y.useMemo(()=>h?{method:n?.method??"",reference:n?.reference??""}:p,[h,n,p]),b=y.useCallback(j=>t.find(T=>T.value===j)?.label??"",[t]),x=y.useCallback(j=>{h||m(j);const T=b(j.method),$={amount:e.value,method:j.method,description:T,reference:j.reference.trim()||void 0,isValid:j.method!==""};s?.($)},[h,e.value,s,b]),w=y.useCallback(j=>{if(o)return;const T=typeof j=="string"?j:Array.from(j)[0]?.toString()??"";x({...v,method:T})},[v,x,o]),S=y.useCallback(j=>{o||x({...v,reference:j})},[v,x,o]),M=`${d}-method`,N=`${d}-reference`;return l.jsxs("div",{className:f.cn("flex flex-col gap-3",c),"data-testid":d,children:[l.jsx(yt,{id:M,label:u.methodLabel,labelPlacement:"outside",placeholder:u.methodPlaceholder,selectedKeys:v.method?[v.method]:[],onSelectionChange:w,isDisabled:o,isRequired:!0,variant:"bordered",radius:"lg","data-testid":`${d}-method-select`,popoverProps:{placement:"bottom-start",classNames:{content:"bg-white border border-default-200 shadow-lg rounded-xl p-1"}},listboxProps:{classNames:{list:"max-h-[var(--popover-available-height,40vh)] overflow-y-auto"},itemClasses:{base:["rounded-lg","px-3 py-2","text-default-800","data-[hover=true]:bg-default-100","data-[selectable=true]:focus:bg-default-100","data-[selected=true]:bg-primary-50","data-[selected=true]:text-primary","data-[selected=true]:font-medium"]}},children:t.map(j=>l.jsx(f.SelectItem,{"data-testid":`${d}-method-option-${j.value}`,children:j.label},j.value))}),a&&l.jsx(f.Input,{id:N,label:u.referenceLabel,labelPlacement:"outside",type:"text",value:v.reference,onChange:j=>S(j.target.value),placeholder:u.referencePlaceholder,isDisabled:o,variant:"bordered",radius:"lg","data-testid":`${d}-reference-input`})]})};ro.displayName="OtherTenderForm";const Rm={collectedHeading:"Collected",remainingLabel:"Remaining:",completeLabel:"Complete",removeAriaLabel:"Remove this tender",removeTooltipForRecorded:"Already recorded",statusPending:"Pending",statusRecorded:"Approved",statusFailed:"Failed"},zm={card:"lucide:credit-card",cash:"lucide:dollar-sign",check:"lucide:edit-3",other:"lucide:more-horizontal"},Bm={pending:"warning",recorded:"success",failed:"danger"},_m=e=>e==="pending"||e==="recorded",Vm=e=>`#${e+1}`,so=({total:e,tenders:t,onRemove:n,locale:r="en-US",labels:s,hideCollectedList:i=!1,className:a,"data-testid":o="split-payment-summary"})=>{const c={...Rm,...s},{collected:d,remaining:u,isComplete:h}=y.useMemo(()=>{const m=t.reduce((b,x)=>_m(x.status)?b+x.amount:b,0),v=Math.max(e.value-m,0);return{collected:m,remaining:v,isComplete:m>=e.value&&e.value>0}},[t,e.value]),p=m=>m==="pending"?c.statusPending:m==="recorded"?c.statusRecorded:c.statusFailed;return l.jsxs("div",{className:f.cn("flex flex-col gap-4",a),"data-testid":o,children:[l.jsxs("div",{className:"rounded-2xl bg-default-100 px-6 py-5 text-center","data-testid":`${o}-remaining-banner`,children:[l.jsx("div",{className:"text-sm text-default-600",children:h?c.completeLabel:c.remainingLabel}),l.jsx("div",{className:"mt-1 text-4xl font-bold tracking-tight","data-testid":`${o}-remaining-amount`,children:rt(h?d:u,r,e.currency)})]}),!i&&t.length>0&&l.jsxs("div",{className:"flex flex-col gap-2","data-testid":`${o}-collected-list`,children:[l.jsx("h3",{className:"text-base font-semibold",children:c.collectedHeading}),t.map((m,v)=>l.jsx(Hm,{index:v,tender:m,locale:r,currency:e.currency,removable:!!n&&m.status!=="recorded",onRemove:n?()=>n(m.id):void 0,statusLabel:p(m.status),removeAriaLabel:c.removeAriaLabel,recordedTooltip:c.removeTooltipForRecorded,dataTestId:`${o}-row-${v}`},m.id))]})]})};so.displayName="SplitPaymentSummary";const Hm=({index:e,tender:t,locale:n,currency:r,removable:s,onRemove:i,statusLabel:a,removeAriaLabel:o,recordedTooltip:c,dataTestId:d})=>{const u=i?l.jsx(K,{isIconOnly:!0,variant:"light",radius:"full",size:"sm",onPress:i,isDisabled:!s,"aria-label":o,"data-testid":`${d}-remove`,className:f.cn(s?"text-default-700 hover:bg-default-200":"text-default-300"),children:l.jsx(U,{icon:"lucide:x",width:18,height:18,"aria-hidden":"true"})}):null;return l.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":d,children:[l.jsx("span",{className:"text-sm font-medium text-default-500 w-6 shrink-0",children:Vm(e)}),l.jsx(U,{icon:zm[t.type],width:20,height:20,className:"text-default-700 shrink-0","aria-hidden":"true"}),l.jsx("span",{className:"flex-1 truncate","data-testid":`${d}-label`,children:t.label}),l.jsx("span",{className:"font-semibold tabular-nums","data-testid":`${d}-amount`,children:rt(t.amount,n,r)}),l.jsx(f.Chip,{size:"sm",radius:"full",variant:"flat",color:Bm[t.status],startContent:t.status==="recorded"?l.jsx(U,{icon:"lucide:check-circle",width:14,height:14,"aria-hidden":"true"}):t.status==="failed"?l.jsx(U,{icon:"lucide:alert-circle",width:14,height:14,"aria-hidden":"true"}):void 0,"data-testid":`${d}-status`,children:a}),u&&(s?u:l.jsx(f.Tooltip,{content:c,placement:"left",children:l.jsx("span",{tabIndex:0,"aria-label":c,children:u})}))]})},Um=`
|
|
20
20
|
@keyframes pp-modal-in {
|
|
21
21
|
from { opacity: 0; transform: scale(0.96); }
|
|
22
22
|
to { opacity: 1; transform: scale(1); }
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
from { opacity: 0; transform: translateY(-6px); }
|
|
42
42
|
to { opacity: 1; transform: translateY(0); }
|
|
43
43
|
}
|
|
44
|
-
`,Ul=y.forwardRef(({children:e,relativeOverlayRoot:t=!0,className:n,style:r,"data-testid":s="modal-shell"},i)=>o.jsxs(o.Fragment,{children:[o.jsx("style",{children:bm}),o.jsx("div",{ref:i,"data-testid":s,style:r,className:h.cn("flex flex-col gap-4 p-4 rounded-3xl bg-white shadow-xl","md:gap-5 md:p-6",t&&"relative","motion-safe:animate-[pp-modal-in_220ms_ease-out]","motion-safe:transition-[min-height] motion-safe:duration-[420ms] motion-safe:ease-in-out",n),children:e})]}));Ul.displayName="ModalShell";const ql=({title:e,onClose:t,closeLabel:n="Close",actions:r,className:s,"data-testid":i="modal-shell-header"})=>o.jsxs("header",{className:h.cn("flex items-center justify-between",s),"data-testid":i,children:[o.jsx("h2",{className:"text-xl font-semibold","data-testid":`${i}-title`,children:e}),o.jsxs("div",{className:"flex items-center gap-2",children:[r,t&&o.jsx(W,{isIconOnly:!0,variant:"light",radius:"full",size:"sm",onPress:t,"aria-label":n,"data-testid":`${i}-close`,children:o.jsx(H,{icon:"lucide:x",width:20,height:20,"aria-hidden":"true"})})]})]});ql.displayName="ModalShellHeader";const Wl=({children:e,columns:t=2,className:n,"data-testid":r="modal-shell-footer"})=>o.jsx("footer",{className:h.cn("mt-2 gap-3",t===2?"flex flex-col md:grid md:grid-cols-2 [&>*]:w-full [&>*:first-child]:md:order-2 [&>*:nth-child(2)]:md:order-1":"grid grid-cols-1",n),"data-testid":r,children:e});Wl.displayName="ModalShellFooter";const vm={2:"sm:grid-cols-2",3:"sm:grid-cols-3",4:"sm:grid-cols-4"},wm={1:"grid-cols-1",2:"grid-cols-2"},mr=e=>typeof e=="string"?o.jsx(H,{icon:e,width:20,height:20,"aria-hidden":"true"}):e,Kl=({options:e,selectedKey:t,onSelect:n,heading:r,ariaLabel:s="Select an option",columnsDesktop:i=3,columnsMobile:a=2,className:l,"data-testid":c="tile-select"})=>{const d=e.find(u=>u.key===t);return o.jsxs("div",{className:h.cn("flex flex-col gap-3",l),"data-testid":c,children:[r&&o.jsx("h3",{className:"text-sm font-medium text-default-700",id:`${c}-heading`,children:r}),o.jsx("div",{className:"md:hidden",children:o.jsx(pt,{"aria-label":r?void 0:s,"aria-labelledby":r?`${c}-heading`:void 0,selectedKeys:t?[t]:[],onSelectionChange:u=>{const p=Array.from(u)[0];typeof p=="string"&&n(p)},placeholder:s,variant:"bordered",radius:"lg","data-testid":`${c}-mobile-select`,startContent:d?o.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:mr(d.icon)}):void 0,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:e.map(u=>o.jsx(h.SelectItem,{isDisabled:u.isDisabled,startContent:o.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:mr(u.icon)}),"data-testid":u["data-testid"]??`${c}-${u.key}-mobile`,children:u.label},u.key))})}),o.jsx("div",{role:"group","aria-labelledby":r?`${c}-heading`:void 0,"aria-label":r?void 0:s,className:h.cn("hidden md:grid gap-3",wm[a],vm[i]),children:e.map(u=>{const f=t===u.key;return o.jsxs(W,{variant:"bordered",radius:"lg","aria-pressed":f,"aria-label":u.label,isDisabled:u.isDisabled,onPress:()=>n(u.key),"data-testid":u["data-testid"]??`${c}-${u.key}`,className:h.cn("flex flex-col items-center justify-center gap-2 h-auto min-h-[80px] px-4 py-4","border bg-transparent transition-colors",f?"border-primary bg-primary-50 text-primary":"border-default-200 text-default-800 hover:bg-default-50"),children:[o.jsx("span",{"aria-hidden":"true",children:mr(u.icon)}),o.jsx("span",{className:"text-sm font-medium",children:u.label})]},u.key)})})]})};Kl.displayName="TileSelect";const km={subtle:{wrapper:"bg-default-100",amount:"text-default-900"},success:{wrapper:"bg-success-50 text-success-700",amount:"text-success-700"}},Jl=({total:e,label:t,locale:n="en-US",variant:r="subtle",className:s,"data-testid":i="payment-total-banner"})=>{const a=km[r];return o.jsxs("div",{"data-testid":i,className:h.cn("rounded-2xl px-6 py-5 text-center",a.wrapper,s),children:[o.jsx("div",{className:"text-sm text-default-600",children:t}),o.jsx("div",{className:h.cn("mt-1 text-4xl font-bold tracking-tight",a.amount),"data-testid":`${i}-amount`,children:tt(e.value,n,e.currency)})]})};Jl.displayName="PaymentTotalBanner";const Nm={white:"bg-white/70 backdrop-blur-sm",transparent:"bg-transparent"},Yl=({title:e,subtitle:t,backdrop:n="white",exiting:r=!1,className:s,"data-testid":i="loading-overlay"})=>o.jsxs("div",{role:"status","aria-live":r?"off":"polite","aria-hidden":r||void 0,"data-testid":i,"data-state":r?"exiting":"visible",className:h.cn("absolute inset-0 z-10 flex flex-col items-center justify-center gap-4 rounded-3xl",Nm[n],r?"pointer-events-none motion-safe:animate-[pp-fade-out_280ms_ease-in_forwards]":"motion-safe:animate-[pp-fade-in_150ms_ease-out]",s),children:[o.jsx("div",{"aria-hidden":"true","data-testid":`${i}-spinner`,className:"h-16 w-16 rounded-full border-4 border-primary-100 border-t-primary animate-spin motion-safe:animate-[pp-scale-in_200ms_ease-out,spin_1s_linear_infinite]"}),o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"text-xl font-semibold","data-testid":`${i}-title`,children:e}),t&&o.jsx("div",{className:"mt-1 text-sm text-default-600",children:t})]})]});Yl.displayName="LoadingOverlay";const gs=({cashChange:e,label:t="Cash to return",secondaryLine:n,locale:r="en-US",onDismiss:s,dismissAriaLabel:i="Dismiss",align:a="left",className:l,"data-testid":c="payment-cash-change-banner"})=>{if(!e||e.value<=0)return null;const d=a==="center";return o.jsxs("div",{role:"status","aria-live":"polite","data-testid":c,className:h.cn("flex w-full items-center gap-3 rounded-2xl border border-info-200 bg-info-50 px-5 py-4",d?"justify-center text-center":"text-left","motion-safe:animate-[pp-slide-down_200ms_ease-out]",l),children:[o.jsx(H,{icon:"lucide:info",width:28,height:28,className:"shrink-0 text-info-700","aria-hidden":"true"}),o.jsxs("div",{className:h.cn("flex flex-col",d?"items-center":"flex-1"),children:[o.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-info-700",children:t}),o.jsx("span",{className:"text-2xl font-bold text-info-700","data-testid":`${c}-amount`,children:tt(e.value,r,e.currency)}),n&&o.jsx("span",{className:"mt-0.5 text-xs text-info-700/80",children:n})]}),s&&o.jsx(W,{isIconOnly:!0,variant:"light",radius:"full",size:"sm",onPress:s,"aria-label":i,"data-testid":`${c}-dismiss`,className:"shrink-0 text-info-700 hover:bg-info-100",children:o.jsx(H,{icon:"lucide:x",width:18,height:18,"aria-hidden":"true"})})]})};gs.displayName="PaymentCashChangeBanner";const Gl=({title:e,subtitle:t,emailLine:n,confirmationEmail:r,cashChange:s,cashChangeLabel:i="Cash to return",locale:a="en-US",closeLabel:l="Close",onClose:c,className:d,"data-testid":u="payment-success-view"})=>{const f=!!(s&&s.value>0);return o.jsxs("div",{"data-testid":u,className:h.cn("flex flex-col items-center gap-6 py-8 px-4 text-center","motion-safe:animate-[pp-fade-in_250ms_ease-out]",d),children:[o.jsx("div",{"aria-hidden":"true",className:"flex items-center justify-center rounded-full bg-[#A2D9C6] p-[10px]",children:o.jsx(H,{icon:"gravity-ui:circle-check-fill",width:76,height:76,className:"text-[#10B981]","aria-hidden":"true"})}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("h2",{className:"text-2xl font-bold","data-testid":`${u}-title`,children:e}),o.jsx("p",{className:"text-default-700",children:t}),n&&r&&o.jsxs("p",{className:"text-default-700",children:[n,o.jsx("br",{}),o.jsx("strong",{className:"font-semibold",children:r})]})]}),f&&s&&o.jsx(gs,{cashChange:s,label:i,locale:a,align:"center",className:"max-w-[400px]","data-testid":`${u}-cash-change`}),c&&o.jsx(W,{color:"default",variant:"bordered",radius:"full",size:"lg",onPress:c,"data-testid":`${u}-close`,className:"mt-4 w-full",children:l})]})};Gl.displayName="PaymentSuccessView";const Ql=({heading:e,amountLabel:t,value:n,defaultValue:r,onChange:s,placeholder:i,isDisabled:a,isInvalid:l,errorMessage:c,autoFocus:d,maxAmount:u,className:f,"data-testid":p="payment-sub-amount-input"})=>{const m=`${p}-input`,v=y.useCallback(x=>{if(u!==void 0){const w=Number.parseFloat(x.replace(",","."));if(Number.isFinite(w)&&w>u)return}s?.(x)},[u,s]),b=y.useCallback(x=>{const w=x.currentTarget;requestAnimationFrame(()=>{w.isConnected&&w.select()})},[]);return o.jsxs("div",{className:h.cn("flex flex-col gap-3 border-t border-default-100 pt-5",f),"data-testid":p,children:[o.jsx("h3",{className:"text-lg font-semibold","data-testid":`${p}-heading`,children:e}),o.jsx(h.Input,{id:m,label:t,labelPlacement:"outside",type:"text",inputMode:"decimal",pattern:"[0-9]*[.,]?[0-9]*",value:n,defaultValue:r,onChange:x=>v(x.target.value),onFocus:b,placeholder:i,isDisabled:a,isInvalid:l,errorMessage:l?c:void 0,variant:"bordered",radius:"lg","aria-invalid":l||void 0,autoFocus:d,"data-testid":`${p}-field`})]})};Ql.displayName="PaymentSubAmountInput";const Zl=({isOpen:e,title:t,body:n,confirmLabel:r,confirmVariant:s="danger",dismissLabel:i,onConfirm:a,onDismiss:l,"data-testid":c="confirm-dialog"})=>o.jsx(h.Modal,{isOpen:e,onOpenChange:d=>{d||l()},role:"alertdialog",size:"sm",backdrop:"opaque","data-testid":c,"aria-labelledby":`${c}-title`,"aria-describedby":`${c}-body`,children:o.jsxs(h.ModalContent,{children:[o.jsx(h.ModalHeader,{id:`${c}-title`,className:"text-lg font-semibold",children:t}),o.jsx(h.ModalBody,{id:`${c}-body`,className:"text-sm text-default-700",children:n}),o.jsxs(h.ModalFooter,{className:"grid grid-cols-2 gap-3",children:[o.jsx(W,{variant:"bordered",radius:"full",onPress:l,"data-testid":`${c}-dismiss`,className:"h-11",children:i}),o.jsx(W,{color:s,variant:"solid",radius:"full",onPress:a,"data-testid":`${c}-confirm`,className:"h-11",children:r})]})]})});Zl.displayName="ConfirmDialog";const Sm=60,Cm=(e,t,n=Sm)=>t?e>n:e<-n,Xl=(e,t)=>Math.max(0,Math.min(e,t)),jm=(e,t,n)=>Xl(e-t,n),Am=(e,t,n)=>e!==null?Xl(e,n):t?n:0,Mm=e=>e?"":"transition-[height] duration-300 ease-out",Em=e=>({onDrag:(t,n)=>{const r=e.open?e.fullHeight:0;e.setDragHeight(jm(r,n?.offset?.y??0,e.fullHeight))},onDragEnd:(t,n)=>{Cm(n?.offset?.y??0,e.open)&&e.onToggleOpen?.(),e.setDragHeight(null)}}),Qt=(e,t)=>tt(e.value,t,e.currency),xs=({item:e,locale:t,onRemove:n,removeAriaLabel:r})=>{const s=!!e.children&&e.children.length>0;return o.jsxs("div",{"data-testid":`summary-item-${e.id}`,className:"flex flex-col gap-2",children:[o.jsxs("div",{className:"flex min-h-9 items-center justify-between gap-2",children:[o.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-base text-foreground",children:[typeof e.quantity=="number"&&o.jsxs("span",{"data-testid":`summary-item-qty-${e.id}`,className:"shrink-0",children:[e.quantity," x"]}),e.leadingIcon,o.jsx("span",{"data-testid":`summary-item-name-${e.id}`,className:h.cn("truncate",e.emphasis&&"font-medium"),children:e.name})]}),o.jsxs("div",{className:"flex shrink-0 items-center",children:[e.amount&&o.jsx("span",{"data-testid":`summary-item-amount-${e.id}`,className:"whitespace-nowrap text-base text-foreground",children:Qt(e.amount,t)}),n&&o.jsx(W,{isIconOnly:!0,size:"sm",variant:"light",radius:"full",className:"ml-1 size-8 min-w-8 p-2 text-danger","aria-label":r,"data-testid":`summary-remove-${e.id}`,onPress:()=>n(e.id),children:o.jsx(H,{icon:"lucide:trash-2",width:16,height:16,className:"text-danger"})})]})]}),e.dateLabel&&o.jsxs("div",{"data-testid":`summary-item-date-${e.id}`,className:"flex items-center gap-2 text-sm text-default-500",children:[o.jsx(H,{icon:"lucide:calendar",width:16,height:16,className:"shrink-0"}),o.jsx("span",{className:"truncate",children:e.dateLabel})]}),e.dateRange&&o.jsxs("div",{"data-testid":`summary-item-daterange-${e.id}`,className:"flex items-center gap-2 text-sm text-default-500",children:[o.jsx(H,{icon:"lucide:calendar",width:16,height:16,className:"shrink-0"}),o.jsx("span",{children:e.dateRange.from}),o.jsx(H,{icon:"lucide:arrow-right",width:16,height:16,className:"shrink-0"}),o.jsx("span",{children:e.dateRange.to})]}),s&&o.jsx("div",{"data-testid":`summary-children-${e.id}`,className:"flex flex-col gap-2 pl-6",children:e.children.map(i=>o.jsx(xs,{item:i,locale:t,onRemove:n,removeAriaLabel:r},i.id))})]})};xs.displayName="SummaryItemRow";const eo=({fee:e,locale:t,className:n})=>o.jsxs("div",{"data-testid":"summary-service-fee",className:h.cn("flex items-center justify-between gap-2",n),children:[o.jsxs("button",{type:"button",role:"switch","aria-checked":!!e.isSelected,"aria-label":typeof e.label=="string"?e.label:"Pay Service fee","data-testid":"summary-service-fee-toggle",onClick:e.onToggle,className:"flex min-w-0 items-center gap-2 text-left",children:[o.jsx("span",{"aria-hidden":"true",className:h.cn("flex size-4 shrink-0 items-center justify-center rounded-full border",e.isSelected?"border-primary":"border-default-200"),children:e.isSelected&&o.jsx("span",{className:"size-2 rounded-full bg-primary"})}),o.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:e.label})]}),o.jsx("span",{"data-testid":"summary-service-fee-amount",className:"whitespace-nowrap text-base text-foreground",children:Qt(e.amount,t)})]});eo.displayName="SummaryServiceFeeRow";const to=({row:e,locale:t,emphasized:n})=>o.jsxs("div",{"data-testid":`summary-row-${e.key}`,className:"flex items-center justify-between text-foreground",children:[o.jsx("span",{"data-testid":`summary-row-label-${e.key}`,className:h.cn(n?"text-xl font-semibold leading-7":"text-base"),children:e.label}),o.jsx("span",{"data-testid":`summary-row-amount-${e.key}`,className:"whitespace-nowrap text-base",children:Qt(e.amount,t)})]});to.displayName="SummaryTotalsLineRow";const no=({pricesInLabel:e,currency:t,items:n,serviceFee:r,rows:s,locale:i,onRemoveItem:a,removeAriaLabel:l,emptyState:c,classNames:d})=>{const u=(n?.length??0)>0;return o.jsxs(o.Fragment,{children:[o.jsxs("div",{"data-testid":"summary-prices",className:h.cn("flex items-center justify-between text-xs text-default-500",d.prices),children:[o.jsx("span",{children:e}),t!=null&&o.jsx("span",{children:t})]}),u?o.jsx("div",{className:h.cn("flex flex-col gap-4",d.items),children:n.map(f=>o.jsx(xs,{item:f,locale:i,onRemove:a,removeAriaLabel:l},f.id))}):o.jsx("div",{"data-testid":"summary-empty",children:c}),r&&o.jsxs(o.Fragment,{children:[o.jsx(h.Divider,{className:"bg-default-200"}),o.jsx(eo,{fee:r,locale:i,className:d.serviceFee})]}),s&&s.length>0&&o.jsx("div",{className:h.cn("flex flex-col gap-4",d.totalsRows),children:s.map((f,p)=>o.jsx(to,{row:f,locale:i,emphasized:p===0},f.key))})]})};no.displayName="SummaryBody";const ro=({total:e,locale:t,className:n})=>o.jsxs("div",{"data-testid":"summary-total",className:h.cn("flex items-center justify-between text-xl font-semibold leading-7 text-foreground",n),children:[o.jsx("span",{children:e.label??"Total"}),o.jsx("span",{"data-testid":"summary-total-amount",className:"whitespace-nowrap text-xl font-semibold leading-7",children:Qt(e.amount,t)})]});ro.displayName="SummaryGrandTotalRow";const En=({action:e,disabledByLoading:t,className:n,testId:r="summary-cta"})=>o.jsx(W,{color:"primary",radius:"full",className:h.cn("px-[18px] py-[14px] font-medium",n),"data-testid":r,isLoading:e.isLoading,isDisabled:e.isDisabled||t,onPress:e.onPress,endContent:o.jsx(H,{icon:"lucide:arrow-right",width:16,height:16}),children:e.label});En.displayName="SummaryPrimaryCta";const so=({title:e,total:t,locale:n,open:r,progress:s,dragging:i,toggleAriaLabel:a,onToggleOpen:l,classNames:c})=>o.jsx("h2",{children:o.jsxs("button",{type:"button","data-testid":"summary-collapse-toggle","aria-expanded":r,"aria-label":a,onClick:l,className:h.cn("-mx-4 -mt-4 grid w-[calc(100%_+_32px)] grid-cols-1 px-4 pb-4 pt-4 text-left",c.header),children:[o.jsxs("span",{"aria-hidden":!r,style:{opacity:s},className:h.cn("col-start-1 row-start-1 flex items-center justify-between",!i&&"transition-opacity duration-300"),children:[o.jsx("span",{"data-testid":"summary-title",className:h.cn("text-xl font-semibold leading-7 text-foreground",c.title),children:e}),o.jsx("span",{"data-testid":"summary-close","aria-hidden":"true",className:h.cn("shrink-0 text-foreground",c.closeButton),children:o.jsx(H,{icon:"lucide:x",width:20,height:20})})]}),o.jsxs("span",{"aria-hidden":r,style:{opacity:1-s},className:h.cn("col-start-1 row-start-1 flex items-center justify-between text-xl font-semibold leading-7 text-foreground",!i&&"transition-opacity duration-300"),children:[o.jsx("span",{children:t.label??"Total"}),o.jsx("span",{className:"whitespace-nowrap",children:Qt(t.amount,n)})]})]})});so.displayName="SummaryCollapseHeader";const io=({cart:e,ariaLabel:t,onPress:n,className:r})=>o.jsxs("button",{type:"button","data-testid":"summary-cart","aria-label":t,onClick:n,className:h.cn("relative flex size-[52px] shrink-0 items-center justify-center rounded-full border border-default-200 bg-content1",r),children:[o.jsx(H,{icon:"lucide:shopping-bag",width:24,height:24,className:"text-foreground"}),e.count!=null&&o.jsx("span",{"data-testid":"summary-cart-badge",className:"absolute -right-1 -top-1 flex size-4 items-center justify-center rounded-full bg-primary text-xs text-primary-foreground",children:e.count})]});io.displayName="SummaryCartButton";const ao=({open:e,progress:t,dragging:n,primaryAction:r,isLoading:s,cart:i,cartAriaLabel:a,onToggleOpen:l,classNames:c})=>o.jsxs("div",{"data-testid":"summary-mobile-bar",className:h.cn("flex flex-col gap-4",c.mobileBar),children:[o.jsx(h.Divider,{className:"bg-default-200"}),o.jsxs("div",{className:"grid",children:[o.jsxs("div",{"aria-hidden":e,style:{opacity:1-t},className:h.cn("col-start-1 row-start-1 flex items-stretch gap-2.5",e&&"pointer-events-none",!n&&"transition-opacity duration-300"),children:[i&&o.jsx(io,{cart:i,ariaLabel:a,className:c.cart,onPress:()=>{l?.(),i.onPress?.()}}),r&&o.jsx(En,{action:r,disabledByLoading:s,className:h.cn("flex-1",c.cta),testId:"summary-cta-compact"})]}),r&&o.jsx("div",{"aria-hidden":!e,style:{opacity:t},className:h.cn("col-start-1 row-start-1 flex",!e&&"pointer-events-none",!n&&"transition-opacity duration-300"),children:o.jsx(En,{action:r,disabledByLoading:s,className:h.cn("w-full",c.cta)})})]})]});ao.displayName="SummaryActionBar";const Tm="(max-width: 767px)",Dm=e=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(e).matches:!1,Im=(e=Tm)=>{const[t,n]=y.useState(()=>Dm(e));return y.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const r=window.matchMedia(e),s=()=>n(r.matches);return s(),r.addEventListener("change",s),()=>r.removeEventListener("change",s)},[e]),t},lo=({title:e="Summary",pricesInLabel:t="Prices are in",currency:n,locale:r="en-US",items:s,serviceFee:i,rows:a,total:l,collapsible:c,isOpen:d,onToggleOpen:u,primaryAction:f,isLoading:p=!1,onRemoveItem:m,variant:v,cart:b,emptyState:x,labels:w,classNames:N={},"data-testid":A="summary",className:S})=>{const j=w?.removeAriaLabel??"Remove item",M=w?.toggleAriaLabel??"Toggle summary",I=w?.cartAriaLabel??"View cart",B=Im(),_=c??(v??(B?"mobile":"main"))==="mobile",E=!_||(d??!1),[T,O]=y.useState(0),[F,K]=y.useState(null),X=y.useCallback(ae=>{ae&&O(ae.scrollHeight)},[]),J=Em({open:E,fullHeight:T,setDragHeight:K,onToggleOpen:u}),se=F!==null,ie=Am(F,E,T),fe=T>0?Math.min(1,Math.max(0,ie/T)):E?1:0,Y=o.jsx(ro,{total:l,locale:r,className:N.total}),q=o.jsx(no,{pricesInLabel:t,currency:n,items:s,serviceFee:i,rows:a,locale:r,onRemoveItem:m,removeAriaLabel:j,emptyState:x,classNames:N});return _?o.jsxs(Le.motion.section,{"data-testid":A,drag:"y",dragConstraints:{top:0,bottom:0},dragElastic:.12,dragSnapToOrigin:!0,onDrag:J.onDrag,onDragEnd:J.onDragEnd,className:h.cn("fixed inset-x-0 bottom-0 z-50 flex w-full flex-col rounded-t-2xl bg-content1 p-4 drop-shadow-[0_-2px_2px_rgba(0,0,0,0.1)]",S,N.base),children:[o.jsx(so,{title:e,total:l,locale:r,open:E,progress:fe,dragging:se,toggleAriaLabel:M,onToggleOpen:u,classNames:N}),o.jsx("div",{"data-testid":"summary-reveal","aria-hidden":!E,style:{height:ie},className:h.cn("overflow-hidden",!E&&"pointer-events-none",Mm(se)),children:o.jsxs("div",{ref:X,className:"flex flex-col gap-4 pb-4",children:[q,o.jsx(h.Divider,{className:"bg-default-200"}),Y]})}),o.jsx(ao,{open:E,progress:fe,dragging:se,primaryAction:f,isLoading:p,cart:b,cartAriaLabel:I,onToggleOpen:u,classNames:N})]}):o.jsxs("section",{"data-testid":A,className:h.cn("flex w-full flex-col gap-4 rounded-2xl border border-default-200 bg-content1 p-4",S,N.base),children:[o.jsx("div",{className:h.cn("flex items-center justify-between",N.header),children:o.jsx("h2",{"data-testid":"summary-title",className:h.cn("text-xl font-semibold leading-7 text-foreground",N.title),children:e})}),q,o.jsx(h.Divider,{className:"bg-default-200"}),Y,f&&o.jsx(En,{action:f,disabledByLoading:p,className:h.cn("w-full",N.cta)})]})};lo.displayName="Summary";exports.Button=W;exports.CashTenderForm=cm;exports.CheckTenderForm=_l;exports.CommitmentDetails=dh;exports.ConfirmDialog=Zl;exports.ConfirmationModal=jn;exports.ConfirmationPageTemplate=Eo;exports.DonationAmounts=Pa;exports.EventDetails=bf;exports.EventDetailsTemplate=Io;exports.ExpireCartTimer=Ra;exports.Footer=$o;exports.HeroUIProvider=No;exports.InstallmentFundAssignment=sh;exports.InstallmentFundAssignmentSkeleton=oh;exports.InstallmentSchedule=Rh;exports.InstallmentScheduleSkeleton=Uh;exports.InstallmentTable=Wh;exports.ItemCard=Rl;exports.LoadingOverlay=Yl;exports.MembershipSelectCards=Gh;exports.ModalShell=Ul;exports.ModalShellFooter=Wl;exports.ModalShellHeader=ql;exports.Multiselect=Oo;exports.Navbar=Mo;exports.OfferCard=rs;exports.OfferCardEmpty=Xa;exports.OfferCardError=el;exports.OfferCardList=sl;exports.OfferCardSkeleton=tl;exports.OtherTenderForm=Vl;exports.PaymentCashChangeBanner=gs;exports.PaymentSubAmountInput=Ql;exports.PaymentSuccessView=Gl;exports.PaymentTotalBanner=Jl;exports.RICH_TEXT_PRESETS=La;exports.RevenueDistributionCard=gl;exports.RevenueDistributionEmpty=xl;exports.RevenueDistributionError=yl;exports.RevenueDistributionSkeleton=bl;exports.RichTextArea=Fa;exports.Select=pt;exports.SplitPaymentSummary=Hl;exports.Stepper=_i;exports.Summary=lo;exports.TicketSelection=am;exports.TileSelect=Kl;exports.Toggle=zl;exports.calculateAllocationDifference=Qf;exports.computeChange=pr;exports.currencyFractionDigits=Br;exports.formatMoney=tt;exports.formatOfferCurrency=Za;exports.formatRevenueAmount=Kf;exports.formatRevenueCurrency=Jf;exports.generateAutomaticInstallments=Ll;exports.generateDistributionId=us;exports.getCurrencySymbol=Yf;exports.offerCardVariants=rl;exports.offerListVariants=nl;exports.parseOfferCurrency=vf;exports.parseRevenueCurrency=Gf;exports.roundToCurrency=Vi;Object.keys(h).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>h[e]})});
|
|
44
|
+
`,io=y.forwardRef(({children:e,relativeOverlayRoot:t=!0,className:n,style:r,"data-testid":s="modal-shell"},i)=>l.jsxs(l.Fragment,{children:[l.jsx("style",{children:Um}),l.jsx("div",{ref:i,"data-testid":s,style:r,className:f.cn("flex flex-col gap-4 p-4 rounded-3xl bg-white shadow-xl","md:gap-5 md:p-6",t&&"relative","motion-safe:animate-[pp-modal-in_220ms_ease-out]","motion-safe:transition-[min-height] motion-safe:duration-[420ms] motion-safe:ease-in-out",n),children:e})]}));io.displayName="ModalShell";const ao=({title:e,onClose:t,closeLabel:n="Close",actions:r,className:s,"data-testid":i="modal-shell-header"})=>l.jsxs("header",{className:f.cn("flex items-center justify-between",s),"data-testid":i,children:[l.jsx("h2",{className:"text-xl font-semibold","data-testid":`${i}-title`,children:e}),l.jsxs("div",{className:"flex items-center gap-2",children:[r,t&&l.jsx(K,{isIconOnly:!0,variant:"light",radius:"full",size:"sm",onPress:t,"aria-label":n,"data-testid":`${i}-close`,children:l.jsx(U,{icon:"lucide:x",width:20,height:20,"aria-hidden":"true"})})]})]});ao.displayName="ModalShellHeader";const lo=({children:e,columns:t=2,className:n,"data-testid":r="modal-shell-footer"})=>l.jsx("footer",{className:f.cn("mt-2 gap-3",t===2?"flex flex-col md:grid md:grid-cols-2 [&>*]:w-full [&>*:first-child]:md:order-2 [&>*:nth-child(2)]:md:order-1":"grid grid-cols-1",n),"data-testid":r,children:e});lo.displayName="ModalShellFooter";const qm={2:"sm:grid-cols-2",3:"sm:grid-cols-3",4:"sm:grid-cols-4"},Wm={1:"grid-cols-1",2:"grid-cols-2"},Sr=e=>typeof e=="string"?l.jsx(U,{icon:e,width:20,height:20,"aria-hidden":"true"}):e,oo=({options:e,selectedKey:t,onSelect:n,heading:r,ariaLabel:s="Select an option",columnsDesktop:i=3,columnsMobile:a=2,className:o,"data-testid":c="tile-select"})=>{const d=e.find(u=>u.key===t);return l.jsxs("div",{className:f.cn("flex flex-col gap-3",o),"data-testid":c,children:[r&&l.jsx("h3",{className:"text-sm font-medium text-default-700",id:`${c}-heading`,children:r}),l.jsx("div",{className:"md:hidden",children:l.jsx(yt,{"aria-label":r?void 0:s,"aria-labelledby":r?`${c}-heading`:void 0,selectedKeys:t?[t]:[],onSelectionChange:u=>{const p=Array.from(u)[0];typeof p=="string"&&n(p)},placeholder:s,variant:"bordered",radius:"lg","data-testid":`${c}-mobile-select`,startContent:d?l.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:Sr(d.icon)}):void 0,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:e.map(u=>l.jsx(f.SelectItem,{isDisabled:u.isDisabled,startContent:l.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:Sr(u.icon)}),"data-testid":u["data-testid"]??`${c}-${u.key}-mobile`,children:u.label},u.key))})}),l.jsx("div",{role:"group","aria-labelledby":r?`${c}-heading`:void 0,"aria-label":r?void 0:s,className:f.cn("hidden md:grid gap-3",Wm[a],qm[i]),children:e.map(u=>{const h=t===u.key;return l.jsxs(K,{variant:"bordered",radius:"lg","aria-pressed":h,"aria-label":u.label,isDisabled:u.isDisabled,onPress:()=>n(u.key),"data-testid":u["data-testid"]??`${c}-${u.key}`,className:f.cn("flex flex-col items-center justify-center gap-2 h-auto min-h-[80px] px-4 py-4","border bg-transparent transition-colors",h?"border-primary bg-primary-50 text-primary":"border-default-200 text-default-800 hover:bg-default-50"),children:[l.jsx("span",{"aria-hidden":"true",children:Sr(u.icon)}),l.jsx("span",{className:"text-sm font-medium",children:u.label})]},u.key)})})]})};oo.displayName="TileSelect";const Km={subtle:{wrapper:"bg-default-100",amount:"text-default-900"},success:{wrapper:"bg-success-50 text-success-700",amount:"text-success-700"}},co=({total:e,label:t,locale:n="en-US",variant:r="subtle",className:s,"data-testid":i="payment-total-banner"})=>{const a=Km[r];return l.jsxs("div",{"data-testid":i,className:f.cn("rounded-2xl px-6 py-5 text-center",a.wrapper,s),children:[l.jsx("div",{className:"text-sm text-default-600",children:t}),l.jsx("div",{className:f.cn("mt-1 text-4xl font-bold tracking-tight",a.amount),"data-testid":`${i}-amount`,children:rt(e.value,n,e.currency)})]})};co.displayName="PaymentTotalBanner";const Jm={white:"bg-white/70 backdrop-blur-sm",transparent:"bg-transparent"},uo=({title:e,subtitle:t,backdrop:n="white",exiting:r=!1,className:s,"data-testid":i="loading-overlay"})=>l.jsxs("div",{role:"status","aria-live":r?"off":"polite","aria-hidden":r||void 0,"data-testid":i,"data-state":r?"exiting":"visible",className:f.cn("absolute inset-0 z-10 flex flex-col items-center justify-center gap-4 rounded-3xl",Jm[n],r?"pointer-events-none motion-safe:animate-[pp-fade-out_280ms_ease-in_forwards]":"motion-safe:animate-[pp-fade-in_150ms_ease-out]",s),children:[l.jsx("div",{"aria-hidden":"true","data-testid":`${i}-spinner`,className:"h-16 w-16 rounded-full border-4 border-primary-100 border-t-primary animate-spin motion-safe:animate-[pp-scale-in_200ms_ease-out,spin_1s_linear_infinite]"}),l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"text-xl font-semibold","data-testid":`${i}-title`,children:e}),t&&l.jsx("div",{className:"mt-1 text-sm text-default-600",children:t})]})]});uo.displayName="LoadingOverlay";const Cs=({cashChange:e,label:t="Cash to return",secondaryLine:n,locale:r="en-US",onDismiss:s,dismissAriaLabel:i="Dismiss",align:a="left",className:o,"data-testid":c="payment-cash-change-banner"})=>{if(!e||e.value<=0)return null;const d=a==="center";return l.jsxs("div",{role:"status","aria-live":"polite","data-testid":c,className:f.cn("flex w-full items-center gap-3 rounded-2xl border border-info-200 bg-info-50 px-5 py-4",d?"justify-center text-center":"text-left","motion-safe:animate-[pp-slide-down_200ms_ease-out]",o),children:[l.jsx(U,{icon:"lucide:info",width:28,height:28,className:"shrink-0 text-info-700","aria-hidden":"true"}),l.jsxs("div",{className:f.cn("flex flex-col",d?"items-center":"flex-1"),children:[l.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-info-700",children:t}),l.jsx("span",{className:"text-2xl font-bold text-info-700","data-testid":`${c}-amount`,children:rt(e.value,r,e.currency)}),n&&l.jsx("span",{className:"mt-0.5 text-xs text-info-700/80",children:n})]}),s&&l.jsx(K,{isIconOnly:!0,variant:"light",radius:"full",size:"sm",onPress:s,"aria-label":i,"data-testid":`${c}-dismiss`,className:"shrink-0 text-info-700 hover:bg-info-100",children:l.jsx(U,{icon:"lucide:x",width:18,height:18,"aria-hidden":"true"})})]})};Cs.displayName="PaymentCashChangeBanner";const fo=({title:e,subtitle:t,emailLine:n,confirmationEmail:r,cashChange:s,cashChangeLabel:i="Cash to return",locale:a="en-US",closeLabel:o="Close",onClose:c,className:d,"data-testid":u="payment-success-view"})=>{const h=!!(s&&s.value>0);return l.jsxs("div",{"data-testid":u,className:f.cn("flex flex-col items-center gap-6 py-8 px-4 text-center","motion-safe:animate-[pp-fade-in_250ms_ease-out]",d),children:[l.jsx("div",{"aria-hidden":"true",className:"flex items-center justify-center rounded-full bg-[#A2D9C6] p-[10px]",children:l.jsx(U,{icon:"gravity-ui:circle-check-fill",width:76,height:76,className:"text-[#10B981]","aria-hidden":"true"})}),l.jsxs("div",{className:"space-y-3",children:[l.jsx("h2",{className:"text-2xl font-bold","data-testid":`${u}-title`,children:e}),l.jsx("p",{className:"text-default-700",children:t}),n&&r&&l.jsxs("p",{className:"text-default-700",children:[n,l.jsx("br",{}),l.jsx("strong",{className:"font-semibold",children:r})]})]}),h&&s&&l.jsx(Cs,{cashChange:s,label:i,locale:a,align:"center",className:"max-w-[400px]","data-testid":`${u}-cash-change`}),c&&l.jsx(K,{color:"default",variant:"bordered",radius:"full",size:"lg",onPress:c,"data-testid":`${u}-close`,className:"mt-4 w-full",children:o})]})};fo.displayName="PaymentSuccessView";const ho=({heading:e,amountLabel:t,value:n,defaultValue:r,onChange:s,placeholder:i,isDisabled:a,isInvalid:o,errorMessage:c,autoFocus:d,maxAmount:u,className:h,"data-testid":p="payment-sub-amount-input"})=>{const m=`${p}-input`,v=y.useCallback(x=>{if(u!==void 0){const w=Number.parseFloat(x.replace(",","."));if(Number.isFinite(w)&&w>u)return}s?.(x)},[u,s]),b=y.useCallback(x=>{const w=x.currentTarget;requestAnimationFrame(()=>{w.isConnected&&w.select()})},[]);return l.jsxs("div",{className:f.cn("flex flex-col gap-3 border-t border-default-100 pt-5",h),"data-testid":p,children:[l.jsx("h3",{className:"text-lg font-semibold","data-testid":`${p}-heading`,children:e}),l.jsx(f.Input,{id:m,label:t,labelPlacement:"outside",type:"text",inputMode:"decimal",pattern:"[0-9]*[.,]?[0-9]*",value:n,defaultValue:r,onChange:x=>v(x.target.value),onFocus:b,placeholder:i,isDisabled:a,isInvalid:o,errorMessage:o?c:void 0,variant:"bordered",radius:"lg","aria-invalid":o||void 0,autoFocus:d,"data-testid":`${p}-field`})]})};ho.displayName="PaymentSubAmountInput";const mo=({isOpen:e,title:t,body:n,confirmLabel:r,confirmVariant:s="danger",dismissLabel:i,onConfirm:a,onDismiss:o,"data-testid":c="confirm-dialog"})=>l.jsx(f.Modal,{isOpen:e,onOpenChange:d=>{d||o()},role:"alertdialog",size:"sm",backdrop:"opaque","data-testid":c,"aria-labelledby":`${c}-title`,"aria-describedby":`${c}-body`,children:l.jsxs(f.ModalContent,{children:[l.jsx(f.ModalHeader,{id:`${c}-title`,className:"text-lg font-semibold",children:t}),l.jsx(f.ModalBody,{id:`${c}-body`,className:"text-sm text-default-700",children:n}),l.jsxs(f.ModalFooter,{className:"grid grid-cols-2 gap-3",children:[l.jsx(K,{variant:"bordered",radius:"full",onPress:o,"data-testid":`${c}-dismiss`,className:"h-11",children:i}),l.jsx(K,{color:s,variant:"solid",radius:"full",onPress:a,"data-testid":`${c}-confirm`,className:"h-11",children:r})]})]})});mo.displayName="ConfirmDialog";const Ym=60,Gm=(e,t,n=Ym)=>t?e>n:e<-n,po=(e,t)=>Math.max(0,Math.min(e,t)),Qm=(e,t,n)=>po(e-t,n),Zm=(e,t,n)=>e!==null?po(e,n):t?n:0,Xm=e=>e?"":"transition-[height] duration-300 ease-out",ep=e=>({onDrag:(t,n)=>{const r=e.open?e.fullHeight:0;e.setDragHeight(Qm(r,n?.offset?.y??0,e.fullHeight))},onDragEnd:(t,n)=>{Gm(n?.offset?.y??0,e.open)&&e.onToggleOpen?.(),e.setDragHeight(null)}}),ln=(e,t)=>rt(e.value,t,e.currency),js=({item:e,locale:t,onRemove:n,removeAriaLabel:r})=>{const s=!!e.children&&e.children.length>0;return l.jsxs("div",{"data-testid":`summary-item-${e.id}`,className:"flex flex-col gap-2",children:[l.jsxs("div",{className:"flex min-h-9 items-center justify-between gap-2",children:[l.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-base text-foreground",children:[typeof e.quantity=="number"&&l.jsxs("span",{"data-testid":`summary-item-qty-${e.id}`,className:"shrink-0",children:[e.quantity," x"]}),e.leadingIcon,l.jsx("span",{"data-testid":`summary-item-name-${e.id}`,className:f.cn("truncate",e.emphasis&&"font-medium"),children:e.name})]}),l.jsxs("div",{className:"flex shrink-0 items-center",children:[e.amount&&l.jsx("span",{"data-testid":`summary-item-amount-${e.id}`,className:"whitespace-nowrap text-base text-foreground",children:ln(e.amount,t)}),n&&l.jsx(K,{isIconOnly:!0,size:"sm",variant:"light",radius:"full",className:"ml-1 size-8 min-w-8 p-2 text-danger","aria-label":r,"data-testid":`summary-remove-${e.id}`,onPress:()=>n(e.id),children:l.jsx(U,{icon:"lucide:trash-2",width:16,height:16,className:"text-danger"})})]})]}),e.dateLabel&&l.jsxs("div",{"data-testid":`summary-item-date-${e.id}`,className:"flex items-center gap-2 text-sm text-default-500",children:[l.jsx(U,{icon:"lucide:calendar",width:16,height:16,className:"shrink-0"}),l.jsx("span",{className:"truncate",children:e.dateLabel})]}),e.dateRange&&l.jsxs("div",{"data-testid":`summary-item-daterange-${e.id}`,className:"flex items-center gap-2 text-sm text-default-500",children:[l.jsx(U,{icon:"lucide:calendar",width:16,height:16,className:"shrink-0"}),l.jsx("span",{children:e.dateRange.from}),l.jsx(U,{icon:"lucide:arrow-right",width:16,height:16,className:"shrink-0"}),l.jsx("span",{children:e.dateRange.to})]}),s&&l.jsx("div",{"data-testid":`summary-children-${e.id}`,className:"flex flex-col gap-2 pl-6",children:e.children.map(i=>l.jsx(js,{item:i,locale:t,onRemove:n,removeAriaLabel:r},i.id))})]})};js.displayName="SummaryItemRow";const go=({fee:e,locale:t,className:n})=>l.jsxs("div",{"data-testid":"summary-service-fee",className:f.cn("flex items-center justify-between gap-2",n),children:[l.jsxs("button",{type:"button",role:"switch","aria-checked":!!e.isSelected,"aria-label":typeof e.label=="string"?e.label:"Pay Service fee","data-testid":"summary-service-fee-toggle",onClick:e.onToggle,className:"flex min-w-0 items-center gap-2 text-left",children:[l.jsx("span",{"aria-hidden":"true",className:f.cn("flex size-4 shrink-0 items-center justify-center rounded-full border",e.isSelected?"border-primary":"border-default-200"),children:e.isSelected&&l.jsx("span",{className:"size-2 rounded-full bg-primary"})}),l.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:e.label})]}),l.jsx("span",{"data-testid":"summary-service-fee-amount",className:"whitespace-nowrap text-base text-foreground",children:ln(e.amount,t)})]});go.displayName="SummaryServiceFeeRow";const xo=({row:e,locale:t,emphasized:n})=>l.jsxs("div",{"data-testid":`summary-row-${e.key}`,className:"flex items-center justify-between text-foreground",children:[l.jsx("span",{"data-testid":`summary-row-label-${e.key}`,className:f.cn(n?"text-xl font-semibold leading-7":"text-base"),children:e.label}),l.jsx("span",{"data-testid":`summary-row-amount-${e.key}`,className:"whitespace-nowrap text-base",children:ln(e.amount,t)})]});xo.displayName="SummaryTotalsLineRow";const yo=({pricesInLabel:e,currency:t,items:n,serviceFee:r,rows:s,locale:i,onRemoveItem:a,removeAriaLabel:o,emptyState:c,classNames:d})=>{const u=(n?.length??0)>0;return l.jsxs(l.Fragment,{children:[l.jsxs("div",{"data-testid":"summary-prices",className:f.cn("flex items-center justify-between text-xs text-default-500",d.prices),children:[l.jsx("span",{children:e}),t!=null&&l.jsx("span",{children:t})]}),u?l.jsx("div",{className:f.cn("flex flex-col gap-4",d.items),children:n.map(h=>l.jsx(js,{item:h,locale:i,onRemove:a,removeAriaLabel:o},h.id))}):l.jsx("div",{"data-testid":"summary-empty",children:c}),r&&l.jsxs(l.Fragment,{children:[l.jsx(f.Divider,{className:"bg-default-200"}),l.jsx(go,{fee:r,locale:i,className:d.serviceFee})]}),s&&s.length>0&&l.jsx("div",{className:f.cn("flex flex-col gap-4",d.totalsRows),children:s.map((h,p)=>l.jsx(xo,{row:h,locale:i,emphasized:p===0},h.key))})]})};yo.displayName="SummaryBody";const bo=({total:e,locale:t,className:n})=>l.jsxs("div",{"data-testid":"summary-total",className:f.cn("flex items-center justify-between text-xl font-semibold leading-7 text-foreground",n),children:[l.jsx("span",{children:e.label??"Total"}),l.jsx("span",{"data-testid":"summary-total-amount",className:"whitespace-nowrap text-xl font-semibold leading-7",children:ln(e.amount,t)})]});bo.displayName="SummaryGrandTotalRow";const _n=({action:e,disabledByLoading:t,className:n,testId:r="summary-cta"})=>l.jsx(K,{color:"primary",radius:"full",className:f.cn("px-[18px] py-[14px] font-medium",n),"data-testid":r,isLoading:e.isLoading,isDisabled:e.isDisabled||t,onPress:e.onPress,endContent:l.jsx(U,{icon:"lucide:arrow-right",width:16,height:16}),children:e.label});_n.displayName="SummaryPrimaryCta";const vo=({title:e,total:t,locale:n,open:r,progress:s,dragging:i,toggleAriaLabel:a,onToggleOpen:o,classNames:c})=>l.jsx("h2",{children:l.jsxs("button",{type:"button","data-testid":"summary-collapse-toggle","aria-expanded":r,"aria-label":a,onClick:o,className:f.cn("-mx-4 -mt-4 grid w-[calc(100%_+_32px)] grid-cols-1 px-4 pb-4 pt-4 text-left",c.header),children:[l.jsxs("span",{"aria-hidden":!r,style:{opacity:s},className:f.cn("col-start-1 row-start-1 flex items-center justify-between",!i&&"transition-opacity duration-300"),children:[l.jsx("span",{"data-testid":"summary-title",className:f.cn("text-xl font-semibold leading-7 text-foreground",c.title),children:e}),l.jsx("span",{"data-testid":"summary-close","aria-hidden":"true",className:f.cn("shrink-0 text-foreground",c.closeButton),children:l.jsx(U,{icon:"lucide:x",width:20,height:20})})]}),l.jsxs("span",{"aria-hidden":r,style:{opacity:1-s},className:f.cn("col-start-1 row-start-1 flex items-center justify-between text-xl font-semibold leading-7 text-foreground",!i&&"transition-opacity duration-300"),children:[l.jsx("span",{children:t.label??"Total"}),l.jsx("span",{className:"whitespace-nowrap",children:ln(t.amount,n)})]})]})});vo.displayName="SummaryCollapseHeader";const wo=({cart:e,ariaLabel:t,onPress:n,className:r})=>l.jsxs("button",{type:"button","data-testid":"summary-cart","aria-label":t,onClick:n,className:f.cn("relative flex size-[52px] shrink-0 items-center justify-center rounded-full border border-default-200 bg-content1",r),children:[l.jsx(U,{icon:"lucide:shopping-bag",width:24,height:24,className:"text-foreground"}),e.count!=null&&l.jsx("span",{"data-testid":"summary-cart-badge",className:"absolute -right-1 -top-1 flex size-4 items-center justify-center rounded-full bg-primary text-xs text-primary-foreground",children:e.count})]});wo.displayName="SummaryCartButton";const ko=({open:e,progress:t,dragging:n,primaryAction:r,isLoading:s,cart:i,cartAriaLabel:a,onToggleOpen:o,classNames:c})=>l.jsxs("div",{"data-testid":"summary-mobile-bar",className:f.cn("flex flex-col gap-4",c.mobileBar),children:[l.jsx(f.Divider,{className:"bg-default-200"}),l.jsxs("div",{className:"grid",children:[l.jsxs("div",{"aria-hidden":e,style:{opacity:1-t},className:f.cn("col-start-1 row-start-1 flex items-stretch gap-2.5",e&&"pointer-events-none",!n&&"transition-opacity duration-300"),children:[i&&l.jsx(wo,{cart:i,ariaLabel:a,className:c.cart,onPress:()=>{o?.(),i.onPress?.()}}),r&&l.jsx(_n,{action:r,disabledByLoading:s,className:f.cn("flex-1",c.cta),testId:"summary-cta-compact"})]}),r&&l.jsx("div",{"aria-hidden":!e,style:{opacity:t},className:f.cn("col-start-1 row-start-1 flex",!e&&"pointer-events-none",!n&&"transition-opacity duration-300"),children:l.jsx(_n,{action:r,disabledByLoading:s,className:f.cn("w-full",c.cta)})})]})]});ko.displayName="SummaryActionBar";const tp="(max-width: 767px)",np=e=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(e).matches:!1,rp=(e=tp)=>{const[t,n]=y.useState(()=>np(e));return y.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const r=window.matchMedia(e),s=()=>n(r.matches);return s(),r.addEventListener("change",s),()=>r.removeEventListener("change",s)},[e]),t},No=({title:e="Summary",pricesInLabel:t="Prices are in",currency:n,locale:r="en-US",items:s,serviceFee:i,rows:a,total:o,collapsible:c,isOpen:d,onToggleOpen:u,primaryAction:h,isLoading:p=!1,onRemoveItem:m,variant:v,cart:b,emptyState:x,labels:w,classNames:S={},"data-testid":M="summary",className:N})=>{const j=w?.removeAriaLabel??"Remove item",T=w?.toggleAriaLabel??"Toggle summary",$=w?.cartAriaLabel??"View cart",W=rp(),R=c??(v??(W?"mobile":"main"))==="mobile",E=!R||(d??!1),[C,I]=y.useState(0),[F,H]=y.useState(null),Q=y.useCallback(G=>{G&&I(G.scrollHeight)},[]),Y=ep({open:E,fullHeight:C,setDragHeight:H,onToggleOpen:u}),te=F!==null,oe=Zm(F,E,C),ce=C>0?Math.min(1,Math.max(0,oe/C)):E?1:0,P=l.jsx(bo,{total:o,locale:r,className:S.total}),_=l.jsx(yo,{pricesInLabel:t,currency:n,items:s,serviceFee:i,rows:a,locale:r,onRemoveItem:m,removeAriaLabel:j,emptyState:x,classNames:S});return R?l.jsxs(Pe.motion.section,{"data-testid":M,drag:"y",dragConstraints:{top:0,bottom:0},dragElastic:.12,dragSnapToOrigin:!0,onDrag:Y.onDrag,onDragEnd:Y.onDragEnd,className:f.cn("fixed inset-x-0 bottom-0 z-50 flex w-full flex-col rounded-t-2xl bg-content1 p-4 drop-shadow-[0_-2px_2px_rgba(0,0,0,0.1)]",N,S.base),children:[l.jsx(vo,{title:e,total:o,locale:r,open:E,progress:ce,dragging:te,toggleAriaLabel:T,onToggleOpen:u,classNames:S}),l.jsx("div",{"data-testid":"summary-reveal","aria-hidden":!E,style:{height:oe},className:f.cn("overflow-hidden",!E&&"pointer-events-none",Xm(te)),children:l.jsxs("div",{ref:Q,className:"flex flex-col gap-4 pb-4",children:[_,l.jsx(f.Divider,{className:"bg-default-200"}),P]})}),l.jsx(ko,{open:E,progress:ce,dragging:te,primaryAction:h,isLoading:p,cart:b,cartAriaLabel:$,onToggleOpen:u,classNames:S})]}):l.jsxs("section",{"data-testid":M,className:f.cn("flex w-full flex-col gap-4 rounded-2xl border border-default-200 bg-content1 p-4",N,S.base),children:[l.jsx("div",{className:f.cn("flex items-center justify-between",S.header),children:l.jsx("h2",{"data-testid":"summary-title",className:f.cn("text-xl font-semibold leading-7 text-foreground",S.title),children:e})}),_,l.jsx(f.Divider,{className:"bg-default-200"}),P,h&&l.jsx(_n,{action:h,disabledByLoading:p,className:f.cn("w-full",S.cta)})]})};No.displayName="Summary";exports.Button=K;exports.CashTenderForm=Om;exports.CatalogItemCard=Kl;exports.CheckTenderForm=no;exports.CommitmentDetails=Nh;exports.ConfirmDialog=mo;exports.ConfirmationModal=Rn;exports.ConfirmationPageTemplate=Vo;exports.DonationAmounts=qa;exports.EmptyState=Jl;exports.ErrorState=Yl;exports.EventDetails=If;exports.EventDetailsTemplate=qo;exports.ExpireCartTimer=Wa;exports.FeedbackState=It;exports.FilterPopover=eo;exports.Footer=Wo;exports.HeroUIProvider=Fo;exports.InstallmentFundAssignment=xh;exports.InstallmentFundAssignmentSkeleton=wh;exports.InstallmentSchedule=Qh;exports.InstallmentScheduleSkeleton=rm;exports.InstallmentTable=im;exports.ItemCard=Wl;exports.LoadingOverlay=uo;exports.LoadingState=Gl;exports.MembershipSelectCards=cm;exports.ModalShell=io;exports.ModalShellFooter=lo;exports.ModalShellHeader=ao;exports.Multiselect=Ko;exports.Navbar=_o;exports.OfferCard=On;exports.OfferCardEmpty=ll;exports.OfferCardError=ol;exports.OfferCardList=fl;exports.OfferCardSkeleton=cl;exports.OtherTenderForm=ro;exports.PaymentCashChangeBanner=Cs;exports.PaymentSubAmountInput=ho;exports.PaymentSuccessView=fo;exports.PaymentTotalBanner=co;exports.RICH_TEXT_PRESETS=Ha;exports.RevenueDistributionCard=Sl;exports.RevenueDistributionEmpty=Cl;exports.RevenueDistributionError=jl;exports.RevenueDistributionSkeleton=Al;exports.RichTextArea=Ua;exports.Select=yt;exports.SessionTimeline=to;exports.SplitPaymentSummary=so;exports.Stepper=Yi;exports.SuccessState=Ql;exports.Summary=No;exports.TicketSelection=Cm;exports.TileSelect=oo;exports.Toggle=Zl;exports.calculateAllocationDifference=dh;exports.computeChange=Cr;exports.currencyFractionDigits=Gr;exports.formatMoney=rt;exports.formatOfferCurrency=al;exports.formatRevenueAmount=ah;exports.formatRevenueCurrency=lh;exports.generateAutomaticInstallments=Hl;exports.generateDistributionId=vs;exports.getCurrencySymbol=oh;exports.offerCardVariants=ul;exports.offerListVariants=dl;exports.parseOfferCurrency=$f;exports.parseRevenueCurrency=ch;exports.roundToCurrency=Gi;Object.keys(f).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>f[e]})});
|
|
45
45
|
(function(){"use strict";try{if(typeof document<"u"){var r=document.createElement("style");r.appendChild(document.createTextNode('.ProseMirror{flex:1;width:100%;min-height:100%;height:100%;cursor:text;background-color:#fff;padding:1rem;overflow-y:auto;box-sizing:border-box}.ProseMirror p{min-height:1.5em}.dark .ProseMirror{background-color:rgb(var(--nextui-background))}.ProseMirror ul{list-style-type:disc!important;list-style-position:outside!important;padding-left:2rem!important;margin:1rem 0!important;display:block!important}.ProseMirror ol{list-style-type:decimal!important;list-style-position:outside!important;padding-left:2rem!important;margin:1rem 0!important;display:block!important}.ProseMirror ul li,.ProseMirror ol li{display:list-item!important;list-style:inherit!important;margin:.25rem 0!important}.ProseMirror ul li p,.ProseMirror ol li p{margin:0!important;display:inline!important}.ProseMirror ul[data-type=taskList]{list-style:none!important;padding-left:0!important;margin:1rem 0!important}.ProseMirror ul[data-type=taskList] li{display:flex!important;align-items:flex-start!important;margin:.5rem 0!important}.ProseMirror ul[data-type=taskList] li label{margin-right:.5rem;-webkit-user-select:none;-moz-user-select:none;user-select:none}.ProseMirror ul[data-type=taskList] li input[type=checkbox]{cursor:pointer;margin-top:.25rem}.ProseMirror h1,.ProseMirror h2,.ProseMirror h3,.ProseMirror h4,.ProseMirror h5,.ProseMirror h6{line-height:1.2!important;margin:1rem 0 .5rem!important;font-weight:600!important}.ProseMirror h1{font-size:2rem!important}.ProseMirror h2{font-size:1.5rem!important}.ProseMirror h3{font-size:1.25rem!important}.ProseMirror h4{font-size:1.1rem!important}.ProseMirror h5{font-size:1rem!important;font-weight:600!important}.ProseMirror h6{font-size:.9rem!important;font-weight:600!important}.ProseMirror code{background-color:rgb(var(--nextui-default-100));border-radius:.4rem;color:rgb(var(--nextui-default-800));font-size:.85rem;padding:.25em .3em}.ProseMirror pre{background:rgb(var(--nextui-default-900));border-radius:.5rem;color:rgb(var(--nextui-default-50));font-family:JetBrainsMono,monospace;margin:1.5rem 0;padding:.75rem 1rem;overflow-x:auto}.ProseMirror pre code{background:none;color:inherit;font-size:.8rem;padding:0}.ProseMirror mark{background-color:#faf594;border-radius:.4rem;-webkit-box-decoration-break:clone;box-decoration-break:clone;padding:.1rem .3rem}.ProseMirror blockquote{border-left:3px solid rgb(var(--nextui-default-300));margin:1.5rem 0;padding-left:1rem;color:rgb(var(--nextui-default-600))}.ProseMirror hr{border:none;border-top:1px solid rgb(var(--nextui-divider));margin:2rem 0}.ProseMirror a{color:rgb(var(--nextui-primary));text-decoration:underline;cursor:pointer}.ProseMirror a:hover{text-decoration:underline}.ProseMirror strong{font-weight:700!important}.ProseMirror em{font-style:italic!important}.ProseMirror s{text-decoration:line-through!important}.ProseMirror u{text-decoration:underline!important}.ProseMirror .has-text-align-left,.ProseMirror [style*="text-align: left"]{text-align:left!important}.ProseMirror .has-text-align-center,.ProseMirror [style*="text-align: center"]{text-align:center!important}.ProseMirror .has-text-align-right,.ProseMirror [style*="text-align: right"]{text-align:right!important}.ProseMirror .has-text-align-justify,.ProseMirror [style*="text-align: justify"]{text-align:justify!important}.ProseMirror ul li[style*="text-align: left"],.ProseMirror ol li[style*="text-align: left"]{text-align:left!important;list-style-position:inside!important}.ProseMirror ul li[style*="text-align: center"],.ProseMirror ol li[style*="text-align: center"]{text-align:center!important;list-style-position:inside!important}.ProseMirror ul li[style*="text-align: right"],.ProseMirror ol li[style*="text-align: right"]{text-align:right!important;list-style-position:inside!important}.ProseMirror ul li[style*="text-align: justify"],.ProseMirror ol li[style*="text-align: justify"]{text-align:justify!important;list-style-position:inside!important}.ProseMirror ul[data-type=taskList] li[style*="text-align: left"]{justify-content:flex-start!important}.ProseMirror ul[data-type=taskList] li[style*="text-align: center"]{justify-content:center!important}.ProseMirror ul[data-type=taskList] li[style*="text-align: right"]{justify-content:flex-end!important}.ProseMirror p.is-editor-empty:first-child:before{color:rgb(var(--nextui-default-400));content:attr(data-placeholder);float:left;height:0;pointer-events:none}')),document.head.appendChild(r)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
|