@veevarts/design-system 1.0.0-alpha.3 → 1.0.0-alpha.31

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 (85) hide show
  1. package/README.md +59 -0
  2. package/dist/components/Button/Button.d.ts +4 -2
  3. package/dist/components/index.d.ts +13 -0
  4. package/dist/index.cjs +11 -11
  5. package/dist/index.d.ts +8 -12
  6. package/dist/index.js +6467 -2836
  7. package/dist/patterns/EventDetails/EventDetails.d.ts +37 -0
  8. package/dist/patterns/EventDetails/__test__/EventDetails.test.d.ts +1 -0
  9. package/dist/patterns/EventDetails/index.d.ts +2 -0
  10. package/dist/patterns/ExpireCartTimer/ExpireCartTimer.d.ts +249 -0
  11. package/dist/patterns/ExpireCartTimer/__test__/ExpireCartTimer.test.d.ts +4 -0
  12. package/dist/patterns/ExpireCartTimer/index.d.ts +1 -0
  13. package/dist/patterns/Footer/__test__/Footer.test.d.ts +1 -0
  14. package/dist/patterns/Multiselect/Multiselect.d.ts +2 -0
  15. package/dist/patterns/Multiselect/__test__/Multiselect.test.d.ts +4 -0
  16. package/dist/patterns/Multiselect/index.d.ts +2 -0
  17. package/dist/patterns/Multiselect/types.d.ts +7 -0
  18. package/dist/patterns/Navbar/Navbar.d.ts +23 -7
  19. package/dist/patterns/Navbar/__test__/Navbar.test.d.ts +1 -0
  20. package/dist/patterns/OfferCard/OfferCard.d.ts +12 -0
  21. package/dist/patterns/OfferCard/__test__/OfferCard.test.d.ts +1 -0
  22. package/dist/patterns/OfferCard/examples/CustomQuantitySelectorExample.d.ts +1 -0
  23. package/dist/patterns/OfferCard/examples/ListWithEurosCurrencyExample.d.ts +1 -0
  24. package/dist/patterns/OfferCard/examples/ListWithoutAnimationExample.d.ts +1 -0
  25. package/dist/patterns/OfferCard/examples/index.d.ts +3 -0
  26. package/dist/patterns/OfferCard/index.d.ts +10 -0
  27. package/dist/patterns/OfferCard/types.d.ts +483 -0
  28. package/dist/patterns/OfferCard/utils/animations.d.ts +42 -0
  29. package/dist/patterns/OfferCard/utils/currency.d.ts +26 -0
  30. package/dist/patterns/OfferCard/utils/index.d.ts +3 -0
  31. package/dist/patterns/OfferCard/utils/offers.d.ts +3 -0
  32. package/dist/patterns/OfferCard/variants/OfferCardEmpty.d.ts +12 -0
  33. package/dist/patterns/OfferCard/variants/OfferCardError.d.ts +12 -0
  34. package/dist/patterns/OfferCard/variants/OfferCardList.d.ts +12 -0
  35. package/dist/patterns/OfferCard/variants/OfferCardSkeleton.d.ts +12 -0
  36. package/dist/patterns/OfferCard/variants/index.d.ts +4 -0
  37. package/dist/patterns/RevenueDistribution/RevenueDistributionCard.d.ts +16 -0
  38. package/dist/patterns/RevenueDistribution/__test__/RevenueDistributionCard.test.d.ts +1 -0
  39. package/dist/patterns/RevenueDistribution/examples/InteractiveExample.d.ts +8 -0
  40. package/dist/patterns/RevenueDistribution/examples/MultipleDistributionsFormExample.d.ts +10 -0
  41. package/dist/patterns/RevenueDistribution/examples/WithGlAccountSearchExample.d.ts +7 -0
  42. package/dist/patterns/RevenueDistribution/examples/index.d.ts +9 -0
  43. package/dist/patterns/RevenueDistribution/index.d.ts +12 -0
  44. package/dist/patterns/RevenueDistribution/types.d.ts +394 -0
  45. package/dist/patterns/RevenueDistribution/utils/amount.d.ts +56 -0
  46. package/dist/patterns/RevenueDistribution/utils/data.d.ts +4 -0
  47. package/dist/patterns/RevenueDistribution/utils/index.d.ts +5 -0
  48. package/dist/patterns/RevenueDistribution/variants/RevenueDistributionEmpty.d.ts +11 -0
  49. package/dist/patterns/RevenueDistribution/variants/RevenueDistributionError.d.ts +11 -0
  50. package/dist/patterns/RevenueDistribution/variants/RevenueDistributionSkeleton.d.ts +11 -0
  51. package/dist/patterns/RevenueDistribution/variants/index.d.ts +3 -0
  52. package/dist/patterns/RichText/TipTapArea/TipTapArea.d.ts +1 -1
  53. package/dist/patterns/RichText/index.d.ts +1 -0
  54. package/dist/patterns/RichText/types/extensions.d.ts +2 -1
  55. package/dist/patterns/RichText/types/props.d.ts +12 -1
  56. package/dist/patterns/RichText/utils/index.d.ts +1 -0
  57. package/dist/patterns/RichText/utils/inlineStyles.d.ts +31 -0
  58. package/dist/patterns/Stepper/Stepper.d.ts +13 -1
  59. package/dist/patterns/index.d.ts +13 -3
  60. package/dist/styles.css +98 -0
  61. package/dist/tailwind/index.d.ts +541 -0
  62. package/dist/tailwind/index.js +293 -0
  63. package/dist/test/framer-motion-mock.d.ts +92 -0
  64. package/dist/test/heroui-dom-animation-mock.d.ts +4 -0
  65. package/dist/test/heroui-framer-utils-mock.d.ts +102 -0
  66. package/dist/theme/index.d.ts +26 -2
  67. package/dist/tokens/colors.d.ts +72 -7
  68. package/package.json +34 -14
  69. package/public/fonts/neue-montreal/Icon/r +0 -0
  70. package/public/fonts/neue-montreal/PPNeueMontreal-Bold.woff +0 -0
  71. package/public/fonts/neue-montreal/PPNeueMontreal-Bold.woff2 +0 -0
  72. package/public/fonts/neue-montreal/PPNeueMontreal-BoldItalic.woff +0 -0
  73. package/public/fonts/neue-montreal/PPNeueMontreal-BoldItalic.woff2 +0 -0
  74. package/public/fonts/neue-montreal/PPNeueMontreal-Italic.woff +0 -0
  75. package/public/fonts/neue-montreal/PPNeueMontreal-Italic.woff2 +0 -0
  76. package/public/fonts/neue-montreal/PPNeueMontreal-Regular.woff +0 -0
  77. package/public/fonts/neue-montreal/PPNeueMontreal-Regular.woff2 +0 -0
  78. package/public/fonts/neue-montreal/PPNeueMontreal-SemiBold.woff +0 -0
  79. package/public/fonts/neue-montreal/PPNeueMontreal-SemiBold.woff2 +0 -0
  80. package/public/fonts/scholar/Scholar-Italic.woff +0 -0
  81. package/public/fonts/scholar/Scholar-Italic.woff2 +0 -0
  82. package/public/fonts/scholar/Scholar-Regular.woff +0 -0
  83. package/public/fonts/scholar/Scholar-Regular.woff2 +0 -0
  84. /package/dist/{patterns/Footer/Footer.test.d.ts → components/Button/Button.test.d.ts} +0 -0
  85. /package/dist/patterns/DonationAmounts/{DonationAmounts.test.d.ts → __test__/DonationAmounts.test.d.ts} +0 -0
package/dist/index.cjs CHANGED
@@ -1,20 +1,20 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react/jsx-runtime"),x=require("@heroui/react"),C=require("react"),Oe=require("framer-motion"),Kt=require("@tiptap/react"),k=require("lucide-react"),m=require("@tiptap/core"),$r=require("@tiptap/extension-underline"),qr=require("@tiptap/extension-color"),Vr=require("@tiptap/extension-highlight"),Jr=require("@tiptap/extension-link"),Kr=require("@tiptap/extension-task-list"),Ur=require("@tiptap/extension-task-item"),Wr=require("@tiptap/extension-text-align"),we={brand:{primary:"#C14615",secondary:"#000000",accent:"#F59E0B"},semantic:{success:"#10B981",warning:"#F59E0B",error:"#EF4444",info:"#3B82F6"},neutral:{white:"#FFFFFF",black:"#000000",gray:{50:"#F9FAFB",100:"#F3F4F6",200:"#E5E7EB",300:"#D1D5DB",400:"#9CA3AF",500:"#6B7280",600:"#4B5563",700:"#374151",800:"#1F2937",900:"#111827"}}},_r={xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem","2xl":"3rem","3xl":"4rem","4xl":"6rem","5xl":"8rem"},Zr={fontFamily:{primary:'"NeueMontreal", system-ui, sans-serif',secondary:'"Scholar", Georgia, serif',sans:'"NeueMontreal", system-ui, sans-serif',serif:'"Scholar", Georgia, serif',mono:'"JetBrains Mono", Consolas, monospace'},fontSize:{xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem","4xl":"2.25rem","5xl":"3rem"},fontWeight:{normal:"400",semibold:"600",bold:"700"},lineHeight:{tight:"1.25",normal:"1.5",relaxed:"1.75"}},Gr={colors:{primary:{50:"#fef5f1",100:"#fde8e0",200:"#fbd5c7",300:"#f7b79f",400:"#f18d68",500:we.brand.primary,600:"#a83b11",700:"#8b2f0e",800:"#73260d",900:"#5f210c",DEFAULT:we.brand.primary},secondary:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:we.brand.secondary,600:"#000000",700:"#000000",800:"#000000",900:"#000000",DEFAULT:we.brand.secondary}}};function Xr({children:n}){return f.jsx(x.HeroUIProvider,{children:n})}function Yr({color:n="primary",radius:e="full",...t}){return f.jsx(x.Button,{color:n,radius:e,...t})}function Qr(n){return f.jsx("div",{className:"w-full p-8",children:f.jsx("div",{className:"container mx-auto flex items-center justify-center",children:f.jsx(x.Alert,{description:"This component needs to be implemented using HeroUI Navbar, NavbarBrand, NavbarContent, and NavbarItem components. Include logo, navigation links, language selector dropdown, and authentication state.",title:"TODO: Implement Navbar Pattern",variant:"faded"})})})}var bt;const es=typeof document<"u"?(bt=C.useInsertionEffect)!==null&&bt!==void 0?bt:C.useLayoutEffect:()=>{};function jn(n,e,t){let[r,s]=C.useState(n||e),i=C.useRef(r),o=C.useRef(n!==void 0),l=n!==void 0;C.useEffect(()=>{let d=o.current;d!==l&&process.env.NODE_ENV!=="production"&&console.warn(`WARN: A component changed from ${d?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}.`),o.current=l},[l]);let a=l?n:r;es(()=>{i.current=a});let[,c]=C.useReducer(()=>({}),{}),u=C.useCallback((d,...h)=>{let p=typeof d=="function"?d(i.current):d;Object.is(i.current,p)||(i.current=p,s(p),c(),t?.(p,...h))},[t]);return[a,u]}function ts(n){return f.jsx("svg",{...n,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:f.jsx(Oe.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 $n=C.forwardRef(({color:n="primary",stepsCount:e=3,defaultStep:t=0,label:r,onStepChange:s,currentStep:i,hideProgressBars:o=!1,stepClassName:l,className:a,...c},u)=>{const[d,h]=jn(i,t,s),p=C.useMemo(()=>{let g,y;const b=["[--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(n){case"primary":g="[--step-color:var(--heroui-primary)]",y="[--step-fg-color:var(--heroui-primary-foreground)]";break;case"secondary":g="[--step-color:var(--heroui-secondary)]",y="[--step-fg-color:var(--heroui-secondary-foreground)]";break;case"success":g="[--step-color:var(--heroui-success)]",y="[--step-fg-color:var(--heroui-success-foreground)]";break;case"warning":g="[--step-color:var(--heroui-warning)]",y="[--step-fg-color:var(--heroui-warning-foreground)]";break;case"danger":g="[--step-color:var(--heroui-danger)]",y="[--step-fg-color:var(--heroui-danger-foreground)]";break;case"default":g="[--step-color:var(--heroui-default)]",y="[--step-fg-color:var(--heroui-default-foreground)]";break;default:g="[--step-color:var(--heroui-primary)]",y="[--step-fg-color:var(--heroui-primary-foreground)]";break}return b.unshift(y),b.unshift(g),b},[n]);return f.jsxs("nav",{ref:u,"aria-label":"Progress",className:x.cn("flex max-w-fit items-center overflow-x-auto",a),...c,children:[r&&f.jsx("label",{className:"text-small text-default-foreground lg:text-medium font-light w-full me-3",children:r}),f.jsx("ol",{className:x.cn("flex flex-row flex-nowrap gap-x-3",p,a),children:Array.from({length:e})?.map((g,y)=>{const b=d===y?"active":d<y?"inactive":"complete";return f.jsx("li",{className:"relative flex w-full items-center pr-12",children:f.jsxs("button",{"aria-current":b==="active"?"step":void 0,className:x.cn("group rounded-large flex w-full cursor-pointer flex-row items-center justify-center gap-x-3 py-2.5",l),onClick:()=>h(y),children:[f.jsx("div",{className:"h-full relative flex items-center",children:f.jsx(Oe.LazyMotion,{features:Oe.domAnimation,children:f.jsx(Oe.m.div,{animate:b,className:"relative",children:f.jsx(Oe.m.div,{animate:b,className:x.cn("border-medium text-large text-default-foreground relative flex h-[26px] w-[26px] items-center justify-center rounded-full font-semibold",{"shadow-lg":b==="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:f.jsx("div",{className:"flex items-center justify-center",children:b==="complete"?f.jsx(ts,{className:"h-5 w-5 text-(--active-fg-color)"}):f.jsx("span",{})})})})})}),y<e-1&&!o&&f.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:f.jsx("div",{className:x.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<d})})})]},y)},y)})})]})});$n.displayName="Stepper";function ns(){return f.jsxs("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()]})}function Pe(n){return typeof n=="string"?n:n.type}function fe({className:n}){return f.jsx("div",{className:`flex items-center h-6 ${n||""}`,children:f.jsx(x.Divider,{orientation:"vertical"})})}function re({icon:n,label:e,isActive:t=!1,isDisabled:r=!1,onClick:s,shortcut:i,iconSize:o=16,className:l}){const a=i?`${e} (${i})`:e;return f.jsx(x.Tooltip,{content:a,children:f.jsx(x.Button,{size:"sm",radius:"sm",color:t?"primary":"default",variant:t?"solid":"bordered",isIconOnly:!0,isDisabled:r,onPress:s,"aria-label":e,className:l,children:f.jsx(n,{size:o})})})}const te={bold:{execute:({editor:n})=>n.chain().focus().toggleBold().run(),canExecute:n=>n.can().chain().focus().toggleBold().run(),isActive:n=>n.isActive("bold"),shortcut:"Mod-b",label:"Bold"},italic:{execute:({editor:n})=>n.chain().focus().toggleItalic().run(),canExecute:n=>n.can().chain().focus().toggleItalic().run(),isActive:n=>n.isActive("italic"),shortcut:"Mod-i",label:"Italic"},strike:{execute:({editor:n})=>n.chain().focus().toggleStrike().run(),canExecute:n=>n.can().chain().focus().toggleStrike().run(),isActive:n=>n.isActive("strike"),shortcut:"Mod-Shift-x",label:"Strikethrough"},underline:{execute:({editor:n})=>n.chain().focus().toggleUnderline().run(),canExecute:n=>n.can().chain().focus().toggleUnderline().run(),isActive:n=>n.isActive("underline"),shortcut:"Mod-u",label:"Underline"},code:{execute:({editor:n})=>n.chain().focus().toggleCode().run(),canExecute:n=>n.can().chain().focus().toggleCode().run(),isActive:n=>n.isActive("code"),shortcut:"Mod-e",label:"Inline code"},textColor:{execute:({editor:n,config:e})=>{const t=e?.type==="textColor"?e.color:"";t?n.chain().focus().setColor(t).run():n.chain().focus().unsetColor().run()},canExecute:()=>!0,isActive:n=>n.isActive("textStyle"),label:"Text color"},highlight:{execute:({editor:n,config:e})=>{const t=e?.type==="highlight"?e.color:"";t?n.chain().focus().setHighlight({color:t}).run():n.chain().focus().unsetHighlight().run()},canExecute:()=>!0,isActive:n=>n.isActive("highlight"),label:"Highlight"},link:{execute:({editor:n,config:e})=>{const t=e?.type==="link"?e.href:"";if(t){const r=e?.type==="link"?e.target:void 0,s=e?.type==="link"?e.rel:void 0;n.chain().focus().setLink({href:t,target:r,rel:s}).run()}else n.chain().focus().unsetLink().run()},canExecute:()=>!0,isActive:n=>n.isActive("link"),shortcut:"Mod-k",label:"Link"},paragraph:{execute:({editor:n})=>n.chain().focus().setParagraph().run(),canExecute:n=>n.can().chain().focus().setParagraph().run(),isActive:n=>n.isActive("paragraph"),shortcut:"Mod-Alt-0",label:"Paragraph"},heading:{execute:({editor:n,config:e})=>{const t=e?.type==="heading"?e.level:1;n.chain().focus().toggleHeading({level:t}).run()},canExecute:(n,e)=>{const t=e?.type==="heading"?e.level:1;return n.can().chain().focus().toggleHeading({level:t}).run()},isActive:(n,e)=>e?.type==="heading"?n.isActive("heading",{level:e.level}):n.isActive("heading"),label:"Heading"},bulletList:{execute:({editor:n})=>n.chain().focus().toggleBulletList().run(),canExecute:n=>n.can().chain().focus().toggleBulletList().run(),isActive:n=>n.isActive("bulletList"),shortcut:"Mod-Shift-8",label:"Bullet list"},orderedList:{execute:({editor:n})=>n.chain().focus().toggleOrderedList().run(),canExecute:n=>n.can().chain().focus().toggleOrderedList().run(),isActive:n=>n.isActive("orderedList"),shortcut:"Mod-Shift-7",label:"Numbered list"},taskList:{execute:({editor:n})=>n.chain().focus().toggleTaskList().run(),canExecute:n=>n.can().chain().focus().toggleTaskList().run(),isActive:n=>n.isActive("taskList"),label:"Task list"},codeBlock:{execute:({editor:n})=>n.chain().focus().toggleCodeBlock().run(),canExecute:n=>n.can().chain().focus().toggleCodeBlock().run(),isActive:n=>n.isActive("codeBlock"),shortcut:"Mod-Alt-c",label:"Code block"},blockquote:{execute:({editor:n})=>n.chain().focus().toggleBlockquote().run(),canExecute:n=>n.can().chain().focus().toggleBlockquote().run(),isActive:n=>n.isActive("blockquote"),shortcut:"Mod-Shift-b",label:"Blockquote"},horizontalRule:{execute:({editor:n})=>n.chain().focus().setHorizontalRule().run(),canExecute:n=>n.can().chain().focus().setHorizontalRule().run(),isActive:()=>!1,label:"Horizontal rule"},hardBreak:{execute:({editor:n})=>n.chain().focus().setHardBreak().run(),canExecute:n=>n.can().chain().focus().setHardBreak().run(),isActive:()=>!1,shortcut:"Mod-Enter",label:"Line break"},textAlign:{execute:({editor:n,config:e})=>{const t=e?.type==="textAlign"?e.alignment:"left";n.chain().focus().setTextAlign(t).run()},canExecute:()=>!0,isActive:(n,e)=>e?.type==="textAlign"?n.isActive({textAlign:e.alignment}):!1,label:"Text alignment"},clearMarks:{execute:({editor:n})=>n.chain().focus().unsetAllMarks().run(),canExecute:n=>n.can().chain().focus().unsetAllMarks().run(),isActive:()=>!1,label:"Clear formatting"},clearNodes:{execute:({editor:n})=>n.chain().focus().clearNodes().run(),canExecute:n=>n.can().chain().focus().clearNodes().run(),isActive:()=>!1,label:"Clear nodes"},undo:{execute:({editor:n})=>n.chain().focus().undo().run(),canExecute:n=>n.can().chain().focus().undo().run(),isActive:()=>!1,shortcut:"Mod-z",label:"Undo"},redo:{execute:({editor:n})=>n.chain().focus().redo().run(),canExecute:n=>n.can().chain().focus().redo().run(),isActive:()=>!1,shortcut:"Mod-Shift-z",label:"Redo"}},rs={1:"Heading 1",2:"Heading 2",3:"Heading 3",4:"Heading 4",5:"Heading 5",6:"Heading 6"};function ss({editor:n,levels:e=[1,2,3,4,5,6],isDisabled:t=!1}){const[,r]=C.useState(0);C.useEffect(()=>{const o=()=>r(l=>l+1);return n.on("selectionUpdate",o),n.on("transaction",o),()=>{n.off("selectionUpdate",o),n.off("transaction",o)}},[n]);const s=e.find(o=>n.isActive("heading",{level:o})),i=o=>{const l=Number(o),a=te.heading;a&&a.execute({editor:n,config:{type:"heading",level:l}})};return f.jsxs(x.Dropdown,{children:[f.jsx(x.DropdownTrigger,{children:f.jsx(x.Button,{size:"sm",radius:"sm",variant:s?"solid":"bordered",color:s?"primary":"default",isDisabled:t,startContent:f.jsx(k.Heading,{size:16}),"aria-label":"Select heading level",children:s?`H${s}`:"H"})}),f.jsx(x.DropdownMenu,{"aria-label":"Heading levels",selectionMode:"single",selectedKeys:s?new Set([String(s)]):new Set,onAction:i,children:e.map(o=>f.jsx(x.DropdownItem,{startContent:n.isActive("heading",{level:o})?f.jsx(k.Check,{size:16}):f.jsx("div",{className:"w-4"}),children:rs[o]},o))})]})}const kt={bulletList:{label:"Bullet List",icon:k.List},orderedList:{label:"Numbered List",icon:k.ListOrdered},taskList:{label:"Task List",icon:k.ListTodo}};function is({editor:n,types:e=["bulletList","orderedList","taskList"],isDisabled:t=!1}){const[,r]=C.useState(0);C.useEffect(()=>{const l=()=>r(a=>a+1);return n.on("selectionUpdate",l),n.on("transaction",l),()=>{n.off("selectionUpdate",l),n.off("transaction",l)}},[n]);const s=e.find(l=>n.isActive(l)),i=s?kt[s].icon:k.List,o=l=>{const c=te[l];c&&c.execute({editor:n})};return f.jsxs(x.Dropdown,{children:[f.jsx(x.DropdownTrigger,{children:f.jsx(x.Button,{size:"sm",radius:"sm",variant:s?"solid":"bordered",color:s?"primary":"default",isDisabled:t,isIconOnly:!0,"aria-label":"Select list type",children:f.jsx(i,{size:16})})}),f.jsx(x.DropdownMenu,{"aria-label":"List types",selectionMode:"single",selectedKeys:s?new Set([s]):new Set,onAction:o,children:e.map(l=>{const a=kt[l].icon;return f.jsx(x.DropdownItem,{startContent:f.jsx(a,{size:16}),children:kt[l].label},l)})})]})}function os({colors:n,selectedColor:e,onColorSelect:t,columns:r=4}){return f.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:`repeat(${r}, minmax(0, 1fr))`},children:n.map(s=>{const i=e===s;return f.jsx("button",{type:"button",onClick:()=>t(s),className:`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),y=require("@heroui/react"),v=require("react"),_=require("lucide-react"),Re=require("framer-motion"),hr=require("@tiptap/react"),R=require("@tiptap/core"),Fo=require("@tiptap/extension-underline"),Po=require("@tiptap/extension-color"),$o=require("@tiptap/extension-highlight"),Vo=require("@tiptap/extension-link"),Bo=require("@tiptap/extension-task-list"),zo=require("@tiptap/extension-task-item"),_o=require("@tiptap/extension-text-align");function Ho({children:t}){return c.jsx(y.HeroUIProvider,{children:t})}const oe=v.forwardRef(({color:t="primary",radius:e="full",testId:n="veevart-button",...r},s)=>c.jsx(y.Button,{ref:s,color:t,radius:e,"data-testid":n,...r}));oe.displayName="Button";const Uo={login:"Login",logout:"Logout",selectLanguage:"Select your language"};function qo({languages:t,selectedLanguage:e,onLanguageChange:n,label:r}){return c.jsx("div",{className:"flex items-center",children:c.jsxs("div",{className:"relative flex items-center",children:[c.jsx(_.Globe,{className:"absolute left-3 w-5 h-5 pointer-events-none text-black"}),c.jsx(y.Select,{"data-testid":"language-select-desktop","aria-label":r,selectedKeys:e?[e]:[],onSelectionChange:s=>{const i=Array.from(s)[0]||e;n?.(i)},className:"min-w-40 hidden md:inline-flex",isDisabled:t.length===0,placeholder:r,startContent:c.jsx(_.Globe,{className:"w-5 h-5 text-black"}),children:t.map(s=>c.jsx(y.SelectItem,{textValue:s.label,"data-testid":`language-select-option-${s.code}`,children:s.label},s.code))}),c.jsx(y.Select,{"aria-label":r,"data-testid":"language-select-mobile",selectedKeys:e?[e]:[],onSelectionChange:s=>{const i=Array.from(s)[0]||e;n?.(i)},className:"min-w-20 inline-flex md:hidden",isDisabled:t.length===0,placeholder:e||"Language",children:t.map(s=>c.jsx(y.SelectItem,{className:"min-w-4",textValue:s.code.toUpperCase(),"data-testid":`language-select-option-mobile-${s.code}`,children:s.code.toUpperCase()},s.code))})]})})}function Ko({isLoggedIn:t,onLogin:e,onLogout:n,labels:r}){return t?c.jsxs(oe,{"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,children:[c.jsx(_.User,{className:"inline w-5 h-5"}),c.jsx("span",{className:"hidden md:inline",children:r.logout})]}):c.jsxs(oe,{"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,children:[c.jsx(_.User,{className:"inline w-5 h-5"}),c.jsx("span",{className:"hidden md:inline",children:r.login})]})}function Jo({logo:t,languages:e=[],selectedLanguage:n,onLanguageChange:r,isLoggedIn:s,onLogin:i,onLogout:o,hasLanguages:l,hasAuth:a,labels:u={},className:d}){const f={...Uo,...u};return c.jsxs("nav",{"data-testid":"navbar",className:y.cn("w-full px-4 md:px-8 py-4 bg-white border-b border-zinc-100 flex items-center justify-between",d),children:[c.jsx("div",{className:"flex items-center min-w-10",children:t&&c.jsx("a",{href:"/",className:"block",children:c.jsx("img",{"data-testid":"navbar-logo",src:t,alt:"Logo",className:"h-8 max-w-28 md:max-w-40"})})}),c.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[(l||e.length>0)&&c.jsx(qo,{languages:e,selectedLanguage:n,onLanguageChange:r,label:f.selectLanguage}),a&&c.jsx(Ko,{isLoggedIn:s,onLogin:i,onLogout:o,labels:f})]})]})}function Wo(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(y.Alert,{description:"This template combines Navbar, Footer, and a confirmation Card. Include title, message, confirmation number, details list, icon, and action buttons. Use Card for the confirmation content.",title:"TODO: Implement ConfirmationPageTemplate",variant:"faded",className:"max-w-2xl"})})})}var Mn;const Go=typeof document<"u"?(Mn=v.useInsertionEffect)!==null&&Mn!==void 0?Mn:v.useLayoutEffect:()=>{};function pr(t,e,n){let[r,s]=v.useState(t||e),i=v.useRef(r),o=v.useRef(t!==void 0),l=t!==void 0;v.useEffect(()=>{let f=o.current;f!==l&&process.env.NODE_ENV!=="production"&&console.warn(`WARN: A component changed from ${f?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}.`),o.current=l},[l]);let a=l?t:r;Go(()=>{i.current=a});let[,u]=v.useReducer(()=>({}),{}),d=v.useCallback((f,...p)=>{let m=typeof f=="function"?f(i.current):f;Object.is(i.current,m)||(i.current=m,s(m),u(),n?.(m,...p))},[n]);return[a,d]}function Zo(t){return c.jsx("svg",{...t,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:c.jsx(Re.m.path,{animate:{pathLength:1},d:"M5 13l4 4L19 7",initial:{pathLength:0},strokeLinecap:"round",strokeLinejoin:"round",transition:{delay:.2,type:"tween",ease:"easeOut",duration:.3}})})}const Zs=v.forwardRef(({color:t="primary",stepsCount:e=3,defaultStep:n=0,label:r,onStepChange:s,currentStep:i,hideProgressBars:o=!1,stepClassName:l,className:a,isDisabled:u=!1,...d},f)=>{const[p,m]=pr(i,n,s),C=v.useMemo(()=>{let b,k;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":b="[--step-color:var(--heroui-primary)]",k="[--step-fg-color:var(--heroui-primary-foreground)]";break;case"secondary":b="[--step-color:var(--heroui-secondary)]",k="[--step-fg-color:var(--heroui-secondary-foreground)]";break;case"success":b="[--step-color:var(--heroui-success)]",k="[--step-fg-color:var(--heroui-success-foreground)]";break;case"warning":b="[--step-color:var(--heroui-warning)]",k="[--step-fg-color:var(--heroui-warning-foreground)]";break;case"danger":b="[--step-color:var(--heroui-danger)]",k="[--step-fg-color:var(--heroui-danger-foreground)]";break;case"default":b="[--step-color:var(--heroui-default)]",k="[--step-fg-color:var(--heroui-default-foreground)]";break;default:b="[--step-color:var(--heroui-primary)]",k="[--step-fg-color:var(--heroui-primary-foreground)]";break}return S.unshift(k),S.unshift(b),S},[t]);return c.jsxs("nav",{ref:f,"aria-label":"Progress",className:y.cn("flex max-w-fit items-center overflow-x-auto",a),"data-testid":"stepper-root",...d,children:[r&&c.jsx("label",{className:"text-small text-default-foreground lg:text-medium font-light w-full me-3","data-testid":"stepper-label",children:r}),c.jsx("ol",{className:y.cn("flex flex-row flex-nowrap gap-x-3",C,a),"data-testid":"stepper-list",children:Array.from({length:e})?.map((b,k)=>{const S=p===k?"active":p<k?"inactive":"complete";return c.jsx("li",{className:"relative flex w-full items-center pr-12","data-testid":`stepper-step-${k}`,children:c.jsxs("button",{"aria-current":S==="active"?"step":void 0,className:y.cn("group rounded-large flex w-full cursor-pointer flex-row items-center justify-center gap-x-3 py-2.5",{"cursor-not-allowed opacity-50":u},l),onClick:()=>!u&&m(k),disabled:u,"data-testid":`stepper-step-btn-${k}`,children:[c.jsx("div",{className:"h-full relative flex items-center",children:c.jsx(Re.LazyMotion,{features:Re.domAnimation,children:c.jsx(Re.m.div,{animate:S,className:"relative",children:c.jsx(Re.m.div,{animate:S,className:y.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(Zo,{className:"h-5 w-5 text-(--active-fg-color)","data-testid":`stepper-step-check-${k}`}):c.jsx("span",{})})})})})}),k<e-1&&!o&&c.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 left-[26px] w-[calc(100%-13px)] flex-none items-center",style:{"--idx":k},children:c.jsx("div",{className:y.cn("bg-default-200 relative h-0.5 w-full transition-colors duration-300","after:absolute after:block after:h-full after:w-0 after:bg-(--active-border-color) after:transition-[width] after:duration-300 after:content-['']",{"after:w-full":k<p})})})]},k)},k)})})]})});Zs.displayName="Stepper";function Qo(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(y.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 Xo(){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 Yo=t=>{const e=v.useMemo(()=>JSON.stringify({allItems:t.allItems,selected:t.selected}),[t.allItems,t.selected]);return c.jsx(el,{...t},e)},el=({allItems:t,selected:e,onSelectedChange:n,titleLeft:r,titleRight:s})=>{const[i,o]=v.useState([]),[l,a]=v.useState([]),[u,d]=v.useState(null),[f,p]=v.useState(null),m=v.useMemo(()=>new Set(e),[e]),C=v.useMemo(()=>new Set(t),[t]),b=v.useMemo(()=>t.filter(P=>!m.has(P)),[t,m]),k=P=>{if(P.length===0)return;const M=Array.from(new Set([...e,...P]));n(M)},S=P=>{if(P.length===0)return;const M=new Set(P);n(e.filter(F=>!M.has(F)))},w=()=>{i.length!==0&&(k(i),o([]))},j=()=>{l.length!==0&&(S(l),a([]))},N=()=>{b.length!==0&&(k(b),o([]))},D=()=>{e.length!==0&&(n([]),a([]))},L=(P,M,F)=>{const $=Math.min(M,F),B=Math.max(M,F);return P.slice($,B+1)},O=(P,M,F)=>{if(F&&u!==null){o(L(b,u,M)),a([]),d(M);return}const $=i.includes(P);o($?i.filter(B=>B!==P):[...i,P]),a([]),d(M)},z=(P,M,F)=>{if(F&&f!==null){a(L(e,f,M)),o([]),p(M);return}const $=l.includes(P);a($?l.filter(B=>B!==P):[...l,P]),o([]),p(M)},H=(P,M,F)=>{const $=F==="available"?i.includes(M)?i:[M]:l.includes(M)?l:[M];P.dataTransfer.setData("text/plain",JSON.stringify({source:F,items:$})),P.dataTransfer.effectAllowed="move"},U=(P,M)=>{P.preventDefault();const F=P.dataTransfer.getData("text/plain");if(F)try{const $=JSON.parse(F),B=($.items||[]).filter(Y=>C.has(Y));if(B.length===0||$.source===M)return;M==="selected"?(k(B),o([])):(S(B),a([]))}catch{return}};return c.jsxs("div",{className:"flex flex-col gap-6 md:flex-row md:items-start md:justify-between",children:[c.jsxs("div",{className:"flex w-full flex-col gap-3 md:w-2/5",children:[c.jsx("h2",{className:"text-sm font-medium text-gray-700",children:r}),c.jsx(y.Card,{className:"w-full border border-gray-200 shadow-none",children:c.jsx(y.CardBody,{className:"h-60 gap-2 overflow-y-auto",onDragOver:P=>P.preventDefault(),onDrop:P=>U(P,"available"),children:b.map((P,M)=>{const F=i.includes(P);return c.jsx("button",{type:"button",onClick:$=>{O(P,M,$.shiftKey)},onMouseDown:$=>{$.shiftKey&&$.preventDefault()},draggable:!0,onDragStart:$=>H($,P,"available"),className:`rounded-md px-3 py-2 text-left text-sm transition ${F?"bg-[#E4571E]/10 text-[#E4571E]":"text-gray-700 hover:bg-gray-100"}`,children:P},P)})})})]}),c.jsxs("div",{className:"flex flex-row items-center justify-center gap-3 md:flex-col md:pt-6",children:[c.jsx(oe,{variant:"light",className:"h-10 w-10 min-w-0 text-2xl font-semibold text-[#E4571E] hover:bg-[#E4571E]/10",isIconOnly:!0,"data-testid":"move-selected-to-available",onPress:w,isDisabled:i.length===0,"aria-label":"Move selected to right",children:"›"}),c.jsx(oe,{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:l.length===0,"aria-label":"Move selected to left",children:"‹"}),c.jsx(oe,{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:"»"}),c.jsx(oe,{variant:"light",className:"h-10 w-10 min-w-0 text-2xl font-semibold text-[#E4571E] hover:bg-[#E4571E]/10",isIconOnly:!0,onPress:D,"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(y.Card,{className:"w-full border border-gray-200 shadow-none",children:c.jsx(y.CardBody,{className:"h-60 gap-2 overflow-y-auto",onDragOver:P=>P.preventDefault(),onDrop:P=>U(P,"selected"),children:e.map((P,M)=>{const F=l.includes(P);return c.jsx("button",{type:"button",onClick:$=>{z(P,M,$.shiftKey)},onMouseDown:$=>{$.shiftKey&&$.preventDefault()},draggable:!0,onDragStart:$=>H($,P,"selected"),className:`rounded-md px-3 py-2 text-left text-sm transition ${F?"bg-[#E4571E]/10 text-[#E4571E]":"text-gray-700 hover:bg-gray-100"}`,children:P},P)})})})]})]})};function Rt(t){return typeof t=="string"?t:t.type}function nt({className:t}){return c.jsx("div",{className:`flex items-center h-6 ${t||""}`,children:c.jsx(y.Divider,{orientation:"vertical"})})}function We({icon:t,label:e,isActive:n=!1,isDisabled:r=!1,onClick:s,shortcut:i,iconSize:o=16,className:l}){const a=i?`${e} (${i})`:e;return c.jsx(y.Tooltip,{content:a,placement:"top",offset:10,children:c.jsx(oe,{size:"sm",radius:"sm",color:n?"primary":"default",variant:n?"solid":"bordered",isIconOnly:!0,isDisabled:r,onPress:s,"aria-label":e,className:l,children:c.jsx(t,{size:o})})})}const He={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"}},tl={1:"Heading 1",2:"Heading 2",3:"Heading 3",4:"Heading 4",5:"Heading 5",6:"Heading 6"};function nl({editor:t,levels:e=[1,2,3,4,5,6],isDisabled:n=!1}){const[,r]=v.useState(0);v.useEffect(()=>{const o=()=>r(l=>l+1);return t.on("selectionUpdate",o),t.on("transaction",o),()=>{t.off("selectionUpdate",o),t.off("transaction",o)}},[t]);const s=e.find(o=>t.isActive("heading",{level:o})),i=o=>{const l=Number(o),a=He.heading;a&&a.execute({editor:t,config:{type:"heading",level:l}})};return c.jsxs(y.Dropdown,{placement:"top-start",offset:10,children:[c.jsx(y.DropdownTrigger,{children:c.jsx(oe,{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(y.DropdownMenu,{"aria-label":"Heading levels",selectionMode:"single",selectedKeys:s?new Set([String(s)]):new Set,onAction:i,children:e.map(o=>c.jsx(y.DropdownItem,{startContent:t.isActive("heading",{level:o})?c.jsx(_.Check,{size:16}):c.jsx("div",{className:"w-4"}),children:tl[o]},o))})]})}const On={bulletList:{label:"Bullet List",icon:_.List},orderedList:{label:"Numbered List",icon:_.ListOrdered},taskList:{label:"Task List",icon:_.ListTodo}};function rl({editor:t,types:e=["bulletList","orderedList","taskList"],isDisabled:n=!1}){const[,r]=v.useState(0);v.useEffect(()=>{const l=()=>r(a=>a+1);return t.on("selectionUpdate",l),t.on("transaction",l),()=>{t.off("selectionUpdate",l),t.off("transaction",l)}},[t]);const s=e.find(l=>t.isActive(l)),i=s?On[s].icon:_.List,o=l=>{const u=He[l];u&&u.execute({editor:t})};return c.jsxs(y.Dropdown,{placement:"top-start",offset:10,children:[c.jsx(y.DropdownTrigger,{children:c.jsx(oe,{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(y.DropdownMenu,{"aria-label":"List types",selectionMode:"single",selectedKeys:s?new Set([s]):new Set,onAction:o,children:e.map(l=>{const a=On[l].icon;return c.jsx(y.DropdownItem,{startContent:c.jsx(a,{size:16}),children:On[l].label},l)})})]})}function sl({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:`
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 ls=["#000000","#374151","#6B7280","#EF4444","#F59E0B","#10B981","#3B82F6","#8B5CF6","#EC4899","#14B8A6","#F97316","#A855F7"],as=["#FEF3C7","#DBEAFE","#D1FAE5","#FCE7F3","#E0E7FF","#FED7AA","#F3E8FF","#CCFBF1","#FEE2E2","#E5E7EB","#FAE8FF","#BFDBFE"];function Ct(n){return/^#([0-9A-F]{3}){1,2}$/i.test(n)}const z={min:50,max:200,step:10,default:100},on={lineHeight:24,toolbarHeight:60},cs={bold:k.Bold,italic:k.Italic,strike:k.Strikethrough,underline:k.Underline,code:k.Code,textColor:k.Palette,highlight:k.Highlighter,link:k.Link2,paragraph:k.FileText,heading:k.Heading,bulletList:k.List,orderedList:k.ListOrdered,taskList:k.ListTodo,codeBlock:k.CodeSquare,blockquote:k.Quote,horizontalRule:k.Minus,clearMarks:k.Eraser,clearNodes:k.Eraser,undo:k.Undo2,redo:k.Redo2,hardBreak:k.CornerDownLeft,textAlign:k.AlignLeft},us={left:k.AlignLeft,center:k.AlignCenter,right:k.AlignRight,justify:k.AlignJustify};function he(n){return cs[n]}function ds({value:n,onChange:e,onApply:t,placeholder:r="#000000"}){const[s,i]=C.useState(""),o=c=>{const u=c.target.value;e(u),s&&i("")},l=()=>{if(!n){i("Please enter a color");return}if(!Ct(n)){i("Invalid hex color (e.g., #FF0000)");return}i(""),t(n)},a=c=>{c.key==="Enter"&&(c.preventDefault(),l())};return f.jsxs("div",{className:"space-y-2",children:[f.jsxs("div",{className:"flex gap-2",children:[f.jsx(x.Input,{type:"text",value:n,onChange:o,onKeyDown:a,placeholder:r,size:"sm",variant:"bordered","aria-label":"Custom color hex code",isInvalid:!!s,errorMessage:s,startContent:f.jsx("div",{className:"w-4 h-4 rounded border border-divider",style:{backgroundColor:Ct(n)?n:"transparent"}})}),f.jsx(x.Button,{size:"sm",color:"primary",variant:"flat",isIconOnly:!0,onPress:l,"aria-label":"Apply custom color",isDisabled:!n||!Ct(n),children:f.jsx(k.Check,{size:16})})]}),f.jsx("p",{className:"text-xs text-default-500",children:"Enter a hex color code (e.g., #FF0000)"})]})}function ln({editor:n,type:e,allowCustomColor:t=!0,label:r,isDisabled:s=!1}){const[i,o]=C.useState(!1),[l,a]=C.useState(""),c=e==="textColor"?ls:as,u=y=>{const b=te[e];b&&b.execute({editor:n,config:{type:e,color:y}}),o(!1),a("")},d=y=>{u(y)},h=()=>{const y=te[e];y&&y.execute({editor:n,config:{type:e,color:""}}),o(!1)},p=e==="textColor"?n.isActive("textStyle"):n.isActive("highlight"),g=e==="textColor"?k.Palette:k.Highlighter;return f.jsxs(x.Popover,{isOpen:i,onOpenChange:o,placement:"bottom",showArrow:!0,children:[f.jsx(x.PopoverTrigger,{children:f.jsx(x.Button,{size:"sm",radius:"sm",variant:p?"solid":"bordered",color:p?"primary":"default",isIconOnly:!0,isDisabled:s,"aria-label":r,children:f.jsx(g,{size:16})})}),f.jsx(x.PopoverContent,{className:"w-64",children:f.jsxs("div",{className:"px-2 py-3 space-y-3",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-sm font-semibold",children:r}),f.jsx(x.Button,{size:"sm",variant:"light",isIconOnly:!0,onPress:h,"aria-label":"Clear color",children:f.jsx(k.X,{size:16})})]}),f.jsx(os,{colors:c,onColorSelect:u}),t&&f.jsxs(f.Fragment,{children:[f.jsx(x.Divider,{}),f.jsxs("div",{children:[f.jsx("p",{className:"text-xs font-semibold mb-2 text-default-700",children:"Custom Color"}),f.jsx(ds,{value:l,onChange:a,onApply:d})]})]})]})})]})}function fs({zoom:n,onZoomChange:e,min:t=z.min,max:r=z.max,step:s=z.step}){const i=()=>{const d=Math.max(t,n-s);e(d)},o=()=>{const d=Math.min(r,n+s);e(d)},l=()=>{e(z.default)},a=n<=t,c=n>=r,u=n===z.default;return f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(x.Tooltip,{content:"Zoom out",children:f.jsx(x.Button,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:a,onPress:i,"aria-label":"Zoom out",children:f.jsx(k.ZoomOut,{size:16})})}),f.jsx(x.Tooltip,{content:u?"Zoom percentage":"Click to reset zoom",children:f.jsxs("button",{type:"button",onClick:l,disabled:u,className:`
7
+ `,style:{backgroundColor:s},"aria-label":`Select color ${s}`,title:s},s)})})}const il=["#000000","#374151","#6B7280","#EF4444","#F59E0B","#10B981","#3B82F6","#8B5CF6","#EC4899","#14B8A6","#F97316","#A855F7"],ol=["#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 me={min:50,max:200,step:10,default:100},Jr={lineHeight:24,toolbarHeight:60},ll={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},al={left:_.AlignLeft,center:_.AlignCenter,right:_.AlignRight,justify:_.AlignJustify};function rt(t){return ll[t]}function cl({value:t,onChange:e,onApply:n,placeholder:r="#000000"}){const[s,i]=v.useState(""),o=u=>{const d=u.target.value;e(d),s&&i("")},l=()=>{if(!t){i("Please enter a color");return}if(!In(t)){i("Invalid hex color (e.g., #FF0000)");return}i(""),n(t)},a=u=>{u.key==="Enter"&&(u.preventDefault(),l())};return c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex gap-2",children:[c.jsx(y.Input,{type:"text",value:t,onChange:o,onKeyDown:a,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(oe,{size:"sm",color:"primary",variant:"flat",isIconOnly:!0,onPress:l,"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 Wr({editor:t,type:e,allowCustomColor:n=!0,label:r,isDisabled:s=!1}){const[i,o]=v.useState(!1),[l,a]=v.useState(""),u=e==="textColor"?il:ol,d=b=>{const k=He[e];k&&k.execute({editor:t,config:{type:e,color:b}}),o(!1),a("")},f=b=>{d(b)},p=()=>{const b=He[e];b&&b.execute({editor:t,config:{type:e,color:""}}),o(!1)},m=e==="textColor"?t.isActive("textStyle"):t.isActive("highlight"),C=e==="textColor"?_.Palette:_.Highlighter;return c.jsxs(y.Popover,{isOpen:i,onOpenChange:o,placement:"top",offset:10,showArrow:!0,children:[c.jsx(y.PopoverTrigger,{children:c.jsx(oe,{size:"sm",radius:"sm",variant:m?"solid":"bordered",color:m?"primary":"default",isIconOnly:!0,isDisabled:s,"aria-label":r,children:c.jsx(C,{size:16})})}),c.jsx(y.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(oe,{size:"sm",variant:"light",isIconOnly:!0,onPress:p,"aria-label":"Clear color",children:c.jsx(_.X,{size:16})})]}),c.jsx(sl,{colors:u,onColorSelect:d}),n&&c.jsxs(c.Fragment,{children:[c.jsx(y.Divider,{}),c.jsxs("div",{children:[c.jsx("p",{className:"text-xs font-semibold mb-2 text-default-700",children:"Custom Color"}),c.jsx(cl,{value:l,onChange:a,onApply:f})]})]})]})})]})}function ul({zoom:t,onZoomChange:e,min:n=me.min,max:r=me.max,step:s=me.step}){const i=()=>{const f=Math.max(n,t-s);e(f)},o=()=>{const f=Math.min(r,t+s);e(f)},l=()=>{e(me.default)},a=t<=n,u=t>=r,d=t===me.default;return c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(y.Tooltip,{content:"Zoom out",placement:"top",offset:10,children:c.jsx(oe,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:a,onPress:i,"aria-label":"Zoom out",children:c.jsx(_.ZoomOut,{size:16})})}),c.jsx(y.Tooltip,{content:d?"Zoom percentage":"Click to reset zoom",placement:"top",offset:10,children:c.jsxs("button",{type:"button",onClick:l,disabled:d,className:`
8
8
  text-xs text-default-500 min-w-[3ch] text-center px-2
9
- ${u?"cursor-default":"cursor-pointer hover:text-primary"}
10
- `,"aria-label":`Zoom level ${n}%`,children:[n,"%"]})}),f.jsx(x.Tooltip,{content:"Zoom in",children:f.jsx(x.Button,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:c,onPress:o,"aria-label":"Zoom in",children:f.jsx(k.ZoomIn,{size:16})})})]})}function hs({children:n,id:e,label:t,className:r,useButtonGroup:s=!0}){return s?f.jsx(x.ButtonGroup,{size:"sm",id:e,"aria-label":t,className:r,children:n}):f.jsx("div",{id:e,role:"group","aria-label":t,className:`flex items-center gap-2 ${r||""}`,children:n})}function qn(n,e){const t=C.useMemo(()=>{if(!n)return{};const i={};return Array.from(new Set(e.map(l=>Pe(l)))).forEach(l=>{const a=te[l];if(a)try{const c=a.canExecute?.(n)??!0,u=a.isActive?.(n)??!1;i[l]={isActive:u,isDisabled:!c,canExecute:c}}catch(c){console.warn(`Extension not available for modifier: ${l}`,c),i[l]={isActive:!1,isDisabled:!0,canExecute:!1}}}),i},[n,e]),[r,s]=C.useState(t);return C.useEffect(()=>{if(!n)return;const i=()=>{const o={};Array.from(new Set(e.map(a=>Pe(a)))).forEach(a=>{const c=te[a];if(c)try{const u=c.canExecute?.(n)??!0,d=c.isActive?.(n)??!1;o[a]={isActive:d,isDisabled:!u,canExecute:u}}catch(u){console.warn(`Extension not available for modifier: ${a}`,u),o[a]={isActive:!1,isDisabled:!0,canExecute:!1}}}),s(o)};return n.on("selectionUpdate",i),n.on("transaction",i),()=>{n.off("selectionUpdate",i),n.off("transaction",i)}},[n,e,t]),r}function Vn(n,e){const t=C.useCallback((o,l)=>{if(!n)return;const a=te[o];if(a)try{a.execute({editor:n,config:l}),e?.({type:"toggle",modifier:o})}catch(c){console.warn(`Failed to execute command for modifier: ${o}`,c)}},[n,e]),r=C.useCallback(o=>{t(o)},[t]),s=C.useCallback((o,l)=>{if(!n)return!1;const a=te[o];try{return a?.canExecute?.(n,l)??!1}catch(c){return console.warn(`Failed to check canExecute for modifier: ${o}`,c),!1}},[n]),i=C.useCallback((o,l)=>{if(!n)return!1;const a=te[o];try{return a?.isActive?.(n,l)??!1}catch(c){return console.warn(`Failed to check isActive for modifier: ${o}`,c),!1}},[n]);return{executeCommand:t,toggleModifier:r,canExecute:s,isActive:i}}function ps(n=z.default){const[e,t]=C.useState(n),r=C.useCallback((l=z.step)=>{t(a=>Math.min(z.max,a+l))},[]),s=C.useCallback((l=z.step)=>{t(a=>Math.max(z.min,a-l))},[]),i=C.useCallback(()=>{t(z.default)},[]),o=C.useCallback(l=>{const a=Math.max(z.min,Math.min(z.max,l));t(a)},[]);return{zoom:e,setZoom:o,zoomIn:r,zoomOut:s,resetZoom:i,isMinZoom:e<=z.min,isMaxZoom:e>=z.max,isDefaultZoom:e===z.default}}const ms=["bold","italic","strike","underline","code"];function gs({editor:n,modifiers:e,onToolbarAction:t}){const r=qn(n,e),{toggleModifier:s}=Vn(n,t);if(!n)return null;const i=e.map(o=>Pe(o)).filter(o=>ms.includes(o));return i.length===0?null:f.jsx(hs,{id:"text-formatting",label:"Text formatting",children:i.map(o=>{const l=r[o],a=he(o);return f.jsx(re,{icon:a,label:o.charAt(0).toUpperCase()+o.slice(1),isActive:l?.isActive,isDisabled:l?.isDisabled,onClick:()=>s(o)},o)})})}function ys({editor:n,modifiers:e,zoom:t=100,onZoomChange:r,sticky:s=!0,className:i,onToolbarAction:o}){const l=qn(n,e),{toggleModifier:a,executeCommand:c}=Vn(n,o);if(!n)return null;const u=e.map(M=>Pe(M)),d=u.some(M=>["bold","italic","strike","underline","code"].includes(M)),h=u.some(M=>["textColor","highlight"].includes(M)),p=u.includes("heading"),g=u.includes("textAlign"),y=u.some(M=>["bulletList","orderedList","taskList"].includes(M)),b=u.includes("blockquote"),E=u.includes("codeBlock"),I=u.includes("link"),F=u.includes("horizontalRule"),q=u.some(M=>["undo","redo"].includes(M)),V=t!==void 0&&r!==void 0,ue=s?"sticky top-0 z-10":"";return f.jsx("div",{className:`w-full p-2 bg-background border-b border-divider ${ue} ${i||""}`,children:f.jsxs("div",{className:"flex flex-row flex-wrap gap-2 w-full items-center",children:[d&&f.jsxs(f.Fragment,{children:[f.jsx(gs,{editor:n,modifiers:e,onToolbarAction:o}),(h||p||g||y||b||E||I||F||q||V)&&f.jsx(fe,{})]}),h&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"flex items-center gap-1",children:[u.includes("textColor")&&f.jsx(ln,{editor:n,type:"textColor",label:"Text color",isDisabled:l.textColor?.isDisabled}),u.includes("highlight")&&f.jsx(ln,{editor:n,type:"highlight",label:"Highlight",isDisabled:l.highlight?.isDisabled})]}),(p||g||y||b||E||I||F||q||V)&&f.jsx(fe,{})]}),p&&f.jsxs(f.Fragment,{children:[f.jsx(ss,{editor:n}),(g||y||b||E||I||F||q||V)&&f.jsx(fe,{})]}),g&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"flex items-center gap-1",children:["left","center","right","justify"].map(M=>{const Y=us[M],de=n.isActive({textAlign:M});return f.jsx(re,{icon:Y,label:`Align ${M}`,isActive:de,onClick:()=>c("textAlign",{type:"textAlign",alignment:M})},M)})}),(y||b||E||I||F||q||V)&&f.jsx(fe,{})]}),y&&f.jsxs(f.Fragment,{children:[f.jsx(is,{editor:n,types:u.filter(M=>["bulletList","orderedList","taskList"].includes(M))}),(b||E||I||F||q||V)&&f.jsx(fe,{})]}),(b||E||I||F)&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"flex items-center gap-1",children:[b&&f.jsx(re,{icon:he("blockquote"),label:"Blockquote",isActive:l.blockquote?.isActive,isDisabled:l.blockquote?.isDisabled,onClick:()=>a("blockquote")}),E&&f.jsx(re,{icon:he("codeBlock"),label:"Code block",isActive:l.codeBlock?.isActive,isDisabled:l.codeBlock?.isDisabled,onClick:()=>a("codeBlock")}),I&&f.jsx(re,{icon:he("link"),label:"Link",isActive:l.link?.isActive,isDisabled:l.link?.isDisabled,onClick:()=>{const M=window.prompt("Enter URL:");M&&c("link",{type:"link",href:M})}}),F&&f.jsx(re,{icon:he("horizontalRule"),label:"Horizontal rule",onClick:()=>a("horizontalRule")})]}),(q||V)&&f.jsx(fe,{})]}),q&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"flex items-center gap-1",children:[u.includes("undo")&&f.jsx(re,{icon:he("undo"),label:"Undo",isDisabled:l.undo?.isDisabled,onClick:()=>a("undo")}),u.includes("redo")&&f.jsx(re,{icon:he("redo"),label:"Redo",isDisabled:l.redo?.isDisabled,onClick:()=>a("redo")})]}),V&&f.jsx(fe,{})]}),V&&f.jsx(fs,{zoom:t,onZoomChange:M=>{r?.(M),o?.({type:"zoom",modifier:`${M}%`})}})]})})}const xs=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,bs=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,ks=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Cs=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Ss=m.Mark.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return["strong",m.mergeAttributes(this.options.HTMLAttributes,n),0]},addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[m.markInputRule({find:xs,type:this.type}),m.markInputRule({find:ks,type:this.type})]},addPasteRules(){return[m.markPasteRule({find:bs,type:this.type}),m.markPasteRule({find:Cs,type:this.type})]}}),As=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Ts=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Ms=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Es=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Ns=m.Mark.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",m.mergeAttributes(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[m.markInputRule({find:As,type:this.type}),m.markInputRule({find:Ms,type:this.type})]},addPasteRules(){return[m.markPasteRule({find:Ts,type:this.type}),m.markPasteRule({find:Es,type:this.type})]}}),vs=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Os=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,ws=m.Mark.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",m.mergeAttributes(this.options.HTMLAttributes,n),0]},addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[m.markInputRule({find:vs,type:this.type})]},addPasteRules(){return[m.markPasteRule({find:Os,type:this.type})]}}),Is=/(^|[^`])`([^`]+)`(?!`)/,Ds=/(^|[^`])`([^`]+)`(?!`)/g,Ls=m.Mark.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",m.mergeAttributes(this.options.HTMLAttributes,n),0]},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[m.markInputRule({find:Is,type:this.type})]},addPasteRules(){return[m.markPasteRule({find:Ds,type:this.type})]}}),Rs=n=>{if(!n.children.length)return;const e=n.querySelectorAll("span");e&&e.forEach(t=>{var r,s;const i=t.getAttribute("style"),o=(s=(r=t.parentElement)===null||r===void 0?void 0:r.closest("span"))===null||s===void 0?void 0:s.getAttribute("style");t.setAttribute("style",`${o};${i}`)})},Ps=m.Mark.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:n=>n.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&Rs(n),{}):!1}]},renderHTML({HTMLAttributes:n}){return["span",m.mergeAttributes(this.options.HTMLAttributes,n),0]},addCommands(){return{removeEmptyTextStyle:()=>({tr:n})=>{const{selection:e}=n;return n.doc.nodesBetween(e.from,e.to,(t,r)=>{if(t.isTextblock)return!0;t.marks.filter(s=>s.type===this.type).some(s=>Object.values(s.attrs).some(i=>!!i))||n.removeMark(r,r+t.nodeSize,this.type)}),!0}}}}),zs=m.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(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,m.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>m.textblockTypeInputRule({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),Jn=m.Node.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",m.mergeAttributes(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Bs="listItem",an="textStyle",cn=/^\s*([-+*])\s$/,Fs=m.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:n}){return["ul",m.mergeAttributes(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Bs,this.editor.getAttributes(an)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=m.wrappingInputRule({find:cn,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=m.wrappingInputRule({find:cn,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(an),editor:this.editor})),[n]}}),Hs="listItem",un="textStyle",dn=/^(\d+)\.\s$/,js=m.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:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",m.mergeAttributes(this.options.HTMLAttributes,t),0]:["ol",m.mergeAttributes(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Hs,this.editor.getAttributes(un)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=m.wrappingInputRule({find:dn,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=m.wrappingInputRule({find:dn,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(un)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),$s=m.Node.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",m.mergeAttributes(this.options.HTMLAttributes,n),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 Kn(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let s=n.child(r),i=e.child(r);if(s==i){t+=s.nodeSize;continue}if(!s.sameMarkup(i))return t;if(s.isText&&s.text!=i.text){for(let o=0;s.text[o]==i.text[o];o++)t++;return t}if(s.content.size||i.content.size){let o=Kn(s.content,i.content,t+1);if(o!=null)return o}t+=s.nodeSize}}function Un(n,e,t,r){for(let s=n.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:t,b:r};let o=n.child(--s),l=e.child(--i),a=o.nodeSize;if(o==l){t-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:t,b:r};if(o.isText&&o.text!=l.text){let c=0,u=Math.min(o.text.length,l.text.length);for(;c<u&&o.text[o.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(o.content.size||l.content.size){let c=Un(o.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class S{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,s=0,i){for(let o=0,l=0;l<t;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,s+l,i||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,s+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,s){let i="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(r)&&(s[s.length-1]=t.withText(t.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new S(s,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],s=0;if(t>e)for(let i=0,o=0;o<t;i++){let l=this.content[i],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),r.push(l),s+=l.nodeSize),o=a}return new S(r,s)}cutByIndex(e,t){return e==t?S.empty:e==0&&t==this.content.length?this:new S(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let s=this.content.slice(),i=this.size+t.nodeSize-r.nodeSize;return s[e]=t,new S(s,i)}addToStart(e){return new S([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new S(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))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 t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let s=this.content[t];e(s,r,t),r+=s.nodeSize}}findDiffStart(e,t=0){return Kn(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Un(this,e,t,r)}findIndex(e){if(e==0)return Ue(0,e);if(e==this.size)return Ue(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let s=this.child(t),i=r+s.nodeSize;if(i>=e)return i==e?Ue(t+1,i):Ue(t,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,t){if(!t)return S.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new S(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return S.empty;let t,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)?(t||(t=e.slice(0,s)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new S(t||e,r)}static from(e){if(!e)return S.empty;if(e instanceof S)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new S([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}S.empty=new S([],0);const St={index:0,offset:0};function Ue(n,e){return St.index=n,St.offset=e,St}function Lt(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Lt(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Lt(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}class K{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,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))t||(t=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),r=!0),t&&t.push(i)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Lt(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let s=r.create(t.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return K.none;if(e instanceof K)return[e];let t=e.slice();return t.sort((r,s)=>r.type.rank-s.type.rank),t}}K.none=[];class qs extends Error{}class A{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=_n(this.content,e+this.openStart,t);return r&&new A(r,this.openStart,this.openEnd)}removeBetween(e,t){return new A(Wn(this.content,e+this.openStart,t+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,t){if(!t)return A.empty;let r=t.openStart||0,s=t.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new A(S.fromJSON(e,t.content),r,s)}static maxOpen(e,t=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)s++;return new A(e,r,s)}}A.empty=new A(S.empty,0,0);function Wn(n,e,t){let{index:r,offset:s}=n.findIndex(e),i=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(s==e||i.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,i.copy(Wn(i.content,e-s-1,t-s-1)))}function _n(n,e,t,r){let{index:s,offset:i}=n.findIndex(e),o=n.maybeChild(s);if(i==e||o.isText)return r&&!r.canReplace(s,s,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=_n(o.content,e-i-1,t,o);return l&&n.replaceChild(s,o.copy(l))}function Vs(n){return n.tag!=null}function Js(n){return n.style!=null}class Qe{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(s=>{if(Vs(s))this.tags.push(s);else if(Js(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,t={}){let r=new hn(this,t,!1);return r.addAll(e,K.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new hn(this,t,!0);return r.addAll(e,K.none,t.from,t.to),A.maxOpen(r.finish())}matchTag(e,t,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(Ws(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||t.matchesContext(i.context))){if(i.getAttrs){let o=i.getAttrs(e);if(o===!1)continue;i.attrs=o||void 0}return i}}}matchStyle(e,t,r,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let o=this.styles[i],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function r(s){let i=s.priority==null?50:s.priority,o=0;for(;o<t.length;o++){let l=t[o];if((l.priority==null?50:l.priority)<i)break}t.splice(o,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(o=>{r(o=pn(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=pn(o)),o.node||o.ignore||o.mark||(o.node=s)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Qe(e,Qe.schemaRules(e)))}}const Zn={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},Ks={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Gn={ol:!0,ul:!0},ze=1,Rt=2,De=4;function fn(n,e,t){return e!=null?(e?ze:0)|(e==="full"?Rt:0):n&&n.whitespace=="pre"?ze|Rt:t&~De}class We{constructor(e,t,r,s,i,o){this.type=e,this.attrs=t,this.marks=r,this.solid=s,this.options=o,this.content=[],this.activeMarks=K.none,this.match=i||(o&De?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(S.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);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&ze)){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 t=S.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(S.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Zn.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class hn{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=t.topNode,i,o=fn(null,t.preserveWhitespace,0)|(r?De:0);s?i=new We(s.type,s.attrs,K.none,!0,t.topMatch||s.type.contentMatch,o):r?i=new We(null,null,K.none,!0,null,o):i=new We(e.schema.topNodeType,null,K.none,!0,null,o),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,s=this.top,i=s.options&Rt?"full":this.localPreserveWS||(s.options&ze)>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 l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(o.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(o.text(l[a]),t,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=s.content[s.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,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(),l;Gn.hasOwnProperty(o)&&this.parser.normalizeLists&&Us(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:Ks.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if(Zn.hasOwnProperty(o))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let d=a&&a.skip?t:this.readStyles(e,t);d&&this.addAll(e,d),c&&this.sync(i),this.needsBlock=u}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=s}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
12
- `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],o=r.getPropertyValue(i);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(i,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,s){let i,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(o,t.attrs||null,r,t.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,t,r,s){let i=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=s==null?null:e.childNodes[s];o!=l;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,t);this.findAtPoint(e,i)}findPlace(e,t,r){let s,i;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],c=a.findWrapping(e);if(c&&(!s||s.length>c.length+l)&&(s=c,i=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!s)return null;this.sync(i);for(let o=0;o<s.length;o++)t=this.enterInner(s[o],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(t=this.enterInner(i,null,t))}let s=this.findPlace(e,t,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let o=K.none;for(let l of s.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):mn(l.type,e.type))&&(o=l.addToSet(o));return i.content.push(e.mark(o)),!0}return!1}enter(e,t,r,s){let i=this.findPlace(e.create(t),r,!1);return i&&(i=this.enterInner(e,t,r,!0,s)),i}enterInner(e,t,r,s=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=fn(e,i,o.options);o.options&De&&o.content.length==0&&(l|=De);let a=K.none;return r=r.filter(c=>(o.type?o.type.allowsMarkType(c.type):mn(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new We(e,t,a,s,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].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 t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=ze)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&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)&&t.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(s?0:1),o=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=i;a--)if(o(l-1,a))return!0;return!1}else{let u=a>0||a==0&&s?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function Us(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Gn.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function Ws(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function pn(n){let e={};for(let t in n)e[t]=n[t];return e}function mn(n,e){let t=e.schema.nodes;for(let r in t){let s=t[r];if(!s.allowsMarkType(n))continue;let i=[],o=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||i.indexOf(u)<0&&o(u))return!0}};if(o(s.contentMatch))return!0}}class ct{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=At(t).createDocumentFragment());let s=r,i=[];return e.forEach(o=>{if(i.length||o.marks.length){let l=0,a=0;for(;l<i.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)s=i.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],u=this.serializeMark(c,o.isInline,t);u&&(i.push([c,s]),s.appendChild(u.dom),s=u.contentDOM||u.dom)}}s.appendChild(this.serializeNodeInner(o,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:s}=Ge(At(t),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,t,s)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,t,r={}){let s=this.marks[e.type.name];return s&&Ge(At(r),s(e,t),null,e.attrs)}static renderSpec(e,t,r=null,s){return Ge(e,t,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new ct(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=gn(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return gn(e.marks)}}function gn(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function At(n){return n.document||window.document}const yn=new WeakMap;function _s(n){let e=yn.get(n);return e===void 0&&yn.set(n,e=Zs(n)),e}function Zs(n){let e=null;function t(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++)t(r[s]);else for(let s in r)t(r[s])}return t(n),e}function Ge(n,e,t,r){if(typeof e=="string")return{dom:n.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=_s(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&&(t=s.slice(0,o),s=s.slice(o+1));let l,a=t?n.createElementNS(t,s):n.createElement(s),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let h=d.indexOf(" ");h>0?a.setAttributeNS(d.slice(0,h),d.slice(h+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let h=e[d];if(h===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:p,contentDOM:g}=Ge(n,h,t,r);if(a.appendChild(p),g){if(l)throw new RangeError("Multiple content holes");l=g}}}return{dom:a,contentDOM:l}}const Xn=65535,Yn=Math.pow(2,16);function Gs(n,e){return n+e*Yn}function xn(n){return n&Xn}function Xs(n){return(n-(n&Xn))/Yn}const Qn=1,er=2,Xe=4,tr=8;class Pt{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&tr)>0}get deletedBefore(){return(this.delInfo&(Qn|Xe))>0}get deletedAfter(){return(this.delInfo&(er|Xe))>0}get deletedAcross(){return(this.delInfo&Xe)>0}}class j{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&j.empty)return j.empty}recover(e){let t=0,r=xn(e);if(!this.inverted)for(let s=0;s<r;s++)t+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+t+Xs(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let s=0,i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+i],u=this.ranges[l+o],d=a+c;if(e<=d){let h=c?e==a?-1:e==d?1:t:t,p=a+s+(h<0?0:u);if(r)return p;let g=e==(t<0?a:d)?null:Gs(l/3,e-a),y=e==a?er:e==d?Qn:Xe;return(t<0?e!=a:e!=d)&&(y|=tr),new Pt(p,y,g)}s+=u-c}return r?e+s:new Pt(e+s,0,null)}touches(e,t){let r=0,s=xn(t),i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+i],u=a+c;if(e<=u&&l==s*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let o=this.ranges[s],l=o-(this.inverted?i:0),a=o+(this.inverted?0:i),c=this.ranges[s+t],u=this.ranges[s+r];e(l,l+c,a,a+u),i+=u-c}}invert(){return new j(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?j.empty:new j(e<0?[0,-e,0]:[0,0,e])}}j.empty=new j([]);class et{constructor(e,t,r=0,s=e?e.length:0){this.mirror=t,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new et(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let s=e.getMirror(t);this.appendMap(e._maps[t],s!=null&&s<t?r+s:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let s=e.getMirror(t);this.appendMap(e._maps[t].invert(),s!=null&&s>t?r-s-1:void 0)}}invert(){let e=new et;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let s=0;for(let i=this.from;i<this.to;i++){let o=this._maps[i],l=o.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this._maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return r?e:new Pt(e,s,null)}}const Tt=Object.create(null);class B{getMap(){return j.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Tt[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Tt)throw new RangeError("Duplicate use of step JSON ID "+e);return Tt[e]=t,t.prototype.jsonID=e,t}}class w{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new w(e,null)}static fail(e){return new w(null,e)}static fromReplace(e,t,r,s){try{return w.ok(e.replace(t,r,s))}catch(i){if(i instanceof qs)return w.fail(i.message);throw i}}}function Ut(n,e,t){let r=[];for(let s=0;s<n.childCount;s++){let i=n.child(s);i.content.size&&(i=i.copy(Ut(i.content,e,i))),i.isInline&&(i=e(i,t,s)),r.push(i)}return S.fromArray(r)}class me extends B{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new A(Ut(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),t.openStart,t.openEnd);return w.fromReplace(e,this.from,this.to,i)}invert(){return new ge(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new me(t.pos,r.pos,this.mark)}merge(e){return e instanceof me&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new me(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,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new me(t.from,t.to,e.markFromJSON(t.mark))}}B.jsonID("addMark",me);class ge extends B{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new A(Ut(t.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),t.openStart,t.openEnd);return w.fromReplace(e,this.from,this.to,r)}invert(){return new me(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new ge(t.pos,r.pos,this.mark)}merge(e){return e instanceof ge&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ge(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,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new ge(t.from,t.to,e.markFromJSON(t.mark))}}B.jsonID("removeMark",ge);class ye extends B{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return w.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return w.fromReplace(e,this.pos,this.pos+1,new A(S.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let s=0;s<t.marks.length;s++)if(!t.marks[s].isInSet(r))return new ye(this.pos,t.marks[s]);return new ye(this.pos,this.mark)}}return new Be(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ye(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new ye(t.pos,e.markFromJSON(t.mark))}}B.jsonID("addNodeMark",ye);class Be extends B{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return w.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return w.fromReplace(e,this.pos,this.pos+1,new A(S.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new ye(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Be(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Be(t.pos,e.markFromJSON(t.mark))}}B.jsonID("removeNodeMark",Be);class ee extends B{constructor(e,t,r,s=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=s}apply(e){return this.structure&&zt(e,this.from,this.to)?w.fail("Structure replace would overwrite content"):w.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new j([this.from,this.to-this.from,this.slice.size])}invert(e){return new ee(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new ee(t.pos,Math.max(t.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof ee)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?A.empty:new A(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new ee(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?A.empty:new A(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new ee(e.from,this.to,t,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,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new ee(t.from,t.to,A.fromJSON(e,t.slice),!!t.structure)}}B.jsonID("replace",ee);class Ee extends B{constructor(e,t,r,s,i,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=l}apply(e){if(this.structure&&(zt(e,this.from,this.gapFrom)||zt(e,this.gapTo,this.to)))return w.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return w.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?w.fromReplace(e,this.from,this.to,r):w.fail("Content does not fit in gap")}getMap(){return new j([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new Ee(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||s<t.pos||i>r.pos?null:new Ee(t.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,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Ee(t.from,t.to,t.gapFrom,t.gapTo,A.fromJSON(e,t.slice),t.insert,!!t.structure)}}B.jsonID("replaceAround",Ee);function zt(n,e,t){let r=n.resolve(e),s=t-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 nr(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let s=t.content;for(let i=0;i<t.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(t.openStart==0&&t.size?2:1);i++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,a=r.index(o)+(l>0?1:0),c=r.node(o),u=!1;if(i==1)u=c.canReplace(a,a,s);else{let d=c.contentMatchAt(a).findWrapping(s.firstChild.type);u=d&&c.canReplaceWith(a,a,d[0])}if(u)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}class Le extends B{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return w.fail("No node at attribute step's position");let r=Object.create(null);for(let i in t.attrs)r[i]=t.attrs[i];r[this.attr]=this.value;let s=t.type.create(r,null,t.marks);return w.fromReplace(e,this.pos,this.pos+1,new A(S.from(s),0,t.isLeaf?0:1))}getMap(){return j.empty}invert(e){return new Le(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Le(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Le(t.pos,t.attr,t.value)}}B.jsonID("attr",Le);class tt extends B{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let s in e.attrs)t[s]=e.attrs[s];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return w.ok(r)}getMap(){return j.empty}invert(e){return new tt(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new tt(t.attr,t.value)}}B.jsonID("docAttr",tt);let Fe=class extends Error{};Fe=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Fe.prototype=Object.create(Error.prototype);Fe.prototype.constructor=Fe;Fe.prototype.name="TransformError";const Mt=Object.create(null);class v{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new Ys(e.min(t),e.max(t))]}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 t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=A.empty){let r=t.content.lastChild,s=null;for(let l=0;l<t.openEnd;l++)s=r,r=r.lastChild;let i=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:c}=o[l],u=e.mapping.slice(i);e.replaceRange(u.map(a.pos),u.map(c.pos),l?A.empty:t),l==0&&Cn(e,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:o,$to:l}=s[i],a=e.mapping.slice(r),c=a.map(o.pos),u=a.map(l.pos);i?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),Cn(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let s=e.parent.inlineContent?new N(e):Te(e.node(0),e.parent,e.pos,e.index(),t,r);if(s)return s;for(let i=e.depth-1;i>=0;i--){let o=t<0?Te(e.node(0),e.node(i),e.before(i+1),e.index(i),t,r):Te(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,r);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new G(e.node(0))}static atStart(e){return Te(e,e,0,0,1)||new G(e)}static atEnd(e){return Te(e,e,e.content.size,e.childCount,-1)||new G(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Mt[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Mt)throw new RangeError("Duplicate use of selection JSON ID "+e);return Mt[e]=t,t.prototype.jsonID=e,t}getBookmark(){return N.between(this.$anchor,this.$head).getBookmark()}}v.prototype.visible=!0;class Ys{constructor(e,t){this.$from=e,this.$to=t}}let bn=!1;function kn(n){!bn&&!n.parent.inlineContent&&(bn=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class N extends v{constructor(e,t=e){kn(e),kn(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return v.near(r);let s=e.resolve(t.map(this.anchor));return new N(s.parent.inlineContent?s:r,r)}replace(e,t=A.empty){if(super.replace(e,t),t==A.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof N&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new ut(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new N(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let s=e.resolve(t);return new this(s,r==t?s:e.resolve(r))}static between(e,t,r){let s=e.pos-t.pos;if((!r||s)&&(r=s>=0?1:-1),!t.parent.inlineContent){let i=v.findFrom(t,r,!0)||v.findFrom(t,-r,!0);if(i)t=i.$head;else return v.near(t,r)}return e.parent.inlineContent||(s==0?e=t:(e=(v.findFrom(e,-r,!0)||v.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=s<0&&(e=t))),new N(e,t)}}v.jsonID("text",N);class ut{constructor(e,t){this.anchor=e,this.head=t}map(e){return new ut(e.map(this.anchor),e.map(this.head))}resolve(e){return N.between(e.resolve(this.anchor),e.resolve(this.head))}}class T extends v{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:s}=t.mapResult(this.anchor),i=e.resolve(s);return r?v.near(i):new T(i)}content(){return new A(S.from(this.node),0,0)}eq(e){return e instanceof T&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Wt(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new T(e.resolve(t.anchor))}static create(e,t){return new T(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}T.prototype.visible=!1;v.jsonID("node",T);class Wt{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new ut(r,r):new Wt(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&T.isSelectable(r)?new T(t):v.near(t)}}class G extends v{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=A.empty){if(t==A.empty){e.delete(0,e.doc.content.size);let r=v.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new G(e)}map(e){return new G(e)}eq(e){return e instanceof G}getBookmark(){return Qs}}v.jsonID("all",G);const Qs={map(){return this},resolve(n){return new G(n)}};function Te(n,e,t,r,s,i=!1){if(e.inlineContent)return N.create(n,t);for(let o=r-(s>0?0:1);s>0?o<e.childCount:o>=0;o+=s){let l=e.child(o);if(l.isAtom){if(!i&&T.isSelectable(l))return T.create(n,t-(s<0?l.nodeSize:0))}else{let a=Te(n,l,t+s,s<0?l.childCount:0,s,i);if(a)return a}t+=l.nodeSize*s}return null}function Cn(n,e,t){let r=n.steps.length-1;if(r<e)return;let s=n.steps[r];if(!(s instanceof ee||s instanceof Ee))return;let i=n.mapping.maps[r],o;i.forEach((l,a,c,u)=>{o==null&&(o=u)}),n.setSelection(v.near(n.doc.resolve(o),t))}function Sn(n,e){return!e||!n?n:n.bind(e)}class _e{constructor(e,t,r){this.name=e,this.init=Sn(t.init,r),this.apply=Sn(t.apply,r)}}new _e("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new _e("selection",{init(n,e){return n.selection||v.atStart(e.doc)},apply(n){return n.selection}}),new _e("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new _e("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}});function rr(n,e,t){for(let r in n){let s=n[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=rr(s,e,{})),t[r]=s}return t}class dt{constructor(e){this.spec=e,this.props={},e.props&&rr(e.props,this,this.props),this.key=e.key?e.key.key:sr("plugin")}getState(e){return e[this.key]}}const Et=Object.create(null);function sr(n){return n in Et?n+"$"+ ++Et[n]:(Et[n]=0,n+"$")}class _t{constructor(e="key"){this.key=sr(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const ei=/^```([a-z]+)?[\s\n]$/,ti=/^~~~([a-z]+)?[\s\n]$/,ni=m.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:n=>{var e;const{languageClassPrefix:t}=this.options,i=[...((e=n.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(o=>o.startsWith(t)).map(o=>o.replace(t,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",m.mergeAttributes(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:s}=t;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
9
+ ${d?"cursor-default":"cursor-pointer hover:text-primary"}
10
+ `,"aria-label":`Zoom level ${t}%`,children:[t,"%"]})}),c.jsx(y.Tooltip,{content:"Zoom in",placement:"top",offset:10,children:c.jsx(oe,{size:"sm",radius:"sm",color:"default",variant:"bordered",isIconOnly:!0,isDisabled:u,onPress:o,"aria-label":"Zoom in",children:c.jsx(_.ZoomIn,{size:16})})})]})}function dl({children:t,id:e,label:n,className:r,useButtonGroup:s=!0}){return s?c.jsx(y.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 Qs(t,e){const n=v.useMemo(()=>{if(!t)return{};const i={};return Array.from(new Set(e.map(l=>Rt(l)))).forEach(l=>{const a=He[l];if(a)try{const u=a.canExecute?.(t)??!0,d=a.isActive?.(t)??!1;i[l]={isActive:d,isDisabled:!u,canExecute:u}}catch(u){console.warn(`Extension not available for modifier: ${l}`,u),i[l]={isActive:!1,isDisabled:!0,canExecute:!1}}}),i},[t,e]),[r,s]=v.useState(n);return v.useEffect(()=>{if(!t)return;const i=()=>{const o={};Array.from(new Set(e.map(a=>Rt(a)))).forEach(a=>{const u=He[a];if(u)try{const d=u.canExecute?.(t)??!0,f=u.isActive?.(t)??!1;o[a]={isActive:f,isDisabled:!d,canExecute:d}}catch(d){console.warn(`Extension not available for modifier: ${a}`,d),o[a]={isActive:!1,isDisabled:!0,canExecute:!1}}}),s(o)};return t.on("selectionUpdate",i),t.on("transaction",i),()=>{t.off("selectionUpdate",i),t.off("transaction",i)}},[t,e,n]),r}function Xs(t,e){const n=v.useCallback((o,l)=>{if(!t)return;const a=He[o];if(a)try{a.execute({editor:t,config:l}),e?.({type:"toggle",modifier:o})}catch(u){console.warn(`Failed to execute command for modifier: ${o}`,u)}},[t,e]),r=v.useCallback(o=>{n(o)},[n]),s=v.useCallback((o,l)=>{if(!t)return!1;const a=He[o];try{return a?.canExecute?.(t,l)??!1}catch(u){return console.warn(`Failed to check canExecute for modifier: ${o}`,u),!1}},[t]),i=v.useCallback((o,l)=>{if(!t)return!1;const a=He[o];try{return a?.isActive?.(t,l)??!1}catch(u){return console.warn(`Failed to check isActive for modifier: ${o}`,u),!1}},[t]);return{executeCommand:n,toggleModifier:r,canExecute:s,isActive:i}}function fl(t=me.default){const[e,n]=v.useState(t),r=v.useCallback((l=me.step)=>{n(a=>Math.min(me.max,a+l))},[]),s=v.useCallback((l=me.step)=>{n(a=>Math.max(me.min,a-l))},[]),i=v.useCallback(()=>{n(me.default)},[]),o=v.useCallback(l=>{const a=Math.max(me.min,Math.min(me.max,l));n(a)},[]);return{zoom:e,setZoom:o,zoomIn:r,zoomOut:s,resetZoom:i,isMinZoom:e<=me.min,isMaxZoom:e>=me.max,isDefaultZoom:e===me.default}}const hl=["bold","italic","strike","underline","code"];function pl({editor:t,modifiers:e,onToolbarAction:n}){const r=Qs(t,e),{toggleModifier:s}=Xs(t,n);if(!t)return null;const i=e.map(o=>Rt(o)).filter(o=>hl.includes(o));return i.length===0?null:c.jsx(dl,{id:"text-formatting",label:"Text formatting",children:i.map(o=>{const l=r[o],a=rt(o);return c.jsx(We,{icon:a,label:o.charAt(0).toUpperCase()+o.slice(1),isActive:l?.isActive,isDisabled:l?.isDisabled,onClick:()=>s(o)},o)})})}function ml({editor:t,modifiers:e,zoom:n=100,onZoomChange:r,sticky:s=!0,className:i,onToolbarAction:o}){const l=Qs(t,e),{toggleModifier:a,executeCommand:u}=Xs(t,o);if(!t)return null;const d=e.map(O=>Rt(O)),f=d.some(O=>["bold","italic","strike","underline","code"].includes(O)),p=d.some(O=>["textColor","highlight"].includes(O)),m=d.includes("heading"),C=d.includes("textAlign"),b=d.some(O=>["bulletList","orderedList","taskList"].includes(O)),k=d.includes("blockquote"),S=d.includes("codeBlock"),w=d.includes("link"),j=d.includes("horizontalRule"),N=d.some(O=>["undo","redo"].includes(O)),D=n!==void 0&&r!==void 0,L=s?"sticky top-0 z-10":"";return c.jsx("div",{className:`w-full p-2 bg-background border-b border-divider ${L} ${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(pl,{editor:t,modifiers:e,onToolbarAction:o}),(p||m||C||b||k||S||w||j||N||D)&&c.jsx(nt,{})]}),p&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-1",children:[d.includes("textColor")&&c.jsx(Wr,{editor:t,type:"textColor",label:"Text color",isDisabled:l.textColor?.isDisabled}),d.includes("highlight")&&c.jsx(Wr,{editor:t,type:"highlight",label:"Highlight",isDisabled:l.highlight?.isDisabled})]}),(m||C||b||k||S||w||j||N||D)&&c.jsx(nt,{})]}),m&&c.jsxs(c.Fragment,{children:[c.jsx(nl,{editor:t}),(C||b||k||S||w||j||N||D)&&c.jsx(nt,{})]}),C&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"flex items-center gap-1",children:["left","center","right","justify"].map(O=>{const z=al[O],H=t.isActive({textAlign:O});return c.jsx(We,{icon:z,label:`Align ${O}`,isActive:H,onClick:()=>u("textAlign",{type:"textAlign",alignment:O})},O)})}),(b||k||S||w||j||N||D)&&c.jsx(nt,{})]}),b&&c.jsxs(c.Fragment,{children:[c.jsx(rl,{editor:t,types:d.filter(O=>["bulletList","orderedList","taskList"].includes(O))}),(k||S||w||j||N||D)&&c.jsx(nt,{})]}),(k||S||w||j)&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-1",children:[k&&c.jsx(We,{icon:rt("blockquote"),label:"Blockquote",isActive:l.blockquote?.isActive,isDisabled:l.blockquote?.isDisabled,onClick:()=>a("blockquote")}),S&&c.jsx(We,{icon:rt("codeBlock"),label:"Code block",isActive:l.codeBlock?.isActive,isDisabled:l.codeBlock?.isDisabled,onClick:()=>a("codeBlock")}),w&&c.jsx(We,{icon:rt("link"),label:"Link",isActive:l.link?.isActive,isDisabled:l.link?.isDisabled,onClick:()=>{const O=window.prompt("Enter URL:");O&&u("link",{type:"link",href:O})}}),j&&c.jsx(We,{icon:rt("horizontalRule"),label:"Horizontal rule",onClick:()=>a("horizontalRule")})]}),(N||D)&&c.jsx(nt,{})]}),N&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-1",children:[d.includes("undo")&&c.jsx(We,{icon:rt("undo"),label:"Undo",isDisabled:l.undo?.isDisabled,onClick:()=>a("undo")}),d.includes("redo")&&c.jsx(We,{icon:rt("redo"),label:"Redo",isDisabled:l.redo?.isDisabled,onClick:()=>a("redo")})]}),D&&c.jsx(nt,{})]}),D&&c.jsx(ul,{zoom:n,onZoomChange:O=>{r?.(O),o?.({type:"zoom",modifier:`${O}%`})}})]})})}const gl=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,yl=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,xl=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,bl=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,kl=R.Mark.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return["strong",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[R.markInputRule({find:gl,type:this.type}),R.markInputRule({find:xl,type:this.type})]},addPasteRules(){return[R.markPasteRule({find:yl,type:this.type}),R.markPasteRule({find:bl,type:this.type})]}}),vl=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Sl=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Cl=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,wl=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Al=R.Mark.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[R.markInputRule({find:vl,type:this.type}),R.markInputRule({find:Cl,type:this.type})]},addPasteRules(){return[R.markPasteRule({find:Sl,type:this.type}),R.markPasteRule({find:wl,type:this.type})]}}),Nl=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,El=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Tl=R.Mark.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[R.markInputRule({find:Nl,type:this.type})]},addPasteRules(){return[R.markPasteRule({find:El,type:this.type})]}}),Ml=/(^|[^`])`([^`]+)`(?!`)/,Ol=/(^|[^`])`([^`]+)`(?!`)/g,Il=R.Mark.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[R.markInputRule({find:Ml,type:this.type})]},addPasteRules(){return[R.markPasteRule({find:Ol,type:this.type})]}}),Dl=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}`)})},jl=R.Mark.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&Dl(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(s=>s.type===this.type).some(s=>Object.values(s.attrs).some(i=>!!i))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),Ll=R.Node.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,R.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>R.textblockTypeInputRule({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),Rl=R.Node.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Fl="listItem",Gr="textStyle",Zr=/^\s*([-+*])\s$/,Pl=R.Node.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Fl,this.editor.getAttributes(Gr)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=R.wrappingInputRule({find:Zr,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=R.wrappingInputRule({find:Zr,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Gr),editor:this.editor})),[t]}}),$l="listItem",Qr="textStyle",Xr=/^(\d+)\.\s$/,Vl=R.Node.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",R.mergeAttributes(this.options.HTMLAttributes,n),0]:["ol",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes($l,this.editor.getAttributes(Qr)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=R.wrappingInputRule({find:Xr,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=R.wrappingInputRule({find:Xr,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Qr)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),Bl=R.Node.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",R.mergeAttributes(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}});function Ys(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=Ys(s.content,i.content,n+1);if(o!=null)return o}n+=s.nodeSize}}function ei(t,e,n,r){for(let s=t.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:n,b:r};let o=t.child(--s),l=e.child(--i),a=o.nodeSize;if(o==l){n-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:n,b:r};if(o.isText&&o.text!=l.text){let u=0,d=Math.min(o.text.length,l.text.length);for(;u<d&&o.text[o.text.length-u-1]==l.text[l.text.length-u-1];)u++,n--,r--;return{a:n,b:r}}if(o.content.size||l.content.size){let u=ei(o.content,l.content,n-1,r-1);if(u)return u}n-=a,r-=a}}class q{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,s=0,i){for(let o=0,l=0;l<n;o++){let a=this.content[o],u=l+a.nodeSize;if(u>e&&r(a,s+l,i||null,o)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,n-d),r,s+d)}l=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let i="",o=!0;return this.nodesBetween(e,n,(l,a)=>{let u=l.isText?l.text.slice(Math.max(e,a)-a,n-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&u||l.isTextblock)&&r&&(o?o=!1:i+=r),i+=u},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new q(s,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],s=0;if(n>e)for(let i=0,o=0;o<n;i++){let l=this.content[i],a=o+l.nodeSize;a>e&&((o<e||a>n)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,n-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,n-o-1))),r.push(l),s+=l.nodeSize),o=a}return new q(r,s)}cutByIndex(e,n){return e==n?q.empty:e==0&&n==this.content.length?this:new q(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 q(s,i)}addToStart(e){return new q([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new q(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 Ys(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return ei(this,e,n,r)}findIndex(e){if(e==0)return qt(0,e);if(e==this.size)return qt(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let s=this.child(n),i=r+s.nodeSize;if(i>=e)return i==e?qt(n+1,i):qt(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return q.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new q(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return q.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 q(n||e,r)}static from(e){if(!e)return q.empty;if(e instanceof q)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new q([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}q.empty=new q([],0);const Dn={index:0,offset:0};function qt(t,e){return Dn.index=t,Dn.offset=e,Dn}function Wn(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!Wn(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Wn(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}class Oe{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let s=0;s<e.length;s++){let i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))n||(n=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,s)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Wn(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let s=r.create(n.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Oe.none;if(e instanceof Oe)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}}Oe.none=[];class zl extends Error{}class K{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=ni(this.content,e+this.openStart,n);return r&&new K(r,this.openStart,this.openEnd)}removeBetween(e,n){return new K(ti(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 K.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 K(q.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 K(e,r,s)}}K.empty=new K(q.empty,0,0);function ti(t,e,n){let{index:r,offset:s}=t.findIndex(e),i=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(s==e||i.isText){if(l!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(ti(i.content,e-s-1,n-s-1)))}function ni(t,e,n,r){let{index:s,offset:i}=t.findIndex(e),o=t.maybeChild(s);if(i==e||o.isText)return r&&!r.canReplace(s,s,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=ni(o.content,e-i-1,n,o);return l&&t.replaceChild(s,o.copy(l))}function _l(t){return t.tag!=null}function Hl(t){return t.style!=null}class tn{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(_l(s))this.tags.push(s);else if(Hl(s)){let i=/[^=]*/.exec(s.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=e.nodes[s.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new es(this,n,!1);return r.addAll(e,Oe.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new es(this,n,!0);return r.addAll(e,Oe.none,n.from,n.to),K.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],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(o.getAttrs){let a=o.getAttrs(n);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let n=[];function r(s){let i=s.priority==null?50:s.priority,o=0;for(;o<n.length;o++){let l=n[o];if((l.priority==null?50:l.priority)<i)break}n.splice(o,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(o=>{r(o=ts(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=ts(o)),o.node||o.ignore||o.mark||(o.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new tn(e,tn.schemaRules(e)))}}const ri={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},Ul={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},si={ol:!0,ul:!0},Ft=1,Gn=2,Mt=4;function Yr(t,e,n){return e!=null?(e?Ft:0)|(e==="full"?Gn:0):t&&t.whitespace=="pre"?Ft|Gn:n&~Mt}class Kt{constructor(e,n,r,s,i,o){this.type=e,this.attrs=n,this.marks=r,this.solid=s,this.options=o,this.content=[],this.activeMarks=Oe.none,this.match=i||(o&Mt?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(q.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Ft)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let n=q.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(q.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&&!ri.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class es{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=n.topNode,i,o=Yr(null,n.preserveWhitespace,0)|(r?Mt:0);s?i=new Kt(s.type,s.attrs,Oe.none,!0,n.topMatch||s.type.contentMatch,o):r?i=new Kt(null,null,Oe.none,!0,null,o):i=new Kt(e.schema.topNodeType,null,Oe.none,!0,null,o),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,s=this.top,i=s.options&Gn?"full":this.localPreserveWS||(s.options&Ft)>0,{schema:o}=this.parser;if(i==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
11
+ `);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(o.linebreakReplacement.create(),n,!0),l[a]&&this.insertNode(o.text(l[a]),n,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=s.content[s.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.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(),l;si.hasOwnProperty(o)&&this.parser.normalizeLists&&ql(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:Ul.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,n);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let u,d=this.needsBlock;if(ri.hasOwnProperty(o))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),u=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let f=a&&a.skip?n:this.readStyles(e,n);f&&this.addAll(e,f),u&&this.sync(i),this.needsBlock=d}else{let u=this.readStyles(e,n);u&&this.addElementByRule(e,a,u,a.consuming===!1?l: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 l=void 0;;){let a=this.parser.matchStyle(i,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?n=n.filter(u=>!a.clearMark(u)):n=n.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return n}addElementByRule(e,n,r,s){let i,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(o,n.attrs||null,r,n.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[n.mark];r=r.concat(a.create(n.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,n,r,s){let i=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=s==null?null:e.childNodes[s];o!=l;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,n);this.findAtPoint(e,i)}findPlace(e,n,r){let s,i;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],u=a.findWrapping(e);if(u&&(!s||s.length>u.length+l)&&(s=u,i=a,!u.length))break;if(a.solid){if(r)break;l+=2}}if(!s)return null;this.sync(i);for(let o=0;o<s.length;o++)n=this.enterInner(s[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let s=this.findPlace(e,n,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let o=Oe.none;for(let l of s.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):ns(l.type,e.type))&&(o=l.addToSet(o));return i.content.push(e.mark(o)),!0}return!1}enter(e,n,r,s){let i=this.findPlace(e.create(n),r,!1);return i&&(i=this.enterInner(e,n,r,!0,s)),i}enterInner(e,n,r,s=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=Yr(e,i,o.options);o.options&Mt&&o.content.length==0&&(l|=Mt);let a=Oe.none;return r=r.filter(u=>(o.type?o.type.allowsMarkType(u.type):ns(u.type,e))?(a=u.addToSet(a),!1):!0),this.nodes.push(new Kt(e,n,a,s,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Ft)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&n.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(s?0:1),o=(l,a)=>{for(;l>=0;l--){let u=n[l];if(u==""){if(l==n.length-1||l==0)continue;for(;a>=i;a--)if(o(l-1,a))return!0;return!1}else{let d=a>0||a==0&&s?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!d||d.name!=u&&!d.isInGroup(u))return!1;a--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function ql(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&si.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 ts(t){let e={};for(let n in t)e[n]=t[n];return e}function ns(t,e){let n=e.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(t))continue;let i=[],o=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:u,next:d}=l.edge(a);if(u==e||i.indexOf(d)<0&&o(d))return!0}};if(o(s.contentMatch))return!0}}class gn{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=jn(n).createDocumentFragment());let s=r,i=[];return e.forEach(o=>{if(i.length||o.marks.length){let l=0,a=0;for(;l<i.length&&a<o.marks.length;){let u=o.marks[a];if(!this.marks[u.type.name]){a++;continue}if(!u.eq(i[l][0])||u.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)s=i.pop()[1];for(;a<o.marks.length;){let u=o.marks[a++],d=this.serializeMark(u,o.isInline,n);d&&(i.push([u,s]),s.appendChild(d.dom),s=d.contentDOM||d.dom)}}s.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:s}=Zt(jn(n),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,s)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let s=this.marks[e.type.name];return s&&Zt(jn(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return Zt(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new gn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=rs(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return rs(e.marks)}}function rs(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function jn(t){return t.document||window.document}const ss=new WeakMap;function Jl(t){let e=ss.get(t);return e===void 0&&ss.set(t,e=Wl(t)),e}function Wl(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)n(r[s]);else for(let s in r)n(r[s])}return n(t),e}function Zt(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let s=e[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=Jl(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=s.indexOf(" ");o>0&&(n=s.slice(0,o),s=s.slice(o+1));let l,a=n?t.createElementNS(n,s):t.createElement(s),u=e[1],d=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){d=2;for(let f in u)if(u[f]!=null){let p=f.indexOf(" ");p>0?a.setAttributeNS(f.slice(0,p),f.slice(p+1),u[f]):f=="style"&&a.style?a.style.cssText=u[f]:a.setAttribute(f,u[f])}}for(let f=d;f<e.length;f++){let p=e[f];if(p===0){if(f<e.length-1||f>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:m,contentDOM:C}=Zt(t,p,n,r);if(a.appendChild(m),C){if(l)throw new RangeError("Multiple content holes");l=C}}}return{dom:a,contentDOM:l}}const ii=65535,oi=Math.pow(2,16);function Gl(t,e){return t+e*oi}function is(t){return t&ii}function Zl(t){return(t-(t&ii))/oi}const li=1,ai=2,Qt=4,ci=8;class Zn{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&ci)>0}get deletedBefore(){return(this.delInfo&(li|Qt))>0}get deletedAfter(){return(this.delInfo&(ai|Qt))>0}get deletedAcross(){return(this.delInfo&Qt)>0}}class Ne{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Ne.empty)return Ne.empty}recover(e){let n=0,r=is(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+Zl(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let s=0,i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let u=this.ranges[l+i],d=this.ranges[l+o],f=a+u;if(e<=f){let p=u?e==a?-1:e==f?1:n:n,m=a+s+(p<0?0:d);if(r)return m;let C=e==(n<0?a:f)?null:Gl(l/3,e-a),b=e==a?ai:e==f?li:Qt;return(n<0?e!=a:e!=f)&&(b|=ci),new Zn(m,b,C)}s+=d-u}return r?e+s:new Zn(e+s,0,null)}touches(e,n){let r=0,s=is(n),i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let u=this.ranges[l+i],d=a+u;if(e<=d&&l==s*3)return!0;r+=this.ranges[l+o]-u}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let o=this.ranges[s],l=o-(this.inverted?i:0),a=o+(this.inverted?0:i),u=this.ranges[s+n],d=this.ranges[s+r];e(l,l+u,a,a+d),i+=d-u}}invert(){return new Ne(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Ne.empty:new Ne(e<0?[0,-e,0]:[0,0,e])}}Ne.empty=new Ne([]);class nn{constructor(e,n,r=0,s=e?e.length:0){this.mirror=n,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new nn(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let s=e.getMirror(n);this.appendMap(e._maps[n],s!=null&&s<n?r+s:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let s=e.getMirror(n);this.appendMap(e._maps[n].invert(),s!=null&&s>n?r-s-1:void 0)}}invert(){let e=new nn;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let s=0;for(let i=this.from;i<this.to;i++){let o=this._maps[i],l=o.mapResult(e,n);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this._maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return r?e:new Zn(e,s,null)}}const Ln=Object.create(null);class ge{getMap(){return Ne.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Ln[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Ln)throw new RangeError("Duplicate use of step JSON ID "+e);return Ln[e]=n,n.prototype.jsonID=e,n}}class ce{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new ce(e,null)}static fail(e){return new ce(null,e)}static fromReplace(e,n,r,s){try{return ce.ok(e.replace(n,r,s))}catch(i){if(i instanceof zl)return ce.fail(i.message);throw i}}}function mr(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(mr(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return q.fromArray(r)}class it extends ge{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 K(mr(n.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),n.openStart,n.openEnd);return ce.fromReplace(e,this.from,this.to,i)}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 it(n.pos,r.pos,this.mark)}merge(e){return e instanceof it&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new it(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 it(n.from,n.to,e.markFromJSON(n.mark))}}ge.jsonID("addMark",it);class ot extends ge{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 K(mr(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return ce.fromReplace(e,this.from,this.to,r)}invert(){return new it(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:"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 ot(n.from,n.to,e.markFromJSON(n.mark))}}ge.jsonID("removeMark",ot);class lt extends ge{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ce.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ce.fromReplace(e,this.pos,this.pos+1,new K(q.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 Pt(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))}}ge.jsonID("addNodeMark",lt);class Pt extends ge{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ce.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return ce.fromReplace(e,this.pos,this.pos+1,new K(q.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 Pt(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Pt(n.pos,e.markFromJSON(n.mark))}}ge.jsonID("removeNodeMark",Pt);class _e extends ge{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&Qn(e,this.from,this.to)?ce.fail("Structure replace would overwrite content"):ce.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ne([this.from,this.to-this.from,this.slice.size])}invert(e){return new _e(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 _e(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof _e)||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?K.empty:new K(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new _e(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?K.empty:new K(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new _e(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 _e(n.from,n.to,K.fromJSON(e,n.slice),!!n.structure)}}ge.jsonID("replace",_e);class kt extends ge{constructor(e,n,r,s,i,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=l}apply(e){if(this.structure&&(Qn(e,this.from,this.gapFrom)||Qn(e,this.gapTo,this.to)))return ce.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return ce.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?ce.fromReplace(e,this.from,this.to,r):ce.fail("Content does not fit in gap")}getMap(){return new Ne([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 kt(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 kt(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 kt(n.from,n.to,n.gapFrom,n.gapTo,K.fromJSON(e,n.slice),n.insert,!!n.structure)}}ge.jsonID("replaceAround",kt);function Qn(t,e,n){let r=t.resolve(e),s=n-e,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,s--}}return!1}function ui(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let s=n.content;for(let i=0;i<n.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.size?2:1);i++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,a=r.index(o)+(l>0?1:0),u=r.node(o),d=!1;if(i==1)d=u.canReplace(a,a,s);else{let f=u.contentMatchAt(a).findWrapping(s.firstChild.type);d=f&&u.canReplaceWith(a,a,f[0])}if(d)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}class Ot extends ge{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 ce.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 ce.fromReplace(e,this.pos,this.pos+1,new K(q.from(s),0,n.isLeaf?0:1))}getMap(){return Ne.empty}invert(e){return new Ot(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 Ot(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 Ot(n.pos,n.attr,n.value)}}ge.jsonID("attr",Ot);class rn extends ge{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 ce.ok(r)}getMap(){return Ne.empty}invert(e){return new rn(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new rn(n.attr,n.value)}}ge.jsonID("docAttr",rn);let $t=class extends Error{};$t=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};$t.prototype=Object.create(Error.prototype);$t.prototype.constructor=$t;$t.prototype.name="TransformError";const Rn=Object.create(null);class X{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Ql(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=K.empty){let r=n.content.lastChild,s=null;for(let l=0;l<n.openEnd;l++)s=r,r=r.lastChild;let i=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:u}=o[l],d=e.mapping.slice(i);e.replaceRange(d.map(a.pos),d.map(u.pos),l?K.empty:n),l==0&&as(e,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:o,$to:l}=s[i],a=e.mapping.slice(r),u=a.map(o.pos),d=a.map(l.pos);i?e.deleteRange(u,d):(e.replaceRangeWith(u,d,n),as(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new Q(e):yt(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?yt(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):yt(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 Ve(e.node(0))}static atStart(e){return yt(e,e,0,0,1)||new Ve(e)}static atEnd(e){return yt(e,e,e.content.size,e.childCount,-1)||new Ve(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Rn[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Rn)throw new RangeError("Duplicate use of selection JSON ID "+e);return Rn[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Q.between(this.$anchor,this.$head).getBookmark()}}X.prototype.visible=!0;class Ql{constructor(e,n){this.$from=e,this.$to=n}}let os=!1;function ls(t){!os&&!t.parent.inlineContent&&(os=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Q extends X{constructor(e,n=e){ls(e),ls(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return X.near(r);let s=e.resolve(n.map(this.anchor));return new Q(s.parent.inlineContent?s:r,r)}replace(e,n=K.empty){if(super.replace(e,n),n==K.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Q&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new yn(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Q(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let s=e.resolve(n);return new this(s,r==n?s:e.resolve(r))}static between(e,n,r){let s=e.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let i=X.findFrom(n,r,!0)||X.findFrom(n,-r,!0);if(i)n=i.$head;else return X.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(X.findFrom(e,-r,!0)||X.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new Q(e,n)}}X.jsonID("text",Q);class yn{constructor(e,n){this.anchor=e,this.head=n}map(e){return new yn(e.map(this.anchor),e.map(this.head))}resolve(e){return Q.between(e.resolve(this.anchor),e.resolve(this.head))}}class J extends X{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),i=e.resolve(s);return r?X.near(i):new J(i)}content(){return new K(q.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 gr(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;X.jsonID("node",J);class gr{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new yn(r,r):new gr(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&J.isSelectable(r)?new J(n):X.near(n)}}class Ve extends X{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=K.empty){if(n==K.empty){e.delete(0,e.doc.content.size);let r=X.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Ve(e)}map(e){return new Ve(e)}eq(e){return e instanceof Ve}getBookmark(){return Xl}}X.jsonID("all",Ve);const Xl={map(){return this},resolve(t){return new Ve(t)}};function yt(t,e,n,r,s,i=!1){if(e.inlineContent)return Q.create(t,n);for(let o=r-(s>0?0:1);s>0?o<e.childCount:o>=0;o+=s){let l=e.child(o);if(l.isAtom){if(!i&&J.isSelectable(l))return J.create(t,n-(s<0?l.nodeSize:0))}else{let a=yt(t,l,n+s,s<0?l.childCount:0,s,i);if(a)return a}n+=l.nodeSize*s}return null}function as(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof _e||s instanceof kt))return;let i=t.mapping.maps[r],o;i.forEach((l,a,u,d)=>{o==null&&(o=d)}),t.setSelection(X.near(t.doc.resolve(o),n))}function cs(t,e){return!e||!t?t:t.bind(e)}class Jt{constructor(e,n,r){this.name=e,this.init=cs(n.init,r),this.apply=cs(n.apply,r)}}new Jt("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Jt("selection",{init(t,e){return t.selection||X.atStart(e.doc)},apply(t){return t.selection}}),new Jt("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Jt("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}});function di(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=di(s,e,{})),n[r]=s}return n}class xn{constructor(e){this.spec=e,this.props={},e.props&&di(e.props,this,this.props),this.key=e.key?e.key.key:fi("plugin")}getState(e){return e[this.key]}}const Fn=Object.create(null);function fi(t){return t in Fn?t+"$"+ ++Fn[t]:(Fn[t]=0,t+"$")}class yr{constructor(e="key"){this.key=fi(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Yl=/^```([a-z]+)?[\s\n]$/,ea=/^~~~([a-z]+)?[\s\n]$/,ta=R.Node.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options,i=[...((e=t.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",R.mergeAttributes(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
13
13
 
14
- `);return!i||!o?!1:n.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=n,{selection:t,doc:r}=e,{$from:s,empty:i}=t;if(!i||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const l=s.after();return l===void 0?!1:r.nodeAt(l)?n.commands.command(({tr:c})=>(c.setSelection(v.near(r.resolve(l))),!0)):n.commands.exitCode()}}},addInputRules(){return[m.textblockTypeInputRule({find:ei,type:this.type,getAttributes:n=>({language:n[1]})}),m.textblockTypeInputRule({find:ti,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new dt({key:new _t("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const t=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s?.mode;if(!t||!i)return!1;const{tr:o,schema:l}=n.state,a=l.text(t.replace(/\r\n?/g,`
15
- `));return o.replaceSelectionWith(this.type.create({language:i},a)),o.selection.$from.parent.type!==this.type&&o.setSelection(N.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),n.dispatch(o),!0}}})]}}),ri=/^\s*>\s$/,si=m.Node.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return["blockquote",m.mergeAttributes(this.options.HTMLAttributes,n),0]},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[m.wrappingInputRule({find:ri,type:this.type})]}}),ii=m.Node.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",m.mergeAttributes(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{if(!m.canInsertNode(e,e.schema.nodes[this.name]))return!1;const{selection:t}=e,{$from:r,$to:s}=t,i=n();return r.parentOffset===0?i.insertContentAt({from:Math.max(r.pos-1,0),to:s.pos},{type:this.name}):m.isNodeSelection(t)?i.insertContentAt(s.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({tr:o,dispatch:l})=>{var a;if(l){const{$to:c}=o.selection,u=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?o.setSelection(N.create(o.doc,c.pos+1)):c.nodeAfter.isBlock?o.setSelection(T.create(o.doc,c.pos)):o.setSelection(N.create(o.doc,c.pos));else{const d=(a=c.parent.type.contentMatch.defaultType)===null||a===void 0?void 0:a.create();d&&(o.insert(u,d),o.setSelection(N.create(o.doc,u+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[m.nodeInputRule({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),oi=m.Node.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",m.mergeAttributes(this.options.HTMLAttributes,n)]},renderText(){return`
16
- `},addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:s,storedMarks:i}=t;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,a=i||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&a&&o){const d=a.filter(h=>l.includes(h.type.name));c.ensureMarks(d)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var nt=200,L=function(){};L.prototype.append=function(e){return e.length?(e=L.from(e),!this.length&&e||e.length<nt&&this.leafAppend(e)||this.length<nt&&e.leafPrepend(this)||this.appendInner(e)):this};L.prototype.prepend=function(e){return e.length?L.from(e).append(this):this};L.prototype.appendInner=function(e){return new li(this,e)};L.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?L.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};L.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};L.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};L.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,o){return s.push(e(i,o))},t,r),s};L.from=function(e){return e instanceof L?e:e&&e.length?new ir(e):L.empty};var ir=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,o,l){for(var a=i;a<o;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,o,l){for(var a=i-1;a>=o;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=nt)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=nt)return new e(s.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(L);L.empty=new ir([]);var li=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,i,o){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(i,l),o)===!1||i>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,i)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,o){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(i,l)-l,o+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(s,l),i,o)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(r,s):r>=i?this.right.slice(r-i,s-i):this.left.slice(r,i).append(this.right.slice(0,s-i))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(L);const ai=500;class U{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){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;t&&(s=this.remapping(r,this.items.length),i=s.maps.length);let o=e.tr,l,a,c=[],u=[];return this.items.forEach((d,h)=>{if(!d.step){s||(s=this.remapping(r,h+1),i=s.maps.length),i--,u.push(d);return}if(s){u.push(new _(d.map));let p=d.step.map(s.slice(i)),g;p&&o.maybeStep(p).doc&&(g=o.mapping.maps[o.mapping.maps.length-1],c.push(new _(g,void 0,void 0,c.length+u.length))),i--,g&&s.appendMap(g,i)}else o.maybeStep(d.step);if(d.selection)return l=s?d.selection.map(s.slice(i)):d.selection,a=new U(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,t,r,s){let i=[],o=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),h=new _(e.mapping.maps[u],d,t),p;(p=a&&a.merge(h))&&(h=p,u?i.pop():l=l.slice(0,l.length-1)),i.push(h),t&&(o++,t=void 0),s||(a=h)}let c=o-r.depth;return c>ui&&(l=ci(l,c),o-=c),new U(l.append(i),o)}remapping(e,t){let r=new et;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,t),r}addMaps(e){return this.eventCount==0?this:new U(this.items.append(e.map(t=>new _(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-t),i=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(h=>{h.selection&&l--},s);let a=t;this.items.forEach(h=>{let p=i.getMirror(--a);if(p==null)return;o=Math.min(o,p);let g=i.maps[p];if(h.step){let y=e.steps[p].invert(e.docs[p]),b=h.selection&&h.selection.map(i.slice(a+1,p));b&&l++,r.push(new _(g,y,b))}else r.push(new _(g))},s);let c=[];for(let h=t;h<o;h++)c.push(new _(i.maps[h]));let u=this.items.slice(0,s).append(c).append(r),d=new U(u,l);return d.emptyItemCount()>ai&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,s=[],i=0;return this.items.forEach((o,l)=>{if(l>=e)s.push(o),o.selection&&i++;else if(o.step){let a=o.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let u=o.selection&&o.selection.map(t.slice(r));u&&i++;let d=new _(c.invert(),a,u),h,p=s.length-1;(h=s.length&&s[p].merge(d))?s[p]=h:s.push(d)}}else o.map&&r--},this.items.length,0),new U(L.from(s.reverse()),i)}}U.empty=new U(L.empty,0);function ci(n,e){let t;return n.forEach((r,s)=>{if(r.selection&&e--==0)return t=s,!1}),n.slice(t)}class _{constructor(e,t,r,s){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new _(t.getMap().invert(),t,this.selection)}}}class se{constructor(e,t,r,s,i){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const ui=20;function di(n,e,t,r){let s=t.getMeta(xe),i;if(s)return s.historyState;t.getMeta(pi)&&(n=new se(n.done,n.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(o&&o.getMeta(xe))return o.getMeta(xe).redo?new se(n.done.addTransform(t,void 0,r,Ye(e)),n.undone,An(t.mapping.maps),n.prevTime,n.prevComposition):new se(n.done,n.undone.addTransform(t,void 0,r,Ye(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!o&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!fi(t,n.prevRanges)),c=o?Nt(n.prevRanges,t.mapping):An(t.mapping.maps);return new se(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,Ye(e)),U.empty,c,t.time,l??n.prevComposition)}else return(i=t.getMeta("rebased"))?new se(n.done.rebased(t,i),n.undone.rebased(t,i),Nt(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new se(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Nt(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function fi(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&s>=e[i]&&(t=!0)}),t}function An(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,s,i,o)=>e.push(i,o));return e}function Nt(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let s=e.map(n[r],1),i=e.map(n[r+1],-1);s<=i&&t.push(s,i)}return t}function hi(n,e,t){let r=Ye(e),s=xe.get(e).spec.config,i=(t?n.undone:n.done).popEvent(e,r);if(!i)return null;let o=i.selection.resolve(i.transform.doc),l=(t?n.done:n.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),a=new se(t?l:i.remaining,t?i.remaining:l,null,0,-1);return i.transform.setSelection(o).setMeta(xe,{redo:t,historyState:a})}let vt=!1,Tn=null;function Ye(n){let e=n.plugins;if(Tn!=e){vt=!1,Tn=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){vt=!0;break}}return vt}const xe=new _t("history"),pi=new _t("closeHistory");function mi(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new dt({key:xe,state:{init(){return new se(U.empty,U.empty,null,0,-1)},apply(e,t,r){return di(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,s=r=="historyUndo"?lr:r=="historyRedo"?ar:null;return!s||!e.editable?!1:(t.preventDefault(),s(e.state,e.dispatch))}}}})}function or(n,e){return(t,r)=>{let s=xe.getState(t);if(!s||(n?s.undone:s.done).eventCount==0)return!1;if(r){let i=hi(s,t,n);i&&r(e?i.scrollIntoView():i)}return!0}}const lr=or(!1,!0),ar=or(!0,!0),Ie=m.Extension.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>lr(n,e),redo:()=>({state:n,dispatch:e})=>ar(n,e)}},addProseMirrorPlugins(){return[mi(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()}}}),gi=m.Node.create({name:"doc",topNode:!0,content:"block+"}),yi=m.Node.create({name:"text",group:"inline"});function xi(n={}){return new dt({view(e){return new bi(e,n)}})}class bi{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.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:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.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),t=!e.parent.inlineContent,r,s=this.editorView.dom,i=s.getBoundingClientRect(),o=i.width/s.offsetWidth,l=i.height/s.offsetHeight;if(t){let d=e.nodeBefore,h=e.nodeAfter;if(d||h){let p=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(p){let g=p.getBoundingClientRect(),y=d?g.bottom:g.top;d&&h&&(y=(y+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let b=this.width/2*l;r={left:g.left,right:g.right,top:y-b,bottom:y+b}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),h=this.width/2*o;r={left:d.left-h,right:d.left+h,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),h=d.width/a.offsetWidth,p=d.height/a.offsetHeight;c=d.left-a.scrollLeft*h,u=d.top-a.scrollTop*p}this.element.style.left=(r.left-c)/o+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),s=r&&r.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,t,e):s;if(t&&!i){let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=nr(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}const ki=m.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[xi(this.options)]}});var ae={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:"'"},rt={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Ci=typeof navigator<"u"&&/Mac/.test(navigator.platform),Si=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var R=0;R<10;R++)ae[48+R]=ae[96+R]=String(R);for(var R=1;R<=24;R++)ae[R+111]="F"+R;for(var R=65;R<=90;R++)ae[R]=String.fromCharCode(R+32),rt[R]=String.fromCharCode(R);for(var Ot in ae)rt.hasOwnProperty(Ot)||(rt[Ot]=ae[Ot]);function Ai(n){var e=Ci&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Si&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?rt:ae)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const Ti=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Mi=typeof navigator<"u"&&/Win/.test(navigator.platform);function Ei(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,s,i,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))Ti?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),s&&(t="Ctrl-"+t),o&&(t="Meta-"+t),i&&(t="Shift-"+t),t}function Ni(n){let e=Object.create(null);for(let t in n)e[Ei(t)]=n[t];return e}function wt(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function vi(n){let e=Ni(n);return function(t,r){let s=Ai(r),i,o=e[wt(s,r)];if(o&&o(t.state,t.dispatch,t))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[wt(s,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(Mi&&r.ctrlKey&&r.altKey)&&(i=ae[r.keyCode])&&i!=s){let l=e[wt(i,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const Ce=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},cr=function(n,e,t,r){return t&&(Mn(n,e,t,r,-1)||Mn(n,e,t,r,1))},Oi=/^(img|br|input|textarea|hr)$/i;function Mn(n,e,t,r,s){for(var i;;){if(n==t&&e==r)return!0;if(e==(s<0?0:st(n))){let o=n.parentNode;if(!o||o.nodeType!=1||Zt(n)||Oi.test(n.nodeName)||n.contentEditable=="false")return!1;e=Ce(n)+(s<0?0:1),n=o}else if(n.nodeType==1){let o=n.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 n=o,e=s<0?st(n):0}else return!1}}function st(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function wi(n,e,t){for(let r=e==0,s=e==st(n);r||s;){if(n==t)return!0;let i=Ce(n);if(n=n.parentNode,!n)return!1;r=r&&i==0,s=s&&i==st(n)}}function Zt(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const ur=function(n){return n.focusNode&&cr(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function dr(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}const X=typeof navigator<"u"?navigator:null,En=typeof document<"u"?document:null,ce=X&&X.userAgent||"",Bt=/Edge\/(\d+)/.exec(ce),fr=/MSIE \d/.exec(ce),Ft=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ce),$e=!!(fr||Ft||Bt),hr=fr?document.documentMode:Ft?+Ft[1]:Bt?+Bt[1]:0,ft=!$e&&/gecko\/(\d+)/i.test(ce);ft&&+(/Firefox\/(\d+)/.exec(ce)||[0,0])[1];const Ht=!$e&&/Chrome\/(\d+)/.exec(ce),ne=!!Ht,pr=Ht?+Ht[1]:0,Se=!$e&&!!X&&/Apple Computer/.test(X.vendor),Gt=Se&&(/Mobile\/\w+/.test(ce)||!!X&&X.maxTouchPoints>2),J=Gt||(X?/Mac/.test(X.platform):!1),mr=X?/Win/.test(X.platform):!1,qe=/Android \d/.test(ce),Xt=!!En&&"webkitFontSmoothing"in En.documentElement.style,Ii=Xt?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Di(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let s=n.docView.nearestDesc(t.focusNode),i=s&&s.size==0,o=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,c;if(ur(t)){for(a=o;s&&!s.node;)s=s.parent;let d=s.node;if(s&&d.isAtom&&T.isSelectable(d)&&s.parent&&!(d.isInline&&wi(t.focusNode,t.focusOffset,s.dom))){let h=s.posBefore;c=new T(o==h?l:r.resolve(h))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let d=o,h=o;for(let p=0;p<t.rangeCount;p++){let g=t.getRangeAt(p);d=Math.min(d,n.docView.posFromDOM(g.startContainer,g.startOffset,1)),h=Math.max(h,n.docView.posFromDOM(g.endContainer,g.endOffset,-1))}if(d<0)return null;[a,o]=h==n.state.selection.anchor?[h,d]:[d,h],l=r.resolve(o)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let d=e=="pointer"||n.state.selection.head<l.pos&&!i?1:-1;c=yr(n,u,l,d)}return c}function gr(n){return n.editable?n.hasFocus():zi(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Yt(n,e=!1){let t=n.state.selection;if(Pi(n,t),!!gr(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&ne){let r=n.domSelectionRange(),s=n.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&cr(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Ri(n);else{let{anchor:r,head:s}=t,i,o;Nn&&!(t instanceof N)&&(t.$from.parent.inlineContent||(i=vn(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(o=vn(n,t.to))),n.docView.setSelection(r,s,n,e),Nn&&(i&&On(i),o&&On(o)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Li(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Nn=Se||ne&&pr<63;function vn(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),s=r<t.childNodes.length?t.childNodes[r]:null,i=r?t.childNodes[r-1]:null;if(Se&&s&&s.contentEditable=="false")return It(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return It(s);if(i)return It(i)}}function It(n){return n.contentEditable="true",Se&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function On(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Li(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,s=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=s)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!gr(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Ri(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,r=t.nodeName=="IMG";r?e.collapse(t.parentNode,Ce(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&$e&&hr<=11&&(t.disabled=!0,t.disabled=!1)}function Pi(n,e){if(e instanceof T){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(wn(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else wn(n)}function wn(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function yr(n,e,t,r){return n.someProp("createSelectionBetween",s=>s(n,e,t))||N.between(e,t,r)}function zi(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function jt(n,e){let{$anchor:t,$head:r}=n.selection,s=e>0?t.max(r):t.min(r),i=s.parent.inlineContent?s.depth?n.doc.resolve(e>0?s.after():s.before()):null:s;return i&&v.findFrom(i,e)}function ie(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function In(n,e,t){let r=n.state.selection;if(r instanceof N)if(t.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=n.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return ie(n,new N(r.$anchor,o))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let s=jt(n.state,e);return s&&s instanceof T?ie(n,s):!1}else if(!(J&&t.indexOf("m")>-1)){let s=r.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,o;if(!i||i.isText)return!1;let l=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(o=n.docView.descAt(l))&&!o.contentDOM?T.isSelectable(i)?ie(n,new T(e<0?n.state.doc.resolve(s.pos-i.nodeSize):s)):Xt?ie(n,new N(n.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof T&&r.node.isInline)return ie(n,new N(e>0?r.$to:r.$from));{let s=jt(n.state,e);return s?ie(n,s):!1}}}function it(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Re(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Ae(n,e){return e<0?Bi(n):Fi(n)}function Bi(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let s,i,o=!1;for(ft&&t.nodeType==1&&r<it(t)&&Re(t.childNodes[r],-1)&&(o=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Re(l,-1))s=t,i=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(xr(t))break;{let l=t.previousSibling;for(;l&&Re(l,-1);)s=t.parentNode,i=Ce(l),l=l.previousSibling;if(l)t=l,r=it(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}o?$t(n,t,r):s&&$t(n,s,i)}function Fi(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let s=it(t),i,o;for(;;)if(r<s){if(t.nodeType!=1)break;let l=t.childNodes[r];if(Re(l,1))i=t,o=++r;else break}else{if(xr(t))break;{let l=t.nextSibling;for(;l&&Re(l,1);)i=l.parentNode,o=Ce(l)+1,l=l.nextSibling;if(l)t=l,r=0,s=it(t);else{if(t=t.parentNode,t==n.dom)break;r=s=0}}}i&&$t(n,i,o)}function xr(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Hi(n,e){for(;n&&e==n.childNodes.length&&!Zt(n);)e=Ce(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function ji(n,e){for(;n&&!e&&!Zt(n);)e=Ce(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function $t(n,e,t){if(e.nodeType!=3){let i,o;(o=Hi(e,t))?(e=o,t=0):(i=ji(e,t))&&(e=i,t=i.nodeValue.length)}let r=n.domSelection();if(!r)return;if(ur(r)){let i=document.createRange();i.setEnd(e,t),i.setStart(e,t),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:s}=n;setTimeout(()=>{n.state==s&&Yt(n)},50)}function Dn(n,e){let t=n.state.doc.resolve(e);if(!(ne||mr)&&t.parent.inlineContent){let s=n.coordsAtPos(e);if(e>t.start()){let i=n.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<t.end()){let i=n.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(n.dom).direction=="rtl"?"rtl":"ltr"}function Ln(n,e,t){let r=n.state.selection;if(r instanceof N&&!r.empty||t.indexOf("s")>-1||J&&t.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=jt(n.state,e);if(o&&o instanceof T)return ie(n,o)}if(!s.parent.inlineContent){let o=e<0?s:i,l=r instanceof G?v.near(o,e):v.findFrom(o,e);return l?ie(n,l):!1}return!1}function Rn(n,e){if(!(n.state.selection instanceof N))return!0;let{$head:t,$anchor:r,empty:s}=n.state.selection;if(!t.sameParent(r))return!0;if(!s)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(i&&!i.isText){let o=n.state.tr;return e<0?o.delete(t.pos-i.nodeSize,t.pos):o.delete(t.pos,t.pos+i.nodeSize),n.dispatch(o),!0}return!1}function Pn(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function $i(n){if(!Se||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Pn(n,r,"true"),setTimeout(()=>Pn(n,r,"false"),20)}return!1}function qi(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Vi(n,e){let t=e.keyCode,r=qi(e);if(t==8||J&&t==72&&r=="c")return Rn(n,-1)||Ae(n,-1);if(t==46&&!e.shiftKey||J&&t==68&&r=="c")return Rn(n,1)||Ae(n,1);if(t==13||t==27)return!0;if(t==37||J&&t==66&&r=="c"){let s=t==37?Dn(n,n.state.selection.from)=="ltr"?-1:1:-1;return In(n,s,r)||Ae(n,s)}else if(t==39||J&&t==70&&r=="c"){let s=t==39?Dn(n,n.state.selection.from)=="ltr"?1:-1:1;return In(n,s,r)||Ae(n,s)}else{if(t==38||J&&t==80&&r=="c")return Ln(n,-1,r)||Ae(n,-1);if(t==40||J&&t==78&&r=="c")return $i(n)||Ln(n,1,r)||Ae(n,1);if(r==(J?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function br(n,e){n.someProp("transformCopied",p=>{e=p(e,n)});let t=[],{content:r,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let p=r.firstChild;t.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let o=n.someProp("clipboardSerializer")||ct.fromSchema(n.state.schema),l=Mr(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=Tr[c.nodeName.toLowerCase()]);){for(let p=u.length-1;p>=0;p--){let g=l.createElement(u[p]);for(;a.firstChild;)g.appendChild(a.firstChild);a.appendChild(g),d++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${i}${d?` -${d}`:""} ${JSON.stringify(t)}`);let h=n.someProp("clipboardTextSerializer",p=>p(e,n))||e.content.textBetween(0,e.content.size,`
14
+ `);return!i||!o?!1:t.chain().command(({tr:l})=>(l.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 l=s.after();return l===void 0?!1:r.nodeAt(l)?t.commands.command(({tr:u})=>(u.setSelection(X.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[R.textblockTypeInputRule({find:Yl,type:this.type,getAttributes:t=>({language:t[1]})}),R.textblockTypeInputRule({find:ea,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new xn({key:new yr("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:l}=t.state,a=l.text(n.replace(/\r\n?/g,`
15
+ `));return o.replaceSelectionWith(this.type.create({language:i},a)),o.selection.$from.parent.type!==this.type&&o.setSelection(Q.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),na=/^\s*>\s$/,ra=R.Node.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",R.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[R.wrappingInputRule({find:na,type:this.type})]}}),sa=R.Node.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",R.mergeAttributes(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!R.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}):R.isNodeSelection(n)?i.insertContentAt(s.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({tr:o,dispatch:l})=>{var a;if(l){const{$to:u}=o.selection,d=u.end();if(u.nodeAfter)u.nodeAfter.isTextblock?o.setSelection(Q.create(o.doc,u.pos+1)):u.nodeAfter.isBlock?o.setSelection(J.create(o.doc,u.pos)):o.setSelection(Q.create(o.doc,u.pos));else{const f=(a=u.parent.type.contentMatch.defaultType)===null||a===void 0?void 0:a.create();f&&(o.insert(d,f),o.setSelection(Q.create(o.doc,d+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[R.nodeInputRule({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),ia=R.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",R.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:l}=r.extensionManager,a=i||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:u,dispatch:d})=>{if(d&&a&&o){const f=a.filter(p=>l.includes(p.type.name));u.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var sn=200,he=function(){};he.prototype.append=function(e){return e.length?(e=he.from(e),!this.length&&e||e.length<sn&&this.leafAppend(e)||this.length<sn&&e.leafPrepend(this)||this.appendInner(e)):this};he.prototype.prepend=function(e){return e.length?he.from(e).append(this):this};he.prototype.appendInner=function(e){return new oa(this,e)};he.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?he.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};he.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};he.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)};he.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};he.from=function(e){return e instanceof he?e:e&&e.length?new hi(e):he.empty};var hi=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,o,l){for(var a=i;a<o;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,o,l){for(var a=i-1;a>=o;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=sn)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=sn)return new e(s.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(he);he.empty=new hi([]);var oa=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,i,o){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(i,l),o)===!1||i>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,i)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,o){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(i,l)-l,o+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(s,l),i,o)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(r,s):r>=i?this.right.slice(r-i,s-i):this.left.slice(r,i).append(this.right.slice(0,s-i))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(he);const la=500;class De{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,i;n&&(s=this.remapping(r,this.items.length),i=s.maps.length);let o=e.tr,l,a,u=[],d=[];return this.items.forEach((f,p)=>{if(!f.step){s||(s=this.remapping(r,p+1),i=s.maps.length),i--,d.push(f);return}if(s){d.push(new Pe(f.map));let m=f.step.map(s.slice(i)),C;m&&o.maybeStep(m).doc&&(C=o.mapping.maps[o.mapping.maps.length-1],u.push(new Pe(C,void 0,void 0,u.length+d.length))),i--,C&&s.appendMap(C,i)}else o.maybeStep(f.step);if(f.selection)return l=s?f.selection.map(s.slice(i)):f.selection,a=new De(this.items.slice(0,r).append(d.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,n,r,s){let i=[],o=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let f=e.steps[d].invert(e.docs[d]),p=new Pe(e.mapping.maps[d],f,n),m;(m=a&&a.merge(p))&&(p=m,d?i.pop():l=l.slice(0,l.length-1)),i.push(p),n&&(o++,n=void 0),s||(a=p)}let u=o-r.depth;return u>ca&&(l=aa(l,u),o-=u),new De(l.append(i),o)}remapping(e,n){let r=new nn;return this.items.forEach((s,i)=>{let o=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new De(this.items.append(e.map(n=>new Pe(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-n),i=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(p=>{p.selection&&l--},s);let a=n;this.items.forEach(p=>{let m=i.getMirror(--a);if(m==null)return;o=Math.min(o,m);let C=i.maps[m];if(p.step){let b=e.steps[m].invert(e.docs[m]),k=p.selection&&p.selection.map(i.slice(a+1,m));k&&l++,r.push(new Pe(C,b,k))}else r.push(new Pe(C))},s);let u=[];for(let p=n;p<o;p++)u.push(new Pe(i.maps[p]));let d=this.items.slice(0,s).append(u).append(r),f=new De(d,l);return f.emptyItemCount()>la&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,s=[],i=0;return this.items.forEach((o,l)=>{if(l>=e)s.push(o),o.selection&&i++;else if(o.step){let a=o.step.map(n.slice(r)),u=a&&a.getMap();if(r--,u&&n.appendMap(u,r),a){let d=o.selection&&o.selection.map(n.slice(r));d&&i++;let f=new Pe(u.invert(),a,d),p,m=s.length-1;(p=s.length&&s[m].merge(f))?s[m]=p:s.push(f)}}else o.map&&r--},this.items.length,0),new De(he.from(s.reverse()),i)}}De.empty=new De(he.empty,0);function aa(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}class Pe{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 Pe(n.getMap().invert(),n,this.selection)}}}class Ge{constructor(e,n,r,s,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const ca=20;function ua(t,e,n,r){let s=n.getMeta(ct),i;if(s)return s.historyState;n.getMeta(ha)&&(t=new Ge(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(ct))return o.getMeta(ct).redo?new Ge(t.done.addTransform(n,void 0,r,Xt(e)),t.undone,us(n.mapping.maps),t.prevTime,t.prevComposition):new Ge(t.done,t.undone.addTransform(n,void 0,r,Xt(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=t.prevTime==0||!o&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!da(n,t.prevRanges)),u=o?Pn(t.prevRanges,n.mapping):us(n.mapping.maps);return new Ge(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,Xt(e)),De.empty,u,n.time,l??t.prevComposition)}else return(i=n.getMeta("rebased"))?new Ge(t.done.rebased(n,i),t.undone.rebased(n,i),Pn(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Ge(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Pn(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function da(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 us(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,s,i,o)=>e.push(i,o));return e}function Pn(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let s=e.map(t[r],1),i=e.map(t[r+1],-1);s<=i&&n.push(s,i)}return n}function fa(t,e,n){let r=Xt(e),s=ct.get(e).spec.config,i=(n?t.undone:t.done).popEvent(e,r);if(!i)return null;let o=i.selection.resolve(i.transform.doc),l=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),a=new Ge(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(o).setMeta(ct,{redo:n,historyState:a})}let $n=!1,ds=null;function Xt(t){let e=t.plugins;if(ds!=e){$n=!1,ds=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){$n=!0;break}}return $n}const ct=new yr("history"),ha=new yr("closeHistory");function pa(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new xn({key:ct,state:{init(){return new Ge(De.empty,De.empty,null,0,-1)},apply(e,n,r){return ua(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?mi:r=="historyRedo"?gi:null;return!s||!e.editable?!1:(n.preventDefault(),s(e.state,e.dispatch))}}}})}function pi(t,e){return(n,r)=>{let s=ct.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let i=fa(s,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const mi=pi(!1,!0),gi=pi(!0,!0),fs=R.Extension.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>mi(t,e),redo:()=>({state:t,dispatch:e})=>gi(t,e)}},addProseMirrorPlugins(){return[pa(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()}}}),ma=R.Node.create({name:"doc",topNode:!0,content:"block+"}),ga=R.Node.create({name:"text",group:"inline"});function ya(t={}){return new xn({view(e){return new xa(e,t)}})}class xa{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let i=o=>{this[s](o)};return e.dom.addEventListener(s,i),{name:s,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,s=this.editorView.dom,i=s.getBoundingClientRect(),o=i.width/s.offsetWidth,l=i.height/s.offsetHeight;if(n){let f=e.nodeBefore,p=e.nodeAfter;if(f||p){let m=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(m){let C=m.getBoundingClientRect(),b=f?C.bottom:C.top;f&&p&&(b=(b+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let k=this.width/2*l;r={left:C.left,right:C.right,top:b-k,bottom:b+k}}}}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 a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let u,d;if(!a||a==document.body&&getComputedStyle(a).position=="static")u=-pageXOffset,d=-pageYOffset;else{let f=a.getBoundingClientRect(),p=f.width/a.offsetWidth,m=f.height/a.offsetHeight;u=f.left-a.scrollLeft*p,d=f.top-a.scrollTop*m}this.element.style.left=(r.left-u)/o+"px",this.element.style.top=(r.top-d)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),s=r&&r.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,n,e):s;if(n&&!i){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=ui(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}const ba=R.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[ya(this.options)]}});var Ye={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},on={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ka=typeof navigator<"u"&&/Mac/.test(navigator.platform),va=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var pe=0;pe<10;pe++)Ye[48+pe]=Ye[96+pe]=String(pe);for(var pe=1;pe<=24;pe++)Ye[pe+111]="F"+pe;for(var pe=65;pe<=90;pe++)Ye[pe]=String.fromCharCode(pe+32),on[pe]=String.fromCharCode(pe);for(var Vn in Ye)on.hasOwnProperty(Vn)||(on[Vn]=Ye[Vn]);function Sa(t){var e=ka&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||va&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?on:Ye)[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 Ca=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),wa=typeof navigator<"u"&&/Win/.test(navigator.platform);function Aa(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,s,i,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))Ca?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),o&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function Na(t){let e=Object.create(null);for(let n in t)e[Aa(n)]=t[n];return e}function Bn(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 Ea(t){let e=Na(t);return function(n,r){let s=Sa(r),i,o=e[Bn(s,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[Bn(s,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(wa&&r.ctrlKey&&r.altKey)&&(i=Ye[r.keyCode])&&i!=s){let l=e[Bn(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}const ft=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},yi=function(t,e,n,r){return n&&(hs(t,e,n,r,-1)||hs(t,e,n,r,1))},Ta=/^(img|br|input|textarea|hr)$/i;function hs(t,e,n,r,s){for(var i;;){if(t==n&&e==r)return!0;if(e==(s<0?0:ln(t))){let o=t.parentNode;if(!o||o.nodeType!=1||xr(t)||Ta.test(t.nodeName)||t.contentEditable=="false")return!1;e=ft(t)+(s<0?0:1),t=o}else if(t.nodeType==1){let o=t.childNodes[e+(s<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((i=o.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=s;else return!1;else t=o,e=s<0?ln(t):0}else return!1}}function ln(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Ma(t,e,n){for(let r=e==0,s=e==ln(t);r||s;){if(t==n)return!0;let i=ft(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,s=s&&i==ln(t)}}function xr(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const xi=function(t){return t.focusNode&&yi(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function bi(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}const Be=typeof navigator<"u"?navigator:null,ps=typeof document<"u"?document:null,et=Be&&Be.userAgent||"",Xn=/Edge\/(\d+)/.exec(et),ki=/MSIE \d/.exec(et),Yn=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(et),_t=!!(ki||Yn||Xn),vi=ki?document.documentMode:Yn?+Yn[1]:Xn?+Xn[1]:0,bn=!_t&&/gecko\/(\d+)/i.test(et);bn&&+(/Firefox\/(\d+)/.exec(et)||[0,0])[1];const er=!_t&&/Chrome\/(\d+)/.exec(et),Ue=!!er,Si=er?+er[1]:0,ht=!_t&&!!Be&&/Apple Computer/.test(Be.vendor),br=ht&&(/Mobile\/\w+/.test(et)||!!Be&&Be.maxTouchPoints>2),Me=br||(Be?/Mac/.test(Be.platform):!1),Ci=Be?/Win/.test(Be.platform):!1,Ht=/Android \d/.test(et),kr=!!ps&&"webkitFontSmoothing"in ps.documentElement.style,Oa=kr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Ia(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let s=t.docView.nearestDesc(n.focusNode),i=s&&s.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,u;if(xi(n)){for(a=o;s&&!s.node;)s=s.parent;let f=s.node;if(s&&f.isAtom&&J.isSelectable(f)&&s.parent&&!(f.isInline&&Ma(n.focusNode,n.focusOffset,s.dom))){let p=s.posBefore;u=new J(o==p?l:r.resolve(p))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=o,p=o;for(let m=0;m<n.rangeCount;m++){let C=n.getRangeAt(m);f=Math.min(f,t.docView.posFromDOM(C.startContainer,C.startOffset,1)),p=Math.max(p,t.docView.posFromDOM(C.endContainer,C.endOffset,-1))}if(f<0)return null;[a,o]=p==t.state.selection.anchor?[p,f]:[f,p],l=r.resolve(o)}else a=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let d=r.resolve(a);if(!u){let f=e=="pointer"||t.state.selection.head<l.pos&&!i?1:-1;u=Ai(t,d,l,f)}return u}function wi(t){return t.editable?t.hasFocus():Ra(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function vr(t,e=!1){let n=t.state.selection;if(La(t,n),!!wi(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Ue){let r=t.domSelectionRange(),s=t.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&yi(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)ja(t);else{let{anchor:r,head:s}=n,i,o;ms&&!(n instanceof Q)&&(n.$from.parent.inlineContent||(i=gs(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=gs(t,n.to))),t.docView.setSelection(r,s,t,e),ms&&(i&&ys(i),o&&ys(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Da(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const ms=ht||Ue&&Si<63;function gs(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(ht&&s&&s.contentEditable=="false")return zn(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return zn(s);if(i)return zn(i)}}function zn(t){return t.contentEditable="true",ht&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function ys(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Da(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(()=>{(!wi(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function ja(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,ft(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&_t&&vi<=11&&(n.disabled=!0,n.disabled=!1)}function La(t,e){if(e instanceof J){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(xs(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else xs(t)}function xs(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Ai(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||Q.between(e,n,r)}function Ra(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function tr(t,e){let{$anchor:n,$head:r}=t.selection,s=e>0?n.max(r):n.min(r),i=s.parent.inlineContent?s.depth?t.doc.resolve(e>0?s.after():s.before()):null:s;return i&&X.findFrom(i,e)}function Ze(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function bs(t,e,n){let r=t.state.selection;if(r instanceof Q)if(n.indexOf("s")>-1){let{$head:s}=r,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=t.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return Ze(t,new Q(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=tr(t.state,e);return s&&s instanceof J?Ze(t,s):!1}else if(!(Me&&n.indexOf("m")>-1)){let s=r.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,o;if(!i||i.isText)return!1;let l=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(o=t.docView.descAt(l))&&!o.contentDOM?J.isSelectable(i)?Ze(t,new J(e<0?t.state.doc.resolve(s.pos-i.nodeSize):s)):kr?Ze(t,new Q(t.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof J&&r.node.isInline)return Ze(t,new Q(e>0?r.$to:r.$from));{let s=tr(t.state,e);return s?Ze(t,s):!1}}}function an(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function It(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function mt(t,e){return e<0?Fa(t):Pa(t)}function Fa(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,i,o=!1;for(bn&&n.nodeType==1&&r<an(n)&&It(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(It(l,-1))s=n,i=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(Ni(n))break;{let l=n.previousSibling;for(;l&&It(l,-1);)s=n.parentNode,i=ft(l),l=l.previousSibling;if(l)n=l,r=an(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?nr(t,n,r):s&&nr(t,s,i)}function Pa(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=an(n),i,o;for(;;)if(r<s){if(n.nodeType!=1)break;let l=n.childNodes[r];if(It(l,1))i=n,o=++r;else break}else{if(Ni(n))break;{let l=n.nextSibling;for(;l&&It(l,1);)i=l.parentNode,o=ft(l)+1,l=l.nextSibling;if(l)n=l,r=0,s=an(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}i&&nr(t,i,o)}function Ni(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function $a(t,e){for(;t&&e==t.childNodes.length&&!xr(t);)e=ft(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 Va(t,e){for(;t&&!e&&!xr(t);)e=ft(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function nr(t,e,n){if(e.nodeType!=3){let i,o;(o=$a(e,n))?(e=o,n=0):(i=Va(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(xi(r)){let i=document.createRange();i.setEnd(e,n),i.setStart(e,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:s}=t;setTimeout(()=>{t.state==s&&vr(t)},50)}function ks(t,e){let n=t.state.doc.resolve(e);if(!(Ue||Ci)&&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 vs(t,e,n){let r=t.state.selection;if(r instanceof Q&&!r.empty||n.indexOf("s")>-1||Me&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=tr(t.state,e);if(o&&o instanceof J)return Ze(t,o)}if(!s.parent.inlineContent){let o=e<0?s:i,l=r instanceof Ve?X.near(o,e):X.findFrom(o,e);return l?Ze(t,l):!1}return!1}function Ss(t,e){if(!(t.state.selection instanceof Q))return!0;let{$head:n,$anchor:r,empty:s}=t.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let o=t.state.tr;return e<0?o.delete(n.pos-i.nodeSize,n.pos):o.delete(n.pos,n.pos+i.nodeSize),t.dispatch(o),!0}return!1}function Cs(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Ba(t){if(!ht||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;Cs(t,r,"true"),setTimeout(()=>Cs(t,r,"false"),20)}return!1}function za(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function _a(t,e){let n=e.keyCode,r=za(e);if(n==8||Me&&n==72&&r=="c")return Ss(t,-1)||mt(t,-1);if(n==46&&!e.shiftKey||Me&&n==68&&r=="c")return Ss(t,1)||mt(t,1);if(n==13||n==27)return!0;if(n==37||Me&&n==66&&r=="c"){let s=n==37?ks(t,t.state.selection.from)=="ltr"?-1:1:-1;return bs(t,s,r)||mt(t,s)}else if(n==39||Me&&n==70&&r=="c"){let s=n==39?ks(t,t.state.selection.from)=="ltr"?1:-1:1;return bs(t,s,r)||mt(t,s)}else{if(n==38||Me&&n==80&&r=="c")return vs(t,-1,r)||mt(t,-1);if(n==40||Me&&n==78&&r=="c")return Ba(t)||vs(t,1,r)||mt(t,1);if(r==(Me?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Ei(t,e){t.someProp("transformCopied",m=>{e=m(e,t)});let n=[],{content:r,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let m=r.firstChild;n.push(m.type.name,m.attrs!=m.type.defaultAttrs?m.attrs:null),r=m.content}let o=t.someProp("clipboardSerializer")||gn.fromSchema(t.state.schema),l=ji(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let u=a.firstChild,d,f=0;for(;u&&u.nodeType==1&&(d=Di[u.nodeName.toLowerCase()]);){for(let m=d.length-1;m>=0;m--){let C=l.createElement(d[m]);for(;a.firstChild;)C.appendChild(a.firstChild);a.appendChild(C),f++}u=a.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${s} ${i}${f?` -${f}`:""} ${JSON.stringify(n)}`);let p=t.someProp("clipboardTextSerializer",m=>m(e,t))||e.content.textBetween(0,e.content.size,`
17
17
 
18
- `);return{dom:a,text:h,slice:e}}function kr(n,e,t,r,s){let i=s.parent.type.spec.code,o,l;if(!t&&!e)return null;let a=!!e&&(r||i||!t);if(a){if(n.someProp("transformPastedText",h=>{e=h(e,i||r,n)}),i)return l=new A(S.from(n.state.schema.text(e.replace(/\r\n?/g,`
19
- `))),0,0),n.someProp("transformPasted",h=>{l=h(l,n,!0)}),l;let d=n.someProp("clipboardTextParser",h=>h(e,s,r,n));if(d)l=d;else{let h=s.marks(),{schema:p}=n.state,g=ct.fromSchema(p);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(y=>{let b=o.appendChild(document.createElement("p"));y&&b.appendChild(g.serializeNode(p.text(y,h)))})}}else n.someProp("transformPastedHTML",d=>{t=d(t,n)}),o=Wi(t),Xt&&_i(o);let c=o&&o.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let h=o.firstChild;for(;h&&h.nodeType!=1;)h=h.nextSibling;if(!h)break;o=h}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Qe.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||u),context:s,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!Ji.test(h.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Zi(zn(l,+u[1],+u[2]),u[4]);else if(l=A.maxOpen(Ki(l.content,s),!0),l.openStart||l.openEnd){let d=0,h=0;for(let p=l.content.firstChild;d<l.openStart&&!p.type.spec.isolating;d++,p=p.firstChild);for(let p=l.content.lastChild;h<l.openEnd&&!p.type.spec.isolating;h++,p=p.lastChild);l=zn(l,d,h)}return n.someProp("transformPasted",d=>{l=d(l,n,a)}),l}const Ji=/^(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 Ki(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let s=e.node(t).contentMatchAt(e.index(t)),i,o=[];if(n.forEach(l=>{if(!o)return;let a=s.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&i.length&&Sr(a,i,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=Ar(o[o.length-1],i.length));let u=Cr(l,a);o.push(u),s=s.matchType(u.type),i=a}}),o)return S.from(o)}return n}function Cr(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,S.from(n));return n}function Sr(n,e,t,r,s){if(s<n.length&&s<e.length&&n[s]==e[s]){let i=Sr(n,e,t,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==n.length-1?t.type:n[s+1]))return r.copy(r.content.append(S.from(Cr(t,n,s+1))))}}function Ar(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Ar(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(S.empty,!0);return n.copy(t.append(r))}function qt(n,e,t,r,s,i){let o=e<0?n.firstChild:n.lastChild,l=o.content;return n.childCount>1&&(i=0),s<r-1&&(l=qt(l,e,t,r,s+1,i)),s>=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(S.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(l))}function zn(n,e,t){return e<n.openStart&&(n=new A(qt(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new A(qt(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Tr={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 Bn=null;function Mr(){return Bn||(Bn=document.implementation.createHTMLDocument("title"))}let Dt=null;function Ui(n){let e=window.trustedTypes;return e?(Dt||(Dt=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Dt.createHTML(n)):n}function Wi(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Mr().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),s;if((s=r&&Tr[r[1].toLowerCase()])&&(n=s.map(i=>"<"+i+">").join("")+n+s.map(i=>"</"+i+">").reverse().join("")),t.innerHTML=Ui(n),s)for(let i=0;i<s.length;i++)t=t.querySelector(s[i])||t;return t}function _i(n){let e=n.querySelectorAll(ne?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function Zi(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:s,openStart:i,openEnd:o}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;s=S.from(a.create(r[l+1],s)),i++,o++}return new A(s,i,o)}const W={},$={};function oe(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}$.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Nr(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(qe&&ne&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Gt&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",s=>s(n,dr(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||Vi(n,t)?t.preventDefault():oe(n,"key")};$.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};$.keypress=(n,e)=>{let t=e;if(Nr(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||J&&t.metaKey)return;if(n.someProp("handleKeyPress",s=>s(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof N)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(t.charCode),i=()=>n.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!n.someProp("handleTextInput",o=>o(n,r.$from.pos,r.$to.pos,s,i))&&n.dispatch(i()),t.preventDefault()}};function ht(n){return{left:n.clientX,top:n.clientY}}function Gi(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Qt(n,e,t,r,s){if(r==-1)return!1;let i=n.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(n.someProp(e,l=>o>i.depth?l(n,t,i.nodeAfter,i.before(o),s,!0):l(n,t,i.node(o),i.before(o),s,!1)))return!0;return!1}function Ne(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function Xi(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&T.isSelectable(r)?(Ne(n,new T(t)),!0):!1}function Yi(n,e){if(e==-1)return!1;let t=n.state.selection,r,s;t instanceof T&&(r=t.node);let i=n.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let l=o>i.depth?i.nodeAfter:i.node(o);if(T.isSelectable(l)){r&&t.$from.depth>0&&o>=t.$from.depth&&i.before(t.$from.depth+1)==t.$from.pos?s=i.before(t.$from.depth):s=i.before(o);break}}return s!=null?(Ne(n,T.create(n.state.doc,s)),!0):!1}function Qi(n,e,t,r,s){return Qt(n,"handleClickOn",e,t,r)||n.someProp("handleClick",i=>i(n,e,r))||(s?Yi(n,t):Xi(n,t))}function eo(n,e,t,r){return Qt(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",s=>s(n,e,r))}function to(n,e,t,r){return Qt(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",s=>s(n,e,r))||no(n,t,r)}function no(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(Ne(n,N.create(r,0,r.content.size)),!0):!1;let s=r.resolve(e);for(let i=s.depth+1;i>0;i--){let o=i>s.depth?s.nodeAfter:s.node(i),l=s.before(i);if(o.inlineContent)Ne(n,N.create(r,l+1,l+1+o.content.size));else if(T.isSelectable(o))Ne(n,T.create(r,l));else continue;return!0}}function en(n){return ot(n)}const Er=J?"metaKey":"ctrlKey";W.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=en(n),s=Date.now(),i="singleClick";s-n.input.lastClick.time<500&&Gi(t,n.input.lastClick)&&!t[Er]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?i="doubleClick":n.input.lastClick.type=="doubleClick"&&(i="tripleClick")),n.input.lastClick={time:s,x:t.clientX,y:t.clientY,type:i,button:t.button};let o=n.posAtCoords(ht(t));o&&(i=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new ro(n,o,t,!!r)):(i=="doubleClick"?eo:to)(n,o.pos,o.inside,t)?t.preventDefault():oe(n,"pointer"))};class ro{constructor(e,t,r,s){this.view=e,this.pos=t,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Er],this.allowDefault=r.shiftKey;let i,o;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),o=t.inside;else{let u=e.state.doc.resolve(t.pos);i=u.parent,o=u.depth?u.before():0}const l=s?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof T&&c.from<=o&&c.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ft&&!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)),oe(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(()=>Yt(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(ht(e))),this.updateAllowDefault(e),this.allowDefault||!t?oe(this.view,"pointer"):Qi(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Se&&this.mightDrag&&!this.mightDrag.node.isAtom||ne&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Ne(this.view,v.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):oe(this.view,"pointer")}move(e){this.updateAllowDefault(e),oe(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)}}W.touchstart=n=>{n.input.lastTouch=Date.now(),en(n),oe(n,"pointer")};W.touchmove=n=>{n.input.lastTouch=Date.now(),oe(n,"pointer")};W.contextmenu=n=>en(n);function Nr(n,e){return n.composing?!0:Se&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const so=qe?5e3:-1;$.compositionstart=$.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof N&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||ne&&mr&&io(n)))n.markCursor=n.state.storedMarks||t.marks(),ot(n,!0),n.markCursor=null;else if(ot(n,!e.selection.empty),ft&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let s=r.focusNode,i=r.focusOffset;s&&s.nodeType==1&&i!=0;){let o=i<0?s.lastChild:s.childNodes[i-1];if(!o)break;if(o.nodeType==3){let l=n.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else s=o,i=-1}}n.input.composing=!0}vr(n,so)};function io(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let r=e.childNodes[t];return r.nodeType==1&&r.contentEditable=="false"}$.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,vr(n,20))};function vr(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>ot(n),e))}function oo(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=lo());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function lo(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function ot(n,e=!1){if(!(qe&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),oo(n),e||n.docView&&n.docView.dirty){let t=Di(n),r=n.state.selection;return t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function ao(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const He=$e&&hr<15||Gt&&Ii<604;W.copy=$.cut=(n,e)=>{let t=e,r=n.state.selection,s=t.type=="cut";if(r.empty)return;let i=He?null:t.clipboardData,o=r.content(),{dom:l,text:a}=br(n,o);i?(t.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):ao(n,l),s&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function co(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function uo(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?Vt(n,r.value,null,s,e):Vt(n,r.textContent,r.innerHTML,s,e)},50)}function Vt(n,e,t,r,s){let i=kr(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,s,i||A.empty)))return!0;if(!i)return!1;let o=co(i),l=o?n.state.tr.replaceSelectionWith(o,r):n.state.tr.replaceSelection(i);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Or(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}$.paste=(n,e)=>{let t=e;if(n.composing&&!qe)return;let r=He?null:t.clipboardData,s=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Vt(n,Or(r),r.getData("text/html"),s,t)?t.preventDefault():uo(n,t)};class fo{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const ho=J?"altKey":"ctrlKey";function wr(n,e){let t=n.someProp("dragCopies",r=>!r(e));return t??!e[ho]}W.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let s=n.state.selection,i=s.empty?null:n.posAtCoords(ht(t)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof T?s.to-1:s.to))){if(r&&r.mightDrag)o=T.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let d=n.docView.nearestDesc(t.target,!0);d&&d.node.type.spec.draggable&&d!=n.docView&&(o=T.create(n.state.doc,d.posBefore))}}let l=(o||n.state.selection).content(),{dom:a,text:c,slice:u}=br(n,l);(!t.dataTransfer.files.length||!ne||pr>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(He?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",He||t.dataTransfer.setData("text/plain",c),n.dragging=new fo(u,wr(n,t),o)};W.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};$.dragover=$.dragenter=(n,e)=>e.preventDefault();$.drop=(n,e)=>{try{po(n,e,n.dragging)}finally{n.dragging=null}};function po(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(ht(e));if(!r)return;let s=n.state.doc.resolve(r.pos),i=t&&t.slice;i?n.someProp("transformPasted",p=>{i=p(i,n,!1)}):i=kr(n,Or(e.dataTransfer),He?null:e.dataTransfer.getData("text/html"),!1,s);let o=!!(t&&wr(n,e));if(n.someProp("handleDrop",p=>p(n,e,i||A.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let l=i?nr(n.state.doc,s.pos,i):s.pos;l==null&&(l=s.pos);let a=n.state.tr;if(o){let{node:p}=t;p?p.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,d=a.doc;if(u?a.replaceRangeWith(c,c,i.content.firstChild):a.replaceRange(c,c,i),a.doc.eq(d))return;let h=a.doc.resolve(c);if(u&&T.isSelectable(i.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new T(h));else{let p=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((g,y,b,E)=>p=E),a.setSelection(yr(n,h,a.doc.resolve(p)))}n.focus(),n.dispatch(a.setMeta("uiEvent","drop"))}W.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Yt(n)},20))};W.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};W.beforeinput=(n,e)=>{if(ne&&qe&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",i=>i(n,dr(8,"Backspace")))))return;let{$cursor:s}=n.state.selection;s&&s.pos>0&&n.dispatch(n.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let n in $)W[n]=$[n];function je(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class lt{constructor(e,t){this.toDOM=e,this.spec=t||be,this.side=this.spec.side||0}map(e,t,r,s){let{pos:i,deleted:o}=e.mapResult(t.from+s,this.side<0?-1:1);return o?null:new Z(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof lt&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&je(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class le{constructor(e,t){this.attrs=e,this.spec=t||be}map(e,t,r,s){let i=e.map(t.from+s,this.spec.inclusiveStart?-1:1)-r,o=e.map(t.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=o?null:new Z(i,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof le&&je(this.attrs,e.attrs)&&je(this.spec,e.spec)}static is(e){return e.type instanceof le}destroy(){}}class tn{constructor(e,t){this.attrs=e,this.spec=t||be}map(e,t,r,s){let i=e.mapResult(t.from+s,1);if(i.deleted)return null;let o=e.mapResult(t.to+s,-1);return o.deleted||o.pos<=i.pos?null:new Z(i.pos-r,o.pos-r,this)}valid(e,t){let{index:r,offset:s}=e.content.findIndex(t.from),i;return s==t.from&&!(i=e.child(r)).isText&&s+i.nodeSize==t.to}eq(e){return this==e||e instanceof tn&&je(this.attrs,e.attrs)&&je(this.spec,e.spec)}destroy(){}}class Z{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new Z(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new Z(e,e,new lt(t,r))}static inline(e,t,r,s){return new Z(e,t,new le(r,s))}static node(e,t,r,s){return new Z(e,t,new tn(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof le}get widget(){return this.type instanceof lt}}const Me=[],be={};class D{constructor(e,t){this.local=e.length?e:Me,this.children=t.length?t:Me}static create(e,t){return t.length?at(t,e,0,be):H}find(e,t,r){let s=[];return this.findInner(e??0,t??1e9,s,0,r),s}findInner(e,t,r,s,i){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=t&&l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+s,l.to+s))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,r,s+l,i)}}map(e,t,r){return this==H||e.maps.length==0?this:this.mapInner(e,t,0,0,r||be)}mapInner(e,t,r,s,i){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,s);a&&a.type.valid(t,a)?(o||(o=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?mo(this.children,o||[],e,t,r,s,i):o?new D(o.sort(ke),Me):H}add(e,t){return t.length?this==H?D.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let s,i=0;e.forEach((l,a)=>{let c=a+r,u;if(u=Dr(t,l,c)){for(s||(s=this.children.slice());i<s.length&&s[i]<a;)i+=3;s[i]==a?s[i+2]=s[i+2].addInner(l,u,c+1):s.splice(i,0,a,a+l.nodeSize,at(u,l,c+1,be)),i+=3}});let o=Ir(i?Lr(t):t,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new D(o.length?this.local.concat(o).sort(ke):this.local,s||this.children)}remove(e){return e.length==0||this==H?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let o,l=r[i]+t,a=r[i+1]+t;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(o||(o=[])).push(d));if(!o)continue;r==this.children&&(r=this.children.slice());let c=r[i+2].removeInner(o,l+1);c!=H?r[i+2]=c:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,o;i<e.length;i++)if(o=e[i])for(let l=0;l<s.length;l++)s[l].eq(o,t)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new D(s,r):H}forChild(e,t){if(this==H)return this;if(t.isLeaf)return D.empty;let r,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,o=i+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>i&&a.type instanceof le){let c=Math.max(i,a.from)-i,u=Math.min(o,a.to)-i;c<u&&(s||(s=[])).push(a.copy(c,u))}}if(s){let l=new D(s.sort(ke),Me);return r?new pe([l,r]):l}return r||H}eq(e){if(this==e)return!0;if(!(e instanceof D)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return nn(this.localsInner(e))}localsInner(e){if(this==H)return Me;if(e.inlineContent||!this.local.some(le.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof le||t.push(this.local[r]);return t}forEachSet(e){e(this)}}D.empty=new D([],[]);D.removeOverlap=nn;const H=D.empty;class pe{constructor(e){this.members=e}map(e,t){const r=this.members.map(s=>s.map(e,t,be));return pe.from(r)}forChild(e,t){if(t.isLeaf)return D.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,t);i!=H&&(i instanceof pe?r=r.concat(i.members):r.push(i))}return pe.from(r)}eq(e){if(!(e instanceof pe)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!t)t=i;else{r&&(t=t.slice(),r=!1);for(let o=0;o<i.length;o++)t.push(i[o])}}return t?nn(r?t:t.sort(ke)):Me}static from(e){switch(e.length){case 0:return H;case 1:return e[0];default:return new pe(e.every(t=>t instanceof D)?e:e.reduce((t,r)=>t.concat(r instanceof D?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function mo(n,e,t,r,s,i,o){let l=n.slice();for(let c=0,u=i;c<t.maps.length;c++){let d=0;t.maps[c].forEach((h,p,g,y)=>{let b=y-g-(p-h);for(let E=0;E<l.length;E+=3){let I=l[E+1];if(I<0||h>I+u-d)continue;let F=l[E]+u-d;p>=F?l[E+1]=h<=F?-2:-1:h>=u&&b&&(l[E]+=b,l[E+1]+=b)}d+=b}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=t.map(n[c]+i),d=u-s;if(d<0||d>=r.content.size){a=!0;continue}let h=t.map(n[c+1]+i,-1),p=h-s,{index:g,offset:y}=r.content.findIndex(d),b=r.maybeChild(g);if(b&&y==d&&y+b.nodeSize==p){let E=l[c+2].mapInner(t,b,u+1,n[c]+i+1,o);E!=H?(l[c]=d,l[c+1]=p,l[c+2]=E):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=go(l,n,e,t,s,i,o),u=at(c,r,0,o);e=u.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,h=0;d<u.children.length;d+=3){let p=u.children[d];for(;h<l.length&&l[h]<p;)h+=3;l.splice(h,0,u.children[d],u.children[d+1],u.children[d+2])}}return new D(e.sort(ke),l)}function Ir(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let s=n[r];t.push(new Z(s.from+e,s.to+e,s.type))}return t}function go(n,e,t,r,s,i,o){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(r,s,c);d?t.push(d):o.onRemove&&o.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+i+1);return t}function Dr(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,s=null;for(let i=0,o;i<n.length;i++)(o=n[i])&&o.from>t&&o.to<r&&((s||(s=[])).push(o),n[i]=null);return s}function Lr(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function at(n,e,t,r){let s=[],i=!1;e.forEach((l,a)=>{let c=Dr(n,l,a+t);if(c){i=!0;let u=at(c,l,t+a+1,r);u!=H&&s.push(a,a+l.nodeSize,u)}});let o=Ir(i?Lr(n):n,-t).sort(ke);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||s.length?new D(o,s):H}function ke(n,e){return n.from-e.from||n.to-e.to}function nn(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let s=t+1;s<e.length;s++){let i=e[s];if(i.from==r.from){i.to!=r.to&&(e==n&&(e=n.slice()),e[s]=i.copy(i.from,r.to),Fn(e,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,i.from),Fn(e,s,r.copy(i.from,r.to)));break}}}return e}function Fn(n,e,t){for(;e<n.length&&ke(t,n[e])>0;)e++;n.splice(e,0,t)}class O extends v{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return O.valid(r)?new O(r):v.near(r)}content(){return A.empty}eq(e){return e instanceof O&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new O(e.resolve(t.pos))}getBookmark(){return new rn(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!yo(e)||!xo(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let s=t.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&O.valid(e))return e;let s=e.pos,i=null;for(let o=e.depth;;o--){let l=e.node(o);if(t>0?e.indexAfter(o)<l.childCount:e.index(o)>0){i=l.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=t;let a=e.doc.resolve(s);if(O.valid(a))return a}for(;;){let o=t>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!T.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*t),r=!1;continue e}break}i=o,s+=t;let l=e.doc.resolve(s);if(O.valid(l))return l}return null}}}O.prototype.visible=!1;O.findFrom=O.findGapCursorFrom;v.jsonID("gapcursor",O);class rn{constructor(e){this.pos=e}map(e){return new rn(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return O.valid(t)?new O(t):v.near(t)}}function Rr(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function yo(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||Rr(s.type))return!0;if(s.inlineContent)return!1}}return!0}function xo(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||Rr(s.type))return!0;if(s.inlineContent)return!1}}return!0}function bo(){return new dt({props:{decorations:Ao,createSelectionBetween(n,e,t){return e.pos==t.pos&&O.valid(t)?new O(t):null},handleClick:Co,handleKeyDown:ko,handleDOMEvents:{beforeinput:So}}})}const ko=vi({ArrowLeft:Ze("horiz",-1),ArrowRight:Ze("horiz",1),ArrowUp:Ze("vert",-1),ArrowDown:Ze("vert",1)});function Ze(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof N){if(!i.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=O.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new O(c))),!0):!1}}function Co(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!O.valid(r))return!1;let s=n.posAtCoords({left:t.clientX,top:t.clientY});return s&&s.inside>-1&&T.isSelectable(n.state.doc.nodeAt(s.inside))?!1:(n.dispatch(n.state.tr.setSelection(new O(r))),!0)}function So(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof O))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let s=S.empty;for(let o=r.length-1;o>=0;o--)s=S.from(r[o].createAndFill(null,s));let i=n.state.tr.replace(t.pos,t.pos,new A(s,0,0));return i.setSelection(N.near(i.doc.resolve(t.pos+1))),n.dispatch(i),!1}function Ao(n){if(!(n.selection instanceof O))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",D.create(n.doc,[Z.widget(n.selection.head,e,{key:"gapcursor"})])}const To=m.Extension.create({name:"gapCursor",addProseMirrorPlugins(){return[bo()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=m.callOrReturn(m.getExtensionField(n,"allowGapCursor",t)))!==null&&e!==void 0?e:null}}}),ve={bold:{category:"mark",extension:Ss,priority:100},italic:{category:"mark",extension:Ns,priority:100},strike:{category:"mark",extension:ws,priority:100},underline:{category:"mark",extension:$r.Underline,priority:100},code:{category:"mark",extension:Ls,priority:100},textColor:{category:"mark",extension:qr.Color,defaultOptions:{types:["textStyle"]},priority:90},highlight:{category:"mark",extension:Vr.Highlight,defaultOptions:{multicolor:!0},priority:90},link:{category:"mark",extension:Jr.Link,defaultOptions:{openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}},priority:100},paragraph:{category:"node",extension:Jn,priority:100},heading:{category:"node",extension:zs,defaultOptions:{levels:[1,2,3,4,5,6]},priority:100},bulletList:{category:"node",extension:Fs,defaultOptions:{HTMLAttributes:{class:"list-disc"}},priority:90},orderedList:{category:"node",extension:js,defaultOptions:{HTMLAttributes:{class:"list-decimal"}},priority:90},taskList:{category:"node",extension:Kr.TaskList,defaultOptions:{HTMLAttributes:{class:"task-list"}},priority:90},codeBlock:{category:"node",extension:ni,priority:100},blockquote:{category:"node",extension:si,priority:100},horizontalRule:{category:"node",extension:ii,priority:100},hardBreak:{category:"node",extension:oi,priority:100},undo:{category:"extension",extension:Ie,priority:50},redo:{category:"extension",extension:Ie,priority:50},textAlign:{category:"extension",extension:Wr.TextAlign,defaultOptions:{types:["heading","paragraph","listItem"],alignments:["left","center","right","justify"],defaultAlignment:"left"},priority:80},clearMarks:{category:"extension",extension:Ie,priority:50},clearNodes:{category:"extension",extension:Ie,priority:50}},Mo=[gi,yi,Jn,Ps,$s,Ur.TaskItem,Ie,ki,To];function Eo(n){const e=[],t=new Set,r=new Set;Mo.forEach(l=>{l&&(e.push(l),r.add(l.name),l.name==="history"&&(t.add("undo"),t.add("redo")))});const s=n.map(l=>Pe(l)),i=new Set;return s.forEach(l=>{const a=ve[l];a?.requiredExtensions&&a.requiredExtensions.forEach(c=>{i.add(c)})}),i.forEach(l=>{if(t.has(l))return;const a=ve[l];if(!a||a.extension===null)return;const c=a.defaultOptions?a.extension.configure(a.defaultOptions):a.extension;e.push(c),t.add(l)}),s.forEach(l=>{if(t.has(l))return;const a=ve[l];if(!a||a.extension===null){console.warn(`Extension not found or not installed for modifier: ${l}`);return}if(a.extension.name==="history"&&t.has("undo"))return;const c=a.defaultOptions?a.extension.configure(a.defaultOptions):a.extension;e.push(c),t.add(l),(l==="undo"||l==="redo")&&(t.add("undo"),t.add("redo"))}),e.sort((l,a)=>{const c=Object.values(ve).find(p=>p?.extension?.name===l.name),u=Object.values(ve).find(p=>p?.extension?.name===a.name),d=c?.priority??100;return(u?.priority??100)-d})}const Pr={simple:["bold","italic","bulletList","orderedList","undo","redo"],blog:["bold","italic","underline",{type:"heading",level:2},{type:"heading",level:3},"textAlign","bulletList","orderedList","blockquote","undo","redo"],documentation:["bold","italic","strike","underline","code","clearMarks","paragraph",{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","textColor","highlight","codeBlock","blockquote","horizontalRule","hardBreak","undo","redo"],comment:["bold","italic","undo","redo"],full:["bold","italic","strike","underline","code","clearMarks","paragraph",{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","textColor","highlight","codeBlock","blockquote","horizontalRule","hardBreak","undo","redo"]},No=({modifiers:n,zoom:e,onZoomChange:t,onToolbarAction:r})=>{const{editor:s}=Kt.useCurrentEditor();return f.jsx(ys,{editor:s,modifiers:n,zoom:e,onZoomChange:t,onToolbarAction:r})},vo=({showCharacterCount:n,showWordCount:e})=>{const{editor:t}=Kt.useCurrentEditor();if(!t||!n&&!e)return null;const r=t.getText(),s=r.length,i=r.split(/\s+/).filter(o=>o.length>0).length;return f.jsxs("div",{className:"flex gap-4 text-xs text-default-500 px-2 pb-1",children:[n&&f.jsxs("span",{children:[s," characters"]}),e&&f.jsxs("span",{children:[i," words"]})]})},Jt=C.forwardRef((n,e)=>{const{minRows:t=10,maxRows:r=30,disableAutosize:s=!1,showCharacterCount:i=!1,showWordCount:o=!1,showToolbar:l=!0,modifiers:a=Pr.full,variant:c="bordered",initialContent:u,content:d,onContentChange:h,onUpdate:p,onToolbarAction:g,isReadOnly:y=!1,isDisabled:b=!1,...E}=n,{zoom:I,setZoom:F}=ps(),q=on.lineHeight,V=t*q,ue=s?void 0:r*q,M=C.useMemo(()=>Eo(a),[a]),{Component:Y,label:de,shouldLabelBeOutside:Ve,getBaseProps:pt,getLabelProps:mt,getInputWrapperProps:Je}=x.useInput({...E,variant:c,ref:e,isMultiline:!0}),Ke=de?f.jsx("label",{...mt(),children:de}):null,P=C.useCallback(({editor:Q})=>{const gt=Q.getHTML(),Fr=Q.getJSON(),yt=Q.getText(),Hr=yt.length,jr=yt.split(/\s+/).filter(xt=>xt.length>0).length,sn={html:gt,json:Fr,text:yt,characters:Hr,words:jr};if(h?.(sn),p?.(sn),"onChange"in E&&typeof E.onChange=="function"){const xt={target:{value:gt},currentTarget:{value:gt}};E.onChange(xt)}},[h,p,E]);return f.jsxs(Y,{...pt(),children:[Ve?Ke:null,f.jsx("div",{...Je(),className:x.cn(Je().className,"flex flex-col w-full p-0 gap-0 rich-text-editor"),style:{maxHeight:ue?`${ue+on.toolbarHeight}px`:void 0,overflow:ue?"auto":void 0},children:f.jsx(Kt.EditorProvider,{editable:!y&&!b,slotBefore:l?f.jsx(No,{modifiers:a,zoom:I,onZoomChange:F,onToolbarAction:g}):void 0,slotAfter:f.jsx(vo,{showCharacterCount:i,showWordCount:o}),editorContainerProps:{className:"w-full flex-1 outline-none",style:{minHeight:`${V}px`,fontSize:`${I}%`,display:"flex",flexDirection:"column"}},editorProps:{attributes:{class:"focus:outline-none w-full h-full"}},extensions:M,content:d||u||n.defaultValue||"",onUpdate:P})})]})});Jt.displayName="TipTapEditor";const zr=C.forwardRef((n,e)=>{const{adapter:t="tiptap",variant:r="bordered",...s}=n;return t==="tiptap"?f.jsx(Jt,{...s,variant:r,ref:e}):(console.warn(`Adapter "${t}" is not supported. Using TipTap.`),f.jsx(Jt,{...s,variant:r,ref:e}))});zr.displayName="RichTextArea";function Oo(n,e="en-US",t="USD"){try{return new Intl.NumberFormat(e,{style:"currency",currency:t,minimumFractionDigits:0,maximumFractionDigits:2}).format(n)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${t} ${n.toFixed(2)}`}}const Hn=[{id:"100",amount:100},{id:"250",amount:250},{id:"500",amount:500},{id:"1000",amount:1e3},{id:"2000",amount:2e3}],wo={title:"Donation Amount",customAmountPlaceholder:"Custom donation amount",customAmountAriaLabel:"Custom donation amount"},Br=({presetAmounts:n=Hn,selectedDonation:e,defaultSelectedDonation:t=null,onChange:r,currency:s="USD",locale:i="en-US",showCustomAmount:o=!0,minCustomAmount:l=.5,maxCustomAmount:a=1e6,labels:c,mobileColumns:u=2,desktopColumns:d=3,isDisabled:h=!1,buttonVariant:p="bordered",buttonColor:g="default",inputVariant:y="bordered",className:b="",showCard:E=!0})=>{const I={...wo,...c},F=Array.isArray(n)?n:Hn,q={2:"grid-cols-2",3:"grid-cols-3"},V={3:"sm:grid-cols-3",4:"sm:grid-cols-4",5:"sm:grid-cols-5",6:"sm:grid-cols-6"},ue=`${q[u]} ${V[d]}`,[M,Y]=jn(e,t,r),[de,Ve]=C.useState(""),pt=C.useCallback(P=>{if(h)return;const Q={amount:P.amount,isCustom:!1,presetId:P.id};Y(Q),Ve("")},[h,Y]),mt=C.useCallback(P=>{if(h)return;if(Ve(P!==void 0?String(P):""),P===void 0||isNaN(P)){Y(null);return}Y({amount:P,isCustom:!0})},[h,Y]),Je=C.useMemo(()=>({style:"currency",currency:s,currencyDisplay:"symbol"}),[s]),Ke=f.jsxs("div",{className:"space-y-4",children:[I.title&&f.jsx("h2",{className:"text-base font-semibold",children:I.title}),F.length>0&&f.jsx("div",{className:x.cn("grid gap-3",ue),children:F.map(P=>{const Q=M!==null&&!M.isCustom&&M.presetId===P.id;return f.jsx(x.Button,{color:Q?"primary":g,variant:Q?"solid":p,className:"w-full",onPress:()=>pt(P),isDisabled:h,children:P.label||Oo(P.amount,i,s)},P.id)})}),o&&f.jsx(x.NumberInput,{placeholder:I.customAmountPlaceholder,"aria-label":I.customAmountAriaLabel,variant:y,radius:"md",minValue:l,maxValue:a,step:.01,formatOptions:Je,value:de!==""?parseFloat(de):void 0,onValueChange:mt,isDisabled:h},M?.isCustom===!1?M.presetId:"custom")]});return E?f.jsx(x.Card,{className:x.cn("w-full",b),children:f.jsx(x.CardBody,{children:Ke})}):f.jsx("div",{className:x.cn("w-full",b),children:Ke})};Br.displayName="DonationAmounts";function Io(n){return f.jsx("div",{className:"min-h-screen flex flex-col",children:f.jsx("div",{className:"flex-1 flex items-center justify-center p-12",children:f.jsx(x.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"})})})}function Do(n){return f.jsx("div",{className:"min-h-screen flex flex-col",children:f.jsx("div",{className:"flex-1 flex items-center justify-center p-12",children:f.jsx(x.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"})})})}exports.Button=Yr;exports.ConfirmationPageTemplate=Io;exports.DonationAmounts=Br;exports.EventDetailsTemplate=Do;exports.Footer=ns;exports.HeroUIProvider=Xr;exports.Navbar=Qr;exports.RICH_TEXT_PRESETS=Pr;exports.RichTextArea=zr;exports.Stepper=$n;exports.colors=we;exports.spacing=_r;exports.theme=Gr;exports.typography=Zr;Object.keys(x).forEach(n=>{n!=="default"&&!Object.prototype.hasOwnProperty.call(exports,n)&&Object.defineProperty(exports,n,{enumerable:!0,get:()=>x[n]})});
18
+ `);return{dom:a,text:p,slice:e}}function Ti(t,e,n,r,s){let i=s.parent.type.spec.code,o,l;if(!n&&!e)return null;let a=!!e&&(r||i||!n);if(a){if(t.someProp("transformPastedText",p=>{e=p(e,i||r,t)}),i)return l=new K(q.from(t.state.schema.text(e.replace(/\r\n?/g,`
19
+ `))),0,0),t.someProp("transformPasted",p=>{l=p(l,t,!0)}),l;let f=t.someProp("clipboardTextParser",p=>p(e,s,r,t));if(f)l=f;else{let p=s.marks(),{schema:m}=t.state,C=gn.fromSchema(m);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(b=>{let k=o.appendChild(document.createElement("p"));b&&k.appendChild(C.serializeNode(m.text(b,p)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),o=Ka(n),kr&&Ja(o);let u=o&&o.querySelector("[data-pm-slice]"),d=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let f=+d[3];f>0;f--){let p=o.firstChild;for(;p&&p.nodeType!=1;)p=p.nextSibling;if(!p)break;o=p}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||tn.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||d),context:s,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!Ha.test(p.parentNode.nodeName)?{ignore:!0}:null}})),d)l=Wa(ws(l,+d[1],+d[2]),d[4]);else if(l=K.maxOpen(Ua(l.content,s),!0),l.openStart||l.openEnd){let f=0,p=0;for(let m=l.content.firstChild;f<l.openStart&&!m.type.spec.isolating;f++,m=m.firstChild);for(let m=l.content.lastChild;p<l.openEnd&&!m.type.spec.isolating;p++,m=m.lastChild);l=ws(l,f,p)}return t.someProp("transformPasted",f=>{l=f(l,t,a)}),l}const Ha=/^(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 Ua(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.index(n)),i,o=[];if(t.forEach(l=>{if(!o)return;let a=s.findWrapping(l.type),u;if(!a)return o=null;if(u=o.length&&i.length&&Oi(a,i,l,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=Ii(o[o.length-1],i.length));let d=Mi(l,a);o.push(d),s=s.matchType(d.type),i=a}}),o)return q.from(o)}return t}function Mi(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,q.from(t));return t}function Oi(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let i=Oi(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(q.from(Mi(n,t,s+1))))}}function Ii(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Ii(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(q.empty,!0);return t.copy(n.append(r))}function rr(t,e,n,r,s,i){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(i=0),s<r-1&&(l=rr(l,e,n,r,s+1,i)),s>=n&&(l=e<0?o.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(q.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function ws(t,e,n){return e<t.openStart&&(t=new K(rr(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new K(rr(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Di={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 As=null;function ji(){return As||(As=document.implementation.createHTMLDocument("title"))}let _n=null;function qa(t){let e=window.trustedTypes;return e?(_n||(_n=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),_n.createHTML(t)):t}function Ka(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=ji().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),s;if((s=r&&Di[r[1].toLowerCase()])&&(t=s.map(i=>"<"+i+">").join("")+t+s.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=qa(t),s)for(let i=0;i<s.length;i++)n=n.querySelector(s[i])||n;return n}function Ja(t){let e=t.querySelectorAll(Ue?"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 Wa(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:s,openStart:i,openEnd:o}=t;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;s=q.from(a.create(r[l+1],s)),i++,o++}return new K(s,i,o)}const Fe={},Te={};function Qe(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}Te.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Ri(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Ht&&Ue&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),br&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",s=>s(t,bi(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||_a(t,n)?n.preventDefault():Qe(t,"key")};Te.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Te.keypress=(t,e)=>{let n=e;if(Ri(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Me&&n.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof Q)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,s,i))&&t.dispatch(i()),n.preventDefault()}};function kn(t){return{left:t.clientX,top:t.clientY}}function Ga(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Sr(t,e,n,r,s){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(t.someProp(e,l=>o>i.depth?l(t,n,i.nodeAfter,i.before(o),s,!0):l(t,n,i.node(o),i.before(o),s,!1)))return!0;return!1}function vt(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 Za(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&J.isSelectable(r)?(vt(t,new J(n)),!0):!1}function Qa(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 l=o>i.depth?i.nodeAfter:i.node(o);if(J.isSelectable(l)){r&&n.$from.depth>0&&o>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?s=i.before(n.$from.depth):s=i.before(o);break}}return s!=null?(vt(t,J.create(t.state.doc,s)),!0):!1}function Xa(t,e,n,r,s){return Sr(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(s?Qa(t,n):Za(t,n))}function Ya(t,e,n,r){return Sr(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function ec(t,e,n,r){return Sr(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||tc(t,n,r)}function tc(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(vt(t,Q.create(r,0,r.content.size)),!0):!1;let s=r.resolve(e);for(let i=s.depth+1;i>0;i--){let o=i>s.depth?s.nodeAfter:s.node(i),l=s.before(i);if(o.inlineContent)vt(t,Q.create(r,l+1,l+1+o.content.size));else if(J.isSelectable(o))vt(t,J.create(r,l));else continue;return!0}}function Cr(t){return cn(t)}const Li=Me?"metaKey":"ctrlKey";Fe.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Cr(t),s=Date.now(),i="singleClick";s-t.input.lastClick.time<500&&Ga(n,t.input.lastClick)&&!n[Li]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:i,button:n.button};let o=t.posAtCoords(kn(n));o&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new nc(t,o,n,!!r)):(i=="doubleClick"?Ya:ec)(t,o.pos,o.inside,n)?n.preventDefault():Qe(t,"pointer"))};class nc{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[Li],this.allowDefault=r.shiftKey;let i,o;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),o=n.inside;else{let d=e.state.doc.resolve(n.pos);i=d.parent,o=d.depth?d.before():0}const l=s?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:u}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||u instanceof J&&u.from<=o&&u.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&bn&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),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(()=>vr(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(kn(e))),this.updateAllowDefault(e),this.allowDefault||!n?Qe(this.view,"pointer"):Xa(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ht&&this.mightDrag&&!this.mightDrag.node.isAtom||Ue&&!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)?(vt(this.view,X.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)}}Fe.touchstart=t=>{t.input.lastTouch=Date.now(),Cr(t),Qe(t,"pointer")};Fe.touchmove=t=>{t.input.lastTouch=Date.now(),Qe(t,"pointer")};Fe.contextmenu=t=>Cr(t);function Ri(t,e){return t.composing?!0:ht&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const rc=Ht?5e3:-1;Te.compositionstart=Te.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof Q&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Ue&&Ci&&sc(t)))t.markCursor=t.state.storedMarks||n.marks(),cn(t,!0),t.markCursor=null;else if(cn(t,!e.selection.empty),bn&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let s=r.focusNode,i=r.focusOffset;s&&s.nodeType==1&&i!=0;){let o=i<0?s.lastChild:s.childNodes[i-1];if(!o)break;if(o.nodeType==3){let l=t.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else s=o,i=-1}}t.input.composing=!0}Fi(t,rc)};function sc(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"}Te.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++,Fi(t,20))};function Fi(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>cn(t),e))}function ic(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=oc());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function oc(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function cn(t,e=!1){if(!(Ht&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),ic(t),e||t.docView&&t.docView.dirty){let n=Ia(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 lc(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const Vt=_t&&vi<15||br&&Oa<604;Fe.copy=Te.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let i=Vt?null:n.clipboardData,o=r.content(),{dom:l,text:a}=Ei(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):lc(t,l),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function ac(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function cc(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?sr(t,r.value,null,s,e):sr(t,r.textContent,r.innerHTML,s,e)},50)}function sr(t,e,n,r,s){let i=Ti(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,s,i||K.empty)))return!0;if(!i)return!1;let o=ac(i),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(i);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Pi(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," "):""}Te.paste=(t,e)=>{let n=e;if(t.composing&&!Ht)return;let r=Vt?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&sr(t,Pi(r),r.getData("text/html"),s,n)?n.preventDefault():cc(t,n)};class uc{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const dc=Me?"altKey":"ctrlKey";function $i(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[dc]}Fe.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=t.state.selection,i=s.empty?null:t.posAtCoords(kn(n)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof 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 l=(o||t.state.selection).content(),{dom:a,text:u,slice:d}=Ei(t,l);(!n.dataTransfer.files.length||!Ue||Si>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Vt?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Vt||n.dataTransfer.setData("text/plain",u),t.dragging=new uc(d,$i(t,n),o)};Fe.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Te.dragover=Te.dragenter=(t,e)=>e.preventDefault();Te.drop=(t,e)=>{try{fc(t,e,t.dragging)}finally{t.dragging=null}};function fc(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(kn(e));if(!r)return;let s=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp("transformPasted",m=>{i=m(i,t,!1)}):i=Ti(t,Pi(e.dataTransfer),Vt?null:e.dataTransfer.getData("text/html"),!1,s);let o=!!(n&&$i(t,e));if(t.someProp("handleDrop",m=>m(t,e,i||K.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let l=i?ui(t.state.doc,s.pos,i):s.pos;l==null&&(l=s.pos);let a=t.state.tr;if(o){let{node:m}=n;m?m.replace(a):a.deleteSelection()}let u=a.mapping.map(l),d=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,f=a.doc;if(d?a.replaceRangeWith(u,u,i.content.firstChild):a.replaceRange(u,u,i),a.doc.eq(f))return;let p=a.doc.resolve(u);if(d&&J.isSelectable(i.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new J(p));else{let m=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((C,b,k,S)=>m=S),a.setSelection(Ai(t,p,a.doc.resolve(m)))}t.focus(),t.dispatch(a.setMeta("uiEvent","drop"))}Fe.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&vr(t)},20))};Fe.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)};Fe.beforeinput=(t,e)=>{if(Ue&&Ht&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,bi(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 Te)Fe[t]=Te[t];function Bt(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class un{constructor(e,n){this.toDOM=e,this.spec=n||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 $e(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof un&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Bt(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 $e(i,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Xe&&Bt(this.attrs,e.attrs)&&Bt(this.spec,e.spec)}static is(e){return e.type instanceof Xe}destroy(){}}class wr{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 $e(i.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:s}=e.content.findIndex(n.from),i;return s==n.from&&!(i=e.child(r)).isText&&s+i.nodeSize==n.to}eq(e){return this==e||e instanceof wr&&Bt(this.attrs,e.attrs)&&Bt(this.spec,e.spec)}destroy(){}}class $e{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new $e(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new $e(e,e,new un(n,r))}static inline(e,n,r,s){return new $e(e,n,new Xe(r,s))}static node(e,n,r,s){return new $e(e,n,new wr(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof Xe}get widget(){return this.type instanceof un}}const xt=[],ut={};class fe{constructor(e,n){this.local=e.length?e:xt,this.children=n.length?n:xt}static create(e,n){return n.length?dn(n,e,0,ut):ve}find(e,n,r){let s=[];return this.findInner(e??0,n??1e9,s,0,r),s}findInner(e,n,r,s,i){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=n&&l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+s,l.to+s))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<n&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,n-l,r,s+l,i)}}map(e,n,r){return this==ve||e.maps.length==0?this:this.mapInner(e,n,0,0,r||ut)}mapInner(e,n,r,s,i){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,s);a&&a.type.valid(n,a)?(o||(o=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?hc(this.children,o||[],e,n,r,s,i):o?new fe(o.sort(dt),xt):ve}add(e,n){return n.length?this==ve?fe.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,i=0;e.forEach((l,a)=>{let u=a+r,d;if(d=Bi(n,l,u)){for(s||(s=this.children.slice());i<s.length&&s[i]<a;)i+=3;s[i]==a?s[i+2]=s[i+2].addInner(l,d,u+1):s.splice(i,0,a,a+l.nodeSize,dn(d,l,u+1,ut)),i+=3}});let o=Vi(i?zi(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new fe(o.length?this.local.concat(o).sort(dt):this.local,s||this.children)}remove(e){return e.length==0||this==ve?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let o,l=r[i]+n,a=r[i+1]+n;for(let d=0,f;d<e.length;d++)(f=e[d])&&f.from>l&&f.to<a&&(e[d]=null,(o||(o=[])).push(f));if(!o)continue;r==this.children&&(r=this.children.slice());let u=r[i+2].removeInner(o,l+1);u!=ve?r[i+2]=u:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,o;i<e.length;i++)if(o=e[i])for(let l=0;l<s.length;l++)s[l].eq(o,n)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new fe(s,r):ve}forChild(e,n){if(this==ve)return this;if(n.isLeaf)return fe.empty;let r,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,o=i+n.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>i&&a.type instanceof Xe){let u=Math.max(i,a.from)-i,d=Math.min(o,a.to)-i;u<d&&(s||(s=[])).push(a.copy(u,d))}}if(s){let l=new fe(s.sort(dt),xt);return r?new st([l,r]):l}return r||ve}eq(e){if(this==e)return!0;if(!(e instanceof fe)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return Ar(this.localsInner(e))}localsInner(e){if(this==ve)return xt;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)}}fe.empty=new fe([],[]);fe.removeOverlap=Ar;const ve=fe.empty;class st{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,ut));return st.from(r)}forChild(e,n){if(n.isLeaf)return fe.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,n);i!=ve&&(i instanceof st?r=r.concat(i.members):r.push(i))}return st.from(r)}eq(e){if(!(e instanceof st)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let o=0;o<i.length;o++)n.push(i[o])}}return n?Ar(r?n:n.sort(dt)):xt}static from(e){switch(e.length){case 0:return ve;case 1:return e[0];default:return new st(e.every(n=>n instanceof fe)?e:e.reduce((n,r)=>n.concat(r instanceof fe?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function hc(t,e,n,r,s,i,o){let l=t.slice();for(let u=0,d=i;u<n.maps.length;u++){let f=0;n.maps[u].forEach((p,m,C,b)=>{let k=b-C-(m-p);for(let S=0;S<l.length;S+=3){let w=l[S+1];if(w<0||p>w+d-f)continue;let j=l[S]+d-f;m>=j?l[S+1]=p<=j?-2:-1:p>=d&&k&&(l[S]+=k,l[S+1]+=k)}f+=k}),d=n.maps[u].map(d,-1)}let a=!1;for(let u=0;u<l.length;u+=3)if(l[u+1]<0){if(l[u+1]==-2){a=!0,l[u+1]=-1;continue}let d=n.map(t[u]+i),f=d-s;if(f<0||f>=r.content.size){a=!0;continue}let p=n.map(t[u+1]+i,-1),m=p-s,{index:C,offset:b}=r.content.findIndex(f),k=r.maybeChild(C);if(k&&b==f&&b+k.nodeSize==m){let S=l[u+2].mapInner(n,k,d+1,t[u]+i+1,o);S!=ve?(l[u]=f,l[u+1]=m,l[u+2]=S):(l[u+1]=-2,a=!0)}else a=!0}if(a){let u=pc(l,t,e,n,s,i,o),d=dn(u,r,0,o);e=d.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,p=0;f<d.children.length;f+=3){let m=d.children[f];for(;p<l.length&&l[p]<m;)p+=3;l.splice(p,0,d.children[f],d.children[f+1],d.children[f+2])}}return new fe(e.sort(dt),l)}function Vi(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let s=t[r];n.push(new $e(s.from+e,s.to+e,s.type))}return n}function pc(t,e,n,r,s,i,o){function l(a,u){for(let d=0;d<a.local.length;d++){let f=a.local[d].map(r,s,u);f?n.push(f):o.onRemove&&o.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+u+1)}for(let a=0;a<t.length;a+=3)t[a+1]==-1&&l(t[a+2],e[a]+i+1);return n}function Bi(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 zi(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function dn(t,e,n,r){let s=[],i=!1;e.forEach((l,a)=>{let u=Bi(t,l,a+n);if(u){i=!0;let d=dn(u,l,n+a+1,r);d!=ve&&s.push(a,a+l.nodeSize,d)}});let o=Vi(i?zi(t):t,-n).sort(dt);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||s.length?new fe(o,s):ve}function dt(t,e){return t.from-e.from||t.to-e.to}function Ar(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let s=n+1;s<e.length;s++){let i=e[s];if(i.from==r.from){i.to!=r.to&&(e==t&&(e=t.slice()),e[s]=i.copy(i.from,r.to),Ns(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),Ns(e,s,r.copy(i.from,r.to)));break}}}return e}function Ns(t,e,n){for(;e<t.length&&dt(n,t[e])>0;)e++;t.splice(e,0,n)}class ie extends X{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return ie.valid(r)?new ie(r):X.near(r)}content(){return K.empty}eq(e){return e instanceof ie&&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 ie(e.resolve(n.pos))}getBookmark(){return new Nr(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!mc(e)||!gc(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&&ie.valid(e))return e;let s=e.pos,i=null;for(let o=e.depth;;o--){let l=e.node(o);if(n>0?e.indexAfter(o)<l.childCount:e.index(o)>0){i=l.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=n;let a=e.doc.resolve(s);if(ie.valid(a))return a}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 l=e.doc.resolve(s);if(ie.valid(l))return l}return null}}}ie.prototype.visible=!1;ie.findFrom=ie.findGapCursorFrom;X.jsonID("gapcursor",ie);class Nr{constructor(e){this.pos=e}map(e){return new Nr(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return ie.valid(n)?new ie(n):X.near(n)}}function _i(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function mc(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||_i(s.type))return!0;if(s.inlineContent)return!1}}return!0}function gc(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||_i(s.type))return!0;if(s.inlineContent)return!1}}return!0}function yc(){return new xn({props:{decorations:vc,createSelectionBetween(t,e,n){return e.pos==n.pos&&ie.valid(n)?new ie(n):null},handleClick:bc,handleKeyDown:xc,handleDOMEvents:{beforeinput:kc}}})}const xc=Ea({ArrowLeft:Wt("horiz",-1),ArrowRight:Wt("horiz",1),ArrowUp:Wt("vert",-1),ArrowDown:Wt("vert",1)});function Wt(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof Q){if(!i.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let u=ie.findGapCursorFrom(l,e,a);return u?(s&&s(r.tr.setSelection(new ie(u))),!0):!1}}function bc(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!ie.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 ie(r))),!0)}function kc(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof ie))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=q.empty;for(let o=r.length-1;o>=0;o--)s=q.from(r[o].createAndFill(null,s));let i=t.state.tr.replace(n.pos,n.pos,new K(s,0,0));return i.setSelection(Q.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function vc(t){if(!(t.selection instanceof ie))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",fe.create(t.doc,[$e.widget(t.selection.head,e,{key:"gapcursor"})])}const Sc=R.Extension.create({name:"gapCursor",addProseMirrorPlugins(){return[yc()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=R.callOrReturn(R.getExtensionField(t,"allowGapCursor",n)))!==null&&e!==void 0?e:null}}}),At={bold:{category:"mark",extension:kl,priority:100},italic:{category:"mark",extension:Al,priority:100},strike:{category:"mark",extension:Tl,priority:100},underline:{category:"mark",extension:Fo.Underline,priority:100},code:{category:"mark",extension:Il,priority:100},textColor:{category:"mark",extension:Po.Color,defaultOptions:{types:["textStyle","heading","paragraph","listItem","taskItem","blockquote"]},priority:90},highlight:{category:"mark",extension:$o.Highlight,defaultOptions:{multicolor:!0},priority:90},link:{category:"mark",extension:Vo.Link,defaultOptions:{openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}},priority:100},heading:{category:"node",extension:Ll,defaultOptions:{levels:[1,2,3,4,5,6]},priority:100},bulletList:{category:"node",extension:Pl,defaultOptions:{HTMLAttributes:{class:"list-disc"}},priority:90},orderedList:{category:"node",extension:Vl,defaultOptions:{HTMLAttributes:{class:"list-decimal"}},priority:90},taskList:{category:"node",extension:Bo.TaskList,defaultOptions:{HTMLAttributes:{class:"task-list"}},priority:90},codeBlock:{category:"node",extension:ta,priority:100},blockquote:{category:"node",extension:ra,priority:100},horizontalRule:{category:"node",extension:sa,priority:100},hardBreak:{category:"node",extension:ia,priority:100},undo:{category:"extension",extension:fs,priority:50},redo:{category:"extension",extension:fs,priority:50},textAlign:{category:"extension",extension:_o.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}},Cc=[ma,ga,Rl,jl.configure({HTMLAttributes:{}}),Bl.configure({HTMLAttributes:{}}),zo.TaskItem.configure({nested:!0}),ba,Sc];function wc(t){const e=[],n=new Set,r=new Set;Cc.forEach(l=>{l&&(e.push(l),r.add(l.name))});const s=t.map(l=>Rt(l)),i=new Set;return s.forEach(l=>{const a=At[l];a?.requiredExtensions&&a.requiredExtensions.forEach(u=>{i.add(u)})}),i.forEach(l=>{if(n.has(l))return;const a=At[l];if(!a||a.extension===null)return;const u=a.extension.name;if(r.has(u)){n.add(l);return}const d=a.defaultOptions?a.extension.configure(a.defaultOptions):a.extension;e.push(d),n.add(l),r.add(u)}),s.forEach(l=>{if(n.has(l))return;const a=At[l];if(!a){console.warn(`Extension config not found for modifier: ${l}`);return}if(a.extension===null){n.add(l);return}const u=a.extension.name;if(r.has(u)){n.add(l);return}const d=a.defaultOptions?a.extension.configure(a.defaultOptions):a.extension;e.push(d),n.add(l),r.add(u)}),e.sort((l,a)=>{const u=Object.values(At).find(m=>m?.extension?.name===l.name),d=Object.values(At).find(m=>m?.extension?.name===a.name),f=u?.priority??100;return(d?.priority??100)-f})}const Hi={simple:["bold","italic","bulletList","orderedList","undo","redo"],blog:["bold","italic","underline",{type:"heading",level:2},{type:"heading",level:3},"textAlign","bulletList","orderedList","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","textColor","highlight","codeBlock","blockquote","horizontalRule","hardBreak","undo","redo"],comment:["bold","italic","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","textColor","highlight","codeBlock","blockquote","horizontalRule","hardBreak","undo","redo"]},se={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"}},Je={brand:{primary:{DEFAULT:"#C14615"}},neutral:{gray:{100:"#F3F4F6",200:"#E5E7EB",300:"#D1D5DB",500:"#6B7280",800:"#1F2937"}},palettes:{warning:{200:"#fde68a"}}},te={xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem"},Ac={h1:`font-size: ${se.fontSize["4xl"]}; font-weight: ${se.fontWeight.semibold}; line-height: ${se.lineHeight.tight}; margin: ${te.md} 0 ${te.sm} 0;`,h2:`font-size: ${se.fontSize["2xl"]}; font-weight: ${se.fontWeight.semibold}; line-height: ${se.lineHeight.tight}; margin: ${te.md} 0 ${te.sm} 0;`,h3:`font-size: ${se.fontSize.xl}; font-weight: ${se.fontWeight.semibold}; line-height: ${se.lineHeight.tight}; margin: ${te.md} 0 ${te.sm} 0;`,h4:`font-size: ${se.fontSize.lg}; font-weight: ${se.fontWeight.semibold}; line-height: ${se.lineHeight.tight}; margin: ${te.md} 0 ${te.sm} 0;`,h5:`font-size: ${se.fontSize.base}; font-weight: ${se.fontWeight.semibold}; line-height: ${se.lineHeight.tight}; margin: ${te.md} 0 ${te.sm} 0;`,h6:`font-size: ${se.fontSize.sm}; font-weight: ${se.fontWeight.semibold}; line-height: ${se.lineHeight.tight}; margin: ${te.md} 0 ${te.sm} 0;`,p:`min-height: ${se.lineHeight.normal}em; margin: 0;`,ul:`list-style-type: disc; list-style-position: outside; padding-left: ${te.xl}; margin: ${te.md} 0;`,ol:`list-style-type: decimal; list-style-position: outside; padding-left: ${te.xl}; margin: ${te.md} 0;`,li:`display: list-item; margin: ${te.xs} 0;`,strong:`font-weight: ${se.fontWeight.bold};`,em:"font-style: italic;",s:"text-decoration: line-through;",u:"text-decoration: underline;",code:`background-color: ${Je.neutral.gray[100]}; border-radius: 0.4rem; font-size: ${se.fontSize.sm}; padding: 0.25em 0.3em; font-family: ${se.fontFamily.mono};`,pre:`background: ${Je.neutral.gray[800]}; border-radius: ${te.sm}; color: ${Je.neutral.gray[100]}; font-family: ${se.fontFamily.mono}; margin: ${te.lg} 0; padding: 0.75rem ${te.md}; overflow-x: auto;`,blockquote:`border-left: 3px solid ${Je.neutral.gray[300]}; margin: ${te.lg} 0; padding-left: ${te.md}; color: ${Je.neutral.gray[500]};`,hr:`border: none; border-top: 1px solid ${Je.neutral.gray[200]}; margin: ${te.xl} 0;`,a:`color: ${Je.brand.primary.DEFAULT}; text-decoration: underline; cursor: pointer;`,mark:`background-color: ${Je.palettes.warning[200]}; border-radius: ${te.xs}; padding: 0 0.125rem;`,label:`display: flex; align-items: center; gap: ${te.sm}; cursor: pointer;`,input:"cursor: pointer; margin: 0;"},Nc={taskList:"list-style: none; padding-left: 0; margin: 1rem 0;",taskItem:"display: flex; align-items: flex-start; gap: 0.5rem; margin: 0.5rem 0;"};function Ec(t){if(!t)return t;let e=t;for(const[n,r]of Object.entries(Nc)){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(Ac)){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 Tc=({modifiers:t,zoom:e,onZoomChange:n,onToolbarAction:r})=>{const{editor:s}=hr.useCurrentEditor();return c.jsx(ml,{editor:s,modifiers:t,zoom:e,onZoomChange:n,onToolbarAction:r})},Mc=({showCharacterCount:t,showWordCount:e})=>{const{editor:n}=hr.useCurrentEditor();if(!n||!t&&!e)return null;const r=n.getText(),s=r.length,i=r.split(/\s+/).filter(o=>o.length>0).length;return c.jsxs("div",{className:"flex gap-4 text-xs text-default-500 px-2 pb-1",children:[t&&c.jsxs("span",{children:[s," characters"]}),e&&c.jsxs("span",{children:[i," words"]})]})},ir=v.forwardRef((t,e)=>{const{minRows:n=10,maxRows:r=30,disableAutosize:s=!1,showCharacterCount:i=!1,showWordCount:o=!1,showToolbar:l=!0,modifiers:a=Hi.full,variant:u="bordered",initialContent:d,content:f,onContentChange:p,onUpdate:m,onToolbarAction:C,isReadOnly:b=!1,isDisabled:k=!1,includeInlineStyles:S=!0,...w}=t,{zoom:j,setZoom:N}=fl(),D=Jr.lineHeight,L=n*D,O=s?void 0:r*D,z=v.useMemo(()=>wc(a),[a]),{Component:H,label:U,shouldLabelBeOutside:P,getBaseProps:M,getLabelProps:F,getInputWrapperProps:$}=y.useInput({...w,variant:u,ref:e,isMultiline:!0}),B=U?c.jsx("label",{...F(),children:U}):null,Y=v.useCallback(({editor:W})=>{const ye=W.getHTML(),de=S?Ec(ye):ye,xe=W.getJSON(),qe=W.getText(),pt=qe.length,Ct=qe.split(/\s+/).filter(we=>we.length>0).length,ne={html:de,json:xe,text:qe,characters:pt,words:Ct};if(p?.(ne),m?.(ne),"onChange"in w&&typeof w.onChange=="function"){const we={target:{value:de},currentTarget:{value:de}};w.onChange(we)}},[p,m,w,S]);return c.jsxs(H,{...M(),children:[P?B:null,c.jsx("div",{...$(),className:y.cn($().className,"flex flex-col w-full p-0 gap-0 rich-text-editor"),style:{maxHeight:O?`${O+Jr.toolbarHeight}px`:void 0,overflow:O?"auto":void 0},children:c.jsx(hr.EditorProvider,{editable:!b&&!k,slotBefore:l?c.jsx(Tc,{modifiers:a,zoom:j,onZoomChange:N,onToolbarAction:C}):void 0,slotAfter:c.jsx(Mc,{showCharacterCount:i,showWordCount:o}),editorContainerProps:{className:"w-full flex-1 outline-none",style:{minHeight:`${L}px`,fontSize:`${j}%`,display:"flex",flexDirection:"column"}},editorProps:{attributes:{class:"focus:outline-none w-full h-full"}},extensions:z,content:f||d||t.defaultValue||"",onUpdate:Y})})]})});ir.displayName="TipTapEditor";const Ui=v.forwardRef((t,e)=>{const{adapter:n="tiptap",variant:r="bordered",...s}=t;return n==="tiptap"?c.jsx(ir,{...s,variant:r,ref:e}):(console.warn(`Adapter "${n}" is not supported. Using TipTap.`),c.jsx(ir,{...s,variant:r,ref:e}))});Ui.displayName="RichTextArea";function Oc(t,e="en-US",n="USD"){try{return new Intl.NumberFormat(e,{style:"currency",currency:n,minimumFractionDigits:0,maximumFractionDigits:2}).format(t)}catch(r){return console.warn(`Invalid currency formatting: ${r}`),`${n} ${t.toFixed(2)}`}}const Es=[{id:"100",amount:100},{id:"250",amount:250},{id:"500",amount:500},{id:"1000",amount:1e3},{id:"2000",amount:2e3}],Ic={title:"Donation Amount",customAmountPlaceholder:"Custom donation amount",customAmountAriaLabel:"Custom donation amount"},qi=({presetAmounts:t=Es,selectedDonation:e,defaultSelectedDonation:n=null,onChange:r,currency:s="USD",locale:i="en-US",showCustomAmount:o=!0,minCustomAmount:l=.5,maxCustomAmount:a=1e6,labels:u,mobileColumns:d=2,desktopColumns:f=3,isDisabled:p=!1,buttonVariant:m="bordered",buttonColor:C="default",inputVariant:b="bordered",className:k="",showCard:S=!0})=>{const w={...Ic,...u},j=Array.isArray(t)?t:Es,N={2:"grid-cols-2",3:"grid-cols-3"},D={3:"sm:grid-cols-3",4:"sm:grid-cols-4",5:"sm:grid-cols-5",6:"sm:grid-cols-6"},L=`${N[d]} ${D[f]}`,[O,z]=pr(e,n,r),[H,U]=v.useState(""),P=v.useCallback(B=>{if(p)return;const Y={amount:B.amount,isCustom:!1,presetId:B.id};z(Y),U("")},[p,z]),M=v.useCallback(B=>{if(p)return;if(U(B!==void 0?String(B):""),B===void 0||isNaN(B)){z(null);return}z({amount:B,isCustom:!0})},[p,z]),F=v.useMemo(()=>({style:"currency",currency:s,currencyDisplay:"symbol"}),[s]),$=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}),j.length>0&&c.jsx("div",{className:y.cn("grid gap-3",L),"data-testid":"donation-amounts-presets",children:j.map(B=>{const Y=O!==null&&!O.isCustom&&O.presetId===B.id;return c.jsx(oe,{color:Y?"primary":C,variant:Y?"solid":m,className:"w-full",onPress:()=>P(B),isDisabled:p,"data-testid":`donation-amounts-preset-${B.id}`,children:B.label||Oc(B.amount,i,s)},B.id)})}),o&&c.jsx(y.NumberInput,{placeholder:w.customAmountPlaceholder,"aria-label":w.customAmountAriaLabel,variant:b,radius:"md",minValue:l,maxValue:a,step:.01,formatOptions:F,value:H!==""?parseFloat(H):void 0,onValueChange:M,isDisabled:p,"data-testid":"donation-amounts-custom-input"},O?.isCustom===!1?O.presetId:"custom")]});return S?c.jsx(y.Card,{className:y.cn("w-full",k),"data-testid":"donation-amounts-card",children:c.jsx(y.CardBody,{children:$})}):c.jsx("div",{className:y.cn("w-full",k),"data-testid":"donation-amounts-plain",children:$})};qi.displayName="DonationAmounts";const Dc=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`},jc=t=>{switch(t){case"warning":return _.Clock;case"error":return _.AlertCircle;case"success":return _.CheckCircle;default:return _.Clock}},Lc=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"}},Ki=v.forwardRef(({timeLeft:t,defaultTimeLeft:e=1200,onTimeChange:n,onExpire:r,variant:s="info",color:i="primary",message:o="Your cart expires in:",showIcon:l=!0,icon:a,position:u="fixed",autoStart:d=!0,formatTime:f=Dc,className:p,...m},C)=>{const[b,k]=pr(t!==void 0?Math.max(0,t):void 0,Math.max(0,e),n),S=v.useRef(null),w=v.useRef(!1);v.useEffect(()=>()=>{S.current&&clearInterval(S.current)},[]),v.useEffect(()=>{if(!d||b<=0){S.current&&(clearInterval(S.current),S.current=null);return}return S.current=setInterval(()=>{k(L=>L<=1?(S.current&&(clearInterval(S.current),S.current=null),w.current||(w.current=!0,r?.()),0):L-1)},1e3),()=>{S.current&&(clearInterval(S.current),S.current=null)}},[d,b,k,r]),v.useEffect(()=>{b>0&&(w.current=!1)},[b]);const j=a||jc(s),N=Lc(i),D={fixed:"fixed top-0 left-0",sticky:"sticky top-0",static:"static"};return c.jsx("div",{ref:C,role:"banner","aria-live":"polite","aria-label":`${o} ${f(b)}`,"data-testid":"expire-cart-timer",className:y.cn("w-full text-white z-50",N,D[u],p),...m,children:c.jsx("div",{className:"container mx-auto px-4 py-3 sm:py-2.5","data-testid":"expire-cart-timer-container",children:c.jsxs("div",{className:"flex items-center justify-between gap-3 sm:gap-4",children:[c.jsxs("div",{className:"flex items-center gap-3 sm:gap-2.5 flex-1 min-w-0","data-testid":"expire-cart-timer-left",children:[l&&c.jsx("div",{className:"flex-shrink-0 w-[0.875rem] h-[0.875rem] sm:w-4 sm:h-4 rounded-full bg-white flex items-center justify-center overflow-hidden","data-testid":"expire-cart-timer-icon-wrapper",children:c.jsx(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(b)}`,"data-testid":"expire-cart-timer-value",children:f(b)})})]})})})});Ki.displayName="ExpireCartTimer";function Rc(t,e){const n=t.icons,r=t.aliases||Object.create(null),s=Object.create(null);function i(o){if(n[o])return s[o]=[];if(!(o in s)){s[o]=null;const l=r[o]&&r[o].parent,a=l&&i(l);a&&(s[o]=[l].concat(a))}return s[o]}return Object.keys(n).concat(Object.keys(r)).forEach(i),s}const Ji=Object.freeze({left:0,top:0,width:16,height:16}),fn=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),Er=Object.freeze({...Ji,...fn}),or=Object.freeze({...Er,body:"",hidden:!1});function Fc(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 Ts(t,e){const n=Fc(t,e);for(const r in or)r in fn?r in t&&!(r in n)&&(n[r]=fn[r]):r in e?n[r]=e[r]:r in t&&(n[r]=t[r]);return n}function Pc(t,e,n){const r=t.icons,s=t.aliases||Object.create(null);let i={};function o(l){i=Ts(r[l]||s[l],i)}return o(e),n.forEach(o),Ts(t,i)}function Wi(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=Rc(t);for(const s in r){const i=r[s];i&&(e(s,Pc(t,s,i)),n.push(s))}return n}const $c={provider:"",aliases:{},not_found:{},...Ji};function Hn(t,e){for(const n in e)if(n in t&&typeof t[n]!=typeof e[n])return!1;return!0}function Gi(t){if(typeof t!="object"||t===null)return null;const e=t;if(typeof e.prefix!="string"||!t.icons||typeof t.icons!="object"||!Hn(t,$c))return null;const n=e.icons;for(const s in n){const i=n[s];if(!s||typeof i.body!="string"||!Hn(i,or))return null}const r=e.aliases||Object.create(null);for(const s in r){const i=r[s],o=i.parent;if(!s||typeof o!="string"||!n[o]&&!r[o]||!Hn(i,or))return null}return e}const Ms=Object.create(null);function Vc(t,e){return{provider:t,prefix:e,icons:Object.create(null),missing:new Set}}function St(t,e){const n=Ms[t]||(Ms[t]=Object.create(null));return n[e]||(n[e]=Vc(t,e))}function Zi(t,e){return Gi(e)?Wi(e,(n,r)=>{r?t.icons[n]=r:t.missing.add(n)}):[]}function Bc(t,e,n){try{if(typeof n.body=="string")return t.icons[e]={...n},!0}catch{}return!1}const Qi=/^[a-z0-9]+(-[a-z0-9]+)*$/,vn=(t,e,n,r="")=>{const s=t.split(":");if(t.slice(0,1)==="@"){if(s.length<2||s.length>3)return null;r=s.shift().slice(1)}if(s.length>3||!s.length)return null;if(s.length>1){const l=s.pop(),a=s.pop(),u={provider:s.length>0?s[0]:r,prefix:a,name:l};return e&&!Yt(u)?null:u}const i=s[0],o=i.split("-");if(o.length>1){const l={provider:r,prefix:o.shift(),name:o.join("-")};return e&&!Yt(l)?null:l}if(n&&r===""){const l={provider:r,prefix:"",name:i};return e&&!Yt(l,n)?null:l}return null},Yt=(t,e)=>t?!!((e&&t.prefix===""||t.prefix)&&t.name):!1;let zt=!1;function Xi(t){return typeof t=="boolean"&&(zt=t),zt}function Os(t){const e=typeof t=="string"?vn(t,!0,zt):t;if(e){const n=St(e.provider,e.prefix),r=e.name;return n.icons[r]||(n.missing.has(r)?null:void 0)}}function zc(t,e){const n=vn(t,!0,zt);if(!n)return!1;const r=St(n.provider,n.prefix);return e?Bc(r,n.name,e):(r.missing.add(n.name),!0)}function _c(t,e){if(typeof t!="object")return!1;if(typeof e!="string"&&(e=t.provider||""),zt&&!e&&!t.prefix){let s=!1;return Gi(t)&&(t.prefix="",Wi(t,(i,o)=>{zc(i,o)&&(s=!0)})),s}const n=t.prefix;if(!Yt({prefix:n,name:"a"}))return!1;const r=St(e,n);return!!Zi(r,t)}const Yi=Object.freeze({width:null,height:null}),eo=Object.freeze({...Yi,...fn}),Hc=/(-?[0-9.]*[0-9]+[0-9.]*)/g,Uc=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function Is(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(Hc);if(r===null||!r.length)return t;const s=[];let i=r.shift(),o=Uc.test(i);for(;;){if(o){const l=parseFloat(i);isNaN(l)?s.push(i):s.push(Math.ceil(l*e*n)/n)}else s.push(i);if(i=r.shift(),i===void 0)return s.join("");o=!o}}function qc(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 Kc(t,e){return t?"<defs>"+t+"</defs>"+e:e}function Jc(t,e,n){const r=qc(t);return Kc(r.defs,e+r.content+n)}const Wc=t=>t==="unset"||t==="undefined"||t==="none";function Gc(t,e){const n={...Er,...t},r={...eo,...e},s={left:n.left,top:n.top,width:n.width,height:n.height};let i=n.body;[n,r].forEach(b=>{const k=[],S=b.hFlip,w=b.vFlip;let j=b.rotate;S?w?j+=2:(k.push("translate("+(s.width+s.left).toString()+" "+(0-s.top).toString()+")"),k.push("scale(-1 1)"),s.top=s.left=0):w&&(k.push("translate("+(0-s.left).toString()+" "+(s.height+s.top).toString()+")"),k.push("scale(1 -1)"),s.top=s.left=0);let N;switch(j<0&&(j-=Math.floor(j/4)*4),j=j%4,j){case 1:N=s.height/2+s.top,k.unshift("rotate(90 "+N.toString()+" "+N.toString()+")");break;case 2:k.unshift("rotate(180 "+(s.width/2+s.left).toString()+" "+(s.height/2+s.top).toString()+")");break;case 3:N=s.width/2+s.left,k.unshift("rotate(-90 "+N.toString()+" "+N.toString()+")");break}j%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)),k.length&&(i=Jc(i,'<g transform="'+k.join(" ")+'">',"</g>"))});const o=r.width,l=r.height,a=s.width,u=s.height;let d,f;o===null?(f=l===null?"1em":l==="auto"?u:l,d=Is(f,a/u)):(d=o==="auto"?a:o,f=l===null?Is(d,u/a):l==="auto"?u:l);const p={},m=(b,k)=>{Wc(k)||(p[b]=k.toString())};m("width",d),m("height",f);const C=[s.left,s.top,a,u];return p.viewBox=C.join(" "),{attributes:p,viewBox:C,body:i}}const Zc=/\sid="(\S+)"/g,Qc="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let Xc=0;function Yc(t,e=Qc){const n=[];let r;for(;r=Zc.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+(Xc++).toString(),l=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");t=t.replace(new RegExp('([#;"])('+l+')([")]|\\.[a-z])',"g"),"$1"+o+s+"$3")}),t=t.replace(new RegExp(s,"g"),""),t}const lr=Object.create(null);function eu(t,e){lr[t]=e}function ar(t){return lr[t]||lr[""]}function Tr(t){let e;if(typeof t.resources=="string")e=[t.resources];else if(e=t.resources,!(e instanceof Array)||!e.length)return null;return{resources:e,path:t.path||"/",maxURL:t.maxURL||500,rotate:t.rotate||750,timeout:t.timeout||5e3,random:t.random===!0,index:t.index||0,dataAfterTimeout:t.dataAfterTimeout!==!1}}const Mr=Object.create(null),Nt=["https://api.simplesvg.com","https://api.unisvg.com"],en=[];for(;Nt.length>0;)Nt.length===1||Math.random()>.5?en.push(Nt.shift()):en.push(Nt.pop());Mr[""]=Tr({resources:["https://api.iconify.design"].concat(en)});function tu(t,e){const n=Tr(e);return n===null?!1:(Mr[t]=n,!0)}function Or(t){return Mr[t]}const nu=()=>{let t;try{if(t=fetch,typeof t=="function")return t}catch{}};let Ds=nu();function ru(t,e){const n=Or(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 su(t){return t===404}const iu=(t,e,n)=>{const r=[],s=ru(t,e),i="icons";let o={type:i,provider:t,prefix:e,icons:[]},l=0;return n.forEach((a,u)=>{l+=a.length+1,l>=s&&u>0&&(r.push(o),o={type:i,provider:t,prefix:e,icons:[]},l=a.length),o.icons.push(a)}),r.push(o),r};function ou(t){if(typeof t=="string"){const e=Or(t);if(e)return e.path}return"/"}const lu=(t,e,n)=>{if(!Ds){n("abort",424);return}let r=ou(e.provider);switch(e.type){case"icons":{const i=e.prefix,l=e.icons.join(","),a=new URLSearchParams({icons:l});r+=i+".json?"+a.toString();break}case"custom":{const i=e.uri;r+=i.slice(0,1)==="/"?i.slice(1):i;break}default:n("abort",400);return}let s=503;Ds(t+r).then(i=>{const o=i.status;if(o!==200){setTimeout(()=>{n(su(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)})},au={prepare:iu,send:lu};function to(t,e){t.forEach(n=>{const r=n.loaderCallbacks;r&&(n.loaderCallbacks=r.filter(s=>s.id!==e))})}function cu(t){t.pendingCallbacksFlag||(t.pendingCallbacksFlag=!0,setTimeout(()=>{t.pendingCallbacksFlag=!1;const e=t.loaderCallbacks?t.loaderCallbacks.slice(0):[];if(!e.length)return;let n=!1;const r=t.provider,s=t.prefix;e.forEach(i=>{const o=i.icons,l=o.pending.length;o.pending=o.pending.filter(a=>{if(a.prefix!==s)return!0;const u=a.name;if(t.icons[u])o.loaded.push({provider:r,prefix:s,name:u});else if(t.missing.has(u))o.missing.push({provider:r,prefix:s,name:u});else return n=!0,!0;return!1}),o.pending.length!==l&&(n||to([t],i.id),i.callback(o.loaded.slice(0),o.missing.slice(0),o.pending.slice(0),i.abort))})}))}let uu=0;function du(t,e,n){const r=uu++,s=to.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 fu(t){const e={loaded:[],missing:[],pending:[]},n=Object.create(null);t.sort((s,i)=>s.provider!==i.provider?s.provider.localeCompare(i.provider):s.prefix!==i.prefix?s.prefix.localeCompare(i.prefix):s.name.localeCompare(i.name));let r={provider:"",prefix:"",name:""};return t.forEach(s=>{if(r.name===s.name&&r.prefix===s.prefix&&r.provider===s.provider)return;r=s;const i=s.provider,o=s.prefix,l=s.name,a=n[i]||(n[i]=Object.create(null)),u=a[o]||(a[o]=St(i,o));let d;l in u.icons?d=e.loaded:o===""||u.missing.has(l)?d=e.missing:d=e.pending;const f={provider:i,prefix:o,name:l};d.push(f)}),e}function hu(t,e=!0,n=!1){const r=[];return t.forEach(s=>{const i=typeof s=="string"?vn(s,e,n):s;i&&r.push(i)}),r}const pu={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function mu(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 L=t.resources.slice(0);for(o=[];L.length>1;){const O=Math.floor(Math.random()*L.length);o.push(L[O]),L=L.slice(0,O).concat(L.slice(O+1))}o=o.concat(L)}else o=t.resources.slice(i).concat(t.resources.slice(0,i));const l=Date.now();let a="pending",u=0,d,f=null,p=[],m=[];typeof r=="function"&&m.push(r);function C(){f&&(clearTimeout(f),f=null)}function b(){a==="pending"&&(a="aborted"),C(),p.forEach(L=>{L.status==="pending"&&(L.status="aborted")}),p=[]}function k(L,O){O&&(m=[]),typeof L=="function"&&m.push(L)}function S(){return{startTime:l,payload:e,status:a,queriesSent:u,queriesPending:p.length,subscribe:k,abort:b}}function w(){a="failed",m.forEach(L=>{L(void 0,d)})}function j(){p.forEach(L=>{L.status==="pending"&&(L.status="aborted")}),p=[]}function N(L,O,z){const H=O!=="success";switch(p=p.filter(U=>U!==L),a){case"pending":break;case"failed":if(H||!t.dataAfterTimeout)return;break;default:return}if(O==="abort"){d=z,w();return}if(H){d=z,p.length||(o.length?D():w());return}if(C(),j(),!t.random){const U=t.resources.indexOf(L.resource);U!==-1&&U!==t.index&&(t.index=U)}a="completed",m.forEach(U=>{U(z)})}function D(){if(a!=="pending")return;C();const L=o.shift();if(L===void 0){if(p.length){f=setTimeout(()=>{C(),a==="pending"&&(j(),w())},t.timeout);return}w();return}const O={status:"pending",resource:L,callback:(z,H)=>{N(O,z,H)}};p.push(O),u++,f=setTimeout(D,t.rotate),n(L,e,O.callback)}return setTimeout(D),S}function no(t){const e={...pu,...t};let n=[];function r(){n=n.filter(l=>l().status==="pending")}function s(l,a,u){const d=mu(e,l,a,(f,p)=>{r(),u&&u(f,p)});return n.push(d),d}function i(l){return n.find(a=>l(a))||null}return{query:s,find:i,setIndex:l=>{e.index=l},getIndex:()=>e.index,cleanup:r}}function js(){}const Un=Object.create(null);function gu(t){if(!Un[t]){const e=Or(t);if(!e)return;const n=no(e),r={config:e,redundancy:n};Un[t]=r}return Un[t]}function yu(t,e,n){let r,s;if(typeof t=="string"){const i=ar(t);if(!i)return n(void 0,424),js;s=i.send;const o=gu(t);o&&(r=o.redundancy)}else{const i=Tr(t);if(i){r=no(i);const o=t.resources?t.resources[0]:"",l=ar(o);l&&(s=l.send)}}return!r||!s?(n(void 0,424),js):r.query(e,s,n)().abort}function Ls(){}function xu(t){t.iconsLoaderFlag||(t.iconsLoaderFlag=!0,setTimeout(()=>{t.iconsLoaderFlag=!1,cu(t)}))}function bu(t){const e=[],n=[];return t.forEach(r=>{(r.match(Qi)?e:n).push(r)}),{valid:e,invalid:n}}function Et(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(!Zi(t,n).length){r();return}}catch(s){console.error(s)}r(),xu(t)}function Rs(t,e){t instanceof Promise?t.then(n=>{e(n)}).catch(()=>{e(null)}):e(t)}function ku(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)){Rs(t.loadIcons(s,r,n),d=>{Et(t,s,d)});return}if(i){s.forEach(d=>{const f=i(d,r,n);Rs(f,p=>{const m=p?{prefix:r,icons:{[d]:p}}:null;Et(t,[d],m)})});return}const{valid:o,invalid:l}=bu(s);if(l.length&&Et(t,l,null),!o.length)return;const a=r.match(Qi)?ar(n):null;if(!a){Et(t,o,null);return}a.prepare(n,r,o).forEach(d=>{yu(n,d,f=>{Et(t,d.icons,f)})})}))}const vu=(t,e)=>{const n=hu(t,!0,Xi()),r=fu(n);if(!r.pending.length){let a=!0;return e&&setTimeout(()=>{a&&e(r.loaded,r.missing,r.pending,Ls)}),()=>{a=!1}}const s=Object.create(null),i=[];let o,l;return r.pending.forEach(a=>{const{provider:u,prefix:d}=a;if(d===l&&u===o)return;o=u,l=d,i.push(St(u,d));const f=s[u]||(s[u]=Object.create(null));f[d]||(f[d]=[])}),r.pending.forEach(a=>{const{provider:u,prefix:d,name:f}=a,p=St(u,d),m=p.pendingIcons||(p.pendingIcons=new Set);m.has(f)||(m.add(f),s[u][d].push(f))}),i.forEach(a=>{const u=s[a.provider][a.prefix];u.length&&ku(a,u)}),e?du(e,r,i):Ls};function Su(t,e){const n={...t};for(const r in e){const s=e[r],i=typeof s;r in Yi?(s===null||s&&(i==="string"||i==="number"))&&(n[r]=s):i===typeof n[r]&&(n[r]=r==="rotate"?s%4:s)}return n}const Cu=/[\s,]+/;function wu(t,e){e.split(Cu).forEach(n=>{switch(n.trim()){case"horizontal":t.hFlip=!0;break;case"vertical":t.vFlip=!0;break}})}function Au(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 Nu(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 Eu(t){return t.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function Tu(t){return"data:image/svg+xml,"+Eu(t)}function Mu(t){return'url("'+Tu(t)+'")'}let Dt;function Ou(){try{Dt=window.trustedTypes.createPolicy("iconify",{createHTML:t=>t})}catch{Dt=null}}function Iu(t){return Dt===void 0&&Ou(),Dt?Dt.createHTML(t):t}const ro={...eo,inline:!1},Du={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},ju={display:"inline-block"},cr={backgroundColor:"currentColor"},so={backgroundColor:"transparent"},Fs={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},Ps={WebkitMask:cr,mask:cr,background:so};for(const t in Ps){const e=Ps[t];for(const n in Fs)e[t+n]=Fs[n]}const Lu={...ro,inline:!0};function $s(t){return t+(t.match(/^[-0-9.]+$/)?"px":"")}const Ru=(t,e,n)=>{const r=e.inline?Lu:ro,s=Su(r,e),i=e.mode||"svg",o={},l=e.style||{},a={...i==="svg"?Du:{}};if(n){const k=vn(n,!1,!0);if(k){const S=["iconify"],w=["provider","prefix"];for(const j of w)k[j]&&S.push("iconify--"+k[j]);a.className=S.join(" ")}}for(let k in e){const S=e[k];if(S!==void 0)switch(k){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":a.ref=S;break;case"className":a[k]=(a[k]?a[k]+" ":"")+S;break;case"inline":case"hFlip":case"vFlip":s[k]=S===!0||S==="true"||S===1;break;case"flip":typeof S=="string"&&wu(s,S);break;case"color":o.color=S;break;case"rotate":typeof S=="string"?s[k]=Au(S):typeof S=="number"&&(s[k]=S);break;case"ariaHidden":case"aria-hidden":S!==!0&&S!=="true"&&delete a["aria-hidden"];break;default:r[k]===void 0&&(a[k]=S)}}const u=Gc(t,s),d=u.attributes;if(s.inline&&(o.verticalAlign="-0.125em"),i==="svg"){a.style={...o,...l},Object.assign(a,d);let k=0,S=e.id;return typeof S=="string"&&(S=S.replace(/-/g,"_")),a.dangerouslySetInnerHTML={__html:Iu(Yc(u.body,S?()=>S+"ID"+k++:"iconifyReact"))},v.createElement("svg",a)}const{body:f,width:p,height:m}=t,C=i==="mask"||(i==="bg"?!1:f.indexOf("currentColor")!==-1),b=Nu(f,{...d,width:p+"",height:m+""});return a.style={...o,"--svg":Mu(b),width:$s(d.width),height:$s(d.height),...ju,...C?cr:so,...l},v.createElement("span",a)};Xi(!0);eu("",au);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"||!_c(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;tu(n,s)||console.error(r)}catch{console.error(r)}}}}function io(t){const[e,n]=v.useState(!!t.ssr),[r,s]=v.useState({});function i(m){if(m){const C=t.icon;if(typeof C=="object")return{name:"",data:C};const b=Os(C);if(b)return{name:C,data:b}}return{name:""}}const[o,l]=v.useState(i(!!t.ssr));function a(){const m=r.callback;m&&(m(),s({}))}function u(m){if(JSON.stringify(o)!==JSON.stringify(m))return a(),l(m),!0}function d(){var m;const C=t.icon;if(typeof C=="object"){u({name:"",data:C});return}const b=Os(C);if(u({name:C,data:b}))if(b===void 0){const k=vu([C],d);s({callback:k})}else b&&((m=t.onLoad)===null||m===void 0||m.call(t,C))}v.useEffect(()=>(n(!0),a),[]),v.useEffect(()=>{e&&d()},[t.icon,e]);const{name:f,data:p}=o;return p?Ru({...Er,...p},t,f):t.children?t.children:t.fallback?t.fallback:v.createElement("span",{})}const Ie=v.forwardRef((t,e)=>io({...t,_ref:e}));v.forwardRef((t,e)=>io({inline:!0,...t,_ref:e}));const qn=({icon:t,children:e,testId:n})=>c.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600","data-testid":n,children:[c.jsx(Ie,{icon:t,width:20,className:"text-default-500"}),c.jsx("span",{children:e})]}),Fu=({classes:t="",name:e,imageUrl:n,eventDate:r,eventTime:s,location:i,description:o,showImage:l=!1,showMoreButtonClassName:a,labels:u})=>{const[d,f]=v.useState(!1),[p,m]=v.useState(!1),C=v.useRef(null);return v.useEffect(()=>{const b=()=>{if(C.current){const k=C.current.scrollHeight>C.current.clientHeight;m(k)}};return b(),window.addEventListener("resize",b),()=>window.removeEventListener("resize",b)},[o]),c.jsxs(y.Card,{className:y.cn("border-0 shadow-none",t),"data-testid":"event-details-root",children:[c.jsxs(y.CardHeader,{className:"pt-2 pb-0 flex-col items-start space-y-2","data-testid":"event-details-header",children:[l&&n&&c.jsx("div",{className:"w-full aspect-[3/1] overflow-hidden rounded-xl","data-testid":"event-details-image-wrapper",children:c.jsx(y.Image,{alt:`Event image for ${e}`,className:"w-full h-full object-cover",src:n,"data-testid":"event-details-image"})}),c.jsx("h2",{className:"font-semibold text-xl text-gray-800","data-testid":"event-details-title",children:e})]}),c.jsxs(y.CardBody,{className:"py-3 space-y-3","data-testid":"event-details-body",children:[c.jsx("h3",{className:"font-semibold text-base text-gray-700","data-testid":"event-details-info-label",children:u.eventInformation}),c.jsxs("div",{className:"flex flex-wrap gap-4","data-testid":"event-details-info",children:[r&&c.jsx(qn,{icon:"solar:calendar-minimalistic-linear",testId:"event-details-date",children:r}),s&&c.jsx(qn,{icon:"solar:clock-circle-linear",testId:"event-details-time",children:s}),i&&c.jsx(qn,{icon:"solar:point-on-map-outline",testId:"event-details-location",children:i})]}),o&&c.jsxs("div",{className:"relative","data-testid":"event-details-description-wrapper",children:[c.jsx("div",{ref:C,className:y.cn("text-sm text-gray-700 leading-relaxed transition-all",!d&&"line-clamp-2"),"data-testid":"event-details-description",dangerouslySetInnerHTML:{__html:o}}),(p||d)&&c.jsx("div",{className:"flex justify-end mt-1",children:c.jsx(oe,{onPress:()=>f(!d),variant:"light",className:y.cn("text-primary",a),startContent:c.jsx(Ie,{icon:d?"solar:eye-closed-linear":"solar:eye-linear",width:20}),"data-testid":"event-details-toggle-description",children:d?u.showLess||"Hide":u.showMore||"Show"})})]})]})]})};function oo(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 Pu(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 $u={person:"Person",people:"People",tickets:"Tickets:",soldOut:"Sold Out",maxReached:"Maximum number of tickets allowed reached"},Gt=t=>typeof t=="number"&&!isNaN(t),Ir=({offer:t,quantity:e,defaultQuantity:n=0,onQuantityChange:r,currency:s="USD",locale:i="en-US",labels:o,slots:l,isDisabled:a=!1,buttonVariant:u="bordered",buttonColor:d="default",showCard:f=!0,showDescription:p=!0,showPeopleCount:m=!0,showPrice:C=!0,classNames:b={},"data-testid":k,selectedColor:S="default"})=>{const w={...$u,...o},[j,N]=v.useState(n),D=e!==void 0?e:j,L=de=>{if(a)return;const xe=Math.max(0,D+de);e===void 0&&N(xe),r?.(t.id,xe)},O=v.useMemo(()=>!Gt(t.totalTicketsSold)||!Gt(t.ticketsAllowed)?!1:t.totalTicketsSold>=t.ticketsAllowed,[t.totalTicketsSold,t.ticketsAllowed]),z=v.useMemo(()=>O||!Gt(t.ticketsAllowed)?!1:D>=t.ticketsAllowed-(t.totalTicketsSold??0),[O,t.ticketsAllowed,t.totalTicketsSold,D]),H=oo(t.price,i,s),U=()=>l?.renderName?l.renderName(t.name,t):c.jsx("h2",{"data-testid":"offer-card-name",className:y.cn("text-base font-medium",b.name),children:t.name}),P=()=>C?l?.renderPrice?l.renderPrice(t.price,H,t):c.jsx("p",{"data-testid":"offer-card-price",className:y.cn("text-primary text-base mt-1",b.price),children:H}):null,M=()=>!p||!t.description?null:l?.renderDescription?l.renderDescription(t.description,t):c.jsx("p",{"data-testid":"offer-card-description",className:y.cn("mb-4 text-sm text-gray-700 leading-relaxed",b.description),children:t.description}),F=()=>{if(!m||!Gt(t.numberOfPeople)||t.numberOfPeople<=0)return null;const de=t.numberOfPeople===1?w.person:w.people;return l?.renderPeopleCount?l.renderPeopleCount(t.numberOfPeople,de,t):c.jsxs("p",{"data-testid":"offer-card-people-count",className:y.cn("text-sm text-gray-600 flex items-center mt-2",b.peopleCount),children:[c.jsx(Ie,{icon:t.numberOfPeople<=1?"solar:user-rounded-outline":"solar:users-group-rounded-outline",width:20,className:"mr-1"}),t.numberOfPeople," ",de]})},$=()=>{const de=D===0||a,xe=z||a;return l?.renderQuantitySelector?l.renderQuantitySelector({quantity:D,onIncrement:()=>L(1),onDecrement:()=>L(-1),isDecrementDisabled:de,isIncrementDisabled:xe,isDisabled:a}):c.jsxs("div",{className:y.cn("flex items-center gap-2",b.quantitySelector),children:[c.jsx(oe,{"data-testid":"offer-card-decrement-button",onPress:()=>L(-1),isDisabled:de,variant:u,color:D>0?S:d,radius:"full",isIconOnly:!0,size:"sm","aria-label":"Decrease quantity",children:c.jsx(Ie,{icon:"gravity-ui:minus",width:16})}),c.jsx("span",{"data-testid":"offer-card-quantity",className:y.cn("min-w-[2rem] text-center font-medium"),children:D}),c.jsx(oe,{"data-testid":"offer-card-increment-button",onPress:()=>L(1),isDisabled:xe,variant:u,color:D>0?S:d,radius:"full",isIconOnly:!0,size:"sm","aria-label":"Increase quantity",children:c.jsx(Ie,{icon:"gravity-ui:plus",width:16})})]})},B=()=>l?.renderSoldOut?l.renderSoldOut(w.soldOut):c.jsx(y.Chip,{"data-testid":"offer-card-sold-out-chip",color:"danger",className:y.cn("gap-2 px-4 h-8",b.soldOut),startContent:c.jsx(Ie,{icon:"gravity-ui:circle-info-fill",width:14}),children:c.jsx("span",{className:"font-medium text-sm",children:w.soldOut})}),Y=()=>l?.renderMaxReachedAlert?l.renderMaxReachedAlert(w.maxReached):c.jsx(y.Chip,{"data-testid":"offer-card-max-reached-chip",variant:"flat",color:"warning",classNames:{base:"gap-2 px-4 h-10",content:"text-black"},className:y.cn(" text-black! gap-2 px-4 h-10",b.maxReachedAlert),startContent:c.jsx(Ie,{icon:"gravity-ui:triangle-exclamation-fill",className:"text-black",width:16}),children:c.jsx("span",{className:"font-medium text-sm",children:w.maxReached})}),W=c.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-1 xl:grid-cols-3 lg:grid-cols-3 gap-2 items-start",children:[c.jsxs("div",{className:y.cn("h-full col-span-2",O?"opacity-50 pointer-events-none select-none":""),children:[U(),P(),c.jsxs("div",{className:y.cn("md:col-span-1 xl:col-span-2 lg:col-span-1 mb-2",O?"opacity-50 pointer-events-none select-none":""),children:[F(),M()]})]}),c.jsx("div",{className:"space-x-2 p-2 h-full flex items-center justify-start md:justify-start lg:justify-end ",children:O?B():$()})]}),ye=z&&!O&&c.jsx(Re.motion.div,{className:"w-full sm:max-w-[60%] md:max-w-[60%] lg:max-w-[60%]",initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.3},children:Y()});return f?c.jsxs(y.Card,{className:y.cn("w-full",b.base),"data-testid":k||`offer-card-${t.id}`,children:[c.jsx(y.CardBody,{className:y.cn("pt-1 pb-0",b.body),children:W}),c.jsx(Re.AnimatePresence,{children:ye&&c.jsx(y.CardFooter,{className:y.cn("w-full mt-0 pt-0",b.footer),children:ye})})]}):c.jsxs("div",{className:y.cn("w-full",b.base),"data-testid":k||`offer-card-${t.id}`,children:[c.jsx("div",{className:y.cn("pt-1 pb-0",b.body),children:W}),c.jsx(Re.AnimatePresence,{children:ye&&c.jsx("div",{className:y.cn("w-full mt-0 pt-0",b.footer),children:ye})})]})};Ir.displayName="OfferCard";const lo=({message:t="No offers available.",icon:e="solar:ticket-sale-outline",iconSize:n=48,showCard:r=!0,classNames:s={},renderEmpty:i})=>{if(i){const l=i();return r?c.jsx(y.Card,{"data-testid":"offer-card-empty",className:y.cn("w-full",s.base),children:c.jsx(y.CardBody,{"data-testid":"offer-card-empty-body",children:l})}):c.jsx("div",{"data-testid":"offer-card-empty",className:y.cn("w-full",s.base),children:l})}const o=c.jsxs("div",{"data-testid":"offer-card-empty-content",className:y.cn("flex flex-col items-center justify-center p-8 text-center text-gray-500",s.content),children:[c.jsx(Ie,{"data-testid":"offer-card-empty-icon",icon:e,width:n,className:y.cn("mb-4",s.icon)}),c.jsx("h3",{"data-testid":"offer-card-empty-message",className:y.cn("text-lg",s.message),children:t})]});return r?c.jsx(y.Card,{"data-testid":"offer-card-empty",className:y.cn("w-full",s.base),children:c.jsx(y.CardBody,{"data-testid":"offer-card-empty-body",children:o})}):c.jsx("div",{"data-testid":"offer-card-empty",className:y.cn("w-full",s.base),children:o})};lo.displayName="OfferCardEmpty";const Vu={title:"Error Fetching Offers",description:"An error occurred while fetching offers."},ao=({error:t,labels:e,showCard:n=!0,color:r="danger",classNames:s={}})=>{const i={...Vu,...e},o=c.jsx(y.Alert,{"data-testid":"offer-card-error-alert",color:r,title:i.title,description:t||i.description,className:s.alert});return n?c.jsx(y.Card,{"data-testid":"offer-card-error",className:y.cn("w-full",s.base),children:c.jsx(y.CardBody,{"data-testid":"offer-card-error-body",children:o})}):c.jsx("div",{"data-testid":"offer-card-error",className:y.cn("w-full",s.base),children:o})};ao.displayName="OfferCardError";const Bu={1:"space-y-1",2:"space-y-2",3:"space-y-3",4:"space-y-4",5:"space-y-5",6:"space-y-6"},co=({quantity:t=2,gap:e=4,classNames:n={}})=>{const r=Bu[e];return c.jsx("div",{"data-testid":"offer-card-skeleton-container",className:y.cn(r,n.base),children:Array.from({length:t}).map((s,i)=>c.jsxs(y.Card,{"data-testid":`offer-card-skeleton-${i}`,className:y.cn("w-full",n.card),children:[c.jsx(y.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(y.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(y.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(y.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(y.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(y.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(y.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(y.Skeleton,{"data-testid":`offer-card-skeleton-btn-dec-${i}`,className:"w-8 h-8 rounded-md bg-default-300"}),c.jsx(y.Skeleton,{"data-testid":`offer-card-skeleton-btn-qty-${i}`,className:"w-8 h-8 rounded-md bg-default-200"}),c.jsx(y.Skeleton,{"data-testid":`offer-card-skeleton-btn-inc-${i}`,className:"w-8 h-8 rounded-md bg-default-300"})]})]})})]})})]},i))})};co.displayName="OfferCardSkeleton";const uo={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.15,delayChildren:.1}}},fo={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"}}},zu={1:"gap-1",2:"gap-2",3:"gap-3",4:"gap-4",5:"gap-5",6:"gap-6"},ho=({offers:t=[],selection:e,defaultSelection:n={},onSelectionChange:r,onQuantityChange:s,currency:i="USD",locale:o="en-US",labels:l,slots:a,isDisabled:u=!1,buttonVariant:d="bordered",buttonColor:f="default",showCard:p=!0,animated:m=!0,gap:C=2,classNames:b={}})=>{const[k,S]=v.useState(n),w=e!==void 0?e:k,j=v.useCallback((z,H)=>{const U={...w,[z]:Math.max(0,H)};e===void 0&&S(U),r?.(U),s?.(z,U[z])},[w,e,r,s]),N=[...t].sort((z,H)=>(z.position??0)-(H.position??0)),D=zu[C],L=y.cn("grid mx-auto pt-2",D,b.base),O=z=>c.jsx(Ir,{offer:z,quantity:w[z.id]||0,onQuantityChange:j,currency:i,locale:o,labels:l,slots:a,isDisabled:u,buttonVariant:d,buttonColor:f,showCard:p,classNames:b.card},z.id);return m?c.jsx(Re.motion.div,{"data-testid":"offer-card-list",className:L,variants:uo,initial:"hidden",animate:"show",children:c.jsx(Re.AnimatePresence,{children:N.map(z=>c.jsx(Re.motion.div,{"data-testid":`offer-card-list-item-${z.id}`,className:b.cardWrapper,variants:fo,exit:{opacity:0,y:-20},transition:{duration:.3},children:O(z)},z.id))})}):c.jsx("div",{"data-testid":"offer-card-list",className:L,children:N.map(O)})};ho.displayName="OfferCardList";var Ut=t=>t.type==="checkbox",at=t=>t instanceof Date,Ce=t=>t==null;const po=t=>typeof t=="object";var ue=t=>!Ce(t)&&!Array.isArray(t)&&po(t)&&!at(t),mo=t=>ue(t)&&t.target?Ut(t.target)?t.target.checked:t.target.value:t,_u=t=>t.substring(0,t.search(/\.\d+(\.|$)/))||t,go=(t,e)=>t.has(_u(e)),Hu=t=>{const e=t.constructor&&t.constructor.prototype;return ue(e)&&e.hasOwnProperty("isPrototypeOf")},Dr=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function le(t){if(t instanceof Date)return new Date(t);const e=typeof FileList<"u"&&t instanceof FileList;if(Dr&&(t instanceof Blob||e))return t;const n=Array.isArray(t);if(!n&&!(ue(t)&&Hu(t)))return t;const r=n?[]:Object.create(Object.getPrototypeOf(t));for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[s]=le(t[s]));return r}var Sn=t=>/^\w*$/.test(t),re=t=>t===void 0,jr=t=>Array.isArray(t)?t.filter(Boolean):[],Lr=t=>jr(t.replace(/["|']|\]/g,"").split(/\.|\[/)),T=(t,e,n)=>{if(!e||!ue(t))return n;const r=(Sn(e)?[e]:Lr(e)).reduce((s,i)=>Ce(s)?s:s[i],t);return re(r)||r===t?re(t[e])?n:t[e]:r},Ae=t=>typeof t=="boolean",Se=t=>typeof t=="function",ee=(t,e,n)=>{let r=-1;const s=Sn(e)?[e]:Lr(e),i=s.length,o=i-1;for(;++r<i;){const l=s[r];let a=n;if(r!==o){const u=t[l];a=ue(u)||Array.isArray(u)?u:isNaN(+s[r+1])?{}:[]}if(l==="__proto__"||l==="constructor"||l==="prototype")return;t[l]=a,t=t[l]}};const hn={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},je={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},ze={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},yo=v.createContext(null);yo.displayName="HookFormControlContext";const Rr=()=>v.useContext(yo);var xo=(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]!==je.all&&(e._proxyFormState[o]=!r||je.all),n&&(n[o]=!0),t[o]}});return s};const Fr=typeof window<"u"?v.useLayoutEffect:v.useEffect;function Uu(t){const e=Rr(),{control:n=e,disabled:r,name:s,exact:i}=t||{},[o,l]=v.useState(n._formState),a=v.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Fr(()=>n._subscribe({name:s,formState:a.current,exact:i,callback:u=>{!r&&l({...n._formState,...u})}}),[s,r,i]),v.useEffect(()=>{a.current.isValid&&n._setValid(!0)},[n]),v.useMemo(()=>xo(o,n,a.current,!1),[o,n])}var Ee=t=>typeof t=="string",ur=(t,e,n,r,s)=>Ee(t)?(r&&e.watch.add(t),T(n,t,s)):Array.isArray(t)?t.map(i=>(r&&e.watch.add(i),T(n,i))):(r&&(e.watchAll=!0),n),dr=t=>Ce(t)||!po(t);function Le(t,e,n=new WeakSet){if(dr(t)||dr(e))return Object.is(t,e);if(at(t)&&at(e))return Object.is(t.getTime(),e.getTime());const r=Object.keys(t),s=Object.keys(e);if(r.length!==s.length)return!1;if(n.has(t)||n.has(e))return!0;n.add(t),n.add(e);for(const i of r){const o=t[i];if(!s.includes(i))return!1;if(i!=="ref"){const l=e[i];if(at(o)&&at(l)||ue(o)&&ue(l)||Array.isArray(o)&&Array.isArray(l)?!Le(o,l,n):!Object.is(o,l))return!1}}return!0}function qu(t){const e=Rr(),{control:n=e,name:r,defaultValue:s,disabled:i,exact:o,compute:l}=t||{},a=v.useRef(s),u=v.useRef(l),d=v.useRef(void 0),f=v.useRef(n),p=v.useRef(r);u.current=l;const[m,C]=v.useState(()=>{const N=n._getWatch(r,a.current);return u.current?u.current(N):N}),b=v.useCallback(N=>{const D=ur(r,n._names,N||n._formValues,!1,a.current);return u.current?u.current(D):D},[n._formValues,n._names,r]),k=v.useCallback(N=>{if(!i){const D=ur(r,n._names,N||n._formValues,!1,a.current);if(u.current){const L=u.current(D);Le(L,d.current)||(C(L),d.current=L)}else C(D)}},[n._formValues,n._names,i,r]);Fr(()=>((f.current!==n||!Le(p.current,r))&&(f.current=n,p.current=r,k()),n._subscribe({name:r,formState:{values:!0},exact:o,callback:N=>{k(N.values)}})),[n,o,r,k]),v.useEffect(()=>n._removeUnmounted());const S=f.current!==n,w=p.current,j=v.useMemo(()=>{if(i)return null;const N=!S&&!Le(w,r);return S||N?b():null},[i,S,r,w,b]);return j!==null?j:m}function Ku(t){const e=Rr(),{name:n,disabled:r,control:s=e,shouldUnregister:i,defaultValue:o,exact:l=!0}=t,a=go(s._names.array,n),u=v.useMemo(()=>T(s._formValues,n,T(s._defaultValues,n,o)),[s,n,o]),d=qu({control:s,name:n,defaultValue:u,exact:l}),f=Uu({control:s,name:n,exact:l}),p=v.useRef(t),m=v.useRef(void 0),C=v.useRef(s.register(n,{...t.rules,value:d,...Ae(t.disabled)?{disabled:t.disabled}:{}}));p.current=t;const b=v.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!T(f.errors,n)},isDirty:{enumerable:!0,get:()=>!!T(f.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!T(f.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!T(f.validatingFields,n)},error:{enumerable:!0,get:()=>T(f.errors,n)}}),[f,n]),k=v.useCallback(N=>C.current.onChange({target:{value:mo(N),name:n},type:hn.CHANGE}),[n]),S=v.useCallback(()=>C.current.onBlur({target:{value:T(s._formValues,n),name:n},type:hn.BLUR}),[n,s._formValues]),w=v.useCallback(N=>{const D=T(s._fields,n);D&&D._f&&N&&(D._f.ref={focus:()=>Se(N.focus)&&N.focus(),select:()=>Se(N.select)&&N.select(),setCustomValidity:L=>Se(N.setCustomValidity)&&N.setCustomValidity(L),reportValidity:()=>Se(N.reportValidity)&&N.reportValidity()})},[s._fields,n]),j=v.useMemo(()=>({name:n,value:d,...Ae(r)||f.disabled?{disabled:f.disabled||r}:{},onChange:k,onBlur:S,ref:w}),[n,r,f.disabled,k,S,w,d]);return v.useEffect(()=>{const N=s._options.shouldUnregister||i,D=m.current;D&&D!==n&&!a&&s.unregister(D),s.register(n,{...p.current.rules,...Ae(p.current.disabled)?{disabled:p.current.disabled}:{}});const L=(O,z)=>{const H=T(s._fields,O);H&&H._f&&(H._f.mount=z)};if(L(n,!0),N){const O=le(T(s._options.defaultValues,n,p.current.defaultValue));ee(s._defaultValues,n,O),re(T(s._formValues,n))&&ee(s._formValues,n,O)}return!a&&s.register(n),m.current=n,()=>{(a?N&&!s._state.action:N)?s.unregister(n):L(n,!1)}},[n,s,a,i]),v.useEffect(()=>{s._setDisabledField({disabled:r,name:n})},[r,n,s]),v.useMemo(()=>({field:j,formState:f,fieldState:b}),[j,f,b])}const Ju=v.createContext(null);Ju.displayName="HookFormContext";var Wu=(t,e,n,r,s)=>e?{...n[t],types:{...n[t]&&n[t].types?n[t].types:{},[r]:s||!0}}:{},jt=t=>Array.isArray(t)?t:[t],Vs=()=>{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 bo(t,e){const n={};for(const r in t)if(t.hasOwnProperty(r)){const s=t[r],i=e[r];if(s&&ue(s)&&i){const o=bo(s,i);ue(o)&&(n[r]=o)}else t[r]&&(n[r]=i)}return n}var ke=t=>ue(t)&&!Object.keys(t).length,Pr=t=>t.type==="file",pn=t=>{if(!Dr)return!1;const e=t?t.ownerDocument:0;return t instanceof(e&&e.defaultView?e.defaultView.HTMLElement:HTMLElement)},ko=t=>t.type==="select-multiple",$r=t=>t.type==="radio",Gu=t=>$r(t)||Ut(t),Kn=t=>pn(t)&&t.isConnected;function Zu(t,e){const n=e.slice(0,-1).length;let r=0;for(;r<n;)t=re(t)?r++:t[e[r++]];return t}function Qu(t){for(const e in t)if(t.hasOwnProperty(e)&&!re(t[e]))return!1;return!0}function ae(t,e){const n=Array.isArray(e)?e:Sn(e)?[e]:Lr(e),r=n.length===1?t:Zu(t,n),s=n.length-1,i=n[s];return r&&delete r[i],s!==0&&(ue(r)&&ke(r)||Array.isArray(r)&&Qu(r))&&ae(t,n.slice(0,-1)),t}var Xu=t=>{for(const e in t)if(Se(t[e]))return!0;return!1};function vo(t){return Array.isArray(t)||ue(t)&&!Xu(t)}function fr(t,e={}){for(const n in t){const r=t[n];vo(r)?(e[n]=Array.isArray(r)?[]:{},fr(r,e[n])):re(r)||(e[n]=!0)}return e}function bt(t,e,n){n||(n=fr(e));for(const r in t){const s=t[r];if(vo(s))re(e)||dr(n[r])?n[r]=fr(s,Array.isArray(s)?[]:{}):bt(s,Ce(e)?{}:e[r],n[r]);else{const i=e[r];n[r]=!Le(s,i)}}return n}const Bs={value:!1,isValid:!1},zs={value:!0,isValid:!0};var So=t=>{if(Array.isArray(t)){if(t.length>1){const e=t.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:e,isValid:!!e.length}}return t[0].checked&&!t[0].disabled?t[0].attributes&&!re(t[0].attributes.value)?re(t[0].value)||t[0].value===""?zs:{value:t[0].value,isValid:!0}:zs:Bs}return Bs},Co=(t,{valueAsNumber:e,valueAsDate:n,setValueAs:r})=>re(t)?t:e?t===""?NaN:t&&+t:n&&Ee(t)?new Date(t):r?r(t):t;const _s={isValid:!1,value:null};var wo=t=>Array.isArray(t)?t.reduce((e,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:e,_s):_s;function Hs(t){const e=t.ref;return Pr(e)?e.files:$r(e)?wo(t.refs).value:ko(e)?[...e.selectedOptions].map(({value:n})=>n):Ut(e)?So(t.refs).value:Co(re(e.value)?t.ref.value:e.value,t)}var Yu=(t,e,n,r)=>{const s={};for(const i of t){const o=T(e,i);o&&ee(s,i,o._f)}return{criteriaMode:n,names:[...t],fields:s,shouldUseNativeValidation:r}},mn=t=>t instanceof RegExp,Tt=t=>re(t)?t:mn(t)?t.source:ue(t)?mn(t.value)?t.value.source:t.value:t,Us=t=>({isOnSubmit:!t||t===je.onSubmit,isOnBlur:t===je.onBlur,isOnChange:t===je.onChange,isOnAll:t===je.all,isOnTouch:t===je.onTouched});const qs="AsyncFunction";var ed=t=>!!t&&!!t.validate&&!!(Se(t.validate)&&t.validate.constructor.name===qs||ue(t.validate)&&Object.values(t.validate).find(e=>e.constructor.name===qs)),td=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate),Ks=(t,e,n)=>!n&&(e.watchAll||e.watch.has(t)||[...e.watch].some(r=>t.startsWith(r)&&/^\.\w+/.test(t.slice(r.length))));const Lt=(t,e,n,r)=>{for(const s of n||Object.keys(t)){const i=T(t,s);if(i){const{_f:o,...l}=i;if(o){if(o.refs&&o.refs[0]&&e(o.refs[0],s)&&!r)return!0;if(o.ref&&e(o.ref,o.name)&&!r)return!0;if(Lt(l,e))break}else if(ue(l)&&Lt(l,e))break}}};function Js(t,e,n){const r=T(t,n);if(r||Sn(n))return{error:r,name:n};const s=n.split(".");for(;s.length;){const i=s.join("."),o=T(e,i),l=T(t,i);if(o&&!Array.isArray(o)&&n!==i)return{name:n};if(l&&l.type)return{name:i,error:l};if(l&&l.root&&l.root.type)return{name:`${i}.root`,error:l.root};s.pop()}return{name:n}}var nd=(t,e,n,r)=>{n(t);const{name:s,...i}=t;return ke(i)||Object.keys(i).length>=Object.keys(e).length||Object.keys(i).find(o=>e[o]===(!r||je.all))},rd=(t,e,n)=>!t||!e||t===e||jt(t).some(r=>r&&(n?r===e:r.startsWith(e)||e.startsWith(r))),sd=(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,id=(t,e)=>!jr(T(t,e)).length&&ae(t,e),od=(t,e,n)=>{const r=jt(T(t,n));return ee(r,"root",e[n]),ee(t,n,r),t};function Ws(t,e,n="validate"){if(Ee(t)||Array.isArray(t)&&t.every(Ee)||Ae(t)&&!t)return{type:n,message:Ee(t)?t:"",ref:e}}var gt=t=>ue(t)&&!mn(t)?t:{value:t,message:""},Gs=async(t,e,n,r,s,i)=>{const{ref:o,refs:l,required:a,maxLength:u,minLength:d,min:f,max:p,pattern:m,validate:C,name:b,valueAsNumber:k,mount:S}=t._f,w=T(n,b);if(!S||e.has(b))return{};const j=l?l[0]:o,N=M=>{s&&j.reportValidity&&(j.setCustomValidity(Ae(M)?"":M||""),j.reportValidity())},D={},L=$r(o),O=Ut(o),z=L||O,H=(k||Pr(o))&&re(o.value)&&re(w)||pn(o)&&o.value===""||w===""||Array.isArray(w)&&!w.length,U=Wu.bind(null,b,r,D),P=(M,F,$,B=ze.maxLength,Y=ze.minLength)=>{const W=M?F:$;D[b]={type:M?B:Y,message:W,ref:o,...U(M?B:Y,W)}};if(i?!Array.isArray(w)||!w.length:a&&(!z&&(H||Ce(w))||Ae(w)&&!w||O&&!So(l).isValid||L&&!wo(l).isValid)){const{value:M,message:F}=Ee(a)?{value:!!a,message:a}:gt(a);if(M&&(D[b]={type:ze.required,message:F,ref:j,...U(ze.required,F)},!r))return N(F),D}if(!H&&(!Ce(f)||!Ce(p))){let M,F;const $=gt(p),B=gt(f);if(!Ce(w)&&!isNaN(w)){const Y=o.valueAsNumber||w&&+w;Ce($.value)||(M=Y>$.value),Ce(B.value)||(F=Y<B.value)}else{const Y=o.valueAsDate||new Date(w),W=xe=>new Date(new Date().toDateString()+" "+xe),ye=o.type=="time",de=o.type=="week";Ee($.value)&&w&&(M=ye?W(w)>W($.value):de?w>$.value:Y>new Date($.value)),Ee(B.value)&&w&&(F=ye?W(w)<W(B.value):de?w<B.value:Y<new Date(B.value))}if((M||F)&&(P(!!M,$.message,B.message,ze.max,ze.min),!r))return N(D[b].message),D}if((u||d)&&!H&&(Ee(w)||i&&Array.isArray(w))){const M=gt(u),F=gt(d),$=!Ce(M.value)&&w.length>+M.value,B=!Ce(F.value)&&w.length<+F.value;if(($||B)&&(P($,M.message,F.message),!r))return N(D[b].message),D}if(m&&!H&&Ee(w)){const{value:M,message:F}=gt(m);if(mn(M)&&!w.match(M)&&(D[b]={type:ze.pattern,message:F,ref:o,...U(ze.pattern,F)},!r))return N(F),D}if(C){if(Se(C)){const M=await C(w,n),F=Ws(M,j);if(F&&(D[b]={...F,...U(ze.validate,F.message)},!r))return N(F.message),D}else if(ue(C)){let M={};for(const F in C){if(!ke(M)&&!r)break;const $=Ws(await C[F](w,n),j,F);$&&(M={...$,...U(F,$.message)},N($.message),r&&(D[b]=M))}if(!ke(M)&&(D[b]={ref:j,...M},!r))return D}}return N(!0),D};const ld={mode:je.onSubmit,reValidateMode:je.onChange,shouldFocusError:!0};function ad(t={}){let e={...ld,...t},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:Se(e.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1},r={},s=ue(e.defaultValues)||ue(e.values)?le(e.defaultValues||e.values)||{}:{},i=e.shouldUnregister?{}:le(s),o={action:!1,mount:!1,watch:!1,keepIsValid:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},a,u=0;const d={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},f={...d};let p={...f};const m={array:Vs(),state:Vs()},C=e.criteriaMode===je.all,b=h=>g=>{clearTimeout(u),u=setTimeout(h,g)},k=async h=>{if(!o.keepIsValid&&!e.disabled&&(f.isValid||p.isValid||h)){let g;e.resolver?(g=ke((await z()).errors),S()):g=await U(r,!0),g!==n.isValid&&m.state.next({isValid:g})}},S=(h,g)=>{!e.disabled&&(f.isValidating||f.validatingFields||p.isValidating||p.validatingFields)&&((h||Array.from(l.mount)).forEach(x=>{x&&(g?ee(n.validatingFields,x,g):ae(n.validatingFields,x))}),m.state.next({validatingFields:n.validatingFields,isValidating:!ke(n.validatingFields)}))},w=(h,g=[],x,I,E=!0,A=!0)=>{if(I&&x&&!e.disabled){if(o.action=!0,A&&Array.isArray(T(r,h))){const V=x(T(r,h),I.argA,I.argB);E&&ee(r,h,V)}if(A&&Array.isArray(T(n.errors,h))){const V=x(T(n.errors,h),I.argA,I.argB);E&&ee(n.errors,h,V),id(n.errors,h)}if((f.touchedFields||p.touchedFields)&&A&&Array.isArray(T(n.touchedFields,h))){const V=x(T(n.touchedFields,h),I.argA,I.argB);E&&ee(n.touchedFields,h,V)}(f.dirtyFields||p.dirtyFields)&&(n.dirtyFields=bt(s,i)),m.state.next({name:h,isDirty:M(h,g),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else ee(i,h,g)},j=(h,g)=>{ee(n.errors,h,g),m.state.next({errors:n.errors})},N=h=>{n.errors=h,m.state.next({errors:n.errors,isValid:!1})},D=(h,g,x,I)=>{const E=T(r,h);if(E){const A=T(i,h,re(x)?T(s,h):x);re(A)||I&&I.defaultChecked||g?ee(i,h,g?A:Hs(E._f)):B(h,A),o.mount&&!o.action&&k()}},L=(h,g,x,I,E)=>{let A=!1,V=!1;const G={name:h};if(!e.disabled){if(!x||I){(f.isDirty||p.isDirty)&&(V=n.isDirty,n.isDirty=G.isDirty=M(),A=V!==G.isDirty);const Z=Le(T(s,h),g);V=!!T(n.dirtyFields,h),Z?ae(n.dirtyFields,h):ee(n.dirtyFields,h,!0),G.dirtyFields=n.dirtyFields,A=A||(f.dirtyFields||p.dirtyFields)&&V!==!Z}if(x){const Z=T(n.touchedFields,h);Z||(ee(n.touchedFields,h,x),G.touchedFields=n.touchedFields,A=A||(f.touchedFields||p.touchedFields)&&Z!==x)}A&&E&&m.state.next(G)}return A?G:{}},O=(h,g,x,I)=>{const E=T(n.errors,h),A=(f.isValid||p.isValid)&&Ae(g)&&n.isValid!==g;if(e.delayError&&x?(a=b(()=>j(h,x)),a(e.delayError)):(clearTimeout(u),a=null,x?ee(n.errors,h,x):ae(n.errors,h)),(x?!Le(E,x):E)||!ke(I)||A){const V={...I,...A&&Ae(g)?{isValid:g}:{},errors:n.errors,name:h};n={...n,...V},m.state.next(V)}},z=async h=>(S(h,!0),await e.resolver(i,e.context,Yu(h||l.mount,r,e.criteriaMode,e.shouldUseNativeValidation))),H=async h=>{const{errors:g}=await z(h);if(S(h),h)for(const x of h){const I=T(g,x);I?ee(n.errors,x,I):ae(n.errors,x)}else n.errors=g;return g},U=async(h,g,x={valid:!0})=>{for(const I in h){const E=h[I];if(E){const{_f:A,...V}=E;if(A){const G=l.array.has(A.name),Z=E._f&&ed(E._f);Z&&f.validatingFields&&S([A.name],!0);const be=await Gs(E,l.disabled,i,C,e.shouldUseNativeValidation&&!g,G);if(Z&&f.validatingFields&&S([A.name]),be[A.name]&&(x.valid=!1,g||t.shouldUseNativeValidation))break;!g&&(T(be,A.name)?G?od(n.errors,be,A.name):ee(n.errors,A.name,be[A.name]):ae(n.errors,A.name))}!ke(V)&&await U(V,g,x)}}return x.valid},P=()=>{for(const h of l.unMount){const g=T(r,h);g&&(g._f.refs?g._f.refs.every(x=>!Kn(x)):!Kn(g._f.ref))&&wn(h)}l.unMount=new Set},M=(h,g)=>!e.disabled&&(h&&g&&ee(i,h,g),!Le(qe(),s)),F=(h,g,x)=>ur(h,l,{...o.mount?i:re(g)?s:Ee(h)?{[h]:g}:g},x,g),$=h=>jr(T(o.mount?i:s,h,e.shouldUnregister?T(s,h,[]):[])),B=(h,g,x={})=>{const I=T(r,h);let E=g;if(I){const A=I._f;A&&(!A.disabled&&ee(i,h,Co(g,A)),E=pn(A.ref)&&Ce(g)?"":g,ko(A.ref)?[...A.ref.options].forEach(V=>V.selected=E.includes(V.value)):A.refs?Ut(A.ref)?A.refs.forEach(V=>{(!V.defaultChecked||!V.disabled)&&(Array.isArray(E)?V.checked=!!E.find(G=>G===V.value):V.checked=E===V.value||!!E)}):A.refs.forEach(V=>V.checked=V.value===E):Pr(A.ref)?A.ref.value="":(A.ref.value=E,A.ref.type||m.state.next({name:h,values:le(i)})))}(x.shouldDirty||x.shouldTouch)&&L(h,E,x.shouldTouch,x.shouldDirty,!0),x.shouldValidate&&xe(h)},Y=(h,g,x)=>{for(const I in g){if(!g.hasOwnProperty(I))return;const E=g[I],A=h+"."+I,V=T(r,A);(l.array.has(h)||ue(E)||V&&!V._f)&&!at(E)?Y(A,E,x):B(A,E,x)}},W=(h,g,x={})=>{const I=T(r,h),E=l.array.has(h),A=le(g);ee(i,h,A),E?(m.array.next({name:h,values:le(i)}),(f.isDirty||f.dirtyFields||p.isDirty||p.dirtyFields)&&x.shouldDirty&&m.state.next({name:h,dirtyFields:bt(s,i),isDirty:M(h,A)})):I&&!I._f&&!Ce(A)?Y(h,A,x):B(h,A,x),Ks(h,l)?m.state.next({...n,name:h,values:le(i)}):m.state.next({name:o.mount?h:void 0,values:le(i)})},ye=async h=>{o.mount=!0;const g=h.target;let x=g.name,I=!0;const E=T(r,x),A=Z=>{I=Number.isNaN(Z)||at(Z)&&isNaN(Z.getTime())||Le(Z,T(i,x,Z))},V=Us(e.mode),G=Us(e.reValidateMode);if(E){let Z,be;const tt=g.type?Hs(E._f):mo(h),Ke=h.type===hn.BLUR||h.type===hn.FOCUS_OUT,jo=!td(E._f)&&!e.resolver&&!T(n.errors,x)&&!E._f.deps||sd(Ke,T(n.touchedFields,x),n.isSubmitted,G,V),En=Ks(x,l,Ke);ee(i,x,tt),Ke?(!g||!g.readOnly)&&(E._f.onBlur&&E._f.onBlur(h),a&&a(0)):E._f.onChange&&E._f.onChange(h);const Tn=L(x,tt,Ke),Lo=!ke(Tn)||En;if(!Ke&&m.state.next({name:x,type:h.type,values:le(i)}),jo)return(f.isValid||p.isValid)&&(e.mode==="onBlur"?Ke&&k():Ke||k()),Lo&&m.state.next({name:x,...En?{}:Tn});if(!Ke&&En&&m.state.next({...n}),e.resolver){const{errors:qr}=await z([x]);if(S([x]),A(tt),I){const Ro=Js(n.errors,r,x),Kr=Js(qr,r,Ro.name||x);Z=Kr.error,x=Kr.name,be=ke(qr)}}else S([x],!0),Z=(await Gs(E,l.disabled,i,C,e.shouldUseNativeValidation))[x],S([x]),A(tt),I&&(Z?be=!1:(f.isValid||p.isValid)&&(be=await U(r,!0)));I&&(E._f.deps&&(!Array.isArray(E._f.deps)||E._f.deps.length>0)&&xe(E._f.deps),O(x,be,Z,Tn))}},de=(h,g)=>{if(T(n.errors,g)&&h.focus)return h.focus(),1},xe=async(h,g={})=>{let x,I;const E=jt(h);if(e.resolver){const A=await H(re(h)?h:E);x=ke(A),I=h?!E.some(V=>T(A,V)):x}else h?(I=(await Promise.all(E.map(async A=>{const V=T(r,A);return await U(V&&V._f?{[A]:V}:V)}))).every(Boolean),!(!I&&!n.isValid)&&k()):I=x=await U(r);return m.state.next({...!Ee(h)||(f.isValid||p.isValid)&&x!==n.isValid?{}:{name:h},...e.resolver||!h?{isValid:x}:{},errors:n.errors}),g.shouldFocus&&!I&&Lt(r,de,h?E:l.mount),I},qe=(h,g)=>{let x={...o.mount?i:s};return g&&(x=bo(g.dirtyFields?n.dirtyFields:n.touchedFields,x)),re(h)?x:Ee(h)?T(x,h):h.map(I=>T(x,I))},pt=(h,g)=>({invalid:!!T((g||n).errors,h),isDirty:!!T((g||n).dirtyFields,h),error:T((g||n).errors,h),isValidating:!!T(n.validatingFields,h),isTouched:!!T((g||n).touchedFields,h)}),Ct=h=>{h&&jt(h).forEach(g=>ae(n.errors,g)),m.state.next({errors:h?n.errors:{}})},ne=(h,g,x)=>{const I=(T(r,h,{_f:{}})._f||{}).ref,E=T(n.errors,h)||{},{ref:A,message:V,type:G,...Z}=E;ee(n.errors,h,{...Z,...g,ref:I}),m.state.next({name:h,errors:n.errors,isValid:!1}),x&&x.shouldFocus&&I&&I.focus&&I.focus()},we=(h,g)=>Se(h)?m.state.subscribe({next:x=>"values"in x&&h(F(void 0,g),x)}):F(h,g,!0),wt=h=>m.state.subscribe({next:g=>{rd(h.name,g.name,h.exact)&&nd(g,h.formState||f,Do,h.reRenderRoot)&&h.callback({values:{...i},...n,...g,defaultValues:s})}}).unsubscribe,Cn=h=>(o.mount=!0,p={...p,...h.formState},wt({...h,formState:{...d,...h.formState}})),wn=(h,g={})=>{for(const x of h?jt(h):l.mount)l.mount.delete(x),l.array.delete(x),g.keepValue||(ae(r,x),ae(i,x)),!g.keepError&&ae(n.errors,x),!g.keepDirty&&ae(n.dirtyFields,x),!g.keepTouched&&ae(n.touchedFields,x),!g.keepIsValidating&&ae(n.validatingFields,x),!e.shouldUnregister&&!g.keepDefaultValue&&ae(s,x);m.state.next({values:le(i)}),m.state.next({...n,...g.keepDirty?{isDirty:M()}:{}}),!g.keepIsValid&&k()},Br=({disabled:h,name:g})=>{if(Ae(h)&&o.mount||h||l.disabled.has(g)){const E=l.disabled.has(g)!==!!h;h?l.disabled.add(g):l.disabled.delete(g),E&&o.mount&&!o.action&&k()}},An=(h,g={})=>{let x=T(r,h);const I=Ae(g.disabled)||Ae(e.disabled);return ee(r,h,{...x||{},_f:{...x&&x._f?x._f:{ref:{name:h}},name:h,mount:!0,...g}}),l.mount.add(h),x?Br({disabled:Ae(g.disabled)?g.disabled:e.disabled,name:h}):D(h,!0,g.value),{...I?{disabled:g.disabled||e.disabled}:{},...e.progressive?{required:!!g.required,min:Tt(g.min),max:Tt(g.max),minLength:Tt(g.minLength),maxLength:Tt(g.maxLength),pattern:Tt(g.pattern)}:{},name:h,onChange:ye,onBlur:ye,ref:E=>{if(E){An(h,g),x=T(r,h);const A=re(E.value)&&E.querySelectorAll&&E.querySelectorAll("input,select,textarea")[0]||E,V=Gu(A),G=x._f.refs||[];if(V?G.find(Z=>Z===A):A===x._f.ref)return;ee(r,h,{_f:{...x._f,...V?{refs:[...G.filter(Kn),A,...Array.isArray(T(s,h))?[{}]:[]],ref:{type:A.type,name:h}}:{ref:A}}}),D(h,!1,void 0,A)}else x=T(r,h,{}),x._f&&(x._f.mount=!1),(e.shouldUnregister||g.shouldUnregister)&&!(go(l.array,h)&&o.action)&&l.unMount.add(h)}}},Nn=()=>e.shouldFocusError&&Lt(r,de,l.mount),Mo=h=>{Ae(h)&&(m.state.next({disabled:h}),Lt(r,(g,x)=>{const I=T(r,x);I&&(g.disabled=I._f.disabled||h,Array.isArray(I._f.refs)&&I._f.refs.forEach(E=>{E.disabled=I._f.disabled||h}))},0,!1))},zr=(h,g)=>async x=>{let I;x&&(x.preventDefault&&x.preventDefault(),x.persist&&x.persist());let E=le(i);if(m.state.next({isSubmitting:!0}),e.resolver){const{errors:A,values:V}=await z();S(),n.errors=A,E=le(V)}else await U(r);if(l.disabled.size)for(const A of l.disabled)ae(E,A);if(ae(n.errors,"root"),ke(n.errors)){m.state.next({errors:{}});try{await h(E,x)}catch(A){I=A}}else g&&await g({...n.errors},x),Nn(),setTimeout(Nn);if(m.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:ke(n.errors)&&!I,submitCount:n.submitCount+1,errors:n.errors}),I)throw I},Oo=(h,g={})=>{T(r,h)&&(re(g.defaultValue)?W(h,le(T(s,h))):(W(h,g.defaultValue),ee(s,h,le(g.defaultValue))),g.keepTouched||ae(n.touchedFields,h),g.keepDirty||(ae(n.dirtyFields,h),n.isDirty=g.defaultValue?M(h,le(T(s,h))):M()),g.keepError||(ae(n.errors,h),f.isValid&&k()),m.state.next({...n}))},_r=(h,g={})=>{const x=h?le(h):s,I=le(x),E=ke(h),A=E?s:I;if(g.keepDefaultValues||(s=x),!g.keepValues){if(g.keepDirtyValues){const V=new Set([...l.mount,...Object.keys(bt(s,i))]);for(const G of Array.from(V)){const Z=T(n.dirtyFields,G),be=T(i,G),tt=T(A,G);Z&&!re(be)?ee(A,G,be):!Z&&!re(tt)&&W(G,tt)}}else{if(Dr&&re(h))for(const V of l.mount){const G=T(r,V);if(G&&G._f){const Z=Array.isArray(G._f.refs)?G._f.refs[0]:G._f.ref;if(pn(Z)){const be=Z.closest("form");if(be){be.reset();break}}}}if(g.keepFieldsRef)for(const V of l.mount)W(V,T(A,V));else r={}}i=e.shouldUnregister?g.keepDefaultValues?le(s):{}:le(A),m.array.next({values:{...A}}),m.state.next({values:{...A}})}l={mount:g.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!f.isValid||!!g.keepIsValid||!!g.keepDirtyValues||!e.shouldUnregister&&!ke(A),o.watch=!!e.shouldUnregister,o.keepIsValid=!!g.keepIsValid,o.action=!1,g.keepErrors||(n.errors={}),m.state.next({submitCount:g.keepSubmitCount?n.submitCount:0,isDirty:E?!1:g.keepDirty?n.isDirty:!!(g.keepDefaultValues&&!Le(h,s)),isSubmitted:g.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:E?{}:g.keepDirtyValues?g.keepDefaultValues&&i?bt(s,i):n.dirtyFields:g.keepDefaultValues&&h?bt(s,h):g.keepDirty?n.dirtyFields:{},touchedFields:g.keepTouched?n.touchedFields:{},errors:g.keepErrors?n.errors:{},isSubmitSuccessful:g.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:s})},Hr=(h,g)=>_r(Se(h)?h(i):h,{...e.resetOptions,...g}),Io=(h,g={})=>{const x=T(r,h),I=x&&x._f;if(I){const E=I.refs?I.refs[0]:I.ref;E.focus&&setTimeout(()=>{E.focus(),g.shouldSelect&&Se(E.select)&&E.select()})}},Do=h=>{n={...n,...h}},Ur={control:{register:An,unregister:wn,getFieldState:pt,handleSubmit:zr,setError:ne,_subscribe:wt,_runSchema:z,_updateIsValidating:S,_focusError:Nn,_getWatch:F,_getDirty:M,_setValid:k,_setFieldArray:w,_setDisabledField:Br,_setErrors:N,_getFieldArray:$,_reset:_r,_resetDefaultValues:()=>Se(e.defaultValues)&&e.defaultValues().then(h=>{Hr(h,e.resetOptions),m.state.next({isLoading:!1})}),_removeUnmounted:P,_disableForm:Mo,_subjects:m,_proxyFormState:f,get _fields(){return r},get _formValues(){return i},get _state(){return o},set _state(h){o=h},get _defaultValues(){return s},get _names(){return l},set _names(h){l=h},get _formState(){return n},get _options(){return e},set _options(h){e={...e,...h}}},subscribe:Cn,trigger:xe,register:An,handleSubmit:zr,watch:we,setValue:W,getValues:qe,reset:Hr,resetField:Oo,clearErrors:Ct,unregister:wn,setError:ne,setFocus:Io,getFieldState:pt};return{...Ur,formControl:Ur}}function cd(t={}){const e=v.useRef(void 0),n=v.useRef(void 0),[r,s]=v.useState({isDirty:!1,isValidating:!1,isLoading:Se(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:Se(t.defaultValues)?void 0:t.defaultValues});if(!e.current)if(t.formControl)e.current={...t.formControl,formState:r},t.defaultValues&&!Se(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:o,...l}=ad(t);e.current={...l,formState:r}}const i=e.current.control;return i._options=t,Fr(()=>{const o=i._subscribe({formState:i._proxyFormState,callback:()=>s({...i._formState}),reRenderRoot:!0});return s(l=>({...l,isReady:!0})),i._formState.isReady=!0,o},[i]),v.useEffect(()=>i._disableForm(t.disabled),[i,t.disabled]),v.useEffect(()=>{t.mode&&(i._options.mode=t.mode),t.reValidateMode&&(i._options.reValidateMode=t.reValidateMode)},[i,t.mode,t.reValidateMode]),v.useEffect(()=>{t.errors&&(i._setErrors(t.errors),i._focusError())},[i,t.errors]),v.useEffect(()=>{t.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,t.shouldUnregister]),v.useEffect(()=>{if(i._proxyFormState.isDirty){const o=i._getDirty();o!==r.isDirty&&i._subjects.state.next({isDirty:o})}},[i,r.isDirty]),v.useEffect(()=>{var o;t.values&&!Le(t.values,n.current)?(i._reset(t.values,{keepFieldsRef:!0,...i._options.resetOptions}),!((o=i._options.resetOptions)===null||o===void 0)&&o.keepIsValid||i._setValid(),n.current=t.values,s(l=>({...l}))):i._resetDefaultValues()},[i,t.values]),v.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=v.useMemo(()=>xo(r,i),[i,r]),e.current}function ud(t,e=3){return t%1===0?t.toString():t.toFixed(e).replace(/\.?0+$/,"")}function dd(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 fd(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 hd(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 pd(t,e,n=.001){const r=t-e,s=Math.abs(r)<=n;return{difference:r,isBalanced:s,isUnderAllocated:!s&&r>0,isOverAllocated:!s&&r<0}}function Vr(){return`dist-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}Vr();const md={amount:"Amount",glAccount:"GL Account",taxDeductible:"Tax Deductible",amountPlaceholder:"0.00",glAccountPlaceholder:"Search GL Account",noGlAccountsFound:"No GL Accounts found. Try another search term",searching:"Searching for GL Accounts...",amountTooltip:"Enter the amount for this distribution",glAccountTooltip:"Select the General Ledger account for this distribution",taxDeductibleTooltip:"Check if this distribution is tax deductible",deleteButton:"Delete",currencySymbol:"$"},Jn=()=>({id:Vr(),amount:0,glAccount:null,isTaxDeductible:!1}),Ao=({distribution:t,defaultDistribution:e,glAccounts:n=[],isLoadingGlAccounts:r=!1,onSearchGlAccounts:s,onDistributionChange:i,onAmountChange:o,onGlAccountChange:l,onTaxDeductibleChange:a,onDelete:u,canDelete:d=!0,canEditTaxDeductible:f=!0,isDisabled:p=!1,labels:m,classNames:C={},"data-testid":b,control:k,name:S,rules:w})=>{const j={...md,...m},N=k!==void 0&&S!==void 0,D=cd({defaultValues:{_internal:e||Jn()}}),L=Ku({control:N?k:D.control,name:N?S:"_internal",rules:N?w:void 0}),[O,z]=v.useState(e||Jn()),H=N?L.field.value??Jn():t??O,U=N&&!!L.fieldState?.error,P=N&&(L.fieldState?.isTouched??!1),M=U||P,F=M&&(!H.amount||H.amount<=0),$=M&&!H.glAccount,[B,Y]=v.useState(H.glAccount?.name||""),W=v.useCallback(ne=>{const we={...H,...ne};N&&L.field.onChange(we),!N&&t===void 0&&z(we),i?.(we)},[H,t,i,N,L]),ye=v.useCallback(ne=>{const we=ne||0;W({amount:we}),o?.(we)},[W,o]),de=v.useCallback(ne=>{Y(ne),s?.(ne)},[s]),xe=v.useCallback(ne=>{if(ne===null){W({glAccount:null}),l?.(null);return}const wt=n.find(Cn=>String(Cn.id)===String(ne))||null;W({glAccount:wt}),l?.(wt)},[n,W,l]),qe=v.useCallback(()=>{Y(""),W({glAccount:null}),l?.(null)},[W,l]),pt=v.useCallback(ne=>{W({isTaxDeductible:ne}),a?.(ne)},[W,a]),Ct=v.useCallback(()=>{u?.()},[u]);return c.jsx(y.Card,{radius:"md",shadow:"sm","data-testid":b||"revenue-distribution-card",className:y.cn(C.base),children:c.jsxs(y.CardBody,{className:y.cn("flex flex-row flex-nowrap items-start gap-4",C.body),children:[c.jsx("div",{className:y.cn("shrink-0",C.amountContainer),children:c.jsx(y.NumberInput,{"data-testid":`${b||"revenue-distribution-card"}-amount-input`,label:c.jsxs("span",{className:"flex items-center gap-1",children:[j.amount,c.jsx(y.Tooltip,{content:j.amountTooltip,children:c.jsx(Ie,{icon:"solar:info-circle-linear",className:"text-default-400 cursor-help",width:16})})]}),value:H.amount||void 0,onValueChange:ye,labelPlacement:"outside",placeholder:j.amountPlaceholder,isWheelDisabled:!0,hideStepper:!0,variant:"bordered",isDisabled:p,isInvalid:F,errorMessage:F?"Amount is required":void 0,minValue:0,step:.01,className:C.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:y.cn("grow",C.glAccountContainer),children:c.jsx(y.Autocomplete,{"data-testid":`${b||"revenue-distribution-card"}-gl-account-input`,label:c.jsxs("span",{className:"flex items-center gap-1",children:[j.glAccount,c.jsx(y.Tooltip,{content:j.glAccountTooltip,children:c.jsx(Ie,{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:H.glAccount?.name??B,selectedKey:H.glAccount?.id??null,isDisabled:p,isInvalid:$,errorMessage:$?"GL Account is required":void 0,listboxProps:{emptyContent:r?j.searching:j.noGlAccountsFound},placeholder:j.glAccountPlaceholder,onInputChange:de,onSelectionChange:xe,onClear:qe,className:C.glAccountInput,children:ne=>c.jsx(y.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:y.cn("shrink-0 pt-6 flex items-center",C.taxDeductibleContainer),children:c.jsx(y.Checkbox,{radius:"full","data-testid":`${b||"revenue-distribution-card"}-tax-deductible`,isSelected:H.isTaxDeductible,onValueChange:pt,isDisabled:p||!f,className:C.taxDeductibleCheckbox,children:j.taxDeductible})}),c.jsx("div",{className:y.cn("shrink-0 pt-6",C.deleteContainer),children:c.jsx(oe,{"data-testid":`${b||"revenue-distribution-card"}-delete-button`,size:"sm",color:"danger",variant:"flat",isDisabled:p||!d,onPress:Ct,startContent:c.jsx(Ie,{icon:"solar:trash-bin-trash-linear",width:16}),className:y.cn("text-danger",C.deleteButton),children:j.deleteButton})})]})})};Ao.displayName="RevenueDistributionCard";const No=({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:y.cn("flex flex-col items-center justify-center py-8",s.content),children:[c.jsx(Ie,{icon:e,width:n,className:y.cn("text-default-300 mb-4",s.icon)}),c.jsx("p",{className:y.cn("text-default-500 text-sm text-center",s.message),children:t})]});return r?c.jsx(y.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-empty",className:y.cn("w-full",s.base),children:c.jsx(y.CardBody,{children:o})}):c.jsx("div",{"data-testid":"revenue-distribution-empty",className:y.cn("w-full",s.base),children:o})};No.displayName="RevenueDistributionEmpty";const gd={title:"Error Loading Distributions",description:"An error occurred while loading the distribution configuration. Please try again."},Eo=({error:t,labels:e,showCard:n=!0,color:r="danger",classNames:s={}})=>{const i={...gd,...e},o=c.jsx(y.Alert,{"data-testid":"revenue-distribution-error-alert",color:r,title:i.title,description:t||i.description,className:s.alert});return n?c.jsx(y.Card,{radius:"sm",shadow:"sm","data-testid":"revenue-distribution-error",className:y.cn("w-full",s.base),children:c.jsx(y.CardBody,{children:o})}):c.jsx("div",{"data-testid":"revenue-distribution-error",className:y.cn("w-full",s.base),children:o})};Eo.displayName="RevenueDistributionError";const To=({rows:t=1,showCard:e=!0,classNames:n={}})=>{const r=Array.from({length:t},(i,o)=>o),s=i=>c.jsxs("div",{className:y.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(y.Skeleton,{className:"h-4 w-14 rounded-md"}),c.jsx(y.Skeleton,{className:"h-4 w-4 rounded-full"})]}),c.jsx(y.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(y.Skeleton,{className:"h-4 w-20 rounded-md"}),c.jsx(y.Skeleton,{className:"h-4 w-4 rounded-full"})]}),c.jsx(y.Skeleton,{className:"h-10 w-full rounded-lg"})]}),c.jsxs("div",{className:"shrink-0 pb-2 flex items-center gap-2",children:[c.jsx(y.Skeleton,{className:"h-5 w-5 rounded-full"}),c.jsx(y.Skeleton,{className:"h-4 w-24 rounded-md"})]}),c.jsx("div",{className:"shrink-0 pb-2",children:c.jsx(y.Skeleton,{className:"h-8 w-20 rounded-lg"})})]},i);return e?c.jsx("div",{className:y.cn("flex flex-col gap-3",n.base),children:r.map(i=>c.jsx(y.Card,{radius:"md",shadow:"sm","data-testid":`revenue-distribution-skeleton-${i}`,children:c.jsx(y.CardBody,{children:s(i)})},i))}):c.jsx("div",{"data-testid":"revenue-distribution-skeleton",className:y.cn("flex flex-col gap-3",n.base),children:r.map(i=>s(i))})};To.displayName="RevenueDistributionSkeleton";exports.Button=oe;exports.ConfirmationPageTemplate=Wo;exports.DonationAmounts=qi;exports.EventDetails=Fu;exports.EventDetailsTemplate=Qo;exports.ExpireCartTimer=Ki;exports.Footer=Xo;exports.HeroUIProvider=Ho;exports.Multiselect=Yo;exports.Navbar=Jo;exports.OfferCard=Ir;exports.OfferCardEmpty=lo;exports.OfferCardError=ao;exports.OfferCardList=ho;exports.OfferCardSkeleton=co;exports.RICH_TEXT_PRESETS=Hi;exports.RevenueDistributionCard=Ao;exports.RevenueDistributionEmpty=No;exports.RevenueDistributionError=Eo;exports.RevenueDistributionSkeleton=To;exports.RichTextArea=Ui;exports.Stepper=Zs;exports.calculateAllocationDifference=pd;exports.formatOfferCurrency=oo;exports.formatRevenueAmount=ud;exports.formatRevenueCurrency=dd;exports.generateDistributionId=Vr;exports.getCurrencySymbol=fd;exports.offerCardVariants=fo;exports.offerListVariants=uo;exports.parseOfferCurrency=Pu;exports.parseRevenueCurrency=hd;Object.keys(y).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>y[t]})});
20
20
  (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:none}.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)}})();