@veevarts/design-system 1.11.0 → 1.12.0-alpha.2
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 +9138 -5480
- 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/Summary/Summary.d.ts +4 -0
- package/dist/patterns/Summary/components/ActionBar.d.ts +17 -0
- package/dist/patterns/Summary/components/CartButton.d.ts +11 -0
- package/dist/patterns/Summary/components/CollapseHeader.d.ts +19 -0
- package/dist/patterns/Summary/components/GrandTotalRow.d.ts +11 -0
- package/dist/patterns/Summary/components/ItemRow.d.ts +9 -0
- package/dist/patterns/Summary/components/PrimaryCta.d.ts +11 -0
- package/dist/patterns/Summary/components/ServiceFeeRow.d.ts +8 -0
- package/dist/patterns/Summary/components/SummaryBody.d.ts +15 -0
- package/dist/patterns/Summary/components/TotalsLineRow.d.ts +8 -0
- package/dist/patterns/Summary/drag.d.ts +55 -0
- package/dist/patterns/Summary/fmt.d.ts +2 -0
- package/dist/patterns/Summary/index.d.ts +7 -0
- package/dist/patterns/Summary/types.d.ts +147 -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 +34 -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 o=require("react/jsx-runtime"),h=require("@heroui/react"),y=require("react"),U=require("lucide-react"),Le=require("framer-motion"),Rr=require("@tiptap/react"),z=require("@tiptap/core"),go=require("@tiptap/extension-underline"),xo=require("@tiptap/extension-color"),yo=require("@tiptap/extension-highlight"),bo=require("@tiptap/extension-link"),vo=require("@tiptap/extension-task-list"),wo=require("@tiptap/extension-task-item"),ko=require("@tiptap/extension-text-align");function No({children:e}){return o.jsx(h.HeroUIProvider,{children:e})}const q=y.forwardRef(({color:e="primary",radius:t="full",testId:n="veevart-button",...r},s)=>o.jsx(h.Button,{ref:s,color:e,radius:t,"data-testid":n,...r}));q.displayName="Button";function So(e){const t=e?.closest('[role="dialog"]');return t?.parentElement??t??void 0}const pt=y.forwardRef(({popoverProps:e,...t},n)=>{const r=y.useRef(null),[s,i]=y.useState(void 0),a={...e,disableDialogFocus:e?.disableDialogFocus??(s?!0:void 0),portalContainer:e?.portalContainer??s};return y.useEffect(()=>{i(So(r.current))},[]),o.jsx("span",{ref:r,className:"contents",children:o.jsx(h.Select,{ref:n,...t,popoverProps:a})})});pt.displayName="Select";const Co={login:"Login",logout:"Logout",selectLanguage:"Select your language"};function jo({languages:e,selectedLanguage:t,onLanguageChange:n,label:r}){const s=e.find(i=>i.code===t);return o.jsx("div",{className:"flex items-center",children:o.jsxs("div",{className:"relative flex items-center",children:[o.jsx(pt,{"data-testid":"language-select-desktop",variant:"bordered","aria-label":r,selectedKeys:t?[t]:[],onSelectionChange:i=>{const a=Array.from(i)[0]||t;n?.(a)},className:"min-w-36 hidden md:inline-flex",isDisabled:e.length===0,placeholder:r,startContent:o.jsx(U.Globe,{className:"w-5 h-5 text-black"}),renderValue:()=>o.jsx("span",{children:s?.label||r}),size:"md",radius:"full",children:e.map(i=>o.jsx(h.SelectItem,{textValue:i.label,"data-testid":`language-select-option-${i.code}`,children:i.label},i.code))}),o.jsx(pt,{"aria-label":r,"data-testid":"language-select-mobile",variant:"bordered",selectedKeys:t?[t]:[],onSelectionChange:i=>{const a=Array.from(i)[0]||t;n?.(a)},className:"w-24 inline-flex md:hidden",isDisabled:e.length===0,placeholder:"",startContent:o.jsx(U.Globe,{className:"w-6 h-6 text-black"}),renderValue:()=>o.jsx("span",{children:s?.code.toUpperCase()||""}),size:"md",radius:"full",children:e.map(i=>o.jsx(h.SelectItem,{textValue:i.code.toUpperCase(),"data-testid":`language-select-option-mobile-${i.code}`,children:i.code.toUpperCase()},i.code))})]})})}function Ao({isLoggedIn:e,onLogin:t,onLogout:n,labels:r}){return e?o.jsxs(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:[o.jsx(U.User,{className:"inline w-5 h-5"}),o.jsx("span",{className:"hidden md:inline",children:r.logout})]}):o.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:t,size:"md",children:[o.jsx(U.User,{className:"inline w-5 h-5"}),o.jsx("span",{className:"hidden md:inline",children:r.login})]})}function Mo({logo:e,languages:t=[],selectedLanguage:n,onLanguageChange:r,isLoggedIn:s,onLogin:i,onLogout:a,hasLanguages:l,hasAuth:c,labels:d={},className:u}){const f={...Co,...d};return o.jsxs("nav",{"data-testid":"navbar",className:h.cn("w-full px-4 md:px-8 py-3 bg-white border-b border-zinc-100 flex items-center justify-between",u),children:[o.jsx("div",{className:"flex items-center min-w-10",children:e&&o.jsx("a",{href:"/",className:"block",children:o.jsx("img",{"data-testid":"navbar-logo",src:e,alt:"Logo",className:"h-8 w-auto max-w-28 md:max-w-40 object-contain"})})}),o.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[(l||t.length>0)&&o.jsx(jo,{languages:t,selectedLanguage:n,onLanguageChange:r,label:f.selectLanguage}),c&&o.jsx(Ao,{isLoggedIn:s,onLogin:i,onLogout:a,labels:f})]})]})}function Eo(e){return o.jsx("div",{className:"min-h-screen flex flex-col",children:o.jsx("div",{className:"flex-1 flex items-center justify-center p-12",children:o.jsx(h.Alert,{description:"This template combines Navbar, Footer, and a confirmation Card. Include title, message, confirmation number, details list, icon, and action buttons. Use Card for the confirmation content.",title:"TODO: Implement ConfirmationPageTemplate",variant:"faded",className:"max-w-2xl"})})})}var Un;const To=typeof document<"u"?(Un=y.useInsertionEffect)!==null&&Un!==void 0?Un:y.useLayoutEffect:()=>{};function zr(e,t,n){let[r,s]=y.useState(e||t),i=y.useRef(r),a=y.useRef(e!==void 0),l=e!==void 0;y.useEffect(()=>{let f=a.current;f!==l&&process.env.NODE_ENV!=="production"&&console.warn(`WARN: A component changed from ${f?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}.`),a.current=l},[l]);let c=l?e:r;To(()=>{i.current=c});let[,d]=y.useReducer(()=>({}),{}),u=y.useCallback((f,...p)=>{let m=typeof f=="function"?f(i.current):f;Object.is(i.current,m)||(i.current=m,s(m),d(),n?.(m,...p))},[n]);return[c,u]}function Do(e){return o.jsx("svg",{...e,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:o.jsx(Le.m.path,{animate:{pathLength:1},d:"M5 13l4 4L19 7",initial:{pathLength:0},strokeLinecap:"round",strokeLinejoin:"round",transition:{delay:.2,type:"tween",ease:"easeOut",duration:.3}})})}const _i=y.forwardRef(({color:e="primary",stepsCount:t=3,defaultStep:n=0,label:r,onStepChange:s,currentStep:i,hideProgressBars:a=!1,stepClassName:l,className:c,isDisabled:d=!1,...u},f)=>{const[p,m]=zr(i,n,s),v=y.useMemo(()=>{let b,x;const w=["[--active-fg-color:hsl(var(--step-fg-color))]","[--active-border-color:hsl(var(--step-color))]","[--active-color:hsl(var(--step-color))]","[--complete-background-color:hsl(var(--step-color))]","[--complete-border-color:hsl(var(--step-color))]","[--inactive-border-color:hsl(var(--heroui-default-300))]","[--inactive-color:hsl(var(--heroui-default-300))]"];switch(e){case"primary":b="[--step-color:var(--heroui-primary)]",x="[--step-fg-color:var(--heroui-primary-foreground)]";break;case"secondary":b="[--step-color:var(--heroui-secondary)]",x="[--step-fg-color:var(--heroui-secondary-foreground)]";break;case"success":b="[--step-color:var(--heroui-success)]",x="[--step-fg-color:var(--heroui-success-foreground)]";break;case"warning":b="[--step-color:var(--heroui-warning)]",x="[--step-fg-color:var(--heroui-warning-foreground)]";break;case"danger":b="[--step-color:var(--heroui-danger)]",x="[--step-fg-color:var(--heroui-danger-foreground)]";break;case"default":b="[--step-color:var(--heroui-default)]",x="[--step-fg-color:var(--heroui-default-foreground)]";break;default:b="[--step-color:var(--heroui-primary)]",x="[--step-fg-color:var(--heroui-primary-foreground)]";break}return w.unshift(x),w.unshift(b),w},[e]);return o.jsxs("nav",{ref:f,"aria-label":"Progress",className:h.cn("flex max-w-fit items-center overflow-x-auto",c),"data-testid":"stepper-root",...u,children:[r&&o.jsx("label",{className:"text-small text-default-foreground lg:text-medium font-light whitespace-nowrap me-3","data-testid":"stepper-label",children:r}),o.jsx("ol",{className:h.cn("flex flex-row flex-nowrap gap-x-3",v,c),"data-testid":"stepper-list",children:Array.from({length:t})?.map((b,x)=>{const w=p===x?"active":p<x?"inactive":"complete";return o.jsx("li",{className:"relative flex shrink-0 items-center pr-12","data-testid":`stepper-step-${x}`,children:o.jsxs("button",{"aria-current":w==="active"?"step":void 0,className:h.cn("group rounded-large flex w-full cursor-pointer flex-row items-center justify-center gap-x-3 py-2.5",{"cursor-not-allowed opacity-50":d},l),onClick:()=>!d&&m(x),disabled:d,"data-testid":`stepper-step-btn-${x}`,children:[o.jsx("div",{className:"h-full relative flex items-center",children:o.jsx(Le.LazyMotion,{features:Le.domAnimation,children:o.jsx(Le.m.div,{animate:w,className:"relative",children:o.jsx(Le.m.div,{animate:w,className:h.cn("border-medium text-large text-default-foreground relative flex h-[26px] w-[26px] items-center justify-center rounded-full font-semibold",{"shadow-lg":w==="complete"}),initial:!1,transition:{duration:.25},variants:{inactive:{backgroundColor:"transparent",borderColor:"var(--inactive-border-color)",color:"var(--inactive-color)"},active:{backgroundColor:"transparent",borderColor:"var(--active-border-color)",color:"var(--active-color)"},complete:{backgroundColor:"var(--complete-background-color)",borderColor:"var(--complete-border-color)",color:"var(--active-fg-color)"}},children:o.jsx("div",{className:"flex items-center justify-center",children:w==="complete"?o.jsx(Do,{className:"h-5 w-5 text-(--active-fg-color)","data-testid":`stepper-step-check-${x}`}):o.jsx("span",{})})})})})}),x<t-1&&!a&&o.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 left-[26px] w-[calc(100%-13px)] flex-none items-center",style:{"--idx":x},children:o.jsx("div",{className:h.cn("bg-default-200 relative h-0.5 w-full transition-colors duration-300","after:absolute after:block after:h-full after:w-0 after:bg-(--active-border-color) after:transition-[width] after:duration-300 after:content-['']",{"after:w-full":x<p})})})]},x)},x)})})]})});_i.displayName="Stepper";function Io(e){return o.jsx("div",{className:"min-h-screen flex flex-col",children:o.jsx("div",{className:"flex-1 flex items-center justify-center p-12",children:o.jsx(h.Alert,{description:"This template combines Navbar, Stepper, Footer, and an event details Card. Include event image, category/spots chips, tags, details grid, and action buttons. Use Card, CardHeader, CardBody for content structure.",title:"TODO: Implement EventDetailsTemplate",variant:"faded",className:"max-w-2xl"})})})}function tt(e,t="en-US",n="USD"){try{return new Intl.NumberFormat(t,{style:"currency",currency:n}).format(e)}catch{return`${n} ${e.toFixed(2)}`}}function Br(e,t="en-US"){try{const n=new Intl.NumberFormat(t,{style:"currency",currency:e}).resolvedOptions();return typeof n.maximumFractionDigits=="number"?n.maximumFractionDigits:2}catch{return 2}}function Vi(e,t,n="en-US"){const r=Br(t,n),s=Math.pow(10,r);return Math.round(e*s)/s}function pr(e,t,n,r){return Vi(e-t,n,r)}function $o(){return o.jsxs("footer",{"data-testid":"footer",className:"fixed left-0 bottom-0 w-full text-left p-4 bg-white font-inter font-light text-base text-zinc-500",children:["Powered by Veevart ® ",new Date().getFullYear()]})}const Oo=e=>{const t=y.useMemo(()=>JSON.stringify({allItems:e.allItems,selected:e.selected}),[e.allItems,e.selected]);return o.jsx(Lo,{...e},t)},Lo=({allItems:e,selected:t,onSelectedChange:n,titleLeft:r,titleRight:s})=>{const[i,a]=y.useState([]),[l,c]=y.useState([]),[d,u]=y.useState(null),[f,p]=y.useState(null),m=y.useMemo(()=>new Set(t),[t]),v=y.useMemo(()=>new Set(e),[e]),b=y.useMemo(()=>e.filter(I=>!m.has(I)),[e,m]),x=I=>{if(I.length===0)return;const E=Array.from(new Set([...t,...I]));n(E)},w=I=>{if(I.length===0)return;const E=new Set(I);n(t.filter(O=>!E.has(O)))},N=()=>{i.length!==0&&(x(i),a([]))},A=()=>{l.length!==0&&(w(l),c([]))},S=()=>{b.length!==0&&(x(b),a([]))},j=()=>{t.length!==0&&(n([]),c([]))},M=(I,E,O)=>{const P=Math.min(E,O),K=Math.max(E,O);return I.slice(P,K+1)},D=(I,E,O)=>{if(O&&d!==null){a(M(b,d,E)),c([]),u(E);return}const P=i.includes(I);a(P?i.filter(K=>K!==I):[...i,I]),c([]),u(E)},B=(I,E,O)=>{if(O&&f!==null){c(M(t,f,E)),a([]),p(E);return}const P=l.includes(I);c(P?l.filter(K=>K!==I):[...l,I]),a([]),p(E)},F=(I,E,O)=>{const P=O==="available"?i.includes(E)?i:[E]:l.includes(E)?l:[E];I.dataTransfer.setData("text/plain",JSON.stringify({source:O,items:P})),I.dataTransfer.effectAllowed="move"},_=(I,E)=>{I.preventDefault();const O=I.dataTransfer.getData("text/plain");if(O)try{const P=JSON.parse(O),K=(P.items||[]).filter(Z=>v.has(Z));if(K.length===0||P.source===E)return;E==="selected"?(x(K),a([])):(w(K),c([]))}catch{return}};return o.jsxs("div",{className:"flex flex-col gap-6 md:flex-row md:items-start md:justify-between",children:[o.jsxs("div",{className:"flex w-full flex-col gap-3 md:w-2/5",children:[o.jsx("h2",{className:"text-sm font-medium text-gray-700",children:r}),o.jsx(h.Card,{className:"w-full border border-gray-200 shadow-none",children:o.jsx(h.CardBody,{className:"h-60 gap-2 overflow-y-auto",onDragOver:I=>I.preventDefault(),onDrop:I=>_(I,"available"),children:b.map((I,E)=>{const O=i.includes(I);return o.jsx("button",{type:"button",onClick:P=>{D(I,E,P.shiftKey)},onMouseDown:P=>{P.shiftKey&&P.preventDefault()},draggable:!0,onDragStart:P=>F(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)})})})]}),o.jsxs("div",{className:"flex flex-row items-center justify-center gap-3 md:flex-col md:pt-6",children:[o.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:N,isDisabled:i.length===0,"aria-label":"Move selected to right",children:"›"}),o.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:l.length===0,"aria-label":"Move selected to left",children:"‹"}),o.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:S,isDisabled:b.length===0,"aria-label":"Move all to right",children:"»"}),o.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:t.length===0,"aria-label":"Move all to left",children:"«"})]}),o.jsxs("div",{className:"flex w-full flex-col gap-3 md:w-2/5",children:[o.jsx("h2",{className:"text-sm font-medium text-gray-700",children:s}),o.jsx(h.Card,{className:"w-full border border-gray-200 shadow-none",children:o.jsx(h.CardBody,{className:"h-60 gap-2 overflow-y-auto",onDragOver:I=>I.preventDefault(),onDrop:I=>_(I,"selected"),children:t.map((I,E)=>{const O=l.includes(I);return o.jsx("button",{type:"button",onClick:P=>{B(I,E,P.shiftKey)},onMouseDown:P=>{P.shiftKey&&P.preventDefault()},draggable:!0,onDragStart:P=>F(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(e){return typeof e=="string"?e:e.type}function it({className:e}){return o.jsx("div",{className:`flex items-center h-6 ${e||""}`,children:o.jsx(h.Divider,{orientation:"vertical"})})}function at({icon:e,label:t,isActive:n=!1,isDisabled:r=!1,onClick:s,shortcut:i,iconSize:a=16,className:l}){const c=i?`${t} (${i})`:t;return o.jsx(h.Tooltip,{content:c,placement:"top",offset:10,children:o.jsx(q,{size:"sm",radius:"sm",color:n?"primary":"default",variant:n?"solid":"bordered",isIconOnly:!0,isDisabled:r,onPress:s,"aria-label":t,className:l,children:o.jsx(e,{size:a})})})}const We={bold:{execute:({editor:e})=>e.chain().focus().toggleBold().run(),canExecute:e=>e.can().chain().focus().toggleBold().run(),isActive:e=>e.isActive("bold"),shortcut:"Mod-b",label:"Bold"},italic:{execute:({editor:e})=>e.chain().focus().toggleItalic().run(),canExecute:e=>e.can().chain().focus().toggleItalic().run(),isActive:e=>e.isActive("italic"),shortcut:"Mod-i",label:"Italic"},strike:{execute:({editor:e})=>e.chain().focus().toggleStrike().run(),canExecute:e=>e.can().chain().focus().toggleStrike().run(),isActive:e=>e.isActive("strike"),shortcut:"Mod-Shift-x",label:"Strikethrough"},underline:{execute:({editor:e})=>e.chain().focus().toggleUnderline().run(),canExecute:e=>e.can().chain().focus().toggleUnderline().run(),isActive:e=>e.isActive("underline"),shortcut:"Mod-u",label:"Underline"},code:{execute:({editor:e})=>e.chain().focus().toggleCode().run(),canExecute:e=>e.can().chain().focus().toggleCode().run(),isActive:e=>e.isActive("code"),shortcut:"Mod-e",label:"Inline code"},textColor:{execute:({editor:e,config:t})=>{const n=t?.type==="textColor"?t.color:"";n?e.chain().focus().setColor(n).run():e.chain().focus().unsetColor().run()},canExecute:()=>!0,isActive:e=>e.isActive("textStyle"),label:"Text color"},highlight:{execute:({editor:e,config:t})=>{const n=t?.type==="highlight"?t.color:"";n?e.chain().focus().setHighlight({color:n}).run():e.chain().focus().unsetHighlight().run()},canExecute:()=>!0,isActive:e=>e.isActive("highlight"),label:"Highlight"},link:{execute:({editor:e,config:t})=>{const n=t?.type==="link"?t.href:"";if(n){const r=t?.type==="link"?t.target:void 0,s=t?.type==="link"?t.rel:void 0;e.chain().focus().setLink({href:n,target:r,rel:s}).run()}else e.chain().focus().unsetLink().run()},canExecute:()=>!0,isActive:e=>e.isActive("link"),shortcut:"Mod-k",label:"Link"},paragraph:{execute:({editor:e})=>e.chain().focus().setParagraph().run(),canExecute:e=>e.can().chain().focus().setParagraph().run(),isActive:e=>e.isActive("paragraph"),shortcut:"Mod-Alt-0",label:"Paragraph"},heading:{execute:({editor:e,config:t})=>{const n=t?.type==="heading"?t.level:1;e.chain().focus().toggleHeading({level:n}).run()},canExecute:(e,t)=>{const n=t?.type==="heading"?t.level:1;return e.can().chain().focus().toggleHeading({level:n}).run()},isActive:(e,t)=>t?.type==="heading"?e.isActive("heading",{level:t.level}):e.isActive("heading"),label:"Heading"},bulletList:{execute:({editor:e})=>e.chain().focus().toggleBulletList().run(),canExecute:e=>e.can().chain().focus().toggleBulletList().run(),isActive:e=>e.isActive("bulletList"),shortcut:"Mod-Shift-8",label:"Bullet list"},orderedList:{execute:({editor:e})=>e.chain().focus().toggleOrderedList().run(),canExecute:e=>e.can().chain().focus().toggleOrderedList().run(),isActive:e=>e.isActive("orderedList"),shortcut:"Mod-Shift-7",label:"Numbered list"},taskList:{execute:({editor:e})=>e.chain().focus().toggleTaskList().run(),canExecute:e=>e.can().chain().focus().toggleTaskList().run(),isActive:e=>e.isActive("taskList"),label:"Task list"},codeBlock:{execute:({editor:e})=>e.chain().focus().toggleCodeBlock().run(),canExecute:e=>e.can().chain().focus().toggleCodeBlock().run(),isActive:e=>e.isActive("codeBlock"),shortcut:"Mod-Alt-c",label:"Code block"},blockquote:{execute:({editor:e})=>e.chain().focus().toggleBlockquote().run(),canExecute:e=>e.can().chain().focus().toggleBlockquote().run(),isActive:e=>e.isActive("blockquote"),shortcut:"Mod-Shift-b",label:"Blockquote"},horizontalRule:{execute:({editor:e})=>e.chain().focus().setHorizontalRule().run(),canExecute:e=>e.can().chain().focus().setHorizontalRule().run(),isActive:()=>!1,label:"Horizontal rule"},hardBreak:{execute:({editor:e})=>e.chain().focus().setHardBreak().run(),canExecute:e=>e.can().chain().focus().setHardBreak().run(),isActive:()=>!1,shortcut:"Mod-Enter",label:"Line break"},textAlign:{execute:({editor:e,config:t})=>{const n=t?.type==="textAlign"?t.alignment:"left";e.chain().focus().setTextAlign(n).run()},canExecute:()=>!0,isActive:(e,t)=>t?.type==="textAlign"?e.isActive({textAlign:t.alignment}):!1,label:"Text alignment"},clearMarks:{execute:({editor:e})=>e.chain().focus().unsetAllMarks().run(),canExecute:e=>e.can().chain().focus().unsetAllMarks().run(),isActive:()=>!1,label:"Clear formatting"},clearNodes:{execute:({editor:e})=>e.chain().focus().clearNodes().run(),canExecute:e=>e.can().chain().focus().clearNodes().run(),isActive:()=>!1,label:"Clear nodes"},undo:{execute:({editor:e})=>e.chain().focus().undo().run(),canExecute:e=>e.can().chain().focus().undo().run(),isActive:()=>!1,shortcut:"Mod-z",label:"Undo"},redo:{execute:({editor:e})=>e.chain().focus().redo().run(),canExecute:e=>e.can().chain().focus().redo().run(),isActive:()=>!1,shortcut:"Mod-Shift-z",label:"Redo"}},Fo={1:"Heading 1",2:"Heading 2",3:"Heading 3",4:"Heading 4",5:"Heading 5",6:"Heading 6"};function Po({editor:e,levels:t=[1,2,3,4,5,6],isDisabled:n=!1}){const[,r]=y.useState(0);y.useEffect(()=>{const a=()=>r(l=>l+1);return e.on("selectionUpdate",a),e.on("transaction",a),()=>{e.off("selectionUpdate",a),e.off("transaction",a)}},[e]);const s=t.find(a=>e.isActive("heading",{level:a})),i=a=>{const l=Number(a),c=We.heading;c&&c.execute({editor:e,config:{type:"heading",level:l}})};return o.jsxs(h.Dropdown,{placement:"top-start",offset:10,children:[o.jsx(h.DropdownTrigger,{children:o.jsx(q,{size:"sm",radius:"sm",variant:s?"solid":"bordered",color:s?"primary":"default",isDisabled:n,startContent:o.jsx(U.Heading,{size:16}),"aria-label":"Select heading level",children:s?`H${s}`:"H"})}),o.jsx(h.DropdownMenu,{"aria-label":"Heading levels",selectionMode:"single",selectedKeys:s?new Set([String(s)]):new Set,onAction:i,children:t.map(a=>o.jsx(h.DropdownItem,{startContent:e.isActive("heading",{level:a})?o.jsx(U.Check,{size:16}):o.jsx("div",{className:"w-4"}),children:Fo[a]},a))})]})}const qn={bulletList:{label:"Bullet List",icon:U.List},orderedList:{label:"Numbered List",icon:U.ListOrdered},taskList:{label:"Task List",icon:U.ListTodo}};function Ro({editor:e,types:t=["bulletList","orderedList","taskList"],isDisabled:n=!1}){const[,r]=y.useState(0);y.useEffect(()=>{const l=()=>r(c=>c+1);return e.on("selectionUpdate",l),e.on("transaction",l),()=>{e.off("selectionUpdate",l),e.off("transaction",l)}},[e]);const s=t.find(l=>e.isActive(l)),i=s?qn[s].icon:U.List,a=l=>{const d=We[l];d&&d.execute({editor:e})};return o.jsxs(h.Dropdown,{placement:"top-start",offset:10,children:[o.jsx(h.DropdownTrigger,{children:o.jsx(q,{size:"sm",radius:"sm",variant:s?"solid":"bordered",color:s?"primary":"default",isDisabled:n,isIconOnly:!0,"aria-label":"Select list type",children:o.jsx(i,{size:16})})}),o.jsx(h.DropdownMenu,{"aria-label":"List types",selectionMode:"single",selectedKeys:s?new Set([s]):new Set,onAction:a,children:t.map(l=>{const c=qn[l].icon;return o.jsx(h.DropdownItem,{startContent:o.jsx(c,{size:16}),children:qn[l].label},l)})})]})}function zo({colors:e,selectedColor:t,onColorSelect:n,columns:r=4}){return o.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:`repeat(${r}, minmax(0, 1fr))`},children:e.map(s=>{const i=t===s;return o.jsx("button",{type:"button",onClick:()=>n(s),className:`
|
|
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 Bo=["#000000","#374151","#6B7280","#EF4444","#F59E0B","#10B981","#3B82F6","#8B5CF6","#EC4899","#14B8A6","#F97316","#A855F7"],_o=["#FEF3C7","#DBEAFE","#D1FAE5","#FCE7F3","#E0E7FF","#FED7AA","#F3E8FF","#CCFBF1","#FEE2E2","#E5E7EB","#FAE8FF","#BFDBFE"];function Wn(e){return/^#([0-9A-F]{3}){1,2}$/i.test(e)}const we={min:50,max:200,step:10,default:100},Cs={lineHeight:24,toolbarHeight:60},Vo={bold:U.Bold,italic:U.Italic,strike:U.Strikethrough,underline:U.Underline,code:U.Code,textColor:U.Palette,highlight:U.Highlighter,link:U.Link2,paragraph:U.FileText,heading:U.Heading,bulletList:U.List,orderedList:U.ListOrdered,taskList:U.ListTodo,codeBlock:U.CodeSquare,blockquote:U.Quote,horizontalRule:U.Minus,clearMarks:U.Eraser,clearNodes:U.Eraser,undo:U.Undo2,redo:U.Redo2,hardBreak:U.CornerDownLeft,textAlign:U.AlignLeft},Ho={left:U.AlignLeft,center:U.AlignCenter,right:U.AlignRight,justify:U.AlignJustify};function vt(e){return Vo[e]}function Uo({value:e,onChange:t,onApply:n,placeholder:r="#000000"}){const[s,i]=y.useState(""),a=d=>{const u=d.target.value;t(u),s&&i("")},l=()=>{if(!e){i("Please enter a color");return}if(!Wn(e)){i("Invalid hex color (e.g., #FF0000)");return}i(""),n(e)},c=d=>{d.key==="Enter"&&(d.preventDefault(),l())};return o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex gap-2",children:[o.jsx(h.Input,{type:"text",value:e,onChange:a,onKeyDown:c,placeholder:r,size:"sm",variant:"bordered","aria-label":"Custom color hex code",isInvalid:!!s,errorMessage:s,startContent:o.jsx("div",{className:"w-4 h-4 rounded border border-divider",style:{backgroundColor:Wn(e)?e:"transparent"}})}),o.jsx(q,{size:"sm",color:"primary",variant:"flat",isIconOnly:!0,onPress:l,"aria-label":"Apply custom color",isDisabled:!e||!Wn(e),children:o.jsx(U.Check,{size:16})})]}),o.jsx("p",{className:"text-xs text-default-500",children:"Enter a hex color code (e.g., #FF0000)"})]})}function js({editor:e,type:t,allowCustomColor:n=!0,label:r,isDisabled:s=!1}){const[i,a]=y.useState(!1),[l,c]=y.useState(""),d=t==="textColor"?Bo:_o,u=b=>{const x=We[t];x&&x.execute({editor:e,config:{type:t,color:b}}),a(!1),c("")},f=b=>{u(b)},p=()=>{const b=We[t];b&&b.execute({editor:e,config:{type:t,color:""}}),a(!1)},m=t==="textColor"?e.isActive("textStyle"):e.isActive("highlight"),v=t==="textColor"?U.Palette:U.Highlighter;return o.jsxs(h.Popover,{isOpen:i,onOpenChange:a,placement:"top",offset:10,showArrow:!0,children:[o.jsx(h.PopoverTrigger,{children:o.jsx(q,{size:"sm",radius:"sm",variant:m?"solid":"bordered",color:m?"primary":"default",isIconOnly:!0,isDisabled:s,"aria-label":r,children:o.jsx(v,{size:16})})}),o.jsx(h.PopoverContent,{className:"w-64",children:o.jsxs("div",{className:"px-2 py-3 space-y-3",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-sm font-semibold",children:r}),o.jsx(q,{size:"sm",variant:"light",isIconOnly:!0,onPress:p,"aria-label":"Clear color",children:o.jsx(U.X,{size:16})})]}),o.jsx(zo,{colors:d,onColorSelect:u}),n&&o.jsxs(o.Fragment,{children:[o.jsx(h.Divider,{}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs font-semibold mb-2 text-default-700",children:"Custom Color"}),o.jsx(Uo,{value:l,onChange:c,onApply:f})]})]})]})})]})}function qo({zoom:e,onZoomChange:t,min:n=we.min,max:r=we.max,step:s=we.step}){const i=()=>{const f=Math.max(n,e-s);t(f)},a=()=>{const f=Math.min(r,e+s);t(f)},l=()=>{t(we.default)},c=e<=n,d=e>=r,u=e===we.default;return o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(h.Tooltip,{content:"Zoom out",placement:"top",offset:10,children:o.jsx(q,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:c,onPress:i,"aria-label":"Zoom out",children:o.jsx(U.ZoomOut,{size:16})})}),o.jsx(h.Tooltip,{content:u?"Zoom percentage":"Click to reset zoom",placement:"top",offset:10,children:o.jsxs("button",{type:"button",onClick:l,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 ${e}%`,children:[e,"%"]})}),o.jsx(h.Tooltip,{content:"Zoom in",placement:"top",offset:10,children:o.jsx(q,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:d,onPress:a,"aria-label":"Zoom in",children:o.jsx(U.ZoomIn,{size:16})})})]})}function Wo({editor:e,isDisabled:t=!1}){const[n,r]=y.useState(!1),[s,i]=y.useState(""),[a,l]=y.useState(""),[c,d]=y.useState(!1),u=e.isActive("link"),f=m=>{if(m){const{from:v,to:b}=e.state.selection,x=e.isActive("link");let w="";if(x){const A=e.schema.marks.link,S=e.state.doc.resolve(v),j=z.getMarkRange(S,A);j&&(w=e.state.doc.textBetween(j.from,j.to,""))}else w=e.state.doc.textBetween(v,b,"");const N=e.getAttributes("link").href||"";i(w),l(N),d(x)}r(m)},p=()=>{if(a.trim()){const{from:m,to:v}=e.state.selection,b=e.schema.marks.link,x=e.state.doc.resolve(m),w=z.getMarkRange(x,b),N=w?.from??m,A=w?.to??v,S=e.state.doc.textBetween(N,A,"");s.trim()&&s!==S?e.chain().focus().setTextSelection({from:N,to:A}).deleteSelection().insertContent(`<a href="${a.trim()}">${s.trim()}</a>`).run():e.chain().focus().extendMarkRange("link").updateAttributes("link",{href:a.trim()}).run()}r(!1)};return o.jsxs(h.Popover,{isOpen:n,onOpenChange:f,placement:"bottom",children:[o.jsx(h.PopoverTrigger,{children:o.jsx(q,{size:"sm",radius:"sm",variant:u?"solid":"bordered",color:u?"primary":"default",isIconOnly:!0,isDisabled:t,"aria-label":"Link",children:o.jsx(U.Link,{size:16})})}),o.jsx(h.PopoverContent,{children:o.jsxs("div",{className:"flex flex-col gap-3 p-3 w-72",children:[o.jsx(h.Input,{size:"sm",variant:"bordered",label:"Name",labelPlacement:"outside",placeholder:"Link text",value:s,onChange:m=>i(m.target.value),classNames:{inputWrapper:"focus-within:border-default-400"}}),o.jsx(h.Input,{size:"sm",variant:"bordered",label:"Link",labelPlacement:"outside",placeholder:"https://example.com",value:a,onChange:m=>l(m.target.value),onKeyDown:m=>m.key==="Enter"&&p(),classNames:{inputWrapper:"focus-within:border-default-400"}}),o.jsx(q,{size:"sm",color:"primary",onPress:p,isDisabled:!a.trim(),children:c?"Update":"Apply"})]})})]})}function Ko({children:e,id:t,label:n,className:r,useButtonGroup:s=!0}){return s?o.jsx(h.ButtonGroup,{size:"sm",id:t,"aria-label":n,className:r,children:e}):o.jsx("div",{id:t,role:"group","aria-label":n,className:`flex items-center gap-2 ${r||""}`,children:e})}function Hi(e,t){const n=y.useMemo(()=>{if(!e)return{};const i={};return Array.from(new Set(t.map(l=>Bt(l)))).forEach(l=>{const c=We[l];if(c)try{const d=c.canExecute?.(e)??!0,u=c.isActive?.(e)??!1;i[l]={isActive:u,isDisabled:!d,canExecute:d}}catch(d){console.warn(`Extension not available for modifier: ${l}`,d),i[l]={isActive:!1,isDisabled:!0,canExecute:!1}}}),i},[e,t]),[r,s]=y.useState(n);return y.useEffect(()=>{if(!e)return;const i=()=>{const a={};Array.from(new Set(t.map(c=>Bt(c)))).forEach(c=>{const d=We[c];if(d)try{const u=d.canExecute?.(e)??!0,f=d.isActive?.(e)??!1;a[c]={isActive:f,isDisabled:!u,canExecute:u}}catch(u){console.warn(`Extension not available for modifier: ${c}`,u),a[c]={isActive:!1,isDisabled:!0,canExecute:!1}}}),s(a)};return e.on("selectionUpdate",i),e.on("transaction",i),()=>{e.off("selectionUpdate",i),e.off("transaction",i)}},[e,t,n]),r}function Ui(e,t){const n=y.useCallback((a,l)=>{if(!e)return;const c=We[a];if(c)try{c.execute({editor:e,config:l}),t?.({type:"toggle",modifier:a})}catch(d){console.warn(`Failed to execute command for modifier: ${a}`,d)}},[e,t]),r=y.useCallback(a=>{n(a)},[n]),s=y.useCallback((a,l)=>{if(!e)return!1;const c=We[a];try{return c?.canExecute?.(e,l)??!1}catch(d){return console.warn(`Failed to check canExecute for modifier: ${a}`,d),!1}},[e]),i=y.useCallback((a,l)=>{if(!e)return!1;const c=We[a];try{return c?.isActive?.(e,l)??!1}catch(d){return console.warn(`Failed to check isActive for modifier: ${a}`,d),!1}},[e]);return{executeCommand:n,toggleModifier:r,canExecute:s,isActive:i}}function Jo(e=we.default){const[t,n]=y.useState(e),r=y.useCallback((l=we.step)=>{n(c=>Math.min(we.max,c+l))},[]),s=y.useCallback((l=we.step)=>{n(c=>Math.max(we.min,c-l))},[]),i=y.useCallback(()=>{n(we.default)},[]),a=y.useCallback(l=>{const c=Math.max(we.min,Math.min(we.max,l));n(c)},[]);return{zoom:t,setZoom:a,zoomIn:r,zoomOut:s,resetZoom:i,isMinZoom:t<=we.min,isMaxZoom:t>=we.max,isDefaultZoom:t===we.default}}const Yo=["bold","italic","strike","underline","code"];function Go({editor:e,modifiers:t,onToolbarAction:n}){const r=Hi(e,t),{toggleModifier:s}=Ui(e,n);if(!e)return null;const i=t.map(a=>Bt(a)).filter(a=>Yo.includes(a));return i.length===0?null:o.jsx(Ko,{id:"text-formatting",label:"Text formatting",children:i.map(a=>{const l=r[a],c=vt(a);return o.jsx(at,{icon:c,label:a.charAt(0).toUpperCase()+a.slice(1),isActive:l?.isActive,isDisabled:l?.isDisabled,onClick:()=>s(a)},a)})})}function Qo({editor:e,modifiers:t,zoom:n=100,onZoomChange:r,sticky:s=!0,className:i,onToolbarAction:a}){const l=Hi(e,t),{toggleModifier:c,executeCommand:d}=Ui(e,a);if(!e)return null;const u=t.map(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"),w=u.includes("codeBlock"),N=u.includes("link"),A=u.includes("horizontalRule"),S=u.some(D=>["undo","redo"].includes(D)),j=n!==void 0&&r!==void 0,M=s?"sticky top-0 z-10":"";return o.jsx("div",{className:`w-full p-2 bg-background border-b border-divider ${M} ${i||""}`,children:o.jsxs("div",{className:"flex flex-row flex-wrap gap-2 w-full items-center",children:[f&&o.jsxs(o.Fragment,{children:[o.jsx(Go,{editor:e,modifiers:t,onToolbarAction:a}),(p||m||v||b||x||w||N||A||S||j)&&o.jsx(it,{})]}),p&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-center gap-1",children:[u.includes("textColor")&&o.jsx(js,{editor:e,type:"textColor",label:"Text color",isDisabled:l.textColor?.isDisabled}),u.includes("highlight")&&o.jsx(js,{editor:e,type:"highlight",label:"Highlight",isDisabled:l.highlight?.isDisabled})]}),(m||v||b||x||w||N||A||S||j)&&o.jsx(it,{})]}),m&&o.jsxs(o.Fragment,{children:[o.jsx(Po,{editor:e}),(v||b||x||w||N||A||S||j)&&o.jsx(it,{})]}),v&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"flex items-center gap-1",children:["left","center","right","justify"].map(D=>{const B=Ho[D],F=e.isActive({textAlign:D});return o.jsx(at,{icon:B,label:`Align ${D}`,isActive:F,onClick:()=>d("textAlign",{type:"textAlign",alignment:D})},D)})}),(b||x||w||N||A||S||j)&&o.jsx(it,{})]}),b&&o.jsxs(o.Fragment,{children:[o.jsx(Ro,{editor:e,types:u.filter(D=>["bulletList","orderedList","taskList"].includes(D))}),(x||w||N||A||S||j)&&o.jsx(it,{})]}),(x||w||N||A)&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-center gap-1",children:[x&&o.jsx(at,{icon:vt("blockquote"),label:"Blockquote",isActive:l.blockquote?.isActive,isDisabled:l.blockquote?.isDisabled,onClick:()=>c("blockquote")}),w&&o.jsx(at,{icon:vt("codeBlock"),label:"Code block",isActive:l.codeBlock?.isActive,isDisabled:l.codeBlock?.isDisabled,onClick:()=>c("codeBlock")}),N&&o.jsx(Wo,{editor:e,isDisabled:l.link?.isDisabled}),A&&o.jsx(at,{icon:vt("horizontalRule"),label:"Horizontal rule",onClick:()=>c("horizontalRule")})]}),(S||j)&&o.jsx(it,{})]}),S&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-center gap-1",children:[u.includes("undo")&&o.jsx(at,{icon:vt("undo"),label:"Undo",isDisabled:l.undo?.isDisabled,onClick:()=>c("undo")}),u.includes("redo")&&o.jsx(at,{icon:vt("redo"),label:"Redo",isDisabled:l.redo?.isDisabled,onClick:()=>c("redo")})]}),j&&o.jsx(it,{})]}),j&&o.jsx(qo,{zoom:n,onZoomChange:D=>{r?.(D),a?.({type:"zoom",modifier:`${D}%`})}})]})})}const Zo=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Xo=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,ec=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,tc=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,nc=z.Mark.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:e=>e.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:e=>e.type.name===this.name},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return["strong",z.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[z.markInputRule({find:Zo,type:this.type}),z.markInputRule({find:ec,type:this.type})]},addPasteRules(){return[z.markPasteRule({find:Xo,type:this.type}),z.markPasteRule({find:tc,type:this.type})]}}),rc=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,sc=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,ic=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,ac=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,lc=z.Mark.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:e=>e.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:e=>e.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:e}){return["em",z.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[z.markInputRule({find:rc,type:this.type}),z.markInputRule({find:ic,type:this.type})]},addPasteRules(){return[z.markPasteRule({find:sc,type:this.type}),z.markPasteRule({find:ac,type:this.type})]}}),oc=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,cc=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,dc=z.Mark.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:e=>e.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["s",z.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[z.markInputRule({find:oc,type:this.type})]},addPasteRules(){return[z.markPasteRule({find:cc,type:this.type})]}}),uc=/(^|[^`])`([^`]+)`(?!`)/,fc=/(^|[^`])`([^`]+)`(?!`)/g,hc=z.Mark.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:e}){return["code",z.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[z.markInputRule({find:uc,type:this.type})]},addPasteRules(){return[z.markPasteRule({find:fc,type:this.type})]}}),mc=e=>{if(!e.children.length)return;const t=e.querySelectorAll("span");t&&t.forEach(n=>{var r,s;const i=n.getAttribute("style"),a=(s=(r=n.parentElement)===null||r===void 0?void 0:r.closest("span"))===null||s===void 0?void 0:s.getAttribute("style");n.setAttribute("style",`${a};${i}`)})},pc=z.Mark.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:e=>e.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&mc(e),{}):!1}]},renderHTML({HTMLAttributes:e}){return["span",z.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{removeEmptyTextStyle:()=>({tr:e})=>{const{selection:t}=e;return e.doc.nodesBetween(t.from,t.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(s=>s.type===this.type).some(s=>Object.values(s.attrs).some(i=>!!i))||e.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),gc=z.Node.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,z.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,"paragraph",e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>z.textblockTypeInputRule({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),xc=z.Node.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",z.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),yc="listItem",As="textStyle",Ms=/^\s*([-+*])\s$/,bc=z.Node.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:e}){return["ul",z.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(yc,this.editor.getAttributes(As)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=z.wrappingInputRule({find:Ms,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=z.wrappingInputRule({find:Ms,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(As),editor:this.editor})),[e]}}),vc="listItem",Es="textStyle",Ts=/^(\d+)\.\s$/,wc=z.Node.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:e=>e.hasAttribute("start")?parseInt(e.getAttribute("start")||"",10):1},type:{default:null,parseHTML:e=>e.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:e}){const{start:t,...n}=e;return t===1?["ol",z.mergeAttributes(this.options.HTMLAttributes,n),0]:["ol",z.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(vc,this.editor.getAttributes(Es)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=z.wrappingInputRule({find:Ts,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:(t,n)=>n.childCount+n.attrs.start===+t[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=z.wrappingInputRule({find:Ts,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(Es)}),joinPredicate:(t,n)=>n.childCount+n.attrs.start===+t[1],editor:this.editor})),[e]}}),kc=z.Node.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:e}){return["li",z.mergeAttributes(this.options.HTMLAttributes,e),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}});function qi(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let s=e.child(r),i=t.child(r);if(s==i){n+=s.nodeSize;continue}if(!s.sameMarkup(i))return n;if(s.isText&&s.text!=i.text){for(let a=0;s.text[a]==i.text[a];a++)n++;return n}if(s.content.size||i.content.size){let a=qi(s.content,i.content,n+1);if(a!=null)return a}n+=s.nodeSize}}function Wi(e,t,n,r){for(let s=e.childCount,i=t.childCount;;){if(s==0||i==0)return s==i?null:{a:n,b:r};let a=e.child(--s),l=t.child(--i),c=a.nodeSize;if(a==l){n-=c,r-=c;continue}if(!a.sameMarkup(l))return{a:n,b:r};if(a.isText&&a.text!=l.text){let d=0,u=Math.min(a.text.length,l.text.length);for(;d<u&&a.text[a.text.length-d-1]==l.text[l.text.length-d-1];)d++,n--,r--;return{a:n,b:r}}if(a.content.size||l.content.size){let d=Wi(a.content,l.content,n-1,r-1);if(d)return d}n-=c,r-=c}}class G{constructor(t,n){if(this.content=t,this.size=n||0,n==null)for(let r=0;r<t.length;r++)this.size+=t[r].nodeSize}nodesBetween(t,n,r,s=0,i){for(let a=0,l=0;l<n;a++){let c=this.content[a],d=l+c.nodeSize;if(d>t&&r(c,s+l,i||null,a)!==!1&&c.content.size){let u=l+1;c.nodesBetween(Math.max(0,t-u),Math.min(c.content.size,n-u),r,s+u)}l=d}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,n,r,s){let i="",a=!0;return this.nodesBetween(t,n,(l,c)=>{let d=l.isText?l.text.slice(Math.max(t,c)-c,n-c):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&d||l.isTextblock)&&r&&(a?a=!1:i+=r),i+=d},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,s=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),i=1);i<t.content.length;i++)s.push(t.content[i]);return new G(s,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],s=0;if(n>t)for(let i=0,a=0;a<n;i++){let l=this.content[i],c=a+l.nodeSize;c>t&&((a<t||c>n)&&(l.isText?l=l.cut(Math.max(0,t-a),Math.min(l.text.length,n-a)):l=l.cut(Math.max(0,t-a-1),Math.min(l.content.size,n-a-1))),r.push(l),s+=l.nodeSize),a=c}return new G(r,s)}cutByIndex(t,n){return t==n?G.empty:t==0&&n==this.content.length?this:new G(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let s=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return s[t]=n,new G(s,i)}addToStart(t){return new G([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new G(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(t.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let n=this.content[t];if(!n)throw new RangeError("Index "+t+" out of range for "+this);return n}maybeChild(t){return this.content[t]||null}forEach(t){for(let n=0,r=0;n<this.content.length;n++){let s=this.content[n];t(s,r,n),r+=s.nodeSize}}findDiffStart(t,n=0){return qi(this,t,n)}findDiffEnd(t,n=this.size,r=t.size){return Wi(this,t,n,r)}findIndex(t){if(t==0)return Zt(0,t);if(t==this.size)return Zt(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let n=0,r=0;;n++){let s=this.child(n),i=r+s.nodeSize;if(i>=t)return i==t?Zt(n+1,i):Zt(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(t=>t.toJSON()):null}static fromJSON(t,n){if(!n)return G.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new G(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return G.empty;let n,r=0;for(let s=0;s<t.length;s++){let i=t[s];r+=i.nodeSize,s&&i.isText&&t[s-1].sameMarkup(i)?(n||(n=t.slice(0,s)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new G(n||t,r)}static from(t){if(!t)return G.empty;if(t instanceof G)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new G([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}G.empty=new G([],0);const Kn={index:0,offset:0};function Zt(e,t){return Kn.index=e,Kn.offset=t,Kn}function gr(e,t){if(e===t)return!0;if(!(e&&typeof e=="object")||!(t&&typeof t=="object"))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!gr(e[r],t[r]))return!1}else{for(let r in e)if(!(r in t)||!gr(e[r],t[r]))return!1;for(let r in t)if(!(r in e))return!1}return!0}class Oe{constructor(t,n){this.type=t,this.attrs=n}addToSet(t){let n,r=!1;for(let s=0;s<t.length;s++){let i=t[s];if(this.eq(i))return t;if(this.type.excludes(i.type))n||(n=t.slice(0,s));else{if(i.type.excludes(this.type))return t;!r&&i.type.rank>this.type.rank&&(n||(n=t.slice(0,s)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=t.slice()),r||n.push(this),n}removeFromSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return t.slice(0,n).concat(t.slice(n+1));return t}isInSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return!0;return!1}eq(t){return this==t||this.type==t.type&&gr(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=t.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let s=r.create(n.attrs);return r.checkAttrs(s.attrs),s}static sameSet(t,n){if(t==n)return!0;if(t.length!=n.length)return!1;for(let r=0;r<t.length;r++)if(!t[r].eq(n[r]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return Oe.none;if(t instanceof Oe)return[t];let n=t.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}}Oe.none=[];class Nc extends Error{}class Q{constructor(t,n,r){this.content=t,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=Ji(this.content,t+this.openStart,n);return r&&new Q(r,this.openStart,this.openEnd)}removeBetween(t,n){return new Q(Ki(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,n){if(!n)return Q.empty;let r=n.openStart||0,s=n.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Q(G.fromJSON(t,n.content),r,s)}static maxOpen(t,n=!0){let r=0,s=0;for(let i=t.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=t.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)s++;return new Q(t,r,s)}}Q.empty=new Q(G.empty,0,0);function Ki(e,t,n){let{index:r,offset:s}=e.findIndex(t),i=e.maybeChild(r),{index:a,offset:l}=e.findIndex(n);if(s==t||i.isText){if(l!=n&&!e.child(a).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(r!=a)throw new RangeError("Removing non-flat range");return e.replaceChild(r,i.copy(Ki(i.content,t-s-1,n-s-1)))}function Ji(e,t,n,r){let{index:s,offset:i}=e.findIndex(t),a=e.maybeChild(s);if(i==t||a.isText)return r&&!r.canReplace(s,s,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=Ji(a.content,t-i-1,n,a);return l&&e.replaceChild(s,a.copy(l))}function Sc(e){return e.tag!=null}function Cc(e){return e.style!=null}class fn{constructor(t,n){this.schema=t,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(Sc(s))this.tags.push(s);else if(Cc(s)){let i=/[^=]*/.exec(s.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=t.nodes[s.node];return i.contentMatch.matchType(i)})}parse(t,n={}){let r=new Is(this,n,!1);return r.addAll(t,Oe.none,n.from,n.to),r.finish()}parseSlice(t,n={}){let r=new Is(this,n,!0);return r.addAll(t,Oe.none,n.from,n.to),Q.maxOpen(r.finish())}matchTag(t,n,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(Mc(t,i.tag)&&(i.namespace===void 0||t.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let a=i.getAttrs(t);if(a===!1)continue;i.attrs=a||void 0}return i}}}matchStyle(t,n,r,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let a=this.styles[i],l=a.style;if(!(l.indexOf(t)!=0||a.context&&!r.matchesContext(a.context)||l.length>t.length&&(l.charCodeAt(t.length)!=61||l.slice(t.length+1)!=n))){if(a.getAttrs){let c=a.getAttrs(n);if(c===!1)continue;a.attrs=c||void 0}return a}}}static schemaRules(t){let n=[];function r(s){let i=s.priority==null?50:s.priority,a=0;for(;a<n.length;a++){let l=n[a];if((l.priority==null?50:l.priority)<i)break}n.splice(a,0,s)}for(let s in t.marks){let i=t.marks[s].spec.parseDOM;i&&i.forEach(a=>{r(a=$s(a)),a.mark||a.ignore||a.clearMark||(a.mark=s)})}for(let s in t.nodes){let i=t.nodes[s].spec.parseDOM;i&&i.forEach(a=>{r(a=$s(a)),a.node||a.ignore||a.mark||(a.node=s)})}return n}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new fn(t,fn.schemaRules(t)))}}const Yi={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},jc={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Gi={ol:!0,ul:!0},_t=1,xr=2,Ot=4;function Ds(e,t,n){return t!=null?(t?_t:0)|(t==="full"?xr:0):e&&e.whitespace=="pre"?_t|xr:n&~Ot}class Xt{constructor(t,n,r,s,i,a){this.type=t,this.attrs=n,this.marks=r,this.solid=s,this.options=a,this.content=[],this.activeMarks=Oe.none,this.match=i||(a&Ot?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(G.from(t));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(t.type))?(this.match=r,s):null}}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&_t)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let n=G.from(this.content);return!t&&this.match&&(n=n.append(this.match.fillBefore(G.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!Yi.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class Is{constructor(t,n,r){this.parser=t,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=n.topNode,i,a=Ds(null,n.preserveWhitespace,0)|(r?Ot:0);s?i=new Xt(s.type,s.attrs,Oe.none,!0,n.topMatch||s.type.contentMatch,a):r?i=new Xt(null,null,Oe.none,!0,null,a):i=new Xt(t.schema.topNodeType,null,Oe.none,!0,null,a),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t,n){t.nodeType==3?this.addTextNode(t,n):t.nodeType==1&&this.addElement(t,n)}addTextNode(t,n){let r=t.nodeValue,s=this.top,i=s.options&xr?"full":this.localPreserveWS||(s.options&_t)>0,{schema:a}=this.parser;if(i==="full"||s.inlineContext(t)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
|
|
11
|
+
`);else if(a.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(a.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let c=0;c<l.length;c++)c&&this.insertNode(a.linebreakReplacement.create(),n,!0),l[c]&&this.insertNode(a.text(l[c]),n,!/\S/.test(l[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 l=s.content[s.content.length-1],c=t.previousSibling;(!l||c&&c.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(a.text(r),n,!/\S/.test(r)),this.findInText(t)}else this.findInside(t)}addElement(t,n,r){let s=this.localPreserveWS,i=this.top;(t.tagName=="PRE"||/pre/.test(t.style&&t.style.whiteSpace))&&(this.localPreserveWS=!0);let a=t.nodeName.toLowerCase(),l;Gi.hasOwnProperty(a)&&this.parser.normalizeLists&&Ac(t);let c=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(l=this.parser.matchTag(t,this,r));e:if(c?c.ignore:jc.hasOwnProperty(a))this.findInside(t),this.ignoreFallback(t,n);else if(!c||c.skip||c.closeParent){c&&c.closeParent?this.open=Math.max(0,this.open-1):c&&c.skip.nodeType&&(t=c.skip);let d,u=this.needsBlock;if(Yi.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),d=!0,i.type||(this.needsBlock=!0);else if(!t.firstChild){this.leafFallback(t,n);break e}let f=c&&c.skip?n:this.readStyles(t,n);f&&this.addAll(t,f),d&&this.sync(i),this.needsBlock=u}else{let d=this.readStyles(t,n);d&&this.addElementByRule(t,c,d,c.consuming===!1?l:void 0)}this.localPreserveWS=s}leafFallback(t,n){t.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode(`
|
|
12
|
+
`),n)}ignoreFallback(t,n){t.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(t,n){let r=t.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],a=r.getPropertyValue(i);if(a)for(let l=void 0;;){let c=this.parser.matchStyle(i,a,this,l);if(!c)break;if(c.ignore)return null;if(c.clearMark?n=n.filter(d=>!c.clearMark(d)):n=n.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)l=c;else break}}return n}addElementByRule(t,n,r,s){let i,a;if(n.node)if(a=this.parser.schema.nodes[n.node],a.isLeaf)this.insertNode(a.create(n.attrs),r,t.nodeName=="BR")||this.leafFallback(t,r);else{let c=this.enter(a,n.attrs||null,r,n.preserveWhitespace);c&&(i=!0,r=c)}else{let c=this.parser.schema.marks[n.mark];r=r.concat(c.create(n.attrs))}let l=this.top;if(a&&a.isLeaf)this.findInside(t);else if(s)this.addElement(t,r,s);else if(n.getContent)this.findInside(t),n.getContent(t,this.parser.schema).forEach(c=>this.insertNode(c,r,!1));else{let c=t;typeof n.contentElement=="string"?c=t.querySelector(n.contentElement):typeof n.contentElement=="function"?c=n.contentElement(t):n.contentElement&&(c=n.contentElement),this.findAround(t,c,!0),this.addAll(c,r),this.findAround(t,c,!1)}i&&this.sync(l)&&this.open--}addAll(t,n,r,s){let i=r||0;for(let a=r?t.childNodes[r]:t.firstChild,l=s==null?null:t.childNodes[s];a!=l;a=a.nextSibling,++i)this.findAtPoint(t,i),this.addDOM(a,n);this.findAtPoint(t,i)}findPlace(t,n,r){let s,i;for(let a=this.open,l=0;a>=0;a--){let c=this.nodes[a],d=c.findWrapping(t);if(d&&(!s||s.length>d.length+l)&&(s=d,i=c,!d.length))break;if(c.solid){if(r)break;l+=2}}if(!s)return null;this.sync(i);for(let a=0;a<s.length;a++)n=this.enterInner(s[a],null,n,!1);return n}insertNode(t,n,r){if(t.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let s=this.findPlace(t,n,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(t.type));let a=Oe.none;for(let l of s.concat(t.marks))(i.type?i.type.allowsMarkType(l.type):Os(l.type,t.type))&&(a=l.addToSet(a));return i.content.push(t.mark(a)),!0}return!1}enter(t,n,r,s){let i=this.findPlace(t.create(n),r,!1);return i&&(i=this.enterInner(t,n,r,!0,s)),i}enterInner(t,n,r,s=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(t);let l=Ds(t,i,a.options);a.options&Ot&&a.content.length==0&&(l|=Ot);let c=Oe.none;return r=r.filter(d=>(a.type?a.type.allowsMarkType(d.type):Os(d.type,t))?(c=d.addToSet(c),!1):!0),this.nodes.push(new Xt(t,n,c,s,null,l)),this.open++,r}closeExtra(t=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(t));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(t){for(let n=this.open;n>=0;n--){if(this.nodes[n]==t)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=_t)}return!1}get currentPos(){this.closeExtra();let t=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let s=r.length-1;s>=0;s--)t+=r[s].nodeSize;n&&t++}return t}findAtPoint(t,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==t&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&t.nodeType==1&&t.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(t,n,r){if(t!=n&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&t.nodeType==1&&t.contains(this.find[s].node)&&n.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==t&&(this.find[n].pos=this.currentPos-(t.nodeValue.length-this.find[n].offset))}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let n=t.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(s?0:1),a=(l,c)=>{for(;l>=0;l--){let d=n[l];if(d==""){if(l==n.length-1||l==0)continue;for(;c>=i;c--)if(a(l-1,c))return!0;return!1}else{let u=c>0||c==0&&s?this.nodes[c].type:r&&c>=i?r.node(c-i).type:null;if(!u||u.name!=d&&!u.isInGroup(d))return!1;c--}}return!0};return a(n.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function Ac(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let r=t.nodeType==1?t.nodeName.toLowerCase():null;r&&Gi.hasOwnProperty(r)&&n?(n.appendChild(t),t=n):r=="li"?n=t:r&&(n=null)}}function Mc(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function $s(e){let t={};for(let n in e)t[n]=e[n];return t}function Os(e,t){let n=t.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(e))continue;let i=[],a=l=>{i.push(l);for(let c=0;c<l.edgeCount;c++){let{type:d,next:u}=l.edge(c);if(d==t||i.indexOf(u)<0&&a(u))return!0}};if(a(s.contentMatch))return!0}}class Tn{constructor(t,n){this.nodes=t,this.marks=n}serializeFragment(t,n={},r){r||(r=Jn(n).createDocumentFragment());let s=r,i=[];return t.forEach(a=>{if(i.length||a.marks.length){let l=0,c=0;for(;l<i.length&&c<a.marks.length;){let d=a.marks[c];if(!this.marks[d.type.name]){c++;continue}if(!d.eq(i[l][0])||d.type.spec.spanning===!1)break;l++,c++}for(;l<i.length;)s=i.pop()[1];for(;c<a.marks.length;){let d=a.marks[c++],u=this.serializeMark(d,a.isInline,n);u&&(i.push([d,s]),s.appendChild(u.dom),s=u.contentDOM||u.dom)}}s.appendChild(this.serializeNodeInner(a,n))}),r}serializeNodeInner(t,n){let{dom:r,contentDOM:s}=an(Jn(n),this.nodes[t.type.name](t),null,t.attrs);if(s){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,n,s)}return r}serializeNode(t,n={}){let r=this.serializeNodeInner(t,n);for(let s=t.marks.length-1;s>=0;s--){let i=this.serializeMark(t.marks[s],t.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(t,n,r={}){let s=this.marks[t.type.name];return s&&an(Jn(r),s(t,n),null,t.attrs)}static renderSpec(t,n,r=null,s){return an(t,n,r,s)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new Tn(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let n=Ls(t.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(t){return Ls(t.marks)}}function Ls(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function Jn(e){return e.document||window.document}const Fs=new WeakMap;function Ec(e){let t=Fs.get(e);return t===void 0&&Fs.set(e,t=Tc(e)),t}function Tc(e){let t=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")t||(t=[]),t.push(r);else for(let s=0;s<r.length;s++)n(r[s]);else for(let s in r)n(r[s])}return n(e),t}function an(e,t,n,r){if(typeof t=="string")return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let s=t[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=Ec(r))&&i.indexOf(t)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let a=s.indexOf(" ");a>0&&(n=s.slice(0,a),s=s.slice(a+1));let l,c=n?e.createElementNS(n,s):e.createElement(s),d=t[1],u=1;if(d&&typeof d=="object"&&d.nodeType==null&&!Array.isArray(d)){u=2;for(let f in d)if(d[f]!=null){let p=f.indexOf(" ");p>0?c.setAttributeNS(f.slice(0,p),f.slice(p+1),d[f]):f=="style"&&c.style?c.style.cssText=d[f]:c.setAttribute(f,d[f])}}for(let f=u;f<t.length;f++){let p=t[f];if(p===0){if(f<t.length-1||f>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else{let{dom:m,contentDOM:v}=an(e,p,n,r);if(c.appendChild(m),v){if(l)throw new RangeError("Multiple content holes");l=v}}}return{dom:c,contentDOM:l}}const Qi=65535,Zi=Math.pow(2,16);function Dc(e,t){return e+t*Zi}function Ps(e){return e&Qi}function Ic(e){return(e-(e&Qi))/Zi}const Xi=1,ea=2,ln=4,ta=8;class yr{constructor(t,n,r){this.pos=t,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&ta)>0}get deletedBefore(){return(this.delInfo&(Xi|ln))>0}get deletedAfter(){return(this.delInfo&(ea|ln))>0}get deletedAcross(){return(this.delInfo&ln)>0}}class Te{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&Te.empty)return Te.empty}recover(t){let n=0,r=Ps(t);if(!this.inverted)for(let s=0;s<r;s++)n+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+n+Ic(t)}mapResult(t,n=1){return this._map(t,n,!1)}map(t,n=1){return this._map(t,n,!0)}_map(t,n,r){let s=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?s:0);if(c>t)break;let d=this.ranges[l+i],u=this.ranges[l+a],f=c+d;if(t<=f){let p=d?t==c?-1:t==f?1:n:n,m=c+s+(p<0?0:u);if(r)return m;let v=t==(n<0?c:f)?null:Dc(l/3,t-c),b=t==c?ea:t==f?Xi:ln;return(n<0?t!=c:t!=f)&&(b|=ta),new yr(m,b,v)}s+=u-d}return r?t+s:new yr(t+s,0,null)}touches(t,n){let r=0,s=Ps(n),i=this.inverted?2:1,a=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?r:0);if(c>t)break;let d=this.ranges[l+i],u=c+d;if(t<=u&&l==s*3)return!0;r+=this.ranges[l+a]-d}return!1}forEach(t){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let a=this.ranges[s],l=a-(this.inverted?i:0),c=a+(this.inverted?0:i),d=this.ranges[s+n],u=this.ranges[s+r];t(l,l+d,c,c+u),i+=u-d}}invert(){return new Te(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return t==0?Te.empty:new Te(t<0?[0,-t,0]:[0,0,t])}}Te.empty=new Te([]);class hn{constructor(t,n,r=0,s=t?t.length:0){this.mirror=n,this.from=r,this.to=s,this._maps=t||[],this.ownData=!(t||n)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new hn(this._maps,this.mirror,t,n)}appendMap(t,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(t),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(t){for(let n=0,r=this._maps.length;n<t._maps.length;n++){let s=t.getMirror(n);this.appendMap(t._maps[n],s!=null&&s<n?r+s:void 0)}}getMirror(t){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==t)return this.mirror[n+(n%2?-1:1)]}}setMirror(t,n){this.mirror||(this.mirror=[]),this.mirror.push(t,n)}appendMappingInverted(t){for(let n=t.maps.length-1,r=this._maps.length+t._maps.length;n>=0;n--){let s=t.getMirror(n);this.appendMap(t._maps[n].invert(),s!=null&&s>n?r-s-1:void 0)}}invert(){let t=new hn;return t.appendMappingInverted(this),t}map(t,n=1){if(this.mirror)return this._map(t,n,!0);for(let r=this.from;r<this.to;r++)t=this._maps[r].map(t,n);return t}mapResult(t,n=1){return this._map(t,n,!1)}_map(t,n,r){let s=0;for(let i=this.from;i<this.to;i++){let a=this._maps[i],l=a.mapResult(t,n);if(l.recover!=null){let c=this.getMirror(i);if(c!=null&&c>i&&c<this.to){i=c,t=this._maps[c].recover(l.recover);continue}}s|=l.delInfo,t=l.pos}return r?t:new yr(t,s,null)}}const Yn=Object.create(null);class ke{getMap(){return Te.empty}merge(t){return null}static fromJSON(t,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Yn[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(t,n)}static jsonID(t,n){if(t in Yn)throw new RangeError("Duplicate use of step JSON ID "+t);return Yn[t]=n,n.prototype.jsonID=t,n}}class ge{constructor(t,n){this.doc=t,this.failed=n}static ok(t){return new ge(t,null)}static fail(t){return new ge(null,t)}static fromReplace(t,n,r,s){try{return ge.ok(t.replace(n,r,s))}catch(i){if(i instanceof Nc)return ge.fail(i.message);throw i}}}function _r(e,t,n){let r=[];for(let s=0;s<e.childCount;s++){let i=e.child(s);i.content.size&&(i=i.copy(_r(i.content,t,i))),i.isInline&&(i=t(i,n,s)),r.push(i)}return G.fromArray(r)}class ot extends ke{constructor(t,n,r){super(),this.from=t,this.to=n,this.mark=r}apply(t){let n=t.slice(this.from,this.to),r=t.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new Q(_r(n.content,(a,l)=>!a.isAtom||!l.type.allowsMarkType(this.mark.type)?a:a.mark(this.mark.addToSet(a.marks)),s),n.openStart,n.openEnd);return ge.fromReplace(t,this.from,this.to,i)}invert(){return new ct(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new ot(n.pos,r.pos,this.mark)}merge(t){return t instanceof ot&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new ot(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new ot(n.from,n.to,t.markFromJSON(n.mark))}}ke.jsonID("addMark",ot);class ct extends ke{constructor(t,n,r){super(),this.from=t,this.to=n,this.mark=r}apply(t){let n=t.slice(this.from,this.to),r=new Q(_r(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),t),n.openStart,n.openEnd);return ge.fromReplace(t,this.from,this.to,r)}invert(){return new ot(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new ct(n.pos,r.pos,this.mark)}merge(t){return t instanceof ct&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new ct(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new ct(n.from,n.to,t.markFromJSON(n.mark))}}ke.jsonID("removeMark",ct);class dt extends ke{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return ge.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ge.fromReplace(t,this.pos,this.pos+1,new Q(G.from(r),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let s=0;s<n.marks.length;s++)if(!n.marks[s].isInSet(r))return new dt(this.pos,n.marks[s]);return new dt(this.pos,this.mark)}}return new Vt(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new dt(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new dt(n.pos,t.markFromJSON(n.mark))}}ke.jsonID("addNodeMark",dt);class Vt extends ke{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return ge.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return ge.fromReplace(t,this.pos,this.pos+1,new Q(G.from(r),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new dt(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new Vt(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Vt(n.pos,t.markFromJSON(n.mark))}}ke.jsonID("removeNodeMark",Vt);class qe extends ke{constructor(t,n,r,s=!1){super(),this.from=t,this.to=n,this.slice=r,this.structure=s}apply(t){return this.structure&&br(t,this.from,this.to)?ge.fail("Structure replace would overwrite content"):ge.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new Te([this.from,this.to-this.from,this.slice.size])}invert(t){return new qe(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new qe(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(t){if(!(t instanceof qe)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?Q.empty:new Q(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new qe(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?Q.empty:new Q(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new qe(t.from,this.to,n,this.structure)}else return null}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new qe(n.from,n.to,Q.fromJSON(t,n.slice),!!n.structure)}}ke.jsonID("replace",qe);class St extends ke{constructor(t,n,r,s,i,a,l=!1){super(),this.from=t,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=a,this.structure=l}apply(t){if(this.structure&&(br(t,this.from,this.gapFrom)||br(t,this.gapTo,this.to)))return ge.fail("Structure gap-replace would overwrite content");let n=t.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return ge.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?ge.fromReplace(t,this.from,this.to,r):ge.fail("Content does not fit in gap")}getMap(){return new Te([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new St(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||i>r.pos?null:new St(n.pos,r.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new St(n.from,n.to,n.gapFrom,n.gapTo,Q.fromJSON(t,n.slice),n.insert,!!n.structure)}}ke.jsonID("replaceAround",St);function br(e,t,n){let r=e.resolve(t),s=n-t,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let a=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!a||a.isLeaf)return!0;a=a.firstChild,s--}}return!1}function na(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let s=n.content;for(let i=0;i<n.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.size?2:1);i++)for(let a=r.depth;a>=0;a--){let l=a==r.depth?0:r.pos<=(r.start(a+1)+r.end(a+1))/2?-1:1,c=r.index(a)+(l>0?1:0),d=r.node(a),u=!1;if(i==1)u=d.canReplace(c,c,s);else{let f=d.contentMatchAt(c).findWrapping(s.firstChild.type);u=f&&d.canReplaceWith(c,c,f[0])}if(u)return l==0?r.pos:l<0?r.before(a+1):r.after(a+1)}return null}class Lt extends ke{constructor(t,n,r){super(),this.pos=t,this.attr=n,this.value=r}apply(t){let n=t.nodeAt(this.pos);if(!n)return ge.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return ge.fromReplace(t,this.pos,this.pos+1,new Q(G.from(s),0,n.isLeaf?0:1))}getMap(){return Te.empty}invert(t){return new Lt(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new Lt(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Lt(n.pos,n.attr,n.value)}}ke.jsonID("attr",Lt);class mn extends ke{constructor(t,n){super(),this.attr=t,this.value=n}apply(t){let n=Object.create(null);for(let s in t.attrs)n[s]=t.attrs[s];n[this.attr]=this.value;let r=t.type.create(n,t.content,t.marks);return ge.ok(r)}getMap(){return Te.empty}invert(t){return new mn(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new mn(n.attr,n.value)}}ke.jsonID("docAttr",mn);let Ht=class extends Error{};Ht=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n};Ht.prototype=Object.create(Error.prototype);Ht.prototype.constructor=Ht;Ht.prototype.name="TransformError";const Gn=Object.create(null);class re{constructor(t,n,r){this.$anchor=t,this.$head=n,this.ranges=r||[new $c(t.min(n),t.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let t=this.ranges;for(let n=0;n<t.length;n++)if(t[n].$from.pos!=t[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,n=Q.empty){let r=n.content.lastChild,s=null;for(let l=0;l<n.openEnd;l++)s=r,r=r.lastChild;let i=t.steps.length,a=this.ranges;for(let l=0;l<a.length;l++){let{$from:c,$to:d}=a[l],u=t.mapping.slice(i);t.replaceRange(u.map(c.pos),u.map(d.pos),l?Q.empty:n),l==0&&Bs(t,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(t,n){let r=t.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:a,$to:l}=s[i],c=t.mapping.slice(r),d=c.map(a.pos),u=c.map(l.pos);i?t.deleteRange(d,u):(t.replaceRangeWith(d,u,n),Bs(t,r,n.isInline?-1:1))}}static findFrom(t,n,r=!1){let s=t.parent.inlineContent?new ne(t):wt(t.node(0),t.parent,t.pos,t.index(),n,r);if(s)return s;for(let i=t.depth-1;i>=0;i--){let a=n<0?wt(t.node(0),t.node(i),t.before(i+1),t.index(i),n,r):wt(t.node(0),t.node(i),t.after(i+1),t.index(i)+1,n,r);if(a)return a}return null}static near(t,n=1){return this.findFrom(t,n)||this.findFrom(t,-n)||new Ve(t.node(0))}static atStart(t){return wt(t,t,0,0,1)||new Ve(t)}static atEnd(t){return wt(t,t,t.content.size,t.childCount,-1)||new Ve(t)}static fromJSON(t,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Gn[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(t,n)}static jsonID(t,n){if(t in Gn)throw new RangeError("Duplicate use of selection JSON ID "+t);return Gn[t]=n,n.prototype.jsonID=t,n}getBookmark(){return ne.between(this.$anchor,this.$head).getBookmark()}}re.prototype.visible=!0;class $c{constructor(t,n){this.$from=t,this.$to=n}}let Rs=!1;function zs(e){!Rs&&!e.parent.inlineContent&&(Rs=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class ne extends re{constructor(t,n=t){zs(t),zs(n),super(t,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return re.near(r);let s=t.resolve(n.map(this.anchor));return new ne(s.parent.inlineContent?s:r,r)}replace(t,n=Q.empty){if(super.replace(t,n),n==Q.empty){let r=this.$from.marksAcross(this.$to);r&&t.ensureMarks(r)}}eq(t){return t instanceof ne&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new Dn(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new ne(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){let s=t.resolve(n);return new this(s,r==n?s:t.resolve(r))}static between(t,n,r){let s=t.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let i=re.findFrom(n,r,!0)||re.findFrom(n,-r,!0);if(i)n=i.$head;else return re.near(n,r)}return t.parent.inlineContent||(s==0?t=n:(t=(re.findFrom(t,-r,!0)||re.findFrom(t,r,!0)).$anchor,t.pos<n.pos!=s<0&&(t=n))),new ne(t,n)}}re.jsonID("text",ne);class Dn{constructor(t,n){this.anchor=t,this.head=n}map(t){return new Dn(t.map(this.anchor),t.map(this.head))}resolve(t){return ne.between(t.resolve(this.anchor),t.resolve(this.head))}}class X extends re{constructor(t){let n=t.nodeAfter,r=t.node(0).resolve(t.pos+n.nodeSize);super(t,r),this.node=n}map(t,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),i=t.resolve(s);return r?re.near(i):new X(i)}content(){return new Q(G.from(this.node),0,0)}eq(t){return t instanceof X&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Vr(this.anchor)}static fromJSON(t,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new X(t.resolve(n.anchor))}static create(t,n){return new X(t.resolve(n))}static isSelectable(t){return!t.isText&&t.type.spec.selectable!==!1}}X.prototype.visible=!1;re.jsonID("node",X);class Vr{constructor(t){this.anchor=t}map(t){let{deleted:n,pos:r}=t.mapResult(this.anchor);return n?new Dn(r,r):new Vr(r)}resolve(t){let n=t.resolve(this.anchor),r=n.nodeAfter;return r&&X.isSelectable(r)?new X(n):re.near(n)}}class Ve extends re{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,n=Q.empty){if(n==Q.empty){t.delete(0,t.doc.content.size);let r=re.atStart(t.doc);r.eq(t.selection)||t.setSelection(r)}else super.replace(t,n)}toJSON(){return{type:"all"}}static fromJSON(t){return new Ve(t)}map(t){return new Ve(t)}eq(t){return t instanceof Ve}getBookmark(){return Oc}}re.jsonID("all",Ve);const Oc={map(){return this},resolve(e){return new Ve(e)}};function wt(e,t,n,r,s,i=!1){if(t.inlineContent)return ne.create(e,n);for(let a=r-(s>0?0:1);s>0?a<t.childCount:a>=0;a+=s){let l=t.child(a);if(l.isAtom){if(!i&&X.isSelectable(l))return X.create(e,n-(s<0?l.nodeSize:0))}else{let c=wt(e,l,n+s,s<0?l.childCount:0,s,i);if(c)return c}n+=l.nodeSize*s}return null}function Bs(e,t,n){let r=e.steps.length-1;if(r<t)return;let s=e.steps[r];if(!(s instanceof qe||s instanceof St))return;let i=e.mapping.maps[r],a;i.forEach((l,c,d,u)=>{a==null&&(a=u)}),e.setSelection(re.near(e.doc.resolve(a),n))}function _s(e,t){return!t||!e?e:e.bind(t)}class en{constructor(t,n,r){this.name=t,this.init=_s(n.init,r),this.apply=_s(n.apply,r)}}new en("doc",{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new en("selection",{init(e,t){return e.selection||re.atStart(t.doc)},apply(e){return e.selection}}),new en("storedMarks",{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new en("scrollToSelection",{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}});function ra(e,t,n){for(let r in e){let s=e[r];s instanceof Function?s=s.bind(t):r=="handleDOMEvents"&&(s=ra(s,t,{})),n[r]=s}return n}class In{constructor(t){this.spec=t,this.props={},t.props&&ra(t.props,this,this.props),this.key=t.key?t.key.key:sa("plugin")}getState(t){return t[this.key]}}const Qn=Object.create(null);function sa(e){return e in Qn?e+"$"+ ++Qn[e]:(Qn[e]=0,e+"$")}class Hr{constructor(t="key"){this.key=sa(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const Lc=/^```([a-z]+)?[\s\n]$/,Fc=/^~~~([a-z]+)?[\s\n]$/,Pc=z.Node.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{var t;const{languageClassPrefix:n}=this.options,i=[...((t=e.firstElementChild)===null||t===void 0?void 0:t.classList)||[]].filter(a=>a.startsWith(n)).map(a=>a.replace(n,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:e,HTMLAttributes:t}){return["pre",z.mergeAttributes(this.options.HTMLAttributes,t),["code",{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:e,$anchor:t}=this.editor.state.selection,n=t.pos===1;return!e||t.parent.type.name!==this.name?!1:n||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:t}=e,{selection:n}=t,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,a=r.parent.textContent.endsWith(`
|
|
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:e.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;const{state:t}=e,{selection:n,doc:r}=t,{$from:s,empty:i}=n;if(!i||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const l=s.after();return l===void 0?!1:r.nodeAt(l)?e.commands.command(({tr:d})=>(d.setSelection(re.near(r.resolve(l))),!0)):e.commands.exitCode()}}},addInputRules(){return[z.textblockTypeInputRule({find:Lc,type:this.type,getAttributes:e=>({language:e[1]})}),z.textblockTypeInputRule({find:Fc,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new In({key:new Hr("codeBlockVSCodeHandler"),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;const n=t.clipboardData.getData("text/plain"),r=t.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s?.mode;if(!n||!i)return!1;const{tr:a,schema:l}=e.state,c=l.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),e.dispatch(a),!0}}})]}}),Rc=/^\s*>\s$/,zc=z.Node.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return["blockquote",z.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[z.wrappingInputRule({find:Rc,type:this.type})]}}),Bc=z.Node.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:e}){return["hr",z.mergeAttributes(this.options.HTMLAttributes,e)]},addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!z.canInsertNode(t,t.schema.nodes[this.name]))return!1;const{selection:n}=t,{$from:r,$to:s}=n,i=e();return r.parentOffset===0?i.insertContentAt({from:Math.max(r.pos-1,0),to:s.pos},{type:this.name}):z.isNodeSelection(n)?i.insertContentAt(s.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({tr:a,dispatch:l})=>{var c;if(l){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(X.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})]}}),_c=z.Node.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:e}){return["br",z.mergeAttributes(this.options.HTMLAttributes,e)]},renderText(){return`
|
|
16
|
+
`},addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{const{selection:s,storedMarks:i}=n;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:a}=this.options,{splittableMarks:l}=r.extensionManager,c=i||s.$to.parentOffset&&s.$from.marks();return t().insertContent({type:this.name}).command(({tr:d,dispatch:u})=>{if(u&&c&&a){const f=c.filter(p=>l.includes(p.type.name));d.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var pn=200,be=function(){};be.prototype.append=function(t){return t.length?(t=be.from(t),!this.length&&t||t.length<pn&&this.leafAppend(t)||this.length<pn&&t.leafPrepend(this)||this.appendInner(t)):this};be.prototype.prepend=function(t){return t.length?be.from(t).append(this):this};be.prototype.appendInner=function(t){return new Vc(this,t)};be.prototype.slice=function(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.length),t>=n?be.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,n))};be.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)};be.prototype.forEach=function(t,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(t,n,r,0):this.forEachInvertedInner(t,n,r,0)};be.prototype.map=function(t,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,a){return s.push(t(i,a))},n,r),s};be.from=function(t){return t instanceof be?t:t&&t.length?new ia(t):be.empty};var ia=(function(e){function t(r){e.call(this),this.values=r}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(s,i){return s==0&&i==this.length?this:new t(this.values.slice(s,i))},t.prototype.getInner=function(s){return this.values[s]},t.prototype.forEachInner=function(s,i,a,l){for(var c=i;c<a;c++)if(s(this.values[c],l+c)===!1)return!1},t.prototype.forEachInvertedInner=function(s,i,a,l){for(var c=i-1;c>=a;c--)if(s(this.values[c],l+c)===!1)return!1},t.prototype.leafAppend=function(s){if(this.length+s.length<=pn)return new t(this.values.concat(s.flatten()))},t.prototype.leafPrepend=function(s){if(this.length+s.length<=pn)return new t(s.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t})(be);be.empty=new ia([]);var Vc=(function(e){function t(n,r){e.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},t.prototype.forEachInner=function(r,s,i,a){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(i,l),a)===!1||i>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,i)-l,a+l)===!1)return!1},t.prototype.forEachInvertedInner=function(r,s,i,a){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(i,l)-l,a+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(s,l),i,a)===!1)return!1},t.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(r,s):r>=i?this.right.slice(r-i,s-i):this.left.slice(r,i).append(this.right.slice(0,s-i))},t.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new t(this.left,s)},t.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new t(s,this.right)},t.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new t(this.left,new t(this.right,r)):new t(this,r)},t})(be);const Hc=500;class Fe{constructor(t,n){this.items=t,this.eventCount=n}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,i;n&&(s=this.remapping(r,this.items.length),i=s.maps.length);let a=t.tr,l,c,d=[],u=[];return this.items.forEach((f,p)=>{if(!f.step){s||(s=this.remapping(r,p+1),i=s.maps.length),i--,u.push(f);return}if(s){u.push(new Be(f.map));let m=f.step.map(s.slice(i)),v;m&&a.maybeStep(m).doc&&(v=a.mapping.maps[a.mapping.maps.length-1],d.push(new Be(v,void 0,void 0,d.length+u.length))),i--,v&&s.appendMap(v,i)}else a.maybeStep(f.step);if(f.selection)return l=s?f.selection.map(s.slice(i)):f.selection,c=new Fe(this.items.slice(0,r).append(u.reverse().concat(d)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:a,selection:l}}addTransform(t,n,r,s){let i=[],a=this.eventCount,l=this.items,c=!s&&l.length?l.get(l.length-1):null;for(let u=0;u<t.steps.length;u++){let f=t.steps[u].invert(t.docs[u]),p=new Be(t.mapping.maps[u],f,n),m;(m=c&&c.merge(p))&&(p=m,u?i.pop():l=l.slice(0,l.length-1)),i.push(p),n&&(a++,n=void 0),s||(c=p)}let d=a-r.depth;return d>qc&&(l=Uc(l,d),a-=d),new Fe(l.append(i),a)}remapping(t,n){let r=new hn;return this.items.forEach((s,i)=>{let a=s.mirrorOffset!=null&&i-s.mirrorOffset>=t?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,a)},t,n),r}addMaps(t){return this.eventCount==0?this:new Fe(this.items.append(t.map(n=>new Be(n))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-n),i=t.mapping,a=t.steps.length,l=this.eventCount;this.items.forEach(p=>{p.selection&&l--},s);let c=n;this.items.forEach(p=>{let m=i.getMirror(--c);if(m==null)return;a=Math.min(a,m);let v=i.maps[m];if(p.step){let b=t.steps[m].invert(t.docs[m]),x=p.selection&&p.selection.map(i.slice(c+1,m));x&&l++,r.push(new Be(v,b,x))}else r.push(new Be(v))},s);let d=[];for(let p=n;p<a;p++)d.push(new Be(i.maps[p]));let u=this.items.slice(0,s).append(d).append(r),f=new Fe(u,l);return f.emptyItemCount()>Hc&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let t=0;return this.items.forEach(n=>{n.step||t++}),t}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,s=[],i=0;return this.items.forEach((a,l)=>{if(l>=t)s.push(a),a.selection&&i++;else if(a.step){let c=a.step.map(n.slice(r)),d=c&&c.getMap();if(r--,d&&n.appendMap(d,r),c){let u=a.selection&&a.selection.map(n.slice(r));u&&i++;let f=new Be(d.invert(),c,u),p,m=s.length-1;(p=s.length&&s[m].merge(f))?s[m]=p:s.push(f)}}else a.map&&r--},this.items.length,0),new Fe(be.from(s.reverse()),i)}}Fe.empty=new Fe(be.empty,0);function Uc(e,t){let n;return e.forEach((r,s)=>{if(r.selection&&t--==0)return n=s,!1}),e.slice(n)}class Be{constructor(t,n,r,s){this.map=t,this.step=n,this.selection=r,this.mirrorOffset=s}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new Be(n.getMap().invert(),n,this.selection)}}}class Ge{constructor(t,n,r,s,i){this.done=t,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const qc=20;function Wc(e,t,n,r){let s=n.getMeta(ft),i;if(s)return s.historyState;n.getMeta(Yc)&&(e=new Ge(e.done,e.undone,null,0,-1));let a=n.getMeta("appendedTransaction");if(n.steps.length==0)return e;if(a&&a.getMeta(ft))return a.getMeta(ft).redo?new Ge(e.done.addTransform(n,void 0,r,on(t)),e.undone,Vs(n.mapping.maps),e.prevTime,e.prevComposition):new Ge(e.done,e.undone.addTransform(n,void 0,r,on(t)),null,e.prevTime,e.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(a&&a.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),c=e.prevTime==0||!a&&e.prevComposition!=l&&(e.prevTime<(n.time||0)-r.newGroupDelay||!Kc(n,e.prevRanges)),d=a?Zn(e.prevRanges,n.mapping):Vs(n.mapping.maps);return new Ge(e.done.addTransform(n,c?t.selection.getBookmark():void 0,r,on(t)),Fe.empty,d,n.time,l??e.prevComposition)}else return(i=n.getMeta("rebased"))?new Ge(e.done.rebased(n,i),e.undone.rebased(n,i),Zn(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new Ge(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),Zn(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function Kc(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<t.length;i+=2)r<=t[i+1]&&s>=t[i]&&(n=!0)}),n}function Vs(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((r,s,i,a)=>t.push(i,a));return t}function Zn(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let s=t.map(e[r],1),i=t.map(e[r+1],-1);s<=i&&n.push(s,i)}return n}function Jc(e,t,n){let r=on(t),s=ft.get(t).spec.config,i=(n?e.undone:e.done).popEvent(t,r);if(!i)return null;let a=i.selection.resolve(i.transform.doc),l=(n?e.done:e.undone).addTransform(i.transform,t.selection.getBookmark(),s,r),c=new Ge(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(a).setMeta(ft,{redo:n,historyState:c})}let Xn=!1,Hs=null;function on(e){let t=e.plugins;if(Hs!=t){Xn=!1,Hs=t;for(let n=0;n<t.length;n++)if(t[n].spec.historyPreserveItems){Xn=!0;break}}return Xn}const ft=new Hr("history"),Yc=new Hr("closeHistory");function Gc(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new In({key:ft,state:{init(){return new Ge(Fe.empty,Fe.empty,null,0,-1)},apply(t,n,r){return Wc(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(t,n){let r=n.inputType,s=r=="historyUndo"?la:r=="historyRedo"?oa:null;return!s||!t.editable?!1:(n.preventDefault(),s(t.state,t.dispatch))}}}})}function aa(e,t){return(n,r)=>{let s=ft.getState(n);if(!s||(e?s.undone:s.done).eventCount==0)return!1;if(r){let i=Jc(s,n,e);i&&r(t?i.scrollIntoView():i)}return!0}}const la=aa(!1,!0),oa=aa(!0,!0),Us=z.Extension.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>la(e,t),redo:()=>({state:e,dispatch:t})=>oa(e,t)}},addProseMirrorPlugins(){return[Gc(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),Qc=z.Node.create({name:"doc",topNode:!0,content:"block+"}),Zc=z.Node.create({name:"text",group:"inline"});function Xc(e={}){return new In({view(t){return new ed(t,e)}})}class ed{constructor(t,n){var r;this.editorView=t,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let i=a=>{this[s](a)};return t.dom.addEventListener(s,i),{name:s,handler:i}})}destroy(){this.handlers.forEach(({name:t,handler:n})=>this.editorView.dom.removeEventListener(t,n))}update(t,n){this.cursorPos!=null&&n.doc!=t.state.doc&&(this.cursorPos>t.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(t){t!=this.cursorPos&&(this.cursorPos=t,t==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let t=this.editorView.state.doc.resolve(this.cursorPos),n=!t.parent.inlineContent,r,s=this.editorView.dom,i=s.getBoundingClientRect(),a=i.width/s.offsetWidth,l=i.height/s.offsetHeight;if(n){let f=t.nodeBefore,p=t.nodeAfter;if(f||p){let m=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(m){let v=m.getBoundingClientRect(),b=f?v.bottom:v.top;f&&p&&(b=(b+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let x=this.width/2*l;r={left:v.left,right:v.right,top:b-x,bottom:b+x}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*a;r={left:f.left-p,right:f.left+p,top:f.top,bottom:f.bottom}}let c=this.editorView.dom.offsetParent;this.element||(this.element=c.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let d,u;if(!c||c==document.body&&getComputedStyle(c).position=="static")d=-pageXOffset,u=-pageYOffset;else{let f=c.getBoundingClientRect(),p=f.width/c.offsetWidth,m=f.height/c.offsetHeight;d=f.left-c.scrollLeft*p,u=f.top-c.scrollTop*m}this.element.style.left=(r.left-d)/a+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/a+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(t){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),t)}dragover(t){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:t.clientX,top:t.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),s=r&&r.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,n,t):s;if(n&&!i){let a=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=na(this.editorView.state.doc,a,this.editorView.dragging.slice);l!=null&&(a=l)}this.setCursor(a),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){this.editorView.dom.contains(t.relatedTarget)||this.setCursor(null)}}const td=z.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Xc(this.options)]}});var nt={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},gn={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},nd=typeof navigator<"u"&&/Mac/.test(navigator.platform),rd=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ve=0;ve<10;ve++)nt[48+ve]=nt[96+ve]=String(ve);for(var ve=1;ve<=24;ve++)nt[ve+111]="F"+ve;for(var ve=65;ve<=90;ve++)nt[ve]=String.fromCharCode(ve+32),gn[ve]=String.fromCharCode(ve);for(var er in nt)gn.hasOwnProperty(er)||(gn[er]=nt[er]);function sd(e){var t=nd&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||rd&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",n=!t&&e.key||(e.shiftKey?gn:nt)[e.keyCode]||e.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const id=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),ad=typeof navigator<"u"&&/Win/.test(navigator.platform);function ld(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n=="Space"&&(n=" ");let r,s,i,a;for(let l=0;l<t.length-1;l++){let c=t[l];if(/^(cmd|meta|m)$/i.test(c))a=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))s=!0;else if(/^s(hift)?$/i.test(c))i=!0;else if(/^mod$/i.test(c))id?a=!0:s=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),a&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function od(e){let t=Object.create(null);for(let n in e)t[ld(n)]=e[n];return t}function tr(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function cd(e){let t=od(e);return function(n,r){let s=sd(r),i,a=t[tr(s,r)];if(a&&a(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=t[tr(s,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(ad&&r.ctrlKey&&r.altKey)&&(i=nt[r.keyCode])&&i!=s){let l=t[tr(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}const gt=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},ca=function(e,t,n,r){return n&&(qs(e,t,n,r,-1)||qs(e,t,n,r,1))},dd=/^(img|br|input|textarea|hr)$/i;function qs(e,t,n,r,s){for(var i;;){if(e==n&&t==r)return!0;if(t==(s<0?0:xn(e))){let a=e.parentNode;if(!a||a.nodeType!=1||Ur(e)||dd.test(e.nodeName)||e.contentEditable=="false")return!1;t=gt(e)+(s<0?0:1),e=a}else if(e.nodeType==1){let a=e.childNodes[t+(s<0?-1:0)];if(a.nodeType==1&&a.contentEditable=="false")if(!((i=a.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)t+=s;else return!1;else e=a,t=s<0?xn(e):0}else return!1}}function xn(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function ud(e,t,n){for(let r=t==0,s=t==xn(e);r||s;){if(e==n)return!0;let i=gt(e);if(e=e.parentNode,!e)return!1;r=r&&i==0,s=s&&i==xn(e)}}function Ur(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const da=function(e){return e.focusNode&&ca(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function ua(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}const He=typeof navigator<"u"?navigator:null,Ws=typeof document<"u"?document:null,rt=He&&He.userAgent||"",vr=/Edge\/(\d+)/.exec(rt),fa=/MSIE \d/.exec(rt),wr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(rt),Jt=!!(fa||wr||vr),ha=fa?document.documentMode:wr?+wr[1]:vr?+vr[1]:0,$n=!Jt&&/gecko\/(\d+)/i.test(rt);$n&&+(/Firefox\/(\d+)/.exec(rt)||[0,0])[1];const kr=!Jt&&/Chrome\/(\d+)/.exec(rt),Ke=!!kr,ma=kr?+kr[1]:0,xt=!Jt&&!!He&&/Apple Computer/.test(He.vendor),qr=xt&&(/Mobile\/\w+/.test(rt)||!!He&&He.maxTouchPoints>2),$e=qr||(He?/Mac/.test(He.platform):!1),pa=He?/Win/.test(He.platform):!1,Yt=/Android \d/.test(rt),Wr=!!Ws&&"webkitFontSmoothing"in Ws.documentElement.style,fd=Wr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function hd(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let s=e.docView.nearestDesc(n.focusNode),i=s&&s.size==0,a=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(a<0)return null;let l=r.resolve(a),c,d;if(da(n)){for(c=a;s&&!s.node;)s=s.parent;let f=s.node;if(s&&f.isAtom&&X.isSelectable(f)&&s.parent&&!(f.isInline&&ud(n.focusNode,n.focusOffset,s.dom))){let p=s.posBefore;d=new X(a==p?l:r.resolve(p))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=a,p=a;for(let m=0;m<n.rangeCount;m++){let v=n.getRangeAt(m);f=Math.min(f,e.docView.posFromDOM(v.startContainer,v.startOffset,1)),p=Math.max(p,e.docView.posFromDOM(v.endContainer,v.endOffset,-1))}if(f<0)return null;[c,a]=p==e.state.selection.anchor?[p,f]:[f,p],l=r.resolve(a)}else c=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let u=r.resolve(c);if(!d){let f=t=="pointer"||e.state.selection.head<l.pos&&!i?1:-1;d=xa(e,u,l,f)}return d}function ga(e){return e.editable?e.hasFocus():xd(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function Kr(e,t=!1){let n=e.state.selection;if(gd(e,n),!!ga(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&Ke){let r=e.domSelectionRange(),s=e.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&ca(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){e.input.mouseDown.delayedSelectionSync=!0,e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)pd(e);else{let{anchor:r,head:s}=n,i,a;Ks&&!(n instanceof ne)&&(n.$from.parent.inlineContent||(i=Js(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(a=Js(e,n.to))),e.docView.setSelection(r,s,e,t),Ks&&(i&&Ys(i),a&&Ys(a)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&md(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}const Ks=xt||Ke&&ma<63;function Js(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),s=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(xt&&s&&s.contentEditable=="false")return nr(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return nr(s);if(i)return nr(i)}}function nr(e){return e.contentEditable="true",xt&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function Ys(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function md(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,s=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=s)&&(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!ga(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}function pd(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName=="IMG";r?t.collapse(n.parentNode,gt(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&Jt&&ha<=11&&(n.disabled=!0,n.disabled=!1)}function gd(e,t){if(t instanceof X){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(Gs(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else Gs(e)}function Gs(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function xa(e,t,n,r){return e.someProp("createSelectionBetween",s=>s(e,t,n))||ne.between(t,n,r)}function xd(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function Nr(e,t){let{$anchor:n,$head:r}=e.selection,s=t>0?n.max(r):n.min(r),i=s.parent.inlineContent?s.depth?e.doc.resolve(t>0?s.after():s.before()):null:s;return i&&re.findFrom(i,t)}function Qe(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Qs(e,t,n){let r=e.state.selection;if(r instanceof ne)if(n.indexOf("s")>-1){let{$head:s}=r,i=s.textOffset?null:t<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let a=e.state.doc.resolve(s.pos+i.nodeSize*(t<0?-1:1));return Qe(e,new ne(r.$anchor,a))}else if(r.empty){if(e.endOfTextblock(t>0?"forward":"backward")){let s=Nr(e.state,t);return s&&s instanceof X?Qe(e,s):!1}else if(!($e&&n.indexOf("m")>-1)){let s=r.$head,i=s.textOffset?null:t<0?s.nodeBefore:s.nodeAfter,a;if(!i||i.isText)return!1;let l=t<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(a=e.docView.descAt(l))&&!a.contentDOM?X.isSelectable(i)?Qe(e,new X(t<0?e.state.doc.resolve(s.pos-i.nodeSize):s)):Wr?Qe(e,new ne(e.state.doc.resolve(t<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof X&&r.node.isInline)return Qe(e,new ne(t>0?r.$to:r.$from));{let s=Nr(e.state,t);return s?Qe(e,s):!1}}}function yn(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function Ft(e,t){let n=e.pmViewDesc;return n&&n.size==0&&(t<0||e.nextSibling||e.nodeName!="BR")}function yt(e,t){return t<0?yd(e):bd(e)}function yd(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let s,i,a=!1;for($n&&n.nodeType==1&&r<yn(n)&&Ft(n.childNodes[r],-1)&&(a=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(Ft(l,-1))s=n,i=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(ya(n))break;{let l=n.previousSibling;for(;l&&Ft(l,-1);)s=n.parentNode,i=gt(l),l=l.previousSibling;if(l)n=l,r=yn(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}a?Sr(e,n,r):s&&Sr(e,s,i)}function bd(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let s=yn(n),i,a;for(;;)if(r<s){if(n.nodeType!=1)break;let l=n.childNodes[r];if(Ft(l,1))i=n,a=++r;else break}else{if(ya(n))break;{let l=n.nextSibling;for(;l&&Ft(l,1);)i=l.parentNode,a=gt(l)+1,l=l.nextSibling;if(l)n=l,r=0,s=yn(n);else{if(n=n.parentNode,n==e.dom)break;r=s=0}}}i&&Sr(e,i,a)}function ya(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function vd(e,t){for(;e&&t==e.childNodes.length&&!Ur(e);)t=gt(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;e=n,t=0}}function wd(e,t){for(;e&&!t&&!Ur(e);)t=gt(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;e=n,t=e.childNodes.length}}function Sr(e,t,n){if(t.nodeType!=3){let i,a;(a=vd(t,n))?(t=a,n=0):(i=wd(t,n))&&(t=i,n=i.nodeValue.length)}let r=e.domSelection();if(!r)return;if(da(r)){let i=document.createRange();i.setEnd(t,n),i.setStart(t,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:s}=e;setTimeout(()=>{e.state==s&&Kr(e)},50)}function Zs(e,t){let n=e.state.doc.resolve(t);if(!(Ke||pa)&&n.parent.inlineContent){let s=e.coordsAtPos(t);if(t>n.start()){let i=e.coordsAtPos(t-1),a=(i.top+i.bottom)/2;if(a>s.top&&a<s.bottom&&Math.abs(i.left-s.left)>1)return i.left<s.left?"ltr":"rtl"}if(t<n.end()){let i=e.coordsAtPos(t+1),a=(i.top+i.bottom)/2;if(a>s.top&&a<s.bottom&&Math.abs(i.left-s.left)>1)return i.left>s.left?"ltr":"rtl"}}return getComputedStyle(e.dom).direction=="rtl"?"rtl":"ltr"}function Xs(e,t,n){let r=e.state.selection;if(r instanceof ne&&!r.empty||n.indexOf("s")>-1||$e&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let a=Nr(e.state,t);if(a&&a instanceof X)return Qe(e,a)}if(!s.parent.inlineContent){let a=t<0?s:i,l=r instanceof Ve?re.near(a,t):re.findFrom(a,t);return l?Qe(e,l):!1}return!1}function ei(e,t){if(!(e.state.selection instanceof ne))return!0;let{$head:n,$anchor:r,empty:s}=e.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let i=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let a=e.state.tr;return t<0?a.delete(n.pos-i.nodeSize,n.pos):a.delete(n.pos,n.pos+i.nodeSize),e.dispatch(a),!0}return!1}function ti(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function kd(e){if(!xt||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&t.nodeType==1&&n==0&&t.firstChild&&t.firstChild.contentEditable=="false"){let r=t.firstChild;ti(e,r,"true"),setTimeout(()=>ti(e,r,"false"),20)}return!1}function Nd(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}function Sd(e,t){let n=t.keyCode,r=Nd(t);if(n==8||$e&&n==72&&r=="c")return ei(e,-1)||yt(e,-1);if(n==46&&!t.shiftKey||$e&&n==68&&r=="c")return ei(e,1)||yt(e,1);if(n==13||n==27)return!0;if(n==37||$e&&n==66&&r=="c"){let s=n==37?Zs(e,e.state.selection.from)=="ltr"?-1:1:-1;return Qs(e,s,r)||yt(e,s)}else if(n==39||$e&&n==70&&r=="c"){let s=n==39?Zs(e,e.state.selection.from)=="ltr"?1:-1:1;return Qs(e,s,r)||yt(e,s)}else{if(n==38||$e&&n==80&&r=="c")return Xs(e,-1,r)||yt(e,-1);if(n==40||$e&&n==78&&r=="c")return kd(e)||Xs(e,1,r)||yt(e,1);if(r==($e?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function ba(e,t){e.someProp("transformCopied",m=>{t=m(t,e)});let n=[],{content:r,openStart:s,openEnd:i}=t;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let m=r.firstChild;n.push(m.type.name,m.attrs!=m.type.defaultAttrs?m.attrs:null),r=m.content}let a=e.someProp("clipboardSerializer")||Tn.fromSchema(e.state.schema),l=Ca(),c=l.createElement("div");c.appendChild(a.serializeFragment(r,{document:l}));let d=c.firstChild,u,f=0;for(;d&&d.nodeType==1&&(u=Sa[d.nodeName.toLowerCase()]);){for(let m=u.length-1;m>=0;m--){let v=l.createElement(u[m]);for(;c.firstChild;)v.appendChild(c.firstChild);c.appendChild(v),f++}d=c.firstChild}d&&d.nodeType==1&&d.setAttribute("data-pm-slice",`${s} ${i}${f?` -${f}`:""} ${JSON.stringify(n)}`);let p=e.someProp("clipboardTextSerializer",m=>m(t,e))||t.content.textBetween(0,t.content.size,`
|
|
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:t}}function va(e,t,n,r,s){let i=s.parent.type.spec.code,a,l;if(!n&&!t)return null;let c=!!t&&(r||i||!n);if(c){if(e.someProp("transformPastedText",p=>{t=p(t,i||r,e)}),i)return l=new Q(G.from(e.state.schema.text(t.replace(/\r\n?/g,`
|
|
19
|
+
`))),0,0),e.someProp("transformPasted",p=>{l=p(l,e,!0)}),l;let f=e.someProp("clipboardTextParser",p=>p(t,s,r,e));if(f)l=f;else{let p=s.marks(),{schema:m}=e.state,v=Tn.fromSchema(m);a=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(b=>{let x=a.appendChild(document.createElement("p"));b&&x.appendChild(v.serializeNode(m.text(b,p)))})}}else e.someProp("transformPastedHTML",f=>{n=f(n,e)}),a=Md(n),Wr&&Ed(a);let d=a&&a.querySelector("[data-pm-slice]"),u=d&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(d.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let f=+u[3];f>0;f--){let p=a.firstChild;for(;p&&p.nodeType!=1;)p=p.nextSibling;if(!p)break;a=p}if(l||(l=(e.someProp("clipboardParser")||e.someProp("domParser")||fn.fromSchema(e.state.schema)).parseSlice(a,{preserveWhitespace:!!(c||u),context:s,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!Cd.test(p.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Td(ni(l,+u[1],+u[2]),u[4]);else if(l=Q.maxOpen(jd(l.content,s),!0),l.openStart||l.openEnd){let f=0,p=0;for(let m=l.content.firstChild;f<l.openStart&&!m.type.spec.isolating;f++,m=m.firstChild);for(let m=l.content.lastChild;p<l.openEnd&&!m.type.spec.isolating;p++,m=m.lastChild);l=ni(l,f,p)}return e.someProp("transformPasted",f=>{l=f(l,e,c)}),l}const Cd=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function jd(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let s=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(l=>{if(!a)return;let c=s.findWrapping(l.type),d;if(!c)return a=null;if(d=a.length&&i.length&&ka(c,i,l,a[a.length-1],0))a[a.length-1]=d;else{a.length&&(a[a.length-1]=Na(a[a.length-1],i.length));let u=wa(l,c);a.push(u),s=s.matchType(u.type),i=c}}),a)return G.from(a)}return e}function wa(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,G.from(e));return e}function ka(e,t,n,r,s){if(s<e.length&&s<t.length&&e[s]==t[s]){let i=ka(e,t,n,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==e.length-1?n.type:e[s+1]))return r.copy(r.content.append(G.from(wa(n,e,s+1))))}}function Na(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,Na(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(G.empty,!0);return e.copy(n.append(r))}function Cr(e,t,n,r,s,i){let a=t<0?e.firstChild:e.lastChild,l=a.content;return e.childCount>1&&(i=0),s<r-1&&(l=Cr(l,t,n,r,s+1,i)),s>=n&&(l=t<0?a.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(a.contentMatchAt(a.childCount).fillBefore(G.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,a.copy(l))}function ni(e,t,n){return t<e.openStart&&(e=new Q(Cr(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new Q(Cr(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const Sa={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let ri=null;function Ca(){return ri||(ri=document.implementation.createHTMLDocument("title"))}let rr=null;function Ad(e){let t=window.trustedTypes;return t?(rr||(rr=t.defaultPolicy||t.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),rr.createHTML(e)):e}function Md(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=Ca().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(e),s;if((s=r&&Sa[r[1].toLowerCase()])&&(e=s.map(i=>"<"+i+">").join("")+e+s.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=Ad(e),s)for(let i=0;i<s.length;i++)n=n.querySelector(s[i])||n;return n}function Ed(e){let t=e.querySelectorAll(Ke?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}function Td(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:s,openStart:i,openEnd:a}=e;for(let l=r.length-2;l>=0;l-=2){let c=n.nodes[r[l]];if(!c||c.hasRequiredAttrs())break;s=G.from(c.create(r[l+1],s)),i++,a++}return new Q(s,i,a)}const ze={},Ie={};function Ze(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}Ie.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!Aa(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(Yt&&Ke&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),qr&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();e.input.lastIOSEnter=r,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==r&&(e.someProp("handleKeyDown",s=>s(e,ua(13,"Enter"))),e.input.lastIOSEnter=0)},200)}else e.someProp("handleKeyDown",r=>r(e,n))||Sd(e,n)?n.preventDefault():Ze(e,"key")};Ie.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)};Ie.keypress=(e,t)=>{let n=t;if(Aa(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||$e&&n.metaKey)return;if(e.someProp("handleKeyPress",s=>s(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof ne)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!e.someProp("handleTextInput",a=>a(e,r.$from.pos,r.$to.pos,s,i))&&e.dispatch(i()),n.preventDefault()}};function On(e){return{left:e.clientX,top:e.clientY}}function Dd(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function Jr(e,t,n,r,s){if(r==-1)return!1;let i=e.state.doc.resolve(r);for(let a=i.depth+1;a>0;a--)if(e.someProp(t,l=>a>i.depth?l(e,n,i.nodeAfter,i.before(a),s,!0):l(e,n,i.node(a),i.before(a),s,!1)))return!0;return!1}function Ct(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);r.setMeta("pointer",!0),e.dispatch(r)}function Id(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&X.isSelectable(r)?(Ct(e,new X(n)),!0):!1}function $d(e,t){if(t==-1)return!1;let n=e.state.selection,r,s;n instanceof X&&(r=n.node);let i=e.state.doc.resolve(t);for(let a=i.depth+1;a>0;a--){let l=a>i.depth?i.nodeAfter:i.node(a);if(X.isSelectable(l)){r&&n.$from.depth>0&&a>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?s=i.before(n.$from.depth):s=i.before(a);break}}return s!=null?(Ct(e,X.create(e.state.doc,s)),!0):!1}function Od(e,t,n,r,s){return Jr(e,"handleClickOn",t,n,r)||e.someProp("handleClick",i=>i(e,t,r))||(s?$d(e,n):Id(e,n))}function Ld(e,t,n,r){return Jr(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",s=>s(e,t,r))}function Fd(e,t,n,r){return Jr(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",s=>s(e,t,r))||Pd(e,n,r)}function Pd(e,t,n){if(n.button!=0)return!1;let r=e.state.doc;if(t==-1)return r.inlineContent?(Ct(e,ne.create(r,0,r.content.size)),!0):!1;let s=r.resolve(t);for(let i=s.depth+1;i>0;i--){let a=i>s.depth?s.nodeAfter:s.node(i),l=s.before(i);if(a.inlineContent)Ct(e,ne.create(r,l+1,l+1+a.content.size));else if(X.isSelectable(a))Ct(e,X.create(r,l));else continue;return!0}}function Yr(e){return bn(e)}const ja=$e?"metaKey":"ctrlKey";ze.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=Yr(e),s=Date.now(),i="singleClick";s-e.input.lastClick.time<500&&Dd(n,e.input.lastClick)&&!n[ja]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type=="singleClick"?i="doubleClick":e.input.lastClick.type=="doubleClick"&&(i="tripleClick")),e.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:i,button:n.button};let a=e.posAtCoords(On(n));a&&(i=="singleClick"?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new Rd(e,a,n,!!r)):(i=="doubleClick"?Ld:Fd)(e,a.pos,a.inside,n)?n.preventDefault():Ze(e,"pointer"))};class Rd{constructor(t,n,r,s){this.view=t,this.pos=n,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!r[ja],this.allowDefault=r.shiftKey;let i,a;if(n.inside>-1)i=t.state.doc.nodeAt(n.inside),a=n.inside;else{let u=t.state.doc.resolve(n.pos);i=u.parent,a=u.depth?u.before():0}const l=s?null:r.target,c=l?t.docView.nearestDesc(l,!0):null;this.target=c&&c.nodeDOM.nodeType==1?c.nodeDOM:null;let{selection:d}=t.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||d instanceof X&&d.from<=a&&d.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&$n&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),Ze(t,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Kr(this.view)),this.view.input.mouseDown=null}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(On(t))),this.updateAllowDefault(t),this.allowDefault||!n?Ze(this.view,"pointer"):Od(this.view,n.pos,n.inside,t,this.selectNode)?t.preventDefault():t.button==0&&(this.flushed||xt&&this.mightDrag&&!this.mightDrag.node.isAtom||Ke&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Ct(this.view,re.near(this.view.state.doc.resolve(n.pos))),t.preventDefault()):Ze(this.view,"pointer")}move(t){this.updateAllowDefault(t),Ze(this.view,"pointer"),t.buttons==0&&this.done()}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}}ze.touchstart=e=>{e.input.lastTouch=Date.now(),Yr(e),Ze(e,"pointer")};ze.touchmove=e=>{e.input.lastTouch=Date.now(),Ze(e,"pointer")};ze.contextmenu=e=>Yr(e);function Aa(e,t){return e.composing?!0:xt&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}const zd=Yt?5e3:-1;Ie.compositionstart=Ie.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof ne&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Ke&&pa&&Bd(e)))e.markCursor=e.state.storedMarks||n.marks(),bn(e,!0),e.markCursor=null;else if(bn(e,!t.selection.empty),$n&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=e.domSelectionRange();for(let s=r.focusNode,i=r.focusOffset;s&&s.nodeType==1&&i!=0;){let a=i<0?s.lastChild:s.childNodes[i-1];if(!a)break;if(a.nodeType==3){let l=e.domSelection();l&&l.collapse(a,a.nodeValue.length);break}else s=a,i=-1}}e.input.composing=!0}Ma(e,zd)};function Bd(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||t.nodeType!=1||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}Ie.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,Ma(e,20))};function Ma(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>bn(e),t))}function _d(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Vd());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function Vd(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}function bn(e,t=!1){if(!(Yt&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),_d(e),t||e.docView&&e.docView.dirty){let n=hd(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function Hd(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}const Ut=Jt&&ha<15||qr&&fd<604;ze.copy=Ie.cut=(e,t)=>{let n=t,r=e.state.selection,s=n.type=="cut";if(r.empty)return;let i=Ut?null:n.clipboardData,a=r.content(),{dom:l,text:c}=ba(e,a);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",c)):Hd(e,l),s&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Ud(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function qd(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?jr(e,r.value,null,s,t):jr(e,r.textContent,r.innerHTML,s,t)},50)}function jr(e,t,n,r,s){let i=va(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",c=>c(e,s,i||Q.empty)))return!0;if(!i)return!1;let a=Ud(i),l=a?e.state.tr.replaceSelectionWith(a,r):e.state.tr.replaceSelection(i);return e.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Ea(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Ie.paste=(e,t)=>{let n=t;if(e.composing&&!Yt)return;let r=Ut?null:n.clipboardData,s=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&jr(e,Ea(r),r.getData("text/html"),s,n)?n.preventDefault():qd(e,n)};class Wd{constructor(t,n,r){this.slice=t,this.move=n,this.node=r}}const Kd=$e?"altKey":"ctrlKey";function Ta(e,t){let n=e.someProp("dragCopies",r=>!r(t));return n??!t[Kd]}ze.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=e.state.selection,i=s.empty?null:e.posAtCoords(On(n)),a;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof X?s.to-1:s.to))){if(r&&r.mightDrag)a=X.create(e.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let f=e.docView.nearestDesc(n.target,!0);f&&f.node.type.spec.draggable&&f!=e.docView&&(a=X.create(e.state.doc,f.posBefore))}}let l=(a||e.state.selection).content(),{dom:c,text:d,slice:u}=ba(e,l);(!n.dataTransfer.files.length||!Ke||ma>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Ut?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",Ut||n.dataTransfer.setData("text/plain",d),e.dragging=new Wd(u,Ta(e,n),a)};ze.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)};Ie.dragover=Ie.dragenter=(e,t)=>t.preventDefault();Ie.drop=(e,t)=>{try{Jd(e,t,e.dragging)}finally{e.dragging=null}};function Jd(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(On(t));if(!r)return;let s=e.state.doc.resolve(r.pos),i=n&&n.slice;i?e.someProp("transformPasted",m=>{i=m(i,e,!1)}):i=va(e,Ea(t.dataTransfer),Ut?null:t.dataTransfer.getData("text/html"),!1,s);let a=!!(n&&Ta(e,t));if(e.someProp("handleDrop",m=>m(e,t,i||Q.empty,a))){t.preventDefault();return}if(!i)return;t.preventDefault();let l=i?na(e.state.doc,s.pos,i):s.pos;l==null&&(l=s.pos);let c=e.state.tr;if(a){let{node:m}=n;m?m.replace(c):c.deleteSelection()}let d=c.mapping.map(l),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,f=c.doc;if(u?c.replaceRangeWith(d,d,i.content.firstChild):c.replaceRange(d,d,i),c.doc.eq(f))return;let p=c.doc.resolve(d);if(u&&X.isSelectable(i.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new X(p));else{let m=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((v,b,x,w)=>m=w),c.setSelection(xa(e,p,c.doc.resolve(m)))}e.focus(),e.dispatch(c.setMeta("uiEvent","drop"))}ze.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&Kr(e)},20))};ze.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)};ze.beforeinput=(e,t)=>{if(Ke&&Yt&&t.inputType=="deleteContentBackward"){e.domObserver.flushSoon();let{domChangeCount:r}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=r||(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",i=>i(e,ua(8,"Backspace")))))return;let{$cursor:s}=e.state.selection;s&&s.pos>0&&e.dispatch(e.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let e in Ie)ze[e]=Ie[e];function qt(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class vn{constructor(t,n){this.toDOM=t,this.spec=n||ht,this.side=this.spec.side||0}map(t,n,r,s){let{pos:i,deleted:a}=t.mapResult(n.from+s,this.side<0?-1:1);return a?null:new _e(i-r,i-r,this)}valid(){return!0}eq(t){return this==t||t instanceof vn&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&qt(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}}class et{constructor(t,n){this.attrs=t,this.spec=n||ht}map(t,n,r,s){let i=t.map(n.from+s,this.spec.inclusiveStart?-1:1)-r,a=t.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=a?null:new _e(i,a,this)}valid(t,n){return n.from<n.to}eq(t){return this==t||t instanceof et&&qt(this.attrs,t.attrs)&&qt(this.spec,t.spec)}static is(t){return t.type instanceof et}destroy(){}}class Gr{constructor(t,n){this.attrs=t,this.spec=n||ht}map(t,n,r,s){let i=t.mapResult(n.from+s,1);if(i.deleted)return null;let a=t.mapResult(n.to+s,-1);return a.deleted||a.pos<=i.pos?null:new _e(i.pos-r,a.pos-r,this)}valid(t,n){let{index:r,offset:s}=t.content.findIndex(n.from),i;return s==n.from&&!(i=t.child(r)).isText&&s+i.nodeSize==n.to}eq(t){return this==t||t instanceof Gr&&qt(this.attrs,t.attrs)&&qt(this.spec,t.spec)}destroy(){}}class _e{constructor(t,n,r){this.from=t,this.to=n,this.type=r}copy(t,n){return new _e(t,n,this.type)}eq(t,n=0){return this.type.eq(t.type)&&this.from+n==t.from&&this.to+n==t.to}map(t,n,r){return this.type.map(t,this,n,r)}static widget(t,n,r){return new _e(t,t,new vn(n,r))}static inline(t,n,r,s){return new _e(t,n,new et(r,s))}static node(t,n,r,s){return new _e(t,n,new Gr(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof et}get widget(){return this.type instanceof vn}}const kt=[],ht={};class ye{constructor(t,n){this.local=t.length?t:kt,this.children=n.length?n:kt}static create(t,n){return n.length?wn(n,t,0,ht):Ce}find(t,n,r){let s=[];return this.findInner(t??0,n??1e9,s,0,r),s}findInner(t,n,r,s,i){for(let a=0;a<this.local.length;a++){let l=this.local[a];l.from<=n&&l.to>=t&&(!i||i(l.spec))&&r.push(l.copy(l.from+s,l.to+s))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<n&&this.children[a+1]>t){let l=this.children[a]+1;this.children[a+2].findInner(t-l,n-l,r,s+l,i)}}map(t,n,r){return this==Ce||t.maps.length==0?this:this.mapInner(t,n,0,0,r||ht)}mapInner(t,n,r,s,i){let a;for(let l=0;l<this.local.length;l++){let c=this.local[l].map(t,r,s);c&&c.type.valid(n,c)?(a||(a=[])).push(c):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?Yd(this.children,a||[],t,n,r,s,i):a?new ye(a.sort(mt),kt):Ce}add(t,n){return n.length?this==Ce?ye.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let s,i=0;t.forEach((l,c)=>{let d=c+r,u;if(u=Ia(n,l,d)){for(s||(s=this.children.slice());i<s.length&&s[i]<c;)i+=3;s[i]==c?s[i+2]=s[i+2].addInner(l,u,d+1):s.splice(i,0,c,c+l.nodeSize,wn(u,l,d+1,ht)),i+=3}});let a=Da(i?$a(n):n,-r);for(let l=0;l<a.length;l++)a[l].type.valid(t,a[l])||a.splice(l--,1);return new ye(a.length?this.local.concat(a).sort(mt):this.local,s||this.children)}remove(t){return t.length==0||this==Ce?this:this.removeInner(t,0)}removeInner(t,n){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let a,l=r[i]+n,c=r[i+1]+n;for(let u=0,f;u<t.length;u++)(f=t[u])&&f.from>l&&f.to<c&&(t[u]=null,(a||(a=[])).push(f));if(!a)continue;r==this.children&&(r=this.children.slice());let d=r[i+2].removeInner(a,l+1);d!=Ce?r[i+2]=d:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,a;i<t.length;i++)if(a=t[i])for(let l=0;l<s.length;l++)s[l].eq(a,n)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new ye(s,r):Ce}forChild(t,n){if(this==Ce)return this;if(n.isLeaf)return ye.empty;let r,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=t){this.children[l]==t&&(r=this.children[l+2]);break}let i=t+1,a=i+n.content.size;for(let l=0;l<this.local.length;l++){let c=this.local[l];if(c.from<a&&c.to>i&&c.type instanceof et){let d=Math.max(i,c.from)-i,u=Math.min(a,c.to)-i;d<u&&(s||(s=[])).push(c.copy(d,u))}}if(s){let l=new ye(s.sort(mt),kt);return r?new lt([l,r]):l}return r||Ce}eq(t){if(this==t)return!0;if(!(t instanceof ye)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(t.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=t.children[n]||this.children[n+1]!=t.children[n+1]||!this.children[n+2].eq(t.children[n+2]))return!1;return!0}locals(t){return Qr(this.localsInner(t))}localsInner(t){if(this==Ce)return kt;if(t.inlineContent||!this.local.some(et.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof et||n.push(this.local[r]);return n}forEachSet(t){t(this)}}ye.empty=new ye([],[]);ye.removeOverlap=Qr;const Ce=ye.empty;class lt{constructor(t){this.members=t}map(t,n){const r=this.members.map(s=>s.map(t,n,ht));return lt.from(r)}forChild(t,n){if(n.isLeaf)return ye.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(t,n);i!=Ce&&(i instanceof lt?r=r.concat(i.members):r.push(i))}return lt.from(r)}eq(t){if(!(t instanceof lt)||t.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(t.members[n]))return!1;return!0}locals(t){let n,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(t);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let a=0;a<i.length;a++)n.push(i[a])}}return n?Qr(r?n:n.sort(mt)):kt}static from(t){switch(t.length){case 0:return Ce;case 1:return t[0];default:return new lt(t.every(n=>n instanceof ye)?t:t.reduce((n,r)=>n.concat(r instanceof ye?r:r.members),[]))}}forEachSet(t){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(t)}}function Yd(e,t,n,r,s,i,a){let l=e.slice();for(let d=0,u=i;d<n.maps.length;d++){let f=0;n.maps[d].forEach((p,m,v,b)=>{let x=b-v-(m-p);for(let w=0;w<l.length;w+=3){let N=l[w+1];if(N<0||p>N+u-f)continue;let A=l[w]+u-f;m>=A?l[w+1]=p<=A?-2:-1:p>=u&&x&&(l[w]+=x,l[w+1]+=x)}f+=x}),u=n.maps[d].map(u,-1)}let c=!1;for(let d=0;d<l.length;d+=3)if(l[d+1]<0){if(l[d+1]==-2){c=!0,l[d+1]=-1;continue}let u=n.map(e[d]+i),f=u-s;if(f<0||f>=r.content.size){c=!0;continue}let p=n.map(e[d+1]+i,-1),m=p-s,{index:v,offset:b}=r.content.findIndex(f),x=r.maybeChild(v);if(x&&b==f&&b+x.nodeSize==m){let w=l[d+2].mapInner(n,x,u+1,e[d]+i+1,a);w!=Ce?(l[d]=f,l[d+1]=m,l[d+2]=w):(l[d+1]=-2,c=!0)}else c=!0}if(c){let d=Gd(l,e,t,n,s,i,a),u=wn(d,r,0,a);t=u.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,p=0;f<u.children.length;f+=3){let m=u.children[f];for(;p<l.length&&l[p]<m;)p+=3;l.splice(p,0,u.children[f],u.children[f+1],u.children[f+2])}}return new ye(t.sort(mt),l)}function Da(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let s=e[r];n.push(new _e(s.from+t,s.to+t,s.type))}return n}function Gd(e,t,n,r,s,i,a){function l(c,d){for(let u=0;u<c.local.length;u++){let f=c.local[u].map(r,s,d);f?n.push(f):a.onRemove&&a.onRemove(c.local[u].spec)}for(let u=0;u<c.children.length;u+=3)l(c.children[u+2],c.children[u]+d+1)}for(let c=0;c<e.length;c+=3)e[c+1]==-1&&l(e[c+2],t[c]+i+1);return n}function Ia(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,s=null;for(let i=0,a;i<e.length;i++)(a=e[i])&&a.from>n&&a.to<r&&((s||(s=[])).push(a),e[i]=null);return s}function $a(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function wn(e,t,n,r){let s=[],i=!1;t.forEach((l,c)=>{let d=Ia(e,l,c+n);if(d){i=!0;let u=wn(d,l,n+c+1,r);u!=Ce&&s.push(c,c+l.nodeSize,u)}});let a=Da(i?$a(e):e,-n).sort(mt);for(let l=0;l<a.length;l++)a[l].type.valid(t,a[l])||(r.onRemove&&r.onRemove(a[l].spec),a.splice(l--,1));return a.length||s.length?new ye(a,s):Ce}function mt(e,t){return e.from-t.from||e.to-t.to}function Qr(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let s=n+1;s<t.length;s++){let i=t[s];if(i.from==r.from){i.to!=r.to&&(t==e&&(t=e.slice()),t[s]=i.copy(i.from,r.to),si(t,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,i.from),si(t,s,r.copy(i.from,r.to)));break}}}return t}function si(e,t,n){for(;t<e.length&&mt(n,e[t])>0;)t++;e.splice(t,0,n)}class he extends re{constructor(t){super(t,t)}map(t,n){let r=t.resolve(n.map(this.head));return he.valid(r)?new he(r):re.near(r)}content(){return Q.empty}eq(t){return t instanceof he&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new he(t.resolve(n.pos))}getBookmark(){return new Zr(this.anchor)}static valid(t){let n=t.parent;if(n.isTextblock||!Qd(t)||!Zd(t))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let s=n.contentMatchAt(t.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(t,n,r=!1){e:for(;;){if(!r&&he.valid(t))return t;let s=t.pos,i=null;for(let a=t.depth;;a--){let l=t.node(a);if(n>0?t.indexAfter(a)<l.childCount:t.index(a)>0){i=l.child(n>0?t.indexAfter(a):t.index(a)-1);break}else if(a==0)return null;s+=n;let c=t.doc.resolve(s);if(he.valid(c))return c}for(;;){let a=n>0?i.firstChild:i.lastChild;if(!a){if(i.isAtom&&!i.isText&&!X.isSelectable(i)){t=t.doc.resolve(s+i.nodeSize*n),r=!1;continue e}break}i=a,s+=n;let l=t.doc.resolve(s);if(he.valid(l))return l}return null}}}he.prototype.visible=!1;he.findFrom=he.findGapCursorFrom;re.jsonID("gapcursor",he);class Zr{constructor(t){this.pos=t}map(t){return new Zr(t.map(this.pos))}resolve(t){let n=t.resolve(this.pos);return he.valid(n)?new he(n):re.near(n)}}function Oa(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function Qd(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||Oa(s.type))return!0;if(s.inlineContent)return!1}}return!0}function Zd(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||Oa(s.type))return!0;if(s.inlineContent)return!1}}return!0}function Xd(){return new In({props:{decorations:ru,createSelectionBetween(e,t,n){return t.pos==n.pos&&he.valid(n)?new he(n):null},handleClick:tu,handleKeyDown:eu,handleDOMEvents:{beforeinput:nu}}})}const eu=cd({ArrowLeft:tn("horiz",-1),ArrowRight:tn("horiz",1),ArrowUp:tn("vert",-1),ArrowDown:tn("vert",1)});function tn(e,t){const n=e=="vert"?t>0?"down":"up":t>0?"right":"left";return function(r,s,i){let a=r.selection,l=t>0?a.$to:a.$from,c=a.empty;if(a instanceof ne){if(!i.endOfTextblock(n)||l.depth==0)return!1;c=!1,l=r.doc.resolve(t>0?l.after():l.before())}let d=he.findGapCursorFrom(l,t,c);return d?(s&&s(r.tr.setSelection(new he(d))),!0):!1}}function tu(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!he.valid(r))return!1;let s=e.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&X.isSelectable(e.state.doc.nodeAt(s.inside))?!1:(e.dispatch(e.state.tr.setSelection(new he(r))),!0)}function nu(e,t){if(t.inputType!="insertCompositionText"||!(e.state.selection instanceof he))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let s=G.empty;for(let a=r.length-1;a>=0;a--)s=G.from(r[a].createAndFill(null,s));let i=e.state.tr.replace(n.pos,n.pos,new Q(s,0,0));return i.setSelection(ne.near(i.doc.resolve(n.pos+1))),e.dispatch(i),!1}function ru(e){if(!(e.selection instanceof he))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",ye.create(e.doc,[_e.widget(e.selection.head,t,{key:"gapcursor"})])}const su=z.Extension.create({name:"gapCursor",addProseMirrorPlugins(){return[Xd()]},extendNodeSchema(e){var t;const n={name:e.name,options:e.options,storage:e.storage};return{allowGapCursor:(t=z.callOrReturn(z.getExtensionField(e,"allowGapCursor",n)))!==null&&t!==void 0?t:null}}}),Et={bold:{category:"mark",extension:nc,priority:100},italic:{category:"mark",extension:lc,priority:100},strike:{category:"mark",extension:dc,priority:100},underline:{category:"mark",extension:go.Underline,priority:100},code:{category:"mark",extension:hc,priority:100},textColor:{category:"mark",extension:xo.Color,defaultOptions:{types:["textStyle","heading","paragraph","listItem","taskItem","blockquote"]},priority:90},highlight:{category:"mark",extension:yo.Highlight,defaultOptions:{multicolor:!0},priority:90},link:{category:"mark",extension:bo.Link,defaultOptions:{autolink:!0,linkOnPaste:!0,openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}},priority:100},heading:{category:"node",extension:gc,defaultOptions:{levels:[1,2,3,4,5,6]},priority:100},bulletList:{category:"node",extension:bc,defaultOptions:{HTMLAttributes:{class:"list-disc"}},priority:90},orderedList:{category:"node",extension:wc,defaultOptions:{HTMLAttributes:{class:"list-decimal"}},priority:90},taskList:{category:"node",extension:vo.TaskList,defaultOptions:{HTMLAttributes:{class:"task-list"}},priority:90},codeBlock:{category:"node",extension:Pc,priority:100},blockquote:{category:"node",extension:zc,priority:100},horizontalRule:{category:"node",extension:Bc,priority:100},hardBreak:{category:"node",extension:_c,priority:100},undo:{category:"extension",extension:Us,priority:50},redo:{category:"extension",extension:Us,priority:50},textAlign:{category:"extension",extension:ko.TextAlign,defaultOptions:{types:["heading","paragraph","listItem","bulletList","orderedList","taskList","taskItem","blockquote"],alignments:["left","center","right","justify"],defaultAlignment:"left"},priority:80},clearMarks:{category:"extension",extension:null,priority:50},clearNodes:{category:"extension",extension:null,priority:50}},iu=[Qc,Zc,xc,pc.configure({HTMLAttributes:{}}),kc.configure({HTMLAttributes:{}}),wo.TaskItem.configure({nested:!0}),td,su];function au(e){const t=[],n=new Set,r=new Set;iu.forEach(l=>{l&&(t.push(l),r.add(l.name))});const s=e.map(l=>Bt(l)),i=new Set;return s.forEach(l=>{const c=Et[l];c?.requiredExtensions&&c.requiredExtensions.forEach(d=>{i.add(d)})}),i.forEach(l=>{if(n.has(l))return;const c=Et[l];if(!c||c.extension===null)return;const d=c.extension.name;if(r.has(d)){n.add(l);return}const u=c.defaultOptions?c.extension.configure(c.defaultOptions):c.extension;t.push(u),n.add(l),r.add(d)}),s.forEach(l=>{if(n.has(l))return;const c=Et[l];if(!c){console.warn(`Extension config not found for modifier: ${l}`);return}if(c.extension===null){n.add(l);return}const d=c.extension.name;if(r.has(d)){n.add(l);return}const u=c.defaultOptions?c.extension.configure(c.defaultOptions):c.extension;t.push(u),n.add(l),r.add(d)}),t.sort((l,c)=>{const d=Object.values(Et).find(m=>m?.extension?.name===l.name),u=Object.values(Et).find(m=>m?.extension?.name===c.name),f=d?.priority??100;return(u?.priority??100)-f})}const La={simple:["bold","italic","bulletList","orderedList","undo","redo"],blog:["bold","italic","underline",{type:"heading",level:2},{type:"heading",level:3},"textAlign","bulletList","orderedList","link","blockquote","undo","redo"],documentation:["bold","italic","strike","underline","code","clearMarks",{type:"heading",level:1},{type:"heading",level:2},{type:"heading",level:3},{type:"heading",level:4},{type:"heading",level:5},{type:"heading",level:6},"textAlign","bulletList","orderedList","taskList","link","textColor","highlight","codeBlock","blockquote","horizontalRule","hardBreak","undo","redo"],comment:["bold","italic","link","undo","redo"],full:["bold","italic","strike","underline","code","clearMarks",{type:"heading",level:1},{type:"heading",level:2},{type:"heading",level:3},{type:"heading",level:4},{type:"heading",level:5},{type:"heading",level:6},"textAlign","bulletList","orderedList","taskList","link","textColor","highlight","codeBlock","blockquote","horizontalRule","hardBreak","undo","redo"]},ue={fontFamily:{mono:'"JetBrains Mono", Consolas, monospace'},fontSize:{sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","4xl":"2.25rem"},fontWeight:{semibold:"600",bold:"700"},lineHeight:{tight:"1.25",normal:"1.5"}},Ye={brand:{primary:{DEFAULT:"#C14615"}},neutral:{gray:{100:"#F3F4F6",200:"#E5E7EB",300:"#D1D5DB",500:"#6B7280",800:"#1F2937"}},palettes:{warning:{200:"#fde68a"}}},oe={xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem"},lu={h1:`font-size: ${ue.fontSize["4xl"]}; font-weight: ${ue.fontWeight.semibold}; line-height: ${ue.lineHeight.tight}; margin: ${oe.md} 0 ${oe.sm} 0;`,h2:`font-size: ${ue.fontSize["2xl"]}; font-weight: ${ue.fontWeight.semibold}; line-height: ${ue.lineHeight.tight}; margin: ${oe.md} 0 ${oe.sm} 0;`,h3:`font-size: ${ue.fontSize.xl}; font-weight: ${ue.fontWeight.semibold}; line-height: ${ue.lineHeight.tight}; margin: ${oe.md} 0 ${oe.sm} 0;`,h4:`font-size: ${ue.fontSize.lg}; font-weight: ${ue.fontWeight.semibold}; line-height: ${ue.lineHeight.tight}; margin: ${oe.md} 0 ${oe.sm} 0;`,h5:`font-size: ${ue.fontSize.base}; font-weight: ${ue.fontWeight.semibold}; line-height: ${ue.lineHeight.tight}; margin: ${oe.md} 0 ${oe.sm} 0;`,h6:`font-size: ${ue.fontSize.sm}; font-weight: ${ue.fontWeight.semibold}; line-height: ${ue.lineHeight.tight}; margin: ${oe.md} 0 ${oe.sm} 0;`,p:`min-height: ${ue.lineHeight.normal}em; margin: 0;`,ul:`list-style-type: disc; list-style-position: outside; padding-left: ${oe.xl}; margin: ${oe.md} 0;`,ol:`list-style-type: decimal; list-style-position: outside; padding-left: ${oe.xl}; margin: ${oe.md} 0;`,li:`display: list-item; margin: ${oe.xs} 0;`,strong:`font-weight: ${ue.fontWeight.bold};`,em:"font-style: italic;",s:"text-decoration: line-through;",u:"text-decoration: underline;",code:`background-color: ${Ye.neutral.gray[100]}; border-radius: 0.4rem; font-size: ${ue.fontSize.sm}; padding: 0.25em 0.3em; font-family: ${ue.fontFamily.mono};`,pre:`background: ${Ye.neutral.gray[800]}; border-radius: ${oe.sm}; color: ${Ye.neutral.gray[100]}; font-family: ${ue.fontFamily.mono}; margin: ${oe.lg} 0; padding: 0.75rem ${oe.md}; overflow-x: auto;`,blockquote:`border-left: 3px solid ${Ye.neutral.gray[300]}; margin: ${oe.lg} 0; padding-left: ${oe.md}; color: ${Ye.neutral.gray[500]};`,hr:`border: none; border-top: 1px solid ${Ye.neutral.gray[200]}; margin: ${oe.xl} 0;`,a:`color: ${Ye.brand.primary.DEFAULT}; text-decoration: underline; cursor: pointer;`,mark:`background-color: ${Ye.palettes.warning[200]}; border-radius: ${oe.xs}; padding: 0 0.125rem;`,label:`display: flex; align-items: center; gap: ${oe.sm}; cursor: pointer;`,input:"cursor: pointer; margin: 0;"},ou={taskList:"list-style: none; padding-left: 0; margin: 1rem 0;",taskItem:"display: flex; align-items: flex-start; gap: 0.5rem; margin: 0.5rem 0;"};function cu(e){if(!e)return e;let t=e;for(const[n,r]of Object.entries(ou)){const s=new RegExp(`(<(?:ul|li)[^>]*data-type="${n}"[^>]*)>`,"gi");t=t.replace(s,(i,a)=>i.includes('style="')?i.replace(/style="([^"]*)"/,`style="$1 ${r}"`):`${a} style="${r}">`)}for(const[n,r]of Object.entries(lu)){const s=new RegExp(`<${n}(\\s[^>]*)?>`,"gi");t=t.replace(s,i=>{if(i.includes('data-type="taskList"')||i.includes('data-type="taskItem"'))return i;if(i.includes('style="'))return i.replace(/style="([^"]*)"/,`style="$1 ${r}"`);if(i.includes("style='"))return i.replace(/style='([^']*)'/,`style='$1 ${r}'`);{const a=i.indexOf(">");return`${i.slice(0,a)} style="${r}"${i.slice(a)}`}})}return t}const du=({modifiers:e,zoom:t,onZoomChange:n,onToolbarAction:r})=>{const{editor:s}=Rr.useCurrentEditor();return o.jsx(Qo,{editor:s,modifiers:e,zoom:t,onZoomChange:n,onToolbarAction:r})},uu=({showCharacterCount:e,showWordCount:t})=>{const{editor:n}=Rr.useCurrentEditor();if(!n||!e&&!t)return null;const r=n.getText(),s=r.length,i=r.split(/\s+/).filter(a=>a.length>0).length;return o.jsxs("div",{className:"flex gap-4 text-xs text-default-500 px-2 pb-1",children:[e&&o.jsxs("span",{children:[s," characters"]}),t&&o.jsxs("span",{children:[i," words"]})]})},Ar=y.forwardRef((e,t)=>{const{minRows:n=10,maxRows:r=30,disableAutosize:s=!1,showCharacterCount:i=!1,showWordCount:a=!1,showToolbar:l=!0,modifiers:c=La.full,variant:d="bordered",initialContent:u,content:f,onContentChange:p,onUpdate:m,onToolbarAction:v,isReadOnly:b=!1,isDisabled:x=!1,includeInlineStyles:w=!0,...N}=e,{zoom:A,setZoom:S}=Jo(),j=Cs.lineHeight,M=n*j,D=s?void 0:r*j,B=y.useMemo(()=>au(c),[c]),{Component:F,label:_,shouldLabelBeOutside:I,getBaseProps:E,getLabelProps:O,getInputWrapperProps:P}=h.useInput({...N,variant:d,ref:t,isMultiline:!0}),K=_?o.jsx("label",{...O(),children:_}):null,Z=y.useCallback(({editor:J})=>{const le=J.getHTML(),se=w?cu(le):le,fe=J.getJSON(),Y=J.getText(),W=Y.length,de=Y.split(/\s+/).filter(Me=>Me.length>0).length,ie={html:se,json:fe,text:Y,characters:W,words:de};if(p?.(ie),m?.(ie),"onChange"in N&&typeof N.onChange=="function"){const Me={target:{value:se},currentTarget:{value:se}};N.onChange(Me)}},[p,m,N,w]);return o.jsxs(F,{...E(),children:[I?K:null,o.jsx("div",{...P(),className:h.cn(P().className,"flex flex-col w-full p-0 gap-0 rich-text-editor"),style:{maxHeight:D?`${D+Cs.toolbarHeight}px`:void 0,overflow:D?"auto":void 0},children:o.jsx(Rr.EditorProvider,{editable:!b&&!x,slotBefore:l?o.jsx(du,{modifiers:c,zoom:A,onZoomChange:S,onToolbarAction:v}):void 0,slotAfter:o.jsx(uu,{showCharacterCount:i,showWordCount:a}),editorContainerProps:{className:"w-full flex-1 outline-none",style:{minHeight:`${M}px`,fontSize:`${A}%`,display:"flex",flexDirection:"column"}},editorProps:{attributes:{class:"focus:outline-none w-full h-full"}},extensions:B,content:f||u||e.defaultValue||"",onUpdate:Z})})]})});Ar.displayName="TipTapEditor";const Fa=y.forwardRef((e,t)=>{const{adapter:n="tiptap",variant:r="bordered",...s}=e;return n==="tiptap"?o.jsx(Ar,{...s,variant:r,ref:t}):(console.warn(`Adapter "${n}" is not supported. Using TipTap.`),o.jsx(Ar,{...s,variant:r,ref:t}))});Fa.displayName="RichTextArea";function fu(e,t="en-US",n="USD"){try{return new Intl.NumberFormat(t,{style:"currency",currency:n,minimumFractionDigits:0,maximumFractionDigits:2}).format(e)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${e.toFixed(2)}`}}const ii=[{id:"100",amount:100},{id:"250",amount:250},{id:"500",amount:500},{id:"1000",amount:1e3},{id:"2000",amount:2e3}],hu={title:"Donation Amount",customAmountPlaceholder:"Custom donation amount",customAmountAriaLabel:"Custom donation amount",addDonationButton:"Add Donation"},Pa=({presetAmounts:e=ii,selectedDonation:t,defaultSelectedDonation:n=null,onChange:r,onAddDonation:s,currency:i="USD",locale:a="en-US",showCustomAmount:l=!0,minCustomAmount:c=.5,maxCustomAmount:d=1e6,labels:u,mobileColumns:f=2,desktopColumns:p=3,isDisabled:m=!1,buttonVariant:v="bordered",buttonColor:b="default",inputVariant:x="bordered",size:w="md",className:N="",showCard:A=!0})=>{const S={...hu,...u},j=Array.isArray(e)?e:ii,M={2:"grid-cols-2",3:"grid-cols-3"},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]}`,[F,_]=zr(t,n,r),[I,E]=y.useState(""),[O,P]=y.useState(!1),[K,Z]=y.useState(0),J=y.useCallback(W=>{if(m)return;const de={amount:W.amount,isCustom:!1,presetId:W.id};_(de),E(""),P(!1),Z(ie=>ie+1),s?.(de)},[m,_,s]),le=y.useCallback(W=>{if(m)return;if(E(W!==void 0?String(W):""),s){_(null);return}if(W===void 0||isNaN(W)){_(null);return}_({amount:W,isCustom:!0})},[m,_,s]),se=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]),fe=y.useMemo(()=>({style:"currency",currency:i,currencyDisplay:"symbol"}),[i]),Y=o.jsxs("div",{className:"space-y-4","data-testid":"donation-amounts-root",children:[S.title&&o.jsx("h2",{className:"text-base font-semibold","data-testid":"donation-amounts-title",children:S.title}),j.length>0&&o.jsx("div",{className:h.cn("grid gap-3",B),"data-testid":"donation-amounts-presets",children:j.map(W=>{const de=F!==null&&!F.isCustom&&F.presetId===W.id;return o.jsx(q,{color:de?"primary":b,variant:de?"solid":v,className:"w-full",onPress:()=>J(W),isDisabled:m,"data-testid":`donation-amounts-preset-${W.id}`,children:W.label||fu(W.amount,a,i)},W.id)})}),l&&o.jsxs("div",{className:"flex gap-3 items-start",children:[o.jsx(h.NumberInput,{placeholder:S.customAmountPlaceholder,"aria-label":S.customAmountAriaLabel,onInput:s?()=>{_(null),P(!0)}:void 0,variant:x,radius:"full",size:w,minValue:c,maxValue:d,step:.01,formatOptions:fe,value:I!==""?parseFloat(I):void 0,onValueChange:le,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}`:F?.isCustom===!1?F.presetId:"custom"),s&&o.jsx(q,{color:"primary",variant:"solid",radius:"full",size:w,className:"shrink-0",onPress:se,isDisabled:m||!O,"data-testid":"donation-amounts-add-button",children:S.addDonationButton})]})]});return A?o.jsx(h.Card,{className:h.cn("w-full",N),"data-testid":"donation-amounts-card",children:o.jsx(h.CardBody,{children:Y})}):o.jsx("div",{className:h.cn("w-full",N),"data-testid":"donation-amounts-plain",children:Y})};Pa.displayName="DonationAmounts";const mu=e=>{const t=Math.max(0,e),n=Math.floor(t/60).toString().padStart(2,"0"),r=(t%60).toString().padStart(2,"0");return`${n}:${r} minutes`},pu=e=>{switch(e){case"warning":return U.Clock;case"error":return U.AlertCircle;case"success":return U.CheckCircle;default:return U.Clock}},gu=e=>{switch(e){case"primary":return"bg-primary-500";case"secondary":return"bg-gray-700";case"success":return"bg-green-600";case"warning":return"bg-amber-500";case"danger":return"bg-red-600";default:return"bg-primary-500"}},Ra=y.forwardRef(({timeLeft:e,defaultTimeLeft:t=1200,onTimeChange:n,onExpire:r,variant:s="info",color:i="primary",message:a="Your cart expires in:",showIcon:l=!0,icon:c,position:d="fixed",autoStart:u=!0,formatTime:f=mu,className:p,...m},v)=>{const[b,x]=zr(e!==void 0?Math.max(0,e):void 0,Math.max(0,t),n),w=y.useRef(null),N=y.useRef(!1);y.useEffect(()=>()=>{w.current&&clearInterval(w.current)},[]),y.useEffect(()=>{if(!u||b<=0){w.current&&(clearInterval(w.current),w.current=null);return}return w.current=setInterval(()=>{x(M=>M<=1?(w.current&&(clearInterval(w.current),w.current=null),N.current||(N.current=!0,r?.()),0):M-1)},1e3),()=>{w.current&&(clearInterval(w.current),w.current=null)}},[u,b,x,r]),y.useEffect(()=>{b>0&&(N.current=!1)},[b]);const A=c||pu(s),S=gu(i),j={fixed:"fixed top-0 left-0",sticky:"sticky top-0",static:"static"};return o.jsx("div",{ref:v,role:"banner","aria-live":"polite","aria-label":`${a} ${f(b)}`,"data-testid":"expire-cart-timer",className:h.cn("w-full text-white z-50",S,j[d],p),...m,children:o.jsx("div",{className:"container mx-auto px-4 py-3 sm:py-2.5","data-testid":"expire-cart-timer-container",children:o.jsxs("div",{className:"flex items-center justify-between gap-3 sm:gap-4",children:[o.jsxs("div",{className:"flex items-center gap-3 sm:gap-2.5 flex-1 min-w-0","data-testid":"expire-cart-timer-left",children:[l&&o.jsx("div",{className:"flex-shrink-0 w-[0.875rem] h-[0.875rem] sm:w-4 sm:h-4 rounded-full bg-white flex items-center justify-center overflow-hidden","data-testid":"expire-cart-timer-icon-wrapper",children:o.jsx(A,{className:"text-primary-500 sm:text-primary-600","aria-hidden":"true",size:14,"data-testid":"expire-cart-timer-icon"})}),o.jsx("p",{className:"text-sm sm:text-base font-medium text-white","data-testid":"expire-cart-timer-message",children:a})]}),o.jsx("div",{className:"flex-shrink-0","data-testid":"expire-cart-timer-right",children:o.jsx("span",{className:"text-sm sm:text-base font-semibold text-white","aria-label":`Time remaining: ${f(b)}`,"data-testid":"expire-cart-timer-value",children:f(b)})})]})})})});Ra.displayName="ExpireCartTimer";function xu(e,t){const n=e.icons,r=e.aliases||Object.create(null),s=Object.create(null);function i(a){if(n[a])return s[a]=[];if(!(a in s)){s[a]=null;const l=r[a]&&r[a].parent,c=l&&i(l);c&&(s[a]=[l].concat(c))}return s[a]}return Object.keys(n).concat(Object.keys(r)).forEach(i),s}const za=Object.freeze({left:0,top:0,width:16,height:16}),kn=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),Xr=Object.freeze({...za,...kn}),Mr=Object.freeze({...Xr,body:"",hidden:!1});function yu(e,t){const n={};!e.hFlip!=!t.hFlip&&(n.hFlip=!0),!e.vFlip!=!t.vFlip&&(n.vFlip=!0);const r=((e.rotate||0)+(t.rotate||0))%4;return r&&(n.rotate=r),n}function ai(e,t){const n=yu(e,t);for(const r in Mr)r in kn?r in e&&!(r in n)&&(n[r]=kn[r]):r in t?n[r]=t[r]:r in e&&(n[r]=e[r]);return n}function bu(e,t,n){const r=e.icons,s=e.aliases||Object.create(null);let i={};function a(l){i=ai(r[l]||s[l],i)}return a(t),n.forEach(a),ai(e,i)}function Ba(e,t){const n=[];if(typeof e!="object"||typeof e.icons!="object")return n;e.not_found instanceof Array&&e.not_found.forEach(s=>{t(s,null),n.push(s)});const r=xu(e);for(const s in r){const i=r[s];i&&(t(s,bu(e,s,i)),n.push(s))}return n}const vu={provider:"",aliases:{},not_found:{},...za};function sr(e,t){for(const n in t)if(n in e&&typeof e[n]!=typeof t[n])return!1;return!0}function _a(e){if(typeof e!="object"||e===null)return null;const t=e;if(typeof t.prefix!="string"||!e.icons||typeof e.icons!="object"||!sr(e,vu))return null;const n=t.icons;for(const s in n){const i=n[s];if(!s||typeof i.body!="string"||!sr(i,Mr))return null}const r=t.aliases||Object.create(null);for(const s in r){const i=r[s],a=i.parent;if(!s||typeof a!="string"||!n[a]&&!r[a]||!sr(i,Mr))return null}return t}const li=Object.create(null);function wu(e,t){return{provider:e,prefix:t,icons:Object.create(null),missing:new Set}}function jt(e,t){const n=li[e]||(li[e]=Object.create(null));return n[t]||(n[t]=wu(e,t))}function Va(e,t){return _a(t)?Ba(t,(n,r)=>{r?e.icons[n]=r:e.missing.add(n)}):[]}function ku(e,t,n){try{if(typeof n.body=="string")return e.icons[t]={...n},!0}catch{}return!1}const Ha=/^[a-z0-9]+(-[a-z0-9]+)*$/,Ln=(e,t,n,r="")=>{const s=e.split(":");if(e.slice(0,1)==="@"){if(s.length<2||s.length>3)return null;r=s.shift().slice(1)}if(s.length>3||!s.length)return null;if(s.length>1){const l=s.pop(),c=s.pop(),d={provider:s.length>0?s[0]:r,prefix:c,name:l};return t&&!cn(d)?null:d}const i=s[0],a=i.split("-");if(a.length>1){const l={provider:r,prefix:a.shift(),name:a.join("-")};return t&&!cn(l)?null:l}if(n&&r===""){const l={provider:r,prefix:"",name:i};return t&&!cn(l,n)?null:l}return null},cn=(e,t)=>e?!!((t&&e.prefix===""||e.prefix)&&e.name):!1;let Wt=!1;function Ua(e){return typeof e=="boolean"&&(Wt=e),Wt}function oi(e){const t=typeof e=="string"?Ln(e,!0,Wt):e;if(t){const n=jt(t.provider,t.prefix),r=t.name;return n.icons[r]||(n.missing.has(r)?null:void 0)}}function Nu(e,t){const n=Ln(e,!0,Wt);if(!n)return!1;const r=jt(n.provider,n.prefix);return t?ku(r,n.name,t):(r.missing.add(n.name),!0)}function Su(e,t){if(typeof e!="object")return!1;if(typeof t!="string"&&(t=e.provider||""),Wt&&!t&&!e.prefix){let s=!1;return _a(e)&&(e.prefix="",Ba(e,(i,a)=>{Nu(i,a)&&(s=!0)})),s}const n=e.prefix;if(!cn({prefix:n,name:"a"}))return!1;const r=jt(t,n);return!!Va(r,e)}const qa=Object.freeze({width:null,height:null}),Wa=Object.freeze({...qa,...kn}),Cu=/(-?[0-9.]*[0-9]+[0-9.]*)/g,ju=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function ci(e,t,n){if(t===1)return e;if(n=n||100,typeof e=="number")return Math.ceil(e*t*n)/n;if(typeof e!="string")return e;const r=e.split(Cu);if(r===null||!r.length)return e;const s=[];let i=r.shift(),a=ju.test(i);for(;;){if(a){const l=parseFloat(i);isNaN(l)?s.push(i):s.push(Math.ceil(l*t*n)/n)}else s.push(i);if(i=r.shift(),i===void 0)return s.join("");a=!a}}function Au(e,t="defs"){let n="";const r=e.indexOf("<"+t);for(;r>=0;){const s=e.indexOf(">",r),i=e.indexOf("</"+t);if(s===-1||i===-1)break;const a=e.indexOf(">",i);if(a===-1)break;n+=e.slice(s+1,i).trim(),e=e.slice(0,r).trim()+e.slice(a+1)}return{defs:n,content:e}}function Mu(e,t){return e?"<defs>"+e+"</defs>"+t:t}function Eu(e,t,n){const r=Au(e);return Mu(r.defs,t+r.content+n)}const Tu=e=>e==="unset"||e==="undefined"||e==="none";function Du(e,t){const n={...Xr,...e},r={...Wa,...t},s={left:n.left,top:n.top,width:n.width,height:n.height};let i=n.body;[n,r].forEach(b=>{const x=[],w=b.hFlip,N=b.vFlip;let A=b.rotate;w?N?A+=2:(x.push("translate("+(s.width+s.left).toString()+" "+(0-s.top).toString()+")"),x.push("scale(-1 1)"),s.top=s.left=0):N&&(x.push("translate("+(0-s.left).toString()+" "+(s.height+s.top).toString()+")"),x.push("scale(1 -1)"),s.top=s.left=0);let S;switch(A<0&&(A-=Math.floor(A/4)*4),A=A%4,A){case 1:S=s.height/2+s.top,x.unshift("rotate(90 "+S.toString()+" "+S.toString()+")");break;case 2:x.unshift("rotate(180 "+(s.width/2+s.left).toString()+" "+(s.height/2+s.top).toString()+")");break;case 3:S=s.width/2+s.left,x.unshift("rotate(-90 "+S.toString()+" "+S.toString()+")");break}A%2===1&&(s.left!==s.top&&(S=s.left,s.left=s.top,s.top=S),s.width!==s.height&&(S=s.width,s.width=s.height,s.height=S)),x.length&&(i=Eu(i,'<g transform="'+x.join(" ")+'">',"</g>"))});const a=r.width,l=r.height,c=s.width,d=s.height;let u,f;a===null?(f=l===null?"1em":l==="auto"?d:l,u=ci(f,c/d)):(u=a==="auto"?c:a,f=l===null?ci(u,d/c):l==="auto"?d:l);const p={},m=(b,x)=>{Tu(x)||(p[b]=x.toString())};m("width",u),m("height",f);const v=[s.left,s.top,c,d];return p.viewBox=v.join(" "),{attributes:p,viewBox:v,body:i}}const Iu=/\sid="(\S+)"/g,$u="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let Ou=0;function Lu(e,t=$u){const n=[];let r;for(;r=Iu.exec(e);)n.push(r[1]);if(!n.length)return e;const s="suffix"+(Math.random()*16777216|Date.now()).toString(16);return n.forEach(i=>{const a=typeof t=="function"?t(i):t+(Ou++).toString(),l=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e=e.replace(new RegExp('([#;"])('+l+')([")]|\\.[a-z])',"g"),"$1"+a+s+"$3")}),e=e.replace(new RegExp(s,"g"),""),e}const Er=Object.create(null);function Fu(e,t){Er[e]=t}function Tr(e){return Er[e]||Er[""]}function es(e){let t;if(typeof e.resources=="string")t=[e.resources];else if(t=e.resources,!(t instanceof Array)||!t.length)return null;return{resources:t,path:e.path||"/",maxURL:e.maxURL||500,rotate:e.rotate||750,timeout:e.timeout||5e3,random:e.random===!0,index:e.index||0,dataAfterTimeout:e.dataAfterTimeout!==!1}}const ts=Object.create(null),Tt=["https://api.simplesvg.com","https://api.unisvg.com"],dn=[];for(;Tt.length>0;)Tt.length===1||Math.random()>.5?dn.push(Tt.shift()):dn.push(Tt.pop());ts[""]=es({resources:["https://api.iconify.design"].concat(dn)});function Pu(e,t){const n=es(t);return n===null?!1:(ts[e]=n,!0)}function ns(e){return ts[e]}const Ru=()=>{let e;try{if(e=fetch,typeof e=="function")return e}catch{}};let di=Ru();function zu(e,t){const n=ns(e);if(!n)return 0;let r;if(!n.maxURL)r=0;else{let s=0;n.resources.forEach(a=>{s=Math.max(s,a.length)});const i=t+".json?icons=";r=n.maxURL-s-n.path.length-i.length}return r}function Bu(e){return e===404}const _u=(e,t,n)=>{const r=[],s=zu(e,t),i="icons";let a={type:i,provider:e,prefix:t,icons:[]},l=0;return n.forEach((c,d)=>{l+=c.length+1,l>=s&&d>0&&(r.push(a),a={type:i,provider:e,prefix:t,icons:[]},l=c.length),a.icons.push(c)}),r.push(a),r};function Vu(e){if(typeof e=="string"){const t=ns(e);if(t)return t.path}return"/"}const Hu=(e,t,n)=>{if(!di){n("abort",424);return}let r=Vu(t.provider);switch(t.type){case"icons":{const i=t.prefix,l=t.icons.join(","),c=new URLSearchParams({icons:l});r+=i+".json?"+c.toString();break}case"custom":{const i=t.uri;r+=i.slice(0,1)==="/"?i.slice(1):i;break}default:n("abort",400);return}let s=503;di(e+r).then(i=>{const a=i.status;if(a!==200){setTimeout(()=>{n(Bu(a)?"abort":"next",a)});return}return s=501,i.json()}).then(i=>{if(typeof i!="object"||i===null){setTimeout(()=>{i===404?n("abort",i):n("next",s)});return}setTimeout(()=>{n("success",i)})}).catch(()=>{n("next",s)})},Uu={prepare:_u,send:Hu};function Ka(e,t){e.forEach(n=>{const r=n.loaderCallbacks;r&&(n.loaderCallbacks=r.filter(s=>s.id!==t))})}function qu(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout(()=>{e.pendingCallbacksFlag=!1;const t=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!t.length)return;let n=!1;const r=e.provider,s=e.prefix;t.forEach(i=>{const a=i.icons,l=a.pending.length;a.pending=a.pending.filter(c=>{if(c.prefix!==s)return!0;const d=c.name;if(e.icons[d])a.loaded.push({provider:r,prefix:s,name:d});else if(e.missing.has(d))a.missing.push({provider:r,prefix:s,name:d});else return n=!0,!0;return!1}),a.pending.length!==l&&(n||Ka([e],i.id),i.callback(a.loaded.slice(0),a.missing.slice(0),a.pending.slice(0),i.abort))})}))}let Wu=0;function Ku(e,t,n){const r=Wu++,s=Ka.bind(null,n,r);if(!t.pending.length)return s;const i={id:r,icons:t,callback:e,abort:s};return n.forEach(a=>{(a.loaderCallbacks||(a.loaderCallbacks=[])).push(i)}),s}function Ju(e){const t={loaded:[],missing:[],pending:[]},n=Object.create(null);e.sort((s,i)=>s.provider!==i.provider?s.provider.localeCompare(i.provider):s.prefix!==i.prefix?s.prefix.localeCompare(i.prefix):s.name.localeCompare(i.name));let r={provider:"",prefix:"",name:""};return e.forEach(s=>{if(r.name===s.name&&r.prefix===s.prefix&&r.provider===s.provider)return;r=s;const i=s.provider,a=s.prefix,l=s.name,c=n[i]||(n[i]=Object.create(null)),d=c[a]||(c[a]=jt(i,a));let u;l in d.icons?u=t.loaded:a===""||d.missing.has(l)?u=t.missing:u=t.pending;const f={provider:i,prefix:a,name:l};u.push(f)}),t}function Yu(e,t=!0,n=!1){const r=[];return e.forEach(s=>{const i=typeof s=="string"?Ln(s,t,n):s;i&&r.push(i)}),r}const Gu={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function Qu(e,t,n,r){const s=e.resources.length,i=e.random?Math.floor(Math.random()*s):e.index;let a;if(e.random){let M=e.resources.slice(0);for(a=[];M.length>1;){const 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=e.resources.slice(i).concat(e.resources.slice(0,i));const l=Date.now();let c="pending",d=0,u,f=null,p=[],m=[];typeof r=="function"&&m.push(r);function v(){f&&(clearTimeout(f),f=null)}function b(){c==="pending"&&(c="aborted"),v(),p.forEach(M=>{M.status==="pending"&&(M.status="aborted")}),p=[]}function x(M,D){D&&(m=[]),typeof M=="function"&&m.push(M)}function w(){return{startTime:l,payload:t,status:c,queriesSent:d,queriesPending:p.length,subscribe:x,abort:b}}function N(){c="failed",m.forEach(M=>{M(void 0,u)})}function A(){p.forEach(M=>{M.status==="pending"&&(M.status="aborted")}),p=[]}function S(M,D,B){const F=D!=="success";switch(p=p.filter(_=>_!==M),c){case"pending":break;case"failed":if(F||!e.dataAfterTimeout)return;break;default:return}if(D==="abort"){u=B,N();return}if(F){u=B,p.length||(a.length?j():N());return}if(v(),A(),!e.random){const _=e.resources.indexOf(M.resource);_!==-1&&_!==e.index&&(e.index=_)}c="completed",m.forEach(_=>{_(B)})}function j(){if(c!=="pending")return;v();const M=a.shift();if(M===void 0){if(p.length){f=setTimeout(()=>{v(),c==="pending"&&(A(),N())},e.timeout);return}N();return}const D={status:"pending",resource:M,callback:(B,F)=>{S(D,B,F)}};p.push(D),d++,f=setTimeout(j,e.rotate),n(M,t,D.callback)}return setTimeout(j),w}function Ja(e){const t={...Gu,...e};let n=[];function r(){n=n.filter(l=>l().status==="pending")}function s(l,c,d){const u=Qu(t,l,c,(f,p)=>{r(),d&&d(f,p)});return n.push(u),u}function i(l){return n.find(c=>l(c))||null}return{query:s,find:i,setIndex:l=>{t.index=l},getIndex:()=>t.index,cleanup:r}}function ui(){}const ir=Object.create(null);function Zu(e){if(!ir[e]){const t=ns(e);if(!t)return;const n=Ja(t),r={config:t,redundancy:n};ir[e]=r}return ir[e]}function Xu(e,t,n){let r,s;if(typeof e=="string"){const i=Tr(e);if(!i)return n(void 0,424),ui;s=i.send;const a=Zu(e);a&&(r=a.redundancy)}else{const i=es(e);if(i){r=Ja(i);const a=e.resources?e.resources[0]:"",l=Tr(a);l&&(s=l.send)}}return!r||!s?(n(void 0,424),ui):r.query(t,s,n)().abort}function fi(){}function ef(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout(()=>{e.iconsLoaderFlag=!1,qu(e)}))}function tf(e){const t=[],n=[];return e.forEach(r=>{(r.match(Ha)?t:n).push(r)}),{valid:t,invalid:n}}function Dt(e,t,n){function r(){const s=e.pendingIcons;t.forEach(i=>{s&&s.delete(i),e.icons[i]||e.missing.add(i)})}if(n&&typeof n=="object")try{if(!Va(e,n).length){r();return}}catch(s){console.error(s)}r(),ef(e)}function hi(e,t){e instanceof Promise?e.then(n=>{t(n)}).catch(()=>{t(null)}):t(e)}function nf(e,t){e.iconsToLoad?e.iconsToLoad=e.iconsToLoad.concat(t).sort():e.iconsToLoad=t,e.iconsQueueFlag||(e.iconsQueueFlag=!0,setTimeout(()=>{e.iconsQueueFlag=!1;const{provider:n,prefix:r}=e,s=e.iconsToLoad;if(delete e.iconsToLoad,!s||!s.length)return;const i=e.loadIcon;if(e.loadIcons&&(s.length>1||!i)){hi(e.loadIcons(s,r,n),u=>{Dt(e,s,u)});return}if(i){s.forEach(u=>{const f=i(u,r,n);hi(f,p=>{const m=p?{prefix:r,icons:{[u]:p}}:null;Dt(e,[u],m)})});return}const{valid:a,invalid:l}=tf(s);if(l.length&&Dt(e,l,null),!a.length)return;const c=r.match(Ha)?Tr(n):null;if(!c){Dt(e,a,null);return}c.prepare(n,r,a).forEach(u=>{Xu(n,u,f=>{Dt(e,u.icons,f)})})}))}const rf=(e,t)=>{const n=Yu(e,!0,Ua()),r=Ju(n);if(!r.pending.length){let c=!0;return t&&setTimeout(()=>{c&&t(r.loaded,r.missing,r.pending,fi)}),()=>{c=!1}}const s=Object.create(null),i=[];let a,l;return r.pending.forEach(c=>{const{provider:d,prefix:u}=c;if(u===l&&d===a)return;a=d,l=u,i.push(jt(d,u));const f=s[d]||(s[d]=Object.create(null));f[u]||(f[u]=[])}),r.pending.forEach(c=>{const{provider:d,prefix:u,name:f}=c,p=jt(d,u),m=p.pendingIcons||(p.pendingIcons=new Set);m.has(f)||(m.add(f),s[d][u].push(f))}),i.forEach(c=>{const d=s[c.provider][c.prefix];d.length&&nf(c,d)}),t?Ku(t,r,i):fi};function sf(e,t){const n={...e};for(const r in t){const s=t[r],i=typeof s;r in qa?(s===null||s&&(i==="string"||i==="number"))&&(n[r]=s):i===typeof n[r]&&(n[r]=r==="rotate"?s%4:s)}return n}const af=/[\s,]+/;function lf(e,t){t.split(af).forEach(n=>{switch(n.trim()){case"horizontal":e.hFlip=!0;break;case"vertical":e.vFlip=!0;break}})}function of(e,t=0){const n=e.replace(/^-?[0-9.]*/,"");function r(s){for(;s<0;)s+=4;return s%4}if(n===""){const s=parseInt(e);return isNaN(s)?0:r(s)}else if(n!==e){let s=0;switch(n){case"%":s=25;break;case"deg":s=90}if(s){let i=parseFloat(e.slice(0,e.length-n.length));return isNaN(i)?0:(i=i/s,i%1===0?r(i):0)}}return t}function cf(e,t){let n=e.indexOf("xlink:")===-1?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const r in t)n+=" "+r+'="'+t[r]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+n+">"+e+"</svg>"}function df(e){return e.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function uf(e){return"data:image/svg+xml,"+df(e)}function ff(e){return'url("'+uf(e)+'")'}let Pt;function hf(){try{Pt=window.trustedTypes.createPolicy("iconify",{createHTML:e=>e})}catch{Pt=null}}function mf(e){return Pt===void 0&&hf(),Pt?Pt.createHTML(e):e}const Ya={...Wa,inline:!1},pf={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},gf={display:"inline-block"},Dr={backgroundColor:"currentColor"},Ga={backgroundColor:"transparent"},mi={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},pi={WebkitMask:Dr,mask:Dr,background:Ga};for(const e in pi){const t=pi[e];for(const n in mi)t[e+n]=mi[n]}const xf={...Ya,inline:!0};function gi(e){return e+(e.match(/^[-0-9.]+$/)?"px":"")}const yf=(e,t,n)=>{const r=t.inline?xf:Ya,s=sf(r,t),i=t.mode||"svg",a={},l=t.style||{},c={...i==="svg"?pf:{}};if(n){const x=Ln(n,!1,!0);if(x){const w=["iconify"],N=["provider","prefix"];for(const A of N)x[A]&&w.push("iconify--"+x[A]);c.className=w.join(" ")}}for(let x in t){const w=t[x];if(w!==void 0)switch(x){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":c.ref=w;break;case"className":c[x]=(c[x]?c[x]+" ":"")+w;break;case"inline":case"hFlip":case"vFlip":s[x]=w===!0||w==="true"||w===1;break;case"flip":typeof w=="string"&&lf(s,w);break;case"color":a.color=w;break;case"rotate":typeof w=="string"?s[x]=of(w):typeof w=="number"&&(s[x]=w);break;case"ariaHidden":case"aria-hidden":w!==!0&&w!=="true"&&delete c["aria-hidden"];break;default:r[x]===void 0&&(c[x]=w)}}const d=Du(e,s),u=d.attributes;if(s.inline&&(a.verticalAlign="-0.125em"),i==="svg"){c.style={...a,...l},Object.assign(c,u);let x=0,w=t.id;return typeof w=="string"&&(w=w.replace(/-/g,"_")),c.dangerouslySetInnerHTML={__html:mf(Lu(d.body,w?()=>w+"ID"+x++:"iconifyReact"))},y.createElement("svg",c)}const{body:f,width:p,height:m}=e,v=i==="mask"||(i==="bg"?!1:f.indexOf("currentColor")!==-1),b=cf(f,{...u,width:p+"",height:m+""});return c.style={...a,"--svg":ff(b),width:gi(u.width),height:gi(u.height),...gf,...v?Dr:Ga,...l},y.createElement("span",c)};Ua(!0);Fu("",Uu);if(typeof document<"u"&&typeof window<"u"){const e=window;if(e.IconifyPreload!==void 0){const t=e.IconifyPreload,n="Invalid IconifyPreload syntax.";typeof t=="object"&&t!==null&&(t instanceof Array?t:[t]).forEach(r=>{try{(typeof r!="object"||r===null||r instanceof Array||typeof r.icons!="object"||typeof r.prefix!="string"||!Su(r))&&console.error(n)}catch{console.error(n)}})}if(e.IconifyProviders!==void 0){const t=e.IconifyProviders;if(typeof t=="object"&&t!==null)for(let n in t){const r="IconifyProviders["+n+"] is invalid.";try{const s=t[n];if(typeof s!="object"||!s||s.resources===void 0)continue;Pu(n,s)||console.error(r)}catch{console.error(r)}}}}function Qa(e){const[t,n]=y.useState(!!e.ssr),[r,s]=y.useState({});function i(m){if(m){const v=e.icon;if(typeof v=="object")return{name:"",data:v};const b=oi(v);if(b)return{name:v,data:b}}return{name:""}}const[a,l]=y.useState(i(!!e.ssr));function c(){const m=r.callback;m&&(m(),s({}))}function d(m){if(JSON.stringify(a)!==JSON.stringify(m))return c(),l(m),!0}function u(){var m;const v=e.icon;if(typeof v=="object"){d({name:"",data:v});return}const b=oi(v);if(d({name:v,data:b}))if(b===void 0){const x=rf([v],u);s({callback:x})}else b&&((m=e.onLoad)===null||m===void 0||m.call(e,v))}y.useEffect(()=>(n(!0),c),[]),y.useEffect(()=>{t&&u()},[e.icon,t]);const{name:f,data:p}=a;return p?yf({...Xr,...p},e,f):e.children?e.children:e.fallback?e.fallback:y.createElement("span",{})}const H=y.forwardRef((e,t)=>Qa({...e,_ref:t}));y.forwardRef((e,t)=>Qa({inline:!0,...e,_ref:t}));const ar=({icon:e,children:t,testId:n})=>o.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600","data-testid":n,children:[o.jsx(H,{icon:e,width:20,className:"text-default-500"}),o.jsx("span",{children:t})]}),bf=({classes:e="",name:t,imageUrl:n,eventDate:r,eventTime:s,location:i,description:a,showImage:l=!1,imageLoading:c="eager",showMoreButtonClassName:d,labels:u})=>{const[f,p]=y.useState(!1),[m,v]=y.useState(!1),b=y.useRef(null);return y.useEffect(()=>{const x=()=>{if(b.current){const w=b.current.scrollHeight>b.current.clientHeight;v(w)}};return x(),window.addEventListener("resize",x),()=>window.removeEventListener("resize",x)},[a]),o.jsxs(h.Card,{className:h.cn("border-0 shadow-none",e),"data-testid":"event-details-root",children:[o.jsxs(h.CardHeader,{className:"pt-2 pb-0 flex-col items-start space-y-2","data-testid":"event-details-header",children:[l&&n&&o.jsx("div",{className:"w-full aspect-[3/1] overflow-hidden rounded-xl","data-testid":"event-details-image-wrapper",children:o.jsx(h.Image,{removeWrapper:!0,loading:c,alt:`Event image for ${t}`,className:"w-full h-full object-cover object-center",src:n,"data-testid":"event-details-image"})}),o.jsx("h2",{className:"font-semibold text-xl text-gray-800","data-testid":"event-details-title",children:t})]}),o.jsxs(h.CardBody,{className:"py-3 space-y-3","data-testid":"event-details-body",children:[o.jsx("h3",{className:"font-semibold text-base text-gray-700","data-testid":"event-details-info-label",children:u.eventInformation}),o.jsxs("div",{className:"flex flex-wrap gap-4","data-testid":"event-details-info",children:[r&&o.jsx(ar,{icon:"solar:calendar-minimalistic-linear",testId:"event-details-date",children:r}),s&&o.jsx(ar,{icon:"solar:clock-circle-linear",testId:"event-details-time",children:s}),i&&o.jsx(ar,{icon:"solar:map-point-linear",testId:"event-details-location",children:i})]}),a&&o.jsxs("div",{className:"relative","data-testid":"event-details-description-wrapper",children:[o.jsxs("div",{className:"relative",children:[o.jsx("div",{ref:b,className:h.cn("text-sm text-gray-700 leading-relaxed transition-all",!f&&"line-clamp-3"),"data-testid":"event-details-description",dangerouslySetInnerHTML:{__html:a}}),!f&&m&&o.jsx("div",{className:"absolute inset-x-0 -bottom-1 h-8 bg-gradient-to-t from-white via-white/70 to-transparent pointer-events-none","data-testid":"event-details-description-fade"})]}),(m||f)&&o.jsx("div",{className:"flex justify-end mt-1",children:o.jsx(q,{onPress:()=>p(!f),variant:"light",className:h.cn("text-primary",d),startContent:o.jsx(H,{icon:f?"solar:eye-closed-linear":"solar:eye-linear",width:20}),"data-testid":"event-details-toggle-description",children:f?u.showLess||"Hide":u.showMore||"Show"})})]})]})]})};function Za(e,t="en-US",n="USD"){try{return new Intl.NumberFormat(t,{style:"currency",currency:n,minimumFractionDigits:2,maximumFractionDigits:2}).format(e)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${e.toFixed(2)}`}}function vf(e){const t=e.replace(/[^\d.,-]/g,""),n=t.match(/,\d{1,2}$/);let r;n?r=t.replace(/\./g,"").replace(",","."):r=t.replace(/,/g,"");const s=parseFloat(r);return isNaN(s)?null:s}const wf={person:"Person",people:"People",tickets:"Tickets:",soldOut:"Sold Out",maxReached:"Maximum number of tickets allowed reached"},nn=e=>typeof e=="number"&&!isNaN(e),rs=({offer:e,quantity:t,defaultQuantity:n=0,onQuantityChange:r,currency:s="USD",locale:i="en-US",labels:a,slots:l,isDisabled:c=!1,buttonVariant:d="bordered",buttonColor:u="default",showCard:f=!0,showDescription:p=!0,showPeopleCount:m=!0,showPrice:v=!0,classNames:b={},"data-testid":x,selectedColor:w="default"})=>{const N={...wf,...a},[A,S]=y.useState(n),j=t!==void 0?t:A,M=se=>{if(c)return;const fe=Math.max(0,j+se);t===void 0&&S(fe),r?.(e.id,fe)},D=y.useMemo(()=>!nn(e.totalTicketsSold)||!nn(e.ticketsAllowed)?!1:e.totalTicketsSold>=e.ticketsAllowed,[e.totalTicketsSold,e.ticketsAllowed]),B=y.useMemo(()=>D||!nn(e.ticketsAllowed)?!1:j>=e.ticketsAllowed-(e.totalTicketsSold??0),[D,e.ticketsAllowed,e.totalTicketsSold,j]),F=Za(e.price,i,s),_=()=>l?.renderName?l.renderName(e.name,e):o.jsx("h2",{"data-testid":"offer-card-name",className:h.cn("text-base font-medium",b.name),children:e.name}),I=()=>v?l?.renderPrice?l.renderPrice(e.price,F,e):o.jsx("p",{"data-testid":"offer-card-price",className:h.cn("text-primary text-base mt-1",b.price),children:F}):null,E=()=>!p||!e.description?null:l?.renderDescription?l.renderDescription(e.description,e):o.jsx("p",{"data-testid":"offer-card-description",className:h.cn("mb-4 text-sm text-gray-700 leading-relaxed",b.description),children:e.description}),O=()=>{if(!m||!nn(e.numberOfPeople)||e.numberOfPeople<=0)return null;const se=e.numberOfPeople===1?N.person:N.people;return l?.renderPeopleCount?l.renderPeopleCount(e.numberOfPeople,se,e):o.jsxs("p",{"data-testid":"offer-card-people-count",className:h.cn("text-sm text-gray-600 flex items-center mt-2",b.peopleCount),children:[o.jsx(H,{icon:e.numberOfPeople<=1?"solar:user-rounded-outline":"solar:users-group-rounded-outline",width:20,className:"mr-1"}),e.numberOfPeople," ",se]})},P=()=>{const se=j===0||c,fe=B||c;return l?.renderQuantitySelector?l.renderQuantitySelector({quantity:j,onIncrement:()=>M(1),onDecrement:()=>M(-1),isDecrementDisabled:se,isIncrementDisabled:fe,isDisabled:c}):o.jsxs("div",{className:h.cn("flex items-center gap-2",b.quantitySelector),children:[o.jsx(q,{"data-testid":"offer-card-decrement-button",onPress:()=>M(-1),isDisabled:se,variant:d,color:j>0?w:u,radius:"full",isIconOnly:!0,size:"sm","aria-label":"Decrease quantity",children:o.jsx(H,{icon:"gravity-ui:minus",width:16})}),o.jsx("span",{"data-testid":"offer-card-quantity",className:h.cn("min-w-[2rem] text-center font-medium"),children:j}),o.jsx(q,{"data-testid":"offer-card-increment-button",onPress:()=>M(1),isDisabled:fe,variant:d,color:j>0?w:u,radius:"full",isIconOnly:!0,size:"sm","aria-label":"Increase quantity",children:o.jsx(H,{icon:"gravity-ui:plus",width:16})})]})},K=()=>l?.renderSoldOut?l.renderSoldOut(N.soldOut):o.jsx(h.Chip,{"data-testid":"offer-card-sold-out-chip",color:"danger",className:h.cn("gap-2 px-4 h-8",b.soldOut),startContent:o.jsx(H,{icon:"gravity-ui:circle-info-fill",width:14}),children:o.jsx("span",{className:"font-medium text-sm",children:N.soldOut})}),Z=()=>l?.renderMaxReachedAlert?l.renderMaxReachedAlert(N.maxReached):o.jsx(h.Chip,{"data-testid":"offer-card-max-reached-chip",variant:"flat",color:"warning",classNames:{base:"gap-2 px-4 h-10",content:"text-black"},className:h.cn(" text-black! gap-2 px-4 h-10",b.maxReachedAlert),startContent:o.jsx(H,{icon:"gravity-ui:triangle-exclamation-fill",className:"text-black",width:16}),children:o.jsx("span",{className:"font-medium text-sm",children:N.maxReached})}),J=o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-1 xl:grid-cols-3 lg:grid-cols-3 gap-2 items-start",children:[o.jsxs("div",{className:h.cn("h-full col-span-2",D?"opacity-50 pointer-events-none select-none":""),children:[_(),I(),o.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(),E()]})]}),o.jsx("div",{className:"space-x-2 pt-0 pb-2 md:p-2 h-full flex items-center justify-start md:justify-start lg:justify-end",children:D?K():P()})]}),le=B&&!D&&o.jsx(Le.motion.div,{className:"w-full sm:max-w-[60%] md:max-w-[60%] lg:max-w-[60%]",initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.3},children:Z()});return f?o.jsxs(h.Card,{className:h.cn("w-full",b.base),"data-testid":x||`offer-card-${e.id}`,children:[o.jsx(h.CardBody,{className:h.cn("pt-1 pb-0",b.body),children:J}),o.jsx(Le.AnimatePresence,{children:le&&o.jsx(h.CardFooter,{className:h.cn("w-full mt-0 pt-0",b.footer),children:le})})]}):o.jsxs("div",{className:h.cn("w-full",b.base),"data-testid":x||`offer-card-${e.id}`,children:[o.jsx("div",{className:h.cn("pt-1 pb-0",b.body),children:J}),o.jsx(Le.AnimatePresence,{children:le&&o.jsx("div",{className:h.cn("w-full mt-0 pt-0",b.footer),children:le})})]})};rs.displayName="OfferCard";const Xa=({message:e="No offers available.",icon:t="solar:ticket-sale-outline",iconSize:n=48,showCard:r=!0,classNames:s={},renderEmpty:i})=>{if(i){const l=i();return r?o.jsx(h.Card,{"data-testid":"offer-card-empty",className:h.cn("w-full",s.base),children:o.jsx(h.CardBody,{"data-testid":"offer-card-empty-body",children:l})}):o.jsx("div",{"data-testid":"offer-card-empty",className:h.cn("w-full",s.base),children:l})}const a=o.jsxs("div",{"data-testid":"offer-card-empty-content",className:h.cn("flex flex-col items-center justify-center p-8 text-center text-gray-500",s.content),children:[o.jsx(H,{"data-testid":"offer-card-empty-icon",icon:t,width:n,className:h.cn("mb-4",s.icon)}),o.jsx("h3",{"data-testid":"offer-card-empty-message",className:h.cn("text-lg",s.message),children:e})]});return r?o.jsx(h.Card,{"data-testid":"offer-card-empty",className:h.cn("w-full",s.base),children:o.jsx(h.CardBody,{"data-testid":"offer-card-empty-body",children:a})}):o.jsx("div",{"data-testid":"offer-card-empty",className:h.cn("w-full",s.base),children:a})};Xa.displayName="OfferCardEmpty";const kf={title:"Error Fetching Offers",description:"An error occurred while fetching offers."},el=({error:e,labels:t,showCard:n=!0,color:r="danger",classNames:s={}})=>{const i={...kf,...t},a=o.jsx(h.Alert,{"data-testid":"offer-card-error-alert",color:r,title:i.title,description:e||i.description,className:s.alert});return n?o.jsx(h.Card,{"data-testid":"offer-card-error",className:h.cn("w-full",s.base),children:o.jsx(h.CardBody,{"data-testid":"offer-card-error-body",children:a})}):o.jsx("div",{"data-testid":"offer-card-error",className:h.cn("w-full",s.base),children:a})};el.displayName="OfferCardError";const Nf={1:"space-y-1",2:"space-y-2",3:"space-y-3",4:"space-y-4",5:"space-y-5",6:"space-y-6"},tl=({quantity:e=2,gap:t=4,classNames:n={}})=>{const r=Nf[t];return o.jsx("div",{"data-testid":"offer-card-skeleton-container",className:h.cn(r,n.base),children:Array.from({length:e}).map((s,i)=>o.jsxs(h.Card,{"data-testid":`offer-card-skeleton-${i}`,className:h.cn("w-full",n.card),children:[o.jsx(h.CardHeader,{"data-testid":`offer-card-skeleton-header-${i}`,className:"flex justify-between items-start pb-0",children:o.jsxs("div",{className:"space-y-2 w-full",children:[o.jsx(h.Skeleton,{"data-testid":`offer-card-skeleton-title-${i}`,className:"w-1/3 rounded-lg",children:o.jsx("div",{className:"h-4 bg-default-200 rounded-lg"})}),o.jsx(h.Skeleton,{"data-testid":`offer-card-skeleton-subtitle-${i}`,className:"w-1/4 rounded-lg",children:o.jsx("div",{className:"h-3 bg-default-300 rounded-lg"})})]})}),o.jsx(h.CardBody,{"data-testid":`offer-card-skeleton-body-${i}`,className:"pt-2 pb-0",children:o.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-2 items-start",children:[o.jsxs("div",{className:"xl:col-span-2 space-y-2",children:[o.jsx(h.Skeleton,{"data-testid":`offer-card-skeleton-people-${i}`,className:"w-1/4 rounded-lg",children:o.jsx("div",{className:"h-4 bg-default-300 rounded-lg"})}),o.jsx(h.Skeleton,{"data-testid":`offer-card-skeleton-description-${i}`,className:"w-3/4 rounded-lg",children:o.jsx("div",{className:"h-4 bg-default-200 rounded-lg"})})]}),o.jsx("div",{className:"flex items-start justify-end",children:o.jsxs("div",{"data-testid":`offer-card-skeleton-controls-${i}`,className:"flex items-center justify-end gap-2 w-full px-4 py-2",children:[o.jsx(h.Skeleton,{"data-testid":`offer-card-skeleton-label-${i}`,className:"w-24 h-4 rounded-md bg-default-200"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(h.Skeleton,{"data-testid":`offer-card-skeleton-btn-dec-${i}`,className:"w-8 h-8 rounded-md bg-default-300"}),o.jsx(h.Skeleton,{"data-testid":`offer-card-skeleton-btn-qty-${i}`,className:"w-8 h-8 rounded-md bg-default-200"}),o.jsx(h.Skeleton,{"data-testid":`offer-card-skeleton-btn-inc-${i}`,className:"w-8 h-8 rounded-md bg-default-300"})]})]})})]})})]},i))})};tl.displayName="OfferCardSkeleton";const nl={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.15,delayChildren:.1}}},rl={hidden:{opacity:0,y:8},show:{opacity:1,y:0,transition:{duration:.45,ease:"easeOut"}},exit:{opacity:0,y:-5,transition:{duration:.35,ease:"easeIn"}}},Sf={1:"gap-1",2:"gap-2",3:"gap-3",4:"gap-4",5:"gap-5",6:"gap-6"},sl=({offers:e=[],selection:t,defaultSelection:n={},onSelectionChange:r,onQuantityChange:s,currency:i="USD",locale:a="en-US",labels:l,slots:c,isDisabled:d=!1,buttonVariant:u="bordered",buttonColor:f="default",showCard:p=!0,animated:m=!0,gap:v=2,classNames:b={}})=>{const[x,w]=y.useState(n),N=t!==void 0?t:x,A=y.useCallback((B,F)=>{const _={...N,[B]:Math.max(0,F)};t===void 0&&w(_),r?.(_),s?.(B,_[B])},[N,t,r,s]),S=[...e].sort((B,F)=>(B.position??0)-(F.position??0)),j=Sf[v],M=h.cn("grid mx-auto pt-2",j,b.base),D=B=>o.jsx(rs,{offer:B,quantity:N[B.id]||0,onQuantityChange:A,currency:i,locale:a,labels:l,slots:c,isDisabled:d,buttonVariant:u,buttonColor:f,showCard:p,classNames:b.card},B.id);return m?o.jsx(Le.motion.div,{"data-testid":"offer-card-list",className:M,variants:nl,initial:"hidden",animate:"show",children:o.jsx(Le.AnimatePresence,{children:S.map(B=>o.jsx(Le.motion.div,{"data-testid":`offer-card-list-item-${B.id}`,className:b.cardWrapper,variants:rl,exit:{opacity:0,y:-20},transition:{duration:.3},children:D(B)},B.id))})}):o.jsx("div",{"data-testid":"offer-card-list",className:M,children:S.map(D)})};sl.displayName="OfferCardList";var Gt=e=>e.type==="checkbox",ut=e=>e instanceof Date,Ae=e=>e==null;const il=e=>typeof e=="object";var xe=e=>!Ae(e)&&!Array.isArray(e)&&il(e)&&!ut(e),al=e=>xe(e)&&e.target?Gt(e.target)?e.target.checked:e.target.value:e,Cf=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,ll=(e,t)=>e.has(Cf(t)),jf=e=>{const t=e.constructor&&e.constructor.prototype;return xe(t)&&t.hasOwnProperty("isPrototypeOf")},ss=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function me(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(ss&&(e instanceof Blob||t))return e;const n=Array.isArray(e);if(!n&&!(xe(e)&&jf(e)))return e;const r=n?[]:Object.create(Object.getPrototypeOf(e));for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r[s]=me(e[s]));return r}var Fn=e=>/^\w*$/.test(e),ce=e=>e===void 0,is=e=>Array.isArray(e)?e.filter(Boolean):[],as=e=>is(e.replace(/["|']|\]/g,"").split(/\.|\[/)),L=(e,t,n)=>{if(!t||!xe(e))return n;const r=(Fn(t)?[t]:as(t)).reduce((s,i)=>Ae(s)?s:s[i],e);return ce(r)||r===e?ce(e[t])?n:e[t]:r},Ee=e=>typeof e=="boolean",je=e=>typeof e=="function",ae=(e,t,n)=>{let r=-1;const s=Fn(t)?[t]:as(t),i=s.length,a=i-1;for(;++r<i;){const l=s[r];let c=n;if(r!==a){const d=e[l];c=xe(d)||Array.isArray(d)?d:isNaN(+s[r+1])?{}:[]}if(l==="__proto__"||l==="constructor"||l==="prototype")return;e[l]=c,e=e[l]}};const Nn={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},Pe={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Ue={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},ol=y.createContext(null);ol.displayName="HookFormControlContext";const ls=()=>y.useContext(ol);var cl=(e,t,n,r=!0)=>{const s={defaultValues:t._defaultValues};for(const i in e)Object.defineProperty(s,i,{get:()=>{const a=i;return t._proxyFormState[a]!==Pe.all&&(t._proxyFormState[a]=!r||Pe.all),n&&(n[a]=!0),e[a]}});return s};const os=typeof window<"u"?y.useLayoutEffect:y.useEffect;function Af(e){const t=ls(),{control:n=t,disabled:r,name:s,exact:i}=e||{},[a,l]=y.useState(n._formState),c=y.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return os(()=>n._subscribe({name:s,formState:c.current,exact:i,callback:d=>{!r&&l({...n._formState,...d})}}),[s,r,i]),y.useEffect(()=>{c.current.isValid&&n._setValid(!0)},[n]),y.useMemo(()=>cl(a,n,c.current,!1),[a,n])}var De=e=>typeof e=="string",Ir=(e,t,n,r,s)=>De(e)?(r&&t.watch.add(e),L(n,e,s)):Array.isArray(e)?e.map(i=>(r&&t.watch.add(i),L(n,i))):(r&&(t.watchAll=!0),n),$r=e=>Ae(e)||!il(e);function Re(e,t,n=new WeakSet){if($r(e)||$r(t))return Object.is(e,t);if(ut(e)&&ut(t))return Object.is(e.getTime(),t.getTime());const r=Object.keys(e),s=Object.keys(t);if(r.length!==s.length)return!1;if(n.has(e)||n.has(t))return!0;n.add(e),n.add(t);for(const i of r){const a=e[i];if(!s.includes(i))return!1;if(i!=="ref"){const l=t[i];if(ut(a)&&ut(l)||xe(a)&&xe(l)||Array.isArray(a)&&Array.isArray(l)?!Re(a,l,n):!Object.is(a,l))return!1}}return!0}function Mf(e){const t=ls(),{control:n=t,name:r,defaultValue:s,disabled:i,exact:a,compute:l}=e||{},c=y.useRef(s),d=y.useRef(l),u=y.useRef(void 0),f=y.useRef(n),p=y.useRef(r);d.current=l;const[m,v]=y.useState(()=>{const S=n._getWatch(r,c.current);return d.current?d.current(S):S}),b=y.useCallback(S=>{const j=Ir(r,n._names,S||n._formValues,!1,c.current);return d.current?d.current(j):j},[n._formValues,n._names,r]),x=y.useCallback(S=>{if(!i){const j=Ir(r,n._names,S||n._formValues,!1,c.current);if(d.current){const M=d.current(j);Re(M,u.current)||(v(M),u.current=M)}else v(j)}},[n._formValues,n._names,i,r]);os(()=>((f.current!==n||!Re(p.current,r))&&(f.current=n,p.current=r,x()),n._subscribe({name:r,formState:{values:!0},exact:a,callback:S=>{x(S.values)}})),[n,a,r,x]),y.useEffect(()=>n._removeUnmounted());const w=f.current!==n,N=p.current,A=y.useMemo(()=>{if(i)return null;const S=!w&&!Re(N,r);return w||S?b():null},[i,w,r,N,b]);return A!==null?A:m}function Ef(e){const t=ls(),{name:n,disabled:r,control:s=t,shouldUnregister:i,defaultValue:a,exact:l=!0}=e,c=ll(s._names.array,n),d=y.useMemo(()=>L(s._formValues,n,L(s._defaultValues,n,a)),[s,n,a]),u=Mf({control:s,name:n,defaultValue:d,exact:l}),f=Af({control:s,name:n,exact:l}),p=y.useRef(e),m=y.useRef(void 0),v=y.useRef(s.register(n,{...e.rules,value:u,...Ee(e.disabled)?{disabled:e.disabled}:{}}));p.current=e;const b=y.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!L(f.errors,n)},isDirty:{enumerable:!0,get:()=>!!L(f.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!L(f.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!L(f.validatingFields,n)},error:{enumerable:!0,get:()=>L(f.errors,n)}}),[f,n]),x=y.useCallback(S=>v.current.onChange({target:{value:al(S),name:n},type:Nn.CHANGE}),[n]),w=y.useCallback(()=>v.current.onBlur({target:{value:L(s._formValues,n),name:n},type:Nn.BLUR}),[n,s._formValues]),N=y.useCallback(S=>{const j=L(s._fields,n);j&&j._f&&S&&(j._f.ref={focus:()=>je(S.focus)&&S.focus(),select:()=>je(S.select)&&S.select(),setCustomValidity:M=>je(S.setCustomValidity)&&S.setCustomValidity(M),reportValidity:()=>je(S.reportValidity)&&S.reportValidity()})},[s._fields,n]),A=y.useMemo(()=>({name:n,value:u,...Ee(r)||f.disabled?{disabled:f.disabled||r}:{},onChange:x,onBlur:w,ref:N}),[n,r,f.disabled,x,w,N,u]);return y.useEffect(()=>{const S=s._options.shouldUnregister||i,j=m.current;j&&j!==n&&!c&&s.unregister(j),s.register(n,{...p.current.rules,...Ee(p.current.disabled)?{disabled:p.current.disabled}:{}});const M=(D,B)=>{const F=L(s._fields,D);F&&F._f&&(F._f.mount=B)};if(M(n,!0),S){const D=me(L(s._options.defaultValues,n,p.current.defaultValue));ae(s._defaultValues,n,D),ce(L(s._formValues,n))&&ae(s._formValues,n,D)}return!c&&s.register(n),m.current=n,()=>{(c?S&&!s._state.action:S)?s.unregister(n):M(n,!1)}},[n,s,c,i]),y.useEffect(()=>{s._setDisabledField({disabled:r,name:n})},[r,n,s]),y.useMemo(()=>({field:A,formState:f,fieldState:b}),[A,f,b])}const Tf=y.createContext(null);Tf.displayName="HookFormContext";var Df=(e,t,n,r,s)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:s||!0}}:{},Rt=e=>Array.isArray(e)?e:[e],xi=()=>{let e=[];return{get observers(){return e},next:s=>{for(const i of e)i.next&&i.next(s)},subscribe:s=>(e.push(s),{unsubscribe:()=>{e=e.filter(i=>i!==s)}}),unsubscribe:()=>{e=[]}}};function dl(e,t){const n={};for(const r in e)if(e.hasOwnProperty(r)){const s=e[r],i=t[r];if(s&&xe(s)&&i){const a=dl(s,i);xe(a)&&(n[r]=a)}else e[r]&&(n[r]=i)}return n}var Se=e=>xe(e)&&!Object.keys(e).length,cs=e=>e.type==="file",Sn=e=>{if(!ss)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},ul=e=>e.type==="select-multiple",ds=e=>e.type==="radio",If=e=>ds(e)||Gt(e),lr=e=>Sn(e)&&e.isConnected;function $f(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=ce(e)?r++:e[t[r++]];return e}function Of(e){for(const t in e)if(e.hasOwnProperty(t)&&!ce(e[t]))return!1;return!0}function pe(e,t){const n=Array.isArray(t)?t:Fn(t)?[t]:as(t),r=n.length===1?e:$f(e,n),s=n.length-1,i=n[s];return r&&delete r[i],s!==0&&(xe(r)&&Se(r)||Array.isArray(r)&&Of(r))&&pe(e,n.slice(0,-1)),e}var Lf=e=>{for(const t in e)if(je(e[t]))return!0;return!1};function fl(e){return Array.isArray(e)||xe(e)&&!Lf(e)}function Or(e,t={}){for(const n in e){const r=e[n];fl(r)?(t[n]=Array.isArray(r)?[]:{},Or(r,t[n])):ce(r)||(t[n]=!0)}return t}function Nt(e,t,n){n||(n=Or(t));for(const r in e){const s=e[r];if(fl(s))ce(t)||$r(n[r])?n[r]=Or(s,Array.isArray(s)?[]:{}):Nt(s,Ae(t)?{}:t[r],n[r]);else{const i=t[r];n[r]=!Re(s,i)}}return n}const yi={value:!1,isValid:!1},bi={value:!0,isValid:!0};var hl=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!ce(e[0].attributes.value)?ce(e[0].value)||e[0].value===""?bi:{value:e[0].value,isValid:!0}:bi:yi}return yi},ml=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>ce(e)?e:t?e===""?NaN:e&&+e:n&&De(e)?new Date(e):r?r(e):e;const vi={isValid:!1,value:null};var pl=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,vi):vi;function wi(e){const t=e.ref;return cs(t)?t.files:ds(t)?pl(e.refs).value:ul(t)?[...t.selectedOptions].map(({value:n})=>n):Gt(t)?hl(e.refs).value:ml(ce(t.value)?e.ref.value:t.value,e)}var Ff=(e,t,n,r)=>{const s={};for(const i of e){const a=L(t,i);a&&ae(s,i,a._f)}return{criteriaMode:n,names:[...e],fields:s,shouldUseNativeValidation:r}},Cn=e=>e instanceof RegExp,It=e=>ce(e)?e:Cn(e)?e.source:xe(e)?Cn(e.value)?e.value.source:e.value:e,ki=e=>({isOnSubmit:!e||e===Pe.onSubmit,isOnBlur:e===Pe.onBlur,isOnChange:e===Pe.onChange,isOnAll:e===Pe.all,isOnTouch:e===Pe.onTouched});const Ni="AsyncFunction";var Pf=e=>!!e&&!!e.validate&&!!(je(e.validate)&&e.validate.constructor.name===Ni||xe(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===Ni)),Rf=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),Si=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const zt=(e,t,n,r)=>{for(const s of n||Object.keys(e)){const i=L(e,s);if(i){const{_f:a,...l}=i;if(a){if(a.refs&&a.refs[0]&&t(a.refs[0],s)&&!r)return!0;if(a.ref&&t(a.ref,a.name)&&!r)return!0;if(zt(l,t))break}else if(xe(l)&&zt(l,t))break}}};function Ci(e,t,n){const r=L(e,n);if(r||Fn(n))return{error:r,name:n};const s=n.split(".");for(;s.length;){const i=s.join("."),a=L(t,i),l=L(e,i);if(a&&!Array.isArray(a)&&n!==i)return{name:n};if(l&&l.type)return{name:i,error:l};if(l&&l.root&&l.root.type)return{name:`${i}.root`,error:l.root};s.pop()}return{name:n}}var zf=(e,t,n,r)=>{n(e);const{name:s,...i}=e;return Se(i)||Object.keys(i).length>=Object.keys(t).length||Object.keys(i).find(a=>t[a]===(!r||Pe.all))},Bf=(e,t,n)=>!e||!t||e===t||Rt(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r))),_f=(e,t,n,r,s)=>s.isOnAll?!1:!n&&s.isOnTouch?!(t||e):(n?r.isOnBlur:s.isOnBlur)?!e:(n?r.isOnChange:s.isOnChange)?e:!0,Vf=(e,t)=>!is(L(e,t)).length&&pe(e,t),Hf=(e,t,n)=>{const r=Rt(L(e,n));return ae(r,"root",t[n]),ae(e,n,r),e};function ji(e,t,n="validate"){if(De(e)||Array.isArray(e)&&e.every(De)||Ee(e)&&!e)return{type:n,message:De(e)?e:"",ref:t}}var bt=e=>xe(e)&&!Cn(e)?e:{value:e,message:""},Ai=async(e,t,n,r,s,i)=>{const{ref:a,refs:l,required:c,maxLength:d,minLength:u,min:f,max:p,pattern:m,validate:v,name:b,valueAsNumber:x,mount:w}=e._f,N=L(n,b);if(!w||t.has(b))return{};const A=l?l[0]:a,S=E=>{s&&A.reportValidity&&(A.setCustomValidity(Ee(E)?"":E||""),A.reportValidity())},j={},M=ds(a),D=Gt(a),B=M||D,F=(x||cs(a))&&ce(a.value)&&ce(N)||Sn(a)&&a.value===""||N===""||Array.isArray(N)&&!N.length,_=Df.bind(null,b,r,j),I=(E,O,P,K=Ue.maxLength,Z=Ue.minLength)=>{const J=E?O:P;j[b]={type:E?K:Z,message:J,ref:a,..._(E?K:Z,J)}};if(i?!Array.isArray(N)||!N.length:c&&(!B&&(F||Ae(N))||Ee(N)&&!N||D&&!hl(l).isValid||M&&!pl(l).isValid)){const{value:E,message:O}=De(c)?{value:!!c,message:c}:bt(c);if(E&&(j[b]={type:Ue.required,message:O,ref:A,..._(Ue.required,O)},!r))return S(O),j}if(!F&&(!Ae(f)||!Ae(p))){let E,O;const P=bt(p),K=bt(f);if(!Ae(N)&&!isNaN(N)){const Z=a.valueAsNumber||N&&+N;Ae(P.value)||(E=Z>P.value),Ae(K.value)||(O=Z<K.value)}else{const Z=a.valueAsDate||new Date(N),J=fe=>new Date(new Date().toDateString()+" "+fe),le=a.type=="time",se=a.type=="week";De(P.value)&&N&&(E=le?J(N)>J(P.value):se?N>P.value:Z>new Date(P.value)),De(K.value)&&N&&(O=le?J(N)<J(K.value):se?N<K.value:Z<new Date(K.value))}if((E||O)&&(I(!!E,P.message,K.message,Ue.max,Ue.min),!r))return S(j[b].message),j}if((d||u)&&!F&&(De(N)||i&&Array.isArray(N))){const E=bt(d),O=bt(u),P=!Ae(E.value)&&N.length>+E.value,K=!Ae(O.value)&&N.length<+O.value;if((P||K)&&(I(P,E.message,O.message),!r))return S(j[b].message),j}if(m&&!F&&De(N)){const{value:E,message:O}=bt(m);if(Cn(E)&&!N.match(E)&&(j[b]={type:Ue.pattern,message:O,ref:a,..._(Ue.pattern,O)},!r))return S(O),j}if(v){if(je(v)){const E=await v(N,n),O=ji(E,A);if(O&&(j[b]={...O,..._(Ue.validate,O.message)},!r))return S(O.message),j}else if(xe(v)){let E={};for(const O in v){if(!Se(E)&&!r)break;const P=ji(await v[O](N,n),A,O);P&&(E={...P,..._(O,P.message)},S(P.message),r&&(j[b]=E))}if(!Se(E)&&(j[b]={ref:A,...E},!r))return j}}return S(!0),j};const Uf={mode:Pe.onSubmit,reValidateMode:Pe.onChange,shouldFocusError:!0};function qf(e={}){let t={...Uf,...e},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:je(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},s=xe(t.defaultValues)||xe(t.values)?me(t.defaultValues||t.values)||{}:{},i=t.shouldUnregister?{}:me(s),a={action:!1,mount:!1,watch:!1,keepIsValid:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},c,d=0;const u={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},f={...u};let p={...f};const m={array:xi(),state:xi()},v=t.criteriaMode===Pe.all,b=g=>k=>{clearTimeout(d),d=setTimeout(g,k)},x=async g=>{if(!a.keepIsValid&&!t.disabled&&(f.isValid||p.isValid||g)){let k;t.resolver?(k=Se((await B()).errors),w()):k=await _(r,!0),k!==n.isValid&&m.state.next({isValid:k})}},w=(g,k)=>{!t.disabled&&(f.isValidating||f.validatingFields||p.isValidating||p.validatingFields)&&((g||Array.from(l.mount)).forEach(C=>{C&&(k?ae(n.validatingFields,C,k):pe(n.validatingFields,C))}),m.state.next({validatingFields:n.validatingFields,isValidating:!Se(n.validatingFields)}))},N=(g,k=[],C,R,$=!0,T=!0)=>{if(R&&C&&!t.disabled){if(a.action=!0,T&&Array.isArray(L(r,g))){const V=C(L(r,g),R.argA,R.argB);$&&ae(r,g,V)}if(T&&Array.isArray(L(n.errors,g))){const V=C(L(n.errors,g),R.argA,R.argB);$&&ae(n.errors,g,V),Vf(n.errors,g)}if((f.touchedFields||p.touchedFields)&&T&&Array.isArray(L(n.touchedFields,g))){const V=C(L(n.touchedFields,g),R.argA,R.argB);$&&ae(n.touchedFields,g,V)}(f.dirtyFields||p.dirtyFields)&&(n.dirtyFields=Nt(s,i)),m.state.next({name:g,isDirty:E(g,k),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else ae(i,g,k)},A=(g,k)=>{ae(n.errors,g,k),m.state.next({errors:n.errors})},S=g=>{n.errors=g,m.state.next({errors:n.errors,isValid:!1})},j=(g,k,C,R)=>{const $=L(r,g);if($){const T=L(i,g,ce(C)?L(s,g):C);ce(T)||R&&R.defaultChecked||k?ae(i,g,k?T:wi($._f)):K(g,T),a.mount&&!a.action&&x()}},M=(g,k,C,R,$)=>{let T=!1,V=!1;const ee={name:g};if(!t.disabled){if(!C||R){(f.isDirty||p.isDirty)&&(V=n.isDirty,n.isDirty=ee.isDirty=E(),T=V!==ee.isDirty);const te=Re(L(s,g),k);V=!!L(n.dirtyFields,g),te?pe(n.dirtyFields,g):ae(n.dirtyFields,g,!0),ee.dirtyFields=n.dirtyFields,T=T||(f.dirtyFields||p.dirtyFields)&&V!==!te}if(C){const te=L(n.touchedFields,g);te||(ae(n.touchedFields,g,C),ee.touchedFields=n.touchedFields,T=T||(f.touchedFields||p.touchedFields)&&te!==C)}T&&$&&m.state.next(ee)}return T?ee:{}},D=(g,k,C,R)=>{const $=L(n.errors,g),T=(f.isValid||p.isValid)&&Ee(k)&&n.isValid!==k;if(t.delayError&&C?(c=b(()=>A(g,C)),c(t.delayError)):(clearTimeout(d),c=null,C?ae(n.errors,g,C):pe(n.errors,g)),(C?!Re($,C):$)||!Se(R)||T){const V={...R,...T&&Ee(k)?{isValid:k}:{},errors:n.errors,name:g};n={...n,...V},m.state.next(V)}},B=async g=>(w(g,!0),await t.resolver(i,t.context,Ff(g||l.mount,r,t.criteriaMode,t.shouldUseNativeValidation))),F=async g=>{const{errors:k}=await B(g);if(w(g),g)for(const C of g){const R=L(k,C);R?ae(n.errors,C,R):pe(n.errors,C)}else n.errors=k;return k},_=async(g,k,C={valid:!0})=>{for(const R in g){const $=g[R];if($){const{_f:T,...V}=$;if(T){const ee=l.array.has(T.name),te=$._f&&Pf($._f);te&&f.validatingFields&&w([T.name],!0);const Ne=await Ai($,l.disabled,i,v,t.shouldUseNativeValidation&&!k,ee);if(te&&f.validatingFields&&w([T.name]),Ne[T.name]&&(C.valid=!1,k||e.shouldUseNativeValidation))break;!k&&(L(Ne,T.name)?ee?Hf(n.errors,Ne,T.name):ae(n.errors,T.name,Ne[T.name]):pe(n.errors,T.name))}!Se(V)&&await _(V,k,C)}}return C.valid},I=()=>{for(const g of l.unMount){const k=L(r,g);k&&(k._f.refs?k._f.refs.every(C=>!lr(C)):!lr(k._f.ref))&&zn(g)}l.unMount=new Set},E=(g,k)=>!t.disabled&&(g&&k&&ae(i,g,k),!Re(Y(),s)),O=(g,k,C)=>Ir(g,l,{...a.mount?i:ce(k)?s:De(g)?{[g]:k}:k},C,k),P=g=>is(L(a.mount?i:s,g,t.shouldUnregister?L(s,g,[]):[])),K=(g,k,C={})=>{const R=L(r,g);let $=k;if(R){const T=R._f;T&&(!T.disabled&&ae(i,g,ml(k,T)),$=Sn(T.ref)&&Ae(k)?"":k,ul(T.ref)?[...T.ref.options].forEach(V=>V.selected=$.includes(V.value)):T.refs?Gt(T.ref)?T.refs.forEach(V=>{(!V.defaultChecked||!V.disabled)&&(Array.isArray($)?V.checked=!!$.find(ee=>ee===V.value):V.checked=$===V.value||!!$)}):T.refs.forEach(V=>V.checked=V.value===$):cs(T.ref)?T.ref.value="":(T.ref.value=$,T.ref.type||m.state.next({name:g,values:me(i)})))}(C.shouldDirty||C.shouldTouch)&&M(g,$,C.shouldTouch,C.shouldDirty,!0),C.shouldValidate&&fe(g)},Z=(g,k,C)=>{for(const R in k){if(!k.hasOwnProperty(R))return;const $=k[R],T=g+"."+R,V=L(r,T);(l.array.has(g)||xe($)||V&&!V._f)&&!ut($)?Z(T,$,C):K(T,$,C)}},J=(g,k,C={})=>{const R=L(r,g),$=l.array.has(g),T=me(k);ae(i,g,T),$?(m.array.next({name:g,values:me(i)}),(f.isDirty||f.dirtyFields||p.isDirty||p.dirtyFields)&&C.shouldDirty&&m.state.next({name:g,dirtyFields:Nt(s,i),isDirty:E(g,T)})):R&&!R._f&&!Ae(T)?Z(g,T,C):K(g,T,C),Si(g,l)?m.state.next({...n,name:g,values:me(i)}):m.state.next({name:a.mount?g:void 0,values:me(i)})},le=async g=>{a.mount=!0;const k=g.target;let C=k.name,R=!0;const $=L(r,C),T=te=>{R=Number.isNaN(te)||ut(te)&&isNaN(te.getTime())||Re(te,L(i,C,te))},V=ki(t.mode),ee=ki(t.reValidateMode);if($){let te,Ne;const st=k.type?wi($._f):al(g),Je=g.type===Nn.BLUR||g.type===Nn.FOCUS_OUT,ho=!Rf($._f)&&!t.resolver&&!L(n.errors,C)&&!$._f.deps||_f(Je,L(n.touchedFields,C),n.isSubmitted,ee,V),Vn=Si(C,l,Je);ae(i,C,st),Je?(!k||!k.readOnly)&&($._f.onBlur&&$._f.onBlur(g),c&&c(0)):$._f.onChange&&$._f.onChange(g);const Hn=M(C,st,Je),mo=!Se(Hn)||Vn;if(!Je&&m.state.next({name:C,type:g.type,values:me(i)}),ho)return(f.isValid||p.isValid)&&(t.mode==="onBlur"?Je&&x():Je||x()),mo&&m.state.next({name:C,...Vn?{}:Hn});if(!Je&&Vn&&m.state.next({...n}),t.resolver){const{errors:Ns}=await B([C]);if(w([C]),T(st),R){const po=Ci(n.errors,r,C),Ss=Ci(Ns,r,po.name||C);te=Ss.error,C=Ss.name,Ne=Se(Ns)}}else w([C],!0),te=(await Ai($,l.disabled,i,v,t.shouldUseNativeValidation))[C],w([C]),T(st),R&&(te?Ne=!1:(f.isValid||p.isValid)&&(Ne=await _(r,!0)));R&&($._f.deps&&(!Array.isArray($._f.deps)||$._f.deps.length>0)&&fe($._f.deps),D(C,Ne,te,Hn))}},se=(g,k)=>{if(L(n.errors,k)&&g.focus)return g.focus(),1},fe=async(g,k={})=>{let C,R;const $=Rt(g);if(t.resolver){const T=await F(ce(g)?g:$);C=Se(T),R=g?!$.some(V=>L(T,V)):C}else g?(R=(await Promise.all($.map(async T=>{const V=L(r,T);return await _(V&&V._f?{[T]:V}:V)}))).every(Boolean),!(!R&&!n.isValid)&&x()):R=C=await _(r);return m.state.next({...!De(g)||(f.isValid||p.isValid)&&C!==n.isValid?{}:{name:g},...t.resolver||!g?{isValid:C}:{},errors:n.errors}),k.shouldFocus&&!R&&zt(r,se,g?$:l.mount),R},Y=(g,k)=>{let C={...a.mount?i:s};return k&&(C=dl(k.dirtyFields?n.dirtyFields:n.touchedFields,C)),ce(g)?C:De(g)?L(C,g):g.map(R=>L(C,R))},W=(g,k)=>({invalid:!!L((k||n).errors,g),isDirty:!!L((k||n).dirtyFields,g),error:L((k||n).errors,g),isValidating:!!L(n.validatingFields,g),isTouched:!!L((k||n).touchedFields,g)}),de=g=>{g&&Rt(g).forEach(k=>pe(n.errors,k)),m.state.next({errors:g?n.errors:{}})},ie=(g,k,C)=>{const R=(L(r,g,{_f:{}})._f||{}).ref,$=L(n.errors,g)||{},{ref:T,message:V,type:ee,...te}=$;ae(n.errors,g,{...te,...k,ref:R}),m.state.next({name:g,errors:n.errors,isValid:!1}),C&&C.shouldFocus&&R&&R.focus&&R.focus()},Me=(g,k)=>je(g)?m.state.subscribe({next:C=>"values"in C&&g(O(void 0,k),C)}):O(g,k,!0),Mt=g=>m.state.subscribe({next:k=>{Bf(g.name,k.name,g.exact)&&zf(k,g.formState||f,fo,g.reRenderRoot)&&g.callback({values:{...i},...n,...k,defaultValues:s})}}).unsubscribe,Rn=g=>(a.mount=!0,p={...p,...g.formState},Mt({...g,formState:{...u,...g.formState}})),zn=(g,k={})=>{for(const C of g?Rt(g):l.mount)l.mount.delete(C),l.array.delete(C),k.keepValue||(pe(r,C),pe(i,C)),!k.keepError&&pe(n.errors,C),!k.keepDirty&&pe(n.dirtyFields,C),!k.keepTouched&&pe(n.touchedFields,C),!k.keepIsValidating&&pe(n.validatingFields,C),!t.shouldUnregister&&!k.keepDefaultValue&&pe(s,C);m.state.next({values:me(i)}),m.state.next({...n,...k.keepDirty?{isDirty:E()}:{}}),!k.keepIsValid&&x()},ys=({disabled:g,name:k})=>{if(Ee(g)&&a.mount||g||l.disabled.has(k)){const $=l.disabled.has(k)!==!!g;g?l.disabled.add(k):l.disabled.delete(k),$&&a.mount&&!a.action&&x()}},Bn=(g,k={})=>{let C=L(r,g);const R=Ee(k.disabled)||Ee(t.disabled);return ae(r,g,{...C||{},_f:{...C&&C._f?C._f:{ref:{name:g}},name:g,mount:!0,...k}}),l.mount.add(g),C?ys({disabled:Ee(k.disabled)?k.disabled:t.disabled,name:g}):j(g,!0,k.value),{...R?{disabled:k.disabled||t.disabled}:{},...t.progressive?{required:!!k.required,min:It(k.min),max:It(k.max),minLength:It(k.minLength),maxLength:It(k.maxLength),pattern:It(k.pattern)}:{},name:g,onChange:le,onBlur:le,ref:$=>{if($){Bn(g,k),C=L(r,g);const T=ce($.value)&&$.querySelectorAll&&$.querySelectorAll("input,select,textarea")[0]||$,V=If(T),ee=C._f.refs||[];if(V?ee.find(te=>te===T):T===C._f.ref)return;ae(r,g,{_f:{...C._f,...V?{refs:[...ee.filter(lr),T,...Array.isArray(L(s,g))?[{}]:[]],ref:{type:T.type,name:g}}:{ref:T}}}),j(g,!1,void 0,T)}else C=L(r,g,{}),C._f&&(C._f.mount=!1),(t.shouldUnregister||k.shouldUnregister)&&!(ll(l.array,g)&&a.action)&&l.unMount.add(g)}}},_n=()=>t.shouldFocusError&&zt(r,se,l.mount),oo=g=>{Ee(g)&&(m.state.next({disabled:g}),zt(r,(k,C)=>{const R=L(r,C);R&&(k.disabled=R._f.disabled||g,Array.isArray(R._f.refs)&&R._f.refs.forEach($=>{$.disabled=R._f.disabled||g}))},0,!1))},bs=(g,k)=>async C=>{let R;C&&(C.preventDefault&&C.preventDefault(),C.persist&&C.persist());let $=me(i);if(m.state.next({isSubmitting:!0}),t.resolver){const{errors:T,values:V}=await B();w(),n.errors=T,$=me(V)}else await _(r);if(l.disabled.size)for(const T of l.disabled)pe($,T);if(pe(n.errors,"root"),Se(n.errors)){m.state.next({errors:{}});try{await g($,C)}catch(T){R=T}}else k&&await k({...n.errors},C),_n(),setTimeout(_n);if(m.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Se(n.errors)&&!R,submitCount:n.submitCount+1,errors:n.errors}),R)throw R},co=(g,k={})=>{L(r,g)&&(ce(k.defaultValue)?J(g,me(L(s,g))):(J(g,k.defaultValue),ae(s,g,me(k.defaultValue))),k.keepTouched||pe(n.touchedFields,g),k.keepDirty||(pe(n.dirtyFields,g),n.isDirty=k.defaultValue?E(g,me(L(s,g))):E()),k.keepError||(pe(n.errors,g),f.isValid&&x()),m.state.next({...n}))},vs=(g,k={})=>{const C=g?me(g):s,R=me(C),$=Se(g),T=$?s:R;if(k.keepDefaultValues||(s=C),!k.keepValues){if(k.keepDirtyValues){const V=new Set([...l.mount,...Object.keys(Nt(s,i))]);for(const ee of Array.from(V)){const te=L(n.dirtyFields,ee),Ne=L(i,ee),st=L(T,ee);te&&!ce(Ne)?ae(T,ee,Ne):!te&&!ce(st)&&J(ee,st)}}else{if(ss&&ce(g))for(const V of l.mount){const ee=L(r,V);if(ee&&ee._f){const te=Array.isArray(ee._f.refs)?ee._f.refs[0]:ee._f.ref;if(Sn(te)){const Ne=te.closest("form");if(Ne){Ne.reset();break}}}}if(k.keepFieldsRef)for(const V of l.mount)J(V,L(T,V));else r={}}i=t.shouldUnregister?k.keepDefaultValues?me(s):{}:me(T),m.array.next({values:{...T}}),m.state.next({values:{...T}})}l={mount:k.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},a.mount=!f.isValid||!!k.keepIsValid||!!k.keepDirtyValues||!t.shouldUnregister&&!Se(T),a.watch=!!t.shouldUnregister,a.keepIsValid=!!k.keepIsValid,a.action=!1,k.keepErrors||(n.errors={}),m.state.next({submitCount:k.keepSubmitCount?n.submitCount:0,isDirty:$?!1:k.keepDirty?n.isDirty:!!(k.keepDefaultValues&&!Re(g,s)),isSubmitted:k.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:$?{}:k.keepDirtyValues?k.keepDefaultValues&&i?Nt(s,i):n.dirtyFields:k.keepDefaultValues&&g?Nt(s,g):k.keepDirty?n.dirtyFields:{},touchedFields:k.keepTouched?n.touchedFields:{},errors:k.keepErrors?n.errors:{},isSubmitSuccessful:k.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:s})},ws=(g,k)=>vs(je(g)?g(i):g,{...t.resetOptions,...k}),uo=(g,k={})=>{const C=L(r,g),R=C&&C._f;if(R){const $=R.refs?R.refs[0]:R.ref;$.focus&&setTimeout(()=>{$.focus(),k.shouldSelect&&je($.select)&&$.select()})}},fo=g=>{n={...n,...g}},ks={control:{register:Bn,unregister:zn,getFieldState:W,handleSubmit:bs,setError:ie,_subscribe:Mt,_runSchema:B,_updateIsValidating:w,_focusError:_n,_getWatch:O,_getDirty:E,_setValid:x,_setFieldArray:N,_setDisabledField:ys,_setErrors:S,_getFieldArray:P,_reset:vs,_resetDefaultValues:()=>je(t.defaultValues)&&t.defaultValues().then(g=>{ws(g,t.resetOptions),m.state.next({isLoading:!1})}),_removeUnmounted:I,_disableForm:oo,_subjects:m,_proxyFormState:f,get _fields(){return r},get _formValues(){return i},get _state(){return a},set _state(g){a=g},get _defaultValues(){return s},get _names(){return l},set _names(g){l=g},get _formState(){return n},get _options(){return t},set _options(g){t={...t,...g}}},subscribe:Rn,trigger:fe,register:Bn,handleSubmit:bs,watch:Me,setValue:J,getValues:Y,reset:ws,resetField:co,clearErrors:de,unregister:zn,setError:ie,setFocus:uo,getFieldState:W};return{...ks,formControl:ks}}function Wf(e={}){const t=y.useRef(void 0),n=y.useRef(void 0),[r,s]=y.useState({isDirty:!1,isValidating:!1,isLoading:je(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:je(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:r},e.defaultValues&&!je(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:a,...l}=qf(e);t.current={...l,formState:r}}const i=t.current.control;return i._options=e,os(()=>{const a=i._subscribe({formState:i._proxyFormState,callback:()=>s({...i._formState}),reRenderRoot:!0});return s(l=>({...l,isReady:!0})),i._formState.isReady=!0,a},[i]),y.useEffect(()=>i._disableForm(e.disabled),[i,e.disabled]),y.useEffect(()=>{e.mode&&(i._options.mode=e.mode),e.reValidateMode&&(i._options.reValidateMode=e.reValidateMode)},[i,e.mode,e.reValidateMode]),y.useEffect(()=>{e.errors&&(i._setErrors(e.errors),i._focusError())},[i,e.errors]),y.useEffect(()=>{e.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,e.shouldUnregister]),y.useEffect(()=>{if(i._proxyFormState.isDirty){const a=i._getDirty();a!==r.isDirty&&i._subjects.state.next({isDirty:a})}},[i,r.isDirty]),y.useEffect(()=>{var a;e.values&&!Re(e.values,n.current)?(i._reset(e.values,{keepFieldsRef:!0,...i._options.resetOptions}),!((a=i._options.resetOptions)===null||a===void 0)&&a.keepIsValid||i._setValid(),n.current=e.values,s(l=>({...l}))):i._resetDefaultValues()},[i,e.values]),y.useEffect(()=>{i._state.mount||(i._setValid(),i._state.mount=!0),i._state.watch&&(i._state.watch=!1,i._subjects.state.next({...i._formState})),i._removeUnmounted()}),t.current.formState=y.useMemo(()=>cl(r,i),[i,r]),t.current}function Kf(e,t=3){return e%1===0?e.toString():e.toFixed(t).replace(/\.?0+$/,"")}function Jf(e,t="en-US",n="USD"){try{return new Intl.NumberFormat(t,{style:"currency",currency:n,minimumFractionDigits:2,maximumFractionDigits:2}).format(e)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${e.toFixed(2)}`}}function Yf(e="USD",t="en-US"){try{return new Intl.NumberFormat(t,{style:"currency",currency:e}).formatToParts(0).find(i=>i.type==="currency")?.value??"$"}catch{return"$"}}function Gf(e){const t=e.replace(/[^\d.,-]/g,""),n=t.match(/,\d{1,2}$/);let r;n?r=t.replace(/\./g,"").replace(",","."):r=t.replace(/,/g,"");const s=parseFloat(r);return isNaN(s)?null:s}function Qf(e,t,n=.001){const r=e-t,s=Math.abs(r)<=n;return{difference:r,isBalanced:s,isUnderAllocated:!s&&r>0,isOverAllocated:!s&&r<0}}function us(){return`dist-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}us();const Zf={amount:"Amount",glAccount:"GL Account",taxDeductible:"Tax Deductible",amountPlaceholder:"0.00",glAccountPlaceholder:"Search GL Account",noGlAccountsFound:"No GL Accounts found. Try another search term",searching:"Searching for GL Accounts...",amountTooltip:"Enter the amount for this distribution",glAccountTooltip:"Select the General Ledger account for this distribution",taxDeductibleTooltip:"Check if this distribution is tax deductible",deleteButton:"Delete",currencySymbol:"$"},or=()=>({id:us(),amount:0,glAccount:null,isTaxDeductible:!1}),gl=({distribution:e,defaultDistribution:t,glAccounts:n=[],isLoadingGlAccounts:r=!1,onSearchGlAccounts:s,onDistributionChange:i,onAmountChange:a,onGlAccountChange:l,onTaxDeductibleChange:c,onDelete:d,canDelete:u=!0,canEditTaxDeductible:f=!0,isDisabled:p=!1,labels:m,classNames:v={},"data-testid":b,control:x,name:w,rules:N})=>{const A={...Zf,...m},S=x!==void 0&&w!==void 0,j=Wf({defaultValues:{_internal:t||or()}}),M=Ef({control:S?x:j.control,name:S?w:"_internal",rules:S?N:void 0}),[D,B]=y.useState(t||or()),F=S?M.field.value??or():e??D,_=S&&!!M.fieldState?.error,I=S&&(M.fieldState?.isTouched??!1),E=_||I,O=E&&(!F.amount||F.amount<=0),P=E&&!F.glAccount,[K,Z]=y.useState(F.glAccount?.name||""),J=y.useCallback(ie=>{const Me={...F,...ie};S&&M.field.onChange(Me),!S&&e===void 0&&B(Me),i?.(Me)},[F,e,i,S,M]),le=y.useCallback(ie=>{const Me=ie||0;J({amount:Me}),a?.(Me)},[J,a]),se=y.useCallback(ie=>{Z(ie),s?.(ie)},[s]),fe=y.useCallback(ie=>{if(ie===null){J({glAccount:null}),l?.(null);return}const Mt=n.find(Rn=>String(Rn.id)===String(ie))||null;J({glAccount:Mt}),l?.(Mt)},[n,J,l]),Y=y.useCallback(()=>{Z(""),J({glAccount:null}),l?.(null)},[J,l]),W=y.useCallback(ie=>{J({isTaxDeductible:ie}),c?.(ie)},[J,c]),de=y.useCallback(()=>{d?.()},[d]);return o.jsx(h.Card,{radius:"md",shadow:"sm","data-testid":b||"revenue-distribution-card",className:h.cn(v.base),children:o.jsxs(h.CardBody,{className:h.cn("flex flex-row flex-nowrap items-start gap-4",v.body),children:[o.jsx("div",{className:h.cn("shrink-0",v.amountContainer),children:o.jsx(h.NumberInput,{"data-testid":`${b||"revenue-distribution-card"}-amount-input`,label:o.jsxs("span",{className:"flex items-center gap-1",children:[A.amount,o.jsx(h.Tooltip,{content:A.amountTooltip,children:o.jsx(H,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),value:F.amount||void 0,onValueChange:le,labelPlacement:"outside",placeholder:A.amountPlaceholder,isWheelDisabled:!0,hideStepper:!0,variant:"bordered",isDisabled:p,isInvalid:O,errorMessage:O?"Amount is required":void 0,minValue:0,step:.01,className:v.amountInput,startContent:o.jsx("div",{className:"pointer-events-none flex items-center",children:o.jsx("span",{className:"text-default-400 text-small",children:A.currencySymbol})})})}),o.jsx("div",{className:h.cn("grow",v.glAccountContainer),children:o.jsx(h.Autocomplete,{"data-testid":`${b||"revenue-distribution-card"}-gl-account-input`,label:o.jsxs("span",{className:"flex items-center gap-1",children:[A.glAccount,o.jsx(h.Tooltip,{content:A.glAccountTooltip,children:o.jsx(H,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),isLoading:r,isClearable:!0,labelPlacement:"outside",variant:"bordered",items:n,menuTrigger:"input",inputValue:F.glAccount?.name??K,selectedKey:F.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:se,onSelectionChange:fe,onClear:Y,className:v.glAccountInput,children:ie=>o.jsx(h.AutocompleteItem,{textValue:ie.name,children:o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{children:ie.name}),ie.code&&o.jsx("span",{className:"text-xs text-default-400",children:ie.code})]})},ie.id)})}),o.jsx("div",{className:h.cn("shrink-0 pt-6 flex items-center",v.taxDeductibleContainer),children:o.jsx(h.Checkbox,{radius:"full","data-testid":`${b||"revenue-distribution-card"}-tax-deductible`,isSelected:F.isTaxDeductible,onValueChange:W,isDisabled:p||!f,className:v.taxDeductibleCheckbox,children:A.taxDeductible})}),o.jsx("div",{className:h.cn("shrink-0 pt-6",v.deleteContainer),children:o.jsx(q,{"data-testid":`${b||"revenue-distribution-card"}-delete-button`,size:"sm",color:"danger",variant:"flat",isDisabled:p||!u,onPress:de,startContent:o.jsx(H,{icon:"solar:trash-bin-trash-linear",width:16}),className:h.cn("text-danger",v.deleteButton),children:A.deleteButton})})]})})};gl.displayName="RevenueDistributionCard";const xl=({message:e="No distributions configured",icon:t="solar:document-text-outline",iconSize:n=48,showCard:r=!0,classNames:s={},renderEmpty:i})=>{if(i)return o.jsx(o.Fragment,{children:i()});const a=o.jsxs("div",{className:h.cn("flex flex-col items-center justify-center py-8",s.content),children:[o.jsx(H,{icon:t,width:n,className:h.cn("text-default-300 mb-4",s.icon)}),o.jsx("p",{className:h.cn("text-default-500 text-sm text-center",s.message),children:e})]});return r?o.jsx(h.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-empty",className:h.cn("w-full",s.base),children:o.jsx(h.CardBody,{children:a})}):o.jsx("div",{"data-testid":"revenue-distribution-empty",className:h.cn("w-full",s.base),children:a})};xl.displayName="RevenueDistributionEmpty";const Xf={title:"Error Loading Distributions",description:"An error occurred while loading the distribution configuration. Please try again."},yl=({error:e,labels:t,showCard:n=!0,color:r="danger",classNames:s={}})=>{const i={...Xf,...t},a=o.jsx(h.Alert,{"data-testid":"revenue-distribution-error-alert",color:r,title:i.title,description:e||i.description,className:s.alert});return n?o.jsx(h.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-error",className:h.cn("w-full",s.base),children:o.jsx(h.CardBody,{children:a})}):o.jsx("div",{"data-testid":"revenue-distribution-error",className:h.cn("w-full",s.base),children:a})};yl.displayName="RevenueDistributionError";const bl=({rows:e=1,showCard:t=!0,classNames:n={}})=>{const r=Array.from({length:e},(i,a)=>a),s=i=>o.jsxs("div",{className:h.cn("flex flex-row flex-nowrap items-end gap-4",n.row),children:[o.jsxs("div",{className:"shrink-0 flex flex-col gap-1",children:[o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(h.Skeleton,{className:"h-4 w-14 rounded-md"}),o.jsx(h.Skeleton,{className:"h-4 w-4 rounded-full"})]}),o.jsx(h.Skeleton,{className:"h-10 w-32 rounded-lg"})]}),o.jsxs("div",{className:"grow flex flex-col gap-1",children:[o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(h.Skeleton,{className:"h-4 w-20 rounded-md"}),o.jsx(h.Skeleton,{className:"h-4 w-4 rounded-full"})]}),o.jsx(h.Skeleton,{className:"h-10 w-full rounded-lg"})]}),o.jsxs("div",{className:"shrink-0 pb-2 flex items-center gap-2",children:[o.jsx(h.Skeleton,{className:"h-5 w-5 rounded-full"}),o.jsx(h.Skeleton,{className:"h-4 w-24 rounded-md"})]}),o.jsx("div",{className:"shrink-0 pb-2",children:o.jsx(h.Skeleton,{className:"h-8 w-20 rounded-lg"})})]},i);return t?o.jsx("div",{className:h.cn("flex flex-col gap-3",n.base),children:r.map(i=>o.jsx(h.Card,{radius:"md",shadow:"sm","data-testid":`revenue-distribution-skeleton-${i}`,children:o.jsx(h.CardBody,{children:s(i)})},i))}):o.jsx("div",{"data-testid":"revenue-distribution-skeleton",className:h.cn("flex flex-col gap-3",n.base),children:r.map(i=>s(i))})};bl.displayName="RevenueDistributionSkeleton";function jn({isOpen:e,labels:t,icon:n,isConfirming:r=!1,confirmColor:s="danger",iconTone:i="danger",onClose:a,onConfirm:l}){return o.jsx(h.Modal,{isOpen:e,size:"md",placement:"center",classNames:{base:"max-w-[440px] rounded-3xl",closeButton:"right-5 top-5 text-zinc-500"},onOpenChange:c=>!c&&a(),children:o.jsxs(h.ModalContent,{children:[o.jsxs(h.ModalHeader,{className:"flex flex-col items-start gap-4 px-7 pb-0 pt-7",children:[n&&o.jsx("span",{className:h.cn("flex h-12 w-12 shrink-0 items-center justify-center rounded-full",i==="warning"?"bg-brand/15 text-brand":"bg-danger-100 text-danger-600"),children:n}),o.jsx("span",{className:"text-lg font-semibold leading-6 text-zinc-950",children:t.title})]}),o.jsx(h.ModalBody,{className:"px-7 pb-3 pt-4",children:o.jsx("div",{className:"text-sm leading-6 text-zinc-500",children:t.description})}),o.jsxs(h.ModalFooter,{className:"grid grid-cols-2 gap-3 px-7 pb-7 pt-3",children:[o.jsx(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:t.cancel}),o.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:l,children:t.confirm})]})]})})}const eh={title:"Payment assignment",singleFund:"Single fund",splitFunds:"Split across multiple funds",saveAssignment:"Save assignment",assignSpecificFund:"Assign specific fund",addFund:"Add account",emptySingle:"You have not assign any specific fund for this opportunity",emptySplit:"Select at least two funds and assign percentages that total 100%",selectedFund:"Selected fund",percentage:"Percentage",total:"Total",totalError:"Percentages must total 100%",removeFund:"Remove fund",modalTitle:"Select an specific fund",searchPlaceholder:"Search...",glCode:"GL Code",accountName:"Specific Fund Name",type:"Type",actions:"Actions",select:"Select",noFunds:"No specific funds available",modifyAssignedFundsTitle:"Modify Assigned Funds",modifyAssignedFundsDescription:"Changing the assigned funds will only affect up and coming payments.",modifyAssignedFundsWarning:"Payments already paid will still keep the previous configuration.",modifyAssignedFundsCancel:"Cancel",modifyAssignedFundsConfirm:"Continue"},vl={base:"min-h-11 rounded-full bg-zinc-100 px-4 py-2 shadow-none",iconWrapper:"!h-4 !w-4 shrink-0 !bg-transparent !shadow-none !border-0 text-zinc-900",alertIcon:"!static !h-4 !w-4 !translate-x-0 !translate-y-0 text-zinc-900",mainWrapper:"min-w-0",title:"text-sm font-normal text-zinc-900"},$t={...vl,base:"min-h-11 rounded-2xl px-4 py-2 shadow-none",title:"text-sm font-medium"},th={inputWrapper:"h-9 rounded-xl border border-zinc-200 bg-white shadow-none hover:border-zinc-300 data-[hover=true]:border-zinc-300 group-data-[focus=true]:border-zinc-400 group-data-[focus-visible=true]:ring-0"},Mi=()=>({id:crypto.randomUUID(),fund:null,percentage:0}),nh=e=>Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e*100)/100)):0,rh=e=>e.fund!==null;function sh({mode:e,assignments:t,funds:n,labels:r,classNames:s,isSaving:i=!1,hasSavedAssignments:a=!1,isFundPickerOpen:l=!1,activeAssignmentId:c=null,footer:d,onModeChange:u,onAssignmentsChange:f,onOpenFundPicker:p,onCloseFundPicker:m,onCollapseChange:v,onSave:b}){const x={...eh,...r},w=t.filter(rh),N=w.length>0,A=y.useMemo(()=>t.reduce((Y,W)=>Y+Number(W.percentage||0),0),[t]),S=Math.round(A*100)/100,j=e==="split"&&t.some(Y=>!Y.fund||Number(Y.percentage||0)<=0),M=e==="split"&&N&&(S!==100||j),D=e==="split"&&N&&S>=100,B=e==="split"||!N,[F,_]=y.useState(null),[I,E]=y.useState(!1),O=Y=>{if(Y!==e){if(Y==="single"){const W=w[0]?.fund??null;f([{id:t[0]?.id??crypto.randomUUID(),fund:W,percentage:W?100:0}])}else{const W=w[0];f([{id:W?.id??crypto.randomUUID(),fund:W?.fund??null,percentage:W?.fund?50:0},Mi()])}u(Y)}},P=(Y,W)=>{f(t.map(de=>de.id===Y?{...de,...W}:de))},K=()=>{D||f([...t,Mi()])},Z=Y=>{if(!(t.length<=2)){if(!a){f(t.filter(W=>W.id!==Y));return}_(Y)}},J=()=>{if(!F||t.length<=2){_(null);return}f(t.filter(Y=>Y.id!==F)),_(null)},le=()=>{if(!i){if(!a){b();return}E(!0)}},se=()=>{E(!1),b()},fe=Y=>{const W=c??t.find(de=>!de.fund)?.id??t[0]?.id;W&&(f(t.map(de=>de.id===W?{...de,fund:Y,percentage:e==="single"?100:de.percentage}:de)),m())};return o.jsxs("div",{className:h.cn("vvt-pa font-sans text-zinc-900",s?.root),children:[o.jsx(h.Accordion,{variant:"splitted",defaultSelectedKeys:["installment-fund-assignment"],className:h.cn("w-full gap-0 px-0",s?.panel),itemClasses:{base:"w-full rounded-2xl border border-zinc-200 bg-white p-0 shadow-sm",trigger:h.cn("px-4 py-4",s?.header),title:"text-xl font-semibold leading-8 text-zinc-900",content:"w-full px-4 pb-4 pt-0",indicator:"text-zinc-500"},onSelectionChange:Y=>v?.(!(Y==="all"||Array.from(Y).length>0)),children:o.jsx(h.AccordionItem,{"aria-label":x.title,title:x.title,children:o.jsxs("div",{className:h.cn("flex w-full flex-col gap-4",s?.content),children:[o.jsxs("div",{className:"flex w-full items-center justify-between gap-6",children:[o.jsx(ih,{mode:e,labels:x,onModeChange:O,className:s?.tabs}),o.jsx(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:o.jsx(H,{icon:"solar:cloud-upload-outline",className:"size-4"}),isLoading:i,onPress:le,children:x.saveAssignment})]}),o.jsxs("div",{className:"flex w-full flex-col gap-4",children:[!N&&o.jsx(h.Alert,{icon:o.jsx(H,{icon:"solar:info-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,classNames:vl,color:"default",variant:"flat",title:e==="single"?x.emptySingle:x.emptySplit}),N&&o.jsx(ah,{mode:e,assignments:t,labels:x,total:A,hasTotalError:M,onSelectFund:Y=>p(Y),onRemoveFund:Z,onPercentageChange:(Y,W)=>P(Y,{percentage:nh(W)})}),B&&o.jsx("div",{className:"flex flex-wrap gap-3",children:o.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:o.jsx(U.Plus,{className:"size-5",strokeWidth:2}),isDisabled:D,onPress:()=>e==="split"&&N?K():p(),children:e==="split"&&N?x.addFund:x.assignSpecificFund})})]}),d]})},"installment-fund-assignment")}),l&&o.jsx(lh,{funds:n,labels:x,selectedFundIds:t.map(Y=>Y.fund?.id).filter(Boolean),onSelect:fe,onClose:m}),o.jsx(jn,{isOpen:I,labels:{title:x.modifyAssignedFundsTitle,description:o.jsxs(o.Fragment,{children:[o.jsx("p",{children:x.modifyAssignedFundsDescription}),o.jsx("p",{className:"mt-3",children:x.modifyAssignedFundsWarning})]}),cancel:x.modifyAssignedFundsCancel,confirm:x.modifyAssignedFundsConfirm},icon:o.jsx(H,{icon:"solar:info-circle-outline",className:"size-7"}),iconTone:"warning",confirmColor:"primary",onClose:()=>E(!1),onConfirm:se}),o.jsx(jn,{isOpen:F!==null,labels:{title:x.modifyAssignedFundsTitle,description:o.jsxs(o.Fragment,{children:[o.jsx("p",{children:x.modifyAssignedFundsDescription}),o.jsx("p",{className:"mt-3",children:x.modifyAssignedFundsWarning})]}),cancel:x.modifyAssignedFundsCancel,confirm:x.modifyAssignedFundsConfirm},icon:o.jsx(H,{icon:"solar:info-circle-outline",className:"size-7"}),iconTone:"warning",confirmColor:"primary",onClose:()=>_(null),onConfirm:J})]})}function ih({mode:e,labels:t,className:n,onModeChange:r}){return o.jsxs(h.Tabs,{"aria-label":t.title,selectedKey:e,radius:"full",size:"sm",variant:"light",className:h.cn("w-fit",n),classNames:{base:"w-fit",tabList:"h-10 w-fit rounded-full bg-zinc-200 p-1",tab:"h-8 w-auto rounded-full px-5 text-sm font-normal",cursor:"rounded-full bg-white shadow-sm",tabContent:"text-zinc-500 group-data-[selected=true]:text-zinc-900",panel:"hidden"},onSelectionChange:s=>r(s),children:[o.jsx(h.Tab,{title:t.singleFund},"single"),o.jsx(h.Tab,{title:t.splitFunds},"split")]})}function ah({mode:e,assignments:t,labels:n,total:r,hasTotalError:s,onSelectFund:i,onRemoveFund:a,onPercentageChange:l}){return o.jsxs("div",{className:"flex flex-col gap-3",children:[t.map((c,d)=>o.jsxs("div",{className:"flex min-h-15 w-full items-center gap-3 rounded-2xl border border-zinc-200 bg-white px-3 py-2",children:[o.jsx("div",{className:h.cn("flex min-h-11 min-w-0 flex-1 items-center",c.fund&&e==="single"?"justify-between":"gap-4"),children:c.fund?o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"rounded-full bg-zinc-100 px-4 py-1.5 text-sm text-zinc-950",children:[c.fund.glCode," - ",c.fund.accountName]}),o.jsx(q,{type:"button",variant:"light",radius:"full",className:"px-2 text-sm font-normal text-brand",onPress:()=>i(c.id),children:"Replace"})]}):o.jsx(q,{type:"button",variant:"light",radius:"full",className:"justify-start px-4 text-base font-normal text-zinc-900",startContent:o.jsx(U.Plus,{className:"size-5",strokeWidth:2}),onPress:()=>i(c.id),children:n.assignSpecificFund})}),e==="split"&&o.jsx("label",{className:"flex w-48 flex-none items-center",children:o.jsx(h.Input,{variant:"bordered",type:"number",min:0,max:100,step:.01,value:String(c.percentage||""),onChange:u=>l(c.id,Number(u.target.value)),endContent:o.jsx("span",{className:"text-sm text-zinc-500",children:"%"}),classNames:th})}),e==="split"&&t.length>2&&o.jsx(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:o.jsx(H,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"})})]},c.id)),e==="split"&&o.jsx(h.Alert,{icon:o.jsx(H,{icon:s?"solar:info-circle-outline":"solar:check-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,color:s?"warning":"success",variant:"flat",classNames:{...$t,base:h.cn($t.base,s?"bg-warning-50 text-warning-700":"bg-success-50 text-success-700"),iconWrapper:h.cn($t.iconWrapper,s?"text-warning-700":"text-success-700"),alertIcon:h.cn($t.alertIcon,s?"text-warning-700":"text-success-700"),title:h.cn($t.title,s?"text-warning-700":"text-success-700")},title:s?`${n.totalError} (${n.total} ${Number(r.toFixed(2))}%)`:`${n.total} ${Number(r.toFixed(2))}%`})]})}function lh({funds:e,labels:t,selectedFundIds:n,onSelect:r,onClose:s}){const[i,a]=y.useState(""),l=e.filter(c=>{const d=i.trim().toLowerCase();return d?`${c.glCode} ${c.accountName} ${c.type}`.toLowerCase().includes(d):!0});return o.jsx(h.Modal,{isOpen:!0,size:"3xl",placement:"center",scrollBehavior:"inside",classNames:{base:"max-w-3xl rounded-3xl",closeButton:"right-6 top-6 text-zinc-500"},onOpenChange:c=>!c&&s(),children:o.jsxs(h.ModalContent,{children:[o.jsx(h.ModalHeader,{className:"px-6 pt-6 text-xl font-semibold leading-7 text-zinc-950",children:t.modalTitle}),o.jsxs(h.ModalBody,{className:"px-6 pb-6",children:[o.jsx(h.Input,{variant:"bordered","aria-label":t.searchPlaceholder,value:i,placeholder:t.searchPlaceholder,onChange:c=>a(c.target.value),startContent:o.jsx(H,{icon:"solar:magnifer-outline",className:"size-5 text-zinc-500"}),classNames:{input:"text-sm placeholder:text-zinc-500",inputWrapper:"h-10 rounded-2xl border border-zinc-200 bg-white px-4 shadow-none hover:border-zinc-300 data-[hover=true]:border-zinc-300 group-data-[focus=true]:border-zinc-400 group-data-[focus-visible=true]:ring-0"}}),o.jsxs("div",{className:"mt-4 overflow-auto",children:[o.jsxs("div",{className:"grid grid-cols-[1fr_1.1fr_0.55fr_0.6fr] gap-5 border-b border-zinc-200 px-3 pb-3 text-sm font-medium leading-5 text-zinc-900",children:[o.jsx("span",{children:t.glCode}),o.jsx("span",{children:t.accountName}),o.jsx("span",{children:t.type}),o.jsx("span",{children:t.actions})]}),l.length===0&&o.jsx("div",{className:"p-4 text-sm text-zinc-500",children:t.noFunds}),l.map(c=>{const d=n.includes(c.id);return o.jsxs("div",{className:"grid grid-cols-[1fr_1.1fr_0.55fr_0.6fr] items-center gap-5 px-3 py-2.5 text-sm leading-5 text-zinc-900",children:[o.jsx("span",{children:c.glCode}),o.jsx("span",{children:c.accountName}),c.type?o.jsx("span",{className:"w-fit rounded-full bg-warning-50 px-3 py-1 text-sm font-medium text-warning-500",children:c.type}):o.jsx("span",{className:"text-sm text-zinc-400",children:"-"}),o.jsx(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:t.select})]},c.id)})]})]})]})})}function oh(){return o.jsxs("section",{className:"flex w-full flex-col gap-4 rounded-2xl border border-zinc-200 bg-white p-4 shadow-sm","aria-busy":"true",children:[o.jsxs("div",{className:"flex items-start justify-between gap-3",children:[o.jsx(h.Skeleton,{className:"h-7 w-56 rounded-lg"}),o.jsx(h.Skeleton,{className:"size-8 rounded-full"})]}),o.jsxs("div",{className:"flex items-center justify-between gap-3",children:[o.jsx(h.Skeleton,{className:"h-10 w-72 rounded-full"}),o.jsx(h.Skeleton,{className:"h-10 w-40 rounded-full"})]}),o.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_160px] items-center gap-4 rounded-2xl border border-zinc-100 p-3",children:[o.jsx(h.Skeleton,{className:"h-8 w-full max-w-xs rounded-full"}),o.jsx(h.Skeleton,{className:"h-8 w-full rounded-xl"})]}),o.jsx(h.Skeleton,{className:"h-11 w-40 rounded-full"})]})}const ch={totalAmount:"Total Amount:",remainingBalance:"Remaining Balance",amountReceived:"Amount Received:"};function dh({totalAmount:e,remainingBalance:t,amountReceived:n,currency:r="USD",locale:s="en-US",labels:i,className:a}){const l={...ch,...i},c=new Intl.NumberFormat(s,{style:"currency",currency:r});return o.jsx("div",{className:h.cn("w-full rounded-2xl border border-zinc-200 bg-white px-4 py-2.5 font-sans text-base leading-6",a),children:o.jsxs("div",{className:"flex w-full flex-wrap items-center gap-x-5 gap-y-2",children:[o.jsx(cr,{label:l.totalAmount,value:c.format(e)}),o.jsx(cr,{label:l.remainingBalance,value:c.format(t)}),o.jsx(cr,{label:l.amountReceived,value:c.format(n)})]})})}function cr({label:e,value:t}){return o.jsxs("div",{className:"flex items-center gap-3 whitespace-nowrap",children:[o.jsx("span",{className:"font-medium text-zinc-700",children:e}),o.jsx("span",{className:"font-normal text-zinc-950",children:t})]})}function dr(e,t){return e-t*Math.floor(e/t)}const wl=1721426;function rn(e,t,n,r){t=fs(e,t);let s=t-1,i=-2;return n<=2?i=0:un(t)&&(i=-1),wl-1+365*s+Math.floor(s/4)-Math.floor(s/100)+Math.floor(s/400)+Math.floor((367*n-362)/12+i+r)}function un(e){return e%4===0&&(e%100!==0||e%400===0)}function fs(e,t){return e==="BC"?1-t:t}function uh(e){let t="AD";return e<=0&&(t="BC",e=1-e),[t,e]}const fh={standard:[31,28,31,30,31,30,31,31,30,31,30,31],leapyear:[31,29,31,30,31,30,31,31,30,31,30,31]};class Pn{fromJulianDay(t){let n=t,r=n-wl,s=Math.floor(r/146097),i=dr(r,146097),a=Math.floor(i/36524),l=dr(i,36524),c=Math.floor(l/1461),d=dr(l,1461),u=Math.floor(d/365),f=s*400+a*100+c*4+u+(a!==4&&u!==4?1:0),[p,m]=uh(f),v=n-rn(p,m,1,1),b=2;n<rn(p,m,3,1)?b=0:un(m)&&(b=1);let x=Math.floor(((v+b)*12+373)/367),w=n-rn(p,m,x,1)+1;return new Kt(p,m,x,w)}toJulianDay(t){return rn(t.era,t.year,t.month,t.day)}getDaysInMonth(t){return fh[un(t.year)?"leapyear":"standard"][t.month-1]}getMonthsInYear(t){return 12}getDaysInYear(t){return un(t.year)?366:365}getMaximumMonthsInYear(){return 12}getMaximumDaysInMonth(){return 31}getYearsInEra(t){return 9999}getEras(){return["BC","AD"]}isInverseEra(t){return t.era==="BC"}balanceDate(t){t.year<=0&&(t.era=t.era==="BC"?"AD":"BC",t.year=1-t.year)}constructor(){this.identifier="gregory"}}function hh(e,t){var n,r,s,i;return(i=(s=(n=e.isEqual)===null||n===void 0?void 0:n.call(e,t))!==null&&s!==void 0?s:(r=t.isEqual)===null||r===void 0?void 0:r.call(t,e))!==null&&i!==void 0?i:e.identifier===t.identifier}function kl(e,t){return e.calendar.toJulianDay(e)-t.calendar.toJulianDay(t)}function mh(e,t){return Ei(e)-Ei(t)}function Ei(e){return e.hour*36e5+e.minute*6e4+e.second*1e3+e.millisecond}let ur=null;function Nl(){return ur==null&&(ur=new Intl.DateTimeFormat().resolvedOptions().timeZone),ur}function Ti(e){e=hs(e,new Pn);let t=fs(e.era,e.year);return Sl(t,e.month,e.day,e.hour,e.minute,e.second,e.millisecond)}function Sl(e,t,n,r,s,i,a){let l=new Date;return l.setUTCHours(r,s,i,a),l.setUTCFullYear(e,t-1,n),l.getTime()}function Di(e,t){if(t==="UTC")return 0;if(e>0&&t===Nl())return new Date(e).getTimezoneOffset()*-6e4;let{year:n,month:r,day:s,hour:i,minute:a,second:l}=Cl(e,t);return Sl(n,r,s,i,a,l,0)-Math.floor(e/1e3)*1e3}const Ii=new Map;function Cl(e,t){let n=Ii.get(t);n||(n=new Intl.DateTimeFormat("en-US",{timeZone:t,hour12:!1,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}),Ii.set(t,n));let r=n.formatToParts(new Date(e)),s={};for(let i of r)i.type!=="literal"&&(s[i.type]=i.value);return{year:s.era==="BC"||s.era==="B"?-s.year+1:+s.year,month:+s.month,day:+s.day,hour:s.hour==="24"?0:+s.hour,minute:+s.minute,second:+s.second}}const $i=864e5;function ph(e,t,n,r){return(n===r?[n]:[n,r]).filter(i=>gh(e,t,i))}function gh(e,t,n){let r=Cl(n,t);return e.year===r.year&&e.month===r.month&&e.day===r.day&&e.hour===r.hour&&e.minute===r.minute&&e.second===r.second}function xh(e,t,n="compatible"){let r=Al(e);if(t==="UTC")return Ti(r);if(t===Nl()&&n==="compatible"){r=hs(r,new Pn);let c=new Date,d=fs(r.era,r.year);return c.setFullYear(d,r.month-1,r.day),c.setHours(r.hour,r.minute,r.second,r.millisecond),c.getTime()}let s=Ti(r),i=Di(s-$i,t),a=Di(s+$i,t),l=ph(r,t,s-i,s-a);if(l.length===1)return l[0];if(l.length>1)switch(n){case"compatible":case"earlier":return l[0];case"later":return l[l.length-1];case"reject":throw new RangeError("Multiple possible absolute times found")}switch(n){case"earlier":return Math.min(s-i,s-a);case"compatible":case"later":return Math.max(s-i,s-a);case"reject":throw new RangeError("No such absolute time found")}}function jl(e,t,n="compatible"){return new Date(xh(e,t,n))}function Al(e,t){let n=0,r=0,s=0,i=0;if("timeZone"in e)({hour:n,minute:r,second:s,millisecond:i}=e);else if("hour"in e&&!t)return e;return t&&({hour:n,minute:r,second:s,millisecond:i}=t),new An(e.calendar,e.era,e.year,e.month,e.day,n,r,s,i)}function hs(e,t){if(hh(e.calendar,t))return e;let n=t.fromJulianDay(e.calendar.toJulianDay(e)),r=e.copy();return r.calendar=t,r.era=n.era,r.year=n.year,r.month=n.month,r.day=n.day,At(r),r}function ms(e,t){let n=e.copy(),r="hour"in n?Nh(n,t):0;Lr(n,t.years||0),n.calendar.balanceYearMonth&&n.calendar.balanceYearMonth(n,e),n.month+=t.months||0,Fr(n),Ml(n),n.day+=(t.weeks||0)*7,n.day+=t.days||0,n.day+=r,yh(n),n.calendar.balanceDate&&n.calendar.balanceDate(n),n.year<1&&(n.year=1,n.month=1,n.day=1);let s=n.calendar.getYearsInEra(n);if(n.year>s){var i,a;let c=(i=(a=n.calendar).isInverseEra)===null||i===void 0?void 0:i.call(a,n);n.year=s,n.month=c?1:n.calendar.getMonthsInYear(n),n.day=c?1:n.calendar.getDaysInMonth(n)}n.month<1&&(n.month=1,n.day=1);let l=n.calendar.getMonthsInYear(n);return n.month>l&&(n.month=l,n.day=n.calendar.getDaysInMonth(n)),n.day=Math.max(1,Math.min(n.calendar.getDaysInMonth(n),n.day)),n}function Lr(e,t){var n,r;!((n=(r=e.calendar).isInverseEra)===null||n===void 0)&&n.call(r,e)&&(t=-t),e.year+=t}function Fr(e){for(;e.month<1;)Lr(e,-1),e.month+=e.calendar.getMonthsInYear(e);let t=0;for(;e.month>(t=e.calendar.getMonthsInYear(e));)e.month-=t,Lr(e,1)}function yh(e){for(;e.day<1;)e.month--,Fr(e),e.day+=e.calendar.getDaysInMonth(e);for(;e.day>e.calendar.getDaysInMonth(e);)e.day-=e.calendar.getDaysInMonth(e),e.month++,Fr(e)}function Ml(e){e.month=Math.max(1,Math.min(e.calendar.getMonthsInYear(e),e.month)),e.day=Math.max(1,Math.min(e.calendar.getDaysInMonth(e),e.day))}function At(e){e.calendar.constrainDate&&e.calendar.constrainDate(e),e.year=Math.max(1,Math.min(e.calendar.getYearsInEra(e),e.year)),Ml(e)}function bh(e){let t={};for(let n in e)typeof e[n]=="number"&&(t[n]=-e[n]);return t}function El(e,t){return ms(e,bh(t))}function Tl(e,t){let n=e.copy();return t.era!=null&&(n.era=t.era),t.year!=null&&(n.year=t.year),t.month!=null&&(n.month=t.month),t.day!=null&&(n.day=t.day),At(n),n}function vh(e,t){let n=e.copy();return t.hour!=null&&(n.hour=t.hour),t.minute!=null&&(n.minute=t.minute),t.second!=null&&(n.second=t.second),t.millisecond!=null&&(n.millisecond=t.millisecond),kh(n),n}function wh(e){e.second+=Math.floor(e.millisecond/1e3),e.millisecond=sn(e.millisecond,1e3),e.minute+=Math.floor(e.second/60),e.second=sn(e.second,60),e.hour+=Math.floor(e.minute/60),e.minute=sn(e.minute,60);let t=Math.floor(e.hour/24);return e.hour=sn(e.hour,24),t}function kh(e){e.millisecond=Math.max(0,Math.min(e.millisecond,1e3)),e.second=Math.max(0,Math.min(e.second,59)),e.minute=Math.max(0,Math.min(e.minute,59)),e.hour=Math.max(0,Math.min(e.hour,23))}function sn(e,t){let n=e%t;return n<0&&(n+=t),n}function Nh(e,t){return e.hour+=t.hours||0,e.minute+=t.minutes||0,e.second+=t.seconds||0,e.millisecond+=t.milliseconds||0,wh(e)}function Dl(e,t,n,r){let s=e.copy();switch(t){case"era":{let l=e.calendar.getEras(),c=l.indexOf(e.era);if(c<0)throw new Error("Invalid era: "+e.era);c=Xe(c,n,0,l.length-1,r?.round),s.era=l[c],At(s);break}case"year":var i,a;!((i=(a=s.calendar).isInverseEra)===null||i===void 0)&&i.call(a,s)&&(n=-n),s.year=Xe(e.year,n,-1/0,9999,r?.round),s.year===-1/0&&(s.year=1),s.calendar.balanceYearMonth&&s.calendar.balanceYearMonth(s,e);break;case"month":s.month=Xe(e.month,n,1,e.calendar.getMonthsInYear(e),r?.round);break;case"day":s.day=Xe(e.day,n,1,e.calendar.getDaysInMonth(e),r?.round);break;default:throw new Error("Unsupported field "+t)}return e.calendar.balanceDate&&e.calendar.balanceDate(s),At(s),s}function Sh(e,t,n,r){let s=e.copy();switch(t){case"hour":{let i=e.hour,a=0,l=23;if(r?.hourCycle===12){let c=i>=12;a=c?12:0,l=c?23:11}s.hour=Xe(i,n,a,l,r?.round);break}case"minute":s.minute=Xe(e.minute,n,0,59,r?.round);break;case"second":s.second=Xe(e.second,n,0,59,r?.round);break;case"millisecond":s.millisecond=Xe(e.millisecond,n,0,999,r?.round);break;default:throw new Error("Unsupported field "+t)}return s}function Xe(e,t,n,r,s=!1){if(s){e+=Math.sign(t),e<n&&(e=r);let i=Math.abs(t);t>0?e=Math.ceil(e/i)*i:e=Math.floor(e/i)*i,e>r&&(e=n)}else e+=t,e<n?e=r-(n-e-1):e>r&&(e=n+(e-r-1));return e}const Ch=/^([+-]\d{6}|\d{4})-(\d{2})-(\d{2})$/,jh=/^([+-]\d{6}|\d{4})-(\d{2})-(\d{2})(?:T(\d{2}))?(?::(\d{2}))?(?::(\d{2}))?(\.\d+)?(?:(?:([+-]\d{2})(?::?(\d{2}))?)|Z)$/;function Ah(e){let t=e.match(Ch);if(!t)throw jh.test(e)?new Error(`Invalid ISO 8601 date string: ${e}. Use parseAbsolute() instead.`):new Error("Invalid ISO 8601 date string: "+e);let n=new Kt(fr(t[1],0,9999),fr(t[2],1,12),1);return n.day=fr(t[3],1,n.calendar.getDaysInMonth(n)),n}function fr(e,t,n){let r=Number(e);if(r<t||r>n)throw new RangeError(`Value out of range: ${t} <= ${r} <= ${n}`);return r}function Mh(e){return`${String(e.hour).padStart(2,"0")}:${String(e.minute).padStart(2,"0")}:${String(e.second).padStart(2,"0")}${e.millisecond?String(e.millisecond/1e3).slice(1):""}`}function Il(e){let t=hs(e,new Pn),n;return t.era==="BC"?n=t.year===1?"0000":"-"+String(Math.abs(1-t.year)).padStart(6,"00"):n=String(t.year).padStart(4,"0"),`${n}-${String(t.month).padStart(2,"0")}-${String(t.day).padStart(2,"0")}`}function Eh(e){return`${Il(e)}T${Mh(e)}`}function Th(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function $l(e,t,n){Th(e,t),t.set(e,n)}function Ol(e){let t=typeof e[0]=="object"?e.shift():new Pn,n;if(typeof e[0]=="string")n=e.shift();else{let a=t.getEras();n=a[a.length-1]}let r=e.shift(),s=e.shift(),i=e.shift();return[t,n,r,s,i]}var Dh=new WeakMap;class Kt{copy(){return this.era?new Kt(this.calendar,this.era,this.year,this.month,this.day):new Kt(this.calendar,this.year,this.month,this.day)}add(t){return ms(this,t)}subtract(t){return El(this,t)}set(t){return Tl(this,t)}cycle(t,n,r){return Dl(this,t,n,r)}toDate(t){return jl(this,t)}toString(){return Il(this)}compare(t){return kl(this,t)}constructor(...t){$l(this,Dh,{writable:!0,value:void 0});let[n,r,s,i,a]=Ol(t);this.calendar=n,this.era=r,this.year=s,this.month=i,this.day=a,At(this)}}var Ih=new WeakMap;class An{copy(){return this.era?new An(this.calendar,this.era,this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond):new An(this.calendar,this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond)}add(t){return ms(this,t)}subtract(t){return El(this,t)}set(t){return Tl(vh(this,t),t)}cycle(t,n,r){switch(t){case"era":case"year":case"month":case"day":return Dl(this,t,n,r);default:return Sh(this,t,n,r)}}toDate(t,n){return jl(this,t,n)}toString(){return Eh(this)}compare(t){let n=kl(this,t);return n===0?mh(this,Al(t)):n}constructor(...t){$l(this,Ih,{writable:!0,value:void 0});let[n,r,s,i,a]=Ol(t);this.calendar=n,this.era=r,this.year=s,this.month=i,this.day=a,this.hour=t.shift()||0,this.minute=t.shift()||0,this.second=t.shift()||0,this.millisecond=t.shift()||0,At(this)}}const $h={monthly:1,quarterly:3,annual:12};function Ll(e,t){const n=Math.max(1,Math.floor(t.numberOfInstallments||1)),r=Math.floor(e*100/n),i=Math.round(e*100)-r*n,a=new Date(`${t.firstInstallmentDate}T00:00:00`),l=$h[t.frequency];return Array.from({length:n},(c,d)=>{const u=new Date(a);return u.setMonth(a.getMonth()+d*l),{id:crypto.randomUUID(),dueDate:u.toISOString().slice(0,10),amount:(r+(d<i?1:0))/100}})}const Oh={title:"Payments",automaticMode:"Auto",manualMode:"Manual",createInstallments:"Create Payments",generateSchedule:"Generate Schedule",saveInstallments:"Save Payments",addInstallment:"Add Payment",emptyAutomatic:"No payments have been generated for this opportunity",emptyManual:"Add payments with custom dates and amounts",numberOfInstallments:"Number of payments",frequency:"Frequency",firstInstallmentDate:"First payment date",installment:"Payment",dueDate:"Due date",amount:"Amount",total:"Total",remaining:"Remaining",deleteInstallment:"Delete installment",monthly:"Monthly",quarterly:"Quarterly",annual:"Annual",totalError:"Payment total must equal donation amount"},Lh=["monthly","quarterly","annual"],Fl={base:"min-h-11 rounded-full bg-zinc-100 px-4 py-2 shadow-none",iconWrapper:"!h-4 !w-4 shrink-0 !bg-transparent !shadow-none !border-0 text-zinc-900",alertIcon:"!static !h-4 !w-4 !translate-x-0 !translate-y-0 text-zinc-900",mainWrapper:"min-w-0",title:"text-sm font-normal text-zinc-950"},Mn={label:"text-sm font-normal text-zinc-950",inputWrapper:"h-9 rounded-xl border border-zinc-200 bg-white shadow-none hover:border-zinc-300 data-[hover=true]:border-zinc-300 group-data-[focus=true]:border-zinc-400 group-data-[focus-visible=true]:ring-0"},Fh={label:"text-sm font-normal text-zinc-950",trigger:"h-9 rounded-xl border border-zinc-200 bg-white shadow-none hover:border-zinc-300 data-[hover=true]:border-zinc-300 data-[focus=true]:border-zinc-400 data-[focus-visible=true]:ring-0"},Oi=()=>({id:crypto.randomUUID(),dueDate:new Date().toISOString().slice(0,10),amount:0}),Pr=e=>Math.round(e*100)/100,Ph=(e,t)=>{const n=new Date(`${e}T00:00:00`);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(t,{month:"short",day:"numeric",year:"numeric"}).format(n)},Pl=e=>{if(!e)return null;try{return Ah(e)}catch{return null}};function Rh({mode:e,donationAmount:t,currency:n="USD",locale:r="en-US",installments:s,automaticSettings:i,labels:a,classNames:l,isSaving:c=!1,isModeSwitchDisabled:d=!1,onModeChange:u,onAutomaticSettingsChange:f,onInstallmentsChange:p,onSave:m}){const v={...Oh,...a},b=y.useMemo(()=>new Intl.NumberFormat(r,{style:"currency",currency:n}),[n,r]),x=e==="automatic"?Ll(t,i):s,w=y.useMemo(()=>Pr(x.reduce((M,D)=>M+Number(D.amount||0),0)),[x]),N=M=>{M!==e&&(u(M),M==="manual"&&s.length===0&&p([Oi()]))},A=(M,D)=>{s.find(F=>F.id===M)?.status!=="paid"&&p(s.map(F=>F.id===M?{...F,...D}:F))},S=()=>{p([...s,Oi()])},j=M=>{s.find(B=>B.id===M)?.status!=="paid"&&p(s.filter(B=>B.id!==M))};return o.jsx("div",{className:h.cn("vvt-ps font-sans text-zinc-900",l?.root),children:o.jsx(h.Accordion,{variant:"splitted",defaultSelectedKeys:["installment-schedule"],className:h.cn("w-full gap-0 px-0",l?.panel),itemClasses:{base:"w-full rounded-2xl border border-zinc-200 bg-white p-0 shadow-sm",trigger:h.cn("px-4 py-4",l?.header),title:"text-xl font-semibold leading-8 text-zinc-900",content:"w-full px-4 pb-4 pt-0",indicator:"text-zinc-500"},children:o.jsx(h.AccordionItem,{"aria-label":v.title,title:v.title,children:o.jsxs("div",{className:h.cn("flex w-full flex-col gap-4",l?.content),children:[o.jsxs("div",{className:"flex w-full items-center justify-between gap-6",children:[o.jsx(zh,{mode:e,labels:v,onModeChange:N,isDisabled:d,className:l?.tabs}),o.jsx(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:o.jsx(H,{icon:"solar:cloud-upload-outline",className:"size-4"}),isLoading:c,onPress:m,children:v.saveInstallments})]}),o.jsxs("div",{className:"flex w-full flex-col gap-4",children:[e==="automatic"&&o.jsx(Bh,{settings:i,labels:v,onSettingsChange:f}),x.length===0&&o.jsx(h.Alert,{icon:o.jsx(H,{icon:"solar:info-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,classNames:Fl,color:"default",variant:"flat",title:e==="automatic"?v.emptyAutomatic:v.emptyManual}),x.length>0&&o.jsx(_h,{mode:e,installments:x,labels:v,formatter:b,locale:r,onUpdateInstallment:A,onRemoveInstallment:j}),e==="manual"&&o.jsx("div",{className:"flex flex-wrap gap-3",children:o.jsx(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:o.jsx(U.Plus,{className:"size-5",strokeWidth:2}),onPress:S,children:v.addInstallment})}),o.jsx(Hh,{total:w,donationAmount:t,difference:Pr(t-w),hasTotalError:e==="manual"&&Math.abs(t-w)>.009,mode:e,installmentCount:x.length,formatter:b})]})]})},"installment-schedule")})})}function zh({mode:e,labels:t,className:n,isDisabled:r=!1,onModeChange:s}){return o.jsxs(h.Tabs,{"aria-label":t.title,selectedKey:e,isDisabled:r,radius:"full",size:"sm",variant:"light",className:h.cn("w-fit",n),classNames:{base:"w-fit",tabList:"h-10 w-fit rounded-full bg-zinc-200 p-1",tab:"h-8 w-auto rounded-full px-5 text-sm font-normal",cursor:"rounded-full bg-white shadow-sm",tabContent:"text-zinc-500 group-data-[selected=true]:text-zinc-900",panel:"hidden"},onSelectionChange:i=>s(i),children:[o.jsx(h.Tab,{title:t.automaticMode},"automatic"),o.jsx(h.Tab,{title:t.manualMode},"manual")]})}function Bh({settings:e,labels:t,onSettingsChange:n}){return o.jsxs("div",{className:"grid gap-4",style:{gridTemplateColumns:"repeat(3, minmax(0, 1fr))"},children:[o.jsx("div",{className:"min-w-0",children:o.jsx(h.Input,{variant:"bordered",label:t.numberOfInstallments,labelPlacement:"outside",type:"number",min:1,step:1,value:e.numberOfInstallments>0?String(e.numberOfInstallments):"",onWheel:r=>r.currentTarget.blur(),onChange:r=>{const s=r.target.value;n({...e,numberOfInstallments:s===""?0:Math.max(1,Number(s))})},classNames:Mn})}),o.jsx("div",{className:"min-w-0",children:o.jsx(pt,{variant:"bordered",label:t.frequency,labelPlacement:"outside",selectedKeys:[e.frequency],onSelectionChange:r=>{const s=Array.from(r)[0];typeof s=="string"&&n({...e,frequency:s})},classNames:Fh,children:Lh.map(r=>o.jsx(h.SelectItem,{textValue:t[r],children:t[r]},r))})}),o.jsx("div",{className:"min-w-0",children:o.jsx(h.DatePicker,{variant:"bordered",label:t.firstInstallmentDate,labelPlacement:"outside",value:Pl(e.firstInstallmentDate),onChange:r=>n({...e,firstInstallmentDate:r?r.toString():""}),startContent:o.jsx(H,{icon:"solar:calendar-outline",className:"size-4 text-zinc-500"}),classNames:Mn})})]})}function _h({mode:e,installments:t,labels:n,formatter:r,locale:s,onUpdateInstallment:i,onRemoveInstallment:a}){return e==="automatic"?o.jsx("div",{className:"rounded-2xl border border-zinc-200 bg-zinc-50 p-4",children:o.jsx("div",{className:h.cn("flex flex-col gap-3",t.length>5&&"max-h-[264px] overflow-y-auto pr-2"),children:t.map((l,c)=>o.jsxs("div",{className:h.cn("flex min-h-10 items-center justify-between rounded-xl px-4 py-2 text-base",c===0&&"border border-brand/25 bg-brand/5 text-brand"),children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("span",{children:["#",c+1]}),o.jsx("span",{children:"▪"}),o.jsx("span",{children:Ph(l.dueDate,s)}),c===0&&o.jsx(h.Chip,{size:"sm",radius:"full",className:"h-6 bg-brand px-2 text-xs font-semibold text-white",children:"First charge"})]}),o.jsx("span",{className:"text-zinc-950",children:r.format(l.amount)})]},l.id))})}):o.jsx("div",{className:"flex flex-col gap-2",children:t.map((l,c)=>o.jsxs("div",{className:"flex w-full items-center gap-4",children:[o.jsx("div",{className:"min-w-0 flex-1",children:o.jsx(h.DatePicker,{variant:"bordered","aria-label":`${n.dueDate} ${c+1}`,isDisabled:l.status==="paid",value:Pl(l.dueDate),onChange:d=>i(l.id,{dueDate:d?d.toString():""}),classNames:Mn})}),o.jsx("div",{className:"min-w-0 flex-1",children:o.jsx(h.Input,{variant:"bordered",type:"number",min:0,step:.01,isDisabled:l.status==="paid",value:String(l.amount||""),onChange:d=>i(l.id,{amount:Pr(Number(d.target.value||0))}),startContent:o.jsx("span",{className:"text-zinc-900",children:"$"}),classNames:Mn})}),o.jsx(Vh,{isDisabled:t.length<=1,isPaid:l.status==="paid",label:n.deleteInstallment,onRemove:()=>a(l.id)})]},l.id))})}function Vh({isDisabled:e,isPaid:t,label:n,onRemove:r}){const s=o.jsx(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:e||t,onPress:r,"aria-label":n,children:o.jsx(H,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"})});return t?o.jsx(h.Tooltip,{content:"This payment cannot be edited or deleted because it has already been paid.",placement:"top",children:o.jsx("span",{className:"inline-flex",children:s})}):s}function Hh({total:e,donationAmount:t,difference:n,hasTotalError:r,mode:s,installmentCount:i,formatter:a}){const l=i>0?e/i:0,c=s==="automatic"?o.jsxs("span",{children:["Saving will create ",o.jsx("strong",{children:i})," scheduled payment records of"," ",o.jsx("strong",{children:a.format(l)})," each."]}):o.jsxs("span",{children:["Total scheduled: ",o.jsx("strong",{children:a.format(e)})," /"," ",o.jsx("strong",{children:a.format(t)}),"."]}),d=s==="automatic"?`Total: ${a.format(e)}`:r?`Missing: ${a.format(n)}`:`Remaining: ${a.format(0)}`;return o.jsx(h.Alert,{icon:o.jsx(H,{icon:"solar:info-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,color:"default",variant:"flat",classNames:Fl,endContent:o.jsx("span",{className:"whitespace-nowrap",children:d}),title:c})}function Uh(){return o.jsxs("section",{className:"flex w-full flex-col gap-4 rounded-2xl border border-zinc-200 bg-white p-4 shadow-sm","aria-busy":"true",children:[o.jsxs("div",{className:"flex items-start justify-between gap-3",children:[o.jsx(h.Skeleton,{className:"h-7 w-56 rounded-lg"}),o.jsx(h.Skeleton,{className:"size-8 rounded-full"})]}),o.jsxs("div",{className:"flex items-center justify-between gap-3",children:[o.jsx(h.Skeleton,{className:"h-10 w-72 rounded-full"}),o.jsx(h.Skeleton,{className:"h-10 w-40 rounded-full"})]}),o.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[o.jsxs("div",{className:"flex w-full max-w-[280px] flex-col gap-2",children:[o.jsx(h.Skeleton,{className:"h-4 w-36 rounded-md"}),o.jsx(h.Skeleton,{className:"h-9 w-full rounded-xl"})]}),o.jsx(h.Skeleton,{className:"h-9 w-36 rounded-full"})]}),o.jsx("div",{className:"flex flex-col gap-3",children:Array.from({length:4}).map((e,t)=>o.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_160px] items-center gap-4 rounded-2xl border border-zinc-100 p-3",children:[o.jsx(h.Skeleton,{className:"h-8 w-full max-w-xs rounded-full"}),o.jsx(h.Skeleton,{className:"h-8 w-full rounded-xl"})]},t))})]})}const Li={paid:"bg-emerald-50 text-emerald-700",fulfilled:"bg-emerald-50 text-emerald-700",scheduled:"bg-blue-50 text-blue-700",failed:"bg-red-50 text-red-700",cancelled:"bg-zinc-100 text-zinc-600",refunded:"bg-zinc-100 text-zinc-600"},Fi={paid:"Paid",fulfilled:"Paid",scheduled:"Scheduled",failed:"Failed",cancelled:"Cancelled",refunded:"Refunded"},qh={title:"Payments",searchLabel:"Search a payment",searchPlaceholder:"Search a payment by ID or Date...",editInstallments:"Edit Payment",installmentId:"Payment ID",amount:"Amount",scheduledDate:"Scheduled Date",status:"Status",actions:"Actions",payNow:"Pay now",sendLink:"Send Link",sendLinkDescription:"Send a payment link to the contact",dangerZone:"Danger zone",deleteInstallment:"Delete Payment",deleteInstallmentDescription:"Remove Payment from Opportunity",deleteInstallmentConfirmationTitle:"Delete Payment",deleteInstallmentConfirmationDescription:o.jsxs(o.Fragment,{children:["Are you sure you want to delete this payment? ",o.jsx("strong",{children:"This action cannot be undone."})]}),deleteInstallmentConfirmationCancel:"Cancel",deleteInstallmentConfirmationConfirm:"Confirm",noInstallmentsFound:"No payments found."};function Wh({installments:e,currency:t,locale:n="en-US",labels:r,isSaving:s=!1,onEditInstallments:i,onPayInstallment:a,onDeleteInstallment:l}){const c={...qh,...r},[d,u]=y.useState(""),f=new Intl.NumberFormat(n,{style:"currency",currency:t}),p=y.useMemo(()=>{const m=d.trim().toLowerCase();return m?e.filter(v=>{const b=v.status??"scheduled";return[v.id,v.amount,v.dueDate,Pi(v.dueDate,n),b,Fi[b]??b].join(" ").toLowerCase().includes(m)}):e},[n,e,d]);return o.jsx("div",{className:"vvt-ps w-full font-sans text-zinc-900",children:o.jsx(h.Accordion,{variant:"splitted",defaultSelectedKeys:["installment-table"],className:"w-full gap-0 px-0",itemClasses:{base:"w-full rounded-2xl border border-zinc-200 bg-white p-0 shadow-sm",trigger:"px-4 py-4",title:"text-xl font-semibold leading-8 text-zinc-900",content:"w-full px-4 pb-4 pt-0",indicator:"text-zinc-500"},children:o.jsx(h.AccordionItem,{"aria-label":c.title,title:c.title,children:o.jsxs("div",{className:"flex w-full flex-col gap-4",children:[o.jsxs("div",{className:"flex w-full items-end justify-between gap-6",children:[o.jsxs("div",{className:"w-full max-w-[280px]",children:[o.jsx("label",{className:"mb-1 block text-sm font-normal text-zinc-950",children:c.searchLabel}),o.jsx(h.Input,{variant:"bordered",size:"sm",value:d,placeholder:c.searchPlaceholder,onChange:m=>u(m.target.value),startContent:o.jsx(H,{icon:"solar:magnifer-outline",className:"size-4 text-zinc-500"}),classNames:{inputWrapper:"h-9 rounded-xl border border-zinc-200 bg-white shadow-none hover:border-zinc-300 data-[hover=true]:border-zinc-300 group-data-[focus=true]:border-zinc-400 group-data-[focus-visible=true]:ring-0"}})]}),o.jsx(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:o.jsx(H,{icon:"solar:pen-outline",className:"size-4"}),isLoading:s,onPress:i,children:c.editInstallments})]}),o.jsx("div",{className:"w-full overflow-hidden",children:o.jsxs("table",{className:"w-full table-fixed border-collapse text-left text-sm",children:[o.jsxs("colgroup",{children:[o.jsx("col",{className:"w-[6%]"}),o.jsx("col",{className:"w-[25%]"}),o.jsx("col",{className:"w-[12%]"}),o.jsx("col",{className:"w-[16%]"}),o.jsx("col",{className:"w-[17%]"}),o.jsx("col",{className:"w-[24%]"})]}),o.jsx("thead",{children:o.jsxs("tr",{className:"border-b border-zinc-200 text-zinc-900",children:[o.jsx("th",{className:"w-14 px-2 py-3 font-medium",children:"#"}),o.jsx("th",{className:"px-2 py-3 font-medium",children:c.installmentId}),o.jsx("th",{className:"px-2 py-3 font-medium",children:c.amount}),o.jsx("th",{className:"px-2 py-3 font-medium",children:c.scheduledDate}),o.jsx("th",{className:"px-2 py-3 font-medium",children:c.status}),o.jsx("th",{className:"px-2 py-3 font-medium",children:c.actions})]})}),o.jsxs("tbody",{children:[p.map((m,v)=>{const b=m.status??"scheduled";return o.jsxs("tr",{className:"text-zinc-500",children:[o.jsx("td",{className:"px-2 py-3",children:v+1}),o.jsx("td",{className:"px-2 py-3",children:o.jsx("span",{className:"block max-w-full truncate",children:m.id||`PMT-${v+1}`})}),o.jsx("td",{className:"px-2 py-3",children:f.format(m.amount)}),o.jsx("td",{className:"px-2 py-3",children:Pi(m.dueDate,n)}),o.jsx("td",{className:"px-2 py-3",children:o.jsx(h.Chip,{size:"sm",radius:"full",className:h.cn("h-8 min-w-[118px] justify-center px-4 text-sm font-normal",Li[b]??Li.scheduled),startContent:o.jsx(Jh,{status:b}),children:Fi[b]??b})}),o.jsx("td",{className:"px-2 py-3",children:o.jsxs("div",{className:"flex min-w-[154px] items-center justify-start gap-2",children:[o.jsx(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:o.jsx(H,{icon:"solar:dollar-minimalistic-outline",className:"size-4"}),onPress:()=>a?.(m),children:c.payNow}),o.jsx(Kh,{isPaid:b==="paid"||b==="fulfilled",labels:c,onDelete:()=>l(m.id)})]})})]},m.id)}),p.length===0&&o.jsx("tr",{children:o.jsx("td",{colSpan:6,className:"px-2 py-6 text-center text-zinc-500",children:c.noInstallmentsFound})})]})]})})]})},"installment-table")})})}function Kh({isPaid:e,labels:t,onDelete:n}){const[r,s]=y.useState(!1);return o.jsxs(o.Fragment,{children:[o.jsxs(h.Dropdown,{placement:"bottom-end",radius:"lg",children:[o.jsx(h.DropdownTrigger,{children:o.jsx(q,{type:"button",isIconOnly:!0,size:"sm",variant:"light",className:"text-zinc-900","aria-label":"More actions",children:o.jsx(H,{icon:"solar:menu-dots-bold",className:"size-4"})})}),o.jsxs(h.DropdownMenu,{"aria-label":"Installment actions",disabledKeys:e?["delete"]:[],className:"w-72 p-2",onAction:i=>{i==="delete"&&!e&&s(!0)},children:[o.jsx(h.DropdownSection,{title:"Actions",showDivider:!0,children:o.jsx(h.DropdownItem,{textValue:t.sendLink,description:t.sendLinkDescription,startContent:o.jsx(H,{icon:"solar:link-outline",className:"size-5 text-zinc-500"}),children:t.sendLink},"send-link")}),o.jsx(h.DropdownSection,{title:t.dangerZone,children:o.jsx(h.DropdownItem,{textValue:t.deleteInstallment,className:"text-danger-600",color:"danger",description:t.deleteInstallmentDescription,startContent:o.jsx(H,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"}),children:t.deleteInstallment},"delete")})]})]}),o.jsx(jn,{isOpen:r,labels:{title:t.deleteInstallmentConfirmationTitle,description:t.deleteInstallmentConfirmationDescription,cancel:t.deleteInstallmentConfirmationCancel,confirm:t.deleteInstallmentConfirmationConfirm},icon:o.jsx(H,{icon:"solar:danger-triangle-outline",className:"size-7"}),confirmColor:"danger",onClose:()=>s(!1),onConfirm:()=>{s(!1),n()}})]})}function Jh({status:e}){return e==="paid"||e==="fulfilled"?o.jsx(H,{icon:"solar:check-circle-bold",className:"size-3"}):e==="failed"?o.jsx(H,{icon:"solar:close-circle-bold",className:"size-3"}):o.jsx(H,{icon:"solar:calendar-outline",className:"size-3"})}function Pi(e,t){const n=new Date(`${e}T00:00:00`);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(t,{month:"short",day:"numeric",year:"numeric"}).format(n)}const Yh={title:"Select Membership",renewalTitle:"Automatic Renewal",renewalDescription:"Membership will automatically renew at the end of each period"},Gh=({cards:e,locale:t,currency:n,listHeightClassName:r="",labels:s,showRenewal:i=!0,defaultRenewalValue:a=!1,initialSelectedMembershipId:l=null,allowReselect:c=!0,onRenewalChange:d,onCardSelect:u,className:f=""})=>{const p=Array.isArray(e)?e:[],[m,v]=y.useState(l),[b,x]=y.useState(a),w={...Yh,...s};y.useEffect(()=>{v(l)},[l]);const N=S=>{if(S===m){c&&u?.(S);return}v(S),u?.(S)},A=S=>{x(S),d?.(S)};return o.jsxs("div",{className:h.cn("w-full flex flex-col gap-4 items-start p-4 h-svh",f),"data-testid":"membership-select-cards",children:[o.jsx("span",{className:"hidden","data-testid":"membership-select-cards-selected-id",children:m??""}),o.jsx("p",{className:"text-2xl font-semibold text-left","data-testid":"membership-select-cards-title",children:w.title}),i&&o.jsx(zl,{title:w.renewalTitle,description:w.renewalDescription,value:b,onValueChange:A}),o.jsx("div",{className:h.cn("w-full min-h-0 flex flex-col gap-4 overflow-y-auto",r===""?"flex-1":h.cn("shrink-0",r)),"data-testid":"membership-select-cards-list",children:p.map(S=>o.jsx(Rl,{itemKey:S.id,name:S.name,type:S.type,price:S.price,locale:t,currency:n,isSelected:m===S.id,onSelect:N},S.id))})]})},Rl=({itemKey:e,name:t,type:n,price:r,locale:s="en-US",currency:i="USD",isSelected:a=!1,onSelect:l,className:c=""})=>{const d=new Intl.NumberFormat(s,{style:"currency",currency:i,minimumFractionDigits:0,maximumFractionDigits:2}).format(r);return o.jsx(h.Card,{shadow:"none",isPressable:!!l,onPress:()=>l?.(e),className:h.cn("w-full min-h-fit border rounded-3xl",a?"border-primary bg-primary/5":"border-default",c),"data-testid":"item-card","data-selected":a,children:o.jsxs("div",{className:"px-4 py-8 flex gap-6 items-center justify-between",children:[o.jsxs("div",{className:"w-max flex flex-col gap-1 items-start",children:[o.jsx("p",{className:"text-xl font-semibold text-left","data-testid":"item-card-name",children:t}),n&&o.jsx("div",{"data-testid":"item-card-type",className:"w-fit bg-default-300 px-4 py-2 text-sm rounded-xl",children:o.jsx("p",{className:"text-center",children:n})})]}),o.jsx("p",{className:"text-2xl font-semibold","data-testid":"item-card-price",children:d})]})})},zl=({title:e,value:t,description:n,onValueChange:r,className:s=""})=>{const i=y.useId();return o.jsxs("div",{className:h.cn("w-full flex flex-row items-center",e||n?"justify-between gap-6":"justify-start",s),"data-testid":"toggle",children:[o.jsxs("div",{className:"flex flex-col items-start",children:[e&&o.jsx("label",{htmlFor:i,className:"font-medium text-left","data-testid":"toggle-title",children:e}),n&&o.jsx("p",{className:"text-left text-gray-500","data-testid":"toggle-description",children:n})]}),o.jsx(h.Switch,{id:i,isSelected:t,onValueChange:r,"data-testid":"toggle-switch"})]})},Qh={ticketSelectionTitle:"Choose tickets to be upgraded",ticketsAllowedToRedeem:"Tickets allowed to redeem:",ticketsSelectedToRedeem:"Tickets selected to redeem",noUpgradeTicketsAvailable:"No upgrade tickets available to select",selectAllButtonLabel:"Select All"},Zh=(e,t)=>new Intl.NumberFormat(e,{style:"currency",currency:t}),Bl=e=>Object.values(e).reduce((t,n)=>t+Object.values(n).reduce((r,s)=>r+Object.values(s).reduce((i,a)=>i+a.selectedQuantity,0),0),0),Xh=e=>e.reduce((t,n)=>t+n.dates.reduce((r,s)=>r+s.tickets.reduce((i,a)=>i+a.max,0),0),0),ps=e=>e.flatMap(t=>t.dates.flatMap(n=>n.tickets.map(r=>({exhibition:t,dateGroup:n,ticket:r})))),Ri=(e,t,n)=>{const r={};let s=n?t??Xh(e):0;for(const{exhibition:i,dateGroup:a,ticket:l}of ps(e)){r[i.id]??={},r[i.id][a.id]??={};const c=n?Math.min(l.max,s):0;r[i.id][a.id][l.id]={id:l.id,selectedQuantity:c,originalPrice:l.originalPrice,discountedPrice:l.price},s-=c}return r},zi=(e,t,n)=>`${e}::${t}::${n}`,em=(e,t,n)=>{const r=Bl(t);for(const{exhibition:s,dateGroup:i,ticket:a}of ps(e)){const l=t[s.id]?.[i.id]?.[a.id]?.selectedQuantity??0,c=n===void 0?a.max:Math.min(a.max,n-(r-l));if(c>0&&l<c)return!1}return!0},tm=({initialQuantity:e=1,minQuantity:t=1,maxQuantity:n=10,onChange:r,disabled:s=!1})=>{const i=Math.max(t,Math.min(n,e)),[a,l]=y.useState(()=>String(i)),[c,d]=y.useState(!1),u=c?a:String(i),f=()=>{s||i>=n||r?.(i+1)},p=()=>{s||i<=t||r?.(i-1)},m=S=>{if(s)return;l(S.target.value);const j=parseInt(S.target.value,10);isNaN(j)||r?.(Math.max(t,Math.min(n,j)))},v=S=>{const j=parseInt(S.target.value,10);if(d(!1),isNaN(j)){r?.(t);return}const M=Math.max(t,Math.min(n,j));M!==j?r?.(M):l(String(M))},b=i<=t,x=i>=n,w="w-10 h-10 flex items-center justify-center border-0 rounded-full cursor-pointer transition-colors duration-150 text-white text-2xl font-regular",N="bg-primary hover:bg-primary/80",A="bg-primary/40 cursor-not-allowed";return o.jsxs("div",{className:"flex items-center gap-4","data-testid":"quantity-selector",children:[o.jsx("button",{type:"button",onClick:p,disabled:s||b,className:h.cn(w,s||b?A:N),"aria-label":"Decrement quantity","data-testid":"quantity-decrement",children:"-"}),o.jsx("input",{type:"number",value:u,onChange:m,onFocus:()=>d(!0),onBlur:v,disabled:s,min:t,max:n,step:"1",className:"w-12 h-10 rounded-md border-0 bg-zinc-100 text-center text-2xl font-medium text-zinc-900 [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none","aria-label":`Selected quantity: ${i}`,"data-testid":"quantity-input"}),o.jsx("button",{type:"button",onClick:f,disabled:s||x,className:h.cn(w,s||x?A:N),"aria-label":"Increment quantity","data-testid":"quantity-increment",children:"+"})]})},nm=({label:e,checked:t=!1,onChange:n,disabled:r=!1})=>{const s=()=>{r||n?.(!t)};return o.jsxs("button",{type:"button",onClick:s,disabled:r,role:"checkbox","aria-checked":t,"data-testid":"checkbox-button","data-checked":t,className:h.cn("flex items-center gap-1.5 px-4 py-3 border-0 rounded-full cursor-pointer text-sm min-h-[30px]","outline-none select-none transition-colors bg-zinc-100 hover:bg-zinc-200 text-primary",r&&"cursor-not-allowed opacity-60"),children:[o.jsxs("span",{className:"relative flex items-center justify-center w-5 h-5 flex-shrink-0",children:[o.jsx("input",{type:"checkbox",checked:t,onChange:()=>{},disabled:r,className:"absolute opacity-0 w-0 h-0 pointer-events-none",tabIndex:-1,readOnly:!0}),o.jsx("span",{className:h.cn("block w-3.5 h-3.5 rounded-sm relative",t?"bg-primary":"bg-white ring-1 ring-zinc-300"),children:t&&o.jsx("span",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-[60%] rotate-45 w-[3px] h-[5px] border border-white border-t-0 border-l-0","aria-hidden":"true"})})]}),o.jsx("p",{className:"flex-1 m-0 text-left leading-snug",children:e})]})},rm=({item:e,quantity:t,onChange:n,getTotalSelectedTickets:r,userMaxLimit:s,settings:i,labels:a})=>{const l=()=>{if(!r||s===void 0)return e.max;const f=r();return Math.min(e.max,s-(f-t))},c=i?.locale??"en-US",d=i?.currency??"USD",u=Zh(c,d);return o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between bg-white px-3 py-2.5 gap-8","data-testid":"upgrade-ticket-item",children:[o.jsxs("div",{className:"min-w-0 flex flex-1 flex-col gap-2",children:[o.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[o.jsxs("h3",{className:"min-w-0 text-base font-semibold text-zinc-900 m-0","data-testid":"ticket-name",children:[e.name,typeof e.purchasedQuantity=="number"&&e.purchasedQuantity>1?o.jsx("span",{"data-testid":"ticket-purchased-quantity",children:` x${e.purchasedQuantity}`}):null]}),o.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[o.jsx("h3",{className:"line-through text-zinc-500 text-[0.9rem] font-normal m-0","data-testid":"ticket-original-price",children:u.format(e.originalPrice)}),o.jsx("h3",{className:"text-base font-semibold text-zinc-900 m-0","data-testid":"ticket-discounted-price",children:u.format(e.price)})]})]}),e.membershipName?o.jsx("div",{"data-testid":"ticket-membership-name",className:"max-w-full self-start rounded-2xl bg-default-100 px-3 py-1 text-xs text-default-700",title:e.membershipName,children:o.jsx("p",{className:"max-w-full truncate text-center",children:e.membershipName})}):null,o.jsx("div",{className:"text-sm text-zinc-500",children:o.jsxs("p",{className:"m-0","data-testid":"ticket-max",children:[a.ticketsAllowedToRedeem," ",e.max]})})]}),o.jsx(tm,{initialQuantity:t,minQuantity:0,maxQuantity:l(),onChange:n})]}),e.membershipAlert?o.jsx(h.Alert,{"data-testid":"ticket-membership-alert",color:"warning",variant:"flat",radius:"full",className:"ticket-selection-membership-alert mb-2 w-full max-w-full py-0 shadow-none",classNames:{base:"ticket-selection-membership-alert-base !min-h-8 !items-center !bg-[#F5CB24]/15 !text-[#5B2C0F] shadow-none",mainWrapper:"ticket-selection-membership-alert-main-wrapper m-0 min-h-8 !py-0 !px-0",alertIcon:"ticket-selection-membership-alert-icon w-4 h-4 !text-[#5B2C0F]",iconWrapper:"ticket-selection-membership-alert-icon-wrapper !min-w-0 !bg-transparent !border-none !shadow-none !rounded-none !p-0 !m-0 !w-4 !h-4",description:"ticket-selection-membership-alert-description !ms-2 !my-2 !text-[#5B2C0F]"},description:o.jsx("span",{className:"ticket-selection-membership-alert-description-text block w-full whitespace-normal break-words text-sm leading-4 text-[#5B2C0F]",children:e.membershipAlert})}):null]})},sm=({exhibitionId:e,dateGroup:t,isLast:n=!1,onQuantityChange:r,getTicketQuantity:s,getTotalSelectedTickets:i,userMaxLimit:a,settings:l,labels:c})=>o.jsxs("div",{className:h.cn("flex flex-col gap-2 pb-3",!n&&"border-b border-zinc-200"),"data-testid":"upgrade-ticket-date-group",children:[o.jsx("p",{className:"m-0 text-sm text-left text-zinc-500","data-testid":"upgrade-ticket-date",children:t.date}),t.tickets.map((d,u)=>o.jsxs("div",{children:[o.jsx(rm,{item:d,quantity:s(e,t.id,d.id),onChange:f=>r(e,t.id,d.id,f),getTotalSelectedTickets:i,userMaxLimit:a,settings:l,labels:c}),u<t.tickets.length-1?o.jsx(h.Divider,{className:"bg-zinc-200","data-testid":"upgrade-ticket-divider"}):null]},d.id))]}),im=({title:e,exhibition:t,onQuantityChange:n,getTicketQuantity:r,getTotalSelectedTickets:s,userMaxLimit:i,settings:a,labels:l,initialExpanded:c=!1})=>{const[d,u]=y.useState(c),f=t.dates.reduce((m,v)=>m+v.tickets.reduce((b,x)=>b+r(t.id,v.id,x.id),0),0),p=t.dates.some(m=>m.tickets.length>0);return o.jsxs("div",{className:"w-full overflow-hidden border-b border-zinc-200","data-testid":"upgrade-ticket-header",children:[o.jsx("button",{type:"button",className:"flex items-center w-full px-5 py-4 border-0 cursor-pointer transition-all bg-white hover:bg-zinc-100",onClick:()=>u(!d),"aria-expanded":d,"aria-controls":`upgrade-items-${t.id}`,"data-testid":"upgrade-ticket-header-button",children:o.jsxs("div",{className:"flex justify-between items-center w-full gap-6",children:[o.jsx("h4",{className:"m-0 text-base font-semibold text-left text-zinc-900","data-testid":"upgrade-ticket-header-title",children:e}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs("p",{className:"m-0 text-sm text-right text-zinc-500","data-testid":"upgrade-ticket-header-count",children:[f," ",l.ticketsSelectedToRedeem]}),o.jsx("span",{className:h.cn("inline-flex items-center justify-center text-zinc-500 text-xl transition-transform duration-200",d&&"rotate-180"),"aria-hidden":"true",children:o.jsx(H,{icon:"mdi:chevron-down"})})]})]})}),o.jsx("div",{id:`upgrade-items-${t.id}`,className:h.cn("transition-all duration-300 overflow-hidden",d?"max-h-[1000px] opacity-100":"max-h-0 opacity-0"),"aria-hidden":!d,children:d&&o.jsx("div",{className:"px-5 flex flex-col gap-6","data-testid":"upgrade-ticket-items",children:p?t.dates.map((m,v)=>o.jsx(sm,{exhibitionId:t.id,dateGroup:m,isLast:v===t.dates.length-1,onQuantityChange:n,getTicketQuantity:r,getTotalSelectedTickets:s,userMaxLimit:i,settings:a,labels:l},m.id)):o.jsx("div",{className:"px-5 py-10 text-center",children:o.jsx("p",{className:"m-0 text-zinc-500 italic",children:l.noUpgradeTicketsAvailable})})})})]})},am=({initialExpanded:e=!1,userMaxLimit:t,labels:n,settings:r,ticketSelectionData:s,className:i="",onSelectionChange:a})=>{const l=y.useMemo(()=>s??[],[s]),c={...Qh,...n},[d,u]=y.useState(()=>Ri(l,t,!0)),f=y.useRef(!1),p=y.useMemo(()=>{const N=ps(l).map(({exhibition:A,dateGroup:S,ticket:j})=>[zi(A.id,S.id,j.id),j]);return new Map(N)},[l]),m=em(l,d,t),v=(N,A,S)=>d[N]?.[A]?.[S]?.selectedQuantity??0,b=()=>Bl(d),x=(N,A,S,j)=>{const M=v(N,A,S),D=b()-M;if(t!==void 0&&D+j>t)return;const B=p.get(zi(N,A,S));if(!B)return;const F={...d,[N]:{...d[N],[A]:{...d[N]?.[A],[S]:{id:S,selectedQuantity:j,originalPrice:B.originalPrice,discountedPrice:B.price}}}};u(F),a?.(F)},w=N=>{const A=Ri(l,t,N);u(A),a?.(A)};return y.useEffect(()=>{!f.current&&m&&(a?.(d),f.current=!0)},[m,d,a]),o.jsxs("div",{className:h.cn("flex flex-col w-full font-sans",i),"data-testid":"ticket-selection",children:[o.jsxs("div",{className:"flex items-center justify-between py-2 gap-4","data-testid":"ticket-selection-header",children:[o.jsx("h3",{className:"text-xl font-semibold m-0","data-testid":"ticket-selection-title",children:c.ticketSelectionTitle}),o.jsx(nm,{label:c.selectAllButtonLabel,checked:m,onChange:w})]}),l.map(N=>o.jsx(im,{title:N.exhibitionName,exhibition:N,onQuantityChange:x,getTicketQuantity:v,getTotalSelectedTickets:b,userMaxLimit:t,settings:r,labels:c,initialExpanded:e},N.id))]})},lm=350,om={receivedLabel:"Cash Received",receivedPlaceholder:"$0.00",changeLabel:"Change",changeMessageTemplate:"You have to give back the client {change} in change",insufficientMessageTemplate:"Amount received must be at least {due}"},hr=(e,t)=>Object.entries(t).reduce((n,[r,s])=>n.replace(`{${r}}`,s),e),cm=({dueAmount:e,received:t,defaultReceived:n=null,onChange:r,locale:s="en-US",labels:i,isDisabled:a=!1,maxAmount:l,autoFocus:c=!1,className:d,"data-testid":u="cash-tender-form"})=>{const f={...om,...i},p=Br(e.currency,s),m=t!==void 0,[v,b]=y.useState(n??null),x=m?t:v,w=y.useMemo(()=>{const O=typeof x=="number"&&Number.isFinite(x)?x:0,P=pr(O,e.value,e.currency,s);return{received:O,change:P>0?P:0,isValid:O>=e.value&&O>0}},[x,e.value,e.currency,s]),N=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),Z=K===null||Number.isNaN(K)?null:K;if(Z!==null&&l!==void 0&&Z>l)return;m||b(Z);const J=typeof Z=="number"&&Number.isFinite(Z)?Z:0,le=pr(J,e.value,e.currency,s);r?.({received:J,change:le>0?le:0,isValid:J>=e.value&&J>0})},[m,a,e.value,e.currency,s,r,l]),S=x==null?"":String(x),j=w.isValid&&w.change>0,M=!w.isValid&&w.received>0,D=tt(w.change,s,e.currency),B=tt(e.value,s,e.currency),[F,_]=y.useState(""),I=y.useRef(null);y.useEffect(()=>{I.current&&clearTimeout(I.current);const O=j?hr(f.changeMessageTemplate,{change:D}):"",P=j?lm:0;return I.current=setTimeout(()=>_(O),P),()=>{I.current&&clearTimeout(I.current)}},[j,D,f.changeMessageTemplate]);const E=`${u}-received`;return o.jsxs("div",{className:h.cn("flex flex-col gap-3",d),"data-testid":u,children:[o.jsx(h.Input,{id:E,label:f.receivedLabel,labelPlacement:"outside",type:"text",inputMode:p===0?"numeric":"decimal",pattern:p===0?"[0-9]*":"[0-9]*[.,]?[0-9]*",value:S,onChange:O=>A(O.target.value),onFocus:N,placeholder:f.receivedPlaceholder,isDisabled:a,isInvalid:M,errorMessage:M?hr(f.insufficientMessageTemplate,{due:B}):void 0,variant:"bordered",radius:"lg",autoFocus:c,"data-testid":`${u}-received-input`}),j&&o.jsx(h.Alert,{"data-testid":`${u}-change-alert`,color:"primary",variant:"flat",radius:"lg",title:f.changeLabel,description:hr(f.changeMessageTemplate,{change:D}),icon:o.jsx(H,{icon:"lucide:info",width:20,height:20,"aria-hidden":"true"}),"aria-live":"off",classNames:{base:"bg-info-50 text-info-700",title:"font-semibold",description:"text-sm leading-relaxed",iconWrapper:"bg-transparent shadow-none border-0"}}),o.jsx("span",{role:"status","aria-live":"polite",className:"sr-only",children:F})]})},dm={checkNumberLabel:"Check Number",checkNumberPlaceholder:"e.g. 11234",bankNameLabel:"Bank Name",bankNamePlaceholder:"e.g. Chase Bank",dateLabel:"Date",checkNumberRequiredMessage:"Check number is required"},Bi=()=>{const e=new Date,t=n=>String(n).padStart(2,"0");return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`},_l=({dueAmount:e,value:t,defaultValue:n,onChange:r,labels:s,hideDate:i=!1,hideBankName:a=!1,isDisabled:l=!1,checkNumberMaxLength:c=34,bankNameMaxLength:d=100,autoFocus:u=!1,className:f,"data-testid":p="check-tender-form"})=>{const m={...dm,...s},v=t!==void 0,[b,x]=y.useState({checkNumber:n?.checkNumber??"",bankName:n?.bankName??"",date:n?.date??Bi()}),[w,N]=y.useState(!!n?.checkNumber),A=y.useMemo(()=>v?{checkNumber:t?.checkNumber??"",bankName:t?.bankName??"",date:t?.date??Bi()}:b,[v,t,b]),S=y.useCallback(I=>{v||x(I);const E=I.checkNumber.trim(),O={amount:e.value,checkNumber:E,bankName:I.bankName.trim()||void 0,date:i?void 0:I.date,isValid:E.length>0&&e.value>0};r?.(O)},[v,e.value,i,r]),j=y.useCallback(I=>E=>{l||(I==="checkNumber"&&E.length>0&&N(!0),S({...A,[I]:E}))},[A,S,l]),M=y.useCallback(()=>{l||N(!0)},[l]),D=w&&A.checkNumber.trim()==="",B=`${p}-check-number`,F=`${p}-bank-name`,_=`${p}-date`;return o.jsxs("div",{className:h.cn("grid grid-cols-1 sm:grid-cols-2 gap-4",f),"data-testid":p,children:[o.jsx(h.Input,{id:B,label:m.checkNumberLabel,labelPlacement:"outside",type:"text",value:A.checkNumber,onChange:I=>j("checkNumber")(I.target.value),onBlur:M,placeholder:m.checkNumberPlaceholder,maxLength:c,isRequired:!0,isInvalid:D,errorMessage:D?m.checkNumberRequiredMessage:void 0,isDisabled:l,variant:"bordered",radius:"lg",autoFocus:u,"data-testid":`${p}-check-number-input`}),!a&&o.jsx(h.Input,{id:F,label:m.bankNameLabel,labelPlacement:"outside",type:"text",value:A.bankName,onChange:I=>j("bankName")(I.target.value),placeholder:m.bankNamePlaceholder,maxLength:d,isDisabled:l,variant:"bordered",radius:"lg","data-testid":`${p}-bank-name-input`}),!i&&o.jsx(h.Input,{id:_,label:m.dateLabel,labelPlacement:"outside",type:"date",value:A.date,onChange:I=>j("date")(I.target.value),isDisabled:l,variant:"bordered",radius:"lg","data-testid":`${p}-date-input`,className:"sm:col-span-2"})]})};_l.displayName="CheckTenderForm";const um={methodLabel:"Method",methodPlaceholder:"Select a payment method",referenceLabel:"Reference",referencePlaceholder:"e.g. Voucher #1234",methodRequiredMessage:"Method is required"},fm=[{value:"ach",label:"ACH"},{value:"wire",label:"Wire"},{value:"gift_card",label:"Gift Card"},{value:"voucher",label:"Voucher"},{value:"other",label:"Other"}],Vl=({dueAmount:e,methodOptions:t=fm,value:n,defaultValue:r,onChange:s,labels:i,showReference:a=!1,isDisabled:l=!1,className:c,"data-testid":d="other-tender-form"})=>{const u={...um,...i},f=n!==void 0,[p,m]=y.useState({method:r?.method??"",reference:r?.reference??""}),v=y.useMemo(()=>f?{method:n?.method??"",reference:n?.reference??""}:p,[f,n,p]),b=y.useCallback(j=>t.find(M=>M.value===j)?.label??"",[t]),x=y.useCallback(j=>{f||m(j);const M=b(j.method),D={amount:e.value,method:j.method,description:M,reference:j.reference.trim()||void 0,isValid:j.method!==""};s?.(D)},[f,e.value,s,b]),w=y.useCallback(j=>{if(l)return;const M=typeof j=="string"?j:Array.from(j)[0]?.toString()??"";x({...v,method:M})},[v,x,l]),N=y.useCallback(j=>{l||x({...v,reference:j})},[v,x,l]),A=`${d}-method`,S=`${d}-reference`;return o.jsxs("div",{className:h.cn("flex flex-col gap-3",c),"data-testid":d,children:[o.jsx(pt,{id:A,label:u.methodLabel,labelPlacement:"outside",placeholder:u.methodPlaceholder,selectedKeys:v.method?[v.method]:[],onSelectionChange:w,isDisabled:l,isRequired:!0,variant:"bordered",radius:"lg","data-testid":`${d}-method-select`,popoverProps:{placement:"bottom-start",classNames:{content:"bg-white border border-default-200 shadow-lg rounded-xl p-1"}},listboxProps:{classNames:{list:"max-h-[var(--popover-available-height,40vh)] overflow-y-auto"},itemClasses:{base:["rounded-lg","px-3 py-2","text-default-800","data-[hover=true]:bg-default-100","data-[selectable=true]:focus:bg-default-100","data-[selected=true]:bg-primary-50","data-[selected=true]:text-primary","data-[selected=true]:font-medium"]}},children:t.map(j=>o.jsx(h.SelectItem,{"data-testid":`${d}-method-option-${j.value}`,children:j.label},j.value))}),a&&o.jsx(h.Input,{id:S,label:u.referenceLabel,labelPlacement:"outside",type:"text",value:v.reference,onChange:j=>N(j.target.value),placeholder:u.referencePlaceholder,isDisabled:l,variant:"bordered",radius:"lg","data-testid":`${d}-reference-input`})]})};Vl.displayName="OtherTenderForm";const hm={collectedHeading:"Collected",remainingLabel:"Remaining:",completeLabel:"Complete",removeAriaLabel:"Remove this tender",removeTooltipForRecorded:"Already recorded",statusPending:"Pending",statusRecorded:"Approved",statusFailed:"Failed"},mm={card:"lucide:credit-card",cash:"lucide:dollar-sign",check:"lucide:edit-3",other:"lucide:more-horizontal"},pm={pending:"warning",recorded:"success",failed:"danger"},gm=e=>e==="pending"||e==="recorded",xm=e=>`#${e+1}`,Hl=({total:e,tenders:t,onRemove:n,locale:r="en-US",labels:s,hideCollectedList:i=!1,className:a,"data-testid":l="split-payment-summary"})=>{const c={...hm,...s},{collected:d,remaining:u,isComplete:f}=y.useMemo(()=>{const m=t.reduce((b,x)=>gm(x.status)?b+x.amount:b,0),v=Math.max(e.value-m,0);return{collected:m,remaining:v,isComplete:m>=e.value&&e.value>0}},[t,e.value]),p=m=>m==="pending"?c.statusPending:m==="recorded"?c.statusRecorded:c.statusFailed;return o.jsxs("div",{className:h.cn("flex flex-col gap-4",a),"data-testid":l,children:[o.jsxs("div",{className:"rounded-2xl bg-default-100 px-6 py-5 text-center","data-testid":`${l}-remaining-banner`,children:[o.jsx("div",{className:"text-sm text-default-600",children:f?c.completeLabel:c.remainingLabel}),o.jsx("div",{className:"mt-1 text-4xl font-bold tracking-tight","data-testid":`${l}-remaining-amount`,children:tt(f?d:u,r,e.currency)})]}),!i&&t.length>0&&o.jsxs("div",{className:"flex flex-col gap-2","data-testid":`${l}-collected-list`,children:[o.jsx("h3",{className:"text-base font-semibold",children:c.collectedHeading}),t.map((m,v)=>o.jsx(ym,{index:v,tender:m,locale:r,currency:e.currency,removable:!!n&&m.status!=="recorded",onRemove:n?()=>n(m.id):void 0,statusLabel:p(m.status),removeAriaLabel:c.removeAriaLabel,recordedTooltip:c.removeTooltipForRecorded,dataTestId:`${l}-row-${v}`},m.id))]})]})};Hl.displayName="SplitPaymentSummary";const ym=({index:e,tender:t,locale:n,currency:r,removable:s,onRemove:i,statusLabel:a,removeAriaLabel:l,recordedTooltip:c,dataTestId:d})=>{const u=i?o.jsx(q,{isIconOnly:!0,variant:"light",radius:"full",size:"sm",onPress:i,isDisabled:!s,"aria-label":l,"data-testid":`${d}-remove`,className:h.cn(s?"text-default-700 hover:bg-default-200":"text-default-300"),children:o.jsx(H,{icon:"lucide:x",width:18,height:18,"aria-hidden":"true"})}):null;return o.jsxs("div",{className:"flex items-center gap-3 rounded-xl bg-default-50 px-4 py-3 motion-safe:animate-[pp-row-in_200ms_ease-out]","data-testid":d,children:[o.jsx("span",{className:"text-sm font-medium text-default-500 w-6 shrink-0",children:xm(e)}),o.jsx(H,{icon:mm[t.type],width:20,height:20,className:"text-default-700 shrink-0","aria-hidden":"true"}),o.jsx("span",{className:"flex-1 truncate","data-testid":`${d}-label`,children:t.label}),o.jsx("span",{className:"font-semibold tabular-nums","data-testid":`${d}-amount`,children:tt(t.amount,n,r)}),o.jsx(h.Chip,{size:"sm",radius:"full",variant:"flat",color:pm[t.status],startContent:t.status==="recorded"?o.jsx(H,{icon:"lucide:check-circle",width:14,height:14,"aria-hidden":"true"}):t.status==="failed"?o.jsx(H,{icon:"lucide:alert-circle",width:14,height:14,"aria-hidden":"true"}):void 0,"data-testid":`${d}-status`,children:a}),u&&(s?u:o.jsx(h.Tooltip,{content:c,placement:"left",children:o.jsx("span",{tabIndex:0,"aria-label":c,children:u})}))]})},bm=`
|
|
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
|
+
`,Ul=y.forwardRef(({children:e,relativeOverlayRoot:t=!0,className:n,style:r,"data-testid":s="modal-shell"},i)=>o.jsxs(o.Fragment,{children:[o.jsx("style",{children:bm}),o.jsx("div",{ref:i,"data-testid":s,style:r,className:h.cn("flex flex-col gap-4 p-4 rounded-3xl bg-white shadow-xl","md:gap-5 md:p-6",t&&"relative","motion-safe:animate-[pp-modal-in_220ms_ease-out]","motion-safe:transition-[min-height] motion-safe:duration-[420ms] motion-safe:ease-in-out",n),children:e})]}));Ul.displayName="ModalShell";const ql=({title:e,onClose:t,closeLabel:n="Close",actions:r,className:s,"data-testid":i="modal-shell-header"})=>o.jsxs("header",{className:h.cn("flex items-center justify-between",s),"data-testid":i,children:[o.jsx("h2",{className:"text-xl font-semibold","data-testid":`${i}-title`,children:e}),o.jsxs("div",{className:"flex items-center gap-2",children:[r,t&&o.jsx(q,{isIconOnly:!0,variant:"light",radius:"full",size:"sm",onPress:t,"aria-label":n,"data-testid":`${i}-close`,children:o.jsx(H,{icon:"lucide:x",width:20,height:20,"aria-hidden":"true"})})]})]});ql.displayName="ModalShellHeader";const Wl=({children:e,columns:t=2,className:n,"data-testid":r="modal-shell-footer"})=>o.jsx("footer",{className:h.cn("mt-2 gap-3",t===2?"flex flex-col md:grid md:grid-cols-2 [&>*]:w-full [&>*:first-child]:md:order-2 [&>*:nth-child(2)]:md:order-1":"grid grid-cols-1",n),"data-testid":r,children:e});Wl.displayName="ModalShellFooter";const vm={2:"sm:grid-cols-2",3:"sm:grid-cols-3",4:"sm:grid-cols-4"},wm={1:"grid-cols-1",2:"grid-cols-2"},mr=e=>typeof e=="string"?o.jsx(H,{icon:e,width:20,height:20,"aria-hidden":"true"}):e,Kl=({options:e,selectedKey:t,onSelect:n,heading:r,ariaLabel:s="Select an option",columnsDesktop:i=3,columnsMobile:a=2,className:l,"data-testid":c="tile-select"})=>{const d=e.find(u=>u.key===t);return o.jsxs("div",{className:h.cn("flex flex-col gap-3",l),"data-testid":c,children:[r&&o.jsx("h3",{className:"text-sm font-medium text-default-700",id:`${c}-heading`,children:r}),o.jsx("div",{className:"md:hidden",children:o.jsx(pt,{"aria-label":r?void 0:s,"aria-labelledby":r?`${c}-heading`:void 0,selectedKeys:t?[t]:[],onSelectionChange:u=>{const p=Array.from(u)[0];typeof p=="string"&&n(p)},placeholder:s,variant:"bordered",radius:"lg","data-testid":`${c}-mobile-select`,startContent:d?o.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:mr(d.icon)}):void 0,popoverProps:{placement:"bottom-start",classNames:{content:"bg-white border border-default-200 shadow-lg rounded-xl p-1"}},listboxProps:{classNames:{list:"max-h-[var(--popover-available-height,40vh)] overflow-y-auto"},itemClasses:{base:["rounded-lg","px-3 py-2","text-default-800","data-[hover=true]:bg-default-100","data-[selectable=true]:focus:bg-default-100","data-[selected=true]:bg-primary-50","data-[selected=true]:text-primary","data-[selected=true]:font-medium"]}},children:e.map(u=>o.jsx(h.SelectItem,{isDisabled:u.isDisabled,startContent:o.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:mr(u.icon)}),"data-testid":u["data-testid"]??`${c}-${u.key}-mobile`,children:u.label},u.key))})}),o.jsx("div",{role:"group","aria-labelledby":r?`${c}-heading`:void 0,"aria-label":r?void 0:s,className:h.cn("hidden md:grid gap-3",wm[a],vm[i]),children:e.map(u=>{const f=t===u.key;return o.jsxs(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:[o.jsx("span",{"aria-hidden":"true",children:mr(u.icon)}),o.jsx("span",{className:"text-sm font-medium",children:u.label})]},u.key)})})]})};Kl.displayName="TileSelect";const km={subtle:{wrapper:"bg-default-100",amount:"text-default-900"},success:{wrapper:"bg-success-50 text-success-700",amount:"text-success-700"}},Jl=({total:e,label:t,locale:n="en-US",variant:r="subtle",className:s,"data-testid":i="payment-total-banner"})=>{const a=km[r];return o.jsxs("div",{"data-testid":i,className:h.cn("rounded-2xl px-6 py-5 text-center",a.wrapper,s),children:[o.jsx("div",{className:"text-sm text-default-600",children:t}),o.jsx("div",{className:h.cn("mt-1 text-4xl font-bold tracking-tight",a.amount),"data-testid":`${i}-amount`,children:tt(e.value,n,e.currency)})]})};Jl.displayName="PaymentTotalBanner";const Nm={white:"bg-white/70 backdrop-blur-sm",transparent:"bg-transparent"},Yl=({title:e,subtitle:t,backdrop:n="white",exiting:r=!1,className:s,"data-testid":i="loading-overlay"})=>o.jsxs("div",{role:"status","aria-live":r?"off":"polite","aria-hidden":r||void 0,"data-testid":i,"data-state":r?"exiting":"visible",className:h.cn("absolute inset-0 z-10 flex flex-col items-center justify-center gap-4 rounded-3xl",Nm[n],r?"pointer-events-none motion-safe:animate-[pp-fade-out_280ms_ease-in_forwards]":"motion-safe:animate-[pp-fade-in_150ms_ease-out]",s),children:[o.jsx("div",{"aria-hidden":"true","data-testid":`${i}-spinner`,className:"h-16 w-16 rounded-full border-4 border-primary-100 border-t-primary animate-spin motion-safe:animate-[pp-scale-in_200ms_ease-out,spin_1s_linear_infinite]"}),o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"text-xl font-semibold","data-testid":`${i}-title`,children:e}),t&&o.jsx("div",{className:"mt-1 text-sm text-default-600",children:t})]})]});Yl.displayName="LoadingOverlay";const gs=({cashChange:e,label:t="Cash to return",secondaryLine:n,locale:r="en-US",onDismiss:s,dismissAriaLabel:i="Dismiss",align:a="left",className:l,"data-testid":c="payment-cash-change-banner"})=>{if(!e||e.value<=0)return null;const d=a==="center";return o.jsxs("div",{role:"status","aria-live":"polite","data-testid":c,className:h.cn("flex w-full items-center gap-3 rounded-2xl border border-info-200 bg-info-50 px-5 py-4",d?"justify-center text-center":"text-left","motion-safe:animate-[pp-slide-down_200ms_ease-out]",l),children:[o.jsx(H,{icon:"lucide:info",width:28,height:28,className:"shrink-0 text-info-700","aria-hidden":"true"}),o.jsxs("div",{className:h.cn("flex flex-col",d?"items-center":"flex-1"),children:[o.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-info-700",children:t}),o.jsx("span",{className:"text-2xl font-bold text-info-700","data-testid":`${c}-amount`,children:tt(e.value,r,e.currency)}),n&&o.jsx("span",{className:"mt-0.5 text-xs text-info-700/80",children:n})]}),s&&o.jsx(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:o.jsx(H,{icon:"lucide:x",width:18,height:18,"aria-hidden":"true"})})]})};gs.displayName="PaymentCashChangeBanner";const Gl=({title:e,subtitle:t,emailLine:n,confirmationEmail:r,cashChange:s,cashChangeLabel:i="Cash to return",locale:a="en-US",closeLabel:l="Close",onClose:c,className:d,"data-testid":u="payment-success-view"})=>{const f=!!(s&&s.value>0);return o.jsxs("div",{"data-testid":u,className:h.cn("flex flex-col items-center gap-6 py-8 px-4 text-center","motion-safe:animate-[pp-fade-in_250ms_ease-out]",d),children:[o.jsx("div",{"aria-hidden":"true",className:"flex items-center justify-center rounded-full bg-[#A2D9C6] p-[10px]",children:o.jsx(H,{icon:"gravity-ui:circle-check-fill",width:76,height:76,className:"text-[#10B981]","aria-hidden":"true"})}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("h2",{className:"text-2xl font-bold","data-testid":`${u}-title`,children:e}),o.jsx("p",{className:"text-default-700",children:t}),n&&r&&o.jsxs("p",{className:"text-default-700",children:[n,o.jsx("br",{}),o.jsx("strong",{className:"font-semibold",children:r})]})]}),f&&s&&o.jsx(gs,{cashChange:s,label:i,locale:a,align:"center",className:"max-w-[400px]","data-testid":`${u}-cash-change`}),c&&o.jsx(q,{color:"default",variant:"bordered",radius:"full",size:"lg",onPress:c,"data-testid":`${u}-close`,className:"mt-4 w-full",children:l})]})};Gl.displayName="PaymentSuccessView";const Ql=({heading:e,amountLabel:t,value:n,defaultValue:r,onChange:s,placeholder:i,isDisabled:a,isInvalid:l,errorMessage:c,autoFocus:d,maxAmount:u,className:f,"data-testid":p="payment-sub-amount-input"})=>{const m=`${p}-input`,v=y.useCallback(x=>{if(u!==void 0){const w=Number.parseFloat(x.replace(",","."));if(Number.isFinite(w)&&w>u)return}s?.(x)},[u,s]),b=y.useCallback(x=>{const w=x.currentTarget;requestAnimationFrame(()=>{w.isConnected&&w.select()})},[]);return o.jsxs("div",{className:h.cn("flex flex-col gap-3 border-t border-default-100 pt-5",f),"data-testid":p,children:[o.jsx("h3",{className:"text-lg font-semibold","data-testid":`${p}-heading`,children:e}),o.jsx(h.Input,{id:m,label:t,labelPlacement:"outside",type:"text",inputMode:"decimal",pattern:"[0-9]*[.,]?[0-9]*",value:n,defaultValue:r,onChange:x=>v(x.target.value),onFocus:b,placeholder:i,isDisabled:a,isInvalid:l,errorMessage:l?c:void 0,variant:"bordered",radius:"lg","aria-invalid":l||void 0,autoFocus:d,"data-testid":`${p}-field`})]})};Ql.displayName="PaymentSubAmountInput";const Zl=({isOpen:e,title:t,body:n,confirmLabel:r,confirmVariant:s="danger",dismissLabel:i,onConfirm:a,onDismiss:l,"data-testid":c="confirm-dialog"})=>o.jsx(h.Modal,{isOpen:e,onOpenChange:d=>{d||l()},role:"alertdialog",size:"sm",backdrop:"opaque","data-testid":c,"aria-labelledby":`${c}-title`,"aria-describedby":`${c}-body`,children:o.jsxs(h.ModalContent,{children:[o.jsx(h.ModalHeader,{id:`${c}-title`,className:"text-lg font-semibold",children:t}),o.jsx(h.ModalBody,{id:`${c}-body`,className:"text-sm text-default-700",children:n}),o.jsxs(h.ModalFooter,{className:"grid grid-cols-2 gap-3",children:[o.jsx(q,{variant:"bordered",radius:"full",onPress:l,"data-testid":`${c}-dismiss`,className:"h-11",children:i}),o.jsx(q,{color:s,variant:"solid",radius:"full",onPress:a,"data-testid":`${c}-confirm`,className:"h-11",children:r})]})]})});Zl.displayName="ConfirmDialog";const Sm=60,Cm=(e,t,n=Sm)=>t?e>n:e<-n,Xl=(e,t)=>Math.max(0,Math.min(e,t)),jm=(e,t,n)=>Xl(e-t,n),Am=(e,t,n)=>e!==null?Xl(e,n):t?n:0,Mm=e=>e?"":"transition-[height] duration-300 ease-out",Em=e=>({onDrag:(t,n)=>{const r=e.open?e.fullHeight:0;e.setDragHeight(jm(r,n?.offset?.y??0,e.fullHeight))},onDragEnd:(t,n)=>{Cm(n?.offset?.y??0,e.open)&&e.onToggleOpen?.(),e.setDragHeight(null)}}),Qt=(e,t)=>tt(e.value,t,e.currency),xs=({item:e,locale:t,onRemove:n,removeAriaLabel:r})=>{const s=!!e.children&&e.children.length>0;return o.jsxs("div",{"data-testid":`summary-item-${e.id}`,className:"flex flex-col gap-2",children:[o.jsxs("div",{className:"flex min-h-9 items-center justify-between gap-2",children:[o.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-base text-foreground",children:[typeof e.quantity=="number"&&o.jsxs("span",{"data-testid":`summary-item-qty-${e.id}`,className:"shrink-0",children:[e.quantity," x"]}),e.leadingIcon,o.jsx("span",{"data-testid":`summary-item-name-${e.id}`,className:h.cn("truncate",e.emphasis&&"font-medium"),children:e.name})]}),o.jsxs("div",{className:"flex shrink-0 items-center",children:[e.amount&&o.jsx("span",{"data-testid":`summary-item-amount-${e.id}`,className:"whitespace-nowrap text-base text-foreground",children:Qt(e.amount,t)}),n&&o.jsx(q,{isIconOnly:!0,size:"sm",variant:"light",radius:"full",className:"ml-1 size-8 min-w-8 p-2 text-danger","aria-label":r,"data-testid":`summary-remove-${e.id}`,onPress:()=>n(e.id),children:o.jsx(H,{icon:"lucide:trash-2",width:16,height:16,className:"text-danger"})})]})]}),e.dateLabel&&o.jsxs("div",{"data-testid":`summary-item-date-${e.id}`,className:"flex items-center gap-2 text-sm text-default-500",children:[o.jsx(H,{icon:"lucide:calendar",width:16,height:16,className:"shrink-0"}),o.jsx("span",{className:"truncate",children:e.dateLabel})]}),e.dateRange&&o.jsxs("div",{"data-testid":`summary-item-daterange-${e.id}`,className:"flex items-center gap-2 text-sm text-default-500",children:[o.jsx(H,{icon:"lucide:calendar",width:16,height:16,className:"shrink-0"}),o.jsx("span",{children:e.dateRange.from}),o.jsx(H,{icon:"lucide:arrow-right",width:16,height:16,className:"shrink-0"}),o.jsx("span",{children:e.dateRange.to})]}),s&&o.jsx("div",{"data-testid":`summary-children-${e.id}`,className:"flex flex-col gap-2 pl-6",children:e.children.map(i=>o.jsx(xs,{item:i,locale:t,onRemove:n,removeAriaLabel:r},i.id))})]})};xs.displayName="SummaryItemRow";const eo=({fee:e,locale:t,className:n})=>o.jsxs("div",{"data-testid":"summary-service-fee",className:h.cn("flex items-center justify-between gap-2",n),children:[o.jsxs("button",{type:"button",role:"switch","aria-checked":!!e.isSelected,"aria-label":typeof e.label=="string"?e.label:"Pay Service fee","data-testid":"summary-service-fee-toggle",onClick:e.onToggle,className:"flex min-w-0 items-center gap-2 text-left",children:[o.jsx("span",{"aria-hidden":"true",className:h.cn("flex size-4 shrink-0 items-center justify-center rounded-full border",e.isSelected?"border-primary":"border-default-200"),children:e.isSelected&&o.jsx("span",{className:"size-2 rounded-full bg-primary"})}),o.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:e.label})]}),o.jsx("span",{"data-testid":"summary-service-fee-amount",className:"whitespace-nowrap text-base text-foreground",children:Qt(e.amount,t)})]});eo.displayName="SummaryServiceFeeRow";const to=({row:e,locale:t,emphasized:n})=>o.jsxs("div",{"data-testid":`summary-row-${e.key}`,className:"flex items-center justify-between text-foreground",children:[o.jsx("span",{"data-testid":`summary-row-label-${e.key}`,className:h.cn(n?"text-xl font-semibold leading-7":"text-base"),children:e.label}),o.jsx("span",{"data-testid":`summary-row-amount-${e.key}`,className:"whitespace-nowrap text-base",children:Qt(e.amount,t)})]});to.displayName="SummaryTotalsLineRow";const no=({pricesInLabel:e,currency:t,items:n,serviceFee:r,rows:s,locale:i,onRemoveItem:a,removeAriaLabel:l,emptyState:c,classNames:d})=>{const u=(n?.length??0)>0;return o.jsxs(o.Fragment,{children:[o.jsxs("div",{"data-testid":"summary-prices",className:h.cn("flex items-center justify-between text-xs text-default-500",d.prices),children:[o.jsx("span",{children:e}),t!=null&&o.jsx("span",{children:t})]}),u?o.jsx("div",{className:h.cn("flex flex-col gap-4",d.items),children:n.map(f=>o.jsx(xs,{item:f,locale:i,onRemove:a,removeAriaLabel:l},f.id))}):o.jsx("div",{"data-testid":"summary-empty",children:c}),r&&o.jsxs(o.Fragment,{children:[o.jsx(h.Divider,{className:"bg-default-200"}),o.jsx(eo,{fee:r,locale:i,className:d.serviceFee})]}),s&&s.length>0&&o.jsx("div",{className:h.cn("flex flex-col gap-4",d.totalsRows),children:s.map((f,p)=>o.jsx(to,{row:f,locale:i,emphasized:p===0},f.key))})]})};no.displayName="SummaryBody";const ro=({total:e,locale:t,className:n})=>o.jsxs("div",{"data-testid":"summary-total",className:h.cn("flex items-center justify-between text-xl font-semibold leading-7 text-foreground",n),children:[o.jsx("span",{children:e.label??"Total"}),o.jsx("span",{"data-testid":"summary-total-amount",className:"whitespace-nowrap text-xl font-semibold leading-7",children:Qt(e.amount,t)})]});ro.displayName="SummaryGrandTotalRow";const En=({action:e,disabledByLoading:t,className:n,testId:r="summary-cta"})=>o.jsx(q,{color:"primary",radius:"full",className:h.cn("px-[18px] py-[14px] font-medium",n),"data-testid":r,isLoading:e.isLoading,isDisabled:e.isDisabled||t,onPress:e.onPress,endContent:o.jsx(H,{icon:"lucide:arrow-right",width:16,height:16}),children:e.label});En.displayName="SummaryPrimaryCta";const so=({title:e,total:t,locale:n,open:r,progress:s,dragging:i,toggleAriaLabel:a,onToggleOpen:l,classNames:c})=>o.jsx("h2",{children:o.jsxs("button",{type:"button","data-testid":"summary-collapse-toggle","aria-expanded":r,"aria-label":a,onClick:l,className:h.cn("-mx-4 -mt-4 grid w-[calc(100%_+_32px)] grid-cols-1 px-4 pb-4 pt-4 text-left",c.header),children:[o.jsxs("span",{"aria-hidden":!r,style:{opacity:s},className:h.cn("col-start-1 row-start-1 flex items-center justify-between",!i&&"transition-opacity duration-300"),children:[o.jsx("span",{"data-testid":"summary-title",className:h.cn("text-xl font-semibold leading-7 text-foreground",c.title),children:e}),o.jsx("span",{"data-testid":"summary-close","aria-hidden":"true",className:h.cn("shrink-0 text-foreground",c.closeButton),children:o.jsx(H,{icon:"lucide:x",width:20,height:20})})]}),o.jsxs("span",{"aria-hidden":r,style:{opacity:1-s},className:h.cn("col-start-1 row-start-1 flex items-center justify-between text-xl font-semibold leading-7 text-foreground",!i&&"transition-opacity duration-300"),children:[o.jsx("span",{children:t.label??"Total"}),o.jsx("span",{className:"whitespace-nowrap",children:Qt(t.amount,n)})]})]})});so.displayName="SummaryCollapseHeader";const io=({cart:e,ariaLabel:t,onPress:n,className:r})=>o.jsxs("button",{type:"button","data-testid":"summary-cart","aria-label":t,onClick:n,className:h.cn("relative flex size-[52px] shrink-0 items-center justify-center rounded-full border border-default-200 bg-content1",r),children:[o.jsx(H,{icon:"lucide:shopping-bag",width:24,height:24,className:"text-foreground"}),e.count!=null&&o.jsx("span",{"data-testid":"summary-cart-badge",className:"absolute -right-1 -top-1 flex size-4 items-center justify-center rounded-full bg-primary text-xs text-primary-foreground",children:e.count})]});io.displayName="SummaryCartButton";const ao=({open:e,progress:t,dragging:n,primaryAction:r,isLoading:s,cart:i,cartAriaLabel:a,onToggleOpen:l,classNames:c})=>o.jsxs("div",{"data-testid":"summary-mobile-bar",className:h.cn("flex flex-col gap-4",c.mobileBar),children:[o.jsx(h.Divider,{className:"bg-default-200"}),o.jsxs("div",{className:"grid",children:[o.jsxs("div",{"aria-hidden":e,style:{opacity:1-t},className:h.cn("col-start-1 row-start-1 flex items-stretch gap-2.5",e&&"pointer-events-none",!n&&"transition-opacity duration-300"),children:[i&&o.jsx(io,{cart:i,ariaLabel:a,className:c.cart,onPress:()=>{l?.(),i.onPress?.()}}),r&&o.jsx(En,{action:r,disabledByLoading:s,className:h.cn("flex-1",c.cta),testId:"summary-cta-compact"})]}),r&&o.jsx("div",{"aria-hidden":!e,style:{opacity:t},className:h.cn("col-start-1 row-start-1 flex",!e&&"pointer-events-none",!n&&"transition-opacity duration-300"),children:o.jsx(En,{action:r,disabledByLoading:s,className:h.cn("w-full",c.cta)})})]})]});ao.displayName="SummaryActionBar";const lo=({title:e="Summary",pricesInLabel:t="Prices are in",currency:n,locale:r="en-US",items:s,serviceFee:i,rows:a,total:l,collapsible:c,isOpen:d=!0,onToggleOpen:u,primaryAction:f,isLoading:p=!1,onRemoveItem:m,variant:v="main",cart:b,emptyState:x,labels:w,classNames:N={},"data-testid":A="summary",className:S})=>{const j=w?.removeAriaLabel??"Remove item",M=w?.toggleAriaLabel??"Toggle summary",D=w?.cartAriaLabel??"View cart",B=c??v==="mobile",F=!B||d,[_,I]=y.useState(0),[E,O]=y.useState(null),P=y.useCallback(Y=>{Y&&I(Y.scrollHeight)},[]),K=Em({open:F,fullHeight:_,setDragHeight:O,onToggleOpen:u}),Z=E!==null,J=Am(E,F,_),le=_>0?Math.min(1,Math.max(0,J/_)):F?1:0,se=o.jsx(ro,{total:l,locale:r,className:N.total}),fe=o.jsx(no,{pricesInLabel:t,currency:n,items:s,serviceFee:i,rows:a,locale:r,onRemoveItem:m,removeAriaLabel:j,emptyState:x,classNames:N});return B?o.jsxs(Le.motion.section,{"data-testid":A,drag:"y",dragConstraints:{top:0,bottom:0},dragElastic:.12,dragSnapToOrigin:!0,onDrag:K.onDrag,onDragEnd:K.onDragEnd,className:h.cn("flex w-full flex-col rounded-t-2xl bg-content1 p-4 drop-shadow-[0_-2px_2px_rgba(0,0,0,0.1)]",S,N.base),children:[o.jsx(so,{title:e,total:l,locale:r,open:F,progress:le,dragging:Z,toggleAriaLabel:M,onToggleOpen:u,classNames:N}),o.jsx("div",{"data-testid":"summary-reveal","aria-hidden":!F,style:{height:J},className:h.cn("overflow-hidden",!F&&"pointer-events-none",Mm(Z)),children:o.jsxs("div",{ref:P,className:"flex flex-col gap-4 pb-4",children:[fe,o.jsx(h.Divider,{className:"bg-default-200"}),se]})}),o.jsx(ao,{open:F,progress:le,dragging:Z,primaryAction:f,isLoading:p,cart:b,cartAriaLabel:D,onToggleOpen:u,classNames:N})]}):o.jsxs("section",{"data-testid":A,className:h.cn("flex w-full flex-col gap-4 rounded-2xl border border-default-200 bg-content1 p-4",S,N.base),children:[o.jsx("div",{className:h.cn("flex items-center justify-between",N.header),children:o.jsx("h2",{"data-testid":"summary-title",className:h.cn("text-xl font-semibold leading-7 text-foreground",N.title),children:e})}),fe,o.jsx(h.Divider,{className:"bg-default-200"}),se,f&&o.jsx(En,{action:f,disabledByLoading:p,className:h.cn("w-full",N.cta)})]})};lo.displayName="Summary";exports.Button=q;exports.CashTenderForm=cm;exports.CheckTenderForm=_l;exports.CommitmentDetails=dh;exports.ConfirmDialog=Zl;exports.ConfirmationModal=jn;exports.ConfirmationPageTemplate=Eo;exports.DonationAmounts=Pa;exports.EventDetails=bf;exports.EventDetailsTemplate=Io;exports.ExpireCartTimer=Ra;exports.Footer=$o;exports.HeroUIProvider=No;exports.InstallmentFundAssignment=sh;exports.InstallmentFundAssignmentSkeleton=oh;exports.InstallmentSchedule=Rh;exports.InstallmentScheduleSkeleton=Uh;exports.InstallmentTable=Wh;exports.ItemCard=Rl;exports.LoadingOverlay=Yl;exports.MembershipSelectCards=Gh;exports.ModalShell=Ul;exports.ModalShellFooter=Wl;exports.ModalShellHeader=ql;exports.Multiselect=Oo;exports.Navbar=Mo;exports.OfferCard=rs;exports.OfferCardEmpty=Xa;exports.OfferCardError=el;exports.OfferCardList=sl;exports.OfferCardSkeleton=tl;exports.OtherTenderForm=Vl;exports.PaymentCashChangeBanner=gs;exports.PaymentSubAmountInput=Ql;exports.PaymentSuccessView=Gl;exports.PaymentTotalBanner=Jl;exports.RICH_TEXT_PRESETS=La;exports.RevenueDistributionCard=gl;exports.RevenueDistributionEmpty=xl;exports.RevenueDistributionError=yl;exports.RevenueDistributionSkeleton=bl;exports.RichTextArea=Fa;exports.Select=pt;exports.SplitPaymentSummary=Hl;exports.Stepper=_i;exports.Summary=lo;exports.TicketSelection=am;exports.TileSelect=Kl;exports.Toggle=zl;exports.calculateAllocationDifference=Qf;exports.computeChange=pr;exports.currencyFractionDigits=Br;exports.formatMoney=tt;exports.formatOfferCurrency=Za;exports.formatRevenueAmount=Kf;exports.formatRevenueCurrency=Jf;exports.generateAutomaticInstallments=Ll;exports.generateDistributionId=us;exports.getCurrencySymbol=Yf;exports.offerCardVariants=rl;exports.offerListVariants=nl;exports.parseOfferCurrency=vf;exports.parseRevenueCurrency=Gf;exports.roundToCurrency=Vi;Object.keys(h).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>h[e]})});
|
|
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)}})();
|