tiptap-editor-codeveda 0.7.0 → 0.8.0
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(F,N){typeof exports=="object"&&typeof module<"u"?N(exports,require("react"),require("@tiptap/react"),require("@tiptap/starter-kit"),require("@tiptap/extension-table"),require("@tiptap/extension-table-row"),require("@tiptap/extension-table-cell"),require("@tiptap/extension-table-header"),require("@tiptap/extension-image"),require("@tiptap/extension-link"),require("@tiptap/extension-text-style"),require("@tiptap/extension-color"),require("@tiptap/extension-highlight"),require("@tiptap/extension-code-block-lowlight"),require("lucide-react"),require("lowlight"),require("@tiptap/core"),require("@tiptap/extension-underline"),require("@tiptap/extension-strike"),require("@tiptap/extension-blockquote"),require("@tiptap/extension-horizontal-rule"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("@floating-ui/react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","@tiptap/react","@tiptap/starter-kit","@tiptap/extension-table","@tiptap/extension-table-row","@tiptap/extension-table-cell","@tiptap/extension-table-header","@tiptap/extension-image","@tiptap/extension-link","@tiptap/extension-text-style","@tiptap/extension-color","@tiptap/extension-highlight","@tiptap/extension-code-block-lowlight","lucide-react","lowlight","@tiptap/core","@tiptap/extension-underline","@tiptap/extension-strike","@tiptap/extension-blockquote","@tiptap/extension-horizontal-rule","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","@floating-ui/react","react-dom"],N):(F=typeof globalThis<"u"?globalThis:F||self,N(F.TiptapEditorCodeveda={},F.React,F.react,F.StarterKit,F.extensionTable,F.TableRow,F.TableCell,F.TableHeader,F.Image,F.Link,F.extensionTextStyle,F.Color,F.Highlight,F.CodeBlockLowlight,F.lucideReact,F.lowlight$1,F.core,F.Underline,F.Strike,F.Blockquote,F.HorizontalRule,F.reactSlot,F.classVarianceAuthority,F.clsx,F.tailwindMerge,F.react$1,F.ReactDOM))})(this,(function(F,N,q,ns,_t,en,tn,nn,rs,ss,is,os,as,ls,O,rn,K,cs,ds,us,fs,ps,hs,ms,gs,se,sn){"use strict";function bs(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const ge=bs(N);var tt={exports:{}},Ke={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var on;function ws(){if(on)return Ke;on=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,s,i){var a=null;if(i!==void 0&&(a=""+i),s.key!==void 0&&(a=""+s.key),"key"in s){i={};for(var l in s)l!=="key"&&(i[l]=s[l])}else i=s;return s=i.ref,{$$typeof:t,type:r,key:a,ref:s!==void 0?s:null,props:i}}return Ke.Fragment=e,Ke.jsx=n,Ke.jsxs=n,Ke}var qe={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,15 +14,15 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
17
|
+
*/var an;function xs(){return an||(an=1,process.env.NODE_ENV!=="production"&&(function(){function t(h){if(h==null)return null;if(typeof h=="function")return h.$$typeof===S?null:h.displayName||h.name||null;if(typeof h=="string")return h;switch(h){case w:return"Fragment";case _:return"Profiler";case g:return"StrictMode";case x:return"Suspense";case k:return"SuspenseList";case D:return"Activity"}if(typeof h=="object")switch(typeof h.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),h.$$typeof){case b:return"Portal";case y:return(h.displayName||"Context")+".Provider";case C:return(h._context.displayName||"Context")+".Consumer";case T:var E=h.render;return h=h.displayName,h||(h=E.displayName||E.name||"",h=h!==""?"ForwardRef("+h+")":"ForwardRef"),h;case M:return E=h.displayName||null,E!==null?E:t(h.type)||"Memo";case z:E=h._payload,h=h._init;try{return t(h(E))}catch{}}return null}function e(h){return""+h}function n(h){try{e(h);var E=!1}catch{E=!0}if(E){E=console;var R=E.error,B=typeof Symbol=="function"&&Symbol.toStringTag&&h[Symbol.toStringTag]||h.constructor.name||"Object";return R.call(E,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",B),e(h)}}function r(h){if(h===w)return"<>";if(typeof h=="object"&&h!==null&&h.$$typeof===z)return"<...>";try{var E=t(h);return E?"<"+E+">":"<...>"}catch{return"<...>"}}function s(){var h=L.A;return h===null?null:h.getOwner()}function i(){return Error("react-stack-top-frame")}function a(h){if(v.call(h,"key")){var E=Object.getOwnPropertyDescriptor(h,"key").get;if(E&&E.isReactWarning)return!1}return h.key!==void 0}function l(h,E){function R(){J||(J=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",E))}R.isReactWarning=!0,Object.defineProperty(h,"key",{get:R,configurable:!0})}function c(){var h=t(this.type);return G[h]||(G[h]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),h=this.props.ref,h!==void 0?h:null}function d(h,E,R,B,Z,X,ae,fe){return R=X.ref,h={$$typeof:p,type:h,key:E,props:X,_owner:Z},(R!==void 0?R:null)!==null?Object.defineProperty(h,"ref",{enumerable:!1,get:c}):Object.defineProperty(h,"ref",{enumerable:!1,value:null}),h._store={},Object.defineProperty(h._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(h,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(h,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:ae}),Object.defineProperty(h,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:fe}),Object.freeze&&(Object.freeze(h.props),Object.freeze(h)),h}function u(h,E,R,B,Z,X,ae,fe){var ee=E.children;if(ee!==void 0)if(B)if(U(ee)){for(B=0;B<ee.length;B++)f(ee[B]);Object.freeze&&Object.freeze(ee)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else f(ee);if(v.call(E,"key")){ee=t(h);var le=Object.keys(E).filter(function(Tt){return Tt!=="key"});B=0<le.length?"{key: someKey, "+le.join(": ..., ")+": ...}":"{key: someKey}",I[ee+B]||(le=0<le.length?"{"+le.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
18
|
let props = %s;
|
|
19
19
|
<%s {...props} />
|
|
20
20
|
React keys must be passed directly to JSX without using spread:
|
|
21
21
|
let props = %s;
|
|
22
|
-
<%s key={someKey} {...props} />`,G,X,Oe,X),F[X+G]=!0)}if(X=null,U!==void 0&&(n(U),X=""+U),o(R)&&(n(R.key),X=""+R.key),"key"in R){U={};for(var Te in R)Te!=="key"&&(U[Te]=R[Te])}else U=R;return X&&l(U,typeof w=="function"?w.displayName||w.name||"Unknown":w),u(w,X,ee,re,s(),U,He,ie)}function f(w){typeof w=="object"&&w!==null&&w.$$typeof===p&&w._store&&(w._store.validated=1)}var h=S,p=Symbol.for("react.transitional.element"),g=Symbol.for("react.portal"),b=Symbol.for("react.fragment"),m=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),x=Symbol.for("react.context"),C=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),_=Symbol.for("react.suspense_list"),D=Symbol.for("react.memo"),E=Symbol.for("react.lazy"),B=Symbol.for("react.activity"),N=Symbol.for("react.client.reference"),z=h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I=Object.prototype.hasOwnProperty,O=Array.isArray,L=console.createTask?console.createTask:function(){return null};h={react_stack_bottom_frame:function(w){return w()}};var j,A={},H=h.react_stack_bottom_frame.bind(h,i)(),M=L(r(i)),F={};Ke.Fragment=b,Ke.jsx=function(w,R,U,G,re){var ee=1e4>z.recentlyCreatedOwnerStacks++;return d(w,R,U,!1,G,re,ee?Error("react-stack-top-frame"):H,ee?L(r(w)):M)},Ke.jsxs=function(w,R,U,G,re){var ee=1e4>z.recentlyCreatedOwnerStacks++;return d(w,R,U,!0,G,re,ee?Error("react-stack-top-frame"):H,ee?L(r(w)):M)}})()),Ke}var tn;function hs(){return tn||(tn=1,process.env.NODE_ENV==="production"?Ze.exports=fs():Ze.exports=ps()),Ze.exports}var a=hs();const nn=Yr.configure({codeBlock:!1}),ms=vt.Table.configure({resizable:!0}),gs=vt.Table.extend({addNodeView(){return({node:t})=>new vt.TableView(t,this.options.cellMinWidth)}}).configure({resizable:!1}),rn=Zr.configure({inline:!1,allowBase64:!1,HTMLAttributes:{class:"max-w-full h-auto rounded-lg shadow-sm"}}),sn=Xr.configure({openOnClick:!1,autolink:!0,defaultProtocol:"https"}),on=Qr.TextStyle,an=es.configure({types:["textStyle"]}),ln=ts.configure({multicolor:!0}),bs=({node:t})=>{const[e,n]=S.useState(!1),r=S.useRef(null);S.useEffect(()=>()=>{r.current&&clearTimeout(r.current)},[]);const s=()=>{navigator.clipboard.writeText(t.textContent).then(()=>{n(!0),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>n(!1),2e3)}).catch(()=>{})};return a.jsxs(Y.NodeViewWrapper,{className:"code-block-wrapper",children:[a.jsx("button",{type:"button",className:"copy-btn",onClick:s,"aria-label":e?"Copied!":"Copy code",title:e?"Copied!":"Copy code",children:e?a.jsx(k.Check,{className:"h-4 w-4"}):a.jsx(k.Copy,{className:"h-4 w-4"})}),a.jsx("pre",{children:a.jsx(Y.NodeViewContent,{style:{whiteSpace:"pre",wordBreak:"normal",overflowWrap:"normal"}})})]})},ws=t=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:t.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:t.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),xs=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],ys=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],vs=[...xs,...ys],Es=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),Ns=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),Ss=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),Cs=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function Ts(t){const e=t.regex,n=ws(t),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},s="and or not only",i=/@-?\w[\w]*(-\w+)*/,o="[a-zA-Z-][a-zA-Z0-9_-]*",l=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[n.BLOCK_COMMENT,r,n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+o,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+Ns.join("|")+")"},{begin:":(:)?("+Ss.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+Cs.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,...l,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...l,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:e.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:i},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:s,attribute:Es.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...l,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+vs.join("|")+")\\b"}]}}const cn="[A-Za-z$_][0-9A-Za-z$_]*",_s=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],ks=["true","false","null","undefined","NaN","Infinity"],un=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],dn=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],fn=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],As=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],Os=[].concat(fn,un,dn);function Ms(t){const e=t.regex,n=(M,{after:F})=>{const w="</"+M[0].slice(1);return M.input.indexOf(w,F)!==-1},r=cn,s={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(M,F)=>{const w=M[0].length+M.index,R=M.input[w];if(R==="<"||R===","){F.ignoreMatch();return}R===">"&&(n(M,{after:w})||F.ignoreMatch());let U;const G=M.input.substring(w);if(U=G.match(/^\s*=/)){F.ignoreMatch();return}if((U=G.match(/^\s+extends\s+/))&&U.index===0){F.ignoreMatch();return}}},l={$pattern:cn,keyword:_s,literal:ks,built_in:Os,"variable.language":As},c="[0-9](_?[0-9])*",u=`\\.(${c})`,d="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",f={className:"number",variants:[{begin:`(\\b(${d})((${u})|\\.)?|(${u}))[eE][+-]?(${c})\\b`},{begin:`\\b(${d})\\b((${u})\\b|\\.)?|(${u})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},h={className:"subst",begin:"\\$\\{",end:"\\}",keywords:l,contains:[]},p={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"xml"}},g={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"css"}},b={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"graphql"}},m={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,h]},T={className:"comment",variants:[t.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),t.C_BLOCK_COMMENT_MODE,t.C_LINE_COMMENT_MODE]},x=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,p,g,b,m,{match:/\$\d+/},f];h.contains=x.concat({begin:/\{/,end:/\}/,keywords:l,contains:["self"].concat(x)});const C=[].concat(T,h.contains),y=C.concat([{begin:/(\s*)\(/,end:/\)/,keywords:l,contains:["self"].concat(C)}]),_={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:y},D={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,e.concat(r,"(",e.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},E={relevance:0,match:e.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...un,...dn]}},B={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},N={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[_],illegal:/%/},z={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function I(M){return e.concat("(?!",M.join("|"),")")}const O={match:e.concat(/\b/,I([...fn,"super","import"].map(M=>`${M}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},L={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},j={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},_]},A="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",H={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(A)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[_]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:y,CLASS_REFERENCE:E},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),B,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,p,g,b,m,T,{match:/\$\d+/},f,E,{scope:"attr",match:r+e.lookahead(":"),relevance:0},H,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[T,t.REGEXP_MODE,{className:"function",begin:A,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:t.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:y}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:i},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:"xml",contains:[{begin:o.begin,end:o.end,skip:!0,contains:["self"]}]}]},N,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[_,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},L,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[_]},O,z,D,j,{match:/\$[(.]/}]}}const Xe="[A-Za-z$_][0-9A-Za-z$_]*",pn=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],hn=["true","false","null","undefined","NaN","Infinity"],mn=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],gn=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],bn=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],wn=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],xn=[].concat(bn,mn,gn);function Is(t){const e=t.regex,n=(M,{after:F})=>{const w="</"+M[0].slice(1);return M.input.indexOf(w,F)!==-1},r=Xe,s={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(M,F)=>{const w=M[0].length+M.index,R=M.input[w];if(R==="<"||R===","){F.ignoreMatch();return}R===">"&&(n(M,{after:w})||F.ignoreMatch());let U;const G=M.input.substring(w);if(U=G.match(/^\s*=/)){F.ignoreMatch();return}if((U=G.match(/^\s+extends\s+/))&&U.index===0){F.ignoreMatch();return}}},l={$pattern:Xe,keyword:pn,literal:hn,built_in:xn,"variable.language":wn},c="[0-9](_?[0-9])*",u=`\\.(${c})`,d="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",f={className:"number",variants:[{begin:`(\\b(${d})((${u})|\\.)?|(${u}))[eE][+-]?(${c})\\b`},{begin:`\\b(${d})\\b((${u})\\b|\\.)?|(${u})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},h={className:"subst",begin:"\\$\\{",end:"\\}",keywords:l,contains:[]},p={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"xml"}},g={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"css"}},b={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"graphql"}},m={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,h]},T={className:"comment",variants:[t.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),t.C_BLOCK_COMMENT_MODE,t.C_LINE_COMMENT_MODE]},x=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,p,g,b,m,{match:/\$\d+/},f];h.contains=x.concat({begin:/\{/,end:/\}/,keywords:l,contains:["self"].concat(x)});const C=[].concat(T,h.contains),y=C.concat([{begin:/(\s*)\(/,end:/\)/,keywords:l,contains:["self"].concat(C)}]),_={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:y},D={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,e.concat(r,"(",e.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},E={relevance:0,match:e.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...mn,...gn]}},B={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},N={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[_],illegal:/%/},z={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function I(M){return e.concat("(?!",M.join("|"),")")}const O={match:e.concat(/\b/,I([...bn,"super","import"].map(M=>`${M}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},L={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},j={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},_]},A="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",H={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(A)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[_]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:y,CLASS_REFERENCE:E},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),B,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,p,g,b,m,T,{match:/\$\d+/},f,E,{scope:"attr",match:r+e.lookahead(":"),relevance:0},H,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[T,t.REGEXP_MODE,{className:"function",begin:A,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:t.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:y}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:i},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:"xml",contains:[{begin:o.begin,end:o.end,skip:!0,contains:["self"]}]}]},N,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[_,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},L,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[_]},O,z,D,j,{match:/\$[(.]/}]}}function Rs(t){const e=t.regex,n=Is(t),r=Xe,s=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],i={begin:[/namespace/,/\s+/,t.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},o={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:s},contains:[n.exports.CLASS_REFERENCE]},l={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},c=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],u={$pattern:Xe,keyword:pn.concat(c),literal:hn,built_in:xn.concat(s),"variable.language":wn},d={className:"meta",begin:"@"+r},f=(b,m,v)=>{const T=b.contains.findIndex(x=>x.label===m);if(T===-1)throw new Error("can not find mode to replace");b.contains.splice(T,1,v)};Object.assign(n.keywords,u),n.exports.PARAMS_CONTAINS.push(d);const h=n.contains.find(b=>b.scope==="attr"),p=Object.assign({},h,{match:e.concat(r,e.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,h,p]),n.contains=n.contains.concat([d,i,o,p]),f(n,"shebang",t.SHEBANG()),f(n,"use_strict",l);const g=n.contains.find(b=>b.label==="func.def");return g.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function Ls(t){const e=t.regex,n=e.concat(/[\p{L}_]/u,e.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,s={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},i={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},o=t.inherit(i,{begin:/\(/,end:/\)/}),l=t.inherit(t.APOS_STRING_MODE,{className:"string"}),c=t.inherit(t.QUOTE_STRING_MODE,{className:"string"}),u={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[s]},{begin:/'/,end:/'/,contains:[s]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[i,c,l,o,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[i,o,c,l]}]}]},t.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},s,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[c]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[u],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[u],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:e.concat(/</,e.lookahead(e.concat(n,e.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:u}]},{className:"tag",begin:e.concat(/<\//,e.lookahead(e.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function js(t){const e=t.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],l={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},c={className:"meta",begin:/^(>>>|\.\.\.) /},u={className:"subst",begin:/\{/,end:/\}/,keywords:l,illegal:/#/},d={begin:/\{\{/,relevance:0},f={className:"string",contains:[t.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,c],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,c],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,c,d,u]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,c,d,u]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[t.BACKSLASH_ESCAPE,d,u]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,d,u]},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},h="[0-9](_?[0-9])*",p=`(\\b(${h}))?\\.(${h})|\\b(${h})\\.`,g=`\\b|${r.join("|")}`,b={className:"number",relevance:0,variants:[{begin:`(\\b(${h})|(${p}))[eE][+-]?(${h})[jJ]?(?=${g})`},{begin:`(${p})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${g})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${g})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${g})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${g})`},{begin:`\\b(${h})[jJ](?=${g})`}]},m={className:"comment",begin:e.lookahead(/# type:/),end:/$/,keywords:l,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},v={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:["self",c,b,f,t.HASH_COMMENT_MODE]}]};return u.contains=[f,b,c],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:l,illegal:/(<\/|\?)|=>/,contains:[c,b,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},f,m,t.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[v]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[b,v,f]}]}}var Le="[0-9](_*[0-9])*",Qe=`\\.(${Le})`,et="[0-9a-fA-F](_*[0-9a-fA-F])*",yn={className:"number",variants:[{begin:`(\\b(${Le})((${Qe})|\\.)?|(${Qe}))[eE][+-]?(${Le})[fFdD]?\\b`},{begin:`\\b(${Le})((${Qe})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${Qe})[fFdD]?\\b`},{begin:`\\b(${Le})[fFdD]\\b`},{begin:`\\b0[xX]((${et})\\.?|(${et})?\\.(${et}))[pP][+-]?(${Le})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${et})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function vn(t,e,n){return n===-1?"":t.replace(e,r=>vn(t,e,n-1))}function Ds(t){const e=t.regex,n="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",r=n+vn("(?:<"+n+"~~~(?:\\s*,\\s*"+n+"~~~)*>)?",/~~~/g,2),c={keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed","yield","permits","goto","when"],literal:["false","true","null"],type:["char","boolean","long","float","int","byte","short","double"],built_in:["super","this"]},u={className:"meta",begin:"@"+n,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},d={className:"params",begin:/\(/,end:/\)/,keywords:c,relevance:0,contains:[t.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:c,illegal:/<\/|#/,contains:[t.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[t.BACKSLASH_ESCAPE]},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,n],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{begin:[e.concat(/(?!else)/,n),/\s+/,n,/\s+/,/=(?!=)/],className:{1:"type",3:"variable",5:"operator"}},{begin:[/record/,/\s+/,n],className:{1:"keyword",3:"title.class"},contains:[d,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{beginKeywords:"new throw return else",relevance:0},{begin:["(?:"+r+"\\s+)",t.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{2:"title.function"},keywords:c,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:c,relevance:0,contains:[u,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,yn,t.C_BLOCK_COMMENT_MODE]},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},yn,u]}}function Ps(t){const e=t.regex,n=t.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",s="[a-zA-Z_]\\w*::",o="("+r+"|"+e.optional(s)+"[a-zA-Z_]\\w*"+e.optional("<[^<>]+>")+")",l={className:"type",variants:[{begin:"\\b[a-z\\d_]*_t\\b"},{match:/\batomic_[a-z]{3,6}\b/}]},u={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[t.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},t.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},d={className:"number",variants:[{match:/\b(0b[01']+)/},{match:/(-?)\b([\d']+(\.[\d']*)?|\.[\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)/},{match:/(-?)\b(0[xX][a-fA-F0-9]+(?:'[a-fA-F0-9]+)*(?:\.[a-fA-F0-9]*(?:'[a-fA-F0-9]*)*)?(?:[pP][-+]?[0-9]+)?(l|L)?(u|U)?)/},{match:/(-?)\b\d+(?:'\d+)*(?:\.\d*(?:'\d*)*)?(?:[eE][-+]?\d+)?/}],relevance:0},f={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef elifdef elifndef include"},contains:[{begin:/\\\n/,relevance:0},t.inherit(u,{className:"string"}),{className:"string",begin:/<.*?>/},n,t.C_BLOCK_COMMENT_MODE]},h={className:"title",begin:e.optional(s)+t.IDENT_RE,relevance:0},p=e.optional(s)+t.IDENT_RE+"\\s*\\(",m={keyword:["asm","auto","break","case","continue","default","do","else","enum","extern","for","fortran","goto","if","inline","register","restrict","return","sizeof","typeof","typeof_unqual","struct","switch","typedef","union","volatile","while","_Alignas","_Alignof","_Atomic","_Generic","_Noreturn","_Static_assert","_Thread_local","alignas","alignof","noreturn","static_assert","thread_local","_Pragma"],type:["float","double","signed","unsigned","int","short","long","char","void","_Bool","_BitInt","_Complex","_Imaginary","_Decimal32","_Decimal64","_Decimal96","_Decimal128","_Decimal64x","_Decimal128x","_Float16","_Float32","_Float64","_Float128","_Float32x","_Float64x","_Float128x","const","static","constexpr","complex","bool","imaginary"],literal:"true false NULL",built_in:"std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr"},v=[f,l,n,t.C_BLOCK_COMMENT_MODE,d,u],T={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:m,contains:v.concat([{begin:/\(/,end:/\)/,keywords:m,contains:v.concat(["self"]),relevance:0}]),relevance:0},x={begin:"("+o+"[\\*&\\s]+)+"+p,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:m,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:m,relevance:0},{begin:p,returnBegin:!0,contains:[t.inherit(h,{className:"title.function"})],relevance:0},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:m,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,u,d,l,{begin:/\(/,end:/\)/,keywords:m,relevance:0,contains:["self",n,t.C_BLOCK_COMMENT_MODE,u,d,l]}]},l,n,t.C_BLOCK_COMMENT_MODE,f]};return{name:"C",aliases:["h"],keywords:m,disableAutodetect:!0,illegal:"</",contains:[].concat(T,x,v,[f,{begin:t.IDENT_RE+"::",keywords:m},{className:"class",beginKeywords:"enum class struct union",end:/[{;:<>=]/,contains:[{beginKeywords:"final class struct"},t.TITLE_MODE]}]),exports:{preprocessor:f,strings:u,keywords:m}}}function Bs(t){const e=t.regex,n=t.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",s="[a-zA-Z_]\\w*::",o="(?!struct)("+r+"|"+e.optional(s)+"[a-zA-Z_]\\w*"+e.optional("<[^<>]+>")+")",l={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},u={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[t.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},t.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},d={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},f={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},t.inherit(u,{className:"string"}),{className:"string",begin:/<.*?>/},n,t.C_BLOCK_COMMENT_MODE]},h={className:"title",begin:e.optional(s)+t.IDENT_RE,relevance:0},p=e.optional(s)+t.IDENT_RE+"\\s*\\(",g=["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],b=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],m=["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"],v=["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"],C={type:b,keyword:g,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:m},y={className:"function.dispatch",relevance:0,keywords:{_hint:v},begin:e.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,t.IDENT_RE,e.lookahead(/(<[^<>]+>|)\s*\(/))},_=[y,f,l,n,t.C_BLOCK_COMMENT_MODE,d,u],D={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:C,contains:_.concat([{begin:/\(/,end:/\)/,keywords:C,contains:_.concat(["self"]),relevance:0}]),relevance:0},E={className:"function",begin:"("+o+"[\\*&\\s]+)+"+p,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:C,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:C,relevance:0},{begin:p,returnBegin:!0,contains:[h],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[u,d]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:C,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,u,d,l,{begin:/\(/,end:/\)/,keywords:C,relevance:0,contains:["self",n,t.C_BLOCK_COMMENT_MODE,u,d,l]}]},l,n,t.C_BLOCK_COMMENT_MODE,f]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:C,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(D,E,y,_,[f,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",end:">",keywords:C,contains:["self",l]},{begin:t.IDENT_RE+"::",keywords:C},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}function zs(t){const e=t.regex,n=t.COMMENT("--","$"),r={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},s={begin:/"/,end:/"/,contains:[{match:/""/}]},i=["true","false","unknown"],o=["double precision","large object","with timezone","without timezone"],l=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],c=["add","asc","collation","desc","final","first","last","view"],u=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],d=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],f=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],h=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],p=d,g=[...u,...c].filter(y=>!d.includes(y)),b={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},m={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},v={match:e.concat(/\b/,e.either(...p),/\s*\(/),relevance:0,keywords:{built_in:p}};function T(y){return e.concat(/\b/,e.either(...y.map(_=>_.replace(/\s+/,"\\s+"))),/\b/)}const x={scope:"keyword",match:T(h),relevance:0};function C(y,{exceptions:_,when:D}={}){const E=D;return _=_||[],y.map(B=>B.match(/\|\d+$/)||_.includes(B)?B:E(B)?`${B}|0`:B)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:C(g,{when:y=>y.length<3}),literal:i,type:l,built_in:f},contains:[{scope:"type",match:T(o)},x,v,b,r,s,t.C_NUMBER_MODE,t.C_BLOCK_COMMENT_MODE,n,m]}}const En=V.Mark.create({name:"codeBlockBg",addOptions(){return{multicolor:!0,HTMLAttributes:{}}},inclusive:!1,addAttributes(){return{color:{default:null,parseHTML:t=>t.getAttribute("data-background-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-background-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}},parseHTML(){return[{tag:"span[data-background-color]",getAttrs:t=>typeof t=="string"?!1:{color:t.getAttribute("data-background-color")}}]},renderHTML({HTMLAttributes:t,mark:e}){const n=e.attrs?.color||t["data-background-color"];return n?["span",{"data-background-color":n,style:`background-color: ${n}; color: inherit`},0]:["span",{},0]},addCommands(){return{setCodeBlockBg:t=>({commands:e})=>e.setMark(this.name,{color:t}),toggleCodeBlockBg:t=>({commands:e})=>e.toggleMark(this.name,{color:t}),unsetCodeBlockBg:()=>({commands:t})=>t.unsetMark(this.name)}}}),me=Zt.createLowlight(Zt.all);me.register("html",Ls),me.register("css",Ts),me.register("js",Ms),me.register("ts",Rs),me.register("java",Ds),me.register("c",Ps),me.register("cpp",Bs),me.register("python",js),me.register("sql",zs);const Nn=ns.extend({marks(){return"codeBlockBg"},addNodeView(){return Y.ReactNodeViewRenderer(bs)}}).configure({lowlight:me}),Sn=rs,Cn=ss,Tn=is,_n=os;function Us({node:t,updateAttributes:e,editor:n}){const[r,s]=S.useState(t.attrs?.open??!0),[i,o]=S.useState(!1),[l,c]=S.useState(t.attrs?.title||"Output"),u=S.useRef(null),d=n?.isEditable??!1;S.useEffect(()=>{i&&u.current&&(u.current.focus(),u.current.select())},[i]);const f=()=>{o(!1),e({title:l,open:r})},h=m=>{m.key==="Enter"?f():m.key==="Escape"&&(c(t.attrs?.title||"Output"),o(!1))},p=()=>{const m=!r;s(m),e({title:l,open:m})},g=()=>{d&&n&&confirm("Are you sure you want to delete this accordion?")&&n.chain().focus().deleteNode("accordion").run()},b=m=>{if(!d||!n)return;const{selection:v}=n.state,{$anchor:T}=v;if(m.key==="Enter"&&!m.shiftKey&&T.nodeBefore?.type.name==="accordion"){m.preventDefault(),m.stopPropagation();const x=T.nodeBefore;if(x&&x.childCount>0){const C=x.lastChild;if(C&&C.content.size>0){let y=-1;if(n.state.doc.descendants((_,D)=>{if(_.type.name==="accordionItem")return y=D,!1}),y!==-1){const _=y+C.nodeSize-2;n.chain().focus().setTextSelection(_).run()}}else{let y=-1;n.state.doc.descendants((_,D)=>{if(_.type.name==="accordionItem")return y=D,!1}),y!==-1&&n.chain().focus().setTextSelection(y+1).run()}}return}if((m.key==="Backspace"||m.key==="Delete")&&!m.shiftKey){if(T.nodeBefore?.type.name==="accordion"){m.preventDefault(),m.stopPropagation();return}if(T.nodeAfter?.type.name==="accordion"){m.preventDefault(),m.stopPropagation();return}if(T.parent.type.name==="accordionItem"){const x=T.parent,C=T.parentOffset===0,y=x.content.content.some(_=>_.type.name==="paragraph"?_.content.size>0:!0);if(C&&!y&&m.key==="Backspace"){m.preventDefault(),m.stopPropagation();return}}if(T.parent.type.name==="accordion"&&!T.parent.content.content.some(y=>y.type.name==="accordionItem"?y.content.content.some(_=>_.type.name==="paragraph"?_.content.size>0:!0):!0)){m.preventDefault(),m.stopPropagation();return}}};return a.jsxs(Y.NodeViewWrapper,{className:"accordion border border-gray-200 rounded-lg mb-3 overflow-hidden",onKeyDown:b,children:[a.jsx("div",{className:"accordion-header bg-gray-50 border-b border-gray-200",onClick:p,children:a.jsxs("div",{className:"flex items-center gap-2 px-1",children:[a.jsx("button",{type:"button",onClick:m=>{m.stopPropagation(),p()},className:"flex items-center justify-center w-6 h-6 text-gray-600 hover:text-gray-800",title:r?"Collapse":"Expand",children:a.jsx("span",{className:`cursor-pointer transition-transform duration-200 ${r?"rotate-90":""}`,children:"▶"})}),i?a.jsx("input",{ref:u,type:"text",value:l,onChange:m=>c(m.target.value),onBlur:f,onKeyDown:h,className:"bg-transparent border-b border-gray-300 outline-none font-medium text-gray-800 flex-1 py-1",placeholder:"Enter accordion title..."}):a.jsx("div",{onClick:d?m=>{m.stopPropagation(),o(!0)}:void 0,className:`font-medium text-gray-800 flex-1 py-1 ${d?"cursor-text hover:text-blue-600":"cursor-pointer"}`,title:d?"Click to edit title":void 0,children:l}),d&&a.jsx("button",{type:"button",onClick:m=>{m.stopPropagation(),g()},className:"px-2 py-1 text-red-600 hover:text-red-700 hover:bg-red-50 transition-colors rounded",title:"Delete accordion",children:a.jsx(k.Trash2,{className:"h-4 w-4"})})]})}),r&&a.jsx("div",{className:"accordion-content p-3 bg-white",children:a.jsx(Y.NodeViewContent,{})})]})}const kn=V.Node.create({name:"accordion",group:"block",content:"accordionItem+",defining:!0,isolating:!0,addAttributes(){return{title:{default:"Output",parseHTML:t=>t.getAttribute("data-title"),renderHTML:t=>t.title?{"data-title":t.title}:{}},open:{default:!0,parseHTML:t=>t.getAttribute("data-open")==="true",renderHTML:t=>({"data-open":t.open})}}},parseHTML(){return[{tag:'div[data-type="accordion"]'}]},renderHTML({HTMLAttributes:t}){return["div",V.mergeAttributes(t,{"data-type":"accordion"}),0]},addNodeView(){return Y.ReactNodeViewRenderer(Us)},addKeyboardShortcuts(){return{Backspace:({editor:t})=>{const{selection:e}=t.state,{$anchor:n}=e;return n.nodeBefore?.type.name==="accordion"||n.parent.type.name==="accordion"&&!n.parent.content.content.some(i=>i.type.name==="accordionItem"?i.content.content.some(o=>o.type.name==="paragraph"?o.content.size>0:!0):!0)},Delete:({editor:t})=>{const{selection:e}=t.state,{$anchor:n}=e;return n.nodeAfter?.type.name==="accordion"||n.parent.type.name==="accordion"&&!n.parent.content.content.some(i=>i.type.name==="accordionItem"?i.content.content.some(o=>o.type.name==="paragraph"?o.content.size>0:!0):!0)}}},addCommands(){return{insertAccordion:()=>({commands:t})=>t.insertContent({type:this.name,content:[{type:"accordionItem",content:[{type:"paragraph",content:[{type:"text",text:"Accordion Item 1"}]}]}]})}}}),An=V.Node.create({name:"accordionItem",group:"block",content:"block+",defining:!0,isolating:!0,parseHTML(){return[{tag:'div[data-type="accordion-item"]'}]},renderHTML({HTMLAttributes:t}){return["div",V.mergeAttributes(t,{"data-type":"accordion-item"}),0]},addKeyboardShortcuts(){return{Enter:({editor:t})=>{const{selection:e}=t.state,{$anchor:n}=e;return n.parent.type.name==="accordionItem",!1},Backspace:({editor:t})=>{const{selection:e}=t.state,{$anchor:n}=e;if(n.parent.type.name==="accordionItem"&&n.parentOffset===0&&n.depth>0){const r=n.start(n.depth);if(n.pos<=r+1)return!0}return!1}}}});function Fs({node:t,updateAttributes:e,editor:n}){const[r,s]=S.useState(t.attrs?.activeTab??0),[i,o]=S.useState(null),[l,c]=S.useState(""),u=S.useRef(null),d=t.content?.content||[],f=n?.isEditable??!1;S.useEffect(()=>{const x=t.attrs?.activeTab??0;x!==r&&s(x)},[t.attrs?.activeTab]),S.useEffect(()=>{i!==null&&u.current&&(u.current.focus(),u.current.select())},[i]);const h=x=>{s(x),e({...t.attrs,activeTab:x})},p=(x,C)=>{f&&(o(x),c(C))},g=()=>{f&&n&&confirm("Are you sure you want to delete this tabs component?")&&n.chain().focus().deleteNode("tabs").run()},b=()=>{if(i!==null&&d[i]&&n){let x=-1;n.state.doc.descendants((C,y)=>{if(C.type.name==="tabItem"&&C.attrs.tabIndex===i)return x=y,!1}),x!==-1&&n.chain().focus().command(({tr:C,dispatch:y})=>{if(y){const _=C.doc.nodeAt(x);_&&C.setNodeMarkup(x,void 0,{..._.attrs,title:l})}return!0}).run()}o(null),c("")},m=x=>{x.key==="Enter"?b():x.key==="Escape"&&(o(null),c(""))},v=x=>d[x]?.attrs?.title||`Tab ${x+1}`,T=x=>{if(!f||!n)return;const{selection:C}=n.state,{$anchor:y}=C;if(x.key==="Enter"&&!x.shiftKey&&y.nodeBefore?.type.name==="tabs"){x.preventDefault(),x.stopPropagation();const _=y.nodeBefore;if(_&&_.childCount>0){const D=_.lastChild;if(D&&D.content.size>0){let E=-1;if(n.state.doc.descendants((B,N)=>{if(B.type.name==="tabItem"&&B.attrs.tabIndex===_.childCount-1)return E=N,!1}),E!==-1){const B=E+D.nodeSize-2;n.chain().focus().setTextSelection(B).run()}}}return}if((x.key==="Backspace"||x.key==="Delete")&&!x.shiftKey){if(y.nodeBefore?.type.name==="tabs"){x.preventDefault(),x.stopPropagation();return}if(y.nodeAfter?.type.name==="tabs"){x.preventDefault(),x.stopPropagation();return}}};return a.jsxs(Y.NodeViewWrapper,{className:"tabs-container border border-gray-200 rounded-lg mb-4 overflow-hidden","data-active-tab":r,onKeyDown:T,children:[a.jsx("div",{className:"tabs-header bg-gray-50 border-b border-gray-200",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("div",{className:"flex flex-1",children:d.map((x,C)=>a.jsx("button",{type:"button",onClick:()=>h(C),className:`flex-1 px-4 py-2 text-sm font-medium border-b-2 border-r border-gray-200 transition-colors relative cursor-pointer ${r===C?"border-blue-500 border-r-gray-200 text-blue-600 bg-white":"border-transparent border-r-gray-200 text-gray-500 hover:text-gray-700 hover:border-gray-300"} ${C===d.length-1?"border-r-0":""}`,children:i===C?a.jsx("input",{ref:u,type:"text",value:l,onChange:y=>c(y.target.value),onBlur:b,onKeyDown:m,className:"bg-transparent border-none outline-none text-center w-full",onClick:y=>y.stopPropagation()}):a.jsx("span",{onClick:f?y=>{y.stopPropagation(),p(C,v(C))}:void 0,className:`block w-full text-center ${f?"cursor-text":"cursor-pointer"}`,title:f?"Click to edit title":void 0,children:v(C)})},C))}),f&&a.jsx("button",{type:"button",onClick:g,className:"px-3 py-2 text-red-600 hover:text-red-700 hover:bg-red-50 transition-colors",title:"Delete tabs",children:a.jsx(k.Trash2,{className:"h-4 w-4"})})]})}),a.jsx("div",{className:"tabs-content",children:a.jsx(Y.NodeViewContent,{className:"tab-content-wrapper","data-active-tab":r})})]})}function Hs({node:t,editor:e}){const n=t.attrs?.tabIndex||0,r=e?.isEditable??!1,s=i=>{if(!r||!e)return;const{selection:o}=e.state,{$anchor:l}=o;if(i.key==="Enter"&&!i.shiftKey&&l.parent.type.name==="tabItem"){const c=l.parent;if(l.parentOffset===c.childCount)return}if(i.key==="Backspace"&&l.parent.type.name==="tabItem"){const c=l.parent;if(l.parentOffset===0&&c.childCount>0&&c.firstChild&&l.pos===l.start(l.depth))return}};return a.jsx(Y.NodeViewWrapper,{className:"tab-item-content p-4","data-tab-index":n,onKeyDown:s,children:a.jsx(Y.NodeViewContent,{})})}const On=V.Node.create({name:"tabs",group:"block",content:"tabItem+",defining:!0,isolating:!0,addAttributes(){return{activeTab:{default:0,parseHTML:t=>parseInt(t.getAttribute("data-active-tab")||"0"),renderHTML:t=>({"data-active-tab":t.activeTab})},tabCount:{default:2,parseHTML:t=>parseInt(t.getAttribute("data-tab-count")||"2"),renderHTML:t=>({"data-tab-count":t.tabCount})}}},parseHTML(){return[{tag:'div[data-type="tabs"]'}]},renderHTML({HTMLAttributes:t}){return["div",V.mergeAttributes(t,{"data-type":"tabs"}),0]},addNodeView(){return Y.ReactNodeViewRenderer(Fs,{contentDOMElementTag:"div"})},addKeyboardShortcuts(){return{Backspace:({editor:t})=>{const{selection:e}=t.state,{$anchor:n}=e;return n.nodeBefore?.type.name==="tabs"},Delete:({editor:t})=>{const{selection:e}=t.state,{$anchor:n}=e;return n.nodeAfter?.type.name==="tabs"}}},addCommands(){return{insertTabs:(t={tabCount:2})=>({commands:e})=>{const n=Math.min(Math.max(t.tabCount||2,2),6),r=Array.from({length:n},(s,i)=>({type:"tabItem",attrs:{tabIndex:i,title:`Tab ${i+1}`},content:[{type:"paragraph",content:[{type:"text",text:`Content for Tab ${i+1}. This is unique content for this tab.`}]}]}));return e.insertContent({type:this.name,attrs:{activeTab:0,tabCount:n},content:r})}}}}),Mn=V.Node.create({name:"tabItem",group:"block",content:"block+",defining:!0,isolating:!0,addAttributes(){return{tabIndex:{default:0,parseHTML:t=>parseInt(t.getAttribute("data-tab-index")||"0"),renderHTML:t=>({"data-tab-index":t.tabIndex})},title:{default:"Tab",parseHTML:t=>t.getAttribute("data-title")||"Tab",renderHTML:t=>({"data-title":t.title})}}},parseHTML(){return[{tag:'div[data-type="tab-item"]'}]},renderHTML({HTMLAttributes:t}){return["div",V.mergeAttributes(t,{"data-type":"tab-item"}),0]},addNodeView(){return Y.ReactNodeViewRenderer(Hs,{contentDOMElementTag:"div"})},addKeyboardShortcuts(){return{Enter:()=>!1,Backspace:({editor:t})=>{const{selection:e}=t.state,{$anchor:n}=e;if(n.parent.type.name==="tabItem"&&n.parentOffset===0&&n.depth>0){const r=n.start(n.depth);if(n.pos<=r+1)return!0}return!1}}}});function $s(...t){return us.twMerge(cs.clsx(t))}const Ks=ls.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function q({className:t,variant:e,size:n,asChild:r=!1,...s}){const i=r?as.Slot:"button";return a.jsx(i,{"data-slot":"button",className:$s(Ks({variant:e,size:n,className:t})),...s})}const qs=({node:t,updateAttributes:e,deleteNode:n,editor:r})=>{const[s,i]=S.useState(!1),[o,l]=S.useState("simple"),[c,u]=S.useState(""),[d,f]=S.useState(!1),h=S.useRef(null),[p,g]=S.useState({src:t.attrs.src||"",width:t.attrs.width||"100%",height:t.attrs.height||"500px",title:t.attrs.title||"",allow:t.attrs.allow||"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",sandbox:t.attrs.sandbox||"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation",style:t.attrs.style||""}),b=N=>{const z=N.toLowerCase();return z.includes("youtube.com")||z.includes("youtu.be")?"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation allow-popups-to-escape-sandbox":z.includes("codesandbox.io")||z.includes("stackblitz.com")?"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation allow-popups-to-escape-sandbox allow-top-navigation":"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation"},m=N=>{const z=b(N);g({...p,src:N,sandbox:z})},v=()=>{x&&(e(p),i(!1))},T=()=>{g({src:t.attrs.src||"",width:t.attrs.width||"100%",height:t.attrs.height||"500px",title:t.attrs.title||"",allow:t.attrs.allow||"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",sandbox:t.attrs.sandbox||"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation",style:t.attrs.style||""}),i(!1)},[x,C]=S.useState(r?.isEditable??!1);S.useEffect(()=>{if(r){const N=()=>{C(r.isEditable)};return N(),r.on("update",N),r.on("selectionUpdate",N),()=>{r.off("update",N),r.off("selectionUpdate",N)}}},[r]);const y=()=>{x&&i(!0)},_=()=>{const N=`<iframe src="${p.src}" style="width:${p.width}; height: ${p.height}; ${p.style}" title="${p.title}" allow="${p.allow}" sandbox="${p.sandbox}"></iframe>`;navigator.clipboard.writeText(N)},D=()=>{h.current&&(d?document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen():h.current.requestFullscreen?h.current.requestFullscreen():h.current.webkitRequestFullscreen?h.current.webkitRequestFullscreen():h.current.mozRequestFullScreen?h.current.mozRequestFullScreen():h.current.msRequestFullscreen&&h.current.msRequestFullscreen())};S.useEffect(()=>{const N=()=>{const z=!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement);f(z)};return document.addEventListener("fullscreenchange",N),document.addEventListener("webkitfullscreenchange",N),document.addEventListener("mozfullscreenchange",N),document.addEventListener("MSFullscreenChange",N),()=>{document.removeEventListener("fullscreenchange",N),document.removeEventListener("webkitfullscreenchange",N),document.removeEventListener("mozfullscreenchange",N),document.removeEventListener("MSFullscreenChange",N)}},[]);const E=N=>{const O=new DOMParser().parseFromString(N,"text/html").querySelector("iframe");if(O){const L=O.getAttribute("src")||"",j={src:L,width:O.getAttribute("width")||"100%",height:O.getAttribute("height")||"500px",title:O.getAttribute("title")||"",allow:O.getAttribute("allow")||"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",sandbox:O.getAttribute("sandbox")||b(L),style:O.getAttribute("style")||""};return g(j),!0}return!1},B=()=>{E(c)?(l("simple"),u("")):alert("Invalid iframe HTML code. Please check your input.")};return s?a.jsx(Y.NodeViewWrapper,{className:"iframe-extension-editing",children:a.jsxs("div",{className:"border-2 border-blue-500 rounded-lg p-4 bg-blue-50",children:[a.jsxs("div",{className:"flex gap-2 mb-4",children:[a.jsx(q,{onClick:()=>l("simple"),size:"sm",variant:o==="simple"?"default":"outline",className:"flex-1",children:"Simple Mode"}),a.jsx(q,{onClick:()=>l("advanced"),size:"sm",variant:o==="advanced"?"default":"outline",className:"flex-1",children:"Advanced Mode"})]}),o==="simple"?a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Source URL"}),a.jsx("input",{type:"url",value:p.src,onChange:N=>m(N.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"https://example.com/embed"}),a.jsx("div",{className:"text-xs text-gray-600 mt-1",children:"Sandbox attributes are automatically configured based on the URL for optimal compatibility."})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Width"}),a.jsx("input",{type:"text",value:p.width,onChange:N=>g({...p,width:N.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"100%"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Height"}),a.jsx("input",{type:"text",value:p.height,onChange:N=>g({...p,height:N.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"500px"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Title"}),a.jsx("input",{type:"text",value:p.title,onChange:N=>g({...p,title:N.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"Embedded Content"})]})]}):a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Paste your iframe HTML code"}),a.jsx("textarea",{value:c,onChange:N=>u(N.target.value),className:"w-full h-32 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 font-mono text-sm",placeholder:'<iframe src="https://example.com/embed" style="width:100%; height:500px; border:0; border-radius:4px; overflow:hidden;" title="Example" allow="..." sandbox="..."></iframe>'})]}),a.jsx("div",{className:"text-xs text-gray-600",children:"Paste your complete iframe HTML code here. The extension will automatically extract the attributes."}),a.jsxs("div",{className:"border-t pt-3",children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Sandbox Attributes (Advanced)"}),a.jsx("input",{type:"text",value:p.sandbox,onChange:N=>g({...p,sandbox:N.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 font-mono text-xs",placeholder:"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation"}),a.jsx("div",{className:"text-xs text-gray-600 mt-1",children:"Override automatic sandbox configuration if needed. Common values: allow-scripts, allow-same-origin, allow-forms, allow-popups"})]})]}),a.jsxs("div",{className:"flex gap-2 mt-4",children:[o==="advanced"&&a.jsx(q,{onClick:B,size:"sm",className:"bg-green-600 hover:bg-green-700",children:"Parse & Apply"}),a.jsx(q,{onClick:v,size:"sm",className:"bg-blue-600 hover:bg-blue-700",children:"Save"}),a.jsx(q,{onClick:T,size:"sm",variant:"outline",children:"Cancel"})]})]})}):a.jsx(Y.NodeViewWrapper,{className:"iframe-extension",children:a.jsxs("div",{ref:h,className:"relative group",children:[a.jsx("iframe",{src:t.attrs.src,...d?{}:{width:t.attrs.width,height:t.attrs.height},title:t.attrs.title,allow:t.attrs.allow,sandbox:t.attrs.sandbox,style:{...Vs(t.attrs.style),...d?{width:"100vw",height:"100vh"}:{width:t.attrs.width,height:t.attrs.height}},className:d?"rounded-lg iframe-fullscreen":"rounded-lg"}),x&&a.jsx("div",{className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity duration-200 bg-white/90 backdrop-blur-sm rounded-lg p-1 shadow-lg border",children:a.jsxs("div",{className:"flex gap-1",children:[a.jsx(q,{onClick:y,size:"sm",variant:"ghost",className:"h-8 w-8 p-0",title:"Edit iframe",children:a.jsx(k.Settings,{className:"h-4 w-4"})}),a.jsx(q,{onClick:()=>window.open(t.attrs.src,"_blank"),size:"sm",variant:"ghost",className:"h-8 w-8 p-0",title:"Open in new tab",children:a.jsx(k.ExternalLink,{className:"h-4 w-4"})}),a.jsx(q,{onClick:_,size:"sm",variant:"ghost",className:"h-8 w-8 p-0",title:"Copy iframe code",children:a.jsx(k.Copy,{className:"h-4 w-4"})}),a.jsx(q,{onClick:()=>{x&&n()},size:"sm",variant:"ghost",className:"h-8 w-8 p-0 text-red-600 hover:text-red-700",title:"Delete iframe",children:a.jsx(k.Trash2,{className:"h-4 w-4"})})]})}),a.jsx("div",{className:"absolute hidden md:block md:bottom-20 md:right-4 bg-white/90 rounded-lg p-1 shadow-lg border z-10 cursor-pointer",children:a.jsx(q,{onClick:D,size:"sm",variant:"ghost",className:"h-6 w-8 p-0 cursor-pointer",title:d?"Exit fullscreen":"Enter fullscreen",children:d?a.jsx(k.Minimize,{className:"h-4 w-4"}):a.jsx(k.Maximize,{className:"h-4 w-4"})})}),x&&t.attrs.src&&a.jsxs("div",{className:"mt-2 text-xs text-gray-500 bg-gray-100 px-2 py-1 rounded",children:["Source: ",t.attrs.src]})]})})},Vs=t=>{const e={};return t&&t.split(";").forEach(n=>{const[r,s]=n.split(":").map(i=>i.trim());if(r&&s){const i=r.replace(/-([a-z])/g,o=>o[1].toUpperCase());e[i]=s}}),e},In=V.Node.create({name:"iframe",group:"block",atom:!0,addOptions(){return{readOnly:!1}},addAttributes(){return{src:{default:"",parseHTML:t=>t.getAttribute("src")||"",renderHTML:t=>({src:t.src})},width:{default:"100%",parseHTML:t=>t.getAttribute("width")||"100%",renderHTML:t=>({width:t.width})},height:{default:"500px",parseHTML:t=>t.getAttribute("height")||"500px",renderHTML:t=>({height:t.height})},title:{default:"",parseHTML:t=>t.getAttribute("title")||"",renderHTML:t=>({title:t.title})},allow:{default:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",parseHTML:t=>t.getAttribute("allow")||"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",renderHTML:t=>({allow:t.allow})},sandbox:{default:"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation",parseHTML:t=>t.getAttribute("sandbox")||"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation",renderHTML:t=>({sandbox:t.sandbox})},style:{default:"",parseHTML:t=>t.getAttribute("style")||"",renderHTML:t=>({style:t.style})}}},parseHTML(){return[{tag:"iframe"}]},renderHTML({HTMLAttributes:t}){return["iframe",V.mergeAttributes(t)]},addNodeView(){return Y.ReactNodeViewRenderer(qs)},addCommands(){return{insertIframe:(t={})=>({commands:e})=>e.insertContent({type:this.name,attrs:{src:t.src||"",width:t.width||"100%",height:t.height||"500px",title:t.title||"Embedded Content",allow:t.allow||"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",sandbox:t.sandbox||"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation",style:t.style||""}})}}}),Et=`<div class="demo">
|
|
22
|
+
<%s key={someKey} {...props} />`,B,ee,le,ee),I[ee+B]=!0)}if(ee=null,R!==void 0&&(n(R),ee=""+R),a(E)&&(n(E.key),ee=""+E.key),"key"in E){R={};for(var Ne in E)Ne!=="key"&&(R[Ne]=E[Ne])}else R=E;return ee&&l(R,typeof h=="function"?h.displayName||h.name||"Unknown":h),d(h,ee,X,Z,s(),R,ae,fe)}function f(h){typeof h=="object"&&h!==null&&h.$$typeof===p&&h._store&&(h._store.validated=1)}var m=N,p=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),g=Symbol.for("react.strict_mode"),_=Symbol.for("react.profiler"),C=Symbol.for("react.consumer"),y=Symbol.for("react.context"),T=Symbol.for("react.forward_ref"),x=Symbol.for("react.suspense"),k=Symbol.for("react.suspense_list"),M=Symbol.for("react.memo"),z=Symbol.for("react.lazy"),D=Symbol.for("react.activity"),S=Symbol.for("react.client.reference"),L=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,v=Object.prototype.hasOwnProperty,U=Array.isArray,P=console.createTask?console.createTask:function(){return null};m={react_stack_bottom_frame:function(h){return h()}};var J,G={},Y=m.react_stack_bottom_frame.bind(m,i)(),A=P(r(i)),I={};qe.Fragment=w,qe.jsx=function(h,E,R,B,Z){var X=1e4>L.recentlyCreatedOwnerStacks++;return u(h,E,R,!1,B,Z,X?Error("react-stack-top-frame"):Y,X?P(r(h)):A)},qe.jsxs=function(h,E,R,B,Z){var X=1e4>L.recentlyCreatedOwnerStacks++;return u(h,E,R,!0,B,Z,X?Error("react-stack-top-frame"):Y,X?P(r(h)):A)}})()),qe}var ln;function ys(){return ln||(ln=1,process.env.NODE_ENV==="production"?tt.exports=ws():tt.exports=xs()),tt.exports}var o=ys();const cn=ns.configure({codeBlock:!1}),vs=_t.Table.configure({resizable:!0}),Es=_t.Table.extend({addNodeView(){return({node:t})=>new _t.TableView(t,this.options.cellMinWidth)}}).configure({resizable:!1}),dn=rs.configure({inline:!1,allowBase64:!1,HTMLAttributes:{class:"max-w-full h-auto rounded-lg shadow-sm"}}),un=ss.configure({openOnClick:!1,autolink:!0,defaultProtocol:"https"}),fn=is.TextStyle,pn=os.configure({types:["textStyle"]}),hn=as.configure({multicolor:!0}),Ns=({node:t})=>{const[e,n]=N.useState(!1),r=N.useRef(null);N.useEffect(()=>()=>{r.current&&clearTimeout(r.current)},[]);const s=()=>{navigator.clipboard.writeText(t.textContent).then(()=>{n(!0),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>n(!1),2e3)}).catch(()=>{})};return o.jsxs(q.NodeViewWrapper,{className:"code-block-wrapper",children:[o.jsx("button",{type:"button",className:"copy-btn",onClick:s,"aria-label":e?"Copied!":"Copy code",title:e?"Copied!":"Copy code",children:e?o.jsx(O.Check,{className:"h-4 w-4"}):o.jsx(O.Copy,{className:"h-4 w-4"})}),o.jsx("pre",{children:o.jsx(q.NodeViewContent,{style:{whiteSpace:"pre",wordBreak:"normal",overflowWrap:"normal"}})})]})},Cs=t=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:t.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:t.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),Ss=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],Ts=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],_s=[...Ss,...Ts],ks=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),As=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),Os=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),Ms=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function Is(t){const e=t.regex,n=Cs(t),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},s="and or not only",i=/@-?\w[\w]*(-\w+)*/,a="[a-zA-Z-][a-zA-Z0-9_-]*",l=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[n.BLOCK_COMMENT,r,n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+a,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+As.join("|")+")"},{begin:":(:)?("+Os.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+Ms.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,...l,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...l,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:e.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:i},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:s,attribute:ks.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...l,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+_s.join("|")+")\\b"}]}}const mn="[A-Za-z$_][0-9A-Za-z$_]*",Rs=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],Ls=["true","false","null","undefined","NaN","Infinity"],gn=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],bn=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],wn=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],js=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],Ds=[].concat(wn,gn,bn);function Ps(t){const e=t.regex,n=(A,{after:I})=>{const h="</"+A[0].slice(1);return A.input.indexOf(h,I)!==-1},r=mn,s={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,a={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(A,I)=>{const h=A[0].length+A.index,E=A.input[h];if(E==="<"||E===","){I.ignoreMatch();return}E===">"&&(n(A,{after:h})||I.ignoreMatch());let R;const B=A.input.substring(h);if(R=B.match(/^\s*=/)){I.ignoreMatch();return}if((R=B.match(/^\s+extends\s+/))&&R.index===0){I.ignoreMatch();return}}},l={$pattern:mn,keyword:Rs,literal:Ls,built_in:Ds,"variable.language":js},c="[0-9](_?[0-9])*",d=`\\.(${c})`,u="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",f={className:"number",variants:[{begin:`(\\b(${u})((${d})|\\.)?|(${d}))[eE][+-]?(${c})\\b`},{begin:`\\b(${u})\\b((${d})\\b|\\.)?|(${d})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},m={className:"subst",begin:"\\$\\{",end:"\\}",keywords:l,contains:[]},p={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,m],subLanguage:"xml"}},b={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,m],subLanguage:"css"}},w={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,m],subLanguage:"graphql"}},g={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,m]},C={className:"comment",variants:[t.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),t.C_BLOCK_COMMENT_MODE,t.C_LINE_COMMENT_MODE]},y=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,p,b,w,g,{match:/\$\d+/},f];m.contains=y.concat({begin:/\{/,end:/\}/,keywords:l,contains:["self"].concat(y)});const T=[].concat(C,m.contains),x=T.concat([{begin:/(\s*)\(/,end:/\)/,keywords:l,contains:["self"].concat(T)}]),k={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:x},M={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,e.concat(r,"(",e.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},z={relevance:0,match:e.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...gn,...bn]}},D={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},S={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[k],illegal:/%/},L={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function v(A){return e.concat("(?!",A.join("|"),")")}const U={match:e.concat(/\b/,v([...wn,"super","import"].map(A=>`${A}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},P={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},J={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},k]},G="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",Y={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(G)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[k]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:x,CLASS_REFERENCE:z},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),D,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,p,b,w,g,C,{match:/\$\d+/},f,z,{scope:"attr",match:r+e.lookahead(":"),relevance:0},Y,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[C,t.REGEXP_MODE,{className:"function",begin:G,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:t.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:x}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:i},{begin:a.begin,"on:begin":a.isTrulyOpeningTag,end:a.end}],subLanguage:"xml",contains:[{begin:a.begin,end:a.end,skip:!0,contains:["self"]}]}]},S,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[k,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},P,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[k]},U,L,M,J,{match:/\$[(.]/}]}}const nt="[A-Za-z$_][0-9A-Za-z$_]*",xn=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],yn=["true","false","null","undefined","NaN","Infinity"],vn=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],En=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Nn=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Cn=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],Sn=[].concat(Nn,vn,En);function Bs(t){const e=t.regex,n=(A,{after:I})=>{const h="</"+A[0].slice(1);return A.input.indexOf(h,I)!==-1},r=nt,s={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,a={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(A,I)=>{const h=A[0].length+A.index,E=A.input[h];if(E==="<"||E===","){I.ignoreMatch();return}E===">"&&(n(A,{after:h})||I.ignoreMatch());let R;const B=A.input.substring(h);if(R=B.match(/^\s*=/)){I.ignoreMatch();return}if((R=B.match(/^\s+extends\s+/))&&R.index===0){I.ignoreMatch();return}}},l={$pattern:nt,keyword:xn,literal:yn,built_in:Sn,"variable.language":Cn},c="[0-9](_?[0-9])*",d=`\\.(${c})`,u="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",f={className:"number",variants:[{begin:`(\\b(${u})((${d})|\\.)?|(${d}))[eE][+-]?(${c})\\b`},{begin:`\\b(${u})\\b((${d})\\b|\\.)?|(${d})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},m={className:"subst",begin:"\\$\\{",end:"\\}",keywords:l,contains:[]},p={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,m],subLanguage:"xml"}},b={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,m],subLanguage:"css"}},w={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,m],subLanguage:"graphql"}},g={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,m]},C={className:"comment",variants:[t.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),t.C_BLOCK_COMMENT_MODE,t.C_LINE_COMMENT_MODE]},y=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,p,b,w,g,{match:/\$\d+/},f];m.contains=y.concat({begin:/\{/,end:/\}/,keywords:l,contains:["self"].concat(y)});const T=[].concat(C,m.contains),x=T.concat([{begin:/(\s*)\(/,end:/\)/,keywords:l,contains:["self"].concat(T)}]),k={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:x},M={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,e.concat(r,"(",e.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},z={relevance:0,match:e.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...vn,...En]}},D={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},S={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[k],illegal:/%/},L={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function v(A){return e.concat("(?!",A.join("|"),")")}const U={match:e.concat(/\b/,v([...Nn,"super","import"].map(A=>`${A}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},P={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},J={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},k]},G="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",Y={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(G)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[k]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:x,CLASS_REFERENCE:z},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),D,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,p,b,w,g,C,{match:/\$\d+/},f,z,{scope:"attr",match:r+e.lookahead(":"),relevance:0},Y,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[C,t.REGEXP_MODE,{className:"function",begin:G,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:t.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:x}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:i},{begin:a.begin,"on:begin":a.isTrulyOpeningTag,end:a.end}],subLanguage:"xml",contains:[{begin:a.begin,end:a.end,skip:!0,contains:["self"]}]}]},S,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[k,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},P,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[k]},U,L,M,J,{match:/\$[(.]/}]}}function zs(t){const e=t.regex,n=Bs(t),r=nt,s=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],i={begin:[/namespace/,/\s+/,t.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},a={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:s},contains:[n.exports.CLASS_REFERENCE]},l={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},c=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],d={$pattern:nt,keyword:xn.concat(c),literal:yn,built_in:Sn.concat(s),"variable.language":Cn},u={className:"meta",begin:"@"+r},f=(w,g,_)=>{const C=w.contains.findIndex(y=>y.label===g);if(C===-1)throw new Error("can not find mode to replace");w.contains.splice(C,1,_)};Object.assign(n.keywords,d),n.exports.PARAMS_CONTAINS.push(u);const m=n.contains.find(w=>w.scope==="attr"),p=Object.assign({},m,{match:e.concat(r,e.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,m,p]),n.contains=n.contains.concat([u,i,a,p]),f(n,"shebang",t.SHEBANG()),f(n,"use_strict",l);const b=n.contains.find(w=>w.label==="func.def");return b.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function Us(t){const e=t.regex,n=e.concat(/[\p{L}_]/u,e.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,s={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},i={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},a=t.inherit(i,{begin:/\(/,end:/\)/}),l=t.inherit(t.APOS_STRING_MODE,{className:"string"}),c=t.inherit(t.QUOTE_STRING_MODE,{className:"string"}),d={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[s]},{begin:/'/,end:/'/,contains:[s]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[i,c,l,a,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[i,a,c,l]}]}]},t.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},s,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[c]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[d],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[d],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:e.concat(/</,e.lookahead(e.concat(n,e.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:d}]},{className:"tag",begin:e.concat(/<\//,e.lookahead(e.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function Fs(t){const e=t.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],l={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},c={className:"meta",begin:/^(>>>|\.\.\.) /},d={className:"subst",begin:/\{/,end:/\}/,keywords:l,illegal:/#/},u={begin:/\{\{/,relevance:0},f={className:"string",contains:[t.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,c],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,c],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,c,u,d]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,c,u,d]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[t.BACKSLASH_ESCAPE,u,d]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,u,d]},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},m="[0-9](_?[0-9])*",p=`(\\b(${m}))?\\.(${m})|\\b(${m})\\.`,b=`\\b|${r.join("|")}`,w={className:"number",relevance:0,variants:[{begin:`(\\b(${m})|(${p}))[eE][+-]?(${m})[jJ]?(?=${b})`},{begin:`(${p})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${b})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${b})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${b})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${b})`},{begin:`\\b(${m})[jJ](?=${b})`}]},g={className:"comment",begin:e.lookahead(/# type:/),end:/$/,keywords:l,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},_={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:["self",c,w,f,t.HASH_COMMENT_MODE]}]};return d.contains=[f,w,c],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:l,illegal:/(<\/|\?)|=>/,contains:[c,w,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},f,g,t.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[_]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[w,_,f]}]}}var De="[0-9](_*[0-9])*",rt=`\\.(${De})`,st="[0-9a-fA-F](_*[0-9a-fA-F])*",Tn={className:"number",variants:[{begin:`(\\b(${De})((${rt})|\\.)?|(${rt}))[eE][+-]?(${De})[fFdD]?\\b`},{begin:`\\b(${De})((${rt})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${rt})[fFdD]?\\b`},{begin:`\\b(${De})[fFdD]\\b`},{begin:`\\b0[xX]((${st})\\.?|(${st})?\\.(${st}))[pP][+-]?(${De})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${st})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function _n(t,e,n){return n===-1?"":t.replace(e,r=>_n(t,e,n-1))}function Hs(t){const e=t.regex,n="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",r=n+_n("(?:<"+n+"~~~(?:\\s*,\\s*"+n+"~~~)*>)?",/~~~/g,2),c={keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed","yield","permits","goto","when"],literal:["false","true","null"],type:["char","boolean","long","float","int","byte","short","double"],built_in:["super","this"]},d={className:"meta",begin:"@"+n,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},u={className:"params",begin:/\(/,end:/\)/,keywords:c,relevance:0,contains:[t.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:c,illegal:/<\/|#/,contains:[t.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[t.BACKSLASH_ESCAPE]},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,n],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{begin:[e.concat(/(?!else)/,n),/\s+/,n,/\s+/,/=(?!=)/],className:{1:"type",3:"variable",5:"operator"}},{begin:[/record/,/\s+/,n],className:{1:"keyword",3:"title.class"},contains:[u,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{beginKeywords:"new throw return else",relevance:0},{begin:["(?:"+r+"\\s+)",t.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{2:"title.function"},keywords:c,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:c,relevance:0,contains:[d,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,Tn,t.C_BLOCK_COMMENT_MODE]},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},Tn,d]}}function $s(t){const e=t.regex,n=t.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",s="[a-zA-Z_]\\w*::",a="("+r+"|"+e.optional(s)+"[a-zA-Z_]\\w*"+e.optional("<[^<>]+>")+")",l={className:"type",variants:[{begin:"\\b[a-z\\d_]*_t\\b"},{match:/\batomic_[a-z]{3,6}\b/}]},d={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[t.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},t.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},u={className:"number",variants:[{match:/\b(0b[01']+)/},{match:/(-?)\b([\d']+(\.[\d']*)?|\.[\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)/},{match:/(-?)\b(0[xX][a-fA-F0-9]+(?:'[a-fA-F0-9]+)*(?:\.[a-fA-F0-9]*(?:'[a-fA-F0-9]*)*)?(?:[pP][-+]?[0-9]+)?(l|L)?(u|U)?)/},{match:/(-?)\b\d+(?:'\d+)*(?:\.\d*(?:'\d*)*)?(?:[eE][-+]?\d+)?/}],relevance:0},f={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef elifdef elifndef include"},contains:[{begin:/\\\n/,relevance:0},t.inherit(d,{className:"string"}),{className:"string",begin:/<.*?>/},n,t.C_BLOCK_COMMENT_MODE]},m={className:"title",begin:e.optional(s)+t.IDENT_RE,relevance:0},p=e.optional(s)+t.IDENT_RE+"\\s*\\(",g={keyword:["asm","auto","break","case","continue","default","do","else","enum","extern","for","fortran","goto","if","inline","register","restrict","return","sizeof","typeof","typeof_unqual","struct","switch","typedef","union","volatile","while","_Alignas","_Alignof","_Atomic","_Generic","_Noreturn","_Static_assert","_Thread_local","alignas","alignof","noreturn","static_assert","thread_local","_Pragma"],type:["float","double","signed","unsigned","int","short","long","char","void","_Bool","_BitInt","_Complex","_Imaginary","_Decimal32","_Decimal64","_Decimal96","_Decimal128","_Decimal64x","_Decimal128x","_Float16","_Float32","_Float64","_Float128","_Float32x","_Float64x","_Float128x","const","static","constexpr","complex","bool","imaginary"],literal:"true false NULL",built_in:"std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr"},_=[f,l,n,t.C_BLOCK_COMMENT_MODE,u,d],C={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:g,contains:_.concat([{begin:/\(/,end:/\)/,keywords:g,contains:_.concat(["self"]),relevance:0}]),relevance:0},y={begin:"("+a+"[\\*&\\s]+)+"+p,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:g,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:g,relevance:0},{begin:p,returnBegin:!0,contains:[t.inherit(m,{className:"title.function"})],relevance:0},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:g,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,d,u,l,{begin:/\(/,end:/\)/,keywords:g,relevance:0,contains:["self",n,t.C_BLOCK_COMMENT_MODE,d,u,l]}]},l,n,t.C_BLOCK_COMMENT_MODE,f]};return{name:"C",aliases:["h"],keywords:g,disableAutodetect:!0,illegal:"</",contains:[].concat(C,y,_,[f,{begin:t.IDENT_RE+"::",keywords:g},{className:"class",beginKeywords:"enum class struct union",end:/[{;:<>=]/,contains:[{beginKeywords:"final class struct"},t.TITLE_MODE]}]),exports:{preprocessor:f,strings:d,keywords:g}}}function Ks(t){const e=t.regex,n=t.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",s="[a-zA-Z_]\\w*::",a="(?!struct)("+r+"|"+e.optional(s)+"[a-zA-Z_]\\w*"+e.optional("<[^<>]+>")+")",l={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},d={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[t.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},t.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},u={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},f={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},t.inherit(d,{className:"string"}),{className:"string",begin:/<.*?>/},n,t.C_BLOCK_COMMENT_MODE]},m={className:"title",begin:e.optional(s)+t.IDENT_RE,relevance:0},p=e.optional(s)+t.IDENT_RE+"\\s*\\(",b=["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],w=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],g=["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"],_=["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"],T={type:w,keyword:b,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:g},x={className:"function.dispatch",relevance:0,keywords:{_hint:_},begin:e.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,t.IDENT_RE,e.lookahead(/(<[^<>]+>|)\s*\(/))},k=[x,f,l,n,t.C_BLOCK_COMMENT_MODE,u,d],M={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:T,contains:k.concat([{begin:/\(/,end:/\)/,keywords:T,contains:k.concat(["self"]),relevance:0}]),relevance:0},z={className:"function",begin:"("+a+"[\\*&\\s]+)+"+p,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:T,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:T,relevance:0},{begin:p,returnBegin:!0,contains:[m],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[d,u]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:T,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,d,u,l,{begin:/\(/,end:/\)/,keywords:T,relevance:0,contains:["self",n,t.C_BLOCK_COMMENT_MODE,d,u,l]}]},l,n,t.C_BLOCK_COMMENT_MODE,f]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:T,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(M,z,x,k,[f,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",end:">",keywords:T,contains:["self",l]},{begin:t.IDENT_RE+"::",keywords:T},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}function qs(t){const e=t.regex,n=t.COMMENT("--","$"),r={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},s={begin:/"/,end:/"/,contains:[{match:/""/}]},i=["true","false","unknown"],a=["double precision","large object","with timezone","without timezone"],l=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],c=["add","asc","collation","desc","final","first","last","view"],d=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],u=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],f=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],m=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],p=u,b=[...d,...c].filter(x=>!u.includes(x)),w={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},g={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},_={match:e.concat(/\b/,e.either(...p),/\s*\(/),relevance:0,keywords:{built_in:p}};function C(x){return e.concat(/\b/,e.either(...x.map(k=>k.replace(/\s+/,"\\s+"))),/\b/)}const y={scope:"keyword",match:C(m),relevance:0};function T(x,{exceptions:k,when:M}={}){const z=M;return k=k||[],x.map(D=>D.match(/\|\d+$/)||k.includes(D)?D:z(D)?`${D}|0`:D)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:T(b,{when:x=>x.length<3}),literal:i,type:l,built_in:f},contains:[{scope:"type",match:C(a)},y,_,w,r,s,t.C_NUMBER_MODE,t.C_BLOCK_COMMENT_MODE,n,g]}}const kn=K.Mark.create({name:"codeBlockBg",addOptions(){return{multicolor:!0,HTMLAttributes:{}}},inclusive:!1,addAttributes(){return{color:{default:null,parseHTML:t=>t.getAttribute("data-background-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-background-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}},parseHTML(){return[{tag:"span[data-background-color]",getAttrs:t=>typeof t=="string"?!1:{color:t.getAttribute("data-background-color")}}]},renderHTML({HTMLAttributes:t,mark:e}){const n=e.attrs?.color||t["data-background-color"];return n?["span",{"data-background-color":n,style:`background-color: ${n}; color: inherit`},0]:["span",{},0]},addCommands(){return{setCodeBlockBg:t=>({commands:e})=>e.setMark(this.name,{color:t}),toggleCodeBlockBg:t=>({commands:e})=>e.toggleMark(this.name,{color:t}),unsetCodeBlockBg:()=>({commands:t})=>t.unsetMark(this.name)}}}),be=rn.createLowlight(rn.all);be.register("html",Us),be.register("css",Is),be.register("js",Ps),be.register("ts",zs),be.register("java",Hs),be.register("c",$s),be.register("cpp",Ks),be.register("python",Fs),be.register("sql",qs);const An=ls.extend({marks(){return"codeBlockBg"},addNodeView(){return q.ReactNodeViewRenderer(Ns)}}).configure({lowlight:be}),On=cs,Mn=ds,In=us,Rn=fs;function Vs({node:t,updateAttributes:e,editor:n}){const[r,s]=N.useState(t.attrs?.open??!0),[i,a]=N.useState(!1),[l,c]=N.useState(t.attrs?.title||"Output"),d=N.useRef(null),u=n?.isEditable??!1;N.useEffect(()=>{i&&d.current&&(d.current.focus(),d.current.select())},[i]);const f=()=>{a(!1),e({title:l,open:r})},m=g=>{g.key==="Enter"?f():g.key==="Escape"&&(c(t.attrs?.title||"Output"),a(!1))},p=()=>{const g=!r;s(g),e({title:l,open:g})},b=()=>{u&&n&&confirm("Are you sure you want to delete this accordion?")&&n.chain().focus().deleteNode("accordion").run()},w=g=>{if(!u||!n)return;const{selection:_}=n.state,{$anchor:C}=_;if(g.key==="Enter"&&!g.shiftKey&&C.nodeBefore?.type.name==="accordion"){g.preventDefault(),g.stopPropagation();const y=C.nodeBefore;if(y&&y.childCount>0){const T=y.lastChild;if(T&&T.content.size>0){let x=-1;if(n.state.doc.descendants((k,M)=>{if(k.type.name==="accordionItem")return x=M,!1}),x!==-1){const k=x+T.nodeSize-2;n.chain().focus().setTextSelection(k).run()}}else{let x=-1;n.state.doc.descendants((k,M)=>{if(k.type.name==="accordionItem")return x=M,!1}),x!==-1&&n.chain().focus().setTextSelection(x+1).run()}}return}if((g.key==="Backspace"||g.key==="Delete")&&!g.shiftKey){if(C.nodeBefore?.type.name==="accordion"){g.preventDefault(),g.stopPropagation();return}if(C.nodeAfter?.type.name==="accordion"){g.preventDefault(),g.stopPropagation();return}if(C.parent.type.name==="accordionItem"){const y=C.parent,T=C.parentOffset===0,x=y.content.content.some(k=>k.type.name==="paragraph"?k.content.size>0:!0);if(T&&!x&&g.key==="Backspace"){g.preventDefault(),g.stopPropagation();return}}if(C.parent.type.name==="accordion"&&!C.parent.content.content.some(x=>x.type.name==="accordionItem"?x.content.content.some(k=>k.type.name==="paragraph"?k.content.size>0:!0):!0)){g.preventDefault(),g.stopPropagation();return}}};return o.jsxs(q.NodeViewWrapper,{className:"accordion border border-gray-200 rounded-lg mb-3 overflow-hidden",onKeyDown:w,children:[o.jsx("div",{className:"accordion-header bg-gray-50 border-b border-gray-200",onClick:p,children:o.jsxs("div",{className:"flex items-center gap-2 px-1",children:[o.jsx("button",{type:"button",onClick:g=>{g.stopPropagation(),p()},className:"flex items-center justify-center w-6 h-6 text-gray-600 hover:text-gray-800",title:r?"Collapse":"Expand",children:o.jsx("span",{className:`cursor-pointer transition-transform duration-200 ${r?"rotate-90":""}`,children:"▶"})}),i?o.jsx("input",{ref:d,type:"text",value:l,onChange:g=>c(g.target.value),onBlur:f,onKeyDown:m,className:"bg-transparent border-b border-gray-300 outline-none font-medium text-gray-800 flex-1 py-1",placeholder:"Enter accordion title..."}):o.jsx("div",{onClick:u?g=>{g.stopPropagation(),a(!0)}:void 0,className:`font-medium text-gray-800 flex-1 py-1 ${u?"cursor-text hover:text-blue-600":"cursor-pointer"}`,title:u?"Click to edit title":void 0,children:l}),u&&o.jsx("button",{type:"button",onClick:g=>{g.stopPropagation(),b()},className:"px-2 py-1 text-red-600 hover:text-red-700 hover:bg-red-50 transition-colors rounded",title:"Delete accordion",children:o.jsx(O.Trash2,{className:"h-4 w-4"})})]})}),r&&o.jsx("div",{className:"accordion-content p-3 bg-white",children:o.jsx(q.NodeViewContent,{})})]})}const Ln=K.Node.create({name:"accordion",group:"block",content:"accordionItem+",defining:!0,isolating:!0,addAttributes(){return{title:{default:"Output",parseHTML:t=>t.getAttribute("data-title"),renderHTML:t=>t.title?{"data-title":t.title}:{}},open:{default:!0,parseHTML:t=>t.getAttribute("data-open")==="true",renderHTML:t=>({"data-open":t.open})}}},parseHTML(){return[{tag:'div[data-type="accordion"]'}]},renderHTML({HTMLAttributes:t}){return["div",K.mergeAttributes(t,{"data-type":"accordion"}),0]},addNodeView(){return q.ReactNodeViewRenderer(Vs)},addKeyboardShortcuts(){return{Backspace:({editor:t})=>{const{selection:e}=t.state,{$anchor:n}=e;return n.nodeBefore?.type.name==="accordion"||n.parent.type.name==="accordion"&&!n.parent.content.content.some(i=>i.type.name==="accordionItem"?i.content.content.some(a=>a.type.name==="paragraph"?a.content.size>0:!0):!0)},Delete:({editor:t})=>{const{selection:e}=t.state,{$anchor:n}=e;return n.nodeAfter?.type.name==="accordion"||n.parent.type.name==="accordion"&&!n.parent.content.content.some(i=>i.type.name==="accordionItem"?i.content.content.some(a=>a.type.name==="paragraph"?a.content.size>0:!0):!0)}}},addCommands(){return{insertAccordion:()=>({commands:t})=>t.insertContent({type:this.name,content:[{type:"accordionItem",content:[{type:"paragraph",content:[{type:"text",text:"Accordion Item 1"}]}]}]})}}}),jn=K.Node.create({name:"accordionItem",group:"block",content:"block+",defining:!0,isolating:!0,parseHTML(){return[{tag:'div[data-type="accordion-item"]'}]},renderHTML({HTMLAttributes:t}){return["div",K.mergeAttributes(t,{"data-type":"accordion-item"}),0]},addKeyboardShortcuts(){return{Enter:({editor:t})=>{const{selection:e}=t.state,{$anchor:n}=e;return n.parent.type.name==="accordionItem",!1},Backspace:({editor:t})=>{const{selection:e}=t.state,{$anchor:n}=e;if(n.parent.type.name==="accordionItem"&&n.parentOffset===0&&n.depth>0){const r=n.start(n.depth);if(n.pos<=r+1)return!0}return!1}}}});function Ws({node:t,updateAttributes:e,editor:n}){const[r,s]=N.useState(t.attrs?.activeTab??0),[i,a]=N.useState(null),[l,c]=N.useState(""),d=N.useRef(null),u=t.content?.content||[],f=n?.isEditable??!1;N.useEffect(()=>{const y=t.attrs?.activeTab??0;y!==r&&s(y)},[t.attrs?.activeTab]),N.useEffect(()=>{i!==null&&d.current&&(d.current.focus(),d.current.select())},[i]);const m=y=>{s(y),e({...t.attrs,activeTab:y})},p=(y,T)=>{f&&(a(y),c(T))},b=()=>{f&&n&&confirm("Are you sure you want to delete this tabs component?")&&n.chain().focus().deleteNode("tabs").run()},w=()=>{if(i!==null&&u[i]&&n){let y=-1;n.state.doc.descendants((T,x)=>{if(T.type.name==="tabItem"&&T.attrs.tabIndex===i)return y=x,!1}),y!==-1&&n.chain().focus().command(({tr:T,dispatch:x})=>{if(x){const k=T.doc.nodeAt(y);k&&T.setNodeMarkup(y,void 0,{...k.attrs,title:l})}return!0}).run()}a(null),c("")},g=y=>{y.key==="Enter"?w():y.key==="Escape"&&(a(null),c(""))},_=y=>u[y]?.attrs?.title||`Tab ${y+1}`,C=y=>{if(!f||!n)return;const{selection:T}=n.state,{$anchor:x}=T;if(y.key==="Enter"&&!y.shiftKey&&x.nodeBefore?.type.name==="tabs"){y.preventDefault(),y.stopPropagation();const k=x.nodeBefore;if(k&&k.childCount>0){const M=k.lastChild;if(M&&M.content.size>0){let z=-1;if(n.state.doc.descendants((D,S)=>{if(D.type.name==="tabItem"&&D.attrs.tabIndex===k.childCount-1)return z=S,!1}),z!==-1){const D=z+M.nodeSize-2;n.chain().focus().setTextSelection(D).run()}}}return}if((y.key==="Backspace"||y.key==="Delete")&&!y.shiftKey){if(x.nodeBefore?.type.name==="tabs"){y.preventDefault(),y.stopPropagation();return}if(x.nodeAfter?.type.name==="tabs"){y.preventDefault(),y.stopPropagation();return}}};return o.jsxs(q.NodeViewWrapper,{className:"tabs-container border border-gray-200 rounded-lg mb-4 overflow-hidden","data-active-tab":r,onKeyDown:C,children:[o.jsx("div",{className:"tabs-header bg-gray-50 border-b border-gray-200",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("div",{className:"flex flex-1",children:u.map((y,T)=>o.jsx("button",{type:"button",onClick:()=>m(T),className:`flex-1 px-4 py-2 text-sm font-medium border-b-2 border-r border-gray-200 transition-colors relative cursor-pointer ${r===T?"border-blue-500 border-r-gray-200 text-blue-600 bg-white":"border-transparent border-r-gray-200 text-gray-500 hover:text-gray-700 hover:border-gray-300"} ${T===u.length-1?"border-r-0":""}`,children:i===T?o.jsx("input",{ref:d,type:"text",value:l,onChange:x=>c(x.target.value),onBlur:w,onKeyDown:g,className:"bg-transparent border-none outline-none text-center w-full",onClick:x=>x.stopPropagation()}):o.jsx("span",{onClick:f?x=>{x.stopPropagation(),p(T,_(T))}:void 0,className:`block w-full text-center ${f?"cursor-text":"cursor-pointer"}`,title:f?"Click to edit title":void 0,children:_(T)})},T))}),f&&o.jsx("button",{type:"button",onClick:b,className:"px-3 py-2 text-red-600 hover:text-red-700 hover:bg-red-50 transition-colors",title:"Delete tabs",children:o.jsx(O.Trash2,{className:"h-4 w-4"})})]})}),o.jsx("div",{className:"tabs-content",children:o.jsx(q.NodeViewContent,{className:"tab-content-wrapper","data-active-tab":r})})]})}function Js({node:t,editor:e}){const n=t.attrs?.tabIndex||0,r=e?.isEditable??!1,s=i=>{if(!r||!e)return;const{selection:a}=e.state,{$anchor:l}=a;if(i.key==="Enter"&&!i.shiftKey&&l.parent.type.name==="tabItem"){const c=l.parent;if(l.parentOffset===c.childCount)return}if(i.key==="Backspace"&&l.parent.type.name==="tabItem"){const c=l.parent;if(l.parentOffset===0&&c.childCount>0&&c.firstChild&&l.pos===l.start(l.depth))return}};return o.jsx(q.NodeViewWrapper,{className:"tab-item-content p-4","data-tab-index":n,onKeyDown:s,children:o.jsx(q.NodeViewContent,{})})}const Dn=K.Node.create({name:"tabs",group:"block",content:"tabItem+",defining:!0,isolating:!0,addAttributes(){return{activeTab:{default:0,parseHTML:t=>parseInt(t.getAttribute("data-active-tab")||"0"),renderHTML:t=>({"data-active-tab":t.activeTab})},tabCount:{default:2,parseHTML:t=>parseInt(t.getAttribute("data-tab-count")||"2"),renderHTML:t=>({"data-tab-count":t.tabCount})}}},parseHTML(){return[{tag:'div[data-type="tabs"]'}]},renderHTML({HTMLAttributes:t}){return["div",K.mergeAttributes(t,{"data-type":"tabs"}),0]},addNodeView(){return q.ReactNodeViewRenderer(Ws,{contentDOMElementTag:"div"})},addKeyboardShortcuts(){return{Backspace:({editor:t})=>{const{selection:e}=t.state,{$anchor:n}=e;return n.nodeBefore?.type.name==="tabs"},Delete:({editor:t})=>{const{selection:e}=t.state,{$anchor:n}=e;return n.nodeAfter?.type.name==="tabs"}}},addCommands(){return{insertTabs:(t={tabCount:2})=>({commands:e})=>{const n=Math.min(Math.max(t.tabCount||2,2),6),r=Array.from({length:n},(s,i)=>({type:"tabItem",attrs:{tabIndex:i,title:`Tab ${i+1}`},content:[{type:"paragraph",content:[{type:"text",text:`Content for Tab ${i+1}. This is unique content for this tab.`}]}]}));return e.insertContent({type:this.name,attrs:{activeTab:0,tabCount:n},content:r})}}}}),Pn=K.Node.create({name:"tabItem",group:"block",content:"block+",defining:!0,isolating:!0,addAttributes(){return{tabIndex:{default:0,parseHTML:t=>parseInt(t.getAttribute("data-tab-index")||"0"),renderHTML:t=>({"data-tab-index":t.tabIndex})},title:{default:"Tab",parseHTML:t=>t.getAttribute("data-title")||"Tab",renderHTML:t=>({"data-title":t.title})}}},parseHTML(){return[{tag:'div[data-type="tab-item"]'}]},renderHTML({HTMLAttributes:t}){return["div",K.mergeAttributes(t,{"data-type":"tab-item"}),0]},addNodeView(){return q.ReactNodeViewRenderer(Js,{contentDOMElementTag:"div"})},addKeyboardShortcuts(){return{Enter:()=>!1,Backspace:({editor:t})=>{const{selection:e}=t.state,{$anchor:n}=e;if(n.parent.type.name==="tabItem"&&n.parentOffset===0&&n.depth>0){const r=n.start(n.depth);if(n.pos<=r+1)return!0}return!1}}}});function Gs(...t){return gs.twMerge(ms.clsx(t))}const Ys=hs.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function $({className:t,variant:e,size:n,asChild:r=!1,...s}){const i=r?ps.Slot:"button";return o.jsx(i,{"data-slot":"button",className:Gs(Ys({variant:e,size:n,className:t})),...s})}const Zs=({node:t,updateAttributes:e,deleteNode:n,editor:r})=>{const[s,i]=N.useState(!1),[a,l]=N.useState("simple"),[c,d]=N.useState(""),[u,f]=N.useState(!1),m=N.useRef(null),[p,b]=N.useState({src:t.attrs.src||"",width:t.attrs.width||"100%",height:t.attrs.height||"500px",title:t.attrs.title||"",allow:t.attrs.allow||"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",sandbox:t.attrs.sandbox||"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation",style:t.attrs.style||""}),w=S=>{const L=S.toLowerCase();return L.includes("youtube.com")||L.includes("youtu.be")?"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation allow-popups-to-escape-sandbox":L.includes("codesandbox.io")||L.includes("stackblitz.com")?"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation allow-popups-to-escape-sandbox allow-top-navigation":"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation"},g=S=>{const L=w(S);b({...p,src:S,sandbox:L})},_=()=>{y&&(e(p),i(!1))},C=()=>{b({src:t.attrs.src||"",width:t.attrs.width||"100%",height:t.attrs.height||"500px",title:t.attrs.title||"",allow:t.attrs.allow||"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",sandbox:t.attrs.sandbox||"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation",style:t.attrs.style||""}),i(!1)},[y,T]=N.useState(r?.isEditable??!1);N.useEffect(()=>{if(r){const S=()=>{T(r.isEditable)};return S(),r.on("update",S),r.on("selectionUpdate",S),()=>{r.off("update",S),r.off("selectionUpdate",S)}}},[r]);const x=()=>{y&&i(!0)},k=()=>{const S=`<iframe src="${p.src}" style="width:${p.width}; height: ${p.height}; ${p.style}" title="${p.title}" allow="${p.allow}" sandbox="${p.sandbox}"></iframe>`;navigator.clipboard.writeText(S)},M=()=>{m.current&&(u?document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen():m.current.requestFullscreen?m.current.requestFullscreen():m.current.webkitRequestFullscreen?m.current.webkitRequestFullscreen():m.current.mozRequestFullScreen?m.current.mozRequestFullScreen():m.current.msRequestFullscreen&&m.current.msRequestFullscreen())};N.useEffect(()=>{const S=()=>{const L=!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement);f(L)};return document.addEventListener("fullscreenchange",S),document.addEventListener("webkitfullscreenchange",S),document.addEventListener("mozfullscreenchange",S),document.addEventListener("MSFullscreenChange",S),()=>{document.removeEventListener("fullscreenchange",S),document.removeEventListener("webkitfullscreenchange",S),document.removeEventListener("mozfullscreenchange",S),document.removeEventListener("MSFullscreenChange",S)}},[]);const z=S=>{const U=new DOMParser().parseFromString(S,"text/html").querySelector("iframe");if(U){const P=U.getAttribute("src")||"",J={src:P,width:U.getAttribute("width")||"100%",height:U.getAttribute("height")||"500px",title:U.getAttribute("title")||"",allow:U.getAttribute("allow")||"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",sandbox:U.getAttribute("sandbox")||w(P),style:U.getAttribute("style")||""};return b(J),!0}return!1},D=()=>{z(c)?(l("simple"),d("")):alert("Invalid iframe HTML code. Please check your input.")};return s?o.jsx(q.NodeViewWrapper,{className:"iframe-extension-editing",children:o.jsxs("div",{className:"border-2 border-blue-500 rounded-lg p-4 bg-blue-50",children:[o.jsxs("div",{className:"flex gap-2 mb-4",children:[o.jsx($,{onClick:()=>l("simple"),size:"sm",variant:a==="simple"?"default":"outline",className:"flex-1",children:"Simple Mode"}),o.jsx($,{onClick:()=>l("advanced"),size:"sm",variant:a==="advanced"?"default":"outline",className:"flex-1",children:"Advanced Mode"})]}),a==="simple"?o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Source URL"}),o.jsx("input",{type:"url",value:p.src,onChange:S=>g(S.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"https://example.com/embed"}),o.jsx("div",{className:"text-xs text-gray-600 mt-1",children:"Sandbox attributes are automatically configured based on the URL for optimal compatibility."})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Width"}),o.jsx("input",{type:"text",value:p.width,onChange:S=>b({...p,width:S.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"100%"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Height"}),o.jsx("input",{type:"text",value:p.height,onChange:S=>b({...p,height:S.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"500px"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Title"}),o.jsx("input",{type:"text",value:p.title,onChange:S=>b({...p,title:S.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"Embedded Content"})]})]}):o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Paste your iframe HTML code"}),o.jsx("textarea",{value:c,onChange:S=>d(S.target.value),className:"w-full h-32 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 font-mono text-sm",placeholder:'<iframe src="https://example.com/embed" style="width:100%; height:500px; border:0; border-radius:4px; overflow:hidden;" title="Example" allow="..." sandbox="..."></iframe>'})]}),o.jsx("div",{className:"text-xs text-gray-600",children:"Paste your complete iframe HTML code here. The extension will automatically extract the attributes."}),o.jsxs("div",{className:"border-t pt-3",children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Sandbox Attributes (Advanced)"}),o.jsx("input",{type:"text",value:p.sandbox,onChange:S=>b({...p,sandbox:S.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 font-mono text-xs",placeholder:"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation"}),o.jsx("div",{className:"text-xs text-gray-600 mt-1",children:"Override automatic sandbox configuration if needed. Common values: allow-scripts, allow-same-origin, allow-forms, allow-popups"})]})]}),o.jsxs("div",{className:"flex gap-2 mt-4",children:[a==="advanced"&&o.jsx($,{onClick:D,size:"sm",className:"bg-green-600 hover:bg-green-700",children:"Parse & Apply"}),o.jsx($,{onClick:_,size:"sm",className:"bg-blue-600 hover:bg-blue-700",children:"Save"}),o.jsx($,{onClick:C,size:"sm",variant:"outline",children:"Cancel"})]})]})}):o.jsx(q.NodeViewWrapper,{className:"iframe-extension",children:o.jsxs("div",{ref:m,className:"relative group",children:[o.jsx("iframe",{src:t.attrs.src,...u?{}:{width:t.attrs.width,height:t.attrs.height},title:t.attrs.title,allow:t.attrs.allow,sandbox:t.attrs.sandbox,style:{...Xs(t.attrs.style),...u?{width:"100vw",height:"100vh"}:{width:t.attrs.width,height:t.attrs.height}},className:u?"rounded-lg iframe-fullscreen":"rounded-lg"}),y&&o.jsx("div",{className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity duration-200 bg-white/90 backdrop-blur-sm rounded-lg p-1 shadow-lg border",children:o.jsxs("div",{className:"flex gap-1",children:[o.jsx($,{onClick:x,size:"sm",variant:"ghost",className:"h-8 w-8 p-0",title:"Edit iframe",children:o.jsx(O.Settings,{className:"h-4 w-4"})}),o.jsx($,{onClick:()=>window.open(t.attrs.src,"_blank"),size:"sm",variant:"ghost",className:"h-8 w-8 p-0",title:"Open in new tab",children:o.jsx(O.ExternalLink,{className:"h-4 w-4"})}),o.jsx($,{onClick:k,size:"sm",variant:"ghost",className:"h-8 w-8 p-0",title:"Copy iframe code",children:o.jsx(O.Copy,{className:"h-4 w-4"})}),o.jsx($,{onClick:()=>{y&&n()},size:"sm",variant:"ghost",className:"h-8 w-8 p-0 text-red-600 hover:text-red-700",title:"Delete iframe",children:o.jsx(O.Trash2,{className:"h-4 w-4"})})]})}),o.jsx("div",{className:"absolute hidden md:block md:bottom-20 md:right-4 bg-white/90 rounded-lg p-1 shadow-lg border z-10 cursor-pointer",children:o.jsx($,{onClick:M,size:"sm",variant:"ghost",className:"h-6 w-8 p-0 cursor-pointer",title:u?"Exit fullscreen":"Enter fullscreen",children:u?o.jsx(O.Minimize,{className:"h-4 w-4"}):o.jsx(O.Maximize,{className:"h-4 w-4"})})}),y&&t.attrs.src&&o.jsxs("div",{className:"mt-2 text-xs text-gray-500 bg-gray-100 px-2 py-1 rounded",children:["Source: ",t.attrs.src]})]})})},Xs=t=>{const e={};return t&&t.split(";").forEach(n=>{const[r,s]=n.split(":").map(i=>i.trim());if(r&&s){const i=r.replace(/-([a-z])/g,a=>a[1].toUpperCase());e[i]=s}}),e},Bn=K.Node.create({name:"iframe",group:"block",atom:!0,addOptions(){return{readOnly:!1}},addAttributes(){return{src:{default:"",parseHTML:t=>t.getAttribute("src")||"",renderHTML:t=>({src:t.src})},width:{default:"100%",parseHTML:t=>t.getAttribute("width")||"100%",renderHTML:t=>({width:t.width})},height:{default:"500px",parseHTML:t=>t.getAttribute("height")||"500px",renderHTML:t=>({height:t.height})},title:{default:"",parseHTML:t=>t.getAttribute("title")||"",renderHTML:t=>({title:t.title})},allow:{default:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",parseHTML:t=>t.getAttribute("allow")||"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",renderHTML:t=>({allow:t.allow})},sandbox:{default:"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation",parseHTML:t=>t.getAttribute("sandbox")||"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation",renderHTML:t=>({sandbox:t.sandbox})},style:{default:"",parseHTML:t=>t.getAttribute("style")||"",renderHTML:t=>({style:t.style})}}},parseHTML(){return[{tag:"iframe"}]},renderHTML({HTMLAttributes:t}){return["iframe",K.mergeAttributes(t)]},addNodeView(){return q.ReactNodeViewRenderer(Zs)},addCommands(){return{insertIframe:(t={})=>({commands:e})=>e.insertContent({type:this.name,attrs:{src:t.src||"",width:t.width||"100%",height:t.height||"500px",title:t.title||"Embedded Content",allow:t.allow||"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",sandbox:t.sandbox||"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation",style:t.style||""}})}}}),kt=`<div class="demo">
|
|
23
23
|
<h1>Hello World</h1>
|
|
24
24
|
<p>Edit the HTML, CSS, and JS to see live output.</p>
|
|
25
|
-
</div>`,
|
|
25
|
+
</div>`,At=`.demo {
|
|
26
26
|
font-family: system-ui, sans-serif;
|
|
27
27
|
padding: 16px;
|
|
28
28
|
}
|
|
@@ -35,23 +35,41 @@ React keys must be passed directly to JSX without using spread:
|
|
|
35
35
|
.demo p {
|
|
36
36
|
color: #4b5563;
|
|
37
37
|
margin: 0;
|
|
38
|
-
}`,
|
|
38
|
+
}`,Ot=`document.querySelector('.demo h1')?.addEventListener('click', () => {
|
|
39
39
|
alert('Hello from live preview!');
|
|
40
|
-
});`;function
|
|
40
|
+
});`;function zn(t,e,n){const r=n.replace(/<\/script>/gi,"<\\/script>");return`<!DOCTYPE html>
|
|
41
41
|
<html lang="en">
|
|
42
42
|
<head>
|
|
43
43
|
<meta charset="UTF-8">
|
|
44
44
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
45
45
|
<style>
|
|
46
46
|
*, *::before, *::after { box-sizing: border-box; }
|
|
47
|
-
body { margin: 0;
|
|
47
|
+
html, body { margin: 0; }
|
|
48
|
+
body { padding: 12px; }
|
|
48
49
|
${e}
|
|
49
50
|
</style>
|
|
50
51
|
</head>
|
|
51
52
|
<body>
|
|
52
53
|
${t}
|
|
53
54
|
<script>${r}<\/script>
|
|
55
|
+
<script>(function () {
|
|
56
|
+
function postHeight() {
|
|
57
|
+
var h = Math.max(
|
|
58
|
+
document.body ? document.body.scrollHeight : 0,
|
|
59
|
+
document.documentElement ? document.documentElement.scrollHeight : 0,
|
|
60
|
+
document.body ? document.body.offsetHeight : 0
|
|
61
|
+
);
|
|
62
|
+
parent.postMessage({ type: "live-preview-height", height: h }, "*");
|
|
63
|
+
}
|
|
64
|
+
window.addEventListener("load", postHeight);
|
|
65
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
66
|
+
var ro = new ResizeObserver(postHeight);
|
|
67
|
+
ro.observe(document.documentElement);
|
|
68
|
+
if (document.body) ro.observe(document.body);
|
|
69
|
+
}
|
|
70
|
+
setTimeout(postHeight, 50);
|
|
71
|
+
})();<\/script>
|
|
54
72
|
</body>
|
|
55
|
-
</html>`}const Ws=[{id:"html",label:"HTML"},{id:"css",label:"CSS"},{id:"js",label:"JS"}],Js=({node:t,updateAttributes:e,deleteNode:n,editor:r})=>{const[s,i]=S.useState(!!t.attrs.pendingEdit),[o,l]=S.useState("html"),[c,u]=S.useState("code"),[d,f]=S.useState(0),[h,p]=S.useState(!1),g=S.useRef(null),[b,m]=S.useState({html:t.attrs.html||"",css:t.attrs.css||"",js:t.attrs.js||"",height:t.attrs.height||"400px",title:t.attrs.title||"Live Preview"}),[v,T]=S.useState(r?.isEditable??!1);S.useEffect(()=>{t.attrs.pendingEdit&&v&&(i(!0),e({pendingEdit:!1}))},[t.attrs.pendingEdit,v,e]),S.useEffect(()=>{if(!r)return;const I=()=>T(r.isEditable);return I(),r.on("update",I),r.on("selectionUpdate",I),()=>{r.off("update",I),r.off("selectionUpdate",I)}},[r]);const x=S.useMemo(()=>Rn(t.attrs.html,t.attrs.css,t.attrs.js),[t.attrs.html,t.attrs.css,t.attrs.js]),C=S.useMemo(()=>Rn(b.html,b.css,b.js),[b.html,b.css,b.js]),y=()=>{v&&(m({html:t.attrs.html||"",css:t.attrs.css||"",js:t.attrs.js||"",height:t.attrs.height||"400px",title:t.attrs.title||"Live Preview"}),l("html"),u("code"),i(!0))},_=()=>{v&&(e(b),f(I=>I+1),i(!1))},D=()=>{m({html:t.attrs.html||"",css:t.attrs.css||"",js:t.attrs.js||"",height:t.attrs.height||"400px",title:t.attrs.title||"Live Preview"}),i(!1)},E=()=>{f(I=>I+1),u("preview")},B=(I,O)=>{m(L=>({...L,[I]:O}))},N=()=>{const I=g.current;I&&(h?document.exitFullscreen?.():I.requestFullscreen?.())};S.useEffect(()=>{const I=()=>{p(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",I),()=>document.removeEventListener("fullscreenchange",I)},[]);const z=(I,O,L)=>a.jsx("iframe",{title:t.attrs.title||"Live Preview",srcDoc:I,sandbox:"allow-scripts allow-modals",className:"live-preview-iframe",style:{width:"100%",height:h?"100vh":O,border:"none",borderRadius:0,display:"block"}},L);return s?a.jsx(Y.NodeViewWrapper,{className:"live-preview-extension live-preview-editing",children:a.jsxs("div",{className:"live-preview-editor-panel",children:[a.jsxs("div",{className:"live-preview-editor-header",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(k.Code2,{className:"h-4 w-4 text-blue-600"}),a.jsx("span",{className:"text-sm font-semibold text-gray-800",children:"Live Preview Editor"})]}),a.jsxs("div",{className:"flex gap-1",children:[a.jsxs(q,{type:"button",size:"sm",variant:c==="code"?"default":"outline",onClick:()=>u("code"),children:[a.jsx(k.Code2,{className:"h-3.5 w-3.5 mr-1"}),"Code"]}),a.jsxs(q,{type:"button",size:"sm",variant:c==="preview"?"default":"outline",onClick:()=>{f(I=>I+1),u("preview")},children:[a.jsx(k.Eye,{className:"h-3.5 w-3.5 mr-1"}),"Preview"]})]})]}),c==="code"?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"live-preview-tabs",children:Ws.map(I=>a.jsx("button",{type:"button",className:`live-preview-tab ${o===I.id?"active":""}`,onClick:()=>l(I.id),children:I.label},I.id))}),a.jsx("textarea",{className:"live-preview-code-input",value:b[o],onChange:I=>B(o,I.target.value),spellCheck:!1,"aria-label":`${o.toUpperCase()} code`}),a.jsxs("div",{className:"live-preview-meta-row",children:[a.jsxs("label",{className:"live-preview-meta-field",children:[a.jsx("span",{children:"Height"}),a.jsx("input",{type:"text",value:b.height,onChange:I=>B("height",I.target.value),placeholder:"400px"})]}),a.jsxs("label",{className:"live-preview-meta-field",children:[a.jsx("span",{children:"Title"}),a.jsx("input",{type:"text",value:b.title,onChange:I=>B("title",I.target.value),placeholder:"Live Preview"})]})]})]}):a.jsx("div",{className:"live-preview-edit-preview",children:z(C,b.height,d)}),a.jsxs("div",{className:"live-preview-actions",children:[a.jsxs(q,{type:"button",size:"sm",variant:"outline",onClick:E,className:"text-green-700 border-green-300 hover:bg-green-50",children:[a.jsx(k.Play,{className:"h-3.5 w-3.5 mr-1"}),"Run"]}),a.jsx(q,{type:"button",size:"sm",onClick:_,children:"Save"}),a.jsx(q,{type:"button",size:"sm",variant:"outline",onClick:D,children:"Cancel"})]})]})}):a.jsx(Y.NodeViewWrapper,{className:"live-preview-extension",children:a.jsxs("div",{ref:g,className:"live-preview-output group relative",children:[z(x,t.attrs.height,d),v&&a.jsxs("div",{className:"live-preview-controls",children:[a.jsx(q,{type:"button",size:"sm",variant:"ghost",className:"h-8 w-8 p-0",title:"Edit code",onClick:y,children:a.jsx(k.Settings,{className:"h-4 w-4"})}),a.jsx(q,{type:"button",size:"sm",variant:"ghost",className:"h-8 w-8 p-0",title:h?"Exit fullscreen":"Fullscreen",onClick:N,children:h?a.jsx(k.Minimize,{className:"h-4 w-4"}):a.jsx(k.Maximize,{className:"h-4 w-4"})}),a.jsx(q,{type:"button",size:"sm",variant:"ghost",className:"h-8 w-8 p-0 text-red-600 hover:text-red-700",title:"Delete",onClick:()=>n(),children:a.jsx(k.Trash2,{className:"h-4 w-4"})})]}),!v&&a.jsx("div",{className:"live-preview-controls live-preview-controls-readonly",children:a.jsx(q,{type:"button",size:"sm",variant:"ghost",className:"h-8 w-8 p-0",title:h?"Exit fullscreen":"Fullscreen",onClick:N,children:h?a.jsx(k.Minimize,{className:"h-4 w-4"}):a.jsx(k.Maximize,{className:"h-4 w-4"})})}),t.attrs.title&&a.jsx("div",{className:"live-preview-label",children:t.attrs.title})]})})};function Ct(t,e){return t.querySelector(`[data-part="${e}"]`)?.textContent??""}const Ln=V.Node.create({name:"livePreview",group:"block",atom:!0,addAttributes(){return{html:{default:Et,parseHTML:t=>Ct(t,"html")||Et},css:{default:Nt,parseHTML:t=>Ct(t,"css")||Nt},js:{default:St,parseHTML:t=>Ct(t,"js")||St},height:{default:"400px",parseHTML:t=>t.getAttribute("data-height")||"400px",renderHTML:t=>({"data-height":t.height})},title:{default:"Live Preview",parseHTML:t=>t.getAttribute("data-title")||"Live Preview",renderHTML:t=>({"data-title":t.title})},pendingEdit:{default:!1,parseHTML:()=>!1,renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="live-preview"]'}]},renderHTML({node:t,HTMLAttributes:e}){return["div",V.mergeAttributes(e,{"data-type":"live-preview","data-height":t.attrs.height,"data-title":t.attrs.title}),["pre",{"data-part":"html",hidden:"hidden"},t.attrs.html],["pre",{"data-part":"css",hidden:"hidden"},t.attrs.css],["pre",{"data-part":"js",hidden:"hidden"},t.attrs.js]]},addNodeView(){return Y.ReactNodeViewRenderer(Js)},addCommands(){return{insertLivePreview:(t={})=>({commands:e})=>e.insertContent({type:this.name,attrs:{html:t.html??Et,css:t.css??Nt,js:t.js??St,height:t.height??"400px",title:t.title??"Live Preview",pendingEdit:t.pendingEdit??!1}})}}}),jn=V.Node.create({name:"video",addOptions(){return{inline:!1,allowBase64:!0,HTMLAttributes:{class:"max-w-full h-auto rounded-lg shadow-sm"}}},group(){return this.options.inline?"inline":"block"},draggable:!1,addAttributes(){return{src:{default:null,parseHTML:t=>t.getAttribute("src"),renderHTML:t=>t.src?{src:t.src}:{}},type:{default:null,parseHTML:t=>t.getAttribute("type"),renderHTML:t=>t.type?{type:t.type}:{}},title:{default:null,parseHTML:t=>t.getAttribute("title"),renderHTML:t=>t.title?{title:t.title}:{}}}},parseHTML(){return[{tag:"video"}]},renderHTML({HTMLAttributes:t}){const{src:e,type:n,title:r}=t;return e?["video",V.mergeAttributes(this.options.HTMLAttributes,t,{controls:!0,preload:"metadata"}),["source",{src:e,type:n||"video/mp4"}],r||"Your browser does not support the video tag."]:["video",V.mergeAttributes(this.options.HTMLAttributes,t)]},addCommands(){return{setVideo:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}}}),Gs=()=>({type:"column",content:[{type:"paragraph"}]}),Dn=V.Node.create({name:"columnLayout",group:"block",content:"column+",defining:!0,isolating:!0,addOptions(){return{HTMLAttributes:{},defaultColumns:2}},addAttributes(){return{columns:{default:this.options.defaultColumns,parseHTML:t=>{const e=Number(t.getAttribute("data-columns"));return Number.isNaN(e)?this.options.defaultColumns:e},renderHTML:t=>({"data-columns":t.columns})}}},parseHTML(){return[{tag:'div[data-type="column-layout"]'}]},renderHTML({HTMLAttributes:t}){return["div",V.mergeAttributes(this.options.HTMLAttributes,t,{"data-type":"column-layout"}),0]},addCommands(){return{insertColumnLayout:t=>({commands:e})=>{const n=t?.columns??this.options.defaultColumns,r=Array.from({length:Math.max(n,1)},()=>Gs());return e.insertContent({type:this.name,attrs:{columns:n},content:r})},setColumnLayoutColumns:t=>({state:e,dispatch:n})=>{const r=V.findParentNode(s=>s.type===this.type)(e.selection);if(!r)return!1;if(n){const s=e.tr.setNodeMarkup(r.pos,this.type,{...r.node.attrs,columns:t},r.node.marks);n(s)}return!0}}}}),Pn=V.Node.create({name:"column",content:"block+",isolating:!0,defining:!0,parseHTML(){return[{tag:'div[data-type="column"]'}]},renderHTML({HTMLAttributes:t}){return["div",V.mergeAttributes(t,{"data-type":"column"}),0]}});function Ys({initialOpen:t=!1,placement:e="top",open:n,onOpenChange:r,delay:s=600,closeDelay:i=0}={}){const[o,l]=he.useState(t),c=n??o,u=r??l,d=se.useFloating({placement:e,open:c,onOpenChange:u,whileElementsMounted:se.autoUpdate,middleware:[se.offset(4),se.flip({crossAxis:e.includes("-"),fallbackAxisSideDirection:"start",padding:4}),se.shift({padding:4})]}),f=d.context,h=se.useHover(f,{mouseOnly:!0,move:!1,restMs:s,enabled:n==null,delay:{close:i}}),p=se.useFocus(f,{enabled:n==null}),g=se.useDismiss(f),b=se.useRole(f,{role:"tooltip"}),m=se.useInteractions([h,p,g,b]);return he.useMemo(()=>({open:c,setOpen:u,...m,...d}),[c,u,m,d])}const Tt=he.createContext(null);function Bn(){const t=he.useContext(Tt);if(t==null)throw new Error("Tooltip components must be wrapped in <TooltipProvider />");return t}function tt({children:t,...e}){const n=Ys(e);return e.useDelayGroup?a.jsx(se.FloatingDelayGroup,{delay:{open:e.delay??0,close:e.closeDelay??0},timeoutMs:e.timeout,children:a.jsx(Tt.Provider,{value:n,children:t})}):a.jsx(Tt.Provider,{value:n,children:t})}const nt=he.forwardRef(function({children:e,asChild:n=!1,...r},s){const i=Bn(),o=he.isValidElement(e)?parseInt(he.version,10)>=19?e.props.ref:e.ref:void 0,l=se.useMergeRefs([i.refs.setReference,s,o]);if(n&&he.isValidElement(e)){const c={"data-tooltip-state":i.open?"open":"closed"};return he.cloneElement(e,i.getReferenceProps({ref:l,...r,...typeof e.props=="object"?e.props:{},...c}))}return a.jsx("button",{ref:l,"data-tooltip-state":i.open?"open":"closed",...i.getReferenceProps(r),children:e})}),rt=he.forwardRef(function({style:e,children:n,portal:r=!0,portalProps:s={},...i},o){const l=Bn(),c=se.useMergeRefs([l.refs.setFloating,o]);if(!l.open)return null;const u=a.jsx("div",{ref:c,style:{...l.floatingStyles,...e},...l.getFloatingProps(i),className:"tiptap-tooltip",children:n});return r?a.jsx(se.FloatingPortal,{...s,children:u}):u});tt.displayName="Tooltip",nt.displayName="TooltipTrigger",rt.displayName="TooltipContent";const P=({onClick:t,isActive:e=!1,children:n,title:r,className:s=""})=>{const i=a.jsx(q,{type:"button",onClick:t,variant:e?"default":"outline",size:"sm",className:`h-8 w-8 p-0 transition-all cursor-pointer ${e?"bg-blue-600 text-white border-blue-600 hover:bg-blue-700":"bg-white hover:bg-gray-50"} ${s}`,children:n});return r?a.jsxs(tt,{delay:500,closeDelay:0,children:[a.jsx(nt,{asChild:!0,children:i}),a.jsx(rt,{children:r})]}):i},Zs=({onColorChange:t})=>{const e=["#000000","#ffffff","#7d7a75","#9f765a","#d27b2d","#fdd835","#50946e","#377dc9","#9a6bb4","#c14c8a","#cf5148"];return a.jsx("div",{className:"flex flex-wrap gap-1 w-32",children:e.map(n=>a.jsxs(tt,{delay:300,closeDelay:0,children:[a.jsx(nt,{asChild:!0,children:a.jsx("button",{type:"button",className:"w-6 h-6 rounded border border-gray-300 cursor-pointer hover:scale-110 transition-transform",style:{backgroundColor:n},onClick:()=>t(n)})}),a.jsxs(rt,{children:["Set color to ",n]})]},n))})},Xs=({onColorChange:t})=>{const e=["#B0B0B0","#F2F0EF","#e7e4de","#f3e1d5","#ffe4c2","#fff7cc","#d6f2e3","#d5e6fa","#ebddf5","#f9d6e8","#f8d0cb"];return a.jsx("div",{className:"flex flex-wrap gap-1 w-32",children:e.map(n=>a.jsxs(tt,{delay:300,closeDelay:0,children:[a.jsx(nt,{asChild:!0,children:a.jsx("button",{type:"button",className:"w-6 h-6 rounded border border-gray-300 cursor-pointer hover:scale-110 transition-transform",style:{backgroundColor:n},onClick:()=>t(n)})}),a.jsxs(rt,{children:["Set background color to ",n]})]},n))})},Qs=({editor:t,isReadOnly:e,onImageUpload:n,onVideoUpload:r,isImageUploading:s,isVideoUploading:i,showImageInput:o,setShowImageInput:l,imageUrl:c,setImageUrl:u,handleImageUrlInsert:d,imageUploadFunction:f})=>{const[h,p]=S.useState(!1),g=S.useRef(null);return S.useEffect(()=>{const b=m=>{g.current&&!g.current.contains(m.target)&&p(!1)};return h&&document.addEventListener("mousedown",b),()=>{document.removeEventListener("mousedown",b)}},[h]),e?null:a.jsxs("div",{className:"sticky top-0 z-40 border border-gray-300 mb-10 p-4 bg-gray-50/95 flex flex-wrap gap-2 shadow-sm backdrop-blur-sm",children:[a.jsxs("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:[a.jsx(P,{onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),isActive:t.isActive("heading",{level:1}),title:"Heading 1",children:a.jsx(k.Heading1,{className:"h-4 w-4"})}),a.jsx(P,{onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),isActive:t.isActive("heading",{level:2}),title:"Heading 2",children:a.jsx(k.Heading2,{className:"h-4 w-4"})}),a.jsx(P,{onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),isActive:t.isActive("heading",{level:3}),title:"Heading 3",children:a.jsx(k.Heading3,{className:"h-4 w-4"})}),a.jsx(P,{onClick:()=>t.chain().focus().toggleHeading({level:4}).run(),isActive:t.isActive("heading",{level:4}),title:"Heading 4",children:a.jsx(k.Heading4,{className:"h-4 w-4"})}),a.jsx(P,{onClick:()=>t.chain().focus().setParagraph().run(),isActive:t.isActive("paragraph"),title:"Paragraph",children:a.jsx(k.FileText,{className:"h-4 w-4"})})]}),a.jsxs("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:[a.jsx(P,{onClick:()=>t.chain().focus().toggleBulletList().run(),isActive:t.isActive("bulletList"),title:"Bullet List",children:a.jsx(k.List,{className:"h-4 w-4"})}),a.jsx(P,{onClick:()=>t.chain().focus().toggleOrderedList().run(),isActive:t.isActive("orderedList"),title:"Numbered List",children:a.jsx(k.ListOrdered,{className:"h-4 w-4"})})]}),a.jsx("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:a.jsx(P,{onClick:()=>t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),title:"Insert Table (3x3)",children:a.jsx(k.Table,{className:"h-4 w-4"})})}),a.jsxs("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:[a.jsx(P,{onClick:()=>t.chain().focus().toggleBlockquote().run(),isActive:t.isActive("blockquote"),title:"Block Quote",children:a.jsx(k.Quote,{className:"h-4 w-4"})}),a.jsx(P,{onClick:()=>t.chain().focus().setHorizontalRule().run(),title:"Horizontal Rule",children:a.jsx(k.Minus,{className:"h-4 w-4"})})]}),a.jsxs("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:[a.jsxs("div",{className:"relative",children:[a.jsx(P,{onClick:()=>l(!o),title:"Insert Image",className:s?"opacity-50":"",children:s?a.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"}):a.jsx(k.Image,{className:"h-4 w-4"})}),s&&a.jsx("div",{className:"absolute -top-1 -right-1 w-3 h-3 bg-blue-600 rounded-full animate-pulse"}),o&&a.jsx("div",{className:`absolute top-full mt-1 z-10 bg-white border border-gray-300 rounded-lg p-2 shadow-lg min-w-80 image-input-container ${s?"opacity-75":""}`,children:a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("h3",{className:"text-sm font-medium text-gray-900",children:"Insert Image"}),a.jsx("button",{type:"button",onClick:()=>l(!1),className:`text-gray-400 hover:text-gray-600 ${s?"opacity-50 cursor-not-allowed":""}`,disabled:s,children:"✕"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Image URL"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"url",value:c,onChange:b=>u(b.target.value),placeholder:"https://example.com/image.jpg",className:`flex-1 px-3 py-2 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 ${s?"opacity-50 cursor-not-allowed":""}`,disabled:s,onKeyDown:b=>{b.key==="Enter"&&d()}}),a.jsx(q,{type:"button",onClick:d,size:"sm",className:"px-4 py-2",disabled:!c.trim()||s,children:"Insert"})]}),c.trim()&&a.jsxs("div",{className:"mt-2 p-2 border border-gray-200 rounded bg-gray-50",children:[a.jsx("p",{className:"text-xs text-gray-600 mb-2",children:"Preview:"}),a.jsx("img",{src:c.trim(),alt:"Preview",className:"max-w-full h-auto max-h-32 rounded border",onError:b=>{const m=b.currentTarget;m.style.display="none";const v=m.nextElementSibling;v&&(v.style.display="block")}}),a.jsx("p",{className:"text-xs text-red-500 hidden",children:"Invalid image URL"})]})]}),a.jsxs("div",{className:"border-t pt-3",children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Or Upload Image"}),a.jsx(q,{type:"button",onClick:n,size:"sm",variant:"outline",className:"w-full",disabled:!f||s,children:s?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"}),a.jsx("span",{children:"Uploading..."})]}):f?"Choose File":"Upload not available"}),s&&a.jsxs("div",{className:"mt-2 text-xs text-blue-600 flex items-center gap-1",children:[a.jsx("div",{className:"animate-pulse",children:"⏳"}),a.jsx("span",{children:"Please wait while your image uploads..."})]}),!f&&a.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Upload function not provided"})]})]})})]}),a.jsxs("div",{className:"relative",children:[a.jsx(P,{onClick:r,title:i?"Upload Video to Firebase":"Upload Video (Base64)",className:i?"opacity-50":"",children:i?a.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"}):a.jsx(k.Video,{className:"h-4 w-4"})}),i&&a.jsx("div",{className:"absolute -top-1 -right-1 w-3 h-3 bg-blue-600 rounded-full animate-pulse"}),!r&&a.jsx("div",{className:"absolute top-full mt-1 left-0 bg-gray-800 text-white text-xs px-2 py-1 rounded whitespace-nowrap z-50",children:"Video upload not available"})]})]}),a.jsxs("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:[a.jsx(P,{onClick:()=>t.chain().focus().toggleCodeBlock().run(),isActive:t.isActive("codeBlock"),title:"Code Block",children:a.jsx(k.Code,{className:"h-4 w-4"})}),a.jsx(P,{onClick:()=>t.chain().focus().insertAccordion().run(),title:"Insert Accordion",children:a.jsx(k.PanelTopOpen,{className:"h-4 w-4 cursor-pointer"})})]}),a.jsxs("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:[a.jsx(P,{onClick:()=>t.chain().focus().insertTabs({tabCount:2}).run(),title:"Insert 2 Tabs",children:a.jsx("span",{className:"text-xs font-mono",children:"2T"})}),a.jsxs("div",{className:"relative w-full",ref:g,children:[a.jsx(P,{onClick:()=>p(!h),title:"Insert Tabs",className:"w-full px-2",children:a.jsxs("div",{className:"flex items-center gap-1 w-full justify-between",children:[a.jsx("span",{className:"text-xs font-mono",children:"Tabs"}),a.jsx(k.ChevronDown,{className:"h-3 w-3"})]})}),h&&a.jsx("div",{className:"absolute top-full mt-1 left-0 z-10 bg-white border border-gray-300 rounded-lg shadow-lg min-w-32",children:a.jsxs("div",{className:"p-1 space-y-1",children:[a.jsx(q,{type:"button",variant:"ghost",size:"sm",onClick:()=>{t.chain().focus().insertTabs({tabCount:3}).run(),p(!1)},className:"w-full justify-start text-xs font-mono hover:bg-gray-100",children:"3 Tabs"}),a.jsx(q,{type:"button",variant:"ghost",size:"sm",onClick:()=>{t.chain().focus().insertTabs({tabCount:4}).run(),p(!1)},className:"w-full justify-start text-xs font-mono hover:bg-gray-100",children:"4 Tabs"}),a.jsx(q,{type:"button",variant:"ghost",size:"sm",onClick:()=>{t.chain().focus().insertTabs({tabCount:5}).run(),p(!1)},className:"w-full justify-start text-xs font-mono hover:bg-gray-100",children:"5 Tabs"}),a.jsx(q,{type:"button",variant:"ghost",size:"sm",onClick:()=>{t.chain().focus().insertTabs({tabCount:6}).run(),p(!1)},className:"w-full justify-start text-xs font-mono hover:bg-gray-100",children:"6 Tabs"})]})})]})]}),a.jsxs("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:[a.jsx(P,{onClick:()=>{const b=prompt("Enter the URL for your iframe:","https://example.com/embed");b&&t.chain().focus().insertIframe({src:b,width:"100%",height:"500px",title:"Embedded Content"}).run()},title:"Insert iframe",children:a.jsx(k.Frame,{className:"h-4 w-4"})}),a.jsx(P,{onClick:()=>{t.chain().focus().insertLivePreview({pendingEdit:!0}).run()},title:"Insert live HTML/CSS/JS preview",children:a.jsx(k.MonitorPlay,{className:"h-4 w-4"})})]}),a.jsx("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:a.jsx(P,{onClick:()=>t.chain().focus().insertColumnLayout({columns:2}).run(),title:"Insert 2 Column Layout",children:a.jsx("div",{className:"flex items-center gap-1",children:a.jsx(k.Columns3,{className:"h-4 w-4"})})})})]})},zn=["top","right","bottom","left"],Un=["start","end"],Fn=zn.reduce((t,e)=>t.concat(e,e+"-"+Un[0],e+"-"+Un[1]),[]),ge=Math.min,ne=Math.max,st=Math.round,be=t=>({x:t,y:t}),ei={left:"right",right:"left",bottom:"top",top:"bottom"},ti={start:"end",end:"start"};function _t(t,e,n){return ne(t,ge(e,n))}function ve(t,e){return typeof t=="function"?t(e):t}function le(t){return t.split("-")[0]}function de(t){return t.split("-")[1]}function Hn(t){return t==="x"?"y":"x"}function kt(t){return t==="y"?"height":"width"}const ni=new Set(["top","bottom"]);function we(t){return ni.has(le(t))?"y":"x"}function At(t){return Hn(we(t))}function $n(t,e,n){n===void 0&&(n=!1);const r=de(t),s=At(t),i=kt(s);let o=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(o=ot(o)),[o,ot(o)]}function ri(t){const e=ot(t);return[it(t),e,it(e)]}function it(t){return t.replace(/start|end/g,e=>ti[e])}const Kn=["left","right"],qn=["right","left"],si=["top","bottom"],ii=["bottom","top"];function oi(t,e,n){switch(t){case"top":case"bottom":return n?e?qn:Kn:e?Kn:qn;case"left":case"right":return e?si:ii;default:return[]}}function ai(t,e,n,r){const s=de(t);let i=oi(le(t),n==="start",r);return s&&(i=i.map(o=>o+"-"+s),e&&(i=i.concat(i.map(it)))),i}function ot(t){return t.replace(/left|right|bottom|top/g,e=>ei[e])}function li(t){return{top:0,right:0,bottom:0,left:0,...t}}function Ot(t){return typeof t!="number"?li(t):{top:t,right:t,bottom:t,left:t}}function je(t){const{x:e,y:n,width:r,height:s}=t;return{width:r,height:s,top:n,left:e,right:e+r,bottom:n+s,x:e,y:n}}function Vn(t,e,n){let{reference:r,floating:s}=t;const i=we(e),o=At(e),l=kt(o),c=le(e),u=i==="y",d=r.x+r.width/2-s.width/2,f=r.y+r.height/2-s.height/2,h=r[l]/2-s[l]/2;let p;switch(c){case"top":p={x:d,y:r.y-s.height};break;case"bottom":p={x:d,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-s.width,y:f};break;default:p={x:r.x,y:r.y}}switch(de(e)){case"start":p[o]-=h*(n&&u?-1:1);break;case"end":p[o]+=h*(n&&u?-1:1);break}return p}const ci=async(t,e,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:i=[],platform:o}=n,l=i.filter(Boolean),c=await(o.isRTL==null?void 0:o.isRTL(e));let u=await o.getElementRects({reference:t,floating:e,strategy:s}),{x:d,y:f}=Vn(u,r,c),h=r,p={},g=0;for(let b=0;b<l.length;b++){const{name:m,fn:v}=l[b],{x:T,y:x,data:C,reset:y}=await v({x:d,y:f,initialPlacement:r,placement:h,strategy:s,middlewareData:p,rects:u,platform:o,elements:{reference:t,floating:e}});d=T??d,f=x??f,p={...p,[m]:{...p[m],...C}},y&&g<=50&&(g++,typeof y=="object"&&(y.placement&&(h=y.placement),y.rects&&(u=y.rects===!0?await o.getElementRects({reference:t,floating:e,strategy:s}):y.rects),{x:d,y:f}=Vn(u,h,c)),b=-1)}return{x:d,y:f,placement:h,strategy:s,middlewareData:p}};async function De(t,e){var n;e===void 0&&(e={});const{x:r,y:s,platform:i,rects:o,elements:l,strategy:c}=t,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=ve(e,t),g=Ot(p),m=l[h?f==="floating"?"reference":"floating":f],v=je(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(m)))==null||n?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:u,rootBoundary:d,strategy:c})),T=f==="floating"?{x:r,y:s,width:o.floating.width,height:o.floating.height}:o.reference,x=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),C=await(i.isElement==null?void 0:i.isElement(x))?await(i.getScale==null?void 0:i.getScale(x))||{x:1,y:1}:{x:1,y:1},y=je(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:T,offsetParent:x,strategy:c}):T);return{top:(v.top-y.top+g.top)/C.y,bottom:(y.bottom-v.bottom+g.bottom)/C.y,left:(v.left-y.left+g.left)/C.x,right:(y.right-v.right+g.right)/C.x}}const ui=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:s,rects:i,platform:o,elements:l,middlewareData:c}=e,{element:u,padding:d=0}=ve(t,e)||{};if(u==null)return{};const f=Ot(d),h={x:n,y:r},p=At(s),g=kt(p),b=await o.getDimensions(u),m=p==="y",v=m?"top":"left",T=m?"bottom":"right",x=m?"clientHeight":"clientWidth",C=i.reference[g]+i.reference[p]-h[p]-i.floating[g],y=h[p]-i.reference[p],_=await(o.getOffsetParent==null?void 0:o.getOffsetParent(u));let D=_?_[x]:0;(!D||!await(o.isElement==null?void 0:o.isElement(_)))&&(D=l.floating[x]||i.floating[g]);const E=C/2-y/2,B=D/2-b[g]/2-1,N=ge(f[v],B),z=ge(f[T],B),I=N,O=D-b[g]-z,L=D/2-b[g]/2+E,j=_t(I,L,O),A=!c.arrow&&de(s)!=null&&L!==j&&i.reference[g]/2-(L<I?N:z)-b[g]/2<0,H=A?L<I?L-I:L-O:0;return{[p]:h[p]+H,data:{[p]:j,centerOffset:L-j-H,...A&&{alignmentOffset:H}},reset:A}}});function di(t,e,n){return(t?[...n.filter(s=>de(s)===t),...n.filter(s=>de(s)!==t)]:n.filter(s=>le(s)===s)).filter(s=>t?de(s)===t||(e?it(s)!==s:!1):!0)}const fi=function(t){return t===void 0&&(t={}),{name:"autoPlacement",options:t,async fn(e){var n,r,s;const{rects:i,middlewareData:o,placement:l,platform:c,elements:u}=e,{crossAxis:d=!1,alignment:f,allowedPlacements:h=Fn,autoAlignment:p=!0,...g}=ve(t,e),b=f!==void 0||h===Fn?di(f||null,p,h):h,m=await De(e,g),v=((n=o.autoPlacement)==null?void 0:n.index)||0,T=b[v];if(T==null)return{};const x=$n(T,i,await(c.isRTL==null?void 0:c.isRTL(u.floating)));if(l!==T)return{reset:{placement:b[0]}};const C=[m[le(T)],m[x[0]],m[x[1]]],y=[...((r=o.autoPlacement)==null?void 0:r.overflows)||[],{placement:T,overflows:C}],_=b[v+1];if(_)return{data:{index:v+1,overflows:y},reset:{placement:_}};const D=y.map(N=>{const z=de(N.placement);return[N.placement,z&&d?N.overflows.slice(0,2).reduce((I,O)=>I+O,0):N.overflows[0],N.overflows]}).sort((N,z)=>N[1]-z[1]),B=((s=D.filter(N=>N[2].slice(0,de(N[0])?2:3).every(z=>z<=0))[0])==null?void 0:s[0])||D[0][0];return B!==l?{data:{index:v+1,overflows:y},reset:{placement:B}}:{}}}},pi=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:s,middlewareData:i,rects:o,initialPlacement:l,platform:c,elements:u}=e,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:b=!0,...m}=ve(t,e);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const v=le(s),T=we(l),x=le(l)===l,C=await(c.isRTL==null?void 0:c.isRTL(u.floating)),y=h||(x||!b?[ot(l)]:ri(l)),_=g!=="none";!h&&_&&y.push(...ai(l,b,g,C));const D=[l,...y],E=await De(e,m),B=[];let N=((r=i.flip)==null?void 0:r.overflows)||[];if(d&&B.push(E[v]),f){const L=$n(s,o,C);B.push(E[L[0]],E[L[1]])}if(N=[...N,{placement:s,overflows:B}],!B.every(L=>L<=0)){var z,I;const L=(((z=i.flip)==null?void 0:z.index)||0)+1,j=D[L];if(j&&(!(f==="alignment"?T!==we(j):!1)||N.every(M=>we(M.placement)===T?M.overflows[0]>0:!0)))return{data:{index:L,overflows:N},reset:{placement:j}};let A=(I=N.filter(H=>H.overflows[0]<=0).sort((H,M)=>H.overflows[1]-M.overflows[1])[0])==null?void 0:I.placement;if(!A)switch(p){case"bestFit":{var O;const H=(O=N.filter(M=>{if(_){const F=we(M.placement);return F===T||F==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(F=>F>0).reduce((F,w)=>F+w,0)]).sort((M,F)=>M[1]-F[1])[0])==null?void 0:O[0];H&&(A=H);break}case"initialPlacement":A=l;break}if(s!==A)return{reset:{placement:A}}}return{}}}};function Wn(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function Jn(t){return zn.some(e=>t[e]>=0)}const hi=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n}=e,{strategy:r="referenceHidden",...s}=ve(t,e);switch(r){case"referenceHidden":{const i=await De(e,{...s,elementContext:"reference"}),o=Wn(i,n.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:Jn(o)}}}case"escaped":{const i=await De(e,{...s,altBoundary:!0}),o=Wn(i,n.floating);return{data:{escapedOffsets:o,escaped:Jn(o)}}}default:return{}}}}};function Gn(t){const e=ge(...t.map(i=>i.left)),n=ge(...t.map(i=>i.top)),r=ne(...t.map(i=>i.right)),s=ne(...t.map(i=>i.bottom));return{x:e,y:n,width:r-e,height:s-n}}function mi(t){const e=t.slice().sort((s,i)=>s.y-i.y),n=[];let r=null;for(let s=0;s<e.length;s++){const i=e[s];!r||i.y-r.y>r.height/2?n.push([i]):n[n.length-1].push(i),r=i}return n.map(s=>je(Gn(s)))}const gi=function(t){return t===void 0&&(t={}),{name:"inline",options:t,async fn(e){const{placement:n,elements:r,rects:s,platform:i,strategy:o}=e,{padding:l=2,x:c,y:u}=ve(t,e),d=Array.from(await(i.getClientRects==null?void 0:i.getClientRects(r.reference))||[]),f=mi(d),h=je(Gn(d)),p=Ot(l);function g(){if(f.length===2&&f[0].left>f[1].right&&c!=null&&u!=null)return f.find(m=>c>m.left-p.left&&c<m.right+p.right&&u>m.top-p.top&&u<m.bottom+p.bottom)||h;if(f.length>=2){if(we(n)==="y"){const N=f[0],z=f[f.length-1],I=le(n)==="top",O=N.top,L=z.bottom,j=I?N.left:z.left,A=I?N.right:z.right,H=A-j,M=L-O;return{top:O,bottom:L,left:j,right:A,width:H,height:M,x:j,y:O}}const m=le(n)==="left",v=ne(...f.map(N=>N.right)),T=ge(...f.map(N=>N.left)),x=f.filter(N=>m?N.left===T:N.right===v),C=x[0].top,y=x[x.length-1].bottom,_=T,D=v,E=D-_,B=y-C;return{top:C,bottom:y,left:_,right:D,width:E,height:B,x:_,y:C}}return h}const b=await i.getElementRects({reference:{getBoundingClientRect:g},floating:r.floating,strategy:o});return s.reference.x!==b.reference.x||s.reference.y!==b.reference.y||s.reference.width!==b.reference.width||s.reference.height!==b.reference.height?{reset:{rects:b}}:{}}}},bi=new Set(["left","top"]);async function wi(t,e){const{placement:n,platform:r,elements:s}=t,i=await(r.isRTL==null?void 0:r.isRTL(s.floating)),o=le(n),l=de(n),c=we(n)==="y",u=bi.has(o)?-1:1,d=i&&c?-1:1,f=ve(e,t);let{mainAxis:h,crossAxis:p,alignmentAxis:g}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof g=="number"&&(p=l==="end"?g*-1:g),c?{x:p*d,y:h*u}:{x:h*u,y:p*d}}const xi=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:s,y:i,placement:o,middlewareData:l}=e,c=await wi(e,t);return o===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:s+c.x,y:i+c.y,data:{...c,placement:o}}}}},yi=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:s}=e,{mainAxis:i=!0,crossAxis:o=!1,limiter:l={fn:m=>{let{x:v,y:T}=m;return{x:v,y:T}}},...c}=ve(t,e),u={x:n,y:r},d=await De(e,c),f=we(le(s)),h=Hn(f);let p=u[h],g=u[f];if(i){const m=h==="y"?"top":"left",v=h==="y"?"bottom":"right",T=p+d[m],x=p-d[v];p=_t(T,p,x)}if(o){const m=f==="y"?"top":"left",v=f==="y"?"bottom":"right",T=g+d[m],x=g-d[v];g=_t(T,g,x)}const b=l.fn({...e,[h]:p,[f]:g});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[h]:i,[f]:o}}}}}},vi=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:s,rects:i,platform:o,elements:l}=e,{apply:c=()=>{},...u}=ve(t,e),d=await De(e,u),f=le(s),h=de(s),p=we(s)==="y",{width:g,height:b}=i.floating;let m,v;f==="top"||f==="bottom"?(m=f,v=h===(await(o.isRTL==null?void 0:o.isRTL(l.floating))?"start":"end")?"left":"right"):(v=f,m=h==="end"?"top":"bottom");const T=b-d.top-d.bottom,x=g-d.left-d.right,C=ge(b-d[m],T),y=ge(g-d[v],x),_=!e.middlewareData.shift;let D=C,E=y;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(E=x),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(D=T),_&&!h){const N=ne(d.left,0),z=ne(d.right,0),I=ne(d.top,0),O=ne(d.bottom,0);p?E=g-2*(N!==0||z!==0?N+z:ne(d.left,d.right)):D=b-2*(I!==0||O!==0?I+O:ne(d.top,d.bottom))}await c({...e,availableWidth:E,availableHeight:D});const B=await o.getDimensions(l.floating);return g!==B.width||b!==B.height?{reset:{rects:!0}}:{}}}};function at(){return typeof window<"u"}function Pe(t){return Yn(t)?(t.nodeName||"").toLowerCase():"#document"}function oe(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Ee(t){var e;return(e=(Yn(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Yn(t){return at()?t instanceof Node||t instanceof oe(t).Node:!1}function fe(t){return at()?t instanceof Element||t instanceof oe(t).Element:!1}function xe(t){return at()?t instanceof HTMLElement||t instanceof oe(t).HTMLElement:!1}function Zn(t){return!at()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof oe(t).ShadowRoot}const Ei=new Set(["inline","contents"]);function qe(t){const{overflow:e,overflowX:n,overflowY:r,display:s}=pe(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!Ei.has(s)}const Ni=new Set(["table","td","th"]);function Si(t){return Ni.has(Pe(t))}const Ci=[":popover-open",":modal"];function lt(t){return Ci.some(e=>{try{return t.matches(e)}catch{return!1}})}const Ti=["transform","translate","scale","rotate","perspective"],_i=["transform","translate","scale","rotate","perspective","filter"],ki=["paint","layout","strict","content"];function Mt(t){const e=It(),n=fe(t)?pe(t):t;return Ti.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||_i.some(r=>(n.willChange||"").includes(r))||ki.some(r=>(n.contain||"").includes(r))}function Ai(t){let e=ke(t);for(;xe(e)&&!Be(e);){if(Mt(e))return e;if(lt(e))return null;e=ke(e)}return null}function It(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Oi=new Set(["html","body","#document"]);function Be(t){return Oi.has(Pe(t))}function pe(t){return oe(t).getComputedStyle(t)}function ct(t){return fe(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function ke(t){if(Pe(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Zn(t)&&t.host||Ee(t);return Zn(e)?e.host:e}function Xn(t){const e=ke(t);return Be(e)?t.ownerDocument?t.ownerDocument.body:t.body:xe(e)&&qe(e)?e:Xn(e)}function Qn(t,e,n){var r;e===void 0&&(e=[]);const s=Xn(t),i=s===((r=t.ownerDocument)==null?void 0:r.body),o=oe(s);return i?(Rt(o),e.concat(o,o.visualViewport||[],qe(s)?s:[],[])):e.concat(s,Qn(s,[]))}function Rt(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function er(t){const e=pe(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const s=xe(t),i=s?t.offsetWidth:n,o=s?t.offsetHeight:r,l=st(n)!==i||st(r)!==o;return l&&(n=i,r=o),{width:n,height:r,$:l}}function tr(t){return fe(t)?t:t.contextElement}function ze(t){const e=tr(t);if(!xe(e))return be(1);const n=e.getBoundingClientRect(),{width:r,height:s,$:i}=er(e);let o=(i?st(n.width):n.width)/r,l=(i?st(n.height):n.height)/s;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const Mi=be(0);function nr(t){const e=oe(t);return!It()||!e.visualViewport?Mi:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Ii(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==oe(t)?!1:e}function Ve(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const s=t.getBoundingClientRect(),i=tr(t);let o=be(1);e&&(r?fe(r)&&(o=ze(r)):o=ze(t));const l=Ii(i,n,r)?nr(i):be(0);let c=(s.left+l.x)/o.x,u=(s.top+l.y)/o.y,d=s.width/o.x,f=s.height/o.y;if(i){const h=oe(i),p=r&&fe(r)?oe(r):r;let g=h,b=Rt(g);for(;b&&r&&p!==g;){const m=ze(b),v=b.getBoundingClientRect(),T=pe(b),x=v.left+(b.clientLeft+parseFloat(T.paddingLeft))*m.x,C=v.top+(b.clientTop+parseFloat(T.paddingTop))*m.y;c*=m.x,u*=m.y,d*=m.x,f*=m.y,c+=x,u+=C,g=oe(b),b=Rt(g)}}return je({width:d,height:f,x:c,y:u})}function ut(t,e){const n=ct(t).scrollLeft;return e?e.left+n:Ve(Ee(t)).left+n}function rr(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-ut(t,n),s=n.top+e.scrollTop;return{x:r,y:s}}function Ri(t){let{elements:e,rect:n,offsetParent:r,strategy:s}=t;const i=s==="fixed",o=Ee(r),l=e?lt(e.floating):!1;if(r===o||l&&i)return n;let c={scrollLeft:0,scrollTop:0},u=be(1);const d=be(0),f=xe(r);if((f||!f&&!i)&&((Pe(r)!=="body"||qe(o))&&(c=ct(r)),xe(r))){const p=Ve(r);u=ze(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const h=o&&!f&&!i?rr(o,c):be(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-c.scrollTop*u.y+d.y+h.y}}function Li(t){return Array.from(t.getClientRects())}function ji(t){const e=Ee(t),n=ct(t),r=t.ownerDocument.body,s=ne(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),i=ne(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+ut(t);const l=-n.scrollTop;return pe(r).direction==="rtl"&&(o+=ne(e.clientWidth,r.clientWidth)-s),{width:s,height:i,x:o,y:l}}const sr=25;function Di(t,e){const n=oe(t),r=Ee(t),s=n.visualViewport;let i=r.clientWidth,o=r.clientHeight,l=0,c=0;if(s){i=s.width,o=s.height;const d=It();(!d||d&&e==="fixed")&&(l=s.offsetLeft,c=s.offsetTop)}const u=ut(r);if(u<=0){const d=r.ownerDocument,f=d.body,h=getComputedStyle(f),p=d.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,g=Math.abs(r.clientWidth-f.clientWidth-p);g<=sr&&(i-=g)}else u<=sr&&(i+=u);return{width:i,height:o,x:l,y:c}}const Pi=new Set(["absolute","fixed"]);function Bi(t,e){const n=Ve(t,!0,e==="fixed"),r=n.top+t.clientTop,s=n.left+t.clientLeft,i=xe(t)?ze(t):be(1),o=t.clientWidth*i.x,l=t.clientHeight*i.y,c=s*i.x,u=r*i.y;return{width:o,height:l,x:c,y:u}}function ir(t,e,n){let r;if(e==="viewport")r=Di(t,n);else if(e==="document")r=ji(Ee(t));else if(fe(e))r=Bi(e,n);else{const s=nr(t);r={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return je(r)}function or(t,e){const n=ke(t);return n===e||!fe(n)||Be(n)?!1:pe(n).position==="fixed"||or(n,e)}function zi(t,e){const n=e.get(t);if(n)return n;let r=Qn(t,[]).filter(l=>fe(l)&&Pe(l)!=="body"),s=null;const i=pe(t).position==="fixed";let o=i?ke(t):t;for(;fe(o)&&!Be(o);){const l=pe(o),c=Mt(o);!c&&l.position==="fixed"&&(s=null),(i?!c&&!s:!c&&l.position==="static"&&!!s&&Pi.has(s.position)||qe(o)&&!c&&or(t,o))?r=r.filter(d=>d!==o):s=l,o=ke(o)}return e.set(t,r),r}function Ui(t){let{element:e,boundary:n,rootBoundary:r,strategy:s}=t;const o=[...n==="clippingAncestors"?lt(e)?[]:zi(e,this._c):[].concat(n),r],l=o[0],c=o.reduce((u,d)=>{const f=ir(e,d,s);return u.top=ne(f.top,u.top),u.right=ge(f.right,u.right),u.bottom=ge(f.bottom,u.bottom),u.left=ne(f.left,u.left),u},ir(e,l,s));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Fi(t){const{width:e,height:n}=er(t);return{width:e,height:n}}function Hi(t,e,n){const r=xe(e),s=Ee(e),i=n==="fixed",o=Ve(t,!0,i,e);let l={scrollLeft:0,scrollTop:0};const c=be(0);function u(){c.x=ut(s)}if(r||!r&&!i)if((Pe(e)!=="body"||qe(s))&&(l=ct(e)),r){const p=Ve(e,!0,i,e);c.x=p.x+e.clientLeft,c.y=p.y+e.clientTop}else s&&u();i&&!r&&s&&u();const d=s&&!r&&!i?rr(s,l):be(0),f=o.left+l.scrollLeft-c.x-d.x,h=o.top+l.scrollTop-c.y-d.y;return{x:f,y:h,width:o.width,height:o.height}}function Lt(t){return pe(t).position==="static"}function ar(t,e){if(!xe(t)||pe(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Ee(t)===n&&(n=n.ownerDocument.body),n}function lr(t,e){const n=oe(t);if(lt(t))return n;if(!xe(t)){let s=ke(t);for(;s&&!Be(s);){if(fe(s)&&!Lt(s))return s;s=ke(s)}return n}let r=ar(t,e);for(;r&&Si(r)&&Lt(r);)r=ar(r,e);return r&&Be(r)&&Lt(r)&&!Mt(r)?n:r||Ai(t)||n}const $i=async function(t){const e=this.getOffsetParent||lr,n=this.getDimensions,r=await n(t.floating);return{reference:Hi(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Ki(t){return pe(t).direction==="rtl"}const qi={convertOffsetParentRelativeRectToViewportRelativeRect:Ri,getDocumentElement:Ee,getClippingRect:Ui,getOffsetParent:lr,getElementRects:$i,getClientRects:Li,getDimensions:Fi,getScale:ze,isElement:fe,isRTL:Ki},cr=xi,ur=fi,dr=yi,fr=pi,pr=vi,hr=hi,mr=ui,gr=gi,br=(t,e,n)=>{const r=new Map,s={platform:qi,...n},i={...s.platform,_c:r};return ci(t,e,{...s,platform:i})};function wr(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=wr(s.content,i.content,n+1);if(o!=null)return o}n+=s.nodeSize}}function xr(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),c=o.nodeSize;if(o==l){n-=c,r-=c;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=xr(o.content,l.content,n-1,r-1);if(u)return u}n-=c,r-=c}}class W{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 c=this.content[o],u=l+c.nodeSize;if(u>e&&r(c,s+l,i||null,o)!==!1&&c.content.size){let d=l+1;c.nodesBetween(Math.max(0,e-d),Math.min(c.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,c)=>{let u=l.isText?l.text.slice(Math.max(e,c)-c,n-c):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&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 W(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],c=o+l.nodeSize;c>e&&((o<e||c>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=c}return new W(r,s)}cutByIndex(e,n){return e==n?W.empty:e==0&&n==this.content.length?this:new W(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 W(s,i)}addToStart(e){return new W([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new W(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 wr(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return xr(this,e,n,r)}findIndex(e){if(e==0)return dt(0,e);if(e==this.size)return dt(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?dt(n+1,i):dt(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 W.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new W(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return W.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 W(n||e,r)}static from(e){if(!e)return W.empty;if(e instanceof W)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new W([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}W.empty=new W([],0);const jt={index:0,offset:0};function dt(t,e){return jt.index=t,jt.offset=e,jt}class Vi 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=vr(this.content,e+this.openStart,n);return r&&new K(r,this.openStart,this.openEnd)}removeBetween(e,n){return new K(yr(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(W.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(W.empty,0,0);function yr(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(yr(i.content,e-s-1,n-s-1)))}function vr(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=vr(o.content,e-i-1,n,o);return l&&t.replaceChild(s,o.copy(l))}const Er=65535,Nr=Math.pow(2,16);function Wi(t,e){return t+e*Nr}function Sr(t){return t&Er}function Ji(t){return(t-(t&Er))/Nr}const Cr=1,Tr=2,ft=4,_r=8;class kr{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&_r)>0}get deletedBefore(){return(this.delInfo&(Cr|ft))>0}get deletedAfter(){return(this.delInfo&(Tr|ft))>0}get deletedAcross(){return(this.delInfo&ft)>0}}class ae{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&ae.empty)return ae.empty}recover(e){let n=0,r=Sr(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+Ji(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 c=this.ranges[l]-(this.inverted?s:0);if(c>e)break;let u=this.ranges[l+i],d=this.ranges[l+o],f=c+u;if(e<=f){let h=u?e==c?-1:e==f?1:n:n,p=c+s+(h<0?0:d);if(r)return p;let g=e==(n<0?c:f)?null:Wi(l/3,e-c),b=e==c?Tr:e==f?Cr:ft;return(n<0?e!=c:e!=f)&&(b|=_r),new kr(p,b,g)}s+=d-u}return r?e+s:new kr(e+s,0,null)}touches(e,n){let r=0,s=Sr(n),i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?r:0);if(c>e)break;let u=this.ranges[l+i],d=c+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),c=o+(this.inverted?0:i),u=this.ranges[s+n],d=this.ranges[s+r];e(l,l+u,c,c+d),i+=d-u}}invert(){return new ae(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?ae.empty:new ae(e<0?[0,-e,0]:[0,0,e])}}ae.empty=new ae([]);const Dt=Object.create(null);class te{getMap(){return ae.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Dt[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 Dt)throw new RangeError("Duplicate use of step JSON ID "+e);return Dt[e]=n,n.prototype.jsonID=e,n}}class Z{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new Z(e,null)}static fail(e){return new Z(null,e)}static fromReplace(e,n,r,s){try{return Z.ok(e.replace(n,r,s))}catch(i){if(i instanceof Vi)return Z.fail(i.message);throw i}}}function Pt(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(Pt(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return W.fromArray(r)}class Me extends te{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(Pt(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 Z.fromReplace(e,this.from,this.to,i)}invert(){return new Ie(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 Me(n.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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Me(n.from,n.to,e.markFromJSON(n.mark))}}te.jsonID("addMark",Me);class Ie extends te{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(Pt(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return Z.fromReplace(e,this.from,this.to,r)}invert(){return new Me(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 Ie(n.pos,r.pos,this.mark)}merge(e){return e instanceof Ie&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ie(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 Ie(n.from,n.to,e.markFromJSON(n.mark))}}te.jsonID("removeMark",Ie);class Re extends te{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Z.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Z.fromReplace(e,this.pos,this.pos+1,new K(W.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 Re(this.pos,n.marks[s]);return new Re(this.pos,this.mark)}}return new We(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Re(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 Re(n.pos,e.markFromJSON(n.mark))}}te.jsonID("addNodeMark",Re);class We extends te{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Z.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Z.fromReplace(e,this.pos,this.pos+1,new K(W.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Re(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new We(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 We(n.pos,e.markFromJSON(n.mark))}}te.jsonID("removeNodeMark",We);class Ne extends te{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&Bt(e,this.from,this.to)?Z.fail("Structure replace would overwrite content"):Z.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new ae([this.from,this.to-this.from,this.slice.size])}invert(e){return new Ne(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 Ne(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Ne)||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 Ne(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 Ne(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 Ne(n.from,n.to,K.fromJSON(e,n.slice),!!n.structure)}}te.jsonID("replace",Ne);class Ue extends te{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&&(Bt(e,this.from,this.gapFrom)||Bt(e,this.gapTo,this.to)))return Z.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Z.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Z.fromReplace(e,this.from,this.to,r):Z.fail("Content does not fit in gap")}getMap(){return new ae([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 Ue(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 Ue(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 Ue(n.from,n.to,n.gapFrom,n.gapTo,K.fromJSON(e,n.slice),n.insert,!!n.structure)}}te.jsonID("replaceAround",Ue);function Bt(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}class Je extends te{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 Z.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 Z.fromReplace(e,this.pos,this.pos+1,new K(W.from(s),0,n.isLeaf?0:1))}getMap(){return ae.empty}invert(e){return new Je(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 Je(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 Je(n.pos,n.attr,n.value)}}te.jsonID("attr",Je);class pt extends te{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 Z.ok(r)}getMap(){return ae.empty}invert(e){return new pt(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 pt(n.attr,n.value)}}te.jsonID("docAttr",pt);let Ge=class extends Error{};Ge=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n},Ge.prototype=Object.create(Error.prototype),Ge.prototype.constructor=Ge,Ge.prototype.name="TransformError";const zt=Object.create(null);class J{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Ar(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:c,$to:u}=o[l],d=e.mapping.slice(i);e.replaceRange(d.map(c.pos),d.map(u.pos),l?K.empty:n),l==0&&Ir(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],c=e.mapping.slice(r),u=c.map(o.pos),d=c.map(l.pos);i?e.deleteRange(u,d):(e.replaceRangeWith(u,d,n),Ir(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new ce(e):Fe(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?Fe(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):Fe(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 Se(e.node(0))}static atStart(e){return Fe(e,e,0,0,1)||new Se(e)}static atEnd(e){return Fe(e,e,e.content.size,e.childCount,-1)||new Se(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=zt[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 zt)throw new RangeError("Duplicate use of selection JSON ID "+e);return zt[e]=n,n.prototype.jsonID=e,n}getBookmark(){return ce.between(this.$anchor,this.$head).getBookmark()}}J.prototype.visible=!0;class Ar{constructor(e,n){this.$from=e,this.$to=n}}let Or=!1;function Mr(t){!Or&&!t.parent.inlineContent&&(Or=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class ce extends J{constructor(e,n=e){Mr(e),Mr(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 J.near(r);let s=e.resolve(n.map(this.anchor));return new ce(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 ce&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new ht(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 ce(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=J.findFrom(n,r,!0)||J.findFrom(n,-r,!0);if(i)n=i.$head;else return J.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(J.findFrom(e,-r,!0)||J.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new ce(e,n)}}J.jsonID("text",ce);class ht{constructor(e,n){this.anchor=e,this.head=n}map(e){return new ht(e.map(this.anchor),e.map(this.head))}resolve(e){return ce.between(e.resolve(this.anchor),e.resolve(this.head))}}class ue extends J{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?J.near(i):new ue(i)}content(){return new K(W.from(this.node),0,0)}eq(e){return e instanceof ue&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Ut(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new ue(e.resolve(n.anchor))}static create(e,n){return new ue(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}ue.prototype.visible=!1,J.jsonID("node",ue);class Ut{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new ht(r,r):new Ut(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&ue.isSelectable(r)?new ue(n):J.near(n)}}class Se extends J{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=J.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Se(e)}map(e){return new Se(e)}eq(e){return e instanceof Se}getBookmark(){return Gi}}J.jsonID("all",Se);const Gi={map(){return this},resolve(t){return new Se(t)}};function Fe(t,e,n,r,s,i=!1){if(e.inlineContent)return ce.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&&ue.isSelectable(l))return ue.create(t,n-(s<0?l.nodeSize:0))}else{let c=Fe(t,l,n+s,s<0?l.childCount:0,s,i);if(c)return c}n+=l.nodeSize*s}return null}function Ir(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof Ne||s instanceof Ue))return;let i=t.mapping.maps[r],o;i.forEach((l,c,u,d)=>{o==null&&(o=d)}),t.setSelection(J.near(t.doc.resolve(o),n))}function Rr(t,e){return!e||!t?t:t.bind(e)}class mt{constructor(e,n,r){this.name=e,this.init=Rr(n.init,r),this.apply=Rr(n.apply,r)}}new mt("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new mt("selection",{init(t,e){return t.selection||J.atStart(e.doc)},apply(t){return t.selection}}),new mt("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new mt("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}});function Lr(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=Lr(s,e,{})),n[r]=s}return n}class jr{constructor(e){this.spec=e,this.props={},e.props&&Lr(e.props,this,this.props),this.key=e.key?e.key.key:Dr("plugin")}getState(e){return e[this.key]}}const Ft=Object.create(null);function Dr(t){return t in Ft?t+"$"+ ++Ft[t]:(Ft[t]=0,t+"$")}class Ye{constructor(e="key"){this.key=Dr(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}for(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:"'"},gt={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Yi=typeof navigator<"u"&&/Mac/.test(navigator.platform),Zi=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Q=0;Q<10;Q++)Ae[48+Q]=Ae[96+Q]=String(Q);for(var Q=1;Q<=24;Q++)Ae[Q+111]="F"+Q;for(var Q=65;Q<=90;Q++)Ae[Q]=String.fromCharCode(Q+32),gt[Q]=String.fromCharCode(Q);for(var Ht in Ae)gt.hasOwnProperty(Ht)||(gt[Ht]=Ae[Ht]);function Xi(t){var e=Yi&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Zi&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?gt:Ae)[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 Qi=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),eo=typeof navigator<"u"&&/Win/.test(navigator.platform);function to(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 c=e[l];if(/^(cmd|meta|m)$/i.test(c))o=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))s=!0;else if(/^s(hift)?$/i.test(c))i=!0;else if(/^mod$/i.test(c))Qi?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),o&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function no(t){let e=Object.create(null);for(let n in t)e[to(n)]=t[n];return e}function $t(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 ro(t){let e=no(t);return function(n,r){let s=Xi(r),i,o=e[$t(s,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[$t(s,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(eo&&r.ctrlKey&&r.altKey)&&(i=Ae[r.keyCode])&&i!=s){let l=e[$t(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var Kt,qt;if(typeof WeakMap<"u"){let t=new WeakMap;Kt=e=>t.get(e),qt=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;Kt=r=>{for(let s=0;s<t.length;s+=2)if(t[s]==r)return t[s+1]},qt=(r,s)=>(n==10&&(n=0),t[n++]=r,t[n++]=s)}var Ce=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const r=e%this.width,s=e/this.width|0;let i=r+1,o=s+1;for(let l=1;i<this.width&&this.map[e+l]==n;l++)i++;for(let l=1;o<this.height&&this.map[e+this.width*l]==n;l++)o++;return{left:r,top:s,right:i,bottom:o}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:r,right:s,top:i,bottom:o}=this.findCell(t);return e=="horiz"?(n<0?r==0:s==this.width)?null:this.map[i*this.width+(n<0?r-1:s)]:(n<0?i==0:o==this.height)?null:this.map[r+this.width*(n<0?i-1:o)]}rectBetween(t,e){const{left:n,right:r,top:s,bottom:i}=this.findCell(t),{left:o,right:l,top:c,bottom:u}=this.findCell(e);return{left:Math.min(n,o),top:Math.min(s,c),right:Math.max(r,l),bottom:Math.max(i,u)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let s=t.left;s<t.right;s++){const i=r*this.width+s,o=this.map[i];n[o]||(n[o]=!0,!(s==t.left&&s&&this.map[i-1]==o||r==t.top&&r&&this.map[i-this.width]==o)&&e.push(o))}return e}positionAt(t,e,n){for(let r=0,s=0;;r++){const i=s+n.child(r).nodeSize;if(r==t){let o=e+t*this.width;const l=(t+1)*this.width;for(;o<l&&this.map[o]<s;)o++;return o==l?i-1:this.map[o]}s=i}}static get(t){return Kt(t)||qt(t,so(t))}};function so(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=io(t),n=t.childCount,r=[];let s=0,i=null;const o=[];for(let u=0,d=e*n;u<d;u++)r[u]=0;for(let u=0,d=0;u<n;u++){const f=t.child(u);d++;for(let g=0;;g++){for(;s<r.length&&r[s]!=0;)s++;if(g==f.childCount)break;const b=f.child(g),{colspan:m,rowspan:v,colwidth:T}=b.attrs;for(let x=0;x<v;x++){if(x+u>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:d,n:v-x});break}const C=s+x*e;for(let y=0;y<m;y++){r[C+y]==0?r[C+y]=d:(i||(i=[])).push({type:"collision",row:u,pos:d,n:m-y});const _=T&&T[y];if(_){const D=(C+y)%e*2,E=o[D];E==null||E!=_&&o[D+1]==1?(o[D]=_,o[D+1]=1):E==_&&o[D+1]++}}}s+=m,d+=b.nodeSize}const h=(u+1)*e;let p=0;for(;s<h;)r[s++]==0&&p++;p&&(i||(i=[])).push({type:"missing",row:u,n:p}),d++}(e===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});const l=new Ce(e,n,r,i);let c=!1;for(let u=0;!c&&u<o.length;u+=2)o[u]!=null&&o[u+1]<n&&(c=!0);return c&&oo(l,o,t),l}function io(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const s=t.child(r);let i=0;if(n)for(let o=0;o<r;o++){const l=t.child(o);for(let c=0;c<l.childCount;c++){const u=l.child(c);o+u.attrs.rowspan>r&&(i+=u.attrs.colspan)}}for(let o=0;o<s.childCount;o++){const l=s.child(o);i+=l.attrs.colspan,l.attrs.rowspan>1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function oo(t,e,n){t.problems||(t.problems=[]);const r={};for(let s=0;s<t.map.length;s++){const i=t.map[s];if(r[i])continue;r[i]=!0;const o=n.nodeAt(i);if(!o)throw new RangeError(`No cell with offset ${i} found`);let l=null;const c=o.attrs;for(let u=0;u<c.colspan;u++){const d=(s+u)%t.width,f=e[d*2];f!=null&&(!c.colwidth||c.colwidth[u]!=f)&&((l||(l=ao(c)))[u]=f)}l&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function ao(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function Vt(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],s=r.spec.tableRole;s&&(e[s]=r)}}return e}new Ye("selectingCells");function lo(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function Pr(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function co(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=lo(e.$head)||uo(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function uo(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function Br(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function zr(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Ur(t,e,n){const r=t.node(-1),s=Ce.get(r),i=t.start(-1),o=s.nextCell(t.pos-i,e,n);return o==null?null:t.node(0).resolve(i+o)}function Fr(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(s=>s>0)||(r.colwidth=null)),r}var ye=class _e extends J{constructor(e,n=e){const r=e.node(-1),s=Ce.get(r),i=e.start(-1),o=s.rectBetween(e.pos-i,n.pos-i),l=e.node(0),c=s.cellsInRect(o).filter(d=>d!=n.pos-i);c.unshift(n.pos-i);const u=c.map(d=>{const f=r.nodeAt(d);if(!f)throw RangeError(`No cell with offset ${d} found`);const h=i+d+1;return new Ar(l.resolve(h),l.resolve(h+f.content.size))});super(u[0].$from,u[0].$to,u),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),s=e.resolve(n.map(this.$headCell.pos));if(Br(r)&&Br(s)&&zr(r,s)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?_e.rowSelection(r,s):i&&this.isColSelection()?_e.colSelection(r,s):new _e(r,s)}return ce.between(r,s)}content(){const e=this.$anchorCell.node(-1),n=Ce.get(e),r=this.$anchorCell.start(-1),s=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},o=[];for(let c=s.top;c<s.bottom;c++){const u=[];for(let d=c*n.width+s.left,f=s.left;f<s.right;f++,d++){const h=n.map[d];if(i[h])continue;i[h]=!0;const p=n.findCell(h);let g=e.nodeAt(h);if(!g)throw RangeError(`No cell with offset ${h} found`);const b=s.left-p.left,m=p.right-s.right;if(b>0||m>0){let v=g.attrs;if(b>0&&(v=Fr(v,0,b)),m>0&&(v=Fr(v,v.colspan-m,m)),p.left<s.left){if(g=g.type.createAndFill(v),!g)throw RangeError(`Could not create cell with attrs ${JSON.stringify(v)}`)}else g=g.type.create(v,g.content)}if(p.top<s.top||p.bottom>s.bottom){const v={...g.attrs,rowspan:Math.min(p.bottom,s.bottom)-Math.max(p.top,s.top)};p.top<s.top?g=g.type.createAndFill(v):g=g.type.create(v,g.content)}u.push(g)}o.push(e.child(c).copy(W.from(u)))}const l=this.isColSelection()&&this.isRowSelection()?e:o;return new K(W.from(l),1,1)}replace(e,n=K.empty){const r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){const{$from:l,$to:c}=s[o],u=e.mapping.slice(r);e.replace(u.map(l.pos),u.map(c.pos),o?K.empty:n)}const i=J.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new K(W.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=Ce.get(n),s=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let o=0;o<i.length;o++)e(n.nodeAt(i[o]),s+i[o])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,s)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),s=Ce.get(r),i=e.start(-1),o=s.findCell(e.pos-i),l=s.findCell(n.pos-i),c=e.node(0);return o.top<=l.top?(o.top>0&&(e=c.resolve(i+s.map[o.left])),l.bottom<s.height&&(n=c.resolve(i+s.map[s.width*(s.height-1)+l.right-1]))):(l.top>0&&(n=c.resolve(i+s.map[l.left])),o.bottom<s.height&&(e=c.resolve(i+s.map[s.width*(s.height-1)+o.right-1]))),new _e(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=Ce.get(e),r=this.$anchorCell.start(-1),s=n.colCount(this.$anchorCell.pos-r),i=n.colCount(this.$headCell.pos-r);if(Math.min(s,i)>0)return!1;const o=s+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,l)==n.width}eq(e){return e instanceof _e&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),s=Ce.get(r),i=e.start(-1),o=s.findCell(e.pos-i),l=s.findCell(n.pos-i),c=e.node(0);return o.left<=l.left?(o.left>0&&(e=c.resolve(i+s.map[o.top*s.width])),l.right<s.width&&(n=c.resolve(i+s.map[s.width*(l.top+1)-1]))):(l.left>0&&(n=c.resolve(i+s.map[l.top*s.width])),o.right<s.width&&(e=c.resolve(i+s.map[s.width*(o.top+1)-1]))),new _e(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new _e(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new _e(e.resolve(n),e.resolve(r))}getBookmark(){return new fo(this.$anchorCell.pos,this.$headCell.pos)}};ye.prototype.visible=!1,J.jsonID("cell",ye);var fo=class Gr{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Gr(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&zr(n,r)?new ye(n,r):J.near(r,1)}};new Ye("fix-tables");function Hr(t){const e=t.selection,n=co(t),r=n.node(-1),s=n.start(-1),i=Ce.get(r);return{...e instanceof ye?i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):i.findCell(n.pos-s),tableStart:s,map:i,table:r}}function po(t){return function(e,n){if(!Pr(e))return!1;if(n){const r=Vt(e.schema),s=Hr(e),i=e.tr,o=s.map.cellsInRect(t=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:t=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),l=o.map(c=>s.table.nodeAt(c));for(let c=0;c<o.length;c++)l[c].type==r.header_cell&&i.setNodeMarkup(s.tableStart+o[c],r.cell,l[c].attrs);if(i.steps.length==0)for(let c=0;c<o.length;c++)i.setNodeMarkup(s.tableStart+o[c],r.header_cell,l[c].attrs);n(i)}return!0}}function $r(t,e,n){const r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let s=0;s<r.length;s++){const i=e.table.nodeAt(r[s]);if(i&&i.type!==n.header_cell)return!1}return!0}function Wt(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?po(t):function(n,r){if(!Pr(n))return!1;if(r){const s=Vt(n.schema),i=Hr(n),o=n.tr,l=$r("row",i,s),c=$r("column",i,s),d=(t==="column"?l:t==="row"?c:!1)?1:0,f=t=="column"?{left:0,top:d,right:1,bottom:i.map.height}:t=="row"?{left:d,top:0,right:i.map.width,bottom:1}:i,h=t=="column"?c?s.cell:s.header_cell:t=="row"?l?s.cell:s.header_cell:s.cell;i.map.cellsInRect(f).forEach(p=>{const g=p+i.tableStart,b=o.doc.nodeAt(g);b&&o.setNodeMarkup(g,h,b.attrs)}),r(o)}return!0}}Wt("row",{useDeprecatedLogic:!0}),Wt("column",{useDeprecatedLogic:!0}),Wt("cell",{useDeprecatedLogic:!0});function bt(t,e){const n=t.selection;if(!(n instanceof ye))return!1;if(e){const r=t.tr,s=Vt(t.schema).cell.createAndFill().content;n.forEachCell((i,o)=>{i.content.eq(s)||r.replace(r.mapping.map(o+1),r.mapping.map(o+i.nodeSize-1),new K(s,0,0))}),r.docChanged&&e(r)}return!0}ro({ArrowLeft:xt("horiz",-1),ArrowRight:xt("horiz",1),ArrowUp:xt("vert",-1),ArrowDown:xt("vert",1),"Shift-ArrowLeft":yt("horiz",-1),"Shift-ArrowRight":yt("horiz",1),"Shift-ArrowUp":yt("vert",-1),"Shift-ArrowDown":yt("vert",1),Backspace:bt,"Mod-Backspace":bt,Delete:bt,"Mod-Delete":bt});function wt(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function xt(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;if(i instanceof ye)return wt(n,r,J.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const o=Kr(s,t,e);if(o==null)return!1;if(t=="horiz")return wt(n,r,J.near(n.doc.resolve(i.head+e),e));{const l=n.doc.resolve(o),c=Ur(l,t,e);let u;return c?u=J.near(c,1):e<0?u=J.near(n.doc.resolve(l.before(-1)),-1):u=J.near(n.doc.resolve(l.after(-1)),1),wt(n,r,u)}}}function yt(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;let o;if(i instanceof ye)o=i;else{const c=Kr(s,t,e);if(c==null)return!1;o=new ye(n.doc.resolve(c))}const l=Ur(o.$headCell,t,e);return l?wt(n,r,new ye(o.$anchorCell,l)):!1}}function Kr(t,e,n){if(!(t.state.selection instanceof ce))return null;const{$head:r}=t.state.selection;for(let s=r.depth-1;s>=0;s--){const i=r.node(s);if((n<0?r.index(s):r.indexAfter(s))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const l=r.before(s),c=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(c)?l:null}}return null}new Ye("tableColumnResizing");function ho(t,e){const n=Math.min(t.top,e.top),r=Math.max(t.bottom,e.bottom),s=Math.min(t.left,e.left),o=Math.max(t.right,e.right)-s,l=r-n,c=s,u=n;return new DOMRect(c,u,o,l)}var mo=class{constructor({editor:t,element:e,view:n,updateDelay:r=250,resizeDelay:s=60,shouldShow:i,appendTo:o,options:l}){this.preventHide=!1,this.isVisible=!1,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:c,state:u,from:d,to:f})=>{const{doc:h,selection:p}=u,{empty:g}=p,b=!h.textBetween(d,f).length&&V.isTextSelection(u.selection),m=this.element.contains(document.activeElement);return!(!(c.hasFocus()||m)||g||b||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:c})=>{var u;if(this.preventHide){this.preventHide=!1;return}c?.relatedTarget&&((u=this.element.parentNode)!=null&&u.contains(c.relatedTarget))||c?.relatedTarget!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(c,u)=>{const d=!u?.selection.eq(c.state.selection),f=!u?.doc.eq(c.state.doc);!d&&!f||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(c,d,f,u)},this.updateDelay))},this.updateHandler=(c,u,d,f)=>{const{composing:h}=c;if(h||!u&&!d)return;if(!this.getShouldShow(f)){this.hide();return}this.updatePosition(),this.show()},this.editor=t,this.element=e,this.view=n,this.updateDelay=r,this.resizeDelay=s,this.appendTo=o,this.floatingUIOptions={...this.floatingUIOptions,...l},this.element.tabIndex=0,i&&(this.shouldShow=i),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),window.addEventListener("resize",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&this.show()}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(fr(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(dr(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(cr(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(mr(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(pr(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(ur(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(hr(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(gr(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),t}updatePosition(){const{selection:t}=this.editor.state,e=V.posToDOMRect(this.view,t.from,t.to);let n={getBoundingClientRect:()=>e,getClientRects:()=>[e]};if(t instanceof ue){let r=this.view.nodeDOM(t.from);const s=r.dataset.nodeViewWrapper?r:r.querySelector("[data-node-view-wrapper]");s&&(r=s),r&&(n={getBoundingClientRect:()=>r.getBoundingClientRect(),getClientRects:()=>[r.getBoundingClientRect()]})}if(t instanceof ye){const{$anchorCell:r,$headCell:s}=t,i=r?r.pos:s.pos,o=s?s.pos:r.pos,l=this.view.nodeDOM(i),c=this.view.nodeDOM(o);if(!l||!c)return;const u=l===c?l.getBoundingClientRect():ho(l.getBoundingClientRect(),c.getBoundingClientRect());n={getBoundingClientRect:()=>u,getClientRects:()=>[u]}}br(n,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:r,y:s,strategy:i})=>{this.element.style.width="max-content",this.element.style.position=i,this.element.style.left=`${r}px`,this.element.style.top=`${s}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(t,e){const{state:n}=t,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r){this.handleDebouncedUpdate(t,e);return}const s=!e?.selection.eq(t.state.selection),i=!e?.doc.eq(t.state.doc);this.updateHandler(t,s,i,e)}getShouldShow(t){var e;const{state:n}=this.view,{selection:r}=n,{ranges:s}=r,i=Math.min(...s.map(c=>c.$from.pos)),o=Math.max(...s.map(c=>c.$to.pos));return(e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,element:this.element,view:this.view,state:n,oldState:t,from:i,to:o})}show(){var t,e;this.isVisible||(this.element.style.visibility="visible",this.element.style.opacity="1",(e=(t=this.appendTo)!=null?t:this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},qr=t=>new jr({key:typeof t.pluginKey=="string"?new Ye(t.pluginKey):t.pluginKey,view:e=>new mo({view:e,...t})});V.Extension.create({name:"bubbleMenu",addOptions(){return{element:null,pluginKey:"bubbleMenu",updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[qr({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}});var go=class{constructor({editor:t,element:e,view:n,options:r,shouldShow:s}){this.preventHide=!1,this.isVisible=!1,this.shouldShow=({view:i,state:o})=>{const{selection:l}=o,{$anchor:c,empty:u}=l,d=c.depth===1,f=c.parent.isTextblock&&!c.parent.type.spec.code&&!c.parent.textContent&&c.parent.childCount===0&&!this.getTextContent(c.parent);return!(!i.hasFocus()||!u||!d||!f||!this.editor.isEditable)},this.floatingUIOptions={strategy:"absolute",placement:"right",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(i,o,l,c)=>{const{composing:u}=i;if(u||!o&&!l)return;if(!this.getShouldShow(c)){this.hide();return}this.updatePosition(),this.show()},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:i})=>{var o;if(this.preventHide){this.preventHide=!1;return}i?.relatedTarget&&((o=this.element.parentNode)!=null&&o.contains(i.relatedTarget))||i?.relatedTarget!==this.editor.view.dom&&this.hide()},this.editor=t,this.element=e,this.view=n,this.floatingUIOptions={...this.floatingUIOptions,...r},this.element.tabIndex=0,s&&(this.shouldShow=s),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.update(n,n.state),this.getShouldShow()&&this.show()}getTextContent(t){return V.getText(t,{textSerializers:V.getTextSerializersFromSchema(this.editor.schema)})}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(fr(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(dr(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(cr(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(mr(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(pr(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(ur(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(hr(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(gr(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),t}getShouldShow(t){var e;const{state:n}=this.view,{selection:r}=n,{ranges:s}=r,i=Math.min(...s.map(c=>c.$from.pos)),o=Math.max(...s.map(c=>c.$to.pos));return(e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,view:this.view,state:n,oldState:t,from:i,to:o})}updatePosition(){const{selection:t}=this.editor.state,e=V.posToDOMRect(this.view,t.from,t.to);br({getBoundingClientRect:()=>e,getClientRects:()=>[e]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:r,y:s,strategy:i})=>{this.element.style.width="max-content",this.element.style.position=i,this.element.style.left=`${r}px`,this.element.style.top=`${s}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(t,e){const n=!e?.selection.eq(t.state.selection),r=!e?.doc.eq(t.state.doc);this.updateHandler(t,n,r,e)}show(){var t;this.isVisible||(this.element.style.visibility="visible",this.element.style.opacity="1",(t=this.view.dom.parentElement)==null||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},Vr=t=>new jr({key:typeof t.pluginKey=="string"?new Ye(t.pluginKey):t.pluginKey,view:e=>new go({view:e,...t})});V.Extension.create({name:"floatingMenu",addOptions(){return{element:null,options:{},pluginKey:"floatingMenu",shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[Vr({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,options:this.options.options,shouldShow:this.options.shouldShow})]:[]}});var Wr=S.forwardRef(({pluginKey:t="bubbleMenu",editor:e,updateDelay:n,resizeDelay:r,shouldShow:s=null,options:i,children:o,...l},c)=>{const u=S.useRef(document.createElement("div"));typeof c=="function"?c(u.current):c&&(c.current=u.current);const{editor:d}=Y.useCurrentEditor();return S.useEffect(()=>{const f=u.current;if(f.style.visibility="hidden",f.style.position="absolute",e?.isDestroyed||d?.isDestroyed)return;const h=e||d;if(!h){console.warn("BubbleMenu component is not rendered inside of an editor component or does not have editor prop.");return}const p=qr({updateDelay:n,resizeDelay:r,editor:h,element:f,pluginKey:t,shouldShow:s,options:i});return h.registerPlugin(p),()=>{h.unregisterPlugin(t),window.requestAnimationFrame(()=>{f.parentNode&&f.parentNode.removeChild(f)})}},[e,d]),Xt.createPortal(a.jsx("div",{...l,children:o}),u.current)}),bo=S.forwardRef(({pluginKey:t="floatingMenu",editor:e,shouldShow:n=null,options:r,children:s,...i},o)=>{const l=S.useRef(document.createElement("div"));typeof o=="function"?o(l.current):o&&(o.current=l.current);const{editor:c}=Y.useCurrentEditor();return S.useEffect(()=>{const u=l.current;if(u.style.visibility="hidden",u.style.position="absolute",e?.isDestroyed||c?.isDestroyed)return;const d=e||c;if(!d){console.warn("FloatingMenu component is not rendered inside of an editor component or does not have editor prop.");return}const f=Vr({editor:d,element:u,pluginKey:t,shouldShow:n,options:r});return d.registerPlugin(f),()=>{d.unregisterPlugin(t),window.requestAnimationFrame(()=>{u.parentNode&&u.parentNode.removeChild(u)})}},[e,c]),Xt.createPortal(a.jsx("div",{...i,children:s}),l.current)});const wo=({editor:t,isReadOnly:e})=>{const[n,r]=S.useState(!1),[s,i]=S.useState(!1),[o,l]=S.useState(""),[c,u]=S.useState(!1),d=()=>{o&&(t.chain().focus().extendMarkRange("link").setLink({href:o}).run(),l(""),u(!1))};return e?null:a.jsx(Wr,{editor:t,shouldShow:({editor:f,state:h})=>{const{from:p,to:g}=h.selection;return p!==g&&!f.isActive("codeBlock")},className:"bubble-menu bg-white border border-gray-300 rounded-lg p-2 shadow-lg z-50",children:a.jsxs("div",{className:"flex gap-1 items-center",children:[a.jsx(P,{onClick:()=>t.chain().focus().toggleBold().run(),isActive:t.isActive("bold"),title:"Bold",children:a.jsx(k.Bold,{className:"h-4 w-4 cursor-pointer"})}),a.jsx(P,{onClick:()=>t.chain().focus().toggleItalic().run(),isActive:t.isActive("italic"),title:"Italic",children:a.jsx(k.Italic,{className:"h-4 w-4 cursor-pointer"})}),a.jsx(P,{onClick:()=>t.chain().focus().toggleUnderline().run(),isActive:t.isActive("underline"),title:"Underline",children:a.jsx(k.Underline,{className:"h-4 w-4 cursor-pointer"})}),a.jsx(P,{onClick:()=>t.chain().focus().toggleStrike().run(),isActive:t.isActive("strike"),title:"Strikethrough",children:a.jsx(k.Strikethrough,{className:"h-4 w-4 cursor-pointer"})}),a.jsx(P,{onClick:()=>t.chain().focus().toggleCode().run(),isActive:t.isActive("code"),title:"Inline Code",children:a.jsx(k.Code,{className:"h-4 w-4 cursor-pointer"})}),a.jsxs("div",{className:"relative",children:[a.jsx(P,{onClick:()=>r(!n),title:"Text Color",children:a.jsx(k.Type,{className:"h-4 w-4 cursor-pointer"})}),n&&a.jsx("div",{className:"absolute top-full mt-1 z-10 bg-white border border-gray-300 rounded-lg p-2 shadow-lg",children:a.jsx(Zs,{onColorChange:f=>{t.chain().focus().setColor(f).run(),r(!1)}})})]}),a.jsxs("div",{className:"relative",children:[a.jsx(P,{onClick:()=>i(!s),title:"Background Color",children:a.jsx(k.Palette,{className:"h-4 w-4 cursor-pointer"})}),s&&a.jsx("div",{className:"absolute top-full mt-1 z-10 bg-white border border-gray-300 rounded-lg p-2 shadow-lg",children:a.jsx(Xs,{onColorChange:f=>{t.chain().focus().toggleHighlight({color:f}).run(),i(!1)}})})]}),a.jsxs("div",{className:"relative",children:[a.jsx(P,{onClick:()=>u(!c),isActive:t.isActive("link"),title:"Add/Edit Link",children:a.jsx(k.Link,{className:"h-4 w-4 cursor-pointer"})}),c&&a.jsx("div",{className:"absolute top-full mt-1 z-10 bg-white border border-gray-300 rounded-lg p-2 shadow-lg",children:a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"url",placeholder:"Enter URL...",value:o,onChange:f=>l(f.target.value),className:"px-2 py-1 text-sm border border-gray-300 rounded",onKeyDown:f=>{f.key==="Enter"&&d()}}),a.jsx(q,{type:"button",onClick:d,size:"sm",className:"h-8 cursor-pointer",children:"Set"})]})})]})]})})},xo=[{label:"Green",value:"#4caf5040"},{label:"Red",value:"#f4433640"},{label:"Grey",value:"#9e9e9e40"}],yo=({onColorChange:t})=>a.jsx("div",{className:"flex gap-2",children:xo.map(({label:e,value:n})=>a.jsxs("button",{type:"button",className:"flex flex-col items-center text-xs text-gray-600",onClick:()=>t(n),children:[a.jsx("span",{className:"w-6 h-6 rounded border border-gray-300 cursor-pointer hover:scale-110 transition-transform",style:{backgroundColor:n}}),e]},n))}),Jr=[{value:"",label:"Plain Text"},{value:"html",label:"HTML"},{value:"css",label:"CSS"},{value:"js",label:"JavaScript"},{value:"ts",label:"TypeScript"},{value:"python",label:"Python"},{value:"java",label:"Java"},{value:"c",label:"C"},{value:"cpp",label:"C++"},{value:"sql",label:"SQL"}],vo=({editor:t,isReadOnly:e})=>{const[n,r]=S.useState(!1),[s,i]=S.useState(!1),o=S.useRef(null),l=t.getAttributes("codeBlock").language||"";if(S.useEffect(()=>{const u=d=>{o.current&&!o.current.contains(d.target)&&i(!1)};return s&&document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u)}},[s]),e)return null;const c=u=>{t.chain().focus().updateAttributes("codeBlock",{language:u||null}).run(),i(!1)};return a.jsx(Wr,{editor:t,shouldShow:({editor:u})=>u.isActive("codeBlock"),className:"bubble-menu bg-white border border-gray-300 rounded-lg p-2 shadow-lg z-50",children:a.jsxs("div",{className:"flex gap-1 items-center",children:[a.jsxs("div",{className:"relative",ref:o,children:[a.jsx(P,{onClick:()=>{i(!s),r(!1)},title:"Select Language",className:"px-2 min-w-[120px]",children:a.jsxs("div",{className:"flex items-center gap-1 w-full justify-between",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(k.Code,{className:"h-3 w-3"}),a.jsx("span",{className:"text-xs",children:Jr.find(u=>u.value===l)?.label||"Plain Text"})]}),a.jsx(k.ChevronDown,{className:"h-3 w-3"})]})}),s&&a.jsx("div",{className:"absolute top-full mt-1 left-0 z-10 bg-white border border-gray-300 rounded-lg shadow-lg min-w-[140px] max-h-[300px] overflow-y-auto",children:a.jsx("div",{className:"p-1 space-y-1",children:Jr.map(u=>a.jsx(q,{type:"button",variant:l===u.value?"default":"ghost",size:"sm",onClick:()=>c(u.value),className:`w-full justify-start text-xs hover:bg-gray-100 ${l===u.value?"bg-blue-600 text-white hover:bg-blue-700":""}`,children:u.label},u.value))})})]}),a.jsxs("div",{className:"relative",children:[a.jsx(P,{onClick:()=>{r(!n),i(!1)},title:"Background Color",isActive:t.isActive("codeBlockBg"),children:a.jsx(k.Palette,{className:"h-4 w-4 cursor-pointer"})}),n&&a.jsx("div",{className:"absolute top-full mt-1 z-10 bg-white border border-gray-300 rounded-lg p-2 shadow-lg",children:a.jsx(yo,{onColorChange:u=>{t.chain().focus().toggleCodeBlockBg(u).run(),r(!1)}})})]})]})})},Eo=({editor:t,isReadOnly:e,onImageClick:n})=>e?null:a.jsxs(bo,{editor:t,className:"floating-menu bg-white border border-gray-300 rounded-lg p-2 shadow-lg flex gap-1 z-50",children:[a.jsx(P,{onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),title:"Heading 1",children:a.jsx(k.Heading1,{className:"h-4 w-4"})}),a.jsx(P,{onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),title:"Heading 2",children:a.jsx(k.Heading2,{className:"h-4 w-4"})}),a.jsx(P,{onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),title:"Heading 3",children:a.jsx(k.Heading3,{className:"h-4 w-4"})}),a.jsx(P,{onClick:()=>t.chain().focus().setParagraph().run(),title:"Paragraph",children:a.jsx(k.FileText,{className:"h-4 w-4"})}),a.jsx(P,{onClick:n,title:"Insert Image",children:a.jsx(k.Image,{className:"h-4 w-4"})})]}),No=({editor:t,isReadOnly:e,position:n})=>!n.show||e?null:a.jsxs("div",{className:"table-bubble-menu bg-white border-2 border-blue-500 rounded-lg p-2 shadow-lg",style:{position:"absolute",top:`${n.top}px`,left:`${n.left}px`,zIndex:50,backdropFilter:"blur(8px)",background:"rgba(255, 255, 255, 0.95)"},children:[a.jsxs("div",{className:"flex gap-1 items-center",children:[a.jsx(P,{onClick:()=>t.chain().focus().addRowBefore().run(),title:"Add Row Before",className:"h-8 w-auto px-2",children:a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(k.Plus,{className:"h-3 w-3"}),a.jsx("span",{className:"text-xs",children:"↑ Row"})]})}),a.jsx(P,{onClick:()=>t.chain().focus().addRowAfter().run(),title:"Add Row After",className:"h-8 w-auto px-2",children:a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(k.Plus,{className:"h-3 w-3"}),a.jsx("span",{className:"text-xs",children:"Row ↓"})]})}),a.jsx("div",{className:"h-6 w-px bg-gray-300 mx-1"}),a.jsx(P,{onClick:()=>t.chain().focus().addColumnBefore().run(),title:"Add Column Before",className:"h-8 w-auto px-2",children:a.jsxs("div",{className:"flex items-center gap-1",children:["ß",a.jsx(k.Plus,{className:"h-3 w-3"}),a.jsx("span",{className:"text-xs",children:"← Col"})]})}),a.jsx(P,{onClick:()=>t.chain().focus().addColumnAfter().run(),title:"Add Column After",className:"h-8 w-auto px-2",children:a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(k.Plus,{className:"h-3 w-3"}),a.jsx("span",{className:"text-xs",children:"Col →"})]})}),a.jsx("div",{className:"h-6 w-px bg-gray-300 mx-1"}),a.jsx(P,{onClick:()=>t.chain().focus().deleteColumn().run(),title:"Delete Column",className:"text-red-600 hover:bg-red-50 h-8 w-auto px-2",children:a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(k.Minus,{className:"h-3 w-3"}),a.jsx("span",{className:"text-xs",children:"Col"})]})}),a.jsx("div",{className:"h-6 w-px bg-gray-300 mx-1"}),a.jsx(P,{onClick:()=>t.chain().focus().deleteRow().run(),title:"Delete Row",className:"text-red-600 hover:bg-red-50 h-8 w-auto px-2",children:a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(k.Minus,{className:"h-3 w-3"}),a.jsx("span",{className:"text-xs",children:"Row"})]})}),a.jsx(P,{onClick:()=>t.chain().focus().deleteTable().run(),title:"Delete Table",className:"text-red-600 hover:bg-red-50",children:a.jsx(k.Trash2,{className:"h-4 w-4"})})]}),a.jsx("div",{className:"absolute top-full left-5 w-0 h-0 border-l-6 border-r-6 border-t-6 border-l-transparent border-r-transparent border-t-blue-500"})]}),So=({editor:t})=>a.jsxs("div",{className:"mb-2 p-2 bg-gray-100 rounded text-xs",children:[a.jsx("strong",{children:"Debug:"})," Current position - H1:"," ",t.isActive("heading",{level:1})?"✅":"❌"," | H2:"," ",t.isActive("heading",{level:2})?"✅":"❌"," | H3:"," ",t.isActive("heading",{level:3})?"✅":"❌"," | P:"," ",t.isActive("paragraph")?"✅":"❌"," | Bold:"," ",t.isActive("bold")?"✅":"❌"," | List:"," ",t.isActive("bulletList")?"✅":"❌"," | Table:"," ",t.isActive("table")?"✅":"❌"]}),Co=({isReadOnly:t,setIsReadOnly:e,onLogContent:n})=>a.jsxs("div",{className:"mb-4 flex justify-end gap-2",children:[a.jsxs(q,{type:"button",onClick:n,variant:"outline",size:"sm",className:"flex items-center gap-2",title:"Log content to console for backend storage",children:[a.jsx(k.Terminal,{className:"h-4 w-4"}),"Log Content"]}),a.jsx(q,{type:"button",onClick:()=>e(!t),variant:t?"default":"outline",size:"sm",className:"flex items-center gap-2",children:t?a.jsxs(a.Fragment,{children:[a.jsx(k.Lock,{className:"h-4 w-4"}),"Read Only"]}):a.jsxs(a.Fragment,{children:[a.jsx(k.LockOpen,{className:"h-4 w-4"}),"Editable"]})})]}),To=t=>{const e={html:t.getHTML(),json:t.getJSON(),text:t.getText(),isEmpty:t.isEmpty,characterCount:t.storage.characterCount?.characters()||t.getText().length,wordCount:t.storage.characterCount?.words()||t.getText().split(/\s+/).filter(n=>n.length>0).length,timestamp:new Date().toISOString()};return console.log("📄 Tiptap Editor Content for Backend Storage:"),console.log("================================================"),console.log("📋 HTML Output (for rendering):",e.html),console.log("📋 JSON Output (for editing):",e.json),console.log("📋 Plain Text:",e.text),console.log("📊 Stats:",{isEmpty:e.isEmpty,characters:e.characterCount,words:e.wordCount,timestamp:e.timestamp}),console.log("================================================"),e},_o=({onImageUpload:t,onVideoUpload:e,onImageDelete:n,onVideoDelete:r,content:s,setEditorContent:i})=>{const[o,l]=S.useState(""),[c,u]=S.useState(!1),[,d]=S.useState({}),[f,h]=S.useState(!1),[p,g]=S.useState(!1),[b,m]=S.useState(!1),[v,T]=S.useState(null),x=S.useRef(null),[C,y]=S.useState({top:0,left:0,show:!1}),_=O=>{const L=new Set,j=A=>{A.type==="image"&&A.attrs?.src&&L.add(A.attrs.src),A.content&&Array.isArray(A.content)&&A.content.forEach(j)};return j(O),L},D=O=>{const L=new Set,j=A=>{A.type==="video"&&A.attrs?.src&&L.add(A.attrs.src),A.content&&Array.isArray(A.content)&&A.content.forEach(j)};return j(O),L},E=Y.useEditor({extensions:[nn,ms,Jt,Yt,Gt,rn,sn,Sn,Cn,on,an,ln,Nn,En,Tn,_n,kn,An,On,Mn,In,Ln,Dn,Pn,jn.configure({inline:!1,allowBase64:!0,HTMLAttributes:{class:"max-w-full h-auto rounded-lg shadow-sm"}})],content:s||`
|
|
73
|
+
</html>`}const Qs=[{id:"html",label:"HTML"},{id:"css",label:"CSS"},{id:"js",label:"JS"}],Ve="Interactive view",it="auto",ei=t=>{const e=(t||"").trim().toLowerCase();return e===""||e==="auto"||e==="fit"||e==="fit-content"||e==="max"||e==="max-content"},ti=t=>{const e=(t||"").trim();if(!e)return it;if(/^\d+(\.\d+)?$/.test(e))return`${e}px`;const n=e.toLowerCase();return n==="min"||n==="min-content"?"min-content":(/^\d+(\.\d+)?(px|%|em|rem|vh|vw|vmin|vmax|ch|pt|pc|cm|mm|in)$/i.test(e),e)},ni=({node:t,updateAttributes:e,deleteNode:n,editor:r})=>{const[s,i]=N.useState(!!t.attrs.pendingEdit),[a,l]=N.useState("html"),[c,d]=N.useState("code"),[u,f]=N.useState(0),[m,p]=N.useState(null),b=N.useRef(null),w=N.useRef(null),[g,_]=N.useState({html:t.attrs.html||"",css:t.attrs.css||"",js:t.attrs.js||"",height:t.attrs.height||it,title:t.attrs.title||Ve}),[C,y]=N.useState(r?.isEditable??!1);N.useEffect(()=>{t.attrs.pendingEdit&&C&&(i(!0),e({pendingEdit:!1}))},[t.attrs.pendingEdit,C,e]),N.useEffect(()=>{if(!r)return;const v=()=>y(r.isEditable);return v(),r.on("update",v),r.on("selectionUpdate",v),()=>{r.off("update",v),r.off("selectionUpdate",v)}},[r]);const T=N.useMemo(()=>zn(t.attrs.html,t.attrs.css,t.attrs.js),[t.attrs.html,t.attrs.css,t.attrs.js]),x=N.useMemo(()=>zn(g.html,g.css,g.js),[g.html,g.css,g.js]),k=()=>{C&&(_({html:t.attrs.html||"",css:t.attrs.css||"",js:t.attrs.js||"",height:t.attrs.height||it,title:t.attrs.title||Ve}),l("html"),d("code"),i(!0))},M=()=>{C&&(e(g),f(v=>v+1),i(!1))},z=()=>{_({html:t.attrs.html||"",css:t.attrs.css||"",js:t.attrs.js||"",height:t.attrs.height||it,title:t.attrs.title||Ve}),i(!1)},D=()=>{f(v=>v+1),d("preview")},S=(v,U)=>{_(P=>({...P,[v]:U}))};N.useEffect(()=>{const v=U=>{if(!w.current||U.source!==w.current.contentWindow)return;const P=U.data;P&&P.type==="live-preview-height"&&typeof P.height=="number"&&p(P.height)};return window.addEventListener("message",v),()=>window.removeEventListener("message",v)},[]);const L=(v,U,P)=>{const J=ei(U),G=J?m!=null?`${m}px`:"auto":ti(U);return o.jsx("iframe",{ref:w,title:t.attrs.title||Ve,srcDoc:v,sandbox:"allow-scripts allow-modals",className:"live-preview-iframe",scrolling:J?"no":"auto",style:{width:"100%",height:G,border:"none",borderRadius:0,display:"block"}},P)};return s?o.jsx(q.NodeViewWrapper,{className:"live-preview-extension live-preview-editing",children:o.jsxs("div",{className:"live-preview-editor-panel",children:[o.jsxs("div",{className:"live-preview-editor-header",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(O.Code2,{className:"h-4 w-4 text-blue-600"}),o.jsx("span",{className:"text-sm font-semibold text-gray-800",children:"Live Preview Editor"})]}),o.jsxs("div",{className:"flex gap-1",children:[o.jsxs($,{type:"button",size:"sm",variant:c==="code"?"default":"outline",onClick:()=>d("code"),children:[o.jsx(O.Code2,{className:"h-3.5 w-3.5 mr-1"}),"Code"]}),o.jsxs($,{type:"button",size:"sm",variant:c==="preview"?"default":"outline",onClick:()=>{f(v=>v+1),d("preview")},children:[o.jsx(O.Eye,{className:"h-3.5 w-3.5 mr-1"}),"Preview"]})]})]}),c==="code"?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"live-preview-tabs",children:Qs.map(v=>o.jsx("button",{type:"button",className:`live-preview-tab ${a===v.id?"active":""}`,onClick:()=>l(v.id),children:v.label},v.id))}),o.jsx("textarea",{className:"live-preview-code-input",value:g[a],onChange:v=>S(a,v.target.value),spellCheck:!1,"aria-label":`${a.toUpperCase()} code`}),o.jsxs("div",{className:"live-preview-meta-row",children:[o.jsxs("label",{className:"live-preview-meta-field",children:[o.jsx("span",{children:"Height"}),o.jsx("input",{type:"text",value:g.height,onChange:v=>S("height",v.target.value),placeholder:"400, 400px, 80%, fit-content, max-content"})]}),o.jsxs("label",{className:"live-preview-meta-field",children:[o.jsx("span",{children:"Title"}),o.jsx("input",{type:"text",value:g.title,onChange:v=>S("title",v.target.value),placeholder:Ve})]})]})]}):o.jsx("div",{className:"live-preview-edit-preview",children:L(x,g.height,u)}),o.jsxs("div",{className:"live-preview-actions",children:[o.jsxs($,{type:"button",size:"sm",variant:"outline",onClick:D,className:"text-green-700 border-green-300 hover:bg-green-50",children:[o.jsx(O.Play,{className:"h-3.5 w-3.5 mr-1"}),"Run"]}),o.jsx($,{type:"button",size:"sm",onClick:M,children:"Save"}),o.jsx($,{type:"button",size:"sm",variant:"outline",onClick:z,children:"Cancel"})]})]})}):o.jsx(q.NodeViewWrapper,{className:"live-preview-extension",children:o.jsxs("div",{ref:b,className:"live-preview-output group relative",children:[L(T,t.attrs.height,u),C&&o.jsxs("div",{className:"live-preview-controls",children:[o.jsx($,{type:"button",size:"sm",variant:"ghost",className:"h-8 w-8 p-0",title:"Edit code",onClick:k,children:o.jsx(O.Settings,{className:"h-4 w-4"})}),o.jsx($,{type:"button",size:"sm",variant:"ghost",className:"h-8 w-8 p-0 text-red-600 hover:text-red-700",title:"Delete",onClick:()=>n(),children:o.jsx(O.Trash2,{className:"h-4 w-4"})})]}),t.attrs.title&&o.jsx("div",{className:"live-preview-label",children:t.attrs.title})]})})};function Mt(t,e){return t.querySelector(`[data-part="${e}"]`)?.textContent??""}const Un=K.Node.create({name:"livePreview",group:"block",atom:!0,addAttributes(){return{html:{default:kt,parseHTML:t=>Mt(t,"html")||kt},css:{default:At,parseHTML:t=>Mt(t,"css")||At},js:{default:Ot,parseHTML:t=>Mt(t,"js")||Ot},height:{default:"auto",parseHTML:t=>t.getAttribute("data-height")||"auto",renderHTML:t=>({"data-height":t.height})},title:{default:"Interactive view",parseHTML:t=>t.getAttribute("data-title")||"Interactive view",renderHTML:t=>({"data-title":t.title})},pendingEdit:{default:!1,parseHTML:()=>!1,renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="live-preview"]'}]},renderHTML({node:t,HTMLAttributes:e}){return["div",K.mergeAttributes(e,{"data-type":"live-preview","data-height":t.attrs.height,"data-title":t.attrs.title}),["pre",{"data-part":"html",hidden:"hidden"},t.attrs.html],["pre",{"data-part":"css",hidden:"hidden"},t.attrs.css],["pre",{"data-part":"js",hidden:"hidden"},t.attrs.js]]},addNodeView(){return q.ReactNodeViewRenderer(ni)},addCommands(){return{insertLivePreview:(t={})=>({commands:e})=>e.insertContent({type:this.name,attrs:{html:t.html??kt,css:t.css??At,js:t.js??Ot,height:t.height??"auto",title:t.title??"Interactive view",pendingEdit:t.pendingEdit??!1}})}}});function We(t){if(!t)return null;const e=[/youtube\.com\/watch\?(?:.*&)?v=([\w-]{11})/i,/youtu\.be\/([\w-]{11})/i,/youtube\.com\/embed\/([\w-]{11})/i,/youtube\.com\/shorts\/([\w-]{11})/i,/youtube\.com\/live\/([\w-]{11})/i,/youtube-nocookie\.com\/embed\/([\w-]{11})/i];for(const n of e){const r=t.match(n);if(r&&r[1])return`https://www.youtube.com/embed/${r[1]}`}return null}function ri(t){return We(t)!==null}const si=({node:t})=>{const{src:e,type:n,title:r}=t.attrs;if(!e)return o.jsx(q.NodeViewWrapper,{className:"video-node-view",children:o.jsx("div",{className:"video-placeholder",children:o.jsxs("div",{className:"video-placeholder-content",children:[o.jsx("div",{className:"video-placeholder-icon",children:"🎥"}),o.jsx("p",{className:"video-placeholder-text",children:"Video not available"})]})})});const s=We(e);return s?o.jsx(q.NodeViewWrapper,{className:"video-node-view",children:o.jsxs("div",{className:"video-container video-youtube",contentEditable:!1,children:[o.jsx("div",{className:"video-youtube-frame",children:o.jsx("iframe",{src:s,title:r||"YouTube video",className:"video-youtube-iframe",frameBorder:0,allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",allowFullScreen:!0,loading:"lazy"})}),r&&o.jsx("div",{className:"video-caption",children:o.jsx("span",{className:"video-caption-text",children:r})})]})}):o.jsx(q.NodeViewWrapper,{className:"video-node-view",children:o.jsxs("div",{className:"video-container",contentEditable:!1,children:[o.jsxs("video",{controls:!0,className:"video-element",preload:"metadata",poster:"",children:[o.jsx("source",{src:e,type:n||"video/mp4"}),r||"Your browser does not support the video tag."]}),r&&o.jsx("div",{className:"video-caption",children:o.jsx("span",{className:"video-caption-text",children:r})})]})})},ii="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",Fn=K.Node.create({name:"video",addOptions(){return{inline:!1,allowBase64:!0,HTMLAttributes:{class:"max-w-full h-auto rounded-lg shadow-sm"}}},group(){return this.options.inline?"inline":"block"},draggable:!1,addAttributes(){return{src:{default:null,parseHTML:t=>t.getAttribute("src")||t.getAttribute("data-src"),renderHTML:t=>t.src?{src:t.src}:{}},type:{default:null,parseHTML:t=>t.getAttribute("type"),renderHTML:t=>t.type?{type:t.type}:{}},title:{default:null,parseHTML:t=>t.getAttribute("title")||t.getAttribute("data-title"),renderHTML:t=>t.title?{title:t.title}:{}}}},parseHTML(){return[{tag:"div[data-video='youtube']",getAttrs:t=>{const e=t;return{src:e.getAttribute("data-src"),title:e.getAttribute("data-title")}}},{tag:"video"}]},renderHTML({HTMLAttributes:t}){const{src:e,type:n,title:r}=t;if(!e)return["video",K.mergeAttributes(this.options.HTMLAttributes,t)];const s=We(e);return s?["div",K.mergeAttributes({class:"video-youtube-embed","data-video":"youtube","data-src":e},r?{"data-title":r}:{}),["iframe",{src:s,title:r||"YouTube video",frameborder:"0",allow:ii,allowfullscreen:"true",loading:"lazy"}]]:["video",K.mergeAttributes(this.options.HTMLAttributes,t,{controls:!0,preload:"metadata"}),["source",{src:e,type:n||"video/mp4"}],r||"Your browser does not support the video tag."]},addNodeView(){return q.ReactNodeViewRenderer(si)},addCommands(){return{setVideo:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}}}),oi=()=>({type:"column",content:[{type:"paragraph"}]}),Hn=K.Node.create({name:"columnLayout",group:"block",content:"column+",defining:!0,isolating:!0,addOptions(){return{HTMLAttributes:{},defaultColumns:2}},addAttributes(){return{columns:{default:this.options.defaultColumns,parseHTML:t=>{const e=Number(t.getAttribute("data-columns"));return Number.isNaN(e)?this.options.defaultColumns:e},renderHTML:t=>({"data-columns":t.columns})}}},parseHTML(){return[{tag:'div[data-type="column-layout"]'}]},renderHTML({HTMLAttributes:t}){return["div",K.mergeAttributes(this.options.HTMLAttributes,t,{"data-type":"column-layout"}),0]},addCommands(){return{insertColumnLayout:t=>({commands:e})=>{const n=t?.columns??this.options.defaultColumns,r=Array.from({length:Math.max(n,1)},()=>oi());return e.insertContent({type:this.name,attrs:{columns:n},content:r})},setColumnLayoutColumns:t=>({state:e,dispatch:n})=>{const r=K.findParentNode(s=>s.type===this.type)(e.selection);if(!r)return!1;if(n){const s=e.tr.setNodeMarkup(r.pos,this.type,{...r.node.attrs,columns:t},r.node.marks);n(s)}return!0}}}}),$n=K.Node.create({name:"column",content:"block+",isolating:!0,defining:!0,parseHTML(){return[{tag:'div[data-type="column"]'}]},renderHTML({HTMLAttributes:t}){return["div",K.mergeAttributes(t,{"data-type":"column"}),0]}});function ai({initialOpen:t=!1,placement:e="top",open:n,onOpenChange:r,delay:s=600,closeDelay:i=0}={}){const[a,l]=ge.useState(t),c=n??a,d=r??l,u=se.useFloating({placement:e,open:c,onOpenChange:d,whileElementsMounted:se.autoUpdate,middleware:[se.offset(4),se.flip({crossAxis:e.includes("-"),fallbackAxisSideDirection:"start",padding:4}),se.shift({padding:4})]}),f=u.context,m=se.useHover(f,{mouseOnly:!0,move:!1,restMs:s,enabled:n==null,delay:{close:i}}),p=se.useFocus(f,{enabled:n==null}),b=se.useDismiss(f),w=se.useRole(f,{role:"tooltip"}),g=se.useInteractions([m,p,b,w]);return ge.useMemo(()=>({open:c,setOpen:d,...g,...u}),[c,d,g,u])}const It=ge.createContext(null);function Kn(){const t=ge.useContext(It);if(t==null)throw new Error("Tooltip components must be wrapped in <TooltipProvider />");return t}function ot({children:t,...e}){const n=ai(e);return e.useDelayGroup?o.jsx(se.FloatingDelayGroup,{delay:{open:e.delay??0,close:e.closeDelay??0},timeoutMs:e.timeout,children:o.jsx(It.Provider,{value:n,children:t})}):o.jsx(It.Provider,{value:n,children:t})}const at=ge.forwardRef(function({children:e,asChild:n=!1,...r},s){const i=Kn(),a=ge.isValidElement(e)?parseInt(ge.version,10)>=19?e.props.ref:e.ref:void 0,l=se.useMergeRefs([i.refs.setReference,s,a]);if(n&&ge.isValidElement(e)){const c={"data-tooltip-state":i.open?"open":"closed"};return ge.cloneElement(e,i.getReferenceProps({ref:l,...r,...typeof e.props=="object"?e.props:{},...c}))}return o.jsx("button",{ref:l,"data-tooltip-state":i.open?"open":"closed",...i.getReferenceProps(r),children:e})}),lt=ge.forwardRef(function({style:e,children:n,portal:r=!0,portalProps:s={},...i},a){const l=Kn(),c=se.useMergeRefs([l.refs.setFloating,a]);if(!l.open)return null;const d=o.jsx("div",{ref:c,style:{...l.floatingStyles,...e},...l.getFloatingProps(i),className:"tiptap-tooltip",children:n});return r?o.jsx(se.FloatingPortal,{...s,children:d}):d});ot.displayName="Tooltip",at.displayName="TooltipTrigger",lt.displayName="TooltipContent";const j=({onClick:t,isActive:e=!1,children:n,title:r,className:s=""})=>{const i=o.jsx($,{type:"button",onClick:t,variant:e?"default":"outline",size:"sm",className:`h-8 w-8 p-0 transition-all cursor-pointer ${e?"bg-blue-600 text-white border-blue-600 hover:bg-blue-700":"bg-white hover:bg-gray-50"} ${s}`,children:n});return r?o.jsxs(ot,{delay:500,closeDelay:0,children:[o.jsx(at,{asChild:!0,children:i}),o.jsx(lt,{children:r})]}):i},li=({onColorChange:t})=>{const e=["#000000","#ffffff","#7d7a75","#9f765a","#d27b2d","#fdd835","#50946e","#377dc9","#9a6bb4","#c14c8a","#cf5148"];return o.jsx("div",{className:"flex flex-wrap gap-1 w-32",children:e.map(n=>o.jsxs(ot,{delay:300,closeDelay:0,children:[o.jsx(at,{asChild:!0,children:o.jsx("button",{type:"button",className:"w-6 h-6 rounded border border-gray-300 cursor-pointer hover:scale-110 transition-transform",style:{backgroundColor:n},onClick:()=>t(n)})}),o.jsxs(lt,{children:["Set color to ",n]})]},n))})},ci=({onColorChange:t})=>{const e=["#B0B0B0","#F2F0EF","#e7e4de","#f3e1d5","#ffe4c2","#fff7cc","#d6f2e3","#d5e6fa","#ebddf5","#f9d6e8","#f8d0cb"];return o.jsx("div",{className:"flex flex-wrap gap-1 w-32",children:e.map(n=>o.jsxs(ot,{delay:300,closeDelay:0,children:[o.jsx(at,{asChild:!0,children:o.jsx("button",{type:"button",className:"w-6 h-6 rounded border border-gray-300 cursor-pointer hover:scale-110 transition-transform",style:{backgroundColor:n},onClick:()=>t(n)})}),o.jsxs(lt,{children:["Set background color to ",n]})]},n))})},di=({editor:t,isReadOnly:e,onImageUpload:n,onVideoUpload:r,isImageUploading:s,isVideoUploading:i,showImageInput:a,setShowImageInput:l,imageUrl:c,setImageUrl:d,handleImageUrlInsert:u,imageUploadFunction:f,showVideoInput:m,setShowVideoInput:p,videoUrl:b,setVideoUrl:w,handleVideoUrlInsert:g,videoUploadFunction:_})=>{const[C,y]=N.useState(!1),T=N.useRef(null);return N.useEffect(()=>{const x=k=>{T.current&&!T.current.contains(k.target)&&y(!1)};return C&&document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x)}},[C]),e?null:o.jsxs("div",{className:"sticky top-0 z-40 border border-gray-300 mb-10 p-4 bg-gray-50/95 flex flex-wrap gap-2 shadow-sm backdrop-blur-sm",children:[o.jsxs("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:[o.jsx(j,{onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),isActive:t.isActive("heading",{level:1}),title:"Heading 1",children:o.jsx(O.Heading1,{className:"h-4 w-4"})}),o.jsx(j,{onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),isActive:t.isActive("heading",{level:2}),title:"Heading 2",children:o.jsx(O.Heading2,{className:"h-4 w-4"})}),o.jsx(j,{onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),isActive:t.isActive("heading",{level:3}),title:"Heading 3",children:o.jsx(O.Heading3,{className:"h-4 w-4"})}),o.jsx(j,{onClick:()=>t.chain().focus().toggleHeading({level:4}).run(),isActive:t.isActive("heading",{level:4}),title:"Heading 4",children:o.jsx(O.Heading4,{className:"h-4 w-4"})}),o.jsx(j,{onClick:()=>t.chain().focus().setParagraph().run(),isActive:t.isActive("paragraph"),title:"Paragraph",children:o.jsx(O.FileText,{className:"h-4 w-4"})})]}),o.jsxs("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:[o.jsx(j,{onClick:()=>t.chain().focus().toggleBulletList().run(),isActive:t.isActive("bulletList"),title:"Bullet List",children:o.jsx(O.List,{className:"h-4 w-4"})}),o.jsx(j,{onClick:()=>t.chain().focus().toggleOrderedList().run(),isActive:t.isActive("orderedList"),title:"Numbered List",children:o.jsx(O.ListOrdered,{className:"h-4 w-4"})})]}),o.jsx("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:o.jsx(j,{onClick:()=>t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),title:"Insert Table (3x3)",children:o.jsx(O.Table,{className:"h-4 w-4"})})}),o.jsxs("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:[o.jsx(j,{onClick:()=>t.chain().focus().toggleBlockquote().run(),isActive:t.isActive("blockquote"),title:"Block Quote",children:o.jsx(O.Quote,{className:"h-4 w-4"})}),o.jsx(j,{onClick:()=>t.chain().focus().setHorizontalRule().run(),title:"Horizontal Rule",children:o.jsx(O.Minus,{className:"h-4 w-4"})})]}),o.jsxs("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:[o.jsxs("div",{className:"relative",children:[o.jsx(j,{onClick:()=>l(!a),title:"Insert Image",className:s?"opacity-50":"",children:s?o.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"}):o.jsx(O.Image,{className:"h-4 w-4"})}),s&&o.jsx("div",{className:"absolute -top-1 -right-1 w-3 h-3 bg-blue-600 rounded-full animate-pulse"}),a&&o.jsx("div",{className:`absolute top-full mt-1 z-10 bg-white border border-gray-300 rounded-lg p-2 shadow-lg min-w-80 image-input-container ${s?"opacity-75":""}`,children:o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("h3",{className:"text-sm font-medium text-gray-900",children:"Insert Image"}),o.jsx("button",{type:"button",onClick:()=>l(!1),className:`text-gray-400 hover:text-gray-600 ${s?"opacity-50 cursor-not-allowed":""}`,disabled:s,children:"✕"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Image URL"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx("input",{type:"url",value:c,onChange:x=>d(x.target.value),placeholder:"https://example.com/image.jpg",className:`flex-1 px-3 py-2 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 ${s?"opacity-50 cursor-not-allowed":""}`,disabled:s,onKeyDown:x=>{x.key==="Enter"&&u()}}),o.jsx($,{type:"button",onClick:u,size:"sm",className:"px-4 py-2",disabled:!c.trim()||s,children:"Insert"})]}),c.trim()&&o.jsxs("div",{className:"mt-2 p-2 border border-gray-200 rounded bg-gray-50",children:[o.jsx("p",{className:"text-xs text-gray-600 mb-2",children:"Preview:"}),o.jsx("img",{src:c.trim(),alt:"Preview",className:"max-w-full h-auto max-h-32 rounded border",onError:x=>{const k=x.currentTarget;k.style.display="none";const M=k.nextElementSibling;M&&(M.style.display="block")}}),o.jsx("p",{className:"text-xs text-red-500 hidden",children:"Invalid image URL"})]})]}),o.jsxs("div",{className:"border-t pt-3",children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Or Upload Image"}),o.jsx($,{type:"button",onClick:n,size:"sm",variant:"outline",className:"w-full",disabled:!f||s,children:s?o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"}),o.jsx("span",{children:"Uploading..."})]}):f?"Choose File":"Upload not available"}),s&&o.jsxs("div",{className:"mt-2 text-xs text-blue-600 flex items-center gap-1",children:[o.jsx("div",{className:"animate-pulse",children:"⏳"}),o.jsx("span",{children:"Please wait while your image uploads..."})]}),!f&&o.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Upload function not provided"})]})]})})]}),o.jsxs("div",{className:"relative",children:[o.jsx(j,{onClick:()=>p(!m),title:"Insert Video",className:i?"opacity-50":"",children:i?o.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"}):o.jsx(O.Video,{className:"h-4 w-4"})}),i&&o.jsx("div",{className:"absolute -top-1 -right-1 w-3 h-3 bg-blue-600 rounded-full animate-pulse"}),m&&o.jsx("div",{className:`absolute top-full mt-1 right-0 z-10 bg-white border border-gray-300 rounded-lg p-2 shadow-lg min-w-80 video-input-container ${i?"opacity-75":""}`,children:o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("h3",{className:"text-sm font-medium text-gray-900",children:"Insert Video"}),o.jsx("button",{type:"button",onClick:()=>p(!1),className:`text-gray-400 hover:text-gray-600 ${i?"opacity-50 cursor-not-allowed":""}`,disabled:i,children:"✕"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"YouTube or Video URL"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx("input",{type:"url",value:b,onChange:x=>w(x.target.value),placeholder:"https://youtube.com/watch?v=… or .mp4",className:`flex-1 px-3 py-2 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 ${i?"opacity-50 cursor-not-allowed":""}`,disabled:i,onKeyDown:x=>{x.key==="Enter"&&g()}}),o.jsx($,{type:"button",onClick:g,size:"sm",className:"px-4 py-2",disabled:!b.trim()||i,children:"Insert"})]}),We(b.trim())&&o.jsxs("div",{className:"mt-2 p-2 border border-gray-200 rounded bg-gray-50",children:[o.jsx("p",{className:"text-xs text-gray-600 mb-2",children:"Preview:"}),o.jsx("div",{className:"relative w-full rounded border overflow-hidden",style:{aspectRatio:"16 / 9"},children:o.jsx("iframe",{src:We(b.trim())||"",title:"YouTube preview",className:"absolute inset-0 w-full h-full",frameBorder:0,allowFullScreen:!0})})]})]}),o.jsxs("div",{className:"border-t pt-3",children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Or Upload Video"}),o.jsx($,{type:"button",onClick:r,size:"sm",variant:"outline",className:"w-full",disabled:i,children:i?o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"}),o.jsx("span",{children:"Uploading..."})]}):_?"Choose File":"Choose File (Base64)"}),!_&&o.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"No upload service provided — files embed as Base64."})]})]})})]})]}),o.jsxs("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:[o.jsx(j,{onClick:()=>t.chain().focus().toggleCodeBlock().run(),isActive:t.isActive("codeBlock"),title:"Code Block",children:o.jsx(O.Code,{className:"h-4 w-4"})}),o.jsx(j,{onClick:()=>t.chain().focus().insertAccordion().run(),title:"Insert Accordion",children:o.jsx(O.PanelTopOpen,{className:"h-4 w-4 cursor-pointer"})})]}),o.jsxs("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:[o.jsx(j,{onClick:()=>t.chain().focus().insertTabs({tabCount:2}).run(),title:"Insert 2 Tabs",children:o.jsx("span",{className:"text-xs font-mono",children:"2T"})}),o.jsxs("div",{className:"relative w-full",ref:T,children:[o.jsx(j,{onClick:()=>y(!C),title:"Insert Tabs",className:"w-full px-2",children:o.jsxs("div",{className:"flex items-center gap-1 w-full justify-between",children:[o.jsx("span",{className:"text-xs font-mono",children:"Tabs"}),o.jsx(O.ChevronDown,{className:"h-3 w-3"})]})}),C&&o.jsx("div",{className:"absolute top-full mt-1 left-0 z-10 bg-white border border-gray-300 rounded-lg shadow-lg min-w-32",children:o.jsxs("div",{className:"p-1 space-y-1",children:[o.jsx($,{type:"button",variant:"ghost",size:"sm",onClick:()=>{t.chain().focus().insertTabs({tabCount:3}).run(),y(!1)},className:"w-full justify-start text-xs font-mono hover:bg-gray-100",children:"3 Tabs"}),o.jsx($,{type:"button",variant:"ghost",size:"sm",onClick:()=>{t.chain().focus().insertTabs({tabCount:4}).run(),y(!1)},className:"w-full justify-start text-xs font-mono hover:bg-gray-100",children:"4 Tabs"}),o.jsx($,{type:"button",variant:"ghost",size:"sm",onClick:()=>{t.chain().focus().insertTabs({tabCount:5}).run(),y(!1)},className:"w-full justify-start text-xs font-mono hover:bg-gray-100",children:"5 Tabs"}),o.jsx($,{type:"button",variant:"ghost",size:"sm",onClick:()=>{t.chain().focus().insertTabs({tabCount:6}).run(),y(!1)},className:"w-full justify-start text-xs font-mono hover:bg-gray-100",children:"6 Tabs"})]})})]})]}),o.jsxs("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:[o.jsx(j,{onClick:()=>{const x=prompt("Enter the URL for your iframe:","https://example.com/embed");x&&t.chain().focus().insertIframe({src:x,width:"100%",height:"500px",title:"Embedded Content"}).run()},title:"Insert iframe",children:o.jsx(O.Frame,{className:"h-4 w-4"})}),o.jsx(j,{onClick:()=>{t.chain().focus().insertLivePreview({pendingEdit:!0}).run()},title:"Insert live HTML/CSS/JS preview",children:o.jsx(O.MonitorPlay,{className:"h-4 w-4"})})]}),o.jsx("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:o.jsx(j,{onClick:()=>t.chain().focus().insertColumnLayout({columns:2}).run(),title:"Insert 2 Column Layout",children:o.jsx("div",{className:"flex items-center gap-1",children:o.jsx(O.Columns3,{className:"h-4 w-4"})})})})]})},qn=["top","right","bottom","left"],Vn=["start","end"],Wn=qn.reduce((t,e)=>t.concat(e,e+"-"+Vn[0],e+"-"+Vn[1]),[]),we=Math.min,re=Math.max,ct=Math.round,xe=t=>({x:t,y:t}),ui={left:"right",right:"left",bottom:"top",top:"bottom"},fi={start:"end",end:"start"};function Rt(t,e,n){return re(t,we(e,n))}function Se(t,e){return typeof t=="function"?t(e):t}function ce(t){return t.split("-")[0]}function pe(t){return t.split("-")[1]}function Jn(t){return t==="x"?"y":"x"}function Lt(t){return t==="y"?"height":"width"}const pi=new Set(["top","bottom"]);function ye(t){return pi.has(ce(t))?"y":"x"}function jt(t){return Jn(ye(t))}function Gn(t,e,n){n===void 0&&(n=!1);const r=pe(t),s=jt(t),i=Lt(s);let a=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(a=ut(a)),[a,ut(a)]}function hi(t){const e=ut(t);return[dt(t),e,dt(e)]}function dt(t){return t.replace(/start|end/g,e=>fi[e])}const Yn=["left","right"],Zn=["right","left"],mi=["top","bottom"],gi=["bottom","top"];function bi(t,e,n){switch(t){case"top":case"bottom":return n?e?Zn:Yn:e?Yn:Zn;case"left":case"right":return e?mi:gi;default:return[]}}function wi(t,e,n,r){const s=pe(t);let i=bi(ce(t),n==="start",r);return s&&(i=i.map(a=>a+"-"+s),e&&(i=i.concat(i.map(dt)))),i}function ut(t){return t.replace(/left|right|bottom|top/g,e=>ui[e])}function xi(t){return{top:0,right:0,bottom:0,left:0,...t}}function Dt(t){return typeof t!="number"?xi(t):{top:t,right:t,bottom:t,left:t}}function Pe(t){const{x:e,y:n,width:r,height:s}=t;return{width:r,height:s,top:n,left:e,right:e+r,bottom:n+s,x:e,y:n}}function Xn(t,e,n){let{reference:r,floating:s}=t;const i=ye(e),a=jt(e),l=Lt(a),c=ce(e),d=i==="y",u=r.x+r.width/2-s.width/2,f=r.y+r.height/2-s.height/2,m=r[l]/2-s[l]/2;let p;switch(c){case"top":p={x:u,y:r.y-s.height};break;case"bottom":p={x:u,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-s.width,y:f};break;default:p={x:r.x,y:r.y}}switch(pe(e)){case"start":p[a]-=m*(n&&d?-1:1);break;case"end":p[a]+=m*(n&&d?-1:1);break}return p}const yi=async(t,e,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:i=[],platform:a}=n,l=i.filter(Boolean),c=await(a.isRTL==null?void 0:a.isRTL(e));let d=await a.getElementRects({reference:t,floating:e,strategy:s}),{x:u,y:f}=Xn(d,r,c),m=r,p={},b=0;for(let w=0;w<l.length;w++){const{name:g,fn:_}=l[w],{x:C,y,data:T,reset:x}=await _({x:u,y:f,initialPlacement:r,placement:m,strategy:s,middlewareData:p,rects:d,platform:a,elements:{reference:t,floating:e}});u=C??u,f=y??f,p={...p,[g]:{...p[g],...T}},x&&b<=50&&(b++,typeof x=="object"&&(x.placement&&(m=x.placement),x.rects&&(d=x.rects===!0?await a.getElementRects({reference:t,floating:e,strategy:s}):x.rects),{x:u,y:f}=Xn(d,m,c)),w=-1)}return{x:u,y:f,placement:m,strategy:s,middlewareData:p}};async function Be(t,e){var n;e===void 0&&(e={});const{x:r,y:s,platform:i,rects:a,elements:l,strategy:c}=t,{boundary:d="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:m=!1,padding:p=0}=Se(e,t),b=Dt(p),g=l[m?f==="floating"?"reference":"floating":f],_=Pe(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(g)))==null||n?g:g.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:d,rootBoundary:u,strategy:c})),C=f==="floating"?{x:r,y:s,width:a.floating.width,height:a.floating.height}:a.reference,y=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),T=await(i.isElement==null?void 0:i.isElement(y))?await(i.getScale==null?void 0:i.getScale(y))||{x:1,y:1}:{x:1,y:1},x=Pe(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:C,offsetParent:y,strategy:c}):C);return{top:(_.top-x.top+b.top)/T.y,bottom:(x.bottom-_.bottom+b.bottom)/T.y,left:(_.left-x.left+b.left)/T.x,right:(x.right-_.right+b.right)/T.x}}const vi=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:s,rects:i,platform:a,elements:l,middlewareData:c}=e,{element:d,padding:u=0}=Se(t,e)||{};if(d==null)return{};const f=Dt(u),m={x:n,y:r},p=jt(s),b=Lt(p),w=await a.getDimensions(d),g=p==="y",_=g?"top":"left",C=g?"bottom":"right",y=g?"clientHeight":"clientWidth",T=i.reference[b]+i.reference[p]-m[p]-i.floating[b],x=m[p]-i.reference[p],k=await(a.getOffsetParent==null?void 0:a.getOffsetParent(d));let M=k?k[y]:0;(!M||!await(a.isElement==null?void 0:a.isElement(k)))&&(M=l.floating[y]||i.floating[b]);const z=T/2-x/2,D=M/2-w[b]/2-1,S=we(f[_],D),L=we(f[C],D),v=S,U=M-w[b]-L,P=M/2-w[b]/2+z,J=Rt(v,P,U),G=!c.arrow&&pe(s)!=null&&P!==J&&i.reference[b]/2-(P<v?S:L)-w[b]/2<0,Y=G?P<v?P-v:P-U:0;return{[p]:m[p]+Y,data:{[p]:J,centerOffset:P-J-Y,...G&&{alignmentOffset:Y}},reset:G}}});function Ei(t,e,n){return(t?[...n.filter(s=>pe(s)===t),...n.filter(s=>pe(s)!==t)]:n.filter(s=>ce(s)===s)).filter(s=>t?pe(s)===t||(e?dt(s)!==s:!1):!0)}const Ni=function(t){return t===void 0&&(t={}),{name:"autoPlacement",options:t,async fn(e){var n,r,s;const{rects:i,middlewareData:a,placement:l,platform:c,elements:d}=e,{crossAxis:u=!1,alignment:f,allowedPlacements:m=Wn,autoAlignment:p=!0,...b}=Se(t,e),w=f!==void 0||m===Wn?Ei(f||null,p,m):m,g=await Be(e,b),_=((n=a.autoPlacement)==null?void 0:n.index)||0,C=w[_];if(C==null)return{};const y=Gn(C,i,await(c.isRTL==null?void 0:c.isRTL(d.floating)));if(l!==C)return{reset:{placement:w[0]}};const T=[g[ce(C)],g[y[0]],g[y[1]]],x=[...((r=a.autoPlacement)==null?void 0:r.overflows)||[],{placement:C,overflows:T}],k=w[_+1];if(k)return{data:{index:_+1,overflows:x},reset:{placement:k}};const M=x.map(S=>{const L=pe(S.placement);return[S.placement,L&&u?S.overflows.slice(0,2).reduce((v,U)=>v+U,0):S.overflows[0],S.overflows]}).sort((S,L)=>S[1]-L[1]),D=((s=M.filter(S=>S[2].slice(0,pe(S[0])?2:3).every(L=>L<=0))[0])==null?void 0:s[0])||M[0][0];return D!==l?{data:{index:_+1,overflows:x},reset:{placement:D}}:{}}}},Ci=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:s,middlewareData:i,rects:a,initialPlacement:l,platform:c,elements:d}=e,{mainAxis:u=!0,crossAxis:f=!0,fallbackPlacements:m,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:b="none",flipAlignment:w=!0,...g}=Se(t,e);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const _=ce(s),C=ye(l),y=ce(l)===l,T=await(c.isRTL==null?void 0:c.isRTL(d.floating)),x=m||(y||!w?[ut(l)]:hi(l)),k=b!=="none";!m&&k&&x.push(...wi(l,w,b,T));const M=[l,...x],z=await Be(e,g),D=[];let S=((r=i.flip)==null?void 0:r.overflows)||[];if(u&&D.push(z[_]),f){const P=Gn(s,a,T);D.push(z[P[0]],z[P[1]])}if(S=[...S,{placement:s,overflows:D}],!D.every(P=>P<=0)){var L,v;const P=(((L=i.flip)==null?void 0:L.index)||0)+1,J=M[P];if(J&&(!(f==="alignment"?C!==ye(J):!1)||S.every(A=>ye(A.placement)===C?A.overflows[0]>0:!0)))return{data:{index:P,overflows:S},reset:{placement:J}};let G=(v=S.filter(Y=>Y.overflows[0]<=0).sort((Y,A)=>Y.overflows[1]-A.overflows[1])[0])==null?void 0:v.placement;if(!G)switch(p){case"bestFit":{var U;const Y=(U=S.filter(A=>{if(k){const I=ye(A.placement);return I===C||I==="y"}return!0}).map(A=>[A.placement,A.overflows.filter(I=>I>0).reduce((I,h)=>I+h,0)]).sort((A,I)=>A[1]-I[1])[0])==null?void 0:U[0];Y&&(G=Y);break}case"initialPlacement":G=l;break}if(s!==G)return{reset:{placement:G}}}return{}}}};function Qn(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function er(t){return qn.some(e=>t[e]>=0)}const Si=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n}=e,{strategy:r="referenceHidden",...s}=Se(t,e);switch(r){case"referenceHidden":{const i=await Be(e,{...s,elementContext:"reference"}),a=Qn(i,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:er(a)}}}case"escaped":{const i=await Be(e,{...s,altBoundary:!0}),a=Qn(i,n.floating);return{data:{escapedOffsets:a,escaped:er(a)}}}default:return{}}}}};function tr(t){const e=we(...t.map(i=>i.left)),n=we(...t.map(i=>i.top)),r=re(...t.map(i=>i.right)),s=re(...t.map(i=>i.bottom));return{x:e,y:n,width:r-e,height:s-n}}function Ti(t){const e=t.slice().sort((s,i)=>s.y-i.y),n=[];let r=null;for(let s=0;s<e.length;s++){const i=e[s];!r||i.y-r.y>r.height/2?n.push([i]):n[n.length-1].push(i),r=i}return n.map(s=>Pe(tr(s)))}const _i=function(t){return t===void 0&&(t={}),{name:"inline",options:t,async fn(e){const{placement:n,elements:r,rects:s,platform:i,strategy:a}=e,{padding:l=2,x:c,y:d}=Se(t,e),u=Array.from(await(i.getClientRects==null?void 0:i.getClientRects(r.reference))||[]),f=Ti(u),m=Pe(tr(u)),p=Dt(l);function b(){if(f.length===2&&f[0].left>f[1].right&&c!=null&&d!=null)return f.find(g=>c>g.left-p.left&&c<g.right+p.right&&d>g.top-p.top&&d<g.bottom+p.bottom)||m;if(f.length>=2){if(ye(n)==="y"){const S=f[0],L=f[f.length-1],v=ce(n)==="top",U=S.top,P=L.bottom,J=v?S.left:L.left,G=v?S.right:L.right,Y=G-J,A=P-U;return{top:U,bottom:P,left:J,right:G,width:Y,height:A,x:J,y:U}}const g=ce(n)==="left",_=re(...f.map(S=>S.right)),C=we(...f.map(S=>S.left)),y=f.filter(S=>g?S.left===C:S.right===_),T=y[0].top,x=y[y.length-1].bottom,k=C,M=_,z=M-k,D=x-T;return{top:T,bottom:x,left:k,right:M,width:z,height:D,x:k,y:T}}return m}const w=await i.getElementRects({reference:{getBoundingClientRect:b},floating:r.floating,strategy:a});return s.reference.x!==w.reference.x||s.reference.y!==w.reference.y||s.reference.width!==w.reference.width||s.reference.height!==w.reference.height?{reset:{rects:w}}:{}}}},ki=new Set(["left","top"]);async function Ai(t,e){const{placement:n,platform:r,elements:s}=t,i=await(r.isRTL==null?void 0:r.isRTL(s.floating)),a=ce(n),l=pe(n),c=ye(n)==="y",d=ki.has(a)?-1:1,u=i&&c?-1:1,f=Se(e,t);let{mainAxis:m,crossAxis:p,alignmentAxis:b}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof b=="number"&&(p=l==="end"?b*-1:b),c?{x:p*u,y:m*d}:{x:m*d,y:p*u}}const Oi=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:s,y:i,placement:a,middlewareData:l}=e,c=await Ai(e,t);return a===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:s+c.x,y:i+c.y,data:{...c,placement:a}}}}},Mi=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:s}=e,{mainAxis:i=!0,crossAxis:a=!1,limiter:l={fn:g=>{let{x:_,y:C}=g;return{x:_,y:C}}},...c}=Se(t,e),d={x:n,y:r},u=await Be(e,c),f=ye(ce(s)),m=Jn(f);let p=d[m],b=d[f];if(i){const g=m==="y"?"top":"left",_=m==="y"?"bottom":"right",C=p+u[g],y=p-u[_];p=Rt(C,p,y)}if(a){const g=f==="y"?"top":"left",_=f==="y"?"bottom":"right",C=b+u[g],y=b-u[_];b=Rt(C,b,y)}const w=l.fn({...e,[m]:p,[f]:b});return{...w,data:{x:w.x-n,y:w.y-r,enabled:{[m]:i,[f]:a}}}}}},Ii=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:s,rects:i,platform:a,elements:l}=e,{apply:c=()=>{},...d}=Se(t,e),u=await Be(e,d),f=ce(s),m=pe(s),p=ye(s)==="y",{width:b,height:w}=i.floating;let g,_;f==="top"||f==="bottom"?(g=f,_=m===(await(a.isRTL==null?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(_=f,g=m==="end"?"top":"bottom");const C=w-u.top-u.bottom,y=b-u.left-u.right,T=we(w-u[g],C),x=we(b-u[_],y),k=!e.middlewareData.shift;let M=T,z=x;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(z=y),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(M=C),k&&!m){const S=re(u.left,0),L=re(u.right,0),v=re(u.top,0),U=re(u.bottom,0);p?z=b-2*(S!==0||L!==0?S+L:re(u.left,u.right)):M=w-2*(v!==0||U!==0?v+U:re(u.top,u.bottom))}await c({...e,availableWidth:z,availableHeight:M});const D=await a.getDimensions(l.floating);return b!==D.width||w!==D.height?{reset:{rects:!0}}:{}}}};function ft(){return typeof window<"u"}function ze(t){return nr(t)?(t.nodeName||"").toLowerCase():"#document"}function ie(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Te(t){var e;return(e=(nr(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function nr(t){return ft()?t instanceof Node||t instanceof ie(t).Node:!1}function he(t){return ft()?t instanceof Element||t instanceof ie(t).Element:!1}function ve(t){return ft()?t instanceof HTMLElement||t instanceof ie(t).HTMLElement:!1}function rr(t){return!ft()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof ie(t).ShadowRoot}const Ri=new Set(["inline","contents"]);function Je(t){const{overflow:e,overflowX:n,overflowY:r,display:s}=me(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!Ri.has(s)}const Li=new Set(["table","td","th"]);function ji(t){return Li.has(ze(t))}const Di=[":popover-open",":modal"];function pt(t){return Di.some(e=>{try{return t.matches(e)}catch{return!1}})}const Pi=["transform","translate","scale","rotate","perspective"],Bi=["transform","translate","scale","rotate","perspective","filter"],zi=["paint","layout","strict","content"];function Pt(t){const e=Bt(),n=he(t)?me(t):t;return Pi.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||Bi.some(r=>(n.willChange||"").includes(r))||zi.some(r=>(n.contain||"").includes(r))}function Ui(t){let e=Me(t);for(;ve(e)&&!Ue(e);){if(Pt(e))return e;if(pt(e))return null;e=Me(e)}return null}function Bt(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Fi=new Set(["html","body","#document"]);function Ue(t){return Fi.has(ze(t))}function me(t){return ie(t).getComputedStyle(t)}function ht(t){return he(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Me(t){if(ze(t)==="html")return t;const e=t.assignedSlot||t.parentNode||rr(t)&&t.host||Te(t);return rr(e)?e.host:e}function sr(t){const e=Me(t);return Ue(e)?t.ownerDocument?t.ownerDocument.body:t.body:ve(e)&&Je(e)?e:sr(e)}function ir(t,e,n){var r;e===void 0&&(e=[]);const s=sr(t),i=s===((r=t.ownerDocument)==null?void 0:r.body),a=ie(s);return i?(zt(a),e.concat(a,a.visualViewport||[],Je(s)?s:[],[])):e.concat(s,ir(s,[]))}function zt(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function or(t){const e=me(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const s=ve(t),i=s?t.offsetWidth:n,a=s?t.offsetHeight:r,l=ct(n)!==i||ct(r)!==a;return l&&(n=i,r=a),{width:n,height:r,$:l}}function ar(t){return he(t)?t:t.contextElement}function Fe(t){const e=ar(t);if(!ve(e))return xe(1);const n=e.getBoundingClientRect(),{width:r,height:s,$:i}=or(e);let a=(i?ct(n.width):n.width)/r,l=(i?ct(n.height):n.height)/s;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const Hi=xe(0);function lr(t){const e=ie(t);return!Bt()||!e.visualViewport?Hi:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function $i(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==ie(t)?!1:e}function Ge(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const s=t.getBoundingClientRect(),i=ar(t);let a=xe(1);e&&(r?he(r)&&(a=Fe(r)):a=Fe(t));const l=$i(i,n,r)?lr(i):xe(0);let c=(s.left+l.x)/a.x,d=(s.top+l.y)/a.y,u=s.width/a.x,f=s.height/a.y;if(i){const m=ie(i),p=r&&he(r)?ie(r):r;let b=m,w=zt(b);for(;w&&r&&p!==b;){const g=Fe(w),_=w.getBoundingClientRect(),C=me(w),y=_.left+(w.clientLeft+parseFloat(C.paddingLeft))*g.x,T=_.top+(w.clientTop+parseFloat(C.paddingTop))*g.y;c*=g.x,d*=g.y,u*=g.x,f*=g.y,c+=y,d+=T,b=ie(w),w=zt(b)}}return Pe({width:u,height:f,x:c,y:d})}function mt(t,e){const n=ht(t).scrollLeft;return e?e.left+n:Ge(Te(t)).left+n}function cr(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-mt(t,n),s=n.top+e.scrollTop;return{x:r,y:s}}function Ki(t){let{elements:e,rect:n,offsetParent:r,strategy:s}=t;const i=s==="fixed",a=Te(r),l=e?pt(e.floating):!1;if(r===a||l&&i)return n;let c={scrollLeft:0,scrollTop:0},d=xe(1);const u=xe(0),f=ve(r);if((f||!f&&!i)&&((ze(r)!=="body"||Je(a))&&(c=ht(r)),ve(r))){const p=Ge(r);d=Fe(r),u.x=p.x+r.clientLeft,u.y=p.y+r.clientTop}const m=a&&!f&&!i?cr(a,c):xe(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-c.scrollLeft*d.x+u.x+m.x,y:n.y*d.y-c.scrollTop*d.y+u.y+m.y}}function qi(t){return Array.from(t.getClientRects())}function Vi(t){const e=Te(t),n=ht(t),r=t.ownerDocument.body,s=re(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),i=re(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+mt(t);const l=-n.scrollTop;return me(r).direction==="rtl"&&(a+=re(e.clientWidth,r.clientWidth)-s),{width:s,height:i,x:a,y:l}}const dr=25;function Wi(t,e){const n=ie(t),r=Te(t),s=n.visualViewport;let i=r.clientWidth,a=r.clientHeight,l=0,c=0;if(s){i=s.width,a=s.height;const u=Bt();(!u||u&&e==="fixed")&&(l=s.offsetLeft,c=s.offsetTop)}const d=mt(r);if(d<=0){const u=r.ownerDocument,f=u.body,m=getComputedStyle(f),p=u.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,b=Math.abs(r.clientWidth-f.clientWidth-p);b<=dr&&(i-=b)}else d<=dr&&(i+=d);return{width:i,height:a,x:l,y:c}}const Ji=new Set(["absolute","fixed"]);function Gi(t,e){const n=Ge(t,!0,e==="fixed"),r=n.top+t.clientTop,s=n.left+t.clientLeft,i=ve(t)?Fe(t):xe(1),a=t.clientWidth*i.x,l=t.clientHeight*i.y,c=s*i.x,d=r*i.y;return{width:a,height:l,x:c,y:d}}function ur(t,e,n){let r;if(e==="viewport")r=Wi(t,n);else if(e==="document")r=Vi(Te(t));else if(he(e))r=Gi(e,n);else{const s=lr(t);r={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return Pe(r)}function fr(t,e){const n=Me(t);return n===e||!he(n)||Ue(n)?!1:me(n).position==="fixed"||fr(n,e)}function Yi(t,e){const n=e.get(t);if(n)return n;let r=ir(t,[]).filter(l=>he(l)&&ze(l)!=="body"),s=null;const i=me(t).position==="fixed";let a=i?Me(t):t;for(;he(a)&&!Ue(a);){const l=me(a),c=Pt(a);!c&&l.position==="fixed"&&(s=null),(i?!c&&!s:!c&&l.position==="static"&&!!s&&Ji.has(s.position)||Je(a)&&!c&&fr(t,a))?r=r.filter(u=>u!==a):s=l,a=Me(a)}return e.set(t,r),r}function Zi(t){let{element:e,boundary:n,rootBoundary:r,strategy:s}=t;const a=[...n==="clippingAncestors"?pt(e)?[]:Yi(e,this._c):[].concat(n),r],l=a[0],c=a.reduce((d,u)=>{const f=ur(e,u,s);return d.top=re(f.top,d.top),d.right=we(f.right,d.right),d.bottom=we(f.bottom,d.bottom),d.left=re(f.left,d.left),d},ur(e,l,s));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Xi(t){const{width:e,height:n}=or(t);return{width:e,height:n}}function Qi(t,e,n){const r=ve(e),s=Te(e),i=n==="fixed",a=Ge(t,!0,i,e);let l={scrollLeft:0,scrollTop:0};const c=xe(0);function d(){c.x=mt(s)}if(r||!r&&!i)if((ze(e)!=="body"||Je(s))&&(l=ht(e)),r){const p=Ge(e,!0,i,e);c.x=p.x+e.clientLeft,c.y=p.y+e.clientTop}else s&&d();i&&!r&&s&&d();const u=s&&!r&&!i?cr(s,l):xe(0),f=a.left+l.scrollLeft-c.x-u.x,m=a.top+l.scrollTop-c.y-u.y;return{x:f,y:m,width:a.width,height:a.height}}function Ut(t){return me(t).position==="static"}function pr(t,e){if(!ve(t)||me(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Te(t)===n&&(n=n.ownerDocument.body),n}function hr(t,e){const n=ie(t);if(pt(t))return n;if(!ve(t)){let s=Me(t);for(;s&&!Ue(s);){if(he(s)&&!Ut(s))return s;s=Me(s)}return n}let r=pr(t,e);for(;r&&ji(r)&&Ut(r);)r=pr(r,e);return r&&Ue(r)&&Ut(r)&&!Pt(r)?n:r||Ui(t)||n}const eo=async function(t){const e=this.getOffsetParent||hr,n=this.getDimensions,r=await n(t.floating);return{reference:Qi(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function to(t){return me(t).direction==="rtl"}const no={convertOffsetParentRelativeRectToViewportRelativeRect:Ki,getDocumentElement:Te,getClippingRect:Zi,getOffsetParent:hr,getElementRects:eo,getClientRects:qi,getDimensions:Xi,getScale:Fe,isElement:he,isRTL:to},mr=Oi,gr=Ni,br=Mi,wr=Ci,xr=Ii,yr=Si,vr=vi,Er=_i,Nr=(t,e,n)=>{const r=new Map,s={platform:no,...n},i={...s.platform,_c:r};return yi(t,e,{...s,platform:i})};function Cr(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let s=t.child(r),i=e.child(r);if(s==i){n+=s.nodeSize;continue}if(!s.sameMarkup(i))return n;if(s.isText&&s.text!=i.text){for(let a=0;s.text[a]==i.text[a];a++)n++;return n}if(s.content.size||i.content.size){let a=Cr(s.content,i.content,n+1);if(a!=null)return a}n+=s.nodeSize}}function Sr(t,e,n,r){for(let s=t.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:n,b:r};let a=t.child(--s),l=e.child(--i),c=a.nodeSize;if(a==l){n-=c,r-=c;continue}if(!a.sameMarkup(l))return{a:n,b:r};if(a.isText&&a.text!=l.text){let d=0,u=Math.min(a.text.length,l.text.length);for(;d<u&&a.text[a.text.length-d-1]==l.text[l.text.length-d-1];)d++,n--,r--;return{a:n,b:r}}if(a.content.size||l.content.size){let d=Sr(a.content,l.content,n-1,r-1);if(d)return d}n-=c,r-=c}}class V{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,s=0,i){for(let a=0,l=0;l<n;a++){let c=this.content[a],d=l+c.nodeSize;if(d>e&&r(c,s+l,i||null,a)!==!1&&c.content.size){let u=l+1;c.nodesBetween(Math.max(0,e-u),Math.min(c.content.size,n-u),r,s+u)}l=d}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let i="",a=!0;return this.nodesBetween(e,n,(l,c)=>{let d=l.isText?l.text.slice(Math.max(e,c)-c,n-c):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&d||l.isTextblock)&&r&&(a?a=!1:i+=r),i+=d},0),i}append(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 V(s,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],s=0;if(n>e)for(let i=0,a=0;a<n;i++){let l=this.content[i],c=a+l.nodeSize;c>e&&((a<e||c>n)&&(l.isText?l=l.cut(Math.max(0,e-a),Math.min(l.text.length,n-a)):l=l.cut(Math.max(0,e-a-1),Math.min(l.content.size,n-a-1))),r.push(l),s+=l.nodeSize),a=c}return new V(r,s)}cutByIndex(e,n){return e==n?V.empty:e==0&&n==this.content.length?this:new V(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 V(s,i)}addToStart(e){return new V([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new V(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 Cr(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Sr(this,e,n,r)}findIndex(e){if(e==0)return gt(0,e);if(e==this.size)return gt(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?gt(n+1,i):gt(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 V.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new V(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return V.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 V(n||e,r)}static from(e){if(!e)return V.empty;if(e instanceof V)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new V([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}V.empty=new V([],0);const Ft={index:0,offset:0};function gt(t,e){return Ft.index=t,Ft.offset=e,Ft}class ro extends Error{}class H{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=_r(this.content,e+this.openStart,n);return r&&new H(r,this.openStart,this.openEnd)}removeBetween(e,n){return new H(Tr(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 H.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 H(V.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 H(e,r,s)}}H.empty=new H(V.empty,0,0);function Tr(t,e,n){let{index:r,offset:s}=t.findIndex(e),i=t.maybeChild(r),{index:a,offset:l}=t.findIndex(n);if(s==e||i.isText){if(l!=n&&!t.child(a).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=a)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(Tr(i.content,e-s-1,n-s-1)))}function _r(t,e,n,r){let{index:s,offset:i}=t.findIndex(e),a=t.maybeChild(s);if(i==e||a.isText)return r&&!r.canReplace(s,s,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=_r(a.content,e-i-1,n,a);return l&&t.replaceChild(s,a.copy(l))}const kr=65535,Ar=Math.pow(2,16);function so(t,e){return t+e*Ar}function Or(t){return t&kr}function io(t){return(t-(t&kr))/Ar}const Mr=1,Ir=2,bt=4,Rr=8;class Lr{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Rr)>0}get deletedBefore(){return(this.delInfo&(Mr|bt))>0}get deletedAfter(){return(this.delInfo&(Ir|bt))>0}get deletedAcross(){return(this.delInfo&bt)>0}}class oe{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&oe.empty)return oe.empty}recover(e){let n=0,r=Or(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+io(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let s=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?s:0);if(c>e)break;let d=this.ranges[l+i],u=this.ranges[l+a],f=c+d;if(e<=f){let m=d?e==c?-1:e==f?1:n:n,p=c+s+(m<0?0:u);if(r)return p;let b=e==(n<0?c:f)?null:so(l/3,e-c),w=e==c?Ir:e==f?Mr:bt;return(n<0?e!=c:e!=f)&&(w|=Rr),new Lr(p,w,b)}s+=u-d}return r?e+s:new Lr(e+s,0,null)}touches(e,n){let r=0,s=Or(n),i=this.inverted?2:1,a=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?r:0);if(c>e)break;let d=this.ranges[l+i],u=c+d;if(e<=u&&l==s*3)return!0;r+=this.ranges[l+a]-d}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let a=this.ranges[s],l=a-(this.inverted?i:0),c=a+(this.inverted?0:i),d=this.ranges[s+n],u=this.ranges[s+r];e(l,l+d,c,c+u),i+=u-d}}invert(){return new oe(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?oe.empty:new oe(e<0?[0,-e,0]:[0,0,e])}}oe.empty=new oe([]);const Ht=Object.create(null);class ne{getMap(){return oe.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Ht[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 Ht)throw new RangeError("Duplicate use of step JSON ID "+e);return Ht[e]=n,n.prototype.jsonID=e,n}}class Q{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new Q(e,null)}static fail(e){return new Q(null,e)}static fromReplace(e,n,r,s){try{return Q.ok(e.replace(n,r,s))}catch(i){if(i instanceof ro)return Q.fail(i.message);throw i}}}function $t(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy($t(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return V.fromArray(r)}class Re extends ne{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 H($t(n.content,(a,l)=>!a.isAtom||!l.type.allowsMarkType(this.mark.type)?a:a.mark(this.mark.addToSet(a.marks)),s),n.openStart,n.openEnd);return Q.fromReplace(e,this.from,this.to,i)}invert(){return new Le(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 Re(n.pos,r.pos,this.mark)}merge(e){return e instanceof Re&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Re(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 Re(n.from,n.to,e.markFromJSON(n.mark))}}ne.jsonID("addMark",Re);class Le extends ne{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 H($t(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return Q.fromReplace(e,this.from,this.to,r)}invert(){return new Re(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 Le(n.pos,r.pos,this.mark)}merge(e){return e instanceof Le&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Le(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 Le(n.from,n.to,e.markFromJSON(n.mark))}}ne.jsonID("removeMark",Le);class je extends ne{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Q.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Q.fromReplace(e,this.pos,this.pos+1,new H(V.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 je(this.pos,n.marks[s]);return new je(this.pos,this.mark)}}return new Ye(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new je(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 je(n.pos,e.markFromJSON(n.mark))}}ne.jsonID("addNodeMark",je);class Ye extends ne{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Q.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Q.fromReplace(e,this.pos,this.pos+1,new H(V.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new je(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Ye(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 Ye(n.pos,e.markFromJSON(n.mark))}}ne.jsonID("removeNodeMark",Ye);class _e extends ne{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&Kt(e,this.from,this.to)?Q.fail("Structure replace would overwrite content"):Q.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new oe([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?H.empty:new H(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?H.empty:new H(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,H.fromJSON(e,n.slice),!!n.structure)}}ne.jsonID("replace",_e);class He extends ne{constructor(e,n,r,s,i,a,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=a,this.structure=l}apply(e){if(this.structure&&(Kt(e,this.from,this.gapFrom)||Kt(e,this.gapTo,this.to)))return Q.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Q.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Q.fromReplace(e,this.from,this.to,r):Q.fail("Content does not fit in gap")}getMap(){return new oe([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 He(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 He(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 He(n.from,n.to,n.gapFrom,n.gapTo,H.fromJSON(e,n.slice),n.insert,!!n.structure)}}ne.jsonID("replaceAround",He);function Kt(t,e,n){let r=t.resolve(e),s=n-e,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let a=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!a||a.isLeaf)return!0;a=a.firstChild,s--}}return!1}class Ze extends ne{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 Q.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 Q.fromReplace(e,this.pos,this.pos+1,new H(V.from(s),0,n.isLeaf?0:1))}getMap(){return oe.empty}invert(e){return new Ze(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 Ze(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 Ze(n.pos,n.attr,n.value)}}ne.jsonID("attr",Ze);class wt extends ne{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 Q.ok(r)}getMap(){return oe.empty}invert(e){return new wt(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 wt(n.attr,n.value)}}ne.jsonID("docAttr",wt);let Xe=class extends Error{};Xe=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n},Xe.prototype=Object.create(Error.prototype),Xe.prototype.constructor=Xe,Xe.prototype.name="TransformError";const qt=Object.create(null);class W{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new jr(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=H.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,a=this.ranges;for(let l=0;l<a.length;l++){let{$from:c,$to:d}=a[l],u=e.mapping.slice(i);e.replaceRange(u.map(c.pos),u.map(d.pos),l?H.empty:n),l==0&&Br(e,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:a,$to:l}=s[i],c=e.mapping.slice(r),d=c.map(a.pos),u=c.map(l.pos);i?e.deleteRange(d,u):(e.replaceRangeWith(d,u,n),Br(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new de(e):$e(e.node(0),e.parent,e.pos,e.index(),n,r);if(s)return s;for(let i=e.depth-1;i>=0;i--){let a=n<0?$e(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):$e(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(a)return a}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new ke(e.node(0))}static atStart(e){return $e(e,e,0,0,1)||new ke(e)}static atEnd(e){return $e(e,e,e.content.size,e.childCount,-1)||new ke(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=qt[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 qt)throw new RangeError("Duplicate use of selection JSON ID "+e);return qt[e]=n,n.prototype.jsonID=e,n}getBookmark(){return de.between(this.$anchor,this.$head).getBookmark()}}W.prototype.visible=!0;class jr{constructor(e,n){this.$from=e,this.$to=n}}let Dr=!1;function Pr(t){!Dr&&!t.parent.inlineContent&&(Dr=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class de extends W{constructor(e,n=e){Pr(e),Pr(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 W.near(r);let s=e.resolve(n.map(this.anchor));return new de(s.parent.inlineContent?s:r,r)}replace(e,n=H.empty){if(super.replace(e,n),n==H.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof de&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new xt(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 de(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=W.findFrom(n,r,!0)||W.findFrom(n,-r,!0);if(i)n=i.$head;else return W.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(W.findFrom(e,-r,!0)||W.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new de(e,n)}}W.jsonID("text",de);class xt{constructor(e,n){this.anchor=e,this.head=n}map(e){return new xt(e.map(this.anchor),e.map(this.head))}resolve(e){return de.between(e.resolve(this.anchor),e.resolve(this.head))}}class ue extends W{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?W.near(i):new ue(i)}content(){return new H(V.from(this.node),0,0)}eq(e){return e instanceof ue&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Vt(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new ue(e.resolve(n.anchor))}static create(e,n){return new ue(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}ue.prototype.visible=!1,W.jsonID("node",ue);class Vt{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new xt(r,r):new Vt(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&ue.isSelectable(r)?new ue(n):W.near(n)}}class ke extends W{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=H.empty){if(n==H.empty){e.delete(0,e.doc.content.size);let r=W.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new ke(e)}map(e){return new ke(e)}eq(e){return e instanceof ke}getBookmark(){return oo}}W.jsonID("all",ke);const oo={map(){return this},resolve(t){return new ke(t)}};function $e(t,e,n,r,s,i=!1){if(e.inlineContent)return de.create(t,n);for(let a=r-(s>0?0:1);s>0?a<e.childCount:a>=0;a+=s){let l=e.child(a);if(l.isAtom){if(!i&&ue.isSelectable(l))return ue.create(t,n-(s<0?l.nodeSize:0))}else{let c=$e(t,l,n+s,s<0?l.childCount:0,s,i);if(c)return c}n+=l.nodeSize*s}return null}function Br(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof _e||s instanceof He))return;let i=t.mapping.maps[r],a;i.forEach((l,c,d,u)=>{a==null&&(a=u)}),t.setSelection(W.near(t.doc.resolve(a),n))}function zr(t,e){return!e||!t?t:t.bind(e)}class yt{constructor(e,n,r){this.name=e,this.init=zr(n.init,r),this.apply=zr(n.apply,r)}}new yt("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new yt("selection",{init(t,e){return t.selection||W.atStart(e.doc)},apply(t){return t.selection}}),new yt("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new yt("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}});function Ur(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=Ur(s,e,{})),n[r]=s}return n}class Fr{constructor(e){this.spec=e,this.props={},e.props&&Ur(e.props,this,this.props),this.key=e.key?e.key.key:Hr("plugin")}getState(e){return e[this.key]}}const Wt=Object.create(null);function Hr(t){return t in Wt?t+"$"+ ++Wt[t]:(Wt[t]=0,t+"$")}class Qe{constructor(e="key"){this.key=Hr(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}for(var Ie={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:"'"},vt={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ao=typeof navigator<"u"&&/Mac/.test(navigator.platform),lo=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),te=0;te<10;te++)Ie[48+te]=Ie[96+te]=String(te);for(var te=1;te<=24;te++)Ie[te+111]="F"+te;for(var te=65;te<=90;te++)Ie[te]=String.fromCharCode(te+32),vt[te]=String.fromCharCode(te);for(var Jt in Ie)vt.hasOwnProperty(Jt)||(vt[Jt]=Ie[Jt]);function co(t){var e=ao&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||lo&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?vt:Ie)[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 uo=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),fo=typeof navigator<"u"&&/Win/.test(navigator.platform);function po(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,s,i,a;for(let l=0;l<e.length-1;l++){let c=e[l];if(/^(cmd|meta|m)$/i.test(c))a=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))s=!0;else if(/^s(hift)?$/i.test(c))i=!0;else if(/^mod$/i.test(c))uo?a=!0:s=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),a&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function ho(t){let e=Object.create(null);for(let n in t)e[po(n)]=t[n];return e}function Gt(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 mo(t){let e=ho(t);return function(n,r){let s=co(r),i,a=e[Gt(s,r)];if(a&&a(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[Gt(s,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(fo&&r.ctrlKey&&r.altKey)&&(i=Ie[r.keyCode])&&i!=s){let l=e[Gt(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var Yt,Zt;if(typeof WeakMap<"u"){let t=new WeakMap;Yt=e=>t.get(e),Zt=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;Yt=r=>{for(let s=0;s<t.length;s+=2)if(t[s]==r)return t[s+1]},Zt=(r,s)=>(n==10&&(n=0),t[n++]=r,t[n++]=s)}var Ae=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const r=e%this.width,s=e/this.width|0;let i=r+1,a=s+1;for(let l=1;i<this.width&&this.map[e+l]==n;l++)i++;for(let l=1;a<this.height&&this.map[e+this.width*l]==n;l++)a++;return{left:r,top:s,right:i,bottom:a}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:r,right:s,top:i,bottom:a}=this.findCell(t);return e=="horiz"?(n<0?r==0:s==this.width)?null:this.map[i*this.width+(n<0?r-1:s)]:(n<0?i==0:a==this.height)?null:this.map[r+this.width*(n<0?i-1:a)]}rectBetween(t,e){const{left:n,right:r,top:s,bottom:i}=this.findCell(t),{left:a,right:l,top:c,bottom:d}=this.findCell(e);return{left:Math.min(n,a),top:Math.min(s,c),right:Math.max(r,l),bottom:Math.max(i,d)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let s=t.left;s<t.right;s++){const i=r*this.width+s,a=this.map[i];n[a]||(n[a]=!0,!(s==t.left&&s&&this.map[i-1]==a||r==t.top&&r&&this.map[i-this.width]==a)&&e.push(a))}return e}positionAt(t,e,n){for(let r=0,s=0;;r++){const i=s+n.child(r).nodeSize;if(r==t){let a=e+t*this.width;const l=(t+1)*this.width;for(;a<l&&this.map[a]<s;)a++;return a==l?i-1:this.map[a]}s=i}}static get(t){return Yt(t)||Zt(t,go(t))}};function go(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=bo(t),n=t.childCount,r=[];let s=0,i=null;const a=[];for(let d=0,u=e*n;d<u;d++)r[d]=0;for(let d=0,u=0;d<n;d++){const f=t.child(d);u++;for(let b=0;;b++){for(;s<r.length&&r[s]!=0;)s++;if(b==f.childCount)break;const w=f.child(b),{colspan:g,rowspan:_,colwidth:C}=w.attrs;for(let y=0;y<_;y++){if(y+d>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:u,n:_-y});break}const T=s+y*e;for(let x=0;x<g;x++){r[T+x]==0?r[T+x]=u:(i||(i=[])).push({type:"collision",row:d,pos:u,n:g-x});const k=C&&C[x];if(k){const M=(T+x)%e*2,z=a[M];z==null||z!=k&&a[M+1]==1?(a[M]=k,a[M+1]=1):z==k&&a[M+1]++}}}s+=g,u+=w.nodeSize}const m=(d+1)*e;let p=0;for(;s<m;)r[s++]==0&&p++;p&&(i||(i=[])).push({type:"missing",row:d,n:p}),u++}(e===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});const l=new Ae(e,n,r,i);let c=!1;for(let d=0;!c&&d<a.length;d+=2)a[d]!=null&&a[d+1]<n&&(c=!0);return c&&wo(l,a,t),l}function bo(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const s=t.child(r);let i=0;if(n)for(let a=0;a<r;a++){const l=t.child(a);for(let c=0;c<l.childCount;c++){const d=l.child(c);a+d.attrs.rowspan>r&&(i+=d.attrs.colspan)}}for(let a=0;a<s.childCount;a++){const l=s.child(a);i+=l.attrs.colspan,l.attrs.rowspan>1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function wo(t,e,n){t.problems||(t.problems=[]);const r={};for(let s=0;s<t.map.length;s++){const i=t.map[s];if(r[i])continue;r[i]=!0;const a=n.nodeAt(i);if(!a)throw new RangeError(`No cell with offset ${i} found`);let l=null;const c=a.attrs;for(let d=0;d<c.colspan;d++){const u=(s+d)%t.width,f=e[u*2];f!=null&&(!c.colwidth||c.colwidth[d]!=f)&&((l||(l=xo(c)))[d]=f)}l&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function xo(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function Xt(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],s=r.spec.tableRole;s&&(e[s]=r)}}return e}new Qe("selectingCells");function yo(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function $r(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function vo(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=yo(e.$head)||Eo(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function Eo(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function Kr(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function qr(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Vr(t,e,n){const r=t.node(-1),s=Ae.get(r),i=t.start(-1),a=s.nextCell(t.pos-i,e,n);return a==null?null:t.node(0).resolve(i+a)}function Wr(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(s=>s>0)||(r.colwidth=null)),r}var Ee=class Oe extends W{constructor(e,n=e){const r=e.node(-1),s=Ae.get(r),i=e.start(-1),a=s.rectBetween(e.pos-i,n.pos-i),l=e.node(0),c=s.cellsInRect(a).filter(u=>u!=n.pos-i);c.unshift(n.pos-i);const d=c.map(u=>{const f=r.nodeAt(u);if(!f)throw RangeError(`No cell with offset ${u} found`);const m=i+u+1;return new jr(l.resolve(m),l.resolve(m+f.content.size))});super(d[0].$from,d[0].$to,d),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),s=e.resolve(n.map(this.$headCell.pos));if(Kr(r)&&Kr(s)&&qr(r,s)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?Oe.rowSelection(r,s):i&&this.isColSelection()?Oe.colSelection(r,s):new Oe(r,s)}return de.between(r,s)}content(){const e=this.$anchorCell.node(-1),n=Ae.get(e),r=this.$anchorCell.start(-1),s=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},a=[];for(let c=s.top;c<s.bottom;c++){const d=[];for(let u=c*n.width+s.left,f=s.left;f<s.right;f++,u++){const m=n.map[u];if(i[m])continue;i[m]=!0;const p=n.findCell(m);let b=e.nodeAt(m);if(!b)throw RangeError(`No cell with offset ${m} found`);const w=s.left-p.left,g=p.right-s.right;if(w>0||g>0){let _=b.attrs;if(w>0&&(_=Wr(_,0,w)),g>0&&(_=Wr(_,_.colspan-g,g)),p.left<s.left){if(b=b.type.createAndFill(_),!b)throw RangeError(`Could not create cell with attrs ${JSON.stringify(_)}`)}else b=b.type.create(_,b.content)}if(p.top<s.top||p.bottom>s.bottom){const _={...b.attrs,rowspan:Math.min(p.bottom,s.bottom)-Math.max(p.top,s.top)};p.top<s.top?b=b.type.createAndFill(_):b=b.type.create(_,b.content)}d.push(b)}a.push(e.child(c).copy(V.from(d)))}const l=this.isColSelection()&&this.isRowSelection()?e:a;return new H(V.from(l),1,1)}replace(e,n=H.empty){const r=e.steps.length,s=this.ranges;for(let a=0;a<s.length;a++){const{$from:l,$to:c}=s[a],d=e.mapping.slice(r);e.replace(d.map(l.pos),d.map(c.pos),a?H.empty:n)}const i=W.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new H(V.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=Ae.get(n),s=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let a=0;a<i.length;a++)e(n.nodeAt(i[a]),s+i[a])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,s)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),s=Ae.get(r),i=e.start(-1),a=s.findCell(e.pos-i),l=s.findCell(n.pos-i),c=e.node(0);return a.top<=l.top?(a.top>0&&(e=c.resolve(i+s.map[a.left])),l.bottom<s.height&&(n=c.resolve(i+s.map[s.width*(s.height-1)+l.right-1]))):(l.top>0&&(n=c.resolve(i+s.map[l.left])),a.bottom<s.height&&(e=c.resolve(i+s.map[s.width*(s.height-1)+a.right-1]))),new Oe(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=Ae.get(e),r=this.$anchorCell.start(-1),s=n.colCount(this.$anchorCell.pos-r),i=n.colCount(this.$headCell.pos-r);if(Math.min(s,i)>0)return!1;const a=s+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(a,l)==n.width}eq(e){return e instanceof Oe&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),s=Ae.get(r),i=e.start(-1),a=s.findCell(e.pos-i),l=s.findCell(n.pos-i),c=e.node(0);return a.left<=l.left?(a.left>0&&(e=c.resolve(i+s.map[a.top*s.width])),l.right<s.width&&(n=c.resolve(i+s.map[s.width*(l.top+1)-1]))):(l.left>0&&(n=c.resolve(i+s.map[l.top*s.width])),a.right<s.width&&(e=c.resolve(i+s.map[s.width*(a.top+1)-1]))),new Oe(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new Oe(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new Oe(e.resolve(n),e.resolve(r))}getBookmark(){return new No(this.$anchorCell.pos,this.$headCell.pos)}};Ee.prototype.visible=!1,W.jsonID("cell",Ee);var No=class ts{constructor(e,n){this.anchor=e,this.head=n}map(e){return new ts(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&qr(n,r)?new Ee(n,r):W.near(r,1)}};new Qe("fix-tables");function Jr(t){const e=t.selection,n=vo(t),r=n.node(-1),s=n.start(-1),i=Ae.get(r);return{...e instanceof Ee?i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):i.findCell(n.pos-s),tableStart:s,map:i,table:r}}function Co(t){return function(e,n){if(!$r(e))return!1;if(n){const r=Xt(e.schema),s=Jr(e),i=e.tr,a=s.map.cellsInRect(t=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:t=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),l=a.map(c=>s.table.nodeAt(c));for(let c=0;c<a.length;c++)l[c].type==r.header_cell&&i.setNodeMarkup(s.tableStart+a[c],r.cell,l[c].attrs);if(i.steps.length==0)for(let c=0;c<a.length;c++)i.setNodeMarkup(s.tableStart+a[c],r.header_cell,l[c].attrs);n(i)}return!0}}function Gr(t,e,n){const r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let s=0;s<r.length;s++){const i=e.table.nodeAt(r[s]);if(i&&i.type!==n.header_cell)return!1}return!0}function Qt(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?Co(t):function(n,r){if(!$r(n))return!1;if(r){const s=Xt(n.schema),i=Jr(n),a=n.tr,l=Gr("row",i,s),c=Gr("column",i,s),u=(t==="column"?l:t==="row"?c:!1)?1:0,f=t=="column"?{left:0,top:u,right:1,bottom:i.map.height}:t=="row"?{left:u,top:0,right:i.map.width,bottom:1}:i,m=t=="column"?c?s.cell:s.header_cell:t=="row"?l?s.cell:s.header_cell:s.cell;i.map.cellsInRect(f).forEach(p=>{const b=p+i.tableStart,w=a.doc.nodeAt(b);w&&a.setNodeMarkup(b,m,w.attrs)}),r(a)}return!0}}Qt("row",{useDeprecatedLogic:!0}),Qt("column",{useDeprecatedLogic:!0}),Qt("cell",{useDeprecatedLogic:!0});function Et(t,e){const n=t.selection;if(!(n instanceof Ee))return!1;if(e){const r=t.tr,s=Xt(t.schema).cell.createAndFill().content;n.forEachCell((i,a)=>{i.content.eq(s)||r.replace(r.mapping.map(a+1),r.mapping.map(a+i.nodeSize-1),new H(s,0,0))}),r.docChanged&&e(r)}return!0}mo({ArrowLeft:Ct("horiz",-1),ArrowRight:Ct("horiz",1),ArrowUp:Ct("vert",-1),ArrowDown:Ct("vert",1),"Shift-ArrowLeft":St("horiz",-1),"Shift-ArrowRight":St("horiz",1),"Shift-ArrowUp":St("vert",-1),"Shift-ArrowDown":St("vert",1),Backspace:Et,"Mod-Backspace":Et,Delete:Et,"Mod-Delete":Et});function Nt(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function Ct(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;if(i instanceof Ee)return Nt(n,r,W.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const a=Yr(s,t,e);if(a==null)return!1;if(t=="horiz")return Nt(n,r,W.near(n.doc.resolve(i.head+e),e));{const l=n.doc.resolve(a),c=Vr(l,t,e);let d;return c?d=W.near(c,1):e<0?d=W.near(n.doc.resolve(l.before(-1)),-1):d=W.near(n.doc.resolve(l.after(-1)),1),Nt(n,r,d)}}}function St(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;let a;if(i instanceof Ee)a=i;else{const c=Yr(s,t,e);if(c==null)return!1;a=new Ee(n.doc.resolve(c))}const l=Vr(a.$headCell,t,e);return l?Nt(n,r,new Ee(a.$anchorCell,l)):!1}}function Yr(t,e,n){if(!(t.state.selection instanceof de))return null;const{$head:r}=t.state.selection;for(let s=r.depth-1;s>=0;s--){const i=r.node(s);if((n<0?r.index(s):r.indexAfter(s))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const l=r.before(s),c=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(c)?l:null}}return null}new Qe("tableColumnResizing");function So(t,e){const n=Math.min(t.top,e.top),r=Math.max(t.bottom,e.bottom),s=Math.min(t.left,e.left),a=Math.max(t.right,e.right)-s,l=r-n,c=s,d=n;return new DOMRect(c,d,a,l)}var To=class{constructor({editor:t,element:e,view:n,updateDelay:r=250,resizeDelay:s=60,shouldShow:i,appendTo:a,options:l}){this.preventHide=!1,this.isVisible=!1,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:c,state:d,from:u,to:f})=>{const{doc:m,selection:p}=d,{empty:b}=p,w=!m.textBetween(u,f).length&&K.isTextSelection(d.selection),g=this.element.contains(document.activeElement);return!(!(c.hasFocus()||g)||b||w||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:c})=>{var d;if(this.preventHide){this.preventHide=!1;return}c?.relatedTarget&&((d=this.element.parentNode)!=null&&d.contains(c.relatedTarget))||c?.relatedTarget!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(c,d)=>{const u=!d?.selection.eq(c.state.selection),f=!d?.doc.eq(c.state.doc);!u&&!f||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(c,u,f,d)},this.updateDelay))},this.updateHandler=(c,d,u,f)=>{const{composing:m}=c;if(m||!d&&!u)return;if(!this.getShouldShow(f)){this.hide();return}this.updatePosition(),this.show()},this.editor=t,this.element=e,this.view=n,this.updateDelay=r,this.resizeDelay=s,this.appendTo=a,this.floatingUIOptions={...this.floatingUIOptions,...l},this.element.tabIndex=0,i&&(this.shouldShow=i),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),window.addEventListener("resize",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&this.show()}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(wr(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(br(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(mr(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(vr(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(xr(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(gr(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(yr(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(Er(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),t}updatePosition(){const{selection:t}=this.editor.state,e=K.posToDOMRect(this.view,t.from,t.to);let n={getBoundingClientRect:()=>e,getClientRects:()=>[e]};if(t instanceof ue){let r=this.view.nodeDOM(t.from);const s=r.dataset.nodeViewWrapper?r:r.querySelector("[data-node-view-wrapper]");s&&(r=s),r&&(n={getBoundingClientRect:()=>r.getBoundingClientRect(),getClientRects:()=>[r.getBoundingClientRect()]})}if(t instanceof Ee){const{$anchorCell:r,$headCell:s}=t,i=r?r.pos:s.pos,a=s?s.pos:r.pos,l=this.view.nodeDOM(i),c=this.view.nodeDOM(a);if(!l||!c)return;const d=l===c?l.getBoundingClientRect():So(l.getBoundingClientRect(),c.getBoundingClientRect());n={getBoundingClientRect:()=>d,getClientRects:()=>[d]}}Nr(n,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:r,y:s,strategy:i})=>{this.element.style.width="max-content",this.element.style.position=i,this.element.style.left=`${r}px`,this.element.style.top=`${s}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(t,e){const{state:n}=t,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r){this.handleDebouncedUpdate(t,e);return}const s=!e?.selection.eq(t.state.selection),i=!e?.doc.eq(t.state.doc);this.updateHandler(t,s,i,e)}getShouldShow(t){var e;const{state:n}=this.view,{selection:r}=n,{ranges:s}=r,i=Math.min(...s.map(c=>c.$from.pos)),a=Math.max(...s.map(c=>c.$to.pos));return(e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,element:this.element,view:this.view,state:n,oldState:t,from:i,to:a})}show(){var t,e;this.isVisible||(this.element.style.visibility="visible",this.element.style.opacity="1",(e=(t=this.appendTo)!=null?t:this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},Zr=t=>new Fr({key:typeof t.pluginKey=="string"?new Qe(t.pluginKey):t.pluginKey,view:e=>new To({view:e,...t})});K.Extension.create({name:"bubbleMenu",addOptions(){return{element:null,pluginKey:"bubbleMenu",updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[Zr({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}});var _o=class{constructor({editor:t,element:e,view:n,options:r,shouldShow:s}){this.preventHide=!1,this.isVisible=!1,this.shouldShow=({view:i,state:a})=>{const{selection:l}=a,{$anchor:c,empty:d}=l,u=c.depth===1,f=c.parent.isTextblock&&!c.parent.type.spec.code&&!c.parent.textContent&&c.parent.childCount===0&&!this.getTextContent(c.parent);return!(!i.hasFocus()||!d||!u||!f||!this.editor.isEditable)},this.floatingUIOptions={strategy:"absolute",placement:"right",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(i,a,l,c)=>{const{composing:d}=i;if(d||!a&&!l)return;if(!this.getShouldShow(c)){this.hide();return}this.updatePosition(),this.show()},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:i})=>{var a;if(this.preventHide){this.preventHide=!1;return}i?.relatedTarget&&((a=this.element.parentNode)!=null&&a.contains(i.relatedTarget))||i?.relatedTarget!==this.editor.view.dom&&this.hide()},this.editor=t,this.element=e,this.view=n,this.floatingUIOptions={...this.floatingUIOptions,...r},this.element.tabIndex=0,s&&(this.shouldShow=s),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.update(n,n.state),this.getShouldShow()&&this.show()}getTextContent(t){return K.getText(t,{textSerializers:K.getTextSerializersFromSchema(this.editor.schema)})}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(wr(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(br(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(mr(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(vr(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(xr(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(gr(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(yr(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(Er(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),t}getShouldShow(t){var e;const{state:n}=this.view,{selection:r}=n,{ranges:s}=r,i=Math.min(...s.map(c=>c.$from.pos)),a=Math.max(...s.map(c=>c.$to.pos));return(e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,view:this.view,state:n,oldState:t,from:i,to:a})}updatePosition(){const{selection:t}=this.editor.state,e=K.posToDOMRect(this.view,t.from,t.to);Nr({getBoundingClientRect:()=>e,getClientRects:()=>[e]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:r,y:s,strategy:i})=>{this.element.style.width="max-content",this.element.style.position=i,this.element.style.left=`${r}px`,this.element.style.top=`${s}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(t,e){const n=!e?.selection.eq(t.state.selection),r=!e?.doc.eq(t.state.doc);this.updateHandler(t,n,r,e)}show(){var t;this.isVisible||(this.element.style.visibility="visible",this.element.style.opacity="1",(t=this.view.dom.parentElement)==null||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},Xr=t=>new Fr({key:typeof t.pluginKey=="string"?new Qe(t.pluginKey):t.pluginKey,view:e=>new _o({view:e,...t})});K.Extension.create({name:"floatingMenu",addOptions(){return{element:null,options:{},pluginKey:"floatingMenu",shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[Xr({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,options:this.options.options,shouldShow:this.options.shouldShow})]:[]}});var Qr=N.forwardRef(({pluginKey:t="bubbleMenu",editor:e,updateDelay:n,resizeDelay:r,shouldShow:s=null,options:i,children:a,...l},c)=>{const d=N.useRef(document.createElement("div"));typeof c=="function"?c(d.current):c&&(c.current=d.current);const{editor:u}=q.useCurrentEditor();return N.useEffect(()=>{const f=d.current;if(f.style.visibility="hidden",f.style.position="absolute",e?.isDestroyed||u?.isDestroyed)return;const m=e||u;if(!m){console.warn("BubbleMenu component is not rendered inside of an editor component or does not have editor prop.");return}const p=Zr({updateDelay:n,resizeDelay:r,editor:m,element:f,pluginKey:t,shouldShow:s,options:i});return m.registerPlugin(p),()=>{m.unregisterPlugin(t),window.requestAnimationFrame(()=>{f.parentNode&&f.parentNode.removeChild(f)})}},[e,u]),sn.createPortal(o.jsx("div",{...l,children:a}),d.current)}),ko=N.forwardRef(({pluginKey:t="floatingMenu",editor:e,shouldShow:n=null,options:r,children:s,...i},a)=>{const l=N.useRef(document.createElement("div"));typeof a=="function"?a(l.current):a&&(a.current=l.current);const{editor:c}=q.useCurrentEditor();return N.useEffect(()=>{const d=l.current;if(d.style.visibility="hidden",d.style.position="absolute",e?.isDestroyed||c?.isDestroyed)return;const u=e||c;if(!u){console.warn("FloatingMenu component is not rendered inside of an editor component or does not have editor prop.");return}const f=Xr({editor:u,element:d,pluginKey:t,shouldShow:n,options:r});return u.registerPlugin(f),()=>{u.unregisterPlugin(t),window.requestAnimationFrame(()=>{d.parentNode&&d.parentNode.removeChild(d)})}},[e,c]),sn.createPortal(o.jsx("div",{...i,children:s}),l.current)});const Ao=({editor:t,isReadOnly:e})=>{const[n,r]=N.useState(!1),[s,i]=N.useState(!1),[a,l]=N.useState(""),[c,d]=N.useState(!1),u=()=>{a&&(t.chain().focus().extendMarkRange("link").setLink({href:a}).run(),l(""),d(!1))};return e?null:o.jsx(Qr,{editor:t,shouldShow:({editor:f,state:m})=>{const{from:p,to:b}=m.selection;return p!==b&&!f.isActive("codeBlock")},className:"bubble-menu bg-white border border-gray-300 rounded-lg p-2 shadow-lg z-50",children:o.jsxs("div",{className:"flex gap-1 items-center",children:[o.jsx(j,{onClick:()=>t.chain().focus().toggleBold().run(),isActive:t.isActive("bold"),title:"Bold",children:o.jsx(O.Bold,{className:"h-4 w-4 cursor-pointer"})}),o.jsx(j,{onClick:()=>t.chain().focus().toggleItalic().run(),isActive:t.isActive("italic"),title:"Italic",children:o.jsx(O.Italic,{className:"h-4 w-4 cursor-pointer"})}),o.jsx(j,{onClick:()=>t.chain().focus().toggleUnderline().run(),isActive:t.isActive("underline"),title:"Underline",children:o.jsx(O.Underline,{className:"h-4 w-4 cursor-pointer"})}),o.jsx(j,{onClick:()=>t.chain().focus().toggleStrike().run(),isActive:t.isActive("strike"),title:"Strikethrough",children:o.jsx(O.Strikethrough,{className:"h-4 w-4 cursor-pointer"})}),o.jsx(j,{onClick:()=>t.chain().focus().toggleCode().run(),isActive:t.isActive("code"),title:"Inline Code",children:o.jsx(O.Code,{className:"h-4 w-4 cursor-pointer"})}),o.jsxs("div",{className:"relative",children:[o.jsx(j,{onClick:()=>r(!n),title:"Text Color",children:o.jsx(O.Type,{className:"h-4 w-4 cursor-pointer"})}),n&&o.jsx("div",{className:"absolute top-full mt-1 z-10 bg-white border border-gray-300 rounded-lg p-2 shadow-lg",children:o.jsx(li,{onColorChange:f=>{t.chain().focus().setColor(f).run(),r(!1)}})})]}),o.jsxs("div",{className:"relative",children:[o.jsx(j,{onClick:()=>i(!s),title:"Background Color",children:o.jsx(O.Palette,{className:"h-4 w-4 cursor-pointer"})}),s&&o.jsx("div",{className:"absolute top-full mt-1 z-10 bg-white border border-gray-300 rounded-lg p-2 shadow-lg",children:o.jsx(ci,{onColorChange:f=>{t.chain().focus().toggleHighlight({color:f}).run(),i(!1)}})})]}),o.jsxs("div",{className:"relative",children:[o.jsx(j,{onClick:()=>d(!c),isActive:t.isActive("link"),title:"Add/Edit Link",children:o.jsx(O.Link,{className:"h-4 w-4 cursor-pointer"})}),c&&o.jsx("div",{className:"absolute top-full mt-1 z-10 bg-white border border-gray-300 rounded-lg p-2 shadow-lg",children:o.jsxs("div",{className:"flex gap-2",children:[o.jsx("input",{type:"url",placeholder:"Enter URL...",value:a,onChange:f=>l(f.target.value),className:"px-2 py-1 text-sm border border-gray-300 rounded",onKeyDown:f=>{f.key==="Enter"&&u()}}),o.jsx($,{type:"button",onClick:u,size:"sm",className:"h-8 cursor-pointer",children:"Set"})]})})]})]})})},Oo=[{label:"Green",value:"#4caf5040"},{label:"Red",value:"#f4433640"},{label:"Grey",value:"#9e9e9e40"}],Mo=({onColorChange:t})=>o.jsx("div",{className:"flex gap-2",children:Oo.map(({label:e,value:n})=>o.jsxs("button",{type:"button",className:"flex flex-col items-center text-xs text-gray-600",onClick:()=>t(n),children:[o.jsx("span",{className:"w-6 h-6 rounded border border-gray-300 cursor-pointer hover:scale-110 transition-transform",style:{backgroundColor:n}}),e]},n))}),es=[{value:"",label:"Plain Text"},{value:"html",label:"HTML"},{value:"css",label:"CSS"},{value:"js",label:"JavaScript"},{value:"ts",label:"TypeScript"},{value:"python",label:"Python"},{value:"java",label:"Java"},{value:"c",label:"C"},{value:"cpp",label:"C++"},{value:"sql",label:"SQL"}],Io=({editor:t,isReadOnly:e})=>{const[n,r]=N.useState(!1),[s,i]=N.useState(!1),a=N.useRef(null),l=t.getAttributes("codeBlock").language||"";if(N.useEffect(()=>{const d=u=>{a.current&&!a.current.contains(u.target)&&i(!1)};return s&&document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d)}},[s]),e)return null;const c=d=>{t.chain().focus().updateAttributes("codeBlock",{language:d||null}).run(),i(!1)};return o.jsx(Qr,{editor:t,shouldShow:({editor:d})=>d.isActive("codeBlock"),className:"bubble-menu bg-white border border-gray-300 rounded-lg p-2 shadow-lg z-50",children:o.jsxs("div",{className:"flex gap-1 items-center",children:[o.jsxs("div",{className:"relative",ref:a,children:[o.jsx(j,{onClick:()=>{i(!s),r(!1)},title:"Select Language",className:"px-2 min-w-[120px]",children:o.jsxs("div",{className:"flex items-center gap-1 w-full justify-between",children:[o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(O.Code,{className:"h-3 w-3"}),o.jsx("span",{className:"text-xs",children:es.find(d=>d.value===l)?.label||"Plain Text"})]}),o.jsx(O.ChevronDown,{className:"h-3 w-3"})]})}),s&&o.jsx("div",{className:"absolute top-full mt-1 left-0 z-10 bg-white border border-gray-300 rounded-lg shadow-lg min-w-[140px] max-h-[300px] overflow-y-auto",children:o.jsx("div",{className:"p-1 space-y-1",children:es.map(d=>o.jsx($,{type:"button",variant:l===d.value?"default":"ghost",size:"sm",onClick:()=>c(d.value),className:`w-full justify-start text-xs hover:bg-gray-100 ${l===d.value?"bg-blue-600 text-white hover:bg-blue-700":""}`,children:d.label},d.value))})})]}),o.jsxs("div",{className:"relative",children:[o.jsx(j,{onClick:()=>{r(!n),i(!1)},title:"Background Color",isActive:t.isActive("codeBlockBg"),children:o.jsx(O.Palette,{className:"h-4 w-4 cursor-pointer"})}),n&&o.jsx("div",{className:"absolute top-full mt-1 z-10 bg-white border border-gray-300 rounded-lg p-2 shadow-lg",children:o.jsx(Mo,{onColorChange:d=>{t.chain().focus().toggleCodeBlockBg(d).run(),r(!1)}})})]})]})})},Ro=({editor:t,isReadOnly:e,onImageClick:n})=>e?null:o.jsxs(ko,{editor:t,className:"floating-menu bg-white border border-gray-300 rounded-lg p-2 shadow-lg flex gap-1 z-50",children:[o.jsx(j,{onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),title:"Heading 1",children:o.jsx(O.Heading1,{className:"h-4 w-4"})}),o.jsx(j,{onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),title:"Heading 2",children:o.jsx(O.Heading2,{className:"h-4 w-4"})}),o.jsx(j,{onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),title:"Heading 3",children:o.jsx(O.Heading3,{className:"h-4 w-4"})}),o.jsx(j,{onClick:()=>t.chain().focus().setParagraph().run(),title:"Paragraph",children:o.jsx(O.FileText,{className:"h-4 w-4"})}),o.jsx(j,{onClick:n,title:"Insert Image",children:o.jsx(O.Image,{className:"h-4 w-4"})})]}),Lo=({editor:t,isReadOnly:e,position:n})=>!n.show||e?null:o.jsxs("div",{className:"table-bubble-menu bg-white border-2 border-blue-500 rounded-lg p-2 shadow-lg",style:{position:"absolute",top:`${n.top}px`,left:`${n.left}px`,zIndex:50,backdropFilter:"blur(8px)",background:"rgba(255, 255, 255, 0.95)"},children:[o.jsxs("div",{className:"flex gap-1 items-center",children:[o.jsx(j,{onClick:()=>t.chain().focus().addRowBefore().run(),title:"Add Row Before",className:"h-8 w-auto px-2",children:o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(O.Plus,{className:"h-3 w-3"}),o.jsx("span",{className:"text-xs",children:"↑ Row"})]})}),o.jsx(j,{onClick:()=>t.chain().focus().addRowAfter().run(),title:"Add Row After",className:"h-8 w-auto px-2",children:o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(O.Plus,{className:"h-3 w-3"}),o.jsx("span",{className:"text-xs",children:"Row ↓"})]})}),o.jsx("div",{className:"h-6 w-px bg-gray-300 mx-1"}),o.jsx(j,{onClick:()=>t.chain().focus().addColumnBefore().run(),title:"Add Column Before",className:"h-8 w-auto px-2",children:o.jsxs("div",{className:"flex items-center gap-1",children:["ß",o.jsx(O.Plus,{className:"h-3 w-3"}),o.jsx("span",{className:"text-xs",children:"← Col"})]})}),o.jsx(j,{onClick:()=>t.chain().focus().addColumnAfter().run(),title:"Add Column After",className:"h-8 w-auto px-2",children:o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(O.Plus,{className:"h-3 w-3"}),o.jsx("span",{className:"text-xs",children:"Col →"})]})}),o.jsx("div",{className:"h-6 w-px bg-gray-300 mx-1"}),o.jsx(j,{onClick:()=>t.chain().focus().deleteColumn().run(),title:"Delete Column",className:"text-red-600 hover:bg-red-50 h-8 w-auto px-2",children:o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(O.Minus,{className:"h-3 w-3"}),o.jsx("span",{className:"text-xs",children:"Col"})]})}),o.jsx("div",{className:"h-6 w-px bg-gray-300 mx-1"}),o.jsx(j,{onClick:()=>t.chain().focus().deleteRow().run(),title:"Delete Row",className:"text-red-600 hover:bg-red-50 h-8 w-auto px-2",children:o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(O.Minus,{className:"h-3 w-3"}),o.jsx("span",{className:"text-xs",children:"Row"})]})}),o.jsx(j,{onClick:()=>t.chain().focus().deleteTable().run(),title:"Delete Table",className:"text-red-600 hover:bg-red-50",children:o.jsx(O.Trash2,{className:"h-4 w-4"})})]}),o.jsx("div",{className:"absolute top-full left-5 w-0 h-0 border-l-6 border-r-6 border-t-6 border-l-transparent border-r-transparent border-t-blue-500"})]}),jo=({editor:t})=>o.jsxs("div",{className:"mb-2 p-2 bg-gray-100 rounded text-xs",children:[o.jsx("strong",{children:"Debug:"})," Current position - H1:"," ",t.isActive("heading",{level:1})?"✅":"❌"," | H2:"," ",t.isActive("heading",{level:2})?"✅":"❌"," | H3:"," ",t.isActive("heading",{level:3})?"✅":"❌"," | P:"," ",t.isActive("paragraph")?"✅":"❌"," | Bold:"," ",t.isActive("bold")?"✅":"❌"," | List:"," ",t.isActive("bulletList")?"✅":"❌"," | Table:"," ",t.isActive("table")?"✅":"❌"]}),Do=({isReadOnly:t,setIsReadOnly:e,onLogContent:n})=>o.jsxs("div",{className:"mb-4 flex justify-end gap-2",children:[o.jsxs($,{type:"button",onClick:n,variant:"outline",size:"sm",className:"flex items-center gap-2",title:"Log content to console for backend storage",children:[o.jsx(O.Terminal,{className:"h-4 w-4"}),"Log Content"]}),o.jsx($,{type:"button",onClick:()=>e(!t),variant:t?"default":"outline",size:"sm",className:"flex items-center gap-2",children:t?o.jsxs(o.Fragment,{children:[o.jsx(O.Lock,{className:"h-4 w-4"}),"Read Only"]}):o.jsxs(o.Fragment,{children:[o.jsx(O.LockOpen,{className:"h-4 w-4"}),"Editable"]})})]}),Po=t=>{const e={html:t.getHTML(),json:t.getJSON(),text:t.getText(),isEmpty:t.isEmpty,characterCount:t.storage.characterCount?.characters()||t.getText().length,wordCount:t.storage.characterCount?.words()||t.getText().split(/\s+/).filter(n=>n.length>0).length,timestamp:new Date().toISOString()};return console.log("📄 Tiptap Editor Content for Backend Storage:"),console.log("================================================"),console.log("📋 HTML Output (for rendering):",e.html),console.log("📋 JSON Output (for editing):",e.json),console.log("📋 Plain Text:",e.text),console.log("📊 Stats:",{isEmpty:e.isEmpty,characters:e.characterCount,words:e.wordCount,timestamp:e.timestamp}),console.log("================================================"),e},Bo=({onImageUpload:t,onVideoUpload:e,onImageDelete:n,onVideoDelete:r,content:s,setEditorContent:i})=>{const[a,l]=N.useState(""),[c,d]=N.useState(!1),[u,f]=N.useState(""),[m,p]=N.useState(!1),[,b]=N.useState({}),[w,g]=N.useState(!1),[_,C]=N.useState(!1),[y,T]=N.useState(!1),[x,k]=N.useState(null),M=N.useRef(null),[z,D]=N.useState({top:0,left:0,show:!1}),S=A=>{const I=new Set,h=E=>{E.type==="image"&&E.attrs?.src&&I.add(E.attrs.src),E.content&&Array.isArray(E.content)&&E.content.forEach(h)};return h(A),I},L=A=>{const I=new Set,h=E=>{E.type==="video"&&E.attrs?.src&&I.add(E.attrs.src),E.content&&Array.isArray(E.content)&&E.content.forEach(h)};return h(A),I},v=q.useEditor({extensions:[cn,vs,en,nn,tn,dn,un,On,Mn,fn,pn,hn,An,kn,In,Rn,Ln,jn,Dn,Pn,Bn,Un,Hn,$n,Fn.configure({inline:!1,allowBase64:!0,HTMLAttributes:{class:"max-w-full h-auto rounded-lg shadow-sm"}})],content:s||`
|
|
56
74
|
<p>Hello World. Create your own content here.</p>
|
|
57
|
-
`,editable:!
|
|
75
|
+
`,editable:!w,editorProps:{attributes:{class:"prose prose-sm sm:prose lg:prose-lg xl:prose-2xl mx-auto focus:outline-none min-h-[400px] p-4"},handlePaste:(A,I,h)=>{const R=Array.from(I.clipboardData?.items||[]).filter(Z=>Z.type.indexOf("image")!==-1);if(R.length>0&&t&&M.current){I.preventDefault();const Z=R.map(X=>{const ae=X.getAsFile();return ae?t(ae).then(fe=>(fe&&M.current&&M.current.chain().focus().setImage({src:fe}).run(),fe)).catch(fe=>(console.error("Failed to upload pasted image:",fe),alert("Failed to upload pasted image. Please try again."),null)):Promise.resolve(null)});return C(!0),Promise.all(Z).finally(()=>{C(!1)}),!0}const B=I.clipboardData?.getData("text/html");if(B&&t&&M.current){const ae=new DOMParser().parseFromString(B,"text/html").querySelectorAll("img");if(ae.length>0){const fe=Array.from(ae).filter(ee=>{const le=ee.getAttribute("src");return le&&(le.startsWith("data:")||le.startsWith("http://")||le.startsWith("https://"))});if(fe.length>0){I.preventDefault();const ee=fe.map(le=>{const Ne=le.getAttribute("src");if(!Ne)return Promise.resolve(null);const Tt=(Ce,Fo)=>{const Ho=new File([Ce],Fo,{type:Ce.type||"image/png"});return t(Ho).then(et=>(et&&M.current&&M.current.chain().focus().setImage({src:et}).run(),et)).catch(et=>(console.error("Failed to upload pasted image:",et),alert("Failed to upload pasted image. Please try again."),null))};return Ne.startsWith("data:")?fetch(Ne).then(Ce=>Ce.blob()).then(Ce=>Tt(Ce,"pasted-image.png")):Ne.startsWith("http://")||Ne.startsWith("https://")?fetch(Ne).then(Ce=>Ce.blob()).then(Ce=>Tt(Ce,"pasted-image.png")):Promise.resolve(null)});return C(!0),Promise.all(ee).finally(()=>{C(!1)}),!0}}}return!1}},onUpdate:()=>{const A=v.getJSON();if(x){const I=S(x),h=S(A),E=[...I].filter(X=>!h.has(X)),R=L(x),B=L(A),Z=[...R].filter(X=>!B.has(X));E.forEach(X=>{n&&n(X).catch(ae=>{console.error("Failed to delete image:",ae)})}),Z.forEach(X=>{r&&r(X).catch(ae=>{console.error("Failed to delete video:",ae)})})}k(A),i?.({html:v.getHTML(),json:A}),b({})},onSelectionUpdate:()=>{i?.({html:v.getHTML(),json:v.getJSON()}),b({})}});N.useEffect(()=>{v&&(M.current=v,k(v.getJSON()))},[v]),N.useEffect(()=>{if(v&&s!==void 0){const A=v.getJSON();k(A)}},[s,v]),N.useEffect(()=>{v&&v.setEditable(!w)},[v,w]),N.useEffect(()=>{if(!v)return;const A=()=>{if(v.isActive("table")&&!w){const{from:h}=v.state.selection;let E=null;const R=v.view.domAtPos(h);if(R.node&&R.node.parentElement){let B=R.node.parentElement;for(;B&&B!==v.view.dom;){if(B.tagName==="TABLE"){E=B;break}B=B.parentElement}}if(E){const B=E.getBoundingClientRect(),Z=v.view.dom.getBoundingClientRect();D({top:B.bottom-Z.top+10,left:B.left-Z.left,show:!0})}}else D(h=>({...h,show:!1}))},I=()=>{A()};return v.on("selectionUpdate",I),v.on("update",I),()=>{v.off("selectionUpdate",I),v.off("update",I)}},[v]),N.useEffect(()=>{const A=I=>{I.target.closest(".image-input-container")||d(!1)};return c&&document.addEventListener("mousedown",A),()=>{document.removeEventListener("mousedown",A)}},[c]),N.useEffect(()=>{const A=I=>{I.target.closest(".video-input-container")||p(!1)};return m&&document.addEventListener("mousedown",A),()=>{document.removeEventListener("mousedown",A)}},[m]);const U=N.useCallback(async()=>{const A=document.createElement("input");A.type="file",A.accept="image/*",A.onchange=async I=>{const h=I.target.files?.[0];if(h&&t)try{C(!0);const E=await t(h);E&&v?.chain().focus().setImage({src:E}).run()}catch(E){console.error("Failed to upload image:",E),alert("Failed to upload image. Please try again.")}finally{C(!1)}},A.click()},[v,t]),P=N.useCallback(()=>{a.trim()&&(v?.chain().focus().setImage({src:a.trim()}).run(),l(""),d(!1))},[v,a]),J=N.useCallback(()=>{const A=u.trim();A&&(v?.chain().focus().setVideo({src:A,type:ri(A)?"youtube":"video/mp4",title:""}).run(),f(""),p(!1))},[v,u]),G=N.useCallback(async()=>{const A=document.createElement("input");A.type="file",A.accept="video/*",A.onchange=async I=>{const h=I.target.files?.[0];if(h&&p(!1),h&&e)try{T(!0);const E=await e(h);if(E){console.log("Attempting to insert video:",{src:E,type:h.type,title:h.name});try{const R=v?.chain().focus().setVideo({src:E,type:h.type,title:h.name}).run();console.log("Video insertion result:",R)}catch(R){throw console.error("Error inserting video into editor:",R),R}}}catch(E){console.error("Failed to upload video:",E),console.error("Error details:",{message:E instanceof Error?E.message:"Unknown error",stack:E instanceof Error?E.stack:"No stack trace"}),alert(`Failed to upload video: ${E instanceof Error?E.message:"Unknown error"}`)}finally{T(!1)}else if(h&&!e){const E=new FileReader;E.onload=R=>{const B=R.target?.result;console.log("Attempting to insert base64 video:",{src:B.substring(0,100)+"...",type:h.type,title:h.name});try{const Z=v?.chain().focus().setVideo({src:B,type:h.type,title:h.name}).run();console.log("Base64 video insertion result:",Z)}catch(Z){console.error("Error inserting base64 video into editor:",Z)}},E.readAsDataURL(h)}},A.click()},[v,e]),Y=N.useCallback(()=>{if(v)return Po(v)},[v]);return v?o.jsxs("div",{className:"w-full max-w-6xl mx-auto p-4",children:[v&&o.jsx(jo,{editor:v}),o.jsx(Do,{editor:v,isReadOnly:w,setIsReadOnly:g,onLogContent:Y}),o.jsx(di,{editor:v,isReadOnly:w,onImageUpload:U,onVideoUpload:G,isImageUploading:_,isVideoUploading:y,showImageInput:c,setShowImageInput:d,imageUrl:a,setImageUrl:l,handleImageUrlInsert:P,imageUploadFunction:t,showVideoInput:m,setShowVideoInput:p,videoUrl:u,setVideoUrl:f,handleVideoUrlInsert:J,videoUploadFunction:e}),o.jsxs("div",{className:"relative border border-gray-300 border-t-1 rounded-t-lg rounded-b-lg min-h-[400px]",children:[o.jsx(q.EditorContent,{editor:v,className:"tiptap-editor"}),_&&o.jsx("div",{className:"absolute inset-0 bg-white/80 backdrop-blur-sm flex items-center justify-center z-50 rounded-lg",children:o.jsxs("div",{className:"flex flex-col items-center gap-3",children:[o.jsxs("div",{className:"relative",children:[o.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-4 border-gray-200 border-t-blue-600"}),o.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:o.jsx("svg",{className:"w-6 h-6 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})})]}),o.jsx("p",{className:"text-sm font-medium text-gray-700",children:"Uploading image..."})]})}),o.jsx(Ro,{editor:v,isReadOnly:w,onImageClick:()=>d(!c)}),o.jsx(Ao,{editor:v,isReadOnly:w}),o.jsx(Io,{editor:v,isReadOnly:w}),o.jsx(Lo,{editor:v,isReadOnly:w,position:z})]})]}):null},zo=({styles:t,editorContent:e,immediatelyRender:n=!1})=>{const[,r]=N.useState({}),[s]=N.useState(!0),i=q.useEditor({extensions:[cn,Es,en,nn,tn,dn.configure({inline:!1,allowBase64:!0}),un.configure({openOnClick:!1,autolink:!0,defaultProtocol:"https"}),On,Mn,fn,pn.configure({types:["textStyle"]}),hn.configure({multicolor:!0}),An,kn,In,Rn,Ln,jn,Dn,Pn,Bn,Un,Hn,$n,Fn.configure({inline:!1,allowBase64:!0,HTMLAttributes:{class:"max-w-full h-auto rounded-lg shadow-sm"}})],content:e||"<h1>Nothing on Canvas :(</h1>",editable:!s,immediatelyRender:n,editorProps:{attributes:{class:`prose prose-sm sm:prose lg:prose-lg xl:prose-2xl mx-auto focus:outline-none min-h-[400px] p-4 ${t}`}},onUpdate:()=>{r({})},onSelectionUpdate:()=>{r({})}});return N.useEffect(()=>{i&&i.setEditable(!s)},[i,s]),i?o.jsx("div",{className:"w-full max-w-6xl mx-auto p-4",children:o.jsx(q.EditorContent,{editor:i,className:"tiptap-editor"})}):null};function Uo(t){const[e,n]=N.useState(t??{html:"",json:null}),r=N.useCallback(s=>{n(s)},[]);return{content:e,html:e.html,json:e.json,setContent:r}}F.TiptapEditor=Bo,F.TiptapViewer=zo,F.useEditorContent=Uo,Object.defineProperty(F,Symbol.toStringTag,{value:"Module"})}));
|