@veevarts/design-system 1.11.0 → 1.12.0-alpha.1
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/components/Select/Select.d.ts +11 -0
- package/dist/components/Select/index.d.ts +2 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/index.cjs +36 -11
- package/dist/index.d.ts +2 -0
- package/dist/index.js +7283 -4123
- package/dist/patterns/CashTenderForm/CashTenderForm.d.ts +4 -0
- package/dist/patterns/CashTenderForm/index.d.ts +9 -0
- package/dist/patterns/CashTenderForm/types.d.ts +95 -0
- package/dist/patterns/CheckTenderForm/CheckTenderForm.d.ts +4 -0
- package/dist/patterns/CheckTenderForm/index.d.ts +9 -0
- package/dist/patterns/CheckTenderForm/types.d.ts +62 -0
- package/dist/patterns/CommitmentDetails/CommitmentDetails.d.ts +16 -0
- package/dist/patterns/CommitmentDetails/index.d.ts +2 -0
- package/dist/patterns/ConfirmDialog/ConfirmDialog.d.ts +21 -0
- package/dist/patterns/ConfirmDialog/index.d.ts +2 -0
- package/dist/patterns/ConfirmationModal/ConfirmationModal.d.ts +18 -0
- package/dist/patterns/ConfirmationModal/index.d.ts +2 -0
- package/dist/patterns/EventDetails/EventDetails.d.ts +3 -1
- package/dist/patterns/InstallmentFundAssignment/InstallmentFundAssignment.d.ts +3 -0
- package/dist/patterns/InstallmentFundAssignment/InstallmentFundAssignmentSkeleton.d.ts +2 -0
- package/dist/patterns/InstallmentFundAssignment/index.d.ts +3 -0
- package/dist/patterns/InstallmentFundAssignment/types.d.ts +67 -0
- package/dist/patterns/InstallmentSchedule/InstallmentSchedule.d.ts +3 -0
- package/dist/patterns/InstallmentSchedule/InstallmentScheduleSkeleton.d.ts +2 -0
- package/dist/patterns/InstallmentSchedule/InstallmentTable.d.ts +3 -0
- package/dist/patterns/InstallmentSchedule/index.d.ts +5 -0
- package/dist/patterns/InstallmentSchedule/types.d.ts +93 -0
- package/dist/patterns/InstallmentSchedule/utils.d.ts +2 -0
- package/dist/patterns/LoadingOverlay/LoadingOverlay.d.ts +18 -0
- package/dist/patterns/LoadingOverlay/index.d.ts +2 -0
- package/dist/patterns/MembershipSelectCards/types.d.ts +2 -0
- package/dist/patterns/ModalShell/ModalShell.d.ts +40 -0
- package/dist/patterns/ModalShell/index.d.ts +2 -0
- package/dist/patterns/OtherTenderForm/OtherTenderForm.d.ts +4 -0
- package/dist/patterns/OtherTenderForm/index.d.ts +8 -0
- package/dist/patterns/OtherTenderForm/types.d.ts +53 -0
- package/dist/patterns/PaymentCashChangeBanner/PaymentCashChangeBanner.d.ts +35 -0
- package/dist/patterns/PaymentCashChangeBanner/index.d.ts +2 -0
- package/dist/patterns/PaymentSubAmountInput/PaymentSubAmountInput.d.ts +55 -0
- package/dist/patterns/PaymentSubAmountInput/index.d.ts +2 -0
- package/dist/patterns/PaymentSuccessView/PaymentSuccessView.d.ts +30 -0
- package/dist/patterns/PaymentSuccessView/index.d.ts +2 -0
- package/dist/patterns/PaymentTotalBanner/PaymentTotalBanner.d.ts +15 -0
- package/dist/patterns/PaymentTotalBanner/index.d.ts +2 -0
- package/dist/patterns/SplitPaymentSummary/SplitPaymentSummary.d.ts +4 -0
- package/dist/patterns/SplitPaymentSummary/index.d.ts +9 -0
- package/dist/patterns/SplitPaymentSummary/types.d.ts +61 -0
- package/dist/patterns/TicketSelection/types.d.ts +3 -0
- package/dist/patterns/TileSelect/TileSelect.d.ts +39 -0
- package/dist/patterns/TileSelect/index.d.ts +2 -0
- package/dist/patterns/index.d.ts +32 -0
- package/dist/tailwind/index.d.ts +13 -0
- package/dist/tailwind/index.js +13 -0
- package/dist/tokens/colors.d.ts +13 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/money.d.ts +55 -0
- package/package.json +2 -1
- package/dist/components/Button/Button.test.d.ts +0 -1
- package/dist/patterns/DonationAmounts/__test__/DonationAmounts.test.d.ts +0 -4
- package/dist/patterns/EventDetails/__test__/EventDetails.test.d.ts +0 -1
- package/dist/patterns/ExpireCartTimer/__test__/ExpireCartTimer.test.d.ts +0 -4
- package/dist/patterns/Footer/__test__/Footer.test.d.ts +0 -1
- package/dist/patterns/ItemCard/__test__/ItemCard.test.d.ts +0 -4
- package/dist/patterns/MembershipSelectCards/__test__/MembershipSelectCards.test.d.ts +0 -4
- package/dist/patterns/Multiselect/__test__/Multiselect.test.d.ts +0 -4
- package/dist/patterns/Navbar/__test__/Navbar.test.d.ts +0 -1
- package/dist/patterns/OfferCard/__test__/OfferCard.test.d.ts +0 -1
- package/dist/patterns/RevenueDistribution/__test__/RevenueDistributionCard.test.d.ts +0 -1
- package/dist/patterns/RichText/RichText.test.d.ts +0 -1
- package/dist/patterns/RichText/core/TipTapEditor.test.d.ts +0 -1
- package/dist/patterns/Stepper/Stepper.test.d.ts +0 -4
- package/dist/patterns/TicketSelection/__test__/TicketSelection.test.d.ts +0 -4
- package/dist/patterns/Toggle/__test__/Toggle.test.d.ts +0 -4
package/dist/index.cjs
CHANGED
|
@@ -1,20 +1,45 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),g=require("@heroui/react"),b=require("react"),B=require("lucide-react"),$e=require("framer-motion"),hr=require("@tiptap/react"),R=require("@tiptap/core"),_o=require("@tiptap/extension-underline"),Ho=require("@tiptap/extension-color"),Uo=require("@tiptap/extension-highlight"),qo=require("@tiptap/extension-link"),Ko=require("@tiptap/extension-task-list"),Jo=require("@tiptap/extension-task-item"),Wo=require("@tiptap/extension-text-align");function Go({children:t}){return c.jsx(g.HeroUIProvider,{children:t})}const se=b.forwardRef(({color:t="primary",radius:e="full",testId:n="veevart-button",...r},s)=>c.jsx(g.Button,{ref:s,color:t,radius:e,"data-testid":n,...r}));se.displayName="Button";const Zo={login:"Login",logout:"Logout",selectLanguage:"Select your language"};function Qo({languages:t,selectedLanguage:e,onLanguageChange:n,label:r}){const s=t.find(i=>i.code===e);return c.jsx("div",{className:"flex items-center",children:c.jsxs("div",{className:"relative flex items-center",children:[c.jsx(g.Select,{"data-testid":"language-select-desktop",variant:"bordered","aria-label":r,selectedKeys:e?[e]:[],onSelectionChange:i=>{const o=Array.from(i)[0]||e;n?.(o)},className:"min-w-36 hidden md:inline-flex",isDisabled:t.length===0,placeholder:r,startContent:c.jsx(B.Globe,{className:"w-5 h-5 text-black"}),renderValue:()=>c.jsx("span",{children:s?.label||r}),size:"md",radius:"full",children:t.map(i=>c.jsx(g.SelectItem,{textValue:i.label,"data-testid":`language-select-option-${i.code}`,children:i.label},i.code))}),c.jsx(g.Select,{"aria-label":r,"data-testid":"language-select-mobile",variant:"bordered",selectedKeys:e?[e]:[],onSelectionChange:i=>{const o=Array.from(i)[0]||e;n?.(o)},className:"w-24 inline-flex md:hidden",isDisabled:t.length===0,placeholder:"",startContent:c.jsx(B.Globe,{className:"w-6 h-6 text-black"}),renderValue:()=>c.jsx("span",{children:s?.code.toUpperCase()||""}),size:"md",radius:"full",children:t.map(i=>c.jsx(g.SelectItem,{textValue:i.code.toUpperCase(),"data-testid":`language-select-option-mobile-${i.code}`,children:i.code.toUpperCase()},i.code))})]})})}function Xo({isLoggedIn:t,onLogin:e,onLogout:n,labels:r}){return t?c.jsxs(se,{"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:[c.jsx(B.User,{className:"inline w-5 h-5"}),c.jsx("span",{className:"hidden md:inline",children:r.logout})]}):c.jsxs(se,{"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:e,size:"md",children:[c.jsx(B.User,{className:"inline w-5 h-5"}),c.jsx("span",{className:"hidden md:inline",children:r.login})]})}function Yo({logo:t,languages:e=[],selectedLanguage:n,onLanguageChange:r,isLoggedIn:s,onLogin:i,onLogout:o,hasLanguages:l,hasAuth:a,labels:u={},className:d}){const f={...Zo,...u};return c.jsxs("nav",{"data-testid":"navbar",className:g.cn("w-full px-4 md:px-8 py-3 bg-white border-b border-zinc-100 flex items-center justify-between",d),children:[c.jsx("div",{className:"flex items-center min-w-10",children:t&&c.jsx("a",{href:"/",className:"block",children:c.jsx("img",{"data-testid":"navbar-logo",src:t,alt:"Logo",className:"h-8 max-w-28 md:max-w-40"})})}),c.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[(l||e.length>0)&&c.jsx(Qo,{languages:e,selectedLanguage:n,onLanguageChange:r,label:f.selectLanguage}),a&&c.jsx(Xo,{isLoggedIn:s,onLogin:i,onLogout:o,labels:f})]})]})}function el(t){return c.jsx("div",{className:"min-h-screen flex flex-col",children:c.jsx("div",{className:"flex-1 flex items-center justify-center p-12",children:c.jsx(g.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 Mn;const tl=typeof document<"u"?(Mn=b.useInsertionEffect)!==null&&Mn!==void 0?Mn:b.useLayoutEffect:()=>{};function pr(t,e,n){let[r,s]=b.useState(t||e),i=b.useRef(r),o=b.useRef(t!==void 0),l=t!==void 0;b.useEffect(()=>{let f=o.current;f!==l&&process.env.NODE_ENV!=="production"&&console.warn(`WARN: A component changed from ${f?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}.`),o.current=l},[l]);let a=l?t:r;tl(()=>{i.current=a});let[,u]=b.useReducer(()=>({}),{}),d=b.useCallback((f,...m)=>{let h=typeof f=="function"?f(i.current):f;Object.is(i.current,h)||(i.current=h,s(h),u(),n?.(h,...m))},[n]);return[a,d]}function nl(t){return c.jsx("svg",{...t,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:c.jsx($e.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 Ys=b.forwardRef(({color:t="primary",stepsCount:e=3,defaultStep:n=0,label:r,onStepChange:s,currentStep:i,hideProgressBars:o=!1,stepClassName:l,className:a,isDisabled:u=!1,...d},f)=>{const[m,h]=pr(i,n,s),S=b.useMemo(()=>{let x,k;const C=["[--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(t){case"primary":x="[--step-color:var(--heroui-primary)]",k="[--step-fg-color:var(--heroui-primary-foreground)]";break;case"secondary":x="[--step-color:var(--heroui-secondary)]",k="[--step-fg-color:var(--heroui-secondary-foreground)]";break;case"success":x="[--step-color:var(--heroui-success)]",k="[--step-fg-color:var(--heroui-success-foreground)]";break;case"warning":x="[--step-color:var(--heroui-warning)]",k="[--step-fg-color:var(--heroui-warning-foreground)]";break;case"danger":x="[--step-color:var(--heroui-danger)]",k="[--step-fg-color:var(--heroui-danger-foreground)]";break;case"default":x="[--step-color:var(--heroui-default)]",k="[--step-fg-color:var(--heroui-default-foreground)]";break;default:x="[--step-color:var(--heroui-primary)]",k="[--step-fg-color:var(--heroui-primary-foreground)]";break}return C.unshift(k),C.unshift(x),C},[t]);return c.jsxs("nav",{ref:f,"aria-label":"Progress",className:g.cn("flex max-w-fit items-center overflow-x-auto",a),"data-testid":"stepper-root",...d,children:[r&&c.jsx("label",{className:"text-small text-default-foreground lg:text-medium font-light whitespace-nowrap me-3","data-testid":"stepper-label",children:r}),c.jsx("ol",{className:g.cn("flex flex-row flex-nowrap gap-x-3",S,a),"data-testid":"stepper-list",children:Array.from({length:e})?.map((x,k)=>{const C=m===k?"active":m<k?"inactive":"complete";return c.jsx("li",{className:"relative flex shrink-0 items-center pr-12","data-testid":`stepper-step-${k}`,children:c.jsxs("button",{"aria-current":C==="active"?"step":void 0,className:g.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":u},l),onClick:()=>!u&&h(k),disabled:u,"data-testid":`stepper-step-btn-${k}`,children:[c.jsx("div",{className:"h-full relative flex items-center",children:c.jsx($e.LazyMotion,{features:$e.domAnimation,children:c.jsx($e.m.div,{animate:C,className:"relative",children:c.jsx($e.m.div,{animate:C,className:g.cn("border-medium text-large text-default-foreground relative flex h-[26px] w-[26px] items-center justify-center rounded-full font-semibold",{"shadow-lg":C==="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:c.jsx("div",{className:"flex items-center justify-center",children:C==="complete"?c.jsx(nl,{className:"h-5 w-5 text-(--active-fg-color)","data-testid":`stepper-step-check-${k}`}):c.jsx("span",{})})})})})}),k<e-1&&!o&&c.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":k},children:c.jsx("div",{className:g.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":k<m})})})]},k)},k)})})]})});Ys.displayName="Stepper";function rl(t){return c.jsx("div",{className:"min-h-screen flex flex-col",children:c.jsx("div",{className:"flex-1 flex items-center justify-center p-12",children:c.jsx(g.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 sl(){return c.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 il=t=>{const e=b.useMemo(()=>JSON.stringify({allItems:t.allItems,selected:t.selected}),[t.allItems,t.selected]);return c.jsx(ol,{...t},e)},ol=({allItems:t,selected:e,onSelectedChange:n,titleLeft:r,titleRight:s})=>{const[i,o]=b.useState([]),[l,a]=b.useState([]),[u,d]=b.useState(null),[f,m]=b.useState(null),h=b.useMemo(()=>new Set(e),[e]),S=b.useMemo(()=>new Set(t),[t]),x=b.useMemo(()=>t.filter(F=>!h.has(F)),[t,h]),k=F=>{if(F.length===0)return;const j=Array.from(new Set([...e,...F]));n(j)},C=F=>{if(F.length===0)return;const j=new Set(F);n(e.filter(P=>!j.has(P)))},w=()=>{i.length!==0&&(k(i),o([]))},T=()=>{l.length!==0&&(C(l),a([]))},A=()=>{x.length!==0&&(k(x),o([]))},N=()=>{e.length!==0&&(n([]),a([]))},O=(F,j,P)=>{const $=Math.min(j,P),J=Math.max(j,P);return F.slice($,J+1)},L=(F,j,P)=>{if(P&&u!==null){o(O(x,u,j)),a([]),d(j);return}const $=i.includes(F);o($?i.filter(J=>J!==F):[...i,F]),a([]),d(j)},_=(F,j,P)=>{if(P&&f!==null){a(O(e,f,j)),o([]),m(j);return}const $=l.includes(F);a($?l.filter(J=>J!==F):[...l,F]),o([]),m(j)},z=(F,j,P)=>{const $=P==="available"?i.includes(j)?i:[j]:l.includes(j)?l:[j];F.dataTransfer.setData("text/plain",JSON.stringify({source:P,items:$})),F.dataTransfer.effectAllowed="move"},H=(F,j)=>{F.preventDefault();const P=F.dataTransfer.getData("text/plain");if(P)try{const $=JSON.parse(P),J=($.items||[]).filter(oe=>S.has(oe));if(J.length===0||$.source===j)return;j==="selected"?(k(J),o([])):(C(J),a([]))}catch{return}};return c.jsxs("div",{className:"flex flex-col gap-6 md:flex-row md:items-start md:justify-between",children:[c.jsxs("div",{className:"flex w-full flex-col gap-3 md:w-2/5",children:[c.jsx("h2",{className:"text-sm font-medium text-gray-700",children:r}),c.jsx(g.Card,{className:"w-full border border-gray-200 shadow-none",children:c.jsx(g.CardBody,{className:"h-60 gap-2 overflow-y-auto",onDragOver:F=>F.preventDefault(),onDrop:F=>H(F,"available"),children:x.map((F,j)=>{const P=i.includes(F);return c.jsx("button",{type:"button",onClick:$=>{L(F,j,$.shiftKey)},onMouseDown:$=>{$.shiftKey&&$.preventDefault()},draggable:!0,onDragStart:$=>z($,F,"available"),className:`rounded-md px-3 py-2 text-left text-sm transition ${P?"bg-[#E4571E]/10 text-[#E4571E]":"text-gray-700 hover:bg-gray-100"}`,children:F},F)})})})]}),c.jsxs("div",{className:"flex flex-row items-center justify-center gap-3 md:flex-col md:pt-6",children:[c.jsx(se,{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:w,isDisabled:i.length===0,"aria-label":"Move selected to right",children:"›"}),c.jsx(se,{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:T,isDisabled:l.length===0,"aria-label":"Move selected to left",children:"‹"}),c.jsx(se,{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:A,isDisabled:x.length===0,"aria-label":"Move all to right",children:"»"}),c.jsx(se,{variant:"light",className:"h-10 w-10 min-w-0 text-2xl font-semibold text-[#E4571E] hover:bg-[#E4571E]/10",isIconOnly:!0,onPress:N,"data-testid":"move-all-to-available",isDisabled:e.length===0,"aria-label":"Move all to left",children:"«"})]}),c.jsxs("div",{className:"flex w-full flex-col gap-3 md:w-2/5",children:[c.jsx("h2",{className:"text-sm font-medium text-gray-700",children:s}),c.jsx(g.Card,{className:"w-full border border-gray-200 shadow-none",children:c.jsx(g.CardBody,{className:"h-60 gap-2 overflow-y-auto",onDragOver:F=>F.preventDefault(),onDrop:F=>H(F,"selected"),children:e.map((F,j)=>{const P=l.includes(F);return c.jsx("button",{type:"button",onClick:$=>{_(F,j,$.shiftKey)},onMouseDown:$=>{$.shiftKey&&$.preventDefault()},draggable:!0,onDragStart:$=>z($,F,"selected"),className:`rounded-md px-3 py-2 text-left text-sm transition ${P?"bg-[#E4571E]/10 text-[#E4571E]":"text-gray-700 hover:bg-gray-100"}`,children:F},F)})})})]})]})};function Rt(t){return typeof t=="string"?t:t.type}function rt({className:t}){return c.jsx("div",{className:`flex items-center h-6 ${t||""}`,children:c.jsx(g.Divider,{orientation:"vertical"})})}function st({icon:t,label:e,isActive:n=!1,isDisabled:r=!1,onClick:s,shortcut:i,iconSize:o=16,className:l}){const a=i?`${e} (${i})`:e;return c.jsx(g.Tooltip,{content:a,placement:"top",offset:10,children:c.jsx(se,{size:"sm",radius:"sm",color:n?"primary":"default",variant:n?"solid":"bordered",isIconOnly:!0,isDisabled:r,onPress:s,"aria-label":e,className:l,children:c.jsx(t,{size:o})})})}const Ke={bold:{execute:({editor:t})=>t.chain().focus().toggleBold().run(),canExecute:t=>t.can().chain().focus().toggleBold().run(),isActive:t=>t.isActive("bold"),shortcut:"Mod-b",label:"Bold"},italic:{execute:({editor:t})=>t.chain().focus().toggleItalic().run(),canExecute:t=>t.can().chain().focus().toggleItalic().run(),isActive:t=>t.isActive("italic"),shortcut:"Mod-i",label:"Italic"},strike:{execute:({editor:t})=>t.chain().focus().toggleStrike().run(),canExecute:t=>t.can().chain().focus().toggleStrike().run(),isActive:t=>t.isActive("strike"),shortcut:"Mod-Shift-x",label:"Strikethrough"},underline:{execute:({editor:t})=>t.chain().focus().toggleUnderline().run(),canExecute:t=>t.can().chain().focus().toggleUnderline().run(),isActive:t=>t.isActive("underline"),shortcut:"Mod-u",label:"Underline"},code:{execute:({editor:t})=>t.chain().focus().toggleCode().run(),canExecute:t=>t.can().chain().focus().toggleCode().run(),isActive:t=>t.isActive("code"),shortcut:"Mod-e",label:"Inline code"},textColor:{execute:({editor:t,config:e})=>{const n=e?.type==="textColor"?e.color:"";n?t.chain().focus().setColor(n).run():t.chain().focus().unsetColor().run()},canExecute:()=>!0,isActive:t=>t.isActive("textStyle"),label:"Text color"},highlight:{execute:({editor:t,config:e})=>{const n=e?.type==="highlight"?e.color:"";n?t.chain().focus().setHighlight({color:n}).run():t.chain().focus().unsetHighlight().run()},canExecute:()=>!0,isActive:t=>t.isActive("highlight"),label:"Highlight"},link:{execute:({editor:t,config:e})=>{const n=e?.type==="link"?e.href:"";if(n){const r=e?.type==="link"?e.target:void 0,s=e?.type==="link"?e.rel:void 0;t.chain().focus().setLink({href:n,target:r,rel:s}).run()}else t.chain().focus().unsetLink().run()},canExecute:()=>!0,isActive:t=>t.isActive("link"),shortcut:"Mod-k",label:"Link"},paragraph:{execute:({editor:t})=>t.chain().focus().setParagraph().run(),canExecute:t=>t.can().chain().focus().setParagraph().run(),isActive:t=>t.isActive("paragraph"),shortcut:"Mod-Alt-0",label:"Paragraph"},heading:{execute:({editor:t,config:e})=>{const n=e?.type==="heading"?e.level:1;t.chain().focus().toggleHeading({level:n}).run()},canExecute:(t,e)=>{const n=e?.type==="heading"?e.level:1;return t.can().chain().focus().toggleHeading({level:n}).run()},isActive:(t,e)=>e?.type==="heading"?t.isActive("heading",{level:e.level}):t.isActive("heading"),label:"Heading"},bulletList:{execute:({editor:t})=>t.chain().focus().toggleBulletList().run(),canExecute:t=>t.can().chain().focus().toggleBulletList().run(),isActive:t=>t.isActive("bulletList"),shortcut:"Mod-Shift-8",label:"Bullet list"},orderedList:{execute:({editor:t})=>t.chain().focus().toggleOrderedList().run(),canExecute:t=>t.can().chain().focus().toggleOrderedList().run(),isActive:t=>t.isActive("orderedList"),shortcut:"Mod-Shift-7",label:"Numbered list"},taskList:{execute:({editor:t})=>t.chain().focus().toggleTaskList().run(),canExecute:t=>t.can().chain().focus().toggleTaskList().run(),isActive:t=>t.isActive("taskList"),label:"Task list"},codeBlock:{execute:({editor:t})=>t.chain().focus().toggleCodeBlock().run(),canExecute:t=>t.can().chain().focus().toggleCodeBlock().run(),isActive:t=>t.isActive("codeBlock"),shortcut:"Mod-Alt-c",label:"Code block"},blockquote:{execute:({editor:t})=>t.chain().focus().toggleBlockquote().run(),canExecute:t=>t.can().chain().focus().toggleBlockquote().run(),isActive:t=>t.isActive("blockquote"),shortcut:"Mod-Shift-b",label:"Blockquote"},horizontalRule:{execute:({editor:t})=>t.chain().focus().setHorizontalRule().run(),canExecute:t=>t.can().chain().focus().setHorizontalRule().run(),isActive:()=>!1,label:"Horizontal rule"},hardBreak:{execute:({editor:t})=>t.chain().focus().setHardBreak().run(),canExecute:t=>t.can().chain().focus().setHardBreak().run(),isActive:()=>!1,shortcut:"Mod-Enter",label:"Line break"},textAlign:{execute:({editor:t,config:e})=>{const n=e?.type==="textAlign"?e.alignment:"left";t.chain().focus().setTextAlign(n).run()},canExecute:()=>!0,isActive:(t,e)=>e?.type==="textAlign"?t.isActive({textAlign:e.alignment}):!1,label:"Text alignment"},clearMarks:{execute:({editor:t})=>t.chain().focus().unsetAllMarks().run(),canExecute:t=>t.can().chain().focus().unsetAllMarks().run(),isActive:()=>!1,label:"Clear formatting"},clearNodes:{execute:({editor:t})=>t.chain().focus().clearNodes().run(),canExecute:t=>t.can().chain().focus().clearNodes().run(),isActive:()=>!1,label:"Clear nodes"},undo:{execute:({editor:t})=>t.chain().focus().undo().run(),canExecute:t=>t.can().chain().focus().undo().run(),isActive:()=>!1,shortcut:"Mod-z",label:"Undo"},redo:{execute:({editor:t})=>t.chain().focus().redo().run(),canExecute:t=>t.can().chain().focus().redo().run(),isActive:()=>!1,shortcut:"Mod-Shift-z",label:"Redo"}},ll={1:"Heading 1",2:"Heading 2",3:"Heading 3",4:"Heading 4",5:"Heading 5",6:"Heading 6"};function al({editor:t,levels:e=[1,2,3,4,5,6],isDisabled:n=!1}){const[,r]=b.useState(0);b.useEffect(()=>{const o=()=>r(l=>l+1);return t.on("selectionUpdate",o),t.on("transaction",o),()=>{t.off("selectionUpdate",o),t.off("transaction",o)}},[t]);const s=e.find(o=>t.isActive("heading",{level:o})),i=o=>{const l=Number(o),a=Ke.heading;a&&a.execute({editor:t,config:{type:"heading",level:l}})};return c.jsxs(g.Dropdown,{placement:"top-start",offset:10,children:[c.jsx(g.DropdownTrigger,{children:c.jsx(se,{size:"sm",radius:"sm",variant:s?"solid":"bordered",color:s?"primary":"default",isDisabled:n,startContent:c.jsx(B.Heading,{size:16}),"aria-label":"Select heading level",children:s?`H${s}`:"H"})}),c.jsx(g.DropdownMenu,{"aria-label":"Heading levels",selectionMode:"single",selectedKeys:s?new Set([String(s)]):new Set,onAction:i,children:e.map(o=>c.jsx(g.DropdownItem,{startContent:t.isActive("heading",{level:o})?c.jsx(B.Check,{size:16}):c.jsx("div",{className:"w-4"}),children:ll[o]},o))})]})}const jn={bulletList:{label:"Bullet List",icon:B.List},orderedList:{label:"Numbered List",icon:B.ListOrdered},taskList:{label:"Task List",icon:B.ListTodo}};function cl({editor:t,types:e=["bulletList","orderedList","taskList"],isDisabled:n=!1}){const[,r]=b.useState(0);b.useEffect(()=>{const l=()=>r(a=>a+1);return t.on("selectionUpdate",l),t.on("transaction",l),()=>{t.off("selectionUpdate",l),t.off("transaction",l)}},[t]);const s=e.find(l=>t.isActive(l)),i=s?jn[s].icon:B.List,o=l=>{const u=Ke[l];u&&u.execute({editor:t})};return c.jsxs(g.Dropdown,{placement:"top-start",offset:10,children:[c.jsx(g.DropdownTrigger,{children:c.jsx(se,{size:"sm",radius:"sm",variant:s?"solid":"bordered",color:s?"primary":"default",isDisabled:n,isIconOnly:!0,"aria-label":"Select list type",children:c.jsx(i,{size:16})})}),c.jsx(g.DropdownMenu,{"aria-label":"List types",selectionMode:"single",selectedKeys:s?new Set([s]):new Set,onAction:o,children:e.map(l=>{const a=jn[l].icon;return c.jsx(g.DropdownItem,{startContent:c.jsx(a,{size:16}),children:jn[l].label},l)})})]})}function ul({colors:t,selectedColor:e,onColorSelect:n,columns:r=4}){return c.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:`repeat(${r}, minmax(0, 1fr))`},children:t.map(s=>{const i=e===s;return c.jsx("button",{type:"button",onClick:()=>n(s),className:`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),h=require("@heroui/react"),y=require("react"),H=require("lucide-react"),Re=require("framer-motion"),Fr=require("@tiptap/react"),z=require("@tiptap/core"),sl=require("@tiptap/extension-underline"),il=require("@tiptap/extension-color"),al=require("@tiptap/extension-highlight"),ol=require("@tiptap/extension-link"),ll=require("@tiptap/extension-task-list"),cl=require("@tiptap/extension-task-item"),dl=require("@tiptap/extension-text-align");function ul({children:t}){return l.jsx(h.HeroUIProvider,{children:t})}const q=y.forwardRef(({color:t="primary",radius:e="full",testId:n="veevart-button",...r},s)=>l.jsx(h.Button,{ref:s,color:t,radius:e,"data-testid":n,...r}));q.displayName="Button";function fl(t){const e=t?.closest('[role="dialog"]');return e?.parentElement??e??void 0}const mt=y.forwardRef(({popoverProps:t,...e},n)=>{const r=y.useRef(null),[s,i]=y.useState(void 0),a={...t,disableDialogFocus:t?.disableDialogFocus??(s?!0:void 0),portalContainer:t?.portalContainer??s};return y.useEffect(()=>{i(fl(r.current))},[]),l.jsx("span",{ref:r,className:"contents",children:l.jsx(h.Select,{ref:n,...e,popoverProps:a})})});mt.displayName="Select";const hl={login:"Login",logout:"Logout",selectLanguage:"Select your language"};function ml({languages:t,selectedLanguage:e,onLanguageChange:n,label:r}){const s=t.find(i=>i.code===e);return l.jsx("div",{className:"flex items-center",children:l.jsxs("div",{className:"relative flex items-center",children:[l.jsx(mt,{"data-testid":"language-select-desktop",variant:"bordered","aria-label":r,selectedKeys:e?[e]:[],onSelectionChange:i=>{const a=Array.from(i)[0]||e;n?.(a)},className:"min-w-36 hidden md:inline-flex",isDisabled:t.length===0,placeholder:r,startContent:l.jsx(H.Globe,{className:"w-5 h-5 text-black"}),renderValue:()=>l.jsx("span",{children:s?.label||r}),size:"md",radius:"full",children:t.map(i=>l.jsx(h.SelectItem,{textValue:i.label,"data-testid":`language-select-option-${i.code}`,children:i.label},i.code))}),l.jsx(mt,{"aria-label":r,"data-testid":"language-select-mobile",variant:"bordered",selectedKeys:e?[e]:[],onSelectionChange:i=>{const a=Array.from(i)[0]||e;n?.(a)},className:"w-24 inline-flex md:hidden",isDisabled:t.length===0,placeholder:"",startContent:l.jsx(H.Globe,{className:"w-6 h-6 text-black"}),renderValue:()=>l.jsx("span",{children:s?.code.toUpperCase()||""}),size:"md",radius:"full",children:t.map(i=>l.jsx(h.SelectItem,{textValue:i.code.toUpperCase(),"data-testid":`language-select-option-mobile-${i.code}`,children:i.code.toUpperCase()},i.code))})]})})}function pl({isLoggedIn:t,onLogin:e,onLogout:n,labels:r}){return t?l.jsxs(q,{"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(H.User,{className:"inline w-5 h-5"}),l.jsx("span",{className:"hidden md:inline",children:r.logout})]}):l.jsxs(q,{"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:e,size:"md",children:[l.jsx(H.User,{className:"inline w-5 h-5"}),l.jsx("span",{className:"hidden md:inline",children:r.login})]})}function gl({logo:t,languages:e=[],selectedLanguage:n,onLanguageChange:r,isLoggedIn:s,onLogin:i,onLogout:a,hasLanguages:o,hasAuth:c,labels:d={},className:u}){const f={...hl,...d};return l.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:[l.jsx("div",{className:"flex items-center min-w-10",children:t&&l.jsx("a",{href:"/",className:"block",children:l.jsx("img",{"data-testid":"navbar-logo",src:t,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||e.length>0)&&l.jsx(ml,{languages:e,selectedLanguage:n,onLanguageChange:r,label:f.selectLanguage}),c&&l.jsx(pl,{isLoggedIn:s,onLogin:i,onLogout:a,labels:f})]})]})}function xl(t){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(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 Vn;const yl=typeof document<"u"?(Vn=y.useInsertionEffect)!==null&&Vn!==void 0?Vn:y.useLayoutEffect:()=>{};function Pr(t,e,n){let[r,s]=y.useState(t||e),i=y.useRef(r),a=y.useRef(t!==void 0),o=t!==void 0;y.useEffect(()=>{let f=a.current;f!==o&&process.env.NODE_ENV!=="production"&&console.warn(`WARN: A component changed from ${f?"controlled":"uncontrolled"} to ${o?"controlled":"uncontrolled"}.`),a.current=o},[o]);let c=o?t:r;yl(()=>{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 bl(t){return l.jsx("svg",{...t,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:l.jsx(Re.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 Ri=y.forwardRef(({color:t="primary",stepsCount:e=3,defaultStep:n=0,label:r,onStepChange:s,currentStep:i,hideProgressBars:a=!1,stepClassName:o,className:c,isDisabled:d=!1,...u},f)=>{const[p,m]=Pr(i,n,s),v=y.useMemo(()=>{let b,x;const k=["[--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(t){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 k.unshift(x),k.unshift(b),k},[t]);return l.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&&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:h.cn("flex flex-row flex-nowrap gap-x-3",v,c),"data-testid":"stepper-list",children:Array.from({length:e})?.map((b,x)=>{const k=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":k==="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},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(Re.LazyMotion,{features:Re.domAnimation,children:l.jsx(Re.m.div,{animate:k,className:"relative",children:l.jsx(Re.m.div,{animate:k,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":k==="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:k==="complete"?l.jsx(bl,{className:"h-5 w-5 text-(--active-fg-color)","data-testid":`stepper-step-check-${x}`}):l.jsx("span",{})})})})})}),x<e-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: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)})})]})});Ri.displayName="Stepper";function vl(t){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(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 pt(t,e="en-US",n="USD"){try{return new Intl.NumberFormat(e,{style:"currency",currency:n}).format(t)}catch{return`${n} ${t.toFixed(2)}`}}function Rr(t,e="en-US"){try{const n=new Intl.NumberFormat(e,{style:"currency",currency:t}).resolvedOptions();return typeof n.maximumFractionDigits=="number"?n.maximumFractionDigits:2}catch{return 2}}function zi(t,e,n="en-US"){const r=Rr(e,n),s=Math.pow(10,r);return Math.round(t*s)/s}function hr(t,e,n,r){return zi(t-e,n,r)}function kl(){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 wl=t=>{const e=y.useMemo(()=>JSON.stringify({allItems:t.allItems,selected:t.selected}),[t.allItems,t.selected]);return l.jsx(Sl,{...t},e)},Sl=({allItems:t,selected:e,onSelectedChange:n,titleLeft:r,titleRight:s})=>{const[i,a]=y.useState([]),[o,c]=y.useState([]),[d,u]=y.useState(null),[f,p]=y.useState(null),m=y.useMemo(()=>new Set(e),[e]),v=y.useMemo(()=>new Set(t),[t]),b=y.useMemo(()=>t.filter(I=>!m.has(I)),[t,m]),x=I=>{if(I.length===0)return;const T=Array.from(new Set([...e,...I]));n(T)},k=I=>{if(I.length===0)return;const T=new Set(I);n(e.filter(O=>!T.has(O)))},S=()=>{i.length!==0&&(x(i),a([]))},A=()=>{o.length!==0&&(k(o),c([]))},N=()=>{b.length!==0&&(x(b),a([]))},j=()=>{e.length!==0&&(n([]),c([]))},M=(I,T,O)=>{const P=Math.min(T,O),K=Math.max(T,O);return I.slice(P,K+1)},D=(I,T,O)=>{if(O&&d!==null){a(M(b,d,T)),c([]),u(T);return}const P=i.includes(I);a(P?i.filter(K=>K!==I):[...i,I]),c([]),u(T)},B=(I,T,O)=>{if(O&&f!==null){c(M(e,f,T)),a([]),p(T);return}const P=o.includes(I);c(P?o.filter(K=>K!==I):[...o,I]),a([]),p(T)},R=(I,T,O)=>{const P=O==="available"?i.includes(T)?i:[T]:o.includes(T)?o:[T];I.dataTransfer.setData("text/plain",JSON.stringify({source:O,items:P})),I.dataTransfer.effectAllowed="move"},V=(I,T)=>{I.preventDefault();const O=I.dataTransfer.getData("text/plain");if(O)try{const P=JSON.parse(O),K=(P.items||[]).filter(X=>v.has(X));if(K.length===0||P.source===T)return;T==="selected"?(x(K),a([])):(k(K),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(h.Card,{className:"w-full border border-gray-200 shadow-none",children:l.jsx(h.CardBody,{className:"h-60 gap-2 overflow-y-auto",onDragOver:I=>I.preventDefault(),onDrop:I=>V(I,"available"),children:b.map((I,T)=>{const O=i.includes(I);return l.jsx("button",{type:"button",onClick:P=>{D(I,T,P.shiftKey)},onMouseDown:P=>{P.shiftKey&&P.preventDefault()},draggable:!0,onDragStart:P=>R(P,I,"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:I},I)})})})]}),l.jsxs("div",{className:"flex flex-row items-center justify-center gap-3 md:flex-col md:pt-6",children:[l.jsx(q,{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(q,{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:o.length===0,"aria-label":"Move selected to left",children:"‹"}),l.jsx(q,{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(q,{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:e.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(h.Card,{className:"w-full border border-gray-200 shadow-none",children:l.jsx(h.CardBody,{className:"h-60 gap-2 overflow-y-auto",onDragOver:I=>I.preventDefault(),onDrop:I=>V(I,"selected"),children:e.map((I,T)=>{const O=o.includes(I);return l.jsx("button",{type:"button",onClick:P=>{B(I,T,P.shiftKey)},onMouseDown:P=>{P.shiftKey&&P.preventDefault()},draggable:!0,onDragStart:P=>R(P,I,"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:I},I)})})})]})]})};function Bt(t){return typeof t=="string"?t:t.type}function st({className:t}){return l.jsx("div",{className:`flex items-center h-6 ${t||""}`,children:l.jsx(h.Divider,{orientation:"vertical"})})}function it({icon:t,label:e,isActive:n=!1,isDisabled:r=!1,onClick:s,shortcut:i,iconSize:a=16,className:o}){const c=i?`${e} (${i})`:e;return l.jsx(h.Tooltip,{content:c,placement:"top",offset:10,children:l.jsx(q,{size:"sm",radius:"sm",color:n?"primary":"default",variant:n?"solid":"bordered",isIconOnly:!0,isDisabled:r,onPress:s,"aria-label":e,className:o,children:l.jsx(t,{size:a})})})}const We={bold:{execute:({editor:t})=>t.chain().focus().toggleBold().run(),canExecute:t=>t.can().chain().focus().toggleBold().run(),isActive:t=>t.isActive("bold"),shortcut:"Mod-b",label:"Bold"},italic:{execute:({editor:t})=>t.chain().focus().toggleItalic().run(),canExecute:t=>t.can().chain().focus().toggleItalic().run(),isActive:t=>t.isActive("italic"),shortcut:"Mod-i",label:"Italic"},strike:{execute:({editor:t})=>t.chain().focus().toggleStrike().run(),canExecute:t=>t.can().chain().focus().toggleStrike().run(),isActive:t=>t.isActive("strike"),shortcut:"Mod-Shift-x",label:"Strikethrough"},underline:{execute:({editor:t})=>t.chain().focus().toggleUnderline().run(),canExecute:t=>t.can().chain().focus().toggleUnderline().run(),isActive:t=>t.isActive("underline"),shortcut:"Mod-u",label:"Underline"},code:{execute:({editor:t})=>t.chain().focus().toggleCode().run(),canExecute:t=>t.can().chain().focus().toggleCode().run(),isActive:t=>t.isActive("code"),shortcut:"Mod-e",label:"Inline code"},textColor:{execute:({editor:t,config:e})=>{const n=e?.type==="textColor"?e.color:"";n?t.chain().focus().setColor(n).run():t.chain().focus().unsetColor().run()},canExecute:()=>!0,isActive:t=>t.isActive("textStyle"),label:"Text color"},highlight:{execute:({editor:t,config:e})=>{const n=e?.type==="highlight"?e.color:"";n?t.chain().focus().setHighlight({color:n}).run():t.chain().focus().unsetHighlight().run()},canExecute:()=>!0,isActive:t=>t.isActive("highlight"),label:"Highlight"},link:{execute:({editor:t,config:e})=>{const n=e?.type==="link"?e.href:"";if(n){const r=e?.type==="link"?e.target:void 0,s=e?.type==="link"?e.rel:void 0;t.chain().focus().setLink({href:n,target:r,rel:s}).run()}else t.chain().focus().unsetLink().run()},canExecute:()=>!0,isActive:t=>t.isActive("link"),shortcut:"Mod-k",label:"Link"},paragraph:{execute:({editor:t})=>t.chain().focus().setParagraph().run(),canExecute:t=>t.can().chain().focus().setParagraph().run(),isActive:t=>t.isActive("paragraph"),shortcut:"Mod-Alt-0",label:"Paragraph"},heading:{execute:({editor:t,config:e})=>{const n=e?.type==="heading"?e.level:1;t.chain().focus().toggleHeading({level:n}).run()},canExecute:(t,e)=>{const n=e?.type==="heading"?e.level:1;return t.can().chain().focus().toggleHeading({level:n}).run()},isActive:(t,e)=>e?.type==="heading"?t.isActive("heading",{level:e.level}):t.isActive("heading"),label:"Heading"},bulletList:{execute:({editor:t})=>t.chain().focus().toggleBulletList().run(),canExecute:t=>t.can().chain().focus().toggleBulletList().run(),isActive:t=>t.isActive("bulletList"),shortcut:"Mod-Shift-8",label:"Bullet list"},orderedList:{execute:({editor:t})=>t.chain().focus().toggleOrderedList().run(),canExecute:t=>t.can().chain().focus().toggleOrderedList().run(),isActive:t=>t.isActive("orderedList"),shortcut:"Mod-Shift-7",label:"Numbered list"},taskList:{execute:({editor:t})=>t.chain().focus().toggleTaskList().run(),canExecute:t=>t.can().chain().focus().toggleTaskList().run(),isActive:t=>t.isActive("taskList"),label:"Task list"},codeBlock:{execute:({editor:t})=>t.chain().focus().toggleCodeBlock().run(),canExecute:t=>t.can().chain().focus().toggleCodeBlock().run(),isActive:t=>t.isActive("codeBlock"),shortcut:"Mod-Alt-c",label:"Code block"},blockquote:{execute:({editor:t})=>t.chain().focus().toggleBlockquote().run(),canExecute:t=>t.can().chain().focus().toggleBlockquote().run(),isActive:t=>t.isActive("blockquote"),shortcut:"Mod-Shift-b",label:"Blockquote"},horizontalRule:{execute:({editor:t})=>t.chain().focus().setHorizontalRule().run(),canExecute:t=>t.can().chain().focus().setHorizontalRule().run(),isActive:()=>!1,label:"Horizontal rule"},hardBreak:{execute:({editor:t})=>t.chain().focus().setHardBreak().run(),canExecute:t=>t.can().chain().focus().setHardBreak().run(),isActive:()=>!1,shortcut:"Mod-Enter",label:"Line break"},textAlign:{execute:({editor:t,config:e})=>{const n=e?.type==="textAlign"?e.alignment:"left";t.chain().focus().setTextAlign(n).run()},canExecute:()=>!0,isActive:(t,e)=>e?.type==="textAlign"?t.isActive({textAlign:e.alignment}):!1,label:"Text alignment"},clearMarks:{execute:({editor:t})=>t.chain().focus().unsetAllMarks().run(),canExecute:t=>t.can().chain().focus().unsetAllMarks().run(),isActive:()=>!1,label:"Clear formatting"},clearNodes:{execute:({editor:t})=>t.chain().focus().clearNodes().run(),canExecute:t=>t.can().chain().focus().clearNodes().run(),isActive:()=>!1,label:"Clear nodes"},undo:{execute:({editor:t})=>t.chain().focus().undo().run(),canExecute:t=>t.can().chain().focus().undo().run(),isActive:()=>!1,shortcut:"Mod-z",label:"Undo"},redo:{execute:({editor:t})=>t.chain().focus().redo().run(),canExecute:t=>t.can().chain().focus().redo().run(),isActive:()=>!1,shortcut:"Mod-Shift-z",label:"Redo"}},Nl={1:"Heading 1",2:"Heading 2",3:"Heading 3",4:"Heading 4",5:"Heading 5",6:"Heading 6"};function Cl({editor:t,levels:e=[1,2,3,4,5,6],isDisabled:n=!1}){const[,r]=y.useState(0);y.useEffect(()=>{const a=()=>r(o=>o+1);return t.on("selectionUpdate",a),t.on("transaction",a),()=>{t.off("selectionUpdate",a),t.off("transaction",a)}},[t]);const s=e.find(a=>t.isActive("heading",{level:a})),i=a=>{const o=Number(a),c=We.heading;c&&c.execute({editor:t,config:{type:"heading",level:o}})};return l.jsxs(h.Dropdown,{placement:"top-start",offset:10,children:[l.jsx(h.DropdownTrigger,{children:l.jsx(q,{size:"sm",radius:"sm",variant:s?"solid":"bordered",color:s?"primary":"default",isDisabled:n,startContent:l.jsx(H.Heading,{size:16}),"aria-label":"Select heading level",children:s?`H${s}`:"H"})}),l.jsx(h.DropdownMenu,{"aria-label":"Heading levels",selectionMode:"single",selectedKeys:s?new Set([String(s)]):new Set,onAction:i,children:e.map(a=>l.jsx(h.DropdownItem,{startContent:t.isActive("heading",{level:a})?l.jsx(H.Check,{size:16}):l.jsx("div",{className:"w-4"}),children:Nl[a]},a))})]})}const Hn={bulletList:{label:"Bullet List",icon:H.List},orderedList:{label:"Numbered List",icon:H.ListOrdered},taskList:{label:"Task List",icon:H.ListTodo}};function jl({editor:t,types:e=["bulletList","orderedList","taskList"],isDisabled:n=!1}){const[,r]=y.useState(0);y.useEffect(()=>{const o=()=>r(c=>c+1);return t.on("selectionUpdate",o),t.on("transaction",o),()=>{t.off("selectionUpdate",o),t.off("transaction",o)}},[t]);const s=e.find(o=>t.isActive(o)),i=s?Hn[s].icon:H.List,a=o=>{const d=We[o];d&&d.execute({editor:t})};return l.jsxs(h.Dropdown,{placement:"top-start",offset:10,children:[l.jsx(h.DropdownTrigger,{children:l.jsx(q,{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(h.DropdownMenu,{"aria-label":"List types",selectionMode:"single",selectedKeys:s?new Set([s]):new Set,onAction:a,children:e.map(o=>{const c=Hn[o].icon;return l.jsx(h.DropdownItem,{startContent:l.jsx(c,{size:16}),children:Hn[o].label},o)})})]})}function Al({colors:t,selectedColor:e,onColorSelect:n,columns:r=4}){return l.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:`repeat(${r}, minmax(0, 1fr))`},children:t.map(s=>{const i=e===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 Ml=["#000000","#374151","#6B7280","#EF4444","#F59E0B","#10B981","#3B82F6","#8B5CF6","#EC4899","#14B8A6","#F97316","#A855F7"],El=["#FEF3C7","#DBEAFE","#D1FAE5","#FCE7F3","#E0E7FF","#FED7AA","#F3E8FF","#CCFBF1","#FEE2E2","#E5E7EB","#FAE8FF","#BFDBFE"];function Un(t){return/^#([0-9A-F]{3}){1,2}$/i.test(t)}const ke={min:50,max:200,step:10,default:100},ws={lineHeight:24,toolbarHeight:60},Tl={bold:H.Bold,italic:H.Italic,strike:H.Strikethrough,underline:H.Underline,code:H.Code,textColor:H.Palette,highlight:H.Highlighter,link:H.Link2,paragraph:H.FileText,heading:H.Heading,bulletList:H.List,orderedList:H.ListOrdered,taskList:H.ListTodo,codeBlock:H.CodeSquare,blockquote:H.Quote,horizontalRule:H.Minus,clearMarks:H.Eraser,clearNodes:H.Eraser,undo:H.Undo2,redo:H.Redo2,hardBreak:H.CornerDownLeft,textAlign:H.AlignLeft},Dl={left:H.AlignLeft,center:H.AlignCenter,right:H.AlignRight,justify:H.AlignJustify};function vt(t){return Tl[t]}function Il({value:t,onChange:e,onApply:n,placeholder:r="#000000"}){const[s,i]=y.useState(""),a=d=>{const u=d.target.value;e(u),s&&i("")},o=()=>{if(!t){i("Please enter a color");return}if(!Un(t)){i("Invalid hex color (e.g., #FF0000)");return}i(""),n(t)},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(h.Input,{type:"text",value:t,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:Un(t)?t:"transparent"}})}),l.jsx(q,{size:"sm",color:"primary",variant:"flat",isIconOnly:!0,onPress:o,"aria-label":"Apply custom color",isDisabled:!t||!Un(t),children:l.jsx(H.Check,{size:16})})]}),l.jsx("p",{className:"text-xs text-default-500",children:"Enter a hex color code (e.g., #FF0000)"})]})}function Ss({editor:t,type:e,allowCustomColor:n=!0,label:r,isDisabled:s=!1}){const[i,a]=y.useState(!1),[o,c]=y.useState(""),d=e==="textColor"?Ml:El,u=b=>{const x=We[e];x&&x.execute({editor:t,config:{type:e,color:b}}),a(!1),c("")},f=b=>{u(b)},p=()=>{const b=We[e];b&&b.execute({editor:t,config:{type:e,color:""}}),a(!1)},m=e==="textColor"?t.isActive("textStyle"):t.isActive("highlight"),v=e==="textColor"?H.Palette:H.Highlighter;return l.jsxs(h.Popover,{isOpen:i,onOpenChange:a,placement:"top",offset:10,showArrow:!0,children:[l.jsx(h.PopoverTrigger,{children:l.jsx(q,{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(h.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(q,{size:"sm",variant:"light",isIconOnly:!0,onPress:p,"aria-label":"Clear color",children:l.jsx(H.X,{size:16})})]}),l.jsx(Al,{colors:d,onColorSelect:u}),n&&l.jsxs(l.Fragment,{children:[l.jsx(h.Divider,{}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs font-semibold mb-2 text-default-700",children:"Custom Color"}),l.jsx(Il,{value:o,onChange:c,onApply:f})]})]})]})})]})}function $l({zoom:t,onZoomChange:e,min:n=ke.min,max:r=ke.max,step:s=ke.step}){const i=()=>{const f=Math.max(n,t-s);e(f)},a=()=>{const f=Math.min(r,t+s);e(f)},o=()=>{e(ke.default)},c=t<=n,d=t>=r,u=t===ke.default;return l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(h.Tooltip,{content:"Zoom out",placement:"top",offset:10,children:l.jsx(q,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:c,onPress:i,"aria-label":"Zoom out",children:l.jsx(H.ZoomOut,{size:16})})}),l.jsx(h.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
|
-
${
|
|
10
|
-
`,"aria-label":`Zoom level ${t}%`,children:[t,"%"]})}),c.jsx(g.Tooltip,{content:"Zoom in",placement:"top",offset:10,children:c.jsx(se,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:u,onPress:o,"aria-label":"Zoom in",children:c.jsx(B.ZoomIn,{size:16})})})]})}function yl({editor:t,isDisabled:e=!1}){const[n,r]=b.useState(!1),[s,i]=b.useState(""),[o,l]=b.useState(""),[a,u]=b.useState(!1),d=t.isActive("link"),f=h=>{if(h){const{from:S,to:x}=t.state.selection,k=t.isActive("link");let C="";if(k){const T=t.schema.marks.link,A=t.state.doc.resolve(S),N=R.getMarkRange(A,T);N&&(C=t.state.doc.textBetween(N.from,N.to,""))}else C=t.state.doc.textBetween(S,x,"");const w=t.getAttributes("link").href||"";i(C),l(w),u(k)}r(h)},m=()=>{if(o.trim()){const{from:h,to:S}=t.state.selection,x=t.schema.marks.link,k=t.state.doc.resolve(h),C=R.getMarkRange(k,x),w=C?.from??h,T=C?.to??S,A=t.state.doc.textBetween(w,T,"");s.trim()&&s!==A?t.chain().focus().setTextSelection({from:w,to:T}).deleteSelection().insertContent(`<a href="${o.trim()}">${s.trim()}</a>`).run():t.chain().focus().extendMarkRange("link").updateAttributes("link",{href:o.trim()}).run()}r(!1)};return c.jsxs(g.Popover,{isOpen:n,onOpenChange:f,placement:"bottom",children:[c.jsx(g.PopoverTrigger,{children:c.jsx(se,{size:"sm",radius:"sm",variant:d?"solid":"bordered",color:d?"primary":"default",isIconOnly:!0,isDisabled:e,"aria-label":"Link",children:c.jsx(B.Link,{size:16})})}),c.jsx(g.PopoverContent,{children:c.jsxs("div",{className:"flex flex-col gap-3 p-3 w-72",children:[c.jsx(g.Input,{size:"sm",variant:"bordered",label:"Name",labelPlacement:"outside",placeholder:"Link text",value:s,onChange:h=>i(h.target.value),classNames:{inputWrapper:"focus-within:border-default-400"}}),c.jsx(g.Input,{size:"sm",variant:"bordered",label:"Link",labelPlacement:"outside",placeholder:"https://example.com",value:o,onChange:h=>l(h.target.value),onKeyDown:h=>h.key==="Enter"&&m(),classNames:{inputWrapper:"focus-within:border-default-400"}}),c.jsx(se,{size:"sm",color:"primary",onPress:m,isDisabled:!o.trim(),children:a?"Update":"Apply"})]})})]})}function xl({children:t,id:e,label:n,className:r,useButtonGroup:s=!0}){return s?c.jsx(g.ButtonGroup,{size:"sm",id:e,"aria-label":n,className:r,children:t}):c.jsx("div",{id:e,role:"group","aria-label":n,className:`flex items-center gap-2 ${r||""}`,children:t})}function ei(t,e){const n=b.useMemo(()=>{if(!t)return{};const i={};return Array.from(new Set(e.map(l=>Rt(l)))).forEach(l=>{const a=Ke[l];if(a)try{const u=a.canExecute?.(t)??!0,d=a.isActive?.(t)??!1;i[l]={isActive:d,isDisabled:!u,canExecute:u}}catch(u){console.warn(`Extension not available for modifier: ${l}`,u),i[l]={isActive:!1,isDisabled:!0,canExecute:!1}}}),i},[t,e]),[r,s]=b.useState(n);return b.useEffect(()=>{if(!t)return;const i=()=>{const o={};Array.from(new Set(e.map(a=>Rt(a)))).forEach(a=>{const u=Ke[a];if(u)try{const d=u.canExecute?.(t)??!0,f=u.isActive?.(t)??!1;o[a]={isActive:f,isDisabled:!d,canExecute:d}}catch(d){console.warn(`Extension not available for modifier: ${a}`,d),o[a]={isActive:!1,isDisabled:!0,canExecute:!1}}}),s(o)};return t.on("selectionUpdate",i),t.on("transaction",i),()=>{t.off("selectionUpdate",i),t.off("transaction",i)}},[t,e,n]),r}function ti(t,e){const n=b.useCallback((o,l)=>{if(!t)return;const a=Ke[o];if(a)try{a.execute({editor:t,config:l}),e?.({type:"toggle",modifier:o})}catch(u){console.warn(`Failed to execute command for modifier: ${o}`,u)}},[t,e]),r=b.useCallback(o=>{n(o)},[n]),s=b.useCallback((o,l)=>{if(!t)return!1;const a=Ke[o];try{return a?.canExecute?.(t,l)??!1}catch(u){return console.warn(`Failed to check canExecute for modifier: ${o}`,u),!1}},[t]),i=b.useCallback((o,l)=>{if(!t)return!1;const a=Ke[o];try{return a?.isActive?.(t,l)??!1}catch(u){return console.warn(`Failed to check isActive for modifier: ${o}`,u),!1}},[t]);return{executeCommand:n,toggleModifier:r,canExecute:s,isActive:i}}function bl(t=xe.default){const[e,n]=b.useState(t),r=b.useCallback((l=xe.step)=>{n(a=>Math.min(xe.max,a+l))},[]),s=b.useCallback((l=xe.step)=>{n(a=>Math.max(xe.min,a-l))},[]),i=b.useCallback(()=>{n(xe.default)},[]),o=b.useCallback(l=>{const a=Math.max(xe.min,Math.min(xe.max,l));n(a)},[]);return{zoom:e,setZoom:o,zoomIn:r,zoomOut:s,resetZoom:i,isMinZoom:e<=xe.min,isMaxZoom:e>=xe.max,isDefaultZoom:e===xe.default}}const kl=["bold","italic","strike","underline","code"];function vl({editor:t,modifiers:e,onToolbarAction:n}){const r=ei(t,e),{toggleModifier:s}=ti(t,n);if(!t)return null;const i=e.map(o=>Rt(o)).filter(o=>kl.includes(o));return i.length===0?null:c.jsx(xl,{id:"text-formatting",label:"Text formatting",children:i.map(o=>{const l=r[o],a=yt(o);return c.jsx(st,{icon:a,label:o.charAt(0).toUpperCase()+o.slice(1),isActive:l?.isActive,isDisabled:l?.isDisabled,onClick:()=>s(o)},o)})})}function Sl({editor:t,modifiers:e,zoom:n=100,onZoomChange:r,sticky:s=!0,className:i,onToolbarAction:o}){const l=ei(t,e),{toggleModifier:a,executeCommand:u}=ti(t,o);if(!t)return null;const d=e.map(L=>Rt(L)),f=d.some(L=>["bold","italic","strike","underline","code"].includes(L)),m=d.some(L=>["textColor","highlight"].includes(L)),h=d.includes("heading"),S=d.includes("textAlign"),x=d.some(L=>["bulletList","orderedList","taskList"].includes(L)),k=d.includes("blockquote"),C=d.includes("codeBlock"),w=d.includes("link"),T=d.includes("horizontalRule"),A=d.some(L=>["undo","redo"].includes(L)),N=n!==void 0&&r!==void 0,O=s?"sticky top-0 z-10":"";return c.jsx("div",{className:`w-full p-2 bg-background border-b border-divider ${O} ${i||""}`,children:c.jsxs("div",{className:"flex flex-row flex-wrap gap-2 w-full items-center",children:[f&&c.jsxs(c.Fragment,{children:[c.jsx(vl,{editor:t,modifiers:e,onToolbarAction:o}),(m||h||S||x||k||C||w||T||A||N)&&c.jsx(rt,{})]}),m&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-1",children:[d.includes("textColor")&&c.jsx(Gr,{editor:t,type:"textColor",label:"Text color",isDisabled:l.textColor?.isDisabled}),d.includes("highlight")&&c.jsx(Gr,{editor:t,type:"highlight",label:"Highlight",isDisabled:l.highlight?.isDisabled})]}),(h||S||x||k||C||w||T||A||N)&&c.jsx(rt,{})]}),h&&c.jsxs(c.Fragment,{children:[c.jsx(al,{editor:t}),(S||x||k||C||w||T||A||N)&&c.jsx(rt,{})]}),S&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"flex items-center gap-1",children:["left","center","right","justify"].map(L=>{const _=pl[L],z=t.isActive({textAlign:L});return c.jsx(st,{icon:_,label:`Align ${L}`,isActive:z,onClick:()=>u("textAlign",{type:"textAlign",alignment:L})},L)})}),(x||k||C||w||T||A||N)&&c.jsx(rt,{})]}),x&&c.jsxs(c.Fragment,{children:[c.jsx(cl,{editor:t,types:d.filter(L=>["bulletList","orderedList","taskList"].includes(L))}),(k||C||w||T||A||N)&&c.jsx(rt,{})]}),(k||C||w||T)&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-1",children:[k&&c.jsx(st,{icon:yt("blockquote"),label:"Blockquote",isActive:l.blockquote?.isActive,isDisabled:l.blockquote?.isDisabled,onClick:()=>a("blockquote")}),C&&c.jsx(st,{icon:yt("codeBlock"),label:"Code block",isActive:l.codeBlock?.isActive,isDisabled:l.codeBlock?.isDisabled,onClick:()=>a("codeBlock")}),w&&c.jsx(yl,{editor:t,isDisabled:l.link?.isDisabled}),T&&c.jsx(st,{icon:yt("horizontalRule"),label:"Horizontal rule",onClick:()=>a("horizontalRule")})]}),(A||N)&&c.jsx(rt,{})]}),A&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-1",children:[d.includes("undo")&&c.jsx(st,{icon:yt("undo"),label:"Undo",isDisabled:l.undo?.isDisabled,onClick:()=>a("undo")}),d.includes("redo")&&c.jsx(st,{icon:yt("redo"),label:"Redo",isDisabled:l.redo?.isDisabled,onClick:()=>a("redo")})]}),N&&c.jsx(rt,{})]}),N&&c.jsx(gl,{zoom:n,onZoomChange:L=>{r?.(L),o?.({type:"zoom",modifier:`${L}%`})}})]})})}const Cl=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,wl=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Al=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Nl=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Tl=R.Mark.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return["strong",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[R.markInputRule({find:Cl,type:this.type}),R.markInputRule({find:Al,type:this.type})]},addPasteRules(){return[R.markPasteRule({find:wl,type:this.type}),R.markPasteRule({find:Nl,type:this.type})]}}),El=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Ml=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,jl=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Il=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Ol=R.Mark.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[R.markInputRule({find:El,type:this.type}),R.markInputRule({find:jl,type:this.type})]},addPasteRules(){return[R.markPasteRule({find:Ml,type:this.type}),R.markPasteRule({find:Il,type:this.type})]}}),Dl=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Ll=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Rl=R.Mark.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[R.markInputRule({find:Dl,type:this.type})]},addPasteRules(){return[R.markPasteRule({find:Ll,type:this.type})]}}),Fl=/(^|[^`])`([^`]+)`(?!`)/,Pl=/(^|[^`])`([^`]+)`(?!`)/g,$l=R.Mark.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[R.markInputRule({find:Fl,type:this.type})]},addPasteRules(){return[R.markPasteRule({find:Pl,type:this.type})]}}),Vl=t=>{if(!t.children.length)return;const e=t.querySelectorAll("span");e&&e.forEach(n=>{var r,s;const i=n.getAttribute("style"),o=(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",`${o};${i}`)})},zl=R.Mark.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&Vl(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.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))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),Bl=R.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(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,R.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>R.textblockTypeInputRule({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),_l=R.Node.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Hl="listItem",Zr="textStyle",Qr=/^\s*([-+*])\s$/,Ul=R.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:t}){return["ul",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Hl,this.editor.getAttributes(Zr)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=R.wrappingInputRule({find:Qr,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=R.wrappingInputRule({find:Qr,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Zr),editor:this.editor})),[t]}}),ql="listItem",Xr="textStyle",Yr=/^(\d+)\.\s$/,Kl=R.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:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",R.mergeAttributes(this.options.HTMLAttributes,n),0]:["ol",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(ql,this.editor.getAttributes(Xr)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=R.wrappingInputRule({find:Yr,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=R.wrappingInputRule({find:Yr,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Xr)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),Jl=R.Node.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",R.mergeAttributes(this.options.HTMLAttributes,t),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 ni(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let s=t.child(r),i=e.child(r);if(s==i){n+=s.nodeSize;continue}if(!s.sameMarkup(i))return n;if(s.isText&&s.text!=i.text){for(let o=0;s.text[o]==i.text[o];o++)n++;return n}if(s.content.size||i.content.size){let o=ni(s.content,i.content,n+1);if(o!=null)return o}n+=s.nodeSize}}function ri(t,e,n,r){for(let s=t.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:n,b:r};let o=t.child(--s),l=e.child(--i),a=o.nodeSize;if(o==l){n-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:n,b:r};if(o.isText&&o.text!=l.text){let u=0,d=Math.min(o.text.length,l.text.length);for(;u<d&&o.text[o.text.length-u-1]==l.text[l.text.length-u-1];)u++,n--,r--;return{a:n,b:r}}if(o.content.size||l.content.size){let u=ri(o.content,l.content,n-1,r-1);if(u)return u}n-=a,r-=a}}class U{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,s=0,i){for(let o=0,l=0;l<n;o++){let a=this.content[o],u=l+a.nodeSize;if(u>e&&r(a,s+l,i||null,o)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,n-d),r,s+d)}l=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let i="",o=!0;return this.nodesBetween(e,n,(l,a)=>{let u=l.isText?l.text.slice(Math.max(e,a)-a,n-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&u||l.isTextblock)&&r&&(o?o=!1:i+=r),i+=u},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.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<e.content.length;i++)s.push(e.content[i]);return new U(s,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],s=0;if(n>e)for(let i=0,o=0;o<n;i++){let l=this.content[i],a=o+l.nodeSize;a>e&&((o<e||a>n)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,n-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,n-o-1))),r.push(l),s+=l.nodeSize),o=a}return new U(r,s)}cutByIndex(e,n){return e==n?U.empty:e==0&&n==this.content.length?this:new U(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let s=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return s[e]=n,new U(s,i)}addToStart(e){return new U([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new U(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.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(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let s=this.content[n];e(s,r,n),r+=s.nodeSize}}findDiffStart(e,n=0){return ni(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return ri(this,e,n,r)}findIndex(e){if(e==0)return qt(0,e);if(e==this.size)return qt(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let s=this.child(n),i=r+s.nodeSize;if(i>=e)return i==e?qt(n+1,i):qt(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return U.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new U(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return U.empty;let n,r=0;for(let s=0;s<e.length;s++){let i=e[s];r+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(n||(n=e.slice(0,s)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new U(n||e,r)}static from(e){if(!e)return U.empty;if(e instanceof U)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new U([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}U.empty=new U([],0);const On={index:0,offset:0};function qt(t,e){return On.index=t,On.offset=e,On}function Wn(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!Wn(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Wn(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}class De{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let s=0;s<e.length;s++){let i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))n||(n=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,s)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Wn(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.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(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return De.none;if(e instanceof De)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}}De.none=[];class Wl extends Error{}class q{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=ii(this.content,e+this.openStart,n);return r&&new q(r,this.openStart,this.openEnd)}removeBetween(e,n){return new q(si(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,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(U.fromJSON(e,n.content),r,s)}static maxOpen(e,n=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)s++;return new q(e,r,s)}}q.empty=new q(U.empty,0,0);function si(t,e,n){let{index:r,offset:s}=t.findIndex(e),i=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(s==e||i.isText){if(l!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(si(i.content,e-s-1,n-s-1)))}function ii(t,e,n,r){let{index:s,offset:i}=t.findIndex(e),o=t.maybeChild(s);if(i==e||o.isText)return r&&!r.canReplace(s,s,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=ii(o.content,e-i-1,n,o);return l&&t.replaceChild(s,o.copy(l))}function Gl(t){return t.tag!=null}function Zl(t){return t.style!=null}class tn{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(Gl(s))this.tags.push(s);else if(Zl(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=e.nodes[s.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new ts(this,n,!1);return r.addAll(e,De.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new ts(this,n,!0);return r.addAll(e,De.none,n.from,n.to),q.maxOpen(r.finish())}matchTag(e,n,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(Yl(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let o=i.getAttrs(e);if(o===!1)continue;i.attrs=o||void 0}return i}}}matchStyle(e,n,r,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let o=this.styles[i],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(o.getAttrs){let a=o.getAttrs(n);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let n=[];function r(s){let i=s.priority==null?50:s.priority,o=0;for(;o<n.length;o++){let l=n[o];if((l.priority==null?50:l.priority)<i)break}n.splice(o,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(o=>{r(o=ns(o)),o.mark||o.ignore||o.clearMark||(o.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(o=>{r(o=ns(o)),o.node||o.ignore||o.mark||(o.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new tn(e,tn.schemaRules(e)))}}const oi={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},Ql={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},li={ol:!0,ul:!0},Ft=1,Gn=2,Mt=4;function es(t,e,n){return e!=null?(e?Ft:0)|(e==="full"?Gn:0):t&&t.whitespace=="pre"?Ft|Gn:n&~Mt}class Kt{constructor(e,n,r,s,i,o){this.type=e,this.attrs=n,this.marks=r,this.solid=s,this.options=o,this.content=[],this.activeMarks=De.none,this.match=i||(o&Mt?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(U.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Ft)){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=U.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(U.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!oi.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class ts{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=n.topNode,i,o=es(null,n.preserveWhitespace,0)|(r?Mt:0);s?i=new Kt(s.type,s.attrs,De.none,!0,n.topMatch||s.type.contentMatch,o):r?i=new Kt(null,null,De.none,!0,null,o):i=new Kt(e.schema.topNodeType,null,De.none,!0,null,o),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,s=this.top,i=s.options&Gn?"full":this.localPreserveWS||(s.options&Ft)>0,{schema:o}=this.parser;if(i==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
|
|
11
|
-
`);else if(
|
|
12
|
-
`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],o=r.getPropertyValue(i);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(i,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?n=n.filter(u=>!a.clearMark(u)):n=n.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return n}addElementByRule(e,n,r,s){let i,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(o,n.attrs||null,r,n.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[n.mark];r=r.concat(a.create(n.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,n,r,s){let i=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=s==null?null:e.childNodes[s];o!=l;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,n);this.findAtPoint(e,i)}findPlace(e,n,r){let s,i;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],u=a.findWrapping(e);if(u&&(!s||s.length>u.length+l)&&(s=u,i=a,!u.length))break;if(a.solid){if(r)break;l+=2}}if(!s)return null;this.sync(i);for(let o=0;o<s.length;o++)n=this.enterInner(s[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let s=this.findPlace(e,n,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let o=De.none;for(let l of s.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):rs(l.type,e.type))&&(o=l.addToSet(o));return i.content.push(e.mark(o)),!0}return!1}enter(e,n,r,s){let i=this.findPlace(e.create(n),r,!1);return i&&(i=this.enterInner(e,n,r,!0,s)),i}enterInner(e,n,r,s=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=es(e,i,o.options);o.options&Mt&&o.content.length==0&&(l|=Mt);let a=De.none;return r=r.filter(u=>(o.type?o.type.allowsMarkType(u.type):rs(u.type,e))?(a=u.addToSet(a),!1):!0),this.nodes.push(new Kt(e,n,a,s,null,l)),this.open++,r}closeExtra(e=!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(e));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(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Ft)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&n.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.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),o=(l,a)=>{for(;l>=0;l--){let u=n[l];if(u==""){if(l==n.length-1||l==0)continue;for(;a>=i;a--)if(o(l-1,a))return!0;return!1}else{let d=a>0||a==0&&s?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!d||d.name!=u&&!d.isInGroup(u))return!1;a--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.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 Xl(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&li.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function Yl(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function ns(t){let e={};for(let n in t)e[n]=t[n];return e}function rs(t,e){let n=e.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(t))continue;let i=[],o=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:u,next:d}=l.edge(a);if(u==e||i.indexOf(d)<0&&o(d))return!0}};if(o(s.contentMatch))return!0}}class gn{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Dn(n).createDocumentFragment());let s=r,i=[];return e.forEach(o=>{if(i.length||o.marks.length){let l=0,a=0;for(;l<i.length&&a<o.marks.length;){let u=o.marks[a];if(!this.marks[u.type.name]){a++;continue}if(!u.eq(i[l][0])||u.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)s=i.pop()[1];for(;a<o.marks.length;){let u=o.marks[a++],d=this.serializeMark(u,o.isInline,n);d&&(i.push([u,s]),s.appendChild(d.dom),s=d.contentDOM||d.dom)}}s.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:s}=Zt(Dn(n),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,s)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let s=this.marks[e.type.name];return s&&Zt(Dn(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return Zt(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new gn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=ss(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return ss(e.marks)}}function ss(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Dn(t){return t.document||window.document}const is=new WeakMap;function ea(t){let e=is.get(t);return e===void 0&&is.set(t,e=ta(t)),e}function ta(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.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(t),e}function Zt(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let s=e[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=ea(r))&&i.indexOf(e)>-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 o=s.indexOf(" ");o>0&&(n=s.slice(0,o),s=s.slice(o+1));let l,a=n?t.createElementNS(n,s):t.createElement(s),u=e[1],d=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){d=2;for(let f in u)if(u[f]!=null){let m=f.indexOf(" ");m>0?a.setAttributeNS(f.slice(0,m),f.slice(m+1),u[f]):f=="style"&&a.style?a.style.cssText=u[f]:a.setAttribute(f,u[f])}}for(let f=d;f<e.length;f++){let m=e[f];if(m===0){if(f<e.length-1||f>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:h,contentDOM:S}=Zt(t,m,n,r);if(a.appendChild(h),S){if(l)throw new RangeError("Multiple content holes");l=S}}}return{dom:a,contentDOM:l}}const ai=65535,ci=Math.pow(2,16);function na(t,e){return t+e*ci}function os(t){return t&ai}function ra(t){return(t-(t&ai))/ci}const ui=1,di=2,Qt=4,fi=8;class Zn{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&fi)>0}get deletedBefore(){return(this.delInfo&(ui|Qt))>0}get deletedAfter(){return(this.delInfo&(di|Qt))>0}get deletedAcross(){return(this.delInfo&Qt)>0}}class Te{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Te.empty)return Te.empty}recover(e){let n=0,r=os(e);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+ra(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let s=0,i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let u=this.ranges[l+i],d=this.ranges[l+o],f=a+u;if(e<=f){let m=u?e==a?-1:e==f?1:n:n,h=a+s+(m<0?0:d);if(r)return h;let S=e==(n<0?a:f)?null:na(l/3,e-a),x=e==a?di:e==f?ui:Qt;return(n<0?e!=a:e!=f)&&(x|=fi),new Zn(h,x,S)}s+=d-u}return r?e+s:new Zn(e+s,0,null)}touches(e,n){let r=0,s=os(n),i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let u=this.ranges[l+i],d=a+u;if(e<=d&&l==s*3)return!0;r+=this.ranges[l+o]-u}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let o=this.ranges[s],l=o-(this.inverted?i:0),a=o+(this.inverted?0:i),u=this.ranges[s+n],d=this.ranges[s+r];e(l,l+u,a,a+d),i+=d-u}}invert(){return new Te(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Te.empty:new Te(e<0?[0,-e,0]:[0,0,e])}}Te.empty=new Te([]);class nn{constructor(e,n,r=0,s=e?e.length:0){this.mirror=n,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new nn(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let s=e.getMirror(n);this.appendMap(e._maps[n],s!=null&&s<n?r+s:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let s=e.getMirror(n);this.appendMap(e._maps[n].invert(),s!=null&&s>n?r-s-1:void 0)}}invert(){let e=new nn;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let s=0;for(let i=this.from;i<this.to;i++){let o=this._maps[i],l=o.mapResult(e,n);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this._maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return r?e:new Zn(e,s,null)}}const Ln=Object.create(null);class be{getMap(){return Te.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Ln[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Ln)throw new RangeError("Duplicate use of step JSON ID "+e);return Ln[e]=n,n.prototype.jsonID=e,n}}class de{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new de(e,null)}static fail(e){return new de(null,e)}static fromReplace(e,n,r,s){try{return de.ok(e.replace(n,r,s))}catch(i){if(i instanceof Wl)return de.fail(i.message);throw i}}}function mr(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(mr(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return U.fromArray(r)}class ot extends be{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new q(mr(n.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),n.openStart,n.openEnd);return de.fromReplace(e,this.from,this.to,i)}invert(){return new lt(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new ot(n.pos,r.pos,this.mark)}merge(e){return e instanceof ot&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ot(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,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,e.markFromJSON(n.mark))}}be.jsonID("addMark",ot);class lt extends be{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new q(mr(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return de.fromReplace(e,this.from,this.to,r)}invert(){return new ot(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new lt(n.pos,r.pos,this.mark)}merge(e){return e instanceof lt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new lt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new lt(n.from,n.to,e.markFromJSON(n.mark))}}be.jsonID("removeMark",lt);class at extends be{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return de.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return de.fromReplace(e,this.pos,this.pos+1,new q(U.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.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 at(this.pos,n.marks[s]);return new at(this.pos,this.mark)}}return new Pt(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new at(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new at(n.pos,e.markFromJSON(n.mark))}}be.jsonID("addNodeMark",at);class Pt extends be{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return de.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return de.fromReplace(e,this.pos,this.pos+1,new q(U.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new at(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Pt(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Pt(n.pos,e.markFromJSON(n.mark))}}be.jsonID("removeNodeMark",Pt);class qe extends be{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&Qn(e,this.from,this.to)?de.fail("Structure replace would overwrite content"):de.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Te([this.from,this.to-this.from,this.slice.size])}invert(e){return new qe(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),r=e.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(e){if(!(e instanceof qe)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?q.empty:new q(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new qe(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?q.empty:new q(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new qe(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,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(e,n.slice),!!n.structure)}}be.jsonID("replace",qe);class vt extends be{constructor(e,n,r,s,i,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=l}apply(e){if(this.structure&&(Qn(e,this.from,this.gapFrom)||Qn(e,this.gapTo,this.to)))return de.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return de.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?de.fromReplace(e,this.from,this.to,r):de.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(e){let n=this.gapTo-this.gapFrom;return new vt(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||i>r.pos?null:new vt(n.pos,r.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,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 vt(n.from,n.to,n.gapFrom,n.gapTo,q.fromJSON(e,n.slice),n.insert,!!n.structure)}}be.jsonID("replaceAround",vt);function Qn(t,e,n){let r=t.resolve(e),s=n-e,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,s--}}return!1}function hi(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;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 o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,a=r.index(o)+(l>0?1:0),u=r.node(o),d=!1;if(i==1)d=u.canReplace(a,a,s);else{let f=u.contentMatchAt(a).findWrapping(s.firstChild.type);d=f&&u.canReplaceWith(a,a,f[0])}if(d)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}class jt extends be{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return de.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 de.fromReplace(e,this.pos,this.pos+1,new q(U.from(s),0,n.isLeaf?0:1))}getMap(){return Te.empty}invert(e){return new jt(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new jt(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new jt(n.pos,n.attr,n.value)}}be.jsonID("attr",jt);class rn extends be{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let s in e.attrs)n[s]=e.attrs[s];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return de.ok(r)}getMap(){return Te.empty}invert(e){return new rn(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new rn(n.attr,n.value)}}be.jsonID("docAttr",rn);let $t=class extends Error{};$t=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};$t.prototype=Object.create(Error.prototype);$t.prototype.constructor=$t;$t.prototype.name="TransformError";const Rn=Object.create(null);class X{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new sa(e.min(n),e.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 e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,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=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:u}=o[l],d=e.mapping.slice(i);e.replaceRange(d.map(a.pos),d.map(u.pos),l?q.empty:n),l==0&&cs(e,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:o,$to:l}=s[i],a=e.mapping.slice(r),u=a.map(o.pos),d=a.map(l.pos);i?e.deleteRange(u,d):(e.replaceRangeWith(u,d,n),cs(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new Q(e):xt(e.node(0),e.parent,e.pos,e.index(),n,r);if(s)return s;for(let i=e.depth-1;i>=0;i--){let o=n<0?xt(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):xt(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new _e(e.node(0))}static atStart(e){return xt(e,e,0,0,1)||new _e(e)}static atEnd(e){return xt(e,e,e.content.size,e.childCount,-1)||new _e(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Rn[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Rn)throw new RangeError("Duplicate use of selection JSON ID "+e);return Rn[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Q.between(this.$anchor,this.$head).getBookmark()}}X.prototype.visible=!0;class sa{constructor(e,n){this.$from=e,this.$to=n}}let ls=!1;function as(t){!ls&&!t.parent.inlineContent&&(ls=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Q extends X{constructor(e,n=e){as(e),as(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return X.near(r);let s=e.resolve(n.map(this.anchor));return new Q(s.parent.inlineContent?s:r,r)}replace(e,n=q.empty){if(super.replace(e,n),n==q.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Q&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new yn(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Q(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let s=e.resolve(n);return new this(s,r==n?s:e.resolve(r))}static between(e,n,r){let s=e.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let i=X.findFrom(n,r,!0)||X.findFrom(n,-r,!0);if(i)n=i.$head;else return X.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(X.findFrom(e,-r,!0)||X.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new Q(e,n)}}X.jsonID("text",Q);class yn{constructor(e,n){this.anchor=e,this.head=n}map(e){return new yn(e.map(this.anchor),e.map(this.head))}resolve(e){return Q.between(e.resolve(this.anchor),e.resolve(this.head))}}class K extends X{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),i=e.resolve(s);return r?X.near(i):new K(i)}content(){return new q(U.from(this.node),0,0)}eq(e){return e instanceof K&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new gr(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new K(e.resolve(n.anchor))}static create(e,n){return new K(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}K.prototype.visible=!1;X.jsonID("node",K);class gr{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new yn(r,r):new gr(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&K.isSelectable(r)?new K(n):X.near(n)}}class _e extends X{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=q.empty){if(n==q.empty){e.delete(0,e.doc.content.size);let r=X.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new _e(e)}map(e){return new _e(e)}eq(e){return e instanceof _e}getBookmark(){return ia}}X.jsonID("all",_e);const ia={map(){return this},resolve(t){return new _e(t)}};function xt(t,e,n,r,s,i=!1){if(e.inlineContent)return Q.create(t,n);for(let o=r-(s>0?0:1);s>0?o<e.childCount:o>=0;o+=s){let l=e.child(o);if(l.isAtom){if(!i&&K.isSelectable(l))return K.create(t,n-(s<0?l.nodeSize:0))}else{let a=xt(t,l,n+s,s<0?l.childCount:0,s,i);if(a)return a}n+=l.nodeSize*s}return null}function cs(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof qe||s instanceof vt))return;let i=t.mapping.maps[r],o;i.forEach((l,a,u,d)=>{o==null&&(o=d)}),t.setSelection(X.near(t.doc.resolve(o),n))}function us(t,e){return!e||!t?t:t.bind(e)}class Jt{constructor(e,n,r){this.name=e,this.init=us(n.init,r),this.apply=us(n.apply,r)}}new Jt("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Jt("selection",{init(t,e){return t.selection||X.atStart(e.doc)},apply(t){return t.selection}}),new Jt("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Jt("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}});function pi(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=pi(s,e,{})),n[r]=s}return n}class xn{constructor(e){this.spec=e,this.props={},e.props&&pi(e.props,this,this.props),this.key=e.key?e.key.key:mi("plugin")}getState(e){return e[this.key]}}const Fn=Object.create(null);function mi(t){return t in Fn?t+"$"+ ++Fn[t]:(Fn[t]=0,t+"$")}class yr{constructor(e="key"){this.key=mi(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const oa=/^```([a-z]+)?[\s\n]$/,la=/^~~~([a-z]+)?[\s\n]$/,aa=R.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:t=>{var e;const{languageClassPrefix:n}=this.options,i=[...((e=t.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",R.mergeAttributes(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
|
|
9
|
+
${u?"cursor-default":"cursor-pointer hover:text-primary"}
|
|
10
|
+
`,"aria-label":`Zoom level ${t}%`,children:[t,"%"]})}),l.jsx(h.Tooltip,{content:"Zoom in",placement:"top",offset:10,children:l.jsx(q,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:d,onPress:a,"aria-label":"Zoom in",children:l.jsx(H.ZoomIn,{size:16})})})]})}function Ol({editor:t,isDisabled:e=!1}){const[n,r]=y.useState(!1),[s,i]=y.useState(""),[a,o]=y.useState(""),[c,d]=y.useState(!1),u=t.isActive("link"),f=m=>{if(m){const{from:v,to:b}=t.state.selection,x=t.isActive("link");let k="";if(x){const A=t.schema.marks.link,N=t.state.doc.resolve(v),j=z.getMarkRange(N,A);j&&(k=t.state.doc.textBetween(j.from,j.to,""))}else k=t.state.doc.textBetween(v,b,"");const S=t.getAttributes("link").href||"";i(k),o(S),d(x)}r(m)},p=()=>{if(a.trim()){const{from:m,to:v}=t.state.selection,b=t.schema.marks.link,x=t.state.doc.resolve(m),k=z.getMarkRange(x,b),S=k?.from??m,A=k?.to??v,N=t.state.doc.textBetween(S,A,"");s.trim()&&s!==N?t.chain().focus().setTextSelection({from:S,to:A}).deleteSelection().insertContent(`<a href="${a.trim()}">${s.trim()}</a>`).run():t.chain().focus().extendMarkRange("link").updateAttributes("link",{href:a.trim()}).run()}r(!1)};return l.jsxs(h.Popover,{isOpen:n,onOpenChange:f,placement:"bottom",children:[l.jsx(h.PopoverTrigger,{children:l.jsx(q,{size:"sm",radius:"sm",variant:u?"solid":"bordered",color:u?"primary":"default",isIconOnly:!0,isDisabled:e,"aria-label":"Link",children:l.jsx(H.Link,{size:16})})}),l.jsx(h.PopoverContent,{children:l.jsxs("div",{className:"flex flex-col gap-3 p-3 w-72",children:[l.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"}}),l.jsx(h.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(q,{size:"sm",color:"primary",onPress:p,isDisabled:!a.trim(),children:c?"Update":"Apply"})]})})]})}function Ll({children:t,id:e,label:n,className:r,useButtonGroup:s=!0}){return s?l.jsx(h.ButtonGroup,{size:"sm",id:e,"aria-label":n,className:r,children:t}):l.jsx("div",{id:e,role:"group","aria-label":n,className:`flex items-center gap-2 ${r||""}`,children:t})}function Bi(t,e){const n=y.useMemo(()=>{if(!t)return{};const i={};return Array.from(new Set(e.map(o=>Bt(o)))).forEach(o=>{const c=We[o];if(c)try{const d=c.canExecute?.(t)??!0,u=c.isActive?.(t)??!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},[t,e]),[r,s]=y.useState(n);return y.useEffect(()=>{if(!t)return;const i=()=>{const a={};Array.from(new Set(e.map(c=>Bt(c)))).forEach(c=>{const d=We[c];if(d)try{const u=d.canExecute?.(t)??!0,f=d.isActive?.(t)??!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 t.on("selectionUpdate",i),t.on("transaction",i),()=>{t.off("selectionUpdate",i),t.off("transaction",i)}},[t,e,n]),r}function _i(t,e){const n=y.useCallback((a,o)=>{if(!t)return;const c=We[a];if(c)try{c.execute({editor:t,config:o}),e?.({type:"toggle",modifier:a})}catch(d){console.warn(`Failed to execute command for modifier: ${a}`,d)}},[t,e]),r=y.useCallback(a=>{n(a)},[n]),s=y.useCallback((a,o)=>{if(!t)return!1;const c=We[a];try{return c?.canExecute?.(t,o)??!1}catch(d){return console.warn(`Failed to check canExecute for modifier: ${a}`,d),!1}},[t]),i=y.useCallback((a,o)=>{if(!t)return!1;const c=We[a];try{return c?.isActive?.(t,o)??!1}catch(d){return console.warn(`Failed to check isActive for modifier: ${a}`,d),!1}},[t]);return{executeCommand:n,toggleModifier:r,canExecute:s,isActive:i}}function Fl(t=ke.default){const[e,n]=y.useState(t),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:e,setZoom:a,zoomIn:r,zoomOut:s,resetZoom:i,isMinZoom:e<=ke.min,isMaxZoom:e>=ke.max,isDefaultZoom:e===ke.default}}const Pl=["bold","italic","strike","underline","code"];function Rl({editor:t,modifiers:e,onToolbarAction:n}){const r=Bi(t,e),{toggleModifier:s}=_i(t,n);if(!t)return null;const i=e.map(a=>Bt(a)).filter(a=>Pl.includes(a));return i.length===0?null:l.jsx(Ll,{id:"text-formatting",label:"Text formatting",children:i.map(a=>{const o=r[a],c=vt(a);return l.jsx(it,{icon:c,label:a.charAt(0).toUpperCase()+a.slice(1),isActive:o?.isActive,isDisabled:o?.isDisabled,onClick:()=>s(a)},a)})})}function zl({editor:t,modifiers:e,zoom:n=100,onZoomChange:r,sticky:s=!0,className:i,onToolbarAction:a}){const o=Bi(t,e),{toggleModifier:c,executeCommand:d}=_i(t,a);if(!t)return null;const u=e.map(D=>Bt(D)),f=u.some(D=>["bold","italic","strike","underline","code"].includes(D)),p=u.some(D=>["textColor","highlight"].includes(D)),m=u.includes("heading"),v=u.includes("textAlign"),b=u.some(D=>["bulletList","orderedList","taskList"].includes(D)),x=u.includes("blockquote"),k=u.includes("codeBlock"),S=u.includes("link"),A=u.includes("horizontalRule"),N=u.some(D=>["undo","redo"].includes(D)),j=n!==void 0&&r!==void 0,M=s?"sticky top-0 z-10":"";return l.jsx("div",{className:`w-full p-2 bg-background border-b border-divider ${M} ${i||""}`,children:l.jsxs("div",{className:"flex flex-row flex-wrap gap-2 w-full items-center",children:[f&&l.jsxs(l.Fragment,{children:[l.jsx(Rl,{editor:t,modifiers:e,onToolbarAction:a}),(p||m||v||b||x||k||S||A||N||j)&&l.jsx(st,{})]}),p&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex items-center gap-1",children:[u.includes("textColor")&&l.jsx(Ss,{editor:t,type:"textColor",label:"Text color",isDisabled:o.textColor?.isDisabled}),u.includes("highlight")&&l.jsx(Ss,{editor:t,type:"highlight",label:"Highlight",isDisabled:o.highlight?.isDisabled})]}),(m||v||b||x||k||S||A||N||j)&&l.jsx(st,{})]}),m&&l.jsxs(l.Fragment,{children:[l.jsx(Cl,{editor:t}),(v||b||x||k||S||A||N||j)&&l.jsx(st,{})]}),v&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"flex items-center gap-1",children:["left","center","right","justify"].map(D=>{const B=Dl[D],R=t.isActive({textAlign:D});return l.jsx(it,{icon:B,label:`Align ${D}`,isActive:R,onClick:()=>d("textAlign",{type:"textAlign",alignment:D})},D)})}),(b||x||k||S||A||N||j)&&l.jsx(st,{})]}),b&&l.jsxs(l.Fragment,{children:[l.jsx(jl,{editor:t,types:u.filter(D=>["bulletList","orderedList","taskList"].includes(D))}),(x||k||S||A||N||j)&&l.jsx(st,{})]}),(x||k||S||A)&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex items-center gap-1",children:[x&&l.jsx(it,{icon:vt("blockquote"),label:"Blockquote",isActive:o.blockquote?.isActive,isDisabled:o.blockquote?.isDisabled,onClick:()=>c("blockquote")}),k&&l.jsx(it,{icon:vt("codeBlock"),label:"Code block",isActive:o.codeBlock?.isActive,isDisabled:o.codeBlock?.isDisabled,onClick:()=>c("codeBlock")}),S&&l.jsx(Ol,{editor:t,isDisabled:o.link?.isDisabled}),A&&l.jsx(it,{icon:vt("horizontalRule"),label:"Horizontal rule",onClick:()=>c("horizontalRule")})]}),(N||j)&&l.jsx(st,{})]}),N&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex items-center gap-1",children:[u.includes("undo")&&l.jsx(it,{icon:vt("undo"),label:"Undo",isDisabled:o.undo?.isDisabled,onClick:()=>c("undo")}),u.includes("redo")&&l.jsx(it,{icon:vt("redo"),label:"Redo",isDisabled:o.redo?.isDisabled,onClick:()=>c("redo")})]}),j&&l.jsx(st,{})]}),j&&l.jsx($l,{zoom:n,onZoomChange:D=>{r?.(D),a?.({type:"zoom",modifier:`${D}%`})}})]})})}const Bl=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,_l=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Vl=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Hl=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Ul=z.Mark.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return["strong",z.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[z.markInputRule({find:Bl,type:this.type}),z.markInputRule({find:Vl,type:this.type})]},addPasteRules(){return[z.markPasteRule({find:_l,type:this.type}),z.markPasteRule({find:Hl,type:this.type})]}}),ql=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Wl=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Kl=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Jl=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Yl=z.Mark.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",z.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[z.markInputRule({find:ql,type:this.type}),z.markInputRule({find:Kl,type:this.type})]},addPasteRules(){return[z.markPasteRule({find:Wl,type:this.type}),z.markPasteRule({find:Jl,type:this.type})]}}),Gl=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Ql=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Zl=z.Mark.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",z.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[z.markInputRule({find:Gl,type:this.type})]},addPasteRules(){return[z.markPasteRule({find:Ql,type:this.type})]}}),Xl=/(^|[^`])`([^`]+)`(?!`)/,ec=/(^|[^`])`([^`]+)`(?!`)/g,tc=z.Mark.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",z.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[z.markInputRule({find:Xl,type:this.type})]},addPasteRules(){return[z.markPasteRule({find:ec,type:this.type})]}}),nc=t=>{if(!t.children.length)return;const e=t.querySelectorAll("span");e&&e.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}`)})},rc=z.Mark.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&nc(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",z.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.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))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),sc=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(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,z.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>z.textblockTypeInputRule({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),ic=z.Node.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",z.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),ac="listItem",Ns="textStyle",Cs=/^\s*([-+*])\s$/,oc=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:t}){return["ul",z.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(ac,this.editor.getAttributes(Ns)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=z.wrappingInputRule({find:Cs,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=z.wrappingInputRule({find:Cs,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Ns),editor:this.editor})),[t]}}),lc="listItem",js="textStyle",As=/^(\d+)\.\s$/,cc=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:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",z.mergeAttributes(this.options.HTMLAttributes,n),0]:["ol",z.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(lc,this.editor.getAttributes(js)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=z.wrappingInputRule({find:As,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=z.wrappingInputRule({find:As,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(js)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),dc=z.Node.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",z.mergeAttributes(this.options.HTMLAttributes,t),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 Vi(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let s=t.child(r),i=e.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=Vi(s.content,i.content,n+1);if(a!=null)return a}n+=s.nodeSize}}function Hi(t,e,n,r){for(let s=t.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:n,b:r};let a=t.child(--s),o=e.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=Hi(a.content,o.content,n-1,r-1);if(d)return d}n-=c,r-=c}}class G{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,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>e&&r(c,s+o,i||null,a)!==!1&&c.content.size){let u=o+1;c.nodesBetween(Math.max(0,e-u),Math.min(c.content.size,n-u),r,s+u)}o=d}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let i="",a=!0;return this.nodesBetween(e,n,(o,c)=>{let d=o.isText?o.text.slice(Math.max(e,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(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.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<e.content.length;i++)s.push(e.content[i]);return new G(s,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],s=0;if(n>e)for(let i=0,a=0;a<n;i++){let o=this.content[i],c=a+o.nodeSize;c>e&&((a<e||c>n)&&(o.isText?o=o.cut(Math.max(0,e-a),Math.min(o.text.length,n-a)):o=o.cut(Math.max(0,e-a-1),Math.min(o.content.size,n-a-1))),r.push(o),s+=o.nodeSize),a=c}return new G(r,s)}cutByIndex(e,n){return e==n?G.empty:e==0&&n==this.content.length?this:new G(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let s=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return s[e]=n,new G(s,i)}addToStart(e){return new G([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new G(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.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(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let s=this.content[n];e(s,r,n),r+=s.nodeSize}}findDiffStart(e,n=0){return Vi(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Hi(this,e,n,r)}findIndex(e){if(e==0)return Qt(0,e);if(e==this.size)return Qt(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let s=this.child(n),i=r+s.nodeSize;if(i>=e)return i==e?Qt(n+1,i):Qt(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return G.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new G(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return G.empty;let n,r=0;for(let s=0;s<e.length;s++){let i=e[s];r+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(n||(n=e.slice(0,s)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new G(n||e,r)}static from(e){if(!e)return G.empty;if(e instanceof G)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new G([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}G.empty=new G([],0);const qn={index:0,offset:0};function Qt(t,e){return qn.index=t,qn.offset=e,qn}function mr(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!mr(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!mr(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}class Oe{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let s=0;s<e.length;s++){let i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))n||(n=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,s)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&mr(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.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(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Oe.none;if(e instanceof Oe)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}}Oe.none=[];class uc extends Error{}class Q{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=qi(this.content,e+this.openStart,n);return r&&new Q(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Q(Ui(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,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(e,n.content),r,s)}static maxOpen(e,n=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)s++;return new Q(e,r,s)}}Q.empty=new Q(G.empty,0,0);function Ui(t,e,n){let{index:r,offset:s}=t.findIndex(e),i=t.maybeChild(r),{index:a,offset:o}=t.findIndex(n);if(s==e||i.isText){if(o!=n&&!t.child(a).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=a)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(Ui(i.content,e-s-1,n-s-1)))}function qi(t,e,n,r){let{index:s,offset:i}=t.findIndex(e),a=t.maybeChild(s);if(i==e||a.isText)return r&&!r.canReplace(s,s,n)?null:t.cut(0,e).append(n).append(t.cut(e));let o=qi(a.content,e-i-1,n,a);return o&&t.replaceChild(s,a.copy(o))}function fc(t){return t.tag!=null}function hc(t){return t.style!=null}class un{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(fc(s))this.tags.push(s);else if(hc(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=e.nodes[s.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new Es(this,n,!1);return r.addAll(e,Oe.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new Es(this,n,!0);return r.addAll(e,Oe.none,n.from,n.to),Q.maxOpen(r.finish())}matchTag(e,n,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(gc(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let a=i.getAttrs(e);if(a===!1)continue;i.attrs=a||void 0}return i}}}matchStyle(e,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(e)!=0||a.context&&!r.matchesContext(a.context)||o.length>e.length&&(o.charCodeAt(e.length)!=61||o.slice(e.length+1)!=n))){if(a.getAttrs){let c=a.getAttrs(n);if(c===!1)continue;a.attrs=c||void 0}return a}}}static schemaRules(e){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 e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(a=>{r(a=Ts(a)),a.mark||a.ignore||a.clearMark||(a.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(a=>{r(a=Ts(a)),a.node||a.ignore||a.mark||(a.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new un(e,un.schemaRules(e)))}}const Wi={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},mc={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ki={ol:!0,ul:!0},_t=1,pr=2,Ot=4;function Ms(t,e,n){return e!=null?(e?_t:0)|(e==="full"?pr:0):t&&t.whitespace=="pre"?_t|pr:n&~Ot}class Zt{constructor(e,n,r,s,i,a){this.type=e,this.attrs=n,this.marks=r,this.solid=s,this.options=a,this.content=[],this.activeMarks=Oe.none,this.match=i||(a&Ot?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(G.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){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!e&&this.match&&(n=n.append(this.match.fillBefore(G.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Wi.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Es{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=n.topNode,i,a=Ms(null,n.preserveWhitespace,0)|(r?Ot:0);s?i=new Zt(s.type,s.attrs,Oe.none,!0,n.topMatch||s.type.contentMatch,a):r?i=new Zt(null,null,Oe.none,!0,null,a):i=new Zt(e.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(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,s=this.top,i=s.options&pr?"full":this.localPreserveWS||(s.options&_t)>0,{schema:a}=this.parser;if(i==="full"||s.inlineContext(e)||/[^ \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=e.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(e)}else this.findInside(e)}addElement(e,n,r){let s=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;Ki.hasOwnProperty(a)&&this.parser.normalizeLists&&pc(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,r));e:if(c?c.ignore:mc.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,n);else if(!c||c.skip||c.closeParent){c&&c.closeParent?this.open=Math.max(0,this.open-1):c&&c.skip.nodeType&&(e=c.skip);let d,u=this.needsBlock;if(Wi.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(!e.firstChild){this.leafFallback(e,n);break e}let f=c&&c.skip?n:this.readStyles(e,n);f&&this.addAll(e,f),d&&this.sync(i),this.needsBlock=u}else{let d=this.readStyles(e,n);d&&this.addElementByRule(e,c,d,c.consuming===!1?o:void 0)}this.localPreserveWS=s}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
12
|
+
`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.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(e,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,e.nodeName=="BR")||this.leafFallback(e,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(e);else if(s)this.addElement(e,r,s);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(c=>this.insertNode(c,r,!1));else{let c=e;typeof n.contentElement=="string"?c=e.querySelector(n.contentElement):typeof n.contentElement=="function"?c=n.contentElement(e):n.contentElement&&(c=n.contentElement),this.findAround(e,c,!0),this.addAll(c,r),this.findAround(e,c,!1)}i&&this.sync(o)&&this.open--}addAll(e,n,r,s){let i=r||0;for(let a=r?e.childNodes[r]:e.firstChild,o=s==null?null:e.childNodes[s];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,n);this.findAtPoint(e,i)}findPlace(e,n,r){let s,i;for(let a=this.open,o=0;a>=0;a--){let c=this.nodes[a],d=c.findWrapping(e);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(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let s=this.findPlace(e,n,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let a=Oe.none;for(let o of s.concat(e.marks))(i.type?i.type.allowsMarkType(o.type):Ds(o.type,e.type))&&(a=o.addToSet(a));return i.content.push(e.mark(a)),!0}return!1}enter(e,n,r,s){let i=this.findPlace(e.create(n),r,!1);return i&&(i=this.enterInner(e,n,r,!0,s)),i}enterInner(e,n,r,s=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=Ms(e,i,a.options);a.options&Ot&&a.content.length==0&&(o|=Ot);let c=Oe.none;return r=r.filter(d=>(a.type?a.type.allowsMarkType(d.type):Ds(d.type,e))?(c=d.addToSet(c),!1):!0),this.nodes.push(new Zt(e,n,c,s,null,o)),this.open++,r}closeExtra(e=!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(e));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(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=_t)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&n.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.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 e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.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 pc(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Ki.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function gc(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Ts(t){let e={};for(let n in t)e[n]=t[n];return e}function Ds(t,e){let n=e.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(t))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==e||i.indexOf(u)<0&&a(u))return!0}};if(a(s.contentMatch))return!0}}class Mn{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Wn(n).createDocumentFragment());let s=r,i=[];return e.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(e,n){let{dom:r,contentDOM:s}=sn(Wn(n),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,s)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let s=this.marks[e.type.name];return s&&sn(Wn(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return sn(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Mn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=Is(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return Is(e.marks)}}function Is(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Wn(t){return t.document||window.document}const $s=new WeakMap;function xc(t){let e=$s.get(t);return e===void 0&&$s.set(t,e=yc(t)),e}function yc(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.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(t),e}function sn(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let s=e[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=xc(r))&&i.indexOf(e)>-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?t.createElementNS(n,s):t.createElement(s),d=e[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<e.length;f++){let p=e[f];if(p===0){if(f<e.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}=sn(t,p,n,r);if(c.appendChild(m),v){if(o)throw new RangeError("Multiple content holes");o=v}}}return{dom:c,contentDOM:o}}const Ji=65535,Yi=Math.pow(2,16);function bc(t,e){return t+e*Yi}function Os(t){return t&Ji}function vc(t){return(t-(t&Ji))/Yi}const Gi=1,Qi=2,an=4,Zi=8;class gr{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Zi)>0}get deletedBefore(){return(this.delInfo&(Gi|an))>0}get deletedAfter(){return(this.delInfo&(Qi|an))>0}get deletedAcross(){return(this.delInfo&an)>0}}class Te{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Te.empty)return Te.empty}recover(e){let n=0,r=Os(e);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+vc(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,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>e)break;let d=this.ranges[o+i],u=this.ranges[o+a],f=c+d;if(e<=f){let p=d?e==c?-1:e==f?1:n:n,m=c+s+(p<0?0:u);if(r)return m;let v=e==(n<0?c:f)?null:bc(o/3,e-c),b=e==c?Qi:e==f?Gi:an;return(n<0?e!=c:e!=f)&&(b|=Zi),new gr(m,b,v)}s+=u-d}return r?e+s:new gr(e+s,0,null)}touches(e,n){let r=0,s=Os(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>e)break;let d=this.ranges[o+i],u=c+d;if(e<=u&&o==s*3)return!0;r+=this.ranges[o+a]-d}return!1}forEach(e){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];e(o,o+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(e){return e==0?Te.empty:new Te(e<0?[0,-e,0]:[0,0,e])}}Te.empty=new Te([]);class fn{constructor(e,n,r=0,s=e?e.length:0){this.mirror=n,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new fn(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let s=e.getMirror(n);this.appendMap(e._maps[n],s!=null&&s<n?r+s:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let s=e.getMirror(n);this.appendMap(e._maps[n].invert(),s!=null&&s>n?r-s-1:void 0)}}invert(){let e=new fn;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let s=0;for(let i=this.from;i<this.to;i++){let a=this._maps[i],o=a.mapResult(e,n);if(o.recover!=null){let c=this.getMirror(i);if(c!=null&&c>i&&c<this.to){i=c,e=this._maps[c].recover(o.recover);continue}}s|=o.delInfo,e=o.pos}return r?e:new gr(e,s,null)}}const Kn=Object.create(null);class we{getMap(){return Te.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Kn[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Kn)throw new RangeError("Duplicate use of step JSON ID "+e);return Kn[e]=n,n.prototype.jsonID=e,n}}class pe{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new pe(e,null)}static fail(e){return new pe(null,e)}static fromReplace(e,n,r,s){try{return pe.ok(e.replace(n,r,s))}catch(i){if(i instanceof uc)return pe.fail(i.message);throw i}}}function zr(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(zr(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return G.fromArray(r)}class ot extends we{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new Q(zr(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 pe.fromReplace(e,this.from,this.to,i)}invert(){return new lt(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new ot(n.pos,r.pos,this.mark)}merge(e){return e instanceof ot&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ot(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,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,e.markFromJSON(n.mark))}}we.jsonID("addMark",ot);class lt extends we{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new Q(zr(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return pe.fromReplace(e,this.from,this.to,r)}invert(){return new ot(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new lt(n.pos,r.pos,this.mark)}merge(e){return e instanceof lt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new lt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new lt(n.from,n.to,e.markFromJSON(n.mark))}}we.jsonID("removeMark",lt);class ct extends we{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return pe.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return pe.fromReplace(e,this.pos,this.pos+1,new Q(G.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.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 ct(this.pos,n.marks[s]);return new ct(this.pos,this.mark)}}return new Vt(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new ct(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new ct(n.pos,e.markFromJSON(n.mark))}}we.jsonID("addNodeMark",ct);class Vt extends we{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return pe.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return pe.fromReplace(e,this.pos,this.pos+1,new Q(G.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new ct(this.pos,this.mark)}map(e){let n=e.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(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Vt(n.pos,e.markFromJSON(n.mark))}}we.jsonID("removeNodeMark",Vt);class qe extends we{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&xr(e,this.from,this.to)?pe.fail("Structure replace would overwrite content"):pe.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Te([this.from,this.to-this.from,this.slice.size])}invert(e){return new qe(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),r=e.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(e){if(!(e instanceof qe)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?Q.empty:new Q(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new qe(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?Q.empty:new Q(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new qe(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,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(e,n.slice),!!n.structure)}}we.jsonID("replace",qe);class Nt extends we{constructor(e,n,r,s,i,a,o=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(xr(e,this.from,this.gapFrom)||xr(e,this.gapTo,this.to)))return pe.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return pe.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?pe.fromReplace(e,this.from,this.to,r):pe.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(e){let n=this.gapTo-this.gapFrom;return new Nt(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||i>r.pos?null:new Nt(n.pos,r.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,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 Nt(n.from,n.to,n.gapFrom,n.gapTo,Q.fromJSON(e,n.slice),n.insert,!!n.structure)}}we.jsonID("replaceAround",Nt);function xr(t,e,n){let r=t.resolve(e),s=n-e,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 Xi(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;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 f=d.contentMatchAt(c).findWrapping(s.firstChild.type);u=f&&d.canReplaceWith(c,c,f[0])}if(u)return o==0?r.pos:o<0?r.before(a+1):r.after(a+1)}return null}class Lt extends we{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return pe.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 pe.fromReplace(e,this.pos,this.pos+1,new Q(G.from(s),0,n.isLeaf?0:1))}getMap(){return Te.empty}invert(e){return new Lt(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.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(e,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)}}we.jsonID("attr",Lt);class hn extends we{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let s in e.attrs)n[s]=e.attrs[s];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return pe.ok(r)}getMap(){return Te.empty}invert(e){return new hn(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new hn(n.attr,n.value)}}we.jsonID("docAttr",hn);let Ht=class extends Error{};Ht=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Ht.prototype=Object.create(Error.prototype);Ht.prototype.constructor=Ht;Ht.prototype.name="TransformError";const Jn=Object.create(null);class re{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new kc(e.min(n),e.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 e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=Q.empty){let r=n.content.lastChild,s=null;for(let o=0;o<n.openEnd;o++)s=r,r=r.lastChild;let i=e.steps.length,a=this.ranges;for(let o=0;o<a.length;o++){let{$from:c,$to:d}=a[o],u=e.mapping.slice(i);e.replaceRange(u.map(c.pos),u.map(d.pos),o?Q.empty:n),o==0&&Ps(e,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:a,$to:o}=s[i],c=e.mapping.slice(r),d=c.map(a.pos),u=c.map(o.pos);i?e.deleteRange(d,u):(e.replaceRangeWith(d,u,n),Ps(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new ne(e):kt(e.node(0),e.parent,e.pos,e.index(),n,r);if(s)return s;for(let i=e.depth-1;i>=0;i--){let a=n<0?kt(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):kt(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(a)return a}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Ve(e.node(0))}static atStart(e){return kt(e,e,0,0,1)||new Ve(e)}static atEnd(e){return kt(e,e,e.content.size,e.childCount,-1)||new Ve(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Jn[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Jn)throw new RangeError("Duplicate use of selection JSON ID "+e);return Jn[e]=n,n.prototype.jsonID=e,n}getBookmark(){return ne.between(this.$anchor,this.$head).getBookmark()}}re.prototype.visible=!0;class kc{constructor(e,n){this.$from=e,this.$to=n}}let Ls=!1;function Fs(t){!Ls&&!t.parent.inlineContent&&(Ls=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class ne extends re{constructor(e,n=e){Fs(e),Fs(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return re.near(r);let s=e.resolve(n.map(this.anchor));return new ne(s.parent.inlineContent?s:r,r)}replace(e,n=Q.empty){if(super.replace(e,n),n==Q.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof ne&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new En(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new ne(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let s=e.resolve(n);return new this(s,r==n?s:e.resolve(r))}static between(e,n,r){let s=e.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 e.parent.inlineContent||(s==0?e=n:(e=(re.findFrom(e,-r,!0)||re.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new ne(e,n)}}re.jsonID("text",ne);class En{constructor(e,n){this.anchor=e,this.head=n}map(e){return new En(e.map(this.anchor),e.map(this.head))}resolve(e){return ne.between(e.resolve(this.anchor),e.resolve(this.head))}}class Z extends re{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),i=e.resolve(s);return r?re.near(i):new Z(i)}content(){return new Q(G.from(this.node),0,0)}eq(e){return e instanceof Z&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Br(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Z(e.resolve(n.anchor))}static create(e,n){return new Z(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Z.prototype.visible=!1;re.jsonID("node",Z);class Br{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new En(r,r):new Br(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Z.isSelectable(r)?new Z(n):re.near(n)}}class Ve extends re{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Q.empty){if(n==Q.empty){e.delete(0,e.doc.content.size);let r=re.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Ve(e)}map(e){return new Ve(e)}eq(e){return e instanceof Ve}getBookmark(){return wc}}re.jsonID("all",Ve);const wc={map(){return this},resolve(t){return new Ve(t)}};function kt(t,e,n,r,s,i=!1){if(e.inlineContent)return ne.create(t,n);for(let a=r-(s>0?0:1);s>0?a<e.childCount:a>=0;a+=s){let o=e.child(a);if(o.isAtom){if(!i&&Z.isSelectable(o))return Z.create(t,n-(s<0?o.nodeSize:0))}else{let c=kt(t,o,n+s,s<0?o.childCount:0,s,i);if(c)return c}n+=o.nodeSize*s}return null}function Ps(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof qe||s instanceof Nt))return;let i=t.mapping.maps[r],a;i.forEach((o,c,d,u)=>{a==null&&(a=u)}),t.setSelection(re.near(t.doc.resolve(a),n))}function Rs(t,e){return!e||!t?t:t.bind(e)}class Xt{constructor(e,n,r){this.name=e,this.init=Rs(n.init,r),this.apply=Rs(n.apply,r)}}new Xt("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Xt("selection",{init(t,e){return t.selection||re.atStart(e.doc)},apply(t){return t.selection}}),new Xt("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Xt("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}});function ea(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=ea(s,e,{})),n[r]=s}return n}class Tn{constructor(e){this.spec=e,this.props={},e.props&&ea(e.props,this,this.props),this.key=e.key?e.key.key:ta("plugin")}getState(e){return e[this.key]}}const Yn=Object.create(null);function ta(t){return t in Yn?t+"$"+ ++Yn[t]:(Yn[t]=0,t+"$")}class _r{constructor(e="key"){this.key=ta(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Sc=/^```([a-z]+)?[\s\n]$/,Nc=/^~~~([a-z]+)?[\s\n]$/,Cc=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:t=>{var e;const{languageClassPrefix:n}=this.options,i=[...((e=t.firstElementChild)===null||e===void 0?void 0:e.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:t,HTMLAttributes:e}){return["pre",z.mergeAttributes(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$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||!
|
|
15
|
-
`));return
|
|
16
|
-
`},addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:s,storedMarks:i}=n;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,a=i||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:u,dispatch:d})=>{if(d&&a&&o){const f=a.filter(m=>l.includes(m.type.name));u.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var sn=200,pe=function(){};pe.prototype.append=function(e){return e.length?(e=pe.from(e),!this.length&&e||e.length<sn&&this.leafAppend(e)||this.length<sn&&e.leafPrepend(this)||this.appendInner(e)):this};pe.prototype.prepend=function(e){return e.length?pe.from(e).append(this):this};pe.prototype.appendInner=function(e){return new ha(this,e)};pe.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?pe.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};pe.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};pe.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};pe.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,o){return s.push(e(i,o))},n,r),s};pe.from=function(e){return e instanceof pe?e:e&&e.length?new gi(e):pe.empty};var gi=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,o,l){for(var a=i;a<o;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,o,l){for(var a=i-1;a>=o;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=sn)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=sn)return new e(s.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(pe);pe.empty=new gi([]);var ha=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,i,o){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(i,l),o)===!1||i>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,i)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,o){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(i,l)-l,o+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(s,l),i,o)===!1)return!1},e.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))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(pe);const pa=500;class Re{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,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 o=e.tr,l,a,u=[],d=[];return this.items.forEach((f,m)=>{if(!f.step){s||(s=this.remapping(r,m+1),i=s.maps.length),i--,d.push(f);return}if(s){d.push(new ze(f.map));let h=f.step.map(s.slice(i)),S;h&&o.maybeStep(h).doc&&(S=o.mapping.maps[o.mapping.maps.length-1],u.push(new ze(S,void 0,void 0,u.length+d.length))),i--,S&&s.appendMap(S,i)}else o.maybeStep(f.step);if(f.selection)return l=s?f.selection.map(s.slice(i)):f.selection,a=new Re(this.items.slice(0,r).append(d.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,n,r,s){let i=[],o=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let f=e.steps[d].invert(e.docs[d]),m=new ze(e.mapping.maps[d],f,n),h;(h=a&&a.merge(m))&&(m=h,d?i.pop():l=l.slice(0,l.length-1)),i.push(m),n&&(o++,n=void 0),s||(a=m)}let u=o-r.depth;return u>ga&&(l=ma(l,u),o-=u),new Re(l.append(i),o)}remapping(e,n){let r=new nn;return this.items.forEach((s,i)=>{let o=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new Re(this.items.append(e.map(n=>new ze(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-n),i=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(m=>{m.selection&&l--},s);let a=n;this.items.forEach(m=>{let h=i.getMirror(--a);if(h==null)return;o=Math.min(o,h);let S=i.maps[h];if(m.step){let x=e.steps[h].invert(e.docs[h]),k=m.selection&&m.selection.map(i.slice(a+1,h));k&&l++,r.push(new ze(S,x,k))}else r.push(new ze(S))},s);let u=[];for(let m=n;m<o;m++)u.push(new ze(i.maps[m]));let d=this.items.slice(0,s).append(u).append(r),f=new Re(d,l);return f.emptyItemCount()>pa&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,s=[],i=0;return this.items.forEach((o,l)=>{if(l>=e)s.push(o),o.selection&&i++;else if(o.step){let a=o.step.map(n.slice(r)),u=a&&a.getMap();if(r--,u&&n.appendMap(u,r),a){let d=o.selection&&o.selection.map(n.slice(r));d&&i++;let f=new ze(u.invert(),a,d),m,h=s.length-1;(m=s.length&&s[h].merge(f))?s[h]=m:s.push(f)}}else o.map&&r--},this.items.length,0),new Re(pe.from(s.reverse()),i)}}Re.empty=new Re(pe.empty,0);function ma(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}class ze{constructor(e,n,r,s){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new ze(n.getMap().invert(),n,this.selection)}}}class Ze{constructor(e,n,r,s,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const ga=20;function ya(t,e,n,r){let s=n.getMeta(ut),i;if(s)return s.historyState;n.getMeta(ka)&&(t=new Ze(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(ut))return o.getMeta(ut).redo?new Ze(t.done.addTransform(n,void 0,r,Xt(e)),t.undone,ds(n.mapping.maps),t.prevTime,t.prevComposition):new Ze(t.done,t.undone.addTransform(n,void 0,r,Xt(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=t.prevTime==0||!o&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!xa(n,t.prevRanges)),u=o?Pn(t.prevRanges,n.mapping):ds(n.mapping.maps);return new Ze(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,Xt(e)),Re.empty,u,n.time,l??t.prevComposition)}else return(i=n.getMeta("rebased"))?new Ze(t.done.rebased(n,i),t.undone.rebased(n,i),Pn(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Ze(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Pn(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function xa(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&s>=e[i]&&(n=!0)}),n}function ds(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,s,i,o)=>e.push(i,o));return e}function Pn(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let s=e.map(t[r],1),i=e.map(t[r+1],-1);s<=i&&n.push(s,i)}return n}function ba(t,e,n){let r=Xt(e),s=ut.get(e).spec.config,i=(n?t.undone:t.done).popEvent(e,r);if(!i)return null;let o=i.selection.resolve(i.transform.doc),l=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),a=new Ze(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(o).setMeta(ut,{redo:n,historyState:a})}let $n=!1,fs=null;function Xt(t){let e=t.plugins;if(fs!=e){$n=!1,fs=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){$n=!0;break}}return $n}const ut=new yr("history"),ka=new yr("closeHistory");function va(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new xn({key:ut,state:{init(){return new Ze(Re.empty,Re.empty,null,0,-1)},apply(e,n,r){return ya(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?xi:r=="historyRedo"?bi:null;return!s||!e.editable?!1:(n.preventDefault(),s(e.state,e.dispatch))}}}})}function yi(t,e){return(n,r)=>{let s=ut.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let i=ba(s,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const xi=yi(!1,!0),bi=yi(!0,!0),hs=R.Extension.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>xi(t,e),redo:()=>({state:t,dispatch:e})=>bi(t,e)}},addProseMirrorPlugins(){return[va(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()}}}),Sa=R.Node.create({name:"doc",topNode:!0,content:"block+"}),Ca=R.Node.create({name:"text",group:"inline"});function wa(t={}){return new xn({view(e){return new Aa(e,t)}})}class Aa{constructor(e,n){var r;this.editorView=e,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=o=>{this[s](o)};return e.dom.addEventListener(s,i),{name:s,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,s=this.editorView.dom,i=s.getBoundingClientRect(),o=i.width/s.offsetWidth,l=i.height/s.offsetHeight;if(n){let f=e.nodeBefore,m=e.nodeAfter;if(f||m){let h=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(h){let S=h.getBoundingClientRect(),x=f?S.bottom:S.top;f&&m&&(x=(x+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let k=this.width/2*l;r={left:S.left,right:S.right,top:x-k,bottom:x+k}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),m=this.width/2*o;r={left:f.left-m,right:f.left+m,top:f.top,bottom:f.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.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 u,d;if(!a||a==document.body&&getComputedStyle(a).position=="static")u=-pageXOffset,d=-pageYOffset;else{let f=a.getBoundingClientRect(),m=f.width/a.offsetWidth,h=f.height/a.offsetHeight;u=f.left-a.scrollLeft*m,d=f.top-a.scrollTop*h}this.element.style.left=(r.left-u)/o+"px",this.element.style.top=(r.top-d)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.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,e):s;if(n&&!i){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=hi(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}const Na=R.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[wa(this.options)]}});var et={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:"'"},on={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Ta=typeof navigator<"u"&&/Mac/.test(navigator.platform),Ea=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ye=0;ye<10;ye++)et[48+ye]=et[96+ye]=String(ye);for(var ye=1;ye<=24;ye++)et[ye+111]="F"+ye;for(var ye=65;ye<=90;ye++)et[ye]=String.fromCharCode(ye+32),on[ye]=String.fromCharCode(ye);for(var Vn in et)on.hasOwnProperty(Vn)||(on[Vn]=et[Vn]);function Ma(t){var e=Ta&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Ea&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?on:et)[t.keyCode]||t.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 ja=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Ia=typeof navigator<"u"&&/Win/.test(navigator.platform);function Oa(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,s,i,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))ja?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),o&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function Da(t){let e=Object.create(null);for(let n in t)e[Oa(n)]=t[n];return e}function zn(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function La(t){let e=Da(t);return function(n,r){let s=Ma(r),i,o=e[zn(s,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[zn(s,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(Ia&&r.ctrlKey&&r.altKey)&&(i=et[r.keyCode])&&i!=s){let l=e[zn(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}const ht=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},ki=function(t,e,n,r){return n&&(ps(t,e,n,r,-1)||ps(t,e,n,r,1))},Ra=/^(img|br|input|textarea|hr)$/i;function ps(t,e,n,r,s){for(var i;;){if(t==n&&e==r)return!0;if(e==(s<0?0:ln(t))){let o=t.parentNode;if(!o||o.nodeType!=1||xr(t)||Ra.test(t.nodeName)||t.contentEditable=="false")return!1;e=ht(t)+(s<0?0:1),t=o}else if(t.nodeType==1){let o=t.childNodes[e+(s<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((i=o.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=s;else return!1;else t=o,e=s<0?ln(t):0}else return!1}}function ln(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Fa(t,e,n){for(let r=e==0,s=e==ln(t);r||s;){if(t==n)return!0;let i=ht(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,s=s&&i==ln(t)}}function xr(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const vi=function(t){return t.focusNode&&ki(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Si(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}const He=typeof navigator<"u"?navigator:null,ms=typeof document<"u"?document:null,tt=He&&He.userAgent||"",Xn=/Edge\/(\d+)/.exec(tt),Ci=/MSIE \d/.exec(tt),Yn=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(tt),_t=!!(Ci||Yn||Xn),wi=Ci?document.documentMode:Yn?+Yn[1]:Xn?+Xn[1]:0,bn=!_t&&/gecko\/(\d+)/i.test(tt);bn&&+(/Firefox\/(\d+)/.exec(tt)||[0,0])[1];const er=!_t&&/Chrome\/(\d+)/.exec(tt),Je=!!er,Ai=er?+er[1]:0,pt=!_t&&!!He&&/Apple Computer/.test(He.vendor),br=pt&&(/Mobile\/\w+/.test(tt)||!!He&&He.maxTouchPoints>2),Oe=br||(He?/Mac/.test(He.platform):!1),Ni=He?/Win/.test(He.platform):!1,Ht=/Android \d/.test(tt),kr=!!ms&&"webkitFontSmoothing"in ms.documentElement.style,Pa=kr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function $a(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let s=t.docView.nearestDesc(n.focusNode),i=s&&s.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,u;if(vi(n)){for(a=o;s&&!s.node;)s=s.parent;let f=s.node;if(s&&f.isAtom&&K.isSelectable(f)&&s.parent&&!(f.isInline&&Fa(n.focusNode,n.focusOffset,s.dom))){let m=s.posBefore;u=new K(o==m?l:r.resolve(m))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=o,m=o;for(let h=0;h<n.rangeCount;h++){let S=n.getRangeAt(h);f=Math.min(f,t.docView.posFromDOM(S.startContainer,S.startOffset,1)),m=Math.max(m,t.docView.posFromDOM(S.endContainer,S.endOffset,-1))}if(f<0)return null;[a,o]=m==t.state.selection.anchor?[m,f]:[f,m],l=r.resolve(o)}else a=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let d=r.resolve(a);if(!u){let f=e=="pointer"||t.state.selection.head<l.pos&&!i?1:-1;u=Ei(t,d,l,f)}return u}function Ti(t){return t.editable?t.hasFocus():_a(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function vr(t,e=!1){let n=t.state.selection;if(Ba(t,n),!!Ti(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Je){let r=t.domSelectionRange(),s=t.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&ki(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)za(t);else{let{anchor:r,head:s}=n,i,o;gs&&!(n instanceof Q)&&(n.$from.parent.inlineContent||(i=ys(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=ys(t,n.to))),t.docView.setSelection(r,s,t,e),gs&&(i&&xs(i),o&&xs(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Va(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const gs=pt||Je&&Ai<63;function ys(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),s=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(pt&&s&&s.contentEditable=="false")return Bn(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return Bn(s);if(i)return Bn(i)}}function Bn(t){return t.contentEditable="true",pt&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function xs(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Va(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,s=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=s)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!Ti(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function za(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,ht(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&_t&&wi<=11&&(n.disabled=!0,n.disabled=!1)}function Ba(t,e){if(e instanceof K){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(bs(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else bs(t)}function bs(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Ei(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||Q.between(e,n,r)}function _a(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function tr(t,e){let{$anchor:n,$head:r}=t.selection,s=e>0?n.max(r):n.min(r),i=s.parent.inlineContent?s.depth?t.doc.resolve(e>0?s.after():s.before()):null:s;return i&&X.findFrom(i,e)}function Qe(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function ks(t,e,n){let r=t.state.selection;if(r instanceof Q)if(n.indexOf("s")>-1){let{$head:s}=r,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=t.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return Qe(t,new Q(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=tr(t.state,e);return s&&s instanceof K?Qe(t,s):!1}else if(!(Oe&&n.indexOf("m")>-1)){let s=r.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,o;if(!i||i.isText)return!1;let l=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(o=t.docView.descAt(l))&&!o.contentDOM?K.isSelectable(i)?Qe(t,new K(e<0?t.state.doc.resolve(s.pos-i.nodeSize):s)):kr?Qe(t,new Q(t.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof K&&r.node.isInline)return Qe(t,new Q(e>0?r.$to:r.$from));{let s=tr(t.state,e);return s?Qe(t,s):!1}}}function an(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function It(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function mt(t,e){return e<0?Ha(t):Ua(t)}function Ha(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,i,o=!1;for(bn&&n.nodeType==1&&r<an(n)&&It(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(It(l,-1))s=n,i=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(Mi(n))break;{let l=n.previousSibling;for(;l&&It(l,-1);)s=n.parentNode,i=ht(l),l=l.previousSibling;if(l)n=l,r=an(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?nr(t,n,r):s&&nr(t,s,i)}function Ua(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=an(n),i,o;for(;;)if(r<s){if(n.nodeType!=1)break;let l=n.childNodes[r];if(It(l,1))i=n,o=++r;else break}else{if(Mi(n))break;{let l=n.nextSibling;for(;l&&It(l,1);)i=l.parentNode,o=ht(l)+1,l=l.nextSibling;if(l)n=l,r=0,s=an(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}i&&nr(t,i,o)}function Mi(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function qa(t,e){for(;t&&e==t.childNodes.length&&!xr(t);)e=ht(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function Ka(t,e){for(;t&&!e&&!xr(t);)e=ht(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function nr(t,e,n){if(e.nodeType!=3){let i,o;(o=qa(e,n))?(e=o,n=0):(i=Ka(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(vi(r)){let i=document.createRange();i.setEnd(e,n),i.setStart(e,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:s}=t;setTimeout(()=>{t.state==s&&vr(t)},50)}function vs(t,e){let n=t.state.doc.resolve(e);if(!(Je||Ni)&&n.parent.inlineContent){let s=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left<s.left?"ltr":"rtl"}if(e<n.end()){let i=t.coordsAtPos(e+1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left>s.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function Ss(t,e,n){let r=t.state.selection;if(r instanceof Q&&!r.empty||n.indexOf("s")>-1||Oe&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=tr(t.state,e);if(o&&o instanceof K)return Qe(t,o)}if(!s.parent.inlineContent){let o=e<0?s:i,l=r instanceof _e?X.near(o,e):X.findFrom(o,e);return l?Qe(t,l):!1}return!1}function Cs(t,e){if(!(t.state.selection instanceof Q))return!0;let{$head:n,$anchor:r,empty:s}=t.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let o=t.state.tr;return e<0?o.delete(n.pos-i.nodeSize,n.pos):o.delete(n.pos,n.pos+i.nodeSize),t.dispatch(o),!0}return!1}function ws(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Ja(t){if(!pt||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;ws(t,r,"true"),setTimeout(()=>ws(t,r,"false"),20)}return!1}function Wa(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function Ga(t,e){let n=e.keyCode,r=Wa(e);if(n==8||Oe&&n==72&&r=="c")return Cs(t,-1)||mt(t,-1);if(n==46&&!e.shiftKey||Oe&&n==68&&r=="c")return Cs(t,1)||mt(t,1);if(n==13||n==27)return!0;if(n==37||Oe&&n==66&&r=="c"){let s=n==37?vs(t,t.state.selection.from)=="ltr"?-1:1:-1;return ks(t,s,r)||mt(t,s)}else if(n==39||Oe&&n==70&&r=="c"){let s=n==39?vs(t,t.state.selection.from)=="ltr"?1:-1:1;return ks(t,s,r)||mt(t,s)}else{if(n==38||Oe&&n==80&&r=="c")return Ss(t,-1,r)||mt(t,-1);if(n==40||Oe&&n==78&&r=="c")return Ja(t)||Ss(t,1,r)||mt(t,1);if(r==(Oe?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function ji(t,e){t.someProp("transformCopied",h=>{e=h(e,t)});let n=[],{content:r,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let h=r.firstChild;n.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let o=t.someProp("clipboardSerializer")||gn.fromSchema(t.state.schema),l=Fi(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let u=a.firstChild,d,f=0;for(;u&&u.nodeType==1&&(d=Ri[u.nodeName.toLowerCase()]);){for(let h=d.length-1;h>=0;h--){let S=l.createElement(d[h]);for(;a.firstChild;)S.appendChild(a.firstChild);a.appendChild(S),f++}u=a.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${s} ${i}${f?` -${f}`:""} ${JSON.stringify(n)}`);let m=t.someProp("clipboardTextSerializer",h=>h(e,t))||e.content.textBetween(0,e.content.size,`
|
|
14
|
+
`);return!i||!a?!1:t.chain().command(({tr:o})=>(o.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$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)?t.commands.command(({tr:d})=>(d.setSelection(re.near(r.resolve(o))),!0)):t.commands.exitCode()}}},addInputRules(){return[z.textblockTypeInputRule({find:Sc,type:this.type,getAttributes:t=>({language:t[1]})}),z.textblockTypeInputRule({find:Nc,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Tn({key:new _r("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.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}=t.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(ne.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta("paste",!0),t.dispatch(a),!0}}})]}}),jc=/^\s*>\s$/,Ac=z.Node.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",z.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[z.wrappingInputRule({find:jc,type:this.type})]}}),Mc=z.Node.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",z.mergeAttributes(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!z.canInsertNode(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$from:r,$to:s}=n,i=t();return r.parentOffset===0?i.insertContentAt({from:Math.max(r.pos-1,0),to:s.pos},{type:this.name}):z.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(ne.create(a.doc,d.pos+1)):d.nodeAfter.isBlock?a.setSelection(Z.create(a.doc,d.pos)):a.setSelection(ne.create(a.doc,d.pos));else{const f=(c=d.parent.type.contentMatch.defaultType)===null||c===void 0?void 0:c.create();f&&(a.insert(u,f),a.setSelection(ne.create(a.doc,u+1)))}a.scrollIntoView()}return!0}).run()}}},addInputRules(){return[z.nodeInputRule({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Ec=z.Node.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",z.mergeAttributes(this.options.HTMLAttributes,t)]},renderText(){return`
|
|
16
|
+
`},addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.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 e().insertContent({type:this.name}).command(({tr:d,dispatch:u})=>{if(u&&c&&a){const f=c.filter(p=>o.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 mn=200,be=function(){};be.prototype.append=function(e){return e.length?(e=be.from(e),!this.length&&e||e.length<mn&&this.leafAppend(e)||this.length<mn&&e.leafPrepend(this)||this.appendInner(e)):this};be.prototype.prepend=function(e){return e.length?be.from(e).append(this):this};be.prototype.appendInner=function(e){return new Tc(this,e)};be.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?be.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};be.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};be.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};be.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,a){return s.push(e(i,a))},n,r),s};be.from=function(e){return e instanceof be?e:e&&e.length?new na(e):be.empty};var na=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,a,o){for(var c=i;c<a;c++)if(s(this.values[c],o+c)===!1)return!1},e.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},e.prototype.leafAppend=function(s){if(this.length+s.length<=mn)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=mn)return new e(s.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(be);be.empty=new na([]);var Tc=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.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},e.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},e.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))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(be);const Dc=500;class Le{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,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=e.tr,o,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 o=s?f.selection.map(s.slice(i)):f.selection,c=new Le(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(e,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<e.steps.length;u++){let f=e.steps[u].invert(e.docs[u]),p=new Be(e.mapping.maps[u],f,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>$c&&(o=Ic(o,d),a-=d),new Le(o.append(i),a)}remapping(e,n){let r=new fn;return this.items.forEach((s,i)=>{let a=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,a)},e,n),r}addMaps(e){return this.eventCount==0?this:new Le(this.items.append(e.map(n=>new Be(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-n),i=e.mapping,a=e.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=e.steps[m].invert(e.docs[m]),x=p.selection&&p.selection.map(i.slice(c+1,m));x&&o++,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 Le(u,o);return f.emptyItemCount()>Dc&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,s=[],i=0;return this.items.forEach((a,o)=>{if(o>=e)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 Le(be.from(s.reverse()),i)}}Le.empty=new Le(be.empty,0);function Ic(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}class Be{constructor(e,n,r,s){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new Be(n.getMap().invert(),n,this.selection)}}}class Ge{constructor(e,n,r,s,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const $c=20;function Oc(t,e,n,r){let s=n.getMeta(ut),i;if(s)return s.historyState;n.getMeta(Pc)&&(t=new Ge(t.done,t.undone,null,0,-1));let a=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(a&&a.getMeta(ut))return a.getMeta(ut).redo?new Ge(t.done.addTransform(n,void 0,r,on(e)),t.undone,zs(n.mapping.maps),t.prevTime,t.prevComposition):new Ge(t.done,t.undone.addTransform(n,void 0,r,on(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(a&&a.getMeta("addToHistory")===!1)){let o=n.getMeta("composition"),c=t.prevTime==0||!a&&t.prevComposition!=o&&(t.prevTime<(n.time||0)-r.newGroupDelay||!Lc(n,t.prevRanges)),d=a?Gn(t.prevRanges,n.mapping):zs(n.mapping.maps);return new Ge(t.done.addTransform(n,c?e.selection.getBookmark():void 0,r,on(e)),Le.empty,d,n.time,o??t.prevComposition)}else return(i=n.getMeta("rebased"))?new Ge(t.done.rebased(n,i),t.undone.rebased(n,i),Gn(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Ge(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Gn(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function Lc(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&s>=e[i]&&(n=!0)}),n}function zs(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,s,i,a)=>e.push(i,a));return e}function Gn(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let s=e.map(t[r],1),i=e.map(t[r+1],-1);s<=i&&n.push(s,i)}return n}function Fc(t,e,n){let r=on(e),s=ut.get(e).spec.config,i=(n?t.undone:t.done).popEvent(e,r);if(!i)return null;let a=i.selection.resolve(i.transform.doc),o=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),c=new Ge(n?o:i.remaining,n?i.remaining:o,null,0,-1);return i.transform.setSelection(a).setMeta(ut,{redo:n,historyState:c})}let Qn=!1,Bs=null;function on(t){let e=t.plugins;if(Bs!=e){Qn=!1,Bs=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Qn=!0;break}}return Qn}const ut=new _r("history"),Pc=new _r("closeHistory");function Rc(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Tn({key:ut,state:{init(){return new Ge(Le.empty,Le.empty,null,0,-1)},apply(e,n,r){return Oc(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?sa:r=="historyRedo"?ia:null;return!s||!e.editable?!1:(n.preventDefault(),s(e.state,e.dispatch))}}}})}function ra(t,e){return(n,r)=>{let s=ut.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let i=Fc(s,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const sa=ra(!1,!0),ia=ra(!0,!0),_s=z.Extension.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>sa(t,e),redo:()=>({state:t,dispatch:e})=>ia(t,e)}},addProseMirrorPlugins(){return[Rc(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()}}}),zc=z.Node.create({name:"doc",topNode:!0,content:"block+"}),Bc=z.Node.create({name:"text",group:"inline"});function _c(t={}){return new Tn({view(e){return new Vc(e,t)}})}class Vc{constructor(e,n){var r;this.editorView=e,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 e.dom.addEventListener(s,i),{name:s,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,s=this.editorView.dom,i=s.getBoundingClientRect(),a=i.width/s.offsetWidth,o=i.height/s.offsetHeight;if(n){let f=e.nodeBefore,p=e.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*o;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)/o+"px",this.element.style.width=(r.right-r.left)/a+"px",this.element.style.height=(r.bottom-r.top)/o+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.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,e):s;if(n&&!i){let a=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let o=Xi(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(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}const Hc=z.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[_c(this.options)]}});var tt={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:"'"},pn={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Uc=typeof navigator<"u"&&/Mac/.test(navigator.platform),qc=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ve=0;ve<10;ve++)tt[48+ve]=tt[96+ve]=String(ve);for(var ve=1;ve<=24;ve++)tt[ve+111]="F"+ve;for(var ve=65;ve<=90;ve++)tt[ve]=String.fromCharCode(ve+32),pn[ve]=String.fromCharCode(ve);for(var Zn in tt)pn.hasOwnProperty(Zn)||(pn[Zn]=tt[Zn]);function Wc(t){var e=Uc&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||qc&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?pn:tt)[t.keyCode]||t.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 Kc=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Jc=typeof navigator<"u"&&/Win/.test(navigator.platform);function Yc(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,s,i,a;for(let o=0;o<e.length-1;o++){let c=e[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))Kc?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 Gc(t){let e=Object.create(null);for(let n in t)e[Yc(n)]=t[n];return e}function Xn(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function Qc(t){let e=Gc(t);return function(n,r){let s=Wc(r),i,a=e[Xn(s,r)];if(a&&a(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let o=e[Xn(s,r,!1)];if(o&&o(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(Jc&&r.ctrlKey&&r.altKey)&&(i=tt[r.keyCode])&&i!=s){let o=e[Xn(i,r)];if(o&&o(n.state,n.dispatch,n))return!0}}return!1}}const gt=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},aa=function(t,e,n,r){return n&&(Vs(t,e,n,r,-1)||Vs(t,e,n,r,1))},Zc=/^(img|br|input|textarea|hr)$/i;function Vs(t,e,n,r,s){for(var i;;){if(t==n&&e==r)return!0;if(e==(s<0?0:gn(t))){let a=t.parentNode;if(!a||a.nodeType!=1||Vr(t)||Zc.test(t.nodeName)||t.contentEditable=="false")return!1;e=gt(t)+(s<0?0:1),t=a}else if(t.nodeType==1){let a=t.childNodes[e+(s<0?-1:0)];if(a.nodeType==1&&a.contentEditable=="false")if(!((i=a.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=s;else return!1;else t=a,e=s<0?gn(t):0}else return!1}}function gn(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Xc(t,e,n){for(let r=e==0,s=e==gn(t);r||s;){if(t==n)return!0;let i=gt(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,s=s&&i==gn(t)}}function Vr(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const oa=function(t){return t.focusNode&&aa(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function la(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}const He=typeof navigator<"u"?navigator:null,Hs=typeof document<"u"?document:null,nt=He&&He.userAgent||"",yr=/Edge\/(\d+)/.exec(nt),ca=/MSIE \d/.exec(nt),br=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nt),Jt=!!(ca||br||yr),da=ca?document.documentMode:br?+br[1]:yr?+yr[1]:0,Dn=!Jt&&/gecko\/(\d+)/i.test(nt);Dn&&+(/Firefox\/(\d+)/.exec(nt)||[0,0])[1];const vr=!Jt&&/Chrome\/(\d+)/.exec(nt),Ke=!!vr,ua=vr?+vr[1]:0,xt=!Jt&&!!He&&/Apple Computer/.test(He.vendor),Hr=xt&&(/Mobile\/\w+/.test(nt)||!!He&&He.maxTouchPoints>2),$e=Hr||(He?/Mac/.test(He.platform):!1),fa=He?/Win/.test(He.platform):!1,Yt=/Android \d/.test(nt),Ur=!!Hs&&"webkitFontSmoothing"in Hs.documentElement.style,ed=Ur?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function td(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let s=t.docView.nearestDesc(n.focusNode),i=s&&s.size==0,a=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(a<0)return null;let o=r.resolve(a),c,d;if(oa(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&&Xc(n.focusNode,n.focusOffset,s.dom))){let p=s.posBefore;d=new Z(a==p?o:r.resolve(p))}}else{if(n instanceof t.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,t.docView.posFromDOM(v.startContainer,v.startOffset,1)),p=Math.max(p,t.docView.posFromDOM(v.endContainer,v.endOffset,-1))}if(f<0)return null;[c,a]=p==t.state.selection.anchor?[p,f]:[f,p],o=r.resolve(a)}else c=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let u=r.resolve(c);if(!d){let f=e=="pointer"||t.state.selection.head<o.pos&&!i?1:-1;d=ma(t,u,o,f)}return d}function ha(t){return t.editable?t.hasFocus():id(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function qr(t,e=!1){let n=t.state.selection;if(sd(t,n),!!ha(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Ke){let r=t.domSelectionRange(),s=t.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&aa(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)rd(t);else{let{anchor:r,head:s}=n,i,a;Us&&!(n instanceof ne)&&(n.$from.parent.inlineContent||(i=qs(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(a=qs(t,n.to))),t.docView.setSelection(r,s,t,e),Us&&(i&&Ws(i),a&&Ws(a)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&nd(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const Us=xt||Ke&&ua<63;function qs(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),s=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(xt&&s&&s.contentEditable=="false")return er(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return er(s);if(i)return er(i)}}function er(t){return t.contentEditable="true",xt&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Ws(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function nd(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,s=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=s)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!ha(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function rd(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,gt(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Jt&&da<=11&&(n.disabled=!0,n.disabled=!1)}function sd(t,e){if(e instanceof Z){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Ks(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Ks(t)}function Ks(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function ma(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||ne.between(e,n,r)}function id(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function kr(t,e){let{$anchor:n,$head:r}=t.selection,s=e>0?n.max(r):n.min(r),i=s.parent.inlineContent?s.depth?t.doc.resolve(e>0?s.after():s.before()):null:s;return i&&re.findFrom(i,e)}function Qe(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Js(t,e,n){let r=t.state.selection;if(r instanceof ne)if(n.indexOf("s")>-1){let{$head:s}=r,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let a=t.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return Qe(t,new ne(r.$anchor,a))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=kr(t.state,e);return s&&s instanceof Z?Qe(t,s):!1}else if(!($e&&n.indexOf("m")>-1)){let s=r.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,a;if(!i||i.isText)return!1;let o=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(a=t.docView.descAt(o))&&!a.contentDOM?Z.isSelectable(i)?Qe(t,new Z(e<0?t.state.doc.resolve(s.pos-i.nodeSize):s)):Ur?Qe(t,new ne(t.state.doc.resolve(e<0?o:o+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Z&&r.node.isInline)return Qe(t,new ne(e>0?r.$to:r.$from));{let s=kr(t.state,e);return s?Qe(t,s):!1}}}function xn(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Ft(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function yt(t,e){return e<0?ad(t):od(t)}function ad(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,i,a=!1;for(Dn&&n.nodeType==1&&r<xn(n)&&Ft(n.childNodes[r],-1)&&(a=!0);;)if(r>0){if(n.nodeType!=1)break;{let o=n.childNodes[r-1];if(Ft(o,-1))s=n,i=--r;else if(o.nodeType==3)n=o,r=n.nodeValue.length;else break}}else{if(pa(n))break;{let o=n.previousSibling;for(;o&&Ft(o,-1);)s=n.parentNode,i=gt(o),o=o.previousSibling;if(o)n=o,r=xn(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}a?wr(t,n,r):s&&wr(t,s,i)}function od(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=xn(n),i,a;for(;;)if(r<s){if(n.nodeType!=1)break;let o=n.childNodes[r];if(Ft(o,1))i=n,a=++r;else break}else{if(pa(n))break;{let o=n.nextSibling;for(;o&&Ft(o,1);)i=o.parentNode,a=gt(o)+1,o=o.nextSibling;if(o)n=o,r=0,s=xn(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}i&&wr(t,i,a)}function pa(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function ld(t,e){for(;t&&e==t.childNodes.length&&!Vr(t);)e=gt(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function cd(t,e){for(;t&&!e&&!Vr(t);)e=gt(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function wr(t,e,n){if(e.nodeType!=3){let i,a;(a=ld(e,n))?(e=a,n=0):(i=cd(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(oa(r)){let i=document.createRange();i.setEnd(e,n),i.setStart(e,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:s}=t;setTimeout(()=>{t.state==s&&qr(t)},50)}function Ys(t,e){let n=t.state.doc.resolve(e);if(!(Ke||fa)&&n.parent.inlineContent){let s=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-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(e<n.end()){let i=t.coordsAtPos(e+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(t.dom).direction=="rtl"?"rtl":"ltr"}function Gs(t,e,n){let r=t.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||t.endOfTextblock(e<0?"up":"down")){let a=kr(t.state,e);if(a&&a instanceof Z)return Qe(t,a)}if(!s.parent.inlineContent){let a=e<0?s:i,o=r instanceof Ve?re.near(a,e):re.findFrom(a,e);return o?Qe(t,o):!1}return!1}function Qs(t,e){if(!(t.state.selection instanceof ne))return!0;let{$head:n,$anchor:r,empty:s}=t.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let a=t.state.tr;return e<0?a.delete(n.pos-i.nodeSize,n.pos):a.delete(n.pos,n.pos+i.nodeSize),t.dispatch(a),!0}return!1}function Zs(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function dd(t){if(!xt||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Zs(t,r,"true"),setTimeout(()=>Zs(t,r,"false"),20)}return!1}function ud(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function fd(t,e){let n=e.keyCode,r=ud(e);if(n==8||$e&&n==72&&r=="c")return Qs(t,-1)||yt(t,-1);if(n==46&&!e.shiftKey||$e&&n==68&&r=="c")return Qs(t,1)||yt(t,1);if(n==13||n==27)return!0;if(n==37||$e&&n==66&&r=="c"){let s=n==37?Ys(t,t.state.selection.from)=="ltr"?-1:1:-1;return Js(t,s,r)||yt(t,s)}else if(n==39||$e&&n==70&&r=="c"){let s=n==39?Ys(t,t.state.selection.from)=="ltr"?1:-1:1;return Js(t,s,r)||yt(t,s)}else{if(n==38||$e&&n==80&&r=="c")return Gs(t,-1,r)||yt(t,-1);if(n==40||$e&&n==78&&r=="c")return dd(t)||Gs(t,1,r)||yt(t,1);if(r==($e?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function ga(t,e){t.someProp("transformCopied",m=>{e=m(e,t)});let n=[],{content:r,openStart:s,openEnd:i}=e;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=t.someProp("clipboardSerializer")||Mn.fromSchema(t.state.schema),o=wa(),c=o.createElement("div");c.appendChild(a.serializeFragment(r,{document:o}));let d=c.firstChild,u,f=0;for(;d&&d.nodeType==1&&(u=ka[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),f++}d=c.firstChild}d&&d.nodeType==1&&d.setAttribute("data-pm-slice",`${s} ${i}${f?` -${f}`:""} ${JSON.stringify(n)}`);let p=t.someProp("clipboardTextSerializer",m=>m(e,t))||e.content.textBetween(0,e.content.size,`
|
|
17
17
|
|
|
18
|
-
`);return{dom:
|
|
19
|
-
`))),0,0),t.someProp("transformPasted",m=>{l=m(l,t,!0)}),l;let f=t.someProp("clipboardTextParser",m=>m(e,s,r,t));if(f)l=f;else{let m=s.marks(),{schema:h}=t.state,S=gn.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(x=>{let k=o.appendChild(document.createElement("p"));x&&k.appendChild(S.serializeNode(h.text(x,m)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),o=Ya(n),kr&&ec(o);let u=o&&o.querySelector("[data-pm-slice]"),d=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let f=+d[3];f>0;f--){let m=o.firstChild;for(;m&&m.nodeType!=1;)m=m.nextSibling;if(!m)break;o=m}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||tn.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||d),context:s,ruleFromNode(m){return m.nodeName=="BR"&&!m.nextSibling&&m.parentNode&&!Za.test(m.parentNode.nodeName)?{ignore:!0}:null}})),d)l=tc(As(l,+d[1],+d[2]),d[4]);else if(l=q.maxOpen(Qa(l.content,s),!0),l.openStart||l.openEnd){let f=0,m=0;for(let h=l.content.firstChild;f<l.openStart&&!h.type.spec.isolating;f++,h=h.firstChild);for(let h=l.content.lastChild;m<l.openEnd&&!h.type.spec.isolating;m++,h=h.lastChild);l=As(l,f,m)}return t.someProp("transformPasted",f=>{l=f(l,t,a)}),l}const Za=/^(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 Qa(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.index(n)),i,o=[];if(t.forEach(l=>{if(!o)return;let a=s.findWrapping(l.type),u;if(!a)return o=null;if(u=o.length&&i.length&&Di(a,i,l,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=Li(o[o.length-1],i.length));let d=Oi(l,a);o.push(d),s=s.matchType(d.type),i=a}}),o)return U.from(o)}return t}function Oi(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,U.from(t));return t}function Di(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let i=Di(t,e,n,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==t.length-1?n.type:t[s+1]))return r.copy(r.content.append(U.from(Oi(n,t,s+1))))}}function Li(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Li(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(U.empty,!0);return t.copy(n.append(r))}function rr(t,e,n,r,s,i){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(i=0),s<r-1&&(l=rr(l,e,n,r,s+1,i)),s>=n&&(l=e<0?o.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(U.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function As(t,e,n){return e<t.openStart&&(t=new q(rr(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new q(rr(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Ri={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 Ns=null;function Fi(){return Ns||(Ns=document.implementation.createHTMLDocument("title"))}let _n=null;function Xa(t){let e=window.trustedTypes;return e?(_n||(_n=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),_n.createHTML(t)):t}function Ya(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Fi().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),s;if((s=r&&Ri[r[1].toLowerCase()])&&(t=s.map(i=>"<"+i+">").join("")+t+s.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=Xa(t),s)for(let i=0;i<s.length;i++)n=n.querySelector(s[i])||n;return n}function ec(t){let e=t.querySelectorAll(Je?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function tc(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:s,openStart:i,openEnd:o}=t;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;s=U.from(a.create(r[l+1],s)),i++,o++}return new q(s,i,o)}const Ve={},je={};function Xe(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}je.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!$i(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Ht&&Je&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),br&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",s=>s(t,Si(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||Ga(t,n)?n.preventDefault():Xe(t,"key")};je.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};je.keypress=(t,e)=>{let n=e;if($i(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Oe&&n.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof Q)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,s,i))&&t.dispatch(i()),n.preventDefault()}};function kn(t){return{left:t.clientX,top:t.clientY}}function nc(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Sr(t,e,n,r,s){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(t.someProp(e,l=>o>i.depth?l(t,n,i.nodeAfter,i.before(o),s,!0):l(t,n,i.node(o),i.before(o),s,!1)))return!0;return!1}function St(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function rc(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&K.isSelectable(r)?(St(t,new K(n)),!0):!1}function sc(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof K&&(r=n.node);let i=t.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let l=o>i.depth?i.nodeAfter:i.node(o);if(K.isSelectable(l)){r&&n.$from.depth>0&&o>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?s=i.before(n.$from.depth):s=i.before(o);break}}return s!=null?(St(t,K.create(t.state.doc,s)),!0):!1}function ic(t,e,n,r,s){return Sr(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(s?sc(t,n):rc(t,n))}function oc(t,e,n,r){return Sr(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function lc(t,e,n,r){return Sr(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||ac(t,n,r)}function ac(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(St(t,Q.create(r,0,r.content.size)),!0):!1;let s=r.resolve(e);for(let i=s.depth+1;i>0;i--){let o=i>s.depth?s.nodeAfter:s.node(i),l=s.before(i);if(o.inlineContent)St(t,Q.create(r,l+1,l+1+o.content.size));else if(K.isSelectable(o))St(t,K.create(r,l));else continue;return!0}}function Cr(t){return cn(t)}const Pi=Oe?"metaKey":"ctrlKey";Ve.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Cr(t),s=Date.now(),i="singleClick";s-t.input.lastClick.time<500&&nc(n,t.input.lastClick)&&!n[Pi]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:i,button:n.button};let o=t.posAtCoords(kn(n));o&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new cc(t,o,n,!!r)):(i=="doubleClick"?oc:lc)(t,o.pos,o.inside,n)?n.preventDefault():Xe(t,"pointer"))};class cc{constructor(e,n,r,s){this.view=e,this.pos=n,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Pi],this.allowDefault=r.shiftKey;let i,o;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),o=n.inside;else{let d=e.state.doc.resolve(n.pos);i=d.parent,o=d.depth?d.before():0}const l=s?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:u}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||u instanceof K&&u.from<=o&&u.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&bn&&!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()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Xe(e,"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(()=>vr(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(kn(e))),this.updateAllowDefault(e),this.allowDefault||!n?Xe(this.view,"pointer"):ic(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||pt&&this.mightDrag&&!this.mightDrag.node.isAtom||Je&&!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)?(St(this.view,X.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Xe(this.view,"pointer")}move(e){this.updateAllowDefault(e),Xe(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}Ve.touchstart=t=>{t.input.lastTouch=Date.now(),Cr(t),Xe(t,"pointer")};Ve.touchmove=t=>{t.input.lastTouch=Date.now(),Xe(t,"pointer")};Ve.contextmenu=t=>Cr(t);function $i(t,e){return t.composing?!0:pt&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const uc=Ht?5e3:-1;je.compositionstart=je.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof Q&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Je&&Ni&&dc(t)))t.markCursor=t.state.storedMarks||n.marks(),cn(t,!0),t.markCursor=null;else if(cn(t,!e.selection.empty),bn&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let s=r.focusNode,i=r.focusOffset;s&&s.nodeType==1&&i!=0;){let o=i<0?s.lastChild:s.childNodes[i-1];if(!o)break;if(o.nodeType==3){let l=t.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else s=o,i=-1}}t.input.composing=!0}Vi(t,uc)};function dc(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}je.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,Vi(t,20))};function Vi(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>cn(t),e))}function fc(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=hc());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function hc(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function cn(t,e=!1){if(!(Ht&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),fc(t),e||t.docView&&t.docView.dirty){let n=$a(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function pc(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const Vt=_t&&wi<15||br&&Pa<604;Ve.copy=je.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let i=Vt?null:n.clipboardData,o=r.content(),{dom:l,text:a}=ji(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):pc(t,l),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function mc(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function gc(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.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=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?sr(t,r.value,null,s,e):sr(t,r.textContent,r.innerHTML,s,e)},50)}function sr(t,e,n,r,s){let i=Ii(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,s,i||q.empty)))return!0;if(!i)return!1;let o=mc(i),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(i);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function zi(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}je.paste=(t,e)=>{let n=e;if(t.composing&&!Ht)return;let r=Vt?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&sr(t,zi(r),r.getData("text/html"),s,n)?n.preventDefault():gc(t,n)};class yc{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const xc=Oe?"altKey":"ctrlKey";function Bi(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[xc]}Ve.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=t.state.selection,i=s.empty?null:t.posAtCoords(kn(n)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof K?s.to-1:s.to))){if(r&&r.mightDrag)o=K.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let f=t.docView.nearestDesc(n.target,!0);f&&f.node.type.spec.draggable&&f!=t.docView&&(o=K.create(t.state.doc,f.posBefore))}}let l=(o||t.state.selection).content(),{dom:a,text:u,slice:d}=ji(t,l);(!n.dataTransfer.files.length||!Je||Ai>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Vt?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Vt||n.dataTransfer.setData("text/plain",u),t.dragging=new yc(d,Bi(t,n),o)};Ve.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};je.dragover=je.dragenter=(t,e)=>e.preventDefault();je.drop=(t,e)=>{try{bc(t,e,t.dragging)}finally{t.dragging=null}};function bc(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(kn(e));if(!r)return;let s=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp("transformPasted",h=>{i=h(i,t,!1)}):i=Ii(t,zi(e.dataTransfer),Vt?null:e.dataTransfer.getData("text/html"),!1,s);let o=!!(n&&Bi(t,e));if(t.someProp("handleDrop",h=>h(t,e,i||q.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let l=i?hi(t.state.doc,s.pos,i):s.pos;l==null&&(l=s.pos);let a=t.state.tr;if(o){let{node:h}=n;h?h.replace(a):a.deleteSelection()}let u=a.mapping.map(l),d=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,f=a.doc;if(d?a.replaceRangeWith(u,u,i.content.firstChild):a.replaceRange(u,u,i),a.doc.eq(f))return;let m=a.doc.resolve(u);if(d&&K.isSelectable(i.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new K(m));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((S,x,k,C)=>h=C),a.setSelection(Ei(t,m,a.doc.resolve(h)))}t.focus(),t.dispatch(a.setMeta("uiEvent","drop"))}Ve.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&vr(t)},20))};Ve.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};Ve.beforeinput=(t,e)=>{if(Je&&Ht&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,Si(8,"Backspace")))))return;let{$cursor:s}=t.state.selection;s&&s.pos>0&&t.dispatch(t.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let t in je)Ve[t]=je[t];function zt(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class un{constructor(e,n){this.toDOM=e,this.spec=n||dt,this.side=this.spec.side||0}map(e,n,r,s){let{pos:i,deleted:o}=e.mapResult(n.from+s,this.side<0?-1:1);return o?null:new Be(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof un&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&zt(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ye{constructor(e,n){this.attrs=e,this.spec=n||dt}map(e,n,r,s){let i=e.map(n.from+s,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=o?null:new Be(i,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Ye&&zt(this.attrs,e.attrs)&&zt(this.spec,e.spec)}static is(e){return e.type instanceof Ye}destroy(){}}class wr{constructor(e,n){this.attrs=e,this.spec=n||dt}map(e,n,r,s){let i=e.mapResult(n.from+s,1);if(i.deleted)return null;let o=e.mapResult(n.to+s,-1);return o.deleted||o.pos<=i.pos?null:new Be(i.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:s}=e.content.findIndex(n.from),i;return s==n.from&&!(i=e.child(r)).isText&&s+i.nodeSize==n.to}eq(e){return this==e||e instanceof wr&&zt(this.attrs,e.attrs)&&zt(this.spec,e.spec)}destroy(){}}class Be{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Be(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new Be(e,e,new un(n,r))}static inline(e,n,r,s){return new Be(e,n,new Ye(r,s))}static node(e,n,r,s){return new Be(e,n,new wr(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ye}get widget(){return this.type instanceof un}}const bt=[],dt={};class he{constructor(e,n){this.local=e.length?e:bt,this.children=n.length?n:bt}static create(e,n){return n.length?dn(n,e,0,dt):Se}find(e,n,r){let s=[];return this.findInner(e??0,n??1e9,s,0,r),s}findInner(e,n,r,s,i){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=n&&l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+s,l.to+s))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<n&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,n-l,r,s+l,i)}}map(e,n,r){return this==Se||e.maps.length==0?this:this.mapInner(e,n,0,0,r||dt)}mapInner(e,n,r,s,i){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,s);a&&a.type.valid(n,a)?(o||(o=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?kc(this.children,o||[],e,n,r,s,i):o?new he(o.sort(ft),bt):Se}add(e,n){return n.length?this==Se?he.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,i=0;e.forEach((l,a)=>{let u=a+r,d;if(d=Hi(n,l,u)){for(s||(s=this.children.slice());i<s.length&&s[i]<a;)i+=3;s[i]==a?s[i+2]=s[i+2].addInner(l,d,u+1):s.splice(i,0,a,a+l.nodeSize,dn(d,l,u+1,dt)),i+=3}});let o=_i(i?Ui(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new he(o.length?this.local.concat(o).sort(ft):this.local,s||this.children)}remove(e){return e.length==0||this==Se?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let o,l=r[i]+n,a=r[i+1]+n;for(let d=0,f;d<e.length;d++)(f=e[d])&&f.from>l&&f.to<a&&(e[d]=null,(o||(o=[])).push(f));if(!o)continue;r==this.children&&(r=this.children.slice());let u=r[i+2].removeInner(o,l+1);u!=Se?r[i+2]=u:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,o;i<e.length;i++)if(o=e[i])for(let l=0;l<s.length;l++)s[l].eq(o,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 he(s,r):Se}forChild(e,n){if(this==Se)return this;if(n.isLeaf)return he.empty;let r,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,o=i+n.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>i&&a.type instanceof Ye){let u=Math.max(i,a.from)-i,d=Math.min(o,a.to)-i;u<d&&(s||(s=[])).push(a.copy(u,d))}}if(s){let l=new he(s.sort(ft),bt);return r?new it([l,r]):l}return r||Se}eq(e){if(this==e)return!0;if(!(e instanceof he)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return Ar(this.localsInner(e))}localsInner(e){if(this==Se)return bt;if(e.inlineContent||!this.local.some(Ye.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Ye||n.push(this.local[r]);return n}forEachSet(e){e(this)}}he.empty=new he([],[]);he.removeOverlap=Ar;const Se=he.empty;class it{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,dt));return it.from(r)}forChild(e,n){if(n.isLeaf)return he.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,n);i!=Se&&(i instanceof it?r=r.concat(i.members):r.push(i))}return it.from(r)}eq(e){if(!(e instanceof it)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let o=0;o<i.length;o++)n.push(i[o])}}return n?Ar(r?n:n.sort(ft)):bt}static from(e){switch(e.length){case 0:return Se;case 1:return e[0];default:return new it(e.every(n=>n instanceof he)?e:e.reduce((n,r)=>n.concat(r instanceof he?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function kc(t,e,n,r,s,i,o){let l=t.slice();for(let u=0,d=i;u<n.maps.length;u++){let f=0;n.maps[u].forEach((m,h,S,x)=>{let k=x-S-(h-m);for(let C=0;C<l.length;C+=3){let w=l[C+1];if(w<0||m>w+d-f)continue;let T=l[C]+d-f;h>=T?l[C+1]=m<=T?-2:-1:m>=d&&k&&(l[C]+=k,l[C+1]+=k)}f+=k}),d=n.maps[u].map(d,-1)}let a=!1;for(let u=0;u<l.length;u+=3)if(l[u+1]<0){if(l[u+1]==-2){a=!0,l[u+1]=-1;continue}let d=n.map(t[u]+i),f=d-s;if(f<0||f>=r.content.size){a=!0;continue}let m=n.map(t[u+1]+i,-1),h=m-s,{index:S,offset:x}=r.content.findIndex(f),k=r.maybeChild(S);if(k&&x==f&&x+k.nodeSize==h){let C=l[u+2].mapInner(n,k,d+1,t[u]+i+1,o);C!=Se?(l[u]=f,l[u+1]=h,l[u+2]=C):(l[u+1]=-2,a=!0)}else a=!0}if(a){let u=vc(l,t,e,n,s,i,o),d=dn(u,r,0,o);e=d.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,m=0;f<d.children.length;f+=3){let h=d.children[f];for(;m<l.length&&l[m]<h;)m+=3;l.splice(m,0,d.children[f],d.children[f+1],d.children[f+2])}}return new he(e.sort(ft),l)}function _i(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let s=t[r];n.push(new Be(s.from+e,s.to+e,s.type))}return n}function vc(t,e,n,r,s,i,o){function l(a,u){for(let d=0;d<a.local.length;d++){let f=a.local[d].map(r,s,u);f?n.push(f):o.onRemove&&o.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+u+1)}for(let a=0;a<t.length;a+=3)t[a+1]==-1&&l(t[a+2],e[a]+i+1);return n}function Hi(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,s=null;for(let i=0,o;i<t.length;i++)(o=t[i])&&o.from>n&&o.to<r&&((s||(s=[])).push(o),t[i]=null);return s}function Ui(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function dn(t,e,n,r){let s=[],i=!1;e.forEach((l,a)=>{let u=Hi(t,l,a+n);if(u){i=!0;let d=dn(u,l,n+a+1,r);d!=Se&&s.push(a,a+l.nodeSize,d)}});let o=_i(i?Ui(t):t,-n).sort(ft);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||s.length?new he(o,s):Se}function ft(t,e){return t.from-e.from||t.to-e.to}function Ar(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let s=n+1;s<e.length;s++){let i=e[s];if(i.from==r.from){i.to!=r.to&&(e==t&&(e=t.slice()),e[s]=i.copy(i.from,r.to),Ts(e,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),Ts(e,s,r.copy(i.from,r.to)));break}}}return e}function Ts(t,e,n){for(;e<t.length&&ft(n,t[e])>0;)e++;t.splice(e,0,n)}class le extends X{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return le.valid(r)?new le(r):X.near(r)}content(){return q.empty}eq(e){return e instanceof le&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new le(e.resolve(n.pos))}getBookmark(){return new Nr(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!Sc(e)||!Cc(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let s=n.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&le.valid(e))return e;let s=e.pos,i=null;for(let o=e.depth;;o--){let l=e.node(o);if(n>0?e.indexAfter(o)<l.childCount:e.index(o)>0){i=l.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=n;let a=e.doc.resolve(s);if(le.valid(a))return a}for(;;){let o=n>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!K.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*n),r=!1;continue e}break}i=o,s+=n;let l=e.doc.resolve(s);if(le.valid(l))return l}return null}}}le.prototype.visible=!1;le.findFrom=le.findGapCursorFrom;X.jsonID("gapcursor",le);class Nr{constructor(e){this.pos=e}map(e){return new Nr(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return le.valid(n)?new le(n):X.near(n)}}function qi(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function Sc(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);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||qi(s.type))return!0;if(s.inlineContent)return!1}}return!0}function Cc(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);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||qi(s.type))return!0;if(s.inlineContent)return!1}}return!0}function wc(){return new xn({props:{decorations:Ec,createSelectionBetween(t,e,n){return e.pos==n.pos&&le.valid(n)?new le(n):null},handleClick:Nc,handleKeyDown:Ac,handleDOMEvents:{beforeinput:Tc}}})}const Ac=La({ArrowLeft:Wt("horiz",-1),ArrowRight:Wt("horiz",1),ArrowUp:Wt("vert",-1),ArrowDown:Wt("vert",1)});function Wt(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof Q){if(!i.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let u=le.findGapCursorFrom(l,e,a);return u?(s&&s(r.tr.setSelection(new le(u))),!0):!1}}function Nc(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!le.valid(r))return!1;let s=t.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&K.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new le(r))),!0)}function Tc(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof le))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let s=U.empty;for(let o=r.length-1;o>=0;o--)s=U.from(r[o].createAndFill(null,s));let i=t.state.tr.replace(n.pos,n.pos,new q(s,0,0));return i.setSelection(Q.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function Ec(t){if(!(t.selection instanceof le))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",he.create(t.doc,[Be.widget(t.selection.head,e,{key:"gapcursor"})])}const Mc=R.Extension.create({name:"gapCursor",addProseMirrorPlugins(){return[wc()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=R.callOrReturn(R.getExtensionField(t,"allowGapCursor",n)))!==null&&e!==void 0?e:null}}}),At={bold:{category:"mark",extension:Tl,priority:100},italic:{category:"mark",extension:Ol,priority:100},strike:{category:"mark",extension:Rl,priority:100},underline:{category:"mark",extension:_o.Underline,priority:100},code:{category:"mark",extension:$l,priority:100},textColor:{category:"mark",extension:Ho.Color,defaultOptions:{types:["textStyle","heading","paragraph","listItem","taskItem","blockquote"]},priority:90},highlight:{category:"mark",extension:Uo.Highlight,defaultOptions:{multicolor:!0},priority:90},link:{category:"mark",extension:qo.Link,defaultOptions:{autolink:!0,linkOnPaste:!0,openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}},priority:100},heading:{category:"node",extension:Bl,defaultOptions:{levels:[1,2,3,4,5,6]},priority:100},bulletList:{category:"node",extension:Ul,defaultOptions:{HTMLAttributes:{class:"list-disc"}},priority:90},orderedList:{category:"node",extension:Kl,defaultOptions:{HTMLAttributes:{class:"list-decimal"}},priority:90},taskList:{category:"node",extension:Ko.TaskList,defaultOptions:{HTMLAttributes:{class:"task-list"}},priority:90},codeBlock:{category:"node",extension:aa,priority:100},blockquote:{category:"node",extension:ua,priority:100},horizontalRule:{category:"node",extension:da,priority:100},hardBreak:{category:"node",extension:fa,priority:100},undo:{category:"extension",extension:hs,priority:50},redo:{category:"extension",extension:hs,priority:50},textAlign:{category:"extension",extension:Wo.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}},jc=[Sa,Ca,_l,zl.configure({HTMLAttributes:{}}),Jl.configure({HTMLAttributes:{}}),Jo.TaskItem.configure({nested:!0}),Na,Mc];function Ic(t){const e=[],n=new Set,r=new Set;jc.forEach(l=>{l&&(e.push(l),r.add(l.name))});const s=t.map(l=>Rt(l)),i=new Set;return s.forEach(l=>{const a=At[l];a?.requiredExtensions&&a.requiredExtensions.forEach(u=>{i.add(u)})}),i.forEach(l=>{if(n.has(l))return;const a=At[l];if(!a||a.extension===null)return;const u=a.extension.name;if(r.has(u)){n.add(l);return}const d=a.defaultOptions?a.extension.configure(a.defaultOptions):a.extension;e.push(d),n.add(l),r.add(u)}),s.forEach(l=>{if(n.has(l))return;const a=At[l];if(!a){console.warn(`Extension config not found for modifier: ${l}`);return}if(a.extension===null){n.add(l);return}const u=a.extension.name;if(r.has(u)){n.add(l);return}const d=a.defaultOptions?a.extension.configure(a.defaultOptions):a.extension;e.push(d),n.add(l),r.add(u)}),e.sort((l,a)=>{const u=Object.values(At).find(h=>h?.extension?.name===l.name),d=Object.values(At).find(h=>h?.extension?.name===a.name),f=u?.priority??100;return(d?.priority??100)-f})}const Ki={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"]},ie={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"}},Ge={brand:{primary:{DEFAULT:"#C14615"}},neutral:{gray:{100:"#F3F4F6",200:"#E5E7EB",300:"#D1D5DB",500:"#6B7280",800:"#1F2937"}},palettes:{warning:{200:"#fde68a"}}},ne={xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem"},Oc={h1:`font-size: ${ie.fontSize["4xl"]}; font-weight: ${ie.fontWeight.semibold}; line-height: ${ie.lineHeight.tight}; margin: ${ne.md} 0 ${ne.sm} 0;`,h2:`font-size: ${ie.fontSize["2xl"]}; font-weight: ${ie.fontWeight.semibold}; line-height: ${ie.lineHeight.tight}; margin: ${ne.md} 0 ${ne.sm} 0;`,h3:`font-size: ${ie.fontSize.xl}; font-weight: ${ie.fontWeight.semibold}; line-height: ${ie.lineHeight.tight}; margin: ${ne.md} 0 ${ne.sm} 0;`,h4:`font-size: ${ie.fontSize.lg}; font-weight: ${ie.fontWeight.semibold}; line-height: ${ie.lineHeight.tight}; margin: ${ne.md} 0 ${ne.sm} 0;`,h5:`font-size: ${ie.fontSize.base}; font-weight: ${ie.fontWeight.semibold}; line-height: ${ie.lineHeight.tight}; margin: ${ne.md} 0 ${ne.sm} 0;`,h6:`font-size: ${ie.fontSize.sm}; font-weight: ${ie.fontWeight.semibold}; line-height: ${ie.lineHeight.tight}; margin: ${ne.md} 0 ${ne.sm} 0;`,p:`min-height: ${ie.lineHeight.normal}em; margin: 0;`,ul:`list-style-type: disc; list-style-position: outside; padding-left: ${ne.xl}; margin: ${ne.md} 0;`,ol:`list-style-type: decimal; list-style-position: outside; padding-left: ${ne.xl}; margin: ${ne.md} 0;`,li:`display: list-item; margin: ${ne.xs} 0;`,strong:`font-weight: ${ie.fontWeight.bold};`,em:"font-style: italic;",s:"text-decoration: line-through;",u:"text-decoration: underline;",code:`background-color: ${Ge.neutral.gray[100]}; border-radius: 0.4rem; font-size: ${ie.fontSize.sm}; padding: 0.25em 0.3em; font-family: ${ie.fontFamily.mono};`,pre:`background: ${Ge.neutral.gray[800]}; border-radius: ${ne.sm}; color: ${Ge.neutral.gray[100]}; font-family: ${ie.fontFamily.mono}; margin: ${ne.lg} 0; padding: 0.75rem ${ne.md}; overflow-x: auto;`,blockquote:`border-left: 3px solid ${Ge.neutral.gray[300]}; margin: ${ne.lg} 0; padding-left: ${ne.md}; color: ${Ge.neutral.gray[500]};`,hr:`border: none; border-top: 1px solid ${Ge.neutral.gray[200]}; margin: ${ne.xl} 0;`,a:`color: ${Ge.brand.primary.DEFAULT}; text-decoration: underline; cursor: pointer;`,mark:`background-color: ${Ge.palettes.warning[200]}; border-radius: ${ne.xs}; padding: 0 0.125rem;`,label:`display: flex; align-items: center; gap: ${ne.sm}; cursor: pointer;`,input:"cursor: pointer; margin: 0;"},Dc={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 Lc(t){if(!t)return t;let e=t;for(const[n,r]of Object.entries(Dc)){const s=new RegExp(`(<(?:ul|li)[^>]*data-type="${n}"[^>]*)>`,"gi");e=e.replace(s,(i,o)=>i.includes('style="')?i.replace(/style="([^"]*)"/,`style="$1 ${r}"`):`${o} style="${r}">`)}for(const[n,r]of Object.entries(Oc)){const s=new RegExp(`<${n}(\\s[^>]*)?>`,"gi");e=e.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 o=i.indexOf(">");return`${i.slice(0,o)} style="${r}"${i.slice(o)}`}})}return e}const Rc=({modifiers:t,zoom:e,onZoomChange:n,onToolbarAction:r})=>{const{editor:s}=hr.useCurrentEditor();return c.jsx(Sl,{editor:s,modifiers:t,zoom:e,onZoomChange:n,onToolbarAction:r})},Fc=({showCharacterCount:t,showWordCount:e})=>{const{editor:n}=hr.useCurrentEditor();if(!n||!t&&!e)return null;const r=n.getText(),s=r.length,i=r.split(/\s+/).filter(o=>o.length>0).length;return c.jsxs("div",{className:"flex gap-4 text-xs text-default-500 px-2 pb-1",children:[t&&c.jsxs("span",{children:[s," characters"]}),e&&c.jsxs("span",{children:[i," words"]})]})},ir=b.forwardRef((t,e)=>{const{minRows:n=10,maxRows:r=30,disableAutosize:s=!1,showCharacterCount:i=!1,showWordCount:o=!1,showToolbar:l=!0,modifiers:a=Ki.full,variant:u="bordered",initialContent:d,content:f,onContentChange:m,onUpdate:h,onToolbarAction:S,isReadOnly:x=!1,isDisabled:k=!1,includeInlineStyles:C=!0,...w}=t,{zoom:T,setZoom:A}=bl(),N=Wr.lineHeight,O=n*N,L=s?void 0:r*N,_=b.useMemo(()=>Ic(a),[a]),{Component:z,label:H,shouldLabelBeOutside:F,getBaseProps:j,getLabelProps:P,getInputWrapperProps:$}=g.useInput({...w,variant:u,ref:e,isMultiline:!0}),J=H?c.jsx("label",{...P(),children:H}):null,oe=b.useCallback(({editor:W})=>{const me=W.getHTML(),ae=C?Lc(me):me,ge=W.getJSON(),Le=W.getText(),Y=Le.length,Ie=Le.split(/\s+/).filter(Ae=>Ae.length>0).length,ee={html:ae,json:ge,text:Le,characters:Y,words:Ie};if(m?.(ee),h?.(ee),"onChange"in w&&typeof w.onChange=="function"){const Ae={target:{value:ae},currentTarget:{value:ae}};w.onChange(Ae)}},[m,h,w,C]);return c.jsxs(z,{...j(),children:[F?J:null,c.jsx("div",{...$(),className:g.cn($().className,"flex flex-col w-full p-0 gap-0 rich-text-editor"),style:{maxHeight:L?`${L+Wr.toolbarHeight}px`:void 0,overflow:L?"auto":void 0},children:c.jsx(hr.EditorProvider,{editable:!x&&!k,slotBefore:l?c.jsx(Rc,{modifiers:a,zoom:T,onZoomChange:A,onToolbarAction:S}):void 0,slotAfter:c.jsx(Fc,{showCharacterCount:i,showWordCount:o}),editorContainerProps:{className:"w-full flex-1 outline-none",style:{minHeight:`${O}px`,fontSize:`${T}%`,display:"flex",flexDirection:"column"}},editorProps:{attributes:{class:"focus:outline-none w-full h-full"}},extensions:_,content:f||d||t.defaultValue||"",onUpdate:oe})})]})});ir.displayName="TipTapEditor";const Ji=b.forwardRef((t,e)=>{const{adapter:n="tiptap",variant:r="bordered",...s}=t;return n==="tiptap"?c.jsx(ir,{...s,variant:r,ref:e}):(console.warn(`Adapter "${n}" is not supported. Using TipTap.`),c.jsx(ir,{...s,variant:r,ref:e}))});Ji.displayName="RichTextArea";function Pc(t,e="en-US",n="USD"){try{return new Intl.NumberFormat(e,{style:"currency",currency:n,minimumFractionDigits:0,maximumFractionDigits:2}).format(t)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${t.toFixed(2)}`}}const Es=[{id:"100",amount:100},{id:"250",amount:250},{id:"500",amount:500},{id:"1000",amount:1e3},{id:"2000",amount:2e3}],$c={title:"Donation Amount",customAmountPlaceholder:"Custom donation amount",customAmountAriaLabel:"Custom donation amount",addDonationButton:"Add Donation"},Wi=({presetAmounts:t=Es,selectedDonation:e,defaultSelectedDonation:n=null,onChange:r,onAddDonation:s,currency:i="USD",locale:o="en-US",showCustomAmount:l=!0,minCustomAmount:a=.5,maxCustomAmount:u=1e6,labels:d,mobileColumns:f=2,desktopColumns:m=3,isDisabled:h=!1,buttonVariant:S="bordered",buttonColor:x="default",inputVariant:k="bordered",size:C="md",className:w="",showCard:T=!0})=>{const A={...$c,...d},N=Array.isArray(t)?t:Es,O={2:"grid-cols-2",3:"grid-cols-3"},L={3:"sm:grid-cols-3",4:"sm:grid-cols-4",5:"sm:grid-cols-5",6:"sm:grid-cols-6"},_=`${O[f]} ${L[m]}`,[z,H]=pr(e,n,r),[F,j]=b.useState(""),[P,$]=b.useState(!1),[J,oe]=b.useState(0),W=b.useCallback(Y=>{if(h)return;const Ie={amount:Y.amount,isCustom:!1,presetId:Y.id};H(Ie),j(""),$(!1),oe(ee=>ee+1),s?.(Ie)},[h,H,s]),me=b.useCallback(Y=>{if(h)return;if(j(Y!==void 0?String(Y):""),s){H(null);return}if(Y===void 0||isNaN(Y)){H(null);return}H({amount:Y,isCustom:!0})},[h,H,s]),ae=b.useCallback(()=>{if(h)return;const Y=F!==""?parseFloat(F):void 0;Y===void 0||isNaN(Y)||s?.({amount:Y,isCustom:!0})},[h,F,s]),ge=b.useMemo(()=>({style:"currency",currency:i,currencyDisplay:"symbol"}),[i]),Le=c.jsxs("div",{className:"space-y-4","data-testid":"donation-amounts-root",children:[A.title&&c.jsx("h2",{className:"text-base font-semibold","data-testid":"donation-amounts-title",children:A.title}),N.length>0&&c.jsx("div",{className:g.cn("grid gap-3",_),"data-testid":"donation-amounts-presets",children:N.map(Y=>{const Ie=z!==null&&!z.isCustom&&z.presetId===Y.id;return c.jsx(se,{color:Ie?"primary":x,variant:Ie?"solid":S,className:"w-full",onPress:()=>W(Y),isDisabled:h,"data-testid":`donation-amounts-preset-${Y.id}`,children:Y.label||Pc(Y.amount,o,i)},Y.id)})}),l&&c.jsxs("div",{className:"flex gap-3 items-start",children:[c.jsx(g.NumberInput,{placeholder:A.customAmountPlaceholder,"aria-label":A.customAmountAriaLabel,onInput:s?()=>{H(null),$(!0)}:void 0,variant:k,radius:"full",size:C,minValue:a,maxValue:u,step:.01,formatOptions:ge,value:F!==""?parseFloat(F):void 0,onValueChange:me,isDisabled:h,className:"flex-1 [&_[data-slot=input-wrapper]]:!h-10 [&_[data-slot=input-wrapper]]:!min-h-10","data-testid":"donation-amounts-custom-input",hideStepper:!0},s?`custom-${J}`:z?.isCustom===!1?z.presetId:"custom"),s&&c.jsx(se,{color:"primary",variant:"solid",radius:"full",size:C,className:"shrink-0",onPress:ae,isDisabled:h||!P,"data-testid":"donation-amounts-add-button",children:A.addDonationButton})]})]});return T?c.jsx(g.Card,{className:g.cn("w-full",w),"data-testid":"donation-amounts-card",children:c.jsx(g.CardBody,{children:Le})}):c.jsx("div",{className:g.cn("w-full",w),"data-testid":"donation-amounts-plain",children:Le})};Wi.displayName="DonationAmounts";const Vc=t=>{const e=Math.max(0,t),n=Math.floor(e/60).toString().padStart(2,"0"),r=(e%60).toString().padStart(2,"0");return`${n}:${r} minutes`},zc=t=>{switch(t){case"warning":return B.Clock;case"error":return B.AlertCircle;case"success":return B.CheckCircle;default:return B.Clock}},Bc=t=>{switch(t){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"}},Gi=b.forwardRef(({timeLeft:t,defaultTimeLeft:e=1200,onTimeChange:n,onExpire:r,variant:s="info",color:i="primary",message:o="Your cart expires in:",showIcon:l=!0,icon:a,position:u="fixed",autoStart:d=!0,formatTime:f=Vc,className:m,...h},S)=>{const[x,k]=pr(t!==void 0?Math.max(0,t):void 0,Math.max(0,e),n),C=b.useRef(null),w=b.useRef(!1);b.useEffect(()=>()=>{C.current&&clearInterval(C.current)},[]),b.useEffect(()=>{if(!d||x<=0){C.current&&(clearInterval(C.current),C.current=null);return}return C.current=setInterval(()=>{k(O=>O<=1?(C.current&&(clearInterval(C.current),C.current=null),w.current||(w.current=!0,r?.()),0):O-1)},1e3),()=>{C.current&&(clearInterval(C.current),C.current=null)}},[d,x,k,r]),b.useEffect(()=>{x>0&&(w.current=!1)},[x]);const T=a||zc(s),A=Bc(i),N={fixed:"fixed top-0 left-0",sticky:"sticky top-0",static:"static"};return c.jsx("div",{ref:S,role:"banner","aria-live":"polite","aria-label":`${o} ${f(x)}`,"data-testid":"expire-cart-timer",className:g.cn("w-full text-white z-50",A,N[u],m),...h,children:c.jsx("div",{className:"container mx-auto px-4 py-3 sm:py-2.5","data-testid":"expire-cart-timer-container",children:c.jsxs("div",{className:"flex items-center justify-between gap-3 sm:gap-4",children:[c.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&&c.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:c.jsx(T,{className:"text-primary-500 sm:text-primary-600","aria-hidden":"true",size:14,"data-testid":"expire-cart-timer-icon"})}),c.jsx("p",{className:"text-sm sm:text-base font-medium text-white","data-testid":"expire-cart-timer-message",children:o})]}),c.jsx("div",{className:"flex-shrink-0","data-testid":"expire-cart-timer-right",children:c.jsx("span",{className:"text-sm sm:text-base font-semibold text-white","aria-label":`Time remaining: ${f(x)}`,"data-testid":"expire-cart-timer-value",children:f(x)})})]})})})});Gi.displayName="ExpireCartTimer";function _c(t,e){const n=t.icons,r=t.aliases||Object.create(null),s=Object.create(null);function i(o){if(n[o])return s[o]=[];if(!(o in s)){s[o]=null;const l=r[o]&&r[o].parent,a=l&&i(l);a&&(s[o]=[l].concat(a))}return s[o]}return Object.keys(n).concat(Object.keys(r)).forEach(i),s}const Zi=Object.freeze({left:0,top:0,width:16,height:16}),fn=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),Tr=Object.freeze({...Zi,...fn}),or=Object.freeze({...Tr,body:"",hidden:!1});function Hc(t,e){const n={};!t.hFlip!=!e.hFlip&&(n.hFlip=!0),!t.vFlip!=!e.vFlip&&(n.vFlip=!0);const r=((t.rotate||0)+(e.rotate||0))%4;return r&&(n.rotate=r),n}function Ms(t,e){const n=Hc(t,e);for(const r in or)r in fn?r in t&&!(r in n)&&(n[r]=fn[r]):r in e?n[r]=e[r]:r in t&&(n[r]=t[r]);return n}function Uc(t,e,n){const r=t.icons,s=t.aliases||Object.create(null);let i={};function o(l){i=Ms(r[l]||s[l],i)}return o(e),n.forEach(o),Ms(t,i)}function Qi(t,e){const n=[];if(typeof t!="object"||typeof t.icons!="object")return n;t.not_found instanceof Array&&t.not_found.forEach(s=>{e(s,null),n.push(s)});const r=_c(t);for(const s in r){const i=r[s];i&&(e(s,Uc(t,s,i)),n.push(s))}return n}const qc={provider:"",aliases:{},not_found:{},...Zi};function Hn(t,e){for(const n in e)if(n in t&&typeof t[n]!=typeof e[n])return!1;return!0}function Xi(t){if(typeof t!="object"||t===null)return null;const e=t;if(typeof e.prefix!="string"||!t.icons||typeof t.icons!="object"||!Hn(t,qc))return null;const n=e.icons;for(const s in n){const i=n[s];if(!s||typeof i.body!="string"||!Hn(i,or))return null}const r=e.aliases||Object.create(null);for(const s in r){const i=r[s],o=i.parent;if(!s||typeof o!="string"||!n[o]&&!r[o]||!Hn(i,or))return null}return e}const js=Object.create(null);function Kc(t,e){return{provider:t,prefix:e,icons:Object.create(null),missing:new Set}}function Ct(t,e){const n=js[t]||(js[t]=Object.create(null));return n[e]||(n[e]=Kc(t,e))}function Yi(t,e){return Xi(e)?Qi(e,(n,r)=>{r?t.icons[n]=r:t.missing.add(n)}):[]}function Jc(t,e,n){try{if(typeof n.body=="string")return t.icons[e]={...n},!0}catch{}return!1}const eo=/^[a-z0-9]+(-[a-z0-9]+)*$/,vn=(t,e,n,r="")=>{const s=t.split(":");if(t.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(),a=s.pop(),u={provider:s.length>0?s[0]:r,prefix:a,name:l};return e&&!Yt(u)?null:u}const i=s[0],o=i.split("-");if(o.length>1){const l={provider:r,prefix:o.shift(),name:o.join("-")};return e&&!Yt(l)?null:l}if(n&&r===""){const l={provider:r,prefix:"",name:i};return e&&!Yt(l,n)?null:l}return null},Yt=(t,e)=>t?!!((e&&t.prefix===""||t.prefix)&&t.name):!1;let Bt=!1;function to(t){return typeof t=="boolean"&&(Bt=t),Bt}function Is(t){const e=typeof t=="string"?vn(t,!0,Bt):t;if(e){const n=Ct(e.provider,e.prefix),r=e.name;return n.icons[r]||(n.missing.has(r)?null:void 0)}}function Wc(t,e){const n=vn(t,!0,Bt);if(!n)return!1;const r=Ct(n.provider,n.prefix);return e?Jc(r,n.name,e):(r.missing.add(n.name),!0)}function Gc(t,e){if(typeof t!="object")return!1;if(typeof e!="string"&&(e=t.provider||""),Bt&&!e&&!t.prefix){let s=!1;return Xi(t)&&(t.prefix="",Qi(t,(i,o)=>{Wc(i,o)&&(s=!0)})),s}const n=t.prefix;if(!Yt({prefix:n,name:"a"}))return!1;const r=Ct(e,n);return!!Yi(r,t)}const no=Object.freeze({width:null,height:null}),ro=Object.freeze({...no,...fn}),Zc=/(-?[0-9.]*[0-9]+[0-9.]*)/g,Qc=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function Os(t,e,n){if(e===1)return t;if(n=n||100,typeof t=="number")return Math.ceil(t*e*n)/n;if(typeof t!="string")return t;const r=t.split(Zc);if(r===null||!r.length)return t;const s=[];let i=r.shift(),o=Qc.test(i);for(;;){if(o){const l=parseFloat(i);isNaN(l)?s.push(i):s.push(Math.ceil(l*e*n)/n)}else s.push(i);if(i=r.shift(),i===void 0)return s.join("");o=!o}}function Xc(t,e="defs"){let n="";const r=t.indexOf("<"+e);for(;r>=0;){const s=t.indexOf(">",r),i=t.indexOf("</"+e);if(s===-1||i===-1)break;const o=t.indexOf(">",i);if(o===-1)break;n+=t.slice(s+1,i).trim(),t=t.slice(0,r).trim()+t.slice(o+1)}return{defs:n,content:t}}function Yc(t,e){return t?"<defs>"+t+"</defs>"+e:e}function eu(t,e,n){const r=Xc(t);return Yc(r.defs,e+r.content+n)}const tu=t=>t==="unset"||t==="undefined"||t==="none";function nu(t,e){const n={...Tr,...t},r={...ro,...e},s={left:n.left,top:n.top,width:n.width,height:n.height};let i=n.body;[n,r].forEach(x=>{const k=[],C=x.hFlip,w=x.vFlip;let T=x.rotate;C?w?T+=2:(k.push("translate("+(s.width+s.left).toString()+" "+(0-s.top).toString()+")"),k.push("scale(-1 1)"),s.top=s.left=0):w&&(k.push("translate("+(0-s.left).toString()+" "+(s.height+s.top).toString()+")"),k.push("scale(1 -1)"),s.top=s.left=0);let A;switch(T<0&&(T-=Math.floor(T/4)*4),T=T%4,T){case 1:A=s.height/2+s.top,k.unshift("rotate(90 "+A.toString()+" "+A.toString()+")");break;case 2:k.unshift("rotate(180 "+(s.width/2+s.left).toString()+" "+(s.height/2+s.top).toString()+")");break;case 3:A=s.width/2+s.left,k.unshift("rotate(-90 "+A.toString()+" "+A.toString()+")");break}T%2===1&&(s.left!==s.top&&(A=s.left,s.left=s.top,s.top=A),s.width!==s.height&&(A=s.width,s.width=s.height,s.height=A)),k.length&&(i=eu(i,'<g transform="'+k.join(" ")+'">',"</g>"))});const o=r.width,l=r.height,a=s.width,u=s.height;let d,f;o===null?(f=l===null?"1em":l==="auto"?u:l,d=Os(f,a/u)):(d=o==="auto"?a:o,f=l===null?Os(d,u/a):l==="auto"?u:l);const m={},h=(x,k)=>{tu(k)||(m[x]=k.toString())};h("width",d),h("height",f);const S=[s.left,s.top,a,u];return m.viewBox=S.join(" "),{attributes:m,viewBox:S,body:i}}const ru=/\sid="(\S+)"/g,su="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let iu=0;function ou(t,e=su){const n=[];let r;for(;r=ru.exec(t);)n.push(r[1]);if(!n.length)return t;const s="suffix"+(Math.random()*16777216|Date.now()).toString(16);return n.forEach(i=>{const o=typeof e=="function"?e(i):e+(iu++).toString(),l=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");t=t.replace(new RegExp('([#;"])('+l+')([")]|\\.[a-z])',"g"),"$1"+o+s+"$3")}),t=t.replace(new RegExp(s,"g"),""),t}const lr=Object.create(null);function lu(t,e){lr[t]=e}function ar(t){return lr[t]||lr[""]}function Er(t){let e;if(typeof t.resources=="string")e=[t.resources];else if(e=t.resources,!(e instanceof Array)||!e.length)return null;return{resources:e,path:t.path||"/",maxURL:t.maxURL||500,rotate:t.rotate||750,timeout:t.timeout||5e3,random:t.random===!0,index:t.index||0,dataAfterTimeout:t.dataAfterTimeout!==!1}}const Mr=Object.create(null),Nt=["https://api.simplesvg.com","https://api.unisvg.com"],en=[];for(;Nt.length>0;)Nt.length===1||Math.random()>.5?en.push(Nt.shift()):en.push(Nt.pop());Mr[""]=Er({resources:["https://api.iconify.design"].concat(en)});function au(t,e){const n=Er(e);return n===null?!1:(Mr[t]=n,!0)}function jr(t){return Mr[t]}const cu=()=>{let t;try{if(t=fetch,typeof t=="function")return t}catch{}};let Ds=cu();function uu(t,e){const n=jr(t);if(!n)return 0;let r;if(!n.maxURL)r=0;else{let s=0;n.resources.forEach(o=>{s=Math.max(s,o.length)});const i=e+".json?icons=";r=n.maxURL-s-n.path.length-i.length}return r}function du(t){return t===404}const fu=(t,e,n)=>{const r=[],s=uu(t,e),i="icons";let o={type:i,provider:t,prefix:e,icons:[]},l=0;return n.forEach((a,u)=>{l+=a.length+1,l>=s&&u>0&&(r.push(o),o={type:i,provider:t,prefix:e,icons:[]},l=a.length),o.icons.push(a)}),r.push(o),r};function hu(t){if(typeof t=="string"){const e=jr(t);if(e)return e.path}return"/"}const pu=(t,e,n)=>{if(!Ds){n("abort",424);return}let r=hu(e.provider);switch(e.type){case"icons":{const i=e.prefix,l=e.icons.join(","),a=new URLSearchParams({icons:l});r+=i+".json?"+a.toString();break}case"custom":{const i=e.uri;r+=i.slice(0,1)==="/"?i.slice(1):i;break}default:n("abort",400);return}let s=503;Ds(t+r).then(i=>{const o=i.status;if(o!==200){setTimeout(()=>{n(du(o)?"abort":"next",o)});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)})},mu={prepare:fu,send:pu};function so(t,e){t.forEach(n=>{const r=n.loaderCallbacks;r&&(n.loaderCallbacks=r.filter(s=>s.id!==e))})}function gu(t){t.pendingCallbacksFlag||(t.pendingCallbacksFlag=!0,setTimeout(()=>{t.pendingCallbacksFlag=!1;const e=t.loaderCallbacks?t.loaderCallbacks.slice(0):[];if(!e.length)return;let n=!1;const r=t.provider,s=t.prefix;e.forEach(i=>{const o=i.icons,l=o.pending.length;o.pending=o.pending.filter(a=>{if(a.prefix!==s)return!0;const u=a.name;if(t.icons[u])o.loaded.push({provider:r,prefix:s,name:u});else if(t.missing.has(u))o.missing.push({provider:r,prefix:s,name:u});else return n=!0,!0;return!1}),o.pending.length!==l&&(n||so([t],i.id),i.callback(o.loaded.slice(0),o.missing.slice(0),o.pending.slice(0),i.abort))})}))}let yu=0;function xu(t,e,n){const r=yu++,s=so.bind(null,n,r);if(!e.pending.length)return s;const i={id:r,icons:e,callback:t,abort:s};return n.forEach(o=>{(o.loaderCallbacks||(o.loaderCallbacks=[])).push(i)}),s}function bu(t){const e={loaded:[],missing:[],pending:[]},n=Object.create(null);t.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 t.forEach(s=>{if(r.name===s.name&&r.prefix===s.prefix&&r.provider===s.provider)return;r=s;const i=s.provider,o=s.prefix,l=s.name,a=n[i]||(n[i]=Object.create(null)),u=a[o]||(a[o]=Ct(i,o));let d;l in u.icons?d=e.loaded:o===""||u.missing.has(l)?d=e.missing:d=e.pending;const f={provider:i,prefix:o,name:l};d.push(f)}),e}function ku(t,e=!0,n=!1){const r=[];return t.forEach(s=>{const i=typeof s=="string"?vn(s,e,n):s;i&&r.push(i)}),r}const vu={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function Su(t,e,n,r){const s=t.resources.length,i=t.random?Math.floor(Math.random()*s):t.index;let o;if(t.random){let O=t.resources.slice(0);for(o=[];O.length>1;){const L=Math.floor(Math.random()*O.length);o.push(O[L]),O=O.slice(0,L).concat(O.slice(L+1))}o=o.concat(O)}else o=t.resources.slice(i).concat(t.resources.slice(0,i));const l=Date.now();let a="pending",u=0,d,f=null,m=[],h=[];typeof r=="function"&&h.push(r);function S(){f&&(clearTimeout(f),f=null)}function x(){a==="pending"&&(a="aborted"),S(),m.forEach(O=>{O.status==="pending"&&(O.status="aborted")}),m=[]}function k(O,L){L&&(h=[]),typeof O=="function"&&h.push(O)}function C(){return{startTime:l,payload:e,status:a,queriesSent:u,queriesPending:m.length,subscribe:k,abort:x}}function w(){a="failed",h.forEach(O=>{O(void 0,d)})}function T(){m.forEach(O=>{O.status==="pending"&&(O.status="aborted")}),m=[]}function A(O,L,_){const z=L!=="success";switch(m=m.filter(H=>H!==O),a){case"pending":break;case"failed":if(z||!t.dataAfterTimeout)return;break;default:return}if(L==="abort"){d=_,w();return}if(z){d=_,m.length||(o.length?N():w());return}if(S(),T(),!t.random){const H=t.resources.indexOf(O.resource);H!==-1&&H!==t.index&&(t.index=H)}a="completed",h.forEach(H=>{H(_)})}function N(){if(a!=="pending")return;S();const O=o.shift();if(O===void 0){if(m.length){f=setTimeout(()=>{S(),a==="pending"&&(T(),w())},t.timeout);return}w();return}const L={status:"pending",resource:O,callback:(_,z)=>{A(L,_,z)}};m.push(L),u++,f=setTimeout(N,t.rotate),n(O,e,L.callback)}return setTimeout(N),C}function io(t){const e={...vu,...t};let n=[];function r(){n=n.filter(l=>l().status==="pending")}function s(l,a,u){const d=Su(e,l,a,(f,m)=>{r(),u&&u(f,m)});return n.push(d),d}function i(l){return n.find(a=>l(a))||null}return{query:s,find:i,setIndex:l=>{e.index=l},getIndex:()=>e.index,cleanup:r}}function Ls(){}const Un=Object.create(null);function Cu(t){if(!Un[t]){const e=jr(t);if(!e)return;const n=io(e),r={config:e,redundancy:n};Un[t]=r}return Un[t]}function wu(t,e,n){let r,s;if(typeof t=="string"){const i=ar(t);if(!i)return n(void 0,424),Ls;s=i.send;const o=Cu(t);o&&(r=o.redundancy)}else{const i=Er(t);if(i){r=io(i);const o=t.resources?t.resources[0]:"",l=ar(o);l&&(s=l.send)}}return!r||!s?(n(void 0,424),Ls):r.query(e,s,n)().abort}function Rs(){}function Au(t){t.iconsLoaderFlag||(t.iconsLoaderFlag=!0,setTimeout(()=>{t.iconsLoaderFlag=!1,gu(t)}))}function Nu(t){const e=[],n=[];return t.forEach(r=>{(r.match(eo)?e:n).push(r)}),{valid:e,invalid:n}}function Tt(t,e,n){function r(){const s=t.pendingIcons;e.forEach(i=>{s&&s.delete(i),t.icons[i]||t.missing.add(i)})}if(n&&typeof n=="object")try{if(!Yi(t,n).length){r();return}}catch(s){console.error(s)}r(),Au(t)}function Fs(t,e){t instanceof Promise?t.then(n=>{e(n)}).catch(()=>{e(null)}):e(t)}function Tu(t,e){t.iconsToLoad?t.iconsToLoad=t.iconsToLoad.concat(e).sort():t.iconsToLoad=e,t.iconsQueueFlag||(t.iconsQueueFlag=!0,setTimeout(()=>{t.iconsQueueFlag=!1;const{provider:n,prefix:r}=t,s=t.iconsToLoad;if(delete t.iconsToLoad,!s||!s.length)return;const i=t.loadIcon;if(t.loadIcons&&(s.length>1||!i)){Fs(t.loadIcons(s,r,n),d=>{Tt(t,s,d)});return}if(i){s.forEach(d=>{const f=i(d,r,n);Fs(f,m=>{const h=m?{prefix:r,icons:{[d]:m}}:null;Tt(t,[d],h)})});return}const{valid:o,invalid:l}=Nu(s);if(l.length&&Tt(t,l,null),!o.length)return;const a=r.match(eo)?ar(n):null;if(!a){Tt(t,o,null);return}a.prepare(n,r,o).forEach(d=>{wu(n,d,f=>{Tt(t,d.icons,f)})})}))}const Eu=(t,e)=>{const n=ku(t,!0,to()),r=bu(n);if(!r.pending.length){let a=!0;return e&&setTimeout(()=>{a&&e(r.loaded,r.missing,r.pending,Rs)}),()=>{a=!1}}const s=Object.create(null),i=[];let o,l;return r.pending.forEach(a=>{const{provider:u,prefix:d}=a;if(d===l&&u===o)return;o=u,l=d,i.push(Ct(u,d));const f=s[u]||(s[u]=Object.create(null));f[d]||(f[d]=[])}),r.pending.forEach(a=>{const{provider:u,prefix:d,name:f}=a,m=Ct(u,d),h=m.pendingIcons||(m.pendingIcons=new Set);h.has(f)||(h.add(f),s[u][d].push(f))}),i.forEach(a=>{const u=s[a.provider][a.prefix];u.length&&Tu(a,u)}),e?xu(e,r,i):Rs};function Mu(t,e){const n={...t};for(const r in e){const s=e[r],i=typeof s;r in no?(s===null||s&&(i==="string"||i==="number"))&&(n[r]=s):i===typeof n[r]&&(n[r]=r==="rotate"?s%4:s)}return n}const ju=/[\s,]+/;function Iu(t,e){e.split(ju).forEach(n=>{switch(n.trim()){case"horizontal":t.hFlip=!0;break;case"vertical":t.vFlip=!0;break}})}function Ou(t,e=0){const n=t.replace(/^-?[0-9.]*/,"");function r(s){for(;s<0;)s+=4;return s%4}if(n===""){const s=parseInt(t);return isNaN(s)?0:r(s)}else if(n!==t){let s=0;switch(n){case"%":s=25;break;case"deg":s=90}if(s){let i=parseFloat(t.slice(0,t.length-n.length));return isNaN(i)?0:(i=i/s,i%1===0?r(i):0)}}return e}function Du(t,e){let n=t.indexOf("xlink:")===-1?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const r in e)n+=" "+r+'="'+e[r]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+n+">"+t+"</svg>"}function Lu(t){return t.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function Ru(t){return"data:image/svg+xml,"+Lu(t)}function Fu(t){return'url("'+Ru(t)+'")'}let Ot;function Pu(){try{Ot=window.trustedTypes.createPolicy("iconify",{createHTML:t=>t})}catch{Ot=null}}function $u(t){return Ot===void 0&&Pu(),Ot?Ot.createHTML(t):t}const oo={...ro,inline:!1},Vu={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},zu={display:"inline-block"},cr={backgroundColor:"currentColor"},lo={backgroundColor:"transparent"},Ps={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},$s={WebkitMask:cr,mask:cr,background:lo};for(const t in $s){const e=$s[t];for(const n in Ps)e[t+n]=Ps[n]}const Bu={...oo,inline:!0};function Vs(t){return t+(t.match(/^[-0-9.]+$/)?"px":"")}const _u=(t,e,n)=>{const r=e.inline?Bu:oo,s=Mu(r,e),i=e.mode||"svg",o={},l=e.style||{},a={...i==="svg"?Vu:{}};if(n){const k=vn(n,!1,!0);if(k){const C=["iconify"],w=["provider","prefix"];for(const T of w)k[T]&&C.push("iconify--"+k[T]);a.className=C.join(" ")}}for(let k in e){const C=e[k];if(C!==void 0)switch(k){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":a.ref=C;break;case"className":a[k]=(a[k]?a[k]+" ":"")+C;break;case"inline":case"hFlip":case"vFlip":s[k]=C===!0||C==="true"||C===1;break;case"flip":typeof C=="string"&&Iu(s,C);break;case"color":o.color=C;break;case"rotate":typeof C=="string"?s[k]=Ou(C):typeof C=="number"&&(s[k]=C);break;case"ariaHidden":case"aria-hidden":C!==!0&&C!=="true"&&delete a["aria-hidden"];break;default:r[k]===void 0&&(a[k]=C)}}const u=nu(t,s),d=u.attributes;if(s.inline&&(o.verticalAlign="-0.125em"),i==="svg"){a.style={...o,...l},Object.assign(a,d);let k=0,C=e.id;return typeof C=="string"&&(C=C.replace(/-/g,"_")),a.dangerouslySetInnerHTML={__html:$u(ou(u.body,C?()=>C+"ID"+k++:"iconifyReact"))},b.createElement("svg",a)}const{body:f,width:m,height:h}=t,S=i==="mask"||(i==="bg"?!1:f.indexOf("currentColor")!==-1),x=Du(f,{...d,width:m+"",height:h+""});return a.style={...o,"--svg":Fu(x),width:Vs(d.width),height:Vs(d.height),...zu,...S?cr:lo,...l},b.createElement("span",a)};to(!0);lu("",mu);if(typeof document<"u"&&typeof window<"u"){const t=window;if(t.IconifyPreload!==void 0){const e=t.IconifyPreload,n="Invalid IconifyPreload syntax.";typeof e=="object"&&e!==null&&(e instanceof Array?e:[e]).forEach(r=>{try{(typeof r!="object"||r===null||r instanceof Array||typeof r.icons!="object"||typeof r.prefix!="string"||!Gc(r))&&console.error(n)}catch{console.error(n)}})}if(t.IconifyProviders!==void 0){const e=t.IconifyProviders;if(typeof e=="object"&&e!==null)for(let n in e){const r="IconifyProviders["+n+"] is invalid.";try{const s=e[n];if(typeof s!="object"||!s||s.resources===void 0)continue;au(n,s)||console.error(r)}catch{console.error(r)}}}}function ao(t){const[e,n]=b.useState(!!t.ssr),[r,s]=b.useState({});function i(h){if(h){const S=t.icon;if(typeof S=="object")return{name:"",data:S};const x=Is(S);if(x)return{name:S,data:x}}return{name:""}}const[o,l]=b.useState(i(!!t.ssr));function a(){const h=r.callback;h&&(h(),s({}))}function u(h){if(JSON.stringify(o)!==JSON.stringify(h))return a(),l(h),!0}function d(){var h;const S=t.icon;if(typeof S=="object"){u({name:"",data:S});return}const x=Is(S);if(u({name:S,data:x}))if(x===void 0){const k=Eu([S],d);s({callback:k})}else x&&((h=t.onLoad)===null||h===void 0||h.call(t,S))}b.useEffect(()=>(n(!0),a),[]),b.useEffect(()=>{e&&d()},[t.icon,e]);const{name:f,data:m}=o;return m?_u({...Tr,...m},t,f):t.children?t.children:t.fallback?t.fallback:b.createElement("span",{})}const Ee=b.forwardRef((t,e)=>ao({...t,_ref:e}));b.forwardRef((t,e)=>ao({inline:!0,...t,_ref:e}));const qn=({icon:t,children:e,testId:n})=>c.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600","data-testid":n,children:[c.jsx(Ee,{icon:t,width:20,className:"text-default-500"}),c.jsx("span",{children:e})]}),Hu=({classes:t="",name:e,imageUrl:n,eventDate:r,eventTime:s,location:i,description:o,showImage:l=!1,showMoreButtonClassName:a,labels:u})=>{const[d,f]=b.useState(!1),[m,h]=b.useState(!1),S=b.useRef(null);return b.useEffect(()=>{const x=()=>{if(S.current){const k=S.current.scrollHeight>S.current.clientHeight;h(k)}};return x(),window.addEventListener("resize",x),()=>window.removeEventListener("resize",x)},[o]),c.jsxs(g.Card,{className:g.cn("border-0 shadow-none",t),"data-testid":"event-details-root",children:[c.jsxs(g.CardHeader,{className:"pt-2 pb-0 flex-col items-start space-y-2","data-testid":"event-details-header",children:[l&&n&&c.jsx("div",{className:"w-full aspect-[3/1] overflow-hidden rounded-xl","data-testid":"event-details-image-wrapper",children:c.jsx(g.Image,{alt:`Event image for ${e}`,className:"w-full h-full object-cover",src:n,"data-testid":"event-details-image"})}),c.jsx("h2",{className:"font-semibold text-xl text-gray-800","data-testid":"event-details-title",children:e})]}),c.jsxs(g.CardBody,{className:"py-3 space-y-3","data-testid":"event-details-body",children:[c.jsx("h3",{className:"font-semibold text-base text-gray-700","data-testid":"event-details-info-label",children:u.eventInformation}),c.jsxs("div",{className:"flex flex-wrap gap-4","data-testid":"event-details-info",children:[r&&c.jsx(qn,{icon:"solar:calendar-minimalistic-linear",testId:"event-details-date",children:r}),s&&c.jsx(qn,{icon:"solar:clock-circle-linear",testId:"event-details-time",children:s}),i&&c.jsx(qn,{icon:"solar:map-point-linear",testId:"event-details-location",children:i})]}),o&&c.jsxs("div",{className:"relative","data-testid":"event-details-description-wrapper",children:[c.jsxs("div",{className:"relative",children:[c.jsx("div",{ref:S,className:g.cn("text-sm text-gray-700 leading-relaxed transition-all",!d&&"line-clamp-3"),"data-testid":"event-details-description",dangerouslySetInnerHTML:{__html:o}}),!d&&m&&c.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||d)&&c.jsx("div",{className:"flex justify-end mt-1",children:c.jsx(se,{onPress:()=>f(!d),variant:"light",className:g.cn("text-primary",a),startContent:c.jsx(Ee,{icon:d?"solar:eye-closed-linear":"solar:eye-linear",width:20}),"data-testid":"event-details-toggle-description",children:d?u.showLess||"Hide":u.showMore||"Show"})})]})]})]})};function co(t,e="en-US",n="USD"){try{return new Intl.NumberFormat(e,{style:"currency",currency:n,minimumFractionDigits:2,maximumFractionDigits:2}).format(t)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${t.toFixed(2)}`}}function Uu(t){const e=t.replace(/[^\d.,-]/g,""),n=e.match(/,\d{1,2}$/);let r;n?r=e.replace(/\./g,"").replace(",","."):r=e.replace(/,/g,"");const s=parseFloat(r);return isNaN(s)?null:s}const qu={person:"Person",people:"People",tickets:"Tickets:",soldOut:"Sold Out",maxReached:"Maximum number of tickets allowed reached"},Gt=t=>typeof t=="number"&&!isNaN(t),Ir=({offer:t,quantity:e,defaultQuantity:n=0,onQuantityChange:r,currency:s="USD",locale:i="en-US",labels:o,slots:l,isDisabled:a=!1,buttonVariant:u="bordered",buttonColor:d="default",showCard:f=!0,showDescription:m=!0,showPeopleCount:h=!0,showPrice:S=!0,classNames:x={},"data-testid":k,selectedColor:C="default"})=>{const w={...qu,...o},[T,A]=b.useState(n),N=e!==void 0?e:T,O=ae=>{if(a)return;const ge=Math.max(0,N+ae);e===void 0&&A(ge),r?.(t.id,ge)},L=b.useMemo(()=>!Gt(t.totalTicketsSold)||!Gt(t.ticketsAllowed)?!1:t.totalTicketsSold>=t.ticketsAllowed,[t.totalTicketsSold,t.ticketsAllowed]),_=b.useMemo(()=>L||!Gt(t.ticketsAllowed)?!1:N>=t.ticketsAllowed-(t.totalTicketsSold??0),[L,t.ticketsAllowed,t.totalTicketsSold,N]),z=co(t.price,i,s),H=()=>l?.renderName?l.renderName(t.name,t):c.jsx("h2",{"data-testid":"offer-card-name",className:g.cn("text-base font-medium",x.name),children:t.name}),F=()=>S?l?.renderPrice?l.renderPrice(t.price,z,t):c.jsx("p",{"data-testid":"offer-card-price",className:g.cn("text-primary text-base mt-1",x.price),children:z}):null,j=()=>!m||!t.description?null:l?.renderDescription?l.renderDescription(t.description,t):c.jsx("p",{"data-testid":"offer-card-description",className:g.cn("mb-4 text-sm text-gray-700 leading-relaxed",x.description),children:t.description}),P=()=>{if(!h||!Gt(t.numberOfPeople)||t.numberOfPeople<=0)return null;const ae=t.numberOfPeople===1?w.person:w.people;return l?.renderPeopleCount?l.renderPeopleCount(t.numberOfPeople,ae,t):c.jsxs("p",{"data-testid":"offer-card-people-count",className:g.cn("text-sm text-gray-600 flex items-center mt-2",x.peopleCount),children:[c.jsx(Ee,{icon:t.numberOfPeople<=1?"solar:user-rounded-outline":"solar:users-group-rounded-outline",width:20,className:"mr-1"}),t.numberOfPeople," ",ae]})},$=()=>{const ae=N===0||a,ge=_||a;return l?.renderQuantitySelector?l.renderQuantitySelector({quantity:N,onIncrement:()=>O(1),onDecrement:()=>O(-1),isDecrementDisabled:ae,isIncrementDisabled:ge,isDisabled:a}):c.jsxs("div",{className:g.cn("flex items-center gap-2",x.quantitySelector),children:[c.jsx(se,{"data-testid":"offer-card-decrement-button",onPress:()=>O(-1),isDisabled:ae,variant:u,color:N>0?C:d,radius:"full",isIconOnly:!0,size:"sm","aria-label":"Decrease quantity",children:c.jsx(Ee,{icon:"gravity-ui:minus",width:16})}),c.jsx("span",{"data-testid":"offer-card-quantity",className:g.cn("min-w-[2rem] text-center font-medium"),children:N}),c.jsx(se,{"data-testid":"offer-card-increment-button",onPress:()=>O(1),isDisabled:ge,variant:u,color:N>0?C:d,radius:"full",isIconOnly:!0,size:"sm","aria-label":"Increase quantity",children:c.jsx(Ee,{icon:"gravity-ui:plus",width:16})})]})},J=()=>l?.renderSoldOut?l.renderSoldOut(w.soldOut):c.jsx(g.Chip,{"data-testid":"offer-card-sold-out-chip",color:"danger",className:g.cn("gap-2 px-4 h-8",x.soldOut),startContent:c.jsx(Ee,{icon:"gravity-ui:circle-info-fill",width:14}),children:c.jsx("span",{className:"font-medium text-sm",children:w.soldOut})}),oe=()=>l?.renderMaxReachedAlert?l.renderMaxReachedAlert(w.maxReached):c.jsx(g.Chip,{"data-testid":"offer-card-max-reached-chip",variant:"flat",color:"warning",classNames:{base:"gap-2 px-4 h-10",content:"text-black"},className:g.cn(" text-black! gap-2 px-4 h-10",x.maxReachedAlert),startContent:c.jsx(Ee,{icon:"gravity-ui:triangle-exclamation-fill",className:"text-black",width:16}),children:c.jsx("span",{className:"font-medium text-sm",children:w.maxReached})}),W=c.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-1 xl:grid-cols-3 lg:grid-cols-3 gap-2 items-start",children:[c.jsxs("div",{className:g.cn("h-full col-span-2",L?"opacity-50 pointer-events-none select-none":""),children:[H(),F(),c.jsxs("div",{className:g.cn("md:col-span-1 xl:col-span-2 lg:col-span-1 mb-2",L?"opacity-50 pointer-events-none select-none":""),children:[P(),j()]})]}),c.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:L?J():$()})]}),me=_&&!L&&c.jsx($e.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:oe()});return f?c.jsxs(g.Card,{className:g.cn("w-full",x.base),"data-testid":k||`offer-card-${t.id}`,children:[c.jsx(g.CardBody,{className:g.cn("pt-1 pb-0",x.body),children:W}),c.jsx($e.AnimatePresence,{children:me&&c.jsx(g.CardFooter,{className:g.cn("w-full mt-0 pt-0",x.footer),children:me})})]}):c.jsxs("div",{className:g.cn("w-full",x.base),"data-testid":k||`offer-card-${t.id}`,children:[c.jsx("div",{className:g.cn("pt-1 pb-0",x.body),children:W}),c.jsx($e.AnimatePresence,{children:me&&c.jsx("div",{className:g.cn("w-full mt-0 pt-0",x.footer),children:me})})]})};Ir.displayName="OfferCard";const uo=({message:t="No offers available.",icon:e="solar:ticket-sale-outline",iconSize:n=48,showCard:r=!0,classNames:s={},renderEmpty:i})=>{if(i){const l=i();return r?c.jsx(g.Card,{"data-testid":"offer-card-empty",className:g.cn("w-full",s.base),children:c.jsx(g.CardBody,{"data-testid":"offer-card-empty-body",children:l})}):c.jsx("div",{"data-testid":"offer-card-empty",className:g.cn("w-full",s.base),children:l})}const o=c.jsxs("div",{"data-testid":"offer-card-empty-content",className:g.cn("flex flex-col items-center justify-center p-8 text-center text-gray-500",s.content),children:[c.jsx(Ee,{"data-testid":"offer-card-empty-icon",icon:e,width:n,className:g.cn("mb-4",s.icon)}),c.jsx("h3",{"data-testid":"offer-card-empty-message",className:g.cn("text-lg",s.message),children:t})]});return r?c.jsx(g.Card,{"data-testid":"offer-card-empty",className:g.cn("w-full",s.base),children:c.jsx(g.CardBody,{"data-testid":"offer-card-empty-body",children:o})}):c.jsx("div",{"data-testid":"offer-card-empty",className:g.cn("w-full",s.base),children:o})};uo.displayName="OfferCardEmpty";const Ku={title:"Error Fetching Offers",description:"An error occurred while fetching offers."},fo=({error:t,labels:e,showCard:n=!0,color:r="danger",classNames:s={}})=>{const i={...Ku,...e},o=c.jsx(g.Alert,{"data-testid":"offer-card-error-alert",color:r,title:i.title,description:t||i.description,className:s.alert});return n?c.jsx(g.Card,{"data-testid":"offer-card-error",className:g.cn("w-full",s.base),children:c.jsx(g.CardBody,{"data-testid":"offer-card-error-body",children:o})}):c.jsx("div",{"data-testid":"offer-card-error",className:g.cn("w-full",s.base),children:o})};fo.displayName="OfferCardError";const Ju={1:"space-y-1",2:"space-y-2",3:"space-y-3",4:"space-y-4",5:"space-y-5",6:"space-y-6"},ho=({quantity:t=2,gap:e=4,classNames:n={}})=>{const r=Ju[e];return c.jsx("div",{"data-testid":"offer-card-skeleton-container",className:g.cn(r,n.base),children:Array.from({length:t}).map((s,i)=>c.jsxs(g.Card,{"data-testid":`offer-card-skeleton-${i}`,className:g.cn("w-full",n.card),children:[c.jsx(g.CardHeader,{"data-testid":`offer-card-skeleton-header-${i}`,className:"flex justify-between items-start pb-0",children:c.jsxs("div",{className:"space-y-2 w-full",children:[c.jsx(g.Skeleton,{"data-testid":`offer-card-skeleton-title-${i}`,className:"w-1/3 rounded-lg",children:c.jsx("div",{className:"h-4 bg-default-200 rounded-lg"})}),c.jsx(g.Skeleton,{"data-testid":`offer-card-skeleton-subtitle-${i}`,className:"w-1/4 rounded-lg",children:c.jsx("div",{className:"h-3 bg-default-300 rounded-lg"})})]})}),c.jsx(g.CardBody,{"data-testid":`offer-card-skeleton-body-${i}`,className:"pt-2 pb-0",children:c.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-2 items-start",children:[c.jsxs("div",{className:"xl:col-span-2 space-y-2",children:[c.jsx(g.Skeleton,{"data-testid":`offer-card-skeleton-people-${i}`,className:"w-1/4 rounded-lg",children:c.jsx("div",{className:"h-4 bg-default-300 rounded-lg"})}),c.jsx(g.Skeleton,{"data-testid":`offer-card-skeleton-description-${i}`,className:"w-3/4 rounded-lg",children:c.jsx("div",{className:"h-4 bg-default-200 rounded-lg"})})]}),c.jsx("div",{className:"flex items-start justify-end",children:c.jsxs("div",{"data-testid":`offer-card-skeleton-controls-${i}`,className:"flex items-center justify-end gap-2 w-full px-4 py-2",children:[c.jsx(g.Skeleton,{"data-testid":`offer-card-skeleton-label-${i}`,className:"w-24 h-4 rounded-md bg-default-200"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(g.Skeleton,{"data-testid":`offer-card-skeleton-btn-dec-${i}`,className:"w-8 h-8 rounded-md bg-default-300"}),c.jsx(g.Skeleton,{"data-testid":`offer-card-skeleton-btn-qty-${i}`,className:"w-8 h-8 rounded-md bg-default-200"}),c.jsx(g.Skeleton,{"data-testid":`offer-card-skeleton-btn-inc-${i}`,className:"w-8 h-8 rounded-md bg-default-300"})]})]})})]})})]},i))})};ho.displayName="OfferCardSkeleton";const po={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.15,delayChildren:.1}}},mo={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"}}},Wu={1:"gap-1",2:"gap-2",3:"gap-3",4:"gap-4",5:"gap-5",6:"gap-6"},go=({offers:t=[],selection:e,defaultSelection:n={},onSelectionChange:r,onQuantityChange:s,currency:i="USD",locale:o="en-US",labels:l,slots:a,isDisabled:u=!1,buttonVariant:d="bordered",buttonColor:f="default",showCard:m=!0,animated:h=!0,gap:S=2,classNames:x={}})=>{const[k,C]=b.useState(n),w=e!==void 0?e:k,T=b.useCallback((_,z)=>{const H={...w,[_]:Math.max(0,z)};e===void 0&&C(H),r?.(H),s?.(_,H[_])},[w,e,r,s]),A=[...t].sort((_,z)=>(_.position??0)-(z.position??0)),N=Wu[S],O=g.cn("grid mx-auto pt-2",N,x.base),L=_=>c.jsx(Ir,{offer:_,quantity:w[_.id]||0,onQuantityChange:T,currency:i,locale:o,labels:l,slots:a,isDisabled:u,buttonVariant:d,buttonColor:f,showCard:m,classNames:x.card},_.id);return h?c.jsx($e.motion.div,{"data-testid":"offer-card-list",className:O,variants:po,initial:"hidden",animate:"show",children:c.jsx($e.AnimatePresence,{children:A.map(_=>c.jsx($e.motion.div,{"data-testid":`offer-card-list-item-${_.id}`,className:x.cardWrapper,variants:mo,exit:{opacity:0,y:-20},transition:{duration:.3},children:L(_)},_.id))})}):c.jsx("div",{"data-testid":"offer-card-list",className:O,children:A.map(L)})};go.displayName="OfferCardList";var Ut=t=>t.type==="checkbox",ct=t=>t instanceof Date,we=t=>t==null;const yo=t=>typeof t=="object";var fe=t=>!we(t)&&!Array.isArray(t)&&yo(t)&&!ct(t),xo=t=>fe(t)&&t.target?Ut(t.target)?t.target.checked:t.target.value:t,Gu=t=>t.substring(0,t.search(/\.\d+(\.|$)/))||t,bo=(t,e)=>t.has(Gu(e)),Zu=t=>{const e=t.constructor&&t.constructor.prototype;return fe(e)&&e.hasOwnProperty("isPrototypeOf")},Or=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function ce(t){if(t instanceof Date)return new Date(t);const e=typeof FileList<"u"&&t instanceof FileList;if(Or&&(t instanceof Blob||e))return t;const n=Array.isArray(t);if(!n&&!(fe(t)&&Zu(t)))return t;const r=n?[]:Object.create(Object.getPrototypeOf(t));for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[s]=ce(t[s]));return r}var Sn=t=>/^\w*$/.test(t),re=t=>t===void 0,Dr=t=>Array.isArray(t)?t.filter(Boolean):[],Lr=t=>Dr(t.replace(/["|']|\]/g,"").split(/\.|\[/)),I=(t,e,n)=>{if(!e||!fe(t))return n;const r=(Sn(e)?[e]:Lr(e)).reduce((s,i)=>we(s)?s:s[i],t);return re(r)||r===t?re(t[e])?n:t[e]:r},Ne=t=>typeof t=="boolean",Ce=t=>typeof t=="function",te=(t,e,n)=>{let r=-1;const s=Sn(e)?[e]:Lr(e),i=s.length,o=i-1;for(;++r<i;){const l=s[r];let a=n;if(r!==o){const u=t[l];a=fe(u)||Array.isArray(u)?u:isNaN(+s[r+1])?{}:[]}if(l==="__proto__"||l==="constructor"||l==="prototype")return;t[l]=a,t=t[l]}};const hn={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},Fe={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"},ko=b.createContext(null);ko.displayName="HookFormControlContext";const Rr=()=>b.useContext(ko);var vo=(t,e,n,r=!0)=>{const s={defaultValues:e._defaultValues};for(const i in t)Object.defineProperty(s,i,{get:()=>{const o=i;return e._proxyFormState[o]!==Fe.all&&(e._proxyFormState[o]=!r||Fe.all),n&&(n[o]=!0),t[o]}});return s};const Fr=typeof window<"u"?b.useLayoutEffect:b.useEffect;function Qu(t){const e=Rr(),{control:n=e,disabled:r,name:s,exact:i}=t||{},[o,l]=b.useState(n._formState),a=b.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Fr(()=>n._subscribe({name:s,formState:a.current,exact:i,callback:u=>{!r&&l({...n._formState,...u})}}),[s,r,i]),b.useEffect(()=>{a.current.isValid&&n._setValid(!0)},[n]),b.useMemo(()=>vo(o,n,a.current,!1),[o,n])}var Me=t=>typeof t=="string",ur=(t,e,n,r,s)=>Me(t)?(r&&e.watch.add(t),I(n,t,s)):Array.isArray(t)?t.map(i=>(r&&e.watch.add(i),I(n,i))):(r&&(e.watchAll=!0),n),dr=t=>we(t)||!yo(t);function Pe(t,e,n=new WeakSet){if(dr(t)||dr(e))return Object.is(t,e);if(ct(t)&&ct(e))return Object.is(t.getTime(),e.getTime());const r=Object.keys(t),s=Object.keys(e);if(r.length!==s.length)return!1;if(n.has(t)||n.has(e))return!0;n.add(t),n.add(e);for(const i of r){const o=t[i];if(!s.includes(i))return!1;if(i!=="ref"){const l=e[i];if(ct(o)&&ct(l)||fe(o)&&fe(l)||Array.isArray(o)&&Array.isArray(l)?!Pe(o,l,n):!Object.is(o,l))return!1}}return!0}function Xu(t){const e=Rr(),{control:n=e,name:r,defaultValue:s,disabled:i,exact:o,compute:l}=t||{},a=b.useRef(s),u=b.useRef(l),d=b.useRef(void 0),f=b.useRef(n),m=b.useRef(r);u.current=l;const[h,S]=b.useState(()=>{const A=n._getWatch(r,a.current);return u.current?u.current(A):A}),x=b.useCallback(A=>{const N=ur(r,n._names,A||n._formValues,!1,a.current);return u.current?u.current(N):N},[n._formValues,n._names,r]),k=b.useCallback(A=>{if(!i){const N=ur(r,n._names,A||n._formValues,!1,a.current);if(u.current){const O=u.current(N);Pe(O,d.current)||(S(O),d.current=O)}else S(N)}},[n._formValues,n._names,i,r]);Fr(()=>((f.current!==n||!Pe(m.current,r))&&(f.current=n,m.current=r,k()),n._subscribe({name:r,formState:{values:!0},exact:o,callback:A=>{k(A.values)}})),[n,o,r,k]),b.useEffect(()=>n._removeUnmounted());const C=f.current!==n,w=m.current,T=b.useMemo(()=>{if(i)return null;const A=!C&&!Pe(w,r);return C||A?x():null},[i,C,r,w,x]);return T!==null?T:h}function Yu(t){const e=Rr(),{name:n,disabled:r,control:s=e,shouldUnregister:i,defaultValue:o,exact:l=!0}=t,a=bo(s._names.array,n),u=b.useMemo(()=>I(s._formValues,n,I(s._defaultValues,n,o)),[s,n,o]),d=Xu({control:s,name:n,defaultValue:u,exact:l}),f=Qu({control:s,name:n,exact:l}),m=b.useRef(t),h=b.useRef(void 0),S=b.useRef(s.register(n,{...t.rules,value:d,...Ne(t.disabled)?{disabled:t.disabled}:{}}));m.current=t;const x=b.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!I(f.errors,n)},isDirty:{enumerable:!0,get:()=>!!I(f.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!I(f.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!I(f.validatingFields,n)},error:{enumerable:!0,get:()=>I(f.errors,n)}}),[f,n]),k=b.useCallback(A=>S.current.onChange({target:{value:xo(A),name:n},type:hn.CHANGE}),[n]),C=b.useCallback(()=>S.current.onBlur({target:{value:I(s._formValues,n),name:n},type:hn.BLUR}),[n,s._formValues]),w=b.useCallback(A=>{const N=I(s._fields,n);N&&N._f&&A&&(N._f.ref={focus:()=>Ce(A.focus)&&A.focus(),select:()=>Ce(A.select)&&A.select(),setCustomValidity:O=>Ce(A.setCustomValidity)&&A.setCustomValidity(O),reportValidity:()=>Ce(A.reportValidity)&&A.reportValidity()})},[s._fields,n]),T=b.useMemo(()=>({name:n,value:d,...Ne(r)||f.disabled?{disabled:f.disabled||r}:{},onChange:k,onBlur:C,ref:w}),[n,r,f.disabled,k,C,w,d]);return b.useEffect(()=>{const A=s._options.shouldUnregister||i,N=h.current;N&&N!==n&&!a&&s.unregister(N),s.register(n,{...m.current.rules,...Ne(m.current.disabled)?{disabled:m.current.disabled}:{}});const O=(L,_)=>{const z=I(s._fields,L);z&&z._f&&(z._f.mount=_)};if(O(n,!0),A){const L=ce(I(s._options.defaultValues,n,m.current.defaultValue));te(s._defaultValues,n,L),re(I(s._formValues,n))&&te(s._formValues,n,L)}return!a&&s.register(n),h.current=n,()=>{(a?A&&!s._state.action:A)?s.unregister(n):O(n,!1)}},[n,s,a,i]),b.useEffect(()=>{s._setDisabledField({disabled:r,name:n})},[r,n,s]),b.useMemo(()=>({field:T,formState:f,fieldState:x}),[T,f,x])}const ed=b.createContext(null);ed.displayName="HookFormContext";var td=(t,e,n,r,s)=>e?{...n[t],types:{...n[t]&&n[t].types?n[t].types:{},[r]:s||!0}}:{},Dt=t=>Array.isArray(t)?t:[t],zs=()=>{let t=[];return{get observers(){return t},next:s=>{for(const i of t)i.next&&i.next(s)},subscribe:s=>(t.push(s),{unsubscribe:()=>{t=t.filter(i=>i!==s)}}),unsubscribe:()=>{t=[]}}};function So(t,e){const n={};for(const r in t)if(t.hasOwnProperty(r)){const s=t[r],i=e[r];if(s&&fe(s)&&i){const o=So(s,i);fe(o)&&(n[r]=o)}else t[r]&&(n[r]=i)}return n}var ve=t=>fe(t)&&!Object.keys(t).length,Pr=t=>t.type==="file",pn=t=>{if(!Or)return!1;const e=t?t.ownerDocument:0;return t instanceof(e&&e.defaultView?e.defaultView.HTMLElement:HTMLElement)},Co=t=>t.type==="select-multiple",$r=t=>t.type==="radio",nd=t=>$r(t)||Ut(t),Kn=t=>pn(t)&&t.isConnected;function rd(t,e){const n=e.slice(0,-1).length;let r=0;for(;r<n;)t=re(t)?r++:t[e[r++]];return t}function sd(t){for(const e in t)if(t.hasOwnProperty(e)&&!re(t[e]))return!1;return!0}function ue(t,e){const n=Array.isArray(e)?e:Sn(e)?[e]:Lr(e),r=n.length===1?t:rd(t,n),s=n.length-1,i=n[s];return r&&delete r[i],s!==0&&(fe(r)&&ve(r)||Array.isArray(r)&&sd(r))&&ue(t,n.slice(0,-1)),t}var id=t=>{for(const e in t)if(Ce(t[e]))return!0;return!1};function wo(t){return Array.isArray(t)||fe(t)&&!id(t)}function fr(t,e={}){for(const n in t){const r=t[n];wo(r)?(e[n]=Array.isArray(r)?[]:{},fr(r,e[n])):re(r)||(e[n]=!0)}return e}function kt(t,e,n){n||(n=fr(e));for(const r in t){const s=t[r];if(wo(s))re(e)||dr(n[r])?n[r]=fr(s,Array.isArray(s)?[]:{}):kt(s,we(e)?{}:e[r],n[r]);else{const i=e[r];n[r]=!Pe(s,i)}}return n}const Bs={value:!1,isValid:!1},_s={value:!0,isValid:!0};var Ao=t=>{if(Array.isArray(t)){if(t.length>1){const e=t.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:e,isValid:!!e.length}}return t[0].checked&&!t[0].disabled?t[0].attributes&&!re(t[0].attributes.value)?re(t[0].value)||t[0].value===""?_s:{value:t[0].value,isValid:!0}:_s:Bs}return Bs},No=(t,{valueAsNumber:e,valueAsDate:n,setValueAs:r})=>re(t)?t:e?t===""?NaN:t&&+t:n&&Me(t)?new Date(t):r?r(t):t;const Hs={isValid:!1,value:null};var To=t=>Array.isArray(t)?t.reduce((e,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:e,Hs):Hs;function Us(t){const e=t.ref;return Pr(e)?e.files:$r(e)?To(t.refs).value:Co(e)?[...e.selectedOptions].map(({value:n})=>n):Ut(e)?Ao(t.refs).value:No(re(e.value)?t.ref.value:e.value,t)}var od=(t,e,n,r)=>{const s={};for(const i of t){const o=I(e,i);o&&te(s,i,o._f)}return{criteriaMode:n,names:[...t],fields:s,shouldUseNativeValidation:r}},mn=t=>t instanceof RegExp,Et=t=>re(t)?t:mn(t)?t.source:fe(t)?mn(t.value)?t.value.source:t.value:t,qs=t=>({isOnSubmit:!t||t===Fe.onSubmit,isOnBlur:t===Fe.onBlur,isOnChange:t===Fe.onChange,isOnAll:t===Fe.all,isOnTouch:t===Fe.onTouched});const Ks="AsyncFunction";var ld=t=>!!t&&!!t.validate&&!!(Ce(t.validate)&&t.validate.constructor.name===Ks||fe(t.validate)&&Object.values(t.validate).find(e=>e.constructor.name===Ks)),ad=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate),Js=(t,e,n)=>!n&&(e.watchAll||e.watch.has(t)||[...e.watch].some(r=>t.startsWith(r)&&/^\.\w+/.test(t.slice(r.length))));const Lt=(t,e,n,r)=>{for(const s of n||Object.keys(t)){const i=I(t,s);if(i){const{_f:o,...l}=i;if(o){if(o.refs&&o.refs[0]&&e(o.refs[0],s)&&!r)return!0;if(o.ref&&e(o.ref,o.name)&&!r)return!0;if(Lt(l,e))break}else if(fe(l)&&Lt(l,e))break}}};function Ws(t,e,n){const r=I(t,n);if(r||Sn(n))return{error:r,name:n};const s=n.split(".");for(;s.length;){const i=s.join("."),o=I(e,i),l=I(t,i);if(o&&!Array.isArray(o)&&n!==i)return{name:n};if(l&&l.type)return{name:i,error:l};if(l&&l.root&&l.root.type)return{name:`${i}.root`,error:l.root};s.pop()}return{name:n}}var cd=(t,e,n,r)=>{n(t);const{name:s,...i}=t;return ve(i)||Object.keys(i).length>=Object.keys(e).length||Object.keys(i).find(o=>e[o]===(!r||Fe.all))},ud=(t,e,n)=>!t||!e||t===e||Dt(t).some(r=>r&&(n?r===e:r.startsWith(e)||e.startsWith(r))),dd=(t,e,n,r,s)=>s.isOnAll?!1:!n&&s.isOnTouch?!(e||t):(n?r.isOnBlur:s.isOnBlur)?!t:(n?r.isOnChange:s.isOnChange)?t:!0,fd=(t,e)=>!Dr(I(t,e)).length&&ue(t,e),hd=(t,e,n)=>{const r=Dt(I(t,n));return te(r,"root",e[n]),te(t,n,r),t};function Gs(t,e,n="validate"){if(Me(t)||Array.isArray(t)&&t.every(Me)||Ne(t)&&!t)return{type:n,message:Me(t)?t:"",ref:e}}var gt=t=>fe(t)&&!mn(t)?t:{value:t,message:""},Zs=async(t,e,n,r,s,i)=>{const{ref:o,refs:l,required:a,maxLength:u,minLength:d,min:f,max:m,pattern:h,validate:S,name:x,valueAsNumber:k,mount:C}=t._f,w=I(n,x);if(!C||e.has(x))return{};const T=l?l[0]:o,A=j=>{s&&T.reportValidity&&(T.setCustomValidity(Ne(j)?"":j||""),T.reportValidity())},N={},O=$r(o),L=Ut(o),_=O||L,z=(k||Pr(o))&&re(o.value)&&re(w)||pn(o)&&o.value===""||w===""||Array.isArray(w)&&!w.length,H=td.bind(null,x,r,N),F=(j,P,$,J=Ue.maxLength,oe=Ue.minLength)=>{const W=j?P:$;N[x]={type:j?J:oe,message:W,ref:o,...H(j?J:oe,W)}};if(i?!Array.isArray(w)||!w.length:a&&(!_&&(z||we(w))||Ne(w)&&!w||L&&!Ao(l).isValid||O&&!To(l).isValid)){const{value:j,message:P}=Me(a)?{value:!!a,message:a}:gt(a);if(j&&(N[x]={type:Ue.required,message:P,ref:T,...H(Ue.required,P)},!r))return A(P),N}if(!z&&(!we(f)||!we(m))){let j,P;const $=gt(m),J=gt(f);if(!we(w)&&!isNaN(w)){const oe=o.valueAsNumber||w&&+w;we($.value)||(j=oe>$.value),we(J.value)||(P=oe<J.value)}else{const oe=o.valueAsDate||new Date(w),W=ge=>new Date(new Date().toDateString()+" "+ge),me=o.type=="time",ae=o.type=="week";Me($.value)&&w&&(j=me?W(w)>W($.value):ae?w>$.value:oe>new Date($.value)),Me(J.value)&&w&&(P=me?W(w)<W(J.value):ae?w<J.value:oe<new Date(J.value))}if((j||P)&&(F(!!j,$.message,J.message,Ue.max,Ue.min),!r))return A(N[x].message),N}if((u||d)&&!z&&(Me(w)||i&&Array.isArray(w))){const j=gt(u),P=gt(d),$=!we(j.value)&&w.length>+j.value,J=!we(P.value)&&w.length<+P.value;if(($||J)&&(F($,j.message,P.message),!r))return A(N[x].message),N}if(h&&!z&&Me(w)){const{value:j,message:P}=gt(h);if(mn(j)&&!w.match(j)&&(N[x]={type:Ue.pattern,message:P,ref:o,...H(Ue.pattern,P)},!r))return A(P),N}if(S){if(Ce(S)){const j=await S(w,n),P=Gs(j,T);if(P&&(N[x]={...P,...H(Ue.validate,P.message)},!r))return A(P.message),N}else if(fe(S)){let j={};for(const P in S){if(!ve(j)&&!r)break;const $=Gs(await S[P](w,n),T,P);$&&(j={...$,...H(P,$.message)},A($.message),r&&(N[x]=j))}if(!ve(j)&&(N[x]={ref:T,...j},!r))return N}}return A(!0),N};const pd={mode:Fe.onSubmit,reValidateMode:Fe.onChange,shouldFocusError:!0};function md(t={}){let e={...pd,...t},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:Ce(e.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1},r={},s=fe(e.defaultValues)||fe(e.values)?ce(e.defaultValues||e.values)||{}:{},i=e.shouldUnregister?{}:ce(s),o={action:!1,mount:!1,watch:!1,keepIsValid:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},a,u=0;const d={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},f={...d};let m={...f};const h={array:zs(),state:zs()},S=e.criteriaMode===Fe.all,x=p=>y=>{clearTimeout(u),u=setTimeout(p,y)},k=async p=>{if(!o.keepIsValid&&!e.disabled&&(f.isValid||m.isValid||p)){let y;e.resolver?(y=ve((await _()).errors),C()):y=await H(r,!0),y!==n.isValid&&h.state.next({isValid:y})}},C=(p,y)=>{!e.disabled&&(f.isValidating||f.validatingFields||m.isValidating||m.validatingFields)&&((p||Array.from(l.mount)).forEach(v=>{v&&(y?te(n.validatingFields,v,y):ue(n.validatingFields,v))}),h.state.next({validatingFields:n.validatingFields,isValidating:!ve(n.validatingFields)}))},w=(p,y=[],v,D,M=!0,E=!0)=>{if(D&&v&&!e.disabled){if(o.action=!0,E&&Array.isArray(I(r,p))){const V=v(I(r,p),D.argA,D.argB);M&&te(r,p,V)}if(E&&Array.isArray(I(n.errors,p))){const V=v(I(n.errors,p),D.argA,D.argB);M&&te(n.errors,p,V),fd(n.errors,p)}if((f.touchedFields||m.touchedFields)&&E&&Array.isArray(I(n.touchedFields,p))){const V=v(I(n.touchedFields,p),D.argA,D.argB);M&&te(n.touchedFields,p,V)}(f.dirtyFields||m.dirtyFields)&&(n.dirtyFields=kt(s,i)),h.state.next({name:p,isDirty:j(p,y),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else te(i,p,y)},T=(p,y)=>{te(n.errors,p,y),h.state.next({errors:n.errors})},A=p=>{n.errors=p,h.state.next({errors:n.errors,isValid:!1})},N=(p,y,v,D)=>{const M=I(r,p);if(M){const E=I(i,p,re(v)?I(s,p):v);re(E)||D&&D.defaultChecked||y?te(i,p,y?E:Us(M._f)):J(p,E),o.mount&&!o.action&&k()}},O=(p,y,v,D,M)=>{let E=!1,V=!1;const G={name:p};if(!e.disabled){if(!v||D){(f.isDirty||m.isDirty)&&(V=n.isDirty,n.isDirty=G.isDirty=j(),E=V!==G.isDirty);const Z=Pe(I(s,p),y);V=!!I(n.dirtyFields,p),Z?ue(n.dirtyFields,p):te(n.dirtyFields,p,!0),G.dirtyFields=n.dirtyFields,E=E||(f.dirtyFields||m.dirtyFields)&&V!==!Z}if(v){const Z=I(n.touchedFields,p);Z||(te(n.touchedFields,p,v),G.touchedFields=n.touchedFields,E=E||(f.touchedFields||m.touchedFields)&&Z!==v)}E&&M&&h.state.next(G)}return E?G:{}},L=(p,y,v,D)=>{const M=I(n.errors,p),E=(f.isValid||m.isValid)&&Ne(y)&&n.isValid!==y;if(e.delayError&&v?(a=x(()=>T(p,v)),a(e.delayError)):(clearTimeout(u),a=null,v?te(n.errors,p,v):ue(n.errors,p)),(v?!Pe(M,v):M)||!ve(D)||E){const V={...D,...E&&Ne(y)?{isValid:y}:{},errors:n.errors,name:p};n={...n,...V},h.state.next(V)}},_=async p=>(C(p,!0),await e.resolver(i,e.context,od(p||l.mount,r,e.criteriaMode,e.shouldUseNativeValidation))),z=async p=>{const{errors:y}=await _(p);if(C(p),p)for(const v of p){const D=I(y,v);D?te(n.errors,v,D):ue(n.errors,v)}else n.errors=y;return y},H=async(p,y,v={valid:!0})=>{for(const D in p){const M=p[D];if(M){const{_f:E,...V}=M;if(E){const G=l.array.has(E.name),Z=M._f&&ld(M._f);Z&&f.validatingFields&&C([E.name],!0);const ke=await Zs(M,l.disabled,i,S,e.shouldUseNativeValidation&&!y,G);if(Z&&f.validatingFields&&C([E.name]),ke[E.name]&&(v.valid=!1,y||t.shouldUseNativeValidation))break;!y&&(I(ke,E.name)?G?hd(n.errors,ke,E.name):te(n.errors,E.name,ke[E.name]):ue(n.errors,E.name))}!ve(V)&&await H(V,y,v)}}return v.valid},F=()=>{for(const p of l.unMount){const y=I(r,p);y&&(y._f.refs?y._f.refs.every(v=>!Kn(v)):!Kn(y._f.ref))&&wn(p)}l.unMount=new Set},j=(p,y)=>!e.disabled&&(p&&y&&te(i,p,y),!Pe(Le(),s)),P=(p,y,v)=>ur(p,l,{...o.mount?i:re(y)?s:Me(p)?{[p]:y}:y},v,y),$=p=>Dr(I(o.mount?i:s,p,e.shouldUnregister?I(s,p,[]):[])),J=(p,y,v={})=>{const D=I(r,p);let M=y;if(D){const E=D._f;E&&(!E.disabled&&te(i,p,No(y,E)),M=pn(E.ref)&&we(y)?"":y,Co(E.ref)?[...E.ref.options].forEach(V=>V.selected=M.includes(V.value)):E.refs?Ut(E.ref)?E.refs.forEach(V=>{(!V.defaultChecked||!V.disabled)&&(Array.isArray(M)?V.checked=!!M.find(G=>G===V.value):V.checked=M===V.value||!!M)}):E.refs.forEach(V=>V.checked=V.value===M):Pr(E.ref)?E.ref.value="":(E.ref.value=M,E.ref.type||h.state.next({name:p,values:ce(i)})))}(v.shouldDirty||v.shouldTouch)&&O(p,M,v.shouldTouch,v.shouldDirty,!0),v.shouldValidate&&ge(p)},oe=(p,y,v)=>{for(const D in y){if(!y.hasOwnProperty(D))return;const M=y[D],E=p+"."+D,V=I(r,E);(l.array.has(p)||fe(M)||V&&!V._f)&&!ct(M)?oe(E,M,v):J(E,M,v)}},W=(p,y,v={})=>{const D=I(r,p),M=l.array.has(p),E=ce(y);te(i,p,E),M?(h.array.next({name:p,values:ce(i)}),(f.isDirty||f.dirtyFields||m.isDirty||m.dirtyFields)&&v.shouldDirty&&h.state.next({name:p,dirtyFields:kt(s,i),isDirty:j(p,E)})):D&&!D._f&&!we(E)?oe(p,E,v):J(p,E,v),Js(p,l)?h.state.next({...n,name:p,values:ce(i)}):h.state.next({name:o.mount?p:void 0,values:ce(i)})},me=async p=>{o.mount=!0;const y=p.target;let v=y.name,D=!0;const M=I(r,v),E=Z=>{D=Number.isNaN(Z)||ct(Z)&&isNaN(Z.getTime())||Pe(Z,I(i,v,Z))},V=qs(e.mode),G=qs(e.reValidateMode);if(M){let Z,ke;const nt=y.type?Us(M._f):xo(p),We=p.type===hn.BLUR||p.type===hn.FOCUS_OUT,Vo=!ad(M._f)&&!e.resolver&&!I(n.errors,v)&&!M._f.deps||dd(We,I(n.touchedFields,v),n.isSubmitted,G,V),Tn=Js(v,l,We);te(i,v,nt),We?(!y||!y.readOnly)&&(M._f.onBlur&&M._f.onBlur(p),a&&a(0)):M._f.onChange&&M._f.onChange(p);const En=O(v,nt,We),zo=!ve(En)||Tn;if(!We&&h.state.next({name:v,type:p.type,values:ce(i)}),Vo)return(f.isValid||m.isValid)&&(e.mode==="onBlur"?We&&k():We||k()),zo&&h.state.next({name:v,...Tn?{}:En});if(!We&&Tn&&h.state.next({...n}),e.resolver){const{errors:Kr}=await _([v]);if(C([v]),E(nt),D){const Bo=Ws(n.errors,r,v),Jr=Ws(Kr,r,Bo.name||v);Z=Jr.error,v=Jr.name,ke=ve(Kr)}}else C([v],!0),Z=(await Zs(M,l.disabled,i,S,e.shouldUseNativeValidation))[v],C([v]),E(nt),D&&(Z?ke=!1:(f.isValid||m.isValid)&&(ke=await H(r,!0)));D&&(M._f.deps&&(!Array.isArray(M._f.deps)||M._f.deps.length>0)&&ge(M._f.deps),L(v,ke,Z,En))}},ae=(p,y)=>{if(I(n.errors,y)&&p.focus)return p.focus(),1},ge=async(p,y={})=>{let v,D;const M=Dt(p);if(e.resolver){const E=await z(re(p)?p:M);v=ve(E),D=p?!M.some(V=>I(E,V)):v}else p?(D=(await Promise.all(M.map(async E=>{const V=I(r,E);return await H(V&&V._f?{[E]:V}:V)}))).every(Boolean),!(!D&&!n.isValid)&&k()):D=v=await H(r);return h.state.next({...!Me(p)||(f.isValid||m.isValid)&&v!==n.isValid?{}:{name:p},...e.resolver||!p?{isValid:v}:{},errors:n.errors}),y.shouldFocus&&!D&&Lt(r,ae,p?M:l.mount),D},Le=(p,y)=>{let v={...o.mount?i:s};return y&&(v=So(y.dirtyFields?n.dirtyFields:n.touchedFields,v)),re(p)?v:Me(p)?I(v,p):p.map(D=>I(v,D))},Y=(p,y)=>({invalid:!!I((y||n).errors,p),isDirty:!!I((y||n).dirtyFields,p),error:I((y||n).errors,p),isValidating:!!I(n.validatingFields,p),isTouched:!!I((y||n).touchedFields,p)}),Ie=p=>{p&&Dt(p).forEach(y=>ue(n.errors,y)),h.state.next({errors:p?n.errors:{}})},ee=(p,y,v)=>{const D=(I(r,p,{_f:{}})._f||{}).ref,M=I(n.errors,p)||{},{ref:E,message:V,type:G,...Z}=M;te(n.errors,p,{...Z,...y,ref:D}),h.state.next({name:p,errors:n.errors,isValid:!1}),v&&v.shouldFocus&&D&&D.focus&&D.focus()},Ae=(p,y)=>Ce(p)?h.state.subscribe({next:v=>"values"in v&&p(P(void 0,y),v)}):P(p,y,!0),wt=p=>h.state.subscribe({next:y=>{ud(p.name,y.name,p.exact)&&cd(y,p.formState||f,$o,p.reRenderRoot)&&p.callback({values:{...i},...n,...y,defaultValues:s})}}).unsubscribe,Cn=p=>(o.mount=!0,m={...m,...p.formState},wt({...p,formState:{...d,...p.formState}})),wn=(p,y={})=>{for(const v of p?Dt(p):l.mount)l.mount.delete(v),l.array.delete(v),y.keepValue||(ue(r,v),ue(i,v)),!y.keepError&&ue(n.errors,v),!y.keepDirty&&ue(n.dirtyFields,v),!y.keepTouched&&ue(n.touchedFields,v),!y.keepIsValidating&&ue(n.validatingFields,v),!e.shouldUnregister&&!y.keepDefaultValue&&ue(s,v);h.state.next({values:ce(i)}),h.state.next({...n,...y.keepDirty?{isDirty:j()}:{}}),!y.keepIsValid&&k()},Br=({disabled:p,name:y})=>{if(Ne(p)&&o.mount||p||l.disabled.has(y)){const M=l.disabled.has(y)!==!!p;p?l.disabled.add(y):l.disabled.delete(y),M&&o.mount&&!o.action&&k()}},An=(p,y={})=>{let v=I(r,p);const D=Ne(y.disabled)||Ne(e.disabled);return te(r,p,{...v||{},_f:{...v&&v._f?v._f:{ref:{name:p}},name:p,mount:!0,...y}}),l.mount.add(p),v?Br({disabled:Ne(y.disabled)?y.disabled:e.disabled,name:p}):N(p,!0,y.value),{...D?{disabled:y.disabled||e.disabled}:{},...e.progressive?{required:!!y.required,min:Et(y.min),max:Et(y.max),minLength:Et(y.minLength),maxLength:Et(y.maxLength),pattern:Et(y.pattern)}:{},name:p,onChange:me,onBlur:me,ref:M=>{if(M){An(p,y),v=I(r,p);const E=re(M.value)&&M.querySelectorAll&&M.querySelectorAll("input,select,textarea")[0]||M,V=nd(E),G=v._f.refs||[];if(V?G.find(Z=>Z===E):E===v._f.ref)return;te(r,p,{_f:{...v._f,...V?{refs:[...G.filter(Kn),E,...Array.isArray(I(s,p))?[{}]:[]],ref:{type:E.type,name:p}}:{ref:E}}}),N(p,!1,void 0,E)}else v=I(r,p,{}),v._f&&(v._f.mount=!1),(e.shouldUnregister||y.shouldUnregister)&&!(bo(l.array,p)&&o.action)&&l.unMount.add(p)}}},Nn=()=>e.shouldFocusError&&Lt(r,ae,l.mount),Ro=p=>{Ne(p)&&(h.state.next({disabled:p}),Lt(r,(y,v)=>{const D=I(r,v);D&&(y.disabled=D._f.disabled||p,Array.isArray(D._f.refs)&&D._f.refs.forEach(M=>{M.disabled=D._f.disabled||p}))},0,!1))},_r=(p,y)=>async v=>{let D;v&&(v.preventDefault&&v.preventDefault(),v.persist&&v.persist());let M=ce(i);if(h.state.next({isSubmitting:!0}),e.resolver){const{errors:E,values:V}=await _();C(),n.errors=E,M=ce(V)}else await H(r);if(l.disabled.size)for(const E of l.disabled)ue(M,E);if(ue(n.errors,"root"),ve(n.errors)){h.state.next({errors:{}});try{await p(M,v)}catch(E){D=E}}else y&&await y({...n.errors},v),Nn(),setTimeout(Nn);if(h.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:ve(n.errors)&&!D,submitCount:n.submitCount+1,errors:n.errors}),D)throw D},Fo=(p,y={})=>{I(r,p)&&(re(y.defaultValue)?W(p,ce(I(s,p))):(W(p,y.defaultValue),te(s,p,ce(y.defaultValue))),y.keepTouched||ue(n.touchedFields,p),y.keepDirty||(ue(n.dirtyFields,p),n.isDirty=y.defaultValue?j(p,ce(I(s,p))):j()),y.keepError||(ue(n.errors,p),f.isValid&&k()),h.state.next({...n}))},Hr=(p,y={})=>{const v=p?ce(p):s,D=ce(v),M=ve(p),E=M?s:D;if(y.keepDefaultValues||(s=v),!y.keepValues){if(y.keepDirtyValues){const V=new Set([...l.mount,...Object.keys(kt(s,i))]);for(const G of Array.from(V)){const Z=I(n.dirtyFields,G),ke=I(i,G),nt=I(E,G);Z&&!re(ke)?te(E,G,ke):!Z&&!re(nt)&&W(G,nt)}}else{if(Or&&re(p))for(const V of l.mount){const G=I(r,V);if(G&&G._f){const Z=Array.isArray(G._f.refs)?G._f.refs[0]:G._f.ref;if(pn(Z)){const ke=Z.closest("form");if(ke){ke.reset();break}}}}if(y.keepFieldsRef)for(const V of l.mount)W(V,I(E,V));else r={}}i=e.shouldUnregister?y.keepDefaultValues?ce(s):{}:ce(E),h.array.next({values:{...E}}),h.state.next({values:{...E}})}l={mount:y.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!f.isValid||!!y.keepIsValid||!!y.keepDirtyValues||!e.shouldUnregister&&!ve(E),o.watch=!!e.shouldUnregister,o.keepIsValid=!!y.keepIsValid,o.action=!1,y.keepErrors||(n.errors={}),h.state.next({submitCount:y.keepSubmitCount?n.submitCount:0,isDirty:M?!1:y.keepDirty?n.isDirty:!!(y.keepDefaultValues&&!Pe(p,s)),isSubmitted:y.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:M?{}:y.keepDirtyValues?y.keepDefaultValues&&i?kt(s,i):n.dirtyFields:y.keepDefaultValues&&p?kt(s,p):y.keepDirty?n.dirtyFields:{},touchedFields:y.keepTouched?n.touchedFields:{},errors:y.keepErrors?n.errors:{},isSubmitSuccessful:y.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:s})},Ur=(p,y)=>Hr(Ce(p)?p(i):p,{...e.resetOptions,...y}),Po=(p,y={})=>{const v=I(r,p),D=v&&v._f;if(D){const M=D.refs?D.refs[0]:D.ref;M.focus&&setTimeout(()=>{M.focus(),y.shouldSelect&&Ce(M.select)&&M.select()})}},$o=p=>{n={...n,...p}},qr={control:{register:An,unregister:wn,getFieldState:Y,handleSubmit:_r,setError:ee,_subscribe:wt,_runSchema:_,_updateIsValidating:C,_focusError:Nn,_getWatch:P,_getDirty:j,_setValid:k,_setFieldArray:w,_setDisabledField:Br,_setErrors:A,_getFieldArray:$,_reset:Hr,_resetDefaultValues:()=>Ce(e.defaultValues)&&e.defaultValues().then(p=>{Ur(p,e.resetOptions),h.state.next({isLoading:!1})}),_removeUnmounted:F,_disableForm:Ro,_subjects:h,_proxyFormState:f,get _fields(){return r},get _formValues(){return i},get _state(){return o},set _state(p){o=p},get _defaultValues(){return s},get _names(){return l},set _names(p){l=p},get _formState(){return n},get _options(){return e},set _options(p){e={...e,...p}}},subscribe:Cn,trigger:ge,register:An,handleSubmit:_r,watch:Ae,setValue:W,getValues:Le,reset:Ur,resetField:Fo,clearErrors:Ie,unregister:wn,setError:ee,setFocus:Po,getFieldState:Y};return{...qr,formControl:qr}}function gd(t={}){const e=b.useRef(void 0),n=b.useRef(void 0),[r,s]=b.useState({isDirty:!1,isValidating:!1,isLoading:Ce(t.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1,isReady:!1,defaultValues:Ce(t.defaultValues)?void 0:t.defaultValues});if(!e.current)if(t.formControl)e.current={...t.formControl,formState:r},t.defaultValues&&!Ce(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:o,...l}=md(t);e.current={...l,formState:r}}const i=e.current.control;return i._options=t,Fr(()=>{const o=i._subscribe({formState:i._proxyFormState,callback:()=>s({...i._formState}),reRenderRoot:!0});return s(l=>({...l,isReady:!0})),i._formState.isReady=!0,o},[i]),b.useEffect(()=>i._disableForm(t.disabled),[i,t.disabled]),b.useEffect(()=>{t.mode&&(i._options.mode=t.mode),t.reValidateMode&&(i._options.reValidateMode=t.reValidateMode)},[i,t.mode,t.reValidateMode]),b.useEffect(()=>{t.errors&&(i._setErrors(t.errors),i._focusError())},[i,t.errors]),b.useEffect(()=>{t.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,t.shouldUnregister]),b.useEffect(()=>{if(i._proxyFormState.isDirty){const o=i._getDirty();o!==r.isDirty&&i._subjects.state.next({isDirty:o})}},[i,r.isDirty]),b.useEffect(()=>{var o;t.values&&!Pe(t.values,n.current)?(i._reset(t.values,{keepFieldsRef:!0,...i._options.resetOptions}),!((o=i._options.resetOptions)===null||o===void 0)&&o.keepIsValid||i._setValid(),n.current=t.values,s(l=>({...l}))):i._resetDefaultValues()},[i,t.values]),b.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()}),e.current.formState=b.useMemo(()=>vo(r,i),[i,r]),e.current}function yd(t,e=3){return t%1===0?t.toString():t.toFixed(e).replace(/\.?0+$/,"")}function xd(t,e="en-US",n="USD"){try{return new Intl.NumberFormat(e,{style:"currency",currency:n,minimumFractionDigits:2,maximumFractionDigits:2}).format(t)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${t.toFixed(2)}`}}function bd(t="USD",e="en-US"){try{return new Intl.NumberFormat(e,{style:"currency",currency:t}).formatToParts(0).find(i=>i.type==="currency")?.value??"$"}catch{return"$"}}function kd(t){const e=t.replace(/[^\d.,-]/g,""),n=e.match(/,\d{1,2}$/);let r;n?r=e.replace(/\./g,"").replace(",","."):r=e.replace(/,/g,"");const s=parseFloat(r);return isNaN(s)?null:s}function vd(t,e,n=.001){const r=t-e,s=Math.abs(r)<=n;return{difference:r,isBalanced:s,isUnderAllocated:!s&&r>0,isOverAllocated:!s&&r<0}}function Vr(){return`dist-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}Vr();const Sd={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:"$"},Jn=()=>({id:Vr(),amount:0,glAccount:null,isTaxDeductible:!1}),Eo=({distribution:t,defaultDistribution:e,glAccounts:n=[],isLoadingGlAccounts:r=!1,onSearchGlAccounts:s,onDistributionChange:i,onAmountChange:o,onGlAccountChange:l,onTaxDeductibleChange:a,onDelete:u,canDelete:d=!0,canEditTaxDeductible:f=!0,isDisabled:m=!1,labels:h,classNames:S={},"data-testid":x,control:k,name:C,rules:w})=>{const T={...Sd,...h},A=k!==void 0&&C!==void 0,N=gd({defaultValues:{_internal:e||Jn()}}),O=Yu({control:A?k:N.control,name:A?C:"_internal",rules:A?w:void 0}),[L,_]=b.useState(e||Jn()),z=A?O.field.value??Jn():t??L,H=A&&!!O.fieldState?.error,F=A&&(O.fieldState?.isTouched??!1),j=H||F,P=j&&(!z.amount||z.amount<=0),$=j&&!z.glAccount,[J,oe]=b.useState(z.glAccount?.name||""),W=b.useCallback(ee=>{const Ae={...z,...ee};A&&O.field.onChange(Ae),!A&&t===void 0&&_(Ae),i?.(Ae)},[z,t,i,A,O]),me=b.useCallback(ee=>{const Ae=ee||0;W({amount:Ae}),o?.(Ae)},[W,o]),ae=b.useCallback(ee=>{oe(ee),s?.(ee)},[s]),ge=b.useCallback(ee=>{if(ee===null){W({glAccount:null}),l?.(null);return}const wt=n.find(Cn=>String(Cn.id)===String(ee))||null;W({glAccount:wt}),l?.(wt)},[n,W,l]),Le=b.useCallback(()=>{oe(""),W({glAccount:null}),l?.(null)},[W,l]),Y=b.useCallback(ee=>{W({isTaxDeductible:ee}),a?.(ee)},[W,a]),Ie=b.useCallback(()=>{u?.()},[u]);return c.jsx(g.Card,{radius:"md",shadow:"sm","data-testid":x||"revenue-distribution-card",className:g.cn(S.base),children:c.jsxs(g.CardBody,{className:g.cn("flex flex-row flex-nowrap items-start gap-4",S.body),children:[c.jsx("div",{className:g.cn("shrink-0",S.amountContainer),children:c.jsx(g.NumberInput,{"data-testid":`${x||"revenue-distribution-card"}-amount-input`,label:c.jsxs("span",{className:"flex items-center gap-1",children:[T.amount,c.jsx(g.Tooltip,{content:T.amountTooltip,children:c.jsx(Ee,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),value:z.amount||void 0,onValueChange:me,labelPlacement:"outside",placeholder:T.amountPlaceholder,isWheelDisabled:!0,hideStepper:!0,variant:"bordered",isDisabled:m,isInvalid:P,errorMessage:P?"Amount is required":void 0,minValue:0,step:.01,className:S.amountInput,startContent:c.jsx("div",{className:"pointer-events-none flex items-center",children:c.jsx("span",{className:"text-default-400 text-small",children:T.currencySymbol})})})}),c.jsx("div",{className:g.cn("grow",S.glAccountContainer),children:c.jsx(g.Autocomplete,{"data-testid":`${x||"revenue-distribution-card"}-gl-account-input`,label:c.jsxs("span",{className:"flex items-center gap-1",children:[T.glAccount,c.jsx(g.Tooltip,{content:T.glAccountTooltip,children:c.jsx(Ee,{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:z.glAccount?.name??J,selectedKey:z.glAccount?.id??null,isDisabled:m,isInvalid:$,errorMessage:$?"GL Account is required":void 0,listboxProps:{emptyContent:r?T.searching:T.noGlAccountsFound},placeholder:T.glAccountPlaceholder,onInputChange:ae,onSelectionChange:ge,onClear:Le,className:S.glAccountInput,children:ee=>c.jsx(g.AutocompleteItem,{textValue:ee.name,children:c.jsxs("div",{className:"flex flex-col",children:[c.jsx("span",{children:ee.name}),ee.code&&c.jsx("span",{className:"text-xs text-default-400",children:ee.code})]})},ee.id)})}),c.jsx("div",{className:g.cn("shrink-0 pt-6 flex items-center",S.taxDeductibleContainer),children:c.jsx(g.Checkbox,{radius:"full","data-testid":`${x||"revenue-distribution-card"}-tax-deductible`,isSelected:z.isTaxDeductible,onValueChange:Y,isDisabled:m||!f,className:S.taxDeductibleCheckbox,children:T.taxDeductible})}),c.jsx("div",{className:g.cn("shrink-0 pt-6",S.deleteContainer),children:c.jsx(se,{"data-testid":`${x||"revenue-distribution-card"}-delete-button`,size:"sm",color:"danger",variant:"flat",isDisabled:m||!d,onPress:Ie,startContent:c.jsx(Ee,{icon:"solar:trash-bin-trash-linear",width:16}),className:g.cn("text-danger",S.deleteButton),children:T.deleteButton})})]})})};Eo.displayName="RevenueDistributionCard";const Mo=({message:t="No distributions configured",icon:e="solar:document-text-outline",iconSize:n=48,showCard:r=!0,classNames:s={},renderEmpty:i})=>{if(i)return c.jsx(c.Fragment,{children:i()});const o=c.jsxs("div",{className:g.cn("flex flex-col items-center justify-center py-8",s.content),children:[c.jsx(Ee,{icon:e,width:n,className:g.cn("text-default-300 mb-4",s.icon)}),c.jsx("p",{className:g.cn("text-default-500 text-sm text-center",s.message),children:t})]});return r?c.jsx(g.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-empty",className:g.cn("w-full",s.base),children:c.jsx(g.CardBody,{children:o})}):c.jsx("div",{"data-testid":"revenue-distribution-empty",className:g.cn("w-full",s.base),children:o})};Mo.displayName="RevenueDistributionEmpty";const Cd={title:"Error Loading Distributions",description:"An error occurred while loading the distribution configuration. Please try again."},jo=({error:t,labels:e,showCard:n=!0,color:r="danger",classNames:s={}})=>{const i={...Cd,...e},o=c.jsx(g.Alert,{"data-testid":"revenue-distribution-error-alert",color:r,title:i.title,description:t||i.description,className:s.alert});return n?c.jsx(g.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-error",className:g.cn("w-full",s.base),children:c.jsx(g.CardBody,{children:o})}):c.jsx("div",{"data-testid":"revenue-distribution-error",className:g.cn("w-full",s.base),children:o})};jo.displayName="RevenueDistributionError";const Io=({rows:t=1,showCard:e=!0,classNames:n={}})=>{const r=Array.from({length:t},(i,o)=>o),s=i=>c.jsxs("div",{className:g.cn("flex flex-row flex-nowrap items-end gap-4",n.row),children:[c.jsxs("div",{className:"shrink-0 flex flex-col gap-1",children:[c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(g.Skeleton,{className:"h-4 w-14 rounded-md"}),c.jsx(g.Skeleton,{className:"h-4 w-4 rounded-full"})]}),c.jsx(g.Skeleton,{className:"h-10 w-32 rounded-lg"})]}),c.jsxs("div",{className:"grow flex flex-col gap-1",children:[c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(g.Skeleton,{className:"h-4 w-20 rounded-md"}),c.jsx(g.Skeleton,{className:"h-4 w-4 rounded-full"})]}),c.jsx(g.Skeleton,{className:"h-10 w-full rounded-lg"})]}),c.jsxs("div",{className:"shrink-0 pb-2 flex items-center gap-2",children:[c.jsx(g.Skeleton,{className:"h-5 w-5 rounded-full"}),c.jsx(g.Skeleton,{className:"h-4 w-24 rounded-md"})]}),c.jsx("div",{className:"shrink-0 pb-2",children:c.jsx(g.Skeleton,{className:"h-8 w-20 rounded-lg"})})]},i);return e?c.jsx("div",{className:g.cn("flex flex-col gap-3",n.base),children:r.map(i=>c.jsx(g.Card,{radius:"md",shadow:"sm","data-testid":`revenue-distribution-skeleton-${i}`,children:c.jsx(g.CardBody,{children:s(i)})},i))}):c.jsx("div",{"data-testid":"revenue-distribution-skeleton",className:g.cn("flex flex-col gap-3",n.base),children:r.map(i=>s(i))})};Io.displayName="RevenueDistributionSkeleton";const wd={title:"Select Membership",renewalTitle:"Automatic Renewal",renewalDescription:"Membership will automatically renew at the end of each period"},Ad=({cards:t,locale:e,currency:n,listHeightClassName:r="",labels:s,showRenewal:i=!0,defaultRenewalValue:o=!1,onRenewalChange:l,onCardSelect:a,className:u=""})=>{const d=Array.isArray(t)?t:[],[f,m]=b.useState(null),[h,S]=b.useState(o),x={...wd,...s},k=w=>{w!==f&&(m(w),a?.(w))},C=w=>{S(w),l?.(w)};return c.jsxs("div",{className:g.cn("w-full flex flex-col gap-4 items-start p-4 h-svh",u),"data-testid":"membership-select-cards",children:[c.jsx("p",{className:"text-2xl font-semibold text-left","data-testid":"membership-select-cards-title",children:x.title}),i&&c.jsx(Do,{title:x.renewalTitle,description:x.renewalDescription,value:h,onValueChange:C}),c.jsx("div",{className:g.cn("w-full min-h-0 flex flex-col gap-4 overflow-y-auto",r===""?"flex-1":g.cn("shrink-0",r)),"data-testid":"membership-select-cards-list",children:d.map(w=>c.jsx(Oo,{itemKey:w.id,name:w.name,type:w.type,price:w.price,locale:e,currency:n,isSelected:f===w.id,onSelect:k},w.id))})]})},Oo=({itemKey:t,name:e,type:n,price:r,locale:s="en-US",currency:i="USD",isSelected:o=!1,onSelect:l,className:a=""})=>{const u=new Intl.NumberFormat(s,{style:"currency",currency:i,minimumFractionDigits:0,maximumFractionDigits:2}).format(r);return c.jsx(g.Card,{shadow:"none",isPressable:!!l,onPress:()=>l?.(t),className:g.cn("w-full min-h-fit border rounded-3xl",o?"border-primary bg-primary/5":"border-default",a),"data-testid":"item-card","data-selected":o,children:c.jsxs("div",{className:"px-4 py-8 flex gap-6 items-center justify-between",children:[c.jsxs("div",{className:"w-max flex flex-col gap-1 items-start",children:[c.jsx("p",{className:"text-xl font-semibold text-left","data-testid":"item-card-name",children:e}),n&&c.jsx("div",{"data-testid":"item-card-type",className:"w-fit bg-default-300 px-4 py-2 text-sm rounded-xl",children:c.jsx("p",{className:"text-center",children:n})})]}),c.jsx("p",{className:"text-2xl font-semibold","data-testid":"item-card-price",children:u})]})})},Do=({title:t,value:e,description:n,onValueChange:r,className:s=""})=>{const i=b.useId();return c.jsxs("div",{className:g.cn("w-full flex flex-row items-center",t||n?"justify-between gap-6":"justify-start",s),"data-testid":"toggle",children:[c.jsxs("div",{className:"flex flex-col items-start",children:[t&&c.jsx("label",{htmlFor:i,className:"font-medium text-left","data-testid":"toggle-title",children:t}),n&&c.jsx("p",{className:"text-left text-gray-500","data-testid":"toggle-description",children:n})]}),c.jsx(g.Switch,{id:i,isSelected:e,onValueChange:r,"data-testid":"toggle-switch"})]})},Nd={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"},Td=(t,e)=>new Intl.NumberFormat(t,{style:"currency",currency:e}),Lo=t=>Object.values(t).reduce((e,n)=>e+Object.values(n).reduce((r,s)=>r+Object.values(s).reduce((i,o)=>i+o.selectedQuantity,0),0),0),Ed=t=>t.reduce((e,n)=>e+n.dates.reduce((r,s)=>r+s.tickets.reduce((i,o)=>i+o.max,0),0),0),zr=t=>t.flatMap(e=>e.dates.flatMap(n=>n.tickets.map(r=>({exhibition:e,dateGroup:n,ticket:r})))),Qs=(t,e,n)=>{const r={};let s=n?e??Ed(t):0;for(const{exhibition:i,dateGroup:o,ticket:l}of zr(t)){r[i.id]??={},r[i.id][o.id]??={};const a=n?Math.min(l.max,s):0;r[i.id][o.id][l.id]={id:l.id,selectedQuantity:a,originalPrice:l.originalPrice,discountedPrice:l.price},s-=a}return r},Xs=(t,e,n)=>`${t}::${e}::${n}`,Md=(t,e,n)=>{const r=Lo(e);for(const{exhibition:s,dateGroup:i,ticket:o}of zr(t)){const l=e[s.id]?.[i.id]?.[o.id]?.selectedQuantity??0,a=n===void 0?o.max:Math.min(o.max,n-(r-l));if(a>0&&l<a)return!1}return!0},jd=({initialQuantity:t=1,minQuantity:e=1,maxQuantity:n=10,onChange:r,disabled:s=!1})=>{const i=Math.max(e,Math.min(n,t)),[o,l]=b.useState(()=>String(i)),[a,u]=b.useState(!1),d=a?o:String(i),f=()=>{s||i>=n||r?.(i+1)},m=()=>{s||i<=e||r?.(i-1)},h=A=>{if(s)return;l(A.target.value);const N=parseInt(A.target.value,10);isNaN(N)||r?.(Math.max(e,Math.min(n,N)))},S=A=>{const N=parseInt(A.target.value,10);if(u(!1),isNaN(N)){r?.(e);return}const O=Math.max(e,Math.min(n,N));O!==N?r?.(O):l(String(O))},x=i<=e,k=i>=n,C="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",w="bg-primary hover:bg-primary/80",T="bg-primary/40 cursor-not-allowed";return c.jsxs("div",{className:"flex items-center gap-4","data-testid":"quantity-selector",children:[c.jsx("button",{type:"button",onClick:m,disabled:s||x,className:g.cn(C,s||x?T:w),"aria-label":"Decrement quantity","data-testid":"quantity-decrement",children:"-"}),c.jsx("input",{type:"number",value:d,onChange:h,onFocus:()=>u(!0),onBlur:S,disabled:s,min:e,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"}),c.jsx("button",{type:"button",onClick:f,disabled:s||k,className:g.cn(C,s||k?T:w),"aria-label":"Increment quantity","data-testid":"quantity-increment",children:"+"})]})},Id=({label:t,checked:e=!1,onChange:n,disabled:r=!1})=>{const s=()=>{r||n?.(!e)};return c.jsxs("button",{type:"button",onClick:s,disabled:r,role:"checkbox","aria-checked":e,"data-testid":"checkbox-button","data-checked":e,className:g.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:[c.jsxs("span",{className:"relative flex items-center justify-center w-5 h-5 flex-shrink-0",children:[c.jsx("input",{type:"checkbox",checked:e,onChange:()=>{},disabled:r,className:"absolute opacity-0 w-0 h-0 pointer-events-none",tabIndex:-1,readOnly:!0}),c.jsx("span",{className:g.cn("block w-3.5 h-3.5 rounded-sm relative",e?"bg-primary":"bg-white ring-1 ring-zinc-300"),children:e&&c.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"})})]}),c.jsx("p",{className:"flex-1 m-0 text-left leading-snug",children:t})]})},Od=({item:t,quantity:e,onChange:n,getTotalSelectedTickets:r,userMaxLimit:s,settings:i,labels:o})=>{const l=()=>{if(!r||s===void 0)return t.max;const f=r();return Math.min(t.max,s-(f-e))},a=i?.locale??"en-US",u=i?.currency??"USD",d=Td(a,u);return c.jsxs("div",{className:"flex items-center justify-between bg-white px-3 py-2.5","data-testid":"upgrade-ticket-item",children:[c.jsxs("div",{className:"flex flex-col gap-2",children:[c.jsxs("div",{className:"flex items-center gap-[30px]",children:[c.jsx("p",{className:"text-base font-semibold text-zinc-900 m-0","data-testid":"ticket-name",children:t.name}),c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx("p",{className:"line-through text-zinc-500 text-[0.9rem] font-normal m-0","data-testid":"ticket-original-price",children:d.format(t.originalPrice)}),c.jsx("p",{className:"text-base font-semibold text-zinc-900 m-0","data-testid":"ticket-discounted-price",children:d.format(t.price)})]})]}),c.jsx("div",{className:"text-sm text-zinc-500",children:c.jsxs("p",{className:"m-0","data-testid":"ticket-max",children:[o.ticketsAllowedToRedeem," ",t.max]})})]}),c.jsx(jd,{initialQuantity:e,minQuantity:0,maxQuantity:l(),onChange:n})]})},Dd=({exhibitionId:t,dateGroup:e,isLast:n=!1,onQuantityChange:r,getTicketQuantity:s,getTotalSelectedTickets:i,userMaxLimit:o,settings:l,labels:a})=>c.jsxs("div",{className:g.cn("flex flex-col gap-2 pb-3",!n&&"border-b border-zinc-200"),"data-testid":"upgrade-ticket-date-group",children:[c.jsx("p",{className:"m-0 text-sm text-left text-zinc-500","data-testid":"upgrade-ticket-date",children:e.date}),e.tickets.map(u=>c.jsx(Od,{item:u,quantity:s(t,e.id,u.id),onChange:d=>r(t,e.id,u.id,d),getTotalSelectedTickets:i,userMaxLimit:o,settings:l,labels:a},u.id))]}),Ld=({title:t,exhibition:e,onQuantityChange:n,getTicketQuantity:r,getTotalSelectedTickets:s,userMaxLimit:i,settings:o,labels:l,initialExpanded:a=!1})=>{const[u,d]=b.useState(a),f=e.dates.reduce((h,S)=>h+S.tickets.reduce((x,k)=>x+r(e.id,S.id,k.id),0),0),m=e.dates.some(h=>h.tickets.length>0);return c.jsxs("div",{className:"w-full overflow-hidden border-b border-zinc-200","data-testid":"upgrade-ticket-header",children:[c.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:()=>d(!u),"aria-expanded":u,"aria-controls":`upgrade-items-${e.id}`,"data-testid":"upgrade-ticket-header-button",children:c.jsxs("div",{className:"flex justify-between items-center w-full gap-6",children:[c.jsx("h4",{className:"m-0 text-base font-semibold text-left text-zinc-900","data-testid":"upgrade-ticket-header-title",children:t}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs("p",{className:"m-0 text-sm text-right text-zinc-500","data-testid":"upgrade-ticket-header-count",children:[f," ",l.ticketsSelectedToRedeem]}),c.jsx("span",{className:g.cn("inline-flex items-center justify-center text-zinc-500 text-xl transition-transform duration-200",u&&"rotate-180"),"aria-hidden":"true",children:c.jsx(Ee,{icon:"mdi:chevron-down"})})]})]})}),c.jsx("div",{id:`upgrade-items-${e.id}`,className:g.cn("transition-all duration-300 overflow-hidden",u?"max-h-[1000px] opacity-100":"max-h-0 opacity-0"),"aria-hidden":!u,children:u&&c.jsx("div",{className:"px-5 flex flex-col gap-6","data-testid":"upgrade-ticket-items",children:m?e.dates.map((h,S)=>c.jsx(Dd,{exhibitionId:e.id,dateGroup:h,isLast:S===e.dates.length-1,onQuantityChange:n,getTicketQuantity:r,getTotalSelectedTickets:s,userMaxLimit:i,settings:o,labels:l},h.id)):c.jsx("div",{className:"px-5 py-10 text-center",children:c.jsx("p",{className:"m-0 text-zinc-500 italic",children:l.noUpgradeTicketsAvailable})})})})]})},Rd=({initialExpanded:t=!1,userMaxLimit:e,labels:n,settings:r,ticketSelectionData:s,className:i="",onSelectionChange:o})=>{const l=b.useMemo(()=>s??[],[s]),a={...Nd,...n},[u,d]=b.useState(()=>Qs(l,e,!0)),f=b.useRef(!1),m=b.useMemo(()=>{const w=zr(l).map(({exhibition:T,dateGroup:A,ticket:N})=>[Xs(T.id,A.id,N.id),N]);return new Map(w)},[l]),h=Md(l,u,e),S=(w,T,A)=>u[w]?.[T]?.[A]?.selectedQuantity??0,x=()=>Lo(u),k=(w,T,A,N)=>{const O=S(w,T,A),L=x()-O;if(e!==void 0&&L+N>e)return;const _=m.get(Xs(w,T,A));if(!_)return;const z={...u,[w]:{...u[w],[T]:{...u[w]?.[T],[A]:{id:A,selectedQuantity:N,originalPrice:_.originalPrice,discountedPrice:_.price}}}};d(z),o?.(z)},C=w=>{const T=Qs(l,e,w);d(T),o?.(T)};return b.useEffect(()=>{!f.current&&h&&(o?.(u),f.current=!0)},[h,u,o]),c.jsxs("div",{className:g.cn("flex flex-col w-full font-sans",i),"data-testid":"ticket-selection",children:[c.jsxs("div",{className:"flex items-center justify-between py-2 gap-4","data-testid":"ticket-selection-header",children:[c.jsx("h3",{className:"text-xl font-semibold m-0","data-testid":"ticket-selection-title",children:a.ticketSelectionTitle}),c.jsx(Id,{label:a.selectAllButtonLabel,checked:h,onChange:C})]}),l.map(w=>c.jsx(Ld,{title:w.exhibitionName,exhibition:w,onQuantityChange:k,getTicketQuantity:S,getTotalSelectedTickets:x,userMaxLimit:e,settings:r,labels:a,initialExpanded:t},w.id))]})};exports.Button=se;exports.ConfirmationPageTemplate=el;exports.DonationAmounts=Wi;exports.EventDetails=Hu;exports.EventDetailsTemplate=rl;exports.ExpireCartTimer=Gi;exports.Footer=sl;exports.HeroUIProvider=Go;exports.ItemCard=Oo;exports.MembershipSelectCards=Ad;exports.Multiselect=il;exports.Navbar=Yo;exports.OfferCard=Ir;exports.OfferCardEmpty=uo;exports.OfferCardError=fo;exports.OfferCardList=go;exports.OfferCardSkeleton=ho;exports.RICH_TEXT_PRESETS=Ki;exports.RevenueDistributionCard=Eo;exports.RevenueDistributionEmpty=Mo;exports.RevenueDistributionError=jo;exports.RevenueDistributionSkeleton=Io;exports.RichTextArea=Ji;exports.Stepper=Ys;exports.TicketSelection=Rd;exports.Toggle=Do;exports.calculateAllocationDifference=vd;exports.formatOfferCurrency=co;exports.formatRevenueAmount=yd;exports.formatRevenueCurrency=xd;exports.generateDistributionId=Vr;exports.getCurrencySymbol=bd;exports.offerCardVariants=mo;exports.offerListVariants=po;exports.parseOfferCurrency=Uu;exports.parseRevenueCurrency=kd;Object.keys(g).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>g[t]})});
|
|
18
|
+
`);return{dom:c,text:p,slice:e}}function xa(t,e,n,r,s){let i=s.parent.type.spec.code,a,o;if(!n&&!e)return null;let c=!!e&&(r||i||!n);if(c){if(t.someProp("transformPastedText",p=>{e=p(e,i||r,t)}),i)return o=new Q(G.from(t.state.schema.text(e.replace(/\r\n?/g,`
|
|
19
|
+
`))),0,0),t.someProp("transformPasted",p=>{o=p(o,t,!0)}),o;let f=t.someProp("clipboardTextParser",p=>p(e,s,r,t));if(f)o=f;else{let p=s.marks(),{schema:m}=t.state,v=Mn.fromSchema(m);a=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(b=>{let x=a.appendChild(document.createElement("p"));b&&x.appendChild(v.serializeNode(m.text(b,p)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),a=gd(n),Ur&&xd(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(o||(o=(t.someProp("clipboardParser")||t.someProp("domParser")||un.fromSchema(t.state.schema)).parseSlice(a,{preserveWhitespace:!!(c||u),context:s,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!hd.test(p.parentNode.nodeName)?{ignore:!0}:null}})),u)o=yd(Xs(o,+u[1],+u[2]),u[4]);else if(o=Q.maxOpen(md(o.content,s),!0),o.openStart||o.openEnd){let f=0,p=0;for(let m=o.content.firstChild;f<o.openStart&&!m.type.spec.isolating;f++,m=m.firstChild);for(let m=o.content.lastChild;p<o.openEnd&&!m.type.spec.isolating;p++,m=m.lastChild);o=Xs(o,f,p)}return t.someProp("transformPasted",f=>{o=f(o,t,c)}),o}const hd=/^(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 md(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.index(n)),i,a=[];if(t.forEach(o=>{if(!a)return;let c=s.findWrapping(o.type),d;if(!c)return a=null;if(d=a.length&&i.length&&ba(c,i,o,a[a.length-1],0))a[a.length-1]=d;else{a.length&&(a[a.length-1]=va(a[a.length-1],i.length));let u=ya(o,c);a.push(u),s=s.matchType(u.type),i=c}}),a)return G.from(a)}return t}function ya(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,G.from(t));return t}function ba(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let i=ba(t,e,n,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==t.length-1?n.type:t[s+1]))return r.copy(r.content.append(G.from(ya(n,t,s+1))))}}function va(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,va(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(G.empty,!0);return t.copy(n.append(r))}function Sr(t,e,n,r,s,i){let a=e<0?t.firstChild:t.lastChild,o=a.content;return t.childCount>1&&(i=0),s<r-1&&(o=Sr(o,e,n,r,s+1,i)),s>=n&&(o=e<0?a.contentMatchAt(0).fillBefore(o,i<=s).append(o):o.append(a.contentMatchAt(a.childCount).fillBefore(G.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,a.copy(o))}function Xs(t,e,n){return e<t.openStart&&(t=new Q(Sr(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Q(Sr(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const ka={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 ei=null;function wa(){return ei||(ei=document.implementation.createHTMLDocument("title"))}let tr=null;function pd(t){let e=window.trustedTypes;return e?(tr||(tr=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),tr.createHTML(t)):t}function gd(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=wa().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),s;if((s=r&&ka[r[1].toLowerCase()])&&(t=s.map(i=>"<"+i+">").join("")+t+s.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=pd(t),s)for(let i=0;i<s.length;i++)n=n.querySelector(s[i])||n;return n}function xd(t){let e=t.querySelectorAll(Ke?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function yd(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:s,openStart:i,openEnd:a}=t;for(let o=r.length-2;o>=0;o-=2){let c=n.nodes[r[o]];if(!c||c.hasRequiredAttrs())break;s=G.from(c.create(r[o+1],s)),i++,a++}return new Q(s,i,a)}const ze={},Ie={};function Ze(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}Ie.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Na(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Yt&&Ke&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Hr&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",s=>s(t,la(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||fd(t,n)?n.preventDefault():Ze(t,"key")};Ie.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Ie.keypress=(t,e)=>{let n=e;if(Na(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||$e&&n.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof ne)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!t.someProp("handleTextInput",a=>a(t,r.$from.pos,r.$to.pos,s,i))&&t.dispatch(i()),n.preventDefault()}};function In(t){return{left:t.clientX,top:t.clientY}}function bd(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Wr(t,e,n,r,s){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let a=i.depth+1;a>0;a--)if(t.someProp(e,o=>a>i.depth?o(t,n,i.nodeAfter,i.before(a),s,!0):o(t,n,i.node(a),i.before(a),s,!1)))return!0;return!1}function Ct(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function vd(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Z.isSelectable(r)?(Ct(t,new Z(n)),!0):!1}function kd(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof Z&&(r=n.node);let i=t.state.doc.resolve(e);for(let a=i.depth+1;a>0;a--){let o=a>i.depth?i.nodeAfter:i.node(a);if(Z.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?(Ct(t,Z.create(t.state.doc,s)),!0):!1}function wd(t,e,n,r,s){return Wr(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(s?kd(t,n):vd(t,n))}function Sd(t,e,n,r){return Wr(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function Nd(t,e,n,r){return Wr(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||Cd(t,n,r)}function Cd(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Ct(t,ne.create(r,0,r.content.size)),!0):!1;let s=r.resolve(e);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)Ct(t,ne.create(r,o+1,o+1+a.content.size));else if(Z.isSelectable(a))Ct(t,Z.create(r,o));else continue;return!0}}function Kr(t){return yn(t)}const Sa=$e?"metaKey":"ctrlKey";ze.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Kr(t),s=Date.now(),i="singleClick";s-t.input.lastClick.time<500&&bd(n,t.input.lastClick)&&!n[Sa]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:i,button:n.button};let a=t.posAtCoords(In(n));a&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new jd(t,a,n,!!r)):(i=="doubleClick"?Sd:Nd)(t,a.pos,a.inside,n)?n.preventDefault():Ze(t,"pointer"))};class jd{constructor(e,n,r,s){this.view=e,this.pos=n,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Sa],this.allowDefault=r.shiftKey;let i,a;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),a=n.inside;else{let u=e.state.doc.resolve(n.pos);i=u.parent,a=u.depth?u.before():0}const o=s?null:r.target,c=o?e.docView.nearestDesc(o,!0):null;this.target=c&&c.nodeDOM.nodeType==1?c.nodeDOM:null;let{selection:d}=e.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&&Dn&&!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()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Ze(e,"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(()=>qr(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(In(e))),this.updateAllowDefault(e),this.allowDefault||!n?Ze(this.view,"pointer"):wd(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.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))),e.preventDefault()):Ze(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ze(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}ze.touchstart=t=>{t.input.lastTouch=Date.now(),Kr(t),Ze(t,"pointer")};ze.touchmove=t=>{t.input.lastTouch=Date.now(),Ze(t,"pointer")};ze.contextmenu=t=>Kr(t);function Na(t,e){return t.composing?!0:xt&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const Ad=Yt?5e3:-1;Ie.compositionstart=Ie.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof ne&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Ke&&fa&&Md(t)))t.markCursor=t.state.storedMarks||n.marks(),yn(t,!0),t.markCursor=null;else if(yn(t,!e.selection.empty),Dn&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.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=t.domSelection();o&&o.collapse(a,a.nodeValue.length);break}else s=a,i=-1}}t.input.composing=!0}Ca(t,Ad)};function Md(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}Ie.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,Ca(t,20))};function Ca(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>yn(t),e))}function Ed(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Td());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function Td(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function yn(t,e=!1){if(!(Yt&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Ed(t),e||t.docView&&t.docView.dirty){let n=td(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function Dd(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const Ut=Jt&&da<15||Hr&&ed<604;ze.copy=Ie.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let i=Ut?null:n.clipboardData,a=r.content(),{dom:o,text:c}=ga(t,a);i?(n.preventDefault(),i.clearData(),i.setData("text/html",o.innerHTML),i.setData("text/plain",c)):Dd(t,o),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Id(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function $d(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.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=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Nr(t,r.value,null,s,e):Nr(t,r.textContent,r.innerHTML,s,e)},50)}function Nr(t,e,n,r,s){let i=xa(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,s,i||Q.empty)))return!0;if(!i)return!1;let a=Id(i),o=a?t.state.tr.replaceSelectionWith(a,r):t.state.tr.replaceSelection(i);return t.dispatch(o.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function ja(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Ie.paste=(t,e)=>{let n=e;if(t.composing&&!Yt)return;let r=Ut?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Nr(t,ja(r),r.getData("text/html"),s,n)?n.preventDefault():$d(t,n)};class Od{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const Ld=$e?"altKey":"ctrlKey";function Aa(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[Ld]}ze.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=t.state.selection,i=s.empty?null:t.posAtCoords(In(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(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let f=t.docView.nearestDesc(n.target,!0);f&&f.node.type.spec.draggable&&f!=t.docView&&(a=Z.create(t.state.doc,f.posBefore))}}let o=(a||t.state.selection).content(),{dom:c,text:d,slice:u}=ga(t,o);(!n.dataTransfer.files.length||!Ke||ua>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Ut?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",Ut||n.dataTransfer.setData("text/plain",d),t.dragging=new Od(u,Aa(t,n),a)};ze.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Ie.dragover=Ie.dragenter=(t,e)=>e.preventDefault();Ie.drop=(t,e)=>{try{Fd(t,e,t.dragging)}finally{t.dragging=null}};function Fd(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(In(e));if(!r)return;let s=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp("transformPasted",m=>{i=m(i,t,!1)}):i=xa(t,ja(e.dataTransfer),Ut?null:e.dataTransfer.getData("text/html"),!1,s);let a=!!(n&&Aa(t,e));if(t.someProp("handleDrop",m=>m(t,e,i||Q.empty,a))){e.preventDefault();return}if(!i)return;e.preventDefault();let o=i?Xi(t.state.doc,s.pos,i):s.pos;o==null&&(o=s.pos);let c=t.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,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(o);c.mapping.maps[c.mapping.maps.length-1].forEach((v,b,x,k)=>m=k),c.setSelection(ma(t,p,c.doc.resolve(m)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))}ze.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&qr(t)},20))};ze.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};ze.beforeinput=(t,e)=>{if(Ke&&Yt&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,la(8,"Backspace")))))return;let{$cursor:s}=t.state.selection;s&&s.pos>0&&t.dispatch(t.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let t in Ie)ze[t]=Ie[t];function qt(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class bn{constructor(e,n){this.toDOM=e,this.spec=n||ft,this.side=this.spec.side||0}map(e,n,r,s){let{pos:i,deleted:a}=e.mapResult(n.from+s,this.side<0?-1:1);return a?null:new _e(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof bn&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&qt(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class et{constructor(e,n){this.attrs=e,this.spec=n||ft}map(e,n,r,s){let i=e.map(n.from+s,this.spec.inclusiveStart?-1:1)-r,a=e.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=a?null:new _e(i,a,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof et&&qt(this.attrs,e.attrs)&&qt(this.spec,e.spec)}static is(e){return e.type instanceof et}destroy(){}}class Jr{constructor(e,n){this.attrs=e,this.spec=n||ft}map(e,n,r,s){let i=e.mapResult(n.from+s,1);if(i.deleted)return null;let a=e.mapResult(n.to+s,-1);return a.deleted||a.pos<=i.pos?null:new _e(i.pos-r,a.pos-r,this)}valid(e,n){let{index:r,offset:s}=e.content.findIndex(n.from),i;return s==n.from&&!(i=e.child(r)).isText&&s+i.nodeSize==n.to}eq(e){return this==e||e instanceof Jr&&qt(this.attrs,e.attrs)&&qt(this.spec,e.spec)}destroy(){}}class _e{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new _e(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new _e(e,e,new bn(n,r))}static inline(e,n,r,s){return new _e(e,n,new et(r,s))}static node(e,n,r,s){return new _e(e,n,new Jr(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof et}get widget(){return this.type instanceof bn}}const wt=[],ft={};class ye{constructor(e,n){this.local=e.length?e:wt,this.children=n.length?n:wt}static create(e,n){return n.length?vn(n,e,0,ft):Ce}find(e,n,r){let s=[];return this.findInner(e??0,n??1e9,s,0,r),s}findInner(e,n,r,s,i){for(let a=0;a<this.local.length;a++){let o=this.local[a];o.from<=n&&o.to>=e&&(!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]>e){let o=this.children[a]+1;this.children[a+2].findInner(e-o,n-o,r,s+o,i)}}map(e,n,r){return this==Ce||e.maps.length==0?this:this.mapInner(e,n,0,0,r||ft)}mapInner(e,n,r,s,i){let a;for(let o=0;o<this.local.length;o++){let c=this.local[o].map(e,r,s);c&&c.type.valid(n,c)?(a||(a=[])).push(c):i.onRemove&&i.onRemove(this.local[o].spec)}return this.children.length?Pd(this.children,a||[],e,n,r,s,i):a?new ye(a.sort(ht),wt):Ce}add(e,n){return n.length?this==Ce?ye.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,i=0;e.forEach((o,c)=>{let d=c+r,u;if(u=Ea(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,vn(u,o,d+1,ft)),i+=3}});let a=Ma(i?Ta(n):n,-r);for(let o=0;o<a.length;o++)a[o].type.valid(e,a[o])||a.splice(o--,1);return new ye(a.length?this.local.concat(a).sort(ht):this.local,s||this.children)}remove(e){return e.length==0||this==Ce?this:this.removeInner(e,0)}removeInner(e,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,f;u<e.length;u++)(f=e[u])&&f.from>o&&f.to<c&&(e[u]=null,(a||(a=[])).push(f));if(!a)continue;r==this.children&&(r=this.children.slice());let d=r[i+2].removeInner(a,o+1);d!=Ce?r[i+2]=d:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,a;i<e.length;i++)if(a=e[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 ye(s,r):Ce}forChild(e,n){if(this==Ce)return this;if(n.isLeaf)return ye.empty;let r,s;for(let o=0;o<this.children.length;o+=3)if(this.children[o]>=e){this.children[o]==e&&(r=this.children[o+2]);break}let i=e+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 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 o=new ye(s.sort(ht),wt);return r?new at([o,r]):o}return r||Ce}eq(e){if(this==e)return!0;if(!(e instanceof ye)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return Yr(this.localsInner(e))}localsInner(e){if(this==Ce)return wt;if(e.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(e){e(this)}}ye.empty=new ye([],[]);ye.removeOverlap=Yr;const Ce=ye.empty;class at{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,ft));return at.from(r)}forChild(e,n){if(n.isLeaf)return ye.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,n);i!=Ce&&(i instanceof at?r=r.concat(i.members):r.push(i))}return at.from(r)}eq(e){if(!(e instanceof at)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);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?Yr(r?n:n.sort(ht)):wt}static from(e){switch(e.length){case 0:return Ce;case 1:return e[0];default:return new at(e.every(n=>n instanceof ye)?e:e.reduce((n,r)=>n.concat(r instanceof ye?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function Pd(t,e,n,r,s,i,a){let o=t.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 k=0;k<o.length;k+=3){let S=o[k+1];if(S<0||p>S+u-f)continue;let A=o[k]+u-f;m>=A?o[k+1]=p<=A?-2:-1:p>=u&&x&&(o[k]+=x,o[k+1]+=x)}f+=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(t[d]+i),f=u-s;if(f<0||f>=r.content.size){c=!0;continue}let p=n.map(t[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 k=o[d+2].mapInner(n,x,u+1,t[d]+i+1,a);k!=Ce?(o[d]=f,o[d+1]=m,o[d+2]=k):(o[d+1]=-2,c=!0)}else c=!0}if(c){let d=Rd(o,t,e,n,s,i,a),u=vn(d,r,0,a);e=u.local;for(let f=0;f<o.length;f+=3)o[f+1]<0&&(o.splice(f,3),f-=3);for(let f=0,p=0;f<u.children.length;f+=3){let m=u.children[f];for(;p<o.length&&o[p]<m;)p+=3;o.splice(p,0,u.children[f],u.children[f+1],u.children[f+2])}}return new ye(e.sort(ht),o)}function Ma(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let s=t[r];n.push(new _e(s.from+e,s.to+e,s.type))}return n}function Rd(t,e,n,r,s,i,a){function o(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)o(c.children[u+2],c.children[u]+d+1)}for(let c=0;c<t.length;c+=3)t[c+1]==-1&&o(t[c+2],e[c]+i+1);return n}function Ea(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,s=null;for(let i=0,a;i<t.length;i++)(a=t[i])&&a.from>n&&a.to<r&&((s||(s=[])).push(a),t[i]=null);return s}function Ta(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function vn(t,e,n,r){let s=[],i=!1;e.forEach((o,c)=>{let d=Ea(t,o,c+n);if(d){i=!0;let u=vn(d,o,n+c+1,r);u!=Ce&&s.push(c,c+o.nodeSize,u)}});let a=Ma(i?Ta(t):t,-n).sort(ht);for(let o=0;o<a.length;o++)a[o].type.valid(e,a[o])||(r.onRemove&&r.onRemove(a[o].spec),a.splice(o--,1));return a.length||s.length?new ye(a,s):Ce}function ht(t,e){return t.from-e.from||t.to-e.to}function Yr(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let s=n+1;s<e.length;s++){let i=e[s];if(i.from==r.from){i.to!=r.to&&(e==t&&(e=t.slice()),e[s]=i.copy(i.from,r.to),ti(e,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),ti(e,s,r.copy(i.from,r.to)));break}}}return e}function ti(t,e,n){for(;e<t.length&&ht(n,t[e])>0;)e++;t.splice(e,0,n)}class fe extends re{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return fe.valid(r)?new fe(r):re.near(r)}content(){return Q.empty}eq(e){return e instanceof fe&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new fe(e.resolve(n.pos))}getBookmark(){return new Gr(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!zd(e)||!Bd(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let s=n.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&fe.valid(e))return e;let s=e.pos,i=null;for(let a=e.depth;;a--){let o=e.node(a);if(n>0?e.indexAfter(a)<o.childCount:e.index(a)>0){i=o.child(n>0?e.indexAfter(a):e.index(a)-1);break}else if(a==0)return null;s+=n;let c=e.doc.resolve(s);if(fe.valid(c))return c}for(;;){let a=n>0?i.firstChild:i.lastChild;if(!a){if(i.isAtom&&!i.isText&&!Z.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*n),r=!1;continue e}break}i=a,s+=n;let o=e.doc.resolve(s);if(fe.valid(o))return o}return null}}}fe.prototype.visible=!1;fe.findFrom=fe.findGapCursorFrom;re.jsonID("gapcursor",fe);class Gr{constructor(e){this.pos=e}map(e){return new Gr(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return fe.valid(n)?new fe(n):re.near(n)}}function Da(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function zd(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);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||Da(s.type))return!0;if(s.inlineContent)return!1}}return!0}function Bd(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);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||Da(s.type))return!0;if(s.inlineContent)return!1}}return!0}function _d(){return new Tn({props:{decorations:qd,createSelectionBetween(t,e,n){return e.pos==n.pos&&fe.valid(n)?new fe(n):null},handleClick:Hd,handleKeyDown:Vd,handleDOMEvents:{beforeinput:Ud}}})}const Vd=Qc({ArrowLeft:en("horiz",-1),ArrowRight:en("horiz",1),ArrowUp:en("vert",-1),ArrowDown:en("vert",1)});function en(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let a=r.selection,o=e>0?a.$to:a.$from,c=a.empty;if(a instanceof ne){if(!i.endOfTextblock(n)||o.depth==0)return!1;c=!1,o=r.doc.resolve(e>0?o.after():o.before())}let d=fe.findGapCursorFrom(o,e,c);return d?(s&&s(r.tr.setSelection(new fe(d))),!0):!1}}function Hd(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!fe.valid(r))return!1;let s=t.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&Z.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new fe(r))),!0)}function Ud(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof fe))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.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=t.state.tr.replace(n.pos,n.pos,new Q(s,0,0));return i.setSelection(ne.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function qd(t){if(!(t.selection instanceof fe))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",ye.create(t.doc,[_e.widget(t.selection.head,e,{key:"gapcursor"})])}const Wd=z.Extension.create({name:"gapCursor",addProseMirrorPlugins(){return[_d()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=z.callOrReturn(z.getExtensionField(t,"allowGapCursor",n)))!==null&&e!==void 0?e:null}}}),Et={bold:{category:"mark",extension:Ul,priority:100},italic:{category:"mark",extension:Yl,priority:100},strike:{category:"mark",extension:Zl,priority:100},underline:{category:"mark",extension:sl.Underline,priority:100},code:{category:"mark",extension:tc,priority:100},textColor:{category:"mark",extension:il.Color,defaultOptions:{types:["textStyle","heading","paragraph","listItem","taskItem","blockquote"]},priority:90},highlight:{category:"mark",extension:al.Highlight,defaultOptions:{multicolor:!0},priority:90},link:{category:"mark",extension:ol.Link,defaultOptions:{autolink:!0,linkOnPaste:!0,openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}},priority:100},heading:{category:"node",extension:sc,defaultOptions:{levels:[1,2,3,4,5,6]},priority:100},bulletList:{category:"node",extension:oc,defaultOptions:{HTMLAttributes:{class:"list-disc"}},priority:90},orderedList:{category:"node",extension:cc,defaultOptions:{HTMLAttributes:{class:"list-decimal"}},priority:90},taskList:{category:"node",extension:ll.TaskList,defaultOptions:{HTMLAttributes:{class:"task-list"}},priority:90},codeBlock:{category:"node",extension:Cc,priority:100},blockquote:{category:"node",extension:Ac,priority:100},horizontalRule:{category:"node",extension:Mc,priority:100},hardBreak:{category:"node",extension:Ec,priority:100},undo:{category:"extension",extension:_s,priority:50},redo:{category:"extension",extension:_s,priority:50},textAlign:{category:"extension",extension:dl.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}},Kd=[zc,Bc,ic,rc.configure({HTMLAttributes:{}}),dc.configure({HTMLAttributes:{}}),cl.TaskItem.configure({nested:!0}),Hc,Wd];function Jd(t){const e=[],n=new Set,r=new Set;Kd.forEach(o=>{o&&(e.push(o),r.add(o.name))});const s=t.map(o=>Bt(o)),i=new Set;return s.forEach(o=>{const c=Et[o];c?.requiredExtensions&&c.requiredExtensions.forEach(d=>{i.add(d)})}),i.forEach(o=>{if(n.has(o))return;const c=Et[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;e.push(u),n.add(o),r.add(d)}),s.forEach(o=>{if(n.has(o))return;const c=Et[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;e.push(u),n.add(o),r.add(d)}),e.sort((o,c)=>{const d=Object.values(Et).find(m=>m?.extension?.name===o.name),u=Object.values(Et).find(m=>m?.extension?.name===c.name),f=d?.priority??100;return(u?.priority??100)-f})}const Ia={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"]},de={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"}}},ae={xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem"},Yd={h1:`font-size: ${de.fontSize["4xl"]}; font-weight: ${de.fontWeight.semibold}; line-height: ${de.lineHeight.tight}; margin: ${ae.md} 0 ${ae.sm} 0;`,h2:`font-size: ${de.fontSize["2xl"]}; font-weight: ${de.fontWeight.semibold}; line-height: ${de.lineHeight.tight}; margin: ${ae.md} 0 ${ae.sm} 0;`,h3:`font-size: ${de.fontSize.xl}; font-weight: ${de.fontWeight.semibold}; line-height: ${de.lineHeight.tight}; margin: ${ae.md} 0 ${ae.sm} 0;`,h4:`font-size: ${de.fontSize.lg}; font-weight: ${de.fontWeight.semibold}; line-height: ${de.lineHeight.tight}; margin: ${ae.md} 0 ${ae.sm} 0;`,h5:`font-size: ${de.fontSize.base}; font-weight: ${de.fontWeight.semibold}; line-height: ${de.lineHeight.tight}; margin: ${ae.md} 0 ${ae.sm} 0;`,h6:`font-size: ${de.fontSize.sm}; font-weight: ${de.fontWeight.semibold}; line-height: ${de.lineHeight.tight}; margin: ${ae.md} 0 ${ae.sm} 0;`,p:`min-height: ${de.lineHeight.normal}em; margin: 0;`,ul:`list-style-type: disc; list-style-position: outside; padding-left: ${ae.xl}; margin: ${ae.md} 0;`,ol:`list-style-type: decimal; list-style-position: outside; padding-left: ${ae.xl}; margin: ${ae.md} 0;`,li:`display: list-item; margin: ${ae.xs} 0;`,strong:`font-weight: ${de.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: ${de.fontSize.sm}; padding: 0.25em 0.3em; font-family: ${de.fontFamily.mono};`,pre:`background: ${Ye.neutral.gray[800]}; border-radius: ${ae.sm}; color: ${Ye.neutral.gray[100]}; font-family: ${de.fontFamily.mono}; margin: ${ae.lg} 0; padding: 0.75rem ${ae.md}; overflow-x: auto;`,blockquote:`border-left: 3px solid ${Ye.neutral.gray[300]}; margin: ${ae.lg} 0; padding-left: ${ae.md}; color: ${Ye.neutral.gray[500]};`,hr:`border: none; border-top: 1px solid ${Ye.neutral.gray[200]}; margin: ${ae.xl} 0;`,a:`color: ${Ye.brand.primary.DEFAULT}; text-decoration: underline; cursor: pointer;`,mark:`background-color: ${Ye.palettes.warning[200]}; border-radius: ${ae.xs}; padding: 0 0.125rem;`,label:`display: flex; align-items: center; gap: ${ae.sm}; cursor: pointer;`,input:"cursor: pointer; margin: 0;"},Gd={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 Qd(t){if(!t)return t;let e=t;for(const[n,r]of Object.entries(Gd)){const s=new RegExp(`(<(?:ul|li)[^>]*data-type="${n}"[^>]*)>`,"gi");e=e.replace(s,(i,a)=>i.includes('style="')?i.replace(/style="([^"]*)"/,`style="$1 ${r}"`):`${a} style="${r}">`)}for(const[n,r]of Object.entries(Yd)){const s=new RegExp(`<${n}(\\s[^>]*)?>`,"gi");e=e.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 e}const Zd=({modifiers:t,zoom:e,onZoomChange:n,onToolbarAction:r})=>{const{editor:s}=Fr.useCurrentEditor();return l.jsx(zl,{editor:s,modifiers:t,zoom:e,onZoomChange:n,onToolbarAction:r})},Xd=({showCharacterCount:t,showWordCount:e})=>{const{editor:n}=Fr.useCurrentEditor();if(!n||!t&&!e)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:[t&&l.jsxs("span",{children:[s," characters"]}),e&&l.jsxs("span",{children:[i," words"]})]})},Cr=y.forwardRef((t,e)=>{const{minRows:n=10,maxRows:r=30,disableAutosize:s=!1,showCharacterCount:i=!1,showWordCount:a=!1,showToolbar:o=!0,modifiers:c=Ia.full,variant:d="bordered",initialContent:u,content:f,onContentChange:p,onUpdate:m,onToolbarAction:v,isReadOnly:b=!1,isDisabled:x=!1,includeInlineStyles:k=!0,...S}=t,{zoom:A,setZoom:N}=Fl(),j=ws.lineHeight,M=n*j,D=s?void 0:r*j,B=y.useMemo(()=>Jd(c),[c]),{Component:R,label:V,shouldLabelBeOutside:I,getBaseProps:T,getLabelProps:O,getInputWrapperProps:P}=h.useInput({...S,variant:d,ref:e,isMultiline:!0}),K=V?l.jsx("label",{...O(),children:V}):null,X=y.useCallback(({editor:J})=>{const ue=J.getHTML(),le=k?Qd(ue):ue,xe=J.getJSON(),Y=J.getText(),W=Y.length,ce=Y.split(/\s+/).filter(Me=>Me.length>0).length,se={html:le,json:xe,text:Y,characters:W,words:ce};if(p?.(se),m?.(se),"onChange"in S&&typeof S.onChange=="function"){const Me={target:{value:le},currentTarget:{value:le}};S.onChange(Me)}},[p,m,S,k]);return l.jsxs(R,{...T(),children:[I?K:null,l.jsx("div",{...P(),className:h.cn(P().className,"flex flex-col w-full p-0 gap-0 rich-text-editor"),style:{maxHeight:D?`${D+ws.toolbarHeight}px`:void 0,overflow:D?"auto":void 0},children:l.jsx(Fr.EditorProvider,{editable:!b&&!x,slotBefore:o?l.jsx(Zd,{modifiers:c,zoom:A,onZoomChange:N,onToolbarAction:v}):void 0,slotAfter:l.jsx(Xd,{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||t.defaultValue||"",onUpdate:X})})]})});Cr.displayName="TipTapEditor";const $a=y.forwardRef((t,e)=>{const{adapter:n="tiptap",variant:r="bordered",...s}=t;return n==="tiptap"?l.jsx(Cr,{...s,variant:r,ref:e}):(console.warn(`Adapter "${n}" is not supported. Using TipTap.`),l.jsx(Cr,{...s,variant:r,ref:e}))});$a.displayName="RichTextArea";function eu(t,e="en-US",n="USD"){try{return new Intl.NumberFormat(e,{style:"currency",currency:n,minimumFractionDigits:0,maximumFractionDigits:2}).format(t)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${t.toFixed(2)}`}}const ni=[{id:"100",amount:100},{id:"250",amount:250},{id:"500",amount:500},{id:"1000",amount:1e3},{id:"2000",amount:2e3}],tu={title:"Donation Amount",customAmountPlaceholder:"Custom donation amount",customAmountAriaLabel:"Custom donation amount",addDonationButton:"Add Donation"},Oa=({presetAmounts:t=ni,selectedDonation:e,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:f=2,desktopColumns:p=3,isDisabled:m=!1,buttonVariant:v="bordered",buttonColor:b="default",inputVariant:x="bordered",size:k="md",className:S="",showCard:A=!0})=>{const N={...tu,...u},j=Array.isArray(t)?t:ni,M={2:"grid-cols-2",3:"grid-cols-3"},D={3:"sm:grid-cols-3",4:"sm:grid-cols-4",5:"sm:grid-cols-5",6:"sm:grid-cols-6"},B=`${M[f]} ${D[p]}`,[R,V]=Pr(e,n,r),[I,T]=y.useState(""),[O,P]=y.useState(!1),[K,X]=y.useState(0),J=y.useCallback(W=>{if(m)return;const ce={amount:W.amount,isCustom:!1,presetId:W.id};V(ce),T(""),P(!1),X(se=>se+1),s?.(ce)},[m,V,s]),ue=y.useCallback(W=>{if(m)return;if(T(W!==void 0?String(W):""),s){V(null);return}if(W===void 0||isNaN(W)){V(null);return}V({amount:W,isCustom:!0})},[m,V,s]),le=y.useCallback(()=>{if(m)return;const W=I!==""?parseFloat(I):void 0;W===void 0||isNaN(W)||s?.({amount:W,isCustom:!0})},[m,I,s]),xe=y.useMemo(()=>({style:"currency",currency:i,currencyDisplay:"symbol"}),[i]),Y=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:h.cn("grid gap-3",B),"data-testid":"donation-amounts-presets",children:j.map(W=>{const ce=R!==null&&!R.isCustom&&R.presetId===W.id;return l.jsx(q,{color:ce?"primary":b,variant:ce?"solid":v,className:"w-full",onPress:()=>J(W),isDisabled:m,"data-testid":`donation-amounts-preset-${W.id}`,children:W.label||eu(W.amount,a,i)},W.id)})}),o&&l.jsxs("div",{className:"flex gap-3 items-start",children:[l.jsx(h.NumberInput,{placeholder:N.customAmountPlaceholder,"aria-label":N.customAmountAriaLabel,onInput:s?()=>{V(null),P(!0)}:void 0,variant:x,radius:"full",size:k,minValue:c,maxValue:d,step:.01,formatOptions:xe,value:I!==""?parseFloat(I):void 0,onValueChange:ue,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&&l.jsx(q,{color:"primary",variant:"solid",radius:"full",size:k,className:"shrink-0",onPress:le,isDisabled:m||!O,"data-testid":"donation-amounts-add-button",children:N.addDonationButton})]})]});return A?l.jsx(h.Card,{className:h.cn("w-full",S),"data-testid":"donation-amounts-card",children:l.jsx(h.CardBody,{children:Y})}):l.jsx("div",{className:h.cn("w-full",S),"data-testid":"donation-amounts-plain",children:Y})};Oa.displayName="DonationAmounts";const nu=t=>{const e=Math.max(0,t),n=Math.floor(e/60).toString().padStart(2,"0"),r=(e%60).toString().padStart(2,"0");return`${n}:${r} minutes`},ru=t=>{switch(t){case"warning":return H.Clock;case"error":return H.AlertCircle;case"success":return H.CheckCircle;default:return H.Clock}},su=t=>{switch(t){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"}},La=y.forwardRef(({timeLeft:t,defaultTimeLeft:e=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:f=nu,className:p,...m},v)=>{const[b,x]=Pr(t!==void 0?Math.max(0,t):void 0,Math.max(0,e),n),k=y.useRef(null),S=y.useRef(!1);y.useEffect(()=>()=>{k.current&&clearInterval(k.current)},[]),y.useEffect(()=>{if(!u||b<=0){k.current&&(clearInterval(k.current),k.current=null);return}return k.current=setInterval(()=>{x(M=>M<=1?(k.current&&(clearInterval(k.current),k.current=null),S.current||(S.current=!0,r?.()),0):M-1)},1e3),()=>{k.current&&(clearInterval(k.current),k.current=null)}},[u,b,x,r]),y.useEffect(()=>{b>0&&(S.current=!1)},[b]);const A=c||ru(s),N=su(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} ${f(b)}`,"data-testid":"expire-cart-timer",className:h.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(A,{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: ${f(b)}`,"data-testid":"expire-cart-timer-value",children:f(b)})})]})})})});La.displayName="ExpireCartTimer";function iu(t,e){const n=t.icons,r=t.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 Fa=Object.freeze({left:0,top:0,width:16,height:16}),kn=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),Qr=Object.freeze({...Fa,...kn}),jr=Object.freeze({...Qr,body:"",hidden:!1});function au(t,e){const n={};!t.hFlip!=!e.hFlip&&(n.hFlip=!0),!t.vFlip!=!e.vFlip&&(n.vFlip=!0);const r=((t.rotate||0)+(e.rotate||0))%4;return r&&(n.rotate=r),n}function ri(t,e){const n=au(t,e);for(const r in jr)r in kn?r in t&&!(r in n)&&(n[r]=kn[r]):r in e?n[r]=e[r]:r in t&&(n[r]=t[r]);return n}function ou(t,e,n){const r=t.icons,s=t.aliases||Object.create(null);let i={};function a(o){i=ri(r[o]||s[o],i)}return a(e),n.forEach(a),ri(t,i)}function Pa(t,e){const n=[];if(typeof t!="object"||typeof t.icons!="object")return n;t.not_found instanceof Array&&t.not_found.forEach(s=>{e(s,null),n.push(s)});const r=iu(t);for(const s in r){const i=r[s];i&&(e(s,ou(t,s,i)),n.push(s))}return n}const lu={provider:"",aliases:{},not_found:{},...Fa};function nr(t,e){for(const n in e)if(n in t&&typeof t[n]!=typeof e[n])return!1;return!0}function Ra(t){if(typeof t!="object"||t===null)return null;const e=t;if(typeof e.prefix!="string"||!t.icons||typeof t.icons!="object"||!nr(t,lu))return null;const n=e.icons;for(const s in n){const i=n[s];if(!s||typeof i.body!="string"||!nr(i,jr))return null}const r=e.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]||!nr(i,jr))return null}return e}const si=Object.create(null);function cu(t,e){return{provider:t,prefix:e,icons:Object.create(null),missing:new Set}}function jt(t,e){const n=si[t]||(si[t]=Object.create(null));return n[e]||(n[e]=cu(t,e))}function za(t,e){return Ra(e)?Pa(e,(n,r)=>{r?t.icons[n]=r:t.missing.add(n)}):[]}function du(t,e,n){try{if(typeof n.body=="string")return t.icons[e]={...n},!0}catch{}return!1}const Ba=/^[a-z0-9]+(-[a-z0-9]+)*$/,$n=(t,e,n,r="")=>{const s=t.split(":");if(t.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 e&&!ln(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 e&&!ln(o)?null:o}if(n&&r===""){const o={provider:r,prefix:"",name:i};return e&&!ln(o,n)?null:o}return null},ln=(t,e)=>t?!!((e&&t.prefix===""||t.prefix)&&t.name):!1;let Wt=!1;function _a(t){return typeof t=="boolean"&&(Wt=t),Wt}function ii(t){const e=typeof t=="string"?$n(t,!0,Wt):t;if(e){const n=jt(e.provider,e.prefix),r=e.name;return n.icons[r]||(n.missing.has(r)?null:void 0)}}function uu(t,e){const n=$n(t,!0,Wt);if(!n)return!1;const r=jt(n.provider,n.prefix);return e?du(r,n.name,e):(r.missing.add(n.name),!0)}function fu(t,e){if(typeof t!="object")return!1;if(typeof e!="string"&&(e=t.provider||""),Wt&&!e&&!t.prefix){let s=!1;return Ra(t)&&(t.prefix="",Pa(t,(i,a)=>{uu(i,a)&&(s=!0)})),s}const n=t.prefix;if(!ln({prefix:n,name:"a"}))return!1;const r=jt(e,n);return!!za(r,t)}const Va=Object.freeze({width:null,height:null}),Ha=Object.freeze({...Va,...kn}),hu=/(-?[0-9.]*[0-9]+[0-9.]*)/g,mu=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function ai(t,e,n){if(e===1)return t;if(n=n||100,typeof t=="number")return Math.ceil(t*e*n)/n;if(typeof t!="string")return t;const r=t.split(hu);if(r===null||!r.length)return t;const s=[];let i=r.shift(),a=mu.test(i);for(;;){if(a){const o=parseFloat(i);isNaN(o)?s.push(i):s.push(Math.ceil(o*e*n)/n)}else s.push(i);if(i=r.shift(),i===void 0)return s.join("");a=!a}}function pu(t,e="defs"){let n="";const r=t.indexOf("<"+e);for(;r>=0;){const s=t.indexOf(">",r),i=t.indexOf("</"+e);if(s===-1||i===-1)break;const a=t.indexOf(">",i);if(a===-1)break;n+=t.slice(s+1,i).trim(),t=t.slice(0,r).trim()+t.slice(a+1)}return{defs:n,content:t}}function gu(t,e){return t?"<defs>"+t+"</defs>"+e:e}function xu(t,e,n){const r=pu(t);return gu(r.defs,e+r.content+n)}const yu=t=>t==="unset"||t==="undefined"||t==="none";function bu(t,e){const n={...Qr,...t},r={...Ha,...e},s={left:n.left,top:n.top,width:n.width,height:n.height};let i=n.body;[n,r].forEach(b=>{const x=[],k=b.hFlip,S=b.vFlip;let A=b.rotate;k?S?A+=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(A<0&&(A-=Math.floor(A/4)*4),A=A%4,A){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}A%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=xu(i,'<g transform="'+x.join(" ")+'">',"</g>"))});const a=r.width,o=r.height,c=s.width,d=s.height;let u,f;a===null?(f=o===null?"1em":o==="auto"?d:o,u=ai(f,c/d)):(u=a==="auto"?c:a,f=o===null?ai(u,d/c):o==="auto"?d:o);const p={},m=(b,x)=>{yu(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 vu=/\sid="(\S+)"/g,ku="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let wu=0;function Su(t,e=ku){const n=[];let r;for(;r=vu.exec(t);)n.push(r[1]);if(!n.length)return t;const s="suffix"+(Math.random()*16777216|Date.now()).toString(16);return n.forEach(i=>{const a=typeof e=="function"?e(i):e+(wu++).toString(),o=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");t=t.replace(new RegExp('([#;"])('+o+')([")]|\\.[a-z])',"g"),"$1"+a+s+"$3")}),t=t.replace(new RegExp(s,"g"),""),t}const Ar=Object.create(null);function Nu(t,e){Ar[t]=e}function Mr(t){return Ar[t]||Ar[""]}function Zr(t){let e;if(typeof t.resources=="string")e=[t.resources];else if(e=t.resources,!(e instanceof Array)||!e.length)return null;return{resources:e,path:t.path||"/",maxURL:t.maxURL||500,rotate:t.rotate||750,timeout:t.timeout||5e3,random:t.random===!0,index:t.index||0,dataAfterTimeout:t.dataAfterTimeout!==!1}}const Xr=Object.create(null),Tt=["https://api.simplesvg.com","https://api.unisvg.com"],cn=[];for(;Tt.length>0;)Tt.length===1||Math.random()>.5?cn.push(Tt.shift()):cn.push(Tt.pop());Xr[""]=Zr({resources:["https://api.iconify.design"].concat(cn)});function Cu(t,e){const n=Zr(e);return n===null?!1:(Xr[t]=n,!0)}function es(t){return Xr[t]}const ju=()=>{let t;try{if(t=fetch,typeof t=="function")return t}catch{}};let oi=ju();function Au(t,e){const n=es(t);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=e+".json?icons=";r=n.maxURL-s-n.path.length-i.length}return r}function Mu(t){return t===404}const Eu=(t,e,n)=>{const r=[],s=Au(t,e),i="icons";let a={type:i,provider:t,prefix:e,icons:[]},o=0;return n.forEach((c,d)=>{o+=c.length+1,o>=s&&d>0&&(r.push(a),a={type:i,provider:t,prefix:e,icons:[]},o=c.length),a.icons.push(c)}),r.push(a),r};function Tu(t){if(typeof t=="string"){const e=es(t);if(e)return e.path}return"/"}const Du=(t,e,n)=>{if(!oi){n("abort",424);return}let r=Tu(e.provider);switch(e.type){case"icons":{const i=e.prefix,o=e.icons.join(","),c=new URLSearchParams({icons:o});r+=i+".json?"+c.toString();break}case"custom":{const i=e.uri;r+=i.slice(0,1)==="/"?i.slice(1):i;break}default:n("abort",400);return}let s=503;oi(t+r).then(i=>{const a=i.status;if(a!==200){setTimeout(()=>{n(Mu(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)})},Iu={prepare:Eu,send:Du};function Ua(t,e){t.forEach(n=>{const r=n.loaderCallbacks;r&&(n.loaderCallbacks=r.filter(s=>s.id!==e))})}function $u(t){t.pendingCallbacksFlag||(t.pendingCallbacksFlag=!0,setTimeout(()=>{t.pendingCallbacksFlag=!1;const e=t.loaderCallbacks?t.loaderCallbacks.slice(0):[];if(!e.length)return;let n=!1;const r=t.provider,s=t.prefix;e.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(t.icons[d])a.loaded.push({provider:r,prefix:s,name:d});else if(t.missing.has(d))a.missing.push({provider:r,prefix:s,name:d});else return n=!0,!0;return!1}),a.pending.length!==o&&(n||Ua([t],i.id),i.callback(a.loaded.slice(0),a.missing.slice(0),a.pending.slice(0),i.abort))})}))}let Ou=0;function Lu(t,e,n){const r=Ou++,s=Ua.bind(null,n,r);if(!e.pending.length)return s;const i={id:r,icons:e,callback:t,abort:s};return n.forEach(a=>{(a.loaderCallbacks||(a.loaderCallbacks=[])).push(i)}),s}function Fu(t){const e={loaded:[],missing:[],pending:[]},n=Object.create(null);t.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 t.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]=jt(i,a));let u;o in d.icons?u=e.loaded:a===""||d.missing.has(o)?u=e.missing:u=e.pending;const f={provider:i,prefix:a,name:o};u.push(f)}),e}function Pu(t,e=!0,n=!1){const r=[];return t.forEach(s=>{const i=typeof s=="string"?$n(s,e,n):s;i&&r.push(i)}),r}const Ru={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function zu(t,e,n,r){const s=t.resources.length,i=t.random?Math.floor(Math.random()*s):t.index;let a;if(t.random){let M=t.resources.slice(0);for(a=[];M.length>1;){const D=Math.floor(Math.random()*M.length);a.push(M[D]),M=M.slice(0,D).concat(M.slice(D+1))}a=a.concat(M)}else a=t.resources.slice(i).concat(t.resources.slice(0,i));const o=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,D){D&&(m=[]),typeof M=="function"&&m.push(M)}function k(){return{startTime:o,payload:e,status:c,queriesSent:d,queriesPending:p.length,subscribe:x,abort:b}}function S(){c="failed",m.forEach(M=>{M(void 0,u)})}function A(){p.forEach(M=>{M.status==="pending"&&(M.status="aborted")}),p=[]}function N(M,D,B){const R=D!=="success";switch(p=p.filter(V=>V!==M),c){case"pending":break;case"failed":if(R||!t.dataAfterTimeout)return;break;default:return}if(D==="abort"){u=B,S();return}if(R){u=B,p.length||(a.length?j():S());return}if(v(),A(),!t.random){const V=t.resources.indexOf(M.resource);V!==-1&&V!==t.index&&(t.index=V)}c="completed",m.forEach(V=>{V(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(),S())},t.timeout);return}S();return}const D={status:"pending",resource:M,callback:(B,R)=>{N(D,B,R)}};p.push(D),d++,f=setTimeout(j,t.rotate),n(M,e,D.callback)}return setTimeout(j),k}function qa(t){const e={...Ru,...t};let n=[];function r(){n=n.filter(o=>o().status==="pending")}function s(o,c,d){const u=zu(e,o,c,(f,p)=>{r(),d&&d(f,p)});return n.push(u),u}function i(o){return n.find(c=>o(c))||null}return{query:s,find:i,setIndex:o=>{e.index=o},getIndex:()=>e.index,cleanup:r}}function li(){}const rr=Object.create(null);function Bu(t){if(!rr[t]){const e=es(t);if(!e)return;const n=qa(e),r={config:e,redundancy:n};rr[t]=r}return rr[t]}function _u(t,e,n){let r,s;if(typeof t=="string"){const i=Mr(t);if(!i)return n(void 0,424),li;s=i.send;const a=Bu(t);a&&(r=a.redundancy)}else{const i=Zr(t);if(i){r=qa(i);const a=t.resources?t.resources[0]:"",o=Mr(a);o&&(s=o.send)}}return!r||!s?(n(void 0,424),li):r.query(e,s,n)().abort}function ci(){}function Vu(t){t.iconsLoaderFlag||(t.iconsLoaderFlag=!0,setTimeout(()=>{t.iconsLoaderFlag=!1,$u(t)}))}function Hu(t){const e=[],n=[];return t.forEach(r=>{(r.match(Ba)?e:n).push(r)}),{valid:e,invalid:n}}function Dt(t,e,n){function r(){const s=t.pendingIcons;e.forEach(i=>{s&&s.delete(i),t.icons[i]||t.missing.add(i)})}if(n&&typeof n=="object")try{if(!za(t,n).length){r();return}}catch(s){console.error(s)}r(),Vu(t)}function di(t,e){t instanceof Promise?t.then(n=>{e(n)}).catch(()=>{e(null)}):e(t)}function Uu(t,e){t.iconsToLoad?t.iconsToLoad=t.iconsToLoad.concat(e).sort():t.iconsToLoad=e,t.iconsQueueFlag||(t.iconsQueueFlag=!0,setTimeout(()=>{t.iconsQueueFlag=!1;const{provider:n,prefix:r}=t,s=t.iconsToLoad;if(delete t.iconsToLoad,!s||!s.length)return;const i=t.loadIcon;if(t.loadIcons&&(s.length>1||!i)){di(t.loadIcons(s,r,n),u=>{Dt(t,s,u)});return}if(i){s.forEach(u=>{const f=i(u,r,n);di(f,p=>{const m=p?{prefix:r,icons:{[u]:p}}:null;Dt(t,[u],m)})});return}const{valid:a,invalid:o}=Hu(s);if(o.length&&Dt(t,o,null),!a.length)return;const c=r.match(Ba)?Mr(n):null;if(!c){Dt(t,a,null);return}c.prepare(n,r,a).forEach(u=>{_u(n,u,f=>{Dt(t,u.icons,f)})})}))}const qu=(t,e)=>{const n=Pu(t,!0,_a()),r=Fu(n);if(!r.pending.length){let c=!0;return e&&setTimeout(()=>{c&&e(r.loaded,r.missing,r.pending,ci)}),()=>{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(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&&Uu(c,d)}),e?Lu(e,r,i):ci};function Wu(t,e){const n={...t};for(const r in e){const s=e[r],i=typeof s;r in Va?(s===null||s&&(i==="string"||i==="number"))&&(n[r]=s):i===typeof n[r]&&(n[r]=r==="rotate"?s%4:s)}return n}const Ku=/[\s,]+/;function Ju(t,e){e.split(Ku).forEach(n=>{switch(n.trim()){case"horizontal":t.hFlip=!0;break;case"vertical":t.vFlip=!0;break}})}function Yu(t,e=0){const n=t.replace(/^-?[0-9.]*/,"");function r(s){for(;s<0;)s+=4;return s%4}if(n===""){const s=parseInt(t);return isNaN(s)?0:r(s)}else if(n!==t){let s=0;switch(n){case"%":s=25;break;case"deg":s=90}if(s){let i=parseFloat(t.slice(0,t.length-n.length));return isNaN(i)?0:(i=i/s,i%1===0?r(i):0)}}return e}function Gu(t,e){let n=t.indexOf("xlink:")===-1?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const r in e)n+=" "+r+'="'+e[r]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+n+">"+t+"</svg>"}function Qu(t){return t.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function Zu(t){return"data:image/svg+xml,"+Qu(t)}function Xu(t){return'url("'+Zu(t)+'")'}let Pt;function ef(){try{Pt=window.trustedTypes.createPolicy("iconify",{createHTML:t=>t})}catch{Pt=null}}function tf(t){return Pt===void 0&&ef(),Pt?Pt.createHTML(t):t}const Wa={...Ha,inline:!1},nf={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},rf={display:"inline-block"},Er={backgroundColor:"currentColor"},Ka={backgroundColor:"transparent"},ui={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},fi={WebkitMask:Er,mask:Er,background:Ka};for(const t in fi){const e=fi[t];for(const n in ui)e[t+n]=ui[n]}const sf={...Wa,inline:!0};function hi(t){return t+(t.match(/^[-0-9.]+$/)?"px":"")}const af=(t,e,n)=>{const r=e.inline?sf:Wa,s=Wu(r,e),i=e.mode||"svg",a={},o=e.style||{},c={...i==="svg"?nf:{}};if(n){const x=$n(n,!1,!0);if(x){const k=["iconify"],S=["provider","prefix"];for(const A of S)x[A]&&k.push("iconify--"+x[A]);c.className=k.join(" ")}}for(let x in e){const k=e[x];if(k!==void 0)switch(x){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":c.ref=k;break;case"className":c[x]=(c[x]?c[x]+" ":"")+k;break;case"inline":case"hFlip":case"vFlip":s[x]=k===!0||k==="true"||k===1;break;case"flip":typeof k=="string"&&Ju(s,k);break;case"color":a.color=k;break;case"rotate":typeof k=="string"?s[x]=Yu(k):typeof k=="number"&&(s[x]=k);break;case"ariaHidden":case"aria-hidden":k!==!0&&k!=="true"&&delete c["aria-hidden"];break;default:r[x]===void 0&&(c[x]=k)}}const d=bu(t,s),u=d.attributes;if(s.inline&&(a.verticalAlign="-0.125em"),i==="svg"){c.style={...a,...o},Object.assign(c,u);let x=0,k=e.id;return typeof k=="string"&&(k=k.replace(/-/g,"_")),c.dangerouslySetInnerHTML={__html:tf(Su(d.body,k?()=>k+"ID"+x++:"iconifyReact"))},y.createElement("svg",c)}const{body:f,width:p,height:m}=t,v=i==="mask"||(i==="bg"?!1:f.indexOf("currentColor")!==-1),b=Gu(f,{...u,width:p+"",height:m+""});return c.style={...a,"--svg":Xu(b),width:hi(u.width),height:hi(u.height),...rf,...v?Er:Ka,...o},y.createElement("span",c)};_a(!0);Nu("",Iu);if(typeof document<"u"&&typeof window<"u"){const t=window;if(t.IconifyPreload!==void 0){const e=t.IconifyPreload,n="Invalid IconifyPreload syntax.";typeof e=="object"&&e!==null&&(e instanceof Array?e:[e]).forEach(r=>{try{(typeof r!="object"||r===null||r instanceof Array||typeof r.icons!="object"||typeof r.prefix!="string"||!fu(r))&&console.error(n)}catch{console.error(n)}})}if(t.IconifyProviders!==void 0){const e=t.IconifyProviders;if(typeof e=="object"&&e!==null)for(let n in e){const r="IconifyProviders["+n+"] is invalid.";try{const s=e[n];if(typeof s!="object"||!s||s.resources===void 0)continue;Cu(n,s)||console.error(r)}catch{console.error(r)}}}}function Ja(t){const[e,n]=y.useState(!!t.ssr),[r,s]=y.useState({});function i(m){if(m){const v=t.icon;if(typeof v=="object")return{name:"",data:v};const b=ii(v);if(b)return{name:v,data:b}}return{name:""}}const[a,o]=y.useState(i(!!t.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=t.icon;if(typeof v=="object"){d({name:"",data:v});return}const b=ii(v);if(d({name:v,data:b}))if(b===void 0){const x=qu([v],u);s({callback:x})}else b&&((m=t.onLoad)===null||m===void 0||m.call(t,v))}y.useEffect(()=>(n(!0),c),[]),y.useEffect(()=>{e&&u()},[t.icon,e]);const{name:f,data:p}=a;return p?af({...Qr,...p},t,f):t.children?t.children:t.fallback?t.fallback:y.createElement("span",{})}const U=y.forwardRef((t,e)=>Ja({...t,_ref:e}));y.forwardRef((t,e)=>Ja({inline:!0,...t,_ref:e}));const sr=({icon:t,children:e,testId:n})=>l.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600","data-testid":n,children:[l.jsx(U,{icon:t,width:20,className:"text-default-500"}),l.jsx("span",{children:e})]}),of=({classes:t="",name:e,imageUrl:n,eventDate:r,eventTime:s,location:i,description:a,showImage:o=!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 k=b.current.scrollHeight>b.current.clientHeight;v(k)}};return x(),window.addEventListener("resize",x),()=>window.removeEventListener("resize",x)},[a]),l.jsxs(h.Card,{className:h.cn("border-0 shadow-none",t),"data-testid":"event-details-root",children:[l.jsxs(h.CardHeader,{className:"pt-2 pb-0 flex-col items-start space-y-2","data-testid":"event-details-header",children:[o&&n&&l.jsx("div",{className:"w-full aspect-[3/1] overflow-hidden rounded-xl","data-testid":"event-details-image-wrapper",children:l.jsx(h.Image,{removeWrapper:!0,loading:c,alt:`Event image for ${e}`,className:"w-full h-full object-cover object-center",src:n,"data-testid":"event-details-image"})}),l.jsx("h2",{className:"font-semibold text-xl text-gray-800","data-testid":"event-details-title",children:e})]}),l.jsxs(h.CardBody,{className:"py-3 space-y-3","data-testid":"event-details-body",children:[l.jsx("h3",{className:"font-semibold text-base text-gray-700","data-testid":"event-details-info-label",children:u.eventInformation}),l.jsxs("div",{className:"flex flex-wrap gap-4","data-testid":"event-details-info",children:[r&&l.jsx(sr,{icon:"solar:calendar-minimalistic-linear",testId:"event-details-date",children:r}),s&&l.jsx(sr,{icon:"solar:clock-circle-linear",testId:"event-details-time",children:s}),i&&l.jsx(sr,{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: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&&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"})]}),(m||f)&&l.jsx("div",{className:"flex justify-end mt-1",children:l.jsx(q,{onPress:()=>p(!f),variant:"light",className:h.cn("text-primary",d),startContent:l.jsx(U,{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 Ya(t,e="en-US",n="USD"){try{return new Intl.NumberFormat(e,{style:"currency",currency:n,minimumFractionDigits:2,maximumFractionDigits:2}).format(t)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${t.toFixed(2)}`}}function lf(t){const e=t.replace(/[^\d.,-]/g,""),n=e.match(/,\d{1,2}$/);let r;n?r=e.replace(/\./g,"").replace(",","."):r=e.replace(/,/g,"");const s=parseFloat(r);return isNaN(s)?null:s}const cf={person:"Person",people:"People",tickets:"Tickets:",soldOut:"Sold Out",maxReached:"Maximum number of tickets allowed reached"},tn=t=>typeof t=="number"&&!isNaN(t),ts=({offer:t,quantity:e,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:f=!0,showDescription:p=!0,showPeopleCount:m=!0,showPrice:v=!0,classNames:b={},"data-testid":x,selectedColor:k="default"})=>{const S={...cf,...a},[A,N]=y.useState(n),j=e!==void 0?e:A,M=le=>{if(c)return;const xe=Math.max(0,j+le);e===void 0&&N(xe),r?.(t.id,xe)},D=y.useMemo(()=>!tn(t.totalTicketsSold)||!tn(t.ticketsAllowed)?!1:t.totalTicketsSold>=t.ticketsAllowed,[t.totalTicketsSold,t.ticketsAllowed]),B=y.useMemo(()=>D||!tn(t.ticketsAllowed)?!1:j>=t.ticketsAllowed-(t.totalTicketsSold??0),[D,t.ticketsAllowed,t.totalTicketsSold,j]),R=Ya(t.price,i,s),V=()=>o?.renderName?o.renderName(t.name,t):l.jsx("h2",{"data-testid":"offer-card-name",className:h.cn("text-base font-medium",b.name),children:t.name}),I=()=>v?o?.renderPrice?o.renderPrice(t.price,R,t):l.jsx("p",{"data-testid":"offer-card-price",className:h.cn("text-primary text-base mt-1",b.price),children:R}):null,T=()=>!p||!t.description?null:o?.renderDescription?o.renderDescription(t.description,t):l.jsx("p",{"data-testid":"offer-card-description",className:h.cn("mb-4 text-sm text-gray-700 leading-relaxed",b.description),children:t.description}),O=()=>{if(!m||!tn(t.numberOfPeople)||t.numberOfPeople<=0)return null;const le=t.numberOfPeople===1?S.person:S.people;return o?.renderPeopleCount?o.renderPeopleCount(t.numberOfPeople,le,t):l.jsxs("p",{"data-testid":"offer-card-people-count",className:h.cn("text-sm text-gray-600 flex items-center mt-2",b.peopleCount),children:[l.jsx(U,{icon:t.numberOfPeople<=1?"solar:user-rounded-outline":"solar:users-group-rounded-outline",width:20,className:"mr-1"}),t.numberOfPeople," ",le]})},P=()=>{const le=j===0||c,xe=B||c;return o?.renderQuantitySelector?o.renderQuantitySelector({quantity:j,onIncrement:()=>M(1),onDecrement:()=>M(-1),isDecrementDisabled:le,isIncrementDisabled:xe,isDisabled:c}):l.jsxs("div",{className:h.cn("flex items-center gap-2",b.quantitySelector),children:[l.jsx(q,{"data-testid":"offer-card-decrement-button",onPress:()=>M(-1),isDisabled:le,variant:d,color:j>0?k:u,radius:"full",isIconOnly:!0,size:"sm","aria-label":"Decrease quantity",children:l.jsx(U,{icon:"gravity-ui:minus",width:16})}),l.jsx("span",{"data-testid":"offer-card-quantity",className:h.cn("min-w-[2rem] text-center font-medium"),children:j}),l.jsx(q,{"data-testid":"offer-card-increment-button",onPress:()=>M(1),isDisabled:xe,variant:d,color:j>0?k:u,radius:"full",isIconOnly:!0,size:"sm","aria-label":"Increase quantity",children:l.jsx(U,{icon:"gravity-ui:plus",width:16})})]})},K=()=>o?.renderSoldOut?o.renderSoldOut(S.soldOut):l.jsx(h.Chip,{"data-testid":"offer-card-sold-out-chip",color:"danger",className:h.cn("gap-2 px-4 h-8",b.soldOut),startContent:l.jsx(U,{icon:"gravity-ui:circle-info-fill",width:14}),children:l.jsx("span",{className:"font-medium text-sm",children:S.soldOut})}),X=()=>o?.renderMaxReachedAlert?o.renderMaxReachedAlert(S.maxReached):l.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:l.jsx(U,{icon:"gravity-ui:triangle-exclamation-fill",className:"text-black",width:16}),children:l.jsx("span",{className:"font-medium text-sm",children:S.maxReached})}),J=l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-1 xl:grid-cols-3 lg:grid-cols-3 gap-2 items-start",children:[l.jsxs("div",{className:h.cn("h-full col-span-2",D?"opacity-50 pointer-events-none select-none":""),children:[V(),I(),l.jsxs("div",{className:h.cn("md:col-span-1 xl:col-span-2 lg:col-span-1 mb-2",D?"opacity-50 pointer-events-none select-none":""),children:[O(),T()]})]}),l.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:D?K():P()})]}),ue=B&&!D&&l.jsx(Re.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?l.jsxs(h.Card,{className:h.cn("w-full",b.base),"data-testid":x||`offer-card-${t.id}`,children:[l.jsx(h.CardBody,{className:h.cn("pt-1 pb-0",b.body),children:J}),l.jsx(Re.AnimatePresence,{children:ue&&l.jsx(h.CardFooter,{className:h.cn("w-full mt-0 pt-0",b.footer),children:ue})})]}):l.jsxs("div",{className:h.cn("w-full",b.base),"data-testid":x||`offer-card-${t.id}`,children:[l.jsx("div",{className:h.cn("pt-1 pb-0",b.body),children:J}),l.jsx(Re.AnimatePresence,{children:ue&&l.jsx("div",{className:h.cn("w-full mt-0 pt-0",b.footer),children:ue})})]})};ts.displayName="OfferCard";const Ga=({message:t="No offers available.",icon:e="solar:ticket-sale-outline",iconSize:n=48,showCard:r=!0,classNames:s={},renderEmpty:i})=>{if(i){const o=i();return r?l.jsx(h.Card,{"data-testid":"offer-card-empty",className:h.cn("w-full",s.base),children:l.jsx(h.CardBody,{"data-testid":"offer-card-empty-body",children:o})}):l.jsx("div",{"data-testid":"offer-card-empty",className:h.cn("w-full",s.base),children:o})}const a=l.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:[l.jsx(U,{"data-testid":"offer-card-empty-icon",icon:e,width:n,className:h.cn("mb-4",s.icon)}),l.jsx("h3",{"data-testid":"offer-card-empty-message",className:h.cn("text-lg",s.message),children:t})]});return r?l.jsx(h.Card,{"data-testid":"offer-card-empty",className:h.cn("w-full",s.base),children:l.jsx(h.CardBody,{"data-testid":"offer-card-empty-body",children:a})}):l.jsx("div",{"data-testid":"offer-card-empty",className:h.cn("w-full",s.base),children:a})};Ga.displayName="OfferCardEmpty";const df={title:"Error Fetching Offers",description:"An error occurred while fetching offers."},Qa=({error:t,labels:e,showCard:n=!0,color:r="danger",classNames:s={}})=>{const i={...df,...e},a=l.jsx(h.Alert,{"data-testid":"offer-card-error-alert",color:r,title:i.title,description:t||i.description,className:s.alert});return n?l.jsx(h.Card,{"data-testid":"offer-card-error",className:h.cn("w-full",s.base),children:l.jsx(h.CardBody,{"data-testid":"offer-card-error-body",children:a})}):l.jsx("div",{"data-testid":"offer-card-error",className:h.cn("w-full",s.base),children:a})};Qa.displayName="OfferCardError";const uf={1:"space-y-1",2:"space-y-2",3:"space-y-3",4:"space-y-4",5:"space-y-5",6:"space-y-6"},Za=({quantity:t=2,gap:e=4,classNames:n={}})=>{const r=uf[e];return l.jsx("div",{"data-testid":"offer-card-skeleton-container",className:h.cn(r,n.base),children:Array.from({length:t}).map((s,i)=>l.jsxs(h.Card,{"data-testid":`offer-card-skeleton-${i}`,className:h.cn("w-full",n.card),children:[l.jsx(h.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(h.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(h.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(h.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(h.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(h.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(h.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(h.Skeleton,{"data-testid":`offer-card-skeleton-btn-dec-${i}`,className:"w-8 h-8 rounded-md bg-default-300"}),l.jsx(h.Skeleton,{"data-testid":`offer-card-skeleton-btn-qty-${i}`,className:"w-8 h-8 rounded-md bg-default-200"}),l.jsx(h.Skeleton,{"data-testid":`offer-card-skeleton-btn-inc-${i}`,className:"w-8 h-8 rounded-md bg-default-300"})]})]})})]})})]},i))})};Za.displayName="OfferCardSkeleton";const Xa={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.15,delayChildren:.1}}},eo={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"}}},ff={1:"gap-1",2:"gap-2",3:"gap-3",4:"gap-4",5:"gap-5",6:"gap-6"},to=({offers:t=[],selection:e,defaultSelection:n={},onSelectionChange:r,onQuantityChange:s,currency:i="USD",locale:a="en-US",labels:o,slots:c,isDisabled:d=!1,buttonVariant:u="bordered",buttonColor:f="default",showCard:p=!0,animated:m=!0,gap:v=2,classNames:b={}})=>{const[x,k]=y.useState(n),S=e!==void 0?e:x,A=y.useCallback((B,R)=>{const V={...S,[B]:Math.max(0,R)};e===void 0&&k(V),r?.(V),s?.(B,V[B])},[S,e,r,s]),N=[...t].sort((B,R)=>(B.position??0)-(R.position??0)),j=ff[v],M=h.cn("grid mx-auto pt-2",j,b.base),D=B=>l.jsx(ts,{offer:B,quantity:S[B.id]||0,onQuantityChange:A,currency:i,locale:a,labels:o,slots:c,isDisabled:d,buttonVariant:u,buttonColor:f,showCard:p,classNames:b.card},B.id);return m?l.jsx(Re.motion.div,{"data-testid":"offer-card-list",className:M,variants:Xa,initial:"hidden",animate:"show",children:l.jsx(Re.AnimatePresence,{children:N.map(B=>l.jsx(Re.motion.div,{"data-testid":`offer-card-list-item-${B.id}`,className:b.cardWrapper,variants:eo,exit:{opacity:0,y:-20},transition:{duration:.3},children:D(B)},B.id))})}):l.jsx("div",{"data-testid":"offer-card-list",className:M,children:N.map(D)})};to.displayName="OfferCardList";var Gt=t=>t.type==="checkbox",dt=t=>t instanceof Date,Ae=t=>t==null;const no=t=>typeof t=="object";var ge=t=>!Ae(t)&&!Array.isArray(t)&&no(t)&&!dt(t),ro=t=>ge(t)&&t.target?Gt(t.target)?t.target.checked:t.target.value:t,hf=t=>t.substring(0,t.search(/\.\d+(\.|$)/))||t,so=(t,e)=>t.has(hf(e)),mf=t=>{const e=t.constructor&&t.constructor.prototype;return ge(e)&&e.hasOwnProperty("isPrototypeOf")},ns=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function he(t){if(t instanceof Date)return new Date(t);const e=typeof FileList<"u"&&t instanceof FileList;if(ns&&(t instanceof Blob||e))return t;const n=Array.isArray(t);if(!n&&!(ge(t)&&mf(t)))return t;const r=n?[]:Object.create(Object.getPrototypeOf(t));for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[s]=he(t[s]));return r}var On=t=>/^\w*$/.test(t),oe=t=>t===void 0,rs=t=>Array.isArray(t)?t.filter(Boolean):[],ss=t=>rs(t.replace(/["|']|\]/g,"").split(/\.|\[/)),L=(t,e,n)=>{if(!e||!ge(t))return n;const r=(On(e)?[e]:ss(e)).reduce((s,i)=>Ae(s)?s:s[i],t);return oe(r)||r===t?oe(t[e])?n:t[e]:r},Ee=t=>typeof t=="boolean",je=t=>typeof t=="function",ie=(t,e,n)=>{let r=-1;const s=On(e)?[e]:ss(e),i=s.length,a=i-1;for(;++r<i;){const o=s[r];let c=n;if(r!==a){const d=t[o];c=ge(d)||Array.isArray(d)?d:isNaN(+s[r+1])?{}:[]}if(o==="__proto__"||o==="constructor"||o==="prototype")return;t[o]=c,t=t[o]}};const wn={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},Fe={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"},io=y.createContext(null);io.displayName="HookFormControlContext";const is=()=>y.useContext(io);var ao=(t,e,n,r=!0)=>{const s={defaultValues:e._defaultValues};for(const i in t)Object.defineProperty(s,i,{get:()=>{const a=i;return e._proxyFormState[a]!==Fe.all&&(e._proxyFormState[a]=!r||Fe.all),n&&(n[a]=!0),t[a]}});return s};const as=typeof window<"u"?y.useLayoutEffect:y.useEffect;function pf(t){const e=is(),{control:n=e,disabled:r,name:s,exact:i}=t||{},[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 as(()=>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(()=>ao(a,n,c.current,!1),[a,n])}var De=t=>typeof t=="string",Tr=(t,e,n,r,s)=>De(t)?(r&&e.watch.add(t),L(n,t,s)):Array.isArray(t)?t.map(i=>(r&&e.watch.add(i),L(n,i))):(r&&(e.watchAll=!0),n),Dr=t=>Ae(t)||!no(t);function Pe(t,e,n=new WeakSet){if(Dr(t)||Dr(e))return Object.is(t,e);if(dt(t)&&dt(e))return Object.is(t.getTime(),e.getTime());const r=Object.keys(t),s=Object.keys(e);if(r.length!==s.length)return!1;if(n.has(t)||n.has(e))return!0;n.add(t),n.add(e);for(const i of r){const a=t[i];if(!s.includes(i))return!1;if(i!=="ref"){const o=e[i];if(dt(a)&&dt(o)||ge(a)&&ge(o)||Array.isArray(a)&&Array.isArray(o)?!Pe(a,o,n):!Object.is(a,o))return!1}}return!0}function gf(t){const e=is(),{control:n=e,name:r,defaultValue:s,disabled:i,exact:a,compute:o}=t||{},c=y.useRef(s),d=y.useRef(o),u=y.useRef(void 0),f=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=Tr(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=Tr(r,n._names,N||n._formValues,!1,c.current);if(d.current){const M=d.current(j);Pe(M,u.current)||(v(M),u.current=M)}else v(j)}},[n._formValues,n._names,i,r]);as(()=>((f.current!==n||!Pe(p.current,r))&&(f.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 k=f.current!==n,S=p.current,A=y.useMemo(()=>{if(i)return null;const N=!k&&!Pe(S,r);return k||N?b():null},[i,k,r,S,b]);return A!==null?A:m}function xf(t){const e=is(),{name:n,disabled:r,control:s=e,shouldUnregister:i,defaultValue:a,exact:o=!0}=t,c=so(s._names.array,n),d=y.useMemo(()=>L(s._formValues,n,L(s._defaultValues,n,a)),[s,n,a]),u=gf({control:s,name:n,defaultValue:d,exact:o}),f=pf({control:s,name:n,exact:o}),p=y.useRef(t),m=y.useRef(void 0),v=y.useRef(s.register(n,{...t.rules,value:u,...Ee(t.disabled)?{disabled:t.disabled}:{}}));p.current=t;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(N=>v.current.onChange({target:{value:ro(N),name:n},type:wn.CHANGE}),[n]),k=y.useCallback(()=>v.current.onBlur({target:{value:L(s._formValues,n),name:n},type:wn.BLUR}),[n,s._formValues]),S=y.useCallback(N=>{const j=L(s._fields,n);j&&j._f&&N&&(j._f.ref={focus:()=>je(N.focus)&&N.focus(),select:()=>je(N.select)&&N.select(),setCustomValidity:M=>je(N.setCustomValidity)&&N.setCustomValidity(M),reportValidity:()=>je(N.reportValidity)&&N.reportValidity()})},[s._fields,n]),A=y.useMemo(()=>({name:n,value:u,...Ee(r)||f.disabled?{disabled:f.disabled||r}:{},onChange:x,onBlur:k,ref:S}),[n,r,f.disabled,x,k,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,...Ee(p.current.disabled)?{disabled:p.current.disabled}:{}});const M=(D,B)=>{const R=L(s._fields,D);R&&R._f&&(R._f.mount=B)};if(M(n,!0),N){const D=he(L(s._options.defaultValues,n,p.current.defaultValue));ie(s._defaultValues,n,D),oe(L(s._formValues,n))&&ie(s._formValues,n,D)}return!c&&s.register(n),m.current=n,()=>{(c?N&&!s._state.action:N)?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 yf=y.createContext(null);yf.displayName="HookFormContext";var bf=(t,e,n,r,s)=>e?{...n[t],types:{...n[t]&&n[t].types?n[t].types:{},[r]:s||!0}}:{},Rt=t=>Array.isArray(t)?t:[t],mi=()=>{let t=[];return{get observers(){return t},next:s=>{for(const i of t)i.next&&i.next(s)},subscribe:s=>(t.push(s),{unsubscribe:()=>{t=t.filter(i=>i!==s)}}),unsubscribe:()=>{t=[]}}};function oo(t,e){const n={};for(const r in t)if(t.hasOwnProperty(r)){const s=t[r],i=e[r];if(s&&ge(s)&&i){const a=oo(s,i);ge(a)&&(n[r]=a)}else t[r]&&(n[r]=i)}return n}var Ne=t=>ge(t)&&!Object.keys(t).length,os=t=>t.type==="file",Sn=t=>{if(!ns)return!1;const e=t?t.ownerDocument:0;return t instanceof(e&&e.defaultView?e.defaultView.HTMLElement:HTMLElement)},lo=t=>t.type==="select-multiple",ls=t=>t.type==="radio",vf=t=>ls(t)||Gt(t),ir=t=>Sn(t)&&t.isConnected;function kf(t,e){const n=e.slice(0,-1).length;let r=0;for(;r<n;)t=oe(t)?r++:t[e[r++]];return t}function wf(t){for(const e in t)if(t.hasOwnProperty(e)&&!oe(t[e]))return!1;return!0}function me(t,e){const n=Array.isArray(e)?e:On(e)?[e]:ss(e),r=n.length===1?t:kf(t,n),s=n.length-1,i=n[s];return r&&delete r[i],s!==0&&(ge(r)&&Ne(r)||Array.isArray(r)&&wf(r))&&me(t,n.slice(0,-1)),t}var Sf=t=>{for(const e in t)if(je(t[e]))return!0;return!1};function co(t){return Array.isArray(t)||ge(t)&&!Sf(t)}function Ir(t,e={}){for(const n in t){const r=t[n];co(r)?(e[n]=Array.isArray(r)?[]:{},Ir(r,e[n])):oe(r)||(e[n]=!0)}return e}function St(t,e,n){n||(n=Ir(e));for(const r in t){const s=t[r];if(co(s))oe(e)||Dr(n[r])?n[r]=Ir(s,Array.isArray(s)?[]:{}):St(s,Ae(e)?{}:e[r],n[r]);else{const i=e[r];n[r]=!Pe(s,i)}}return n}const pi={value:!1,isValid:!1},gi={value:!0,isValid:!0};var uo=t=>{if(Array.isArray(t)){if(t.length>1){const e=t.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:e,isValid:!!e.length}}return t[0].checked&&!t[0].disabled?t[0].attributes&&!oe(t[0].attributes.value)?oe(t[0].value)||t[0].value===""?gi:{value:t[0].value,isValid:!0}:gi:pi}return pi},fo=(t,{valueAsNumber:e,valueAsDate:n,setValueAs:r})=>oe(t)?t:e?t===""?NaN:t&&+t:n&&De(t)?new Date(t):r?r(t):t;const xi={isValid:!1,value:null};var ho=t=>Array.isArray(t)?t.reduce((e,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:e,xi):xi;function yi(t){const e=t.ref;return os(e)?e.files:ls(e)?ho(t.refs).value:lo(e)?[...e.selectedOptions].map(({value:n})=>n):Gt(e)?uo(t.refs).value:fo(oe(e.value)?t.ref.value:e.value,t)}var Nf=(t,e,n,r)=>{const s={};for(const i of t){const a=L(e,i);a&&ie(s,i,a._f)}return{criteriaMode:n,names:[...t],fields:s,shouldUseNativeValidation:r}},Nn=t=>t instanceof RegExp,It=t=>oe(t)?t:Nn(t)?t.source:ge(t)?Nn(t.value)?t.value.source:t.value:t,bi=t=>({isOnSubmit:!t||t===Fe.onSubmit,isOnBlur:t===Fe.onBlur,isOnChange:t===Fe.onChange,isOnAll:t===Fe.all,isOnTouch:t===Fe.onTouched});const vi="AsyncFunction";var Cf=t=>!!t&&!!t.validate&&!!(je(t.validate)&&t.validate.constructor.name===vi||ge(t.validate)&&Object.values(t.validate).find(e=>e.constructor.name===vi)),jf=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate),ki=(t,e,n)=>!n&&(e.watchAll||e.watch.has(t)||[...e.watch].some(r=>t.startsWith(r)&&/^\.\w+/.test(t.slice(r.length))));const zt=(t,e,n,r)=>{for(const s of n||Object.keys(t)){const i=L(t,s);if(i){const{_f:a,...o}=i;if(a){if(a.refs&&a.refs[0]&&e(a.refs[0],s)&&!r)return!0;if(a.ref&&e(a.ref,a.name)&&!r)return!0;if(zt(o,e))break}else if(ge(o)&&zt(o,e))break}}};function wi(t,e,n){const r=L(t,n);if(r||On(n))return{error:r,name:n};const s=n.split(".");for(;s.length;){const i=s.join("."),a=L(e,i),o=L(t,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 Af=(t,e,n,r)=>{n(t);const{name:s,...i}=t;return Ne(i)||Object.keys(i).length>=Object.keys(e).length||Object.keys(i).find(a=>e[a]===(!r||Fe.all))},Mf=(t,e,n)=>!t||!e||t===e||Rt(t).some(r=>r&&(n?r===e:r.startsWith(e)||e.startsWith(r))),Ef=(t,e,n,r,s)=>s.isOnAll?!1:!n&&s.isOnTouch?!(e||t):(n?r.isOnBlur:s.isOnBlur)?!t:(n?r.isOnChange:s.isOnChange)?t:!0,Tf=(t,e)=>!rs(L(t,e)).length&&me(t,e),Df=(t,e,n)=>{const r=Rt(L(t,n));return ie(r,"root",e[n]),ie(t,n,r),t};function Si(t,e,n="validate"){if(De(t)||Array.isArray(t)&&t.every(De)||Ee(t)&&!t)return{type:n,message:De(t)?t:"",ref:e}}var bt=t=>ge(t)&&!Nn(t)?t:{value:t,message:""},Ni=async(t,e,n,r,s,i)=>{const{ref:a,refs:o,required:c,maxLength:d,minLength:u,min:f,max:p,pattern:m,validate:v,name:b,valueAsNumber:x,mount:k}=t._f,S=L(n,b);if(!k||e.has(b))return{};const A=o?o[0]:a,N=T=>{s&&A.reportValidity&&(A.setCustomValidity(Ee(T)?"":T||""),A.reportValidity())},j={},M=ls(a),D=Gt(a),B=M||D,R=(x||os(a))&&oe(a.value)&&oe(S)||Sn(a)&&a.value===""||S===""||Array.isArray(S)&&!S.length,V=bf.bind(null,b,r,j),I=(T,O,P,K=Ue.maxLength,X=Ue.minLength)=>{const J=T?O:P;j[b]={type:T?K:X,message:J,ref:a,...V(T?K:X,J)}};if(i?!Array.isArray(S)||!S.length:c&&(!B&&(R||Ae(S))||Ee(S)&&!S||D&&!uo(o).isValid||M&&!ho(o).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,...V(Ue.required,O)},!r))return N(O),j}if(!R&&(!Ae(f)||!Ae(p))){let T,O;const P=bt(p),K=bt(f);if(!Ae(S)&&!isNaN(S)){const X=a.valueAsNumber||S&&+S;Ae(P.value)||(T=X>P.value),Ae(K.value)||(O=X<K.value)}else{const X=a.valueAsDate||new Date(S),J=xe=>new Date(new Date().toDateString()+" "+xe),ue=a.type=="time",le=a.type=="week";De(P.value)&&S&&(T=ue?J(S)>J(P.value):le?S>P.value:X>new Date(P.value)),De(K.value)&&S&&(O=ue?J(S)<J(K.value):le?S<K.value:X<new Date(K.value))}if((T||O)&&(I(!!T,P.message,K.message,Ue.max,Ue.min),!r))return N(j[b].message),j}if((d||u)&&!R&&(De(S)||i&&Array.isArray(S))){const T=bt(d),O=bt(u),P=!Ae(T.value)&&S.length>+T.value,K=!Ae(O.value)&&S.length<+O.value;if((P||K)&&(I(P,T.message,O.message),!r))return N(j[b].message),j}if(m&&!R&&De(S)){const{value:T,message:O}=bt(m);if(Nn(T)&&!S.match(T)&&(j[b]={type:Ue.pattern,message:O,ref:a,...V(Ue.pattern,O)},!r))return N(O),j}if(v){if(je(v)){const T=await v(S,n),O=Si(T,A);if(O&&(j[b]={...O,...V(Ue.validate,O.message)},!r))return N(O.message),j}else if(ge(v)){let T={};for(const O in v){if(!Ne(T)&&!r)break;const P=Si(await v[O](S,n),A,O);P&&(T={...P,...V(O,P.message)},N(P.message),r&&(j[b]=T))}if(!Ne(T)&&(j[b]={ref:A,...T},!r))return j}}return N(!0),j};const If={mode:Fe.onSubmit,reValidateMode:Fe.onChange,shouldFocusError:!0};function $f(t={}){let e={...If,...t},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:je(e.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1},r={},s=ge(e.defaultValues)||ge(e.values)?he(e.defaultValues||e.values)||{}:{},i=e.shouldUnregister?{}:he(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},f={...u};let p={...f};const m={array:mi(),state:mi()},v=e.criteriaMode===Fe.all,b=g=>w=>{clearTimeout(d),d=setTimeout(g,w)},x=async g=>{if(!a.keepIsValid&&!e.disabled&&(f.isValid||p.isValid||g)){let w;e.resolver?(w=Ne((await B()).errors),k()):w=await V(r,!0),w!==n.isValid&&m.state.next({isValid:w})}},k=(g,w)=>{!e.disabled&&(f.isValidating||f.validatingFields||p.isValidating||p.validatingFields)&&((g||Array.from(o.mount)).forEach(C=>{C&&(w?ie(n.validatingFields,C,w):me(n.validatingFields,C))}),m.state.next({validatingFields:n.validatingFields,isValidating:!Ne(n.validatingFields)}))},S=(g,w=[],C,F,$=!0,E=!0)=>{if(F&&C&&!e.disabled){if(a.action=!0,E&&Array.isArray(L(r,g))){const _=C(L(r,g),F.argA,F.argB);$&&ie(r,g,_)}if(E&&Array.isArray(L(n.errors,g))){const _=C(L(n.errors,g),F.argA,F.argB);$&&ie(n.errors,g,_),Tf(n.errors,g)}if((f.touchedFields||p.touchedFields)&&E&&Array.isArray(L(n.touchedFields,g))){const _=C(L(n.touchedFields,g),F.argA,F.argB);$&&ie(n.touchedFields,g,_)}(f.dirtyFields||p.dirtyFields)&&(n.dirtyFields=St(s,i)),m.state.next({name:g,isDirty:T(g,w),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else ie(i,g,w)},A=(g,w)=>{ie(n.errors,g,w),m.state.next({errors:n.errors})},N=g=>{n.errors=g,m.state.next({errors:n.errors,isValid:!1})},j=(g,w,C,F)=>{const $=L(r,g);if($){const E=L(i,g,oe(C)?L(s,g):C);oe(E)||F&&F.defaultChecked||w?ie(i,g,w?E:yi($._f)):K(g,E),a.mount&&!a.action&&x()}},M=(g,w,C,F,$)=>{let E=!1,_=!1;const ee={name:g};if(!e.disabled){if(!C||F){(f.isDirty||p.isDirty)&&(_=n.isDirty,n.isDirty=ee.isDirty=T(),E=_!==ee.isDirty);const te=Pe(L(s,g),w);_=!!L(n.dirtyFields,g),te?me(n.dirtyFields,g):ie(n.dirtyFields,g,!0),ee.dirtyFields=n.dirtyFields,E=E||(f.dirtyFields||p.dirtyFields)&&_!==!te}if(C){const te=L(n.touchedFields,g);te||(ie(n.touchedFields,g,C),ee.touchedFields=n.touchedFields,E=E||(f.touchedFields||p.touchedFields)&&te!==C)}E&&$&&m.state.next(ee)}return E?ee:{}},D=(g,w,C,F)=>{const $=L(n.errors,g),E=(f.isValid||p.isValid)&&Ee(w)&&n.isValid!==w;if(e.delayError&&C?(c=b(()=>A(g,C)),c(e.delayError)):(clearTimeout(d),c=null,C?ie(n.errors,g,C):me(n.errors,g)),(C?!Pe($,C):$)||!Ne(F)||E){const _={...F,...E&&Ee(w)?{isValid:w}:{},errors:n.errors,name:g};n={...n,..._},m.state.next(_)}},B=async g=>(k(g,!0),await e.resolver(i,e.context,Nf(g||o.mount,r,e.criteriaMode,e.shouldUseNativeValidation))),R=async g=>{const{errors:w}=await B(g);if(k(g),g)for(const C of g){const F=L(w,C);F?ie(n.errors,C,F):me(n.errors,C)}else n.errors=w;return w},V=async(g,w,C={valid:!0})=>{for(const F in g){const $=g[F];if($){const{_f:E,..._}=$;if(E){const ee=o.array.has(E.name),te=$._f&&Cf($._f);te&&f.validatingFields&&k([E.name],!0);const Se=await Ni($,o.disabled,i,v,e.shouldUseNativeValidation&&!w,ee);if(te&&f.validatingFields&&k([E.name]),Se[E.name]&&(C.valid=!1,w||t.shouldUseNativeValidation))break;!w&&(L(Se,E.name)?ee?Df(n.errors,Se,E.name):ie(n.errors,E.name,Se[E.name]):me(n.errors,E.name))}!Ne(_)&&await V(_,w,C)}}return C.valid},I=()=>{for(const g of o.unMount){const w=L(r,g);w&&(w._f.refs?w._f.refs.every(C=>!ir(C)):!ir(w._f.ref))&&Pn(g)}o.unMount=new Set},T=(g,w)=>!e.disabled&&(g&&w&&ie(i,g,w),!Pe(Y(),s)),O=(g,w,C)=>Tr(g,o,{...a.mount?i:oe(w)?s:De(g)?{[g]:w}:w},C,w),P=g=>rs(L(a.mount?i:s,g,e.shouldUnregister?L(s,g,[]):[])),K=(g,w,C={})=>{const F=L(r,g);let $=w;if(F){const E=F._f;E&&(!E.disabled&&ie(i,g,fo(w,E)),$=Sn(E.ref)&&Ae(w)?"":w,lo(E.ref)?[...E.ref.options].forEach(_=>_.selected=$.includes(_.value)):E.refs?Gt(E.ref)?E.refs.forEach(_=>{(!_.defaultChecked||!_.disabled)&&(Array.isArray($)?_.checked=!!$.find(ee=>ee===_.value):_.checked=$===_.value||!!$)}):E.refs.forEach(_=>_.checked=_.value===$):os(E.ref)?E.ref.value="":(E.ref.value=$,E.ref.type||m.state.next({name:g,values:he(i)})))}(C.shouldDirty||C.shouldTouch)&&M(g,$,C.shouldTouch,C.shouldDirty,!0),C.shouldValidate&&xe(g)},X=(g,w,C)=>{for(const F in w){if(!w.hasOwnProperty(F))return;const $=w[F],E=g+"."+F,_=L(r,E);(o.array.has(g)||ge($)||_&&!_._f)&&!dt($)?X(E,$,C):K(E,$,C)}},J=(g,w,C={})=>{const F=L(r,g),$=o.array.has(g),E=he(w);ie(i,g,E),$?(m.array.next({name:g,values:he(i)}),(f.isDirty||f.dirtyFields||p.isDirty||p.dirtyFields)&&C.shouldDirty&&m.state.next({name:g,dirtyFields:St(s,i),isDirty:T(g,E)})):F&&!F._f&&!Ae(E)?X(g,E,C):K(g,E,C),ki(g,o)?m.state.next({...n,name:g,values:he(i)}):m.state.next({name:a.mount?g:void 0,values:he(i)})},ue=async g=>{a.mount=!0;const w=g.target;let C=w.name,F=!0;const $=L(r,C),E=te=>{F=Number.isNaN(te)||dt(te)&&isNaN(te.getTime())||Pe(te,L(i,C,te))},_=bi(e.mode),ee=bi(e.reValidateMode);if($){let te,Se;const rt=w.type?yi($._f):ro(g),Je=g.type===wn.BLUR||g.type===wn.FOCUS_OUT,tl=!jf($._f)&&!e.resolver&&!L(n.errors,C)&&!$._f.deps||Ef(Je,L(n.touchedFields,C),n.isSubmitted,ee,_),Bn=ki(C,o,Je);ie(i,C,rt),Je?(!w||!w.readOnly)&&($._f.onBlur&&$._f.onBlur(g),c&&c(0)):$._f.onChange&&$._f.onChange(g);const _n=M(C,rt,Je),nl=!Ne(_n)||Bn;if(!Je&&m.state.next({name:C,type:g.type,values:he(i)}),tl)return(f.isValid||p.isValid)&&(e.mode==="onBlur"?Je&&x():Je||x()),nl&&m.state.next({name:C,...Bn?{}:_n});if(!Je&&Bn&&m.state.next({...n}),e.resolver){const{errors:vs}=await B([C]);if(k([C]),E(rt),F){const rl=wi(n.errors,r,C),ks=wi(vs,r,rl.name||C);te=ks.error,C=ks.name,Se=Ne(vs)}}else k([C],!0),te=(await Ni($,o.disabled,i,v,e.shouldUseNativeValidation))[C],k([C]),E(rt),F&&(te?Se=!1:(f.isValid||p.isValid)&&(Se=await V(r,!0)));F&&($._f.deps&&(!Array.isArray($._f.deps)||$._f.deps.length>0)&&xe($._f.deps),D(C,Se,te,_n))}},le=(g,w)=>{if(L(n.errors,w)&&g.focus)return g.focus(),1},xe=async(g,w={})=>{let C,F;const $=Rt(g);if(e.resolver){const E=await R(oe(g)?g:$);C=Ne(E),F=g?!$.some(_=>L(E,_)):C}else g?(F=(await Promise.all($.map(async E=>{const _=L(r,E);return await V(_&&_._f?{[E]:_}:_)}))).every(Boolean),!(!F&&!n.isValid)&&x()):F=C=await V(r);return m.state.next({...!De(g)||(f.isValid||p.isValid)&&C!==n.isValid?{}:{name:g},...e.resolver||!g?{isValid:C}:{},errors:n.errors}),w.shouldFocus&&!F&&zt(r,le,g?$:o.mount),F},Y=(g,w)=>{let C={...a.mount?i:s};return w&&(C=oo(w.dirtyFields?n.dirtyFields:n.touchedFields,C)),oe(g)?C:De(g)?L(C,g):g.map(F=>L(C,F))},W=(g,w)=>({invalid:!!L((w||n).errors,g),isDirty:!!L((w||n).dirtyFields,g),error:L((w||n).errors,g),isValidating:!!L(n.validatingFields,g),isTouched:!!L((w||n).touchedFields,g)}),ce=g=>{g&&Rt(g).forEach(w=>me(n.errors,w)),m.state.next({errors:g?n.errors:{}})},se=(g,w,C)=>{const F=(L(r,g,{_f:{}})._f||{}).ref,$=L(n.errors,g)||{},{ref:E,message:_,type:ee,...te}=$;ie(n.errors,g,{...te,...w,ref:F}),m.state.next({name:g,errors:n.errors,isValid:!1}),C&&C.shouldFocus&&F&&F.focus&&F.focus()},Me=(g,w)=>je(g)?m.state.subscribe({next:C=>"values"in C&&g(O(void 0,w),C)}):O(g,w,!0),Mt=g=>m.state.subscribe({next:w=>{Mf(g.name,w.name,g.exact)&&Af(w,g.formState||f,el,g.reRenderRoot)&&g.callback({values:{...i},...n,...w,defaultValues:s})}}).unsubscribe,Fn=g=>(a.mount=!0,p={...p,...g.formState},Mt({...g,formState:{...u,...g.formState}})),Pn=(g,w={})=>{for(const C of g?Rt(g):o.mount)o.mount.delete(C),o.array.delete(C),w.keepValue||(me(r,C),me(i,C)),!w.keepError&&me(n.errors,C),!w.keepDirty&&me(n.dirtyFields,C),!w.keepTouched&&me(n.touchedFields,C),!w.keepIsValidating&&me(n.validatingFields,C),!e.shouldUnregister&&!w.keepDefaultValue&&me(s,C);m.state.next({values:he(i)}),m.state.next({...n,...w.keepDirty?{isDirty:T()}:{}}),!w.keepIsValid&&x()},ps=({disabled:g,name:w})=>{if(Ee(g)&&a.mount||g||o.disabled.has(w)){const $=o.disabled.has(w)!==!!g;g?o.disabled.add(w):o.disabled.delete(w),$&&a.mount&&!a.action&&x()}},Rn=(g,w={})=>{let C=L(r,g);const F=Ee(w.disabled)||Ee(e.disabled);return ie(r,g,{...C||{},_f:{...C&&C._f?C._f:{ref:{name:g}},name:g,mount:!0,...w}}),o.mount.add(g),C?ps({disabled:Ee(w.disabled)?w.disabled:e.disabled,name:g}):j(g,!0,w.value),{...F?{disabled:w.disabled||e.disabled}:{},...e.progressive?{required:!!w.required,min:It(w.min),max:It(w.max),minLength:It(w.minLength),maxLength:It(w.maxLength),pattern:It(w.pattern)}:{},name:g,onChange:ue,onBlur:ue,ref:$=>{if($){Rn(g,w),C=L(r,g);const E=oe($.value)&&$.querySelectorAll&&$.querySelectorAll("input,select,textarea")[0]||$,_=vf(E),ee=C._f.refs||[];if(_?ee.find(te=>te===E):E===C._f.ref)return;ie(r,g,{_f:{...C._f,..._?{refs:[...ee.filter(ir),E,...Array.isArray(L(s,g))?[{}]:[]],ref:{type:E.type,name:g}}:{ref:E}}}),j(g,!1,void 0,E)}else C=L(r,g,{}),C._f&&(C._f.mount=!1),(e.shouldUnregister||w.shouldUnregister)&&!(so(o.array,g)&&a.action)&&o.unMount.add(g)}}},zn=()=>e.shouldFocusError&&zt(r,le,o.mount),Qo=g=>{Ee(g)&&(m.state.next({disabled:g}),zt(r,(w,C)=>{const F=L(r,C);F&&(w.disabled=F._f.disabled||g,Array.isArray(F._f.refs)&&F._f.refs.forEach($=>{$.disabled=F._f.disabled||g}))},0,!1))},gs=(g,w)=>async C=>{let F;C&&(C.preventDefault&&C.preventDefault(),C.persist&&C.persist());let $=he(i);if(m.state.next({isSubmitting:!0}),e.resolver){const{errors:E,values:_}=await B();k(),n.errors=E,$=he(_)}else await V(r);if(o.disabled.size)for(const E of o.disabled)me($,E);if(me(n.errors,"root"),Ne(n.errors)){m.state.next({errors:{}});try{await g($,C)}catch(E){F=E}}else w&&await w({...n.errors},C),zn(),setTimeout(zn);if(m.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Ne(n.errors)&&!F,submitCount:n.submitCount+1,errors:n.errors}),F)throw F},Zo=(g,w={})=>{L(r,g)&&(oe(w.defaultValue)?J(g,he(L(s,g))):(J(g,w.defaultValue),ie(s,g,he(w.defaultValue))),w.keepTouched||me(n.touchedFields,g),w.keepDirty||(me(n.dirtyFields,g),n.isDirty=w.defaultValue?T(g,he(L(s,g))):T()),w.keepError||(me(n.errors,g),f.isValid&&x()),m.state.next({...n}))},xs=(g,w={})=>{const C=g?he(g):s,F=he(C),$=Ne(g),E=$?s:F;if(w.keepDefaultValues||(s=C),!w.keepValues){if(w.keepDirtyValues){const _=new Set([...o.mount,...Object.keys(St(s,i))]);for(const ee of Array.from(_)){const te=L(n.dirtyFields,ee),Se=L(i,ee),rt=L(E,ee);te&&!oe(Se)?ie(E,ee,Se):!te&&!oe(rt)&&J(ee,rt)}}else{if(ns&&oe(g))for(const _ of o.mount){const ee=L(r,_);if(ee&&ee._f){const te=Array.isArray(ee._f.refs)?ee._f.refs[0]:ee._f.ref;if(Sn(te)){const Se=te.closest("form");if(Se){Se.reset();break}}}}if(w.keepFieldsRef)for(const _ of o.mount)J(_,L(E,_));else r={}}i=e.shouldUnregister?w.keepDefaultValues?he(s):{}:he(E),m.array.next({values:{...E}}),m.state.next({values:{...E}})}o={mount:w.keepDirtyValues?o.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},a.mount=!f.isValid||!!w.keepIsValid||!!w.keepDirtyValues||!e.shouldUnregister&&!Ne(E),a.watch=!!e.shouldUnregister,a.keepIsValid=!!w.keepIsValid,a.action=!1,w.keepErrors||(n.errors={}),m.state.next({submitCount:w.keepSubmitCount?n.submitCount:0,isDirty:$?!1:w.keepDirty?n.isDirty:!!(w.keepDefaultValues&&!Pe(g,s)),isSubmitted:w.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:$?{}:w.keepDirtyValues?w.keepDefaultValues&&i?St(s,i):n.dirtyFields:w.keepDefaultValues&&g?St(s,g):w.keepDirty?n.dirtyFields:{},touchedFields:w.keepTouched?n.touchedFields:{},errors:w.keepErrors?n.errors:{},isSubmitSuccessful:w.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:s})},ys=(g,w)=>xs(je(g)?g(i):g,{...e.resetOptions,...w}),Xo=(g,w={})=>{const C=L(r,g),F=C&&C._f;if(F){const $=F.refs?F.refs[0]:F.ref;$.focus&&setTimeout(()=>{$.focus(),w.shouldSelect&&je($.select)&&$.select()})}},el=g=>{n={...n,...g}},bs={control:{register:Rn,unregister:Pn,getFieldState:W,handleSubmit:gs,setError:se,_subscribe:Mt,_runSchema:B,_updateIsValidating:k,_focusError:zn,_getWatch:O,_getDirty:T,_setValid:x,_setFieldArray:S,_setDisabledField:ps,_setErrors:N,_getFieldArray:P,_reset:xs,_resetDefaultValues:()=>je(e.defaultValues)&&e.defaultValues().then(g=>{ys(g,e.resetOptions),m.state.next({isLoading:!1})}),_removeUnmounted:I,_disableForm:Qo,_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 o},set _names(g){o=g},get _formState(){return n},get _options(){return e},set _options(g){e={...e,...g}}},subscribe:Fn,trigger:xe,register:Rn,handleSubmit:gs,watch:Me,setValue:J,getValues:Y,reset:ys,resetField:Zo,clearErrors:ce,unregister:Pn,setError:se,setFocus:Xo,getFieldState:W};return{...bs,formControl:bs}}function Of(t={}){const e=y.useRef(void 0),n=y.useRef(void 0),[r,s]=y.useState({isDirty:!1,isValidating:!1,isLoading:je(t.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1,isReady:!1,defaultValues:je(t.defaultValues)?void 0:t.defaultValues});if(!e.current)if(t.formControl)e.current={...t.formControl,formState:r},t.defaultValues&&!je(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:a,...o}=$f(t);e.current={...o,formState:r}}const i=e.current.control;return i._options=t,as(()=>{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(t.disabled),[i,t.disabled]),y.useEffect(()=>{t.mode&&(i._options.mode=t.mode),t.reValidateMode&&(i._options.reValidateMode=t.reValidateMode)},[i,t.mode,t.reValidateMode]),y.useEffect(()=>{t.errors&&(i._setErrors(t.errors),i._focusError())},[i,t.errors]),y.useEffect(()=>{t.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,t.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;t.values&&!Pe(t.values,n.current)?(i._reset(t.values,{keepFieldsRef:!0,...i._options.resetOptions}),!((a=i._options.resetOptions)===null||a===void 0)&&a.keepIsValid||i._setValid(),n.current=t.values,s(o=>({...o}))):i._resetDefaultValues()},[i,t.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()}),e.current.formState=y.useMemo(()=>ao(r,i),[i,r]),e.current}function Lf(t,e=3){return t%1===0?t.toString():t.toFixed(e).replace(/\.?0+$/,"")}function Ff(t,e="en-US",n="USD"){try{return new Intl.NumberFormat(e,{style:"currency",currency:n,minimumFractionDigits:2,maximumFractionDigits:2}).format(t)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${t.toFixed(2)}`}}function Pf(t="USD",e="en-US"){try{return new Intl.NumberFormat(e,{style:"currency",currency:t}).formatToParts(0).find(i=>i.type==="currency")?.value??"$"}catch{return"$"}}function Rf(t){const e=t.replace(/[^\d.,-]/g,""),n=e.match(/,\d{1,2}$/);let r;n?r=e.replace(/\./g,"").replace(",","."):r=e.replace(/,/g,"");const s=parseFloat(r);return isNaN(s)?null:s}function zf(t,e,n=.001){const r=t-e,s=Math.abs(r)<=n;return{difference:r,isBalanced:s,isUnderAllocated:!s&&r>0,isOverAllocated:!s&&r<0}}function cs(){return`dist-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}cs();const Bf={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:"$"},ar=()=>({id:cs(),amount:0,glAccount:null,isTaxDeductible:!1}),mo=({distribution:t,defaultDistribution:e,glAccounts:n=[],isLoadingGlAccounts:r=!1,onSearchGlAccounts:s,onDistributionChange:i,onAmountChange:a,onGlAccountChange:o,onTaxDeductibleChange:c,onDelete:d,canDelete:u=!0,canEditTaxDeductible:f=!0,isDisabled:p=!1,labels:m,classNames:v={},"data-testid":b,control:x,name:k,rules:S})=>{const A={...Bf,...m},N=x!==void 0&&k!==void 0,j=Of({defaultValues:{_internal:e||ar()}}),M=xf({control:N?x:j.control,name:N?k:"_internal",rules:N?S:void 0}),[D,B]=y.useState(e||ar()),R=N?M.field.value??ar():t??D,V=N&&!!M.fieldState?.error,I=N&&(M.fieldState?.isTouched??!1),T=V||I,O=T&&(!R.amount||R.amount<=0),P=T&&!R.glAccount,[K,X]=y.useState(R.glAccount?.name||""),J=y.useCallback(se=>{const Me={...R,...se};N&&M.field.onChange(Me),!N&&t===void 0&&B(Me),i?.(Me)},[R,t,i,N,M]),ue=y.useCallback(se=>{const Me=se||0;J({amount:Me}),a?.(Me)},[J,a]),le=y.useCallback(se=>{X(se),s?.(se)},[s]),xe=y.useCallback(se=>{if(se===null){J({glAccount:null}),o?.(null);return}const Mt=n.find(Fn=>String(Fn.id)===String(se))||null;J({glAccount:Mt}),o?.(Mt)},[n,J,o]),Y=y.useCallback(()=>{X(""),J({glAccount:null}),o?.(null)},[J,o]),W=y.useCallback(se=>{J({isTaxDeductible:se}),c?.(se)},[J,c]),ce=y.useCallback(()=>{d?.()},[d]);return l.jsx(h.Card,{radius:"md",shadow:"sm","data-testid":b||"revenue-distribution-card",className:h.cn(v.base),children:l.jsxs(h.CardBody,{className:h.cn("flex flex-row flex-nowrap items-start gap-4",v.body),children:[l.jsx("div",{className:h.cn("shrink-0",v.amountContainer),children:l.jsx(h.NumberInput,{"data-testid":`${b||"revenue-distribution-card"}-amount-input`,label:l.jsxs("span",{className:"flex items-center gap-1",children:[A.amount,l.jsx(h.Tooltip,{content:A.amountTooltip,children:l.jsx(U,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),value:R.amount||void 0,onValueChange:ue,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:l.jsx("div",{className:"pointer-events-none flex items-center",children:l.jsx("span",{className:"text-default-400 text-small",children:A.currencySymbol})})})}),l.jsx("div",{className:h.cn("grow",v.glAccountContainer),children:l.jsx(h.Autocomplete,{"data-testid":`${b||"revenue-distribution-card"}-gl-account-input`,label:l.jsxs("span",{className:"flex items-center gap-1",children:[A.glAccount,l.jsx(h.Tooltip,{content:A.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:R.glAccount?.name??K,selectedKey:R.glAccount?.id??null,isDisabled:p,isInvalid:P,errorMessage:P?"GL Account is required":void 0,listboxProps:{emptyContent:r?A.searching:A.noGlAccountsFound},placeholder:A.glAccountPlaceholder,onInputChange:le,onSelectionChange:xe,onClear:Y,className:v.glAccountInput,children:se=>l.jsx(h.AutocompleteItem,{textValue:se.name,children:l.jsxs("div",{className:"flex flex-col",children:[l.jsx("span",{children:se.name}),se.code&&l.jsx("span",{className:"text-xs text-default-400",children:se.code})]})},se.id)})}),l.jsx("div",{className:h.cn("shrink-0 pt-6 flex items-center",v.taxDeductibleContainer),children:l.jsx(h.Checkbox,{radius:"full","data-testid":`${b||"revenue-distribution-card"}-tax-deductible`,isSelected:R.isTaxDeductible,onValueChange:W,isDisabled:p||!f,className:v.taxDeductibleCheckbox,children:A.taxDeductible})}),l.jsx("div",{className:h.cn("shrink-0 pt-6",v.deleteContainer),children:l.jsx(q,{"data-testid":`${b||"revenue-distribution-card"}-delete-button`,size:"sm",color:"danger",variant:"flat",isDisabled:p||!u,onPress:ce,startContent:l.jsx(U,{icon:"solar:trash-bin-trash-linear",width:16}),className:h.cn("text-danger",v.deleteButton),children:A.deleteButton})})]})})};mo.displayName="RevenueDistributionCard";const po=({message:t="No distributions configured",icon:e="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:h.cn("flex flex-col items-center justify-center py-8",s.content),children:[l.jsx(U,{icon:e,width:n,className:h.cn("text-default-300 mb-4",s.icon)}),l.jsx("p",{className:h.cn("text-default-500 text-sm text-center",s.message),children:t})]});return r?l.jsx(h.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-empty",className:h.cn("w-full",s.base),children:l.jsx(h.CardBody,{children:a})}):l.jsx("div",{"data-testid":"revenue-distribution-empty",className:h.cn("w-full",s.base),children:a})};po.displayName="RevenueDistributionEmpty";const _f={title:"Error Loading Distributions",description:"An error occurred while loading the distribution configuration. Please try again."},go=({error:t,labels:e,showCard:n=!0,color:r="danger",classNames:s={}})=>{const i={..._f,...e},a=l.jsx(h.Alert,{"data-testid":"revenue-distribution-error-alert",color:r,title:i.title,description:t||i.description,className:s.alert});return n?l.jsx(h.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-error",className:h.cn("w-full",s.base),children:l.jsx(h.CardBody,{children:a})}):l.jsx("div",{"data-testid":"revenue-distribution-error",className:h.cn("w-full",s.base),children:a})};go.displayName="RevenueDistributionError";const xo=({rows:t=1,showCard:e=!0,classNames:n={}})=>{const r=Array.from({length:t},(i,a)=>a),s=i=>l.jsxs("div",{className:h.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(h.Skeleton,{className:"h-4 w-14 rounded-md"}),l.jsx(h.Skeleton,{className:"h-4 w-4 rounded-full"})]}),l.jsx(h.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(h.Skeleton,{className:"h-4 w-20 rounded-md"}),l.jsx(h.Skeleton,{className:"h-4 w-4 rounded-full"})]}),l.jsx(h.Skeleton,{className:"h-10 w-full rounded-lg"})]}),l.jsxs("div",{className:"shrink-0 pb-2 flex items-center gap-2",children:[l.jsx(h.Skeleton,{className:"h-5 w-5 rounded-full"}),l.jsx(h.Skeleton,{className:"h-4 w-24 rounded-md"})]}),l.jsx("div",{className:"shrink-0 pb-2",children:l.jsx(h.Skeleton,{className:"h-8 w-20 rounded-lg"})})]},i);return e?l.jsx("div",{className:h.cn("flex flex-col gap-3",n.base),children:r.map(i=>l.jsx(h.Card,{radius:"md",shadow:"sm","data-testid":`revenue-distribution-skeleton-${i}`,children:l.jsx(h.CardBody,{children:s(i)})},i))}):l.jsx("div",{"data-testid":"revenue-distribution-skeleton",className:h.cn("flex flex-col gap-3",n.base),children:r.map(i=>s(i))})};xo.displayName="RevenueDistributionSkeleton";function Cn({isOpen:t,labels:e,icon:n,isConfirming:r=!1,confirmColor:s="danger",iconTone:i="danger",onClose:a,onConfirm:o}){return l.jsx(h.Modal,{isOpen:t,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(h.ModalContent,{children:[l.jsxs(h.ModalHeader,{className:"flex flex-col items-start gap-4 px-7 pb-0 pt-7",children:[n&&l.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}),l.jsx("span",{className:"text-lg font-semibold leading-6 text-zinc-950",children:e.title})]}),l.jsx(h.ModalBody,{className:"px-7 pb-3 pt-4",children:l.jsx("div",{className:"text-sm leading-6 text-zinc-500",children:e.description})}),l.jsxs(h.ModalFooter,{className:"grid grid-cols-2 gap-3 px-7 pb-7 pt-3",children:[l.jsx(q,{type:"button",variant:"bordered",radius:"full",className:"h-10 border-zinc-200 bg-white text-sm font-normal text-zinc-900",onPress:a,children:e.cancel}),l.jsx(q,{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:o,children:e.confirm})]})]})})}const Vf={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"},yo={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={...yo,base:"min-h-11 rounded-2xl px-4 py-2 shadow-none",title:"text-sm font-medium"},Hf={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"},Ci=()=>({id:crypto.randomUUID(),fund:null,percentage:0}),Uf=t=>Number.isFinite(t)?Math.max(0,Math.min(100,Math.round(t*100)/100)):0,qf=t=>t.fund!==null;function Wf({mode:t,assignments:e,funds:n,labels:r,classNames:s,isSaving:i=!1,hasSavedAssignments:a=!1,isFundPickerOpen:o=!1,activeAssignmentId:c=null,footer:d,onModeChange:u,onAssignmentsChange:f,onOpenFundPicker:p,onCloseFundPicker:m,onCollapseChange:v,onSave:b}){const x={...Vf,...r},k=e.filter(qf),S=k.length>0,A=y.useMemo(()=>e.reduce((Y,W)=>Y+Number(W.percentage||0),0),[e]),N=Math.round(A*100)/100,j=t==="split"&&e.some(Y=>!Y.fund||Number(Y.percentage||0)<=0),M=t==="split"&&S&&(N!==100||j),D=t==="split"&&S&&N>=100,B=t==="split"||!S,[R,V]=y.useState(null),[I,T]=y.useState(!1),O=Y=>{if(Y!==t){if(Y==="single"){const W=k[0]?.fund??null;f([{id:e[0]?.id??crypto.randomUUID(),fund:W,percentage:W?100:0}])}else{const W=k[0];f([{id:W?.id??crypto.randomUUID(),fund:W?.fund??null,percentage:W?.fund?50:0},Ci()])}u(Y)}},P=(Y,W)=>{f(e.map(ce=>ce.id===Y?{...ce,...W}:ce))},K=()=>{D||f([...e,Ci()])},X=Y=>{if(!(e.length<=2)){if(!a){f(e.filter(W=>W.id!==Y));return}V(Y)}},J=()=>{if(!R||e.length<=2){V(null);return}f(e.filter(Y=>Y.id!==R)),V(null)},ue=()=>{if(!i){if(!a){b();return}T(!0)}},le=()=>{T(!1),b()},xe=Y=>{const W=c??e.find(ce=>!ce.fund)?.id??e[0]?.id;W&&(f(e.map(ce=>ce.id===W?{...ce,fund:Y,percentage:t==="single"?100:ce.percentage}:ce)),m())};return l.jsxs("div",{className:h.cn("vvt-pa font-sans text-zinc-900",s?.root),children:[l.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:l.jsx(h.AccordionItem,{"aria-label":x.title,title:x.title,children:l.jsxs("div",{className:h.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(Kf,{mode:t,labels:x,onModeChange:O,className:s?.tabs}),l.jsx(q,{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:ue,children:x.saveAssignment})]}),l.jsxs("div",{className:"flex w-full flex-col gap-4",children:[!S&&l.jsx(h.Alert,{icon:l.jsx(U,{icon:"solar:info-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,classNames:yo,color:"default",variant:"flat",title:t==="single"?x.emptySingle:x.emptySplit}),S&&l.jsx(Jf,{mode:t,assignments:e,labels:x,total:A,hasTotalError:M,onSelectFund:Y=>p(Y),onRemoveFund:X,onPercentageChange:(Y,W)=>P(Y,{percentage:Uf(W)})}),B&&l.jsx("div",{className:"flex flex-wrap gap-3",children:l.jsx(q,{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(H.Plus,{className:"size-5",strokeWidth:2}),isDisabled:D,onPress:()=>t==="split"&&S?K():p(),children:t==="split"&&S?x.addFund:x.assignSpecificFund})})]}),d]})},"installment-fund-assignment")}),o&&l.jsx(Yf,{funds:n,labels:x,selectedFundIds:e.map(Y=>Y.fund?.id).filter(Boolean),onSelect:xe,onClose:m}),l.jsx(Cn,{isOpen:I,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:()=>T(!1),onConfirm:le}),l.jsx(Cn,{isOpen:R!==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:()=>V(null),onConfirm:J})]})}function Kf({mode:t,labels:e,className:n,onModeChange:r}){return l.jsxs(h.Tabs,{"aria-label":e.title,selectedKey:t,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:[l.jsx(h.Tab,{title:e.singleFund},"single"),l.jsx(h.Tab,{title:e.splitFunds},"split")]})}function Jf({mode:t,assignments:e,labels:n,total:r,hasTotalError:s,onSelectFund:i,onRemoveFund:a,onPercentageChange:o}){return l.jsxs("div",{className:"flex flex-col gap-3",children:[e.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:h.cn("flex min-h-11 min-w-0 flex-1 items-center",c.fund&&t==="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(q,{type:"button",variant:"light",radius:"full",className:"px-2 text-sm font-normal text-brand",onPress:()=>i(c.id),children:"Replace"})]}):l.jsx(q,{type:"button",variant:"light",radius:"full",className:"justify-start px-4 text-base font-normal text-zinc-900",startContent:l.jsx(H.Plus,{className:"size-5",strokeWidth:2}),onPress:()=>i(c.id),children:n.assignSpecificFund})}),t==="split"&&l.jsx("label",{className:"flex w-48 flex-none items-center",children:l.jsx(h.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:Hf})}),t==="split"&&e.length>2&&l.jsx(q,{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:l.jsx(U,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"})})]},c.id)),t==="split"&&l.jsx(h.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:{...$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 Yf({funds:t,labels:e,selectedFundIds:n,onSelect:r,onClose:s}){const[i,a]=y.useState(""),o=t.filter(c=>{const d=i.trim().toLowerCase();return d?`${c.glCode} ${c.accountName} ${c.type}`.toLowerCase().includes(d):!0});return l.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:l.jsxs(h.ModalContent,{children:[l.jsx(h.ModalHeader,{className:"px-6 pt-6 text-xl font-semibold leading-7 text-zinc-950",children:e.modalTitle}),l.jsxs(h.ModalBody,{className:"px-6 pb-6",children:[l.jsx(h.Input,{variant:"bordered","aria-label":e.searchPlaceholder,value:i,placeholder:e.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:e.glCode}),l.jsx("span",{children:e.accountName}),l.jsx("span",{children:e.type}),l.jsx("span",{children:e.actions})]}),o.length===0&&l.jsx("div",{className:"p-4 text-sm text-zinc-500",children:e.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(q,{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:e.select})]},c.id)})]})]})]})})}function Gf(){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(h.Skeleton,{className:"h-7 w-56 rounded-lg"}),l.jsx(h.Skeleton,{className:"size-8 rounded-full"})]}),l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsx(h.Skeleton,{className:"h-10 w-72 rounded-full"}),l.jsx(h.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(h.Skeleton,{className:"h-8 w-full max-w-xs rounded-full"}),l.jsx(h.Skeleton,{className:"h-8 w-full rounded-xl"})]}),l.jsx(h.Skeleton,{className:"h-11 w-40 rounded-full"})]})}const Qf={totalAmount:"Total Amount:",remainingBalance:"Remaining Balance",amountReceived:"Amount Received:"};function Zf({totalAmount:t,remainingBalance:e,amountReceived:n,currency:r="USD",locale:s="en-US",labels:i,className:a}){const o={...Qf,...i},c=new Intl.NumberFormat(s,{style:"currency",currency:r});return l.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:l.jsxs("div",{className:"flex w-full flex-wrap items-center gap-x-5 gap-y-2",children:[l.jsx(or,{label:o.totalAmount,value:c.format(t)}),l.jsx(or,{label:o.remainingBalance,value:c.format(e)}),l.jsx(or,{label:o.amountReceived,value:c.format(n)})]})})}function or({label:t,value:e}){return l.jsxs("div",{className:"flex items-center gap-3 whitespace-nowrap",children:[l.jsx("span",{className:"font-medium text-zinc-700",children:t}),l.jsx("span",{className:"font-normal text-zinc-950",children:e})]})}function lr(t,e){return t-e*Math.floor(t/e)}const bo=1721426;function nn(t,e,n,r){e=ds(t,e);let s=e-1,i=-2;return n<=2?i=0:dn(e)&&(i=-1),bo-1+365*s+Math.floor(s/4)-Math.floor(s/100)+Math.floor(s/400)+Math.floor((367*n-362)/12+i+r)}function dn(t){return t%4===0&&(t%100!==0||t%400===0)}function ds(t,e){return t==="BC"?1-e:e}function Xf(t){let e="AD";return t<=0&&(e="BC",t=1-t),[e,t]}const eh={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 Ln{fromJulianDay(e){let n=e,r=n-bo,s=Math.floor(r/146097),i=lr(r,146097),a=Math.floor(i/36524),o=lr(i,36524),c=Math.floor(o/1461),d=lr(o,1461),u=Math.floor(d/365),f=s*400+a*100+c*4+u+(a!==4&&u!==4?1:0),[p,m]=Xf(f),v=n-nn(p,m,1,1),b=2;n<nn(p,m,3,1)?b=0:dn(m)&&(b=1);let x=Math.floor(((v+b)*12+373)/367),k=n-nn(p,m,x,1)+1;return new Kt(p,m,x,k)}toJulianDay(e){return nn(e.era,e.year,e.month,e.day)}getDaysInMonth(e){return eh[dn(e.year)?"leapyear":"standard"][e.month-1]}getMonthsInYear(e){return 12}getDaysInYear(e){return dn(e.year)?366:365}getMaximumMonthsInYear(){return 12}getMaximumDaysInMonth(){return 31}getYearsInEra(e){return 9999}getEras(){return["BC","AD"]}isInverseEra(e){return e.era==="BC"}balanceDate(e){e.year<=0&&(e.era=e.era==="BC"?"AD":"BC",e.year=1-e.year)}constructor(){this.identifier="gregory"}}function th(t,e){var n,r,s,i;return(i=(s=(n=t.isEqual)===null||n===void 0?void 0:n.call(t,e))!==null&&s!==void 0?s:(r=e.isEqual)===null||r===void 0?void 0:r.call(e,t))!==null&&i!==void 0?i:t.identifier===e.identifier}function vo(t,e){return t.calendar.toJulianDay(t)-e.calendar.toJulianDay(e)}function nh(t,e){return ji(t)-ji(e)}function ji(t){return t.hour*36e5+t.minute*6e4+t.second*1e3+t.millisecond}let cr=null;function ko(){return cr==null&&(cr=new Intl.DateTimeFormat().resolvedOptions().timeZone),cr}function Ai(t){t=us(t,new Ln);let e=ds(t.era,t.year);return wo(e,t.month,t.day,t.hour,t.minute,t.second,t.millisecond)}function wo(t,e,n,r,s,i,a){let o=new Date;return o.setUTCHours(r,s,i,a),o.setUTCFullYear(t,e-1,n),o.getTime()}function Mi(t,e){if(e==="UTC")return 0;if(t>0&&e===ko())return new Date(t).getTimezoneOffset()*-6e4;let{year:n,month:r,day:s,hour:i,minute:a,second:o}=So(t,e);return wo(n,r,s,i,a,o,0)-Math.floor(t/1e3)*1e3}const Ei=new Map;function So(t,e){let n=Ei.get(e);n||(n=new Intl.DateTimeFormat("en-US",{timeZone:e,hour12:!1,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}),Ei.set(e,n));let r=n.formatToParts(new Date(t)),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 Ti=864e5;function rh(t,e,n,r){return(n===r?[n]:[n,r]).filter(i=>sh(t,e,i))}function sh(t,e,n){let r=So(n,e);return t.year===r.year&&t.month===r.month&&t.day===r.day&&t.hour===r.hour&&t.minute===r.minute&&t.second===r.second}function ih(t,e,n="compatible"){let r=Co(t);if(e==="UTC")return Ai(r);if(e===ko()&&n==="compatible"){r=us(r,new Ln);let c=new Date,d=ds(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=Ai(r),i=Mi(s-Ti,e),a=Mi(s+Ti,e),o=rh(r,e,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 No(t,e,n="compatible"){return new Date(ih(t,e,n))}function Co(t,e){let n=0,r=0,s=0,i=0;if("timeZone"in t)({hour:n,minute:r,second:s,millisecond:i}=t);else if("hour"in t&&!e)return t;return e&&({hour:n,minute:r,second:s,millisecond:i}=e),new jn(t.calendar,t.era,t.year,t.month,t.day,n,r,s,i)}function us(t,e){if(th(t.calendar,e))return t;let n=e.fromJulianDay(t.calendar.toJulianDay(t)),r=t.copy();return r.calendar=e,r.era=n.era,r.year=n.year,r.month=n.month,r.day=n.day,At(r),r}function fs(t,e){let n=t.copy(),r="hour"in n?uh(n,e):0;$r(n,e.years||0),n.calendar.balanceYearMonth&&n.calendar.balanceYearMonth(n,t),n.month+=e.months||0,Or(n),jo(n),n.day+=(e.weeks||0)*7,n.day+=e.days||0,n.day+=r,ah(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 $r(t,e){var n,r;!((n=(r=t.calendar).isInverseEra)===null||n===void 0)&&n.call(r,t)&&(e=-e),t.year+=e}function Or(t){for(;t.month<1;)$r(t,-1),t.month+=t.calendar.getMonthsInYear(t);let e=0;for(;t.month>(e=t.calendar.getMonthsInYear(t));)t.month-=e,$r(t,1)}function ah(t){for(;t.day<1;)t.month--,Or(t),t.day+=t.calendar.getDaysInMonth(t);for(;t.day>t.calendar.getDaysInMonth(t);)t.day-=t.calendar.getDaysInMonth(t),t.month++,Or(t)}function jo(t){t.month=Math.max(1,Math.min(t.calendar.getMonthsInYear(t),t.month)),t.day=Math.max(1,Math.min(t.calendar.getDaysInMonth(t),t.day))}function At(t){t.calendar.constrainDate&&t.calendar.constrainDate(t),t.year=Math.max(1,Math.min(t.calendar.getYearsInEra(t),t.year)),jo(t)}function oh(t){let e={};for(let n in t)typeof t[n]=="number"&&(e[n]=-t[n]);return e}function Ao(t,e){return fs(t,oh(e))}function Mo(t,e){let n=t.copy();return e.era!=null&&(n.era=e.era),e.year!=null&&(n.year=e.year),e.month!=null&&(n.month=e.month),e.day!=null&&(n.day=e.day),At(n),n}function lh(t,e){let n=t.copy();return e.hour!=null&&(n.hour=e.hour),e.minute!=null&&(n.minute=e.minute),e.second!=null&&(n.second=e.second),e.millisecond!=null&&(n.millisecond=e.millisecond),dh(n),n}function ch(t){t.second+=Math.floor(t.millisecond/1e3),t.millisecond=rn(t.millisecond,1e3),t.minute+=Math.floor(t.second/60),t.second=rn(t.second,60),t.hour+=Math.floor(t.minute/60),t.minute=rn(t.minute,60);let e=Math.floor(t.hour/24);return t.hour=rn(t.hour,24),e}function dh(t){t.millisecond=Math.max(0,Math.min(t.millisecond,1e3)),t.second=Math.max(0,Math.min(t.second,59)),t.minute=Math.max(0,Math.min(t.minute,59)),t.hour=Math.max(0,Math.min(t.hour,23))}function rn(t,e){let n=t%e;return n<0&&(n+=e),n}function uh(t,e){return t.hour+=e.hours||0,t.minute+=e.minutes||0,t.second+=e.seconds||0,t.millisecond+=e.milliseconds||0,ch(t)}function Eo(t,e,n,r){let s=t.copy();switch(e){case"era":{let o=t.calendar.getEras(),c=o.indexOf(t.era);if(c<0)throw new Error("Invalid era: "+t.era);c=Xe(c,n,0,o.length-1,r?.round),s.era=o[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(t.year,n,-1/0,9999,r?.round),s.year===-1/0&&(s.year=1),s.calendar.balanceYearMonth&&s.calendar.balanceYearMonth(s,t);break;case"month":s.month=Xe(t.month,n,1,t.calendar.getMonthsInYear(t),r?.round);break;case"day":s.day=Xe(t.day,n,1,t.calendar.getDaysInMonth(t),r?.round);break;default:throw new Error("Unsupported field "+e)}return t.calendar.balanceDate&&t.calendar.balanceDate(s),At(s),s}function fh(t,e,n,r){let s=t.copy();switch(e){case"hour":{let i=t.hour,a=0,o=23;if(r?.hourCycle===12){let c=i>=12;a=c?12:0,o=c?23:11}s.hour=Xe(i,n,a,o,r?.round);break}case"minute":s.minute=Xe(t.minute,n,0,59,r?.round);break;case"second":s.second=Xe(t.second,n,0,59,r?.round);break;case"millisecond":s.millisecond=Xe(t.millisecond,n,0,999,r?.round);break;default:throw new Error("Unsupported field "+e)}return s}function Xe(t,e,n,r,s=!1){if(s){t+=Math.sign(e),t<n&&(t=r);let i=Math.abs(e);e>0?t=Math.ceil(t/i)*i:t=Math.floor(t/i)*i,t>r&&(t=n)}else t+=e,t<n?t=r-(n-t-1):t>r&&(t=n+(t-r-1));return t}const hh=/^([+-]\d{6}|\d{4})-(\d{2})-(\d{2})$/,mh=/^([+-]\d{6}|\d{4})-(\d{2})-(\d{2})(?:T(\d{2}))?(?::(\d{2}))?(?::(\d{2}))?(\.\d+)?(?:(?:([+-]\d{2})(?::?(\d{2}))?)|Z)$/;function ph(t){let e=t.match(hh);if(!e)throw mh.test(t)?new Error(`Invalid ISO 8601 date string: ${t}. Use parseAbsolute() instead.`):new Error("Invalid ISO 8601 date string: "+t);let n=new Kt(dr(e[1],0,9999),dr(e[2],1,12),1);return n.day=dr(e[3],1,n.calendar.getDaysInMonth(n)),n}function dr(t,e,n){let r=Number(t);if(r<e||r>n)throw new RangeError(`Value out of range: ${e} <= ${r} <= ${n}`);return r}function gh(t){return`${String(t.hour).padStart(2,"0")}:${String(t.minute).padStart(2,"0")}:${String(t.second).padStart(2,"0")}${t.millisecond?String(t.millisecond/1e3).slice(1):""}`}function To(t){let e=us(t,new Ln),n;return e.era==="BC"?n=e.year===1?"0000":"-"+String(Math.abs(1-e.year)).padStart(6,"00"):n=String(e.year).padStart(4,"0"),`${n}-${String(e.month).padStart(2,"0")}-${String(e.day).padStart(2,"0")}`}function xh(t){return`${To(t)}T${gh(t)}`}function yh(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function Do(t,e,n){yh(t,e),e.set(t,n)}function Io(t){let e=typeof t[0]=="object"?t.shift():new Ln,n;if(typeof t[0]=="string")n=t.shift();else{let a=e.getEras();n=a[a.length-1]}let r=t.shift(),s=t.shift(),i=t.shift();return[e,n,r,s,i]}var bh=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(e){return fs(this,e)}subtract(e){return Ao(this,e)}set(e){return Mo(this,e)}cycle(e,n,r){return Eo(this,e,n,r)}toDate(e){return No(this,e)}toString(){return To(this)}compare(e){return vo(this,e)}constructor(...e){Do(this,bh,{writable:!0,value:void 0});let[n,r,s,i,a]=Io(e);this.calendar=n,this.era=r,this.year=s,this.month=i,this.day=a,At(this)}}var vh=new WeakMap;class jn{copy(){return this.era?new jn(this.calendar,this.era,this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond):new jn(this.calendar,this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond)}add(e){return fs(this,e)}subtract(e){return Ao(this,e)}set(e){return Mo(lh(this,e),e)}cycle(e,n,r){switch(e){case"era":case"year":case"month":case"day":return Eo(this,e,n,r);default:return fh(this,e,n,r)}}toDate(e,n){return No(this,e,n)}toString(){return xh(this)}compare(e){let n=vo(this,e);return n===0?nh(this,Co(e)):n}constructor(...e){Do(this,vh,{writable:!0,value:void 0});let[n,r,s,i,a]=Io(e);this.calendar=n,this.era=r,this.year=s,this.month=i,this.day=a,this.hour=e.shift()||0,this.minute=e.shift()||0,this.second=e.shift()||0,this.millisecond=e.shift()||0,At(this)}}const kh={monthly:1,quarterly:3,annual:12};function $o(t,e){const n=Math.max(1,Math.floor(e.numberOfInstallments||1)),r=Math.floor(t*100/n),i=Math.round(t*100)-r*n,a=new Date(`${e.firstInstallmentDate}T00:00:00`),o=kh[e.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 wh={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"},Sh=["monthly","quarterly","annual"],Oo={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"},An={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"},Nh={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"},Di=()=>({id:crypto.randomUUID(),dueDate:new Date().toISOString().slice(0,10),amount:0}),Lr=t=>Math.round(t*100)/100,Ch=(t,e)=>{const n=new Date(`${t}T00:00:00`);return Number.isNaN(n.getTime())?t:new Intl.DateTimeFormat(e,{month:"short",day:"numeric",year:"numeric"}).format(n)},Lo=t=>{if(!t)return null;try{return ph(t)}catch{return null}};function jh({mode:t,donationAmount:e,currency:n="USD",locale:r="en-US",installments:s,automaticSettings:i,labels:a,classNames:o,isSaving:c=!1,isModeSwitchDisabled:d=!1,onModeChange:u,onAutomaticSettingsChange:f,onInstallmentsChange:p,onSave:m}){const v={...wh,...a},b=y.useMemo(()=>new Intl.NumberFormat(r,{style:"currency",currency:n}),[n,r]),x=t==="automatic"?$o(e,i):s,k=y.useMemo(()=>Lr(x.reduce((M,D)=>M+Number(D.amount||0),0)),[x]),S=M=>{M!==t&&(u(M),M==="manual"&&s.length===0&&p([Di()]))},A=(M,D)=>{s.find(R=>R.id===M)?.status!=="paid"&&p(s.map(R=>R.id===M?{...R,...D}:R))},N=()=>{p([...s,Di()])},j=M=>{s.find(B=>B.id===M)?.status!=="paid"&&p(s.filter(B=>B.id!==M))};return l.jsx("div",{className:h.cn("vvt-ps font-sans text-zinc-900",o?.root),children:l.jsx(h.Accordion,{variant:"splitted",defaultSelectedKeys:["installment-schedule"],className:h.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:h.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(h.AccordionItem,{"aria-label":v.title,title:v.title,children:l.jsxs("div",{className:h.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(Ah,{mode:t,labels:v,onModeChange:S,isDisabled:d,className:o?.tabs}),l.jsx(q,{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:[t==="automatic"&&l.jsx(Mh,{settings:i,labels:v,onSettingsChange:f}),x.length===0&&l.jsx(h.Alert,{icon:l.jsx(U,{icon:"solar:info-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,classNames:Oo,color:"default",variant:"flat",title:t==="automatic"?v.emptyAutomatic:v.emptyManual}),x.length>0&&l.jsx(Eh,{mode:t,installments:x,labels:v,formatter:b,locale:r,onUpdateInstallment:A,onRemoveInstallment:j}),t==="manual"&&l.jsx("div",{className:"flex flex-wrap gap-3",children:l.jsx(q,{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(H.Plus,{className:"size-5",strokeWidth:2}),onPress:N,children:v.addInstallment})}),l.jsx(Dh,{total:k,donationAmount:e,difference:Lr(e-k),hasTotalError:t==="manual"&&Math.abs(e-k)>.009,mode:t,installmentCount:x.length,formatter:b})]})]})},"installment-schedule")})})}function Ah({mode:t,labels:e,className:n,isDisabled:r=!1,onModeChange:s}){return l.jsxs(h.Tabs,{"aria-label":e.title,selectedKey:t,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:[l.jsx(h.Tab,{title:e.automaticMode},"automatic"),l.jsx(h.Tab,{title:e.manualMode},"manual")]})}function Mh({settings:t,labels:e,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(h.Input,{variant:"bordered",label:e.numberOfInstallments,labelPlacement:"outside",type:"number",min:1,step:1,value:t.numberOfInstallments>0?String(t.numberOfInstallments):"",onWheel:r=>r.currentTarget.blur(),onChange:r=>{const s=r.target.value;n({...t,numberOfInstallments:s===""?0:Math.max(1,Number(s))})},classNames:An})}),l.jsx("div",{className:"min-w-0",children:l.jsx(mt,{variant:"bordered",label:e.frequency,labelPlacement:"outside",selectedKeys:[t.frequency],onSelectionChange:r=>{const s=Array.from(r)[0];typeof s=="string"&&n({...t,frequency:s})},classNames:Nh,children:Sh.map(r=>l.jsx(h.SelectItem,{textValue:e[r],children:e[r]},r))})}),l.jsx("div",{className:"min-w-0",children:l.jsx(h.DatePicker,{variant:"bordered",label:e.firstInstallmentDate,labelPlacement:"outside",value:Lo(t.firstInstallmentDate),onChange:r=>n({...t,firstInstallmentDate:r?r.toString():""}),startContent:l.jsx(U,{icon:"solar:calendar-outline",className:"size-4 text-zinc-500"}),classNames:An})})]})}function Eh({mode:t,installments:e,labels:n,formatter:r,locale:s,onUpdateInstallment:i,onRemoveInstallment:a}){return t==="automatic"?l.jsx("div",{className:"rounded-2xl border border-zinc-200 bg-zinc-50 p-4",children:l.jsx("div",{className:h.cn("flex flex-col gap-3",e.length>5&&"max-h-[264px] overflow-y-auto pr-2"),children:e.map((o,c)=>l.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:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("span",{children:["#",c+1]}),l.jsx("span",{children:"▪"}),l.jsx("span",{children:Ch(o.dueDate,s)}),c===0&&l.jsx(h.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:e.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(h.DatePicker,{variant:"bordered","aria-label":`${n.dueDate} ${c+1}`,isDisabled:o.status==="paid",value:Lo(o.dueDate),onChange:d=>i(o.id,{dueDate:d?d.toString():""}),classNames:An})}),l.jsx("div",{className:"min-w-0 flex-1",children:l.jsx(h.Input,{variant:"bordered",type:"number",min:0,step:.01,isDisabled:o.status==="paid",value:String(o.amount||""),onChange:d=>i(o.id,{amount:Lr(Number(d.target.value||0))}),startContent:l.jsx("span",{className:"text-zinc-900",children:"$"}),classNames:An})}),l.jsx(Th,{isDisabled:e.length<=1,isPaid:o.status==="paid",label:n.deleteInstallment,onRemove:()=>a(o.id)})]},o.id))})}function Th({isDisabled:t,isPaid:e,label:n,onRemove:r}){const s=l.jsx(q,{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:t||e,onPress:r,"aria-label":n,children:l.jsx(U,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"})});return e?l.jsx(h.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 Dh({total:t,donationAmount:e,difference:n,hasTotalError:r,mode:s,installmentCount:i,formatter:a}){const o=i>0?t/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(t)})," /"," ",l.jsx("strong",{children:a.format(e)}),"."]}),d=s==="automatic"?`Total: ${a.format(t)}`:r?`Missing: ${a.format(n)}`:`Remaining: ${a.format(0)}`;return l.jsx(h.Alert,{icon:l.jsx(U,{icon:"solar:info-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,color:"default",variant:"flat",classNames:Oo,endContent:l.jsx("span",{className:"whitespace-nowrap",children:d}),title:c})}function Ih(){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(h.Skeleton,{className:"h-7 w-56 rounded-lg"}),l.jsx(h.Skeleton,{className:"size-8 rounded-full"})]}),l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsx(h.Skeleton,{className:"h-10 w-72 rounded-full"}),l.jsx(h.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(h.Skeleton,{className:"h-4 w-36 rounded-md"}),l.jsx(h.Skeleton,{className:"h-9 w-full rounded-xl"})]}),l.jsx(h.Skeleton,{className:"h-9 w-36 rounded-full"})]}),l.jsx("div",{className:"flex flex-col gap-3",children:Array.from({length:4}).map((t,e)=>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(h.Skeleton,{className:"h-8 w-full max-w-xs rounded-full"}),l.jsx(h.Skeleton,{className:"h-8 w-full rounded-xl"})]},e))})]})}const Ii={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"},$h={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 Oh({installments:t,currency:e,locale:n="en-US",labels:r,isSaving:s=!1,onEditInstallments:i,onPayInstallment:a,onDeleteInstallment:o}){const c={...$h,...r},[d,u]=y.useState(""),f=new Intl.NumberFormat(n,{style:"currency",currency:e}),p=y.useMemo(()=>{const m=d.trim().toLowerCase();return m?t.filter(v=>{const b=v.status??"scheduled";return[v.id,v.amount,v.dueDate,Oi(v.dueDate,n),b,$i[b]??b].join(" ").toLowerCase().includes(m)}):t},[n,t,d]);return l.jsx("div",{className:"vvt-ps w-full font-sans text-zinc-900",children:l.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:l.jsx(h.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(h.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(q,{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:f.format(m.amount)}),l.jsx("td",{className:"px-2 py-3",children:Oi(m.dueDate,n)}),l.jsx("td",{className:"px-2 py-3",children:l.jsx(h.Chip,{size:"sm",radius:"full",className:h.cn("h-8 min-w-[118px] justify-center px-4 text-sm font-normal",Ii[b]??Ii.scheduled),startContent:l.jsx(Fh,{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(q,{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(Lh,{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 Lh({isPaid:t,labels:e,onDelete:n}){const[r,s]=y.useState(!1);return l.jsxs(l.Fragment,{children:[l.jsxs(h.Dropdown,{placement:"bottom-end",radius:"lg",children:[l.jsx(h.DropdownTrigger,{children:l.jsx(q,{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(h.DropdownMenu,{"aria-label":"Installment actions",disabledKeys:t?["delete"]:[],className:"w-72 p-2",onAction:i=>{i==="delete"&&!t&&s(!0)},children:[l.jsx(h.DropdownSection,{title:"Actions",showDivider:!0,children:l.jsx(h.DropdownItem,{textValue:e.sendLink,description:e.sendLinkDescription,startContent:l.jsx(U,{icon:"solar:link-outline",className:"size-5 text-zinc-500"}),children:e.sendLink},"send-link")}),l.jsx(h.DropdownSection,{title:e.dangerZone,children:l.jsx(h.DropdownItem,{textValue:e.deleteInstallment,className:"text-danger-600",color:"danger",description:e.deleteInstallmentDescription,startContent:l.jsx(U,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"}),children:e.deleteInstallment},"delete")})]})]}),l.jsx(Cn,{isOpen:r,labels:{title:e.deleteInstallmentConfirmationTitle,description:e.deleteInstallmentConfirmationDescription,cancel:e.deleteInstallmentConfirmationCancel,confirm:e.deleteInstallmentConfirmationConfirm},icon:l.jsx(U,{icon:"solar:danger-triangle-outline",className:"size-7"}),confirmColor:"danger",onClose:()=>s(!1),onConfirm:()=>{s(!1),n()}})]})}function Fh({status:t}){return t==="paid"||t==="fulfilled"?l.jsx(U,{icon:"solar:check-circle-bold",className:"size-3"}):t==="failed"?l.jsx(U,{icon:"solar:close-circle-bold",className:"size-3"}):l.jsx(U,{icon:"solar:calendar-outline",className:"size-3"})}function Oi(t,e){const n=new Date(`${t}T00:00:00`);return Number.isNaN(n.getTime())?t:new Intl.DateTimeFormat(e,{month:"short",day:"numeric",year:"numeric"}).format(n)}const Ph={title:"Select Membership",renewalTitle:"Automatic Renewal",renewalDescription:"Membership will automatically renew at the end of each period"},Rh=({cards:t,locale:e,currency:n,listHeightClassName:r="",labels:s,showRenewal:i=!0,defaultRenewalValue:a=!1,initialSelectedMembershipId:o=null,allowReselect:c=!0,onRenewalChange:d,onCardSelect:u,className:f=""})=>{const p=Array.isArray(t)?t:[],[m,v]=y.useState(o),[b,x]=y.useState(a),k={...Ph,...s};y.useEffect(()=>{v(o)},[o]);const S=N=>{if(N===m){c&&u?.(N);return}v(N),u?.(N)},A=N=>{x(N),d?.(N)};return l.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:[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:k.title}),i&&l.jsx(Po,{title:k.renewalTitle,description:k.renewalDescription,value:b,onValueChange:A}),l.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(N=>l.jsx(Fo,{itemKey:N.id,name:N.name,type:N.type,price:N.price,locale:e,currency:n,isSelected:m===N.id,onSelect:S},N.id))})]})},Fo=({itemKey:t,name:e,type:n,price:r,locale:s="en-US",currency:i="USD",isSelected:a=!1,onSelect:o,className:c=""})=>{const d=new Intl.NumberFormat(s,{style:"currency",currency:i,minimumFractionDigits:0,maximumFractionDigits:2}).format(r);return l.jsx(h.Card,{shadow:"none",isPressable:!!o,onPress:()=>o?.(t),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:l.jsxs("div",{className:"px-4 py-8 flex gap-6 items-center justify-between",children:[l.jsxs("div",{className:"w-max flex flex-col gap-1 items-start",children:[l.jsx("p",{className:"text-xl font-semibold text-left","data-testid":"item-card-name",children:e}),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})})]}),l.jsx("p",{className:"text-2xl font-semibold","data-testid":"item-card-price",children:d})]})})},Po=({title:t,value:e,description:n,onValueChange:r,className:s=""})=>{const i=y.useId();return l.jsxs("div",{className:h.cn("w-full flex flex-row items-center",t||n?"justify-between gap-6":"justify-start",s),"data-testid":"toggle",children:[l.jsxs("div",{className:"flex flex-col items-start",children:[t&&l.jsx("label",{htmlFor:i,className:"font-medium text-left","data-testid":"toggle-title",children:t}),n&&l.jsx("p",{className:"text-left text-gray-500","data-testid":"toggle-description",children:n})]}),l.jsx(h.Switch,{id:i,isSelected:e,onValueChange:r,"data-testid":"toggle-switch"})]})},zh={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"},Bh=(t,e)=>new Intl.NumberFormat(t,{style:"currency",currency:e}),Ro=t=>Object.values(t).reduce((e,n)=>e+Object.values(n).reduce((r,s)=>r+Object.values(s).reduce((i,a)=>i+a.selectedQuantity,0),0),0),_h=t=>t.reduce((e,n)=>e+n.dates.reduce((r,s)=>r+s.tickets.reduce((i,a)=>i+a.max,0),0),0),hs=t=>t.flatMap(e=>e.dates.flatMap(n=>n.tickets.map(r=>({exhibition:e,dateGroup:n,ticket:r})))),Li=(t,e,n)=>{const r={};let s=n?e??_h(t):0;for(const{exhibition:i,dateGroup:a,ticket:o}of hs(t)){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},Fi=(t,e,n)=>`${t}::${e}::${n}`,Vh=(t,e,n)=>{const r=Ro(e);for(const{exhibition:s,dateGroup:i,ticket:a}of hs(t)){const o=e[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},Hh=({initialQuantity:t=1,minQuantity:e=1,maxQuantity:n=10,onChange:r,disabled:s=!1})=>{const i=Math.max(e,Math.min(n,t)),[a,o]=y.useState(()=>String(i)),[c,d]=y.useState(!1),u=c?a:String(i),f=()=>{s||i>=n||r?.(i+1)},p=()=>{s||i<=e||r?.(i-1)},m=N=>{if(s)return;o(N.target.value);const j=parseInt(N.target.value,10);isNaN(j)||r?.(Math.max(e,Math.min(n,j)))},v=N=>{const j=parseInt(N.target.value,10);if(d(!1),isNaN(j)){r?.(e);return}const M=Math.max(e,Math.min(n,j));M!==j?r?.(M):o(String(M))},b=i<=e,x=i>=n,k="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",A="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:h.cn(k,s||b?A: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:e,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:f,disabled:s||x,className:h.cn(k,s||x?A:S),"aria-label":"Increment quantity","data-testid":"quantity-increment",children:"+"})]})},Uh=({label:t,checked:e=!1,onChange:n,disabled:r=!1})=>{const s=()=>{r||n?.(!e)};return l.jsxs("button",{type:"button",onClick:s,disabled:r,role:"checkbox","aria-checked":e,"data-testid":"checkbox-button","data-checked":e,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:[l.jsxs("span",{className:"relative flex items-center justify-center w-5 h-5 flex-shrink-0",children:[l.jsx("input",{type:"checkbox",checked:e,onChange:()=>{},disabled:r,className:"absolute opacity-0 w-0 h-0 pointer-events-none",tabIndex:-1,readOnly:!0}),l.jsx("span",{className:h.cn("block w-3.5 h-3.5 rounded-sm relative",e?"bg-primary":"bg-white ring-1 ring-zinc-300"),children:e&&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:t})]})},qh=({item:t,quantity:e,onChange:n,getTotalSelectedTickets:r,userMaxLimit:s,settings:i,labels:a})=>{const o=()=>{if(!r||s===void 0)return t.max;const f=r();return Math.min(t.max,s-(f-e))},c=i?.locale??"en-US",d=i?.currency??"USD",u=Bh(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:[t.name,typeof t.purchasedQuantity=="number"&&t.purchasedQuantity>1?l.jsx("span",{"data-testid":"ticket-purchased-quantity",children:` x${t.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(t.originalPrice)}),l.jsx("h3",{className:"text-base font-semibold text-zinc-900 m-0","data-testid":"ticket-discounted-price",children:u.format(t.price)})]})]}),t.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:t.membershipName,children:l.jsx("p",{className:"max-w-full truncate text-center",children:t.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," ",t.max]})})]}),l.jsx(Hh,{initialQuantity:e,minQuantity:0,maxQuantity:o(),onChange:n})]}),t.membershipAlert?l.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:l.jsx("span",{className:"ticket-selection-membership-alert-description-text block w-full whitespace-normal break-words text-sm leading-4 text-[#5B2C0F]",children:t.membershipAlert})}):null]})},Wh=({exhibitionId:t,dateGroup:e,isLast:n=!1,onQuantityChange:r,getTicketQuantity:s,getTotalSelectedTickets:i,userMaxLimit:a,settings:o,labels:c})=>l.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:[l.jsx("p",{className:"m-0 text-sm text-left text-zinc-500","data-testid":"upgrade-ticket-date",children:e.date}),e.tickets.map((d,u)=>l.jsxs("div",{children:[l.jsx(qh,{item:d,quantity:s(t,e.id,d.id),onChange:f=>r(t,e.id,d.id,f),getTotalSelectedTickets:i,userMaxLimit:a,settings:o,labels:c}),u<e.tickets.length-1?l.jsx(h.Divider,{className:"bg-zinc-200","data-testid":"upgrade-ticket-divider"}):null]},d.id))]}),Kh=({title:t,exhibition:e,onQuantityChange:n,getTicketQuantity:r,getTotalSelectedTickets:s,userMaxLimit:i,settings:a,labels:o,initialExpanded:c=!1})=>{const[d,u]=y.useState(c),f=e.dates.reduce((m,v)=>m+v.tickets.reduce((b,x)=>b+r(e.id,v.id,x.id),0),0),p=e.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-${e.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:t}),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:[f," ",o.ticketsSelectedToRedeem]}),l.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:l.jsx(U,{icon:"mdi:chevron-down"})})]})]})}),l.jsx("div",{id:`upgrade-items-${e.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&&l.jsx("div",{className:"px-5 flex flex-col gap-6","data-testid":"upgrade-ticket-items",children:p?e.dates.map((m,v)=>l.jsx(Wh,{exhibitionId:e.id,dateGroup:m,isLast:v===e.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})})})})]})},Jh=({initialExpanded:t=!1,userMaxLimit:e,labels:n,settings:r,ticketSelectionData:s,className:i="",onSelectionChange:a})=>{const o=y.useMemo(()=>s??[],[s]),c={...zh,...n},[d,u]=y.useState(()=>Li(o,e,!0)),f=y.useRef(!1),p=y.useMemo(()=>{const S=hs(o).map(({exhibition:A,dateGroup:N,ticket:j})=>[Fi(A.id,N.id,j.id),j]);return new Map(S)},[o]),m=Vh(o,d,e),v=(S,A,N)=>d[S]?.[A]?.[N]?.selectedQuantity??0,b=()=>Ro(d),x=(S,A,N,j)=>{const M=v(S,A,N),D=b()-M;if(e!==void 0&&D+j>e)return;const B=p.get(Fi(S,A,N));if(!B)return;const R={...d,[S]:{...d[S],[A]:{...d[S]?.[A],[N]:{id:N,selectedQuantity:j,originalPrice:B.originalPrice,discountedPrice:B.price}}}};u(R),a?.(R)},k=S=>{const A=Li(o,e,S);u(A),a?.(A)};return y.useEffect(()=>{!f.current&&m&&(a?.(d),f.current=!0)},[m,d,a]),l.jsxs("div",{className:h.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(Uh,{label:c.selectAllButtonLabel,checked:m,onChange:k})]}),o.map(S=>l.jsx(Kh,{title:S.exhibitionName,exhibition:S,onQuantityChange:x,getTicketQuantity:v,getTotalSelectedTickets:b,userMaxLimit:e,settings:r,labels:c,initialExpanded:t},S.id))]})},Yh=350,Gh={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}"},ur=(t,e)=>Object.entries(e).reduce((n,[r,s])=>n.replace(`{${r}}`,s),t),Qh=({dueAmount:t,received:e,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 f={...Gh,...i},p=Rr(t.currency,s),m=e!==void 0,[v,b]=y.useState(n??null),x=m?e:v,k=y.useMemo(()=>{const O=typeof x=="number"&&Number.isFinite(x)?x:0,P=hr(O,t.value,t.currency,s);return{received:O,change:P>0?P:0,isValid:O>=t.value&&O>0}},[x,t.value,t.currency,s]),S=y.useCallback(O=>{const P=O.currentTarget;requestAnimationFrame(()=>{P.isConnected&&P.select()})},[]),A=y.useCallback(O=>{if(a)return;const P=O.replace(/[^\d.,]/g,"").replace(",","."),K=P===""?null:Number.parseFloat(P),X=K===null||Number.isNaN(K)?null:K;if(X!==null&&o!==void 0&&X>o)return;m||b(X);const J=typeof X=="number"&&Number.isFinite(X)?X:0,ue=hr(J,t.value,t.currency,s);r?.({received:J,change:ue>0?ue:0,isValid:J>=t.value&&J>0})},[m,a,t.value,t.currency,s,r,o]),N=x==null?"":String(x),j=k.isValid&&k.change>0,M=!k.isValid&&k.received>0,D=pt(k.change,s,t.currency),B=pt(t.value,s,t.currency),[R,V]=y.useState(""),I=y.useRef(null);y.useEffect(()=>{I.current&&clearTimeout(I.current);const O=j?ur(f.changeMessageTemplate,{change:D}):"",P=j?Yh:0;return I.current=setTimeout(()=>V(O),P),()=>{I.current&&clearTimeout(I.current)}},[j,D,f.changeMessageTemplate]);const T=`${u}-received`;return l.jsxs("div",{className:h.cn("flex flex-col gap-3",d),"data-testid":u,children:[l.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:N,onChange:O=>A(O.target.value),onFocus:S,placeholder:f.receivedPlaceholder,isDisabled:a,isInvalid:M,errorMessage:M?ur(f.insufficientMessageTemplate,{due:B}):void 0,variant:"bordered",radius:"lg",autoFocus:c,"data-testid":`${u}-received-input`}),j&&l.jsx(h.Alert,{"data-testid":`${u}-change-alert`,color:"primary",variant:"flat",radius:"lg",title:f.changeLabel,description:ur(f.changeMessageTemplate,{change:D}),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:R})]})},Zh={checkNumberLabel:"Check Number",checkNumberPlaceholder:"e.g. 11234",bankNameLabel:"Bank Name",bankNamePlaceholder:"e.g. Chase Bank",dateLabel:"Date",checkNumberRequiredMessage:"Check number is required"},Pi=()=>{const t=new Date,e=n=>String(n).padStart(2,"0");return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}`},zo=({dueAmount:t,value:e,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:f,"data-testid":p="check-tender-form"})=>{const m={...Zh,...s},v=e!==void 0,[b,x]=y.useState({checkNumber:n?.checkNumber??"",bankName:n?.bankName??"",date:n?.date??Pi()}),[k,S]=y.useState(!!n?.checkNumber),A=y.useMemo(()=>v?{checkNumber:e?.checkNumber??"",bankName:e?.bankName??"",date:e?.date??Pi()}:b,[v,e,b]),N=y.useCallback(I=>{v||x(I);const T=I.checkNumber.trim(),O={amount:t.value,checkNumber:T,bankName:I.bankName.trim()||void 0,date:i?void 0:I.date,isValid:T.length>0&&t.value>0};r?.(O)},[v,t.value,i,r]),j=y.useCallback(I=>T=>{o||(I==="checkNumber"&&T.length>0&&S(!0),N({...A,[I]:T}))},[A,N,o]),M=y.useCallback(()=>{o||S(!0)},[o]),D=k&&A.checkNumber.trim()==="",B=`${p}-check-number`,R=`${p}-bank-name`,V=`${p}-date`;return l.jsxs("div",{className:h.cn("grid grid-cols-1 sm:grid-cols-2 gap-4",f),"data-testid":p,children:[l.jsx(h.Input,{id:B,label:m.checkNumberLabel,labelPlacement:"outside",type:"text",value:A.checkNumber,onChange:I=>j("checkNumber")(I.target.value),onBlur:M,placeholder:m.checkNumberPlaceholder,maxLength:c,isRequired:!0,isInvalid:D,errorMessage:D?m.checkNumberRequiredMessage:void 0,isDisabled:o,variant:"bordered",radius:"lg",autoFocus:u,"data-testid":`${p}-check-number-input`}),!a&&l.jsx(h.Input,{id:R,label:m.bankNameLabel,labelPlacement:"outside",type:"text",value:A.bankName,onChange:I=>j("bankName")(I.target.value),placeholder:m.bankNamePlaceholder,maxLength:d,isDisabled:o,variant:"bordered",radius:"lg","data-testid":`${p}-bank-name-input`}),!i&&l.jsx(h.Input,{id:V,label:m.dateLabel,labelPlacement:"outside",type:"date",value:A.date,onChange:I=>j("date")(I.target.value),isDisabled:o,variant:"bordered",radius:"lg","data-testid":`${p}-date-input`,className:"sm:col-span-2"})]})};zo.displayName="CheckTenderForm";const Xh={methodLabel:"Method",methodPlaceholder:"Select a payment method",referenceLabel:"Reference",referencePlaceholder:"e.g. Voucher #1234",methodRequiredMessage:"Method is required"},em=[{value:"ach",label:"ACH"},{value:"wire",label:"Wire"},{value:"gift_card",label:"Gift Card"},{value:"voucher",label:"Voucher"},{value:"other",label:"Other"}],Bo=({dueAmount:t,methodOptions:e=em,value:n,defaultValue:r,onChange:s,labels:i,showReference:a=!1,isDisabled:o=!1,className:c,"data-testid":d="other-tender-form"})=>{const u={...Xh,...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=>e.find(M=>M.value===j)?.label??"",[e]),x=y.useCallback(j=>{f||m(j);const M=b(j.method),D={amount:t.value,method:j.method,description:M,reference:j.reference.trim()||void 0,isValid:j.method!==""};s?.(D)},[f,t.value,s,b]),k=y.useCallback(j=>{if(o)return;const M=typeof j=="string"?j:Array.from(j)[0]?.toString()??"";x({...v,method:M})},[v,x,o]),S=y.useCallback(j=>{o||x({...v,reference:j})},[v,x,o]),A=`${d}-method`,N=`${d}-reference`;return l.jsxs("div",{className:h.cn("flex flex-col gap-3",c),"data-testid":d,children:[l.jsx(mt,{id:A,label:u.methodLabel,labelPlacement:"outside",placeholder:u.methodPlaceholder,selectedKeys:v.method?[v.method]:[],onSelectionChange:k,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:e.map(j=>l.jsx(h.SelectItem,{"data-testid":`${d}-method-option-${j.value}`,children:j.label},j.value))}),a&&l.jsx(h.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`})]})};Bo.displayName="OtherTenderForm";const tm={collectedHeading:"Collected",remainingLabel:"Remaining:",completeLabel:"Complete",removeAriaLabel:"Remove this tender",removeTooltipForRecorded:"Already recorded",statusPending:"Pending",statusRecorded:"Approved",statusFailed:"Failed"},nm={card:"lucide:credit-card",cash:"lucide:dollar-sign",check:"lucide:edit-3",other:"lucide:more-horizontal"},rm={pending:"warning",recorded:"success",failed:"danger"},sm=t=>t==="pending"||t==="recorded",im=t=>`#${t+1}`,_o=({total:t,tenders:e,onRemove:n,locale:r="en-US",labels:s,hideCollectedList:i=!1,className:a,"data-testid":o="split-payment-summary"})=>{const c={...tm,...s},{collected:d,remaining:u,isComplete:f}=y.useMemo(()=>{const m=e.reduce((b,x)=>sm(x.status)?b+x.amount:b,0),v=Math.max(t.value-m,0);return{collected:m,remaining:v,isComplete:m>=t.value&&t.value>0}},[e,t.value]),p=m=>m==="pending"?c.statusPending:m==="recorded"?c.statusRecorded:c.statusFailed;return l.jsxs("div",{className:h.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:f?c.completeLabel:c.remainingLabel}),l.jsx("div",{className:"mt-1 text-4xl font-bold tracking-tight","data-testid":`${o}-remaining-amount`,children:pt(f?d:u,r,t.currency)})]}),!i&&e.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}),e.map((m,v)=>l.jsx(am,{index:v,tender:m,locale:r,currency:t.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))]})]})};_o.displayName="SplitPaymentSummary";const am=({index:t,tender:e,locale:n,currency:r,removable:s,onRemove:i,statusLabel:a,removeAriaLabel:o,recordedTooltip:c,dataTestId:d})=>{const u=i?l.jsx(q,{isIconOnly:!0,variant:"light",radius:"full",size:"sm",onPress:i,isDisabled:!s,"aria-label":o,"data-testid":`${d}-remove`,className:h.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:im(t)}),l.jsx(U,{icon:nm[e.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:e.label}),l.jsx("span",{className:"font-semibold tabular-nums","data-testid":`${d}-amount`,children:pt(e.amount,n,r)}),l.jsx(h.Chip,{size:"sm",radius:"full",variant:"flat",color:rm[e.status],startContent:e.status==="recorded"?l.jsx(U,{icon:"lucide:check-circle",width:14,height:14,"aria-hidden":"true"}):e.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(h.Tooltip,{content:c,placement:"left",children:l.jsx("span",{tabIndex:0,"aria-label":c,children:u})}))]})},om=`
|
|
20
|
+
@keyframes pp-modal-in {
|
|
21
|
+
from { opacity: 0; transform: scale(0.96); }
|
|
22
|
+
to { opacity: 1; transform: scale(1); }
|
|
23
|
+
}
|
|
24
|
+
@keyframes pp-fade-in {
|
|
25
|
+
from { opacity: 0; }
|
|
26
|
+
to { opacity: 1; }
|
|
27
|
+
}
|
|
28
|
+
@keyframes pp-fade-out {
|
|
29
|
+
from { opacity: 1; }
|
|
30
|
+
to { opacity: 0; }
|
|
31
|
+
}
|
|
32
|
+
@keyframes pp-scale-in {
|
|
33
|
+
from { opacity: 0; transform: scale(0.92); }
|
|
34
|
+
to { opacity: 1; transform: scale(1); }
|
|
35
|
+
}
|
|
36
|
+
@keyframes pp-slide-down {
|
|
37
|
+
from { opacity: 0; transform: translateY(-8px); }
|
|
38
|
+
to { opacity: 1; transform: translateY(0); }
|
|
39
|
+
}
|
|
40
|
+
@keyframes pp-row-in {
|
|
41
|
+
from { opacity: 0; transform: translateY(-6px); }
|
|
42
|
+
to { opacity: 1; transform: translateY(0); }
|
|
43
|
+
}
|
|
44
|
+
`,Vo=y.forwardRef(({children:t,relativeOverlayRoot:e=!0,className:n,style:r,"data-testid":s="modal-shell"},i)=>l.jsxs(l.Fragment,{children:[l.jsx("style",{children:om}),l.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",e&&"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:t})]}));Vo.displayName="ModalShell";const Ho=({title:t,onClose:e,closeLabel:n="Close",actions:r,className:s,"data-testid":i="modal-shell-header"})=>l.jsxs("header",{className:h.cn("flex items-center justify-between",s),"data-testid":i,children:[l.jsx("h2",{className:"text-xl font-semibold","data-testid":`${i}-title`,children:t}),l.jsxs("div",{className:"flex items-center gap-2",children:[r,e&&l.jsx(q,{isIconOnly:!0,variant:"light",radius:"full",size:"sm",onPress:e,"aria-label":n,"data-testid":`${i}-close`,children:l.jsx(U,{icon:"lucide:x",width:20,height:20,"aria-hidden":"true"})})]})]});Ho.displayName="ModalShellHeader";const Uo=({children:t,columns:e=2,className:n,"data-testid":r="modal-shell-footer"})=>l.jsx("footer",{className:h.cn("mt-2 gap-3",e===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:t});Uo.displayName="ModalShellFooter";const lm={2:"sm:grid-cols-2",3:"sm:grid-cols-3",4:"sm:grid-cols-4"},cm={1:"grid-cols-1",2:"grid-cols-2"},fr=t=>typeof t=="string"?l.jsx(U,{icon:t,width:20,height:20,"aria-hidden":"true"}):t,qo=({options:t,selectedKey:e,onSelect:n,heading:r,ariaLabel:s="Select an option",columnsDesktop:i=3,columnsMobile:a=2,className:o,"data-testid":c="tile-select"})=>{const d=t.find(u=>u.key===e);return l.jsxs("div",{className:h.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(mt,{"aria-label":r?void 0:s,"aria-labelledby":r?`${c}-heading`:void 0,selectedKeys:e?[e]:[],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:fr(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:t.map(u=>l.jsx(h.SelectItem,{isDisabled:u.isDisabled,startContent:l.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:fr(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:h.cn("hidden md:grid gap-3",cm[a],lm[i]),children:t.map(u=>{const f=e===u.key;return l.jsxs(q,{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:[l.jsx("span",{"aria-hidden":"true",children:fr(u.icon)}),l.jsx("span",{className:"text-sm font-medium",children:u.label})]},u.key)})})]})};qo.displayName="TileSelect";const dm={subtle:{wrapper:"bg-default-100",amount:"text-default-900"},success:{wrapper:"bg-success-50 text-success-700",amount:"text-success-700"}},Wo=({total:t,label:e,locale:n="en-US",variant:r="subtle",className:s,"data-testid":i="payment-total-banner"})=>{const a=dm[r];return l.jsxs("div",{"data-testid":i,className:h.cn("rounded-2xl px-6 py-5 text-center",a.wrapper,s),children:[l.jsx("div",{className:"text-sm text-default-600",children:e}),l.jsx("div",{className:h.cn("mt-1 text-4xl font-bold tracking-tight",a.amount),"data-testid":`${i}-amount`,children:pt(t.value,n,t.currency)})]})};Wo.displayName="PaymentTotalBanner";const um={white:"bg-white/70 backdrop-blur-sm",transparent:"bg-transparent"},Ko=({title:t,subtitle:e,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:h.cn("absolute inset-0 z-10 flex flex-col items-center justify-center gap-4 rounded-3xl",um[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:t}),e&&l.jsx("div",{className:"mt-1 text-sm text-default-600",children:e})]})]});Ko.displayName="LoadingOverlay";const ms=({cashChange:t,label:e="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(!t||t.value<=0)return null;const d=a==="center";return l.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]",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:h.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:e}),l.jsx("span",{className:"text-2xl font-bold text-info-700","data-testid":`${c}-amount`,children:pt(t.value,r,t.currency)}),n&&l.jsx("span",{className:"mt-0.5 text-xs text-info-700/80",children:n})]}),s&&l.jsx(q,{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"})})]})};ms.displayName="PaymentCashChangeBanner";const Jo=({title:t,subtitle:e,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 f=!!(s&&s.value>0);return l.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:[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:t}),l.jsx("p",{className:"text-default-700",children:e}),n&&r&&l.jsxs("p",{className:"text-default-700",children:[n,l.jsx("br",{}),l.jsx("strong",{className:"font-semibold",children:r})]})]}),f&&s&&l.jsx(ms,{cashChange:s,label:i,locale:a,align:"center",className:"max-w-[400px]","data-testid":`${u}-cash-change`}),c&&l.jsx(q,{color:"default",variant:"bordered",radius:"full",size:"lg",onPress:c,"data-testid":`${u}-close`,className:"mt-4 w-full",children:o})]})};Jo.displayName="PaymentSuccessView";const Yo=({heading:t,amountLabel:e,value:n,defaultValue:r,onChange:s,placeholder:i,isDisabled:a,isInvalid:o,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 k=Number.parseFloat(x.replace(",","."));if(Number.isFinite(k)&&k>u)return}s?.(x)},[u,s]),b=y.useCallback(x=>{const k=x.currentTarget;requestAnimationFrame(()=>{k.isConnected&&k.select()})},[]);return l.jsxs("div",{className:h.cn("flex flex-col gap-3 border-t border-default-100 pt-5",f),"data-testid":p,children:[l.jsx("h3",{className:"text-lg font-semibold","data-testid":`${p}-heading`,children:t}),l.jsx(h.Input,{id:m,label:e,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`})]})};Yo.displayName="PaymentSubAmountInput";const Go=({isOpen:t,title:e,body:n,confirmLabel:r,confirmVariant:s="danger",dismissLabel:i,onConfirm:a,onDismiss:o,"data-testid":c="confirm-dialog"})=>l.jsx(h.Modal,{isOpen:t,onOpenChange:d=>{d||o()},role:"alertdialog",size:"sm",backdrop:"opaque","data-testid":c,"aria-labelledby":`${c}-title`,"aria-describedby":`${c}-body`,children:l.jsxs(h.ModalContent,{children:[l.jsx(h.ModalHeader,{id:`${c}-title`,className:"text-lg font-semibold",children:e}),l.jsx(h.ModalBody,{id:`${c}-body`,className:"text-sm text-default-700",children:n}),l.jsxs(h.ModalFooter,{className:"grid grid-cols-2 gap-3",children:[l.jsx(q,{variant:"bordered",radius:"full",onPress:o,"data-testid":`${c}-dismiss`,className:"h-11",children:i}),l.jsx(q,{color:s,variant:"solid",radius:"full",onPress:a,"data-testid":`${c}-confirm`,className:"h-11",children:r})]})]})});Go.displayName="ConfirmDialog";exports.Button=q;exports.CashTenderForm=Qh;exports.CheckTenderForm=zo;exports.CommitmentDetails=Zf;exports.ConfirmDialog=Go;exports.ConfirmationModal=Cn;exports.ConfirmationPageTemplate=xl;exports.DonationAmounts=Oa;exports.EventDetails=of;exports.EventDetailsTemplate=vl;exports.ExpireCartTimer=La;exports.Footer=kl;exports.HeroUIProvider=ul;exports.InstallmentFundAssignment=Wf;exports.InstallmentFundAssignmentSkeleton=Gf;exports.InstallmentSchedule=jh;exports.InstallmentScheduleSkeleton=Ih;exports.InstallmentTable=Oh;exports.ItemCard=Fo;exports.LoadingOverlay=Ko;exports.MembershipSelectCards=Rh;exports.ModalShell=Vo;exports.ModalShellFooter=Uo;exports.ModalShellHeader=Ho;exports.Multiselect=wl;exports.Navbar=gl;exports.OfferCard=ts;exports.OfferCardEmpty=Ga;exports.OfferCardError=Qa;exports.OfferCardList=to;exports.OfferCardSkeleton=Za;exports.OtherTenderForm=Bo;exports.PaymentCashChangeBanner=ms;exports.PaymentSubAmountInput=Yo;exports.PaymentSuccessView=Jo;exports.PaymentTotalBanner=Wo;exports.RICH_TEXT_PRESETS=Ia;exports.RevenueDistributionCard=mo;exports.RevenueDistributionEmpty=po;exports.RevenueDistributionError=go;exports.RevenueDistributionSkeleton=xo;exports.RichTextArea=$a;exports.Select=mt;exports.SplitPaymentSummary=_o;exports.Stepper=Ri;exports.TicketSelection=Jh;exports.TileSelect=qo;exports.Toggle=Po;exports.calculateAllocationDifference=zf;exports.computeChange=hr;exports.currencyFractionDigits=Rr;exports.formatMoney=pt;exports.formatOfferCurrency=Ya;exports.formatRevenueAmount=Lf;exports.formatRevenueCurrency=Ff;exports.generateAutomaticInstallments=$o;exports.generateDistributionId=cs;exports.getCurrencySymbol=Pf;exports.offerCardVariants=eo;exports.offerListVariants=Xa;exports.parseOfferCurrency=lf;exports.parseRevenueCurrency=Rf;exports.roundToCurrency=zi;Object.keys(h).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>h[t]})});
|
|
20
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)}})();
|