tiptap-editor-codeveda 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
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,K,ns,_t,en,tn,nn,rs,ss,is,os,as,ls,O,rn,q,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:{}},qe={};/**
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,W,rs,_t,en,tn,nn,ss,is,os,as,ls,cs,O,rn,q,ds,us,fs,ps,hs,ms,gs,bs,se,sn){"use strict";function ws(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=ws(N);var tt={exports:{}},qe={};/**
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 on;function ws(){if(on)return qe;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 qe.Fragment=e,qe.jsx=n,qe.jsxs=n,qe}var Ke={};/**
9
+ */var on;function xs(){if(on)return qe;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 qe.Fragment=e,qe.jsx=n,qe.jsxs=n,qe}var Ke={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,12 +14,12 @@
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 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:
17
+ */var an;function ys(){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 k:return"Profiler";case g:return"StrictMode";case x:return"Suspense";case A: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 U: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,z=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.",z),e(h)}}function r(h){if(h===w)return"<>";if(typeof h=="object"&&h!==null&&h.$$typeof===U)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(){G||(G=!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 K[h]||(K[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,z,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,z,Z,X,ae,fe){var ee=E.children;if(ee!==void 0)if(z)if(P(ee)){for(z=0;z<ee.length;z++)f(ee[z]);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"});z=0<le.length?"{key: someKey, "+le.join(": ..., ")+": ...}":"{key: someKey}",I[ee+z]||(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} />`,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={};Ke.Fragment=w,Ke.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)},Ke.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)}})()),Ke}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(K.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(K.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 qs(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 Ks(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=q.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",qs),be.register("python",Fs),be.register("sql",Ks);const An=ls.extend({marks(){return"codeBlockBg"},addNodeView(){return K.ReactNodeViewRenderer(Ns)}}).configure({lowlight:be}),On=cs,Mn=ds,In=us,Rn=fs;function Ws({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(K.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(K.NodeViewContent,{})})]})}const Ln=q.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",q.mergeAttributes(t,{"data-type":"accordion"}),0]},addNodeView(){return K.ReactNodeViewRenderer(Ws)},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=q.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",q.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 Vs({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(K.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(K.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(K.NodeViewWrapper,{className:"tab-item-content p-4","data-tab-index":n,onKeyDown:s,children:o.jsx(K.NodeViewContent,{})})}const Dn=q.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",q.mergeAttributes(t,{"data-type":"tabs"}),0]},addNodeView(){return K.ReactNodeViewRenderer(Vs,{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=q.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",q.mergeAttributes(t,{"data-type":"tab-item"}),0]},addNodeView(){return K.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(K.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(K.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=q.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",q.mergeAttributes(t)]},addNodeView(){return K.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">
22
+ <%s key={someKey} {...props} />`,z,ee,le,ee),I[ee+z]=!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"),k=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"),A=Symbol.for("react.suspense_list"),M=Symbol.for("react.memo"),U=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,P=Array.isArray,B=console.createTask?console.createTask:function(){return null};m={react_stack_bottom_frame:function(h){return h()}};var G,K={},Y=m.react_stack_bottom_frame.bind(m,i)(),_=B(r(i)),I={};Ke.Fragment=w,Ke.jsx=function(h,E,R,z,Z){var X=1e4>L.recentlyCreatedOwnerStacks++;return u(h,E,R,!1,z,Z,X?Error("react-stack-top-frame"):Y,X?B(r(h)):_)},Ke.jsxs=function(h,E,R,z,Z){var X=1e4>L.recentlyCreatedOwnerStacks++;return u(h,E,R,!0,z,Z,X?Error("react-stack-top-frame"):Y,X?B(r(h)):_)}})()),Ke}var ln;function vs(){return ln||(ln=1,process.env.NODE_ENV==="production"?tt.exports=xs():tt.exports=ys()),tt.exports}var o=vs();const cn=rs.configure({codeBlock:!1}),Es=_t.Table.configure({resizable:!0}),Ns=_t.Table.extend({addNodeView(){return({node:t})=>new _t.TableView(t,this.options.cellMinWidth)}}).configure({resizable:!1}),dn=ss.configure({inline:!1,allowBase64:!1,HTMLAttributes:{class:"max-w-full h-auto rounded-lg shadow-sm"}}),un=is.configure({openOnClick:!1,autolink:!0,defaultProtocol:"https"}),fn=os.TextStyle,pn=as.configure({types:["textStyle"]}),hn=ls.configure({multicolor:!0}),Cs=({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(W.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(W.NodeViewContent,{style:{whiteSpace:"pre",wordBreak:"normal",overflowWrap:"normal"}})})]})},Ss=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_-]*/}}),Ts=["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"],_s=["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"],ks=[...Ts,..._s],As=["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(),Os=["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(),Ms=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),Is=["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 Rs(t){const e=t.regex,n=Ss(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:":("+Os.join("|")+")"},{begin:":(:)?("+Ms.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+Is.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:As.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...l,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+ks.join("|")+")\\b"}]}}const mn="[A-Za-z$_][0-9A-Za-z$_]*",Ls=["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"],js=["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"],Ds=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],Ps=[].concat(wn,gn,bn);function Bs(t){const e=t.regex,n=(_,{after:I})=>{const h="</"+_[0].slice(1);return _.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:(_,I)=>{const h=_[0].length+_.index,E=_.input[h];if(E==="<"||E===","){I.ignoreMatch();return}E===">"&&(n(_,{after:h})||I.ignoreMatch());let R;const z=_.input.substring(h);if(R=z.match(/^\s*=/)){I.ignoreMatch();return}if((R=z.match(/^\s+extends\s+/))&&R.index===0){I.ignoreMatch();return}}},l={$pattern:mn,keyword:Ls,literal:js,built_in:Ps,"variable.language":Ds},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)}]),A={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"}}]},U={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:[A],illegal:/%/},L={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function v(_){return e.concat("(?!",_.join("|"),")")}const P={match:e.concat(/\b/,v([...wn,"super","import"].map(_=>`${_}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},B={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},G={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},A]},K="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",Y={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(K)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[A]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:x,CLASS_REFERENCE:U},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,U,{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:K,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:[A,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},B,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[A]},P,L,M,G,{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 zs(t){const e=t.regex,n=(_,{after:I})=>{const h="</"+_[0].slice(1);return _.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:(_,I)=>{const h=_[0].length+_.index,E=_.input[h];if(E==="<"||E===","){I.ignoreMatch();return}E===">"&&(n(_,{after:h})||I.ignoreMatch());let R;const z=_.input.substring(h);if(R=z.match(/^\s*=/)){I.ignoreMatch();return}if((R=z.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)}]),A={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"}}]},U={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:[A],illegal:/%/},L={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function v(_){return e.concat("(?!",_.join("|"),")")}const P={match:e.concat(/\b/,v([...Nn,"super","import"].map(_=>`${_}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},B={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},G={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},A]},K="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",Y={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(K)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[A]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:x,CLASS_REFERENCE:U},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,U,{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:K,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:[A,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},B,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[A]},P,L,M,G,{match:/\$[(.]/}]}}function Us(t){const e=t.regex,n=zs(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,k)=>{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,k)};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 Fs(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 Hs(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}]},k={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:[k]},{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,k,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 $s(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 qs(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"},k=[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:k.concat([{begin:/\(/,end:/\)/,keywords:g,contains:k.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,k,[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"],k=["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:k},begin:e.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,t.IDENT_RE,e.lookahead(/(<[^<>]+>|)\s*\(/))},A=[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:A.concat([{begin:/\(/,end:/\)/,keywords:T,contains:A.concat(["self"]),relevance:0}]),relevance:0},U={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,U,x,A,[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 Ws(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},k={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(A=>A.replace(/\s+/,"\\s+"))),/\b/)}const y={scope:"keyword",match:C(m),relevance:0};function T(x,{exceptions:A,when:M}={}){const U=M;return A=A||[],x.map(D=>D.match(/\|\d+$/)||A.includes(D)?D:U(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,k,w,r,s,t.C_NUMBER_MODE,t.C_BLOCK_COMMENT_MODE,n,g]}}const kn=q.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",Fs),be.register("css",Rs),be.register("js",Bs),be.register("ts",Us),be.register("java",$s),be.register("c",qs),be.register("cpp",Ks),be.register("python",Hs),be.register("sql",Ws);const An=cs.extend({marks(){return"codeBlockBg"},addNodeView(){return W.ReactNodeViewRenderer(Cs)}}).configure({lowlight:be}),On=ds,Mn=us,In=fs,Rn=ps;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:k}=n.state,{$anchor:C}=k;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((A,M)=>{if(A.type.name==="accordionItem")return x=M,!1}),x!==-1){const A=x+T.nodeSize-2;n.chain().focus().setTextSelection(A).run()}}else{let x=-1;n.state.doc.descendants((A,M)=>{if(A.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(A=>A.type.name==="paragraph"?A.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(A=>A.type.name==="paragraph"?A.content.size>0:!0):!0)){g.preventDefault(),g.stopPropagation();return}}};return o.jsxs(W.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(W.NodeViewContent,{})})]})}const Ln=q.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",q.mergeAttributes(t,{"data-type":"accordion"}),0]},addNodeView(){return W.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=q.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",q.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 Js({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 A=T.doc.nodeAt(y);A&&T.setNodeMarkup(y,void 0,{...A.attrs,title:l})}return!0}).run()}a(null),c("")},g=y=>{y.key==="Enter"?w():y.key==="Escape"&&(a(null),c(""))},k=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 A=x.nodeBefore;if(A&&A.childCount>0){const M=A.lastChild;if(M&&M.content.size>0){let U=-1;if(n.state.doc.descendants((D,S)=>{if(D.type.name==="tabItem"&&D.attrs.tabIndex===A.childCount-1)return U=S,!1}),U!==-1){const D=U+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(W.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,k(T))}:void 0,className:`block w-full text-center ${f?"cursor-text":"cursor-pointer"}`,title:f?"Click to edit title":void 0,children:k(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(W.NodeViewContent,{className:"tab-content-wrapper","data-active-tab":r})})]})}function Gs({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(W.NodeViewWrapper,{className:"tab-item-content p-4","data-tab-index":n,onKeyDown:s,children:o.jsx(W.NodeViewContent,{})})}const Dn=q.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",q.mergeAttributes(t,{"data-type":"tabs"}),0]},addNodeView(){return W.ReactNodeViewRenderer(Js,{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=q.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",q.mergeAttributes(t,{"data-type":"tab-item"}),0]},addNodeView(){return W.ReactNodeViewRenderer(Gs,{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 Ys(...t){return bs.twMerge(gs.clsx(t))}const Zs=ms.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?hs.Slot:"button";return o.jsx(i,{"data-slot":"button",className:Ys(Zs({variant:e,size:n,className:t})),...s})}const Xs=({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})},k=()=>{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)},A=()=>{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 U=S=>{const P=new DOMParser().parseFromString(S,"text/html").querySelector("iframe");if(P){const B=P.getAttribute("src")||"",G={src:B,width:P.getAttribute("width")||"100%",height:P.getAttribute("height")||"500px",title:P.getAttribute("title")||"",allow:P.getAttribute("allow")||"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",sandbox:P.getAttribute("sandbox")||w(B),style:P.getAttribute("style")||""};return b(G),!0}return!1},D=()=>{U(c)?(l("simple"),d("")):alert("Invalid iframe HTML code. Please check your input.")};return s?o.jsx(W.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:k,size:"sm",className:"bg-blue-600 hover:bg-blue-700",children:"Save"}),o.jsx($,{onClick:C,size:"sm",variant:"outline",children:"Cancel"})]})]})}):o.jsx(W.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:{...Qs(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:A,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]})]})})},Qs=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=q.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",q.mergeAttributes(t)]},addNodeView(){return W.ReactNodeViewRenderer(Xs)},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
25
  </div>`,At=`.demo {
@@ -87,6 +87,6 @@ ${t}
87
87
  });
88
88
  })();<\/script>
89
89
  </body>
90
- </html>`}const Qs=[{id:"html",label:"HTML"},{id:"css",label:"CSS"},{id:"js",label:"JS"}],We="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||We}),[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||We}),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||We}),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||We,srcDoc:v,sandbox:"allow-scripts allow-modals",className:"live-preview-iframe",scrolling:J?"no":"auto",onLoad:Y=>{Y.currentTarget.contentWindow?.postMessage({type:"live-preview-request-height"},"*")},style:{width:"100%",height:G,border:"none",borderRadius:0,display:"block"}},P)};return s?o.jsx(K.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:We})]})]})]}):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(K.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=q.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",q.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 K.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 Ve(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 Ve(t)!==null}const si=({node:t})=>{const{src:e,type:n,title:r}=t.attrs;if(!e)return o.jsx(K.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=Ve(e);return s?o.jsx(K.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(K.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=q.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",q.mergeAttributes(this.options.HTMLAttributes,t)];const s=Ve(e);return s?["div",q.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",q.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 K.ReactNodeViewRenderer(si)},addCommands(){return{setVideo:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}}}),oi=()=>({type:"column",content:[{type:"paragraph"}]}),Hn=q.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",q.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=q.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=q.Node.create({name:"column",content:"block+",isolating:!0,defining:!0,parseHTML(){return[{tag:'div[data-type="column"]'}]},renderHTML({HTMLAttributes:t}){return["div",q.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 qn(){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=qn(),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=qn(),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"})]}),Ve(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:Ve(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"})})})})]})},Kn=["top","right","bottom","left"],Wn=["start","end"],Vn=Kn.reduce((t,e)=>t.concat(e,e+"-"+Wn[0],e+"-"+Wn[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=Vn,autoAlignment:p=!0,...b}=Se(t,e),w=f!==void 0||m===Vn?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 Kn.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 qi(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 Ki(t){return Array.from(t.getClientRects())}function Wi(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 Vi(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=Vi(t,n);else if(e==="document")r=Wi(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:qi,getDocumentElement:Te,getClippingRect:Zi,getOffsetParent:hr,getElementRects:eo,getClientRects:Ki,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 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 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 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,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 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 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 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 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(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 H(e,r,s)}}H.empty=new H(W.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 W.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(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 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(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 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&&qt(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&&(qt(e,this.from,this.gapFrom)||qt(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 qt(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(W.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 Kt=Object.create(null);class V{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=Kt[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 Kt)throw new RangeError("Duplicate use of selection JSON ID "+e);return Kt[e]=n,n.prototype.jsonID=e,n}getBookmark(){return de.between(this.$anchor,this.$head).getBookmark()}}V.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 V{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 V.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=V.findFrom(n,r,!0)||V.findFrom(n,-r,!0);if(i)n=i.$head;else return V.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(V.findFrom(e,-r,!0)||V.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new de(e,n)}}V.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 V{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?V.near(i):new ue(i)}content(){return new H(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 Wt(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,V.jsonID("node",ue);class Wt{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new xt(r,r):new Wt(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&ue.isSelectable(r)?new ue(n):V.near(n)}}class ke extends V{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=V.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}}V.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(V.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||V.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 Vt=Object.create(null);function Hr(t){return t in Vt?t+"$"+ ++Vt[t]:(Vt[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 qr(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function Kr(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Wr(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 Vr(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 V{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(qr(r)&&qr(s)&&Kr(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&&(_=Vr(_,0,w)),g>0&&(_=Vr(_,_.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(W.from(d)))}const l=this.isColSelection()&&this.isRowSelection()?e:a;return new H(W.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=V.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new H(W.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,V.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&&Kr(n,r)?new Ee(n,r):V.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,V.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,V.near(n.doc.resolve(i.head+e),e));{const l=n.doc.resolve(a),c=Wr(l,t,e);let d;return c?d=V.near(c,1):e<0?d=V.near(n.doc.resolve(l.before(-1)),-1):d=V.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=Wr(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&&q.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=q.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})});q.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 q.getText(t,{textSerializers:q.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=q.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})});q.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}=K.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}=K.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=K.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||`
90
+ </html>`}const ei=[{id:"html",label:"HTML"},{id:"css",label:"CSS"},{id:"js",label:"JS"}],We="Interactive view",it="auto",ti=t=>{const e=(t||"").trim().toLowerCase();return e===""||e==="auto"||e==="fit"||e==="fit-content"||e==="max"||e==="max-content"},Un=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,k]=N.useState({html:t.attrs.html||"",css:t.attrs.css||"",js:t.attrs.js||"",height:t.attrs.height||it,title:t.attrs.title||We}),[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]),A=()=>{C&&(k({html:t.attrs.html||"",css:t.attrs.css||"",js:t.attrs.js||"",height:t.attrs.height||it,title:t.attrs.title||We}),l("html"),d("code"),i(!0))},M=()=>{C&&(e(g),f(v=>v+1),i(!1))},U=()=>{k({html:t.attrs.html||"",css:t.attrs.css||"",js:t.attrs.js||"",height:t.attrs.height||it,title:t.attrs.title||We}),i(!1)},D=()=>{f(v=>v+1),d("preview")},S=(v,P)=>{k(B=>({...B,[v]:P}))};N.useEffect(()=>{const v=P=>{if(!w.current||P.source!==w.current.contentWindow)return;const B=P.data;B&&B.type==="live-preview-height"&&typeof B.height=="number"&&p(B.height)};return window.addEventListener("message",v),()=>window.removeEventListener("message",v)},[]);const L=(v,P,B)=>{const G=ti(P);let K,Y=!1;if(m!=null)if(G)K=`${m}px`;else{const _=Un(P),I=/^\d+(\.\d+)?px$/.test(_)?parseFloat(_):null;I!=null?K=`${Math.max(I,m)}px`:(K=_,Y=!0)}else K=G?"auto":Un(P),Y=!G;return o.jsx("iframe",{ref:w,title:t.attrs.title||We,srcDoc:v,sandbox:"allow-scripts allow-modals",className:"live-preview-iframe",scrolling:Y?"auto":"no",onLoad:_=>{_.currentTarget.contentWindow?.postMessage({type:"live-preview-request-height"},"*")},style:{width:"100%",height:K,border:"none",borderRadius:0,display:"block"}},B)};return s?o.jsx(W.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:ei.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:We})]})]})]}):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:U,children:"Cancel"})]})]})}):o.jsx(W.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:A,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 Fn=q.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",q.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 W.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 Ve(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 Ve(t)!==null}const si=({node:t})=>{const{src:e,type:n,title:r}=t.attrs;if(!e)return o.jsx(W.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=Ve(e);return s?o.jsx(W.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(W.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",Hn=q.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",q.mergeAttributes(this.options.HTMLAttributes,t)];const s=Ve(e);return s?["div",q.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",q.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 W.ReactNodeViewRenderer(si)},addCommands(){return{setVideo:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}}}),oi=()=>({type:"column",content:[{type:"paragraph"}]}),$n=q.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",q.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=q.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}}}}),qn=q.Node.create({name:"column",content:"block+",isolating:!0,defining:!0,parseHTML(){return[{tag:'div[data-type="column"]'}]},renderHTML({HTMLAttributes:t}){return["div",q.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:k})=>{const[C,y]=N.useState(!1),T=N.useRef(null);return N.useEffect(()=>{const x=A=>{T.current&&!T.current.contains(A.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 A=x.currentTarget;A.style.display="none";const M=A.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"})]}),Ve(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:Ve(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..."})]}):k?"Choose File":"Choose File (Base64)"}),!k&&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"})})})})]})},Wn=["top","right","bottom","left"],Vn=["start","end"],Jn=Wn.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 Gn(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 Gn(ye(t))}function Yn(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 Zn=["left","right"],Xn=["right","left"],mi=["top","bottom"],gi=["bottom","top"];function bi(t,e,n){switch(t){case"top":case"bottom":return n?e?Xn:Zn:e?Zn:Xn;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 Qn(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}=Qn(d,r,c),m=r,p={},b=0;for(let w=0;w<l.length;w++){const{name:g,fn:k}=l[w],{x:C,y,data:T,reset:x}=await k({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}=Qn(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],k=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:(k.top-x.top+b.top)/T.y,bottom:(x.bottom-k.bottom+b.bottom)/T.y,left:(k.left-x.left+b.left)/T.x,right:(x.right-k.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",k=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],A=await(a.getOffsetParent==null?void 0:a.getOffsetParent(d));let M=A?A[y]:0;(!M||!await(a.isElement==null?void 0:a.isElement(A)))&&(M=l.floating[y]||i.floating[b]);const U=T/2-x/2,D=M/2-w[b]/2-1,S=we(f[k],D),L=we(f[C],D),v=S,P=M-w[b]-L,B=M/2-w[b]/2+U,G=Rt(v,B,P),K=!c.arrow&&pe(s)!=null&&B!==G&&i.reference[b]/2-(B<v?S:L)-w[b]/2<0,Y=K?B<v?B-v:B-P:0;return{[p]:m[p]+Y,data:{[p]:G,centerOffset:B-G-Y,...K&&{alignmentOffset:Y}},reset:K}}});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=Jn,autoAlignment:p=!0,...b}=Se(t,e),w=f!==void 0||m===Jn?Ei(f||null,p,m):m,g=await Be(e,b),k=((n=a.autoPlacement)==null?void 0:n.index)||0,C=w[k];if(C==null)return{};const y=Yn(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}],A=w[k+1];if(A)return{data:{index:k+1,overflows:x},reset:{placement:A}};const M=x.map(S=>{const L=pe(S.placement);return[S.placement,L&&u?S.overflows.slice(0,2).reduce((v,P)=>v+P,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:k+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 k=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)),A=b!=="none";!m&&A&&x.push(...wi(l,w,b,T));const M=[l,...x],U=await Be(e,g),D=[];let S=((r=i.flip)==null?void 0:r.overflows)||[];if(u&&D.push(U[k]),f){const B=Yn(s,a,T);D.push(U[B[0]],U[B[1]])}if(S=[...S,{placement:s,overflows:D}],!D.every(B=>B<=0)){var L,v;const B=(((L=i.flip)==null?void 0:L.index)||0)+1,G=M[B];if(G&&(!(f==="alignment"?C!==ye(G):!1)||S.every(_=>ye(_.placement)===C?_.overflows[0]>0:!0)))return{data:{index:B,overflows:S},reset:{placement:G}};let K=(v=S.filter(Y=>Y.overflows[0]<=0).sort((Y,_)=>Y.overflows[1]-_.overflows[1])[0])==null?void 0:v.placement;if(!K)switch(p){case"bestFit":{var P;const Y=(P=S.filter(_=>{if(A){const I=ye(_.placement);return I===C||I==="y"}return!0}).map(_=>[_.placement,_.overflows.filter(I=>I>0).reduce((I,h)=>I+h,0)]).sort((_,I)=>_[1]-I[1])[0])==null?void 0:P[0];Y&&(K=Y);break}case"initialPlacement":K=l;break}if(s!==K)return{reset:{placement:K}}}return{}}}};function er(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function tr(t){return Wn.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=er(i,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:tr(a)}}}case"escaped":{const i=await Be(e,{...s,altBoundary:!0}),a=er(i,n.floating);return{data:{escapedOffsets:a,escaped:tr(a)}}}default:return{}}}}};function nr(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(nr(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(nr(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",P=S.top,B=L.bottom,G=v?S.left:L.left,K=v?S.right:L.right,Y=K-G,_=B-P;return{top:P,bottom:B,left:G,right:K,width:Y,height:_,x:G,y:P}}const g=ce(n)==="left",k=re(...f.map(S=>S.right)),C=we(...f.map(S=>S.left)),y=f.filter(S=>g?S.left===C:S.right===k),T=y[0].top,x=y[y.length-1].bottom,A=C,M=k,U=M-A,D=x-T;return{top:T,bottom:x,left:A,right:M,width:U,height:D,x:A,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:k,y:C}=g;return{x:k,y:C}}},...c}=Se(t,e),d={x:n,y:r},u=await Be(e,c),f=ye(ce(s)),m=Gn(f);let p=d[m],b=d[f];if(i){const g=m==="y"?"top":"left",k=m==="y"?"bottom":"right",C=p+u[g],y=p-u[k];p=Rt(C,p,y)}if(a){const g=f==="y"?"top":"left",k=f==="y"?"bottom":"right",C=b+u[g],y=b-u[k];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,k;f==="top"||f==="bottom"?(g=f,k=m===(await(a.isRTL==null?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(k=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[k],y),A=!e.middlewareData.shift;let M=T,U=x;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(U=y),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(M=C),A&&!m){const S=re(u.left,0),L=re(u.right,0),v=re(u.top,0),P=re(u.bottom,0);p?U=b-2*(S!==0||L!==0?S+L:re(u.left,u.right)):M=w-2*(v!==0||P!==0?v+P:re(u.top,u.bottom))}await c({...e,availableWidth:U,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 rr(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=(rr(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function rr(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 sr(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||sr(t)&&t.host||Te(t);return sr(e)?e.host:e}function ir(t){const e=Me(t);return Ue(e)?t.ownerDocument?t.ownerDocument.body:t.body:ve(e)&&Je(e)?e:ir(e)}function or(t,e,n){var r;e===void 0&&(e=[]);const s=ir(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,or(s,[]))}function zt(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function ar(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 lr(t){return he(t)?t:t.contextElement}function Fe(t){const e=lr(t);if(!ve(e))return xe(1);const n=e.getBoundingClientRect(),{width:r,height:s,$:i}=ar(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 cr(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=lr(t);let a=xe(1);e&&(r?he(r)&&(a=Fe(r)):a=Fe(t));const l=$i(i,n,r)?cr(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),k=w.getBoundingClientRect(),C=me(w),y=k.left+(w.clientLeft+parseFloat(C.paddingLeft))*g.x,T=k.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 dr(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 qi(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?dr(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 Ki(t){return Array.from(t.getClientRects())}function Wi(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 ur=25;function Vi(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<=ur&&(i-=b)}else d<=ur&&(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 fr(t,e,n){let r;if(e==="viewport")r=Vi(t,n);else if(e==="document")r=Wi(Te(t));else if(he(e))r=Gi(e,n);else{const s=cr(t);r={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return Pe(r)}function pr(t,e){const n=Me(t);return n===e||!he(n)||Ue(n)?!1:me(n).position==="fixed"||pr(n,e)}function Yi(t,e){const n=e.get(t);if(n)return n;let r=or(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&&pr(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=fr(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},fr(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}=ar(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?dr(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 hr(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 mr(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=hr(t,e);for(;r&&ji(r)&&Ut(r);)r=hr(r,e);return r&&Ue(r)&&Ut(r)&&!Pt(r)?n:r||Ui(t)||n}const eo=async function(t){const e=this.getOffsetParent||mr,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:qi,getDocumentElement:Te,getClippingRect:Zi,getOffsetParent:mr,getElementRects:eo,getClientRects:Ki,getDimensions:Xi,getScale:Fe,isElement:he,isRTL:to},gr=Oi,br=Ni,wr=Mi,xr=Ci,yr=Ii,vr=Si,Er=vi,Nr=_i,Cr=(t,e,n)=>{const r=new Map,s={platform:no,...n},i={...s.platform,_c:r};return yi(t,e,{...s,platform:i})};function Sr(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=Sr(s.content,i.content,n+1);if(a!=null)return a}n+=s.nodeSize}}function Tr(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=Tr(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 Sr(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Tr(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=kr(this.content,e+this.openStart,n);return r&&new H(r,this.openStart,this.openEnd)}removeBetween(e,n){return new H(_r(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 _r(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(_r(i.content,e-s-1,n-s-1)))}function kr(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=kr(a.content,e-i-1,n,a);return l&&t.replaceChild(s,a.copy(l))}const Ar=65535,Or=Math.pow(2,16);function so(t,e){return t+e*Or}function Mr(t){return t&Ar}function io(t){return(t-(t&Ar))/Or}const Ir=1,Rr=2,bt=4,Lr=8;class jr{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Lr)>0}get deletedBefore(){return(this.delInfo&(Ir|bt))>0}get deletedAfter(){return(this.delInfo&(Rr|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=Mr(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?Rr:e==f?Ir:bt;return(n<0?e!=c:e!=f)&&(w|=Lr),new jr(p,w,b)}s+=u-d}return r?e+s:new jr(e+s,0,null)}touches(e,n){let r=0,s=Mr(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&&qt(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&&(qt(e,this.from,this.gapFrom)||qt(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 qt(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 Kt=Object.create(null);class J{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Dr(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&&zr(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),zr(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=Kt[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 Kt)throw new RangeError("Duplicate use of selection JSON ID "+e);return Kt[e]=n,n.prototype.jsonID=e,n}getBookmark(){return de.between(this.$anchor,this.$head).getBookmark()}}J.prototype.visible=!0;class Dr{constructor(e,n){this.$from=e,this.$to=n}}let Pr=!1;function Br(t){!Pr&&!t.parent.inlineContent&&(Pr=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class de extends J{constructor(e,n=e){Br(e),Br(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 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=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 de(e,n)}}J.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 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 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 Wt(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 Wt{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new xt(r,r):new Wt(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&ue.isSelectable(r)?new ue(n):J.near(n)}}class ke extends J{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=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 ke(e)}map(e){return new ke(e)}eq(e){return e instanceof ke}getBookmark(){return oo}}J.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 zr(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(J.near(t.doc.resolve(a),n))}function Ur(t,e){return!e||!t?t:t.bind(e)}class yt{constructor(e,n,r){this.name=e,this.init=Ur(n.init,r),this.apply=Ur(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||J.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 Fr(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=Fr(s,e,{})),n[r]=s}return n}class Hr{constructor(e){this.spec=e,this.props={},e.props&&Fr(e.props,this,this.props),this.key=e.key?e.key.key:$r("plugin")}getState(e){return e[this.key]}}const Vt=Object.create(null);function $r(t){return t in Vt?t+"$"+ ++Vt[t]:(Vt[t]=0,t+"$")}class Qe{constructor(e="key"){this.key=$r(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:k,colwidth:C}=w.attrs;for(let y=0;y<k;y++){if(y+d>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:u,n:k-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 A=C&&C[x];if(A){const M=(T+x)%e*2,U=a[M];U==null||U!=A&&a[M+1]==1?(a[M]=A,a[M+1]=1):U==A&&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 qr(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 Wr(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 Jr(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 J{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 Dr(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)&&Wr(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 k=b.attrs;if(w>0&&(k=Jr(k,0,w)),g>0&&(k=Jr(k,k.colspan-g,g)),p.left<s.left){if(b=b.type.createAndFill(k),!b)throw RangeError(`Could not create cell with attrs ${JSON.stringify(k)}`)}else b=b.type.create(k,b.content)}if(p.top<s.top||p.bottom>s.bottom){const k={...b.attrs,rowspan:Math.min(p.bottom,s.bottom)-Math.max(p.top,s.top)};p.top<s.top?b=b.type.createAndFill(k):b=b.type.create(k,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=J.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,J.jsonID("cell",Ee);var No=class ns{constructor(e,n){this.anchor=e,this.head=n}map(e){return new ns(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&&Wr(n,r)?new Ee(n,r):J.near(r,1)}};new Qe("fix-tables");function Gr(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(!qr(e))return!1;if(n){const r=Xt(e.schema),s=Gr(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 Yr(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(!qr(n))return!1;if(r){const s=Xt(n.schema),i=Gr(n),a=n.tr,l=Yr("row",i,s),c=Yr("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,J.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const a=Zr(s,t,e);if(a==null)return!1;if(t=="horiz")return Nt(n,r,J.near(n.doc.resolve(i.head+e),e));{const l=n.doc.resolve(a),c=Vr(l,t,e);let d;return c?d=J.near(c,1):e<0?d=J.near(n.doc.resolve(l.before(-1)),-1):d=J.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=Zr(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 Zr(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&&q.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(xr(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(wr(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(gr(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(Er(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(yr(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(br(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(vr(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(Nr(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),t}updatePosition(){const{selection:t}=this.editor.state,e=q.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]}}Cr(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()}},Xr=t=>new Hr({key:typeof t.pluginKey=="string"?new Qe(t.pluginKey):t.pluginKey,view:e=>new To({view:e,...t})});q.Extension.create({name:"bubbleMenu",addOptions(){return{element:null,pluginKey:"bubbleMenu",updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[Xr({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 q.getText(t,{textSerializers:q.getTextSerializersFromSchema(this.editor.schema)})}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(xr(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(wr(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(gr(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(Er(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(yr(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(br(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(vr(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(Nr(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=q.posToDOMRect(this.view,t.from,t.to);Cr({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()}},Qr=t=>new Hr({key:typeof t.pluginKey=="string"?new Qe(t.pluginKey):t.pluginKey,view:e=>new _o({view:e,...t})});q.Extension.create({name:"floatingMenu",addOptions(){return{element:null,options:{},pluginKey:"floatingMenu",shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[Qr({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,options:this.options.options,shouldShow:this.options.shouldShow})]:[]}});var es=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}=W.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=Xr({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}=W.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=Qr({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(es,{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))}),ts=[{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(es,{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:ts.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:ts.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),[k,C]=N.useState(!1),[y,T]=N.useState(!1),[x,A]=N.useState(null),M=N.useRef(null),[U,D]=N.useState({top:0,left:0,show:!1}),S=_=>{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(_),I},L=_=>{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(_),I},v=W.useEditor({extensions:[cn,Es,en,nn,tn,dn,un,On,Mn,fn,pn,hn,An,kn,In,Rn,Ln,jn,Dn,Pn,Bn,Fn,$n,qn,Hn.configure({inline:!1,allowBase64:!0,HTMLAttributes:{class:"max-w-full h-auto rounded-lg shadow-sm"}})],content:s||`
91
91
  <p>Hello World. Create your own content here.</p>
92
- `,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(K.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=K.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(K.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"})}));
92
+ `,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:(_,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 z=I.clipboardData?.getData("text/html");if(z&&t&&M.current){const ae=new DOMParser().parseFromString(z,"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 _=v.getJSON();if(x){const I=S(x),h=S(_),E=[...I].filter(X=>!h.has(X)),R=L(x),z=L(_),Z=[...R].filter(X=>!z.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)})})}A(_),i?.({html:v.getHTML(),json:_}),b({})},onSelectionUpdate:()=>{i?.({html:v.getHTML(),json:v.getJSON()}),b({})}});N.useEffect(()=>{v&&(M.current=v,A(v.getJSON()))},[v]),N.useEffect(()=>{if(v&&s!==void 0){const _=v.getJSON();A(_)}},[s,v]),N.useEffect(()=>{v&&v.setEditable(!w)},[v,w]),N.useEffect(()=>{if(!v)return;const _=()=>{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 z=R.node.parentElement;for(;z&&z!==v.view.dom;){if(z.tagName==="TABLE"){E=z;break}z=z.parentElement}}if(E){const z=E.getBoundingClientRect(),Z=v.view.dom.getBoundingClientRect();D({top:z.bottom-Z.top+10,left:z.left-Z.left,show:!0})}}else D(h=>({...h,show:!1}))},I=()=>{_()};return v.on("selectionUpdate",I),v.on("update",I),()=>{v.off("selectionUpdate",I),v.off("update",I)}},[v]),N.useEffect(()=>{const _=I=>{I.target.closest(".image-input-container")||d(!1)};return c&&document.addEventListener("mousedown",_),()=>{document.removeEventListener("mousedown",_)}},[c]),N.useEffect(()=>{const _=I=>{I.target.closest(".video-input-container")||p(!1)};return m&&document.addEventListener("mousedown",_),()=>{document.removeEventListener("mousedown",_)}},[m]);const P=N.useCallback(async()=>{const _=document.createElement("input");_.type="file",_.accept="image/*",_.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)}},_.click()},[v,t]),B=N.useCallback(()=>{a.trim()&&(v?.chain().focus().setImage({src:a.trim()}).run(),l(""),d(!1))},[v,a]),G=N.useCallback(()=>{const _=u.trim();_&&(v?.chain().focus().setVideo({src:_,type:ri(_)?"youtube":"video/mp4",title:""}).run(),f(""),p(!1))},[v,u]),K=N.useCallback(async()=>{const _=document.createElement("input");_.type="file",_.accept="video/*",_.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 z=R.target?.result;console.log("Attempting to insert base64 video:",{src:z.substring(0,100)+"...",type:h.type,title:h.name});try{const Z=v?.chain().focus().setVideo({src:z,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)}},_.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:P,onVideoUpload:K,isImageUploading:k,isVideoUploading:y,showImageInput:c,setShowImageInput:d,imageUrl:a,setImageUrl:l,handleImageUrlInsert:B,imageUploadFunction:t,showVideoInput:m,setShowVideoInput:p,videoUrl:u,setVideoUrl:f,handleVideoUrlInsert:G,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(W.EditorContent,{editor:v,className:"tiptap-editor"}),k&&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:U})]})]}):null},zo=({styles:t,editorContent:e,immediatelyRender:n=!1})=>{const[,r]=N.useState({}),[s]=N.useState(!0),i=W.useEditor({extensions:[cn,Ns,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,Fn,$n,qn,Hn.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(W.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"})}));