@veevarts/design-system 1.12.8 → 1.13.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/dist/index.cjs +11 -11
  2. package/dist/index.js +8772 -5713
  3. package/dist/patterns/CatalogItemCard/CatalogItemCard.d.ts +7 -0
  4. package/dist/patterns/CatalogItemCard/index.d.ts +2 -0
  5. package/dist/patterns/CatalogItemCard/type.d.ts +82 -0
  6. package/dist/patterns/CommitmentDetails/CommitmentDetails.d.ts +16 -0
  7. package/dist/patterns/CommitmentDetails/index.d.ts +2 -0
  8. package/dist/patterns/ConfirmationModal/ConfirmationModal.d.ts +18 -0
  9. package/dist/patterns/ConfirmationModal/index.d.ts +2 -0
  10. package/dist/patterns/EventDetails/EventDetails.d.ts +3 -1
  11. package/dist/patterns/FeedbackState/FeedbackState.d.ts +23 -0
  12. package/dist/patterns/FeedbackState/index.d.ts +2 -0
  13. package/dist/patterns/FeedbackState/type.d.ts +40 -0
  14. package/dist/patterns/FilterPopover/FilterPopover.d.ts +6 -0
  15. package/dist/patterns/FilterPopover/index.d.ts +2 -0
  16. package/dist/patterns/FilterPopover/type.d.ts +85 -0
  17. package/dist/patterns/InstallmentFundAssignment/InstallmentFundAssignment.d.ts +3 -0
  18. package/dist/patterns/InstallmentFundAssignment/InstallmentFundAssignmentSkeleton.d.ts +2 -0
  19. package/dist/patterns/InstallmentFundAssignment/index.d.ts +3 -0
  20. package/dist/patterns/InstallmentFundAssignment/types.d.ts +67 -0
  21. package/dist/patterns/InstallmentSchedule/InstallmentSchedule.d.ts +3 -0
  22. package/dist/patterns/InstallmentSchedule/InstallmentScheduleSkeleton.d.ts +2 -0
  23. package/dist/patterns/InstallmentSchedule/InstallmentTable.d.ts +3 -0
  24. package/dist/patterns/InstallmentSchedule/index.d.ts +5 -0
  25. package/dist/patterns/InstallmentSchedule/types.d.ts +93 -0
  26. package/dist/patterns/InstallmentSchedule/utils.d.ts +2 -0
  27. package/dist/patterns/ItemCard/type.d.ts +52 -0
  28. package/dist/patterns/OfferCard/OfferCard.d.ts +1 -1
  29. package/dist/patterns/OfferCard/types.d.ts +93 -2
  30. package/dist/patterns/OfferCard/variants/OfferCardList.d.ts +2 -2
  31. package/dist/patterns/SessionTimeline/SessionTimeline.d.ts +7 -0
  32. package/dist/patterns/SessionTimeline/index.d.ts +2 -0
  33. package/dist/patterns/SessionTimeline/type.d.ts +76 -0
  34. package/dist/patterns/Summary/Summary.d.ts +4 -0
  35. package/dist/patterns/Summary/components/ActionBar.d.ts +17 -0
  36. package/dist/patterns/Summary/components/CartButton.d.ts +11 -0
  37. package/dist/patterns/Summary/components/CollapseHeader.d.ts +19 -0
  38. package/dist/patterns/Summary/components/GrandTotalRow.d.ts +11 -0
  39. package/dist/patterns/Summary/components/ItemRow.d.ts +9 -0
  40. package/dist/patterns/Summary/components/PrimaryCta.d.ts +11 -0
  41. package/dist/patterns/Summary/components/ServiceFeeRow.d.ts +8 -0
  42. package/dist/patterns/Summary/components/SummaryBody.d.ts +15 -0
  43. package/dist/patterns/Summary/components/TotalsLineRow.d.ts +8 -0
  44. package/dist/patterns/Summary/drag.d.ts +55 -0
  45. package/dist/patterns/Summary/fmt.d.ts +2 -0
  46. package/dist/patterns/Summary/index.d.ts +7 -0
  47. package/dist/patterns/Summary/types.d.ts +154 -0
  48. package/dist/patterns/Summary/useIsMobile.d.ts +17 -0
  49. package/dist/patterns/index.d.ts +18 -0
  50. package/package.json +2 -1
  51. package/dist/components/Button/Button.test.d.ts +0 -1
  52. package/dist/components/Select/Select.test.d.ts +0 -1
  53. package/dist/patterns/CashTenderForm/__test__/CashTenderForm.test.d.ts +0 -4
  54. package/dist/patterns/CheckTenderForm/__test__/CheckTenderForm.test.d.ts +0 -4
  55. package/dist/patterns/DonationAmounts/__test__/DonationAmounts.test.d.ts +0 -4
  56. package/dist/patterns/EventDetails/__test__/EventDetails.test.d.ts +0 -1
  57. package/dist/patterns/ExpireCartTimer/__test__/ExpireCartTimer.test.d.ts +0 -4
  58. package/dist/patterns/Footer/__test__/Footer.test.d.ts +0 -1
  59. package/dist/patterns/ItemCard/__test__/ItemCard.test.d.ts +0 -4
  60. package/dist/patterns/MembershipSelectCards/__test__/MembershipSelectCards.test.d.ts +0 -4
  61. package/dist/patterns/Multiselect/__test__/Multiselect.test.d.ts +0 -4
  62. package/dist/patterns/Navbar/__test__/Navbar.test.d.ts +0 -1
  63. package/dist/patterns/OfferCard/__test__/OfferCard.test.d.ts +0 -1
  64. package/dist/patterns/OtherTenderForm/__test__/OtherTenderForm.test.d.ts +0 -4
  65. package/dist/patterns/PaymentSubAmountInput/__test__/PaymentSubAmountInput.test.d.ts +0 -4
  66. package/dist/patterns/RevenueDistribution/__test__/RevenueDistributionCard.test.d.ts +0 -1
  67. package/dist/patterns/RichText/RichText.test.d.ts +0 -1
  68. package/dist/patterns/RichText/core/TipTapEditor.test.d.ts +0 -1
  69. package/dist/patterns/SplitPaymentSummary/__test__/SplitPaymentSummary.test.d.ts +0 -4
  70. package/dist/patterns/Stepper/Stepper.test.d.ts +0 -4
  71. package/dist/patterns/TicketSelection/__test__/TicketSelection.test.d.ts +0 -4
  72. package/dist/patterns/Toggle/__test__/Toggle.test.d.ts +0 -4
package/dist/index.cjs CHANGED
@@ -1,22 +1,22 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),g=require("@heroui/react"),x=require("react"),_=require("lucide-react"),$e=require("framer-motion"),yr=require("@tiptap/react"),$=require("@tiptap/core"),ca=require("@tiptap/extension-underline"),da=require("@tiptap/extension-color"),ua=require("@tiptap/extension-highlight"),fa=require("@tiptap/extension-link"),ha=require("@tiptap/extension-task-list"),pa=require("@tiptap/extension-task-item"),ma=require("@tiptap/extension-text-align");function ga({children:t}){return c.jsx(g.HeroUIProvider,{children:t})}const G=x.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}));G.displayName="Button";function xa(t){const e=t?.closest('[role="dialog"]');return e?.parentElement??e??void 0}const wt=x.forwardRef(({popoverProps:t,...e},n)=>{const r=x.useRef(null),[s,i]=x.useState(void 0),o={...t,disableDialogFocus:t?.disableDialogFocus??(s?!0:void 0),portalContainer:t?.portalContainer??s};return x.useEffect(()=>{i(xa(r.current))},[]),c.jsx("span",{ref:r,className:"contents",children:c.jsx(g.Select,{ref:n,...e,popoverProps:o})})});wt.displayName="Select";const ya={login:"Login",logout:"Logout",selectLanguage:"Select your language"};function ba({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(wt,{"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(_.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(wt,{"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(_.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 va({isLoggedIn:t,onLogin:e,onLogout:n,labels:r}){return t?c.jsxs(G,{"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(_.User,{className:"inline w-5 h-5"}),c.jsx("span",{className:"hidden md:inline",children:r.logout})]}):c.jsxs(G,{"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(_.User,{className:"inline w-5 h-5"}),c.jsx("span",{className:"hidden md:inline",children:r.login})]})}function ka({logo:t,languages:e=[],selectedLanguage:n,onLanguageChange:r,isLoggedIn:s,onLogin:i,onLogout:o,hasLanguages:a,hasAuth:l,labels:d={},className:u}){const f={...ya,...d};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",u),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 w-auto max-w-28 md:max-w-40 object-contain"})})}),c.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[(a||e.length>0)&&c.jsx(ba,{languages:e,selectedLanguage:n,onLanguageChange:r,label:f.selectLanguage}),l&&c.jsx(va,{isLoggedIn:s,onLogin:i,onLogout:o,labels:f})]})]})}function Sa(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 On;const Ca=typeof document<"u"?(On=x.useInsertionEffect)!==null&&On!==void 0?On:x.useLayoutEffect:()=>{};function br(t,e,n){let[r,s]=x.useState(t||e),i=x.useRef(r),o=x.useRef(t!==void 0),a=t!==void 0;x.useEffect(()=>{let f=o.current;f!==a&&process.env.NODE_ENV!=="production"&&console.warn(`WARN: A component changed from ${f?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}.`),o.current=a},[a]);let l=a?t:r;Ca(()=>{i.current=l});let[,d]=x.useReducer(()=>({}),{}),u=x.useCallback((f,...p)=>{let h=typeof f=="function"?f(i.current):f;Object.is(i.current,h)||(i.current=h,s(h),d(),n?.(h,...p))},[n]);return[l,u]}function wa(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 ai=x.forwardRef(({color:t="primary",stepsCount:e=3,defaultStep:n=0,label:r,onStepChange:s,currentStep:i,hideProgressBars:o=!1,stepClassName:a,className:l,isDisabled:d=!1,...u},f)=>{const[p,h]=br(i,n,s),k=x.useMemo(()=>{let v,y;const S=["[--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":v="[--step-color:var(--heroui-primary)]",y="[--step-fg-color:var(--heroui-primary-foreground)]";break;case"secondary":v="[--step-color:var(--heroui-secondary)]",y="[--step-fg-color:var(--heroui-secondary-foreground)]";break;case"success":v="[--step-color:var(--heroui-success)]",y="[--step-fg-color:var(--heroui-success-foreground)]";break;case"warning":v="[--step-color:var(--heroui-warning)]",y="[--step-fg-color:var(--heroui-warning-foreground)]";break;case"danger":v="[--step-color:var(--heroui-danger)]",y="[--step-fg-color:var(--heroui-danger-foreground)]";break;case"default":v="[--step-color:var(--heroui-default)]",y="[--step-fg-color:var(--heroui-default-foreground)]";break;default:v="[--step-color:var(--heroui-primary)]",y="[--step-fg-color:var(--heroui-primary-foreground)]";break}return S.unshift(y),S.unshift(v),S},[t]);return c.jsxs("nav",{ref:f,"aria-label":"Progress",className:g.cn("flex max-w-fit items-center overflow-x-auto",l),"data-testid":"stepper-root",...u,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",k,l),"data-testid":"stepper-list",children:Array.from({length:e})?.map((v,y)=>{const S=p===y?"active":p<y?"inactive":"complete";return c.jsx("li",{className:"relative flex shrink-0 items-center pr-12","data-testid":`stepper-step-${y}`,children:c.jsxs("button",{"aria-current":S==="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":d},a),onClick:()=>!d&&h(y),disabled:d,"data-testid":`stepper-step-btn-${y}`,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:S,className:"relative",children:c.jsx($e.m.div,{animate:S,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":S==="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:S==="complete"?c.jsx(wa,{className:"h-5 w-5 text-(--active-fg-color)","data-testid":`stepper-step-check-${y}`}):c.jsx("span",{})})})})})}),y<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":y},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":y<p})})})]},y)},y)})})]})});ai.displayName="Stepper";function Na(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 ht(t,e="en-US",n="USD"){try{return new Intl.NumberFormat(e,{style:"currency",currency:n}).format(t)}catch{return`${n} ${t.toFixed(2)}`}}function vr(t,e="en-US"){try{const n=new Intl.NumberFormat(e,{style:"currency",currency:t}).resolvedOptions();return typeof n.maximumFractionDigits=="number"?n.maximumFractionDigits:2}catch{return 2}}function li(t,e,n="en-US"){const r=vr(e,n),s=Math.pow(10,r);return Math.round(t*s)/s}function Qn(t,e,n,r){return li(t-e,n,r)}function Aa(){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 ja=t=>{const e=x.useMemo(()=>JSON.stringify({allItems:t.allItems,selected:t.selected}),[t.allItems,t.selected]);return c.jsx(Ea,{...t},e)},Ea=({allItems:t,selected:e,onSelectedChange:n,titleLeft:r,titleRight:s})=>{const[i,o]=x.useState([]),[a,l]=x.useState([]),[d,u]=x.useState(null),[f,p]=x.useState(null),h=x.useMemo(()=>new Set(e),[e]),k=x.useMemo(()=>new Set(t),[t]),v=x.useMemo(()=>t.filter(O=>!h.has(O)),[t,h]),y=O=>{if(O.length===0)return;const M=Array.from(new Set([...e,...O]));n(M)},S=O=>{if(O.length===0)return;const M=new Set(O);n(e.filter(L=>!M.has(L)))},N=()=>{i.length!==0&&(y(i),o([]))},j=()=>{a.length!==0&&(S(a),l([]))},w=()=>{v.length!==0&&(y(v),o([]))},A=()=>{e.length!==0&&(n([]),l([]))},T=(O,M,L)=>{const R=Math.min(M,L),U=Math.max(M,L);return O.slice(R,U+1)},I=(O,M,L)=>{if(L&&d!==null){o(T(v,d,M)),l([]),u(M);return}const R=i.includes(O);o(R?i.filter(U=>U!==O):[...i,O]),l([]),u(M)},z=(O,M,L)=>{if(L&&f!==null){l(T(e,f,M)),o([]),p(M);return}const R=a.includes(O);l(R?a.filter(U=>U!==O):[...a,O]),o([]),p(M)},B=(O,M,L)=>{const R=L==="available"?i.includes(M)?i:[M]:a.includes(M)?a:[M];O.dataTransfer.setData("text/plain",JSON.stringify({source:L,items:R})),O.dataTransfer.effectAllowed="move"},H=(O,M)=>{O.preventDefault();const L=O.dataTransfer.getData("text/plain");if(L)try{const R=JSON.parse(L),U=(R.items||[]).filter(Z=>k.has(Z));if(U.length===0||R.source===M)return;M==="selected"?(y(U),o([])):(S(U),l([]))}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:O=>O.preventDefault(),onDrop:O=>H(O,"available"),children:v.map((O,M)=>{const L=i.includes(O);return c.jsx("button",{type:"button",onClick:R=>{I(O,M,R.shiftKey)},onMouseDown:R=>{R.shiftKey&&R.preventDefault()},draggable:!0,onDragStart:R=>B(R,O,"available"),className:`rounded-md px-3 py-2 text-left text-sm transition ${L?"bg-[#E4571E]/10 text-[#E4571E]":"text-gray-700 hover:bg-gray-100"}`,children:O},O)})})})]}),c.jsxs("div",{className:"flex flex-row items-center justify-center gap-3 md:flex-col md:pt-6",children:[c.jsx(G,{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:"›"}),c.jsx(G,{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:j,isDisabled:a.length===0,"aria-label":"Move selected to left",children:"‹"}),c.jsx(G,{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:w,isDisabled:v.length===0,"aria-label":"Move all to right",children:"»"}),c.jsx(G,{variant:"light",className:"h-10 w-10 min-w-0 text-2xl font-semibold text-[#E4571E] hover:bg-[#E4571E]/10",isIconOnly:!0,onPress:A,"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:O=>O.preventDefault(),onDrop:O=>H(O,"selected"),children:e.map((O,M)=>{const L=a.includes(O);return c.jsx("button",{type:"button",onClick:R=>{z(O,M,R.shiftKey)},onMouseDown:R=>{R.shiftKey&&R.preventDefault()},draggable:!0,onDragStart:R=>B(R,O,"selected"),className:`rounded-md px-3 py-2 text-left text-sm transition ${L?"bg-[#E4571E]/10 text-[#E4571E]":"text-gray-700 hover:bg-gray-100"}`,children:O},O)})})})]})]})};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:a}){const l=i?`${e} (${i})`:e;return c.jsx(g.Tooltip,{content:l,placement:"top",offset:10,children:c.jsx(G,{size:"sm",radius:"sm",color:n?"primary":"default",variant:n?"solid":"bordered",isIconOnly:!0,isDisabled:r,onPress:s,"aria-label":e,className:a,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"}},Ta={1:"Heading 1",2:"Heading 2",3:"Heading 3",4:"Heading 4",5:"Heading 5",6:"Heading 6"};function Ma({editor:t,levels:e=[1,2,3,4,5,6],isDisabled:n=!1}){const[,r]=x.useState(0);x.useEffect(()=>{const o=()=>r(a=>a+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 a=Number(o),l=Ke.heading;l&&l.execute({editor:t,config:{type:"heading",level:a}})};return c.jsxs(g.Dropdown,{placement:"top-start",offset:10,children:[c.jsx(g.DropdownTrigger,{children:c.jsx(G,{size:"sm",radius:"sm",variant:s?"solid":"bordered",color:s?"primary":"default",isDisabled:n,startContent:c.jsx(_.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(_.Check,{size:16}):c.jsx("div",{className:"w-4"}),children:Ta[o]},o))})]})}const Dn={bulletList:{label:"Bullet List",icon:_.List},orderedList:{label:"Numbered List",icon:_.ListOrdered},taskList:{label:"Task List",icon:_.ListTodo}};function Oa({editor:t,types:e=["bulletList","orderedList","taskList"],isDisabled:n=!1}){const[,r]=x.useState(0);x.useEffect(()=>{const a=()=>r(l=>l+1);return t.on("selectionUpdate",a),t.on("transaction",a),()=>{t.off("selectionUpdate",a),t.off("transaction",a)}},[t]);const s=e.find(a=>t.isActive(a)),i=s?Dn[s].icon:_.List,o=a=>{const d=Ke[a];d&&d.execute({editor:t})};return c.jsxs(g.Dropdown,{placement:"top-start",offset:10,children:[c.jsx(g.DropdownTrigger,{children:c.jsx(G,{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(a=>{const l=Dn[a].icon;return c.jsx(g.DropdownItem,{startContent:c.jsx(l,{size:16}),children:Dn[a].label},a)})})]})}function Da({colors:t,selectedColor:e,onColorSelect:n,columns:r=4}){return c.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:`repeat(${r}, minmax(0, 1fr))`},children:t.map(s=>{const i=e===s;return c.jsx("button",{type:"button",onClick:()=>n(s),className:`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),f=require("@heroui/react"),y=require("react"),J=require("lucide-react"),Pe=require("framer-motion"),Jr=require("@tiptap/react"),V=require("@tiptap/core"),Eo=require("@tiptap/extension-underline"),To=require("@tiptap/extension-color"),Do=require("@tiptap/extension-highlight"),Io=require("@tiptap/extension-link"),$o=require("@tiptap/extension-task-list"),Oo=require("@tiptap/extension-task-item"),Lo=require("@tiptap/extension-text-align");function Fo({children:e}){return l.jsx(f.HeroUIProvider,{children:e})}const K=y.forwardRef(({color:e="primary",radius:t="full",testId:n="veevart-button",...r},s)=>l.jsx(f.Button,{ref:s,color:e,radius:t,"data-testid":n,...r}));K.displayName="Button";function Po(e){const t=e?.closest('[role="dialog"]');return t?.parentElement??t??void 0}const yt=y.forwardRef(({popoverProps:e,...t},n)=>{const r=y.useRef(null),[s,i]=y.useState(void 0),a={...e,disableDialogFocus:e?.disableDialogFocus??(s?!0:void 0),portalContainer:e?.portalContainer??s};return y.useEffect(()=>{i(Po(r.current))},[]),l.jsx("span",{ref:r,className:"contents",children:l.jsx(f.Select,{ref:n,...t,popoverProps:a})})});yt.displayName="Select";const Ro={login:"Login",logout:"Logout",selectLanguage:"Select your language"};function zo({languages:e,selectedLanguage:t,onLanguageChange:n,label:r}){const s=e.find(i=>i.code===t);return l.jsx("div",{className:"flex items-center",children:l.jsxs("div",{className:"relative flex items-center",children:[l.jsx(yt,{"data-testid":"language-select-desktop",variant:"bordered","aria-label":r,selectedKeys:t?[t]:[],onSelectionChange:i=>{const a=Array.from(i)[0]||t;n?.(a)},className:"min-w-36 hidden md:inline-flex",isDisabled:e.length===0,placeholder:r,startContent:l.jsx(J.Globe,{className:"w-5 h-5 text-black"}),renderValue:()=>l.jsx("span",{children:s?.label||r}),size:"md",radius:"full",children:e.map(i=>l.jsx(f.SelectItem,{textValue:i.label,"data-testid":`language-select-option-${i.code}`,children:i.label},i.code))}),l.jsx(yt,{"aria-label":r,"data-testid":"language-select-mobile",variant:"bordered",selectedKeys:t?[t]:[],onSelectionChange:i=>{const a=Array.from(i)[0]||t;n?.(a)},className:"w-24 inline-flex md:hidden",isDisabled:e.length===0,placeholder:"",startContent:l.jsx(J.Globe,{className:"w-6 h-6 text-black"}),renderValue:()=>l.jsx("span",{children:s?.code.toUpperCase()||""}),size:"md",radius:"full",children:e.map(i=>l.jsx(f.SelectItem,{textValue:i.code.toUpperCase(),"data-testid":`language-select-option-mobile-${i.code}`,children:i.code.toUpperCase()},i.code))})]})})}function Bo({isLoggedIn:e,onLogin:t,onLogout:n,labels:r}){return e?l.jsxs(K,{"data-testid":"navbar-auth-button",className:"px-2 py-1 w-1 min-w-12 md:min-w-24 rounded-full bg-black text-white text-sm flex items-center",onPress:n,size:"md",children:[l.jsx(J.User,{className:"inline w-5 h-5"}),l.jsx("span",{className:"hidden md:inline",children:r.logout})]}):l.jsxs(K,{"data-testid":"navbar-auth-button",className:"px-2 py-1 min-w-12 md:min-w-24 rounded-full bg-black text-white text-sm flex items-center",onPress:t,size:"md",children:[l.jsx(J.User,{className:"inline w-5 h-5"}),l.jsx("span",{className:"hidden md:inline",children:r.login})]})}function _o({logo:e,languages:t=[],selectedLanguage:n,onLanguageChange:r,isLoggedIn:s,onLogin:i,onLogout:a,hasLanguages:o,hasAuth:c,labels:d={},className:u}){const h={...Ro,...d};return l.jsxs("nav",{"data-testid":"navbar",className:f.cn("w-full px-4 md:px-8 py-3 bg-white border-b border-zinc-100 flex items-center justify-between",u),children:[l.jsx("div",{className:"flex items-center min-w-10",children:e&&l.jsx("a",{href:"/",className:"block",children:l.jsx("img",{"data-testid":"navbar-logo",src:e,alt:"Logo",className:"h-8 w-auto max-w-28 md:max-w-40 object-contain"})})}),l.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[(o||t.length>0)&&l.jsx(zo,{languages:t,selectedLanguage:n,onLanguageChange:r,label:h.selectLanguage}),c&&l.jsx(Bo,{isLoggedIn:s,onLogin:i,onLogout:a,labels:h})]})]})}function Vo(e){return l.jsx("div",{className:"min-h-screen flex flex-col",children:l.jsx("div",{className:"flex-1 flex items-center justify-center p-12",children:l.jsx(f.Alert,{description:"This template combines Navbar, Footer, and a confirmation Card. Include title, message, confirmation number, details list, icon, and action buttons. Use Card for the confirmation content.",title:"TODO: Implement ConfirmationPageTemplate",variant:"faded",className:"max-w-2xl"})})})}var Zn;const Ho=typeof document<"u"?(Zn=y.useInsertionEffect)!==null&&Zn!==void 0?Zn:y.useLayoutEffect:()=>{};function Yr(e,t,n){let[r,s]=y.useState(e||t),i=y.useRef(r),a=y.useRef(e!==void 0),o=e!==void 0;y.useEffect(()=>{let h=a.current;h!==o&&process.env.NODE_ENV!=="production"&&console.warn(`WARN: A component changed from ${h?"controlled":"uncontrolled"} to ${o?"controlled":"uncontrolled"}.`),a.current=o},[o]);let c=o?e:r;Ho(()=>{i.current=c});let[,d]=y.useReducer(()=>({}),{}),u=y.useCallback((h,...p)=>{let m=typeof h=="function"?h(i.current):h;Object.is(i.current,m)||(i.current=m,s(m),d(),n?.(m,...p))},[n]);return[c,u]}function Uo(e){return l.jsx("svg",{...e,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:l.jsx(Pe.m.path,{animate:{pathLength:1},d:"M5 13l4 4L19 7",initial:{pathLength:0},strokeLinecap:"round",strokeLinejoin:"round",transition:{delay:.2,type:"tween",ease:"easeOut",duration:.3}})})}const Yi=y.forwardRef(({color:e="primary",stepsCount:t=3,defaultStep:n=0,label:r,onStepChange:s,currentStep:i,hideProgressBars:a=!1,stepClassName:o,className:c,isDisabled:d=!1,...u},h)=>{const[p,m]=Yr(i,n,s),v=y.useMemo(()=>{let b,x;const w=["[--active-fg-color:hsl(var(--step-fg-color))]","[--active-border-color:hsl(var(--step-color))]","[--active-color:hsl(var(--step-color))]","[--complete-background-color:hsl(var(--step-color))]","[--complete-border-color:hsl(var(--step-color))]","[--inactive-border-color:hsl(var(--heroui-default-300))]","[--inactive-color:hsl(var(--heroui-default-300))]"];switch(e){case"primary":b="[--step-color:var(--heroui-primary)]",x="[--step-fg-color:var(--heroui-primary-foreground)]";break;case"secondary":b="[--step-color:var(--heroui-secondary)]",x="[--step-fg-color:var(--heroui-secondary-foreground)]";break;case"success":b="[--step-color:var(--heroui-success)]",x="[--step-fg-color:var(--heroui-success-foreground)]";break;case"warning":b="[--step-color:var(--heroui-warning)]",x="[--step-fg-color:var(--heroui-warning-foreground)]";break;case"danger":b="[--step-color:var(--heroui-danger)]",x="[--step-fg-color:var(--heroui-danger-foreground)]";break;case"default":b="[--step-color:var(--heroui-default)]",x="[--step-fg-color:var(--heroui-default-foreground)]";break;default:b="[--step-color:var(--heroui-primary)]",x="[--step-fg-color:var(--heroui-primary-foreground)]";break}return w.unshift(x),w.unshift(b),w},[e]);return l.jsxs("nav",{ref:h,"aria-label":"Progress",className:f.cn("flex max-w-fit items-center overflow-x-auto",c),"data-testid":"stepper-root",...u,children:[r&&l.jsx("label",{className:"text-small text-default-foreground lg:text-medium font-light whitespace-nowrap me-3","data-testid":"stepper-label",children:r}),l.jsx("ol",{className:f.cn("flex flex-row flex-nowrap gap-x-3",v,c),"data-testid":"stepper-list",children:Array.from({length:t})?.map((b,x)=>{const w=p===x?"active":p<x?"inactive":"complete";return l.jsx("li",{className:"relative flex shrink-0 items-center pr-12","data-testid":`stepper-step-${x}`,children:l.jsxs("button",{"aria-current":w==="active"?"step":void 0,className:f.cn("group rounded-large flex w-full cursor-pointer flex-row items-center justify-center gap-x-3 py-2.5",{"cursor-not-allowed opacity-50":d},o),onClick:()=>!d&&m(x),disabled:d,"data-testid":`stepper-step-btn-${x}`,children:[l.jsx("div",{className:"h-full relative flex items-center",children:l.jsx(Pe.LazyMotion,{features:Pe.domAnimation,children:l.jsx(Pe.m.div,{animate:w,className:"relative",children:l.jsx(Pe.m.div,{animate:w,className:f.cn("border-medium text-large text-default-foreground relative flex h-[26px] w-[26px] items-center justify-center rounded-full font-semibold",{"shadow-lg":w==="complete"}),initial:!1,transition:{duration:.25},variants:{inactive:{backgroundColor:"transparent",borderColor:"var(--inactive-border-color)",color:"var(--inactive-color)"},active:{backgroundColor:"transparent",borderColor:"var(--active-border-color)",color:"var(--active-color)"},complete:{backgroundColor:"var(--complete-background-color)",borderColor:"var(--complete-border-color)",color:"var(--active-fg-color)"}},children:l.jsx("div",{className:"flex items-center justify-center",children:w==="complete"?l.jsx(Uo,{className:"h-5 w-5 text-(--active-fg-color)","data-testid":`stepper-step-check-${x}`}):l.jsx("span",{})})})})})}),x<t-1&&!a&&l.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 left-[26px] w-[calc(100%-13px)] flex-none items-center",style:{"--idx":x},children:l.jsx("div",{className:f.cn("bg-default-200 relative h-0.5 w-full transition-colors duration-300","after:absolute after:block after:h-full after:w-0 after:bg-(--active-border-color) after:transition-[width] after:duration-300 after:content-['']",{"after:w-full":x<p})})})]},x)},x)})})]})});Yi.displayName="Stepper";function qo(e){return l.jsx("div",{className:"min-h-screen flex flex-col",children:l.jsx("div",{className:"flex-1 flex items-center justify-center p-12",children:l.jsx(f.Alert,{description:"This template combines Navbar, Stepper, Footer, and an event details Card. Include event image, category/spots chips, tags, details grid, and action buttons. Use Card, CardHeader, CardBody for content structure.",title:"TODO: Implement EventDetailsTemplate",variant:"faded",className:"max-w-2xl"})})})}function rt(e,t="en-US",n="USD"){try{return new Intl.NumberFormat(t,{style:"currency",currency:n}).format(e)}catch{return`${n} ${e.toFixed(2)}`}}function Gr(e,t="en-US"){try{const n=new Intl.NumberFormat(t,{style:"currency",currency:e}).resolvedOptions();return typeof n.maximumFractionDigits=="number"?n.maximumFractionDigits:2}catch{return 2}}function Gi(e,t,n="en-US"){const r=Gr(t,n),s=Math.pow(10,r);return Math.round(e*s)/s}function Cr(e,t,n,r){return Gi(e-t,n,r)}function Wo(){return l.jsxs("footer",{"data-testid":"footer",className:"fixed left-0 bottom-0 w-full text-left p-4 bg-white font-inter font-light text-base text-zinc-500",children:["Powered by Veevart ® ",new Date().getFullYear()]})}const Ko=e=>{const t=y.useMemo(()=>JSON.stringify({allItems:e.allItems,selected:e.selected}),[e.allItems,e.selected]);return l.jsx(Jo,{...e},t)},Jo=({allItems:e,selected:t,onSelectedChange:n,titleLeft:r,titleRight:s})=>{const[i,a]=y.useState([]),[o,c]=y.useState([]),[d,u]=y.useState(null),[h,p]=y.useState(null),m=y.useMemo(()=>new Set(t),[t]),v=y.useMemo(()=>new Set(e),[e]),b=y.useMemo(()=>e.filter(E=>!m.has(E)),[e,m]),x=E=>{if(E.length===0)return;const C=Array.from(new Set([...t,...E]));n(C)},w=E=>{if(E.length===0)return;const C=new Set(E);n(t.filter(I=>!C.has(I)))},S=()=>{i.length!==0&&(x(i),a([]))},M=()=>{o.length!==0&&(w(o),c([]))},N=()=>{b.length!==0&&(x(b),a([]))},j=()=>{t.length!==0&&(n([]),c([]))},T=(E,C,I)=>{const F=Math.min(C,I),H=Math.max(C,I);return E.slice(F,H+1)},$=(E,C,I)=>{if(I&&d!==null){a(T(b,d,C)),c([]),u(C);return}const F=i.includes(E);a(F?i.filter(H=>H!==E):[...i,E]),c([]),u(C)},W=(E,C,I)=>{if(I&&h!==null){c(T(t,h,C)),a([]),p(C);return}const F=o.includes(E);c(F?o.filter(H=>H!==E):[...o,E]),a([]),p(C)},D=(E,C,I)=>{const F=I==="available"?i.includes(C)?i:[C]:o.includes(C)?o:[C];E.dataTransfer.setData("text/plain",JSON.stringify({source:I,items:F})),E.dataTransfer.effectAllowed="move"},R=(E,C)=>{E.preventDefault();const I=E.dataTransfer.getData("text/plain");if(I)try{const F=JSON.parse(I),H=(F.items||[]).filter(Q=>v.has(Q));if(H.length===0||F.source===C)return;C==="selected"?(x(H),a([])):(w(H),c([]))}catch{return}};return l.jsxs("div",{className:"flex flex-col gap-6 md:flex-row md:items-start md:justify-between",children:[l.jsxs("div",{className:"flex w-full flex-col gap-3 md:w-2/5",children:[l.jsx("h2",{className:"text-sm font-medium text-gray-700",children:r}),l.jsx(f.Card,{className:"w-full border border-gray-200 shadow-none",children:l.jsx(f.CardBody,{className:"h-60 gap-2 overflow-y-auto",onDragOver:E=>E.preventDefault(),onDrop:E=>R(E,"available"),children:b.map((E,C)=>{const I=i.includes(E);return l.jsx("button",{type:"button",onClick:F=>{$(E,C,F.shiftKey)},onMouseDown:F=>{F.shiftKey&&F.preventDefault()},draggable:!0,onDragStart:F=>D(F,E,"available"),className:`rounded-md px-3 py-2 text-left text-sm transition ${I?"bg-[#E4571E]/10 text-[#E4571E]":"text-gray-700 hover:bg-gray-100"}`,children:E},E)})})})]}),l.jsxs("div",{className:"flex flex-row items-center justify-center gap-3 md:flex-col md:pt-6",children:[l.jsx(K,{variant:"light",className:"h-10 w-10 min-w-0 text-2xl font-semibold text-[#E4571E] hover:bg-[#E4571E]/10",isIconOnly:!0,"data-testid":"move-selected-to-available",onPress:S,isDisabled:i.length===0,"aria-label":"Move selected to right",children:"›"}),l.jsx(K,{variant:"light",className:"h-10 w-10 min-w-0 text-2xl font-semibold text-[#E4571E] hover:bg-[#E4571E]/10",isIconOnly:!0,"data-testid":"move-selected-to-available",onPress:M,isDisabled:o.length===0,"aria-label":"Move selected to left",children:"‹"}),l.jsx(K,{variant:"light",className:"h-10 w-10 min-w-0 text-2xl font-semibold text-[#E4571E] hover:bg-[#E4571E]/10",isIconOnly:!0,"data-testid":"move-all-to-selected",onPress:N,isDisabled:b.length===0,"aria-label":"Move all to right",children:"»"}),l.jsx(K,{variant:"light",className:"h-10 w-10 min-w-0 text-2xl font-semibold text-[#E4571E] hover:bg-[#E4571E]/10",isIconOnly:!0,onPress:j,"data-testid":"move-all-to-available",isDisabled:t.length===0,"aria-label":"Move all to left",children:"«"})]}),l.jsxs("div",{className:"flex w-full flex-col gap-3 md:w-2/5",children:[l.jsx("h2",{className:"text-sm font-medium text-gray-700",children:s}),l.jsx(f.Card,{className:"w-full border border-gray-200 shadow-none",children:l.jsx(f.CardBody,{className:"h-60 gap-2 overflow-y-auto",onDragOver:E=>E.preventDefault(),onDrop:E=>R(E,"selected"),children:t.map((E,C)=>{const I=o.includes(E);return l.jsx("button",{type:"button",onClick:F=>{W(E,C,F.shiftKey)},onMouseDown:F=>{F.shiftKey&&F.preventDefault()},draggable:!0,onDragStart:F=>D(F,E,"selected"),className:`rounded-md px-3 py-2 text-left text-sm transition ${I?"bg-[#E4571E]/10 text-[#E4571E]":"text-gray-700 hover:bg-gray-100"}`,children:E},E)})})})]})]})};function Yt(e){return typeof e=="string"?e:e.type}function ot({className:e}){return l.jsx("div",{className:`flex items-center h-6 ${e||""}`,children:l.jsx(f.Divider,{orientation:"vertical"})})}function ct({icon:e,label:t,isActive:n=!1,isDisabled:r=!1,onClick:s,shortcut:i,iconSize:a=16,className:o}){const c=i?`${t} (${i})`:t;return l.jsx(f.Tooltip,{content:c,placement:"top",offset:10,children:l.jsx(K,{size:"sm",radius:"sm",color:n?"primary":"default",variant:n?"solid":"bordered",isIconOnly:!0,isDisabled:r,onPress:s,"aria-label":t,className:o,children:l.jsx(e,{size:a})})})}const Je={bold:{execute:({editor:e})=>e.chain().focus().toggleBold().run(),canExecute:e=>e.can().chain().focus().toggleBold().run(),isActive:e=>e.isActive("bold"),shortcut:"Mod-b",label:"Bold"},italic:{execute:({editor:e})=>e.chain().focus().toggleItalic().run(),canExecute:e=>e.can().chain().focus().toggleItalic().run(),isActive:e=>e.isActive("italic"),shortcut:"Mod-i",label:"Italic"},strike:{execute:({editor:e})=>e.chain().focus().toggleStrike().run(),canExecute:e=>e.can().chain().focus().toggleStrike().run(),isActive:e=>e.isActive("strike"),shortcut:"Mod-Shift-x",label:"Strikethrough"},underline:{execute:({editor:e})=>e.chain().focus().toggleUnderline().run(),canExecute:e=>e.can().chain().focus().toggleUnderline().run(),isActive:e=>e.isActive("underline"),shortcut:"Mod-u",label:"Underline"},code:{execute:({editor:e})=>e.chain().focus().toggleCode().run(),canExecute:e=>e.can().chain().focus().toggleCode().run(),isActive:e=>e.isActive("code"),shortcut:"Mod-e",label:"Inline code"},textColor:{execute:({editor:e,config:t})=>{const n=t?.type==="textColor"?t.color:"";n?e.chain().focus().setColor(n).run():e.chain().focus().unsetColor().run()},canExecute:()=>!0,isActive:e=>e.isActive("textStyle"),label:"Text color"},highlight:{execute:({editor:e,config:t})=>{const n=t?.type==="highlight"?t.color:"";n?e.chain().focus().setHighlight({color:n}).run():e.chain().focus().unsetHighlight().run()},canExecute:()=>!0,isActive:e=>e.isActive("highlight"),label:"Highlight"},link:{execute:({editor:e,config:t})=>{const n=t?.type==="link"?t.href:"";if(n){const r=t?.type==="link"?t.target:void 0,s=t?.type==="link"?t.rel:void 0;e.chain().focus().setLink({href:n,target:r,rel:s}).run()}else e.chain().focus().unsetLink().run()},canExecute:()=>!0,isActive:e=>e.isActive("link"),shortcut:"Mod-k",label:"Link"},paragraph:{execute:({editor:e})=>e.chain().focus().setParagraph().run(),canExecute:e=>e.can().chain().focus().setParagraph().run(),isActive:e=>e.isActive("paragraph"),shortcut:"Mod-Alt-0",label:"Paragraph"},heading:{execute:({editor:e,config:t})=>{const n=t?.type==="heading"?t.level:1;e.chain().focus().toggleHeading({level:n}).run()},canExecute:(e,t)=>{const n=t?.type==="heading"?t.level:1;return e.can().chain().focus().toggleHeading({level:n}).run()},isActive:(e,t)=>t?.type==="heading"?e.isActive("heading",{level:t.level}):e.isActive("heading"),label:"Heading"},bulletList:{execute:({editor:e})=>e.chain().focus().toggleBulletList().run(),canExecute:e=>e.can().chain().focus().toggleBulletList().run(),isActive:e=>e.isActive("bulletList"),shortcut:"Mod-Shift-8",label:"Bullet list"},orderedList:{execute:({editor:e})=>e.chain().focus().toggleOrderedList().run(),canExecute:e=>e.can().chain().focus().toggleOrderedList().run(),isActive:e=>e.isActive("orderedList"),shortcut:"Mod-Shift-7",label:"Numbered list"},taskList:{execute:({editor:e})=>e.chain().focus().toggleTaskList().run(),canExecute:e=>e.can().chain().focus().toggleTaskList().run(),isActive:e=>e.isActive("taskList"),label:"Task list"},codeBlock:{execute:({editor:e})=>e.chain().focus().toggleCodeBlock().run(),canExecute:e=>e.can().chain().focus().toggleCodeBlock().run(),isActive:e=>e.isActive("codeBlock"),shortcut:"Mod-Alt-c",label:"Code block"},blockquote:{execute:({editor:e})=>e.chain().focus().toggleBlockquote().run(),canExecute:e=>e.can().chain().focus().toggleBlockquote().run(),isActive:e=>e.isActive("blockquote"),shortcut:"Mod-Shift-b",label:"Blockquote"},horizontalRule:{execute:({editor:e})=>e.chain().focus().setHorizontalRule().run(),canExecute:e=>e.can().chain().focus().setHorizontalRule().run(),isActive:()=>!1,label:"Horizontal rule"},hardBreak:{execute:({editor:e})=>e.chain().focus().setHardBreak().run(),canExecute:e=>e.can().chain().focus().setHardBreak().run(),isActive:()=>!1,shortcut:"Mod-Enter",label:"Line break"},textAlign:{execute:({editor:e,config:t})=>{const n=t?.type==="textAlign"?t.alignment:"left";e.chain().focus().setTextAlign(n).run()},canExecute:()=>!0,isActive:(e,t)=>t?.type==="textAlign"?e.isActive({textAlign:t.alignment}):!1,label:"Text alignment"},clearMarks:{execute:({editor:e})=>e.chain().focus().unsetAllMarks().run(),canExecute:e=>e.can().chain().focus().unsetAllMarks().run(),isActive:()=>!1,label:"Clear formatting"},clearNodes:{execute:({editor:e})=>e.chain().focus().clearNodes().run(),canExecute:e=>e.can().chain().focus().clearNodes().run(),isActive:()=>!1,label:"Clear nodes"},undo:{execute:({editor:e})=>e.chain().focus().undo().run(),canExecute:e=>e.can().chain().focus().undo().run(),isActive:()=>!1,shortcut:"Mod-z",label:"Undo"},redo:{execute:({editor:e})=>e.chain().focus().redo().run(),canExecute:e=>e.can().chain().focus().redo().run(),isActive:()=>!1,shortcut:"Mod-Shift-z",label:"Redo"}},Yo={1:"Heading 1",2:"Heading 2",3:"Heading 3",4:"Heading 4",5:"Heading 5",6:"Heading 6"};function Go({editor:e,levels:t=[1,2,3,4,5,6],isDisabled:n=!1}){const[,r]=y.useState(0);y.useEffect(()=>{const a=()=>r(o=>o+1);return e.on("selectionUpdate",a),e.on("transaction",a),()=>{e.off("selectionUpdate",a),e.off("transaction",a)}},[e]);const s=t.find(a=>e.isActive("heading",{level:a})),i=a=>{const o=Number(a),c=Je.heading;c&&c.execute({editor:e,config:{type:"heading",level:o}})};return l.jsxs(f.Dropdown,{placement:"top-start",offset:10,children:[l.jsx(f.DropdownTrigger,{children:l.jsx(K,{size:"sm",radius:"sm",variant:s?"solid":"bordered",color:s?"primary":"default",isDisabled:n,startContent:l.jsx(J.Heading,{size:16}),"aria-label":"Select heading level",children:s?`H${s}`:"H"})}),l.jsx(f.DropdownMenu,{"aria-label":"Heading levels",selectionMode:"single",selectedKeys:s?new Set([String(s)]):new Set,onAction:i,children:t.map(a=>l.jsx(f.DropdownItem,{startContent:e.isActive("heading",{level:a})?l.jsx(J.Check,{size:16}):l.jsx("div",{className:"w-4"}),children:Yo[a]},a))})]})}const Xn={bulletList:{label:"Bullet List",icon:J.List},orderedList:{label:"Numbered List",icon:J.ListOrdered},taskList:{label:"Task List",icon:J.ListTodo}};function Qo({editor:e,types:t=["bulletList","orderedList","taskList"],isDisabled:n=!1}){const[,r]=y.useState(0);y.useEffect(()=>{const o=()=>r(c=>c+1);return e.on("selectionUpdate",o),e.on("transaction",o),()=>{e.off("selectionUpdate",o),e.off("transaction",o)}},[e]);const s=t.find(o=>e.isActive(o)),i=s?Xn[s].icon:J.List,a=o=>{const d=Je[o];d&&d.execute({editor:e})};return l.jsxs(f.Dropdown,{placement:"top-start",offset:10,children:[l.jsx(f.DropdownTrigger,{children:l.jsx(K,{size:"sm",radius:"sm",variant:s?"solid":"bordered",color:s?"primary":"default",isDisabled:n,isIconOnly:!0,"aria-label":"Select list type",children:l.jsx(i,{size:16})})}),l.jsx(f.DropdownMenu,{"aria-label":"List types",selectionMode:"single",selectedKeys:s?new Set([s]):new Set,onAction:a,children:t.map(o=>{const c=Xn[o].icon;return l.jsx(f.DropdownItem,{startContent:l.jsx(c,{size:16}),children:Xn[o].label},o)})})]})}function Zo({colors:e,selectedColor:t,onColorSelect:n,columns:r=4}){return l.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:`repeat(${r}, minmax(0, 1fr))`},children:e.map(s=>{const i=t===s;return l.jsx("button",{type:"button",onClick:()=>n(s),className:`
2
2
  w-8 h-8 rounded-full border-2 cursor-pointer
3
3
  transition-all duration-200
4
4
  hover:scale-110 hover:shadow-md
5
5
  focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2
6
6
  ${i?"border-primary ring-2 ring-primary ring-offset-2 scale-110":"border-divider"}
7
- `,style:{backgroundColor:s},"aria-label":`Select color ${s}`,title:s},s)})})}const Ia=["#000000","#374151","#6B7280","#EF4444","#F59E0B","#10B981","#3B82F6","#8B5CF6","#EC4899","#14B8A6","#F97316","#A855F7"],La=["#FEF3C7","#DBEAFE","#D1FAE5","#FCE7F3","#E0E7FF","#FED7AA","#F3E8FF","#CCFBF1","#FEE2E2","#E5E7EB","#FAE8FF","#BFDBFE"];function In(t){return/^#([0-9A-F]{3}){1,2}$/i.test(t)}const be={min:50,max:200,step:10,default:100},ts={lineHeight:24,toolbarHeight:60},Fa={bold:_.Bold,italic:_.Italic,strike:_.Strikethrough,underline:_.Underline,code:_.Code,textColor:_.Palette,highlight:_.Highlighter,link:_.Link2,paragraph:_.FileText,heading:_.Heading,bulletList:_.List,orderedList:_.ListOrdered,taskList:_.ListTodo,codeBlock:_.CodeSquare,blockquote:_.Quote,horizontalRule:_.Minus,clearMarks:_.Eraser,clearNodes:_.Eraser,undo:_.Undo2,redo:_.Redo2,hardBreak:_.CornerDownLeft,textAlign:_.AlignLeft},Pa={left:_.AlignLeft,center:_.AlignCenter,right:_.AlignRight,justify:_.AlignJustify};function yt(t){return Fa[t]}function Ra({value:t,onChange:e,onApply:n,placeholder:r="#000000"}){const[s,i]=x.useState(""),o=d=>{const u=d.target.value;e(u),s&&i("")},a=()=>{if(!t){i("Please enter a color");return}if(!In(t)){i("Invalid hex color (e.g., #FF0000)");return}i(""),n(t)},l=d=>{d.key==="Enter"&&(d.preventDefault(),a())};return c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex gap-2",children:[c.jsx(g.Input,{type:"text",value:t,onChange:o,onKeyDown:l,placeholder:r,size:"sm",variant:"bordered","aria-label":"Custom color hex code",isInvalid:!!s,errorMessage:s,startContent:c.jsx("div",{className:"w-4 h-4 rounded border border-divider",style:{backgroundColor:In(t)?t:"transparent"}})}),c.jsx(G,{size:"sm",color:"primary",variant:"flat",isIconOnly:!0,onPress:a,"aria-label":"Apply custom color",isDisabled:!t||!In(t),children:c.jsx(_.Check,{size:16})})]}),c.jsx("p",{className:"text-xs text-default-500",children:"Enter a hex color code (e.g., #FF0000)"})]})}function ns({editor:t,type:e,allowCustomColor:n=!0,label:r,isDisabled:s=!1}){const[i,o]=x.useState(!1),[a,l]=x.useState(""),d=e==="textColor"?Ia:La,u=v=>{const y=Ke[e];y&&y.execute({editor:t,config:{type:e,color:v}}),o(!1),l("")},f=v=>{u(v)},p=()=>{const v=Ke[e];v&&v.execute({editor:t,config:{type:e,color:""}}),o(!1)},h=e==="textColor"?t.isActive("textStyle"):t.isActive("highlight"),k=e==="textColor"?_.Palette:_.Highlighter;return c.jsxs(g.Popover,{isOpen:i,onOpenChange:o,placement:"top",offset:10,showArrow:!0,children:[c.jsx(g.PopoverTrigger,{children:c.jsx(G,{size:"sm",radius:"sm",variant:h?"solid":"bordered",color:h?"primary":"default",isIconOnly:!0,isDisabled:s,"aria-label":r,children:c.jsx(k,{size:16})})}),c.jsx(g.PopoverContent,{className:"w-64",children:c.jsxs("div",{className:"px-2 py-3 space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm font-semibold",children:r}),c.jsx(G,{size:"sm",variant:"light",isIconOnly:!0,onPress:p,"aria-label":"Clear color",children:c.jsx(_.X,{size:16})})]}),c.jsx(Da,{colors:d,onColorSelect:u}),n&&c.jsxs(c.Fragment,{children:[c.jsx(g.Divider,{}),c.jsxs("div",{children:[c.jsx("p",{className:"text-xs font-semibold mb-2 text-default-700",children:"Custom Color"}),c.jsx(Ra,{value:a,onChange:l,onApply:f})]})]})]})})]})}function $a({zoom:t,onZoomChange:e,min:n=be.min,max:r=be.max,step:s=be.step}){const i=()=>{const f=Math.max(n,t-s);e(f)},o=()=>{const f=Math.min(r,t+s);e(f)},a=()=>{e(be.default)},l=t<=n,d=t>=r,u=t===be.default;return c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(g.Tooltip,{content:"Zoom out",placement:"top",offset:10,children:c.jsx(G,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:l,onPress:i,"aria-label":"Zoom out",children:c.jsx(_.ZoomOut,{size:16})})}),c.jsx(g.Tooltip,{content:u?"Zoom percentage":"Click to reset zoom",placement:"top",offset:10,children:c.jsxs("button",{type:"button",onClick:a,disabled:u,className:`
7
+ `,style:{backgroundColor:s},"aria-label":`Select color ${s}`,title:s},s)})})}const Xo=["#000000","#374151","#6B7280","#EF4444","#F59E0B","#10B981","#3B82F6","#8B5CF6","#EC4899","#14B8A6","#F97316","#A855F7"],ec=["#FEF3C7","#DBEAFE","#D1FAE5","#FCE7F3","#E0E7FF","#FED7AA","#F3E8FF","#CCFBF1","#FEE2E2","#E5E7EB","#FAE8FF","#BFDBFE"];function er(e){return/^#([0-9A-F]{3}){1,2}$/i.test(e)}const ke={min:50,max:200,step:10,default:100},Ts={lineHeight:24,toolbarHeight:60},tc={bold:J.Bold,italic:J.Italic,strike:J.Strikethrough,underline:J.Underline,code:J.Code,textColor:J.Palette,highlight:J.Highlighter,link:J.Link2,paragraph:J.FileText,heading:J.Heading,bulletList:J.List,orderedList:J.ListOrdered,taskList:J.ListTodo,codeBlock:J.CodeSquare,blockquote:J.Quote,horizontalRule:J.Minus,clearMarks:J.Eraser,clearNodes:J.Eraser,undo:J.Undo2,redo:J.Redo2,hardBreak:J.CornerDownLeft,textAlign:J.AlignLeft},nc={left:J.AlignLeft,center:J.AlignCenter,right:J.AlignRight,justify:J.AlignJustify};function St(e){return tc[e]}function rc({value:e,onChange:t,onApply:n,placeholder:r="#000000"}){const[s,i]=y.useState(""),a=d=>{const u=d.target.value;t(u),s&&i("")},o=()=>{if(!e){i("Please enter a color");return}if(!er(e)){i("Invalid hex color (e.g., #FF0000)");return}i(""),n(e)},c=d=>{d.key==="Enter"&&(d.preventDefault(),o())};return l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsx(f.Input,{type:"text",value:e,onChange:a,onKeyDown:c,placeholder:r,size:"sm",variant:"bordered","aria-label":"Custom color hex code",isInvalid:!!s,errorMessage:s,startContent:l.jsx("div",{className:"w-4 h-4 rounded border border-divider",style:{backgroundColor:er(e)?e:"transparent"}})}),l.jsx(K,{size:"sm",color:"primary",variant:"flat",isIconOnly:!0,onPress:o,"aria-label":"Apply custom color",isDisabled:!e||!er(e),children:l.jsx(J.Check,{size:16})})]}),l.jsx("p",{className:"text-xs text-default-500",children:"Enter a hex color code (e.g., #FF0000)"})]})}function Ds({editor:e,type:t,allowCustomColor:n=!0,label:r,isDisabled:s=!1}){const[i,a]=y.useState(!1),[o,c]=y.useState(""),d=t==="textColor"?Xo:ec,u=b=>{const x=Je[t];x&&x.execute({editor:e,config:{type:t,color:b}}),a(!1),c("")},h=b=>{u(b)},p=()=>{const b=Je[t];b&&b.execute({editor:e,config:{type:t,color:""}}),a(!1)},m=t==="textColor"?e.isActive("textStyle"):e.isActive("highlight"),v=t==="textColor"?J.Palette:J.Highlighter;return l.jsxs(f.Popover,{isOpen:i,onOpenChange:a,placement:"top",offset:10,showArrow:!0,children:[l.jsx(f.PopoverTrigger,{children:l.jsx(K,{size:"sm",radius:"sm",variant:m?"solid":"bordered",color:m?"primary":"default",isIconOnly:!0,isDisabled:s,"aria-label":r,children:l.jsx(v,{size:16})})}),l.jsx(f.PopoverContent,{className:"w-64",children:l.jsxs("div",{className:"px-2 py-3 space-y-3",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm font-semibold",children:r}),l.jsx(K,{size:"sm",variant:"light",isIconOnly:!0,onPress:p,"aria-label":"Clear color",children:l.jsx(J.X,{size:16})})]}),l.jsx(Zo,{colors:d,onColorSelect:u}),n&&l.jsxs(l.Fragment,{children:[l.jsx(f.Divider,{}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs font-semibold mb-2 text-default-700",children:"Custom Color"}),l.jsx(rc,{value:o,onChange:c,onApply:h})]})]})]})})]})}function sc({zoom:e,onZoomChange:t,min:n=ke.min,max:r=ke.max,step:s=ke.step}){const i=()=>{const h=Math.max(n,e-s);t(h)},a=()=>{const h=Math.min(r,e+s);t(h)},o=()=>{t(ke.default)},c=e<=n,d=e>=r,u=e===ke.default;return l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(f.Tooltip,{content:"Zoom out",placement:"top",offset:10,children:l.jsx(K,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:c,onPress:i,"aria-label":"Zoom out",children:l.jsx(J.ZoomOut,{size:16})})}),l.jsx(f.Tooltip,{content:u?"Zoom percentage":"Click to reset zoom",placement:"top",offset:10,children:l.jsxs("button",{type:"button",onClick:o,disabled:u,className:`
8
8
  text-xs text-default-500 min-w-[3ch] text-center px-2
9
9
  ${u?"cursor-default":"cursor-pointer hover:text-primary"}
10
- `,"aria-label":`Zoom level ${t}%`,children:[t,"%"]})}),c.jsx(g.Tooltip,{content:"Zoom in",placement:"top",offset:10,children:c.jsx(G,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:d,onPress:o,"aria-label":"Zoom in",children:c.jsx(_.ZoomIn,{size:16})})})]})}function Va({editor:t,isDisabled:e=!1}){const[n,r]=x.useState(!1),[s,i]=x.useState(""),[o,a]=x.useState(""),[l,d]=x.useState(!1),u=t.isActive("link"),f=h=>{if(h){const{from:k,to:v}=t.state.selection,y=t.isActive("link");let S="";if(y){const j=t.schema.marks.link,w=t.state.doc.resolve(k),A=$.getMarkRange(w,j);A&&(S=t.state.doc.textBetween(A.from,A.to,""))}else S=t.state.doc.textBetween(k,v,"");const N=t.getAttributes("link").href||"";i(S),a(N),d(y)}r(h)},p=()=>{if(o.trim()){const{from:h,to:k}=t.state.selection,v=t.schema.marks.link,y=t.state.doc.resolve(h),S=$.getMarkRange(y,v),N=S?.from??h,j=S?.to??k,w=t.state.doc.textBetween(N,j,"");s.trim()&&s!==w?t.chain().focus().setTextSelection({from:N,to:j}).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(G,{size:"sm",radius:"sm",variant:u?"solid":"bordered",color:u?"primary":"default",isIconOnly:!0,isDisabled:e,"aria-label":"Link",children:c.jsx(_.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=>a(h.target.value),onKeyDown:h=>h.key==="Enter"&&p(),classNames:{inputWrapper:"focus-within:border-default-400"}}),c.jsx(G,{size:"sm",color:"primary",onPress:p,isDisabled:!o.trim(),children:l?"Update":"Apply"})]})})]})}function Ba({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 ci(t,e){const n=x.useMemo(()=>{if(!t)return{};const i={};return Array.from(new Set(e.map(a=>Rt(a)))).forEach(a=>{const l=Ke[a];if(l)try{const d=l.canExecute?.(t)??!0,u=l.isActive?.(t)??!1;i[a]={isActive:u,isDisabled:!d,canExecute:d}}catch(d){console.warn(`Extension not available for modifier: ${a}`,d),i[a]={isActive:!1,isDisabled:!0,canExecute:!1}}}),i},[t,e]),[r,s]=x.useState(n);return x.useEffect(()=>{if(!t)return;const i=()=>{const o={};Array.from(new Set(e.map(l=>Rt(l)))).forEach(l=>{const d=Ke[l];if(d)try{const u=d.canExecute?.(t)??!0,f=d.isActive?.(t)??!1;o[l]={isActive:f,isDisabled:!u,canExecute:u}}catch(u){console.warn(`Extension not available for modifier: ${l}`,u),o[l]={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 di(t,e){const n=x.useCallback((o,a)=>{if(!t)return;const l=Ke[o];if(l)try{l.execute({editor:t,config:a}),e?.({type:"toggle",modifier:o})}catch(d){console.warn(`Failed to execute command for modifier: ${o}`,d)}},[t,e]),r=x.useCallback(o=>{n(o)},[n]),s=x.useCallback((o,a)=>{if(!t)return!1;const l=Ke[o];try{return l?.canExecute?.(t,a)??!1}catch(d){return console.warn(`Failed to check canExecute for modifier: ${o}`,d),!1}},[t]),i=x.useCallback((o,a)=>{if(!t)return!1;const l=Ke[o];try{return l?.isActive?.(t,a)??!1}catch(d){return console.warn(`Failed to check isActive for modifier: ${o}`,d),!1}},[t]);return{executeCommand:n,toggleModifier:r,canExecute:s,isActive:i}}function za(t=be.default){const[e,n]=x.useState(t),r=x.useCallback((a=be.step)=>{n(l=>Math.min(be.max,l+a))},[]),s=x.useCallback((a=be.step)=>{n(l=>Math.max(be.min,l-a))},[]),i=x.useCallback(()=>{n(be.default)},[]),o=x.useCallback(a=>{const l=Math.max(be.min,Math.min(be.max,a));n(l)},[]);return{zoom:e,setZoom:o,zoomIn:r,zoomOut:s,resetZoom:i,isMinZoom:e<=be.min,isMaxZoom:e>=be.max,isDefaultZoom:e===be.default}}const _a=["bold","italic","strike","underline","code"];function Ha({editor:t,modifiers:e,onToolbarAction:n}){const r=ci(t,e),{toggleModifier:s}=di(t,n);if(!t)return null;const i=e.map(o=>Rt(o)).filter(o=>_a.includes(o));return i.length===0?null:c.jsx(Ba,{id:"text-formatting",label:"Text formatting",children:i.map(o=>{const a=r[o],l=yt(o);return c.jsx(st,{icon:l,label:o.charAt(0).toUpperCase()+o.slice(1),isActive:a?.isActive,isDisabled:a?.isDisabled,onClick:()=>s(o)},o)})})}function Ua({editor:t,modifiers:e,zoom:n=100,onZoomChange:r,sticky:s=!0,className:i,onToolbarAction:o}){const a=ci(t,e),{toggleModifier:l,executeCommand:d}=di(t,o);if(!t)return null;const u=e.map(I=>Rt(I)),f=u.some(I=>["bold","italic","strike","underline","code"].includes(I)),p=u.some(I=>["textColor","highlight"].includes(I)),h=u.includes("heading"),k=u.includes("textAlign"),v=u.some(I=>["bulletList","orderedList","taskList"].includes(I)),y=u.includes("blockquote"),S=u.includes("codeBlock"),N=u.includes("link"),j=u.includes("horizontalRule"),w=u.some(I=>["undo","redo"].includes(I)),A=n!==void 0&&r!==void 0,T=s?"sticky top-0 z-10":"";return c.jsx("div",{className:`w-full p-2 bg-background border-b border-divider ${T} ${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(Ha,{editor:t,modifiers:e,onToolbarAction:o}),(p||h||k||v||y||S||N||j||w||A)&&c.jsx(rt,{})]}),p&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-1",children:[u.includes("textColor")&&c.jsx(ns,{editor:t,type:"textColor",label:"Text color",isDisabled:a.textColor?.isDisabled}),u.includes("highlight")&&c.jsx(ns,{editor:t,type:"highlight",label:"Highlight",isDisabled:a.highlight?.isDisabled})]}),(h||k||v||y||S||N||j||w||A)&&c.jsx(rt,{})]}),h&&c.jsxs(c.Fragment,{children:[c.jsx(Ma,{editor:t}),(k||v||y||S||N||j||w||A)&&c.jsx(rt,{})]}),k&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"flex items-center gap-1",children:["left","center","right","justify"].map(I=>{const z=Pa[I],B=t.isActive({textAlign:I});return c.jsx(st,{icon:z,label:`Align ${I}`,isActive:B,onClick:()=>d("textAlign",{type:"textAlign",alignment:I})},I)})}),(v||y||S||N||j||w||A)&&c.jsx(rt,{})]}),v&&c.jsxs(c.Fragment,{children:[c.jsx(Oa,{editor:t,types:u.filter(I=>["bulletList","orderedList","taskList"].includes(I))}),(y||S||N||j||w||A)&&c.jsx(rt,{})]}),(y||S||N||j)&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-1",children:[y&&c.jsx(st,{icon:yt("blockquote"),label:"Blockquote",isActive:a.blockquote?.isActive,isDisabled:a.blockquote?.isDisabled,onClick:()=>l("blockquote")}),S&&c.jsx(st,{icon:yt("codeBlock"),label:"Code block",isActive:a.codeBlock?.isActive,isDisabled:a.codeBlock?.isDisabled,onClick:()=>l("codeBlock")}),N&&c.jsx(Va,{editor:t,isDisabled:a.link?.isDisabled}),j&&c.jsx(st,{icon:yt("horizontalRule"),label:"Horizontal rule",onClick:()=>l("horizontalRule")})]}),(w||A)&&c.jsx(rt,{})]}),w&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-1",children:[u.includes("undo")&&c.jsx(st,{icon:yt("undo"),label:"Undo",isDisabled:a.undo?.isDisabled,onClick:()=>l("undo")}),u.includes("redo")&&c.jsx(st,{icon:yt("redo"),label:"Redo",isDisabled:a.redo?.isDisabled,onClick:()=>l("redo")})]}),A&&c.jsx(rt,{})]}),A&&c.jsx($a,{zoom:n,onZoomChange:I=>{r?.(I),o?.({type:"zoom",modifier:`${I}%`})}})]})})}const qa=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Ka=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Wa=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Ja=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Ga=$.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",$.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[$.markInputRule({find:qa,type:this.type}),$.markInputRule({find:Wa,type:this.type})]},addPasteRules(){return[$.markPasteRule({find:Ka,type:this.type}),$.markPasteRule({find:Ja,type:this.type})]}}),Za=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Ya=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Qa=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Xa=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,el=$.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",$.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[$.markInputRule({find:Za,type:this.type}),$.markInputRule({find:Qa,type:this.type})]},addPasteRules(){return[$.markPasteRule({find:Ya,type:this.type}),$.markPasteRule({find:Xa,type:this.type})]}}),tl=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,nl=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,rl=$.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",$.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[$.markInputRule({find:tl,type:this.type})]},addPasteRules(){return[$.markPasteRule({find:nl,type:this.type})]}}),sl=/(^|[^`])`([^`]+)`(?!`)/,il=/(^|[^`])`([^`]+)`(?!`)/g,ol=$.Mark.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",$.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[$.markInputRule({find:sl,type:this.type})]},addPasteRules(){return[$.markPasteRule({find:il,type:this.type})]}}),al=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}`)})},ll=$.Mark.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&al(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",$.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}}}}),cl=$.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]}`,$.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=>$.textblockTypeInputRule({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),dl=$.Node.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",$.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),ul="listItem",rs="textStyle",ss=/^\s*([-+*])\s$/,fl=$.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",$.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(ul,this.editor.getAttributes(rs)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=$.wrappingInputRule({find:ss,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=$.wrappingInputRule({find:ss,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(rs),editor:this.editor})),[t]}}),hl="listItem",is="textStyle",os=/^(\d+)\.\s$/,pl=$.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",$.mergeAttributes(this.options.HTMLAttributes,n),0]:["ol",$.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(hl,this.editor.getAttributes(is)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=$.wrappingInputRule({find:os,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=$.wrappingInputRule({find:os,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(is)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),ml=$.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",$.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 ui(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=ui(s.content,i.content,n+1);if(o!=null)return o}n+=s.nodeSize}}function fi(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),a=e.child(--i),l=o.nodeSize;if(o==a){n-=l,r-=l;continue}if(!o.sameMarkup(a))return{a:n,b:r};if(o.isText&&o.text!=a.text){let d=0,u=Math.min(o.text.length,a.text.length);for(;d<u&&o.text[o.text.length-d-1]==a.text[a.text.length-d-1];)d++,n--,r--;return{a:n,b:r}}if(o.content.size||a.content.size){let d=fi(o.content,a.content,n-1,r-1);if(d)return d}n-=l,r-=l}}class K{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,a=0;a<n;o++){let l=this.content[o],d=a+l.nodeSize;if(d>e&&r(l,s+a,i||null,o)!==!1&&l.content.size){let u=a+1;l.nodesBetween(Math.max(0,e-u),Math.min(l.content.size,n-u),r,s+u)}a=d}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let i="",o=!0;return this.nodesBetween(e,n,(a,l)=>{let d=a.isText?a.text.slice(Math.max(e,l)-l,n-l):a.isLeaf?s?typeof s=="function"?s(a):s:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&d||a.isTextblock)&&r&&(o?o=!1:i+=r),i+=d},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new K(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 a=this.content[i],l=o+a.nodeSize;l>e&&((o<e||l>n)&&(a.isText?a=a.cut(Math.max(0,e-o),Math.min(a.text.length,n-o)):a=a.cut(Math.max(0,e-o-1),Math.min(a.content.size,n-o-1))),r.push(a),s+=a.nodeSize),o=l}return new K(r,s)}cutByIndex(e,n){return e==n?K.empty:e==0&&n==this.content.length?this:new K(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 K(s,i)}addToStart(e){return new K([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new K(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 ui(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return fi(this,e,n,r)}findIndex(e){if(e==0)return Wt(0,e);if(e==this.size)return Wt(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?Wt(n+1,i):Wt(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 K.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new K(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return K.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 K(n||e,r)}static from(e){if(!e)return K.empty;if(e instanceof K)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new K([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}K.empty=new K([],0);const Ln={index:0,offset:0};function Wt(t,e){return Ln.index=t,Ln.offset=e,Ln}function Xn(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(!Xn(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Xn(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}class Ie{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&&Xn(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 Ie.none;if(e instanceof Ie)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}}Ie.none=[];class gl extends Error{}class W{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=pi(this.content,e+this.openStart,n);return r&&new W(r,this.openStart,this.openEnd)}removeBetween(e,n){return new W(hi(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 W.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 W(K.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 W(e,r,s)}}W.empty=new W(K.empty,0,0);function hi(t,e,n){let{index:r,offset:s}=t.findIndex(e),i=t.maybeChild(r),{index:o,offset:a}=t.findIndex(n);if(s==e||i.isText){if(a!=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(hi(i.content,e-s-1,n-s-1)))}function pi(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 a=pi(o.content,e-i-1,n,o);return a&&t.replaceChild(s,o.copy(a))}function xl(t){return t.tag!=null}function yl(t){return t.style!=null}class rn{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(xl(s))this.tags.push(s);else if(yl(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 ls(this,n,!1);return r.addAll(e,Ie.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new ls(this,n,!0);return r.addAll(e,Ie.none,n.from,n.to),W.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(kl(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],a=o.style;if(!(a.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=n))){if(o.getAttrs){let l=o.getAttrs(n);if(l===!1)continue;o.attrs=l||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 a=n[o];if((a.priority==null?50:a.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=cs(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=cs(o)),o.node||o.ignore||o.mark||(o.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new rn(e,rn.schemaRules(e)))}}const mi={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},bl={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},gi={ol:!0,ul:!0},$t=1,er=2,Ot=4;function as(t,e,n){return e!=null?(e?$t:0)|(e==="full"?er:0):t&&t.whitespace=="pre"?$t|er:n&~Ot}class Jt{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=Ie.none,this.match=i||(o&Ot?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(K.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&$t)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let n=K.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(K.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&&!mi.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class ls{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=as(null,n.preserveWhitespace,0)|(r?Ot:0);s?i=new Jt(s.type,s.attrs,Ie.none,!0,n.topMatch||s.type.contentMatch,o):r?i=new Jt(null,null,Ie.none,!0,null,o):i=new Jt(e.schema.topNodeType,null,Ie.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&er?"full":this.localPreserveWS||(s.options&$t)>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(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let a=r.split(/\r?\n|\r/);for(let l=0;l<a.length;l++)l&&this.insertNode(o.linebreakReplacement.create(),n,!0),a[l]&&this.insertNode(o.text(a[l]),n,!/\S/.test(a[l]));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 a=s.content[s.content.length-1],l=e.previousSibling;(!a||l&&l.nodeName=="BR"||a.isText&&/[ \t\r\n\u000c]$/.test(a.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let s=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),a;gi.hasOwnProperty(o)&&this.parser.normalizeLists&&vl(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,r));e:if(l?l.ignore:bl.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,n);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let d,u=this.needsBlock;if(mi.hasOwnProperty(o))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),d=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let f=l&&l.skip?n:this.readStyles(e,n);f&&this.addAll(e,f),d&&this.sync(i),this.needsBlock=u}else{let d=this.readStyles(e,n);d&&this.addElementByRule(e,l,d,l.consuming===!1?a:void 0)}this.localPreserveWS=s}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
12
- `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],o=r.getPropertyValue(i);if(o)for(let a=void 0;;){let l=this.parser.matchStyle(i,o,this,a);if(!l)break;if(l.ignore)return null;if(l.clearMark?n=n.filter(d=>!l.clearMark(d)):n=n.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)a=l;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 l=this.enter(o,n.attrs||null,r,n.preserveWhitespace);l&&(i=!0,r=l)}else{let l=this.parser.schema.marks[n.mark];r=r.concat(l.create(n.attrs))}let a=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(l=>this.insertNode(l,r,!1));else{let l=e;typeof n.contentElement=="string"?l=e.querySelector(n.contentElement):typeof n.contentElement=="function"?l=n.contentElement(e):n.contentElement&&(l=n.contentElement),this.findAround(e,l,!0),this.addAll(l,r),this.findAround(e,l,!1)}i&&this.sync(a)&&this.open--}addAll(e,n,r,s){let i=r||0;for(let o=r?e.childNodes[r]:e.firstChild,a=s==null?null:e.childNodes[s];o!=a;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,a=0;o>=0;o--){let l=this.nodes[o],d=l.findWrapping(e);if(d&&(!s||s.length>d.length+a)&&(s=d,i=l,!d.length))break;if(l.solid){if(r)break;a+=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=Ie.none;for(let a of s.concat(e.marks))(i.type?i.type.allowsMarkType(a.type):ds(a.type,e.type))&&(o=a.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 a=as(e,i,o.options);o.options&Ot&&o.content.length==0&&(a|=Ot);let l=Ie.none;return r=r.filter(d=>(o.type?o.type.allowsMarkType(d.type):ds(d.type,e))?(l=d.addToSet(l),!1):!0),this.nodes.push(new Jt(e,n,l,s,null,a)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=$t)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&n.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(s?0:1),o=(a,l)=>{for(;a>=0;a--){let d=n[a];if(d==""){if(a==n.length-1||a==0)continue;for(;l>=i;l--)if(o(a-1,l))return!0;return!1}else{let u=l>0||l==0&&s?this.nodes[l].type:r&&l>=i?r.node(l-i).type:null;if(!u||u.name!=d&&!u.isInGroup(d))return!1;l--}}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 vl(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&gi.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function kl(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function cs(t){let e={};for(let n in t)e[n]=t[n];return e}function ds(t,e){let n=e.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(t))continue;let i=[],o=a=>{i.push(a);for(let l=0;l<a.edgeCount;l++){let{type:d,next:u}=a.edge(l);if(d==e||i.indexOf(u)<0&&o(u))return!0}};if(o(s.contentMatch))return!0}}class yn{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Fn(n).createDocumentFragment());let s=r,i=[];return e.forEach(o=>{if(i.length||o.marks.length){let a=0,l=0;for(;a<i.length&&l<o.marks.length;){let d=o.marks[l];if(!this.marks[d.type.name]){l++;continue}if(!d.eq(i[a][0])||d.type.spec.spanning===!1)break;a++,l++}for(;a<i.length;)s=i.pop()[1];for(;l<o.marks.length;){let d=o.marks[l++],u=this.serializeMark(d,o.isInline,n);u&&(i.push([d,s]),s.appendChild(u.dom),s=u.contentDOM||u.dom)}}s.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:s}=Qt(Fn(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&&Qt(Fn(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return Qt(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new yn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=us(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return us(e.marks)}}function us(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Fn(t){return t.document||window.document}const fs=new WeakMap;function Sl(t){let e=fs.get(t);return e===void 0&&fs.set(t,e=Cl(t)),e}function Cl(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 Qt(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=Sl(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 a,l=n?t.createElementNS(n,s):t.createElement(s),d=e[1],u=1;if(d&&typeof d=="object"&&d.nodeType==null&&!Array.isArray(d)){u=2;for(let f in d)if(d[f]!=null){let p=f.indexOf(" ");p>0?l.setAttributeNS(f.slice(0,p),f.slice(p+1),d[f]):f=="style"&&l.style?l.style.cssText=d[f]:l.setAttribute(f,d[f])}}for(let f=u;f<e.length;f++){let p=e[f];if(p===0){if(f<e.length-1||f>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:h,contentDOM:k}=Qt(t,p,n,r);if(l.appendChild(h),k){if(a)throw new RangeError("Multiple content holes");a=k}}}return{dom:l,contentDOM:a}}const xi=65535,yi=Math.pow(2,16);function wl(t,e){return t+e*yi}function hs(t){return t&xi}function Nl(t){return(t-(t&xi))/yi}const bi=1,vi=2,Xt=4,ki=8;class tr{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&ki)>0}get deletedBefore(){return(this.delInfo&(bi|Xt))>0}get deletedAfter(){return(this.delInfo&(vi|Xt))>0}get deletedAcross(){return(this.delInfo&Xt)>0}}class Ee{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Ee.empty)return Ee.empty}recover(e){let n=0,r=hs(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+Nl(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 a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?s:0);if(l>e)break;let d=this.ranges[a+i],u=this.ranges[a+o],f=l+d;if(e<=f){let p=d?e==l?-1:e==f?1:n:n,h=l+s+(p<0?0:u);if(r)return h;let k=e==(n<0?l:f)?null:wl(a/3,e-l),v=e==l?vi:e==f?bi:Xt;return(n<0?e!=l:e!=f)&&(v|=ki),new tr(h,v,k)}s+=u-d}return r?e+s:new tr(e+s,0,null)}touches(e,n){let r=0,s=hs(n),i=this.inverted?2:1,o=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?r:0);if(l>e)break;let d=this.ranges[a+i],u=l+d;if(e<=u&&a==s*3)return!0;r+=this.ranges[a+o]-d}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let o=this.ranges[s],a=o-(this.inverted?i:0),l=o+(this.inverted?0:i),d=this.ranges[s+n],u=this.ranges[s+r];e(a,a+d,l,l+u),i+=u-d}}invert(){return new Ee(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Ee.empty:new Ee(e<0?[0,-e,0]:[0,0,e])}}Ee.empty=new Ee([]);class sn{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 sn(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 sn;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],a=o.mapResult(e,n);if(a.recover!=null){let l=this.getMirror(i);if(l!=null&&l>i&&l<this.to){i=l,e=this._maps[l].recover(a.recover);continue}}s|=a.delInfo,e=a.pos}return r?e:new tr(e,s,null)}}const Pn=Object.create(null);class ve{getMap(){return Ee.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Pn[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 Pn)throw new RangeError("Duplicate use of step JSON ID "+e);return Pn[e]=n,n.prototype.jsonID=e,n}}class he{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new he(e,null)}static fail(e){return new he(null,e)}static fromReplace(e,n,r,s){try{return he.ok(e.replace(n,r,s))}catch(i){if(i instanceof gl)return he.fail(i.message);throw i}}}function kr(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(kr(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return K.fromArray(r)}class ot extends ve{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 W(kr(n.content,(o,a)=>!o.isAtom||!a.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),n.openStart,n.openEnd);return he.fromReplace(e,this.from,this.to,i)}invert(){return new at(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))}}ve.jsonID("addMark",ot);class at extends ve{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 W(kr(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return he.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 at(n.pos,r.pos,this.mark)}merge(e){return e instanceof at&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new at(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 at(n.from,n.to,e.markFromJSON(n.mark))}}ve.jsonID("removeMark",at);class lt extends ve{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return he.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return he.fromReplace(e,this.pos,this.pos+1,new W(K.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 lt(this.pos,n.marks[s]);return new lt(this.pos,this.mark)}}return new Vt(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new lt(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 lt(n.pos,e.markFromJSON(n.mark))}}ve.jsonID("addNodeMark",lt);class Vt extends ve{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return he.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return he.fromReplace(e,this.pos,this.pos+1,new W(K.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new lt(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Vt(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Vt(n.pos,e.markFromJSON(n.mark))}}ve.jsonID("removeNodeMark",Vt);class qe extends ve{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&nr(e,this.from,this.to)?he.fail("Structure replace would overwrite content"):he.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ee([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?W.empty:new W(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?W.empty:new W(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,W.fromJSON(e,n.slice),!!n.structure)}}ve.jsonID("replace",qe);class St extends ve{constructor(e,n,r,s,i,o,a=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=a}apply(e){if(this.structure&&(nr(e,this.from,this.gapFrom)||nr(e,this.gapTo,this.to)))return he.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return he.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?he.fromReplace(e,this.from,this.to,r):he.fail("Content does not fit in gap")}getMap(){return new Ee([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 St(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 St(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 St(n.from,n.to,n.gapFrom,n.gapTo,W.fromJSON(e,n.slice),n.insert,!!n.structure)}}ve.jsonID("replaceAround",St);function nr(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 Si(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 a=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,l=r.index(o)+(a>0?1:0),d=r.node(o),u=!1;if(i==1)u=d.canReplace(l,l,s);else{let f=d.contentMatchAt(l).findWrapping(s.firstChild.type);u=f&&d.canReplaceWith(l,l,f[0])}if(u)return a==0?r.pos:a<0?r.before(o+1):r.after(o+1)}return null}class Dt extends ve{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 he.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 he.fromReplace(e,this.pos,this.pos+1,new W(K.from(s),0,n.isLeaf?0:1))}getMap(){return Ee.empty}invert(e){return new Dt(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 Dt(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 Dt(n.pos,n.attr,n.value)}}ve.jsonID("attr",Dt);class on extends ve{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 he.ok(r)}getMap(){return Ee.empty}invert(e){return new on(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 on(n.attr,n.value)}}ve.jsonID("docAttr",on);let Bt=class extends Error{};Bt=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Bt.prototype=Object.create(Error.prototype);Bt.prototype.constructor=Bt;Bt.prototype.name="TransformError";const Rn=Object.create(null);class ee{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Al(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=W.empty){let r=n.content.lastChild,s=null;for(let a=0;a<n.openEnd;a++)s=r,r=r.lastChild;let i=e.steps.length,o=this.ranges;for(let a=0;a<o.length;a++){let{$from:l,$to:d}=o[a],u=e.mapping.slice(i);e.replaceRange(u.map(l.pos),u.map(d.pos),a?W.empty:n),a==0&&gs(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:a}=s[i],l=e.mapping.slice(r),d=l.map(o.pos),u=l.map(a.pos);i?e.deleteRange(d,u):(e.replaceRangeWith(d,u,n),gs(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new X(e):bt(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?bt(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):bt(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 bt(e,e,0,0,1)||new _e(e)}static atEnd(e){return bt(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 X.between(this.$anchor,this.$head).getBookmark()}}ee.prototype.visible=!0;class Al{constructor(e,n){this.$from=e,this.$to=n}}let ps=!1;function ms(t){!ps&&!t.parent.inlineContent&&(ps=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class X extends ee{constructor(e,n=e){ms(e),ms(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 ee.near(r);let s=e.resolve(n.map(this.anchor));return new X(s.parent.inlineContent?s:r,r)}replace(e,n=W.empty){if(super.replace(e,n),n==W.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof X&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new bn(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 X(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=ee.findFrom(n,r,!0)||ee.findFrom(n,-r,!0);if(i)n=i.$head;else return ee.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(ee.findFrom(e,-r,!0)||ee.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new X(e,n)}}ee.jsonID("text",X);class bn{constructor(e,n){this.anchor=e,this.head=n}map(e){return new bn(e.map(this.anchor),e.map(this.head))}resolve(e){return X.between(e.resolve(this.anchor),e.resolve(this.head))}}class J extends ee{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?ee.near(i):new J(i)}content(){return new W(K.from(this.node),0,0)}eq(e){return e instanceof J&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Sr(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new J(e.resolve(n.anchor))}static create(e,n){return new J(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}J.prototype.visible=!1;ee.jsonID("node",J);class Sr{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new bn(r,r):new Sr(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&J.isSelectable(r)?new J(n):ee.near(n)}}class _e extends ee{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=W.empty){if(n==W.empty){e.delete(0,e.doc.content.size);let r=ee.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 jl}}ee.jsonID("all",_e);const jl={map(){return this},resolve(t){return new _e(t)}};function bt(t,e,n,r,s,i=!1){if(e.inlineContent)return X.create(t,n);for(let o=r-(s>0?0:1);s>0?o<e.childCount:o>=0;o+=s){let a=e.child(o);if(a.isAtom){if(!i&&J.isSelectable(a))return J.create(t,n-(s<0?a.nodeSize:0))}else{let l=bt(t,a,n+s,s<0?a.childCount:0,s,i);if(l)return l}n+=a.nodeSize*s}return null}function gs(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof qe||s instanceof St))return;let i=t.mapping.maps[r],o;i.forEach((a,l,d,u)=>{o==null&&(o=u)}),t.setSelection(ee.near(t.doc.resolve(o),n))}function xs(t,e){return!e||!t?t:t.bind(e)}class Gt{constructor(e,n,r){this.name=e,this.init=xs(n.init,r),this.apply=xs(n.apply,r)}}new Gt("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Gt("selection",{init(t,e){return t.selection||ee.atStart(e.doc)},apply(t){return t.selection}}),new Gt("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Gt("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}});function Ci(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=Ci(s,e,{})),n[r]=s}return n}class vn{constructor(e){this.spec=e,this.props={},e.props&&Ci(e.props,this,this.props),this.key=e.key?e.key.key:wi("plugin")}getState(e){return e[this.key]}}const $n=Object.create(null);function wi(t){return t in $n?t+"$"+ ++$n[t]:($n[t]=0,t+"$")}class Cr{constructor(e="key"){this.key=wi(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const El=/^```([a-z]+)?[\s\n]$/,Tl=/^~~~([a-z]+)?[\s\n]$/,Ml=$.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",$.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(`
10
+ `,"aria-label":`Zoom level ${e}%`,children:[e,"%"]})}),l.jsx(f.Tooltip,{content:"Zoom in",placement:"top",offset:10,children:l.jsx(K,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:d,onPress:a,"aria-label":"Zoom in",children:l.jsx(J.ZoomIn,{size:16})})})]})}function ic({editor:e,isDisabled:t=!1}){const[n,r]=y.useState(!1),[s,i]=y.useState(""),[a,o]=y.useState(""),[c,d]=y.useState(!1),u=e.isActive("link"),h=m=>{if(m){const{from:v,to:b}=e.state.selection,x=e.isActive("link");let w="";if(x){const M=e.schema.marks.link,N=e.state.doc.resolve(v),j=V.getMarkRange(N,M);j&&(w=e.state.doc.textBetween(j.from,j.to,""))}else w=e.state.doc.textBetween(v,b,"");const S=e.getAttributes("link").href||"";i(w),o(S),d(x)}r(m)},p=()=>{if(a.trim()){const{from:m,to:v}=e.state.selection,b=e.schema.marks.link,x=e.state.doc.resolve(m),w=V.getMarkRange(x,b),S=w?.from??m,M=w?.to??v,N=e.state.doc.textBetween(S,M,"");s.trim()&&s!==N?e.chain().focus().setTextSelection({from:S,to:M}).deleteSelection().insertContent(`<a href="${a.trim()}">${s.trim()}</a>`).run():e.chain().focus().extendMarkRange("link").updateAttributes("link",{href:a.trim()}).run()}r(!1)};return l.jsxs(f.Popover,{isOpen:n,onOpenChange:h,placement:"bottom",children:[l.jsx(f.PopoverTrigger,{children:l.jsx(K,{size:"sm",radius:"sm",variant:u?"solid":"bordered",color:u?"primary":"default",isIconOnly:!0,isDisabled:t,"aria-label":"Link",children:l.jsx(J.Link,{size:16})})}),l.jsx(f.PopoverContent,{children:l.jsxs("div",{className:"flex flex-col gap-3 p-3 w-72",children:[l.jsx(f.Input,{size:"sm",variant:"bordered",label:"Name",labelPlacement:"outside",placeholder:"Link text",value:s,onChange:m=>i(m.target.value),classNames:{inputWrapper:"focus-within:border-default-400"}}),l.jsx(f.Input,{size:"sm",variant:"bordered",label:"Link",labelPlacement:"outside",placeholder:"https://example.com",value:a,onChange:m=>o(m.target.value),onKeyDown:m=>m.key==="Enter"&&p(),classNames:{inputWrapper:"focus-within:border-default-400"}}),l.jsx(K,{size:"sm",color:"primary",onPress:p,isDisabled:!a.trim(),children:c?"Update":"Apply"})]})})]})}function ac({children:e,id:t,label:n,className:r,useButtonGroup:s=!0}){return s?l.jsx(f.ButtonGroup,{size:"sm",id:t,"aria-label":n,className:r,children:e}):l.jsx("div",{id:t,role:"group","aria-label":n,className:`flex items-center gap-2 ${r||""}`,children:e})}function Qi(e,t){const n=y.useMemo(()=>{if(!e)return{};const i={};return Array.from(new Set(t.map(o=>Yt(o)))).forEach(o=>{const c=Je[o];if(c)try{const d=c.canExecute?.(e)??!0,u=c.isActive?.(e)??!1;i[o]={isActive:u,isDisabled:!d,canExecute:d}}catch(d){console.warn(`Extension not available for modifier: ${o}`,d),i[o]={isActive:!1,isDisabled:!0,canExecute:!1}}}),i},[e,t]),[r,s]=y.useState(n);return y.useEffect(()=>{if(!e)return;const i=()=>{const a={};Array.from(new Set(t.map(c=>Yt(c)))).forEach(c=>{const d=Je[c];if(d)try{const u=d.canExecute?.(e)??!0,h=d.isActive?.(e)??!1;a[c]={isActive:h,isDisabled:!u,canExecute:u}}catch(u){console.warn(`Extension not available for modifier: ${c}`,u),a[c]={isActive:!1,isDisabled:!0,canExecute:!1}}}),s(a)};return e.on("selectionUpdate",i),e.on("transaction",i),()=>{e.off("selectionUpdate",i),e.off("transaction",i)}},[e,t,n]),r}function Zi(e,t){const n=y.useCallback((a,o)=>{if(!e)return;const c=Je[a];if(c)try{c.execute({editor:e,config:o}),t?.({type:"toggle",modifier:a})}catch(d){console.warn(`Failed to execute command for modifier: ${a}`,d)}},[e,t]),r=y.useCallback(a=>{n(a)},[n]),s=y.useCallback((a,o)=>{if(!e)return!1;const c=Je[a];try{return c?.canExecute?.(e,o)??!1}catch(d){return console.warn(`Failed to check canExecute for modifier: ${a}`,d),!1}},[e]),i=y.useCallback((a,o)=>{if(!e)return!1;const c=Je[a];try{return c?.isActive?.(e,o)??!1}catch(d){return console.warn(`Failed to check isActive for modifier: ${a}`,d),!1}},[e]);return{executeCommand:n,toggleModifier:r,canExecute:s,isActive:i}}function lc(e=ke.default){const[t,n]=y.useState(e),r=y.useCallback((o=ke.step)=>{n(c=>Math.min(ke.max,c+o))},[]),s=y.useCallback((o=ke.step)=>{n(c=>Math.max(ke.min,c-o))},[]),i=y.useCallback(()=>{n(ke.default)},[]),a=y.useCallback(o=>{const c=Math.max(ke.min,Math.min(ke.max,o));n(c)},[]);return{zoom:t,setZoom:a,zoomIn:r,zoomOut:s,resetZoom:i,isMinZoom:t<=ke.min,isMaxZoom:t>=ke.max,isDefaultZoom:t===ke.default}}const oc=["bold","italic","strike","underline","code"];function cc({editor:e,modifiers:t,onToolbarAction:n}){const r=Qi(e,t),{toggleModifier:s}=Zi(e,n);if(!e)return null;const i=t.map(a=>Yt(a)).filter(a=>oc.includes(a));return i.length===0?null:l.jsx(ac,{id:"text-formatting",label:"Text formatting",children:i.map(a=>{const o=r[a],c=St(a);return l.jsx(ct,{icon:c,label:a.charAt(0).toUpperCase()+a.slice(1),isActive:o?.isActive,isDisabled:o?.isDisabled,onClick:()=>s(a)},a)})})}function dc({editor:e,modifiers:t,zoom:n=100,onZoomChange:r,sticky:s=!0,className:i,onToolbarAction:a}){const o=Qi(e,t),{toggleModifier:c,executeCommand:d}=Zi(e,a);if(!e)return null;const u=t.map($=>Yt($)),h=u.some($=>["bold","italic","strike","underline","code"].includes($)),p=u.some($=>["textColor","highlight"].includes($)),m=u.includes("heading"),v=u.includes("textAlign"),b=u.some($=>["bulletList","orderedList","taskList"].includes($)),x=u.includes("blockquote"),w=u.includes("codeBlock"),S=u.includes("link"),M=u.includes("horizontalRule"),N=u.some($=>["undo","redo"].includes($)),j=n!==void 0&&r!==void 0,T=s?"sticky top-0 z-10":"";return l.jsx("div",{className:`w-full p-2 bg-background border-b border-divider ${T} ${i||""}`,children:l.jsxs("div",{className:"flex flex-row flex-wrap gap-2 w-full items-center",children:[h&&l.jsxs(l.Fragment,{children:[l.jsx(cc,{editor:e,modifiers:t,onToolbarAction:a}),(p||m||v||b||x||w||S||M||N||j)&&l.jsx(ot,{})]}),p&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex items-center gap-1",children:[u.includes("textColor")&&l.jsx(Ds,{editor:e,type:"textColor",label:"Text color",isDisabled:o.textColor?.isDisabled}),u.includes("highlight")&&l.jsx(Ds,{editor:e,type:"highlight",label:"Highlight",isDisabled:o.highlight?.isDisabled})]}),(m||v||b||x||w||S||M||N||j)&&l.jsx(ot,{})]}),m&&l.jsxs(l.Fragment,{children:[l.jsx(Go,{editor:e}),(v||b||x||w||S||M||N||j)&&l.jsx(ot,{})]}),v&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"flex items-center gap-1",children:["left","center","right","justify"].map($=>{const W=nc[$],D=e.isActive({textAlign:$});return l.jsx(ct,{icon:W,label:`Align ${$}`,isActive:D,onClick:()=>d("textAlign",{type:"textAlign",alignment:$})},$)})}),(b||x||w||S||M||N||j)&&l.jsx(ot,{})]}),b&&l.jsxs(l.Fragment,{children:[l.jsx(Qo,{editor:e,types:u.filter($=>["bulletList","orderedList","taskList"].includes($))}),(x||w||S||M||N||j)&&l.jsx(ot,{})]}),(x||w||S||M)&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex items-center gap-1",children:[x&&l.jsx(ct,{icon:St("blockquote"),label:"Blockquote",isActive:o.blockquote?.isActive,isDisabled:o.blockquote?.isDisabled,onClick:()=>c("blockquote")}),w&&l.jsx(ct,{icon:St("codeBlock"),label:"Code block",isActive:o.codeBlock?.isActive,isDisabled:o.codeBlock?.isDisabled,onClick:()=>c("codeBlock")}),S&&l.jsx(ic,{editor:e,isDisabled:o.link?.isDisabled}),M&&l.jsx(ct,{icon:St("horizontalRule"),label:"Horizontal rule",onClick:()=>c("horizontalRule")})]}),(N||j)&&l.jsx(ot,{})]}),N&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex items-center gap-1",children:[u.includes("undo")&&l.jsx(ct,{icon:St("undo"),label:"Undo",isDisabled:o.undo?.isDisabled,onClick:()=>c("undo")}),u.includes("redo")&&l.jsx(ct,{icon:St("redo"),label:"Redo",isDisabled:o.redo?.isDisabled,onClick:()=>c("redo")})]}),j&&l.jsx(ot,{})]}),j&&l.jsx(sc,{zoom:n,onZoomChange:$=>{r?.($),a?.({type:"zoom",modifier:`${$}%`})}})]})})}const uc=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,fc=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,hc=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,mc=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,pc=V.Mark.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:e=>e.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:e=>e.type.name===this.name},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return["strong",V.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[V.markInputRule({find:uc,type:this.type}),V.markInputRule({find:hc,type:this.type})]},addPasteRules(){return[V.markPasteRule({find:fc,type:this.type}),V.markPasteRule({find:mc,type:this.type})]}}),gc=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,xc=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,yc=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,bc=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,vc=V.Mark.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:e=>e.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:e=>e.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:e}){return["em",V.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[V.markInputRule({find:gc,type:this.type}),V.markInputRule({find:yc,type:this.type})]},addPasteRules(){return[V.markPasteRule({find:xc,type:this.type}),V.markPasteRule({find:bc,type:this.type})]}}),wc=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,kc=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Nc=V.Mark.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:e=>e.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["s",V.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[V.markInputRule({find:wc,type:this.type})]},addPasteRules(){return[V.markPasteRule({find:kc,type:this.type})]}}),Sc=/(^|[^`])`([^`]+)`(?!`)/,Cc=/(^|[^`])`([^`]+)`(?!`)/g,jc=V.Mark.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:e}){return["code",V.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[V.markInputRule({find:Sc,type:this.type})]},addPasteRules(){return[V.markPasteRule({find:Cc,type:this.type})]}}),Ac=e=>{if(!e.children.length)return;const t=e.querySelectorAll("span");t&&t.forEach(n=>{var r,s;const i=n.getAttribute("style"),a=(s=(r=n.parentElement)===null||r===void 0?void 0:r.closest("span"))===null||s===void 0?void 0:s.getAttribute("style");n.setAttribute("style",`${a};${i}`)})},Mc=V.Mark.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:e=>e.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&Ac(e),{}):!1}]},renderHTML({HTMLAttributes:e}){return["span",V.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{removeEmptyTextStyle:()=>({tr:e})=>{const{selection:t}=e;return e.doc.nodesBetween(t.from,t.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(s=>s.type===this.type).some(s=>Object.values(s.attrs).some(i=>!!i))||e.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),Ec=V.Node.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,V.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,"paragraph",e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>V.textblockTypeInputRule({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),Tc=V.Node.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",V.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Dc="listItem",Is="textStyle",$s=/^\s*([-+*])\s$/,Ic=V.Node.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:e}){return["ul",V.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Dc,this.editor.getAttributes(Is)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=V.wrappingInputRule({find:$s,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=V.wrappingInputRule({find:$s,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Is),editor:this.editor})),[e]}}),$c="listItem",Os="textStyle",Ls=/^(\d+)\.\s$/,Oc=V.Node.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:e=>e.hasAttribute("start")?parseInt(e.getAttribute("start")||"",10):1},type:{default:null,parseHTML:e=>e.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:e}){const{start:t,...n}=e;return t===1?["ol",V.mergeAttributes(this.options.HTMLAttributes,n),0]:["ol",V.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes($c,this.editor.getAttributes(Os)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=V.wrappingInputRule({find:Ls,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:(t,n)=>n.childCount+n.attrs.start===+t[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=V.wrappingInputRule({find:Ls,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(Os)}),joinPredicate:(t,n)=>n.childCount+n.attrs.start===+t[1],editor:this.editor})),[e]}}),Lc=V.Node.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:e}){return["li",V.mergeAttributes(this.options.HTMLAttributes,e),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}});function Xi(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let s=e.child(r),i=t.child(r);if(s==i){n+=s.nodeSize;continue}if(!s.sameMarkup(i))return n;if(s.isText&&s.text!=i.text){for(let a=0;s.text[a]==i.text[a];a++)n++;return n}if(s.content.size||i.content.size){let a=Xi(s.content,i.content,n+1);if(a!=null)return a}n+=s.nodeSize}}function ea(e,t,n,r){for(let s=e.childCount,i=t.childCount;;){if(s==0||i==0)return s==i?null:{a:n,b:r};let a=e.child(--s),o=t.child(--i),c=a.nodeSize;if(a==o){n-=c,r-=c;continue}if(!a.sameMarkup(o))return{a:n,b:r};if(a.isText&&a.text!=o.text){let d=0,u=Math.min(a.text.length,o.text.length);for(;d<u&&a.text[a.text.length-d-1]==o.text[o.text.length-d-1];)d++,n--,r--;return{a:n,b:r}}if(a.content.size||o.content.size){let d=ea(a.content,o.content,n-1,r-1);if(d)return d}n-=c,r-=c}}class Z{constructor(t,n){if(this.content=t,this.size=n||0,n==null)for(let r=0;r<t.length;r++)this.size+=t[r].nodeSize}nodesBetween(t,n,r,s=0,i){for(let a=0,o=0;o<n;a++){let c=this.content[a],d=o+c.nodeSize;if(d>t&&r(c,s+o,i||null,a)!==!1&&c.content.size){let u=o+1;c.nodesBetween(Math.max(0,t-u),Math.min(c.content.size,n-u),r,s+u)}o=d}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,n,r,s){let i="",a=!0;return this.nodesBetween(t,n,(o,c)=>{let d=o.isText?o.text.slice(Math.max(t,c)-c,n-c):o.isLeaf?s?typeof s=="function"?s(o):s:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&d||o.isTextblock)&&r&&(a?a=!1:i+=r),i+=d},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,s=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),i=1);i<t.content.length;i++)s.push(t.content[i]);return new Z(s,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],s=0;if(n>t)for(let i=0,a=0;a<n;i++){let o=this.content[i],c=a+o.nodeSize;c>t&&((a<t||c>n)&&(o.isText?o=o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o=o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),s+=o.nodeSize),a=c}return new Z(r,s)}cutByIndex(t,n){return t==n?Z.empty:t==0&&n==this.content.length?this:new Z(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let s=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return s[t]=n,new Z(s,i)}addToStart(t){return new Z([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new Z(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(t.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let n=this.content[t];if(!n)throw new RangeError("Index "+t+" out of range for "+this);return n}maybeChild(t){return this.content[t]||null}forEach(t){for(let n=0,r=0;n<this.content.length;n++){let s=this.content[n];t(s,r,n),r+=s.nodeSize}}findDiffStart(t,n=0){return Xi(this,t,n)}findDiffEnd(t,n=this.size,r=t.size){return ea(this,t,n,r)}findIndex(t){if(t==0)return dn(0,t);if(t==this.size)return dn(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let n=0,r=0;;n++){let s=this.child(n),i=r+s.nodeSize;if(i>=t)return i==t?dn(n+1,i):dn(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(t=>t.toJSON()):null}static fromJSON(t,n){if(!n)return Z.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new Z(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return Z.empty;let n,r=0;for(let s=0;s<t.length;s++){let i=t[s];r+=i.nodeSize,s&&i.isText&&t[s-1].sameMarkup(i)?(n||(n=t.slice(0,s)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new Z(n||t,r)}static from(t){if(!t)return Z.empty;if(t instanceof Z)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new Z([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}Z.empty=new Z([],0);const tr={index:0,offset:0};function dn(e,t){return tr.index=e,tr.offset=t,tr}function jr(e,t){if(e===t)return!0;if(!(e&&typeof e=="object")||!(t&&typeof t=="object"))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!jr(e[r],t[r]))return!1}else{for(let r in e)if(!(r in t)||!jr(e[r],t[r]))return!1;for(let r in t)if(!(r in e))return!1}return!0}class Fe{constructor(t,n){this.type=t,this.attrs=n}addToSet(t){let n,r=!1;for(let s=0;s<t.length;s++){let i=t[s];if(this.eq(i))return t;if(this.type.excludes(i.type))n||(n=t.slice(0,s));else{if(i.type.excludes(this.type))return t;!r&&i.type.rank>this.type.rank&&(n||(n=t.slice(0,s)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=t.slice()),r||n.push(this),n}removeFromSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return t.slice(0,n).concat(t.slice(n+1));return t}isInSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return!0;return!1}eq(t){return this==t||this.type==t.type&&jr(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=t.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let s=r.create(n.attrs);return r.checkAttrs(s.attrs),s}static sameSet(t,n){if(t==n)return!0;if(t.length!=n.length)return!1;for(let r=0;r<t.length;r++)if(!t[r].eq(n[r]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return Fe.none;if(t instanceof Fe)return[t];let n=t.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}}Fe.none=[];class Fc extends Error{}class X{constructor(t,n,r){this.content=t,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=na(this.content,t+this.openStart,n);return r&&new X(r,this.openStart,this.openEnd)}removeBetween(t,n){return new X(ta(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,n){if(!n)return X.empty;let r=n.openStart||0,s=n.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new X(Z.fromJSON(t,n.content),r,s)}static maxOpen(t,n=!0){let r=0,s=0;for(let i=t.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=t.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)s++;return new X(t,r,s)}}X.empty=new X(Z.empty,0,0);function ta(e,t,n){let{index:r,offset:s}=e.findIndex(t),i=e.maybeChild(r),{index:a,offset:o}=e.findIndex(n);if(s==t||i.isText){if(o!=n&&!e.child(a).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(r!=a)throw new RangeError("Removing non-flat range");return e.replaceChild(r,i.copy(ta(i.content,t-s-1,n-s-1)))}function na(e,t,n,r){let{index:s,offset:i}=e.findIndex(t),a=e.maybeChild(s);if(i==t||a.isText)return r&&!r.canReplace(s,s,n)?null:e.cut(0,t).append(n).append(e.cut(t));let o=na(a.content,t-i-1,n,a);return o&&e.replaceChild(s,a.copy(o))}function Pc(e){return e.tag!=null}function Rc(e){return e.style!=null}class Nn{constructor(t,n){this.schema=t,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(Pc(s))this.tags.push(s);else if(Rc(s)){let i=/[^=]*/.exec(s.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=t.nodes[s.node];return i.contentMatch.matchType(i)})}parse(t,n={}){let r=new Ps(this,n,!1);return r.addAll(t,Fe.none,n.from,n.to),r.finish()}parseSlice(t,n={}){let r=new Ps(this,n,!0);return r.addAll(t,Fe.none,n.from,n.to),X.maxOpen(r.finish())}matchTag(t,n,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(_c(t,i.tag)&&(i.namespace===void 0||t.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let a=i.getAttrs(t);if(a===!1)continue;i.attrs=a||void 0}return i}}}matchStyle(t,n,r,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let a=this.styles[i],o=a.style;if(!(o.indexOf(t)!=0||a.context&&!r.matchesContext(a.context)||o.length>t.length&&(o.charCodeAt(t.length)!=61||o.slice(t.length+1)!=n))){if(a.getAttrs){let c=a.getAttrs(n);if(c===!1)continue;a.attrs=c||void 0}return a}}}static schemaRules(t){let n=[];function r(s){let i=s.priority==null?50:s.priority,a=0;for(;a<n.length;a++){let o=n[a];if((o.priority==null?50:o.priority)<i)break}n.splice(a,0,s)}for(let s in t.marks){let i=t.marks[s].spec.parseDOM;i&&i.forEach(a=>{r(a=Rs(a)),a.mark||a.ignore||a.clearMark||(a.mark=s)})}for(let s in t.nodes){let i=t.nodes[s].spec.parseDOM;i&&i.forEach(a=>{r(a=Rs(a)),a.node||a.ignore||a.mark||(a.node=s)})}return n}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new Nn(t,Nn.schemaRules(t)))}}const ra={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},zc={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},sa={ol:!0,ul:!0},Gt=1,Ar=2,Ht=4;function Fs(e,t,n){return t!=null?(t?Gt:0)|(t==="full"?Ar:0):e&&e.whitespace=="pre"?Gt|Ar:n&~Ht}class un{constructor(t,n,r,s,i,a){this.type=t,this.attrs=n,this.marks=r,this.solid=s,this.options=a,this.content=[],this.activeMarks=Fe.none,this.match=i||(a&Ht?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(Z.from(t));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(t.type))?(this.match=r,s):null}}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&Gt)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let n=Z.from(this.content);return!t&&this.match&&(n=n.append(this.match.fillBefore(Z.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!ra.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class Ps{constructor(t,n,r){this.parser=t,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=n.topNode,i,a=Fs(null,n.preserveWhitespace,0)|(r?Ht:0);s?i=new un(s.type,s.attrs,Fe.none,!0,n.topMatch||s.type.contentMatch,a):r?i=new un(null,null,Fe.none,!0,null,a):i=new un(t.schema.topNodeType,null,Fe.none,!0,null,a),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t,n){t.nodeType==3?this.addTextNode(t,n):t.nodeType==1&&this.addElement(t,n)}addTextNode(t,n){let r=t.nodeValue,s=this.top,i=s.options&Ar?"full":this.localPreserveWS||(s.options&Gt)>0,{schema:a}=this.parser;if(i==="full"||s.inlineContext(t)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
11
+ `);else if(a.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(a.linebreakReplacement.create())){let o=r.split(/\r?\n|\r/);for(let c=0;c<o.length;c++)c&&this.insertNode(a.linebreakReplacement.create(),n,!0),o[c]&&this.insertNode(a.text(o[c]),n,!/\S/.test(o[c]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let o=s.content[s.content.length-1],c=t.previousSibling;(!o||c&&c.nodeName=="BR"||o.isText&&/[ \t\r\n\u000c]$/.test(o.text))&&(r=r.slice(1))}r&&this.insertNode(a.text(r),n,!/\S/.test(r)),this.findInText(t)}else this.findInside(t)}addElement(t,n,r){let s=this.localPreserveWS,i=this.top;(t.tagName=="PRE"||/pre/.test(t.style&&t.style.whiteSpace))&&(this.localPreserveWS=!0);let a=t.nodeName.toLowerCase(),o;sa.hasOwnProperty(a)&&this.parser.normalizeLists&&Bc(t);let c=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(o=this.parser.matchTag(t,this,r));e:if(c?c.ignore:zc.hasOwnProperty(a))this.findInside(t),this.ignoreFallback(t,n);else if(!c||c.skip||c.closeParent){c&&c.closeParent?this.open=Math.max(0,this.open-1):c&&c.skip.nodeType&&(t=c.skip);let d,u=this.needsBlock;if(ra.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),d=!0,i.type||(this.needsBlock=!0);else if(!t.firstChild){this.leafFallback(t,n);break e}let h=c&&c.skip?n:this.readStyles(t,n);h&&this.addAll(t,h),d&&this.sync(i),this.needsBlock=u}else{let d=this.readStyles(t,n);d&&this.addElementByRule(t,c,d,c.consuming===!1?o:void 0)}this.localPreserveWS=s}leafFallback(t,n){t.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode(`
12
+ `),n)}ignoreFallback(t,n){t.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(t,n){let r=t.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],a=r.getPropertyValue(i);if(a)for(let o=void 0;;){let c=this.parser.matchStyle(i,a,this,o);if(!c)break;if(c.ignore)return null;if(c.clearMark?n=n.filter(d=>!c.clearMark(d)):n=n.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)o=c;else break}}return n}addElementByRule(t,n,r,s){let i,a;if(n.node)if(a=this.parser.schema.nodes[n.node],a.isLeaf)this.insertNode(a.create(n.attrs),r,t.nodeName=="BR")||this.leafFallback(t,r);else{let c=this.enter(a,n.attrs||null,r,n.preserveWhitespace);c&&(i=!0,r=c)}else{let c=this.parser.schema.marks[n.mark];r=r.concat(c.create(n.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(t);else if(s)this.addElement(t,r,s);else if(n.getContent)this.findInside(t),n.getContent(t,this.parser.schema).forEach(c=>this.insertNode(c,r,!1));else{let c=t;typeof n.contentElement=="string"?c=t.querySelector(n.contentElement):typeof n.contentElement=="function"?c=n.contentElement(t):n.contentElement&&(c=n.contentElement),this.findAround(t,c,!0),this.addAll(c,r),this.findAround(t,c,!1)}i&&this.sync(o)&&this.open--}addAll(t,n,r,s){let i=r||0;for(let a=r?t.childNodes[r]:t.firstChild,o=s==null?null:t.childNodes[s];a!=o;a=a.nextSibling,++i)this.findAtPoint(t,i),this.addDOM(a,n);this.findAtPoint(t,i)}findPlace(t,n,r){let s,i;for(let a=this.open,o=0;a>=0;a--){let c=this.nodes[a],d=c.findWrapping(t);if(d&&(!s||s.length>d.length+o)&&(s=d,i=c,!d.length))break;if(c.solid){if(r)break;o+=2}}if(!s)return null;this.sync(i);for(let a=0;a<s.length;a++)n=this.enterInner(s[a],null,n,!1);return n}insertNode(t,n,r){if(t.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let s=this.findPlace(t,n,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(t.type));let a=Fe.none;for(let o of s.concat(t.marks))(i.type?i.type.allowsMarkType(o.type):zs(o.type,t.type))&&(a=o.addToSet(a));return i.content.push(t.mark(a)),!0}return!1}enter(t,n,r,s){let i=this.findPlace(t.create(n),r,!1);return i&&(i=this.enterInner(t,n,r,!0,s)),i}enterInner(t,n,r,s=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(t);let o=Fs(t,i,a.options);a.options&Ht&&a.content.length==0&&(o|=Ht);let c=Fe.none;return r=r.filter(d=>(a.type?a.type.allowsMarkType(d.type):zs(d.type,t))?(c=d.addToSet(c),!1):!0),this.nodes.push(new un(t,n,c,s,null,o)),this.open++,r}closeExtra(t=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(t));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(t){for(let n=this.open;n>=0;n--){if(this.nodes[n]==t)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Gt)}return!1}get currentPos(){this.closeExtra();let t=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let s=r.length-1;s>=0;s--)t+=r[s].nodeSize;n&&t++}return t}findAtPoint(t,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==t&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&t.nodeType==1&&t.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(t,n,r){if(t!=n&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&t.nodeType==1&&t.contains(this.find[s].node)&&n.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==t&&(this.find[n].pos=this.currentPos-(t.nodeValue.length-this.find[n].offset))}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let n=t.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(s?0:1),a=(o,c)=>{for(;o>=0;o--){let d=n[o];if(d==""){if(o==n.length-1||o==0)continue;for(;c>=i;c--)if(a(o-1,c))return!0;return!1}else{let u=c>0||c==0&&s?this.nodes[c].type:r&&c>=i?r.node(c-i).type:null;if(!u||u.name!=d&&!u.isInGroup(d))return!1;c--}}return!0};return a(n.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function Bc(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let r=t.nodeType==1?t.nodeName.toLowerCase():null;r&&sa.hasOwnProperty(r)&&n?(n.appendChild(t),t=n):r=="li"?n=t:r&&(n=null)}}function _c(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Rs(e){let t={};for(let n in e)t[n]=e[n];return t}function zs(e,t){let n=t.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(e))continue;let i=[],a=o=>{i.push(o);for(let c=0;c<o.edgeCount;c++){let{type:d,next:u}=o.edge(c);if(d==t||i.indexOf(u)<0&&a(u))return!0}};if(a(s.contentMatch))return!0}}class Vn{constructor(t,n){this.nodes=t,this.marks=n}serializeFragment(t,n={},r){r||(r=nr(n).createDocumentFragment());let s=r,i=[];return t.forEach(a=>{if(i.length||a.marks.length){let o=0,c=0;for(;o<i.length&&c<a.marks.length;){let d=a.marks[c];if(!this.marks[d.type.name]){c++;continue}if(!d.eq(i[o][0])||d.type.spec.spanning===!1)break;o++,c++}for(;o<i.length;)s=i.pop()[1];for(;c<a.marks.length;){let d=a.marks[c++],u=this.serializeMark(d,a.isInline,n);u&&(i.push([d,s]),s.appendChild(u.dom),s=u.contentDOM||u.dom)}}s.appendChild(this.serializeNodeInner(a,n))}),r}serializeNodeInner(t,n){let{dom:r,contentDOM:s}=xn(nr(n),this.nodes[t.type.name](t),null,t.attrs);if(s){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,n,s)}return r}serializeNode(t,n={}){let r=this.serializeNodeInner(t,n);for(let s=t.marks.length-1;s>=0;s--){let i=this.serializeMark(t.marks[s],t.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(t,n,r={}){let s=this.marks[t.type.name];return s&&xn(nr(r),s(t,n),null,t.attrs)}static renderSpec(t,n,r=null,s){return xn(t,n,r,s)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new Vn(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let n=Bs(t.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(t){return Bs(t.marks)}}function Bs(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function nr(e){return e.document||window.document}const _s=new WeakMap;function Vc(e){let t=_s.get(e);return t===void 0&&_s.set(e,t=Hc(e)),t}function Hc(e){let t=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")t||(t=[]),t.push(r);else for(let s=0;s<r.length;s++)n(r[s]);else for(let s in r)n(r[s])}return n(e),t}function xn(e,t,n,r){if(typeof t=="string")return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let s=t[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=Vc(r))&&i.indexOf(t)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let a=s.indexOf(" ");a>0&&(n=s.slice(0,a),s=s.slice(a+1));let o,c=n?e.createElementNS(n,s):e.createElement(s),d=t[1],u=1;if(d&&typeof d=="object"&&d.nodeType==null&&!Array.isArray(d)){u=2;for(let h in d)if(d[h]!=null){let p=h.indexOf(" ");p>0?c.setAttributeNS(h.slice(0,p),h.slice(p+1),d[h]):h=="style"&&c.style?c.style.cssText=d[h]:c.setAttribute(h,d[h])}}for(let h=u;h<t.length;h++){let p=t[h];if(p===0){if(h<t.length-1||h>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else{let{dom:m,contentDOM:v}=xn(e,p,n,r);if(c.appendChild(m),v){if(o)throw new RangeError("Multiple content holes");o=v}}}return{dom:c,contentDOM:o}}const ia=65535,aa=Math.pow(2,16);function Uc(e,t){return e+t*aa}function Vs(e){return e&ia}function qc(e){return(e-(e&ia))/aa}const la=1,oa=2,yn=4,ca=8;class Mr{constructor(t,n,r){this.pos=t,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&ca)>0}get deletedBefore(){return(this.delInfo&(la|yn))>0}get deletedAfter(){return(this.delInfo&(oa|yn))>0}get deletedAcross(){return(this.delInfo&yn)>0}}class Ie{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&Ie.empty)return Ie.empty}recover(t){let n=0,r=Vs(t);if(!this.inverted)for(let s=0;s<r;s++)n+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+n+qc(t)}mapResult(t,n=1){return this._map(t,n,!1)}map(t,n=1){return this._map(t,n,!0)}_map(t,n,r){let s=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let c=this.ranges[o]-(this.inverted?s:0);if(c>t)break;let d=this.ranges[o+i],u=this.ranges[o+a],h=c+d;if(t<=h){let p=d?t==c?-1:t==h?1:n:n,m=c+s+(p<0?0:u);if(r)return m;let v=t==(n<0?c:h)?null:Uc(o/3,t-c),b=t==c?oa:t==h?la:yn;return(n<0?t!=c:t!=h)&&(b|=ca),new Mr(m,b,v)}s+=u-d}return r?t+s:new Mr(t+s,0,null)}touches(t,n){let r=0,s=Vs(n),i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let c=this.ranges[o]-(this.inverted?r:0);if(c>t)break;let d=this.ranges[o+i],u=c+d;if(t<=u&&o==s*3)return!0;r+=this.ranges[o+a]-d}return!1}forEach(t){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let a=this.ranges[s],o=a-(this.inverted?i:0),c=a+(this.inverted?0:i),d=this.ranges[s+n],u=this.ranges[s+r];t(o,o+d,c,c+u),i+=u-d}}invert(){return new Ie(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return t==0?Ie.empty:new Ie(t<0?[0,-t,0]:[0,0,t])}}Ie.empty=new Ie([]);class Sn{constructor(t,n,r=0,s=t?t.length:0){this.mirror=n,this.from=r,this.to=s,this._maps=t||[],this.ownData=!(t||n)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new Sn(this._maps,this.mirror,t,n)}appendMap(t,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(t),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(t){for(let n=0,r=this._maps.length;n<t._maps.length;n++){let s=t.getMirror(n);this.appendMap(t._maps[n],s!=null&&s<n?r+s:void 0)}}getMirror(t){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==t)return this.mirror[n+(n%2?-1:1)]}}setMirror(t,n){this.mirror||(this.mirror=[]),this.mirror.push(t,n)}appendMappingInverted(t){for(let n=t.maps.length-1,r=this._maps.length+t._maps.length;n>=0;n--){let s=t.getMirror(n);this.appendMap(t._maps[n].invert(),s!=null&&s>n?r-s-1:void 0)}}invert(){let t=new Sn;return t.appendMappingInverted(this),t}map(t,n=1){if(this.mirror)return this._map(t,n,!0);for(let r=this.from;r<this.to;r++)t=this._maps[r].map(t,n);return t}mapResult(t,n=1){return this._map(t,n,!1)}_map(t,n,r){let s=0;for(let i=this.from;i<this.to;i++){let a=this._maps[i],o=a.mapResult(t,n);if(o.recover!=null){let c=this.getMirror(i);if(c!=null&&c>i&&c<this.to){i=c,t=this._maps[c].recover(o.recover);continue}}s|=o.delInfo,t=o.pos}return r?t:new Mr(t,s,null)}}const rr=Object.create(null);class Ne{getMap(){return Ie.empty}merge(t){return null}static fromJSON(t,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=rr[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(t,n)}static jsonID(t,n){if(t in rr)throw new RangeError("Duplicate use of step JSON ID "+t);return rr[t]=n,n.prototype.jsonID=t,n}}class xe{constructor(t,n){this.doc=t,this.failed=n}static ok(t){return new xe(t,null)}static fail(t){return new xe(null,t)}static fromReplace(t,n,r,s){try{return xe.ok(t.replace(n,r,s))}catch(i){if(i instanceof Fc)return xe.fail(i.message);throw i}}}function Qr(e,t,n){let r=[];for(let s=0;s<e.childCount;s++){let i=e.child(s);i.content.size&&(i=i.copy(Qr(i.content,t,i))),i.isInline&&(i=t(i,n,s)),r.push(i)}return Z.fromArray(r)}class ut extends Ne{constructor(t,n,r){super(),this.from=t,this.to=n,this.mark=r}apply(t){let n=t.slice(this.from,this.to),r=t.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new X(Qr(n.content,(a,o)=>!a.isAtom||!o.type.allowsMarkType(this.mark.type)?a:a.mark(this.mark.addToSet(a.marks)),s),n.openStart,n.openEnd);return xe.fromReplace(t,this.from,this.to,i)}invert(){return new ft(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new ut(n.pos,r.pos,this.mark)}merge(t){return t instanceof ut&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new ut(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new ut(n.from,n.to,t.markFromJSON(n.mark))}}Ne.jsonID("addMark",ut);class ft extends Ne{constructor(t,n,r){super(),this.from=t,this.to=n,this.mark=r}apply(t){let n=t.slice(this.from,this.to),r=new X(Qr(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),t),n.openStart,n.openEnd);return xe.fromReplace(t,this.from,this.to,r)}invert(){return new ut(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new ft(n.pos,r.pos,this.mark)}merge(t){return t instanceof ft&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new ft(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new ft(n.from,n.to,t.markFromJSON(n.mark))}}Ne.jsonID("removeMark",ft);class ht extends Ne{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return xe.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return xe.fromReplace(t,this.pos,this.pos+1,new X(Z.from(r),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let s=0;s<n.marks.length;s++)if(!n.marks[s].isInSet(r))return new ht(this.pos,n.marks[s]);return new ht(this.pos,this.mark)}}return new Qt(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new ht(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new ht(n.pos,t.markFromJSON(n.mark))}}Ne.jsonID("addNodeMark",ht);class Qt extends Ne{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return xe.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return xe.fromReplace(t,this.pos,this.pos+1,new X(Z.from(r),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new ht(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new Qt(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Qt(n.pos,t.markFromJSON(n.mark))}}Ne.jsonID("removeNodeMark",Qt);class Ke extends Ne{constructor(t,n,r,s=!1){super(),this.from=t,this.to=n,this.slice=r,this.structure=s}apply(t){return this.structure&&Er(t,this.from,this.to)?xe.fail("Structure replace would overwrite content"):xe.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new Ie([this.from,this.to-this.from,this.slice.size])}invert(t){return new Ke(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new Ke(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(t){if(!(t instanceof Ke)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?X.empty:new X(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new Ke(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?X.empty:new X(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new Ke(t.from,this.to,n,this.structure)}else return null}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Ke(n.from,n.to,X.fromJSON(t,n.slice),!!n.structure)}}Ne.jsonID("replace",Ke);class Mt extends Ne{constructor(t,n,r,s,i,a,o=!1){super(),this.from=t,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=a,this.structure=o}apply(t){if(this.structure&&(Er(t,this.from,this.gapFrom)||Er(t,this.gapTo,this.to)))return xe.fail("Structure gap-replace would overwrite content");let n=t.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return xe.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?xe.fromReplace(t,this.from,this.to,r):xe.fail("Content does not fit in gap")}getMap(){return new Ie([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new Mt(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||i>r.pos?null:new Mt(n.pos,r.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Mt(n.from,n.to,n.gapFrom,n.gapTo,X.fromJSON(t,n.slice),n.insert,!!n.structure)}}Ne.jsonID("replaceAround",Mt);function Er(e,t,n){let r=e.resolve(t),s=n-t,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let a=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!a||a.isLeaf)return!0;a=a.firstChild,s--}}return!1}function da(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let s=n.content;for(let i=0;i<n.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.size?2:1);i++)for(let a=r.depth;a>=0;a--){let o=a==r.depth?0:r.pos<=(r.start(a+1)+r.end(a+1))/2?-1:1,c=r.index(a)+(o>0?1:0),d=r.node(a),u=!1;if(i==1)u=d.canReplace(c,c,s);else{let h=d.contentMatchAt(c).findWrapping(s.firstChild.type);u=h&&d.canReplaceWith(c,c,h[0])}if(u)return o==0?r.pos:o<0?r.before(a+1):r.after(a+1)}return null}class Ut extends Ne{constructor(t,n,r){super(),this.pos=t,this.attr=n,this.value=r}apply(t){let n=t.nodeAt(this.pos);if(!n)return xe.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return xe.fromReplace(t,this.pos,this.pos+1,new X(Z.from(s),0,n.isLeaf?0:1))}getMap(){return Ie.empty}invert(t){return new Ut(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new Ut(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Ut(n.pos,n.attr,n.value)}}Ne.jsonID("attr",Ut);class Cn extends Ne{constructor(t,n){super(),this.attr=t,this.value=n}apply(t){let n=Object.create(null);for(let s in t.attrs)n[s]=t.attrs[s];n[this.attr]=this.value;let r=t.type.create(n,t.content,t.marks);return xe.ok(r)}getMap(){return Ie.empty}invert(t){return new Cn(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Cn(n.attr,n.value)}}Ne.jsonID("docAttr",Cn);let Zt=class extends Error{};Zt=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n};Zt.prototype=Object.create(Error.prototype);Zt.prototype.constructor=Zt;Zt.prototype.name="TransformError";const sr=Object.create(null);class ae{constructor(t,n,r){this.$anchor=t,this.$head=n,this.ranges=r||[new Wc(t.min(n),t.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let t=this.ranges;for(let n=0;n<t.length;n++)if(t[n].$from.pos!=t[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,n=X.empty){let r=n.content.lastChild,s=null;for(let o=0;o<n.openEnd;o++)s=r,r=r.lastChild;let i=t.steps.length,a=this.ranges;for(let o=0;o<a.length;o++){let{$from:c,$to:d}=a[o],u=t.mapping.slice(i);t.replaceRange(u.map(c.pos),u.map(d.pos),o?X.empty:n),o==0&&qs(t,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(t,n){let r=t.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:a,$to:o}=s[i],c=t.mapping.slice(r),d=c.map(a.pos),u=c.map(o.pos);i?t.deleteRange(d,u):(t.replaceRangeWith(d,u,n),qs(t,r,n.isInline?-1:1))}}static findFrom(t,n,r=!1){let s=t.parent.inlineContent?new ie(t):Ct(t.node(0),t.parent,t.pos,t.index(),n,r);if(s)return s;for(let i=t.depth-1;i>=0;i--){let a=n<0?Ct(t.node(0),t.node(i),t.before(i+1),t.index(i),n,r):Ct(t.node(0),t.node(i),t.after(i+1),t.index(i)+1,n,r);if(a)return a}return null}static near(t,n=1){return this.findFrom(t,n)||this.findFrom(t,-n)||new Ue(t.node(0))}static atStart(t){return Ct(t,t,0,0,1)||new Ue(t)}static atEnd(t){return Ct(t,t,t.content.size,t.childCount,-1)||new Ue(t)}static fromJSON(t,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=sr[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(t,n)}static jsonID(t,n){if(t in sr)throw new RangeError("Duplicate use of selection JSON ID "+t);return sr[t]=n,n.prototype.jsonID=t,n}getBookmark(){return ie.between(this.$anchor,this.$head).getBookmark()}}ae.prototype.visible=!0;class Wc{constructor(t,n){this.$from=t,this.$to=n}}let Hs=!1;function Us(e){!Hs&&!e.parent.inlineContent&&(Hs=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class ie extends ae{constructor(t,n=t){Us(t),Us(n),super(t,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return ae.near(r);let s=t.resolve(n.map(this.anchor));return new ie(s.parent.inlineContent?s:r,r)}replace(t,n=X.empty){if(super.replace(t,n),n==X.empty){let r=this.$from.marksAcross(this.$to);r&&t.ensureMarks(r)}}eq(t){return t instanceof ie&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new Hn(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new ie(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){let s=t.resolve(n);return new this(s,r==n?s:t.resolve(r))}static between(t,n,r){let s=t.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let i=ae.findFrom(n,r,!0)||ae.findFrom(n,-r,!0);if(i)n=i.$head;else return ae.near(n,r)}return t.parent.inlineContent||(s==0?t=n:(t=(ae.findFrom(t,-r,!0)||ae.findFrom(t,r,!0)).$anchor,t.pos<n.pos!=s<0&&(t=n))),new ie(t,n)}}ae.jsonID("text",ie);class Hn{constructor(t,n){this.anchor=t,this.head=n}map(t){return new Hn(t.map(this.anchor),t.map(this.head))}resolve(t){return ie.between(t.resolve(this.anchor),t.resolve(this.head))}}class ee extends ae{constructor(t){let n=t.nodeAfter,r=t.node(0).resolve(t.pos+n.nodeSize);super(t,r),this.node=n}map(t,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),i=t.resolve(s);return r?ae.near(i):new ee(i)}content(){return new X(Z.from(this.node),0,0)}eq(t){return t instanceof ee&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Zr(this.anchor)}static fromJSON(t,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new ee(t.resolve(n.anchor))}static create(t,n){return new ee(t.resolve(n))}static isSelectable(t){return!t.isText&&t.type.spec.selectable!==!1}}ee.prototype.visible=!1;ae.jsonID("node",ee);class Zr{constructor(t){this.anchor=t}map(t){let{deleted:n,pos:r}=t.mapResult(this.anchor);return n?new Hn(r,r):new Zr(r)}resolve(t){let n=t.resolve(this.anchor),r=n.nodeAfter;return r&&ee.isSelectable(r)?new ee(n):ae.near(n)}}class Ue extends ae{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,n=X.empty){if(n==X.empty){t.delete(0,t.doc.content.size);let r=ae.atStart(t.doc);r.eq(t.selection)||t.setSelection(r)}else super.replace(t,n)}toJSON(){return{type:"all"}}static fromJSON(t){return new Ue(t)}map(t){return new Ue(t)}eq(t){return t instanceof Ue}getBookmark(){return Kc}}ae.jsonID("all",Ue);const Kc={map(){return this},resolve(e){return new Ue(e)}};function Ct(e,t,n,r,s,i=!1){if(t.inlineContent)return ie.create(e,n);for(let a=r-(s>0?0:1);s>0?a<t.childCount:a>=0;a+=s){let o=t.child(a);if(o.isAtom){if(!i&&ee.isSelectable(o))return ee.create(e,n-(s<0?o.nodeSize:0))}else{let c=Ct(e,o,n+s,s<0?o.childCount:0,s,i);if(c)return c}n+=o.nodeSize*s}return null}function qs(e,t,n){let r=e.steps.length-1;if(r<t)return;let s=e.steps[r];if(!(s instanceof Ke||s instanceof Mt))return;let i=e.mapping.maps[r],a;i.forEach((o,c,d,u)=>{a==null&&(a=u)}),e.setSelection(ae.near(e.doc.resolve(a),n))}function Ws(e,t){return!t||!e?e:e.bind(t)}class fn{constructor(t,n,r){this.name=t,this.init=Ws(n.init,r),this.apply=Ws(n.apply,r)}}new fn("doc",{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new fn("selection",{init(e,t){return e.selection||ae.atStart(t.doc)},apply(e){return e.selection}}),new fn("storedMarks",{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new fn("scrollToSelection",{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}});function ua(e,t,n){for(let r in e){let s=e[r];s instanceof Function?s=s.bind(t):r=="handleDOMEvents"&&(s=ua(s,t,{})),n[r]=s}return n}class Un{constructor(t){this.spec=t,this.props={},t.props&&ua(t.props,this,this.props),this.key=t.key?t.key.key:fa("plugin")}getState(t){return t[this.key]}}const ir=Object.create(null);function fa(e){return e in ir?e+"$"+ ++ir[e]:(ir[e]=0,e+"$")}class Xr{constructor(t="key"){this.key=fa(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const Jc=/^```([a-z]+)?[\s\n]$/,Yc=/^~~~([a-z]+)?[\s\n]$/,Gc=V.Node.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{var t;const{languageClassPrefix:n}=this.options,i=[...((t=e.firstElementChild)===null||t===void 0?void 0:t.classList)||[]].filter(a=>a.startsWith(n)).map(a=>a.replace(n,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:e,HTMLAttributes:t}){return["pre",V.mergeAttributes(this.options.HTMLAttributes,t),["code",{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:e,$anchor:t}=this.editor.state.selection,n=t.pos===1;return!e||t.parent.type.name!==this.name?!1:n||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:t}=e,{selection:n}=t,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,a=r.parent.textContent.endsWith(`
13
13
 
14
- `);return!i||!o?!1:t.chain().command(({tr:a})=>(a.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:s,empty:i}=n;if(!i||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const a=s.after();return a===void 0?!1:r.nodeAt(a)?t.commands.command(({tr:d})=>(d.setSelection(ee.near(r.resolve(a))),!0)):t.commands.exitCode()}}},addInputRules(){return[$.textblockTypeInputRule({find:El,type:this.type,getAttributes:t=>({language:t[1]})}),$.textblockTypeInputRule({find:Tl,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new vn({key:new Cr("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s?.mode;if(!n||!i)return!1;const{tr:o,schema:a}=t.state,l=a.text(n.replace(/\r\n?/g,`
15
- `));return o.replaceSelectionWith(this.type.create({language:i},l)),o.selection.$from.parent.type!==this.type&&o.setSelection(X.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),Ol=/^\s*>\s$/,Dl=$.Node.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",$.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[$.wrappingInputRule({find:Ol,type:this.type})]}}),Il=$.Node.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",$.mergeAttributes(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!$.canInsertNode(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$from:r,$to:s}=n,i=t();return r.parentOffset===0?i.insertContentAt({from:Math.max(r.pos-1,0),to:s.pos},{type:this.name}):$.isNodeSelection(n)?i.insertContentAt(s.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({tr:o,dispatch:a})=>{var l;if(a){const{$to:d}=o.selection,u=d.end();if(d.nodeAfter)d.nodeAfter.isTextblock?o.setSelection(X.create(o.doc,d.pos+1)):d.nodeAfter.isBlock?o.setSelection(J.create(o.doc,d.pos)):o.setSelection(X.create(o.doc,d.pos));else{const f=(l=d.parent.type.contentMatch.defaultType)===null||l===void 0?void 0:l.create();f&&(o.insert(u,f),o.setSelection(X.create(o.doc,u+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[$.nodeInputRule({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Ll=$.Node.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",$.mergeAttributes(this.options.HTMLAttributes,t)]},renderText(){return`
16
- `},addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:s,storedMarks:i}=n;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:a}=r.extensionManager,l=i||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:d,dispatch:u})=>{if(u&&l&&o){const f=l.filter(p=>a.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 an=200,ge=function(){};ge.prototype.append=function(e){return e.length?(e=ge.from(e),!this.length&&e||e.length<an&&this.leafAppend(e)||this.length<an&&e.leafPrepend(this)||this.appendInner(e)):this};ge.prototype.prepend=function(e){return e.length?ge.from(e).append(this):this};ge.prototype.appendInner=function(e){return new Fl(this,e)};ge.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?ge.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};ge.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ge.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)};ge.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};ge.from=function(e){return e instanceof ge?e:e&&e.length?new Ni(e):ge.empty};var Ni=(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,a){for(var l=i;l<o;l++)if(s(this.values[l],a+l)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,o,a){for(var l=i-1;l>=o;l--)if(s(this.values[l],a+l)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=an)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=an)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})(ge);ge.empty=new Ni([]);var Fl=(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 a=this.left.length;if(s<a&&this.left.forEachInner(r,s,Math.min(i,a),o)===!1||i>a&&this.right.forEachInner(r,Math.max(s-a,0),Math.min(this.length,i)-a,o+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,o){var a=this.left.length;if(s>a&&this.right.forEachInvertedInner(r,s-a,Math.max(i,a)-a,o+a)===!1||i<a&&this.left.forEachInvertedInner(r,Math.min(s,a),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})(ge);const Pl=500;class Fe{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,a,l,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 h=f.step.map(s.slice(i)),k;h&&o.maybeStep(h).doc&&(k=o.mapping.maps[o.mapping.maps.length-1],d.push(new Be(k,void 0,void 0,d.length+u.length))),i--,k&&s.appendMap(k,i)}else o.maybeStep(f.step);if(f.selection)return a=s?f.selection.map(s.slice(i)):f.selection,l=new Fe(this.items.slice(0,r).append(u.reverse().concat(d)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:o,selection:a}}addTransform(e,n,r,s){let i=[],o=this.eventCount,a=this.items,l=!s&&a.length?a.get(a.length-1):null;for(let u=0;u<e.steps.length;u++){let f=e.steps[u].invert(e.docs[u]),p=new Be(e.mapping.maps[u],f,n),h;(h=l&&l.merge(p))&&(p=h,u?i.pop():a=a.slice(0,a.length-1)),i.push(p),n&&(o++,n=void 0),s||(l=p)}let d=o-r.depth;return d>$l&&(a=Rl(a,d),o-=d),new Fe(a.append(i),o)}remapping(e,n){let r=new sn;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 Fe(this.items.append(e.map(n=>new Be(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-n),i=e.mapping,o=e.steps.length,a=this.eventCount;this.items.forEach(p=>{p.selection&&a--},s);let l=n;this.items.forEach(p=>{let h=i.getMirror(--l);if(h==null)return;o=Math.min(o,h);let k=i.maps[h];if(p.step){let v=e.steps[h].invert(e.docs[h]),y=p.selection&&p.selection.map(i.slice(l+1,h));y&&a++,r.push(new Be(k,v,y))}else r.push(new Be(k))},s);let d=[];for(let p=n;p<o;p++)d.push(new Be(i.maps[p]));let u=this.items.slice(0,s).append(d).append(r),f=new Fe(u,a);return f.emptyItemCount()>Pl&&(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,a)=>{if(a>=e)s.push(o),o.selection&&i++;else if(o.step){let l=o.step.map(n.slice(r)),d=l&&l.getMap();if(r--,d&&n.appendMap(d,r),l){let u=o.selection&&o.selection.map(n.slice(r));u&&i++;let f=new Be(d.invert(),l,u),p,h=s.length-1;(p=s.length&&s[h].merge(f))?s[h]=p:s.push(f)}}else o.map&&r--},this.items.length,0),new Fe(ge.from(s.reverse()),i)}}Fe.empty=new Fe(ge.empty,0);function Rl(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}class Be{constructor(e,n,r,s){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new Be(n.getMap().invert(),n,this.selection)}}}class Ze{constructor(e,n,r,s,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const $l=20;function Vl(t,e,n,r){let s=n.getMeta(dt),i;if(s)return s.historyState;n.getMeta(_l)&&(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(dt))return o.getMeta(dt).redo?new Ze(t.done.addTransform(n,void 0,r,en(e)),t.undone,ys(n.mapping.maps),t.prevTime,t.prevComposition):new Ze(t.done,t.undone.addTransform(n,void 0,r,en(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let a=n.getMeta("composition"),l=t.prevTime==0||!o&&t.prevComposition!=a&&(t.prevTime<(n.time||0)-r.newGroupDelay||!Bl(n,t.prevRanges)),d=o?Vn(t.prevRanges,n.mapping):ys(n.mapping.maps);return new Ze(t.done.addTransform(n,l?e.selection.getBookmark():void 0,r,en(e)),Fe.empty,d,n.time,a??t.prevComposition)}else return(i=n.getMeta("rebased"))?new Ze(t.done.rebased(n,i),t.undone.rebased(n,i),Vn(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Ze(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Vn(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function Bl(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 ys(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 Vn(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 zl(t,e,n){let r=en(e),s=dt.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),a=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),l=new Ze(n?a:i.remaining,n?i.remaining:a,null,0,-1);return i.transform.setSelection(o).setMeta(dt,{redo:n,historyState:l})}let Bn=!1,bs=null;function en(t){let e=t.plugins;if(bs!=e){Bn=!1,bs=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Bn=!0;break}}return Bn}const dt=new Cr("history"),_l=new Cr("closeHistory");function Hl(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new vn({key:dt,state:{init(){return new Ze(Fe.empty,Fe.empty,null,0,-1)},apply(e,n,r){return Vl(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?ji:r=="historyRedo"?Ei:null;return!s||!e.editable?!1:(n.preventDefault(),s(e.state,e.dispatch))}}}})}function Ai(t,e){return(n,r)=>{let s=dt.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let i=zl(s,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const ji=Ai(!1,!0),Ei=Ai(!0,!0),vs=$.Extension.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>ji(t,e),redo:()=>({state:t,dispatch:e})=>Ei(t,e)}},addProseMirrorPlugins(){return[Hl(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()}}}),Ul=$.Node.create({name:"doc",topNode:!0,content:"block+"}),ql=$.Node.create({name:"text",group:"inline"});function Kl(t={}){return new vn({view(e){return new Wl(e,t)}})}class Wl{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,a=i.height/s.offsetHeight;if(n){let f=e.nodeBefore,p=e.nodeAfter;if(f||p){let h=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(h){let k=h.getBoundingClientRect(),v=f?k.bottom:k.top;f&&p&&(v=(v+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*a;r={left:k.left,right:k.right,top:v-y,bottom:v+y}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*o;r={left:f.left-p,right:f.left+p,top:f.top,bottom:f.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.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(!l||l==document.body&&getComputedStyle(l).position=="static")d=-pageXOffset,u=-pageYOffset;else{let f=l.getBoundingClientRect(),p=f.width/l.offsetWidth,h=f.height/l.offsetHeight;d=f.left-l.scrollLeft*p,u=f.top-l.scrollTop*h}this.element.style.left=(r.left-d)/o+"px",this.element.style.top=(r.top-u)/a+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/a+"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 a=Si(this.editorView.state.doc,o,this.editorView.dragging.slice);a!=null&&(o=a)}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 Jl=$.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Kl(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:"'"},ln={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Gl=typeof navigator<"u"&&/Mac/.test(navigator.platform),Zl=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),ln[ye]=String.fromCharCode(ye);for(var zn in et)ln.hasOwnProperty(zn)||(ln[zn]=et[zn]);function Yl(t){var e=Gl&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Zl&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?ln: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 Ql=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Xl=typeof navigator<"u"&&/Win/.test(navigator.platform);function ec(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,s,i,o;for(let a=0;a<e.length-1;a++){let l=e[a];if(/^(cmd|meta|m)$/i.test(l))o=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))s=!0;else if(/^s(hift)?$/i.test(l))i=!0;else if(/^mod$/i.test(l))Ql?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+l)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),o&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function tc(t){let e=Object.create(null);for(let n in t)e[ec(n)]=t[n];return e}function _n(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 nc(t){let e=tc(t);return function(n,r){let s=Yl(r),i,o=e[_n(s,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let a=e[_n(s,r,!1)];if(a&&a(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(Xl&&r.ctrlKey&&r.altKey)&&(i=et[r.keyCode])&&i!=s){let a=e[_n(i,r)];if(a&&a(n.state,n.dispatch,n))return!0}}return!1}}const pt=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Ti=function(t,e,n,r){return n&&(ks(t,e,n,r,-1)||ks(t,e,n,r,1))},rc=/^(img|br|input|textarea|hr)$/i;function ks(t,e,n,r,s){for(var i;;){if(t==n&&e==r)return!0;if(e==(s<0?0:cn(t))){let o=t.parentNode;if(!o||o.nodeType!=1||wr(t)||rc.test(t.nodeName)||t.contentEditable=="false")return!1;e=pt(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?cn(t):0}else return!1}}function cn(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function sc(t,e,n){for(let r=e==0,s=e==cn(t);r||s;){if(t==n)return!0;let i=pt(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,s=s&&i==cn(t)}}function wr(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 Mi=function(t){return t.focusNode&&Ti(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Oi(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,Ss=typeof document<"u"?document:null,tt=He&&He.userAgent||"",rr=/Edge\/(\d+)/.exec(tt),Di=/MSIE \d/.exec(tt),sr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(tt),Ut=!!(Di||sr||rr),Ii=Di?document.documentMode:sr?+sr[1]:rr?+rr[1]:0,kn=!Ut&&/gecko\/(\d+)/i.test(tt);kn&&+(/Firefox\/(\d+)/.exec(tt)||[0,0])[1];const ir=!Ut&&/Chrome\/(\d+)/.exec(tt),We=!!ir,Li=ir?+ir[1]:0,mt=!Ut&&!!He&&/Apple Computer/.test(He.vendor),Nr=mt&&(/Mobile\/\w+/.test(tt)||!!He&&He.maxTouchPoints>2),De=Nr||(He?/Mac/.test(He.platform):!1),Fi=He?/Win/.test(He.platform):!1,qt=/Android \d/.test(tt),Ar=!!Ss&&"webkitFontSmoothing"in Ss.documentElement.style,ic=Ar?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function oc(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 a=r.resolve(o),l,d;if(Mi(n)){for(l=o;s&&!s.node;)s=s.parent;let f=s.node;if(s&&f.isAtom&&J.isSelectable(f)&&s.parent&&!(f.isInline&&sc(n.focusNode,n.focusOffset,s.dom))){let p=s.posBefore;d=new J(o==p?a:r.resolve(p))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=o,p=o;for(let h=0;h<n.rangeCount;h++){let k=n.getRangeAt(h);f=Math.min(f,t.docView.posFromDOM(k.startContainer,k.startOffset,1)),p=Math.max(p,t.docView.posFromDOM(k.endContainer,k.endOffset,-1))}if(f<0)return null;[l,o]=p==t.state.selection.anchor?[p,f]:[f,p],a=r.resolve(o)}else l=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let u=r.resolve(l);if(!d){let f=e=="pointer"||t.state.selection.head<a.pos&&!i?1:-1;d=Ri(t,u,a,f)}return d}function Pi(t){return t.editable?t.hasFocus():dc(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function jr(t,e=!1){let n=t.state.selection;if(cc(t,n),!!Pi(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&We){let r=t.domSelectionRange(),s=t.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&Ti(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)lc(t);else{let{anchor:r,head:s}=n,i,o;Cs&&!(n instanceof X)&&(n.$from.parent.inlineContent||(i=ws(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=ws(t,n.to))),t.docView.setSelection(r,s,t,e),Cs&&(i&&Ns(i),o&&Ns(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&ac(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const Cs=mt||We&&Li<63;function ws(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(mt&&s&&s.contentEditable=="false")return Hn(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return Hn(s);if(i)return Hn(i)}}function Hn(t){return t.contentEditable="true",mt&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Ns(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function ac(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(()=>{(!Pi(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function lc(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,pt(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Ut&&Ii<=11&&(n.disabled=!0,n.disabled=!1)}function cc(t,e){if(e instanceof J){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(As(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else As(t)}function As(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Ri(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||X.between(e,n,r)}function dc(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 or(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&&ee.findFrom(i,e)}function Ye(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function js(t,e,n){let r=t.state.selection;if(r instanceof X)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 Ye(t,new X(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=or(t.state,e);return s&&s instanceof J?Ye(t,s):!1}else if(!(De&&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 a=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(o=t.docView.descAt(a))&&!o.contentDOM?J.isSelectable(i)?Ye(t,new J(e<0?t.state.doc.resolve(s.pos-i.nodeSize):s)):Ar?Ye(t,new X(t.state.doc.resolve(e<0?a:a+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof J&&r.node.isInline)return Ye(t,new X(e>0?r.$to:r.$from));{let s=or(t.state,e);return s?Ye(t,s):!1}}}function dn(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 gt(t,e){return e<0?uc(t):fc(t)}function uc(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,i,o=!1;for(kn&&n.nodeType==1&&r<dn(n)&&It(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let a=n.childNodes[r-1];if(It(a,-1))s=n,i=--r;else if(a.nodeType==3)n=a,r=n.nodeValue.length;else break}}else{if($i(n))break;{let a=n.previousSibling;for(;a&&It(a,-1);)s=n.parentNode,i=pt(a),a=a.previousSibling;if(a)n=a,r=dn(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?ar(t,n,r):s&&ar(t,s,i)}function fc(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=dn(n),i,o;for(;;)if(r<s){if(n.nodeType!=1)break;let a=n.childNodes[r];if(It(a,1))i=n,o=++r;else break}else{if($i(n))break;{let a=n.nextSibling;for(;a&&It(a,1);)i=a.parentNode,o=pt(a)+1,a=a.nextSibling;if(a)n=a,r=0,s=dn(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}i&&ar(t,i,o)}function $i(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function hc(t,e){for(;t&&e==t.childNodes.length&&!wr(t);)e=pt(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 pc(t,e){for(;t&&!e&&!wr(t);)e=pt(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 ar(t,e,n){if(e.nodeType!=3){let i,o;(o=hc(e,n))?(e=o,n=0):(i=pc(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(Mi(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&&jr(t)},50)}function Es(t,e){let n=t.state.doc.resolve(e);if(!(We||Fi)&&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 Ts(t,e,n){let r=t.state.selection;if(r instanceof X&&!r.empty||n.indexOf("s")>-1||De&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=or(t.state,e);if(o&&o instanceof J)return Ye(t,o)}if(!s.parent.inlineContent){let o=e<0?s:i,a=r instanceof _e?ee.near(o,e):ee.findFrom(o,e);return a?Ye(t,a):!1}return!1}function Ms(t,e){if(!(t.state.selection instanceof X))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 Os(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function mc(t){if(!mt||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;Os(t,r,"true"),setTimeout(()=>Os(t,r,"false"),20)}return!1}function gc(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function xc(t,e){let n=e.keyCode,r=gc(e);if(n==8||De&&n==72&&r=="c")return Ms(t,-1)||gt(t,-1);if(n==46&&!e.shiftKey||De&&n==68&&r=="c")return Ms(t,1)||gt(t,1);if(n==13||n==27)return!0;if(n==37||De&&n==66&&r=="c"){let s=n==37?Es(t,t.state.selection.from)=="ltr"?-1:1:-1;return js(t,s,r)||gt(t,s)}else if(n==39||De&&n==70&&r=="c"){let s=n==39?Es(t,t.state.selection.from)=="ltr"?1:-1:1;return js(t,s,r)||gt(t,s)}else{if(n==38||De&&n==80&&r=="c")return Ts(t,-1,r)||gt(t,-1);if(n==40||De&&n==78&&r=="c")return mc(t)||Ts(t,1,r)||gt(t,1);if(r==(De?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Vi(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")||yn.fromSchema(t.state.schema),a=qi(),l=a.createElement("div");l.appendChild(o.serializeFragment(r,{document:a}));let d=l.firstChild,u,f=0;for(;d&&d.nodeType==1&&(u=Ui[d.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let k=a.createElement(u[h]);for(;l.firstChild;)k.appendChild(l.firstChild);l.appendChild(k),f++}d=l.firstChild}d&&d.nodeType==1&&d.setAttribute("data-pm-slice",`${s} ${i}${f?` -${f}`:""} ${JSON.stringify(n)}`);let p=t.someProp("clipboardTextSerializer",h=>h(e,t))||e.content.textBetween(0,e.content.size,`
14
+ `);return!i||!a?!1:e.chain().command(({tr:o})=>(o.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;const{state:t}=e,{selection:n,doc:r}=t,{$from:s,empty:i}=n;if(!i||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const o=s.after();return o===void 0?!1:r.nodeAt(o)?e.commands.command(({tr:d})=>(d.setSelection(ae.near(r.resolve(o))),!0)):e.commands.exitCode()}}},addInputRules(){return[V.textblockTypeInputRule({find:Jc,type:this.type,getAttributes:e=>({language:e[1]})}),V.textblockTypeInputRule({find:Yc,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new Un({key:new Xr("codeBlockVSCodeHandler"),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;const n=t.clipboardData.getData("text/plain"),r=t.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s?.mode;if(!n||!i)return!1;const{tr:a,schema:o}=e.state,c=o.text(n.replace(/\r\n?/g,`
15
+ `));return a.replaceSelectionWith(this.type.create({language:i},c)),a.selection.$from.parent.type!==this.type&&a.setSelection(ie.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta("paste",!0),e.dispatch(a),!0}}})]}}),Qc=/^\s*>\s$/,Zc=V.Node.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return["blockquote",V.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[V.wrappingInputRule({find:Qc,type:this.type})]}}),Xc=V.Node.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:e}){return["hr",V.mergeAttributes(this.options.HTMLAttributes,e)]},addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!V.canInsertNode(t,t.schema.nodes[this.name]))return!1;const{selection:n}=t,{$from:r,$to:s}=n,i=e();return r.parentOffset===0?i.insertContentAt({from:Math.max(r.pos-1,0),to:s.pos},{type:this.name}):V.isNodeSelection(n)?i.insertContentAt(s.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({tr:a,dispatch:o})=>{var c;if(o){const{$to:d}=a.selection,u=d.end();if(d.nodeAfter)d.nodeAfter.isTextblock?a.setSelection(ie.create(a.doc,d.pos+1)):d.nodeAfter.isBlock?a.setSelection(ee.create(a.doc,d.pos)):a.setSelection(ie.create(a.doc,d.pos));else{const h=(c=d.parent.type.contentMatch.defaultType)===null||c===void 0?void 0:c.create();h&&(a.insert(u,h),a.setSelection(ie.create(a.doc,u+1)))}a.scrollIntoView()}return!0}).run()}}},addInputRules(){return[V.nodeInputRule({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),ed=V.Node.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:e}){return["br",V.mergeAttributes(this.options.HTMLAttributes,e)]},renderText(){return`
16
+ `},addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{const{selection:s,storedMarks:i}=n;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:a}=this.options,{splittableMarks:o}=r.extensionManager,c=i||s.$to.parentOffset&&s.$from.marks();return t().insertContent({type:this.name}).command(({tr:d,dispatch:u})=>{if(u&&c&&a){const h=c.filter(p=>o.includes(p.type.name));d.ensureMarks(h)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var jn=200,ve=function(){};ve.prototype.append=function(t){return t.length?(t=ve.from(t),!this.length&&t||t.length<jn&&this.leafAppend(t)||this.length<jn&&t.leafPrepend(this)||this.appendInner(t)):this};ve.prototype.prepend=function(t){return t.length?ve.from(t).append(this):this};ve.prototype.appendInner=function(t){return new td(this,t)};ve.prototype.slice=function(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.length),t>=n?ve.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,n))};ve.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)};ve.prototype.forEach=function(t,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(t,n,r,0):this.forEachInvertedInner(t,n,r,0)};ve.prototype.map=function(t,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,a){return s.push(t(i,a))},n,r),s};ve.from=function(t){return t instanceof ve?t:t&&t.length?new ha(t):ve.empty};var ha=(function(e){function t(r){e.call(this),this.values=r}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(s,i){return s==0&&i==this.length?this:new t(this.values.slice(s,i))},t.prototype.getInner=function(s){return this.values[s]},t.prototype.forEachInner=function(s,i,a,o){for(var c=i;c<a;c++)if(s(this.values[c],o+c)===!1)return!1},t.prototype.forEachInvertedInner=function(s,i,a,o){for(var c=i-1;c>=a;c--)if(s(this.values[c],o+c)===!1)return!1},t.prototype.leafAppend=function(s){if(this.length+s.length<=jn)return new t(this.values.concat(s.flatten()))},t.prototype.leafPrepend=function(s){if(this.length+s.length<=jn)return new t(s.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t})(ve);ve.empty=new ha([]);var td=(function(e){function t(n,r){e.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},t.prototype.forEachInner=function(r,s,i,a){var o=this.left.length;if(s<o&&this.left.forEachInner(r,s,Math.min(i,o),a)===!1||i>o&&this.right.forEachInner(r,Math.max(s-o,0),Math.min(this.length,i)-o,a+o)===!1)return!1},t.prototype.forEachInvertedInner=function(r,s,i,a){var o=this.left.length;if(s>o&&this.right.forEachInvertedInner(r,s-o,Math.max(i,o)-o,a+o)===!1||i<o&&this.left.forEachInvertedInner(r,Math.min(s,o),i,a)===!1)return!1},t.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(r,s):r>=i?this.right.slice(r-i,s-i):this.left.slice(r,i).append(this.right.slice(0,s-i))},t.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new t(this.left,s)},t.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new t(s,this.right)},t.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new t(this.left,new t(this.right,r)):new t(this,r)},t})(ve);const nd=500;class Re{constructor(t,n){this.items=t,this.eventCount=n}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,i;n&&(s=this.remapping(r,this.items.length),i=s.maps.length);let a=t.tr,o,c,d=[],u=[];return this.items.forEach((h,p)=>{if(!h.step){s||(s=this.remapping(r,p+1),i=s.maps.length),i--,u.push(h);return}if(s){u.push(new Ve(h.map));let m=h.step.map(s.slice(i)),v;m&&a.maybeStep(m).doc&&(v=a.mapping.maps[a.mapping.maps.length-1],d.push(new Ve(v,void 0,void 0,d.length+u.length))),i--,v&&s.appendMap(v,i)}else a.maybeStep(h.step);if(h.selection)return o=s?h.selection.map(s.slice(i)):h.selection,c=new Re(this.items.slice(0,r).append(u.reverse().concat(d)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:a,selection:o}}addTransform(t,n,r,s){let i=[],a=this.eventCount,o=this.items,c=!s&&o.length?o.get(o.length-1):null;for(let u=0;u<t.steps.length;u++){let h=t.steps[u].invert(t.docs[u]),p=new Ve(t.mapping.maps[u],h,n),m;(m=c&&c.merge(p))&&(p=m,u?i.pop():o=o.slice(0,o.length-1)),i.push(p),n&&(a++,n=void 0),s||(c=p)}let d=a-r.depth;return d>sd&&(o=rd(o,d),a-=d),new Re(o.append(i),a)}remapping(t,n){let r=new Sn;return this.items.forEach((s,i)=>{let a=s.mirrorOffset!=null&&i-s.mirrorOffset>=t?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,a)},t,n),r}addMaps(t){return this.eventCount==0?this:new Re(this.items.append(t.map(n=>new Ve(n))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-n),i=t.mapping,a=t.steps.length,o=this.eventCount;this.items.forEach(p=>{p.selection&&o--},s);let c=n;this.items.forEach(p=>{let m=i.getMirror(--c);if(m==null)return;a=Math.min(a,m);let v=i.maps[m];if(p.step){let b=t.steps[m].invert(t.docs[m]),x=p.selection&&p.selection.map(i.slice(c+1,m));x&&o++,r.push(new Ve(v,b,x))}else r.push(new Ve(v))},s);let d=[];for(let p=n;p<a;p++)d.push(new Ve(i.maps[p]));let u=this.items.slice(0,s).append(d).append(r),h=new Re(u,o);return h.emptyItemCount()>nd&&(h=h.compress(this.items.length-r.length)),h}emptyItemCount(){let t=0;return this.items.forEach(n=>{n.step||t++}),t}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,s=[],i=0;return this.items.forEach((a,o)=>{if(o>=t)s.push(a),a.selection&&i++;else if(a.step){let c=a.step.map(n.slice(r)),d=c&&c.getMap();if(r--,d&&n.appendMap(d,r),c){let u=a.selection&&a.selection.map(n.slice(r));u&&i++;let h=new Ve(d.invert(),c,u),p,m=s.length-1;(p=s.length&&s[m].merge(h))?s[m]=p:s.push(h)}}else a.map&&r--},this.items.length,0),new Re(ve.from(s.reverse()),i)}}Re.empty=new Re(ve.empty,0);function rd(e,t){let n;return e.forEach((r,s)=>{if(r.selection&&t--==0)return n=s,!1}),e.slice(n)}class Ve{constructor(t,n,r,s){this.map=t,this.step=n,this.selection=r,this.mirrorOffset=s}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new Ve(n.getMap().invert(),n,this.selection)}}}class Ze{constructor(t,n,r,s,i){this.done=t,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const sd=20;function id(e,t,n,r){let s=n.getMeta(pt),i;if(s)return s.historyState;n.getMeta(od)&&(e=new Ze(e.done,e.undone,null,0,-1));let a=n.getMeta("appendedTransaction");if(n.steps.length==0)return e;if(a&&a.getMeta(pt))return a.getMeta(pt).redo?new Ze(e.done.addTransform(n,void 0,r,bn(t)),e.undone,Ks(n.mapping.maps),e.prevTime,e.prevComposition):new Ze(e.done,e.undone.addTransform(n,void 0,r,bn(t)),null,e.prevTime,e.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(a&&a.getMeta("addToHistory")===!1)){let o=n.getMeta("composition"),c=e.prevTime==0||!a&&e.prevComposition!=o&&(e.prevTime<(n.time||0)-r.newGroupDelay||!ad(n,e.prevRanges)),d=a?ar(e.prevRanges,n.mapping):Ks(n.mapping.maps);return new Ze(e.done.addTransform(n,c?t.selection.getBookmark():void 0,r,bn(t)),Re.empty,d,n.time,o??e.prevComposition)}else return(i=n.getMeta("rebased"))?new Ze(e.done.rebased(n,i),e.undone.rebased(n,i),ar(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new Ze(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),ar(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function ad(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<t.length;i+=2)r<=t[i+1]&&s>=t[i]&&(n=!0)}),n}function Ks(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((r,s,i,a)=>t.push(i,a));return t}function ar(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let s=t.map(e[r],1),i=t.map(e[r+1],-1);s<=i&&n.push(s,i)}return n}function ld(e,t,n){let r=bn(t),s=pt.get(t).spec.config,i=(n?e.undone:e.done).popEvent(t,r);if(!i)return null;let a=i.selection.resolve(i.transform.doc),o=(n?e.done:e.undone).addTransform(i.transform,t.selection.getBookmark(),s,r),c=new Ze(n?o:i.remaining,n?i.remaining:o,null,0,-1);return i.transform.setSelection(a).setMeta(pt,{redo:n,historyState:c})}let lr=!1,Js=null;function bn(e){let t=e.plugins;if(Js!=t){lr=!1,Js=t;for(let n=0;n<t.length;n++)if(t[n].spec.historyPreserveItems){lr=!0;break}}return lr}const pt=new Xr("history"),od=new Xr("closeHistory");function cd(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new Un({key:pt,state:{init(){return new Ze(Re.empty,Re.empty,null,0,-1)},apply(t,n,r){return id(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(t,n){let r=n.inputType,s=r=="historyUndo"?pa:r=="historyRedo"?ga:null;return!s||!t.editable?!1:(n.preventDefault(),s(t.state,t.dispatch))}}}})}function ma(e,t){return(n,r)=>{let s=pt.getState(n);if(!s||(e?s.undone:s.done).eventCount==0)return!1;if(r){let i=ld(s,n,e);i&&r(t?i.scrollIntoView():i)}return!0}}const pa=ma(!1,!0),ga=ma(!0,!0),Ys=V.Extension.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>pa(e,t),redo:()=>({state:e,dispatch:t})=>ga(e,t)}},addProseMirrorPlugins(){return[cd(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),dd=V.Node.create({name:"doc",topNode:!0,content:"block+"}),ud=V.Node.create({name:"text",group:"inline"});function fd(e={}){return new Un({view(t){return new hd(t,e)}})}class hd{constructor(t,n){var r;this.editorView=t,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let i=a=>{this[s](a)};return t.dom.addEventListener(s,i),{name:s,handler:i}})}destroy(){this.handlers.forEach(({name:t,handler:n})=>this.editorView.dom.removeEventListener(t,n))}update(t,n){this.cursorPos!=null&&n.doc!=t.state.doc&&(this.cursorPos>t.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(t){t!=this.cursorPos&&(this.cursorPos=t,t==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let t=this.editorView.state.doc.resolve(this.cursorPos),n=!t.parent.inlineContent,r,s=this.editorView.dom,i=s.getBoundingClientRect(),a=i.width/s.offsetWidth,o=i.height/s.offsetHeight;if(n){let h=t.nodeBefore,p=t.nodeAfter;if(h||p){let m=this.editorView.nodeDOM(this.cursorPos-(h?h.nodeSize:0));if(m){let v=m.getBoundingClientRect(),b=h?v.bottom:v.top;h&&p&&(b=(b+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let x=this.width/2*o;r={left:v.left,right:v.right,top:b-x,bottom:b+x}}}}if(!r){let h=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*a;r={left:h.left-p,right:h.left+p,top:h.top,bottom:h.bottom}}let c=this.editorView.dom.offsetParent;this.element||(this.element=c.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let d,u;if(!c||c==document.body&&getComputedStyle(c).position=="static")d=-pageXOffset,u=-pageYOffset;else{let h=c.getBoundingClientRect(),p=h.width/c.offsetWidth,m=h.height/c.offsetHeight;d=h.left-c.scrollLeft*p,u=h.top-c.scrollTop*m}this.element.style.left=(r.left-d)/a+"px",this.element.style.top=(r.top-u)/o+"px",this.element.style.width=(r.right-r.left)/a+"px",this.element.style.height=(r.bottom-r.top)/o+"px"}scheduleRemoval(t){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),t)}dragover(t){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:t.clientX,top:t.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),s=r&&r.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,n,t):s;if(n&&!i){let a=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let o=da(this.editorView.state.doc,a,this.editorView.dragging.slice);o!=null&&(a=o)}this.setCursor(a),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){this.editorView.dom.contains(t.relatedTarget)||this.setCursor(null)}}const md=V.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[fd(this.options)]}});var st={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},An={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},pd=typeof navigator<"u"&&/Mac/.test(navigator.platform),gd=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var we=0;we<10;we++)st[48+we]=st[96+we]=String(we);for(var we=1;we<=24;we++)st[we+111]="F"+we;for(var we=65;we<=90;we++)st[we]=String.fromCharCode(we+32),An[we]=String.fromCharCode(we);for(var or in st)An.hasOwnProperty(or)||(An[or]=st[or]);function xd(e){var t=pd&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||gd&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",n=!t&&e.key||(e.shiftKey?An:st)[e.keyCode]||e.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const yd=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),bd=typeof navigator<"u"&&/Win/.test(navigator.platform);function vd(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n=="Space"&&(n=" ");let r,s,i,a;for(let o=0;o<t.length-1;o++){let c=t[o];if(/^(cmd|meta|m)$/i.test(c))a=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))s=!0;else if(/^s(hift)?$/i.test(c))i=!0;else if(/^mod$/i.test(c))yd?a=!0:s=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),a&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function wd(e){let t=Object.create(null);for(let n in e)t[vd(n)]=e[n];return t}function cr(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function kd(e){let t=wd(e);return function(n,r){let s=xd(r),i,a=t[cr(s,r)];if(a&&a(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let o=t[cr(s,r,!1)];if(o&&o(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(bd&&r.ctrlKey&&r.altKey)&&(i=st[r.keyCode])&&i!=s){let o=t[cr(i,r)];if(o&&o(n.state,n.dispatch,n))return!0}}return!1}}const bt=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},xa=function(e,t,n,r){return n&&(Gs(e,t,n,r,-1)||Gs(e,t,n,r,1))},Nd=/^(img|br|input|textarea|hr)$/i;function Gs(e,t,n,r,s){for(var i;;){if(e==n&&t==r)return!0;if(t==(s<0?0:Mn(e))){let a=e.parentNode;if(!a||a.nodeType!=1||es(e)||Nd.test(e.nodeName)||e.contentEditable=="false")return!1;t=bt(e)+(s<0?0:1),e=a}else if(e.nodeType==1){let a=e.childNodes[t+(s<0?-1:0)];if(a.nodeType==1&&a.contentEditable=="false")if(!((i=a.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)t+=s;else return!1;else e=a,t=s<0?Mn(e):0}else return!1}}function Mn(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function Sd(e,t,n){for(let r=t==0,s=t==Mn(e);r||s;){if(e==n)return!0;let i=bt(e);if(e=e.parentNode,!e)return!1;r=r&&i==0,s=s&&i==Mn(e)}}function es(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const ya=function(e){return e.focusNode&&xa(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function ba(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}const qe=typeof navigator<"u"?navigator:null,Qs=typeof document<"u"?document:null,it=qe&&qe.userAgent||"",Tr=/Edge\/(\d+)/.exec(it),va=/MSIE \d/.exec(it),Dr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(it),rn=!!(va||Dr||Tr),wa=va?document.documentMode:Dr?+Dr[1]:Tr?+Tr[1]:0,qn=!rn&&/gecko\/(\d+)/i.test(it);qn&&+(/Firefox\/(\d+)/.exec(it)||[0,0])[1];const Ir=!rn&&/Chrome\/(\d+)/.exec(it),Ye=!!Ir,ka=Ir?+Ir[1]:0,vt=!rn&&!!qe&&/Apple Computer/.test(qe.vendor),ts=vt&&(/Mobile\/\w+/.test(it)||!!qe&&qe.maxTouchPoints>2),Le=ts||(qe?/Mac/.test(qe.platform):!1),Na=qe?/Win/.test(qe.platform):!1,sn=/Android \d/.test(it),ns=!!Qs&&"webkitFontSmoothing"in Qs.documentElement.style,Cd=ns?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function jd(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let s=e.docView.nearestDesc(n.focusNode),i=s&&s.size==0,a=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(a<0)return null;let o=r.resolve(a),c,d;if(ya(n)){for(c=a;s&&!s.node;)s=s.parent;let h=s.node;if(s&&h.isAtom&&ee.isSelectable(h)&&s.parent&&!(h.isInline&&Sd(n.focusNode,n.focusOffset,s.dom))){let p=s.posBefore;d=new ee(a==p?o:r.resolve(p))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let h=a,p=a;for(let m=0;m<n.rangeCount;m++){let v=n.getRangeAt(m);h=Math.min(h,e.docView.posFromDOM(v.startContainer,v.startOffset,1)),p=Math.max(p,e.docView.posFromDOM(v.endContainer,v.endOffset,-1))}if(h<0)return null;[c,a]=p==e.state.selection.anchor?[p,h]:[h,p],o=r.resolve(a)}else c=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let u=r.resolve(c);if(!d){let h=t=="pointer"||e.state.selection.head<o.pos&&!i?1:-1;d=Ca(e,u,o,h)}return d}function Sa(e){return e.editable?e.hasFocus():Td(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function rs(e,t=!1){let n=e.state.selection;if(Ed(e,n),!!Sa(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&Ye){let r=e.domSelectionRange(),s=e.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&xa(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){e.input.mouseDown.delayedSelectionSync=!0,e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)Md(e);else{let{anchor:r,head:s}=n,i,a;Zs&&!(n instanceof ie)&&(n.$from.parent.inlineContent||(i=Xs(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(a=Xs(e,n.to))),e.docView.setSelection(r,s,e,t),Zs&&(i&&ei(i),a&&ei(a)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Ad(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}const Zs=vt||Ye&&ka<63;function Xs(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),s=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(vt&&s&&s.contentEditable=="false")return dr(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return dr(s);if(i)return dr(i)}}function dr(e){return e.contentEditable="true",vt&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function ei(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function Ad(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,s=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=s)&&(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!Sa(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}function Md(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName=="IMG";r?t.collapse(n.parentNode,bt(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&rn&&wa<=11&&(n.disabled=!0,n.disabled=!1)}function Ed(e,t){if(t instanceof ee){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(ti(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else ti(e)}function ti(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function Ca(e,t,n,r){return e.someProp("createSelectionBetween",s=>s(e,t,n))||ie.between(t,n,r)}function Td(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function $r(e,t){let{$anchor:n,$head:r}=e.selection,s=t>0?n.max(r):n.min(r),i=s.parent.inlineContent?s.depth?e.doc.resolve(t>0?s.after():s.before()):null:s;return i&&ae.findFrom(i,t)}function Xe(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function ni(e,t,n){let r=e.state.selection;if(r instanceof ie)if(n.indexOf("s")>-1){let{$head:s}=r,i=s.textOffset?null:t<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let a=e.state.doc.resolve(s.pos+i.nodeSize*(t<0?-1:1));return Xe(e,new ie(r.$anchor,a))}else if(r.empty){if(e.endOfTextblock(t>0?"forward":"backward")){let s=$r(e.state,t);return s&&s instanceof ee?Xe(e,s):!1}else if(!(Le&&n.indexOf("m")>-1)){let s=r.$head,i=s.textOffset?null:t<0?s.nodeBefore:s.nodeAfter,a;if(!i||i.isText)return!1;let o=t<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(a=e.docView.descAt(o))&&!a.contentDOM?ee.isSelectable(i)?Xe(e,new ee(t<0?e.state.doc.resolve(s.pos-i.nodeSize):s)):ns?Xe(e,new ie(e.state.doc.resolve(t<0?o:o+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof ee&&r.node.isInline)return Xe(e,new ie(t>0?r.$to:r.$from));{let s=$r(e.state,t);return s?Xe(e,s):!1}}}function En(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function qt(e,t){let n=e.pmViewDesc;return n&&n.size==0&&(t<0||e.nextSibling||e.nodeName!="BR")}function kt(e,t){return t<0?Dd(e):Id(e)}function Dd(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let s,i,a=!1;for(qn&&n.nodeType==1&&r<En(n)&&qt(n.childNodes[r],-1)&&(a=!0);;)if(r>0){if(n.nodeType!=1)break;{let o=n.childNodes[r-1];if(qt(o,-1))s=n,i=--r;else if(o.nodeType==3)n=o,r=n.nodeValue.length;else break}}else{if(ja(n))break;{let o=n.previousSibling;for(;o&&qt(o,-1);)s=n.parentNode,i=bt(o),o=o.previousSibling;if(o)n=o,r=En(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}a?Or(e,n,r):s&&Or(e,s,i)}function Id(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let s=En(n),i,a;for(;;)if(r<s){if(n.nodeType!=1)break;let o=n.childNodes[r];if(qt(o,1))i=n,a=++r;else break}else{if(ja(n))break;{let o=n.nextSibling;for(;o&&qt(o,1);)i=o.parentNode,a=bt(o)+1,o=o.nextSibling;if(o)n=o,r=0,s=En(n);else{if(n=n.parentNode,n==e.dom)break;r=s=0}}}i&&Or(e,i,a)}function ja(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function $d(e,t){for(;e&&t==e.childNodes.length&&!es(e);)t=bt(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;e=n,t=0}}function Od(e,t){for(;e&&!t&&!es(e);)t=bt(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;e=n,t=e.childNodes.length}}function Or(e,t,n){if(t.nodeType!=3){let i,a;(a=$d(t,n))?(t=a,n=0):(i=Od(t,n))&&(t=i,n=i.nodeValue.length)}let r=e.domSelection();if(!r)return;if(ya(r)){let i=document.createRange();i.setEnd(t,n),i.setStart(t,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:s}=e;setTimeout(()=>{e.state==s&&rs(e)},50)}function ri(e,t){let n=e.state.doc.resolve(t);if(!(Ye||Na)&&n.parent.inlineContent){let s=e.coordsAtPos(t);if(t>n.start()){let i=e.coordsAtPos(t-1),a=(i.top+i.bottom)/2;if(a>s.top&&a<s.bottom&&Math.abs(i.left-s.left)>1)return i.left<s.left?"ltr":"rtl"}if(t<n.end()){let i=e.coordsAtPos(t+1),a=(i.top+i.bottom)/2;if(a>s.top&&a<s.bottom&&Math.abs(i.left-s.left)>1)return i.left>s.left?"ltr":"rtl"}}return getComputedStyle(e.dom).direction=="rtl"?"rtl":"ltr"}function si(e,t,n){let r=e.state.selection;if(r instanceof ie&&!r.empty||n.indexOf("s")>-1||Le&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let a=$r(e.state,t);if(a&&a instanceof ee)return Xe(e,a)}if(!s.parent.inlineContent){let a=t<0?s:i,o=r instanceof Ue?ae.near(a,t):ae.findFrom(a,t);return o?Xe(e,o):!1}return!1}function ii(e,t){if(!(e.state.selection instanceof ie))return!0;let{$head:n,$anchor:r,empty:s}=e.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let i=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let a=e.state.tr;return t<0?a.delete(n.pos-i.nodeSize,n.pos):a.delete(n.pos,n.pos+i.nodeSize),e.dispatch(a),!0}return!1}function ai(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Ld(e){if(!vt||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&t.nodeType==1&&n==0&&t.firstChild&&t.firstChild.contentEditable=="false"){let r=t.firstChild;ai(e,r,"true"),setTimeout(()=>ai(e,r,"false"),20)}return!1}function Fd(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}function Pd(e,t){let n=t.keyCode,r=Fd(t);if(n==8||Le&&n==72&&r=="c")return ii(e,-1)||kt(e,-1);if(n==46&&!t.shiftKey||Le&&n==68&&r=="c")return ii(e,1)||kt(e,1);if(n==13||n==27)return!0;if(n==37||Le&&n==66&&r=="c"){let s=n==37?ri(e,e.state.selection.from)=="ltr"?-1:1:-1;return ni(e,s,r)||kt(e,s)}else if(n==39||Le&&n==70&&r=="c"){let s=n==39?ri(e,e.state.selection.from)=="ltr"?1:-1:1;return ni(e,s,r)||kt(e,s)}else{if(n==38||Le&&n==80&&r=="c")return si(e,-1,r)||kt(e,-1);if(n==40||Le&&n==78&&r=="c")return Ld(e)||si(e,1,r)||kt(e,1);if(r==(Le?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Aa(e,t){e.someProp("transformCopied",m=>{t=m(t,e)});let n=[],{content:r,openStart:s,openEnd:i}=t;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let m=r.firstChild;n.push(m.type.name,m.attrs!=m.type.defaultAttrs?m.attrs:null),r=m.content}let a=e.someProp("clipboardSerializer")||Vn.fromSchema(e.state.schema),o=$a(),c=o.createElement("div");c.appendChild(a.serializeFragment(r,{document:o}));let d=c.firstChild,u,h=0;for(;d&&d.nodeType==1&&(u=Ia[d.nodeName.toLowerCase()]);){for(let m=u.length-1;m>=0;m--){let v=o.createElement(u[m]);for(;c.firstChild;)v.appendChild(c.firstChild);c.appendChild(v),h++}d=c.firstChild}d&&d.nodeType==1&&d.setAttribute("data-pm-slice",`${s} ${i}${h?` -${h}`:""} ${JSON.stringify(n)}`);let p=e.someProp("clipboardTextSerializer",m=>m(t,e))||t.content.textBetween(0,t.content.size,`
17
17
 
18
- `);return{dom:l,text:p,slice:e}}function Bi(t,e,n,r,s){let i=s.parent.type.spec.code,o,a;if(!n&&!e)return null;let l=!!e&&(r||i||!n);if(l){if(t.someProp("transformPastedText",p=>{e=p(e,i||r,t)}),i)return a=new W(K.from(t.state.schema.text(e.replace(/\r\n?/g,`
19
- `))),0,0),t.someProp("transformPasted",p=>{a=p(a,t,!0)}),a;let f=t.someProp("clipboardTextParser",p=>p(e,s,r,t));if(f)a=f;else{let p=s.marks(),{schema:h}=t.state,k=yn.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(v=>{let y=o.appendChild(document.createElement("p"));v&&y.appendChild(k.serializeNode(h.text(v,p)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),o=kc(n),Ar&&Sc(o);let d=o&&o.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=o.firstChild;for(;p&&p.nodeType!=1;)p=p.nextSibling;if(!p)break;o=p}if(a||(a=(t.someProp("clipboardParser")||t.someProp("domParser")||rn.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(l||u),context:s,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!yc.test(p.parentNode.nodeName)?{ignore:!0}:null}})),u)a=Cc(Ds(a,+u[1],+u[2]),u[4]);else if(a=W.maxOpen(bc(a.content,s),!0),a.openStart||a.openEnd){let f=0,p=0;for(let h=a.content.firstChild;f<a.openStart&&!h.type.spec.isolating;f++,h=h.firstChild);for(let h=a.content.lastChild;p<a.openEnd&&!h.type.spec.isolating;p++,h=h.lastChild);a=Ds(a,f,p)}return t.someProp("transformPasted",f=>{a=f(a,t,l)}),a}const yc=/^(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 bc(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(a=>{if(!o)return;let l=s.findWrapping(a.type),d;if(!l)return o=null;if(d=o.length&&i.length&&_i(l,i,a,o[o.length-1],0))o[o.length-1]=d;else{o.length&&(o[o.length-1]=Hi(o[o.length-1],i.length));let u=zi(a,l);o.push(u),s=s.matchType(u.type),i=l}}),o)return K.from(o)}return t}function zi(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,K.from(t));return t}function _i(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let i=_i(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(K.from(zi(n,t,s+1))))}}function Hi(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Hi(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(K.empty,!0);return t.copy(n.append(r))}function lr(t,e,n,r,s,i){let o=e<0?t.firstChild:t.lastChild,a=o.content;return t.childCount>1&&(i=0),s<r-1&&(a=lr(a,e,n,r,s+1,i)),s>=n&&(a=e<0?o.contentMatchAt(0).fillBefore(a,i<=s).append(a):a.append(o.contentMatchAt(o.childCount).fillBefore(K.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(a))}function Ds(t,e,n){return e<t.openStart&&(t=new W(lr(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new W(lr(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Ui={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 Is=null;function qi(){return Is||(Is=document.implementation.createHTMLDocument("title"))}let Un=null;function vc(t){let e=window.trustedTypes;return e?(Un||(Un=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Un.createHTML(t)):t}function kc(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=qi().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),s;if((s=r&&Ui[r[1].toLowerCase()])&&(t=s.map(i=>"<"+i+">").join("")+t+s.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=vc(t),s)for(let i=0;i<s.length;i++)n=n.querySelector(s[i])||n;return n}function Sc(t){let e=t.querySelectorAll(We?"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 Cc(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 a=r.length-2;a>=0;a-=2){let l=n.nodes[r[a]];if(!l||l.hasRequiredAttrs())break;s=K.from(l.create(r[a+1],s)),i++,o++}return new W(s,i,o)}const Ve={},Me={};function Qe(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}Me.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Wi(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(qt&&We&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Nr&&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,Oi(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||xc(t,n)?n.preventDefault():Qe(t,"key")};Me.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Me.keypress=(t,e)=>{let n=e;if(Wi(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||De&&n.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof X)||!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 Sn(t){return{left:t.clientX,top:t.clientY}}function wc(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Er(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,a=>o>i.depth?a(t,n,i.nodeAfter,i.before(o),s,!0):a(t,n,i.node(o),i.before(o),s,!1)))return!0;return!1}function Ct(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function Nc(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&J.isSelectable(r)?(Ct(t,new J(n)),!0):!1}function Ac(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof J&&(r=n.node);let i=t.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let a=o>i.depth?i.nodeAfter:i.node(o);if(J.isSelectable(a)){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?(Ct(t,J.create(t.state.doc,s)),!0):!1}function jc(t,e,n,r,s){return Er(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(s?Ac(t,n):Nc(t,n))}function Ec(t,e,n,r){return Er(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function Tc(t,e,n,r){return Er(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||Mc(t,n,r)}function Mc(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Ct(t,X.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),a=s.before(i);if(o.inlineContent)Ct(t,X.create(r,a+1,a+1+o.content.size));else if(J.isSelectable(o))Ct(t,J.create(r,a));else continue;return!0}}function Tr(t){return un(t)}const Ki=De?"metaKey":"ctrlKey";Ve.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Tr(t),s=Date.now(),i="singleClick";s-t.input.lastClick.time<500&&wc(n,t.input.lastClick)&&!n[Ki]&&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(Sn(n));o&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new Oc(t,o,n,!!r)):(i=="doubleClick"?Ec:Tc)(t,o.pos,o.inside,n)?n.preventDefault():Qe(t,"pointer"))};class Oc{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[Ki],this.allowDefault=r.shiftKey;let i,o;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),o=n.inside;else{let u=e.state.doc.resolve(n.pos);i=u.parent,o=u.depth?u.before():0}const a=s?null:r.target,l=a?e.docView.nearestDesc(a,!0):null;this.target=l&&l.nodeDOM.nodeType==1?l.nodeDOM:null;let{selection:d}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||d instanceof J&&d.from<=o&&d.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&kn&&!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)),Qe(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(()=>jr(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(Sn(e))),this.updateAllowDefault(e),this.allowDefault||!n?Qe(this.view,"pointer"):jc(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||mt&&this.mightDrag&&!this.mightDrag.node.isAtom||We&&!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,ee.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Qe(this.view,"pointer")}move(e){this.updateAllowDefault(e),Qe(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(),Tr(t),Qe(t,"pointer")};Ve.touchmove=t=>{t.input.lastTouch=Date.now(),Qe(t,"pointer")};Ve.contextmenu=t=>Tr(t);function Wi(t,e){return t.composing?!0:mt&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const Dc=qt?5e3:-1;Me.compositionstart=Me.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof X&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||We&&Fi&&Ic(t)))t.markCursor=t.state.storedMarks||n.marks(),un(t,!0),t.markCursor=null;else if(un(t,!e.selection.empty),kn&&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 a=t.domSelection();a&&a.collapse(o,o.nodeValue.length);break}else s=o,i=-1}}t.input.composing=!0}Ji(t,Dc)};function Ic(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"}Me.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++,Ji(t,20))};function Ji(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>un(t),e))}function Lc(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Fc());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function Fc(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function un(t,e=!1){if(!(qt&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Lc(t),e||t.docView&&t.docView.dirty){let n=oc(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 zt=Ut&&Ii<15||Nr&&ic<604;Ve.copy=Me.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let i=zt?null:n.clipboardData,o=r.content(),{dom:a,text:l}=Vi(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",a.innerHTML),i.setData("text/plain",l)):Pc(t,a),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Rc(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function $c(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?cr(t,r.value,null,s,e):cr(t,r.textContent,r.innerHTML,s,e)},50)}function cr(t,e,n,r,s){let i=Bi(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",l=>l(t,s,i||W.empty)))return!0;if(!i)return!1;let o=Rc(i),a=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(i);return t.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Gi(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," "):""}Me.paste=(t,e)=>{let n=e;if(t.composing&&!qt)return;let r=zt?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&cr(t,Gi(r),r.getData("text/html"),s,n)?n.preventDefault():$c(t,n)};class Vc{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const Bc=De?"altKey":"ctrlKey";function Zi(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[Bc]}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(Sn(n)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof J?s.to-1:s.to))){if(r&&r.mightDrag)o=J.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=J.create(t.state.doc,f.posBefore))}}let a=(o||t.state.selection).content(),{dom:l,text:d,slice:u}=Vi(t,a);(!n.dataTransfer.files.length||!We||Li>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(zt?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",zt||n.dataTransfer.setData("text/plain",d),t.dragging=new Vc(u,Zi(t,n),o)};Ve.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Me.dragover=Me.dragenter=(t,e)=>e.preventDefault();Me.drop=(t,e)=>{try{zc(t,e,t.dragging)}finally{t.dragging=null}};function zc(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(Sn(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=Bi(t,Gi(e.dataTransfer),zt?null:e.dataTransfer.getData("text/html"),!1,s);let o=!!(n&&Zi(t,e));if(t.someProp("handleDrop",h=>h(t,e,i||W.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let a=i?Si(t.state.doc,s.pos,i):s.pos;a==null&&(a=s.pos);let l=t.state.tr;if(o){let{node:h}=n;h?h.replace(l):l.deleteSelection()}let d=l.mapping.map(a),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,f=l.doc;if(u?l.replaceRangeWith(d,d,i.content.firstChild):l.replaceRange(d,d,i),l.doc.eq(f))return;let p=l.doc.resolve(d);if(u&&J.isSelectable(i.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(i.content.firstChild))l.setSelection(new J(p));else{let h=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((k,v,y,S)=>h=S),l.setSelection(Ri(t,p,l.doc.resolve(h)))}t.focus(),t.dispatch(l.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())&&jr(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(We&&qt&&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,Oi(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 Me)Ve[t]=Me[t];function _t(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 fn{constructor(e,n){this.toDOM=e,this.spec=n||ut,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 ze(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof fn&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&_t(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Xe{constructor(e,n){this.attrs=e,this.spec=n||ut}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 ze(i,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Xe&&_t(this.attrs,e.attrs)&&_t(this.spec,e.spec)}static is(e){return e.type instanceof Xe}destroy(){}}class Mr{constructor(e,n){this.attrs=e,this.spec=n||ut}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 ze(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 Mr&&_t(this.attrs,e.attrs)&&_t(this.spec,e.spec)}destroy(){}}class ze{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new ze(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 ze(e,e,new fn(n,r))}static inline(e,n,r,s){return new ze(e,n,new Xe(r,s))}static node(e,n,r,s){return new ze(e,n,new Mr(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof Xe}get widget(){return this.type instanceof fn}}const vt=[],ut={};class me{constructor(e,n){this.local=e.length?e:vt,this.children=n.length?n:vt}static create(e,n){return n.length?hn(n,e,0,ut):Ce}find(e,n,r){let s=[];return this.findInner(e??0,n??1e9,s,0,r),s}findInner(e,n,r,s,i){for(let o=0;o<this.local.length;o++){let a=this.local[o];a.from<=n&&a.to>=e&&(!i||i(a.spec))&&r.push(a.copy(a.from+s,a.to+s))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<n&&this.children[o+1]>e){let a=this.children[o]+1;this.children[o+2].findInner(e-a,n-a,r,s+a,i)}}map(e,n,r){return this==Ce||e.maps.length==0?this:this.mapInner(e,n,0,0,r||ut)}mapInner(e,n,r,s,i){let o;for(let a=0;a<this.local.length;a++){let l=this.local[a].map(e,r,s);l&&l.type.valid(n,l)?(o||(o=[])).push(l):i.onRemove&&i.onRemove(this.local[a].spec)}return this.children.length?_c(this.children,o||[],e,n,r,s,i):o?new me(o.sort(ft),vt):Ce}add(e,n){return n.length?this==Ce?me.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,i=0;e.forEach((a,l)=>{let d=l+r,u;if(u=Qi(n,a,d)){for(s||(s=this.children.slice());i<s.length&&s[i]<l;)i+=3;s[i]==l?s[i+2]=s[i+2].addInner(a,u,d+1):s.splice(i,0,l,l+a.nodeSize,hn(u,a,d+1,ut)),i+=3}});let o=Yi(i?Xi(n):n,-r);for(let a=0;a<o.length;a++)o[a].type.valid(e,o[a])||o.splice(a--,1);return new me(o.length?this.local.concat(o).sort(ft):this.local,s||this.children)}remove(e){return e.length==0||this==Ce?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let o,a=r[i]+n,l=r[i+1]+n;for(let u=0,f;u<e.length;u++)(f=e[u])&&f.from>a&&f.to<l&&(e[u]=null,(o||(o=[])).push(f));if(!o)continue;r==this.children&&(r=this.children.slice());let d=r[i+2].removeInner(o,a+1);d!=Ce?r[i+2]=d:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,o;i<e.length;i++)if(o=e[i])for(let a=0;a<s.length;a++)s[a].eq(o,n)&&(s==this.local&&(s=this.local.slice()),s.splice(a--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new me(s,r):Ce}forChild(e,n){if(this==Ce)return this;if(n.isLeaf)return me.empty;let r,s;for(let a=0;a<this.children.length;a+=3)if(this.children[a]>=e){this.children[a]==e&&(r=this.children[a+2]);break}let i=e+1,o=i+n.content.size;for(let a=0;a<this.local.length;a++){let l=this.local[a];if(l.from<o&&l.to>i&&l.type instanceof Xe){let d=Math.max(i,l.from)-i,u=Math.min(o,l.to)-i;d<u&&(s||(s=[])).push(l.copy(d,u))}}if(s){let a=new me(s.sort(ft),vt);return r?new it([a,r]):a}return r||Ce}eq(e){if(this==e)return!0;if(!(e instanceof me)||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 Or(this.localsInner(e))}localsInner(e){if(this==Ce)return vt;if(e.inlineContent||!this.local.some(Xe.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Xe||n.push(this.local[r]);return n}forEachSet(e){e(this)}}me.empty=new me([],[]);me.removeOverlap=Or;const Ce=me.empty;class it{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,ut));return it.from(r)}forChild(e,n){if(n.isLeaf)return me.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,n);i!=Ce&&(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?Or(r?n:n.sort(ft)):vt}static from(e){switch(e.length){case 0:return Ce;case 1:return e[0];default:return new it(e.every(n=>n instanceof me)?e:e.reduce((n,r)=>n.concat(r instanceof me?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function _c(t,e,n,r,s,i,o){let a=t.slice();for(let d=0,u=i;d<n.maps.length;d++){let f=0;n.maps[d].forEach((p,h,k,v)=>{let y=v-k-(h-p);for(let S=0;S<a.length;S+=3){let N=a[S+1];if(N<0||p>N+u-f)continue;let j=a[S]+u-f;h>=j?a[S+1]=p<=j?-2:-1:p>=u&&y&&(a[S]+=y,a[S+1]+=y)}f+=y}),u=n.maps[d].map(u,-1)}let l=!1;for(let d=0;d<a.length;d+=3)if(a[d+1]<0){if(a[d+1]==-2){l=!0,a[d+1]=-1;continue}let u=n.map(t[d]+i),f=u-s;if(f<0||f>=r.content.size){l=!0;continue}let p=n.map(t[d+1]+i,-1),h=p-s,{index:k,offset:v}=r.content.findIndex(f),y=r.maybeChild(k);if(y&&v==f&&v+y.nodeSize==h){let S=a[d+2].mapInner(n,y,u+1,t[d]+i+1,o);S!=Ce?(a[d]=f,a[d+1]=h,a[d+2]=S):(a[d+1]=-2,l=!0)}else l=!0}if(l){let d=Hc(a,t,e,n,s,i,o),u=hn(d,r,0,o);e=u.local;for(let f=0;f<a.length;f+=3)a[f+1]<0&&(a.splice(f,3),f-=3);for(let f=0,p=0;f<u.children.length;f+=3){let h=u.children[f];for(;p<a.length&&a[p]<h;)p+=3;a.splice(p,0,u.children[f],u.children[f+1],u.children[f+2])}}return new me(e.sort(ft),a)}function Yi(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 ze(s.from+e,s.to+e,s.type))}return n}function Hc(t,e,n,r,s,i,o){function a(l,d){for(let u=0;u<l.local.length;u++){let f=l.local[u].map(r,s,d);f?n.push(f):o.onRemove&&o.onRemove(l.local[u].spec)}for(let u=0;u<l.children.length;u+=3)a(l.children[u+2],l.children[u]+d+1)}for(let l=0;l<t.length;l+=3)t[l+1]==-1&&a(t[l+2],e[l]+i+1);return n}function Qi(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 Xi(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function hn(t,e,n,r){let s=[],i=!1;e.forEach((a,l)=>{let d=Qi(t,a,l+n);if(d){i=!0;let u=hn(d,a,n+l+1,r);u!=Ce&&s.push(l,l+a.nodeSize,u)}});let o=Yi(i?Xi(t):t,-n).sort(ft);for(let a=0;a<o.length;a++)o[a].type.valid(e,o[a])||(r.onRemove&&r.onRemove(o[a].spec),o.splice(a--,1));return o.length||s.length?new me(o,s):Ce}function ft(t,e){return t.from-e.from||t.to-e.to}function Or(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),Ls(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),Ls(e,s,r.copy(i.from,r.to)));break}}}return e}function Ls(t,e,n){for(;e<t.length&&ft(n,t[e])>0;)e++;t.splice(e,0,n)}class le extends ee{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return le.valid(r)?new le(r):ee.near(r)}content(){return W.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 Dr(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!Uc(e)||!qc(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 a=e.node(o);if(n>0?e.indexAfter(o)<a.childCount:e.index(o)>0){i=a.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=n;let l=e.doc.resolve(s);if(le.valid(l))return l}for(;;){let o=n>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!J.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*n),r=!1;continue e}break}i=o,s+=n;let a=e.doc.resolve(s);if(le.valid(a))return a}return null}}}le.prototype.visible=!1;le.findFrom=le.findGapCursorFrom;ee.jsonID("gapcursor",le);class Dr{constructor(e){this.pos=e}map(e){return new Dr(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return le.valid(n)?new le(n):ee.near(n)}}function eo(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function Uc(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||eo(s.type))return!0;if(s.inlineContent)return!1}}return!0}function qc(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||eo(s.type))return!0;if(s.inlineContent)return!1}}return!0}function Kc(){return new vn({props:{decorations:Zc,createSelectionBetween(t,e,n){return e.pos==n.pos&&le.valid(n)?new le(n):null},handleClick:Jc,handleKeyDown:Wc,handleDOMEvents:{beforeinput:Gc}}})}const Wc=nc({ArrowLeft:Zt("horiz",-1),ArrowRight:Zt("horiz",1),ArrowUp:Zt("vert",-1),ArrowDown:Zt("vert",1)});function Zt(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let o=r.selection,a=e>0?o.$to:o.$from,l=o.empty;if(o instanceof X){if(!i.endOfTextblock(n)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let d=le.findGapCursorFrom(a,e,l);return d?(s&&s(r.tr.setSelection(new le(d))),!0):!1}}function Jc(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&&J.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new le(r))),!0)}function Gc(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=K.empty;for(let o=r.length-1;o>=0;o--)s=K.from(r[o].createAndFill(null,s));let i=t.state.tr.replace(n.pos,n.pos,new W(s,0,0));return i.setSelection(X.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function Zc(t){if(!(t.selection instanceof le))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",me.create(t.doc,[ze.widget(t.selection.head,e,{key:"gapcursor"})])}const Yc=$.Extension.create({name:"gapCursor",addProseMirrorPlugins(){return[Kc()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=$.callOrReturn($.getExtensionField(t,"allowGapCursor",n)))!==null&&e!==void 0?e:null}}}),jt={bold:{category:"mark",extension:Ga,priority:100},italic:{category:"mark",extension:el,priority:100},strike:{category:"mark",extension:rl,priority:100},underline:{category:"mark",extension:ca.Underline,priority:100},code:{category:"mark",extension:ol,priority:100},textColor:{category:"mark",extension:da.Color,defaultOptions:{types:["textStyle","heading","paragraph","listItem","taskItem","blockquote"]},priority:90},highlight:{category:"mark",extension:ua.Highlight,defaultOptions:{multicolor:!0},priority:90},link:{category:"mark",extension:fa.Link,defaultOptions:{autolink:!0,linkOnPaste:!0,openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}},priority:100},heading:{category:"node",extension:cl,defaultOptions:{levels:[1,2,3,4,5,6]},priority:100},bulletList:{category:"node",extension:fl,defaultOptions:{HTMLAttributes:{class:"list-disc"}},priority:90},orderedList:{category:"node",extension:pl,defaultOptions:{HTMLAttributes:{class:"list-decimal"}},priority:90},taskList:{category:"node",extension:ha.TaskList,defaultOptions:{HTMLAttributes:{class:"task-list"}},priority:90},codeBlock:{category:"node",extension:Ml,priority:100},blockquote:{category:"node",extension:Dl,priority:100},horizontalRule:{category:"node",extension:Il,priority:100},hardBreak:{category:"node",extension:Ll,priority:100},undo:{category:"extension",extension:vs,priority:50},redo:{category:"extension",extension:vs,priority:50},textAlign:{category:"extension",extension:ma.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}},Qc=[Ul,ql,dl,ll.configure({HTMLAttributes:{}}),ml.configure({HTMLAttributes:{}}),pa.TaskItem.configure({nested:!0}),Jl,Yc];function Xc(t){const e=[],n=new Set,r=new Set;Qc.forEach(a=>{a&&(e.push(a),r.add(a.name))});const s=t.map(a=>Rt(a)),i=new Set;return s.forEach(a=>{const l=jt[a];l?.requiredExtensions&&l.requiredExtensions.forEach(d=>{i.add(d)})}),i.forEach(a=>{if(n.has(a))return;const l=jt[a];if(!l||l.extension===null)return;const d=l.extension.name;if(r.has(d)){n.add(a);return}const u=l.defaultOptions?l.extension.configure(l.defaultOptions):l.extension;e.push(u),n.add(a),r.add(d)}),s.forEach(a=>{if(n.has(a))return;const l=jt[a];if(!l){console.warn(`Extension config not found for modifier: ${a}`);return}if(l.extension===null){n.add(a);return}const d=l.extension.name;if(r.has(d)){n.add(a);return}const u=l.defaultOptions?l.extension.configure(l.defaultOptions):l.extension;e.push(u),n.add(a),r.add(d)}),e.sort((a,l)=>{const d=Object.values(jt).find(h=>h?.extension?.name===a.name),u=Object.values(jt).find(h=>h?.extension?.name===l.name),f=d?.priority??100;return(u?.priority??100)-f})}const to={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"]},oe={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"}}},se={xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem"},ed={h1:`font-size: ${oe.fontSize["4xl"]}; font-weight: ${oe.fontWeight.semibold}; line-height: ${oe.lineHeight.tight}; margin: ${se.md} 0 ${se.sm} 0;`,h2:`font-size: ${oe.fontSize["2xl"]}; font-weight: ${oe.fontWeight.semibold}; line-height: ${oe.lineHeight.tight}; margin: ${se.md} 0 ${se.sm} 0;`,h3:`font-size: ${oe.fontSize.xl}; font-weight: ${oe.fontWeight.semibold}; line-height: ${oe.lineHeight.tight}; margin: ${se.md} 0 ${se.sm} 0;`,h4:`font-size: ${oe.fontSize.lg}; font-weight: ${oe.fontWeight.semibold}; line-height: ${oe.lineHeight.tight}; margin: ${se.md} 0 ${se.sm} 0;`,h5:`font-size: ${oe.fontSize.base}; font-weight: ${oe.fontWeight.semibold}; line-height: ${oe.lineHeight.tight}; margin: ${se.md} 0 ${se.sm} 0;`,h6:`font-size: ${oe.fontSize.sm}; font-weight: ${oe.fontWeight.semibold}; line-height: ${oe.lineHeight.tight}; margin: ${se.md} 0 ${se.sm} 0;`,p:`min-height: ${oe.lineHeight.normal}em; margin: 0;`,ul:`list-style-type: disc; list-style-position: outside; padding-left: ${se.xl}; margin: ${se.md} 0;`,ol:`list-style-type: decimal; list-style-position: outside; padding-left: ${se.xl}; margin: ${se.md} 0;`,li:`display: list-item; margin: ${se.xs} 0;`,strong:`font-weight: ${oe.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: ${oe.fontSize.sm}; padding: 0.25em 0.3em; font-family: ${oe.fontFamily.mono};`,pre:`background: ${Ge.neutral.gray[800]}; border-radius: ${se.sm}; color: ${Ge.neutral.gray[100]}; font-family: ${oe.fontFamily.mono}; margin: ${se.lg} 0; padding: 0.75rem ${se.md}; overflow-x: auto;`,blockquote:`border-left: 3px solid ${Ge.neutral.gray[300]}; margin: ${se.lg} 0; padding-left: ${se.md}; color: ${Ge.neutral.gray[500]};`,hr:`border: none; border-top: 1px solid ${Ge.neutral.gray[200]}; margin: ${se.xl} 0;`,a:`color: ${Ge.brand.primary.DEFAULT}; text-decoration: underline; cursor: pointer;`,mark:`background-color: ${Ge.palettes.warning[200]}; border-radius: ${se.xs}; padding: 0 0.125rem;`,label:`display: flex; align-items: center; gap: ${se.sm}; cursor: pointer;`,input:"cursor: pointer; margin: 0;"},td={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 nd(t){if(!t)return t;let e=t;for(const[n,r]of Object.entries(td)){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(ed)){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 rd=({modifiers:t,zoom:e,onZoomChange:n,onToolbarAction:r})=>{const{editor:s}=yr.useCurrentEditor();return c.jsx(Ua,{editor:s,modifiers:t,zoom:e,onZoomChange:n,onToolbarAction:r})},sd=({showCharacterCount:t,showWordCount:e})=>{const{editor:n}=yr.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"]})]})},dr=x.forwardRef((t,e)=>{const{minRows:n=10,maxRows:r=30,disableAutosize:s=!1,showCharacterCount:i=!1,showWordCount:o=!1,showToolbar:a=!0,modifiers:l=to.full,variant:d="bordered",initialContent:u,content:f,onContentChange:p,onUpdate:h,onToolbarAction:k,isReadOnly:v=!1,isDisabled:y=!1,includeInlineStyles:S=!0,...N}=t,{zoom:j,setZoom:w}=za(),A=ts.lineHeight,T=n*A,I=s?void 0:r*A,z=x.useMemo(()=>Xc(l),[l]),{Component:B,label:H,shouldLabelBeOutside:O,getBaseProps:M,getLabelProps:L,getInputWrapperProps:R}=g.useInput({...N,variant:d,ref:e,isMultiline:!0}),U=H?c.jsx("label",{...L(),children:H}):null,Z=x.useCallback(({editor:q})=>{const de=q.getHTML(),ce=S?nd(de):de,xe=q.getJSON(),Le=q.getText(),te=Le.length,Oe=Le.split(/\s+/).filter(Ae=>Ae.length>0).length,ne={html:ce,json:xe,text:Le,characters:te,words:Oe};if(p?.(ne),h?.(ne),"onChange"in N&&typeof N.onChange=="function"){const Ae={target:{value:ce},currentTarget:{value:ce}};N.onChange(Ae)}},[p,h,N,S]);return c.jsxs(B,{...M(),children:[O?U:null,c.jsx("div",{...R(),className:g.cn(R().className,"flex flex-col w-full p-0 gap-0 rich-text-editor"),style:{maxHeight:I?`${I+ts.toolbarHeight}px`:void 0,overflow:I?"auto":void 0},children:c.jsx(yr.EditorProvider,{editable:!v&&!y,slotBefore:a?c.jsx(rd,{modifiers:l,zoom:j,onZoomChange:w,onToolbarAction:k}):void 0,slotAfter:c.jsx(sd,{showCharacterCount:i,showWordCount:o}),editorContainerProps:{className:"w-full flex-1 outline-none",style:{minHeight:`${T}px`,fontSize:`${j}%`,display:"flex",flexDirection:"column"}},editorProps:{attributes:{class:"focus:outline-none w-full h-full"}},extensions:z,content:f||u||t.defaultValue||"",onUpdate:Z})})]})});dr.displayName="TipTapEditor";const no=x.forwardRef((t,e)=>{const{adapter:n="tiptap",variant:r="bordered",...s}=t;return n==="tiptap"?c.jsx(dr,{...s,variant:r,ref:e}):(console.warn(`Adapter "${n}" is not supported. Using TipTap.`),c.jsx(dr,{...s,variant:r,ref:e}))});no.displayName="RichTextArea";function id(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 Fs=[{id:"100",amount:100},{id:"250",amount:250},{id:"500",amount:500},{id:"1000",amount:1e3},{id:"2000",amount:2e3}],od={title:"Donation Amount",customAmountPlaceholder:"Custom donation amount",customAmountAriaLabel:"Custom donation amount",addDonationButton:"Add Donation"},ro=({presetAmounts:t=Fs,selectedDonation:e,defaultSelectedDonation:n=null,onChange:r,onAddDonation:s,currency:i="USD",locale:o="en-US",showCustomAmount:a=!0,minCustomAmount:l=.5,maxCustomAmount:d=1e6,labels:u,mobileColumns:f=2,desktopColumns:p=3,isDisabled:h=!1,buttonVariant:k="bordered",buttonColor:v="default",inputVariant:y="bordered",size:S="md",className:N="",showCard:j=!0})=>{const w={...od,...u},A=Array.isArray(t)?t:Fs,T={2:"grid-cols-2",3:"grid-cols-3"},I={3:"sm:grid-cols-3",4:"sm:grid-cols-4",5:"sm:grid-cols-5",6:"sm:grid-cols-6"},z=`${T[f]} ${I[p]}`,[B,H]=br(e,n,r),[O,M]=x.useState(""),[L,R]=x.useState(!1),[U,Z]=x.useState(0),q=x.useCallback(te=>{if(h)return;const Oe={amount:te.amount,isCustom:!1,presetId:te.id};H(Oe),M(""),R(!1),Z(ne=>ne+1),s?.(Oe)},[h,H,s]),de=x.useCallback(te=>{if(h)return;if(M(te!==void 0?String(te):""),s){H(null);return}if(te===void 0||isNaN(te)){H(null);return}H({amount:te,isCustom:!0})},[h,H,s]),ce=x.useCallback(()=>{if(h)return;const te=O!==""?parseFloat(O):void 0;te===void 0||isNaN(te)||s?.({amount:te,isCustom:!0})},[h,O,s]),xe=x.useMemo(()=>({style:"currency",currency:i,currencyDisplay:"symbol"}),[i]),Le=c.jsxs("div",{className:"space-y-4","data-testid":"donation-amounts-root",children:[w.title&&c.jsx("h2",{className:"text-base font-semibold","data-testid":"donation-amounts-title",children:w.title}),A.length>0&&c.jsx("div",{className:g.cn("grid gap-3",z),"data-testid":"donation-amounts-presets",children:A.map(te=>{const Oe=B!==null&&!B.isCustom&&B.presetId===te.id;return c.jsx(G,{color:Oe?"primary":v,variant:Oe?"solid":k,className:"w-full",onPress:()=>q(te),isDisabled:h,"data-testid":`donation-amounts-preset-${te.id}`,children:te.label||id(te.amount,o,i)},te.id)})}),a&&c.jsxs("div",{className:"flex gap-3 items-start",children:[c.jsx(g.NumberInput,{placeholder:w.customAmountPlaceholder,"aria-label":w.customAmountAriaLabel,onInput:s?()=>{H(null),R(!0)}:void 0,variant:y,radius:"full",size:S,minValue:l,maxValue:d,step:.01,formatOptions:xe,value:O!==""?parseFloat(O):void 0,onValueChange:de,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-${U}`:B?.isCustom===!1?B.presetId:"custom"),s&&c.jsx(G,{color:"primary",variant:"solid",radius:"full",size:S,className:"shrink-0",onPress:ce,isDisabled:h||!L,"data-testid":"donation-amounts-add-button",children:w.addDonationButton})]})]});return j?c.jsx(g.Card,{className:g.cn("w-full",N),"data-testid":"donation-amounts-card",children:c.jsx(g.CardBody,{children:Le})}):c.jsx("div",{className:g.cn("w-full",N),"data-testid":"donation-amounts-plain",children:Le})};ro.displayName="DonationAmounts";const ad=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`},ld=t=>{switch(t){case"warning":return _.Clock;case"error":return _.AlertCircle;case"success":return _.CheckCircle;default:return _.Clock}},cd=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"}},so=x.forwardRef(({timeLeft:t,defaultTimeLeft:e=1200,onTimeChange:n,onExpire:r,variant:s="info",color:i="primary",message:o="Your cart expires in:",showIcon:a=!0,icon:l,position:d="fixed",autoStart:u=!0,formatTime:f=ad,className:p,...h},k)=>{const[v,y]=br(t!==void 0?Math.max(0,t):void 0,Math.max(0,e),n),S=x.useRef(null),N=x.useRef(!1);x.useEffect(()=>()=>{S.current&&clearInterval(S.current)},[]),x.useEffect(()=>{if(!u||v<=0){S.current&&(clearInterval(S.current),S.current=null);return}return S.current=setInterval(()=>{y(T=>T<=1?(S.current&&(clearInterval(S.current),S.current=null),N.current||(N.current=!0,r?.()),0):T-1)},1e3),()=>{S.current&&(clearInterval(S.current),S.current=null)}},[u,v,y,r]),x.useEffect(()=>{v>0&&(N.current=!1)},[v]);const j=l||ld(s),w=cd(i),A={fixed:"fixed top-0 left-0",sticky:"sticky top-0",static:"static"};return c.jsx("div",{ref:k,role:"banner","aria-live":"polite","aria-label":`${o} ${f(v)}`,"data-testid":"expire-cart-timer",className:g.cn("w-full text-white z-50",w,A[d],p),...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:[a&&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(j,{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(v)}`,"data-testid":"expire-cart-timer-value",children:f(v)})})]})})})});so.displayName="ExpireCartTimer";function dd(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 a=r[o]&&r[o].parent,l=a&&i(a);l&&(s[o]=[a].concat(l))}return s[o]}return Object.keys(n).concat(Object.keys(r)).forEach(i),s}const io=Object.freeze({left:0,top:0,width:16,height:16}),pn=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),Ir=Object.freeze({...io,...pn}),ur=Object.freeze({...Ir,body:"",hidden:!1});function ud(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 Ps(t,e){const n=ud(t,e);for(const r in ur)r in pn?r in t&&!(r in n)&&(n[r]=pn[r]):r in e?n[r]=e[r]:r in t&&(n[r]=t[r]);return n}function fd(t,e,n){const r=t.icons,s=t.aliases||Object.create(null);let i={};function o(a){i=Ps(r[a]||s[a],i)}return o(e),n.forEach(o),Ps(t,i)}function oo(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=dd(t);for(const s in r){const i=r[s];i&&(e(s,fd(t,s,i)),n.push(s))}return n}const hd={provider:"",aliases:{},not_found:{},...io};function qn(t,e){for(const n in e)if(n in t&&typeof t[n]!=typeof e[n])return!1;return!0}function ao(t){if(typeof t!="object"||t===null)return null;const e=t;if(typeof e.prefix!="string"||!t.icons||typeof t.icons!="object"||!qn(t,hd))return null;const n=e.icons;for(const s in n){const i=n[s];if(!s||typeof i.body!="string"||!qn(i,ur))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]||!qn(i,ur))return null}return e}const Rs=Object.create(null);function pd(t,e){return{provider:t,prefix:e,icons:Object.create(null),missing:new Set}}function Nt(t,e){const n=Rs[t]||(Rs[t]=Object.create(null));return n[e]||(n[e]=pd(t,e))}function lo(t,e){return ao(e)?oo(e,(n,r)=>{r?t.icons[n]=r:t.missing.add(n)}):[]}function md(t,e,n){try{if(typeof n.body=="string")return t.icons[e]={...n},!0}catch{}return!1}const co=/^[a-z0-9]+(-[a-z0-9]+)*$/,Cn=(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 a=s.pop(),l=s.pop(),d={provider:s.length>0?s[0]:r,prefix:l,name:a};return e&&!tn(d)?null:d}const i=s[0],o=i.split("-");if(o.length>1){const a={provider:r,prefix:o.shift(),name:o.join("-")};return e&&!tn(a)?null:a}if(n&&r===""){const a={provider:r,prefix:"",name:i};return e&&!tn(a,n)?null:a}return null},tn=(t,e)=>t?!!((e&&t.prefix===""||t.prefix)&&t.name):!1;let Ht=!1;function uo(t){return typeof t=="boolean"&&(Ht=t),Ht}function $s(t){const e=typeof t=="string"?Cn(t,!0,Ht):t;if(e){const n=Nt(e.provider,e.prefix),r=e.name;return n.icons[r]||(n.missing.has(r)?null:void 0)}}function gd(t,e){const n=Cn(t,!0,Ht);if(!n)return!1;const r=Nt(n.provider,n.prefix);return e?md(r,n.name,e):(r.missing.add(n.name),!0)}function xd(t,e){if(typeof t!="object")return!1;if(typeof e!="string"&&(e=t.provider||""),Ht&&!e&&!t.prefix){let s=!1;return ao(t)&&(t.prefix="",oo(t,(i,o)=>{gd(i,o)&&(s=!0)})),s}const n=t.prefix;if(!tn({prefix:n,name:"a"}))return!1;const r=Nt(e,n);return!!lo(r,t)}const fo=Object.freeze({width:null,height:null}),ho=Object.freeze({...fo,...pn}),yd=/(-?[0-9.]*[0-9]+[0-9.]*)/g,bd=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function Vs(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(yd);if(r===null||!r.length)return t;const s=[];let i=r.shift(),o=bd.test(i);for(;;){if(o){const a=parseFloat(i);isNaN(a)?s.push(i):s.push(Math.ceil(a*e*n)/n)}else s.push(i);if(i=r.shift(),i===void 0)return s.join("");o=!o}}function vd(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 kd(t,e){return t?"<defs>"+t+"</defs>"+e:e}function Sd(t,e,n){const r=vd(t);return kd(r.defs,e+r.content+n)}const Cd=t=>t==="unset"||t==="undefined"||t==="none";function wd(t,e){const n={...Ir,...t},r={...ho,...e},s={left:n.left,top:n.top,width:n.width,height:n.height};let i=n.body;[n,r].forEach(v=>{const y=[],S=v.hFlip,N=v.vFlip;let j=v.rotate;S?N?j+=2:(y.push("translate("+(s.width+s.left).toString()+" "+(0-s.top).toString()+")"),y.push("scale(-1 1)"),s.top=s.left=0):N&&(y.push("translate("+(0-s.left).toString()+" "+(s.height+s.top).toString()+")"),y.push("scale(1 -1)"),s.top=s.left=0);let w;switch(j<0&&(j-=Math.floor(j/4)*4),j=j%4,j){case 1:w=s.height/2+s.top,y.unshift("rotate(90 "+w.toString()+" "+w.toString()+")");break;case 2:y.unshift("rotate(180 "+(s.width/2+s.left).toString()+" "+(s.height/2+s.top).toString()+")");break;case 3:w=s.width/2+s.left,y.unshift("rotate(-90 "+w.toString()+" "+w.toString()+")");break}j%2===1&&(s.left!==s.top&&(w=s.left,s.left=s.top,s.top=w),s.width!==s.height&&(w=s.width,s.width=s.height,s.height=w)),y.length&&(i=Sd(i,'<g transform="'+y.join(" ")+'">',"</g>"))});const o=r.width,a=r.height,l=s.width,d=s.height;let u,f;o===null?(f=a===null?"1em":a==="auto"?d:a,u=Vs(f,l/d)):(u=o==="auto"?l:o,f=a===null?Vs(u,d/l):a==="auto"?d:a);const p={},h=(v,y)=>{Cd(y)||(p[v]=y.toString())};h("width",u),h("height",f);const k=[s.left,s.top,l,d];return p.viewBox=k.join(" "),{attributes:p,viewBox:k,body:i}}const Nd=/\sid="(\S+)"/g,Ad="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let jd=0;function Ed(t,e=Ad){const n=[];let r;for(;r=Nd.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+(jd++).toString(),a=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");t=t.replace(new RegExp('([#;"])('+a+')([")]|\\.[a-z])',"g"),"$1"+o+s+"$3")}),t=t.replace(new RegExp(s,"g"),""),t}const fr=Object.create(null);function Td(t,e){fr[t]=e}function hr(t){return fr[t]||fr[""]}function Lr(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 Fr=Object.create(null),Et=["https://api.simplesvg.com","https://api.unisvg.com"],nn=[];for(;Et.length>0;)Et.length===1||Math.random()>.5?nn.push(Et.shift()):nn.push(Et.pop());Fr[""]=Lr({resources:["https://api.iconify.design"].concat(nn)});function Md(t,e){const n=Lr(e);return n===null?!1:(Fr[t]=n,!0)}function Pr(t){return Fr[t]}const Od=()=>{let t;try{if(t=fetch,typeof t=="function")return t}catch{}};let Bs=Od();function Dd(t,e){const n=Pr(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 Id(t){return t===404}const Ld=(t,e,n)=>{const r=[],s=Dd(t,e),i="icons";let o={type:i,provider:t,prefix:e,icons:[]},a=0;return n.forEach((l,d)=>{a+=l.length+1,a>=s&&d>0&&(r.push(o),o={type:i,provider:t,prefix:e,icons:[]},a=l.length),o.icons.push(l)}),r.push(o),r};function Fd(t){if(typeof t=="string"){const e=Pr(t);if(e)return e.path}return"/"}const Pd=(t,e,n)=>{if(!Bs){n("abort",424);return}let r=Fd(e.provider);switch(e.type){case"icons":{const i=e.prefix,a=e.icons.join(","),l=new URLSearchParams({icons:a});r+=i+".json?"+l.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;Bs(t+r).then(i=>{const o=i.status;if(o!==200){setTimeout(()=>{n(Id(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)})},Rd={prepare:Ld,send:Pd};function po(t,e){t.forEach(n=>{const r=n.loaderCallbacks;r&&(n.loaderCallbacks=r.filter(s=>s.id!==e))})}function $d(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,a=o.pending.length;o.pending=o.pending.filter(l=>{if(l.prefix!==s)return!0;const d=l.name;if(t.icons[d])o.loaded.push({provider:r,prefix:s,name:d});else if(t.missing.has(d))o.missing.push({provider:r,prefix:s,name:d});else return n=!0,!0;return!1}),o.pending.length!==a&&(n||po([t],i.id),i.callback(o.loaded.slice(0),o.missing.slice(0),o.pending.slice(0),i.abort))})}))}let Vd=0;function Bd(t,e,n){const r=Vd++,s=po.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 zd(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,a=s.name,l=n[i]||(n[i]=Object.create(null)),d=l[o]||(l[o]=Nt(i,o));let u;a in d.icons?u=e.loaded:o===""||d.missing.has(a)?u=e.missing:u=e.pending;const f={provider:i,prefix:o,name:a};u.push(f)}),e}function _d(t,e=!0,n=!1){const r=[];return t.forEach(s=>{const i=typeof s=="string"?Cn(s,e,n):s;i&&r.push(i)}),r}const Hd={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function Ud(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 T=t.resources.slice(0);for(o=[];T.length>1;){const I=Math.floor(Math.random()*T.length);o.push(T[I]),T=T.slice(0,I).concat(T.slice(I+1))}o=o.concat(T)}else o=t.resources.slice(i).concat(t.resources.slice(0,i));const a=Date.now();let l="pending",d=0,u,f=null,p=[],h=[];typeof r=="function"&&h.push(r);function k(){f&&(clearTimeout(f),f=null)}function v(){l==="pending"&&(l="aborted"),k(),p.forEach(T=>{T.status==="pending"&&(T.status="aborted")}),p=[]}function y(T,I){I&&(h=[]),typeof T=="function"&&h.push(T)}function S(){return{startTime:a,payload:e,status:l,queriesSent:d,queriesPending:p.length,subscribe:y,abort:v}}function N(){l="failed",h.forEach(T=>{T(void 0,u)})}function j(){p.forEach(T=>{T.status==="pending"&&(T.status="aborted")}),p=[]}function w(T,I,z){const B=I!=="success";switch(p=p.filter(H=>H!==T),l){case"pending":break;case"failed":if(B||!t.dataAfterTimeout)return;break;default:return}if(I==="abort"){u=z,N();return}if(B){u=z,p.length||(o.length?A():N());return}if(k(),j(),!t.random){const H=t.resources.indexOf(T.resource);H!==-1&&H!==t.index&&(t.index=H)}l="completed",h.forEach(H=>{H(z)})}function A(){if(l!=="pending")return;k();const T=o.shift();if(T===void 0){if(p.length){f=setTimeout(()=>{k(),l==="pending"&&(j(),N())},t.timeout);return}N();return}const I={status:"pending",resource:T,callback:(z,B)=>{w(I,z,B)}};p.push(I),d++,f=setTimeout(A,t.rotate),n(T,e,I.callback)}return setTimeout(A),S}function mo(t){const e={...Hd,...t};let n=[];function r(){n=n.filter(a=>a().status==="pending")}function s(a,l,d){const u=Ud(e,a,l,(f,p)=>{r(),d&&d(f,p)});return n.push(u),u}function i(a){return n.find(l=>a(l))||null}return{query:s,find:i,setIndex:a=>{e.index=a},getIndex:()=>e.index,cleanup:r}}function zs(){}const Kn=Object.create(null);function qd(t){if(!Kn[t]){const e=Pr(t);if(!e)return;const n=mo(e),r={config:e,redundancy:n};Kn[t]=r}return Kn[t]}function Kd(t,e,n){let r,s;if(typeof t=="string"){const i=hr(t);if(!i)return n(void 0,424),zs;s=i.send;const o=qd(t);o&&(r=o.redundancy)}else{const i=Lr(t);if(i){r=mo(i);const o=t.resources?t.resources[0]:"",a=hr(o);a&&(s=a.send)}}return!r||!s?(n(void 0,424),zs):r.query(e,s,n)().abort}function _s(){}function Wd(t){t.iconsLoaderFlag||(t.iconsLoaderFlag=!0,setTimeout(()=>{t.iconsLoaderFlag=!1,$d(t)}))}function Jd(t){const e=[],n=[];return t.forEach(r=>{(r.match(co)?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(!lo(t,n).length){r();return}}catch(s){console.error(s)}r(),Wd(t)}function Hs(t,e){t instanceof Promise?t.then(n=>{e(n)}).catch(()=>{e(null)}):e(t)}function Gd(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)){Hs(t.loadIcons(s,r,n),u=>{Tt(t,s,u)});return}if(i){s.forEach(u=>{const f=i(u,r,n);Hs(f,p=>{const h=p?{prefix:r,icons:{[u]:p}}:null;Tt(t,[u],h)})});return}const{valid:o,invalid:a}=Jd(s);if(a.length&&Tt(t,a,null),!o.length)return;const l=r.match(co)?hr(n):null;if(!l){Tt(t,o,null);return}l.prepare(n,r,o).forEach(u=>{Kd(n,u,f=>{Tt(t,u.icons,f)})})}))}const Zd=(t,e)=>{const n=_d(t,!0,uo()),r=zd(n);if(!r.pending.length){let l=!0;return e&&setTimeout(()=>{l&&e(r.loaded,r.missing,r.pending,_s)}),()=>{l=!1}}const s=Object.create(null),i=[];let o,a;return r.pending.forEach(l=>{const{provider:d,prefix:u}=l;if(u===a&&d===o)return;o=d,a=u,i.push(Nt(d,u));const f=s[d]||(s[d]=Object.create(null));f[u]||(f[u]=[])}),r.pending.forEach(l=>{const{provider:d,prefix:u,name:f}=l,p=Nt(d,u),h=p.pendingIcons||(p.pendingIcons=new Set);h.has(f)||(h.add(f),s[d][u].push(f))}),i.forEach(l=>{const d=s[l.provider][l.prefix];d.length&&Gd(l,d)}),e?Bd(e,r,i):_s};function Yd(t,e){const n={...t};for(const r in e){const s=e[r],i=typeof s;r in fo?(s===null||s&&(i==="string"||i==="number"))&&(n[r]=s):i===typeof n[r]&&(n[r]=r==="rotate"?s%4:s)}return n}const Qd=/[\s,]+/;function Xd(t,e){e.split(Qd).forEach(n=>{switch(n.trim()){case"horizontal":t.hFlip=!0;break;case"vertical":t.vFlip=!0;break}})}function eu(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 tu(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 nu(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,"+nu(t)}function su(t){return'url("'+ru(t)+'")'}let Lt;function iu(){try{Lt=window.trustedTypes.createPolicy("iconify",{createHTML:t=>t})}catch{Lt=null}}function ou(t){return Lt===void 0&&iu(),Lt?Lt.createHTML(t):t}const go={...ho,inline:!1},au={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},lu={display:"inline-block"},pr={backgroundColor:"currentColor"},xo={backgroundColor:"transparent"},Us={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},qs={WebkitMask:pr,mask:pr,background:xo};for(const t in qs){const e=qs[t];for(const n in Us)e[t+n]=Us[n]}const cu={...go,inline:!0};function Ks(t){return t+(t.match(/^[-0-9.]+$/)?"px":"")}const du=(t,e,n)=>{const r=e.inline?cu:go,s=Yd(r,e),i=e.mode||"svg",o={},a=e.style||{},l={...i==="svg"?au:{}};if(n){const y=Cn(n,!1,!0);if(y){const S=["iconify"],N=["provider","prefix"];for(const j of N)y[j]&&S.push("iconify--"+y[j]);l.className=S.join(" ")}}for(let y in e){const S=e[y];if(S!==void 0)switch(y){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":l.ref=S;break;case"className":l[y]=(l[y]?l[y]+" ":"")+S;break;case"inline":case"hFlip":case"vFlip":s[y]=S===!0||S==="true"||S===1;break;case"flip":typeof S=="string"&&Xd(s,S);break;case"color":o.color=S;break;case"rotate":typeof S=="string"?s[y]=eu(S):typeof S=="number"&&(s[y]=S);break;case"ariaHidden":case"aria-hidden":S!==!0&&S!=="true"&&delete l["aria-hidden"];break;default:r[y]===void 0&&(l[y]=S)}}const d=wd(t,s),u=d.attributes;if(s.inline&&(o.verticalAlign="-0.125em"),i==="svg"){l.style={...o,...a},Object.assign(l,u);let y=0,S=e.id;return typeof S=="string"&&(S=S.replace(/-/g,"_")),l.dangerouslySetInnerHTML={__html:ou(Ed(d.body,S?()=>S+"ID"+y++:"iconifyReact"))},x.createElement("svg",l)}const{body:f,width:p,height:h}=t,k=i==="mask"||(i==="bg"?!1:f.indexOf("currentColor")!==-1),v=tu(f,{...u,width:p+"",height:h+""});return l.style={...o,"--svg":su(v),width:Ks(u.width),height:Ks(u.height),...lu,...k?pr:xo,...a},x.createElement("span",l)};uo(!0);Td("",Rd);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"||!xd(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;Md(n,s)||console.error(r)}catch{console.error(r)}}}}function yo(t){const[e,n]=x.useState(!!t.ssr),[r,s]=x.useState({});function i(h){if(h){const k=t.icon;if(typeof k=="object")return{name:"",data:k};const v=$s(k);if(v)return{name:k,data:v}}return{name:""}}const[o,a]=x.useState(i(!!t.ssr));function l(){const h=r.callback;h&&(h(),s({}))}function d(h){if(JSON.stringify(o)!==JSON.stringify(h))return l(),a(h),!0}function u(){var h;const k=t.icon;if(typeof k=="object"){d({name:"",data:k});return}const v=$s(k);if(d({name:k,data:v}))if(v===void 0){const y=Zd([k],u);s({callback:y})}else v&&((h=t.onLoad)===null||h===void 0||h.call(t,k))}x.useEffect(()=>(n(!0),l),[]),x.useEffect(()=>{e&&u()},[t.icon,e]);const{name:f,data:p}=o;return p?du({...Ir,...p},t,f):t.children?t.children:t.fallback?t.fallback:x.createElement("span",{})}const ae=x.forwardRef((t,e)=>yo({...t,_ref:e}));x.forwardRef((t,e)=>yo({inline:!0,...t,_ref:e}));const Wn=({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(ae,{icon:t,width:20,className:"text-default-500"}),c.jsx("span",{children:e})]}),uu=({classes:t="",name:e,imageUrl:n,eventDate:r,eventTime:s,location:i,description:o,showImage:a=!1,imageLoading:l="eager",showMoreButtonClassName:d,labels:u})=>{const[f,p]=x.useState(!1),[h,k]=x.useState(!1),v=x.useRef(null);return x.useEffect(()=>{const y=()=>{if(v.current){const S=v.current.scrollHeight>v.current.clientHeight;k(S)}};return y(),window.addEventListener("resize",y),()=>window.removeEventListener("resize",y)},[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:[a&&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,{removeWrapper:!0,loading:l,alt:`Event image for ${e}`,className:"w-full h-full object-cover object-center",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(Wn,{icon:"solar:calendar-minimalistic-linear",testId:"event-details-date",children:r}),s&&c.jsx(Wn,{icon:"solar:clock-circle-linear",testId:"event-details-time",children:s}),i&&c.jsx(Wn,{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:v,className:g.cn("text-sm text-gray-700 leading-relaxed transition-all",!f&&"line-clamp-3"),"data-testid":"event-details-description",dangerouslySetInnerHTML:{__html:o}}),!f&&h&&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"})]}),(h||f)&&c.jsx("div",{className:"flex justify-end mt-1",children:c.jsx(G,{onPress:()=>p(!f),variant:"light",className:g.cn("text-primary",d),startContent:c.jsx(ae,{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 bo(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 fu(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 hu={person:"Person",people:"People",tickets:"Tickets:",soldOut:"Sold Out",maxReached:"Maximum number of tickets allowed reached"},Yt=t=>typeof t=="number"&&!isNaN(t),Rr=({offer:t,quantity:e,defaultQuantity:n=0,onQuantityChange:r,currency:s="USD",locale:i="en-US",labels:o,slots:a,isDisabled:l=!1,buttonVariant:d="bordered",buttonColor:u="default",showCard:f=!0,showDescription:p=!0,showPeopleCount:h=!0,showPrice:k=!0,classNames:v={},"data-testid":y,selectedColor:S="default"})=>{const N={...hu,...o},[j,w]=x.useState(n),A=e!==void 0?e:j,T=ce=>{if(l)return;const xe=Math.max(0,A+ce);e===void 0&&w(xe),r?.(t.id,xe)},I=x.useMemo(()=>!Yt(t.totalTicketsSold)||!Yt(t.ticketsAllowed)?!1:t.totalTicketsSold>=t.ticketsAllowed,[t.totalTicketsSold,t.ticketsAllowed]),z=x.useMemo(()=>I||!Yt(t.ticketsAllowed)?!1:A>=t.ticketsAllowed-(t.totalTicketsSold??0),[I,t.ticketsAllowed,t.totalTicketsSold,A]),B=bo(t.price,i,s),H=()=>a?.renderName?a.renderName(t.name,t):c.jsx("h2",{"data-testid":"offer-card-name",className:g.cn("text-base font-medium",v.name),children:t.name}),O=()=>k?a?.renderPrice?a.renderPrice(t.price,B,t):c.jsx("p",{"data-testid":"offer-card-price",className:g.cn("text-primary text-base mt-1",v.price),children:B}):null,M=()=>!p||!t.description?null:a?.renderDescription?a.renderDescription(t.description,t):c.jsx("p",{"data-testid":"offer-card-description",className:g.cn("mb-4 text-sm text-gray-700 leading-relaxed",v.description),children:t.description}),L=()=>{if(!h||!Yt(t.numberOfPeople)||t.numberOfPeople<=0)return null;const ce=t.numberOfPeople===1?N.person:N.people;return a?.renderPeopleCount?a.renderPeopleCount(t.numberOfPeople,ce,t):c.jsxs("p",{"data-testid":"offer-card-people-count",className:g.cn("text-sm text-gray-600 flex items-center mt-2",v.peopleCount),children:[c.jsx(ae,{icon:t.numberOfPeople<=1?"solar:user-rounded-outline":"solar:users-group-rounded-outline",width:20,className:"mr-1"}),t.numberOfPeople," ",ce]})},R=()=>{const ce=A===0||l,xe=z||l;return a?.renderQuantitySelector?a.renderQuantitySelector({quantity:A,onIncrement:()=>T(1),onDecrement:()=>T(-1),isDecrementDisabled:ce,isIncrementDisabled:xe,isDisabled:l}):c.jsxs("div",{className:g.cn("flex items-center gap-2",v.quantitySelector),children:[c.jsx(G,{"data-testid":"offer-card-decrement-button",onPress:()=>T(-1),isDisabled:ce,variant:d,color:A>0?S:u,radius:"full",isIconOnly:!0,size:"sm","aria-label":"Decrease quantity",children:c.jsx(ae,{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:A}),c.jsx(G,{"data-testid":"offer-card-increment-button",onPress:()=>T(1),isDisabled:xe,variant:d,color:A>0?S:u,radius:"full",isIconOnly:!0,size:"sm","aria-label":"Increase quantity",children:c.jsx(ae,{icon:"gravity-ui:plus",width:16})})]})},U=()=>a?.renderSoldOut?a.renderSoldOut(N.soldOut):c.jsx(g.Chip,{"data-testid":"offer-card-sold-out-chip",color:"danger",className:g.cn("gap-2 px-4 h-8",v.soldOut),startContent:c.jsx(ae,{icon:"gravity-ui:circle-info-fill",width:14}),children:c.jsx("span",{className:"font-medium text-sm",children:N.soldOut})}),Z=()=>a?.renderMaxReachedAlert?a.renderMaxReachedAlert(N.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",v.maxReachedAlert),startContent:c.jsx(ae,{icon:"gravity-ui:triangle-exclamation-fill",className:"text-black",width:16}),children:c.jsx("span",{className:"font-medium text-sm",children:N.maxReached})}),q=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",I?"opacity-50 pointer-events-none select-none":""),children:[H(),O(),c.jsxs("div",{className:g.cn("md:col-span-1 xl:col-span-2 lg:col-span-1 mb-2",I?"opacity-50 pointer-events-none select-none":""),children:[L(),M()]})]}),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:I?U():R()})]}),de=z&&!I&&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:Z()});return f?c.jsxs(g.Card,{className:g.cn("w-full",v.base),"data-testid":y||`offer-card-${t.id}`,children:[c.jsx(g.CardBody,{className:g.cn("pt-1 pb-0",v.body),children:q}),c.jsx($e.AnimatePresence,{children:de&&c.jsx(g.CardFooter,{className:g.cn("w-full mt-0 pt-0",v.footer),children:de})})]}):c.jsxs("div",{className:g.cn("w-full",v.base),"data-testid":y||`offer-card-${t.id}`,children:[c.jsx("div",{className:g.cn("pt-1 pb-0",v.body),children:q}),c.jsx($e.AnimatePresence,{children:de&&c.jsx("div",{className:g.cn("w-full mt-0 pt-0",v.footer),children:de})})]})};Rr.displayName="OfferCard";const vo=({message:t="No offers available.",icon:e="solar:ticket-sale-outline",iconSize:n=48,showCard:r=!0,classNames:s={},renderEmpty:i})=>{if(i){const a=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:a})}):c.jsx("div",{"data-testid":"offer-card-empty",className:g.cn("w-full",s.base),children:a})}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(ae,{"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})};vo.displayName="OfferCardEmpty";const pu={title:"Error Fetching Offers",description:"An error occurred while fetching offers."},ko=({error:t,labels:e,showCard:n=!0,color:r="danger",classNames:s={}})=>{const i={...pu,...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})};ko.displayName="OfferCardError";const mu={1:"space-y-1",2:"space-y-2",3:"space-y-3",4:"space-y-4",5:"space-y-5",6:"space-y-6"},So=({quantity:t=2,gap:e=4,classNames:n={}})=>{const r=mu[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))})};So.displayName="OfferCardSkeleton";const Co={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.15,delayChildren:.1}}},wo={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"}}},gu={1:"gap-1",2:"gap-2",3:"gap-3",4:"gap-4",5:"gap-5",6:"gap-6"},No=({offers:t=[],selection:e,defaultSelection:n={},onSelectionChange:r,onQuantityChange:s,currency:i="USD",locale:o="en-US",labels:a,slots:l,isDisabled:d=!1,buttonVariant:u="bordered",buttonColor:f="default",showCard:p=!0,animated:h=!0,gap:k=2,classNames:v={}})=>{const[y,S]=x.useState(n),N=e!==void 0?e:y,j=x.useCallback((z,B)=>{const H={...N,[z]:Math.max(0,B)};e===void 0&&S(H),r?.(H),s?.(z,H[z])},[N,e,r,s]),w=[...t].sort((z,B)=>(z.position??0)-(B.position??0)),A=gu[k],T=g.cn("grid mx-auto pt-2",A,v.base),I=z=>c.jsx(Rr,{offer:z,quantity:N[z.id]||0,onQuantityChange:j,currency:i,locale:o,labels:a,slots:l,isDisabled:d,buttonVariant:u,buttonColor:f,showCard:p,classNames:v.card},z.id);return h?c.jsx($e.motion.div,{"data-testid":"offer-card-list",className:T,variants:Co,initial:"hidden",animate:"show",children:c.jsx($e.AnimatePresence,{children:w.map(z=>c.jsx($e.motion.div,{"data-testid":`offer-card-list-item-${z.id}`,className:v.cardWrapper,variants:wo,exit:{opacity:0,y:-20},transition:{duration:.3},children:I(z)},z.id))})}):c.jsx("div",{"data-testid":"offer-card-list",className:T,children:w.map(I)})};No.displayName="OfferCardList";var Kt=t=>t.type==="checkbox",ct=t=>t instanceof Date,Ne=t=>t==null;const Ao=t=>typeof t=="object";var pe=t=>!Ne(t)&&!Array.isArray(t)&&Ao(t)&&!ct(t),jo=t=>pe(t)&&t.target?Kt(t.target)?t.target.checked:t.target.value:t,xu=t=>t.substring(0,t.search(/\.\d+(\.|$)/))||t,Eo=(t,e)=>t.has(xu(e)),yu=t=>{const e=t.constructor&&t.constructor.prototype;return pe(e)&&e.hasOwnProperty("isPrototypeOf")},$r=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function ue(t){if(t instanceof Date)return new Date(t);const e=typeof FileList<"u"&&t instanceof FileList;if($r&&(t instanceof Blob||e))return t;const n=Array.isArray(t);if(!n&&!(pe(t)&&yu(t)))return t;const r=n?[]:Object.create(Object.getPrototypeOf(t));for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[s]=ue(t[s]));return r}var wn=t=>/^\w*$/.test(t),ie=t=>t===void 0,Vr=t=>Array.isArray(t)?t.filter(Boolean):[],Br=t=>Vr(t.replace(/["|']|\]/g,"").split(/\.|\[/)),F=(t,e,n)=>{if(!e||!pe(t))return n;const r=(wn(e)?[e]:Br(e)).reduce((s,i)=>Ne(s)?s:s[i],t);return ie(r)||r===t?ie(t[e])?n:t[e]:r},je=t=>typeof t=="boolean",we=t=>typeof t=="function",re=(t,e,n)=>{let r=-1;const s=wn(e)?[e]:Br(e),i=s.length,o=i-1;for(;++r<i;){const a=s[r];let l=n;if(r!==o){const d=t[a];l=pe(d)||Array.isArray(d)?d:isNaN(+s[r+1])?{}:[]}if(a==="__proto__"||a==="constructor"||a==="prototype")return;t[a]=l,t=t[a]}};const mn={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"},To=x.createContext(null);To.displayName="HookFormControlContext";const zr=()=>x.useContext(To);var Mo=(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]!==Pe.all&&(e._proxyFormState[o]=!r||Pe.all),n&&(n[o]=!0),t[o]}});return s};const _r=typeof window<"u"?x.useLayoutEffect:x.useEffect;function bu(t){const e=zr(),{control:n=e,disabled:r,name:s,exact:i}=t||{},[o,a]=x.useState(n._formState),l=x.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return _r(()=>n._subscribe({name:s,formState:l.current,exact:i,callback:d=>{!r&&a({...n._formState,...d})}}),[s,r,i]),x.useEffect(()=>{l.current.isValid&&n._setValid(!0)},[n]),x.useMemo(()=>Mo(o,n,l.current,!1),[o,n])}var Te=t=>typeof t=="string",mr=(t,e,n,r,s)=>Te(t)?(r&&e.watch.add(t),F(n,t,s)):Array.isArray(t)?t.map(i=>(r&&e.watch.add(i),F(n,i))):(r&&(e.watchAll=!0),n),gr=t=>Ne(t)||!Ao(t);function Re(t,e,n=new WeakSet){if(gr(t)||gr(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 a=e[i];if(ct(o)&&ct(a)||pe(o)&&pe(a)||Array.isArray(o)&&Array.isArray(a)?!Re(o,a,n):!Object.is(o,a))return!1}}return!0}function vu(t){const e=zr(),{control:n=e,name:r,defaultValue:s,disabled:i,exact:o,compute:a}=t||{},l=x.useRef(s),d=x.useRef(a),u=x.useRef(void 0),f=x.useRef(n),p=x.useRef(r);d.current=a;const[h,k]=x.useState(()=>{const w=n._getWatch(r,l.current);return d.current?d.current(w):w}),v=x.useCallback(w=>{const A=mr(r,n._names,w||n._formValues,!1,l.current);return d.current?d.current(A):A},[n._formValues,n._names,r]),y=x.useCallback(w=>{if(!i){const A=mr(r,n._names,w||n._formValues,!1,l.current);if(d.current){const T=d.current(A);Re(T,u.current)||(k(T),u.current=T)}else k(A)}},[n._formValues,n._names,i,r]);_r(()=>((f.current!==n||!Re(p.current,r))&&(f.current=n,p.current=r,y()),n._subscribe({name:r,formState:{values:!0},exact:o,callback:w=>{y(w.values)}})),[n,o,r,y]),x.useEffect(()=>n._removeUnmounted());const S=f.current!==n,N=p.current,j=x.useMemo(()=>{if(i)return null;const w=!S&&!Re(N,r);return S||w?v():null},[i,S,r,N,v]);return j!==null?j:h}function ku(t){const e=zr(),{name:n,disabled:r,control:s=e,shouldUnregister:i,defaultValue:o,exact:a=!0}=t,l=Eo(s._names.array,n),d=x.useMemo(()=>F(s._formValues,n,F(s._defaultValues,n,o)),[s,n,o]),u=vu({control:s,name:n,defaultValue:d,exact:a}),f=bu({control:s,name:n,exact:a}),p=x.useRef(t),h=x.useRef(void 0),k=x.useRef(s.register(n,{...t.rules,value:u,...je(t.disabled)?{disabled:t.disabled}:{}}));p.current=t;const v=x.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!F(f.errors,n)},isDirty:{enumerable:!0,get:()=>!!F(f.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!F(f.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!F(f.validatingFields,n)},error:{enumerable:!0,get:()=>F(f.errors,n)}}),[f,n]),y=x.useCallback(w=>k.current.onChange({target:{value:jo(w),name:n},type:mn.CHANGE}),[n]),S=x.useCallback(()=>k.current.onBlur({target:{value:F(s._formValues,n),name:n},type:mn.BLUR}),[n,s._formValues]),N=x.useCallback(w=>{const A=F(s._fields,n);A&&A._f&&w&&(A._f.ref={focus:()=>we(w.focus)&&w.focus(),select:()=>we(w.select)&&w.select(),setCustomValidity:T=>we(w.setCustomValidity)&&w.setCustomValidity(T),reportValidity:()=>we(w.reportValidity)&&w.reportValidity()})},[s._fields,n]),j=x.useMemo(()=>({name:n,value:u,...je(r)||f.disabled?{disabled:f.disabled||r}:{},onChange:y,onBlur:S,ref:N}),[n,r,f.disabled,y,S,N,u]);return x.useEffect(()=>{const w=s._options.shouldUnregister||i,A=h.current;A&&A!==n&&!l&&s.unregister(A),s.register(n,{...p.current.rules,...je(p.current.disabled)?{disabled:p.current.disabled}:{}});const T=(I,z)=>{const B=F(s._fields,I);B&&B._f&&(B._f.mount=z)};if(T(n,!0),w){const I=ue(F(s._options.defaultValues,n,p.current.defaultValue));re(s._defaultValues,n,I),ie(F(s._formValues,n))&&re(s._formValues,n,I)}return!l&&s.register(n),h.current=n,()=>{(l?w&&!s._state.action:w)?s.unregister(n):T(n,!1)}},[n,s,l,i]),x.useEffect(()=>{s._setDisabledField({disabled:r,name:n})},[r,n,s]),x.useMemo(()=>({field:j,formState:f,fieldState:v}),[j,f,v])}const Su=x.createContext(null);Su.displayName="HookFormContext";var Cu=(t,e,n,r,s)=>e?{...n[t],types:{...n[t]&&n[t].types?n[t].types:{},[r]:s||!0}}:{},Ft=t=>Array.isArray(t)?t:[t],Ws=()=>{let t=[];return{get observers(){return t},next:s=>{for(const i of t)i.next&&i.next(s)},subscribe:s=>(t.push(s),{unsubscribe:()=>{t=t.filter(i=>i!==s)}}),unsubscribe:()=>{t=[]}}};function Oo(t,e){const n={};for(const r in t)if(t.hasOwnProperty(r)){const s=t[r],i=e[r];if(s&&pe(s)&&i){const o=Oo(s,i);pe(o)&&(n[r]=o)}else t[r]&&(n[r]=i)}return n}var Se=t=>pe(t)&&!Object.keys(t).length,Hr=t=>t.type==="file",gn=t=>{if(!$r)return!1;const e=t?t.ownerDocument:0;return t instanceof(e&&e.defaultView?e.defaultView.HTMLElement:HTMLElement)},Do=t=>t.type==="select-multiple",Ur=t=>t.type==="radio",wu=t=>Ur(t)||Kt(t),Jn=t=>gn(t)&&t.isConnected;function Nu(t,e){const n=e.slice(0,-1).length;let r=0;for(;r<n;)t=ie(t)?r++:t[e[r++]];return t}function Au(t){for(const e in t)if(t.hasOwnProperty(e)&&!ie(t[e]))return!1;return!0}function fe(t,e){const n=Array.isArray(e)?e:wn(e)?[e]:Br(e),r=n.length===1?t:Nu(t,n),s=n.length-1,i=n[s];return r&&delete r[i],s!==0&&(pe(r)&&Se(r)||Array.isArray(r)&&Au(r))&&fe(t,n.slice(0,-1)),t}var ju=t=>{for(const e in t)if(we(t[e]))return!0;return!1};function Io(t){return Array.isArray(t)||pe(t)&&!ju(t)}function xr(t,e={}){for(const n in t){const r=t[n];Io(r)?(e[n]=Array.isArray(r)?[]:{},xr(r,e[n])):ie(r)||(e[n]=!0)}return e}function kt(t,e,n){n||(n=xr(e));for(const r in t){const s=t[r];if(Io(s))ie(e)||gr(n[r])?n[r]=xr(s,Array.isArray(s)?[]:{}):kt(s,Ne(e)?{}:e[r],n[r]);else{const i=e[r];n[r]=!Re(s,i)}}return n}const Js={value:!1,isValid:!1},Gs={value:!0,isValid:!0};var Lo=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&&!ie(t[0].attributes.value)?ie(t[0].value)||t[0].value===""?Gs:{value:t[0].value,isValid:!0}:Gs:Js}return Js},Fo=(t,{valueAsNumber:e,valueAsDate:n,setValueAs:r})=>ie(t)?t:e?t===""?NaN:t&&+t:n&&Te(t)?new Date(t):r?r(t):t;const Zs={isValid:!1,value:null};var Po=t=>Array.isArray(t)?t.reduce((e,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:e,Zs):Zs;function Ys(t){const e=t.ref;return Hr(e)?e.files:Ur(e)?Po(t.refs).value:Do(e)?[...e.selectedOptions].map(({value:n})=>n):Kt(e)?Lo(t.refs).value:Fo(ie(e.value)?t.ref.value:e.value,t)}var Eu=(t,e,n,r)=>{const s={};for(const i of t){const o=F(e,i);o&&re(s,i,o._f)}return{criteriaMode:n,names:[...t],fields:s,shouldUseNativeValidation:r}},xn=t=>t instanceof RegExp,Mt=t=>ie(t)?t:xn(t)?t.source:pe(t)?xn(t.value)?t.value.source:t.value:t,Qs=t=>({isOnSubmit:!t||t===Pe.onSubmit,isOnBlur:t===Pe.onBlur,isOnChange:t===Pe.onChange,isOnAll:t===Pe.all,isOnTouch:t===Pe.onTouched});const Xs="AsyncFunction";var Tu=t=>!!t&&!!t.validate&&!!(we(t.validate)&&t.validate.constructor.name===Xs||pe(t.validate)&&Object.values(t.validate).find(e=>e.constructor.name===Xs)),Mu=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate),ei=(t,e,n)=>!n&&(e.watchAll||e.watch.has(t)||[...e.watch].some(r=>t.startsWith(r)&&/^\.\w+/.test(t.slice(r.length))));const Pt=(t,e,n,r)=>{for(const s of n||Object.keys(t)){const i=F(t,s);if(i){const{_f:o,...a}=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(Pt(a,e))break}else if(pe(a)&&Pt(a,e))break}}};function ti(t,e,n){const r=F(t,n);if(r||wn(n))return{error:r,name:n};const s=n.split(".");for(;s.length;){const i=s.join("."),o=F(e,i),a=F(t,i);if(o&&!Array.isArray(o)&&n!==i)return{name:n};if(a&&a.type)return{name:i,error:a};if(a&&a.root&&a.root.type)return{name:`${i}.root`,error:a.root};s.pop()}return{name:n}}var Ou=(t,e,n,r)=>{n(t);const{name:s,...i}=t;return Se(i)||Object.keys(i).length>=Object.keys(e).length||Object.keys(i).find(o=>e[o]===(!r||Pe.all))},Du=(t,e,n)=>!t||!e||t===e||Ft(t).some(r=>r&&(n?r===e:r.startsWith(e)||e.startsWith(r))),Iu=(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,Lu=(t,e)=>!Vr(F(t,e)).length&&fe(t,e),Fu=(t,e,n)=>{const r=Ft(F(t,n));return re(r,"root",e[n]),re(t,n,r),t};function ni(t,e,n="validate"){if(Te(t)||Array.isArray(t)&&t.every(Te)||je(t)&&!t)return{type:n,message:Te(t)?t:"",ref:e}}var xt=t=>pe(t)&&!xn(t)?t:{value:t,message:""},ri=async(t,e,n,r,s,i)=>{const{ref:o,refs:a,required:l,maxLength:d,minLength:u,min:f,max:p,pattern:h,validate:k,name:v,valueAsNumber:y,mount:S}=t._f,N=F(n,v);if(!S||e.has(v))return{};const j=a?a[0]:o,w=M=>{s&&j.reportValidity&&(j.setCustomValidity(je(M)?"":M||""),j.reportValidity())},A={},T=Ur(o),I=Kt(o),z=T||I,B=(y||Hr(o))&&ie(o.value)&&ie(N)||gn(o)&&o.value===""||N===""||Array.isArray(N)&&!N.length,H=Cu.bind(null,v,r,A),O=(M,L,R,U=Ue.maxLength,Z=Ue.minLength)=>{const q=M?L:R;A[v]={type:M?U:Z,message:q,ref:o,...H(M?U:Z,q)}};if(i?!Array.isArray(N)||!N.length:l&&(!z&&(B||Ne(N))||je(N)&&!N||I&&!Lo(a).isValid||T&&!Po(a).isValid)){const{value:M,message:L}=Te(l)?{value:!!l,message:l}:xt(l);if(M&&(A[v]={type:Ue.required,message:L,ref:j,...H(Ue.required,L)},!r))return w(L),A}if(!B&&(!Ne(f)||!Ne(p))){let M,L;const R=xt(p),U=xt(f);if(!Ne(N)&&!isNaN(N)){const Z=o.valueAsNumber||N&&+N;Ne(R.value)||(M=Z>R.value),Ne(U.value)||(L=Z<U.value)}else{const Z=o.valueAsDate||new Date(N),q=xe=>new Date(new Date().toDateString()+" "+xe),de=o.type=="time",ce=o.type=="week";Te(R.value)&&N&&(M=de?q(N)>q(R.value):ce?N>R.value:Z>new Date(R.value)),Te(U.value)&&N&&(L=de?q(N)<q(U.value):ce?N<U.value:Z<new Date(U.value))}if((M||L)&&(O(!!M,R.message,U.message,Ue.max,Ue.min),!r))return w(A[v].message),A}if((d||u)&&!B&&(Te(N)||i&&Array.isArray(N))){const M=xt(d),L=xt(u),R=!Ne(M.value)&&N.length>+M.value,U=!Ne(L.value)&&N.length<+L.value;if((R||U)&&(O(R,M.message,L.message),!r))return w(A[v].message),A}if(h&&!B&&Te(N)){const{value:M,message:L}=xt(h);if(xn(M)&&!N.match(M)&&(A[v]={type:Ue.pattern,message:L,ref:o,...H(Ue.pattern,L)},!r))return w(L),A}if(k){if(we(k)){const M=await k(N,n),L=ni(M,j);if(L&&(A[v]={...L,...H(Ue.validate,L.message)},!r))return w(L.message),A}else if(pe(k)){let M={};for(const L in k){if(!Se(M)&&!r)break;const R=ni(await k[L](N,n),j,L);R&&(M={...R,...H(L,R.message)},w(R.message),r&&(A[v]=M))}if(!Se(M)&&(A[v]={ref:j,...M},!r))return A}}return w(!0),A};const Pu={mode:Pe.onSubmit,reValidateMode:Pe.onChange,shouldFocusError:!0};function Ru(t={}){let e={...Pu,...t},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:we(e.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1},r={},s=pe(e.defaultValues)||pe(e.values)?ue(e.defaultValues||e.values)||{}:{},i=e.shouldUnregister?{}:ue(s),o={action:!1,mount:!1,watch:!1,keepIsValid:!1},a={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},l,d=0;const u={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},f={...u};let p={...f};const h={array:Ws(),state:Ws()},k=e.criteriaMode===Pe.all,v=m=>b=>{clearTimeout(d),d=setTimeout(m,b)},y=async m=>{if(!o.keepIsValid&&!e.disabled&&(f.isValid||p.isValid||m)){let b;e.resolver?(b=Se((await z()).errors),S()):b=await H(r,!0),b!==n.isValid&&h.state.next({isValid:b})}},S=(m,b)=>{!e.disabled&&(f.isValidating||f.validatingFields||p.isValidating||p.validatingFields)&&((m||Array.from(a.mount)).forEach(C=>{C&&(b?re(n.validatingFields,C,b):fe(n.validatingFields,C))}),h.state.next({validatingFields:n.validatingFields,isValidating:!Se(n.validatingFields)}))},N=(m,b=[],C,P,D=!0,E=!0)=>{if(P&&C&&!e.disabled){if(o.action=!0,E&&Array.isArray(F(r,m))){const V=C(F(r,m),P.argA,P.argB);D&&re(r,m,V)}if(E&&Array.isArray(F(n.errors,m))){const V=C(F(n.errors,m),P.argA,P.argB);D&&re(n.errors,m,V),Lu(n.errors,m)}if((f.touchedFields||p.touchedFields)&&E&&Array.isArray(F(n.touchedFields,m))){const V=C(F(n.touchedFields,m),P.argA,P.argB);D&&re(n.touchedFields,m,V)}(f.dirtyFields||p.dirtyFields)&&(n.dirtyFields=kt(s,i)),h.state.next({name:m,isDirty:M(m,b),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else re(i,m,b)},j=(m,b)=>{re(n.errors,m,b),h.state.next({errors:n.errors})},w=m=>{n.errors=m,h.state.next({errors:n.errors,isValid:!1})},A=(m,b,C,P)=>{const D=F(r,m);if(D){const E=F(i,m,ie(C)?F(s,m):C);ie(E)||P&&P.defaultChecked||b?re(i,m,b?E:Ys(D._f)):U(m,E),o.mount&&!o.action&&y()}},T=(m,b,C,P,D)=>{let E=!1,V=!1;const Y={name:m};if(!e.disabled){if(!C||P){(f.isDirty||p.isDirty)&&(V=n.isDirty,n.isDirty=Y.isDirty=M(),E=V!==Y.isDirty);const Q=Re(F(s,m),b);V=!!F(n.dirtyFields,m),Q?fe(n.dirtyFields,m):re(n.dirtyFields,m,!0),Y.dirtyFields=n.dirtyFields,E=E||(f.dirtyFields||p.dirtyFields)&&V!==!Q}if(C){const Q=F(n.touchedFields,m);Q||(re(n.touchedFields,m,C),Y.touchedFields=n.touchedFields,E=E||(f.touchedFields||p.touchedFields)&&Q!==C)}E&&D&&h.state.next(Y)}return E?Y:{}},I=(m,b,C,P)=>{const D=F(n.errors,m),E=(f.isValid||p.isValid)&&je(b)&&n.isValid!==b;if(e.delayError&&C?(l=v(()=>j(m,C)),l(e.delayError)):(clearTimeout(d),l=null,C?re(n.errors,m,C):fe(n.errors,m)),(C?!Re(D,C):D)||!Se(P)||E){const V={...P,...E&&je(b)?{isValid:b}:{},errors:n.errors,name:m};n={...n,...V},h.state.next(V)}},z=async m=>(S(m,!0),await e.resolver(i,e.context,Eu(m||a.mount,r,e.criteriaMode,e.shouldUseNativeValidation))),B=async m=>{const{errors:b}=await z(m);if(S(m),m)for(const C of m){const P=F(b,C);P?re(n.errors,C,P):fe(n.errors,C)}else n.errors=b;return b},H=async(m,b,C={valid:!0})=>{for(const P in m){const D=m[P];if(D){const{_f:E,...V}=D;if(E){const Y=a.array.has(E.name),Q=D._f&&Tu(D._f);Q&&f.validatingFields&&S([E.name],!0);const ke=await ri(D,a.disabled,i,k,e.shouldUseNativeValidation&&!b,Y);if(Q&&f.validatingFields&&S([E.name]),ke[E.name]&&(C.valid=!1,b||t.shouldUseNativeValidation))break;!b&&(F(ke,E.name)?Y?Fu(n.errors,ke,E.name):re(n.errors,E.name,ke[E.name]):fe(n.errors,E.name))}!Se(V)&&await H(V,b,C)}}return C.valid},O=()=>{for(const m of a.unMount){const b=F(r,m);b&&(b._f.refs?b._f.refs.every(C=>!Jn(C)):!Jn(b._f.ref))&&An(m)}a.unMount=new Set},M=(m,b)=>!e.disabled&&(m&&b&&re(i,m,b),!Re(Le(),s)),L=(m,b,C)=>mr(m,a,{...o.mount?i:ie(b)?s:Te(m)?{[m]:b}:b},C,b),R=m=>Vr(F(o.mount?i:s,m,e.shouldUnregister?F(s,m,[]):[])),U=(m,b,C={})=>{const P=F(r,m);let D=b;if(P){const E=P._f;E&&(!E.disabled&&re(i,m,Fo(b,E)),D=gn(E.ref)&&Ne(b)?"":b,Do(E.ref)?[...E.ref.options].forEach(V=>V.selected=D.includes(V.value)):E.refs?Kt(E.ref)?E.refs.forEach(V=>{(!V.defaultChecked||!V.disabled)&&(Array.isArray(D)?V.checked=!!D.find(Y=>Y===V.value):V.checked=D===V.value||!!D)}):E.refs.forEach(V=>V.checked=V.value===D):Hr(E.ref)?E.ref.value="":(E.ref.value=D,E.ref.type||h.state.next({name:m,values:ue(i)})))}(C.shouldDirty||C.shouldTouch)&&T(m,D,C.shouldTouch,C.shouldDirty,!0),C.shouldValidate&&xe(m)},Z=(m,b,C)=>{for(const P in b){if(!b.hasOwnProperty(P))return;const D=b[P],E=m+"."+P,V=F(r,E);(a.array.has(m)||pe(D)||V&&!V._f)&&!ct(D)?Z(E,D,C):U(E,D,C)}},q=(m,b,C={})=>{const P=F(r,m),D=a.array.has(m),E=ue(b);re(i,m,E),D?(h.array.next({name:m,values:ue(i)}),(f.isDirty||f.dirtyFields||p.isDirty||p.dirtyFields)&&C.shouldDirty&&h.state.next({name:m,dirtyFields:kt(s,i),isDirty:M(m,E)})):P&&!P._f&&!Ne(E)?Z(m,E,C):U(m,E,C),ei(m,a)?h.state.next({...n,name:m,values:ue(i)}):h.state.next({name:o.mount?m:void 0,values:ue(i)})},de=async m=>{o.mount=!0;const b=m.target;let C=b.name,P=!0;const D=F(r,C),E=Q=>{P=Number.isNaN(Q)||ct(Q)&&isNaN(Q.getTime())||Re(Q,F(i,C,Q))},V=Qs(e.mode),Y=Qs(e.reValidateMode);if(D){let Q,ke;const nt=b.type?Ys(D._f):jo(m),Je=m.type===mn.BLUR||m.type===mn.FOCUS_OUT,oa=!Mu(D._f)&&!e.resolver&&!F(n.errors,C)&&!D._f.deps||Iu(Je,F(n.touchedFields,C),n.isSubmitted,Y,V),Tn=ei(C,a,Je);re(i,C,nt),Je?(!b||!b.readOnly)&&(D._f.onBlur&&D._f.onBlur(m),l&&l(0)):D._f.onChange&&D._f.onChange(m);const Mn=T(C,nt,Je),aa=!Se(Mn)||Tn;if(!Je&&h.state.next({name:C,type:m.type,values:ue(i)}),oa)return(f.isValid||p.isValid)&&(e.mode==="onBlur"?Je&&y():Je||y()),aa&&h.state.next({name:C,...Tn?{}:Mn});if(!Je&&Tn&&h.state.next({...n}),e.resolver){const{errors:Xr}=await z([C]);if(S([C]),E(nt),P){const la=ti(n.errors,r,C),es=ti(Xr,r,la.name||C);Q=es.error,C=es.name,ke=Se(Xr)}}else S([C],!0),Q=(await ri(D,a.disabled,i,k,e.shouldUseNativeValidation))[C],S([C]),E(nt),P&&(Q?ke=!1:(f.isValid||p.isValid)&&(ke=await H(r,!0)));P&&(D._f.deps&&(!Array.isArray(D._f.deps)||D._f.deps.length>0)&&xe(D._f.deps),I(C,ke,Q,Mn))}},ce=(m,b)=>{if(F(n.errors,b)&&m.focus)return m.focus(),1},xe=async(m,b={})=>{let C,P;const D=Ft(m);if(e.resolver){const E=await B(ie(m)?m:D);C=Se(E),P=m?!D.some(V=>F(E,V)):C}else m?(P=(await Promise.all(D.map(async E=>{const V=F(r,E);return await H(V&&V._f?{[E]:V}:V)}))).every(Boolean),!(!P&&!n.isValid)&&y()):P=C=await H(r);return h.state.next({...!Te(m)||(f.isValid||p.isValid)&&C!==n.isValid?{}:{name:m},...e.resolver||!m?{isValid:C}:{},errors:n.errors}),b.shouldFocus&&!P&&Pt(r,ce,m?D:a.mount),P},Le=(m,b)=>{let C={...o.mount?i:s};return b&&(C=Oo(b.dirtyFields?n.dirtyFields:n.touchedFields,C)),ie(m)?C:Te(m)?F(C,m):m.map(P=>F(C,P))},te=(m,b)=>({invalid:!!F((b||n).errors,m),isDirty:!!F((b||n).dirtyFields,m),error:F((b||n).errors,m),isValidating:!!F(n.validatingFields,m),isTouched:!!F((b||n).touchedFields,m)}),Oe=m=>{m&&Ft(m).forEach(b=>fe(n.errors,b)),h.state.next({errors:m?n.errors:{}})},ne=(m,b,C)=>{const P=(F(r,m,{_f:{}})._f||{}).ref,D=F(n.errors,m)||{},{ref:E,message:V,type:Y,...Q}=D;re(n.errors,m,{...Q,...b,ref:P}),h.state.next({name:m,errors:n.errors,isValid:!1}),C&&C.shouldFocus&&P&&P.focus&&P.focus()},Ae=(m,b)=>we(m)?h.state.subscribe({next:C=>"values"in C&&m(L(void 0,b),C)}):L(m,b,!0),At=m=>h.state.subscribe({next:b=>{Du(m.name,b.name,m.exact)&&Ou(b,m.formState||f,ia,m.reRenderRoot)&&m.callback({values:{...i},...n,...b,defaultValues:s})}}).unsubscribe,Nn=m=>(o.mount=!0,p={...p,...m.formState},At({...m,formState:{...u,...m.formState}})),An=(m,b={})=>{for(const C of m?Ft(m):a.mount)a.mount.delete(C),a.array.delete(C),b.keepValue||(fe(r,C),fe(i,C)),!b.keepError&&fe(n.errors,C),!b.keepDirty&&fe(n.dirtyFields,C),!b.keepTouched&&fe(n.touchedFields,C),!b.keepIsValidating&&fe(n.validatingFields,C),!e.shouldUnregister&&!b.keepDefaultValue&&fe(s,C);h.state.next({values:ue(i)}),h.state.next({...n,...b.keepDirty?{isDirty:M()}:{}}),!b.keepIsValid&&y()},Jr=({disabled:m,name:b})=>{if(je(m)&&o.mount||m||a.disabled.has(b)){const D=a.disabled.has(b)!==!!m;m?a.disabled.add(b):a.disabled.delete(b),D&&o.mount&&!o.action&&y()}},jn=(m,b={})=>{let C=F(r,m);const P=je(b.disabled)||je(e.disabled);return re(r,m,{...C||{},_f:{...C&&C._f?C._f:{ref:{name:m}},name:m,mount:!0,...b}}),a.mount.add(m),C?Jr({disabled:je(b.disabled)?b.disabled:e.disabled,name:m}):A(m,!0,b.value),{...P?{disabled:b.disabled||e.disabled}:{},...e.progressive?{required:!!b.required,min:Mt(b.min),max:Mt(b.max),minLength:Mt(b.minLength),maxLength:Mt(b.maxLength),pattern:Mt(b.pattern)}:{},name:m,onChange:de,onBlur:de,ref:D=>{if(D){jn(m,b),C=F(r,m);const E=ie(D.value)&&D.querySelectorAll&&D.querySelectorAll("input,select,textarea")[0]||D,V=wu(E),Y=C._f.refs||[];if(V?Y.find(Q=>Q===E):E===C._f.ref)return;re(r,m,{_f:{...C._f,...V?{refs:[...Y.filter(Jn),E,...Array.isArray(F(s,m))?[{}]:[]],ref:{type:E.type,name:m}}:{ref:E}}}),A(m,!1,void 0,E)}else C=F(r,m,{}),C._f&&(C._f.mount=!1),(e.shouldUnregister||b.shouldUnregister)&&!(Eo(a.array,m)&&o.action)&&a.unMount.add(m)}}},En=()=>e.shouldFocusError&&Pt(r,ce,a.mount),na=m=>{je(m)&&(h.state.next({disabled:m}),Pt(r,(b,C)=>{const P=F(r,C);P&&(b.disabled=P._f.disabled||m,Array.isArray(P._f.refs)&&P._f.refs.forEach(D=>{D.disabled=P._f.disabled||m}))},0,!1))},Gr=(m,b)=>async C=>{let P;C&&(C.preventDefault&&C.preventDefault(),C.persist&&C.persist());let D=ue(i);if(h.state.next({isSubmitting:!0}),e.resolver){const{errors:E,values:V}=await z();S(),n.errors=E,D=ue(V)}else await H(r);if(a.disabled.size)for(const E of a.disabled)fe(D,E);if(fe(n.errors,"root"),Se(n.errors)){h.state.next({errors:{}});try{await m(D,C)}catch(E){P=E}}else b&&await b({...n.errors},C),En(),setTimeout(En);if(h.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Se(n.errors)&&!P,submitCount:n.submitCount+1,errors:n.errors}),P)throw P},ra=(m,b={})=>{F(r,m)&&(ie(b.defaultValue)?q(m,ue(F(s,m))):(q(m,b.defaultValue),re(s,m,ue(b.defaultValue))),b.keepTouched||fe(n.touchedFields,m),b.keepDirty||(fe(n.dirtyFields,m),n.isDirty=b.defaultValue?M(m,ue(F(s,m))):M()),b.keepError||(fe(n.errors,m),f.isValid&&y()),h.state.next({...n}))},Zr=(m,b={})=>{const C=m?ue(m):s,P=ue(C),D=Se(m),E=D?s:P;if(b.keepDefaultValues||(s=C),!b.keepValues){if(b.keepDirtyValues){const V=new Set([...a.mount,...Object.keys(kt(s,i))]);for(const Y of Array.from(V)){const Q=F(n.dirtyFields,Y),ke=F(i,Y),nt=F(E,Y);Q&&!ie(ke)?re(E,Y,ke):!Q&&!ie(nt)&&q(Y,nt)}}else{if($r&&ie(m))for(const V of a.mount){const Y=F(r,V);if(Y&&Y._f){const Q=Array.isArray(Y._f.refs)?Y._f.refs[0]:Y._f.ref;if(gn(Q)){const ke=Q.closest("form");if(ke){ke.reset();break}}}}if(b.keepFieldsRef)for(const V of a.mount)q(V,F(E,V));else r={}}i=e.shouldUnregister?b.keepDefaultValues?ue(s):{}:ue(E),h.array.next({values:{...E}}),h.state.next({values:{...E}})}a={mount:b.keepDirtyValues?a.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!f.isValid||!!b.keepIsValid||!!b.keepDirtyValues||!e.shouldUnregister&&!Se(E),o.watch=!!e.shouldUnregister,o.keepIsValid=!!b.keepIsValid,o.action=!1,b.keepErrors||(n.errors={}),h.state.next({submitCount:b.keepSubmitCount?n.submitCount:0,isDirty:D?!1:b.keepDirty?n.isDirty:!!(b.keepDefaultValues&&!Re(m,s)),isSubmitted:b.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:D?{}:b.keepDirtyValues?b.keepDefaultValues&&i?kt(s,i):n.dirtyFields:b.keepDefaultValues&&m?kt(s,m):b.keepDirty?n.dirtyFields:{},touchedFields:b.keepTouched?n.touchedFields:{},errors:b.keepErrors?n.errors:{},isSubmitSuccessful:b.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:s})},Yr=(m,b)=>Zr(we(m)?m(i):m,{...e.resetOptions,...b}),sa=(m,b={})=>{const C=F(r,m),P=C&&C._f;if(P){const D=P.refs?P.refs[0]:P.ref;D.focus&&setTimeout(()=>{D.focus(),b.shouldSelect&&we(D.select)&&D.select()})}},ia=m=>{n={...n,...m}},Qr={control:{register:jn,unregister:An,getFieldState:te,handleSubmit:Gr,setError:ne,_subscribe:At,_runSchema:z,_updateIsValidating:S,_focusError:En,_getWatch:L,_getDirty:M,_setValid:y,_setFieldArray:N,_setDisabledField:Jr,_setErrors:w,_getFieldArray:R,_reset:Zr,_resetDefaultValues:()=>we(e.defaultValues)&&e.defaultValues().then(m=>{Yr(m,e.resetOptions),h.state.next({isLoading:!1})}),_removeUnmounted:O,_disableForm:na,_subjects:h,_proxyFormState:f,get _fields(){return r},get _formValues(){return i},get _state(){return o},set _state(m){o=m},get _defaultValues(){return s},get _names(){return a},set _names(m){a=m},get _formState(){return n},get _options(){return e},set _options(m){e={...e,...m}}},subscribe:Nn,trigger:xe,register:jn,handleSubmit:Gr,watch:Ae,setValue:q,getValues:Le,reset:Yr,resetField:ra,clearErrors:Oe,unregister:An,setError:ne,setFocus:sa,getFieldState:te};return{...Qr,formControl:Qr}}function $u(t={}){const e=x.useRef(void 0),n=x.useRef(void 0),[r,s]=x.useState({isDirty:!1,isValidating:!1,isLoading:we(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:we(t.defaultValues)?void 0:t.defaultValues});if(!e.current)if(t.formControl)e.current={...t.formControl,formState:r},t.defaultValues&&!we(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:o,...a}=Ru(t);e.current={...a,formState:r}}const i=e.current.control;return i._options=t,_r(()=>{const o=i._subscribe({formState:i._proxyFormState,callback:()=>s({...i._formState}),reRenderRoot:!0});return s(a=>({...a,isReady:!0})),i._formState.isReady=!0,o},[i]),x.useEffect(()=>i._disableForm(t.disabled),[i,t.disabled]),x.useEffect(()=>{t.mode&&(i._options.mode=t.mode),t.reValidateMode&&(i._options.reValidateMode=t.reValidateMode)},[i,t.mode,t.reValidateMode]),x.useEffect(()=>{t.errors&&(i._setErrors(t.errors),i._focusError())},[i,t.errors]),x.useEffect(()=>{t.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,t.shouldUnregister]),x.useEffect(()=>{if(i._proxyFormState.isDirty){const o=i._getDirty();o!==r.isDirty&&i._subjects.state.next({isDirty:o})}},[i,r.isDirty]),x.useEffect(()=>{var o;t.values&&!Re(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(a=>({...a}))):i._resetDefaultValues()},[i,t.values]),x.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=x.useMemo(()=>Mo(r,i),[i,r]),e.current}function Vu(t,e=3){return t%1===0?t.toString():t.toFixed(e).replace(/\.?0+$/,"")}function Bu(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 zu(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 _u(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 Hu(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 qr(){return`dist-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}qr();const Uu={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:"$"},Gn=()=>({id:qr(),amount:0,glAccount:null,isTaxDeductible:!1}),Ro=({distribution:t,defaultDistribution:e,glAccounts:n=[],isLoadingGlAccounts:r=!1,onSearchGlAccounts:s,onDistributionChange:i,onAmountChange:o,onGlAccountChange:a,onTaxDeductibleChange:l,onDelete:d,canDelete:u=!0,canEditTaxDeductible:f=!0,isDisabled:p=!1,labels:h,classNames:k={},"data-testid":v,control:y,name:S,rules:N})=>{const j={...Uu,...h},w=y!==void 0&&S!==void 0,A=$u({defaultValues:{_internal:e||Gn()}}),T=ku({control:w?y:A.control,name:w?S:"_internal",rules:w?N:void 0}),[I,z]=x.useState(e||Gn()),B=w?T.field.value??Gn():t??I,H=w&&!!T.fieldState?.error,O=w&&(T.fieldState?.isTouched??!1),M=H||O,L=M&&(!B.amount||B.amount<=0),R=M&&!B.glAccount,[U,Z]=x.useState(B.glAccount?.name||""),q=x.useCallback(ne=>{const Ae={...B,...ne};w&&T.field.onChange(Ae),!w&&t===void 0&&z(Ae),i?.(Ae)},[B,t,i,w,T]),de=x.useCallback(ne=>{const Ae=ne||0;q({amount:Ae}),o?.(Ae)},[q,o]),ce=x.useCallback(ne=>{Z(ne),s?.(ne)},[s]),xe=x.useCallback(ne=>{if(ne===null){q({glAccount:null}),a?.(null);return}const At=n.find(Nn=>String(Nn.id)===String(ne))||null;q({glAccount:At}),a?.(At)},[n,q,a]),Le=x.useCallback(()=>{Z(""),q({glAccount:null}),a?.(null)},[q,a]),te=x.useCallback(ne=>{q({isTaxDeductible:ne}),l?.(ne)},[q,l]),Oe=x.useCallback(()=>{d?.()},[d]);return c.jsx(g.Card,{radius:"md",shadow:"sm","data-testid":v||"revenue-distribution-card",className:g.cn(k.base),children:c.jsxs(g.CardBody,{className:g.cn("flex flex-row flex-nowrap items-start gap-4",k.body),children:[c.jsx("div",{className:g.cn("shrink-0",k.amountContainer),children:c.jsx(g.NumberInput,{"data-testid":`${v||"revenue-distribution-card"}-amount-input`,label:c.jsxs("span",{className:"flex items-center gap-1",children:[j.amount,c.jsx(g.Tooltip,{content:j.amountTooltip,children:c.jsx(ae,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),value:B.amount||void 0,onValueChange:de,labelPlacement:"outside",placeholder:j.amountPlaceholder,isWheelDisabled:!0,hideStepper:!0,variant:"bordered",isDisabled:p,isInvalid:L,errorMessage:L?"Amount is required":void 0,minValue:0,step:.01,className:k.amountInput,startContent:c.jsx("div",{className:"pointer-events-none flex items-center",children:c.jsx("span",{className:"text-default-400 text-small",children:j.currencySymbol})})})}),c.jsx("div",{className:g.cn("grow",k.glAccountContainer),children:c.jsx(g.Autocomplete,{"data-testid":`${v||"revenue-distribution-card"}-gl-account-input`,label:c.jsxs("span",{className:"flex items-center gap-1",children:[j.glAccount,c.jsx(g.Tooltip,{content:j.glAccountTooltip,children:c.jsx(ae,{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:B.glAccount?.name??U,selectedKey:B.glAccount?.id??null,isDisabled:p,isInvalid:R,errorMessage:R?"GL Account is required":void 0,listboxProps:{emptyContent:r?j.searching:j.noGlAccountsFound},placeholder:j.glAccountPlaceholder,onInputChange:ce,onSelectionChange:xe,onClear:Le,className:k.glAccountInput,children:ne=>c.jsx(g.AutocompleteItem,{textValue:ne.name,children:c.jsxs("div",{className:"flex flex-col",children:[c.jsx("span",{children:ne.name}),ne.code&&c.jsx("span",{className:"text-xs text-default-400",children:ne.code})]})},ne.id)})}),c.jsx("div",{className:g.cn("shrink-0 pt-6 flex items-center",k.taxDeductibleContainer),children:c.jsx(g.Checkbox,{radius:"full","data-testid":`${v||"revenue-distribution-card"}-tax-deductible`,isSelected:B.isTaxDeductible,onValueChange:te,isDisabled:p||!f,className:k.taxDeductibleCheckbox,children:j.taxDeductible})}),c.jsx("div",{className:g.cn("shrink-0 pt-6",k.deleteContainer),children:c.jsx(G,{"data-testid":`${v||"revenue-distribution-card"}-delete-button`,size:"sm",color:"danger",variant:"flat",isDisabled:p||!u,onPress:Oe,startContent:c.jsx(ae,{icon:"solar:trash-bin-trash-linear",width:16}),className:g.cn("text-danger",k.deleteButton),children:j.deleteButton})})]})})};Ro.displayName="RevenueDistributionCard";const $o=({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(ae,{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})};$o.displayName="RevenueDistributionEmpty";const qu={title:"Error Loading Distributions",description:"An error occurred while loading the distribution configuration. Please try again."},Vo=({error:t,labels:e,showCard:n=!0,color:r="danger",classNames:s={}})=>{const i={...qu,...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})};Vo.displayName="RevenueDistributionError";const Bo=({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))})};Bo.displayName="RevenueDistributionSkeleton";const Ku={title:"Select Membership",renewalTitle:"Automatic Renewal",renewalDescription:"Membership will automatically renew at the end of each period"},Wu=({cards:t,locale:e,currency:n,listHeightClassName:r="",labels:s,showRenewal:i=!0,defaultRenewalValue:o=!1,initialSelectedMembershipId:a=null,allowReselect:l=!0,onRenewalChange:d,onCardSelect:u,className:f=""})=>{const p=Array.isArray(t)?t:[],[h,k]=x.useState(a),[v,y]=x.useState(o),S={...Ku,...s};x.useEffect(()=>{k(a)},[a]);const N=w=>{if(w===h){l&&u?.(w);return}k(w),u?.(w)},j=w=>{y(w),d?.(w)};return c.jsxs("div",{className:g.cn("w-full flex flex-col gap-4 items-start p-4 h-svh",f),"data-testid":"membership-select-cards",children:[c.jsx("span",{className:"hidden","data-testid":"membership-select-cards-selected-id",children:h??""}),c.jsx("p",{className:"text-2xl font-semibold text-left","data-testid":"membership-select-cards-title",children:S.title}),i&&c.jsx(_o,{title:S.renewalTitle,description:S.renewalDescription,value:v,onValueChange:j}),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:p.map(w=>c.jsx(zo,{itemKey:w.id,name:w.name,type:w.type,price:w.price,locale:e,currency:n,isSelected:h===w.id,onSelect:N},w.id))})]})},zo=({itemKey:t,name:e,type:n,price:r,locale:s="en-US",currency:i="USD",isSelected:o=!1,onSelect:a,className:l=""})=>{const d=new Intl.NumberFormat(s,{style:"currency",currency:i,minimumFractionDigits:0,maximumFractionDigits:2}).format(r);return c.jsx(g.Card,{shadow:"none",isPressable:!!a,onPress:()=>a?.(t),className:g.cn("w-full min-h-fit border rounded-3xl",o?"border-primary bg-primary/5":"border-default",l),"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:d})]})})},_o=({title:t,value:e,description:n,onValueChange:r,className:s=""})=>{const i=x.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"})]})},Ju={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"},Gu=(t,e)=>new Intl.NumberFormat(t,{style:"currency",currency:e}),Ho=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),Zu=t=>t.reduce((e,n)=>e+n.dates.reduce((r,s)=>r+s.tickets.reduce((i,o)=>i+o.max,0),0),0),Kr=t=>t.flatMap(e=>e.dates.flatMap(n=>n.tickets.map(r=>({exhibition:e,dateGroup:n,ticket:r})))),si=(t,e,n)=>{const r={};let s=n?e??Zu(t):0;for(const{exhibition:i,dateGroup:o,ticket:a}of Kr(t)){r[i.id]??={},r[i.id][o.id]??={};const l=n?Math.min(a.max,s):0;r[i.id][o.id][a.id]={id:a.id,selectedQuantity:l,originalPrice:a.originalPrice,discountedPrice:a.price},s-=l}return r},ii=(t,e,n)=>`${t}::${e}::${n}`,Yu=(t,e,n)=>{const r=Ho(e);for(const{exhibition:s,dateGroup:i,ticket:o}of Kr(t)){const a=e[s.id]?.[i.id]?.[o.id]?.selectedQuantity??0,l=n===void 0?o.max:Math.min(o.max,n-(r-a));if(l>0&&a<l)return!1}return!0},Qu=({initialQuantity:t=1,minQuantity:e=1,maxQuantity:n=10,onChange:r,disabled:s=!1})=>{const i=Math.max(e,Math.min(n,t)),[o,a]=x.useState(()=>String(i)),[l,d]=x.useState(!1),u=l?o:String(i),f=()=>{s||i>=n||r?.(i+1)},p=()=>{s||i<=e||r?.(i-1)},h=w=>{if(s)return;a(w.target.value);const A=parseInt(w.target.value,10);isNaN(A)||r?.(Math.max(e,Math.min(n,A)))},k=w=>{const A=parseInt(w.target.value,10);if(d(!1),isNaN(A)){r?.(e);return}const T=Math.max(e,Math.min(n,A));T!==A?r?.(T):a(String(T))},v=i<=e,y=i>=n,S="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",j="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:p,disabled:s||v,className:g.cn(S,s||v?j:N),"aria-label":"Decrement quantity","data-testid":"quantity-decrement",children:"-"}),c.jsx("input",{type:"number",value:u,onChange:h,onFocus:()=>d(!0),onBlur:k,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||y,className:g.cn(S,s||y?j:N),"aria-label":"Increment quantity","data-testid":"quantity-increment",children:"+"})]})},Xu=({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})]})},ef=({item:t,quantity:e,onChange:n,getTotalSelectedTickets:r,userMaxLimit:s,settings:i,labels:o})=>{const a=()=>{if(!r||s===void 0)return t.max;const f=r();return Math.min(t.max,s-(f-e))},l=i?.locale??"en-US",d=i?.currency??"USD",u=Gu(l,d);return c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center justify-between bg-white px-3 py-2.5 gap-8","data-testid":"upgrade-ticket-item",children:[c.jsxs("div",{className:"min-w-0 flex flex-1 flex-col gap-2",children:[c.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[c.jsxs("h3",{className:"min-w-0 text-base font-semibold text-zinc-900 m-0","data-testid":"ticket-name",children:[t.name,typeof t.purchasedQuantity=="number"&&t.purchasedQuantity>1?c.jsx("span",{"data-testid":"ticket-purchased-quantity",children:` x${t.purchasedQuantity}`}):null]}),c.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[c.jsx("h3",{className:"line-through text-zinc-500 text-[0.9rem] font-normal m-0","data-testid":"ticket-original-price",children:u.format(t.originalPrice)}),c.jsx("h3",{className:"text-base font-semibold text-zinc-900 m-0","data-testid":"ticket-discounted-price",children:u.format(t.price)})]})]}),t.membershipName?c.jsx("div",{"data-testid":"ticket-membership-name",className:"max-w-full self-start rounded-2xl bg-default-100 px-3 py-1 text-xs text-default-700",title:t.membershipName,children:c.jsx("p",{className:"max-w-full truncate text-center",children:t.membershipName})}):null,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(Qu,{initialQuantity:e,minQuantity:0,maxQuantity:a(),onChange:n})]}),t.membershipAlert?c.jsx(g.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:c.jsx("span",{className:"ticket-selection-membership-alert-description-text block w-full whitespace-normal break-words text-sm leading-4 text-[#5B2C0F]",children:t.membershipAlert})}):null]})},tf=({exhibitionId:t,dateGroup:e,isLast:n=!1,onQuantityChange:r,getTicketQuantity:s,getTotalSelectedTickets:i,userMaxLimit:o,settings:a,labels:l})=>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((d,u)=>c.jsxs("div",{children:[c.jsx(ef,{item:d,quantity:s(t,e.id,d.id),onChange:f=>r(t,e.id,d.id,f),getTotalSelectedTickets:i,userMaxLimit:o,settings:a,labels:l}),u<e.tickets.length-1?c.jsx(g.Divider,{className:"bg-zinc-200","data-testid":"upgrade-ticket-divider"}):null]},d.id))]}),nf=({title:t,exhibition:e,onQuantityChange:n,getTicketQuantity:r,getTotalSelectedTickets:s,userMaxLimit:i,settings:o,labels:a,initialExpanded:l=!1})=>{const[d,u]=x.useState(l),f=e.dates.reduce((h,k)=>h+k.tickets.reduce((v,y)=>v+r(e.id,k.id,y.id),0),0),p=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:()=>u(!d),"aria-expanded":d,"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," ",a.ticketsSelectedToRedeem]}),c.jsx("span",{className:g.cn("inline-flex items-center justify-center text-zinc-500 text-xl transition-transform duration-200",d&&"rotate-180"),"aria-hidden":"true",children:c.jsx(ae,{icon:"mdi:chevron-down"})})]})]})}),c.jsx("div",{id:`upgrade-items-${e.id}`,className:g.cn("transition-all duration-300 overflow-hidden",d?"max-h-[1000px] opacity-100":"max-h-0 opacity-0"),"aria-hidden":!d,children:d&&c.jsx("div",{className:"px-5 flex flex-col gap-6","data-testid":"upgrade-ticket-items",children:p?e.dates.map((h,k)=>c.jsx(tf,{exhibitionId:e.id,dateGroup:h,isLast:k===e.dates.length-1,onQuantityChange:n,getTicketQuantity:r,getTotalSelectedTickets:s,userMaxLimit:i,settings:o,labels:a},h.id)):c.jsx("div",{className:"px-5 py-10 text-center",children:c.jsx("p",{className:"m-0 text-zinc-500 italic",children:a.noUpgradeTicketsAvailable})})})})]})},rf=({initialExpanded:t=!1,userMaxLimit:e,labels:n,settings:r,ticketSelectionData:s,className:i="",onSelectionChange:o})=>{const a=x.useMemo(()=>s??[],[s]),l={...Ju,...n},[d,u]=x.useState(()=>si(a,e,!0)),f=x.useRef(!1),p=x.useMemo(()=>{const N=Kr(a).map(({exhibition:j,dateGroup:w,ticket:A})=>[ii(j.id,w.id,A.id),A]);return new Map(N)},[a]),h=Yu(a,d,e),k=(N,j,w)=>d[N]?.[j]?.[w]?.selectedQuantity??0,v=()=>Ho(d),y=(N,j,w,A)=>{const T=k(N,j,w),I=v()-T;if(e!==void 0&&I+A>e)return;const z=p.get(ii(N,j,w));if(!z)return;const B={...d,[N]:{...d[N],[j]:{...d[N]?.[j],[w]:{id:w,selectedQuantity:A,originalPrice:z.originalPrice,discountedPrice:z.price}}}};u(B),o?.(B)},S=N=>{const j=si(a,e,N);u(j),o?.(j)};return x.useEffect(()=>{!f.current&&h&&(o?.(d),f.current=!0)},[h,d,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:l.ticketSelectionTitle}),c.jsx(Xu,{label:l.selectAllButtonLabel,checked:h,onChange:S})]}),a.map(N=>c.jsx(nf,{title:N.exhibitionName,exhibition:N,onQuantityChange:y,getTicketQuantity:k,getTotalSelectedTickets:v,userMaxLimit:e,settings:r,labels:l,initialExpanded:t},N.id))]})},sf=350,of={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}"},Zn=(t,e)=>Object.entries(e).reduce((n,[r,s])=>n.replace(`{${r}}`,s),t),af=({dueAmount:t,received:e,defaultReceived:n=null,onChange:r,locale:s="en-US",labels:i,isDisabled:o=!1,maxAmount:a,autoFocus:l=!1,className:d,"data-testid":u="cash-tender-form"})=>{const f={...of,...i},p=vr(t.currency,s),h=e!==void 0,[k,v]=x.useState(n??null),y=h?e:k,S=x.useMemo(()=>{const L=typeof y=="number"&&Number.isFinite(y)?y:0,R=Qn(L,t.value,t.currency,s);return{received:L,change:R>0?R:0,isValid:L>=t.value&&L>0}},[y,t.value,t.currency,s]),N=x.useCallback(L=>{const R=L.currentTarget;requestAnimationFrame(()=>{R.isConnected&&R.select()})},[]),j=x.useCallback(L=>{if(o)return;const R=L.replace(/[^\d.,]/g,"").replace(",","."),U=R===""?null:Number.parseFloat(R),Z=U===null||Number.isNaN(U)?null:U;if(Z!==null&&a!==void 0&&Z>a)return;h||v(Z);const q=typeof Z=="number"&&Number.isFinite(Z)?Z:0,de=Qn(q,t.value,t.currency,s);r?.({received:q,change:de>0?de:0,isValid:q>=t.value&&q>0})},[h,o,t.value,t.currency,s,r,a]),w=y==null?"":String(y),A=S.isValid&&S.change>0,T=!S.isValid&&S.received>0,I=ht(S.change,s,t.currency),z=ht(t.value,s,t.currency),[B,H]=x.useState(""),O=x.useRef(null);x.useEffect(()=>{O.current&&clearTimeout(O.current);const L=A?Zn(f.changeMessageTemplate,{change:I}):"",R=A?sf:0;return O.current=setTimeout(()=>H(L),R),()=>{O.current&&clearTimeout(O.current)}},[A,I,f.changeMessageTemplate]);const M=`${u}-received`;return c.jsxs("div",{className:g.cn("flex flex-col gap-3",d),"data-testid":u,children:[c.jsx(g.Input,{id:M,label:f.receivedLabel,labelPlacement:"outside",type:"text",inputMode:p===0?"numeric":"decimal",pattern:p===0?"[0-9]*":"[0-9]*[.,]?[0-9]*",value:w,onChange:L=>j(L.target.value),onFocus:N,placeholder:f.receivedPlaceholder,isDisabled:o,isInvalid:T,errorMessage:T?Zn(f.insufficientMessageTemplate,{due:z}):void 0,variant:"bordered",radius:"lg",autoFocus:l,"data-testid":`${u}-received-input`}),A&&c.jsx(g.Alert,{"data-testid":`${u}-change-alert`,color:"primary",variant:"flat",radius:"lg",title:f.changeLabel,description:Zn(f.changeMessageTemplate,{change:I}),icon:c.jsx(ae,{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"}}),c.jsx("span",{role:"status","aria-live":"polite",className:"sr-only",children:B})]})},lf={checkNumberLabel:"Check Number",checkNumberPlaceholder:"e.g. 11234",bankNameLabel:"Bank Name",bankNamePlaceholder:"e.g. Chase Bank",dateLabel:"Date",checkNumberRequiredMessage:"Check number is required"},oi=()=>{const t=new Date,e=n=>String(n).padStart(2,"0");return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}`},Uo=({dueAmount:t,value:e,defaultValue:n,onChange:r,labels:s,hideDate:i=!1,hideBankName:o=!1,isDisabled:a=!1,checkNumberMaxLength:l=34,bankNameMaxLength:d=100,autoFocus:u=!1,className:f,"data-testid":p="check-tender-form"})=>{const h={...lf,...s},k=e!==void 0,[v,y]=x.useState({checkNumber:n?.checkNumber??"",bankName:n?.bankName??"",date:n?.date??oi()}),[S,N]=x.useState(!!n?.checkNumber),j=x.useMemo(()=>k?{checkNumber:e?.checkNumber??"",bankName:e?.bankName??"",date:e?.date??oi()}:v,[k,e,v]),w=x.useCallback(O=>{k||y(O);const M=O.checkNumber.trim(),L={amount:t.value,checkNumber:M,bankName:O.bankName.trim()||void 0,date:i?void 0:O.date,isValid:M.length>0&&t.value>0};r?.(L)},[k,t.value,i,r]),A=x.useCallback(O=>M=>{a||(O==="checkNumber"&&M.length>0&&N(!0),w({...j,[O]:M}))},[j,w,a]),T=x.useCallback(()=>{a||N(!0)},[a]),I=S&&j.checkNumber.trim()==="",z=`${p}-check-number`,B=`${p}-bank-name`,H=`${p}-date`;return c.jsxs("div",{className:g.cn("grid grid-cols-1 sm:grid-cols-2 gap-4",f),"data-testid":p,children:[c.jsx(g.Input,{id:z,label:h.checkNumberLabel,labelPlacement:"outside",type:"text",value:j.checkNumber,onChange:O=>A("checkNumber")(O.target.value),onBlur:T,placeholder:h.checkNumberPlaceholder,maxLength:l,isRequired:!0,isInvalid:I,errorMessage:I?h.checkNumberRequiredMessage:void 0,isDisabled:a,variant:"bordered",radius:"lg",autoFocus:u,"data-testid":`${p}-check-number-input`}),!o&&c.jsx(g.Input,{id:B,label:h.bankNameLabel,labelPlacement:"outside",type:"text",value:j.bankName,onChange:O=>A("bankName")(O.target.value),placeholder:h.bankNamePlaceholder,maxLength:d,isDisabled:a,variant:"bordered",radius:"lg","data-testid":`${p}-bank-name-input`}),!i&&c.jsx(g.Input,{id:H,label:h.dateLabel,labelPlacement:"outside",type:"date",value:j.date,onChange:O=>A("date")(O.target.value),isDisabled:a,variant:"bordered",radius:"lg","data-testid":`${p}-date-input`,className:"sm:col-span-2"})]})};Uo.displayName="CheckTenderForm";const cf={methodLabel:"Method",methodPlaceholder:"Select a payment method",referenceLabel:"Reference",referencePlaceholder:"e.g. Voucher #1234",methodRequiredMessage:"Method is required"},df=[{value:"ach",label:"ACH"},{value:"wire",label:"Wire"},{value:"gift_card",label:"Gift Card"},{value:"voucher",label:"Voucher"},{value:"other",label:"Other"}],qo=({dueAmount:t,methodOptions:e=df,value:n,defaultValue:r,onChange:s,labels:i,showReference:o=!1,isDisabled:a=!1,className:l,"data-testid":d="other-tender-form"})=>{const u={...cf,...i},f=n!==void 0,[p,h]=x.useState({method:r?.method??"",reference:r?.reference??""}),k=x.useMemo(()=>f?{method:n?.method??"",reference:n?.reference??""}:p,[f,n,p]),v=x.useCallback(A=>e.find(T=>T.value===A)?.label??"",[e]),y=x.useCallback(A=>{f||h(A);const T=v(A.method),I={amount:t.value,method:A.method,description:T,reference:A.reference.trim()||void 0,isValid:A.method!==""};s?.(I)},[f,t.value,s,v]),S=x.useCallback(A=>{if(a)return;const T=typeof A=="string"?A:Array.from(A)[0]?.toString()??"";y({...k,method:T})},[k,y,a]),N=x.useCallback(A=>{a||y({...k,reference:A})},[k,y,a]),j=`${d}-method`,w=`${d}-reference`;return c.jsxs("div",{className:g.cn("flex flex-col gap-3",l),"data-testid":d,children:[c.jsx(wt,{id:j,label:u.methodLabel,labelPlacement:"outside",placeholder:u.methodPlaceholder,selectedKeys:k.method?[k.method]:[],onSelectionChange:S,isDisabled:a,isRequired:!0,variant:"bordered",radius:"lg","data-testid":`${d}-method-select`,popoverProps:{placement:"bottom-start",classNames:{content:"bg-white border border-default-200 shadow-lg rounded-xl p-1"}},listboxProps:{classNames:{list:"max-h-[var(--popover-available-height,40vh)] overflow-y-auto"},itemClasses:{base:["rounded-lg","px-3 py-2","text-default-800","data-[hover=true]:bg-default-100","data-[selectable=true]:focus:bg-default-100","data-[selected=true]:bg-primary-50","data-[selected=true]:text-primary","data-[selected=true]:font-medium"]}},children:e.map(A=>c.jsx(g.SelectItem,{"data-testid":`${d}-method-option-${A.value}`,children:A.label},A.value))}),o&&c.jsx(g.Input,{id:w,label:u.referenceLabel,labelPlacement:"outside",type:"text",value:k.reference,onChange:A=>N(A.target.value),placeholder:u.referencePlaceholder,isDisabled:a,variant:"bordered",radius:"lg","data-testid":`${d}-reference-input`})]})};qo.displayName="OtherTenderForm";const uf={collectedHeading:"Collected",remainingLabel:"Remaining:",completeLabel:"Complete",removeAriaLabel:"Remove this tender",removeTooltipForRecorded:"Already recorded",statusPending:"Pending",statusRecorded:"Approved",statusFailed:"Failed"},ff={card:"lucide:credit-card",cash:"lucide:dollar-sign",check:"lucide:edit-3",other:"lucide:more-horizontal"},hf={pending:"warning",recorded:"success",failed:"danger"},pf=t=>t==="pending"||t==="recorded",mf=t=>`#${t+1}`,Ko=({total:t,tenders:e,onRemove:n,locale:r="en-US",labels:s,hideCollectedList:i=!1,className:o,"data-testid":a="split-payment-summary"})=>{const l={...uf,...s},{collected:d,remaining:u,isComplete:f}=x.useMemo(()=>{const h=e.reduce((v,y)=>pf(y.status)?v+y.amount:v,0),k=Math.max(t.value-h,0);return{collected:h,remaining:k,isComplete:h>=t.value&&t.value>0}},[e,t.value]),p=h=>h==="pending"?l.statusPending:h==="recorded"?l.statusRecorded:l.statusFailed;return c.jsxs("div",{className:g.cn("flex flex-col gap-4",o),"data-testid":a,children:[c.jsxs("div",{className:"rounded-2xl bg-default-100 px-6 py-5 text-center","data-testid":`${a}-remaining-banner`,children:[c.jsx("div",{className:"text-sm text-default-600",children:f?l.completeLabel:l.remainingLabel}),c.jsx("div",{className:"mt-1 text-4xl font-bold tracking-tight","data-testid":`${a}-remaining-amount`,children:ht(f?d:u,r,t.currency)})]}),!i&&e.length>0&&c.jsxs("div",{className:"flex flex-col gap-2","data-testid":`${a}-collected-list`,children:[c.jsx("h3",{className:"text-base font-semibold",children:l.collectedHeading}),e.map((h,k)=>c.jsx(gf,{index:k,tender:h,locale:r,currency:t.currency,removable:!!n&&h.status!=="recorded",onRemove:n?()=>n(h.id):void 0,statusLabel:p(h.status),removeAriaLabel:l.removeAriaLabel,recordedTooltip:l.removeTooltipForRecorded,dataTestId:`${a}-row-${k}`},h.id))]})]})};Ko.displayName="SplitPaymentSummary";const gf=({index:t,tender:e,locale:n,currency:r,removable:s,onRemove:i,statusLabel:o,removeAriaLabel:a,recordedTooltip:l,dataTestId:d})=>{const u=i?c.jsx(G,{isIconOnly:!0,variant:"light",radius:"full",size:"sm",onPress:i,isDisabled:!s,"aria-label":a,"data-testid":`${d}-remove`,className:g.cn(s?"text-default-700 hover:bg-default-200":"text-default-300"),children:c.jsx(ae,{icon:"lucide:x",width:18,height:18,"aria-hidden":"true"})}):null;return c.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:[c.jsx("span",{className:"text-sm font-medium text-default-500 w-6 shrink-0",children:mf(t)}),c.jsx(ae,{icon:ff[e.type],width:20,height:20,className:"text-default-700 shrink-0","aria-hidden":"true"}),c.jsx("span",{className:"flex-1 truncate","data-testid":`${d}-label`,children:e.label}),c.jsx("span",{className:"font-semibold tabular-nums","data-testid":`${d}-amount`,children:ht(e.amount,n,r)}),c.jsx(g.Chip,{size:"sm",radius:"full",variant:"flat",color:hf[e.status],startContent:e.status==="recorded"?c.jsx(ae,{icon:"lucide:check-circle",width:14,height:14,"aria-hidden":"true"}):e.status==="failed"?c.jsx(ae,{icon:"lucide:alert-circle",width:14,height:14,"aria-hidden":"true"}):void 0,"data-testid":`${d}-status`,children:o}),u&&(s?u:c.jsx(g.Tooltip,{content:l,placement:"left",children:c.jsx("span",{tabIndex:0,"aria-label":l,children:u})}))]})},xf=`
18
+ `);return{dom:c,text:p,slice:t}}function Ma(e,t,n,r,s){let i=s.parent.type.spec.code,a,o;if(!n&&!t)return null;let c=!!t&&(r||i||!n);if(c){if(e.someProp("transformPastedText",p=>{t=p(t,i||r,e)}),i)return o=new X(Z.from(e.state.schema.text(t.replace(/\r\n?/g,`
19
+ `))),0,0),e.someProp("transformPasted",p=>{o=p(o,e,!0)}),o;let h=e.someProp("clipboardTextParser",p=>p(t,s,r,e));if(h)o=h;else{let p=s.marks(),{schema:m}=e.state,v=Vn.fromSchema(m);a=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(b=>{let x=a.appendChild(document.createElement("p"));b&&x.appendChild(v.serializeNode(m.text(b,p)))})}}else e.someProp("transformPastedHTML",h=>{n=h(n,e)}),a=_d(n),ns&&Vd(a);let d=a&&a.querySelector("[data-pm-slice]"),u=d&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(d.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let h=+u[3];h>0;h--){let p=a.firstChild;for(;p&&p.nodeType!=1;)p=p.nextSibling;if(!p)break;a=p}if(o||(o=(e.someProp("clipboardParser")||e.someProp("domParser")||Nn.fromSchema(e.state.schema)).parseSlice(a,{preserveWhitespace:!!(c||u),context:s,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!Rd.test(p.parentNode.nodeName)?{ignore:!0}:null}})),u)o=Hd(li(o,+u[1],+u[2]),u[4]);else if(o=X.maxOpen(zd(o.content,s),!0),o.openStart||o.openEnd){let h=0,p=0;for(let m=o.content.firstChild;h<o.openStart&&!m.type.spec.isolating;h++,m=m.firstChild);for(let m=o.content.lastChild;p<o.openEnd&&!m.type.spec.isolating;p++,m=m.lastChild);o=li(o,h,p)}return e.someProp("transformPasted",h=>{o=h(o,e,c)}),o}const Rd=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function zd(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let s=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(o=>{if(!a)return;let c=s.findWrapping(o.type),d;if(!c)return a=null;if(d=a.length&&i.length&&Ta(c,i,o,a[a.length-1],0))a[a.length-1]=d;else{a.length&&(a[a.length-1]=Da(a[a.length-1],i.length));let u=Ea(o,c);a.push(u),s=s.matchType(u.type),i=c}}),a)return Z.from(a)}return e}function Ea(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,Z.from(e));return e}function Ta(e,t,n,r,s){if(s<e.length&&s<t.length&&e[s]==t[s]){let i=Ta(e,t,n,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==e.length-1?n.type:e[s+1]))return r.copy(r.content.append(Z.from(Ea(n,e,s+1))))}}function Da(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,Da(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(Z.empty,!0);return e.copy(n.append(r))}function Lr(e,t,n,r,s,i){let a=t<0?e.firstChild:e.lastChild,o=a.content;return e.childCount>1&&(i=0),s<r-1&&(o=Lr(o,t,n,r,s+1,i)),s>=n&&(o=t<0?a.contentMatchAt(0).fillBefore(o,i<=s).append(o):o.append(a.contentMatchAt(a.childCount).fillBefore(Z.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,a.copy(o))}function li(e,t,n){return t<e.openStart&&(e=new X(Lr(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new X(Lr(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const Ia={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let oi=null;function $a(){return oi||(oi=document.implementation.createHTMLDocument("title"))}let ur=null;function Bd(e){let t=window.trustedTypes;return t?(ur||(ur=t.defaultPolicy||t.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),ur.createHTML(e)):e}function _d(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=$a().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(e),s;if((s=r&&Ia[r[1].toLowerCase()])&&(e=s.map(i=>"<"+i+">").join("")+e+s.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=Bd(e),s)for(let i=0;i<s.length;i++)n=n.querySelector(s[i])||n;return n}function Vd(e){let t=e.querySelectorAll(Ye?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}function Hd(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:s,openStart:i,openEnd:a}=e;for(let o=r.length-2;o>=0;o-=2){let c=n.nodes[r[o]];if(!c||c.hasRequiredAttrs())break;s=Z.from(c.create(r[o+1],s)),i++,a++}return new X(s,i,a)}const _e={},Oe={};function et(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}Oe.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!La(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(sn&&Ye&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),ts&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();e.input.lastIOSEnter=r,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==r&&(e.someProp("handleKeyDown",s=>s(e,ba(13,"Enter"))),e.input.lastIOSEnter=0)},200)}else e.someProp("handleKeyDown",r=>r(e,n))||Pd(e,n)?n.preventDefault():et(e,"key")};Oe.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)};Oe.keypress=(e,t)=>{let n=t;if(La(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||Le&&n.metaKey)return;if(e.someProp("handleKeyPress",s=>s(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof ie)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!e.someProp("handleTextInput",a=>a(e,r.$from.pos,r.$to.pos,s,i))&&e.dispatch(i()),n.preventDefault()}};function Wn(e){return{left:e.clientX,top:e.clientY}}function Ud(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function ss(e,t,n,r,s){if(r==-1)return!1;let i=e.state.doc.resolve(r);for(let a=i.depth+1;a>0;a--)if(e.someProp(t,o=>a>i.depth?o(e,n,i.nodeAfter,i.before(a),s,!0):o(e,n,i.node(a),i.before(a),s,!1)))return!0;return!1}function Et(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);r.setMeta("pointer",!0),e.dispatch(r)}function qd(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&ee.isSelectable(r)?(Et(e,new ee(n)),!0):!1}function Wd(e,t){if(t==-1)return!1;let n=e.state.selection,r,s;n instanceof ee&&(r=n.node);let i=e.state.doc.resolve(t);for(let a=i.depth+1;a>0;a--){let o=a>i.depth?i.nodeAfter:i.node(a);if(ee.isSelectable(o)){r&&n.$from.depth>0&&a>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?s=i.before(n.$from.depth):s=i.before(a);break}}return s!=null?(Et(e,ee.create(e.state.doc,s)),!0):!1}function Kd(e,t,n,r,s){return ss(e,"handleClickOn",t,n,r)||e.someProp("handleClick",i=>i(e,t,r))||(s?Wd(e,n):qd(e,n))}function Jd(e,t,n,r){return ss(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",s=>s(e,t,r))}function Yd(e,t,n,r){return ss(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",s=>s(e,t,r))||Gd(e,n,r)}function Gd(e,t,n){if(n.button!=0)return!1;let r=e.state.doc;if(t==-1)return r.inlineContent?(Et(e,ie.create(r,0,r.content.size)),!0):!1;let s=r.resolve(t);for(let i=s.depth+1;i>0;i--){let a=i>s.depth?s.nodeAfter:s.node(i),o=s.before(i);if(a.inlineContent)Et(e,ie.create(r,o+1,o+1+a.content.size));else if(ee.isSelectable(a))Et(e,ee.create(r,o));else continue;return!0}}function is(e){return Tn(e)}const Oa=Le?"metaKey":"ctrlKey";_e.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=is(e),s=Date.now(),i="singleClick";s-e.input.lastClick.time<500&&Ud(n,e.input.lastClick)&&!n[Oa]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type=="singleClick"?i="doubleClick":e.input.lastClick.type=="doubleClick"&&(i="tripleClick")),e.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:i,button:n.button};let a=e.posAtCoords(Wn(n));a&&(i=="singleClick"?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new Qd(e,a,n,!!r)):(i=="doubleClick"?Jd:Yd)(e,a.pos,a.inside,n)?n.preventDefault():et(e,"pointer"))};class Qd{constructor(t,n,r,s){this.view=t,this.pos=n,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!r[Oa],this.allowDefault=r.shiftKey;let i,a;if(n.inside>-1)i=t.state.doc.nodeAt(n.inside),a=n.inside;else{let u=t.state.doc.resolve(n.pos);i=u.parent,a=u.depth?u.before():0}const o=s?null:r.target,c=o?t.docView.nearestDesc(o,!0):null;this.target=c&&c.nodeDOM.nodeType==1?c.nodeDOM:null;let{selection:d}=t.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||d instanceof ee&&d.from<=a&&d.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&qn&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),et(t,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>rs(this.view)),this.view.input.mouseDown=null}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(Wn(t))),this.updateAllowDefault(t),this.allowDefault||!n?et(this.view,"pointer"):Kd(this.view,n.pos,n.inside,t,this.selectNode)?t.preventDefault():t.button==0&&(this.flushed||vt&&this.mightDrag&&!this.mightDrag.node.isAtom||Ye&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Et(this.view,ae.near(this.view.state.doc.resolve(n.pos))),t.preventDefault()):et(this.view,"pointer")}move(t){this.updateAllowDefault(t),et(this.view,"pointer"),t.buttons==0&&this.done()}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}}_e.touchstart=e=>{e.input.lastTouch=Date.now(),is(e),et(e,"pointer")};_e.touchmove=e=>{e.input.lastTouch=Date.now(),et(e,"pointer")};_e.contextmenu=e=>is(e);function La(e,t){return e.composing?!0:vt&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}const Zd=sn?5e3:-1;Oe.compositionstart=Oe.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof ie&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Ye&&Na&&Xd(e)))e.markCursor=e.state.storedMarks||n.marks(),Tn(e,!0),e.markCursor=null;else if(Tn(e,!t.selection.empty),qn&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=e.domSelectionRange();for(let s=r.focusNode,i=r.focusOffset;s&&s.nodeType==1&&i!=0;){let a=i<0?s.lastChild:s.childNodes[i-1];if(!a)break;if(a.nodeType==3){let o=e.domSelection();o&&o.collapse(a,a.nodeValue.length);break}else s=a,i=-1}}e.input.composing=!0}Fa(e,Zd)};function Xd(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||t.nodeType!=1||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}Oe.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,Fa(e,20))};function Fa(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Tn(e),t))}function eu(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=tu());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function tu(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}function Tn(e,t=!1){if(!(sn&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),eu(e),t||e.docView&&e.docView.dirty){let n=jd(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function nu(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}const Xt=rn&&wa<15||ts&&Cd<604;_e.copy=Oe.cut=(e,t)=>{let n=t,r=e.state.selection,s=n.type=="cut";if(r.empty)return;let i=Xt?null:n.clipboardData,a=r.content(),{dom:o,text:c}=Aa(e,a);i?(n.preventDefault(),i.clearData(),i.setData("text/html",o.innerHTML),i.setData("text/plain",c)):nu(e,o),s&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function ru(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function su(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Fr(e,r.value,null,s,t):Fr(e,r.textContent,r.innerHTML,s,t)},50)}function Fr(e,t,n,r,s){let i=Ma(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",c=>c(e,s,i||X.empty)))return!0;if(!i)return!1;let a=ru(i),o=a?e.state.tr.replaceSelectionWith(a,r):e.state.tr.replaceSelection(i);return e.dispatch(o.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Pa(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Oe.paste=(e,t)=>{let n=t;if(e.composing&&!sn)return;let r=Xt?null:n.clipboardData,s=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&Fr(e,Pa(r),r.getData("text/html"),s,n)?n.preventDefault():su(e,n)};class iu{constructor(t,n,r){this.slice=t,this.move=n,this.node=r}}const au=Le?"altKey":"ctrlKey";function Ra(e,t){let n=e.someProp("dragCopies",r=>!r(t));return n??!t[au]}_e.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=e.state.selection,i=s.empty?null:e.posAtCoords(Wn(n)),a;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof ee?s.to-1:s.to))){if(r&&r.mightDrag)a=ee.create(e.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let h=e.docView.nearestDesc(n.target,!0);h&&h.node.type.spec.draggable&&h!=e.docView&&(a=ee.create(e.state.doc,h.posBefore))}}let o=(a||e.state.selection).content(),{dom:c,text:d,slice:u}=Aa(e,o);(!n.dataTransfer.files.length||!Ye||ka>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Xt?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",Xt||n.dataTransfer.setData("text/plain",d),e.dragging=new iu(u,Ra(e,n),a)};_e.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)};Oe.dragover=Oe.dragenter=(e,t)=>t.preventDefault();Oe.drop=(e,t)=>{try{lu(e,t,e.dragging)}finally{e.dragging=null}};function lu(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(Wn(t));if(!r)return;let s=e.state.doc.resolve(r.pos),i=n&&n.slice;i?e.someProp("transformPasted",m=>{i=m(i,e,!1)}):i=Ma(e,Pa(t.dataTransfer),Xt?null:t.dataTransfer.getData("text/html"),!1,s);let a=!!(n&&Ra(e,t));if(e.someProp("handleDrop",m=>m(e,t,i||X.empty,a))){t.preventDefault();return}if(!i)return;t.preventDefault();let o=i?da(e.state.doc,s.pos,i):s.pos;o==null&&(o=s.pos);let c=e.state.tr;if(a){let{node:m}=n;m?m.replace(c):c.deleteSelection()}let d=c.mapping.map(o),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,h=c.doc;if(u?c.replaceRangeWith(d,d,i.content.firstChild):c.replaceRange(d,d,i),c.doc.eq(h))return;let p=c.doc.resolve(d);if(u&&ee.isSelectable(i.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new ee(p));else{let m=c.mapping.map(o);c.mapping.maps[c.mapping.maps.length-1].forEach((v,b,x,w)=>m=w),c.setSelection(Ca(e,p,c.doc.resolve(m)))}e.focus(),e.dispatch(c.setMeta("uiEvent","drop"))}_e.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&rs(e)},20))};_e.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)};_e.beforeinput=(e,t)=>{if(Ye&&sn&&t.inputType=="deleteContentBackward"){e.domObserver.flushSoon();let{domChangeCount:r}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=r||(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",i=>i(e,ba(8,"Backspace")))))return;let{$cursor:s}=e.state.selection;s&&s.pos>0&&e.dispatch(e.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let e in Oe)_e[e]=Oe[e];function en(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class Dn{constructor(t,n){this.toDOM=t,this.spec=n||gt,this.side=this.spec.side||0}map(t,n,r,s){let{pos:i,deleted:a}=t.mapResult(n.from+s,this.side<0?-1:1);return a?null:new He(i-r,i-r,this)}valid(){return!0}eq(t){return this==t||t instanceof Dn&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&en(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}}class nt{constructor(t,n){this.attrs=t,this.spec=n||gt}map(t,n,r,s){let i=t.map(n.from+s,this.spec.inclusiveStart?-1:1)-r,a=t.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=a?null:new He(i,a,this)}valid(t,n){return n.from<n.to}eq(t){return this==t||t instanceof nt&&en(this.attrs,t.attrs)&&en(this.spec,t.spec)}static is(t){return t.type instanceof nt}destroy(){}}class as{constructor(t,n){this.attrs=t,this.spec=n||gt}map(t,n,r,s){let i=t.mapResult(n.from+s,1);if(i.deleted)return null;let a=t.mapResult(n.to+s,-1);return a.deleted||a.pos<=i.pos?null:new He(i.pos-r,a.pos-r,this)}valid(t,n){let{index:r,offset:s}=t.content.findIndex(n.from),i;return s==n.from&&!(i=t.child(r)).isText&&s+i.nodeSize==n.to}eq(t){return this==t||t instanceof as&&en(this.attrs,t.attrs)&&en(this.spec,t.spec)}destroy(){}}class He{constructor(t,n,r){this.from=t,this.to=n,this.type=r}copy(t,n){return new He(t,n,this.type)}eq(t,n=0){return this.type.eq(t.type)&&this.from+n==t.from&&this.to+n==t.to}map(t,n,r){return this.type.map(t,this,n,r)}static widget(t,n,r){return new He(t,t,new Dn(n,r))}static inline(t,n,r,s){return new He(t,n,new nt(r,s))}static node(t,n,r,s){return new He(t,n,new as(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof nt}get widget(){return this.type instanceof Dn}}const jt=[],gt={};class be{constructor(t,n){this.local=t.length?t:jt,this.children=n.length?n:jt}static create(t,n){return n.length?In(n,t,0,gt):Ae}find(t,n,r){let s=[];return this.findInner(t??0,n??1e9,s,0,r),s}findInner(t,n,r,s,i){for(let a=0;a<this.local.length;a++){let o=this.local[a];o.from<=n&&o.to>=t&&(!i||i(o.spec))&&r.push(o.copy(o.from+s,o.to+s))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<n&&this.children[a+1]>t){let o=this.children[a]+1;this.children[a+2].findInner(t-o,n-o,r,s+o,i)}}map(t,n,r){return this==Ae||t.maps.length==0?this:this.mapInner(t,n,0,0,r||gt)}mapInner(t,n,r,s,i){let a;for(let o=0;o<this.local.length;o++){let c=this.local[o].map(t,r,s);c&&c.type.valid(n,c)?(a||(a=[])).push(c):i.onRemove&&i.onRemove(this.local[o].spec)}return this.children.length?ou(this.children,a||[],t,n,r,s,i):a?new be(a.sort(xt),jt):Ae}add(t,n){return n.length?this==Ae?be.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let s,i=0;t.forEach((o,c)=>{let d=c+r,u;if(u=Ba(n,o,d)){for(s||(s=this.children.slice());i<s.length&&s[i]<c;)i+=3;s[i]==c?s[i+2]=s[i+2].addInner(o,u,d+1):s.splice(i,0,c,c+o.nodeSize,In(u,o,d+1,gt)),i+=3}});let a=za(i?_a(n):n,-r);for(let o=0;o<a.length;o++)a[o].type.valid(t,a[o])||a.splice(o--,1);return new be(a.length?this.local.concat(a).sort(xt):this.local,s||this.children)}remove(t){return t.length==0||this==Ae?this:this.removeInner(t,0)}removeInner(t,n){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let a,o=r[i]+n,c=r[i+1]+n;for(let u=0,h;u<t.length;u++)(h=t[u])&&h.from>o&&h.to<c&&(t[u]=null,(a||(a=[])).push(h));if(!a)continue;r==this.children&&(r=this.children.slice());let d=r[i+2].removeInner(a,o+1);d!=Ae?r[i+2]=d:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,a;i<t.length;i++)if(a=t[i])for(let o=0;o<s.length;o++)s[o].eq(a,n)&&(s==this.local&&(s=this.local.slice()),s.splice(o--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new be(s,r):Ae}forChild(t,n){if(this==Ae)return this;if(n.isLeaf)return be.empty;let r,s;for(let o=0;o<this.children.length;o+=3)if(this.children[o]>=t){this.children[o]==t&&(r=this.children[o+2]);break}let i=t+1,a=i+n.content.size;for(let o=0;o<this.local.length;o++){let c=this.local[o];if(c.from<a&&c.to>i&&c.type instanceof nt){let d=Math.max(i,c.from)-i,u=Math.min(a,c.to)-i;d<u&&(s||(s=[])).push(c.copy(d,u))}}if(s){let o=new be(s.sort(xt),jt);return r?new dt([o,r]):o}return r||Ae}eq(t){if(this==t)return!0;if(!(t instanceof be)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(t.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=t.children[n]||this.children[n+1]!=t.children[n+1]||!this.children[n+2].eq(t.children[n+2]))return!1;return!0}locals(t){return ls(this.localsInner(t))}localsInner(t){if(this==Ae)return jt;if(t.inlineContent||!this.local.some(nt.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof nt||n.push(this.local[r]);return n}forEachSet(t){t(this)}}be.empty=new be([],[]);be.removeOverlap=ls;const Ae=be.empty;class dt{constructor(t){this.members=t}map(t,n){const r=this.members.map(s=>s.map(t,n,gt));return dt.from(r)}forChild(t,n){if(n.isLeaf)return be.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(t,n);i!=Ae&&(i instanceof dt?r=r.concat(i.members):r.push(i))}return dt.from(r)}eq(t){if(!(t instanceof dt)||t.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(t.members[n]))return!1;return!0}locals(t){let n,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(t);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let a=0;a<i.length;a++)n.push(i[a])}}return n?ls(r?n:n.sort(xt)):jt}static from(t){switch(t.length){case 0:return Ae;case 1:return t[0];default:return new dt(t.every(n=>n instanceof be)?t:t.reduce((n,r)=>n.concat(r instanceof be?r:r.members),[]))}}forEachSet(t){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(t)}}function ou(e,t,n,r,s,i,a){let o=e.slice();for(let d=0,u=i;d<n.maps.length;d++){let h=0;n.maps[d].forEach((p,m,v,b)=>{let x=b-v-(m-p);for(let w=0;w<o.length;w+=3){let S=o[w+1];if(S<0||p>S+u-h)continue;let M=o[w]+u-h;m>=M?o[w+1]=p<=M?-2:-1:p>=u&&x&&(o[w]+=x,o[w+1]+=x)}h+=x}),u=n.maps[d].map(u,-1)}let c=!1;for(let d=0;d<o.length;d+=3)if(o[d+1]<0){if(o[d+1]==-2){c=!0,o[d+1]=-1;continue}let u=n.map(e[d]+i),h=u-s;if(h<0||h>=r.content.size){c=!0;continue}let p=n.map(e[d+1]+i,-1),m=p-s,{index:v,offset:b}=r.content.findIndex(h),x=r.maybeChild(v);if(x&&b==h&&b+x.nodeSize==m){let w=o[d+2].mapInner(n,x,u+1,e[d]+i+1,a);w!=Ae?(o[d]=h,o[d+1]=m,o[d+2]=w):(o[d+1]=-2,c=!0)}else c=!0}if(c){let d=cu(o,e,t,n,s,i,a),u=In(d,r,0,a);t=u.local;for(let h=0;h<o.length;h+=3)o[h+1]<0&&(o.splice(h,3),h-=3);for(let h=0,p=0;h<u.children.length;h+=3){let m=u.children[h];for(;p<o.length&&o[p]<m;)p+=3;o.splice(p,0,u.children[h],u.children[h+1],u.children[h+2])}}return new be(t.sort(xt),o)}function za(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let s=e[r];n.push(new He(s.from+t,s.to+t,s.type))}return n}function cu(e,t,n,r,s,i,a){function o(c,d){for(let u=0;u<c.local.length;u++){let h=c.local[u].map(r,s,d);h?n.push(h):a.onRemove&&a.onRemove(c.local[u].spec)}for(let u=0;u<c.children.length;u+=3)o(c.children[u+2],c.children[u]+d+1)}for(let c=0;c<e.length;c+=3)e[c+1]==-1&&o(e[c+2],t[c]+i+1);return n}function Ba(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,s=null;for(let i=0,a;i<e.length;i++)(a=e[i])&&a.from>n&&a.to<r&&((s||(s=[])).push(a),e[i]=null);return s}function _a(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function In(e,t,n,r){let s=[],i=!1;t.forEach((o,c)=>{let d=Ba(e,o,c+n);if(d){i=!0;let u=In(d,o,n+c+1,r);u!=Ae&&s.push(c,c+o.nodeSize,u)}});let a=za(i?_a(e):e,-n).sort(xt);for(let o=0;o<a.length;o++)a[o].type.valid(t,a[o])||(r.onRemove&&r.onRemove(a[o].spec),a.splice(o--,1));return a.length||s.length?new be(a,s):Ae}function xt(e,t){return e.from-t.from||e.to-t.to}function ls(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let s=n+1;s<t.length;s++){let i=t[s];if(i.from==r.from){i.to!=r.to&&(t==e&&(t=e.slice()),t[s]=i.copy(i.from,r.to),ci(t,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,i.from),ci(t,s,r.copy(i.from,r.to)));break}}}return t}function ci(e,t,n){for(;t<e.length&&xt(n,e[t])>0;)t++;e.splice(t,0,n)}class me extends ae{constructor(t){super(t,t)}map(t,n){let r=t.resolve(n.map(this.head));return me.valid(r)?new me(r):ae.near(r)}content(){return X.empty}eq(t){return t instanceof me&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new me(t.resolve(n.pos))}getBookmark(){return new os(this.anchor)}static valid(t){let n=t.parent;if(n.isTextblock||!du(t)||!uu(t))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let s=n.contentMatchAt(t.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(t,n,r=!1){e:for(;;){if(!r&&me.valid(t))return t;let s=t.pos,i=null;for(let a=t.depth;;a--){let o=t.node(a);if(n>0?t.indexAfter(a)<o.childCount:t.index(a)>0){i=o.child(n>0?t.indexAfter(a):t.index(a)-1);break}else if(a==0)return null;s+=n;let c=t.doc.resolve(s);if(me.valid(c))return c}for(;;){let a=n>0?i.firstChild:i.lastChild;if(!a){if(i.isAtom&&!i.isText&&!ee.isSelectable(i)){t=t.doc.resolve(s+i.nodeSize*n),r=!1;continue e}break}i=a,s+=n;let o=t.doc.resolve(s);if(me.valid(o))return o}return null}}}me.prototype.visible=!1;me.findFrom=me.findGapCursorFrom;ae.jsonID("gapcursor",me);class os{constructor(t){this.pos=t}map(t){return new os(t.map(this.pos))}resolve(t){let n=t.resolve(this.pos);return me.valid(n)?new me(n):ae.near(n)}}function Va(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function du(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||Va(s.type))return!0;if(s.inlineContent)return!1}}return!0}function uu(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||Va(s.type))return!0;if(s.inlineContent)return!1}}return!0}function fu(){return new Un({props:{decorations:gu,createSelectionBetween(e,t,n){return t.pos==n.pos&&me.valid(n)?new me(n):null},handleClick:mu,handleKeyDown:hu,handleDOMEvents:{beforeinput:pu}}})}const hu=kd({ArrowLeft:hn("horiz",-1),ArrowRight:hn("horiz",1),ArrowUp:hn("vert",-1),ArrowDown:hn("vert",1)});function hn(e,t){const n=e=="vert"?t>0?"down":"up":t>0?"right":"left";return function(r,s,i){let a=r.selection,o=t>0?a.$to:a.$from,c=a.empty;if(a instanceof ie){if(!i.endOfTextblock(n)||o.depth==0)return!1;c=!1,o=r.doc.resolve(t>0?o.after():o.before())}let d=me.findGapCursorFrom(o,t,c);return d?(s&&s(r.tr.setSelection(new me(d))),!0):!1}}function mu(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!me.valid(r))return!1;let s=e.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&ee.isSelectable(e.state.doc.nodeAt(s.inside))?!1:(e.dispatch(e.state.tr.setSelection(new me(r))),!0)}function pu(e,t){if(t.inputType!="insertCompositionText"||!(e.state.selection instanceof me))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let s=Z.empty;for(let a=r.length-1;a>=0;a--)s=Z.from(r[a].createAndFill(null,s));let i=e.state.tr.replace(n.pos,n.pos,new X(s,0,0));return i.setSelection(ie.near(i.doc.resolve(n.pos+1))),e.dispatch(i),!1}function gu(e){if(!(e.selection instanceof me))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",be.create(e.doc,[He.widget(e.selection.head,t,{key:"gapcursor"})])}const xu=V.Extension.create({name:"gapCursor",addProseMirrorPlugins(){return[fu()]},extendNodeSchema(e){var t;const n={name:e.name,options:e.options,storage:e.storage};return{allowGapCursor:(t=V.callOrReturn(V.getExtensionField(e,"allowGapCursor",n)))!==null&&t!==void 0?t:null}}}),Rt={bold:{category:"mark",extension:pc,priority:100},italic:{category:"mark",extension:vc,priority:100},strike:{category:"mark",extension:Nc,priority:100},underline:{category:"mark",extension:Eo.Underline,priority:100},code:{category:"mark",extension:jc,priority:100},textColor:{category:"mark",extension:To.Color,defaultOptions:{types:["textStyle","heading","paragraph","listItem","taskItem","blockquote"]},priority:90},highlight:{category:"mark",extension:Do.Highlight,defaultOptions:{multicolor:!0},priority:90},link:{category:"mark",extension:Io.Link,defaultOptions:{autolink:!0,linkOnPaste:!0,openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}},priority:100},heading:{category:"node",extension:Ec,defaultOptions:{levels:[1,2,3,4,5,6]},priority:100},bulletList:{category:"node",extension:Ic,defaultOptions:{HTMLAttributes:{class:"list-disc"}},priority:90},orderedList:{category:"node",extension:Oc,defaultOptions:{HTMLAttributes:{class:"list-decimal"}},priority:90},taskList:{category:"node",extension:$o.TaskList,defaultOptions:{HTMLAttributes:{class:"task-list"}},priority:90},codeBlock:{category:"node",extension:Gc,priority:100},blockquote:{category:"node",extension:Zc,priority:100},horizontalRule:{category:"node",extension:Xc,priority:100},hardBreak:{category:"node",extension:ed,priority:100},undo:{category:"extension",extension:Ys,priority:50},redo:{category:"extension",extension:Ys,priority:50},textAlign:{category:"extension",extension:Lo.TextAlign,defaultOptions:{types:["heading","paragraph","listItem","bulletList","orderedList","taskList","taskItem","blockquote"],alignments:["left","center","right","justify"],defaultAlignment:"left"},priority:80},clearMarks:{category:"extension",extension:null,priority:50},clearNodes:{category:"extension",extension:null,priority:50}},yu=[dd,ud,Tc,Mc.configure({HTMLAttributes:{}}),Lc.configure({HTMLAttributes:{}}),Oo.TaskItem.configure({nested:!0}),md,xu];function bu(e){const t=[],n=new Set,r=new Set;yu.forEach(o=>{o&&(t.push(o),r.add(o.name))});const s=e.map(o=>Yt(o)),i=new Set;return s.forEach(o=>{const c=Rt[o];c?.requiredExtensions&&c.requiredExtensions.forEach(d=>{i.add(d)})}),i.forEach(o=>{if(n.has(o))return;const c=Rt[o];if(!c||c.extension===null)return;const d=c.extension.name;if(r.has(d)){n.add(o);return}const u=c.defaultOptions?c.extension.configure(c.defaultOptions):c.extension;t.push(u),n.add(o),r.add(d)}),s.forEach(o=>{if(n.has(o))return;const c=Rt[o];if(!c){console.warn(`Extension config not found for modifier: ${o}`);return}if(c.extension===null){n.add(o);return}const d=c.extension.name;if(r.has(d)){n.add(o);return}const u=c.defaultOptions?c.extension.configure(c.defaultOptions):c.extension;t.push(u),n.add(o),r.add(d)}),t.sort((o,c)=>{const d=Object.values(Rt).find(m=>m?.extension?.name===o.name),u=Object.values(Rt).find(m=>m?.extension?.name===c.name),h=d?.priority??100;return(u?.priority??100)-h})}const Ha={simple:["bold","italic","bulletList","orderedList","undo","redo"],blog:["bold","italic","underline",{type:"heading",level:2},{type:"heading",level:3},"textAlign","bulletList","orderedList","link","blockquote","undo","redo"],documentation:["bold","italic","strike","underline","code","clearMarks",{type:"heading",level:1},{type:"heading",level:2},{type:"heading",level:3},{type:"heading",level:4},{type:"heading",level:5},{type:"heading",level:6},"textAlign","bulletList","orderedList","taskList","link","textColor","highlight","codeBlock","blockquote","horizontalRule","hardBreak","undo","redo"],comment:["bold","italic","link","undo","redo"],full:["bold","italic","strike","underline","code","clearMarks",{type:"heading",level:1},{type:"heading",level:2},{type:"heading",level:3},{type:"heading",level:4},{type:"heading",level:5},{type:"heading",level:6},"textAlign","bulletList","orderedList","taskList","link","textColor","highlight","codeBlock","blockquote","horizontalRule","hardBreak","undo","redo"]},he={fontFamily:{mono:'"JetBrains Mono", Consolas, monospace'},fontSize:{sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","4xl":"2.25rem"},fontWeight:{semibold:"600",bold:"700"},lineHeight:{tight:"1.25",normal:"1.5"}},Qe={brand:{primary:{DEFAULT:"#C14615"}},neutral:{gray:{100:"#F3F4F6",200:"#E5E7EB",300:"#D1D5DB",500:"#6B7280",800:"#1F2937"}},palettes:{warning:{200:"#fde68a"}}},de={xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem"},vu={h1:`font-size: ${he.fontSize["4xl"]}; font-weight: ${he.fontWeight.semibold}; line-height: ${he.lineHeight.tight}; margin: ${de.md} 0 ${de.sm} 0;`,h2:`font-size: ${he.fontSize["2xl"]}; font-weight: ${he.fontWeight.semibold}; line-height: ${he.lineHeight.tight}; margin: ${de.md} 0 ${de.sm} 0;`,h3:`font-size: ${he.fontSize.xl}; font-weight: ${he.fontWeight.semibold}; line-height: ${he.lineHeight.tight}; margin: ${de.md} 0 ${de.sm} 0;`,h4:`font-size: ${he.fontSize.lg}; font-weight: ${he.fontWeight.semibold}; line-height: ${he.lineHeight.tight}; margin: ${de.md} 0 ${de.sm} 0;`,h5:`font-size: ${he.fontSize.base}; font-weight: ${he.fontWeight.semibold}; line-height: ${he.lineHeight.tight}; margin: ${de.md} 0 ${de.sm} 0;`,h6:`font-size: ${he.fontSize.sm}; font-weight: ${he.fontWeight.semibold}; line-height: ${he.lineHeight.tight}; margin: ${de.md} 0 ${de.sm} 0;`,p:`min-height: ${he.lineHeight.normal}em; margin: 0;`,ul:`list-style-type: disc; list-style-position: outside; padding-left: ${de.xl}; margin: ${de.md} 0;`,ol:`list-style-type: decimal; list-style-position: outside; padding-left: ${de.xl}; margin: ${de.md} 0;`,li:`display: list-item; margin: ${de.xs} 0;`,strong:`font-weight: ${he.fontWeight.bold};`,em:"font-style: italic;",s:"text-decoration: line-through;",u:"text-decoration: underline;",code:`background-color: ${Qe.neutral.gray[100]}; border-radius: 0.4rem; font-size: ${he.fontSize.sm}; padding: 0.25em 0.3em; font-family: ${he.fontFamily.mono};`,pre:`background: ${Qe.neutral.gray[800]}; border-radius: ${de.sm}; color: ${Qe.neutral.gray[100]}; font-family: ${he.fontFamily.mono}; margin: ${de.lg} 0; padding: 0.75rem ${de.md}; overflow-x: auto;`,blockquote:`border-left: 3px solid ${Qe.neutral.gray[300]}; margin: ${de.lg} 0; padding-left: ${de.md}; color: ${Qe.neutral.gray[500]};`,hr:`border: none; border-top: 1px solid ${Qe.neutral.gray[200]}; margin: ${de.xl} 0;`,a:`color: ${Qe.brand.primary.DEFAULT}; text-decoration: underline; cursor: pointer;`,mark:`background-color: ${Qe.palettes.warning[200]}; border-radius: ${de.xs}; padding: 0 0.125rem;`,label:`display: flex; align-items: center; gap: ${de.sm}; cursor: pointer;`,input:"cursor: pointer; margin: 0;"},wu={taskList:"list-style: none; padding-left: 0; margin: 1rem 0;",taskItem:"display: flex; align-items: flex-start; gap: 0.5rem; margin: 0.5rem 0;"};function ku(e){if(!e)return e;let t=e;for(const[n,r]of Object.entries(wu)){const s=new RegExp(`(<(?:ul|li)[^>]*data-type="${n}"[^>]*)>`,"gi");t=t.replace(s,(i,a)=>i.includes('style="')?i.replace(/style="([^"]*)"/,`style="$1 ${r}"`):`${a} style="${r}">`)}for(const[n,r]of Object.entries(vu)){const s=new RegExp(`<${n}(\\s[^>]*)?>`,"gi");t=t.replace(s,i=>{if(i.includes('data-type="taskList"')||i.includes('data-type="taskItem"'))return i;if(i.includes('style="'))return i.replace(/style="([^"]*)"/,`style="$1 ${r}"`);if(i.includes("style='"))return i.replace(/style='([^']*)'/,`style='$1 ${r}'`);{const a=i.indexOf(">");return`${i.slice(0,a)} style="${r}"${i.slice(a)}`}})}return t}const Nu=({modifiers:e,zoom:t,onZoomChange:n,onToolbarAction:r})=>{const{editor:s}=Jr.useCurrentEditor();return l.jsx(dc,{editor:s,modifiers:e,zoom:t,onZoomChange:n,onToolbarAction:r})},Su=({showCharacterCount:e,showWordCount:t})=>{const{editor:n}=Jr.useCurrentEditor();if(!n||!e&&!t)return null;const r=n.getText(),s=r.length,i=r.split(/\s+/).filter(a=>a.length>0).length;return l.jsxs("div",{className:"flex gap-4 text-xs text-default-500 px-2 pb-1",children:[e&&l.jsxs("span",{children:[s," characters"]}),t&&l.jsxs("span",{children:[i," words"]})]})},Pr=y.forwardRef((e,t)=>{const{minRows:n=10,maxRows:r=30,disableAutosize:s=!1,showCharacterCount:i=!1,showWordCount:a=!1,showToolbar:o=!0,modifiers:c=Ha.full,variant:d="bordered",initialContent:u,content:h,onContentChange:p,onUpdate:m,onToolbarAction:v,isReadOnly:b=!1,isDisabled:x=!1,includeInlineStyles:w=!0,...S}=e,{zoom:M,setZoom:N}=lc(),j=Ts.lineHeight,T=n*j,$=s?void 0:r*j,W=y.useMemo(()=>bu(c),[c]),{Component:D,label:R,shouldLabelBeOutside:E,getBaseProps:C,getLabelProps:I,getInputWrapperProps:F}=f.useInput({...S,variant:d,ref:t,isMultiline:!0}),H=R?l.jsx("label",{...I(),children:R}):null,Q=y.useCallback(({editor:Y})=>{const te=Y.getHTML(),oe=w?ku(te):te,ce=Y.getJSON(),P=Y.getText(),_=P.length,G=P.split(/\s+/).filter(Se=>Se.length>0).length,ne={html:oe,json:ce,text:P,characters:_,words:G};if(p?.(ne),m?.(ne),"onChange"in S&&typeof S.onChange=="function"){const Se={target:{value:oe},currentTarget:{value:oe}};S.onChange(Se)}},[p,m,S,w]);return l.jsxs(D,{...C(),children:[E?H:null,l.jsx("div",{...F(),className:f.cn(F().className,"flex flex-col w-full p-0 gap-0 rich-text-editor"),style:{maxHeight:$?`${$+Ts.toolbarHeight}px`:void 0,overflow:$?"auto":void 0},children:l.jsx(Jr.EditorProvider,{editable:!b&&!x,slotBefore:o?l.jsx(Nu,{modifiers:c,zoom:M,onZoomChange:N,onToolbarAction:v}):void 0,slotAfter:l.jsx(Su,{showCharacterCount:i,showWordCount:a}),editorContainerProps:{className:"w-full flex-1 outline-none",style:{minHeight:`${T}px`,fontSize:`${M}%`,display:"flex",flexDirection:"column"}},editorProps:{attributes:{class:"focus:outline-none w-full h-full"}},extensions:W,content:h||u||e.defaultValue||"",onUpdate:Q})})]})});Pr.displayName="TipTapEditor";const Ua=y.forwardRef((e,t)=>{const{adapter:n="tiptap",variant:r="bordered",...s}=e;return n==="tiptap"?l.jsx(Pr,{...s,variant:r,ref:t}):(console.warn(`Adapter "${n}" is not supported. Using TipTap.`),l.jsx(Pr,{...s,variant:r,ref:t}))});Ua.displayName="RichTextArea";function Cu(e,t="en-US",n="USD"){try{return new Intl.NumberFormat(t,{style:"currency",currency:n,minimumFractionDigits:0,maximumFractionDigits:2}).format(e)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${e.toFixed(2)}`}}const di=[{id:"100",amount:100},{id:"250",amount:250},{id:"500",amount:500},{id:"1000",amount:1e3},{id:"2000",amount:2e3}],ju={title:"Donation Amount",customAmountPlaceholder:"Custom donation amount",customAmountAriaLabel:"Custom donation amount",addDonationButton:"Add Donation"},qa=({presetAmounts:e=di,selectedDonation:t,defaultSelectedDonation:n=null,onChange:r,onAddDonation:s,currency:i="USD",locale:a="en-US",showCustomAmount:o=!0,minCustomAmount:c=.5,maxCustomAmount:d=1e6,labels:u,mobileColumns:h=2,desktopColumns:p=3,isDisabled:m=!1,buttonVariant:v="bordered",buttonColor:b="default",inputVariant:x="bordered",size:w="md",className:S="",showCard:M=!0})=>{const N={...ju,...u},j=Array.isArray(e)?e:di,T={2:"grid-cols-2",3:"grid-cols-3"},$={3:"sm:grid-cols-3",4:"sm:grid-cols-4",5:"sm:grid-cols-5",6:"sm:grid-cols-6"},W=`${T[h]} ${$[p]}`,[D,R]=Yr(t,n,r),[E,C]=y.useState(""),[I,F]=y.useState(!1),[H,Q]=y.useState(0),Y=y.useCallback(_=>{if(m)return;const G={amount:_.amount,isCustom:!1,presetId:_.id};R(G),C(""),F(!1),Q(ne=>ne+1),s?.(G)},[m,R,s]),te=y.useCallback(_=>{if(m)return;if(C(_!==void 0?String(_):""),s){R(null);return}if(_===void 0||isNaN(_)){R(null);return}R({amount:_,isCustom:!0})},[m,R,s]),oe=y.useCallback(()=>{if(m)return;const _=E!==""?parseFloat(E):void 0;_===void 0||isNaN(_)||s?.({amount:_,isCustom:!0})},[m,E,s]),ce=y.useMemo(()=>({style:"currency",currency:i,currencyDisplay:"symbol"}),[i]),P=l.jsxs("div",{className:"space-y-4","data-testid":"donation-amounts-root",children:[N.title&&l.jsx("h2",{className:"text-base font-semibold","data-testid":"donation-amounts-title",children:N.title}),j.length>0&&l.jsx("div",{className:f.cn("grid gap-3",W),"data-testid":"donation-amounts-presets",children:j.map(_=>{const G=D!==null&&!D.isCustom&&D.presetId===_.id;return l.jsx(K,{color:G?"primary":b,variant:G?"solid":v,className:"w-full",onPress:()=>Y(_),isDisabled:m,"data-testid":`donation-amounts-preset-${_.id}`,children:_.label||Cu(_.amount,a,i)},_.id)})}),o&&l.jsxs("div",{className:"flex gap-3 items-start",children:[l.jsx(f.NumberInput,{placeholder:N.customAmountPlaceholder,"aria-label":N.customAmountAriaLabel,onInput:s?()=>{R(null),F(!0)}:void 0,variant:x,radius:"full",size:w,minValue:c,maxValue:d,step:.01,formatOptions:ce,value:E!==""?parseFloat(E):void 0,onValueChange:te,isDisabled:m,className:"flex-1 [&_[data-slot=input-wrapper]]:!h-10 [&_[data-slot=input-wrapper]]:!min-h-10","data-testid":"donation-amounts-custom-input",hideStepper:!0},s?`custom-${H}`:D?.isCustom===!1?D.presetId:"custom"),s&&l.jsx(K,{color:"primary",variant:"solid",radius:"full",size:w,className:"shrink-0",onPress:oe,isDisabled:m||!I,"data-testid":"donation-amounts-add-button",children:N.addDonationButton})]})]});return M?l.jsx(f.Card,{className:f.cn("w-full",S),"data-testid":"donation-amounts-card",children:l.jsx(f.CardBody,{children:P})}):l.jsx("div",{className:f.cn("w-full",S),"data-testid":"donation-amounts-plain",children:P})};qa.displayName="DonationAmounts";const Au=e=>{const t=Math.max(0,e),n=Math.floor(t/60).toString().padStart(2,"0"),r=(t%60).toString().padStart(2,"0");return`${n}:${r} minutes`},Mu=e=>{switch(e){case"warning":return J.Clock;case"error":return J.AlertCircle;case"success":return J.CheckCircle;default:return J.Clock}},Eu=e=>{switch(e){case"primary":return"bg-primary-500";case"secondary":return"bg-gray-700";case"success":return"bg-green-600";case"warning":return"bg-amber-500";case"danger":return"bg-red-600";default:return"bg-primary-500"}},Wa=y.forwardRef(({timeLeft:e,defaultTimeLeft:t=1200,onTimeChange:n,onExpire:r,variant:s="info",color:i="primary",message:a="Your cart expires in:",showIcon:o=!0,icon:c,position:d="fixed",autoStart:u=!0,formatTime:h=Au,className:p,...m},v)=>{const[b,x]=Yr(e!==void 0?Math.max(0,e):void 0,Math.max(0,t),n),w=y.useRef(null),S=y.useRef(!1);y.useEffect(()=>()=>{w.current&&clearInterval(w.current)},[]),y.useEffect(()=>{if(!u||b<=0){w.current&&(clearInterval(w.current),w.current=null);return}return w.current=setInterval(()=>{x(T=>T<=1?(w.current&&(clearInterval(w.current),w.current=null),S.current||(S.current=!0,r?.()),0):T-1)},1e3),()=>{w.current&&(clearInterval(w.current),w.current=null)}},[u,b,x,r]),y.useEffect(()=>{b>0&&(S.current=!1)},[b]);const M=c||Mu(s),N=Eu(i),j={fixed:"fixed top-0 left-0",sticky:"sticky top-0",static:"static"};return l.jsx("div",{ref:v,role:"banner","aria-live":"polite","aria-label":`${a} ${h(b)}`,"data-testid":"expire-cart-timer",className:f.cn("w-full text-white z-50",N,j[d],p),...m,children:l.jsx("div",{className:"container mx-auto px-4 py-3 sm:py-2.5","data-testid":"expire-cart-timer-container",children:l.jsxs("div",{className:"flex items-center justify-between gap-3 sm:gap-4",children:[l.jsxs("div",{className:"flex items-center gap-3 sm:gap-2.5 flex-1 min-w-0","data-testid":"expire-cart-timer-left",children:[o&&l.jsx("div",{className:"flex-shrink-0 w-[0.875rem] h-[0.875rem] sm:w-4 sm:h-4 rounded-full bg-white flex items-center justify-center overflow-hidden","data-testid":"expire-cart-timer-icon-wrapper",children:l.jsx(M,{className:"text-primary-500 sm:text-primary-600","aria-hidden":"true",size:14,"data-testid":"expire-cart-timer-icon"})}),l.jsx("p",{className:"text-sm sm:text-base font-medium text-white","data-testid":"expire-cart-timer-message",children:a})]}),l.jsx("div",{className:"flex-shrink-0","data-testid":"expire-cart-timer-right",children:l.jsx("span",{className:"text-sm sm:text-base font-semibold text-white","aria-label":`Time remaining: ${h(b)}`,"data-testid":"expire-cart-timer-value",children:h(b)})})]})})})});Wa.displayName="ExpireCartTimer";function Tu(e,t){const n=e.icons,r=e.aliases||Object.create(null),s=Object.create(null);function i(a){if(n[a])return s[a]=[];if(!(a in s)){s[a]=null;const o=r[a]&&r[a].parent,c=o&&i(o);c&&(s[a]=[o].concat(c))}return s[a]}return Object.keys(n).concat(Object.keys(r)).forEach(i),s}const Ka=Object.freeze({left:0,top:0,width:16,height:16}),$n=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),cs=Object.freeze({...Ka,...$n}),Rr=Object.freeze({...cs,body:"",hidden:!1});function Du(e,t){const n={};!e.hFlip!=!t.hFlip&&(n.hFlip=!0),!e.vFlip!=!t.vFlip&&(n.vFlip=!0);const r=((e.rotate||0)+(t.rotate||0))%4;return r&&(n.rotate=r),n}function ui(e,t){const n=Du(e,t);for(const r in Rr)r in $n?r in e&&!(r in n)&&(n[r]=$n[r]):r in t?n[r]=t[r]:r in e&&(n[r]=e[r]);return n}function Iu(e,t,n){const r=e.icons,s=e.aliases||Object.create(null);let i={};function a(o){i=ui(r[o]||s[o],i)}return a(t),n.forEach(a),ui(e,i)}function Ja(e,t){const n=[];if(typeof e!="object"||typeof e.icons!="object")return n;e.not_found instanceof Array&&e.not_found.forEach(s=>{t(s,null),n.push(s)});const r=Tu(e);for(const s in r){const i=r[s];i&&(t(s,Iu(e,s,i)),n.push(s))}return n}const $u={provider:"",aliases:{},not_found:{},...Ka};function fr(e,t){for(const n in t)if(n in e&&typeof e[n]!=typeof t[n])return!1;return!0}function Ya(e){if(typeof e!="object"||e===null)return null;const t=e;if(typeof t.prefix!="string"||!e.icons||typeof e.icons!="object"||!fr(e,$u))return null;const n=t.icons;for(const s in n){const i=n[s];if(!s||typeof i.body!="string"||!fr(i,Rr))return null}const r=t.aliases||Object.create(null);for(const s in r){const i=r[s],a=i.parent;if(!s||typeof a!="string"||!n[a]&&!r[a]||!fr(i,Rr))return null}return t}const fi=Object.create(null);function Ou(e,t){return{provider:e,prefix:t,icons:Object.create(null),missing:new Set}}function Tt(e,t){const n=fi[e]||(fi[e]=Object.create(null));return n[t]||(n[t]=Ou(e,t))}function Ga(e,t){return Ya(t)?Ja(t,(n,r)=>{r?e.icons[n]=r:e.missing.add(n)}):[]}function Lu(e,t,n){try{if(typeof n.body=="string")return e.icons[t]={...n},!0}catch{}return!1}const Qa=/^[a-z0-9]+(-[a-z0-9]+)*$/,Kn=(e,t,n,r="")=>{const s=e.split(":");if(e.slice(0,1)==="@"){if(s.length<2||s.length>3)return null;r=s.shift().slice(1)}if(s.length>3||!s.length)return null;if(s.length>1){const o=s.pop(),c=s.pop(),d={provider:s.length>0?s[0]:r,prefix:c,name:o};return t&&!vn(d)?null:d}const i=s[0],a=i.split("-");if(a.length>1){const o={provider:r,prefix:a.shift(),name:a.join("-")};return t&&!vn(o)?null:o}if(n&&r===""){const o={provider:r,prefix:"",name:i};return t&&!vn(o,n)?null:o}return null},vn=(e,t)=>e?!!((t&&e.prefix===""||e.prefix)&&e.name):!1;let tn=!1;function Za(e){return typeof e=="boolean"&&(tn=e),tn}function hi(e){const t=typeof e=="string"?Kn(e,!0,tn):e;if(t){const n=Tt(t.provider,t.prefix),r=t.name;return n.icons[r]||(n.missing.has(r)?null:void 0)}}function Fu(e,t){const n=Kn(e,!0,tn);if(!n)return!1;const r=Tt(n.provider,n.prefix);return t?Lu(r,n.name,t):(r.missing.add(n.name),!0)}function Pu(e,t){if(typeof e!="object")return!1;if(typeof t!="string"&&(t=e.provider||""),tn&&!t&&!e.prefix){let s=!1;return Ya(e)&&(e.prefix="",Ja(e,(i,a)=>{Fu(i,a)&&(s=!0)})),s}const n=e.prefix;if(!vn({prefix:n,name:"a"}))return!1;const r=Tt(t,n);return!!Ga(r,e)}const Xa=Object.freeze({width:null,height:null}),el=Object.freeze({...Xa,...$n}),Ru=/(-?[0-9.]*[0-9]+[0-9.]*)/g,zu=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function mi(e,t,n){if(t===1)return e;if(n=n||100,typeof e=="number")return Math.ceil(e*t*n)/n;if(typeof e!="string")return e;const r=e.split(Ru);if(r===null||!r.length)return e;const s=[];let i=r.shift(),a=zu.test(i);for(;;){if(a){const o=parseFloat(i);isNaN(o)?s.push(i):s.push(Math.ceil(o*t*n)/n)}else s.push(i);if(i=r.shift(),i===void 0)return s.join("");a=!a}}function Bu(e,t="defs"){let n="";const r=e.indexOf("<"+t);for(;r>=0;){const s=e.indexOf(">",r),i=e.indexOf("</"+t);if(s===-1||i===-1)break;const a=e.indexOf(">",i);if(a===-1)break;n+=e.slice(s+1,i).trim(),e=e.slice(0,r).trim()+e.slice(a+1)}return{defs:n,content:e}}function _u(e,t){return e?"<defs>"+e+"</defs>"+t:t}function Vu(e,t,n){const r=Bu(e);return _u(r.defs,t+r.content+n)}const Hu=e=>e==="unset"||e==="undefined"||e==="none";function Uu(e,t){const n={...cs,...e},r={...el,...t},s={left:n.left,top:n.top,width:n.width,height:n.height};let i=n.body;[n,r].forEach(b=>{const x=[],w=b.hFlip,S=b.vFlip;let M=b.rotate;w?S?M+=2:(x.push("translate("+(s.width+s.left).toString()+" "+(0-s.top).toString()+")"),x.push("scale(-1 1)"),s.top=s.left=0):S&&(x.push("translate("+(0-s.left).toString()+" "+(s.height+s.top).toString()+")"),x.push("scale(1 -1)"),s.top=s.left=0);let N;switch(M<0&&(M-=Math.floor(M/4)*4),M=M%4,M){case 1:N=s.height/2+s.top,x.unshift("rotate(90 "+N.toString()+" "+N.toString()+")");break;case 2:x.unshift("rotate(180 "+(s.width/2+s.left).toString()+" "+(s.height/2+s.top).toString()+")");break;case 3:N=s.width/2+s.left,x.unshift("rotate(-90 "+N.toString()+" "+N.toString()+")");break}M%2===1&&(s.left!==s.top&&(N=s.left,s.left=s.top,s.top=N),s.width!==s.height&&(N=s.width,s.width=s.height,s.height=N)),x.length&&(i=Vu(i,'<g transform="'+x.join(" ")+'">',"</g>"))});const a=r.width,o=r.height,c=s.width,d=s.height;let u,h;a===null?(h=o===null?"1em":o==="auto"?d:o,u=mi(h,c/d)):(u=a==="auto"?c:a,h=o===null?mi(u,d/c):o==="auto"?d:o);const p={},m=(b,x)=>{Hu(x)||(p[b]=x.toString())};m("width",u),m("height",h);const v=[s.left,s.top,c,d];return p.viewBox=v.join(" "),{attributes:p,viewBox:v,body:i}}const qu=/\sid="(\S+)"/g,Wu="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let Ku=0;function Ju(e,t=Wu){const n=[];let r;for(;r=qu.exec(e);)n.push(r[1]);if(!n.length)return e;const s="suffix"+(Math.random()*16777216|Date.now()).toString(16);return n.forEach(i=>{const a=typeof t=="function"?t(i):t+(Ku++).toString(),o=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e=e.replace(new RegExp('([#;"])('+o+')([")]|\\.[a-z])',"g"),"$1"+a+s+"$3")}),e=e.replace(new RegExp(s,"g"),""),e}const zr=Object.create(null);function Yu(e,t){zr[e]=t}function Br(e){return zr[e]||zr[""]}function ds(e){let t;if(typeof e.resources=="string")t=[e.resources];else if(t=e.resources,!(t instanceof Array)||!t.length)return null;return{resources:t,path:e.path||"/",maxURL:e.maxURL||500,rotate:e.rotate||750,timeout:e.timeout||5e3,random:e.random===!0,index:e.index||0,dataAfterTimeout:e.dataAfterTimeout!==!1}}const us=Object.create(null),zt=["https://api.simplesvg.com","https://api.unisvg.com"],wn=[];for(;zt.length>0;)zt.length===1||Math.random()>.5?wn.push(zt.shift()):wn.push(zt.pop());us[""]=ds({resources:["https://api.iconify.design"].concat(wn)});function Gu(e,t){const n=ds(t);return n===null?!1:(us[e]=n,!0)}function fs(e){return us[e]}const Qu=()=>{let e;try{if(e=fetch,typeof e=="function")return e}catch{}};let pi=Qu();function Zu(e,t){const n=fs(e);if(!n)return 0;let r;if(!n.maxURL)r=0;else{let s=0;n.resources.forEach(a=>{s=Math.max(s,a.length)});const i=t+".json?icons=";r=n.maxURL-s-n.path.length-i.length}return r}function Xu(e){return e===404}const ef=(e,t,n)=>{const r=[],s=Zu(e,t),i="icons";let a={type:i,provider:e,prefix:t,icons:[]},o=0;return n.forEach((c,d)=>{o+=c.length+1,o>=s&&d>0&&(r.push(a),a={type:i,provider:e,prefix:t,icons:[]},o=c.length),a.icons.push(c)}),r.push(a),r};function tf(e){if(typeof e=="string"){const t=fs(e);if(t)return t.path}return"/"}const nf=(e,t,n)=>{if(!pi){n("abort",424);return}let r=tf(t.provider);switch(t.type){case"icons":{const i=t.prefix,o=t.icons.join(","),c=new URLSearchParams({icons:o});r+=i+".json?"+c.toString();break}case"custom":{const i=t.uri;r+=i.slice(0,1)==="/"?i.slice(1):i;break}default:n("abort",400);return}let s=503;pi(e+r).then(i=>{const a=i.status;if(a!==200){setTimeout(()=>{n(Xu(a)?"abort":"next",a)});return}return s=501,i.json()}).then(i=>{if(typeof i!="object"||i===null){setTimeout(()=>{i===404?n("abort",i):n("next",s)});return}setTimeout(()=>{n("success",i)})}).catch(()=>{n("next",s)})},rf={prepare:ef,send:nf};function tl(e,t){e.forEach(n=>{const r=n.loaderCallbacks;r&&(n.loaderCallbacks=r.filter(s=>s.id!==t))})}function sf(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout(()=>{e.pendingCallbacksFlag=!1;const t=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!t.length)return;let n=!1;const r=e.provider,s=e.prefix;t.forEach(i=>{const a=i.icons,o=a.pending.length;a.pending=a.pending.filter(c=>{if(c.prefix!==s)return!0;const d=c.name;if(e.icons[d])a.loaded.push({provider:r,prefix:s,name:d});else if(e.missing.has(d))a.missing.push({provider:r,prefix:s,name:d});else return n=!0,!0;return!1}),a.pending.length!==o&&(n||tl([e],i.id),i.callback(a.loaded.slice(0),a.missing.slice(0),a.pending.slice(0),i.abort))})}))}let af=0;function lf(e,t,n){const r=af++,s=tl.bind(null,n,r);if(!t.pending.length)return s;const i={id:r,icons:t,callback:e,abort:s};return n.forEach(a=>{(a.loaderCallbacks||(a.loaderCallbacks=[])).push(i)}),s}function of(e){const t={loaded:[],missing:[],pending:[]},n=Object.create(null);e.sort((s,i)=>s.provider!==i.provider?s.provider.localeCompare(i.provider):s.prefix!==i.prefix?s.prefix.localeCompare(i.prefix):s.name.localeCompare(i.name));let r={provider:"",prefix:"",name:""};return e.forEach(s=>{if(r.name===s.name&&r.prefix===s.prefix&&r.provider===s.provider)return;r=s;const i=s.provider,a=s.prefix,o=s.name,c=n[i]||(n[i]=Object.create(null)),d=c[a]||(c[a]=Tt(i,a));let u;o in d.icons?u=t.loaded:a===""||d.missing.has(o)?u=t.missing:u=t.pending;const h={provider:i,prefix:a,name:o};u.push(h)}),t}function cf(e,t=!0,n=!1){const r=[];return e.forEach(s=>{const i=typeof s=="string"?Kn(s,t,n):s;i&&r.push(i)}),r}const df={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function uf(e,t,n,r){const s=e.resources.length,i=e.random?Math.floor(Math.random()*s):e.index;let a;if(e.random){let T=e.resources.slice(0);for(a=[];T.length>1;){const $=Math.floor(Math.random()*T.length);a.push(T[$]),T=T.slice(0,$).concat(T.slice($+1))}a=a.concat(T)}else a=e.resources.slice(i).concat(e.resources.slice(0,i));const o=Date.now();let c="pending",d=0,u,h=null,p=[],m=[];typeof r=="function"&&m.push(r);function v(){h&&(clearTimeout(h),h=null)}function b(){c==="pending"&&(c="aborted"),v(),p.forEach(T=>{T.status==="pending"&&(T.status="aborted")}),p=[]}function x(T,$){$&&(m=[]),typeof T=="function"&&m.push(T)}function w(){return{startTime:o,payload:t,status:c,queriesSent:d,queriesPending:p.length,subscribe:x,abort:b}}function S(){c="failed",m.forEach(T=>{T(void 0,u)})}function M(){p.forEach(T=>{T.status==="pending"&&(T.status="aborted")}),p=[]}function N(T,$,W){const D=$!=="success";switch(p=p.filter(R=>R!==T),c){case"pending":break;case"failed":if(D||!e.dataAfterTimeout)return;break;default:return}if($==="abort"){u=W,S();return}if(D){u=W,p.length||(a.length?j():S());return}if(v(),M(),!e.random){const R=e.resources.indexOf(T.resource);R!==-1&&R!==e.index&&(e.index=R)}c="completed",m.forEach(R=>{R(W)})}function j(){if(c!=="pending")return;v();const T=a.shift();if(T===void 0){if(p.length){h=setTimeout(()=>{v(),c==="pending"&&(M(),S())},e.timeout);return}S();return}const $={status:"pending",resource:T,callback:(W,D)=>{N($,W,D)}};p.push($),d++,h=setTimeout(j,e.rotate),n(T,t,$.callback)}return setTimeout(j),w}function nl(e){const t={...df,...e};let n=[];function r(){n=n.filter(o=>o().status==="pending")}function s(o,c,d){const u=uf(t,o,c,(h,p)=>{r(),d&&d(h,p)});return n.push(u),u}function i(o){return n.find(c=>o(c))||null}return{query:s,find:i,setIndex:o=>{t.index=o},getIndex:()=>t.index,cleanup:r}}function gi(){}const hr=Object.create(null);function ff(e){if(!hr[e]){const t=fs(e);if(!t)return;const n=nl(t),r={config:t,redundancy:n};hr[e]=r}return hr[e]}function hf(e,t,n){let r,s;if(typeof e=="string"){const i=Br(e);if(!i)return n(void 0,424),gi;s=i.send;const a=ff(e);a&&(r=a.redundancy)}else{const i=ds(e);if(i){r=nl(i);const a=e.resources?e.resources[0]:"",o=Br(a);o&&(s=o.send)}}return!r||!s?(n(void 0,424),gi):r.query(t,s,n)().abort}function xi(){}function mf(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout(()=>{e.iconsLoaderFlag=!1,sf(e)}))}function pf(e){const t=[],n=[];return e.forEach(r=>{(r.match(Qa)?t:n).push(r)}),{valid:t,invalid:n}}function Bt(e,t,n){function r(){const s=e.pendingIcons;t.forEach(i=>{s&&s.delete(i),e.icons[i]||e.missing.add(i)})}if(n&&typeof n=="object")try{if(!Ga(e,n).length){r();return}}catch(s){console.error(s)}r(),mf(e)}function yi(e,t){e instanceof Promise?e.then(n=>{t(n)}).catch(()=>{t(null)}):t(e)}function gf(e,t){e.iconsToLoad?e.iconsToLoad=e.iconsToLoad.concat(t).sort():e.iconsToLoad=t,e.iconsQueueFlag||(e.iconsQueueFlag=!0,setTimeout(()=>{e.iconsQueueFlag=!1;const{provider:n,prefix:r}=e,s=e.iconsToLoad;if(delete e.iconsToLoad,!s||!s.length)return;const i=e.loadIcon;if(e.loadIcons&&(s.length>1||!i)){yi(e.loadIcons(s,r,n),u=>{Bt(e,s,u)});return}if(i){s.forEach(u=>{const h=i(u,r,n);yi(h,p=>{const m=p?{prefix:r,icons:{[u]:p}}:null;Bt(e,[u],m)})});return}const{valid:a,invalid:o}=pf(s);if(o.length&&Bt(e,o,null),!a.length)return;const c=r.match(Qa)?Br(n):null;if(!c){Bt(e,a,null);return}c.prepare(n,r,a).forEach(u=>{hf(n,u,h=>{Bt(e,u.icons,h)})})}))}const xf=(e,t)=>{const n=cf(e,!0,Za()),r=of(n);if(!r.pending.length){let c=!0;return t&&setTimeout(()=>{c&&t(r.loaded,r.missing,r.pending,xi)}),()=>{c=!1}}const s=Object.create(null),i=[];let a,o;return r.pending.forEach(c=>{const{provider:d,prefix:u}=c;if(u===o&&d===a)return;a=d,o=u,i.push(Tt(d,u));const h=s[d]||(s[d]=Object.create(null));h[u]||(h[u]=[])}),r.pending.forEach(c=>{const{provider:d,prefix:u,name:h}=c,p=Tt(d,u),m=p.pendingIcons||(p.pendingIcons=new Set);m.has(h)||(m.add(h),s[d][u].push(h))}),i.forEach(c=>{const d=s[c.provider][c.prefix];d.length&&gf(c,d)}),t?lf(t,r,i):xi};function yf(e,t){const n={...e};for(const r in t){const s=t[r],i=typeof s;r in Xa?(s===null||s&&(i==="string"||i==="number"))&&(n[r]=s):i===typeof n[r]&&(n[r]=r==="rotate"?s%4:s)}return n}const bf=/[\s,]+/;function vf(e,t){t.split(bf).forEach(n=>{switch(n.trim()){case"horizontal":e.hFlip=!0;break;case"vertical":e.vFlip=!0;break}})}function wf(e,t=0){const n=e.replace(/^-?[0-9.]*/,"");function r(s){for(;s<0;)s+=4;return s%4}if(n===""){const s=parseInt(e);return isNaN(s)?0:r(s)}else if(n!==e){let s=0;switch(n){case"%":s=25;break;case"deg":s=90}if(s){let i=parseFloat(e.slice(0,e.length-n.length));return isNaN(i)?0:(i=i/s,i%1===0?r(i):0)}}return t}function kf(e,t){let n=e.indexOf("xlink:")===-1?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const r in t)n+=" "+r+'="'+t[r]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+n+">"+e+"</svg>"}function Nf(e){return e.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function Sf(e){return"data:image/svg+xml,"+Nf(e)}function Cf(e){return'url("'+Sf(e)+'")'}let Wt;function jf(){try{Wt=window.trustedTypes.createPolicy("iconify",{createHTML:e=>e})}catch{Wt=null}}function Af(e){return Wt===void 0&&jf(),Wt?Wt.createHTML(e):e}const rl={...el,inline:!1},Mf={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},Ef={display:"inline-block"},_r={backgroundColor:"currentColor"},sl={backgroundColor:"transparent"},bi={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},vi={WebkitMask:_r,mask:_r,background:sl};for(const e in vi){const t=vi[e];for(const n in bi)t[e+n]=bi[n]}const Tf={...rl,inline:!0};function wi(e){return e+(e.match(/^[-0-9.]+$/)?"px":"")}const Df=(e,t,n)=>{const r=t.inline?Tf:rl,s=yf(r,t),i=t.mode||"svg",a={},o=t.style||{},c={...i==="svg"?Mf:{}};if(n){const x=Kn(n,!1,!0);if(x){const w=["iconify"],S=["provider","prefix"];for(const M of S)x[M]&&w.push("iconify--"+x[M]);c.className=w.join(" ")}}for(let x in t){const w=t[x];if(w!==void 0)switch(x){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":c.ref=w;break;case"className":c[x]=(c[x]?c[x]+" ":"")+w;break;case"inline":case"hFlip":case"vFlip":s[x]=w===!0||w==="true"||w===1;break;case"flip":typeof w=="string"&&vf(s,w);break;case"color":a.color=w;break;case"rotate":typeof w=="string"?s[x]=wf(w):typeof w=="number"&&(s[x]=w);break;case"ariaHidden":case"aria-hidden":w!==!0&&w!=="true"&&delete c["aria-hidden"];break;default:r[x]===void 0&&(c[x]=w)}}const d=Uu(e,s),u=d.attributes;if(s.inline&&(a.verticalAlign="-0.125em"),i==="svg"){c.style={...a,...o},Object.assign(c,u);let x=0,w=t.id;return typeof w=="string"&&(w=w.replace(/-/g,"_")),c.dangerouslySetInnerHTML={__html:Af(Ju(d.body,w?()=>w+"ID"+x++:"iconifyReact"))},y.createElement("svg",c)}const{body:h,width:p,height:m}=e,v=i==="mask"||(i==="bg"?!1:h.indexOf("currentColor")!==-1),b=kf(h,{...u,width:p+"",height:m+""});return c.style={...a,"--svg":Cf(b),width:wi(u.width),height:wi(u.height),...Ef,...v?_r:sl,...o},y.createElement("span",c)};Za(!0);Yu("",rf);if(typeof document<"u"&&typeof window<"u"){const e=window;if(e.IconifyPreload!==void 0){const t=e.IconifyPreload,n="Invalid IconifyPreload syntax.";typeof t=="object"&&t!==null&&(t instanceof Array?t:[t]).forEach(r=>{try{(typeof r!="object"||r===null||r instanceof Array||typeof r.icons!="object"||typeof r.prefix!="string"||!Pu(r))&&console.error(n)}catch{console.error(n)}})}if(e.IconifyProviders!==void 0){const t=e.IconifyProviders;if(typeof t=="object"&&t!==null)for(let n in t){const r="IconifyProviders["+n+"] is invalid.";try{const s=t[n];if(typeof s!="object"||!s||s.resources===void 0)continue;Gu(n,s)||console.error(r)}catch{console.error(r)}}}}function il(e){const[t,n]=y.useState(!!e.ssr),[r,s]=y.useState({});function i(m){if(m){const v=e.icon;if(typeof v=="object")return{name:"",data:v};const b=hi(v);if(b)return{name:v,data:b}}return{name:""}}const[a,o]=y.useState(i(!!e.ssr));function c(){const m=r.callback;m&&(m(),s({}))}function d(m){if(JSON.stringify(a)!==JSON.stringify(m))return c(),o(m),!0}function u(){var m;const v=e.icon;if(typeof v=="object"){d({name:"",data:v});return}const b=hi(v);if(d({name:v,data:b}))if(b===void 0){const x=xf([v],u);s({callback:x})}else b&&((m=e.onLoad)===null||m===void 0||m.call(e,v))}y.useEffect(()=>(n(!0),c),[]),y.useEffect(()=>{t&&u()},[e.icon,t]);const{name:h,data:p}=a;return p?Df({...cs,...p},e,h):e.children?e.children:e.fallback?e.fallback:y.createElement("span",{})}const U=y.forwardRef((e,t)=>il({...e,_ref:t}));y.forwardRef((e,t)=>il({inline:!0,...e,_ref:t}));const mr=({icon:e,children:t,testId:n})=>l.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600","data-testid":n,children:[l.jsx(U,{icon:e,width:20,className:"text-default-500"}),l.jsx("span",{children:t})]}),If=({classes:e="",name:t,imageUrl:n,eventDate:r,eventTime:s,location:i,description:a,showImage:o=!1,compact:c=!1,imageLoading:d="eager",showMoreButtonClassName:u,labels:h})=>{const[p,m]=y.useState(!1),[v,b]=y.useState(!1),x=y.useRef(null);return y.useEffect(()=>{const w=()=>{if(x.current){const S=x.current.scrollHeight>x.current.clientHeight;b(S)}};return w(),window.addEventListener("resize",w),()=>window.removeEventListener("resize",w)},[a]),l.jsxs(f.Card,{className:f.cn("border-0 shadow-none",e),"data-testid":"event-details-root",children:[l.jsxs(f.CardHeader,{className:f.cn("pt-2 pb-0 flex-col items-start",c?"space-y-1":"space-y-2"),"data-testid":"event-details-header",children:[o&&n&&l.jsx("div",{className:f.cn("w-full overflow-hidden rounded-xl","aspect-[3/1]"),"data-testid":"event-details-image-wrapper",children:l.jsx(f.Image,{removeWrapper:!0,loading:d,alt:`Event image for ${t}`,className:"w-full h-full object-cover object-center",src:n,"data-testid":"event-details-image"})}),l.jsx("h2",{className:f.cn("font-semibold text-gray-800",c?"text-base":"text-xl"),"data-testid":"event-details-title",children:t})]}),l.jsxs(f.CardBody,{className:f.cn("space-y-3",c?"py-1 space-y-2":"py-3"),"data-testid":"event-details-body",children:[l.jsx("h3",{className:f.cn("font-semibold text-base text-gray-700",c?"text-sm":""),"data-testid":"event-details-info-label",children:h.eventInformation}),l.jsxs("div",{className:"flex flex-wrap gap-4","data-testid":"event-details-info",children:[r&&l.jsx(mr,{icon:"solar:calendar-minimalistic-linear",testId:"event-details-date",children:r}),s&&l.jsx(mr,{icon:"solar:clock-circle-linear",testId:"event-details-time",children:s}),i&&l.jsx(mr,{icon:"solar:map-point-linear",testId:"event-details-location",children:i})]}),a&&l.jsxs("div",{className:"relative","data-testid":"event-details-description-wrapper",children:[l.jsxs("div",{className:"relative",children:[l.jsx("div",{ref:x,className:f.cn("text-sm text-gray-700 leading-relaxed transition-all",c?"text-xs":"",!p&&"line-clamp-3"),"data-testid":"event-details-description",dangerouslySetInnerHTML:{__html:a}}),!p&&v&&l.jsx("div",{className:"absolute inset-x-0 -bottom-1 h-8 bg-gradient-to-t from-white via-white/70 to-transparent pointer-events-none","data-testid":"event-details-description-fade"})]}),(v||p)&&l.jsx("div",{className:"flex justify-end mt-1",children:l.jsx(K,{onPress:()=>m(!p),variant:"light",className:f.cn("text-primary",u),size:c?"sm":"md",startContent:l.jsx(U,{icon:p?"solar:eye-closed-linear":"solar:eye-linear",width:c?16:20}),"data-testid":"event-details-toggle-description",children:p?h.showLess||"Hide":h.showMore||"Show"})})]})]})]})};function al(e,t="en-US",n="USD"){try{return new Intl.NumberFormat(t,{style:"currency",currency:n,minimumFractionDigits:2,maximumFractionDigits:2}).format(e)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${e.toFixed(2)}`}}function $f(e){const t=e.replace(/[^\d.,-]/g,""),n=t.match(/,\d{1,2}$/);let r;n?r=t.replace(/\./g,"").replace(",","."):r=t.replace(/,/g,"");const s=parseFloat(r);return isNaN(s)?null:s}const Of={person:"Person",people:"People",tickets:"Tickets:",soldOut:"Sold Out",maxReached:"Maximum number of tickets allowed reached",ruleBlocked:"Unavailable for selected ticket options",disabled:"Ticket selection is unavailable"},mn=e=>typeof e=="number"&&!isNaN(e),On=({offer:e,quantity:t,defaultQuantity:n=0,onQuantityChange:r,currency:s="USD",locale:i="en-US",labels:a,slots:o,isDisabled:c=!1,buttonVariant:d="bordered",buttonColor:u="default",showCard:h=!0,showDescription:p=!0,showPeopleCount:m=!0,showPrice:v=!0,classNames:b={},"data-testid":x,selectedColor:w="default",compact:S=!1,isSoldOut:M,isMaxReached:N,isRuleBlocked:j,statusTone:T="default",statusLabel:$,disabledReason:W,disabled:D})=>{const R=y.useMemo(()=>({...Of,...a}),[a]),[E,C]=y.useState(n),I=t!==void 0?t:E,F=!!(c||D),H=S||!!e.compact,Q=y.useMemo(()=>typeof M=="boolean"?M:typeof e.isSoldOut=="boolean"?e.isSoldOut:!mn(e.totalTicketsSold)||!mn(e.ticketsAllowed)?!1:e.totalTicketsSold>=e.ticketsAllowed,[M,e.isSoldOut,e.totalTicketsSold,e.ticketsAllowed]),Y=y.useMemo(()=>typeof N=="boolean"?N:typeof e.isMaxReached=="boolean"?e.isMaxReached:Q||!mn(e.ticketsAllowed)?!1:I>=e.ticketsAllowed-(e.totalTicketsSold??0),[N,e.isMaxReached,Q,e.ticketsAllowed,e.totalTicketsSold,I]),te=y.useMemo(()=>typeof j=="boolean"?j:typeof e.isRuleBlocked=="boolean"?e.isRuleBlocked:!1,[j,e.isRuleBlocked]),oe=W||e.disabledReason,ce=F||Q||te,P=ue=>{if(ce||ue>0&&Y)return;const Te=Math.max(0,I+ue);t===void 0&&C(Te),r?.(e.id,Te)},_=y.useMemo(()=>{if(Q)return"soldOut";if(te)return"ruleBlocked";if(F)return"disabled"},[Q,te,F]),G=y.useMemo(()=>T||(Q||te?"danger":Y?"warning":"default"),[T,Q,te,Y]),ne=y.useMemo(()=>{if(_)return _==="ruleBlocked"?$||oe||R.ruleBlocked:_==="soldOut"?$||oe||R.soldOut:_==="disabled"?$||oe||R.disabled:$||R.maxReached},[_,$,oe,R]),Se={soldOut:"danger",ruleBlocked:G,disabled:"default",maxReached:"warning"},at={soldOut:"offer-card-sold-out-chip",maxReached:"offer-card-max-reached-chip",ruleBlocked:"offer-card-ruleBlocked-chip",disabled:"offer-card-disabled-chip"},$t=()=>o?.renderName?o.renderName(e.name,e):l.jsx("h2",{"data-testid":"offer-card-name",className:f.cn("text-base font-medium",H&&"text-sm",b.name),children:e.name}),Ot=()=>{if(!v)return null;const ue=al(e.price,i,s);return o?.renderPrice?o.renderPrice(e.price,ue,e):l.jsx("p",{"data-testid":"offer-card-price",className:f.cn("text-primary text-base mt-1",H&&"text-sm mt-0.5",b.price),children:ue})},on=()=>!p||!e.description?null:o?.renderDescription?o.renderDescription(e.description,e):l.jsx("p",{"data-testid":"offer-card-description",className:f.cn("mb-4 text-sm text-gray-700 leading-relaxed",H&&"mb-2 text-xs text-gray-600",b.description),children:e.description}),Lt=()=>{if(!m||!mn(e.numberOfPeople)||e.numberOfPeople<=0)return null;const ue=e.numberOfPeople===1?R.person:R.people;return o?.renderPeopleCount?o.renderPeopleCount(e.numberOfPeople,ue,e):l.jsxs("p",{"data-testid":"offer-card-people-count",className:f.cn("text-sm text-gray-600 flex items-center mt-2",H&&"mt-1 text-xs",b.peopleCount),children:[l.jsx(U,{icon:e.numberOfPeople<=1?"solar:user-rounded-outline":"solar:users-group-rounded-outline",width:20,className:"mr-1"}),e.numberOfPeople," ",ue]})},Ft=()=>{const ue=I===0||ce,Te=Y||ce;return o?.renderQuantitySelector?o.renderQuantitySelector({quantity:I,onIncrement:()=>P(1),onDecrement:()=>P(-1),isDecrementDisabled:ue,isIncrementDisabled:Te,isDisabled:ce}):l.jsxs("div",{className:f.cn("flex items-center gap-2",b.quantitySelector),children:[l.jsx(K,{"data-testid":"offer-card-decrement-button",onPress:()=>P(-1),isDisabled:ue,variant:d,color:I>0?w:u,radius:"full",isIconOnly:!0,size:H?"md":"sm","aria-label":"Decrease quantity",children:l.jsx(U,{icon:"gravity-ui:minus",width:16})}),l.jsx("span",{"data-testid":"offer-card-quantity",className:f.cn("min-w-[2rem] text-center font-medium",H&&"text-sm"),children:I}),l.jsx(K,{"data-testid":"offer-card-increment-button",onPress:()=>P(1),isDisabled:Te,variant:d,color:I>0?w:u,radius:"full",isIconOnly:!0,size:H?"md":"sm","aria-label":"Increase quantity",children:l.jsx(U,{icon:"gravity-ui:plus",width:16})})]})},cn=(ue,Te)=>o?.renderDisabledState?o.renderDisabledState(ue,Te):ue==="soldOut"&&o?.renderSoldOut?o.renderSoldOut(Te):ue==="maxReached"&&o?.renderMaxReachedAlert?o.renderMaxReachedAlert(Te):l.jsx(f.Chip,{"data-testid":at[ue],color:Se[ue],variant:ue==="maxReached"?"flat":"solid",className:f.cn("gap-2 px-4",ue==="maxReached"?"h-8":"h-10",ue==="soldOut"&&b.soldOut,ue==="maxReached"&&b.maxReachedAlert,H&&"h-8"),startContent:l.jsx(U,{icon:"gravity-ui:triangle-exclamation-fill",width:14}),children:l.jsx("span",{className:"font-medium text-sm",children:Te})}),Pt=l.jsxs("div",{className:f.cn("grid grid-cols-1 md:grid-cols-1 xl:grid-cols-3 lg:grid-cols-3 items-start",H?"gap-1":"gap-2"),children:[l.jsxs("div",{className:f.cn("h-full col-span-2",ce||Y?"opacity-50 pointer-events-none select-none":""),children:[$t(),Ot(),l.jsxs("div",{className:f.cn("md:col-span-1 xl:col-span-2 lg:col-span-1",H?"mb-1":"mb-2"),children:[Lt(),on()]})]}),l.jsx("div",{className:f.cn("space-x-2 pt-0 pb-2 md:p-2 h-full flex items-center justify-start md:justify-start lg:justify-end",H&&"space-x-1 pb-1 md:p-1",b.compactFooter),children:_&&ne?cn(_,ne):Ft()})]}),wt=Y&&!Q&&!te&&!F?l.jsx(Pe.motion.div,{className:f.cn("w-full sm:max-w-[60%] md:max-w-[60%] lg:max-w-[60%]",b.compactFooter),initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.3},children:cn("maxReached",ne||R.maxReached)}):null;return h?l.jsxs(f.Card,{className:f.cn("w-full",H&&b.compact,b.base),"data-testid":x||`offer-card-${e.id}`,children:[l.jsx(f.CardBody,{className:f.cn("pt-1 pb-0",H?"pb-0.5":"",b.body),children:Pt}),l.jsx(Pe.AnimatePresence,{children:wt&&l.jsx(f.CardFooter,{className:f.cn("w-full mt-0 pt-0",H?"pt-1":"",b.footer),children:wt})})]}):l.jsxs("div",{className:f.cn("w-full",H&&b.compact,b.base),"data-testid":x||`offer-card-${e.id}`,children:[l.jsx("div",{className:f.cn("pt-1 pb-0",H?"pb-0.5":"",b.body),children:Pt}),l.jsx(Pe.AnimatePresence,{children:wt&&l.jsx("div",{className:f.cn("w-full mt-0 pt-0",H?"pt-1":"",b.footer),children:wt})})]})};On.displayName="OfferCard";const ll=({message:e="No offers available.",icon:t="solar:ticket-sale-outline",iconSize:n=48,showCard:r=!0,classNames:s={},renderEmpty:i})=>{if(i){const o=i();return r?l.jsx(f.Card,{"data-testid":"offer-card-empty",className:f.cn("w-full",s.base),children:l.jsx(f.CardBody,{"data-testid":"offer-card-empty-body",children:o})}):l.jsx("div",{"data-testid":"offer-card-empty",className:f.cn("w-full",s.base),children:o})}const a=l.jsxs("div",{"data-testid":"offer-card-empty-content",className:f.cn("flex flex-col items-center justify-center p-8 text-center text-gray-500",s.content),children:[l.jsx(U,{"data-testid":"offer-card-empty-icon",icon:t,width:n,className:f.cn("mb-4",s.icon)}),l.jsx("h3",{"data-testid":"offer-card-empty-message",className:f.cn("text-lg",s.message),children:e})]});return r?l.jsx(f.Card,{"data-testid":"offer-card-empty",className:f.cn("w-full",s.base),children:l.jsx(f.CardBody,{"data-testid":"offer-card-empty-body",children:a})}):l.jsx("div",{"data-testid":"offer-card-empty",className:f.cn("w-full",s.base),children:a})};ll.displayName="OfferCardEmpty";const Lf={title:"Error Fetching Offers",description:"An error occurred while fetching offers."},ol=({error:e,labels:t,showCard:n=!0,color:r="danger",classNames:s={}})=>{const i={...Lf,...t},a=l.jsx(f.Alert,{"data-testid":"offer-card-error-alert",color:r,title:i.title,description:e||i.description,className:s.alert});return n?l.jsx(f.Card,{"data-testid":"offer-card-error",className:f.cn("w-full",s.base),children:l.jsx(f.CardBody,{"data-testid":"offer-card-error-body",children:a})}):l.jsx("div",{"data-testid":"offer-card-error",className:f.cn("w-full",s.base),children:a})};ol.displayName="OfferCardError";const Ff={1:"space-y-1",2:"space-y-2",3:"space-y-3",4:"space-y-4",5:"space-y-5",6:"space-y-6"},cl=({quantity:e=2,gap:t=4,classNames:n={}})=>{const r=Ff[t];return l.jsx("div",{"data-testid":"offer-card-skeleton-container",className:f.cn(r,n.base),children:Array.from({length:e}).map((s,i)=>l.jsxs(f.Card,{"data-testid":`offer-card-skeleton-${i}`,className:f.cn("w-full",n.card),children:[l.jsx(f.CardHeader,{"data-testid":`offer-card-skeleton-header-${i}`,className:"flex justify-between items-start pb-0",children:l.jsxs("div",{className:"space-y-2 w-full",children:[l.jsx(f.Skeleton,{"data-testid":`offer-card-skeleton-title-${i}`,className:"w-1/3 rounded-lg",children:l.jsx("div",{className:"h-4 bg-default-200 rounded-lg"})}),l.jsx(f.Skeleton,{"data-testid":`offer-card-skeleton-subtitle-${i}`,className:"w-1/4 rounded-lg",children:l.jsx("div",{className:"h-3 bg-default-300 rounded-lg"})})]})}),l.jsx(f.CardBody,{"data-testid":`offer-card-skeleton-body-${i}`,className:"pt-2 pb-0",children:l.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-2 items-start",children:[l.jsxs("div",{className:"xl:col-span-2 space-y-2",children:[l.jsx(f.Skeleton,{"data-testid":`offer-card-skeleton-people-${i}`,className:"w-1/4 rounded-lg",children:l.jsx("div",{className:"h-4 bg-default-300 rounded-lg"})}),l.jsx(f.Skeleton,{"data-testid":`offer-card-skeleton-description-${i}`,className:"w-3/4 rounded-lg",children:l.jsx("div",{className:"h-4 bg-default-200 rounded-lg"})})]}),l.jsx("div",{className:"flex items-start justify-end",children:l.jsxs("div",{"data-testid":`offer-card-skeleton-controls-${i}`,className:"flex items-center justify-end gap-2 w-full px-4 py-2",children:[l.jsx(f.Skeleton,{"data-testid":`offer-card-skeleton-label-${i}`,className:"w-24 h-4 rounded-md bg-default-200"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(f.Skeleton,{"data-testid":`offer-card-skeleton-btn-dec-${i}`,className:"w-8 h-8 rounded-md bg-default-300"}),l.jsx(f.Skeleton,{"data-testid":`offer-card-skeleton-btn-qty-${i}`,className:"w-8 h-8 rounded-md bg-default-200"}),l.jsx(f.Skeleton,{"data-testid":`offer-card-skeleton-btn-inc-${i}`,className:"w-8 h-8 rounded-md bg-default-300"})]})]})})]})})]},i))})};cl.displayName="OfferCardSkeleton";const dl={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.15,delayChildren:.1}}},ul={hidden:{opacity:0,y:8},show:{opacity:1,y:0,transition:{duration:.45,ease:"easeOut"}},exit:{opacity:0,y:-5,transition:{duration:.35,ease:"easeIn"}}},Pf={1:"gap-1",2:"gap-2",3:"gap-3",4:"gap-4",5:"gap-5",6:"gap-6"},fl=({offers:e=[],mapOffer:t,selection:n,defaultSelection:r={},onSelectionChange:s,onQuantityChange:i,currency:a="USD",locale:o="en-US",labels:c,slots:d,isDisabled:u=!1,buttonVariant:h="bordered",buttonColor:p="default",showCard:m=!0,animated:v=!0,gap:b=2,compact:x=!1,classNames:w={}})=>{const[S,M]=y.useState(r),N=n!==void 0?n:S,j=y.useCallback((E,C)=>{const I={...N,[E]:Math.max(0,C)};n===void 0&&M(I),s?.(I),i?.(E,I[E])},[N,n,s,i]),T=[...e].sort((E,C)=>(E.position??0)-(C.position??0)),$=E=>{const C=t?t(E):E,I=(N??{})[C.id]||0;return{offer:C,quantity:I,onQuantityChange:j,currency:a,locale:o,labels:c,slots:d,isDisabled:u,buttonVariant:h,buttonColor:p,showCard:m,compact:x}},W=Pf[b],D=f.cn("grid mx-auto pt-2",W,w.base),R=E=>{const C=$(E);return l.jsx(On,{offer:C.offer,quantity:C.quantity,onQuantityChange:C.onQuantityChange,currency:C.currency,locale:C.locale,labels:C.labels,slots:C.slots,isDisabled:C.isDisabled,buttonVariant:C.buttonVariant,buttonColor:C.buttonColor,showCard:C.showCard,compact:C.compact,classNames:w.card},C.offer.id)};return v?l.jsx(Pe.motion.div,{"data-testid":"offer-card-list",className:D,variants:dl,initial:"hidden",animate:"show",children:l.jsx(Pe.AnimatePresence,{children:T.map(E=>{const C=$(E);return l.jsx(Pe.motion.div,{"data-testid":`offer-card-list-item-${C.offer.id}`,className:w.cardWrapper,variants:ul,exit:{opacity:0,y:-20},transition:{duration:.3},children:l.jsx(On,{offer:C.offer,quantity:C.quantity,onQuantityChange:j,currency:a,locale:o,labels:c,slots:d,isDisabled:u,buttonVariant:h,buttonColor:p,showCard:m,compact:x||C.offer.compact,classNames:w.card})},C.offer.id)})})}):l.jsx("div",{"data-testid":"offer-card-list",className:D,children:T.map(R)})};fl.displayName="OfferCardList";var an=e=>e.type==="checkbox",mt=e=>e instanceof Date,Ee=e=>e==null;const hl=e=>typeof e=="object";var ye=e=>!Ee(e)&&!Array.isArray(e)&&hl(e)&&!mt(e),ml=e=>ye(e)&&e.target?an(e.target)?e.target.checked:e.target.value:e,Rf=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,pl=(e,t)=>e.has(Rf(t)),zf=e=>{const t=e.constructor&&e.constructor.prototype;return ye(t)&&t.hasOwnProperty("isPrototypeOf")},hs=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function pe(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(hs&&(e instanceof Blob||t))return e;const n=Array.isArray(e);if(!n&&!(ye(e)&&zf(e)))return e;const r=n?[]:Object.create(Object.getPrototypeOf(e));for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r[s]=pe(e[s]));return r}var Jn=e=>/^\w*$/.test(e),fe=e=>e===void 0,ms=e=>Array.isArray(e)?e.filter(Boolean):[],ps=e=>ms(e.replace(/["|']|\]/g,"").split(/\.|\[/)),z=(e,t,n)=>{if(!t||!ye(e))return n;const r=(Jn(t)?[t]:ps(t)).reduce((s,i)=>Ee(s)?s:s[i],e);return fe(r)||r===e?fe(e[t])?n:e[t]:r},De=e=>typeof e=="boolean",Me=e=>typeof e=="function",le=(e,t,n)=>{let r=-1;const s=Jn(t)?[t]:ps(t),i=s.length,a=i-1;for(;++r<i;){const o=s[r];let c=n;if(r!==a){const d=e[o];c=ye(d)||Array.isArray(d)?d:isNaN(+s[r+1])?{}:[]}if(o==="__proto__"||o==="constructor"||o==="prototype")return;e[o]=c,e=e[o]}};const Ln={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},ze={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},We={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},gl=y.createContext(null);gl.displayName="HookFormControlContext";const gs=()=>y.useContext(gl);var xl=(e,t,n,r=!0)=>{const s={defaultValues:t._defaultValues};for(const i in e)Object.defineProperty(s,i,{get:()=>{const a=i;return t._proxyFormState[a]!==ze.all&&(t._proxyFormState[a]=!r||ze.all),n&&(n[a]=!0),e[a]}});return s};const xs=typeof window<"u"?y.useLayoutEffect:y.useEffect;function Bf(e){const t=gs(),{control:n=t,disabled:r,name:s,exact:i}=e||{},[a,o]=y.useState(n._formState),c=y.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return xs(()=>n._subscribe({name:s,formState:c.current,exact:i,callback:d=>{!r&&o({...n._formState,...d})}}),[s,r,i]),y.useEffect(()=>{c.current.isValid&&n._setValid(!0)},[n]),y.useMemo(()=>xl(a,n,c.current,!1),[a,n])}var $e=e=>typeof e=="string",Vr=(e,t,n,r,s)=>$e(e)?(r&&t.watch.add(e),z(n,e,s)):Array.isArray(e)?e.map(i=>(r&&t.watch.add(i),z(n,i))):(r&&(t.watchAll=!0),n),Hr=e=>Ee(e)||!hl(e);function Be(e,t,n=new WeakSet){if(Hr(e)||Hr(t))return Object.is(e,t);if(mt(e)&&mt(t))return Object.is(e.getTime(),t.getTime());const r=Object.keys(e),s=Object.keys(t);if(r.length!==s.length)return!1;if(n.has(e)||n.has(t))return!0;n.add(e),n.add(t);for(const i of r){const a=e[i];if(!s.includes(i))return!1;if(i!=="ref"){const o=t[i];if(mt(a)&&mt(o)||ye(a)&&ye(o)||Array.isArray(a)&&Array.isArray(o)?!Be(a,o,n):!Object.is(a,o))return!1}}return!0}function _f(e){const t=gs(),{control:n=t,name:r,defaultValue:s,disabled:i,exact:a,compute:o}=e||{},c=y.useRef(s),d=y.useRef(o),u=y.useRef(void 0),h=y.useRef(n),p=y.useRef(r);d.current=o;const[m,v]=y.useState(()=>{const N=n._getWatch(r,c.current);return d.current?d.current(N):N}),b=y.useCallback(N=>{const j=Vr(r,n._names,N||n._formValues,!1,c.current);return d.current?d.current(j):j},[n._formValues,n._names,r]),x=y.useCallback(N=>{if(!i){const j=Vr(r,n._names,N||n._formValues,!1,c.current);if(d.current){const T=d.current(j);Be(T,u.current)||(v(T),u.current=T)}else v(j)}},[n._formValues,n._names,i,r]);xs(()=>((h.current!==n||!Be(p.current,r))&&(h.current=n,p.current=r,x()),n._subscribe({name:r,formState:{values:!0},exact:a,callback:N=>{x(N.values)}})),[n,a,r,x]),y.useEffect(()=>n._removeUnmounted());const w=h.current!==n,S=p.current,M=y.useMemo(()=>{if(i)return null;const N=!w&&!Be(S,r);return w||N?b():null},[i,w,r,S,b]);return M!==null?M:m}function Vf(e){const t=gs(),{name:n,disabled:r,control:s=t,shouldUnregister:i,defaultValue:a,exact:o=!0}=e,c=pl(s._names.array,n),d=y.useMemo(()=>z(s._formValues,n,z(s._defaultValues,n,a)),[s,n,a]),u=_f({control:s,name:n,defaultValue:d,exact:o}),h=Bf({control:s,name:n,exact:o}),p=y.useRef(e),m=y.useRef(void 0),v=y.useRef(s.register(n,{...e.rules,value:u,...De(e.disabled)?{disabled:e.disabled}:{}}));p.current=e;const b=y.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!z(h.errors,n)},isDirty:{enumerable:!0,get:()=>!!z(h.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!z(h.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!z(h.validatingFields,n)},error:{enumerable:!0,get:()=>z(h.errors,n)}}),[h,n]),x=y.useCallback(N=>v.current.onChange({target:{value:ml(N),name:n},type:Ln.CHANGE}),[n]),w=y.useCallback(()=>v.current.onBlur({target:{value:z(s._formValues,n),name:n},type:Ln.BLUR}),[n,s._formValues]),S=y.useCallback(N=>{const j=z(s._fields,n);j&&j._f&&N&&(j._f.ref={focus:()=>Me(N.focus)&&N.focus(),select:()=>Me(N.select)&&N.select(),setCustomValidity:T=>Me(N.setCustomValidity)&&N.setCustomValidity(T),reportValidity:()=>Me(N.reportValidity)&&N.reportValidity()})},[s._fields,n]),M=y.useMemo(()=>({name:n,value:u,...De(r)||h.disabled?{disabled:h.disabled||r}:{},onChange:x,onBlur:w,ref:S}),[n,r,h.disabled,x,w,S,u]);return y.useEffect(()=>{const N=s._options.shouldUnregister||i,j=m.current;j&&j!==n&&!c&&s.unregister(j),s.register(n,{...p.current.rules,...De(p.current.disabled)?{disabled:p.current.disabled}:{}});const T=($,W)=>{const D=z(s._fields,$);D&&D._f&&(D._f.mount=W)};if(T(n,!0),N){const $=pe(z(s._options.defaultValues,n,p.current.defaultValue));le(s._defaultValues,n,$),fe(z(s._formValues,n))&&le(s._formValues,n,$)}return!c&&s.register(n),m.current=n,()=>{(c?N&&!s._state.action:N)?s.unregister(n):T(n,!1)}},[n,s,c,i]),y.useEffect(()=>{s._setDisabledField({disabled:r,name:n})},[r,n,s]),y.useMemo(()=>({field:M,formState:h,fieldState:b}),[M,h,b])}const Hf=y.createContext(null);Hf.displayName="HookFormContext";var Uf=(e,t,n,r,s)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:s||!0}}:{},Kt=e=>Array.isArray(e)?e:[e],ki=()=>{let e=[];return{get observers(){return e},next:s=>{for(const i of e)i.next&&i.next(s)},subscribe:s=>(e.push(s),{unsubscribe:()=>{e=e.filter(i=>i!==s)}}),unsubscribe:()=>{e=[]}}};function yl(e,t){const n={};for(const r in e)if(e.hasOwnProperty(r)){const s=e[r],i=t[r];if(s&&ye(s)&&i){const a=yl(s,i);ye(a)&&(n[r]=a)}else e[r]&&(n[r]=i)}return n}var je=e=>ye(e)&&!Object.keys(e).length,ys=e=>e.type==="file",Fn=e=>{if(!hs)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},bl=e=>e.type==="select-multiple",bs=e=>e.type==="radio",qf=e=>bs(e)||an(e),pr=e=>Fn(e)&&e.isConnected;function Wf(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=fe(e)?r++:e[t[r++]];return e}function Kf(e){for(const t in e)if(e.hasOwnProperty(t)&&!fe(e[t]))return!1;return!0}function ge(e,t){const n=Array.isArray(t)?t:Jn(t)?[t]:ps(t),r=n.length===1?e:Wf(e,n),s=n.length-1,i=n[s];return r&&delete r[i],s!==0&&(ye(r)&&je(r)||Array.isArray(r)&&Kf(r))&&ge(e,n.slice(0,-1)),e}var Jf=e=>{for(const t in e)if(Me(e[t]))return!0;return!1};function vl(e){return Array.isArray(e)||ye(e)&&!Jf(e)}function Ur(e,t={}){for(const n in e){const r=e[n];vl(r)?(t[n]=Array.isArray(r)?[]:{},Ur(r,t[n])):fe(r)||(t[n]=!0)}return t}function At(e,t,n){n||(n=Ur(t));for(const r in e){const s=e[r];if(vl(s))fe(t)||Hr(n[r])?n[r]=Ur(s,Array.isArray(s)?[]:{}):At(s,Ee(t)?{}:t[r],n[r]);else{const i=t[r];n[r]=!Be(s,i)}}return n}const Ni={value:!1,isValid:!1},Si={value:!0,isValid:!0};var wl=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!fe(e[0].attributes.value)?fe(e[0].value)||e[0].value===""?Si:{value:e[0].value,isValid:!0}:Si:Ni}return Ni},kl=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>fe(e)?e:t?e===""?NaN:e&&+e:n&&$e(e)?new Date(e):r?r(e):e;const Ci={isValid:!1,value:null};var Nl=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,Ci):Ci;function ji(e){const t=e.ref;return ys(t)?t.files:bs(t)?Nl(e.refs).value:bl(t)?[...t.selectedOptions].map(({value:n})=>n):an(t)?wl(e.refs).value:kl(fe(t.value)?e.ref.value:t.value,e)}var Yf=(e,t,n,r)=>{const s={};for(const i of e){const a=z(t,i);a&&le(s,i,a._f)}return{criteriaMode:n,names:[...e],fields:s,shouldUseNativeValidation:r}},Pn=e=>e instanceof RegExp,_t=e=>fe(e)?e:Pn(e)?e.source:ye(e)?Pn(e.value)?e.value.source:e.value:e,Ai=e=>({isOnSubmit:!e||e===ze.onSubmit,isOnBlur:e===ze.onBlur,isOnChange:e===ze.onChange,isOnAll:e===ze.all,isOnTouch:e===ze.onTouched});const Mi="AsyncFunction";var Gf=e=>!!e&&!!e.validate&&!!(Me(e.validate)&&e.validate.constructor.name===Mi||ye(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===Mi)),Qf=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),Ei=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const Jt=(e,t,n,r)=>{for(const s of n||Object.keys(e)){const i=z(e,s);if(i){const{_f:a,...o}=i;if(a){if(a.refs&&a.refs[0]&&t(a.refs[0],s)&&!r)return!0;if(a.ref&&t(a.ref,a.name)&&!r)return!0;if(Jt(o,t))break}else if(ye(o)&&Jt(o,t))break}}};function Ti(e,t,n){const r=z(e,n);if(r||Jn(n))return{error:r,name:n};const s=n.split(".");for(;s.length;){const i=s.join("."),a=z(t,i),o=z(e,i);if(a&&!Array.isArray(a)&&n!==i)return{name:n};if(o&&o.type)return{name:i,error:o};if(o&&o.root&&o.root.type)return{name:`${i}.root`,error:o.root};s.pop()}return{name:n}}var Zf=(e,t,n,r)=>{n(e);const{name:s,...i}=e;return je(i)||Object.keys(i).length>=Object.keys(t).length||Object.keys(i).find(a=>t[a]===(!r||ze.all))},Xf=(e,t,n)=>!e||!t||e===t||Kt(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r))),eh=(e,t,n,r,s)=>s.isOnAll?!1:!n&&s.isOnTouch?!(t||e):(n?r.isOnBlur:s.isOnBlur)?!e:(n?r.isOnChange:s.isOnChange)?e:!0,th=(e,t)=>!ms(z(e,t)).length&&ge(e,t),nh=(e,t,n)=>{const r=Kt(z(e,n));return le(r,"root",t[n]),le(e,n,r),e};function Di(e,t,n="validate"){if($e(e)||Array.isArray(e)&&e.every($e)||De(e)&&!e)return{type:n,message:$e(e)?e:"",ref:t}}var Nt=e=>ye(e)&&!Pn(e)?e:{value:e,message:""},Ii=async(e,t,n,r,s,i)=>{const{ref:a,refs:o,required:c,maxLength:d,minLength:u,min:h,max:p,pattern:m,validate:v,name:b,valueAsNumber:x,mount:w}=e._f,S=z(n,b);if(!w||t.has(b))return{};const M=o?o[0]:a,N=C=>{s&&M.reportValidity&&(M.setCustomValidity(De(C)?"":C||""),M.reportValidity())},j={},T=bs(a),$=an(a),W=T||$,D=(x||ys(a))&&fe(a.value)&&fe(S)||Fn(a)&&a.value===""||S===""||Array.isArray(S)&&!S.length,R=Uf.bind(null,b,r,j),E=(C,I,F,H=We.maxLength,Q=We.minLength)=>{const Y=C?I:F;j[b]={type:C?H:Q,message:Y,ref:a,...R(C?H:Q,Y)}};if(i?!Array.isArray(S)||!S.length:c&&(!W&&(D||Ee(S))||De(S)&&!S||$&&!wl(o).isValid||T&&!Nl(o).isValid)){const{value:C,message:I}=$e(c)?{value:!!c,message:c}:Nt(c);if(C&&(j[b]={type:We.required,message:I,ref:M,...R(We.required,I)},!r))return N(I),j}if(!D&&(!Ee(h)||!Ee(p))){let C,I;const F=Nt(p),H=Nt(h);if(!Ee(S)&&!isNaN(S)){const Q=a.valueAsNumber||S&&+S;Ee(F.value)||(C=Q>F.value),Ee(H.value)||(I=Q<H.value)}else{const Q=a.valueAsDate||new Date(S),Y=ce=>new Date(new Date().toDateString()+" "+ce),te=a.type=="time",oe=a.type=="week";$e(F.value)&&S&&(C=te?Y(S)>Y(F.value):oe?S>F.value:Q>new Date(F.value)),$e(H.value)&&S&&(I=te?Y(S)<Y(H.value):oe?S<H.value:Q<new Date(H.value))}if((C||I)&&(E(!!C,F.message,H.message,We.max,We.min),!r))return N(j[b].message),j}if((d||u)&&!D&&($e(S)||i&&Array.isArray(S))){const C=Nt(d),I=Nt(u),F=!Ee(C.value)&&S.length>+C.value,H=!Ee(I.value)&&S.length<+I.value;if((F||H)&&(E(F,C.message,I.message),!r))return N(j[b].message),j}if(m&&!D&&$e(S)){const{value:C,message:I}=Nt(m);if(Pn(C)&&!S.match(C)&&(j[b]={type:We.pattern,message:I,ref:a,...R(We.pattern,I)},!r))return N(I),j}if(v){if(Me(v)){const C=await v(S,n),I=Di(C,M);if(I&&(j[b]={...I,...R(We.validate,I.message)},!r))return N(I.message),j}else if(ye(v)){let C={};for(const I in v){if(!je(C)&&!r)break;const F=Di(await v[I](S,n),M,I);F&&(C={...F,...R(I,F.message)},N(F.message),r&&(j[b]=C))}if(!je(C)&&(j[b]={ref:M,...C},!r))return j}}return N(!0),j};const rh={mode:ze.onSubmit,reValidateMode:ze.onChange,shouldFocusError:!0};function sh(e={}){let t={...rh,...e},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:Me(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},s=ye(t.defaultValues)||ye(t.values)?pe(t.defaultValues||t.values)||{}:{},i=t.shouldUnregister?{}:pe(s),a={action:!1,mount:!1,watch:!1,keepIsValid:!1},o={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},c,d=0;const u={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},h={...u};let p={...h};const m={array:ki(),state:ki()},v=t.criteriaMode===ze.all,b=g=>k=>{clearTimeout(d),d=setTimeout(g,k)},x=async g=>{if(!a.keepIsValid&&!t.disabled&&(h.isValid||p.isValid||g)){let k;t.resolver?(k=je((await W()).errors),w()):k=await R(r,!0),k!==n.isValid&&m.state.next({isValid:k})}},w=(g,k)=>{!t.disabled&&(h.isValidating||h.validatingFields||p.isValidating||p.validatingFields)&&((g||Array.from(o.mount)).forEach(A=>{A&&(k?le(n.validatingFields,A,k):ge(n.validatingFields,A))}),m.state.next({validatingFields:n.validatingFields,isValidating:!je(n.validatingFields)}))},S=(g,k=[],A,B,L=!0,O=!0)=>{if(B&&A&&!t.disabled){if(a.action=!0,O&&Array.isArray(z(r,g))){const q=A(z(r,g),B.argA,B.argB);L&&le(r,g,q)}if(O&&Array.isArray(z(n.errors,g))){const q=A(z(n.errors,g),B.argA,B.argB);L&&le(n.errors,g,q),th(n.errors,g)}if((h.touchedFields||p.touchedFields)&&O&&Array.isArray(z(n.touchedFields,g))){const q=A(z(n.touchedFields,g),B.argA,B.argB);L&&le(n.touchedFields,g,q)}(h.dirtyFields||p.dirtyFields)&&(n.dirtyFields=At(s,i)),m.state.next({name:g,isDirty:C(g,k),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else le(i,g,k)},M=(g,k)=>{le(n.errors,g,k),m.state.next({errors:n.errors})},N=g=>{n.errors=g,m.state.next({errors:n.errors,isValid:!1})},j=(g,k,A,B)=>{const L=z(r,g);if(L){const O=z(i,g,fe(A)?z(s,g):A);fe(O)||B&&B.defaultChecked||k?le(i,g,k?O:ji(L._f)):H(g,O),a.mount&&!a.action&&x()}},T=(g,k,A,B,L)=>{let O=!1,q=!1;const re={name:g};if(!t.disabled){if(!A||B){(h.isDirty||p.isDirty)&&(q=n.isDirty,n.isDirty=re.isDirty=C(),O=q!==re.isDirty);const se=Be(z(s,g),k);q=!!z(n.dirtyFields,g),se?ge(n.dirtyFields,g):le(n.dirtyFields,g,!0),re.dirtyFields=n.dirtyFields,O=O||(h.dirtyFields||p.dirtyFields)&&q!==!se}if(A){const se=z(n.touchedFields,g);se||(le(n.touchedFields,g,A),re.touchedFields=n.touchedFields,O=O||(h.touchedFields||p.touchedFields)&&se!==A)}O&&L&&m.state.next(re)}return O?re:{}},$=(g,k,A,B)=>{const L=z(n.errors,g),O=(h.isValid||p.isValid)&&De(k)&&n.isValid!==k;if(t.delayError&&A?(c=b(()=>M(g,A)),c(t.delayError)):(clearTimeout(d),c=null,A?le(n.errors,g,A):ge(n.errors,g)),(A?!Be(L,A):L)||!je(B)||O){const q={...B,...O&&De(k)?{isValid:k}:{},errors:n.errors,name:g};n={...n,...q},m.state.next(q)}},W=async g=>(w(g,!0),await t.resolver(i,t.context,Yf(g||o.mount,r,t.criteriaMode,t.shouldUseNativeValidation))),D=async g=>{const{errors:k}=await W(g);if(w(g),g)for(const A of g){const B=z(k,A);B?le(n.errors,A,B):ge(n.errors,A)}else n.errors=k;return k},R=async(g,k,A={valid:!0})=>{for(const B in g){const L=g[B];if(L){const{_f:O,...q}=L;if(O){const re=o.array.has(O.name),se=L._f&&Gf(L._f);se&&h.validatingFields&&w([O.name],!0);const Ce=await Ii(L,o.disabled,i,v,t.shouldUseNativeValidation&&!k,re);if(se&&h.validatingFields&&w([O.name]),Ce[O.name]&&(A.valid=!1,k||e.shouldUseNativeValidation))break;!k&&(z(Ce,O.name)?re?nh(n.errors,Ce,O.name):le(n.errors,O.name,Ce[O.name]):ge(n.errors,O.name))}!je(q)&&await R(q,k,A)}}return A.valid},E=()=>{for(const g of o.unMount){const k=z(r,g);k&&(k._f.refs?k._f.refs.every(A=>!pr(A)):!pr(k._f.ref))&&Ot(g)}o.unMount=new Set},C=(g,k)=>!t.disabled&&(g&&k&&le(i,g,k),!Be(P(),s)),I=(g,k,A)=>Vr(g,o,{...a.mount?i:fe(k)?s:$e(g)?{[g]:k}:k},A,k),F=g=>ms(z(a.mount?i:s,g,t.shouldUnregister?z(s,g,[]):[])),H=(g,k,A={})=>{const B=z(r,g);let L=k;if(B){const O=B._f;O&&(!O.disabled&&le(i,g,kl(k,O)),L=Fn(O.ref)&&Ee(k)?"":k,bl(O.ref)?[...O.ref.options].forEach(q=>q.selected=L.includes(q.value)):O.refs?an(O.ref)?O.refs.forEach(q=>{(!q.defaultChecked||!q.disabled)&&(Array.isArray(L)?q.checked=!!L.find(re=>re===q.value):q.checked=L===q.value||!!L)}):O.refs.forEach(q=>q.checked=q.value===L):ys(O.ref)?O.ref.value="":(O.ref.value=L,O.ref.type||m.state.next({name:g,values:pe(i)})))}(A.shouldDirty||A.shouldTouch)&&T(g,L,A.shouldTouch,A.shouldDirty,!0),A.shouldValidate&&ce(g)},Q=(g,k,A)=>{for(const B in k){if(!k.hasOwnProperty(B))return;const L=k[B],O=g+"."+B,q=z(r,O);(o.array.has(g)||ye(L)||q&&!q._f)&&!mt(L)?Q(O,L,A):H(O,L,A)}},Y=(g,k,A={})=>{const B=z(r,g),L=o.array.has(g),O=pe(k);le(i,g,O),L?(m.array.next({name:g,values:pe(i)}),(h.isDirty||h.dirtyFields||p.isDirty||p.dirtyFields)&&A.shouldDirty&&m.state.next({name:g,dirtyFields:At(s,i),isDirty:C(g,O)})):B&&!B._f&&!Ee(O)?Q(g,O,A):H(g,O,A),Ei(g,o)?m.state.next({...n,name:g,values:pe(i)}):m.state.next({name:a.mount?g:void 0,values:pe(i)})},te=async g=>{a.mount=!0;const k=g.target;let A=k.name,B=!0;const L=z(r,A),O=se=>{B=Number.isNaN(se)||mt(se)&&isNaN(se.getTime())||Be(se,z(i,A,se))},q=Ai(t.mode),re=Ai(t.reValidateMode);if(L){let se,Ce;const lt=k.type?ji(L._f):ml(g),Ge=g.type===Ln.BLUR||g.type===Ln.FOCUS_OUT,jo=!Qf(L._f)&&!t.resolver&&!z(n.errors,A)&&!L._f.deps||eh(Ge,z(n.touchedFields,A),n.isSubmitted,re,q),Gn=Ei(A,o,Ge);le(i,A,lt),Ge?(!k||!k.readOnly)&&(L._f.onBlur&&L._f.onBlur(g),c&&c(0)):L._f.onChange&&L._f.onChange(g);const Qn=T(A,lt,Ge),Ao=!je(Qn)||Gn;if(!Ge&&m.state.next({name:A,type:g.type,values:pe(i)}),jo)return(h.isValid||p.isValid)&&(t.mode==="onBlur"?Ge&&x():Ge||x()),Ao&&m.state.next({name:A,...Gn?{}:Qn});if(!Ge&&Gn&&m.state.next({...n}),t.resolver){const{errors:Ms}=await W([A]);if(w([A]),O(lt),B){const Mo=Ti(n.errors,r,A),Es=Ti(Ms,r,Mo.name||A);se=Es.error,A=Es.name,Ce=je(Ms)}}else w([A],!0),se=(await Ii(L,o.disabled,i,v,t.shouldUseNativeValidation))[A],w([A]),O(lt),B&&(se?Ce=!1:(h.isValid||p.isValid)&&(Ce=await R(r,!0)));B&&(L._f.deps&&(!Array.isArray(L._f.deps)||L._f.deps.length>0)&&ce(L._f.deps),$(A,Ce,se,Qn))}},oe=(g,k)=>{if(z(n.errors,k)&&g.focus)return g.focus(),1},ce=async(g,k={})=>{let A,B;const L=Kt(g);if(t.resolver){const O=await D(fe(g)?g:L);A=je(O),B=g?!L.some(q=>z(O,q)):A}else g?(B=(await Promise.all(L.map(async O=>{const q=z(r,O);return await R(q&&q._f?{[O]:q}:q)}))).every(Boolean),!(!B&&!n.isValid)&&x()):B=A=await R(r);return m.state.next({...!$e(g)||(h.isValid||p.isValid)&&A!==n.isValid?{}:{name:g},...t.resolver||!g?{isValid:A}:{},errors:n.errors}),k.shouldFocus&&!B&&Jt(r,oe,g?L:o.mount),B},P=(g,k)=>{let A={...a.mount?i:s};return k&&(A=yl(k.dirtyFields?n.dirtyFields:n.touchedFields,A)),fe(g)?A:$e(g)?z(A,g):g.map(B=>z(A,B))},_=(g,k)=>({invalid:!!z((k||n).errors,g),isDirty:!!z((k||n).dirtyFields,g),error:z((k||n).errors,g),isValidating:!!z(n.validatingFields,g),isTouched:!!z((k||n).touchedFields,g)}),G=g=>{g&&Kt(g).forEach(k=>ge(n.errors,k)),m.state.next({errors:g?n.errors:{}})},ne=(g,k,A)=>{const B=(z(r,g,{_f:{}})._f||{}).ref,L=z(n.errors,g)||{},{ref:O,message:q,type:re,...se}=L;le(n.errors,g,{...se,...k,ref:B}),m.state.next({name:g,errors:n.errors,isValid:!1}),A&&A.shouldFocus&&B&&B.focus&&B.focus()},Se=(g,k)=>Me(g)?m.state.subscribe({next:A=>"values"in A&&g(I(void 0,k),A)}):I(g,k,!0),at=g=>m.state.subscribe({next:k=>{Xf(g.name,k.name,g.exact)&&Zf(k,g.formState||h,Co,g.reRenderRoot)&&g.callback({values:{...i},...n,...k,defaultValues:s})}}).unsubscribe,$t=g=>(a.mount=!0,p={...p,...g.formState},at({...g,formState:{...u,...g.formState}})),Ot=(g,k={})=>{for(const A of g?Kt(g):o.mount)o.mount.delete(A),o.array.delete(A),k.keepValue||(ge(r,A),ge(i,A)),!k.keepError&&ge(n.errors,A),!k.keepDirty&&ge(n.dirtyFields,A),!k.keepTouched&&ge(n.touchedFields,A),!k.keepIsValidating&&ge(n.validatingFields,A),!t.shouldUnregister&&!k.keepDefaultValue&&ge(s,A);m.state.next({values:pe(i)}),m.state.next({...n,...k.keepDirty?{isDirty:C()}:{}}),!k.keepIsValid&&x()},on=({disabled:g,name:k})=>{if(De(g)&&a.mount||g||o.disabled.has(k)){const L=o.disabled.has(k)!==!!g;g?o.disabled.add(k):o.disabled.delete(k),L&&a.mount&&!a.action&&x()}},Lt=(g,k={})=>{let A=z(r,g);const B=De(k.disabled)||De(t.disabled);return le(r,g,{...A||{},_f:{...A&&A._f?A._f:{ref:{name:g}},name:g,mount:!0,...k}}),o.mount.add(g),A?on({disabled:De(k.disabled)?k.disabled:t.disabled,name:g}):j(g,!0,k.value),{...B?{disabled:k.disabled||t.disabled}:{},...t.progressive?{required:!!k.required,min:_t(k.min),max:_t(k.max),minLength:_t(k.minLength),maxLength:_t(k.maxLength),pattern:_t(k.pattern)}:{},name:g,onChange:te,onBlur:te,ref:L=>{if(L){Lt(g,k),A=z(r,g);const O=fe(L.value)&&L.querySelectorAll&&L.querySelectorAll("input,select,textarea")[0]||L,q=qf(O),re=A._f.refs||[];if(q?re.find(se=>se===O):O===A._f.ref)return;le(r,g,{_f:{...A._f,...q?{refs:[...re.filter(pr),O,...Array.isArray(z(s,g))?[{}]:[]],ref:{type:O.type,name:g}}:{ref:O}}}),j(g,!1,void 0,O)}else A=z(r,g,{}),A._f&&(A._f.mount=!1),(t.shouldUnregister||k.shouldUnregister)&&!(pl(o.array,g)&&a.action)&&o.unMount.add(g)}}},Ft=()=>t.shouldFocusError&&Jt(r,oe,o.mount),cn=g=>{De(g)&&(m.state.next({disabled:g}),Jt(r,(k,A)=>{const B=z(r,A);B&&(k.disabled=B._f.disabled||g,Array.isArray(B._f.refs)&&B._f.refs.forEach(L=>{L.disabled=B._f.disabled||g}))},0,!1))},Pt=(g,k)=>async A=>{let B;A&&(A.preventDefault&&A.preventDefault(),A.persist&&A.persist());let L=pe(i);if(m.state.next({isSubmitting:!0}),t.resolver){const{errors:O,values:q}=await W();w(),n.errors=O,L=pe(q)}else await R(r);if(o.disabled.size)for(const O of o.disabled)ge(L,O);if(ge(n.errors,"root"),je(n.errors)){m.state.next({errors:{}});try{await g(L,A)}catch(O){B=O}}else k&&await k({...n.errors},A),Ft(),setTimeout(Ft);if(m.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:je(n.errors)&&!B,submitCount:n.submitCount+1,errors:n.errors}),B)throw B},wt=(g,k={})=>{z(r,g)&&(fe(k.defaultValue)?Y(g,pe(z(s,g))):(Y(g,k.defaultValue),le(s,g,pe(k.defaultValue))),k.keepTouched||ge(n.touchedFields,g),k.keepDirty||(ge(n.dirtyFields,g),n.isDirty=k.defaultValue?C(g,pe(z(s,g))):C()),k.keepError||(ge(n.errors,g),h.isValid&&x()),m.state.next({...n}))},ue=(g,k={})=>{const A=g?pe(g):s,B=pe(A),L=je(g),O=L?s:B;if(k.keepDefaultValues||(s=A),!k.keepValues){if(k.keepDirtyValues){const q=new Set([...o.mount,...Object.keys(At(s,i))]);for(const re of Array.from(q)){const se=z(n.dirtyFields,re),Ce=z(i,re),lt=z(O,re);se&&!fe(Ce)?le(O,re,Ce):!se&&!fe(lt)&&Y(re,lt)}}else{if(hs&&fe(g))for(const q of o.mount){const re=z(r,q);if(re&&re._f){const se=Array.isArray(re._f.refs)?re._f.refs[0]:re._f.ref;if(Fn(se)){const Ce=se.closest("form");if(Ce){Ce.reset();break}}}}if(k.keepFieldsRef)for(const q of o.mount)Y(q,z(O,q));else r={}}i=t.shouldUnregister?k.keepDefaultValues?pe(s):{}:pe(O),m.array.next({values:{...O}}),m.state.next({values:{...O}})}o={mount:k.keepDirtyValues?o.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},a.mount=!h.isValid||!!k.keepIsValid||!!k.keepDirtyValues||!t.shouldUnregister&&!je(O),a.watch=!!t.shouldUnregister,a.keepIsValid=!!k.keepIsValid,a.action=!1,k.keepErrors||(n.errors={}),m.state.next({submitCount:k.keepSubmitCount?n.submitCount:0,isDirty:L?!1:k.keepDirty?n.isDirty:!!(k.keepDefaultValues&&!Be(g,s)),isSubmitted:k.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:L?{}:k.keepDirtyValues?k.keepDefaultValues&&i?At(s,i):n.dirtyFields:k.keepDefaultValues&&g?At(s,g):k.keepDirty?n.dirtyFields:{},touchedFields:k.keepTouched?n.touchedFields:{},errors:k.keepErrors?n.errors:{},isSubmitSuccessful:k.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:s})},Te=(g,k)=>ue(Me(g)?g(i):g,{...t.resetOptions,...k}),So=(g,k={})=>{const A=z(r,g),B=A&&A._f;if(B){const L=B.refs?B.refs[0]:B.ref;L.focus&&setTimeout(()=>{L.focus(),k.shouldSelect&&Me(L.select)&&L.select()})}},Co=g=>{n={...n,...g}},As={control:{register:Lt,unregister:Ot,getFieldState:_,handleSubmit:Pt,setError:ne,_subscribe:at,_runSchema:W,_updateIsValidating:w,_focusError:Ft,_getWatch:I,_getDirty:C,_setValid:x,_setFieldArray:S,_setDisabledField:on,_setErrors:N,_getFieldArray:F,_reset:ue,_resetDefaultValues:()=>Me(t.defaultValues)&&t.defaultValues().then(g=>{Te(g,t.resetOptions),m.state.next({isLoading:!1})}),_removeUnmounted:E,_disableForm:cn,_subjects:m,_proxyFormState:h,get _fields(){return r},get _formValues(){return i},get _state(){return a},set _state(g){a=g},get _defaultValues(){return s},get _names(){return o},set _names(g){o=g},get _formState(){return n},get _options(){return t},set _options(g){t={...t,...g}}},subscribe:$t,trigger:ce,register:Lt,handleSubmit:Pt,watch:Se,setValue:Y,getValues:P,reset:Te,resetField:wt,clearErrors:G,unregister:Ot,setError:ne,setFocus:So,getFieldState:_};return{...As,formControl:As}}function ih(e={}){const t=y.useRef(void 0),n=y.useRef(void 0),[r,s]=y.useState({isDirty:!1,isValidating:!1,isLoading:Me(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:Me(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:r},e.defaultValues&&!Me(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:a,...o}=sh(e);t.current={...o,formState:r}}const i=t.current.control;return i._options=e,xs(()=>{const a=i._subscribe({formState:i._proxyFormState,callback:()=>s({...i._formState}),reRenderRoot:!0});return s(o=>({...o,isReady:!0})),i._formState.isReady=!0,a},[i]),y.useEffect(()=>i._disableForm(e.disabled),[i,e.disabled]),y.useEffect(()=>{e.mode&&(i._options.mode=e.mode),e.reValidateMode&&(i._options.reValidateMode=e.reValidateMode)},[i,e.mode,e.reValidateMode]),y.useEffect(()=>{e.errors&&(i._setErrors(e.errors),i._focusError())},[i,e.errors]),y.useEffect(()=>{e.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,e.shouldUnregister]),y.useEffect(()=>{if(i._proxyFormState.isDirty){const a=i._getDirty();a!==r.isDirty&&i._subjects.state.next({isDirty:a})}},[i,r.isDirty]),y.useEffect(()=>{var a;e.values&&!Be(e.values,n.current)?(i._reset(e.values,{keepFieldsRef:!0,...i._options.resetOptions}),!((a=i._options.resetOptions)===null||a===void 0)&&a.keepIsValid||i._setValid(),n.current=e.values,s(o=>({...o}))):i._resetDefaultValues()},[i,e.values]),y.useEffect(()=>{i._state.mount||(i._setValid(),i._state.mount=!0),i._state.watch&&(i._state.watch=!1,i._subjects.state.next({...i._formState})),i._removeUnmounted()}),t.current.formState=y.useMemo(()=>xl(r,i),[i,r]),t.current}function ah(e,t=3){return e%1===0?e.toString():e.toFixed(t).replace(/\.?0+$/,"")}function lh(e,t="en-US",n="USD"){try{return new Intl.NumberFormat(t,{style:"currency",currency:n,minimumFractionDigits:2,maximumFractionDigits:2}).format(e)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${e.toFixed(2)}`}}function oh(e="USD",t="en-US"){try{return new Intl.NumberFormat(t,{style:"currency",currency:e}).formatToParts(0).find(i=>i.type==="currency")?.value??"$"}catch{return"$"}}function ch(e){const t=e.replace(/[^\d.,-]/g,""),n=t.match(/,\d{1,2}$/);let r;n?r=t.replace(/\./g,"").replace(",","."):r=t.replace(/,/g,"");const s=parseFloat(r);return isNaN(s)?null:s}function dh(e,t,n=.001){const r=e-t,s=Math.abs(r)<=n;return{difference:r,isBalanced:s,isUnderAllocated:!s&&r>0,isOverAllocated:!s&&r<0}}function vs(){return`dist-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}vs();const uh={amount:"Amount",glAccount:"GL Account",taxDeductible:"Tax Deductible",amountPlaceholder:"0.00",glAccountPlaceholder:"Search GL Account",noGlAccountsFound:"No GL Accounts found. Try another search term",searching:"Searching for GL Accounts...",amountTooltip:"Enter the amount for this distribution",glAccountTooltip:"Select the General Ledger account for this distribution",taxDeductibleTooltip:"Check if this distribution is tax deductible",deleteButton:"Delete",currencySymbol:"$"},gr=()=>({id:vs(),amount:0,glAccount:null,isTaxDeductible:!1}),Sl=({distribution:e,defaultDistribution:t,glAccounts:n=[],isLoadingGlAccounts:r=!1,onSearchGlAccounts:s,onDistributionChange:i,onAmountChange:a,onGlAccountChange:o,onTaxDeductibleChange:c,onDelete:d,canDelete:u=!0,canEditTaxDeductible:h=!0,isDisabled:p=!1,labels:m,classNames:v={},"data-testid":b,control:x,name:w,rules:S})=>{const M={...uh,...m},N=x!==void 0&&w!==void 0,j=ih({defaultValues:{_internal:t||gr()}}),T=Vf({control:N?x:j.control,name:N?w:"_internal",rules:N?S:void 0}),[$,W]=y.useState(t||gr()),D=N?T.field.value??gr():e??$,R=N&&!!T.fieldState?.error,E=N&&(T.fieldState?.isTouched??!1),C=R||E,I=C&&(!D.amount||D.amount<=0),F=C&&!D.glAccount,[H,Q]=y.useState(D.glAccount?.name||""),Y=y.useCallback(ne=>{const Se={...D,...ne};N&&T.field.onChange(Se),!N&&e===void 0&&W(Se),i?.(Se)},[D,e,i,N,T]),te=y.useCallback(ne=>{const Se=ne||0;Y({amount:Se}),a?.(Se)},[Y,a]),oe=y.useCallback(ne=>{Q(ne),s?.(ne)},[s]),ce=y.useCallback(ne=>{if(ne===null){Y({glAccount:null}),o?.(null);return}const at=n.find($t=>String($t.id)===String(ne))||null;Y({glAccount:at}),o?.(at)},[n,Y,o]),P=y.useCallback(()=>{Q(""),Y({glAccount:null}),o?.(null)},[Y,o]),_=y.useCallback(ne=>{Y({isTaxDeductible:ne}),c?.(ne)},[Y,c]),G=y.useCallback(()=>{d?.()},[d]);return l.jsx(f.Card,{radius:"md",shadow:"sm","data-testid":b||"revenue-distribution-card",className:f.cn(v.base),children:l.jsxs(f.CardBody,{className:f.cn("flex flex-row flex-nowrap items-start gap-4",v.body),children:[l.jsx("div",{className:f.cn("shrink-0",v.amountContainer),children:l.jsx(f.NumberInput,{"data-testid":`${b||"revenue-distribution-card"}-amount-input`,label:l.jsxs("span",{className:"flex items-center gap-1",children:[M.amount,l.jsx(f.Tooltip,{content:M.amountTooltip,children:l.jsx(U,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),value:D.amount||void 0,onValueChange:te,labelPlacement:"outside",placeholder:M.amountPlaceholder,isWheelDisabled:!0,hideStepper:!0,variant:"bordered",isDisabled:p,isInvalid:I,errorMessage:I?"Amount is required":void 0,minValue:0,step:.01,className:v.amountInput,startContent:l.jsx("div",{className:"pointer-events-none flex items-center",children:l.jsx("span",{className:"text-default-400 text-small",children:M.currencySymbol})})})}),l.jsx("div",{className:f.cn("grow",v.glAccountContainer),children:l.jsx(f.Autocomplete,{"data-testid":`${b||"revenue-distribution-card"}-gl-account-input`,label:l.jsxs("span",{className:"flex items-center gap-1",children:[M.glAccount,l.jsx(f.Tooltip,{content:M.glAccountTooltip,children:l.jsx(U,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),isLoading:r,isClearable:!0,labelPlacement:"outside",variant:"bordered",items:n,menuTrigger:"input",inputValue:D.glAccount?.name??H,selectedKey:D.glAccount?.id??null,isDisabled:p,isInvalid:F,errorMessage:F?"GL Account is required":void 0,listboxProps:{emptyContent:r?M.searching:M.noGlAccountsFound},placeholder:M.glAccountPlaceholder,onInputChange:oe,onSelectionChange:ce,onClear:P,className:v.glAccountInput,children:ne=>l.jsx(f.AutocompleteItem,{textValue:ne.name,children:l.jsxs("div",{className:"flex flex-col",children:[l.jsx("span",{children:ne.name}),ne.code&&l.jsx("span",{className:"text-xs text-default-400",children:ne.code})]})},ne.id)})}),l.jsx("div",{className:f.cn("shrink-0 pt-6 flex items-center",v.taxDeductibleContainer),children:l.jsx(f.Checkbox,{radius:"full","data-testid":`${b||"revenue-distribution-card"}-tax-deductible`,isSelected:D.isTaxDeductible,onValueChange:_,isDisabled:p||!h,className:v.taxDeductibleCheckbox,children:M.taxDeductible})}),l.jsx("div",{className:f.cn("shrink-0 pt-6",v.deleteContainer),children:l.jsx(K,{"data-testid":`${b||"revenue-distribution-card"}-delete-button`,size:"sm",color:"danger",variant:"flat",isDisabled:p||!u,onPress:G,startContent:l.jsx(U,{icon:"solar:trash-bin-trash-linear",width:16}),className:f.cn("text-danger",v.deleteButton),children:M.deleteButton})})]})})};Sl.displayName="RevenueDistributionCard";const Cl=({message:e="No distributions configured",icon:t="solar:document-text-outline",iconSize:n=48,showCard:r=!0,classNames:s={},renderEmpty:i})=>{if(i)return l.jsx(l.Fragment,{children:i()});const a=l.jsxs("div",{className:f.cn("flex flex-col items-center justify-center py-8",s.content),children:[l.jsx(U,{icon:t,width:n,className:f.cn("text-default-300 mb-4",s.icon)}),l.jsx("p",{className:f.cn("text-default-500 text-sm text-center",s.message),children:e})]});return r?l.jsx(f.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-empty",className:f.cn("w-full",s.base),children:l.jsx(f.CardBody,{children:a})}):l.jsx("div",{"data-testid":"revenue-distribution-empty",className:f.cn("w-full",s.base),children:a})};Cl.displayName="RevenueDistributionEmpty";const fh={title:"Error Loading Distributions",description:"An error occurred while loading the distribution configuration. Please try again."},jl=({error:e,labels:t,showCard:n=!0,color:r="danger",classNames:s={}})=>{const i={...fh,...t},a=l.jsx(f.Alert,{"data-testid":"revenue-distribution-error-alert",color:r,title:i.title,description:e||i.description,className:s.alert});return n?l.jsx(f.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-error",className:f.cn("w-full",s.base),children:l.jsx(f.CardBody,{children:a})}):l.jsx("div",{"data-testid":"revenue-distribution-error",className:f.cn("w-full",s.base),children:a})};jl.displayName="RevenueDistributionError";const Al=({rows:e=1,showCard:t=!0,classNames:n={}})=>{const r=Array.from({length:e},(i,a)=>a),s=i=>l.jsxs("div",{className:f.cn("flex flex-row flex-nowrap items-end gap-4",n.row),children:[l.jsxs("div",{className:"shrink-0 flex flex-col gap-1",children:[l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(f.Skeleton,{className:"h-4 w-14 rounded-md"}),l.jsx(f.Skeleton,{className:"h-4 w-4 rounded-full"})]}),l.jsx(f.Skeleton,{className:"h-10 w-32 rounded-lg"})]}),l.jsxs("div",{className:"grow flex flex-col gap-1",children:[l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(f.Skeleton,{className:"h-4 w-20 rounded-md"}),l.jsx(f.Skeleton,{className:"h-4 w-4 rounded-full"})]}),l.jsx(f.Skeleton,{className:"h-10 w-full rounded-lg"})]}),l.jsxs("div",{className:"shrink-0 pb-2 flex items-center gap-2",children:[l.jsx(f.Skeleton,{className:"h-5 w-5 rounded-full"}),l.jsx(f.Skeleton,{className:"h-4 w-24 rounded-md"})]}),l.jsx("div",{className:"shrink-0 pb-2",children:l.jsx(f.Skeleton,{className:"h-8 w-20 rounded-lg"})})]},i);return t?l.jsx("div",{className:f.cn("flex flex-col gap-3",n.base),children:r.map(i=>l.jsx(f.Card,{radius:"md",shadow:"sm","data-testid":`revenue-distribution-skeleton-${i}`,children:l.jsx(f.CardBody,{children:s(i)})},i))}):l.jsx("div",{"data-testid":"revenue-distribution-skeleton",className:f.cn("flex flex-col gap-3",n.base),children:r.map(i=>s(i))})};Al.displayName="RevenueDistributionSkeleton";function Rn({isOpen:e,labels:t,icon:n,isConfirming:r=!1,confirmColor:s="danger",iconTone:i="danger",onClose:a,onConfirm:o}){return l.jsx(f.Modal,{isOpen:e,size:"md",placement:"center",classNames:{base:"max-w-[440px] rounded-3xl",closeButton:"right-5 top-5 text-zinc-500"},onOpenChange:c=>!c&&a(),children:l.jsxs(f.ModalContent,{children:[l.jsxs(f.ModalHeader,{className:"flex flex-col items-start gap-4 px-7 pb-0 pt-7",children:[n&&l.jsx("span",{className:f.cn("flex h-12 w-12 shrink-0 items-center justify-center rounded-full",i==="warning"?"bg-brand/15 text-brand":"bg-danger-100 text-danger-600"),children:n}),l.jsx("span",{className:"text-lg font-semibold leading-6 text-zinc-950",children:t.title})]}),l.jsx(f.ModalBody,{className:"px-7 pb-3 pt-4",children:l.jsx("div",{className:"text-sm leading-6 text-zinc-500",children:t.description})}),l.jsxs(f.ModalFooter,{className:"grid grid-cols-2 gap-3 px-7 pb-7 pt-3",children:[l.jsx(K,{type:"button",variant:"bordered",radius:"full",className:"h-10 border-zinc-200 bg-white text-sm font-normal text-zinc-900",onPress:a,children:t.cancel}),l.jsx(K,{type:"button",color:s,radius:"full",className:f.cn("h-10 text-sm font-normal text-white",s==="danger"?"bg-danger-600":"bg-brand"),isLoading:r,onPress:o,children:t.confirm})]})]})})}const hh={title:"Payment assignment",singleFund:"Single fund",splitFunds:"Split across multiple funds",saveAssignment:"Save assignment",assignSpecificFund:"Assign specific fund",addFund:"Add account",emptySingle:"You have not assign any specific fund for this opportunity",emptySplit:"Select at least two funds and assign percentages that total 100%",selectedFund:"Selected fund",percentage:"Percentage",total:"Total",totalError:"Percentages must total 100%",removeFund:"Remove fund",modalTitle:"Select an specific fund",searchPlaceholder:"Search...",glCode:"GL Code",accountName:"Specific Fund Name",type:"Type",actions:"Actions",select:"Select",noFunds:"No specific funds available",modifyAssignedFundsTitle:"Modify Assigned Funds",modifyAssignedFundsDescription:"Changing the assigned funds will only affect up and coming payments.",modifyAssignedFundsWarning:"Payments already paid will still keep the previous configuration.",modifyAssignedFundsCancel:"Cancel",modifyAssignedFundsConfirm:"Continue"},Ml={base:"min-h-11 rounded-full bg-zinc-100 px-4 py-2 shadow-none",iconWrapper:"!h-4 !w-4 shrink-0 !bg-transparent !shadow-none !border-0 text-zinc-900",alertIcon:"!static !h-4 !w-4 !translate-x-0 !translate-y-0 text-zinc-900",mainWrapper:"min-w-0",title:"text-sm font-normal text-zinc-900"},Vt={...Ml,base:"min-h-11 rounded-2xl px-4 py-2 shadow-none",title:"text-sm font-medium"},mh={inputWrapper:"h-9 rounded-xl border border-zinc-200 bg-white shadow-none hover:border-zinc-300 data-[hover=true]:border-zinc-300 group-data-[focus=true]:border-zinc-400 group-data-[focus-visible=true]:ring-0"},$i=()=>({id:crypto.randomUUID(),fund:null,percentage:0}),ph=e=>Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e*100)/100)):0,gh=e=>e.fund!==null;function xh({mode:e,assignments:t,funds:n,labels:r,classNames:s,isSaving:i=!1,hasSavedAssignments:a=!1,isFundPickerOpen:o=!1,activeAssignmentId:c=null,footer:d,onModeChange:u,onAssignmentsChange:h,onOpenFundPicker:p,onCloseFundPicker:m,onCollapseChange:v,onSave:b}){const x={...hh,...r},w=t.filter(gh),S=w.length>0,M=y.useMemo(()=>t.reduce((P,_)=>P+Number(_.percentage||0),0),[t]),N=Math.round(M*100)/100,j=e==="split"&&t.some(P=>!P.fund||Number(P.percentage||0)<=0),T=e==="split"&&S&&(N!==100||j),$=e==="split"&&S&&N>=100,W=e==="split"||!S,[D,R]=y.useState(null),[E,C]=y.useState(!1),I=P=>{if(P!==e){if(P==="single"){const _=w[0]?.fund??null;h([{id:t[0]?.id??crypto.randomUUID(),fund:_,percentage:_?100:0}])}else{const _=w[0];h([{id:_?.id??crypto.randomUUID(),fund:_?.fund??null,percentage:_?.fund?50:0},$i()])}u(P)}},F=(P,_)=>{h(t.map(G=>G.id===P?{...G,..._}:G))},H=()=>{$||h([...t,$i()])},Q=P=>{if(!(t.length<=2)){if(!a){h(t.filter(_=>_.id!==P));return}R(P)}},Y=()=>{if(!D||t.length<=2){R(null);return}h(t.filter(P=>P.id!==D)),R(null)},te=()=>{if(!i){if(!a){b();return}C(!0)}},oe=()=>{C(!1),b()},ce=P=>{const _=c??t.find(G=>!G.fund)?.id??t[0]?.id;_&&(h(t.map(G=>G.id===_?{...G,fund:P,percentage:e==="single"?100:G.percentage}:G)),m())};return l.jsxs("div",{className:f.cn("vvt-pa font-sans text-zinc-900",s?.root),children:[l.jsx(f.Accordion,{variant:"splitted",defaultSelectedKeys:["installment-fund-assignment"],className:f.cn("w-full gap-0 px-0",s?.panel),itemClasses:{base:"w-full rounded-2xl border border-zinc-200 bg-white p-0 shadow-sm",trigger:f.cn("px-4 py-4",s?.header),title:"text-xl font-semibold leading-8 text-zinc-900",content:"w-full px-4 pb-4 pt-0",indicator:"text-zinc-500"},onSelectionChange:P=>v?.(!(P==="all"||Array.from(P).length>0)),children:l.jsx(f.AccordionItem,{"aria-label":x.title,title:x.title,children:l.jsxs("div",{className:f.cn("flex w-full flex-col gap-4",s?.content),children:[l.jsxs("div",{className:"flex w-full items-center justify-between gap-6",children:[l.jsx(yh,{mode:e,labels:x,onModeChange:I,className:s?.tabs}),l.jsx(K,{type:"button",size:"sm",color:"primary",radius:"full",className:"ml-auto h-9 min-w-40 bg-brand px-4 text-sm font-medium text-white",startContent:l.jsx(U,{icon:"solar:cloud-upload-outline",className:"size-4"}),isLoading:i,onPress:te,children:x.saveAssignment})]}),l.jsxs("div",{className:"flex w-full flex-col gap-4",children:[!S&&l.jsx(f.Alert,{icon:l.jsx(U,{icon:"solar:info-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,classNames:Ml,color:"default",variant:"flat",title:e==="single"?x.emptySingle:x.emptySplit}),S&&l.jsx(bh,{mode:e,assignments:t,labels:x,total:M,hasTotalError:T,onSelectFund:P=>p(P),onRemoveFund:Q,onPercentageChange:(P,_)=>F(P,{percentage:ph(_)})}),W&&l.jsx("div",{className:"flex flex-wrap gap-3",children:l.jsx(K,{type:"button",color:"default",radius:"full",className:"h-11 bg-zinc-950 px-4 text-base font-normal text-white disabled:opacity-50",startContent:l.jsx(J.Plus,{className:"size-5",strokeWidth:2}),isDisabled:$,onPress:()=>e==="split"&&S?H():p(),children:e==="split"&&S?x.addFund:x.assignSpecificFund})})]}),d]})},"installment-fund-assignment")}),o&&l.jsx(vh,{funds:n,labels:x,selectedFundIds:t.map(P=>P.fund?.id).filter(Boolean),onSelect:ce,onClose:m}),l.jsx(Rn,{isOpen:E,labels:{title:x.modifyAssignedFundsTitle,description:l.jsxs(l.Fragment,{children:[l.jsx("p",{children:x.modifyAssignedFundsDescription}),l.jsx("p",{className:"mt-3",children:x.modifyAssignedFundsWarning})]}),cancel:x.modifyAssignedFundsCancel,confirm:x.modifyAssignedFundsConfirm},icon:l.jsx(U,{icon:"solar:info-circle-outline",className:"size-7"}),iconTone:"warning",confirmColor:"primary",onClose:()=>C(!1),onConfirm:oe}),l.jsx(Rn,{isOpen:D!==null,labels:{title:x.modifyAssignedFundsTitle,description:l.jsxs(l.Fragment,{children:[l.jsx("p",{children:x.modifyAssignedFundsDescription}),l.jsx("p",{className:"mt-3",children:x.modifyAssignedFundsWarning})]}),cancel:x.modifyAssignedFundsCancel,confirm:x.modifyAssignedFundsConfirm},icon:l.jsx(U,{icon:"solar:info-circle-outline",className:"size-7"}),iconTone:"warning",confirmColor:"primary",onClose:()=>R(null),onConfirm:Y})]})}function yh({mode:e,labels:t,className:n,onModeChange:r}){return l.jsxs(f.Tabs,{"aria-label":t.title,selectedKey:e,radius:"full",size:"sm",variant:"light",className:f.cn("w-fit",n),classNames:{base:"w-fit",tabList:"h-10 w-fit rounded-full bg-zinc-200 p-1",tab:"h-8 w-auto rounded-full px-5 text-sm font-normal",cursor:"rounded-full bg-white shadow-sm",tabContent:"text-zinc-500 group-data-[selected=true]:text-zinc-900",panel:"hidden"},onSelectionChange:s=>r(s),children:[l.jsx(f.Tab,{title:t.singleFund},"single"),l.jsx(f.Tab,{title:t.splitFunds},"split")]})}function bh({mode:e,assignments:t,labels:n,total:r,hasTotalError:s,onSelectFund:i,onRemoveFund:a,onPercentageChange:o}){return l.jsxs("div",{className:"flex flex-col gap-3",children:[t.map((c,d)=>l.jsxs("div",{className:"flex min-h-15 w-full items-center gap-3 rounded-2xl border border-zinc-200 bg-white px-3 py-2",children:[l.jsx("div",{className:f.cn("flex min-h-11 min-w-0 flex-1 items-center",c.fund&&e==="single"?"justify-between":"gap-4"),children:c.fund?l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:"rounded-full bg-zinc-100 px-4 py-1.5 text-sm text-zinc-950",children:[c.fund.glCode," - ",c.fund.accountName]}),l.jsx(K,{type:"button",variant:"light",radius:"full",className:"px-2 text-sm font-normal text-brand",onPress:()=>i(c.id),children:"Replace"})]}):l.jsx(K,{type:"button",variant:"light",radius:"full",className:"justify-start px-4 text-base font-normal text-zinc-900",startContent:l.jsx(J.Plus,{className:"size-5",strokeWidth:2}),onPress:()=>i(c.id),children:n.assignSpecificFund})}),e==="split"&&l.jsx("label",{className:"flex w-48 flex-none items-center",children:l.jsx(f.Input,{variant:"bordered",type:"number",min:0,max:100,step:.01,value:String(c.percentage||""),onChange:u=>o(c.id,Number(u.target.value)),endContent:l.jsx("span",{className:"text-sm text-zinc-500",children:"%"}),classNames:mh})}),e==="split"&&t.length>2&&l.jsx(K,{type:"button",isIconOnly:!0,variant:"flat",radius:"full",className:f.cn("h-10 w-10 flex-none p-0",d<2?"bg-danger-100 text-danger-500 opacity-60":"bg-danger-600 text-white"),style:{height:40,minWidth:40,width:40},isDisabled:d<2,onPress:()=>a(c.id),"aria-label":n.removeFund,children:l.jsx(U,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"})})]},c.id)),e==="split"&&l.jsx(f.Alert,{icon:l.jsx(U,{icon:s?"solar:info-circle-outline":"solar:check-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,color:s?"warning":"success",variant:"flat",classNames:{...Vt,base:f.cn(Vt.base,s?"bg-warning-50 text-warning-700":"bg-success-50 text-success-700"),iconWrapper:f.cn(Vt.iconWrapper,s?"text-warning-700":"text-success-700"),alertIcon:f.cn(Vt.alertIcon,s?"text-warning-700":"text-success-700"),title:f.cn(Vt.title,s?"text-warning-700":"text-success-700")},title:s?`${n.totalError} (${n.total} ${Number(r.toFixed(2))}%)`:`${n.total} ${Number(r.toFixed(2))}%`})]})}function vh({funds:e,labels:t,selectedFundIds:n,onSelect:r,onClose:s}){const[i,a]=y.useState(""),o=e.filter(c=>{const d=i.trim().toLowerCase();return d?`${c.glCode} ${c.accountName} ${c.type}`.toLowerCase().includes(d):!0});return l.jsx(f.Modal,{isOpen:!0,size:"3xl",placement:"center",scrollBehavior:"inside",classNames:{base:"max-w-3xl rounded-3xl",closeButton:"right-6 top-6 text-zinc-500"},onOpenChange:c=>!c&&s(),children:l.jsxs(f.ModalContent,{children:[l.jsx(f.ModalHeader,{className:"px-6 pt-6 text-xl font-semibold leading-7 text-zinc-950",children:t.modalTitle}),l.jsxs(f.ModalBody,{className:"px-6 pb-6",children:[l.jsx(f.Input,{variant:"bordered","aria-label":t.searchPlaceholder,value:i,placeholder:t.searchPlaceholder,onChange:c=>a(c.target.value),startContent:l.jsx(U,{icon:"solar:magnifer-outline",className:"size-5 text-zinc-500"}),classNames:{input:"text-sm placeholder:text-zinc-500",inputWrapper:"h-10 rounded-2xl border border-zinc-200 bg-white px-4 shadow-none hover:border-zinc-300 data-[hover=true]:border-zinc-300 group-data-[focus=true]:border-zinc-400 group-data-[focus-visible=true]:ring-0"}}),l.jsxs("div",{className:"mt-4 overflow-auto",children:[l.jsxs("div",{className:"grid grid-cols-[1fr_1.1fr_0.55fr_0.6fr] gap-5 border-b border-zinc-200 px-3 pb-3 text-sm font-medium leading-5 text-zinc-900",children:[l.jsx("span",{children:t.glCode}),l.jsx("span",{children:t.accountName}),l.jsx("span",{children:t.type}),l.jsx("span",{children:t.actions})]}),o.length===0&&l.jsx("div",{className:"p-4 text-sm text-zinc-500",children:t.noFunds}),o.map(c=>{const d=n.includes(c.id);return l.jsxs("div",{className:"grid grid-cols-[1fr_1.1fr_0.55fr_0.6fr] items-center gap-5 px-3 py-2.5 text-sm leading-5 text-zinc-900",children:[l.jsx("span",{children:c.glCode}),l.jsx("span",{children:c.accountName}),c.type?l.jsx("span",{className:"w-fit rounded-full bg-warning-50 px-3 py-1 text-sm font-medium text-warning-500",children:c.type}):l.jsx("span",{className:"text-sm text-zinc-400",children:"-"}),l.jsx(K,{type:"button",variant:"bordered",radius:"full",className:"h-9 min-w-24 border-zinc-200 bg-white text-sm font-medium text-zinc-900",isDisabled:d,onPress:()=>r(c),children:t.select})]},c.id)})]})]})]})})}function wh(){return l.jsxs("section",{className:"flex w-full flex-col gap-4 rounded-2xl border border-zinc-200 bg-white p-4 shadow-sm","aria-busy":"true",children:[l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsx(f.Skeleton,{className:"h-7 w-56 rounded-lg"}),l.jsx(f.Skeleton,{className:"size-8 rounded-full"})]}),l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsx(f.Skeleton,{className:"h-10 w-72 rounded-full"}),l.jsx(f.Skeleton,{className:"h-10 w-40 rounded-full"})]}),l.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_160px] items-center gap-4 rounded-2xl border border-zinc-100 p-3",children:[l.jsx(f.Skeleton,{className:"h-8 w-full max-w-xs rounded-full"}),l.jsx(f.Skeleton,{className:"h-8 w-full rounded-xl"})]}),l.jsx(f.Skeleton,{className:"h-11 w-40 rounded-full"})]})}const kh={totalAmount:"Total Amount:",remainingBalance:"Remaining Balance",amountReceived:"Amount Received:"};function Nh({totalAmount:e,remainingBalance:t,amountReceived:n,currency:r="USD",locale:s="en-US",labels:i,className:a}){const o={...kh,...i},c=new Intl.NumberFormat(s,{style:"currency",currency:r});return l.jsx("div",{className:f.cn("w-full rounded-2xl border border-zinc-200 bg-white px-4 py-2.5 font-sans text-base leading-6",a),children:l.jsxs("div",{className:"flex w-full flex-wrap items-center gap-x-5 gap-y-2",children:[l.jsx(xr,{label:o.totalAmount,value:c.format(e)}),l.jsx(xr,{label:o.remainingBalance,value:c.format(t)}),l.jsx(xr,{label:o.amountReceived,value:c.format(n)})]})})}function xr({label:e,value:t}){return l.jsxs("div",{className:"flex items-center gap-3 whitespace-nowrap",children:[l.jsx("span",{className:"font-medium text-zinc-700",children:e}),l.jsx("span",{className:"font-normal text-zinc-950",children:t})]})}function yr(e,t){return e-t*Math.floor(e/t)}const El=1721426;function pn(e,t,n,r){t=ws(e,t);let s=t-1,i=-2;return n<=2?i=0:kn(t)&&(i=-1),El-1+365*s+Math.floor(s/4)-Math.floor(s/100)+Math.floor(s/400)+Math.floor((367*n-362)/12+i+r)}function kn(e){return e%4===0&&(e%100!==0||e%400===0)}function ws(e,t){return e==="BC"?1-t:t}function Sh(e){let t="AD";return e<=0&&(t="BC",e=1-e),[t,e]}const Ch={standard:[31,28,31,30,31,30,31,31,30,31,30,31],leapyear:[31,29,31,30,31,30,31,31,30,31,30,31]};class Yn{fromJulianDay(t){let n=t,r=n-El,s=Math.floor(r/146097),i=yr(r,146097),a=Math.floor(i/36524),o=yr(i,36524),c=Math.floor(o/1461),d=yr(o,1461),u=Math.floor(d/365),h=s*400+a*100+c*4+u+(a!==4&&u!==4?1:0),[p,m]=Sh(h),v=n-pn(p,m,1,1),b=2;n<pn(p,m,3,1)?b=0:kn(m)&&(b=1);let x=Math.floor(((v+b)*12+373)/367),w=n-pn(p,m,x,1)+1;return new nn(p,m,x,w)}toJulianDay(t){return pn(t.era,t.year,t.month,t.day)}getDaysInMonth(t){return Ch[kn(t.year)?"leapyear":"standard"][t.month-1]}getMonthsInYear(t){return 12}getDaysInYear(t){return kn(t.year)?366:365}getMaximumMonthsInYear(){return 12}getMaximumDaysInMonth(){return 31}getYearsInEra(t){return 9999}getEras(){return["BC","AD"]}isInverseEra(t){return t.era==="BC"}balanceDate(t){t.year<=0&&(t.era=t.era==="BC"?"AD":"BC",t.year=1-t.year)}constructor(){this.identifier="gregory"}}function jh(e,t){var n,r,s,i;return(i=(s=(n=e.isEqual)===null||n===void 0?void 0:n.call(e,t))!==null&&s!==void 0?s:(r=t.isEqual)===null||r===void 0?void 0:r.call(t,e))!==null&&i!==void 0?i:e.identifier===t.identifier}function Tl(e,t){return e.calendar.toJulianDay(e)-t.calendar.toJulianDay(t)}function Ah(e,t){return Oi(e)-Oi(t)}function Oi(e){return e.hour*36e5+e.minute*6e4+e.second*1e3+e.millisecond}let br=null;function Dl(){return br==null&&(br=new Intl.DateTimeFormat().resolvedOptions().timeZone),br}function Li(e){e=ks(e,new Yn);let t=ws(e.era,e.year);return Il(t,e.month,e.day,e.hour,e.minute,e.second,e.millisecond)}function Il(e,t,n,r,s,i,a){let o=new Date;return o.setUTCHours(r,s,i,a),o.setUTCFullYear(e,t-1,n),o.getTime()}function Fi(e,t){if(t==="UTC")return 0;if(e>0&&t===Dl())return new Date(e).getTimezoneOffset()*-6e4;let{year:n,month:r,day:s,hour:i,minute:a,second:o}=$l(e,t);return Il(n,r,s,i,a,o,0)-Math.floor(e/1e3)*1e3}const Pi=new Map;function $l(e,t){let n=Pi.get(t);n||(n=new Intl.DateTimeFormat("en-US",{timeZone:t,hour12:!1,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}),Pi.set(t,n));let r=n.formatToParts(new Date(e)),s={};for(let i of r)i.type!=="literal"&&(s[i.type]=i.value);return{year:s.era==="BC"||s.era==="B"?-s.year+1:+s.year,month:+s.month,day:+s.day,hour:s.hour==="24"?0:+s.hour,minute:+s.minute,second:+s.second}}const Ri=864e5;function Mh(e,t,n,r){return(n===r?[n]:[n,r]).filter(i=>Eh(e,t,i))}function Eh(e,t,n){let r=$l(n,t);return e.year===r.year&&e.month===r.month&&e.day===r.day&&e.hour===r.hour&&e.minute===r.minute&&e.second===r.second}function Th(e,t,n="compatible"){let r=Ll(e);if(t==="UTC")return Li(r);if(t===Dl()&&n==="compatible"){r=ks(r,new Yn);let c=new Date,d=ws(r.era,r.year);return c.setFullYear(d,r.month-1,r.day),c.setHours(r.hour,r.minute,r.second,r.millisecond),c.getTime()}let s=Li(r),i=Fi(s-Ri,t),a=Fi(s+Ri,t),o=Mh(r,t,s-i,s-a);if(o.length===1)return o[0];if(o.length>1)switch(n){case"compatible":case"earlier":return o[0];case"later":return o[o.length-1];case"reject":throw new RangeError("Multiple possible absolute times found")}switch(n){case"earlier":return Math.min(s-i,s-a);case"compatible":case"later":return Math.max(s-i,s-a);case"reject":throw new RangeError("No such absolute time found")}}function Ol(e,t,n="compatible"){return new Date(Th(e,t,n))}function Ll(e,t){let n=0,r=0,s=0,i=0;if("timeZone"in e)({hour:n,minute:r,second:s,millisecond:i}=e);else if("hour"in e&&!t)return e;return t&&({hour:n,minute:r,second:s,millisecond:i}=t),new zn(e.calendar,e.era,e.year,e.month,e.day,n,r,s,i)}function ks(e,t){if(jh(e.calendar,t))return e;let n=t.fromJulianDay(e.calendar.toJulianDay(e)),r=e.copy();return r.calendar=t,r.era=n.era,r.year=n.year,r.month=n.month,r.day=n.day,Dt(r),r}function Ns(e,t){let n=e.copy(),r="hour"in n?Fh(n,t):0;qr(n,t.years||0),n.calendar.balanceYearMonth&&n.calendar.balanceYearMonth(n,e),n.month+=t.months||0,Wr(n),Fl(n),n.day+=(t.weeks||0)*7,n.day+=t.days||0,n.day+=r,Dh(n),n.calendar.balanceDate&&n.calendar.balanceDate(n),n.year<1&&(n.year=1,n.month=1,n.day=1);let s=n.calendar.getYearsInEra(n);if(n.year>s){var i,a;let c=(i=(a=n.calendar).isInverseEra)===null||i===void 0?void 0:i.call(a,n);n.year=s,n.month=c?1:n.calendar.getMonthsInYear(n),n.day=c?1:n.calendar.getDaysInMonth(n)}n.month<1&&(n.month=1,n.day=1);let o=n.calendar.getMonthsInYear(n);return n.month>o&&(n.month=o,n.day=n.calendar.getDaysInMonth(n)),n.day=Math.max(1,Math.min(n.calendar.getDaysInMonth(n),n.day)),n}function qr(e,t){var n,r;!((n=(r=e.calendar).isInverseEra)===null||n===void 0)&&n.call(r,e)&&(t=-t),e.year+=t}function Wr(e){for(;e.month<1;)qr(e,-1),e.month+=e.calendar.getMonthsInYear(e);let t=0;for(;e.month>(t=e.calendar.getMonthsInYear(e));)e.month-=t,qr(e,1)}function Dh(e){for(;e.day<1;)e.month--,Wr(e),e.day+=e.calendar.getDaysInMonth(e);for(;e.day>e.calendar.getDaysInMonth(e);)e.day-=e.calendar.getDaysInMonth(e),e.month++,Wr(e)}function Fl(e){e.month=Math.max(1,Math.min(e.calendar.getMonthsInYear(e),e.month)),e.day=Math.max(1,Math.min(e.calendar.getDaysInMonth(e),e.day))}function Dt(e){e.calendar.constrainDate&&e.calendar.constrainDate(e),e.year=Math.max(1,Math.min(e.calendar.getYearsInEra(e),e.year)),Fl(e)}function Ih(e){let t={};for(let n in e)typeof e[n]=="number"&&(t[n]=-e[n]);return t}function Pl(e,t){return Ns(e,Ih(t))}function Rl(e,t){let n=e.copy();return t.era!=null&&(n.era=t.era),t.year!=null&&(n.year=t.year),t.month!=null&&(n.month=t.month),t.day!=null&&(n.day=t.day),Dt(n),n}function $h(e,t){let n=e.copy();return t.hour!=null&&(n.hour=t.hour),t.minute!=null&&(n.minute=t.minute),t.second!=null&&(n.second=t.second),t.millisecond!=null&&(n.millisecond=t.millisecond),Lh(n),n}function Oh(e){e.second+=Math.floor(e.millisecond/1e3),e.millisecond=gn(e.millisecond,1e3),e.minute+=Math.floor(e.second/60),e.second=gn(e.second,60),e.hour+=Math.floor(e.minute/60),e.minute=gn(e.minute,60);let t=Math.floor(e.hour/24);return e.hour=gn(e.hour,24),t}function Lh(e){e.millisecond=Math.max(0,Math.min(e.millisecond,1e3)),e.second=Math.max(0,Math.min(e.second,59)),e.minute=Math.max(0,Math.min(e.minute,59)),e.hour=Math.max(0,Math.min(e.hour,23))}function gn(e,t){let n=e%t;return n<0&&(n+=t),n}function Fh(e,t){return e.hour+=t.hours||0,e.minute+=t.minutes||0,e.second+=t.seconds||0,e.millisecond+=t.milliseconds||0,Oh(e)}function zl(e,t,n,r){let s=e.copy();switch(t){case"era":{let o=e.calendar.getEras(),c=o.indexOf(e.era);if(c<0)throw new Error("Invalid era: "+e.era);c=tt(c,n,0,o.length-1,r?.round),s.era=o[c],Dt(s);break}case"year":var i,a;!((i=(a=s.calendar).isInverseEra)===null||i===void 0)&&i.call(a,s)&&(n=-n),s.year=tt(e.year,n,-1/0,9999,r?.round),s.year===-1/0&&(s.year=1),s.calendar.balanceYearMonth&&s.calendar.balanceYearMonth(s,e);break;case"month":s.month=tt(e.month,n,1,e.calendar.getMonthsInYear(e),r?.round);break;case"day":s.day=tt(e.day,n,1,e.calendar.getDaysInMonth(e),r?.round);break;default:throw new Error("Unsupported field "+t)}return e.calendar.balanceDate&&e.calendar.balanceDate(s),Dt(s),s}function Ph(e,t,n,r){let s=e.copy();switch(t){case"hour":{let i=e.hour,a=0,o=23;if(r?.hourCycle===12){let c=i>=12;a=c?12:0,o=c?23:11}s.hour=tt(i,n,a,o,r?.round);break}case"minute":s.minute=tt(e.minute,n,0,59,r?.round);break;case"second":s.second=tt(e.second,n,0,59,r?.round);break;case"millisecond":s.millisecond=tt(e.millisecond,n,0,999,r?.round);break;default:throw new Error("Unsupported field "+t)}return s}function tt(e,t,n,r,s=!1){if(s){e+=Math.sign(t),e<n&&(e=r);let i=Math.abs(t);t>0?e=Math.ceil(e/i)*i:e=Math.floor(e/i)*i,e>r&&(e=n)}else e+=t,e<n?e=r-(n-e-1):e>r&&(e=n+(e-r-1));return e}const Rh=/^([+-]\d{6}|\d{4})-(\d{2})-(\d{2})$/,zh=/^([+-]\d{6}|\d{4})-(\d{2})-(\d{2})(?:T(\d{2}))?(?::(\d{2}))?(?::(\d{2}))?(\.\d+)?(?:(?:([+-]\d{2})(?::?(\d{2}))?)|Z)$/;function Bh(e){let t=e.match(Rh);if(!t)throw zh.test(e)?new Error(`Invalid ISO 8601 date string: ${e}. Use parseAbsolute() instead.`):new Error("Invalid ISO 8601 date string: "+e);let n=new nn(vr(t[1],0,9999),vr(t[2],1,12),1);return n.day=vr(t[3],1,n.calendar.getDaysInMonth(n)),n}function vr(e,t,n){let r=Number(e);if(r<t||r>n)throw new RangeError(`Value out of range: ${t} <= ${r} <= ${n}`);return r}function _h(e){return`${String(e.hour).padStart(2,"0")}:${String(e.minute).padStart(2,"0")}:${String(e.second).padStart(2,"0")}${e.millisecond?String(e.millisecond/1e3).slice(1):""}`}function Bl(e){let t=ks(e,new Yn),n;return t.era==="BC"?n=t.year===1?"0000":"-"+String(Math.abs(1-t.year)).padStart(6,"00"):n=String(t.year).padStart(4,"0"),`${n}-${String(t.month).padStart(2,"0")}-${String(t.day).padStart(2,"0")}`}function Vh(e){return`${Bl(e)}T${_h(e)}`}function Hh(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function _l(e,t,n){Hh(e,t),t.set(e,n)}function Vl(e){let t=typeof e[0]=="object"?e.shift():new Yn,n;if(typeof e[0]=="string")n=e.shift();else{let a=t.getEras();n=a[a.length-1]}let r=e.shift(),s=e.shift(),i=e.shift();return[t,n,r,s,i]}var Uh=new WeakMap;class nn{copy(){return this.era?new nn(this.calendar,this.era,this.year,this.month,this.day):new nn(this.calendar,this.year,this.month,this.day)}add(t){return Ns(this,t)}subtract(t){return Pl(this,t)}set(t){return Rl(this,t)}cycle(t,n,r){return zl(this,t,n,r)}toDate(t){return Ol(this,t)}toString(){return Bl(this)}compare(t){return Tl(this,t)}constructor(...t){_l(this,Uh,{writable:!0,value:void 0});let[n,r,s,i,a]=Vl(t);this.calendar=n,this.era=r,this.year=s,this.month=i,this.day=a,Dt(this)}}var qh=new WeakMap;class zn{copy(){return this.era?new zn(this.calendar,this.era,this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond):new zn(this.calendar,this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond)}add(t){return Ns(this,t)}subtract(t){return Pl(this,t)}set(t){return Rl($h(this,t),t)}cycle(t,n,r){switch(t){case"era":case"year":case"month":case"day":return zl(this,t,n,r);default:return Ph(this,t,n,r)}}toDate(t,n){return Ol(this,t,n)}toString(){return Vh(this)}compare(t){let n=Tl(this,t);return n===0?Ah(this,Ll(t)):n}constructor(...t){_l(this,qh,{writable:!0,value:void 0});let[n,r,s,i,a]=Vl(t);this.calendar=n,this.era=r,this.year=s,this.month=i,this.day=a,this.hour=t.shift()||0,this.minute=t.shift()||0,this.second=t.shift()||0,this.millisecond=t.shift()||0,Dt(this)}}const Wh={monthly:1,quarterly:3,annual:12};function Hl(e,t){const n=Math.max(1,Math.floor(t.numberOfInstallments||1)),r=Math.floor(e*100/n),i=Math.round(e*100)-r*n,a=new Date(`${t.firstInstallmentDate}T00:00:00`),o=Wh[t.frequency];return Array.from({length:n},(c,d)=>{const u=new Date(a);return u.setMonth(a.getMonth()+d*o),{id:crypto.randomUUID(),dueDate:u.toISOString().slice(0,10),amount:(r+(d<i?1:0))/100}})}const Kh={title:"Payments",automaticMode:"Auto",manualMode:"Manual",createInstallments:"Create Payments",generateSchedule:"Generate Schedule",saveInstallments:"Save Payments",addInstallment:"Add Payment",emptyAutomatic:"No payments have been generated for this opportunity",emptyManual:"Add payments with custom dates and amounts",numberOfInstallments:"Number of payments",frequency:"Frequency",firstInstallmentDate:"First payment date",installment:"Payment",dueDate:"Due date",amount:"Amount",total:"Total",remaining:"Remaining",deleteInstallment:"Delete installment",monthly:"Monthly",quarterly:"Quarterly",annual:"Annual",totalError:"Payment total must equal donation amount"},Jh=["monthly","quarterly","annual"],Ul={base:"min-h-11 rounded-full bg-zinc-100 px-4 py-2 shadow-none",iconWrapper:"!h-4 !w-4 shrink-0 !bg-transparent !shadow-none !border-0 text-zinc-900",alertIcon:"!static !h-4 !w-4 !translate-x-0 !translate-y-0 text-zinc-900",mainWrapper:"min-w-0",title:"text-sm font-normal text-zinc-950"},Bn={label:"text-sm font-normal text-zinc-950",inputWrapper:"h-9 rounded-xl border border-zinc-200 bg-white shadow-none hover:border-zinc-300 data-[hover=true]:border-zinc-300 group-data-[focus=true]:border-zinc-400 group-data-[focus-visible=true]:ring-0"},Yh={label:"text-sm font-normal text-zinc-950",trigger:"h-9 rounded-xl border border-zinc-200 bg-white shadow-none hover:border-zinc-300 data-[hover=true]:border-zinc-300 data-[focus=true]:border-zinc-400 data-[focus-visible=true]:ring-0"},zi=()=>({id:crypto.randomUUID(),dueDate:new Date().toISOString().slice(0,10),amount:0}),Kr=e=>Math.round(e*100)/100,Gh=(e,t)=>{const n=new Date(`${e}T00:00:00`);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(t,{month:"short",day:"numeric",year:"numeric"}).format(n)},ql=e=>{if(!e)return null;try{return Bh(e)}catch{return null}};function Qh({mode:e,donationAmount:t,currency:n="USD",locale:r="en-US",installments:s,automaticSettings:i,labels:a,classNames:o,isSaving:c=!1,isModeSwitchDisabled:d=!1,onModeChange:u,onAutomaticSettingsChange:h,onInstallmentsChange:p,onSave:m}){const v={...Kh,...a},b=y.useMemo(()=>new Intl.NumberFormat(r,{style:"currency",currency:n}),[n,r]),x=e==="automatic"?Hl(t,i):s,w=y.useMemo(()=>Kr(x.reduce((T,$)=>T+Number($.amount||0),0)),[x]),S=T=>{T!==e&&(u(T),T==="manual"&&s.length===0&&p([zi()]))},M=(T,$)=>{s.find(D=>D.id===T)?.status!=="paid"&&p(s.map(D=>D.id===T?{...D,...$}:D))},N=()=>{p([...s,zi()])},j=T=>{s.find(W=>W.id===T)?.status!=="paid"&&p(s.filter(W=>W.id!==T))};return l.jsx("div",{className:f.cn("vvt-ps font-sans text-zinc-900",o?.root),children:l.jsx(f.Accordion,{variant:"splitted",defaultSelectedKeys:["installment-schedule"],className:f.cn("w-full gap-0 px-0",o?.panel),itemClasses:{base:"w-full rounded-2xl border border-zinc-200 bg-white p-0 shadow-sm",trigger:f.cn("px-4 py-4",o?.header),title:"text-xl font-semibold leading-8 text-zinc-900",content:"w-full px-4 pb-4 pt-0",indicator:"text-zinc-500"},children:l.jsx(f.AccordionItem,{"aria-label":v.title,title:v.title,children:l.jsxs("div",{className:f.cn("flex w-full flex-col gap-4",o?.content),children:[l.jsxs("div",{className:"flex w-full items-center justify-between gap-6",children:[l.jsx(Zh,{mode:e,labels:v,onModeChange:S,isDisabled:d,className:o?.tabs}),l.jsx(K,{type:"button",size:"sm",color:"primary",radius:"full",className:"ml-auto h-9 min-w-36 bg-brand px-4 text-sm font-medium text-white",startContent:l.jsx(U,{icon:"solar:cloud-upload-outline",className:"size-4"}),isLoading:c,onPress:m,children:v.saveInstallments})]}),l.jsxs("div",{className:"flex w-full flex-col gap-4",children:[e==="automatic"&&l.jsx(Xh,{settings:i,labels:v,onSettingsChange:h}),x.length===0&&l.jsx(f.Alert,{icon:l.jsx(U,{icon:"solar:info-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,classNames:Ul,color:"default",variant:"flat",title:e==="automatic"?v.emptyAutomatic:v.emptyManual}),x.length>0&&l.jsx(em,{mode:e,installments:x,labels:v,formatter:b,locale:r,onUpdateInstallment:M,onRemoveInstallment:j}),e==="manual"&&l.jsx("div",{className:"flex flex-wrap gap-3",children:l.jsx(K,{type:"button",variant:"bordered",radius:"full",className:"h-9 border-zinc-200 bg-white px-4 text-sm font-normal text-zinc-900",startContent:l.jsx(J.Plus,{className:"size-5",strokeWidth:2}),onPress:N,children:v.addInstallment})}),l.jsx(nm,{total:w,donationAmount:t,difference:Kr(t-w),hasTotalError:e==="manual"&&Math.abs(t-w)>.009,mode:e,installmentCount:x.length,formatter:b})]})]})},"installment-schedule")})})}function Zh({mode:e,labels:t,className:n,isDisabled:r=!1,onModeChange:s}){return l.jsxs(f.Tabs,{"aria-label":t.title,selectedKey:e,isDisabled:r,radius:"full",size:"sm",variant:"light",className:f.cn("w-fit",n),classNames:{base:"w-fit",tabList:"h-10 w-fit rounded-full bg-zinc-200 p-1",tab:"h-8 w-auto rounded-full px-5 text-sm font-normal",cursor:"rounded-full bg-white shadow-sm",tabContent:"text-zinc-500 group-data-[selected=true]:text-zinc-900",panel:"hidden"},onSelectionChange:i=>s(i),children:[l.jsx(f.Tab,{title:t.automaticMode},"automatic"),l.jsx(f.Tab,{title:t.manualMode},"manual")]})}function Xh({settings:e,labels:t,onSettingsChange:n}){return l.jsxs("div",{className:"grid gap-4",style:{gridTemplateColumns:"repeat(3, minmax(0, 1fr))"},children:[l.jsx("div",{className:"min-w-0",children:l.jsx(f.Input,{variant:"bordered",label:t.numberOfInstallments,labelPlacement:"outside",type:"number",min:1,step:1,value:e.numberOfInstallments>0?String(e.numberOfInstallments):"",onWheel:r=>r.currentTarget.blur(),onChange:r=>{const s=r.target.value;n({...e,numberOfInstallments:s===""?0:Math.max(1,Number(s))})},classNames:Bn})}),l.jsx("div",{className:"min-w-0",children:l.jsx(yt,{variant:"bordered",label:t.frequency,labelPlacement:"outside",selectedKeys:[e.frequency],onSelectionChange:r=>{const s=Array.from(r)[0];typeof s=="string"&&n({...e,frequency:s})},classNames:Yh,children:Jh.map(r=>l.jsx(f.SelectItem,{textValue:t[r],children:t[r]},r))})}),l.jsx("div",{className:"min-w-0",children:l.jsx(f.DatePicker,{variant:"bordered",label:t.firstInstallmentDate,labelPlacement:"outside",value:ql(e.firstInstallmentDate),onChange:r=>n({...e,firstInstallmentDate:r?r.toString():""}),startContent:l.jsx(U,{icon:"solar:calendar-outline",className:"size-4 text-zinc-500"}),classNames:Bn})})]})}function em({mode:e,installments:t,labels:n,formatter:r,locale:s,onUpdateInstallment:i,onRemoveInstallment:a}){return e==="automatic"?l.jsx("div",{className:"rounded-2xl border border-zinc-200 bg-zinc-50 p-4",children:l.jsx("div",{className:f.cn("flex flex-col gap-3",t.length>5&&"max-h-[264px] overflow-y-auto pr-2"),children:t.map((o,c)=>l.jsxs("div",{className:f.cn("flex min-h-10 items-center justify-between rounded-xl px-4 py-2 text-base",c===0&&"border border-brand/25 bg-brand/5 text-brand"),children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("span",{children:["#",c+1]}),l.jsx("span",{children:"▪"}),l.jsx("span",{children:Gh(o.dueDate,s)}),c===0&&l.jsx(f.Chip,{size:"sm",radius:"full",className:"h-6 bg-brand px-2 text-xs font-semibold text-white",children:"First charge"})]}),l.jsx("span",{className:"text-zinc-950",children:r.format(o.amount)})]},o.id))})}):l.jsx("div",{className:"flex flex-col gap-2",children:t.map((o,c)=>l.jsxs("div",{className:"flex w-full items-center gap-4",children:[l.jsx("div",{className:"min-w-0 flex-1",children:l.jsx(f.DatePicker,{variant:"bordered","aria-label":`${n.dueDate} ${c+1}`,isDisabled:o.status==="paid",value:ql(o.dueDate),onChange:d=>i(o.id,{dueDate:d?d.toString():""}),classNames:Bn})}),l.jsx("div",{className:"min-w-0 flex-1",children:l.jsx(f.Input,{variant:"bordered",type:"number",min:0,step:.01,isDisabled:o.status==="paid",value:String(o.amount||""),onChange:d=>i(o.id,{amount:Kr(Number(d.target.value||0))}),startContent:l.jsx("span",{className:"text-zinc-900",children:"$"}),classNames:Bn})}),l.jsx(tm,{isDisabled:t.length<=1,isPaid:o.status==="paid",label:n.deleteInstallment,onRemove:()=>a(o.id)})]},o.id))})}function tm({isDisabled:e,isPaid:t,label:n,onRemove:r}){const s=l.jsx(K,{type:"button",isIconOnly:!0,variant:"flat",radius:"full",className:"h-9 w-9 flex-none bg-danger-100 p-0 text-danger-600",style:{height:36,minWidth:36,width:36},isDisabled:e||t,onPress:r,"aria-label":n,children:l.jsx(U,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"})});return t?l.jsx(f.Tooltip,{content:"This payment cannot be edited or deleted because it has already been paid.",placement:"top",children:l.jsx("span",{className:"inline-flex",children:s})}):s}function nm({total:e,donationAmount:t,difference:n,hasTotalError:r,mode:s,installmentCount:i,formatter:a}){const o=i>0?e/i:0,c=s==="automatic"?l.jsxs("span",{children:["Saving will create ",l.jsx("strong",{children:i})," scheduled payment records of"," ",l.jsx("strong",{children:a.format(o)})," each."]}):l.jsxs("span",{children:["Total scheduled: ",l.jsx("strong",{children:a.format(e)})," /"," ",l.jsx("strong",{children:a.format(t)}),"."]}),d=s==="automatic"?`Total: ${a.format(e)}`:r?`Missing: ${a.format(n)}`:`Remaining: ${a.format(0)}`;return l.jsx(f.Alert,{icon:l.jsx(U,{icon:"solar:info-circle-outline",className:"size-4"}),hideIconWrapper:!0,isClosable:!1,color:"default",variant:"flat",classNames:Ul,endContent:l.jsx("span",{className:"whitespace-nowrap",children:d}),title:c})}function rm(){return l.jsxs("section",{className:"flex w-full flex-col gap-4 rounded-2xl border border-zinc-200 bg-white p-4 shadow-sm","aria-busy":"true",children:[l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsx(f.Skeleton,{className:"h-7 w-56 rounded-lg"}),l.jsx(f.Skeleton,{className:"size-8 rounded-full"})]}),l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsx(f.Skeleton,{className:"h-10 w-72 rounded-full"}),l.jsx(f.Skeleton,{className:"h-10 w-40 rounded-full"})]}),l.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[l.jsxs("div",{className:"flex w-full max-w-[280px] flex-col gap-2",children:[l.jsx(f.Skeleton,{className:"h-4 w-36 rounded-md"}),l.jsx(f.Skeleton,{className:"h-9 w-full rounded-xl"})]}),l.jsx(f.Skeleton,{className:"h-9 w-36 rounded-full"})]}),l.jsx("div",{className:"flex flex-col gap-3",children:Array.from({length:4}).map((e,t)=>l.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_160px] items-center gap-4 rounded-2xl border border-zinc-100 p-3",children:[l.jsx(f.Skeleton,{className:"h-8 w-full max-w-xs rounded-full"}),l.jsx(f.Skeleton,{className:"h-8 w-full rounded-xl"})]},t))})]})}const Bi={paid:"bg-emerald-50 text-emerald-700",fulfilled:"bg-emerald-50 text-emerald-700",scheduled:"bg-blue-50 text-blue-700",failed:"bg-red-50 text-red-700",cancelled:"bg-zinc-100 text-zinc-600",refunded:"bg-zinc-100 text-zinc-600"},_i={paid:"Paid",fulfilled:"Paid",scheduled:"Scheduled",failed:"Failed",cancelled:"Cancelled",refunded:"Refunded"},sm={title:"Payments",searchLabel:"Search a payment",searchPlaceholder:"Search a payment by ID or Date...",editInstallments:"Edit Payment",installmentId:"Payment ID",amount:"Amount",scheduledDate:"Scheduled Date",status:"Status",actions:"Actions",payNow:"Pay now",sendLink:"Send Link",sendLinkDescription:"Send a payment link to the contact",dangerZone:"Danger zone",deleteInstallment:"Delete Payment",deleteInstallmentDescription:"Remove Payment from Opportunity",deleteInstallmentConfirmationTitle:"Delete Payment",deleteInstallmentConfirmationDescription:l.jsxs(l.Fragment,{children:["Are you sure you want to delete this payment? ",l.jsx("strong",{children:"This action cannot be undone."})]}),deleteInstallmentConfirmationCancel:"Cancel",deleteInstallmentConfirmationConfirm:"Confirm",noInstallmentsFound:"No payments found."};function im({installments:e,currency:t,locale:n="en-US",labels:r,isSaving:s=!1,onEditInstallments:i,onPayInstallment:a,onDeleteInstallment:o}){const c={...sm,...r},[d,u]=y.useState(""),h=new Intl.NumberFormat(n,{style:"currency",currency:t}),p=y.useMemo(()=>{const m=d.trim().toLowerCase();return m?e.filter(v=>{const b=v.status??"scheduled";return[v.id,v.amount,v.dueDate,Vi(v.dueDate,n),b,_i[b]??b].join(" ").toLowerCase().includes(m)}):e},[n,e,d]);return l.jsx("div",{className:"vvt-ps w-full font-sans text-zinc-900",children:l.jsx(f.Accordion,{variant:"splitted",defaultSelectedKeys:["installment-table"],className:"w-full gap-0 px-0",itemClasses:{base:"w-full rounded-2xl border border-zinc-200 bg-white p-0 shadow-sm",trigger:"px-4 py-4",title:"text-xl font-semibold leading-8 text-zinc-900",content:"w-full px-4 pb-4 pt-0",indicator:"text-zinc-500"},children:l.jsx(f.AccordionItem,{"aria-label":c.title,title:c.title,children:l.jsxs("div",{className:"flex w-full flex-col gap-4",children:[l.jsxs("div",{className:"flex w-full items-end justify-between gap-6",children:[l.jsxs("div",{className:"w-full max-w-[280px]",children:[l.jsx("label",{className:"mb-1 block text-sm font-normal text-zinc-950",children:c.searchLabel}),l.jsx(f.Input,{variant:"bordered",size:"sm",value:d,placeholder:c.searchPlaceholder,onChange:m=>u(m.target.value),startContent:l.jsx(U,{icon:"solar:magnifer-outline",className:"size-4 text-zinc-500"}),classNames:{inputWrapper:"h-9 rounded-xl border border-zinc-200 bg-white shadow-none hover:border-zinc-300 data-[hover=true]:border-zinc-300 group-data-[focus=true]:border-zinc-400 group-data-[focus-visible=true]:ring-0"}})]}),l.jsx(K,{type:"button",variant:"bordered",radius:"full",size:"sm",className:"h-8 border-zinc-200 bg-white px-3 text-sm font-normal text-zinc-900",startContent:l.jsx(U,{icon:"solar:pen-outline",className:"size-4"}),isLoading:s,onPress:i,children:c.editInstallments})]}),l.jsx("div",{className:"w-full overflow-hidden",children:l.jsxs("table",{className:"w-full table-fixed border-collapse text-left text-sm",children:[l.jsxs("colgroup",{children:[l.jsx("col",{className:"w-[6%]"}),l.jsx("col",{className:"w-[25%]"}),l.jsx("col",{className:"w-[12%]"}),l.jsx("col",{className:"w-[16%]"}),l.jsx("col",{className:"w-[17%]"}),l.jsx("col",{className:"w-[24%]"})]}),l.jsx("thead",{children:l.jsxs("tr",{className:"border-b border-zinc-200 text-zinc-900",children:[l.jsx("th",{className:"w-14 px-2 py-3 font-medium",children:"#"}),l.jsx("th",{className:"px-2 py-3 font-medium",children:c.installmentId}),l.jsx("th",{className:"px-2 py-3 font-medium",children:c.amount}),l.jsx("th",{className:"px-2 py-3 font-medium",children:c.scheduledDate}),l.jsx("th",{className:"px-2 py-3 font-medium",children:c.status}),l.jsx("th",{className:"px-2 py-3 font-medium",children:c.actions})]})}),l.jsxs("tbody",{children:[p.map((m,v)=>{const b=m.status??"scheduled";return l.jsxs("tr",{className:"text-zinc-500",children:[l.jsx("td",{className:"px-2 py-3",children:v+1}),l.jsx("td",{className:"px-2 py-3",children:l.jsx("span",{className:"block max-w-full truncate",children:m.id||`PMT-${v+1}`})}),l.jsx("td",{className:"px-2 py-3",children:h.format(m.amount)}),l.jsx("td",{className:"px-2 py-3",children:Vi(m.dueDate,n)}),l.jsx("td",{className:"px-2 py-3",children:l.jsx(f.Chip,{size:"sm",radius:"full",className:f.cn("h-8 min-w-[118px] justify-center px-4 text-sm font-normal",Bi[b]??Bi.scheduled),startContent:l.jsx(lm,{status:b}),children:_i[b]??b})}),l.jsx("td",{className:"px-2 py-3",children:l.jsxs("div",{className:"flex min-w-[154px] items-center justify-start gap-2",children:[l.jsx(K,{type:"button",size:"sm",radius:"full",className:"h-9 min-w-[104px] shrink-0 bg-brand px-3 text-sm font-medium text-white disabled:opacity-50",isDisabled:b==="paid"||b==="fulfilled",startContent:l.jsx(U,{icon:"solar:dollar-minimalistic-outline",className:"size-4"}),onPress:()=>a?.(m),children:c.payNow}),l.jsx(am,{isPaid:b==="paid"||b==="fulfilled",labels:c,onDelete:()=>o(m.id)})]})})]},m.id)}),p.length===0&&l.jsx("tr",{children:l.jsx("td",{colSpan:6,className:"px-2 py-6 text-center text-zinc-500",children:c.noInstallmentsFound})})]})]})})]})},"installment-table")})})}function am({isPaid:e,labels:t,onDelete:n}){const[r,s]=y.useState(!1);return l.jsxs(l.Fragment,{children:[l.jsxs(f.Dropdown,{placement:"bottom-end",radius:"lg",children:[l.jsx(f.DropdownTrigger,{children:l.jsx(K,{type:"button",isIconOnly:!0,size:"sm",variant:"light",className:"text-zinc-900","aria-label":"More actions",children:l.jsx(U,{icon:"solar:menu-dots-bold",className:"size-4"})})}),l.jsxs(f.DropdownMenu,{"aria-label":"Installment actions",disabledKeys:e?["delete"]:[],className:"w-72 p-2",onAction:i=>{i==="delete"&&!e&&s(!0)},children:[l.jsx(f.DropdownSection,{title:"Actions",showDivider:!0,children:l.jsx(f.DropdownItem,{textValue:t.sendLink,description:t.sendLinkDescription,startContent:l.jsx(U,{icon:"solar:link-outline",className:"size-5 text-zinc-500"}),children:t.sendLink},"send-link")}),l.jsx(f.DropdownSection,{title:t.dangerZone,children:l.jsx(f.DropdownItem,{textValue:t.deleteInstallment,className:"text-danger-600",color:"danger",description:t.deleteInstallmentDescription,startContent:l.jsx(U,{icon:"solar:trash-bin-minimalistic-outline",className:"size-5"}),children:t.deleteInstallment},"delete")})]})]}),l.jsx(Rn,{isOpen:r,labels:{title:t.deleteInstallmentConfirmationTitle,description:t.deleteInstallmentConfirmationDescription,cancel:t.deleteInstallmentConfirmationCancel,confirm:t.deleteInstallmentConfirmationConfirm},icon:l.jsx(U,{icon:"solar:danger-triangle-outline",className:"size-7"}),confirmColor:"danger",onClose:()=>s(!1),onConfirm:()=>{s(!1),n()}})]})}function lm({status:e}){return e==="paid"||e==="fulfilled"?l.jsx(U,{icon:"solar:check-circle-bold",className:"size-3"}):e==="failed"?l.jsx(U,{icon:"solar:close-circle-bold",className:"size-3"}):l.jsx(U,{icon:"solar:calendar-outline",className:"size-3"})}function Vi(e,t){const n=new Date(`${e}T00:00:00`);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(t,{month:"short",day:"numeric",year:"numeric"}).format(n)}const om={title:"Select Membership",renewalTitle:"Automatic Renewal",renewalDescription:"Membership will automatically renew at the end of each period"},cm=({cards:e,locale:t,currency:n,listHeightClassName:r="",labels:s,showRenewal:i=!0,defaultRenewalValue:a=!1,initialSelectedMembershipId:o=null,allowReselect:c=!0,onRenewalChange:d,onCardSelect:u,className:h=""})=>{const p=Array.isArray(e)?e:[],[m,v]=y.useState(o),[b,x]=y.useState(a),w={...om,...s};y.useEffect(()=>{v(o)},[o]);const S=N=>{if(N===m){c&&u?.(N);return}v(N),u?.(N)},M=N=>{x(N),d?.(N)};return l.jsxs("div",{className:f.cn("w-full flex flex-col gap-4 items-start p-4 h-svh",h),"data-testid":"membership-select-cards",children:[l.jsx("span",{className:"hidden","data-testid":"membership-select-cards-selected-id",children:m??""}),l.jsx("p",{className:"text-2xl font-semibold text-left","data-testid":"membership-select-cards-title",children:w.title}),i&&l.jsx(Zl,{title:w.renewalTitle,description:w.renewalDescription,value:b,onValueChange:M}),l.jsx("div",{className:f.cn("w-full min-h-0 flex flex-col gap-4 overflow-y-auto",r===""?"flex-1":f.cn("shrink-0",r)),"data-testid":"membership-select-cards-list",children:p.map(N=>l.jsx(Wl,{itemKey:N.id,name:N.name,type:N.type,price:N.price,locale:t,currency:n,isSelected:m===N.id,onSelect:S},N.id))})]})},Wl=({itemKey:e,name:t,type:n,price:r,locale:s="en-US",currency:i="USD",showPrice:a=!0,isSelected:o=!1,onSelect:c,compact:d=!1,isDisabled:u=!1,disabledReason:h,statusLabel:p,statusTone:m="default",className:v=""})=>{const b=new Intl.NumberFormat(s,{style:"currency",currency:i,minimumFractionDigits:0,maximumFractionDigits:2}).format(r),x=!!c&&!u,w=h||p,S=()=>{x&&c?.(e)};return l.jsx(f.Card,{shadow:"none",isPressable:!!c,onPress:S,className:f.cn("w-full min-h-fit border rounded-3xl",o?"border-primary bg-primary/5":"border-default",u?"opacity-60":"",d?"rounded-2xl":"",v),"data-testid":"item-card","data-selected":o,isDisabled:u,children:l.jsxs("div",{className:f.cn("px-4 py-8 flex gap-6 items-center justify-between",d&&"px-3 py-3 gap-4"),children:[l.jsxs("div",{className:"w-max flex flex-col gap-1 items-start",children:[l.jsx("p",{className:f.cn("font-semibold text-left",d?"text-sm":"text-xl"),"data-testid":"item-card-name",children:t}),n&&l.jsx("div",{"data-testid":"item-card-type",className:"w-fit bg-default-300 px-4 py-2 text-sm rounded-xl",children:l.jsx("p",{className:"text-center",children:n})}),w&&l.jsx(f.Chip,{"data-testid":"item-card-status",color:m,size:"sm",variant:"flat",className:"px-2",children:w})]}),a&&l.jsx("p",{className:f.cn("font-semibold text-right",d?"text-lg":"text-2xl"),"data-testid":"item-card-price",children:b})]})})},Hi="w-full bg-gray-100",Ui={variant:"light",color:"default"},Kl=({id:e,title:t,media:n,imageUrl:r,imageAlt:s,imageClassName:i="",imageAspect:a="aspect-[4/3]",meta:o=[],price:c,action:d,footer:u,onPress:h,isPressable:p=!1,isDisabled:m=!1,compact:v=!1,className:b="",bodyClassName:x="",footerClassName:w="",dataTestId:S})=>{const M=!!(c&&c.value),N=!!d?.label,j=p&&!!h&&!N,T=!j,$=N?{variant:d?.variant??Ui.variant,color:d?.color??Ui.color,size:d?.size??"sm",isDisabled:m||d?.isDisabled,startContent:d?.icon?l.jsx(U,{icon:d.icon,width:16}):void 0}:null,W=n??(r?l.jsx("div",{className:f.cn("relative overflow-hidden rounded-xl",a,Hi,i),children:l.jsx(f.Image,{removeWrapper:!0,src:r,alt:s||t,className:"size-full object-cover",classNames:{wrapper:"absolute inset-0"}})}):l.jsx("div",{className:f.cn("relative overflow-hidden rounded-xl",a,Hi,"grid place-items-center",i),"data-testid":`catalog-item-card-${e??"media"}-fallback`,children:l.jsx(U,{icon:"solar:ticket-outline",width:48,className:"text-default-400"})}));return l.jsxs(f.Card,{"data-testid":S||`catalog-item-card-${e??"item"}`,className:f.cn("w-full overflow-hidden",b),isPressable:j,onPress:h,isDisabled:m,shadow:"sm",radius:"lg",children:[l.jsx("div",{children:W}),l.jsxs(f.CardBody,{className:f.cn("gap-3",v?"p-3":"p-4",x),children:[l.jsx("h3",{"data-testid":`catalog-item-card-title-${e??""}`,className:f.cn("line-clamp-2 text-base font-semibold text-gray-900",v?"text-sm":""),children:t}),o.length>0?l.jsx("div",{className:"flex flex-col gap-1.5 text-sm text-gray-600","data-testid":`catalog-item-card-meta-${e??""}`,children:o.map((D,R)=>l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx(U,{icon:D.icon,className:"size-4 text-gray-400",width:16}),l.jsx("span",{children:D.label})]},`${D.label}-${R}`))}):null,(M||N)&&l.jsxs("div",{className:f.cn("flex items-center justify-end gap-2 pt-1 text-sm",v?"pt-0.5":"",w),children:[M?l.jsxs("span",{className:f.cn("mr-auto text-gray-500",v?"text-xs":""),"data-testid":`catalog-item-card-price-${e??""}`,children:[c?.label&&l.jsxs("span",{children:[c.label," "]}),l.jsx("span",{className:"font-semibold text-brand",children:c?.value})]}):l.jsx("span",{className:"ml-auto","aria-hidden":!0}),N&&T?l.jsx(K,{className:f.cn("rounded-full",d?.className),onPress:d?.onPress,variant:$?.variant,color:$?.color,size:$?.size,startContent:$?.startContent,isDisabled:$?.isDisabled,"aria-label":d?.ariaLabel||d?.label,children:d?.label}):null]}),u?l.jsx("div",{className:"pt-1",children:u}):null]})]})};Kl.displayName="CatalogItemCard";const dm={empty:"solar:inbox-line-duotone",error:"solar:danger-triangle-outline",success:"solar:check-circle-bold"},um={empty:"border-default-200 bg-white",error:"border-danger-200 bg-white",success:"border-success-100 bg-success-50/40",loading:"border-default-200 bg-white"},fm={empty:"bg-default-100 text-default-400",error:"bg-danger-50 text-danger-600",success:"bg-success-100 text-success-700",loading:"bg-primary-50 text-primary"},hm={empty:"status",error:"alert",success:"status",loading:"status"},mm={empty:"polite",error:"assertive",success:"polite",loading:"polite"};function pm(e,t,n,r){if(t===!1)return null;if(e==="loading"&&t===void 0)return l.jsx(f.Spinner,{size:"lg",color:"primary",className:r.spinner});if(y.isValidElement(t))return l.jsx(l.Fragment,{children:t});const s=typeof t=="string"?t:dm[e];return s?l.jsx(U,{icon:s,width:n,height:n,"aria-hidden":"true",className:r.icon}):null}function It({variant:e="empty",title:t,titleAs:n="p",description:r,icon:s,actions:i,role:a=hm[e],ariaLive:o=mm[e],iconSize:c=24,className:d,classNames:u={},"data-testid":h="feedback-state"}){const p=pm(e,s,c,u);return l.jsxs("div",{role:a,"aria-live":o,"data-variant":e,"data-testid":h,className:f.cn("flex flex-col items-center justify-center gap-3 rounded-xl border border-dashed px-6 py-12 text-center",um[e],d,u.base),children:[p?l.jsx("span",{"aria-hidden":"true","data-testid":`${h}-icon`,className:f.cn("inline-flex size-12 items-center justify-center rounded-2xl",e==="success"&&"rounded-full",fm[e],u.iconWrapper),children:p}):null,l.jsxs("div",{className:"flex flex-col items-center gap-1",children:[l.jsx(n,{"data-testid":`${h}-title`,className:f.cn("text-base font-medium text-default-900",u.title),children:t}),r?l.jsx("p",{"data-testid":`${h}-description`,className:f.cn("max-w-sm text-sm text-default-600",u.description),children:r}):null]}),i?l.jsx("div",{"data-testid":`${h}-actions`,className:f.cn("mt-1 flex flex-wrap items-center justify-center gap-2",u.actions),children:i}):null]})}function Jl(e){return l.jsx(It,{...e,variant:"empty"})}function Yl(e){return l.jsx(It,{...e,variant:"error"})}function Gl(e){return l.jsx(It,{...e,variant:"loading"})}function Ql(e){return l.jsx(It,{...e,variant:"success"})}It.displayName="FeedbackState";Jl.displayName="EmptyState";Yl.displayName="ErrorState";Gl.displayName="LoadingState";Ql.displayName="SuccessState";const Zl=({title:e,value:t,description:n,onValueChange:r,className:s=""})=>{const i=y.useId();return l.jsxs("div",{className:f.cn("w-full flex flex-row items-center",e||n?"justify-between gap-6":"justify-start",s),"data-testid":"toggle",children:[l.jsxs("div",{className:"flex flex-col items-start",children:[e&&l.jsx("label",{htmlFor:i,className:"font-medium text-left","data-testid":"toggle-title",children:e}),n&&l.jsx("p",{className:"text-left text-gray-500","data-testid":"toggle-description",children:n})]}),l.jsx(f.Switch,{id:i,isSelected:t,onValueChange:r,"data-testid":"toggle-switch"})]})},gm={ticketSelectionTitle:"Choose tickets to be upgraded",ticketsAllowedToRedeem:"Tickets allowed to redeem:",ticketsSelectedToRedeem:"Tickets selected to redeem",noUpgradeTicketsAvailable:"No upgrade tickets available to select",selectAllButtonLabel:"Select All"},xm=(e,t)=>new Intl.NumberFormat(e,{style:"currency",currency:t}),Xl=e=>Object.values(e).reduce((t,n)=>t+Object.values(n).reduce((r,s)=>r+Object.values(s).reduce((i,a)=>i+a.selectedQuantity,0),0),0),ym=e=>e.reduce((t,n)=>t+n.dates.reduce((r,s)=>r+s.tickets.reduce((i,a)=>i+a.max,0),0),0),Ss=e=>e.flatMap(t=>t.dates.flatMap(n=>n.tickets.map(r=>({exhibition:t,dateGroup:n,ticket:r})))),qi=(e,t,n)=>{const r={};let s=n?t??ym(e):0;for(const{exhibition:i,dateGroup:a,ticket:o}of Ss(e)){r[i.id]??={},r[i.id][a.id]??={};const c=n?Math.min(o.max,s):0;r[i.id][a.id][o.id]={id:o.id,selectedQuantity:c,originalPrice:o.originalPrice,discountedPrice:o.price},s-=c}return r},Wi=(e,t,n)=>`${e}::${t}::${n}`,bm=(e,t,n)=>{const r=Xl(t);for(const{exhibition:s,dateGroup:i,ticket:a}of Ss(e)){const o=t[s.id]?.[i.id]?.[a.id]?.selectedQuantity??0,c=n===void 0?a.max:Math.min(a.max,n-(r-o));if(c>0&&o<c)return!1}return!0},vm=({initialQuantity:e=1,minQuantity:t=1,maxQuantity:n=10,onChange:r,disabled:s=!1})=>{const i=Math.max(t,Math.min(n,e)),[a,o]=y.useState(()=>String(i)),[c,d]=y.useState(!1),u=c?a:String(i),h=()=>{s||i>=n||r?.(i+1)},p=()=>{s||i<=t||r?.(i-1)},m=N=>{if(s)return;o(N.target.value);const j=parseInt(N.target.value,10);isNaN(j)||r?.(Math.max(t,Math.min(n,j)))},v=N=>{const j=parseInt(N.target.value,10);if(d(!1),isNaN(j)){r?.(t);return}const T=Math.max(t,Math.min(n,j));T!==j?r?.(T):o(String(T))},b=i<=t,x=i>=n,w="w-10 h-10 flex items-center justify-center border-0 rounded-full cursor-pointer transition-colors duration-150 text-white text-2xl font-regular",S="bg-primary hover:bg-primary/80",M="bg-primary/40 cursor-not-allowed";return l.jsxs("div",{className:"flex items-center gap-4","data-testid":"quantity-selector",children:[l.jsx("button",{type:"button",onClick:p,disabled:s||b,className:f.cn(w,s||b?M:S),"aria-label":"Decrement quantity","data-testid":"quantity-decrement",children:"-"}),l.jsx("input",{type:"number",value:u,onChange:m,onFocus:()=>d(!0),onBlur:v,disabled:s,min:t,max:n,step:"1",className:"w-12 h-10 rounded-md border-0 bg-zinc-100 text-center text-2xl font-medium text-zinc-900 [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none","aria-label":`Selected quantity: ${i}`,"data-testid":"quantity-input"}),l.jsx("button",{type:"button",onClick:h,disabled:s||x,className:f.cn(w,s||x?M:S),"aria-label":"Increment quantity","data-testid":"quantity-increment",children:"+"})]})},wm=({label:e,checked:t=!1,onChange:n,disabled:r=!1})=>{const s=()=>{r||n?.(!t)};return l.jsxs("button",{type:"button",onClick:s,disabled:r,role:"checkbox","aria-checked":t,"data-testid":"checkbox-button","data-checked":t,className:f.cn("flex items-center gap-1.5 px-4 py-3 border-0 rounded-full cursor-pointer text-sm min-h-[30px]","outline-none select-none transition-colors bg-zinc-100 hover:bg-zinc-200 text-primary",r&&"cursor-not-allowed opacity-60"),children:[l.jsxs("span",{className:"relative flex items-center justify-center w-5 h-5 flex-shrink-0",children:[l.jsx("input",{type:"checkbox",checked:t,onChange:()=>{},disabled:r,className:"absolute opacity-0 w-0 h-0 pointer-events-none",tabIndex:-1,readOnly:!0}),l.jsx("span",{className:f.cn("block w-3.5 h-3.5 rounded-sm relative",t?"bg-primary":"bg-white ring-1 ring-zinc-300"),children:t&&l.jsx("span",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-[60%] rotate-45 w-[3px] h-[5px] border border-white border-t-0 border-l-0","aria-hidden":"true"})})]}),l.jsx("p",{className:"flex-1 m-0 text-left leading-snug",children:e})]})},km=({item:e,quantity:t,onChange:n,getTotalSelectedTickets:r,userMaxLimit:s,settings:i,labels:a})=>{const o=()=>{if(!r||s===void 0)return e.max;const h=r();return Math.min(e.max,s-(h-t))},c=i?.locale??"en-US",d=i?.currency??"USD",u=xm(c,d);return l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between bg-white px-3 py-2.5 gap-8","data-testid":"upgrade-ticket-item",children:[l.jsxs("div",{className:"min-w-0 flex flex-1 flex-col gap-2",children:[l.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[l.jsxs("h3",{className:"min-w-0 text-base font-semibold text-zinc-900 m-0","data-testid":"ticket-name",children:[e.name,typeof e.purchasedQuantity=="number"&&e.purchasedQuantity>1?l.jsx("span",{"data-testid":"ticket-purchased-quantity",children:` x${e.purchasedQuantity}`}):null]}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[l.jsx("h3",{className:"line-through text-zinc-500 text-[0.9rem] font-normal m-0","data-testid":"ticket-original-price",children:u.format(e.originalPrice)}),l.jsx("h3",{className:"text-base font-semibold text-zinc-900 m-0","data-testid":"ticket-discounted-price",children:u.format(e.price)})]})]}),e.membershipName?l.jsx("div",{"data-testid":"ticket-membership-name",className:"max-w-full self-start rounded-2xl bg-default-100 px-3 py-1 text-xs text-default-700",title:e.membershipName,children:l.jsx("p",{className:"max-w-full truncate text-center",children:e.membershipName})}):null,l.jsx("div",{className:"text-sm text-zinc-500",children:l.jsxs("p",{className:"m-0","data-testid":"ticket-max",children:[a.ticketsAllowedToRedeem," ",e.max]})})]}),l.jsx(vm,{initialQuantity:t,minQuantity:0,maxQuantity:o(),onChange:n})]}),e.membershipAlert?l.jsx(f.Alert,{"data-testid":"ticket-membership-alert",color:"warning",variant:"flat",radius:"full",className:"ticket-selection-membership-alert mb-2 w-full max-w-full py-0 shadow-none",classNames:{base:"ticket-selection-membership-alert-base !min-h-8 !items-center !bg-[#F5CB24]/15 !text-[#5B2C0F] shadow-none",mainWrapper:"ticket-selection-membership-alert-main-wrapper m-0 min-h-8 !py-0 !px-0",alertIcon:"ticket-selection-membership-alert-icon w-4 h-4 !text-[#5B2C0F]",iconWrapper:"ticket-selection-membership-alert-icon-wrapper !min-w-0 !bg-transparent !border-none !shadow-none !rounded-none !p-0 !m-0 !w-4 !h-4",description:"ticket-selection-membership-alert-description !ms-2 !my-2 !text-[#5B2C0F]"},description:l.jsx("span",{className:"ticket-selection-membership-alert-description-text block w-full whitespace-normal break-words text-sm leading-4 text-[#5B2C0F]",children:e.membershipAlert})}):null]})},Nm=({exhibitionId:e,dateGroup:t,isLast:n=!1,onQuantityChange:r,getTicketQuantity:s,getTotalSelectedTickets:i,userMaxLimit:a,settings:o,labels:c})=>l.jsxs("div",{className:f.cn("flex flex-col gap-2 pb-3",!n&&"border-b border-zinc-200"),"data-testid":"upgrade-ticket-date-group",children:[l.jsx("p",{className:"m-0 text-sm text-left text-zinc-500","data-testid":"upgrade-ticket-date",children:t.date}),t.tickets.map((d,u)=>l.jsxs("div",{children:[l.jsx(km,{item:d,quantity:s(e,t.id,d.id),onChange:h=>r(e,t.id,d.id,h),getTotalSelectedTickets:i,userMaxLimit:a,settings:o,labels:c}),u<t.tickets.length-1?l.jsx(f.Divider,{className:"bg-zinc-200","data-testid":"upgrade-ticket-divider"}):null]},d.id))]}),Sm=({title:e,exhibition:t,onQuantityChange:n,getTicketQuantity:r,getTotalSelectedTickets:s,userMaxLimit:i,settings:a,labels:o,initialExpanded:c=!1})=>{const[d,u]=y.useState(c),h=t.dates.reduce((m,v)=>m+v.tickets.reduce((b,x)=>b+r(t.id,v.id,x.id),0),0),p=t.dates.some(m=>m.tickets.length>0);return l.jsxs("div",{className:"w-full overflow-hidden border-b border-zinc-200","data-testid":"upgrade-ticket-header",children:[l.jsx("button",{type:"button",className:"flex items-center w-full px-5 py-4 border-0 cursor-pointer transition-all bg-white hover:bg-zinc-100",onClick:()=>u(!d),"aria-expanded":d,"aria-controls":`upgrade-items-${t.id}`,"data-testid":"upgrade-ticket-header-button",children:l.jsxs("div",{className:"flex justify-between items-center w-full gap-6",children:[l.jsx("h4",{className:"m-0 text-base font-semibold text-left text-zinc-900","data-testid":"upgrade-ticket-header-title",children:e}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("p",{className:"m-0 text-sm text-right text-zinc-500","data-testid":"upgrade-ticket-header-count",children:[h," ",o.ticketsSelectedToRedeem]}),l.jsx("span",{className:f.cn("inline-flex items-center justify-center text-zinc-500 text-xl transition-transform duration-200",d&&"rotate-180"),"aria-hidden":"true",children:l.jsx(U,{icon:"mdi:chevron-down"})})]})]})}),l.jsx("div",{id:`upgrade-items-${t.id}`,className:f.cn("transition-all duration-300 overflow-hidden",d?"max-h-[1000px] opacity-100":"max-h-0 opacity-0"),"aria-hidden":!d,children:d&&l.jsx("div",{className:"px-5 flex flex-col gap-6","data-testid":"upgrade-ticket-items",children:p?t.dates.map((m,v)=>l.jsx(Nm,{exhibitionId:t.id,dateGroup:m,isLast:v===t.dates.length-1,onQuantityChange:n,getTicketQuantity:r,getTotalSelectedTickets:s,userMaxLimit:i,settings:a,labels:o},m.id)):l.jsx("div",{className:"px-5 py-10 text-center",children:l.jsx("p",{className:"m-0 text-zinc-500 italic",children:o.noUpgradeTicketsAvailable})})})})]})},Cm=({initialExpanded:e=!1,userMaxLimit:t,labels:n,settings:r,ticketSelectionData:s,className:i="",onSelectionChange:a})=>{const o=y.useMemo(()=>s??[],[s]),c={...gm,...n},[d,u]=y.useState(()=>qi(o,t,!0)),h=y.useRef(!1),p=y.useMemo(()=>{const S=Ss(o).map(({exhibition:M,dateGroup:N,ticket:j})=>[Wi(M.id,N.id,j.id),j]);return new Map(S)},[o]),m=bm(o,d,t),v=(S,M,N)=>d[S]?.[M]?.[N]?.selectedQuantity??0,b=()=>Xl(d),x=(S,M,N,j)=>{const T=v(S,M,N),$=b()-T;if(t!==void 0&&$+j>t)return;const W=p.get(Wi(S,M,N));if(!W)return;const D={...d,[S]:{...d[S],[M]:{...d[S]?.[M],[N]:{id:N,selectedQuantity:j,originalPrice:W.originalPrice,discountedPrice:W.price}}}};u(D),a?.(D)},w=S=>{const M=qi(o,t,S);u(M),a?.(M)};return y.useEffect(()=>{!h.current&&m&&(a?.(d),h.current=!0)},[m,d,a]),l.jsxs("div",{className:f.cn("flex flex-col w-full font-sans",i),"data-testid":"ticket-selection",children:[l.jsxs("div",{className:"flex items-center justify-between py-2 gap-4","data-testid":"ticket-selection-header",children:[l.jsx("h3",{className:"text-xl font-semibold m-0","data-testid":"ticket-selection-title",children:c.ticketSelectionTitle}),l.jsx(wm,{label:c.selectAllButtonLabel,checked:m,onChange:w})]}),o.map(S=>l.jsx(Sm,{title:S.exhibitionName,exhibition:S,onQuantityChange:x,getTicketQuantity:v,getTotalSelectedTickets:b,userMaxLimit:t,settings:r,labels:c,initialExpanded:e},S.id))]})},wr={confirm:"Confirm",clear:"Clear",noLabel:"Filters"},kr=e=>{const t={};for(const n of e)n.type==="checkbox"?t[n.id]=[...n.selectedValues]:t[n.id]=n.selectedValue?[n.selectedValue]:[];return t},jm=(e,t)=>{const n={};for(const r of t){if(r.type==="checkbox"){n[r.id]=e[r.id]??[...r.selectedValues];continue}const s=e[r.id]??[];n[r.id]=s.length>0?s[0]:null}return n},Am=e=>e.type==="checkbox"?e.selectedValues.length>0:e.selectedValue!==null,eo=({triggerLabel:e,triggerAriaLabel:t,triggerIcon:n="solar:tuning-square-outline",triggerVariant:r="bordered",triggerColor:s="default",triggerSize:i="sm",triggerClassName:a,popoverClassName:o,className:c,sections:d,onConfirm:u,onClear:h,appliedCount:p,countAriaLabel:m,countDisplay:v="badge",confirmLabel:b=wr.confirm,clearLabel:x=wr.clear,isOpen:w,defaultOpen:S=!1,onOpenChange:M,isDisabled:N=!1,closeOnConfirm:j=!0,keepOpenAfterClear:T=!1})=>{const[$,W]=y.useState(S),[D,R]=y.useState(()=>kr(d)),E=w??$,C=p??d.filter(P=>Am(P)).length,I=P=>{P&&R(kr(d)),w||W(P),M?.(P)},F=(P,_)=>{R(G=>({...G,[P.id]:_}))},H=(P,_)=>{R(G=>({...G,[P.id]:_?[_]:[]}))},Q=async()=>{R(kr(d.map(P=>P.type==="checkbox"?{...P,selectedValues:[]}:{...P,selectedValue:null}))),await h(),T||I(!1)},Y=async()=>{const P=jm(D,d);await u(P),j&&I(!1)},te=P=>{if(P.type==="checkbox")return l.jsx(f.CheckboxGroup,{label:P.label,value:D[P.id]??[],onValueChange:G=>F(P,G),children:P.options.map(G=>l.jsx(f.Checkbox,{value:G.value,isDisabled:G.isDisabled,children:G.label},G.value))},P.id);const _=D[P.id]?.[0]??"";return l.jsx(f.RadioGroup,{label:P.label,value:_,onValueChange:G=>H(P,G||null),children:P.options.map(G=>l.jsx(f.Radio,{value:G.value,isDisabled:G.isDisabled,children:G.label},G.value))},P.id)},oe=y.useMemo(()=>C>0?m?.(C)||`${C} filters applied`:void 0,[m,C]),ce=y.useMemo(()=>C===0?e||wr.noLabel:m?m(C):`${e} (${C})`,[C,e,m]);return l.jsx("div",{className:c,children:l.jsxs(f.Popover,{isOpen:E,onOpenChange:I,placement:"bottom-end",children:[l.jsx(f.PopoverTrigger,{children:l.jsxs(K,{isDisabled:N,variant:r,color:s,size:i,className:a,"aria-label":t,"aria-haspopup":"dialog","aria-expanded":E,children:[l.jsx(U,{icon:n,width:16}),l.jsx("span",{children:e}),v==="badge"&&C>0?l.jsx("span",{className:"ml-1 inline-flex h-5 min-w-5 items-center justify-center rounded-full bg-gray-900 px-1.5 text-xs font-medium text-white","aria-label":oe,children:C}):v==="summary"&&ce!==e?l.jsx("span",{className:"text-xs",children:ce}):null]})}),l.jsx(f.PopoverContent,{className:o,children:l.jsxs("div",{className:"flex w-full flex-col gap-5 px-4 py-4",children:[d.map(P=>te(P)),l.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-gray-200 pt-3",children:[l.jsx(K,{variant:"light",color:"default",size:"sm",onPress:Q,children:x}),l.jsx(K,{color:"primary",size:"sm",onPress:Y,children:b})]})]})})]})})};eo.displayName="FilterPopover";const Mm="No sessions available for this date",Em=e=>e==="sold-out"||e==="closed"?"danger":"success",Tm=e=>{const t=e.seatsRemaining;return e.status==="sold-out"||e.status==="closed"?"Sold out":e.status==="limited"?typeof t=="number"?`${t} left`:"Limited":typeof t=="number"?`${t} seats available`:"Available"},Ki=e=>e.isDisabled?!0:e.status==="sold-out"||e.status==="closed",Dm=(e,t)=>t&&e.some(n=>n.date===t)?t:e[0]?.date??null,to=({heading:e,subheading:t,days:n,selectedDate:r,onDateSelect:s,quickDates:i,selectedSessionId:a=null,onSessionSelect:o,emptyStateMessage:c=Mm,statusLabel:d,statusTone:u,sessionAriaLabel:h,dayButtonClassName:p,calendarSlot:m,dayGroupAriaLabel:v,sessionGridAriaLabel:b,className:x,headingClassName:w,subheadingClassName:S})=>{const M=Dm(n,r),N=n.find(D=>D.date===M),j=i??n.map(D=>({date:D.date,label:D.label})),T=N?.sessions??[],$=D=>D===M?"solid":"bordered",W=D=>{if(!Ki(D)){if(D.id===a){o(null);return}o(D.id)}};return l.jsxs("section",{className:f.cn("flex flex-col gap-4 rounded-xl bg-white p-3 sm:p-4",x),"data-testid":"session-timeline-root",children:[l.jsxs("header",{className:"flex flex-col gap-1",children:[l.jsx("h2",{className:f.cn("text-base font-semibold text-gray-900",w),children:e}),t?l.jsx("p",{className:f.cn("text-sm text-gray-700",S),children:t}):null]}),l.jsxs("div",{className:"flex flex-wrap items-center gap-2",role:"group","aria-label":v||"Session days",children:[j.map(D=>l.jsx(K,{size:"sm",variant:$(D.date),color:"default",className:f.cn("rounded-full",p),isDisabled:D.isDisabled,onPress:()=>{s(D.date)},children:l.jsx("span",{children:D.label})},D.date)),m?l.jsx("div",{children:m}):null]}),l.jsxs("ul",{className:"grid grid-cols-1 gap-2 sm:grid-cols-3","aria-label":b||"Sessions",children:[T.length===0?l.jsx("li",{className:"rounded-lg bg-white px-4 py-6 text-center text-sm text-gray-600 sm:col-span-3",children:c}):null,T.map(D=>{const R=Ki(D),E=D.id===a;return l.jsx("li",{className:"rounded-xl",children:l.jsx(f.Card,{shadow:"sm",radius:"lg",isPressable:!R,onPress:()=>{W(D)},"aria-disabled":R,"aria-pressed":R?void 0:E,className:f.cn("w-full",R?"bg-gray-100 opacity-70":"",E?"w-full ring-2 ring-gray-900":""),"aria-label":h?h(D,{isSelected:E,isUnavailable:R}):R?`${D.startTime} ${D.endTime} sold out`:`${D.startTime} ${D.endTime} available`,children:l.jsxs(f.CardBody,{className:"flex flex-col items-center gap-3 p-4 text-center",children:[l.jsxs("span",{className:"text-sm font-semibold text-gray-900",children:[D.startTime," – ",D.endTime]}),l.jsx(f.Chip,{size:"sm",color:u?u(D):Em(D.status),variant:"flat",children:d?d(D):Tm(D)})]})})},D.id)})]})]})};to.displayName="SessionTimeline";const Im=350,$m={receivedLabel:"Cash Received",receivedPlaceholder:"$0.00",changeLabel:"Change",changeMessageTemplate:"You have to give back the client {change} in change",insufficientMessageTemplate:"Amount received must be at least {due}"},Nr=(e,t)=>Object.entries(t).reduce((n,[r,s])=>n.replace(`{${r}}`,s),e),Om=({dueAmount:e,received:t,defaultReceived:n=null,onChange:r,locale:s="en-US",labels:i,isDisabled:a=!1,maxAmount:o,autoFocus:c=!1,className:d,"data-testid":u="cash-tender-form"})=>{const h={...$m,...i},p=Gr(e.currency,s),m=t!==void 0,[v,b]=y.useState(n??null),x=m?t:v,w=y.useMemo(()=>{const I=typeof x=="number"&&Number.isFinite(x)?x:0,F=Cr(I,e.value,e.currency,s);return{received:I,change:F>0?F:0,isValid:I>=e.value&&I>0}},[x,e.value,e.currency,s]),S=y.useCallback(I=>{const F=I.currentTarget;requestAnimationFrame(()=>{F.isConnected&&F.select()})},[]),M=y.useCallback(I=>{if(a)return;const F=I.replace(/[^\d.,]/g,"").replace(",","."),H=F===""?null:Number.parseFloat(F),Q=H===null||Number.isNaN(H)?null:H;if(Q!==null&&o!==void 0&&Q>o)return;m||b(Q);const Y=typeof Q=="number"&&Number.isFinite(Q)?Q:0,te=Cr(Y,e.value,e.currency,s);r?.({received:Y,change:te>0?te:0,isValid:Y>=e.value&&Y>0})},[m,a,e.value,e.currency,s,r,o]),N=x==null?"":String(x),j=w.isValid&&w.change>0,T=!w.isValid&&w.received>0,$=rt(w.change,s,e.currency),W=rt(e.value,s,e.currency),[D,R]=y.useState(""),E=y.useRef(null);y.useEffect(()=>{E.current&&clearTimeout(E.current);const I=j?Nr(h.changeMessageTemplate,{change:$}):"",F=j?Im:0;return E.current=setTimeout(()=>R(I),F),()=>{E.current&&clearTimeout(E.current)}},[j,$,h.changeMessageTemplate]);const C=`${u}-received`;return l.jsxs("div",{className:f.cn("flex flex-col gap-3",d),"data-testid":u,children:[l.jsx(f.Input,{id:C,label:h.receivedLabel,labelPlacement:"outside",type:"text",inputMode:p===0?"numeric":"decimal",pattern:p===0?"[0-9]*":"[0-9]*[.,]?[0-9]*",value:N,onChange:I=>M(I.target.value),onFocus:S,placeholder:h.receivedPlaceholder,isDisabled:a,isInvalid:T,errorMessage:T?Nr(h.insufficientMessageTemplate,{due:W}):void 0,variant:"bordered",radius:"lg",autoFocus:c,"data-testid":`${u}-received-input`}),j&&l.jsx(f.Alert,{"data-testid":`${u}-change-alert`,color:"primary",variant:"flat",radius:"lg",title:h.changeLabel,description:Nr(h.changeMessageTemplate,{change:$}),icon:l.jsx(U,{icon:"lucide:info",width:20,height:20,"aria-hidden":"true"}),"aria-live":"off",classNames:{base:"bg-info-50 text-info-700",title:"font-semibold",description:"text-sm leading-relaxed",iconWrapper:"bg-transparent shadow-none border-0"}}),l.jsx("span",{role:"status","aria-live":"polite",className:"sr-only",children:D})]})},Lm={checkNumberLabel:"Check Number",checkNumberPlaceholder:"e.g. 11234",bankNameLabel:"Bank Name",bankNamePlaceholder:"e.g. Chase Bank",dateLabel:"Date",checkNumberRequiredMessage:"Check number is required"},Ji=()=>{const e=new Date,t=n=>String(n).padStart(2,"0");return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`},no=({dueAmount:e,value:t,defaultValue:n,onChange:r,labels:s,hideDate:i=!1,hideBankName:a=!1,isDisabled:o=!1,checkNumberMaxLength:c=34,bankNameMaxLength:d=100,autoFocus:u=!1,className:h,"data-testid":p="check-tender-form"})=>{const m={...Lm,...s},v=t!==void 0,[b,x]=y.useState({checkNumber:n?.checkNumber??"",bankName:n?.bankName??"",date:n?.date??Ji()}),[w,S]=y.useState(!!n?.checkNumber),M=y.useMemo(()=>v?{checkNumber:t?.checkNumber??"",bankName:t?.bankName??"",date:t?.date??Ji()}:b,[v,t,b]),N=y.useCallback(E=>{v||x(E);const C=E.checkNumber.trim(),I={amount:e.value,checkNumber:C,bankName:E.bankName.trim()||void 0,date:i?void 0:E.date,isValid:C.length>0&&e.value>0};r?.(I)},[v,e.value,i,r]),j=y.useCallback(E=>C=>{o||(E==="checkNumber"&&C.length>0&&S(!0),N({...M,[E]:C}))},[M,N,o]),T=y.useCallback(()=>{o||S(!0)},[o]),$=w&&M.checkNumber.trim()==="",W=`${p}-check-number`,D=`${p}-bank-name`,R=`${p}-date`;return l.jsxs("div",{className:f.cn("grid grid-cols-1 sm:grid-cols-2 gap-4",h),"data-testid":p,children:[l.jsx(f.Input,{id:W,label:m.checkNumberLabel,labelPlacement:"outside",type:"text",value:M.checkNumber,onChange:E=>j("checkNumber")(E.target.value),onBlur:T,placeholder:m.checkNumberPlaceholder,maxLength:c,isRequired:!0,isInvalid:$,errorMessage:$?m.checkNumberRequiredMessage:void 0,isDisabled:o,variant:"bordered",radius:"lg",autoFocus:u,"data-testid":`${p}-check-number-input`}),!a&&l.jsx(f.Input,{id:D,label:m.bankNameLabel,labelPlacement:"outside",type:"text",value:M.bankName,onChange:E=>j("bankName")(E.target.value),placeholder:m.bankNamePlaceholder,maxLength:d,isDisabled:o,variant:"bordered",radius:"lg","data-testid":`${p}-bank-name-input`}),!i&&l.jsx(f.Input,{id:R,label:m.dateLabel,labelPlacement:"outside",type:"date",value:M.date,onChange:E=>j("date")(E.target.value),isDisabled:o,variant:"bordered",radius:"lg","data-testid":`${p}-date-input`,className:"sm:col-span-2"})]})};no.displayName="CheckTenderForm";const Fm={methodLabel:"Method",methodPlaceholder:"Select a payment method",referenceLabel:"Reference",referencePlaceholder:"e.g. Voucher #1234",methodRequiredMessage:"Method is required"},Pm=[{value:"ach",label:"ACH"},{value:"wire",label:"Wire"},{value:"gift_card",label:"Gift Card"},{value:"voucher",label:"Voucher"},{value:"other",label:"Other"}],ro=({dueAmount:e,methodOptions:t=Pm,value:n,defaultValue:r,onChange:s,labels:i,showReference:a=!1,isDisabled:o=!1,className:c,"data-testid":d="other-tender-form"})=>{const u={...Fm,...i},h=n!==void 0,[p,m]=y.useState({method:r?.method??"",reference:r?.reference??""}),v=y.useMemo(()=>h?{method:n?.method??"",reference:n?.reference??""}:p,[h,n,p]),b=y.useCallback(j=>t.find(T=>T.value===j)?.label??"",[t]),x=y.useCallback(j=>{h||m(j);const T=b(j.method),$={amount:e.value,method:j.method,description:T,reference:j.reference.trim()||void 0,isValid:j.method!==""};s?.($)},[h,e.value,s,b]),w=y.useCallback(j=>{if(o)return;const T=typeof j=="string"?j:Array.from(j)[0]?.toString()??"";x({...v,method:T})},[v,x,o]),S=y.useCallback(j=>{o||x({...v,reference:j})},[v,x,o]),M=`${d}-method`,N=`${d}-reference`;return l.jsxs("div",{className:f.cn("flex flex-col gap-3",c),"data-testid":d,children:[l.jsx(yt,{id:M,label:u.methodLabel,labelPlacement:"outside",placeholder:u.methodPlaceholder,selectedKeys:v.method?[v.method]:[],onSelectionChange:w,isDisabled:o,isRequired:!0,variant:"bordered",radius:"lg","data-testid":`${d}-method-select`,popoverProps:{placement:"bottom-start",classNames:{content:"bg-white border border-default-200 shadow-lg rounded-xl p-1"}},listboxProps:{classNames:{list:"max-h-[var(--popover-available-height,40vh)] overflow-y-auto"},itemClasses:{base:["rounded-lg","px-3 py-2","text-default-800","data-[hover=true]:bg-default-100","data-[selectable=true]:focus:bg-default-100","data-[selected=true]:bg-primary-50","data-[selected=true]:text-primary","data-[selected=true]:font-medium"]}},children:t.map(j=>l.jsx(f.SelectItem,{"data-testid":`${d}-method-option-${j.value}`,children:j.label},j.value))}),a&&l.jsx(f.Input,{id:N,label:u.referenceLabel,labelPlacement:"outside",type:"text",value:v.reference,onChange:j=>S(j.target.value),placeholder:u.referencePlaceholder,isDisabled:o,variant:"bordered",radius:"lg","data-testid":`${d}-reference-input`})]})};ro.displayName="OtherTenderForm";const Rm={collectedHeading:"Collected",remainingLabel:"Remaining:",completeLabel:"Complete",removeAriaLabel:"Remove this tender",removeTooltipForRecorded:"Already recorded",statusPending:"Pending",statusRecorded:"Approved",statusFailed:"Failed"},zm={card:"lucide:credit-card",cash:"lucide:dollar-sign",check:"lucide:edit-3",other:"lucide:more-horizontal"},Bm={pending:"warning",recorded:"success",failed:"danger"},_m=e=>e==="pending"||e==="recorded",Vm=e=>`#${e+1}`,so=({total:e,tenders:t,onRemove:n,locale:r="en-US",labels:s,hideCollectedList:i=!1,className:a,"data-testid":o="split-payment-summary"})=>{const c={...Rm,...s},{collected:d,remaining:u,isComplete:h}=y.useMemo(()=>{const m=t.reduce((b,x)=>_m(x.status)?b+x.amount:b,0),v=Math.max(e.value-m,0);return{collected:m,remaining:v,isComplete:m>=e.value&&e.value>0}},[t,e.value]),p=m=>m==="pending"?c.statusPending:m==="recorded"?c.statusRecorded:c.statusFailed;return l.jsxs("div",{className:f.cn("flex flex-col gap-4",a),"data-testid":o,children:[l.jsxs("div",{className:"rounded-2xl bg-default-100 px-6 py-5 text-center","data-testid":`${o}-remaining-banner`,children:[l.jsx("div",{className:"text-sm text-default-600",children:h?c.completeLabel:c.remainingLabel}),l.jsx("div",{className:"mt-1 text-4xl font-bold tracking-tight","data-testid":`${o}-remaining-amount`,children:rt(h?d:u,r,e.currency)})]}),!i&&t.length>0&&l.jsxs("div",{className:"flex flex-col gap-2","data-testid":`${o}-collected-list`,children:[l.jsx("h3",{className:"text-base font-semibold",children:c.collectedHeading}),t.map((m,v)=>l.jsx(Hm,{index:v,tender:m,locale:r,currency:e.currency,removable:!!n&&m.status!=="recorded",onRemove:n?()=>n(m.id):void 0,statusLabel:p(m.status),removeAriaLabel:c.removeAriaLabel,recordedTooltip:c.removeTooltipForRecorded,dataTestId:`${o}-row-${v}`},m.id))]})]})};so.displayName="SplitPaymentSummary";const Hm=({index:e,tender:t,locale:n,currency:r,removable:s,onRemove:i,statusLabel:a,removeAriaLabel:o,recordedTooltip:c,dataTestId:d})=>{const u=i?l.jsx(K,{isIconOnly:!0,variant:"light",radius:"full",size:"sm",onPress:i,isDisabled:!s,"aria-label":o,"data-testid":`${d}-remove`,className:f.cn(s?"text-default-700 hover:bg-default-200":"text-default-300"),children:l.jsx(U,{icon:"lucide:x",width:18,height:18,"aria-hidden":"true"})}):null;return l.jsxs("div",{className:"flex items-center gap-3 rounded-xl bg-default-50 px-4 py-3 motion-safe:animate-[pp-row-in_200ms_ease-out]","data-testid":d,children:[l.jsx("span",{className:"text-sm font-medium text-default-500 w-6 shrink-0",children:Vm(e)}),l.jsx(U,{icon:zm[t.type],width:20,height:20,className:"text-default-700 shrink-0","aria-hidden":"true"}),l.jsx("span",{className:"flex-1 truncate","data-testid":`${d}-label`,children:t.label}),l.jsx("span",{className:"font-semibold tabular-nums","data-testid":`${d}-amount`,children:rt(t.amount,n,r)}),l.jsx(f.Chip,{size:"sm",radius:"full",variant:"flat",color:Bm[t.status],startContent:t.status==="recorded"?l.jsx(U,{icon:"lucide:check-circle",width:14,height:14,"aria-hidden":"true"}):t.status==="failed"?l.jsx(U,{icon:"lucide:alert-circle",width:14,height:14,"aria-hidden":"true"}):void 0,"data-testid":`${d}-status`,children:a}),u&&(s?u:l.jsx(f.Tooltip,{content:c,placement:"left",children:l.jsx("span",{tabIndex:0,"aria-label":c,children:u})}))]})},Um=`
20
20
  @keyframes pp-modal-in {
21
21
  from { opacity: 0; transform: scale(0.96); }
22
22
  to { opacity: 1; transform: scale(1); }
@@ -41,5 +41,5 @@
41
41
  from { opacity: 0; transform: translateY(-6px); }
42
42
  to { opacity: 1; transform: translateY(0); }
43
43
  }
44
- `,Wo=x.forwardRef(({children:t,relativeOverlayRoot:e=!0,className:n,style:r,"data-testid":s="modal-shell"},i)=>c.jsxs(c.Fragment,{children:[c.jsx("style",{children:xf}),c.jsx("div",{ref:i,"data-testid":s,style:r,className:g.cn("flex flex-col gap-4 p-4 rounded-3xl bg-white shadow-xl","md:gap-5 md:p-6",e&&"relative","motion-safe:animate-[pp-modal-in_220ms_ease-out]","motion-safe:transition-[min-height] motion-safe:duration-[420ms] motion-safe:ease-in-out",n),children:t})]}));Wo.displayName="ModalShell";const Jo=({title:t,onClose:e,closeLabel:n="Close",actions:r,className:s,"data-testid":i="modal-shell-header"})=>c.jsxs("header",{className:g.cn("flex items-center justify-between",s),"data-testid":i,children:[c.jsx("h2",{className:"text-xl font-semibold","data-testid":`${i}-title`,children:t}),c.jsxs("div",{className:"flex items-center gap-2",children:[r,e&&c.jsx(G,{isIconOnly:!0,variant:"light",radius:"full",size:"sm",onPress:e,"aria-label":n,"data-testid":`${i}-close`,children:c.jsx(ae,{icon:"lucide:x",width:20,height:20,"aria-hidden":"true"})})]})]});Jo.displayName="ModalShellHeader";const Go=({children:t,columns:e=2,className:n,"data-testid":r="modal-shell-footer"})=>c.jsx("footer",{className:g.cn("mt-2 gap-3",e===2?"flex flex-col md:grid md:grid-cols-2 [&>*]:w-full [&>*:first-child]:md:order-2 [&>*:nth-child(2)]:md:order-1":"grid grid-cols-1",n),"data-testid":r,children:t});Go.displayName="ModalShellFooter";const yf={2:"sm:grid-cols-2",3:"sm:grid-cols-3",4:"sm:grid-cols-4"},bf={1:"grid-cols-1",2:"grid-cols-2"},Yn=t=>typeof t=="string"?c.jsx(ae,{icon:t,width:20,height:20,"aria-hidden":"true"}):t,Zo=({options:t,selectedKey:e,onSelect:n,heading:r,ariaLabel:s="Select an option",columnsDesktop:i=3,columnsMobile:o=2,className:a,"data-testid":l="tile-select"})=>{const d=t.find(u=>u.key===e);return c.jsxs("div",{className:g.cn("flex flex-col gap-3",a),"data-testid":l,children:[r&&c.jsx("h3",{className:"text-sm font-medium text-default-700",id:`${l}-heading`,children:r}),c.jsx("div",{className:"md:hidden",children:c.jsx(wt,{"aria-label":r?void 0:s,"aria-labelledby":r?`${l}-heading`:void 0,selectedKeys:e?[e]:[],onSelectionChange:u=>{const p=Array.from(u)[0];typeof p=="string"&&n(p)},placeholder:s,variant:"bordered",radius:"lg","data-testid":`${l}-mobile-select`,startContent:d?c.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:Yn(d.icon)}):void 0,popoverProps:{placement:"bottom-start",classNames:{content:"bg-white border border-default-200 shadow-lg rounded-xl p-1"}},listboxProps:{classNames:{list:"max-h-[var(--popover-available-height,40vh)] overflow-y-auto"},itemClasses:{base:["rounded-lg","px-3 py-2","text-default-800","data-[hover=true]:bg-default-100","data-[selectable=true]:focus:bg-default-100","data-[selected=true]:bg-primary-50","data-[selected=true]:text-primary","data-[selected=true]:font-medium"]}},children:t.map(u=>c.jsx(g.SelectItem,{isDisabled:u.isDisabled,startContent:c.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:Yn(u.icon)}),"data-testid":u["data-testid"]??`${l}-${u.key}-mobile`,children:u.label},u.key))})}),c.jsx("div",{role:"group","aria-labelledby":r?`${l}-heading`:void 0,"aria-label":r?void 0:s,className:g.cn("hidden md:grid gap-3",bf[o],yf[i]),children:t.map(u=>{const f=e===u.key;return c.jsxs(G,{variant:"bordered",radius:"lg","aria-pressed":f,"aria-label":u.label,isDisabled:u.isDisabled,onPress:()=>n(u.key),"data-testid":u["data-testid"]??`${l}-${u.key}`,className:g.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:[c.jsx("span",{"aria-hidden":"true",children:Yn(u.icon)}),c.jsx("span",{className:"text-sm font-medium",children:u.label})]},u.key)})})]})};Zo.displayName="TileSelect";const vf={subtle:{wrapper:"bg-default-100",amount:"text-default-900"},success:{wrapper:"bg-success-50 text-success-700",amount:"text-success-700"}},Yo=({total:t,label:e,locale:n="en-US",variant:r="subtle",className:s,"data-testid":i="payment-total-banner"})=>{const o=vf[r];return c.jsxs("div",{"data-testid":i,className:g.cn("rounded-2xl px-6 py-5 text-center",o.wrapper,s),children:[c.jsx("div",{className:"text-sm text-default-600",children:e}),c.jsx("div",{className:g.cn("mt-1 text-4xl font-bold tracking-tight",o.amount),"data-testid":`${i}-amount`,children:ht(t.value,n,t.currency)})]})};Yo.displayName="PaymentTotalBanner";const kf={white:"bg-white/70 backdrop-blur-sm",transparent:"bg-transparent"},Qo=({title:t,subtitle:e,backdrop:n="white",exiting:r=!1,className:s,"data-testid":i="loading-overlay"})=>c.jsxs("div",{role:"status","aria-live":r?"off":"polite","aria-hidden":r||void 0,"data-testid":i,"data-state":r?"exiting":"visible",className:g.cn("absolute inset-0 z-10 flex flex-col items-center justify-center gap-4 rounded-3xl",kf[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:[c.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]"}),c.jsxs("div",{className:"text-center",children:[c.jsx("div",{className:"text-xl font-semibold","data-testid":`${i}-title`,children:t}),e&&c.jsx("div",{className:"mt-1 text-sm text-default-600",children:e})]})]});Qo.displayName="LoadingOverlay";const Wr=({cashChange:t,label:e="Cash to return",secondaryLine:n,locale:r="en-US",onDismiss:s,dismissAriaLabel:i="Dismiss",align:o="left",className:a,"data-testid":l="payment-cash-change-banner"})=>{if(!t||t.value<=0)return null;const d=o==="center";return c.jsxs("div",{role:"status","aria-live":"polite","data-testid":l,className:g.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]",a),children:[c.jsx(ae,{icon:"lucide:info",width:28,height:28,className:"shrink-0 text-info-700","aria-hidden":"true"}),c.jsxs("div",{className:g.cn("flex flex-col",d?"items-center":"flex-1"),children:[c.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-info-700",children:e}),c.jsx("span",{className:"text-2xl font-bold text-info-700","data-testid":`${l}-amount`,children:ht(t.value,r,t.currency)}),n&&c.jsx("span",{className:"mt-0.5 text-xs text-info-700/80",children:n})]}),s&&c.jsx(G,{isIconOnly:!0,variant:"light",radius:"full",size:"sm",onPress:s,"aria-label":i,"data-testid":`${l}-dismiss`,className:"shrink-0 text-info-700 hover:bg-info-100",children:c.jsx(ae,{icon:"lucide:x",width:18,height:18,"aria-hidden":"true"})})]})};Wr.displayName="PaymentCashChangeBanner";const Xo=({title:t,subtitle:e,emailLine:n,confirmationEmail:r,cashChange:s,cashChangeLabel:i="Cash to return",locale:o="en-US",closeLabel:a="Close",onClose:l,className:d,"data-testid":u="payment-success-view"})=>{const f=!!(s&&s.value>0);return c.jsxs("div",{"data-testid":u,className:g.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:[c.jsx("div",{"aria-hidden":"true",className:"flex items-center justify-center rounded-full bg-[#A2D9C6] p-[10px]",children:c.jsx(ae,{icon:"gravity-ui:circle-check-fill",width:76,height:76,className:"text-[#10B981]","aria-hidden":"true"})}),c.jsxs("div",{className:"space-y-3",children:[c.jsx("h2",{className:"text-2xl font-bold","data-testid":`${u}-title`,children:t}),c.jsx("p",{className:"text-default-700",children:e}),n&&r&&c.jsxs("p",{className:"text-default-700",children:[n,c.jsx("br",{}),c.jsx("strong",{className:"font-semibold",children:r})]})]}),f&&s&&c.jsx(Wr,{cashChange:s,label:i,locale:o,align:"center",className:"max-w-[400px]","data-testid":`${u}-cash-change`}),l&&c.jsx(G,{color:"default",variant:"bordered",radius:"full",size:"lg",onPress:l,"data-testid":`${u}-close`,className:"mt-4 w-full",children:a})]})};Xo.displayName="PaymentSuccessView";const ea=({heading:t,amountLabel:e,value:n,defaultValue:r,onChange:s,placeholder:i,isDisabled:o,isInvalid:a,errorMessage:l,autoFocus:d,maxAmount:u,className:f,"data-testid":p="payment-sub-amount-input"})=>{const h=`${p}-input`,k=x.useCallback(y=>{if(u!==void 0){const S=Number.parseFloat(y.replace(",","."));if(Number.isFinite(S)&&S>u)return}s?.(y)},[u,s]),v=x.useCallback(y=>{const S=y.currentTarget;requestAnimationFrame(()=>{S.isConnected&&S.select()})},[]);return c.jsxs("div",{className:g.cn("flex flex-col gap-3 border-t border-default-100 pt-5",f),"data-testid":p,children:[c.jsx("h3",{className:"text-lg font-semibold","data-testid":`${p}-heading`,children:t}),c.jsx(g.Input,{id:h,label:e,labelPlacement:"outside",type:"text",inputMode:"decimal",pattern:"[0-9]*[.,]?[0-9]*",value:n,defaultValue:r,onChange:y=>k(y.target.value),onFocus:v,placeholder:i,isDisabled:o,isInvalid:a,errorMessage:a?l:void 0,variant:"bordered",radius:"lg","aria-invalid":a||void 0,autoFocus:d,"data-testid":`${p}-field`})]})};ea.displayName="PaymentSubAmountInput";const ta=({isOpen:t,title:e,body:n,confirmLabel:r,confirmVariant:s="danger",dismissLabel:i,onConfirm:o,onDismiss:a,"data-testid":l="confirm-dialog"})=>c.jsx(g.Modal,{isOpen:t,onOpenChange:d=>{d||a()},role:"alertdialog",size:"sm",backdrop:"opaque","data-testid":l,"aria-labelledby":`${l}-title`,"aria-describedby":`${l}-body`,children:c.jsxs(g.ModalContent,{children:[c.jsx(g.ModalHeader,{id:`${l}-title`,className:"text-lg font-semibold",children:e}),c.jsx(g.ModalBody,{id:`${l}-body`,className:"text-sm text-default-700",children:n}),c.jsxs(g.ModalFooter,{className:"grid grid-cols-2 gap-3",children:[c.jsx(G,{variant:"bordered",radius:"full",onPress:a,"data-testid":`${l}-dismiss`,className:"h-11",children:i}),c.jsx(G,{color:s,variant:"solid",radius:"full",onPress:o,"data-testid":`${l}-confirm`,className:"h-11",children:r})]})]})});ta.displayName="ConfirmDialog";exports.Button=G;exports.CashTenderForm=af;exports.CheckTenderForm=Uo;exports.ConfirmDialog=ta;exports.ConfirmationPageTemplate=Sa;exports.DonationAmounts=ro;exports.EventDetails=uu;exports.EventDetailsTemplate=Na;exports.ExpireCartTimer=so;exports.Footer=Aa;exports.HeroUIProvider=ga;exports.ItemCard=zo;exports.LoadingOverlay=Qo;exports.MembershipSelectCards=Wu;exports.ModalShell=Wo;exports.ModalShellFooter=Go;exports.ModalShellHeader=Jo;exports.Multiselect=ja;exports.Navbar=ka;exports.OfferCard=Rr;exports.OfferCardEmpty=vo;exports.OfferCardError=ko;exports.OfferCardList=No;exports.OfferCardSkeleton=So;exports.OtherTenderForm=qo;exports.PaymentCashChangeBanner=Wr;exports.PaymentSubAmountInput=ea;exports.PaymentSuccessView=Xo;exports.PaymentTotalBanner=Yo;exports.RICH_TEXT_PRESETS=to;exports.RevenueDistributionCard=Ro;exports.RevenueDistributionEmpty=$o;exports.RevenueDistributionError=Vo;exports.RevenueDistributionSkeleton=Bo;exports.RichTextArea=no;exports.Select=wt;exports.SplitPaymentSummary=Ko;exports.Stepper=ai;exports.TicketSelection=rf;exports.TileSelect=Zo;exports.Toggle=_o;exports.calculateAllocationDifference=Hu;exports.computeChange=Qn;exports.currencyFractionDigits=vr;exports.formatMoney=ht;exports.formatOfferCurrency=bo;exports.formatRevenueAmount=Vu;exports.formatRevenueCurrency=Bu;exports.generateDistributionId=qr;exports.getCurrencySymbol=zu;exports.offerCardVariants=wo;exports.offerListVariants=Co;exports.parseOfferCurrency=fu;exports.parseRevenueCurrency=_u;exports.roundToCurrency=li;Object.keys(g).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>g[t]})});
44
+ `,io=y.forwardRef(({children:e,relativeOverlayRoot:t=!0,className:n,style:r,"data-testid":s="modal-shell"},i)=>l.jsxs(l.Fragment,{children:[l.jsx("style",{children:Um}),l.jsx("div",{ref:i,"data-testid":s,style:r,className:f.cn("flex flex-col gap-4 p-4 rounded-3xl bg-white shadow-xl","md:gap-5 md:p-6",t&&"relative","motion-safe:animate-[pp-modal-in_220ms_ease-out]","motion-safe:transition-[min-height] motion-safe:duration-[420ms] motion-safe:ease-in-out",n),children:e})]}));io.displayName="ModalShell";const ao=({title:e,onClose:t,closeLabel:n="Close",actions:r,className:s,"data-testid":i="modal-shell-header"})=>l.jsxs("header",{className:f.cn("flex items-center justify-between",s),"data-testid":i,children:[l.jsx("h2",{className:"text-xl font-semibold","data-testid":`${i}-title`,children:e}),l.jsxs("div",{className:"flex items-center gap-2",children:[r,t&&l.jsx(K,{isIconOnly:!0,variant:"light",radius:"full",size:"sm",onPress:t,"aria-label":n,"data-testid":`${i}-close`,children:l.jsx(U,{icon:"lucide:x",width:20,height:20,"aria-hidden":"true"})})]})]});ao.displayName="ModalShellHeader";const lo=({children:e,columns:t=2,className:n,"data-testid":r="modal-shell-footer"})=>l.jsx("footer",{className:f.cn("mt-2 gap-3",t===2?"flex flex-col md:grid md:grid-cols-2 [&>*]:w-full [&>*:first-child]:md:order-2 [&>*:nth-child(2)]:md:order-1":"grid grid-cols-1",n),"data-testid":r,children:e});lo.displayName="ModalShellFooter";const qm={2:"sm:grid-cols-2",3:"sm:grid-cols-3",4:"sm:grid-cols-4"},Wm={1:"grid-cols-1",2:"grid-cols-2"},Sr=e=>typeof e=="string"?l.jsx(U,{icon:e,width:20,height:20,"aria-hidden":"true"}):e,oo=({options:e,selectedKey:t,onSelect:n,heading:r,ariaLabel:s="Select an option",columnsDesktop:i=3,columnsMobile:a=2,className:o,"data-testid":c="tile-select"})=>{const d=e.find(u=>u.key===t);return l.jsxs("div",{className:f.cn("flex flex-col gap-3",o),"data-testid":c,children:[r&&l.jsx("h3",{className:"text-sm font-medium text-default-700",id:`${c}-heading`,children:r}),l.jsx("div",{className:"md:hidden",children:l.jsx(yt,{"aria-label":r?void 0:s,"aria-labelledby":r?`${c}-heading`:void 0,selectedKeys:t?[t]:[],onSelectionChange:u=>{const p=Array.from(u)[0];typeof p=="string"&&n(p)},placeholder:s,variant:"bordered",radius:"lg","data-testid":`${c}-mobile-select`,startContent:d?l.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:Sr(d.icon)}):void 0,popoverProps:{placement:"bottom-start",classNames:{content:"bg-white border border-default-200 shadow-lg rounded-xl p-1"}},listboxProps:{classNames:{list:"max-h-[var(--popover-available-height,40vh)] overflow-y-auto"},itemClasses:{base:["rounded-lg","px-3 py-2","text-default-800","data-[hover=true]:bg-default-100","data-[selectable=true]:focus:bg-default-100","data-[selected=true]:bg-primary-50","data-[selected=true]:text-primary","data-[selected=true]:font-medium"]}},children:e.map(u=>l.jsx(f.SelectItem,{isDisabled:u.isDisabled,startContent:l.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:Sr(u.icon)}),"data-testid":u["data-testid"]??`${c}-${u.key}-mobile`,children:u.label},u.key))})}),l.jsx("div",{role:"group","aria-labelledby":r?`${c}-heading`:void 0,"aria-label":r?void 0:s,className:f.cn("hidden md:grid gap-3",Wm[a],qm[i]),children:e.map(u=>{const h=t===u.key;return l.jsxs(K,{variant:"bordered",radius:"lg","aria-pressed":h,"aria-label":u.label,isDisabled:u.isDisabled,onPress:()=>n(u.key),"data-testid":u["data-testid"]??`${c}-${u.key}`,className:f.cn("flex flex-col items-center justify-center gap-2 h-auto min-h-[80px] px-4 py-4","border bg-transparent transition-colors",h?"border-primary bg-primary-50 text-primary":"border-default-200 text-default-800 hover:bg-default-50"),children:[l.jsx("span",{"aria-hidden":"true",children:Sr(u.icon)}),l.jsx("span",{className:"text-sm font-medium",children:u.label})]},u.key)})})]})};oo.displayName="TileSelect";const Km={subtle:{wrapper:"bg-default-100",amount:"text-default-900"},success:{wrapper:"bg-success-50 text-success-700",amount:"text-success-700"}},co=({total:e,label:t,locale:n="en-US",variant:r="subtle",className:s,"data-testid":i="payment-total-banner"})=>{const a=Km[r];return l.jsxs("div",{"data-testid":i,className:f.cn("rounded-2xl px-6 py-5 text-center",a.wrapper,s),children:[l.jsx("div",{className:"text-sm text-default-600",children:t}),l.jsx("div",{className:f.cn("mt-1 text-4xl font-bold tracking-tight",a.amount),"data-testid":`${i}-amount`,children:rt(e.value,n,e.currency)})]})};co.displayName="PaymentTotalBanner";const Jm={white:"bg-white/70 backdrop-blur-sm",transparent:"bg-transparent"},uo=({title:e,subtitle:t,backdrop:n="white",exiting:r=!1,className:s,"data-testid":i="loading-overlay"})=>l.jsxs("div",{role:"status","aria-live":r?"off":"polite","aria-hidden":r||void 0,"data-testid":i,"data-state":r?"exiting":"visible",className:f.cn("absolute inset-0 z-10 flex flex-col items-center justify-center gap-4 rounded-3xl",Jm[n],r?"pointer-events-none motion-safe:animate-[pp-fade-out_280ms_ease-in_forwards]":"motion-safe:animate-[pp-fade-in_150ms_ease-out]",s),children:[l.jsx("div",{"aria-hidden":"true","data-testid":`${i}-spinner`,className:"h-16 w-16 rounded-full border-4 border-primary-100 border-t-primary animate-spin motion-safe:animate-[pp-scale-in_200ms_ease-out,spin_1s_linear_infinite]"}),l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"text-xl font-semibold","data-testid":`${i}-title`,children:e}),t&&l.jsx("div",{className:"mt-1 text-sm text-default-600",children:t})]})]});uo.displayName="LoadingOverlay";const Cs=({cashChange:e,label:t="Cash to return",secondaryLine:n,locale:r="en-US",onDismiss:s,dismissAriaLabel:i="Dismiss",align:a="left",className:o,"data-testid":c="payment-cash-change-banner"})=>{if(!e||e.value<=0)return null;const d=a==="center";return l.jsxs("div",{role:"status","aria-live":"polite","data-testid":c,className:f.cn("flex w-full items-center gap-3 rounded-2xl border border-info-200 bg-info-50 px-5 py-4",d?"justify-center text-center":"text-left","motion-safe:animate-[pp-slide-down_200ms_ease-out]",o),children:[l.jsx(U,{icon:"lucide:info",width:28,height:28,className:"shrink-0 text-info-700","aria-hidden":"true"}),l.jsxs("div",{className:f.cn("flex flex-col",d?"items-center":"flex-1"),children:[l.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-info-700",children:t}),l.jsx("span",{className:"text-2xl font-bold text-info-700","data-testid":`${c}-amount`,children:rt(e.value,r,e.currency)}),n&&l.jsx("span",{className:"mt-0.5 text-xs text-info-700/80",children:n})]}),s&&l.jsx(K,{isIconOnly:!0,variant:"light",radius:"full",size:"sm",onPress:s,"aria-label":i,"data-testid":`${c}-dismiss`,className:"shrink-0 text-info-700 hover:bg-info-100",children:l.jsx(U,{icon:"lucide:x",width:18,height:18,"aria-hidden":"true"})})]})};Cs.displayName="PaymentCashChangeBanner";const fo=({title:e,subtitle:t,emailLine:n,confirmationEmail:r,cashChange:s,cashChangeLabel:i="Cash to return",locale:a="en-US",closeLabel:o="Close",onClose:c,className:d,"data-testid":u="payment-success-view"})=>{const h=!!(s&&s.value>0);return l.jsxs("div",{"data-testid":u,className:f.cn("flex flex-col items-center gap-6 py-8 px-4 text-center","motion-safe:animate-[pp-fade-in_250ms_ease-out]",d),children:[l.jsx("div",{"aria-hidden":"true",className:"flex items-center justify-center rounded-full bg-[#A2D9C6] p-[10px]",children:l.jsx(U,{icon:"gravity-ui:circle-check-fill",width:76,height:76,className:"text-[#10B981]","aria-hidden":"true"})}),l.jsxs("div",{className:"space-y-3",children:[l.jsx("h2",{className:"text-2xl font-bold","data-testid":`${u}-title`,children:e}),l.jsx("p",{className:"text-default-700",children:t}),n&&r&&l.jsxs("p",{className:"text-default-700",children:[n,l.jsx("br",{}),l.jsx("strong",{className:"font-semibold",children:r})]})]}),h&&s&&l.jsx(Cs,{cashChange:s,label:i,locale:a,align:"center",className:"max-w-[400px]","data-testid":`${u}-cash-change`}),c&&l.jsx(K,{color:"default",variant:"bordered",radius:"full",size:"lg",onPress:c,"data-testid":`${u}-close`,className:"mt-4 w-full",children:o})]})};fo.displayName="PaymentSuccessView";const ho=({heading:e,amountLabel:t,value:n,defaultValue:r,onChange:s,placeholder:i,isDisabled:a,isInvalid:o,errorMessage:c,autoFocus:d,maxAmount:u,className:h,"data-testid":p="payment-sub-amount-input"})=>{const m=`${p}-input`,v=y.useCallback(x=>{if(u!==void 0){const w=Number.parseFloat(x.replace(",","."));if(Number.isFinite(w)&&w>u)return}s?.(x)},[u,s]),b=y.useCallback(x=>{const w=x.currentTarget;requestAnimationFrame(()=>{w.isConnected&&w.select()})},[]);return l.jsxs("div",{className:f.cn("flex flex-col gap-3 border-t border-default-100 pt-5",h),"data-testid":p,children:[l.jsx("h3",{className:"text-lg font-semibold","data-testid":`${p}-heading`,children:e}),l.jsx(f.Input,{id:m,label:t,labelPlacement:"outside",type:"text",inputMode:"decimal",pattern:"[0-9]*[.,]?[0-9]*",value:n,defaultValue:r,onChange:x=>v(x.target.value),onFocus:b,placeholder:i,isDisabled:a,isInvalid:o,errorMessage:o?c:void 0,variant:"bordered",radius:"lg","aria-invalid":o||void 0,autoFocus:d,"data-testid":`${p}-field`})]})};ho.displayName="PaymentSubAmountInput";const mo=({isOpen:e,title:t,body:n,confirmLabel:r,confirmVariant:s="danger",dismissLabel:i,onConfirm:a,onDismiss:o,"data-testid":c="confirm-dialog"})=>l.jsx(f.Modal,{isOpen:e,onOpenChange:d=>{d||o()},role:"alertdialog",size:"sm",backdrop:"opaque","data-testid":c,"aria-labelledby":`${c}-title`,"aria-describedby":`${c}-body`,children:l.jsxs(f.ModalContent,{children:[l.jsx(f.ModalHeader,{id:`${c}-title`,className:"text-lg font-semibold",children:t}),l.jsx(f.ModalBody,{id:`${c}-body`,className:"text-sm text-default-700",children:n}),l.jsxs(f.ModalFooter,{className:"grid grid-cols-2 gap-3",children:[l.jsx(K,{variant:"bordered",radius:"full",onPress:o,"data-testid":`${c}-dismiss`,className:"h-11",children:i}),l.jsx(K,{color:s,variant:"solid",radius:"full",onPress:a,"data-testid":`${c}-confirm`,className:"h-11",children:r})]})]})});mo.displayName="ConfirmDialog";const Ym=60,Gm=(e,t,n=Ym)=>t?e>n:e<-n,po=(e,t)=>Math.max(0,Math.min(e,t)),Qm=(e,t,n)=>po(e-t,n),Zm=(e,t,n)=>e!==null?po(e,n):t?n:0,Xm=e=>e?"":"transition-[height] duration-300 ease-out",ep=e=>({onDrag:(t,n)=>{const r=e.open?e.fullHeight:0;e.setDragHeight(Qm(r,n?.offset?.y??0,e.fullHeight))},onDragEnd:(t,n)=>{Gm(n?.offset?.y??0,e.open)&&e.onToggleOpen?.(),e.setDragHeight(null)}}),ln=(e,t)=>rt(e.value,t,e.currency),js=({item:e,locale:t,onRemove:n,removeAriaLabel:r})=>{const s=!!e.children&&e.children.length>0;return l.jsxs("div",{"data-testid":`summary-item-${e.id}`,className:"flex flex-col gap-2",children:[l.jsxs("div",{className:"flex min-h-9 items-center justify-between gap-2",children:[l.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-base text-foreground",children:[typeof e.quantity=="number"&&l.jsxs("span",{"data-testid":`summary-item-qty-${e.id}`,className:"shrink-0",children:[e.quantity," x"]}),e.leadingIcon,l.jsx("span",{"data-testid":`summary-item-name-${e.id}`,className:f.cn("truncate",e.emphasis&&"font-medium"),children:e.name})]}),l.jsxs("div",{className:"flex shrink-0 items-center",children:[e.amount&&l.jsx("span",{"data-testid":`summary-item-amount-${e.id}`,className:"whitespace-nowrap text-base text-foreground",children:ln(e.amount,t)}),n&&l.jsx(K,{isIconOnly:!0,size:"sm",variant:"light",radius:"full",className:"ml-1 size-8 min-w-8 p-2 text-danger","aria-label":r,"data-testid":`summary-remove-${e.id}`,onPress:()=>n(e.id),children:l.jsx(U,{icon:"lucide:trash-2",width:16,height:16,className:"text-danger"})})]})]}),e.dateLabel&&l.jsxs("div",{"data-testid":`summary-item-date-${e.id}`,className:"flex items-center gap-2 text-sm text-default-500",children:[l.jsx(U,{icon:"lucide:calendar",width:16,height:16,className:"shrink-0"}),l.jsx("span",{className:"truncate",children:e.dateLabel})]}),e.dateRange&&l.jsxs("div",{"data-testid":`summary-item-daterange-${e.id}`,className:"flex items-center gap-2 text-sm text-default-500",children:[l.jsx(U,{icon:"lucide:calendar",width:16,height:16,className:"shrink-0"}),l.jsx("span",{children:e.dateRange.from}),l.jsx(U,{icon:"lucide:arrow-right",width:16,height:16,className:"shrink-0"}),l.jsx("span",{children:e.dateRange.to})]}),s&&l.jsx("div",{"data-testid":`summary-children-${e.id}`,className:"flex flex-col gap-2 pl-6",children:e.children.map(i=>l.jsx(js,{item:i,locale:t,onRemove:n,removeAriaLabel:r},i.id))})]})};js.displayName="SummaryItemRow";const go=({fee:e,locale:t,className:n})=>l.jsxs("div",{"data-testid":"summary-service-fee",className:f.cn("flex items-center justify-between gap-2",n),children:[l.jsxs("button",{type:"button",role:"switch","aria-checked":!!e.isSelected,"aria-label":typeof e.label=="string"?e.label:"Pay Service fee","data-testid":"summary-service-fee-toggle",onClick:e.onToggle,className:"flex min-w-0 items-center gap-2 text-left",children:[l.jsx("span",{"aria-hidden":"true",className:f.cn("flex size-4 shrink-0 items-center justify-center rounded-full border",e.isSelected?"border-primary":"border-default-200"),children:e.isSelected&&l.jsx("span",{className:"size-2 rounded-full bg-primary"})}),l.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:e.label})]}),l.jsx("span",{"data-testid":"summary-service-fee-amount",className:"whitespace-nowrap text-base text-foreground",children:ln(e.amount,t)})]});go.displayName="SummaryServiceFeeRow";const xo=({row:e,locale:t,emphasized:n})=>l.jsxs("div",{"data-testid":`summary-row-${e.key}`,className:"flex items-center justify-between text-foreground",children:[l.jsx("span",{"data-testid":`summary-row-label-${e.key}`,className:f.cn(n?"text-xl font-semibold leading-7":"text-base"),children:e.label}),l.jsx("span",{"data-testid":`summary-row-amount-${e.key}`,className:"whitespace-nowrap text-base",children:ln(e.amount,t)})]});xo.displayName="SummaryTotalsLineRow";const yo=({pricesInLabel:e,currency:t,items:n,serviceFee:r,rows:s,locale:i,onRemoveItem:a,removeAriaLabel:o,emptyState:c,classNames:d})=>{const u=(n?.length??0)>0;return l.jsxs(l.Fragment,{children:[l.jsxs("div",{"data-testid":"summary-prices",className:f.cn("flex items-center justify-between text-xs text-default-500",d.prices),children:[l.jsx("span",{children:e}),t!=null&&l.jsx("span",{children:t})]}),u?l.jsx("div",{className:f.cn("flex flex-col gap-4",d.items),children:n.map(h=>l.jsx(js,{item:h,locale:i,onRemove:a,removeAriaLabel:o},h.id))}):l.jsx("div",{"data-testid":"summary-empty",children:c}),r&&l.jsxs(l.Fragment,{children:[l.jsx(f.Divider,{className:"bg-default-200"}),l.jsx(go,{fee:r,locale:i,className:d.serviceFee})]}),s&&s.length>0&&l.jsx("div",{className:f.cn("flex flex-col gap-4",d.totalsRows),children:s.map((h,p)=>l.jsx(xo,{row:h,locale:i,emphasized:p===0},h.key))})]})};yo.displayName="SummaryBody";const bo=({total:e,locale:t,className:n})=>l.jsxs("div",{"data-testid":"summary-total",className:f.cn("flex items-center justify-between text-xl font-semibold leading-7 text-foreground",n),children:[l.jsx("span",{children:e.label??"Total"}),l.jsx("span",{"data-testid":"summary-total-amount",className:"whitespace-nowrap text-xl font-semibold leading-7",children:ln(e.amount,t)})]});bo.displayName="SummaryGrandTotalRow";const _n=({action:e,disabledByLoading:t,className:n,testId:r="summary-cta"})=>l.jsx(K,{color:"primary",radius:"full",className:f.cn("px-[18px] py-[14px] font-medium",n),"data-testid":r,isLoading:e.isLoading,isDisabled:e.isDisabled||t,onPress:e.onPress,endContent:l.jsx(U,{icon:"lucide:arrow-right",width:16,height:16}),children:e.label});_n.displayName="SummaryPrimaryCta";const vo=({title:e,total:t,locale:n,open:r,progress:s,dragging:i,toggleAriaLabel:a,onToggleOpen:o,classNames:c})=>l.jsx("h2",{children:l.jsxs("button",{type:"button","data-testid":"summary-collapse-toggle","aria-expanded":r,"aria-label":a,onClick:o,className:f.cn("-mx-4 -mt-4 grid w-[calc(100%_+_32px)] grid-cols-1 px-4 pb-4 pt-4 text-left",c.header),children:[l.jsxs("span",{"aria-hidden":!r,style:{opacity:s},className:f.cn("col-start-1 row-start-1 flex items-center justify-between",!i&&"transition-opacity duration-300"),children:[l.jsx("span",{"data-testid":"summary-title",className:f.cn("text-xl font-semibold leading-7 text-foreground",c.title),children:e}),l.jsx("span",{"data-testid":"summary-close","aria-hidden":"true",className:f.cn("shrink-0 text-foreground",c.closeButton),children:l.jsx(U,{icon:"lucide:x",width:20,height:20})})]}),l.jsxs("span",{"aria-hidden":r,style:{opacity:1-s},className:f.cn("col-start-1 row-start-1 flex items-center justify-between text-xl font-semibold leading-7 text-foreground",!i&&"transition-opacity duration-300"),children:[l.jsx("span",{children:t.label??"Total"}),l.jsx("span",{className:"whitespace-nowrap",children:ln(t.amount,n)})]})]})});vo.displayName="SummaryCollapseHeader";const wo=({cart:e,ariaLabel:t,onPress:n,className:r})=>l.jsxs("button",{type:"button","data-testid":"summary-cart","aria-label":t,onClick:n,className:f.cn("relative flex size-[52px] shrink-0 items-center justify-center rounded-full border border-default-200 bg-content1",r),children:[l.jsx(U,{icon:"lucide:shopping-bag",width:24,height:24,className:"text-foreground"}),e.count!=null&&l.jsx("span",{"data-testid":"summary-cart-badge",className:"absolute -right-1 -top-1 flex size-4 items-center justify-center rounded-full bg-primary text-xs text-primary-foreground",children:e.count})]});wo.displayName="SummaryCartButton";const ko=({open:e,progress:t,dragging:n,primaryAction:r,isLoading:s,cart:i,cartAriaLabel:a,onToggleOpen:o,classNames:c})=>l.jsxs("div",{"data-testid":"summary-mobile-bar",className:f.cn("flex flex-col gap-4",c.mobileBar),children:[l.jsx(f.Divider,{className:"bg-default-200"}),l.jsxs("div",{className:"grid",children:[l.jsxs("div",{"aria-hidden":e,style:{opacity:1-t},className:f.cn("col-start-1 row-start-1 flex items-stretch gap-2.5",e&&"pointer-events-none",!n&&"transition-opacity duration-300"),children:[i&&l.jsx(wo,{cart:i,ariaLabel:a,className:c.cart,onPress:()=>{o?.(),i.onPress?.()}}),r&&l.jsx(_n,{action:r,disabledByLoading:s,className:f.cn("flex-1",c.cta),testId:"summary-cta-compact"})]}),r&&l.jsx("div",{"aria-hidden":!e,style:{opacity:t},className:f.cn("col-start-1 row-start-1 flex",!e&&"pointer-events-none",!n&&"transition-opacity duration-300"),children:l.jsx(_n,{action:r,disabledByLoading:s,className:f.cn("w-full",c.cta)})})]})]});ko.displayName="SummaryActionBar";const tp="(max-width: 767px)",np=e=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(e).matches:!1,rp=(e=tp)=>{const[t,n]=y.useState(()=>np(e));return y.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const r=window.matchMedia(e),s=()=>n(r.matches);return s(),r.addEventListener("change",s),()=>r.removeEventListener("change",s)},[e]),t},No=({title:e="Summary",pricesInLabel:t="Prices are in",currency:n,locale:r="en-US",items:s,serviceFee:i,rows:a,total:o,collapsible:c,isOpen:d,onToggleOpen:u,primaryAction:h,isLoading:p=!1,onRemoveItem:m,variant:v,cart:b,emptyState:x,labels:w,classNames:S={},"data-testid":M="summary",className:N})=>{const j=w?.removeAriaLabel??"Remove item",T=w?.toggleAriaLabel??"Toggle summary",$=w?.cartAriaLabel??"View cart",W=rp(),R=c??(v??(W?"mobile":"main"))==="mobile",E=!R||(d??!1),[C,I]=y.useState(0),[F,H]=y.useState(null),Q=y.useCallback(G=>{G&&I(G.scrollHeight)},[]),Y=ep({open:E,fullHeight:C,setDragHeight:H,onToggleOpen:u}),te=F!==null,oe=Zm(F,E,C),ce=C>0?Math.min(1,Math.max(0,oe/C)):E?1:0,P=l.jsx(bo,{total:o,locale:r,className:S.total}),_=l.jsx(yo,{pricesInLabel:t,currency:n,items:s,serviceFee:i,rows:a,locale:r,onRemoveItem:m,removeAriaLabel:j,emptyState:x,classNames:S});return R?l.jsxs(Pe.motion.section,{"data-testid":M,drag:"y",dragConstraints:{top:0,bottom:0},dragElastic:.12,dragSnapToOrigin:!0,onDrag:Y.onDrag,onDragEnd:Y.onDragEnd,className:f.cn("fixed inset-x-0 bottom-0 z-50 flex w-full flex-col rounded-t-2xl bg-content1 p-4 drop-shadow-[0_-2px_2px_rgba(0,0,0,0.1)]",N,S.base),children:[l.jsx(vo,{title:e,total:o,locale:r,open:E,progress:ce,dragging:te,toggleAriaLabel:T,onToggleOpen:u,classNames:S}),l.jsx("div",{"data-testid":"summary-reveal","aria-hidden":!E,style:{height:oe},className:f.cn("overflow-hidden",!E&&"pointer-events-none",Xm(te)),children:l.jsxs("div",{ref:Q,className:"flex flex-col gap-4 pb-4",children:[_,l.jsx(f.Divider,{className:"bg-default-200"}),P]})}),l.jsx(ko,{open:E,progress:ce,dragging:te,primaryAction:h,isLoading:p,cart:b,cartAriaLabel:$,onToggleOpen:u,classNames:S})]}):l.jsxs("section",{"data-testid":M,className:f.cn("flex w-full flex-col gap-4 rounded-2xl border border-default-200 bg-content1 p-4",N,S.base),children:[l.jsx("div",{className:f.cn("flex items-center justify-between",S.header),children:l.jsx("h2",{"data-testid":"summary-title",className:f.cn("text-xl font-semibold leading-7 text-foreground",S.title),children:e})}),_,l.jsx(f.Divider,{className:"bg-default-200"}),P,h&&l.jsx(_n,{action:h,disabledByLoading:p,className:f.cn("w-full",S.cta)})]})};No.displayName="Summary";exports.Button=K;exports.CashTenderForm=Om;exports.CatalogItemCard=Kl;exports.CheckTenderForm=no;exports.CommitmentDetails=Nh;exports.ConfirmDialog=mo;exports.ConfirmationModal=Rn;exports.ConfirmationPageTemplate=Vo;exports.DonationAmounts=qa;exports.EmptyState=Jl;exports.ErrorState=Yl;exports.EventDetails=If;exports.EventDetailsTemplate=qo;exports.ExpireCartTimer=Wa;exports.FeedbackState=It;exports.FilterPopover=eo;exports.Footer=Wo;exports.HeroUIProvider=Fo;exports.InstallmentFundAssignment=xh;exports.InstallmentFundAssignmentSkeleton=wh;exports.InstallmentSchedule=Qh;exports.InstallmentScheduleSkeleton=rm;exports.InstallmentTable=im;exports.ItemCard=Wl;exports.LoadingOverlay=uo;exports.LoadingState=Gl;exports.MembershipSelectCards=cm;exports.ModalShell=io;exports.ModalShellFooter=lo;exports.ModalShellHeader=ao;exports.Multiselect=Ko;exports.Navbar=_o;exports.OfferCard=On;exports.OfferCardEmpty=ll;exports.OfferCardError=ol;exports.OfferCardList=fl;exports.OfferCardSkeleton=cl;exports.OtherTenderForm=ro;exports.PaymentCashChangeBanner=Cs;exports.PaymentSubAmountInput=ho;exports.PaymentSuccessView=fo;exports.PaymentTotalBanner=co;exports.RICH_TEXT_PRESETS=Ha;exports.RevenueDistributionCard=Sl;exports.RevenueDistributionEmpty=Cl;exports.RevenueDistributionError=jl;exports.RevenueDistributionSkeleton=Al;exports.RichTextArea=Ua;exports.Select=yt;exports.SessionTimeline=to;exports.SplitPaymentSummary=so;exports.Stepper=Yi;exports.SuccessState=Ql;exports.Summary=No;exports.TicketSelection=Cm;exports.TileSelect=oo;exports.Toggle=Zl;exports.calculateAllocationDifference=dh;exports.computeChange=Cr;exports.currencyFractionDigits=Gr;exports.formatMoney=rt;exports.formatOfferCurrency=al;exports.formatRevenueAmount=ah;exports.formatRevenueCurrency=lh;exports.generateAutomaticInstallments=Hl;exports.generateDistributionId=vs;exports.getCurrencySymbol=oh;exports.offerCardVariants=ul;exports.offerListVariants=dl;exports.parseOfferCurrency=$f;exports.parseRevenueCurrency=ch;exports.roundToCurrency=Gi;Object.keys(f).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>f[e]})});
45
45
  (function(){"use strict";try{if(typeof document<"u"){var r=document.createElement("style");r.appendChild(document.createTextNode('.ProseMirror{flex:1;width:100%;min-height:100%;height:100%;cursor:text;background-color:#fff;padding:1rem;overflow-y:auto;box-sizing:border-box}.ProseMirror p{min-height:1.5em}.dark .ProseMirror{background-color:rgb(var(--nextui-background))}.ProseMirror ul{list-style-type:disc!important;list-style-position:outside!important;padding-left:2rem!important;margin:1rem 0!important;display:block!important}.ProseMirror ol{list-style-type:decimal!important;list-style-position:outside!important;padding-left:2rem!important;margin:1rem 0!important;display:block!important}.ProseMirror ul li,.ProseMirror ol li{display:list-item!important;list-style:inherit!important;margin:.25rem 0!important}.ProseMirror ul li p,.ProseMirror ol li p{margin:0!important;display:inline!important}.ProseMirror ul[data-type=taskList]{list-style:none!important;padding-left:0!important;margin:1rem 0!important}.ProseMirror ul[data-type=taskList] li{display:flex!important;align-items:flex-start!important;margin:.5rem 0!important}.ProseMirror ul[data-type=taskList] li label{margin-right:.5rem;-webkit-user-select:none;-moz-user-select:none;user-select:none}.ProseMirror ul[data-type=taskList] li input[type=checkbox]{cursor:pointer;margin-top:.25rem}.ProseMirror h1,.ProseMirror h2,.ProseMirror h3,.ProseMirror h4,.ProseMirror h5,.ProseMirror h6{line-height:1.2!important;margin:1rem 0 .5rem!important;font-weight:600!important}.ProseMirror h1{font-size:2rem!important}.ProseMirror h2{font-size:1.5rem!important}.ProseMirror h3{font-size:1.25rem!important}.ProseMirror h4{font-size:1.1rem!important}.ProseMirror h5{font-size:1rem!important;font-weight:600!important}.ProseMirror h6{font-size:.9rem!important;font-weight:600!important}.ProseMirror code{background-color:rgb(var(--nextui-default-100));border-radius:.4rem;color:rgb(var(--nextui-default-800));font-size:.85rem;padding:.25em .3em}.ProseMirror pre{background:rgb(var(--nextui-default-900));border-radius:.5rem;color:rgb(var(--nextui-default-50));font-family:JetBrainsMono,monospace;margin:1.5rem 0;padding:.75rem 1rem;overflow-x:auto}.ProseMirror pre code{background:none;color:inherit;font-size:.8rem;padding:0}.ProseMirror mark{background-color:#faf594;border-radius:.4rem;-webkit-box-decoration-break:clone;box-decoration-break:clone;padding:.1rem .3rem}.ProseMirror blockquote{border-left:3px solid rgb(var(--nextui-default-300));margin:1.5rem 0;padding-left:1rem;color:rgb(var(--nextui-default-600))}.ProseMirror hr{border:none;border-top:1px solid rgb(var(--nextui-divider));margin:2rem 0}.ProseMirror a{color:rgb(var(--nextui-primary));text-decoration:underline;cursor:pointer}.ProseMirror a:hover{text-decoration:underline}.ProseMirror strong{font-weight:700!important}.ProseMirror em{font-style:italic!important}.ProseMirror s{text-decoration:line-through!important}.ProseMirror u{text-decoration:underline!important}.ProseMirror .has-text-align-left,.ProseMirror [style*="text-align: left"]{text-align:left!important}.ProseMirror .has-text-align-center,.ProseMirror [style*="text-align: center"]{text-align:center!important}.ProseMirror .has-text-align-right,.ProseMirror [style*="text-align: right"]{text-align:right!important}.ProseMirror .has-text-align-justify,.ProseMirror [style*="text-align: justify"]{text-align:justify!important}.ProseMirror ul li[style*="text-align: left"],.ProseMirror ol li[style*="text-align: left"]{text-align:left!important;list-style-position:inside!important}.ProseMirror ul li[style*="text-align: center"],.ProseMirror ol li[style*="text-align: center"]{text-align:center!important;list-style-position:inside!important}.ProseMirror ul li[style*="text-align: right"],.ProseMirror ol li[style*="text-align: right"]{text-align:right!important;list-style-position:inside!important}.ProseMirror ul li[style*="text-align: justify"],.ProseMirror ol li[style*="text-align: justify"]{text-align:justify!important;list-style-position:inside!important}.ProseMirror ul[data-type=taskList] li[style*="text-align: left"]{justify-content:flex-start!important}.ProseMirror ul[data-type=taskList] li[style*="text-align: center"]{justify-content:center!important}.ProseMirror ul[data-type=taskList] li[style*="text-align: right"]{justify-content:flex-end!important}.ProseMirror p.is-editor-empty:first-child:before{color:rgb(var(--nextui-default-400));content:attr(data-placeholder);float:left;height:0;pointer-events:none}')),document.head.appendChild(r)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();