From a047d4284f8088d98a02accdc3dcb67ad7dce2be Mon Sep 17 00:00:00 2001 From: Jakub Zych Date: Sat, 28 Nov 2026 13:13:09 +0100 Subject: [PATCH] fix(embeds): address Phase 38 review findings across registry, Blog Editor, and docs --- README.md | 4 +-- assets/dist/blogeditor.js | 50 ++++++++++++++++---------------- assets/src/blogeditor/element.ts | 4 +-- assets/src/blogeditor/embed.ts | 9 ++++-- assets/src/blogeditor/labels.ts | 6 ++++ assets/src/blogeditor/preview.ts | 5 ++-- classes/embed_registry.go | 11 +++++-- classes/embed_registry_test.go | 2 ++ tests/blogeditor/embed.test.ts | 15 +++++++++- 9 files changed, 69 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index f8ef888..c9d9df0 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ WinterCMS theme components such as `journalPost` and `journalPosts` are a later ## Features -- **Posts.** `models.Post` maps `golem15_journal_posts`. Translatable fields are title, content, content_html, excerpt, metadata, and slug (indexed). Fillable does not include `redactor_id`, `content_html`, or `user_id`. Attachments `featured_images` and `content_images` use `system_files` under the same MorphName. YAML admin uses `mltext`, `mltextarea` and the plugin's own `mlblogeditor` field type for content (see [Admin: Blog Editor field types](#admin-blog-editor-field-types)); an admin save stores the sanitized HTML in both `content` and `content_html`. `classes.FormatHTML` regenerates `content_html` on the other write paths (`journal:import-posts`, Journal API writes). It renders markdown and passes raw HTML in `content` through the renderer (Winter parity), then sanitizes the result with a `bluemonday` allow-list: bluemonday's UGC policy plus `footer`, `class`, schema.org microdata, the `color`, `font-size`, `font-weight` and `text-align` styles, goldmark's footnote roles, `dir="auto"`, two pasted-transcript `data-message-*` attributes, and exactly five rules for the Blog Editor's own output (Phase 16.2, Phase 33): `data-embed` matching `^youtube$` and `data-id` matching `^[A-Za-z0-9_-]{11}$` on `figure` (the embed placeholder), `alt` with any text on `img`, `start` matching `^[0-9]+$` on `ol`, and `rel` on `a` holding only the tokens `nofollow`, `sponsored` and `ugc` (`^(nofollow|sponsored|ugc)( (nofollow|sponsored|ugc))*$`; any other `rel` value is removed). No iframe, other data attribute, style property or URL scheme is allowed for the editor; `TestEditorOutputPassesPolicy` checks every entry of the editor corpus against the policy. Like Winter's `Html::clean`, it strips what the policy does not allow instead of refusing the save: script, style, iframe, object, embed, form, base and meta elements, comments, event handler attributes, and URLs other than http, https, mailto and relative ones. HTML the policy keeps whole is stored byte for byte, so imported bodies survive a save. Admin saves strip the same way and name what they removed (`classes.SanitizeHTMLReport`). A tag that repeats an attribute is never kept whole: the sanitized output, which keeps the first value, is stored. On the API and import paths `content` itself is stored as submitted. Translated `content_html` goes through the same policy on the API and `journal:import-posts` write paths (`classes.FormatTranslation`): when the translation carries a non-blank `content`, `content_html` is rendered from it and a supplied `content_html` is replaced, as the host column is always derived; a translation with only `content_html` is sanitized with `classes.SanitizeHTML`. Winter stored a supplied translated `content_html` verbatim. The API response shapes and status codes are unchanged. +- **Posts.** `models.Post` maps `golem15_journal_posts`. Translatable fields are title, content, content_html, excerpt, metadata, and slug (indexed). Fillable does not include `redactor_id`, `content_html`, or `user_id`. Attachments `featured_images` and `content_images` use `system_files` under the same MorphName. YAML admin uses `mltext`, `mltextarea` and the plugin's own `mlblogeditor` field type for content (see [Admin: Blog Editor field types](#admin-blog-editor-field-types)); an admin save stores the sanitized HTML in both `content` and `content_html`. `classes.FormatHTML` regenerates `content_html` on the other write paths (`journal:import-posts`, Journal API writes). It renders markdown and passes raw HTML in `content` through the renderer (Winter parity), then sanitizes the result with a `bluemonday` allow-list: bluemonday's UGC policy plus `footer`, `class`, schema.org microdata, the `color`, `font-size`, `font-weight` and `text-align` styles, goldmark's footnote roles, `dir="auto"`, two pasted-transcript `data-message-*` attributes, and rules for the Blog Editor's own output (Phase 16.2, Phase 33, Phase 38): pair-aware `data-embed` and `data-id` on `figure` against the app's `classes.EmbedRegistry` (`youtube` matching `^[A-Za-z0-9_-]{11}$` by default, plus app-registered providers) alongside validated `data-aspect` and `data-height` CLS hints, `alt` with any text on `img`, `start` matching `^[0-9]+$` on `ol`, and `rel` on `a` holding only the tokens `nofollow`, `sponsored` and `ugc` (`^(nofollow|sponsored|ugc)( (nofollow|sponsored|ugc))*$`; any other `rel` value is removed). No iframe, other data attribute, style property or URL scheme is allowed for the editor; `TestEditorOutputPassesPolicy` checks every entry of the editor corpus against the policy. Like Winter's `Html::clean`, it strips what the policy does not allow instead of refusing the save: script, style, iframe, object, embed, form, base and meta elements, comments, event handler attributes, and URLs other than http, https, mailto and relative ones. HTML the policy keeps whole is stored byte for byte, so imported bodies survive a save. Admin saves strip the same way and name what they removed (`classes.SanitizeHTMLReport`). A tag that repeats an attribute is never kept whole: the sanitized output, which keeps the first value, is stored. On the API and import paths `content` itself is stored as submitted. Translated `content_html` goes through the same policy on the API and `journal:import-posts` write paths (`classes.FormatTranslation`): when the translation carries a non-blank `content`, `content_html` is rendered from it and a supplied `content_html` is replaced, as the host column is always derived; a translation with only `content_html` is sanitized with `classes.SanitizeHTML`. Winter stored a supplied translated `content_html` verbatim. The API response shapes and status codes are unchanged. - **Categories and tags.** `models.Category` is translatable (name, description, slug). It also stores `content`, an HTML host column that is not translatable, edited in the admin with the `blogeditor` field type. Fillable is name, slug, code, description, content and parent_id; nest_* columns exist in DDL and are not fillable. `models.Tag` is not translatable. Fillable is name, slug, description. Pivots are `golem15_journal_posts_categories` and `golem15_journal_posts_tags`. - **Menu and sitemap item types.** The plugin registers its five PHP menu item types (`journal-category`, `all-journal-categories`, `journal-post`, `all-journal-posts`, `category-journal-posts`), `journal-tag` and `journal-author` with the framework's menu item type registry, so menus and sitemaps can point at posts, categories, tags and author pages. Posts, categories, tags and authors carry content descriptors, so plugins that work on every content type (sitemaps, SEO, search) describe, page and match Journal records without the Journal importing them. See [menu item types](#menu-item-types) and [content descriptors](#content-descriptors). - **Settings.** Singleton row ID=1 on `golem15_journal_settings`, not PHP `system_settings`. `search_use_typesense` defaults to false. A fresh save never contacts Typesense. The Headings and links tab holds the H1 setting `content_h1_to_h2` (on by default) and the generic link texts `generic_anchors`; see [headings and links](#headings-and-links). @@ -474,7 +474,7 @@ if reg := classes.EmbedRegistryFrom(app); reg != nil { | `journal.Plugin` | Compiled plugin; `ID` is `golem15.journal`. | | `journal.Plugin.Requires` | Returns `golem15.translate` only. | | `journal.Plugin.LangFS` | Embedded English and Polish UI phrasebooks. | -| `journal.Plugin.ConfigFS` | Ships `config/config.yaml` (`golem15.journal.content_h1_to_h2`, `golem15.journal.related_mode`, `golem15.journal.related_count`, `golem15.journal.image_widths`). | +| `journal.Plugin.ConfigFS` | Ships `config/config.yaml` (`golem15.journal.content_h1_to_h2`, `golem15.journal.related_mode`, `golem15.journal.related_count`, `golem15.journal.image_widths`, `golem15.journal.embed_providers`). | | `journal.Plugin.Migrations` | gormigrate steps registered by this plugin. | | `journal.Plugin.Models` | Models registered by this plugin. | | `journal.Plugin.Commands` | Registers `journal:export-posts`, `journal:import-posts`, `journal:reindex`, `journal:fix-headings` and `journal:image-variants`. | diff --git a/assets/dist/blogeditor.js b/assets/dist/blogeditor.js index 03de87e..4d29331 100644 --- a/assets/dist/blogeditor.js +++ b/assets/dist/blogeditor.js @@ -95,26 +95,26 @@ img.ProseMirror-separator { display: block; }`;var lb=class extends ky{constructor(n={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.hasWarnedStaleDecorationRead=!1,this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:t})=>{throw t},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:Kg,createMappablePosition:qg},this.setOptions(n),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:t,slice:r,moved:i})=>this.options.onDrop(t,r,i)),this.on("paste",({event:t,slice:r})=>this.options.onPaste(t,r)),this.on("delete",this.options.onDelete);const e=this.createDoc();if(!this.editorState){const t=Ns(e,this.options.autofocus);this.editorState=Ue.create({doc:e,schema:this.schema,selection:t||void 0})}ib(this.schema),this.options.element&&this.mount(this.options.element)}mount(n){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(n),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){this.editorState=this.editorView.state;const n=this.editorView.dom;n?.editor&&delete n.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(n){console.warn("Failed to remove CSS element:",n)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager?this.commandManager.chain():Xt.createFakeChain()}can(){return this.commandManager?this.commandManager.can():Xt.createFallbackCan()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=Iy(ob,this.options.injectNonce))}setOptions(n={}){this.options={...this.options,...n},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps({...this.options.editorProps,attributes:this.getEditorViewAttributes()}),this.view.updateState(this.state))}setEditable(n,e=!0){this.setOptions({editable:n}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:n=>{this.editorState=n},dispatch:n=>{this.dispatchTransaction(n)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(n,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in n)return Reflect.get(n,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(n,e){const t=Rs(e)?e(n,[...this.state.plugins]):[...this.state.plugins,n],r=this.state.reconfigure({plugins:t});return this.view.updateState(r),r}unregisterPlugin(n){if(this.isDestroyed)return;const e=this.state.plugins;let t=e;if([].concat(n).forEach(i=>{const s=typeof i=="string"?`${i}$`:i.key;t=t.filter(o=>!o.key.startsWith(s))}),e.length===t.length)return;const r=this.state.reconfigure({plugins:t});return this.view.updateState(r),r}createExtensionManager(){var n,e;const t=[...this.options.enableCoreExtensions?[Xy,qy.configure({blockSeparator:(n=this.options.coreExtensionOptions)===null||n===void 0||(n=n.clipboardTextSerializer)===null||n===void 0?void 0:n.blockSeparator}),Jy,Zy,eb,nb.configure({value:(e=this.options.coreExtensionOptions)===null||e===void 0||(e=e.tabindex)===null||e===void 0?void 0:e.value}),Yy,tb,Gy,rb.configure({direction:this.options.textDirection})].filter(r=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[r.name]!==!1:!0):[],...this.options.extensions].filter(r=>["extension","node","mark"].includes(r?.type));this.extensionManager=new Oi(t,this)}createCommandManager(){this.commandManager=new Xt({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let n;try{n=Os(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;const t=Os(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1});return this.editorState=Ue.create({doc:t,schema:this.schema,selection:Ns(t,this.options.autofocus)||void 0}),this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(r=>r.name!=="collaboration"),this.createExtensionManager()}}),this.editorState.doc}return n}getEditorViewAttributes(){var n;const e=(n=this.options.editorProps)===null||n===void 0?void 0:n.attributes;return Rs(e)?t=>({role:"textbox",...e(t)}):{role:"textbox",...e}}createView(n){const{editorProps:e,enableExtensionDispatchTransaction:t}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),i=t?this.extensionManager.dispatchTransaction(r):r,s=e.transformPastedHTML,o=this.extensionManager.transformPastedHTML(s);this.editorView=new Ad(n,{...e,attributes:this.getEditorViewAttributes(),dispatchTransaction:i,transformPastedHTML:o,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const l=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(l),this.prependClass(),this.injectCSS();const a=this.view.dom;a.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(n){this.isCapturingTransaction=!0,n(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(n){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=n;return}n.steps.forEach(c=>{var d;return(d=this.capturedTransaction)===null||d===void 0?void 0:d.step(c)});return}const{state:e,transactions:t}=this.state.applyTransaction(n),r=!this.state.selection.eq(e.selection),i=t.includes(n),s=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:n,nextState:e}),!i)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:n,appendedTransactions:t.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:n});const o=t.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),l=o?.getMeta("focus"),a=o?.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:o}),a&&this.emit("blur",{editor:this,event:a.event,transaction:o}),!(n.getMeta("preventUpdate")||!t.some(c=>c.docChanged)||s.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:n,appendedTransactions:t.slice(1)})}getAttributes(n){return Gd(this.state,n)}isActive(n,e){const t=typeof n=="string"?n:null,r=typeof n=="string"?e:n;return Wg(this.state,t,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return So(this.state.doc.content,this.schema)}getText(n){const{blockSeparator:e=` -`,textSerializers:t={}}=n||{};return zg(this.state.doc,{blockSeparator:e,textSerializers:{...Jd(this.schema),...t}})}get isEmpty(){return Zn(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit("destroy"),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){var n,e;return(n=(e=this.editorView)===null||e===void 0?void 0:e.isDestroyed)!==null&&n!==void 0?n:!0}$node(n,e){var t;return((t=this.$doc)===null||t===void 0?void 0:t.querySelector(n,e))||null}$nodes(n,e){var t;return((t=this.$doc)===null||t===void 0?void 0:t.querySelectorAll(n,e))||null}$pos(n){const e=this.state.doc.resolve(n),t=n>0&&e.nodeAfter&&!e.nodeAfter.isText&&e.nodeAfter.isAtom?e.nodeAfter:null;return new sb(e,this,!1,t)}get $doc(){return this.$pos(0)}};function $t(n){return new er({find:n.find,handler:({state:e,range:t,match:r})=>{const i=$(n.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:s}=e,o=r[r.length-1],l=r[0];if(o){const a=l.search(/\S/),c=t.from+l.indexOf(o),d=c+o.length;if(Ni(t.from,t.to,e.doc).filter(f=>f.mark.type.excluded.find(h=>h===n.type&&h!==f.mark.type)).filter(f=>f.to>c).length)return null;dt.from&&s.delete(t.from+a,c);const u=t.from+a+o.length;s.addMark(t.from+a,u,n.type.create(i||{})),s.removeStoredMark(n.type)}},undoable:n.undoable})}function cu(n){return new er({find:n.find,handler:({state:e,range:t,match:r})=>{const i=$(n.getAttributes,void 0,r)||{},{tr:s}=e,o=t.from;let l=t.to;const a=n.type.create(i);if(r[1]){let c=o+r[0].lastIndexOf(r[1]);c>l?c=l:l=c+r[1].length;const d=r[0][r[0].length-1];s.insertText(d,o+r[0].length-1),s.replaceWith(c,l,a)}else if(r[0]){const c=n.type.isInline?o:o-1;s.insert(c,n.type.create(i)).delete(s.mapping.map(o),s.mapping.map(l))}s.scrollIntoView()},undoable:n.undoable})}function Is(n){return new er({find:n.find,handler:({state:e,range:t,match:r})=>{const i=e.doc.resolve(t.from),s=$(n.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,s)},undoable:n.undoable})}function ln(n){return new er({find:n.find,handler:({state:e,range:t,match:r,chain:i})=>{const s=$(n.getAttributes,void 0,r)||{},o=e.tr.delete(t.from,t.to),l=o.doc.resolve(t.from).blockRange(),a=l&&eo(l,n.type,s);if(!a)return null;if(o.wrap(l,a),n.keepMarks&&n.editor){const{selection:d,storedMarks:u}=e,{splittableMarks:f}=n.editor.extensionManager,h=u||d.$to.parentOffset&&d.$from.marks();if(h){const p=h.filter(m=>f.includes(m.type.name));o.ensureMarks(p)}}if(n.keepAttributes){const d=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(d,s).run()}const c=o.doc.resolve(t.from-1).nodeBefore;c&&c.type===n.type&>(o.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,c))&&o.join(t.from-1)},undoable:n.undoable})}const ab=n=>"touches"in n;var du=class{constructor(n){var e,t,r,i,s,o;this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=l=>{if(!this.isResizing||!this.activeHandle)return;const a=l.clientX-this.startX,c=l.clientY-this.startY;this.handleResize(a,c)},this.handleTouchMove=l=>{if(!this.isResizing||!this.activeHandle)return;const a=l.touches[0];if(!a)return;const c=a.clientX-this.startX,d=a.clientY-this.startY;this.handleResize(c,d)},this.handleMouseUp=()=>{if(!this.isResizing)return;const l=this.element.offsetWidth,a=this.element.offsetHeight;this.onCommit(l,a),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!1)},this.node=n.node,this.editor=n.editor,this.element=n.element,this.element.draggable=!1,this.contentElement=n.contentElement,this.getPos=n.getPos,this.onResize=n.onResize,this.onCommit=n.onCommit,this.onUpdate=n.onUpdate,!((e=n.options)===null||e===void 0)&&e.min&&(this.minSize={...this.minSize,...n.options.min}),!((t=n.options)===null||t===void 0)&&t.max&&(this.maxSize=n.options.max),!(n==null||(r=n.options)===null||r===void 0)&&r.directions&&(this.directions=n.options.directions),!((i=n.options)===null||i===void 0)&&i.preserveAspectRatio&&(this.preserveAspectRatio=n.options.preserveAspectRatio),!((s=n.options)===null||s===void 0)&&s.className&&(this.classNames={container:n.options.className.container||"",wrapper:n.options.className.wrapper||"",handle:n.options.className.handle||"",resizing:n.options.className.resizing||""}),!((o=n.options)===null||o===void 0)&&o.createCustomHandle&&(this.createCustomHandle=n.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var n;return(n=this.contentElement)!==null&&n!==void 0?n:null}handleEditorUpdate(){const n=this.editor.isEditable;n!==this.lastEditableState&&(this.lastEditableState=n,n?n&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(n,e,t){return n.type!==this.node.type?!1:(this.node=n,this.onUpdate?this.onUpdate(n,e,t):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){const n=document.createElement("div");return n.dataset.resizeContainer="",n.dataset.node=this.node.type.name,n.style.display=this.node.type.isInline?"inline-flex":"flex",this.classNames.container&&(n.className=this.classNames.container),n.appendChild(this.wrapper),n}createWrapper(){const n=document.createElement("div");return n.style.position="relative",n.style.display="block",n.dataset.resizeWrapper="",this.classNames.wrapper&&(n.className=this.classNames.wrapper),n.appendChild(this.element),n}createHandle(n){const e=document.createElement("div");return e.dataset.resizeHandle=n,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(n,e){const t=e.includes("top"),r=e.includes("bottom"),i=e.includes("left"),s=e.includes("right");t&&(n.style.top="0"),r&&(n.style.bottom="0"),i&&(n.style.left="0"),s&&(n.style.right="0"),(e==="top"||e==="bottom")&&(n.style.left="0",n.style.right="0"),(e==="left"||e==="right")&&(n.style.top="0",n.style.bottom="0")}attachHandles(){this.directions.forEach(n=>{let e;this.createCustomHandle?e=this.createCustomHandle(n):e=this.createHandle(n),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${n}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(n)),this.createCustomHandle||this.positionHandle(e,n),e.addEventListener("mousedown",t=>this.handleResizeStart(t,n)),e.addEventListener("touchstart",t=>this.handleResizeStart(t,n)),this.handleMap.set(n,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(n=>n.remove()),this.handleMap.clear()}applyInitialSize(){const n=this.node.attrs.width,e=this.node.attrs.height;n?(this.element.style.width=`${n}px`,this.initialWidth=n):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(n,e){n.preventDefault(),n.stopPropagation(),this.isResizing=!0,this.activeHandle=e,ab(n)?(this.startX=n.touches[0].clientX,this.startY=n.touches[0].clientY):(this.startX=n.clientX,this.startY=n.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(n,e){if(!this.activeHandle)return;const t=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:i}=this.calculateNewDimensions(this.activeHandle,n,e),s=this.applyConstraints(r,i,t);this.element.style.width=`${s.width}px`,this.element.style.height=`${s.height}px`,this.onResize&&this.onResize(s.width,s.height)}calculateNewDimensions(n,e,t){let r=this.startWidth,i=this.startHeight;const s=n.includes("right"),o=n.includes("left"),l=n.includes("bottom"),a=n.includes("top");return s?r=this.startWidth+e:o&&(r=this.startWidth-e),l?i=this.startHeight+t:a&&(i=this.startHeight-t),(n==="right"||n==="left")&&(r=this.startWidth+(s?e:-e)),(n==="top"||n==="bottom")&&(i=this.startHeight+(l?t:-t)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,n):{width:r,height:i}}applyConstraints(n,e,t){var r,i;if(!t){var s,o;let c=Math.max(this.minSize.width,n),d=Math.max(this.minSize.height,e);return!((s=this.maxSize)===null||s===void 0)&&s.width&&(c=Math.min(this.maxSize.width,c)),!((o=this.maxSize)===null||o===void 0)&&o.height&&(d=Math.min(this.maxSize.height,d)),{width:c,height:d}}let l=n,a=e;return lthis.maxSize.width&&(l=this.maxSize.width,a=l/this.aspectRatio),!((i=this.maxSize)===null||i===void 0)&&i.height&&a>this.maxSize.height&&(a=this.maxSize.height,l=a*this.aspectRatio),{width:l,height:a}}applyAspectRatio(n,e,t){const r=t==="left"||t==="right",i=t==="top"||t==="bottom";return r?{width:n,height:n/this.aspectRatio}:i?{width:e*this.aspectRatio,height:e}:{width:n,height:n/this.aspectRatio}}},U=class uu extends xo{constructor(...e){super(...e),this.type="node"}static create(e={}){const t=typeof e=="function"?e():e;return new uu(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}};function pt(n){return new lu({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:i})=>{const s=$(n.getAttributes,void 0,r,i);if(s===!1||s===null)return null;const{tr:o}=e,l=r[r.length-1],a=r[0];let c=t.to;if(l){const d=a.search(/\S/),u=t.from+a.indexOf(l),f=u+l.length;if(Ni(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(p=>p===n.type&&p!==h.mark.type)).filter(h=>h.to>u).length)return null;ft.from&&o.delete(t.from+d,u),c=t.from+d+l.length,o.addMark(t.from+d,c,n.type.create(s||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||o.removeStoredMark(n.type)}}})}const cb=new Set(["youtube.com","www.youtube.com","m.youtube.com","music.youtube.com","youtube-nocookie.com","www.youtube-nocookie.com"]),db=/^[a-z][a-z0-9_-]{0,31}$/,ub=/^[1-9][0-9]{0,3}(?:\s*\/\s*[1-9][0-9]{0,3}|\.[0-9]{1,4})?$/,fb=/^[1-9][0-9]{0,3}(?:px)?$/,En={youtube:{name:"YouTube",idPattern:/^[A-Za-z0-9_-]{11}$/,idFromUrl(n){const e=n.hostname.toLowerCase();if(e==="youtu.be")return n.pathname.split("/")[1]??null;if(!cb.has(e))return null;if(n.pathname==="/watch")return n.searchParams.get("v");const t=/^\/(?:shorts|embed)\/([^/]+)\/?$/.exec(n.pathname);return t?t[1]:null}}},an=[{key:"youtube",name:En.youtube.name,idPattern:En.youtube.idPattern,mode:"url",idFromUrl:En.youtube.idFromUrl}];function hb(n){return Object.prototype.hasOwnProperty.call(En,n)}function pb(n){if(!Array.isArray(n))return[...an];const e=new Set,t=[];for(const r of n){if(!r||typeof r!="object"||Array.isArray(r))continue;const i=r,s=typeof i.key=="string"?i.key.trim():"";if(!db.test(s)||e.has(s))continue;const o=typeof i.idPattern=="string"?i.idPattern.trim():"";if(!o)continue;let l;try{new RegExp(o),l=new RegExp(`^(?:${o})$`)}catch{continue}const a=typeof i.name=="string"&&i.name.trim()!==""?i.name.trim():s,c=typeof i.mode=="string"?i.mode.trim():"",d=c==="url"||c==="id"?c:s==="youtube"?"url":"id",u=typeof i.placeholder=="string"&&i.placeholder.trim()!==""?i.placeholder.trim():void 0,f={key:s,name:a,idPattern:l,mode:d,...u?{placeholder:u}:{},...s==="youtube"?{idFromUrl:En.youtube.idFromUrl}:{}};e.add(s),t.push(f)}return t.length>0?t:[...an]}function Qt(n,e){return n.find(t=>t.key===e)}function fu(n,e,t){const r=Qt(n,e);return!!(r&&t!==""&&r.idPattern.test(t))}const Co=fu;function $r(n){return ub.test(n.trim())}function Br(n){return fb.test(n.trim())}function hu(n,e){let t;try{t=new URL(e.trim())}catch{return null}if(t.protocol!=="https:"&&t.protocol!=="http:")return null;for(const r of n){if(!r.idFromUrl)continue;const i=r.idFromUrl(t);if(i&&r.idPattern.test(i))return{provider:r.key,id:i}}return null}function mb(n){const e=hu(an,n);return!e||!hb(e.provider)?null:{provider:e.provider,id:e.id}}const gb=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,yb=U.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:n}){return["img",F(this.options.HTMLAttributes,n)]},parseMarkdown:(n,e)=>e.createNode("image",{src:n.href,title:n.title,alt:n.text}),renderMarkdown:n=>{var e,t,r,i,s,o;const l=(e=(t=n.attrs)===null||t===void 0?void 0:t.src)!==null&&e!==void 0?e:"",a=(r=(i=n.attrs)===null||i===void 0?void 0:i.alt)!==null&&r!==void 0?r:"",c=(s=(o=n.attrs)===null||o===void 0?void 0:o.title)!==null&&s!==void 0?s:"";return c?`![${a}](${l} "${c}")`:`![${a}](${l})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u")return null;const{directions:n,minWidth:e,minHeight:t,alwaysPreserveAspectRatio:r}=this.options.resize,i=new Set(["src","width","height"]);return({node:s,getPos:o,HTMLAttributes:l,editor:a})=>{const c=document.createElement("img");c.draggable=!1;const d=F(this.options.HTMLAttributes,l);Object.entries(d).forEach(([y,b])=>{if(b!=null)switch(y){case"src":case"width":case"height":break;default:c.setAttribute(y,b)}}),d.src!==null&&(c.src=d.src);let u={...l};const f=y=>{if(typeof y=="string"&&y!==""){c.getAttribute("src")!==y&&(c.src=y);return}c.hasAttribute("src")&&c.removeAttribute("src"),c.src!==""&&(c.src="")};f(l.src);const h=y=>{if(y.type!==s.type)return!1;const b=a.extensionManager.attributes.filter(S=>S.type===y.type.name),k=on(y,b);return Object.keys(u).forEach(S=>{!i.has(S)&&!(S in k)&&c.removeAttribute(S)}),Object.entries(k).forEach(([S,v])=>{i.has(S)||(v!=null?c.setAttribute(S,v):c.removeAttribute(S))}),f(k.src),u=k,!0},p=new du({element:c,editor:a,node:s,getPos:o,onResize:(y,b)=>{c.style.width=`${y}px`,c.style.height=`${b}px`},onCommit:(y,b)=>{const k=o();k!==void 0&&this.editor.chain().setNodeSelection(k).updateAttributes(this.name,{width:y,height:b}).run()},onUpdate:h,options:{directions:n,min:{width:e,height:t},preserveAspectRatio:r===!0}}),m=p.dom,g=()=>{m.style.visibility="",m.style.pointerEvents=""};return m.style.visibility="hidden",m.style.pointerEvents="none",c.complete&&c.naturalWidth>0?g():(c.onload=g,c.onerror=g),p}},addCommands(){return{setImage:n=>({commands:e})=>e.insertContent({type:this.name,attrs:n})}},addInputRules(){return[cu({find:gb,type:this.type,getAttributes:n=>{const[,,e,t,r]=n;return{src:t,alt:e,title:r}}})]}});var bb=yb;let Ds,Ps;if(typeof WeakMap<"u"){let n=new WeakMap;Ds=e=>n.get(e),Ps=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;Ds=r=>{for(let i=0;i(t==10&&(t=0),n[t++]=r,n[t++]=i)}var G=class{constructor(n,e,t,r){this.width=n,this.height=e,this.map=t,this.problems=r}findCell(n){for(let e=0;e=t){(s||(s=[])).push({type:"overlong_rowspan",pos:d,n:y-k});break}const S=i+k*e;for(let v=0;vr&&(s+=c.attrs.colspan)}}for(let o=0;o1&&(t=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function Sb(n,e,t){n.problems||(n.problems=[]);const r={};for(let i=0;i0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function Cb(n){for(let e=n.depth;e>0;e--){const t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function Oe(n){const e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function Ri(n){const e=n.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 t=Bt(e.$head)||vb(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function vb(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function zs(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function Eb(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function vo(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function pu(n,e,t){const r=n.node(-1),i=G.get(r),s=n.start(-1),o=i.nextCell(n.pos-s,e,t);return o==null?null:n.node(0).resolve(s+o)}function Ht(n,e,t=1){const r={...n,colspan:n.colspan-t};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}function mu(n,e,t=1){const r={...n,colspan:n.colspan+t};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;id!=t.pos-s);a.unshift(t.pos-s);const c=a.map(d=>{const u=r.nodeAt(d);if(!u)throw new RangeError(`No cell with offset ${d} found`);const f=s+d+1;return new Nc(l.resolve(f),l.resolve(f+u.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const r=e.resolve(t.map(this.$anchorCell.pos)),i=e.resolve(t.map(this.$headCell.pos));if(zs(r)&&zs(i)&&vo(r,i)){const s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?Ve.rowSelection(r,i):s&&this.isColSelection()?Ve.colSelection(r,i):new Ve(r,i)}return M.between(r,i)}content(){const e=this.$anchorCell.node(-1),t=G.get(e),r=this.$anchorCell.start(-1),i=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),s={},o=[];for(let a=i.top;a0||g>0){let y=p.attrs;if(m>0&&(y=Ht(y,0,m)),g>0&&(y=Ht(y,y.colspan-g,g)),h.lefti.bottom){const y={...p.attrs,rowspan:Math.min(h.bottom,i.bottom)-Math.max(h.top,i.top)};h.top0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const r=e.node(-1),i=G.get(r),s=e.start(-1),o=i.findCell(e.pos-s),l=i.findCell(t.pos-s),a=e.node(0);return o.top<=l.top?(o.top>0&&(e=a.resolve(s+i.map[o.left])),l.bottom0&&(t=a.resolve(s+i.map[l.left])),o.bottom0)return!1;const o=i+this.$anchorCell.nodeAfter.attrs.colspan,l=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,l)==t.width}eq(e){return e instanceof Ve&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const r=e.node(-1),i=G.get(r),s=e.start(-1),o=i.findCell(e.pos-s),l=i.findCell(t.pos-s),a=e.node(0);return o.left<=l.left?(o.left>0&&(e=a.resolve(s+i.map[o.top*i.width])),l.right0&&(t=a.resolve(s+i.map[l.top*i.width])),o.right{e.push(te.node(r,r+t.nodeSize,{class:"selectedCell"}))}),z.create(n.doc,e)}function Nb({$from:n,$to:e}){if(n.pos==e.pos||n.pos=0&&!(n.after(i+1)=0&&!(e.before(s+1)>e.start(s));s--,r--);return t==r&&/row|table/.test(n.node(i).type.spec.tableRole)}function Ob({$from:n,$to:e}){let t,r;for(let i=n.depth;i>0;i--){const s=n.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){t=s;break}}for(let i=e.depth;i>0;i--){const s=e.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){r=s;break}}return t!==r&&e.parentOffset===0}function Rb(n,e,t){const r=(e||n).selection,i=(e||n).doc;let s,o;if(r instanceof T&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")s=_.create(i,r.from);else if(o=="row"){const l=i.resolve(r.from+1);s=_.rowSelection(l,l)}else if(!t){const l=G.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];s=_.create(i,a+1,c)}}else r instanceof M&&Nb(r)?s=M.create(i,r.from):r instanceof M&&Ob(r)&&(s=M.create(i,r.$from.start(),r.$from.end()));return s&&(e||(e=n.tr)).setSelection(s),e}const Lb=new W("fix-tables");function yu(n,e,t,r){const i=n.childCount,s=e.childCount;e:for(let o=0,l=0;o{i.type.spec.tableRole=="table"&&(t=Ib(n,i,s,t))};return e?e.doc!=n.doc&&yu(e.doc,n.doc,0,r):n.doc.descendants(r),t}function Ib(n,e,t,r){const i=G.get(e);if(!i.problems)return r;r||(r=n.tr);const s=[];for(let a=0;a0){let h="cell";d.firstChild&&(h=d.firstChild.type.spec.tableRole);const p=[];for(let g=0;g0?-1:0;Mb(e,r,i+s)&&(s=i==0||i==e.width?null:0);for(let o=0;o0&&i0&&e.map[l-1]==a||i0?-1:0;Bb(e,r,i+l)&&(l=i==0||i==e.height?null:0);for(let c=0,d=e.width*i;c0&&i0&&u==e.map[d-e.width]){const f=t.nodeAt(u).attrs;n.setNodeMarkup(n.mapping.slice(l).map(u+r),null,{...f,rowspan:f.rowspan-1}),c+=f.colspan-1}else if(i0&&t[s]==t[s-1]||r.right0&&t[i]==t[i-n]||r.bottom0){const d=a+1+c.content.size,u=ia(c)?a+1:d;s.replaceWith(u+r.tableStart,d+r.tableStart,l)}s.setSelection(new _(s.doc.resolve(a+r.tableStart))),e(s)}return!0}function oa(n,e){const t=ue(n.schema);return jb(({node:r})=>t[r.type.spec.tableRole])(n,e)}function jb(n){return(e,t)=>{const r=e.selection;let i,s;if(r instanceof _){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,s=r.$anchorCell.pos}else{var o;if(i=Cb(r.$from),!i)return!1;s=(o=Bt(r.$from))===null||o===void 0?void 0:o.pos}if(i==null||s==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(t){let l=i.attrs;const a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const d=$e(e),u=e.tr;for(let h=0;h{o.attrs[n]!==e&&s.setNodeMarkup(l,null,{...o.attrs,[n]:e})}):s.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[n]:e}),r(s)}return!0}}function Kb(n){return function(e,t){if(!Oe(e))return!1;if(t){const r=ue(e.schema),i=$e(e),s=e.tr,o=i.map.cellsInRect(n=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:n=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),l=o.map(a=>i.table.nodeAt(a));for(let a=0;a{const h=f+s.tableStart,p=o.doc.nodeAt(h);p&&o.setNodeMarkup(h,u,p.attrs)}),r(o)}return!0}}jn("row",{useDeprecatedLogic:!0});jn("column",{useDeprecatedLogic:!0});const qb=jn("cell",{useDeprecatedLogic:!0});function Jb(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,i=n.before();r>=0;r--){const s=n.node(-1).child(r),o=s.lastChild;if(o)return i-1-o.nodeSize;i-=s.nodeSize}}else{if(n.index()0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}function lr(n,e){const t=n.selection;if(!(t instanceof _))return!1;if(e){const r=n.tr,i=ue(n.schema).cell.createAndFill().content;t.forEachCell((s,o)=>{s.content.eq(i)||r.replace(r.mapping.map(o+1),r.mapping.map(o+s.nodeSize-1),new C(i,0,0))}),r.docChanged&&e(r)}return!0}function Yb(n){if(n.size===0)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.child(0).type.spec.tableRole=="table");)t--,r--,e=e.child(0).content;const i=e.child(0),s=i.type.spec.tableRole,o=i.type.schema,l=[];if(s=="row")for(let a=0;a=0;o--){const{rowspan:l,colspan:a}=s.child(o).attrs;for(let c=i;c=e.length&&e.push(w.empty),t[i]r&&(f=f.type.createChecked(Ht(f.attrs,f.attrs.colspan,d+f.attrs.colspan-r),f.content)),c.push(f),d+=f.attrs.colspan;for(let h=1;hi&&(u=u.type.create({...u.attrs,rowspan:Math.max(1,i-u.attrs.rowspan)},u.content)),a.push(u)}s.push(w.from(a))}t=s,e=i}return{width:n,height:e,rows:t}}function Zb(n,e,t,r,i,s,o){const l=n.doc.type.schema,a=ue(l);let c,d;if(i>e.width)for(let u=0,f=0;ue.height){const u=[];for(let p=0,m=(e.height-1)*e.width;p=e.width?!1:t.nodeAt(e.map[m+p]).type==a.header_cell;u.push(g?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const f=a.row.create(null,w.from(u)),h=[];for(let p=e.height;p{if(!i)return!1;const s=t.selection;if(s instanceof _)return xr(t,r,O.near(s.$headCell,e));if(n!="horiz"&&!s.empty)return!1;const o=Su(i,n,e);if(o==null)return!1;if(n=="horiz")return xr(t,r,O.near(t.doc.resolve(s.head+e),e));{const l=t.doc.resolve(o),a=pu(l,n,e);let c;return a?c=O.near(a,1):e<0?c=O.near(t.doc.resolve(l.before(-1)),-1):c=O.near(t.doc.resolve(l.after(-1)),1),xr(t,r,c)}}}function cr(n,e){return(t,r,i)=>{if(!i)return!1;const s=t.selection;let o;if(s instanceof _)o=s;else{const a=Su(i,n,e);if(a==null)return!1;o=new _(t.doc.resolve(a))}const l=pu(o.$headCell,n,e);return l?xr(t,r,new _(o.$anchorCell,l)):!1}}function t0(n,e){const t=n.state.doc,r=Bt(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new _(r))),!0):!1}function n0(n,e,t){if(!Oe(n.state))return!1;let r=Yb(t);const i=n.state.selection;if(i instanceof _){r||(r={width:1,height:1,rows:[w.from($s(ue(n.state.schema).cell,t))]});const s=i.$anchorCell.node(-1),o=i.$anchorCell.start(-1),l=G.get(s).rectBetween(i.$anchorCell.pos-o,i.$headCell.pos-o);return r=Qb(r,l.right-l.left,l.bottom-l.top),ua(n.state,n.dispatch,o,l,r),!0}else if(r){const s=Ri(n.state),o=s.start(-1);return ua(n.state,n.dispatch,o,G.get(s.node(-1)).findCell(s.pos-o),r),!0}else return!1}function r0(n,e){var t;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=fa(n,e.target);let i;if(e.shiftKey&&n.state.selection instanceof _)s(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=Bt(n.state.selection.$anchor))!=null&&((t=Zi(n,e))===null||t===void 0?void 0:t.pos)!=i.pos)s(i,e),e.preventDefault();else if(!r)return;function s(a,c){let d=Zi(n,c);const u=st.getState(n.state)==null;if(!d||!vo(a,d))if(u)d=a;else return;const f=new _(a,d);if(u||!n.state.selection.eq(f)){const h=n.state.tr.setSelection(f);u&&h.setMeta(st,a.pos),n.dispatch(h)}}function o(){n.root.removeEventListener("mouseup",o),n.root.removeEventListener("dragstart",o),n.root.removeEventListener("mousemove",l),st.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(st,-1))}function l(a){const c=a,d=st.getState(n.state);let u;if(d!=null)u=n.state.doc.resolve(d);else if(fa(n,c.target)!=r&&(u=Zi(n,e),!u))return o();u&&s(u,c)}n.root.addEventListener("mouseup",o),n.root.addEventListener("dragstart",o),n.root.addEventListener("mousemove",l)}function Su(n,e,t){if(!(n.state.selection instanceof M))return null;const{$head:r}=n.state.selection;for(let i=r.depth-1;i>=0;i--){const s=r.node(i);if((t<0?r.index(i):r.indexAfter(i))!=(t<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const o=r.before(i),l=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(l)?o:null}}return null}function fa(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Zi(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});if(!t)return null;let{inside:r,pos:i}=t;return r>=0&&Bt(n.state.doc.resolve(r))||Bt(n.state.doc.resolve(i))}var i0=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${t}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Bs(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,Bs(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Bs(n,e,t,r,i,s){let o=0,l=!0,a=e.firstChild;const c=n.firstChild;if(c){for(let u=0,f=0;unew r(u,t,f)),new o0(-1,!1)},apply(o,l){return l.apply(o)}},props:{attributes:o=>{const l=ke.getState(o);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,l)=>{l0(o,l,n,i)},mouseleave:o=>{a0(o)},mousedown:(o,l)=>{c0(o,l,e,t)}},decorations:o=>{const l=ke.getState(o);if(l&&l.activeHandle>-1)return p0(o,l.activeHandle)},nodeViews:{}}});return s}var o0=class Cr{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,r=e.getMeta(ke);if(r&&r.setHandle!=null)return new Cr(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Cr(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let i=e.mapping.map(t.activeHandle,-1);return zs(e.doc.resolve(i))||(i=-1),new Cr(i,t.dragging)}return t}};function l0(n,e,t,r){if(!n.editable)return;const i=ke.getState(n.state);if(i&&!i.dragging){const s=u0(e.target);let o=-1;if(s){const{left:l,right:a}=s.getBoundingClientRect();e.clientX-l<=t?o=ha(n,e,"left",t):a-e.clientX<=t&&(o=ha(n,e,"right",t))}if(o!=i.activeHandle){if(!r&&o!==-1){const l=n.state.doc.resolve(o),a=l.node(-1),c=G.get(a),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}xu(n,o)}}}function a0(n){if(!n.editable)return;const e=ke.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&xu(n,-1)}function c0(n,e,t,r){var i;if(!n.editable)return!1;const s=(i=n.dom.ownerDocument.defaultView)!==null&&i!==void 0?i:window,o=ke.getState(n.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const l=n.state.doc.nodeAt(o.activeHandle),a=d0(n,o.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(ke,{setDragging:{startX:e.clientX,startWidth:a}}));function c(u){s.removeEventListener("mouseup",c),s.removeEventListener("mousemove",d);const f=ke.getState(n.state);f?.dragging&&(f0(n,f.activeHandle,pa(f.dragging,u,t)),n.dispatch(n.state.tr.setMeta(ke,{setDragging:null})))}function d(u){if(!u.which)return c(u);const f=ke.getState(n.state);if(f&&f.dragging){const h=pa(f.dragging,u,t);ma(n,f.activeHandle,h,r)}}return ma(n,o.activeHandle,a,r),s.addEventListener("mouseup",c),s.addEventListener("mousemove",d),e.preventDefault(),!0}function d0(n,e,{colspan:t,colwidth:r}){const i=r&&r[r.length-1];if(i)return i;const s=n.domAtPos(e);let o=s.node.childNodes[s.offset].offsetWidth,l=t;if(r)for(let a=0;ag0(n),renderHTML:n=>{const e=Un(n.align);return zy(e)?{style:`text-align: ${e}`}:{}}}}function b0(n){var e;const t=n.parentElement,r=n.closest("table");if(!t||!r)return null;const i=Array.from(t.children).indexOf(n),s=(e=r.querySelectorAll("colgroup > col")[i])===null||e===void 0?void 0:e.getAttribute("width");return s?[parseInt(s,10)]:null}function vu(n){const e=n.getAttribute("colwidth");return e?e.split(",").map(t=>parseInt(t,10)):b0(n)}const k0=/[ \t\r\n\f]+/g;function Eu(n){var e;return n.children.length>0?!1:((e=n.textContent)!==null&&e!==void 0?e:"").replace(k0,"")===""}function Mu(n){const e=n.createAndFill();if(!e)throw new Error(`[tiptap error]: "${n.name}" has no default content to backfill.`);return e.content}function Hr(n,e,t){if(!(t in e))return;const r=e[t];(r===1||r==="1"||r===null||r===void 0)&&delete n[t]}const Au=U.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:vu},align:Cu()}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td",getAttrs:n=>Eu(n)?{}:!1,getContent:(n,e)=>Mu(e.nodes[this.name])},{tag:"td"}]},renderHTML({HTMLAttributes:n}){const e=F(this.options.HTMLAttributes,n);return Hr(e,n,"colspan"),Hr(e,n,"rowspan"),["td",e,0]}}),Tu=U.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:vu},align:Cu()}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th",getAttrs:n=>Eu(n)?{}:!1,getContent:(n,e)=>Mu(e.nodes[this.name])},{tag:"th"}]},renderHTML({HTMLAttributes:n}){const e=F(this.options.HTMLAttributes,n);return Hr(e,n,"colspan"),Hr(e,n,"rowspan"),["th",e,0]}}),Nu=U.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",F(this.options.HTMLAttributes,n),0]}});function Hs(n,e){return e?["width",`${Math.max(e,n)}px`]:["min-width",`${n}px`]}function ga(n,e,t,r,i,s){let o=0,l=!0,a=e.firstChild;const c=n.firstChild;if(c!==null)for(let f=0,h=0;f{const r=n.nodes[t];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),n.cached.tableNodeTypes=e,e}function C0(n,e,t,r,i){const s=x0(n),o=[],l=[];for(let c=0;c{const{selection:e}=n.state;if(!Ou(e))return!1;let t=0;const r=Wn(e.ranges[0].$from,i=>i.type.name==="table");return r?.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(t+=1)}),t!==e.ranges.length?!1:(n.commands.deleteTable(),!0)};function ba(n,e){const t=n.mapping.map(e),r=Wn(n.selection.$from,o=>o.type.name==="table");if(r?.pos===t)return;const i=n.doc.nodeAt(t);if(!i)return;const s=t+i.nodeSize-1;n.setSelection(M.near(n.doc.resolve(s),-1))}function v0(n){let e="",t=0;for(;ta==="|"?"\\|":a)+n.slice(i,i+r),t=i+r,s=!0;break}i+=o}s||(e+=n.slice(t,t+r),t+=r)}return e}function E0(n){return n.split(` -`).map(e=>!e.includes("|")||!e.includes("`")?e:v0(e)).join(` -`)}function M0(n){return(n||"").replaceAll(""," ").replace(/\s+/g," ").trim()}function ka(n,e){return e?n.split(e).join(` -`):n}function A0(n){return n.replace(/\\.|\|/g,e=>e==="|"?"\\|":e)}function T0(n,e,t={}){if(!n||!n.content||n.content.length===0)return"";const r=[];n.content.forEach(f=>{const h=[];f.content&&f.content.forEach(p=>{let m="";p.content&&Array.isArray(p.content)&&p.content.length>1?m=p.content.map(k=>ka(e.renderChildren(k),t.cellLineSeparator)).join(` -`):m=ka(p.content?e.renderChildren(p.content):"",t.cellLineSeparator);const g=A0(M0(m.replace(/[ \t]*\r?\n[ \t]*/g,"
"))),y=p.type==="tableHeader",b=y0(p.attrs);h.push({text:g,isHeader:y,align:b})}),r.push(h)});const i=r.reduce((f,h)=>Math.max(f,h.length),0);if(i===0)return"";const s=Array.from({length:i}).fill(0);r.forEach(f=>{for(let p=0;ps[p]&&(s[p]=m),s[p]<3&&(s[p]=3)}});const o=(f,h)=>f+" ".repeat(Math.max(0,h-f.length)),l=r[0],a=l.some(f=>f.isHeader),c=Array.from({length:i}).fill(null);r.forEach(f=>{for(let p=0;p0&&e.nodeAfter&&!e.nodeAfter.isText&&e.nodeAfter.isAtom?e.nodeAfter:null;return new sb(e,this,!1,t)}get $doc(){return this.$pos(0)}};function $t(n){return new er({find:n.find,handler:({state:e,range:t,match:r})=>{const i=$(n.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:s}=e,o=r[r.length-1],l=r[0];if(o){const a=l.search(/\S/),c=t.from+l.indexOf(o),d=c+o.length;if(Ni(t.from,t.to,e.doc).filter(f=>f.mark.type.excluded.find(h=>h===n.type&&h!==f.mark.type)).filter(f=>f.to>c).length)return null;dt.from&&s.delete(t.from+a,c);const u=t.from+a+o.length;s.addMark(t.from+a,u,n.type.create(i||{})),s.removeStoredMark(n.type)}},undoable:n.undoable})}function cu(n){return new er({find:n.find,handler:({state:e,range:t,match:r})=>{const i=$(n.getAttributes,void 0,r)||{},{tr:s}=e,o=t.from;let l=t.to;const a=n.type.create(i);if(r[1]){let c=o+r[0].lastIndexOf(r[1]);c>l?c=l:l=c+r[1].length;const d=r[0][r[0].length-1];s.insertText(d,o+r[0].length-1),s.replaceWith(c,l,a)}else if(r[0]){const c=n.type.isInline?o:o-1;s.insert(c,n.type.create(i)).delete(s.mapping.map(o),s.mapping.map(l))}s.scrollIntoView()},undoable:n.undoable})}function Is(n){return new er({find:n.find,handler:({state:e,range:t,match:r})=>{const i=e.doc.resolve(t.from),s=$(n.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,s)},undoable:n.undoable})}function ln(n){return new er({find:n.find,handler:({state:e,range:t,match:r,chain:i})=>{const s=$(n.getAttributes,void 0,r)||{},o=e.tr.delete(t.from,t.to),l=o.doc.resolve(t.from).blockRange(),a=l&&eo(l,n.type,s);if(!a)return null;if(o.wrap(l,a),n.keepMarks&&n.editor){const{selection:d,storedMarks:u}=e,{splittableMarks:f}=n.editor.extensionManager,h=u||d.$to.parentOffset&&d.$from.marks();if(h){const p=h.filter(m=>f.includes(m.type.name));o.ensureMarks(p)}}if(n.keepAttributes){const d=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(d,s).run()}const c=o.doc.resolve(t.from-1).nodeBefore;c&&c.type===n.type&>(o.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,c))&&o.join(t.from-1)},undoable:n.undoable})}const ab=n=>"touches"in n;var du=class{constructor(n){var e,t,r,i,s,o;this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=l=>{if(!this.isResizing||!this.activeHandle)return;const a=l.clientX-this.startX,c=l.clientY-this.startY;this.handleResize(a,c)},this.handleTouchMove=l=>{if(!this.isResizing||!this.activeHandle)return;const a=l.touches[0];if(!a)return;const c=a.clientX-this.startX,d=a.clientY-this.startY;this.handleResize(c,d)},this.handleMouseUp=()=>{if(!this.isResizing)return;const l=this.element.offsetWidth,a=this.element.offsetHeight;this.onCommit(l,a),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!1)},this.node=n.node,this.editor=n.editor,this.element=n.element,this.element.draggable=!1,this.contentElement=n.contentElement,this.getPos=n.getPos,this.onResize=n.onResize,this.onCommit=n.onCommit,this.onUpdate=n.onUpdate,!((e=n.options)===null||e===void 0)&&e.min&&(this.minSize={...this.minSize,...n.options.min}),!((t=n.options)===null||t===void 0)&&t.max&&(this.maxSize=n.options.max),!(n==null||(r=n.options)===null||r===void 0)&&r.directions&&(this.directions=n.options.directions),!((i=n.options)===null||i===void 0)&&i.preserveAspectRatio&&(this.preserveAspectRatio=n.options.preserveAspectRatio),!((s=n.options)===null||s===void 0)&&s.className&&(this.classNames={container:n.options.className.container||"",wrapper:n.options.className.wrapper||"",handle:n.options.className.handle||"",resizing:n.options.className.resizing||""}),!((o=n.options)===null||o===void 0)&&o.createCustomHandle&&(this.createCustomHandle=n.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var n;return(n=this.contentElement)!==null&&n!==void 0?n:null}handleEditorUpdate(){const n=this.editor.isEditable;n!==this.lastEditableState&&(this.lastEditableState=n,n?n&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(n,e,t){return n.type!==this.node.type?!1:(this.node=n,this.onUpdate?this.onUpdate(n,e,t):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){const n=document.createElement("div");return n.dataset.resizeContainer="",n.dataset.node=this.node.type.name,n.style.display=this.node.type.isInline?"inline-flex":"flex",this.classNames.container&&(n.className=this.classNames.container),n.appendChild(this.wrapper),n}createWrapper(){const n=document.createElement("div");return n.style.position="relative",n.style.display="block",n.dataset.resizeWrapper="",this.classNames.wrapper&&(n.className=this.classNames.wrapper),n.appendChild(this.element),n}createHandle(n){const e=document.createElement("div");return e.dataset.resizeHandle=n,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(n,e){const t=e.includes("top"),r=e.includes("bottom"),i=e.includes("left"),s=e.includes("right");t&&(n.style.top="0"),r&&(n.style.bottom="0"),i&&(n.style.left="0"),s&&(n.style.right="0"),(e==="top"||e==="bottom")&&(n.style.left="0",n.style.right="0"),(e==="left"||e==="right")&&(n.style.top="0",n.style.bottom="0")}attachHandles(){this.directions.forEach(n=>{let e;this.createCustomHandle?e=this.createCustomHandle(n):e=this.createHandle(n),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${n}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(n)),this.createCustomHandle||this.positionHandle(e,n),e.addEventListener("mousedown",t=>this.handleResizeStart(t,n)),e.addEventListener("touchstart",t=>this.handleResizeStart(t,n)),this.handleMap.set(n,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(n=>n.remove()),this.handleMap.clear()}applyInitialSize(){const n=this.node.attrs.width,e=this.node.attrs.height;n?(this.element.style.width=`${n}px`,this.initialWidth=n):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(n,e){n.preventDefault(),n.stopPropagation(),this.isResizing=!0,this.activeHandle=e,ab(n)?(this.startX=n.touches[0].clientX,this.startY=n.touches[0].clientY):(this.startX=n.clientX,this.startY=n.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(n,e){if(!this.activeHandle)return;const t=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:i}=this.calculateNewDimensions(this.activeHandle,n,e),s=this.applyConstraints(r,i,t);this.element.style.width=`${s.width}px`,this.element.style.height=`${s.height}px`,this.onResize&&this.onResize(s.width,s.height)}calculateNewDimensions(n,e,t){let r=this.startWidth,i=this.startHeight;const s=n.includes("right"),o=n.includes("left"),l=n.includes("bottom"),a=n.includes("top");return s?r=this.startWidth+e:o&&(r=this.startWidth-e),l?i=this.startHeight+t:a&&(i=this.startHeight-t),(n==="right"||n==="left")&&(r=this.startWidth+(s?e:-e)),(n==="top"||n==="bottom")&&(i=this.startHeight+(l?t:-t)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,n):{width:r,height:i}}applyConstraints(n,e,t){var r,i;if(!t){var s,o;let c=Math.max(this.minSize.width,n),d=Math.max(this.minSize.height,e);return!((s=this.maxSize)===null||s===void 0)&&s.width&&(c=Math.min(this.maxSize.width,c)),!((o=this.maxSize)===null||o===void 0)&&o.height&&(d=Math.min(this.maxSize.height,d)),{width:c,height:d}}let l=n,a=e;return lthis.maxSize.width&&(l=this.maxSize.width,a=l/this.aspectRatio),!((i=this.maxSize)===null||i===void 0)&&i.height&&a>this.maxSize.height&&(a=this.maxSize.height,l=a*this.aspectRatio),{width:l,height:a}}applyAspectRatio(n,e,t){const r=t==="left"||t==="right",i=t==="top"||t==="bottom";return r?{width:n,height:n/this.aspectRatio}:i?{width:e*this.aspectRatio,height:e}:{width:n,height:n/this.aspectRatio}}},U=class uu extends xo{constructor(...e){super(...e),this.type="node"}static create(e={}){const t=typeof e=="function"?e():e;return new uu(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}};function pt(n){return new lu({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:i})=>{const s=$(n.getAttributes,void 0,r,i);if(s===!1||s===null)return null;const{tr:o}=e,l=r[r.length-1],a=r[0];let c=t.to;if(l){const d=a.search(/\S/),u=t.from+a.indexOf(l),f=u+l.length;if(Ni(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(p=>p===n.type&&p!==h.mark.type)).filter(h=>h.to>u).length)return null;ft.from&&o.delete(t.from+d,u),c=t.from+d+l.length,o.addMark(t.from+d,c,n.type.create(s||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||o.removeStoredMark(n.type)}}})}const cb=new Set(["youtube.com","www.youtube.com","m.youtube.com","music.youtube.com","youtube-nocookie.com","www.youtube-nocookie.com"]),db=/^[a-z][a-z0-9_-]{0,31}$/,ub=new Set(["constructor","prototype"]),fb=/^[1-9][0-9]{0,3}(?:\s*\/\s*[1-9][0-9]{0,3}|\.[0-9]{1,4})?$/,hb=/^[1-9][0-9]{0,3}(?:px)?$/,En={youtube:{name:"YouTube",idPattern:/^[A-Za-z0-9_-]{11}$/,idFromUrl(n){const e=n.hostname.toLowerCase();if(e==="youtu.be")return n.pathname.split("/")[1]??null;if(!cb.has(e))return null;if(n.pathname==="/watch")return n.searchParams.get("v");const t=/^\/(?:shorts|embed)\/([^/]+)\/?$/.exec(n.pathname);return t?t[1]:null}}},an=[{key:"youtube",name:En.youtube.name,idPattern:En.youtube.idPattern,mode:"url",idFromUrl:En.youtube.idFromUrl}];function pb(n){return Object.prototype.hasOwnProperty.call(En,n)}function mb(n){if(!Array.isArray(n))return[...an];const e=new Set,t=[];for(const r of n){if(!r||typeof r!="object"||Array.isArray(r))continue;const i=r,s=typeof i.key=="string"?i.key.trim():"";if(!db.test(s)||ub.has(s)||e.has(s))continue;const o=typeof i.idPattern=="string"?i.idPattern.trim():"";if(!o)continue;let l;try{new RegExp(o),l=new RegExp(`^(?:${o})$`)}catch{continue}const a=typeof i.name=="string"&&i.name.trim()!==""?i.name.trim():s,c=s==="youtube"?En.youtube.idFromUrl:void 0,d=typeof i.mode=="string"?i.mode.trim():"",u=d==="url"&&c?"url":d==="id"?"id":c?"url":"id",f=typeof i.placeholder=="string"&&i.placeholder.trim()!==""?i.placeholder.trim():void 0,h={key:s,name:a,idPattern:l,mode:u,...f?{placeholder:f}:{},...c?{idFromUrl:c}:{}};e.add(s),t.push(h)}return t.length>0?t:[...an]}function Qt(n,e){return n.find(t=>t.key===e)}function fu(n,e,t){const r=Qt(n,e);return!!(r&&t!==""&&r.idPattern.test(t))}const Co=fu;function $r(n){return fb.test(n.trim())}function Br(n){return hb.test(n.trim())}function hu(n,e){let t;try{t=new URL(e.trim())}catch{return null}if(t.protocol!=="https:"&&t.protocol!=="http:")return null;for(const r of n){if(!r.idFromUrl)continue;const i=r.idFromUrl(t);if(i&&r.idPattern.test(i))return{provider:r.key,id:i}}return null}function gb(n){const e=hu(an,n);return!e||!pb(e.provider)?null:{provider:e.provider,id:e.id}}const yb=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,bb=U.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:n}){return["img",F(this.options.HTMLAttributes,n)]},parseMarkdown:(n,e)=>e.createNode("image",{src:n.href,title:n.title,alt:n.text}),renderMarkdown:n=>{var e,t,r,i,s,o;const l=(e=(t=n.attrs)===null||t===void 0?void 0:t.src)!==null&&e!==void 0?e:"",a=(r=(i=n.attrs)===null||i===void 0?void 0:i.alt)!==null&&r!==void 0?r:"",c=(s=(o=n.attrs)===null||o===void 0?void 0:o.title)!==null&&s!==void 0?s:"";return c?`![${a}](${l} "${c}")`:`![${a}](${l})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u")return null;const{directions:n,minWidth:e,minHeight:t,alwaysPreserveAspectRatio:r}=this.options.resize,i=new Set(["src","width","height"]);return({node:s,getPos:o,HTMLAttributes:l,editor:a})=>{const c=document.createElement("img");c.draggable=!1;const d=F(this.options.HTMLAttributes,l);Object.entries(d).forEach(([y,b])=>{if(b!=null)switch(y){case"src":case"width":case"height":break;default:c.setAttribute(y,b)}}),d.src!==null&&(c.src=d.src);let u={...l};const f=y=>{if(typeof y=="string"&&y!==""){c.getAttribute("src")!==y&&(c.src=y);return}c.hasAttribute("src")&&c.removeAttribute("src"),c.src!==""&&(c.src="")};f(l.src);const h=y=>{if(y.type!==s.type)return!1;const b=a.extensionManager.attributes.filter(S=>S.type===y.type.name),k=on(y,b);return Object.keys(u).forEach(S=>{!i.has(S)&&!(S in k)&&c.removeAttribute(S)}),Object.entries(k).forEach(([S,v])=>{i.has(S)||(v!=null?c.setAttribute(S,v):c.removeAttribute(S))}),f(k.src),u=k,!0},p=new du({element:c,editor:a,node:s,getPos:o,onResize:(y,b)=>{c.style.width=`${y}px`,c.style.height=`${b}px`},onCommit:(y,b)=>{const k=o();k!==void 0&&this.editor.chain().setNodeSelection(k).updateAttributes(this.name,{width:y,height:b}).run()},onUpdate:h,options:{directions:n,min:{width:e,height:t},preserveAspectRatio:r===!0}}),m=p.dom,g=()=>{m.style.visibility="",m.style.pointerEvents=""};return m.style.visibility="hidden",m.style.pointerEvents="none",c.complete&&c.naturalWidth>0?g():(c.onload=g,c.onerror=g),p}},addCommands(){return{setImage:n=>({commands:e})=>e.insertContent({type:this.name,attrs:n})}},addInputRules(){return[cu({find:yb,type:this.type,getAttributes:n=>{const[,,e,t,r]=n;return{src:t,alt:e,title:r}}})]}});var kb=bb;let Ds,Ps;if(typeof WeakMap<"u"){let n=new WeakMap;Ds=e=>n.get(e),Ps=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;Ds=r=>{for(let i=0;i(t==10&&(t=0),n[t++]=r,n[t++]=i)}var G=class{constructor(n,e,t,r){this.width=n,this.height=e,this.map=t,this.problems=r}findCell(n){for(let e=0;e=t){(s||(s=[])).push({type:"overlong_rowspan",pos:d,n:y-k});break}const S=i+k*e;for(let v=0;vr&&(s+=c.attrs.colspan)}}for(let o=0;o1&&(t=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function xb(n,e,t){n.problems||(n.problems=[]);const r={};for(let i=0;i0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function vb(n){for(let e=n.depth;e>0;e--){const t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function Oe(n){const e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function Ri(n){const e=n.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 t=Bt(e.$head)||Eb(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function Eb(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function zs(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function Mb(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function vo(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function pu(n,e,t){const r=n.node(-1),i=G.get(r),s=n.start(-1),o=i.nextCell(n.pos-s,e,t);return o==null?null:n.node(0).resolve(s+o)}function Ht(n,e,t=1){const r={...n,colspan:n.colspan-t};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}function mu(n,e,t=1){const r={...n,colspan:n.colspan+t};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;id!=t.pos-s);a.unshift(t.pos-s);const c=a.map(d=>{const u=r.nodeAt(d);if(!u)throw new RangeError(`No cell with offset ${d} found`);const f=s+d+1;return new Nc(l.resolve(f),l.resolve(f+u.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const r=e.resolve(t.map(this.$anchorCell.pos)),i=e.resolve(t.map(this.$headCell.pos));if(zs(r)&&zs(i)&&vo(r,i)){const s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?Ve.rowSelection(r,i):s&&this.isColSelection()?Ve.colSelection(r,i):new Ve(r,i)}return M.between(r,i)}content(){const e=this.$anchorCell.node(-1),t=G.get(e),r=this.$anchorCell.start(-1),i=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),s={},o=[];for(let a=i.top;a0||g>0){let y=p.attrs;if(m>0&&(y=Ht(y,0,m)),g>0&&(y=Ht(y,y.colspan-g,g)),h.lefti.bottom){const y={...p.attrs,rowspan:Math.min(h.bottom,i.bottom)-Math.max(h.top,i.top)};h.top0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const r=e.node(-1),i=G.get(r),s=e.start(-1),o=i.findCell(e.pos-s),l=i.findCell(t.pos-s),a=e.node(0);return o.top<=l.top?(o.top>0&&(e=a.resolve(s+i.map[o.left])),l.bottom0&&(t=a.resolve(s+i.map[l.left])),o.bottom0)return!1;const o=i+this.$anchorCell.nodeAfter.attrs.colspan,l=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,l)==t.width}eq(e){return e instanceof Ve&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const r=e.node(-1),i=G.get(r),s=e.start(-1),o=i.findCell(e.pos-s),l=i.findCell(t.pos-s),a=e.node(0);return o.left<=l.left?(o.left>0&&(e=a.resolve(s+i.map[o.top*i.width])),l.right0&&(t=a.resolve(s+i.map[l.top*i.width])),o.right{e.push(te.node(r,r+t.nodeSize,{class:"selectedCell"}))}),z.create(n.doc,e)}function Ob({$from:n,$to:e}){if(n.pos==e.pos||n.pos=0&&!(n.after(i+1)=0&&!(e.before(s+1)>e.start(s));s--,r--);return t==r&&/row|table/.test(n.node(i).type.spec.tableRole)}function Rb({$from:n,$to:e}){let t,r;for(let i=n.depth;i>0;i--){const s=n.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){t=s;break}}for(let i=e.depth;i>0;i--){const s=e.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){r=s;break}}return t!==r&&e.parentOffset===0}function Lb(n,e,t){const r=(e||n).selection,i=(e||n).doc;let s,o;if(r instanceof T&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")s=_.create(i,r.from);else if(o=="row"){const l=i.resolve(r.from+1);s=_.rowSelection(l,l)}else if(!t){const l=G.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];s=_.create(i,a+1,c)}}else r instanceof M&&Ob(r)?s=M.create(i,r.from):r instanceof M&&Rb(r)&&(s=M.create(i,r.$from.start(),r.$from.end()));return s&&(e||(e=n.tr)).setSelection(s),e}const Ib=new W("fix-tables");function yu(n,e,t,r){const i=n.childCount,s=e.childCount;e:for(let o=0,l=0;o{i.type.spec.tableRole=="table"&&(t=Db(n,i,s,t))};return e?e.doc!=n.doc&&yu(e.doc,n.doc,0,r):n.doc.descendants(r),t}function Db(n,e,t,r){const i=G.get(e);if(!i.problems)return r;r||(r=n.tr);const s=[];for(let a=0;a0){let h="cell";d.firstChild&&(h=d.firstChild.type.spec.tableRole);const p=[];for(let g=0;g0?-1:0;Ab(e,r,i+s)&&(s=i==0||i==e.width?null:0);for(let o=0;o0&&i0&&e.map[l-1]==a||i0?-1:0;Hb(e,r,i+l)&&(l=i==0||i==e.height?null:0);for(let c=0,d=e.width*i;c0&&i0&&u==e.map[d-e.width]){const f=t.nodeAt(u).attrs;n.setNodeMarkup(n.mapping.slice(l).map(u+r),null,{...f,rowspan:f.rowspan-1}),c+=f.colspan-1}else if(i0&&t[s]==t[s-1]||r.right0&&t[i]==t[i-n]||r.bottom0){const d=a+1+c.content.size,u=ia(c)?a+1:d;s.replaceWith(u+r.tableStart,d+r.tableStart,l)}s.setSelection(new _(s.doc.resolve(a+r.tableStart))),e(s)}return!0}function oa(n,e){const t=ue(n.schema);return Ub(({node:r})=>t[r.type.spec.tableRole])(n,e)}function Ub(n){return(e,t)=>{const r=e.selection;let i,s;if(r instanceof _){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,s=r.$anchorCell.pos}else{var o;if(i=vb(r.$from),!i)return!1;s=(o=Bt(r.$from))===null||o===void 0?void 0:o.pos}if(i==null||s==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(t){let l=i.attrs;const a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const d=$e(e),u=e.tr;for(let h=0;h{o.attrs[n]!==e&&s.setNodeMarkup(l,null,{...o.attrs,[n]:e})}):s.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[n]:e}),r(s)}return!0}}function qb(n){return function(e,t){if(!Oe(e))return!1;if(t){const r=ue(e.schema),i=$e(e),s=e.tr,o=i.map.cellsInRect(n=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:n=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),l=o.map(a=>i.table.nodeAt(a));for(let a=0;a{const h=f+s.tableStart,p=o.doc.nodeAt(h);p&&o.setNodeMarkup(h,u,p.attrs)}),r(o)}return!0}}jn("row",{useDeprecatedLogic:!0});jn("column",{useDeprecatedLogic:!0});const Jb=jn("cell",{useDeprecatedLogic:!0});function Gb(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,i=n.before();r>=0;r--){const s=n.node(-1).child(r),o=s.lastChild;if(o)return i-1-o.nodeSize;i-=s.nodeSize}}else{if(n.index()0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}function lr(n,e){const t=n.selection;if(!(t instanceof _))return!1;if(e){const r=n.tr,i=ue(n.schema).cell.createAndFill().content;t.forEachCell((s,o)=>{s.content.eq(i)||r.replace(r.mapping.map(o+1),r.mapping.map(o+s.nodeSize-1),new C(i,0,0))}),r.docChanged&&e(r)}return!0}function Xb(n){if(n.size===0)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.child(0).type.spec.tableRole=="table");)t--,r--,e=e.child(0).content;const i=e.child(0),s=i.type.spec.tableRole,o=i.type.schema,l=[];if(s=="row")for(let a=0;a=0;o--){const{rowspan:l,colspan:a}=s.child(o).attrs;for(let c=i;c=e.length&&e.push(w.empty),t[i]r&&(f=f.type.createChecked(Ht(f.attrs,f.attrs.colspan,d+f.attrs.colspan-r),f.content)),c.push(f),d+=f.attrs.colspan;for(let h=1;hi&&(u=u.type.create({...u.attrs,rowspan:Math.max(1,i-u.attrs.rowspan)},u.content)),a.push(u)}s.push(w.from(a))}t=s,e=i}return{width:n,height:e,rows:t}}function e0(n,e,t,r,i,s,o){const l=n.doc.type.schema,a=ue(l);let c,d;if(i>e.width)for(let u=0,f=0;ue.height){const u=[];for(let p=0,m=(e.height-1)*e.width;p=e.width?!1:t.nodeAt(e.map[m+p]).type==a.header_cell;u.push(g?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const f=a.row.create(null,w.from(u)),h=[];for(let p=e.height;p{if(!i)return!1;const s=t.selection;if(s instanceof _)return xr(t,r,O.near(s.$headCell,e));if(n!="horiz"&&!s.empty)return!1;const o=Su(i,n,e);if(o==null)return!1;if(n=="horiz")return xr(t,r,O.near(t.doc.resolve(s.head+e),e));{const l=t.doc.resolve(o),a=pu(l,n,e);let c;return a?c=O.near(a,1):e<0?c=O.near(t.doc.resolve(l.before(-1)),-1):c=O.near(t.doc.resolve(l.after(-1)),1),xr(t,r,c)}}}function cr(n,e){return(t,r,i)=>{if(!i)return!1;const s=t.selection;let o;if(s instanceof _)o=s;else{const a=Su(i,n,e);if(a==null)return!1;o=new _(t.doc.resolve(a))}const l=pu(o.$headCell,n,e);return l?xr(t,r,new _(o.$anchorCell,l)):!1}}function n0(n,e){const t=n.state.doc,r=Bt(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new _(r))),!0):!1}function r0(n,e,t){if(!Oe(n.state))return!1;let r=Xb(t);const i=n.state.selection;if(i instanceof _){r||(r={width:1,height:1,rows:[w.from($s(ue(n.state.schema).cell,t))]});const s=i.$anchorCell.node(-1),o=i.$anchorCell.start(-1),l=G.get(s).rectBetween(i.$anchorCell.pos-o,i.$headCell.pos-o);return r=Zb(r,l.right-l.left,l.bottom-l.top),ua(n.state,n.dispatch,o,l,r),!0}else if(r){const s=Ri(n.state),o=s.start(-1);return ua(n.state,n.dispatch,o,G.get(s.node(-1)).findCell(s.pos-o),r),!0}else return!1}function i0(n,e){var t;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=fa(n,e.target);let i;if(e.shiftKey&&n.state.selection instanceof _)s(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=Bt(n.state.selection.$anchor))!=null&&((t=Zi(n,e))===null||t===void 0?void 0:t.pos)!=i.pos)s(i,e),e.preventDefault();else if(!r)return;function s(a,c){let d=Zi(n,c);const u=st.getState(n.state)==null;if(!d||!vo(a,d))if(u)d=a;else return;const f=new _(a,d);if(u||!n.state.selection.eq(f)){const h=n.state.tr.setSelection(f);u&&h.setMeta(st,a.pos),n.dispatch(h)}}function o(){n.root.removeEventListener("mouseup",o),n.root.removeEventListener("dragstart",o),n.root.removeEventListener("mousemove",l),st.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(st,-1))}function l(a){const c=a,d=st.getState(n.state);let u;if(d!=null)u=n.state.doc.resolve(d);else if(fa(n,c.target)!=r&&(u=Zi(n,e),!u))return o();u&&s(u,c)}n.root.addEventListener("mouseup",o),n.root.addEventListener("dragstart",o),n.root.addEventListener("mousemove",l)}function Su(n,e,t){if(!(n.state.selection instanceof M))return null;const{$head:r}=n.state.selection;for(let i=r.depth-1;i>=0;i--){const s=r.node(i);if((t<0?r.index(i):r.indexAfter(i))!=(t<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const o=r.before(i),l=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(l)?o:null}}return null}function fa(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Zi(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});if(!t)return null;let{inside:r,pos:i}=t;return r>=0&&Bt(n.state.doc.resolve(r))||Bt(n.state.doc.resolve(i))}var s0=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${t}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Bs(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,Bs(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Bs(n,e,t,r,i,s){let o=0,l=!0,a=e.firstChild;const c=n.firstChild;if(c){for(let u=0,f=0;unew r(u,t,f)),new l0(-1,!1)},apply(o,l){return l.apply(o)}},props:{attributes:o=>{const l=ke.getState(o);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,l)=>{a0(o,l,n,i)},mouseleave:o=>{c0(o)},mousedown:(o,l)=>{d0(o,l,e,t)}},decorations:o=>{const l=ke.getState(o);if(l&&l.activeHandle>-1)return m0(o,l.activeHandle)},nodeViews:{}}});return s}var l0=class Cr{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,r=e.getMeta(ke);if(r&&r.setHandle!=null)return new Cr(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Cr(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let i=e.mapping.map(t.activeHandle,-1);return zs(e.doc.resolve(i))||(i=-1),new Cr(i,t.dragging)}return t}};function a0(n,e,t,r){if(!n.editable)return;const i=ke.getState(n.state);if(i&&!i.dragging){const s=f0(e.target);let o=-1;if(s){const{left:l,right:a}=s.getBoundingClientRect();e.clientX-l<=t?o=ha(n,e,"left",t):a-e.clientX<=t&&(o=ha(n,e,"right",t))}if(o!=i.activeHandle){if(!r&&o!==-1){const l=n.state.doc.resolve(o),a=l.node(-1),c=G.get(a),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}xu(n,o)}}}function c0(n){if(!n.editable)return;const e=ke.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&xu(n,-1)}function d0(n,e,t,r){var i;if(!n.editable)return!1;const s=(i=n.dom.ownerDocument.defaultView)!==null&&i!==void 0?i:window,o=ke.getState(n.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const l=n.state.doc.nodeAt(o.activeHandle),a=u0(n,o.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(ke,{setDragging:{startX:e.clientX,startWidth:a}}));function c(u){s.removeEventListener("mouseup",c),s.removeEventListener("mousemove",d);const f=ke.getState(n.state);f?.dragging&&(h0(n,f.activeHandle,pa(f.dragging,u,t)),n.dispatch(n.state.tr.setMeta(ke,{setDragging:null})))}function d(u){if(!u.which)return c(u);const f=ke.getState(n.state);if(f&&f.dragging){const h=pa(f.dragging,u,t);ma(n,f.activeHandle,h,r)}}return ma(n,o.activeHandle,a,r),s.addEventListener("mouseup",c),s.addEventListener("mousemove",d),e.preventDefault(),!0}function u0(n,e,{colspan:t,colwidth:r}){const i=r&&r[r.length-1];if(i)return i;const s=n.domAtPos(e);let o=s.node.childNodes[s.offset].offsetWidth,l=t;if(r)for(let a=0;ay0(n),renderHTML:n=>{const e=Un(n.align);return zy(e)?{style:`text-align: ${e}`}:{}}}}function k0(n){var e;const t=n.parentElement,r=n.closest("table");if(!t||!r)return null;const i=Array.from(t.children).indexOf(n),s=(e=r.querySelectorAll("colgroup > col")[i])===null||e===void 0?void 0:e.getAttribute("width");return s?[parseInt(s,10)]:null}function vu(n){const e=n.getAttribute("colwidth");return e?e.split(",").map(t=>parseInt(t,10)):k0(n)}const w0=/[ \t\r\n\f]+/g;function Eu(n){var e;return n.children.length>0?!1:((e=n.textContent)!==null&&e!==void 0?e:"").replace(w0,"")===""}function Mu(n){const e=n.createAndFill();if(!e)throw new Error(`[tiptap error]: "${n.name}" has no default content to backfill.`);return e.content}function Hr(n,e,t){if(!(t in e))return;const r=e[t];(r===1||r==="1"||r===null||r===void 0)&&delete n[t]}const Au=U.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:vu},align:Cu()}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td",getAttrs:n=>Eu(n)?{}:!1,getContent:(n,e)=>Mu(e.nodes[this.name])},{tag:"td"}]},renderHTML({HTMLAttributes:n}){const e=F(this.options.HTMLAttributes,n);return Hr(e,n,"colspan"),Hr(e,n,"rowspan"),["td",e,0]}}),Tu=U.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:vu},align:Cu()}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th",getAttrs:n=>Eu(n)?{}:!1,getContent:(n,e)=>Mu(e.nodes[this.name])},{tag:"th"}]},renderHTML({HTMLAttributes:n}){const e=F(this.options.HTMLAttributes,n);return Hr(e,n,"colspan"),Hr(e,n,"rowspan"),["th",e,0]}}),Nu=U.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",F(this.options.HTMLAttributes,n),0]}});function Hs(n,e){return e?["width",`${Math.max(e,n)}px`]:["min-width",`${n}px`]}function ga(n,e,t,r,i,s){let o=0,l=!0,a=e.firstChild;const c=n.firstChild;if(c!==null)for(let f=0,h=0;f{const r=n.nodes[t];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),n.cached.tableNodeTypes=e,e}function v0(n,e,t,r,i){const s=C0(n),o=[],l=[];for(let c=0;c{const{selection:e}=n.state;if(!Ou(e))return!1;let t=0;const r=Wn(e.ranges[0].$from,i=>i.type.name==="table");return r?.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(t+=1)}),t!==e.ranges.length?!1:(n.commands.deleteTable(),!0)};function ba(n,e){const t=n.mapping.map(e),r=Wn(n.selection.$from,o=>o.type.name==="table");if(r?.pos===t)return;const i=n.doc.nodeAt(t);if(!i)return;const s=t+i.nodeSize-1;n.setSelection(M.near(n.doc.resolve(s),-1))}function E0(n){let e="",t=0;for(;ta==="|"?"\\|":a)+n.slice(i,i+r),t=i+r,s=!0;break}i+=o}s||(e+=n.slice(t,t+r),t+=r)}return e}function M0(n){return n.split(` +`).map(e=>!e.includes("|")||!e.includes("`")?e:E0(e)).join(` +`)}function A0(n){return(n||"").replaceAll(""," ").replace(/\s+/g," ").trim()}function ka(n,e){return e?n.split(e).join(` +`):n}function T0(n){return n.replace(/\\.|\|/g,e=>e==="|"?"\\|":e)}function N0(n,e,t={}){if(!n||!n.content||n.content.length===0)return"";const r=[];n.content.forEach(f=>{const h=[];f.content&&f.content.forEach(p=>{let m="";p.content&&Array.isArray(p.content)&&p.content.length>1?m=p.content.map(k=>ka(e.renderChildren(k),t.cellLineSeparator)).join(` +`):m=ka(p.content?e.renderChildren(p.content):"",t.cellLineSeparator);const g=T0(A0(m.replace(/[ \t]*\r?\n[ \t]*/g,"
"))),y=p.type==="tableHeader",b=b0(p.attrs);h.push({text:g,isHeader:y,align:b})}),r.push(h)});const i=r.reduce((f,h)=>Math.max(f,h.length),0);if(i===0)return"";const s=Array.from({length:i}).fill(0);r.forEach(f=>{for(let p=0;ps[p]&&(s[p]=m),s[p]<3&&(s[p]=3)}});const o=(f,h)=>f+" ".repeat(Math.max(0,h-f.length)),l=r[0],a=l.some(f=>f.isHeader),c=Array.from({length:i}).fill(null);r.forEach(f=>{for(let p=0;pa&&l[h]&&l[h].text||"");return d+=`| ${u.map((f,h)=>o(f,s[h])).join(" | ")} | `,d+=`| ${s.map((f,h)=>{const p=Math.max(3,f),m=c[h];return m==="left"?`:${"-".repeat(p)}`:m==="right"?`${"-".repeat(p)}:`:m==="center"?`:${"-".repeat(p)}:`:"-".repeat(p)}).join(" | ")} | `,(a?r.slice(1):r).forEach(f=>{d+=`| ${Array.from({length:i}).fill(0).map((h,p)=>o(f[p]&&f[p].text||"",s[p])).join(" | ")} | -`}),d}const N0=new W("preserveCellSelectionOnContextMenu");function O0(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});if(t)return t.pos;if(!(e.target instanceof Node))return null;try{return n.posAtDOM(e.target,0)}catch{return null}}function R0(n,e){let t=!1;return n.forEachCell((r,i)=>{e>=i&&e{const t=[],r=Array.isArray(n.align)?n.align:[];if(n.header){const i=[];n.header.forEach((s,o)=>{var l;const a=Un((l=r[o])!==null&&l!==void 0?l:s.align),c=a?{align:a}:{};i.push(e.createNode("tableHeader",c,[{type:"paragraph",content:e.parseInline(s.tokens)}]))}),t.push(e.createNode("tableRow",{},i))}return n.rows&&n.rows.forEach(i=>{const s=[];i.forEach((o,l)=>{var a;const c=Un((a=r[l])!==null&&a!==void 0?a:o.align),d=c?{align:c}:{};s.push(e.createNode("tableCell",d,[{type:"paragraph",content:e.parseInline(o.tokens)}]))}),t.push(e.createNode("tableRow",{},s))}),e.createNode("table",void 0,t)},renderMarkdown:(n,e)=>T0(n,e),markdownTokenizer:{name:"table",level:"block",start:n=>{const e=n.split(` +`}),d}const O0=new W("preserveCellSelectionOnContextMenu");function R0(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});if(t)return t.pos;if(!(e.target instanceof Node))return null;try{return n.posAtDOM(e.target,0)}catch{return null}}function L0(n,e){let t=!1;return n.forEachCell((r,i)=>{e>=i&&e{const t=[],r=Array.isArray(n.align)?n.align:[];if(n.header){const i=[];n.header.forEach((s,o)=>{var l;const a=Un((l=r[o])!==null&&l!==void 0?l:s.align),c=a?{align:a}:{};i.push(e.createNode("tableHeader",c,[{type:"paragraph",content:e.parseInline(s.tokens)}]))}),t.push(e.createNode("tableRow",{},i))}return n.rows&&n.rows.forEach(i=>{const s=[];i.forEach((o,l)=>{var a;const c=Un((a=r[l])!==null&&a!==void 0?a:o.align),d=c?{align:c}:{};s.push(e.createNode("tableCell",d,[{type:"paragraph",content:e.parseInline(o.tokens)}]))}),t.push(e.createNode("tableRow",{},s))}),e.createNode("table",void 0,t)},renderMarkdown:(n,e)=>N0(n,e),markdownTokenizer:{name:"table",level:"block",start:n=>{const e=n.split(` `);if(e.length<2)return-1;const t=e[1];return!/^[ \t|:]*-[ \t|:-]*$/.test(t)||!t.includes("|")?-1:e[0].includes("|")?0:-1},tokenize(n,e,t){const r=n.indexOf(` `),i=r>=0?n.slice(0,r):n,s=i.split(` -`);if(s.length<2)return;const o=s[1];if(!/^[ \t|:]*-[ \t|:-]*$/.test(o)||!o.includes("|"))return;const l=E0(i);if(l===i)return;const a=t.blockTokens(l)[0];if(a?.type!=="table"||!a.raw)return;const c=a.raw.split(` +`);if(s.length<2)return;const o=s[1];if(!/^[ \t|:]*-[ \t|:-]*$/.test(o)||!o.includes("|"))return;const l=M0(i);if(l===i)return;const a=t.blockTokens(l)[0];if(a?.type!=="table"||!a.raw)return;const c=a.raw.split(` `).length,d=n.split(` `).slice(0,c).join(` -`);return{...a,raw:d}}},addCommands(){return{insertTable:({rows:n=3,cols:e=3,withHeaderRow:t=!0}={})=>({tr:r,dispatch:i,editor:s})=>{const o=C0(s.schema,n,e,t);if(i){const l=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(M.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:n,dispatch:e})=>Db(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>Pb(n,e),deleteColumn:()=>({state:n,dispatch:e})=>{const t=Wn(n.selection.$from,r=>r.type.name==="table");return $b(n,e&&(r=>{t&&ba(r,t.pos),e(r)}))},addRowBefore:()=>({state:n,dispatch:e})=>Hb(n,e),addRowAfter:()=>({state:n,dispatch:e})=>Fb(n,e),deleteRow:()=>({state:n,dispatch:e})=>{const t=Wn(n.selection.$from,r=>r.type.name==="table");return Vb(n,e&&(r=>{t&&ba(r,t.pos),e(r)}))},deleteTable:()=>({state:n,dispatch:e})=>Gb(n,e),mergeCells:()=>({state:n,dispatch:e})=>sa(n,e),splitCell:()=>({state:n,dispatch:e})=>oa(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>jn("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>jn("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>qb(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>sa(n,e)?!0:oa(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>Ub(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>aa(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>aa(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&bu(n),!0),setCellSelection:n=>({tr:e,dispatch:t})=>{if(t){const r=_.create(e.doc,n.anchorCell,n.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:dr,"Mod-Backspace":dr,Delete:dr,"Mod-Delete":dr}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[s0({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],m0({allowTableNodeSelection:this.options.allowTableNodeSelection}),L0()]},addNodeView(){const n=this.options.resizable&&this.editor.isEditable,e=this.options.View;return n||!e?null:({node:t,view:r,HTMLAttributes:i})=>{const s=F(this.options.HTMLAttributes,i);return new e(t,this.options.cellMinWidth,r,s)}},extendNodeSchema(n){const e={name:n.name,options:n.options,storage:n.storage};return{tableRole:$(A(n,"tableRole",e))}}});j.create({name:"tableKit",addExtensions(){const n=[];return this.options.table!==!1&&n.push(Ru.configure(this.options.table)),this.options.tableCell!==!1&&n.push(Au.configure(this.options.tableCell)),this.options.tableHeader!==!1&&n.push(Tu.configure(this.options.tableHeader)),this.options.tableRow!==!1&&n.push(Nu.configure(this.options.tableRow)),n}});const Lu=new WeakSet,Iu=new WeakSet;function kt(n){const e=n;return Lu.add(e),e}function Fs(n){return Array.isArray(n)&&Lu.has(n)}function Du(n){return n.flatMap(e=>e==null?[]:Array.isArray(e)&&Iu.has(e)&&!Fs(e)?Du(e):[e])}function I0(n,e){if(n==="slot")return 0;if(n instanceof Function){const i=n(e);return Array.isArray(i)&&!Fs(i)&&!Iu.has(i)?kt(i):i}const{children:t,...r}=e??{};if(n==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");if(Array.isArray(t)){if(Fs(t))return kt([n,r,t]);if(t.length===0)return kt([n,r]);const i=Du(t);return i.length===0?kt([n,r]):kt([n,r,...i])}return t!=null?kt([n,r,t]):kt([n,r])}const Fr=(n,e)=>I0(n,e),D0=(n,e)=>{var t;const{state:r}=n,{selection:i}=r;if(!i.empty)return!1;const{$from:s}=i;if(s.parentOffset!==0)return!1;const o=s.depth-1;if(o<0)return!1;const l=s.node(o),a=s.index(o);if(a===0)return!1;if(l.type===e)return n.commands.lift(e.name);const c=l.child(a-1);if(c.type!==e||!(!((t=c.lastChild)===null||t===void 0)&&t.isTextblock))return!1;const d=s.before()-1-1;return n.commands.command(({tr:u,dispatch:f})=>{if(!f)return!0;const h=s.parent.content,p=new C(h,0,0);return u.replace(d,s.after(),p),u.setSelection(M.create(u.doc,d+h.size)),u.scrollIntoView(),f(u),!0})},P0=/^\s*>\s$/,z0=U.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return Fr("blockquote",{...F(this.options.HTMLAttributes,n),children:Fr("slot",{})})},parseMarkdown:(n,e)=>{var t;const r=(t=e.parseBlockChildren)!==null&&t!==void 0?t:e.parseChildren;return e.createNode("blockquote",void 0,r(n.tokens||[]))},renderMarkdown:(n,e)=>{if(!n.content)return"";const t=">",r=[];return n.content.forEach((i,s)=>{var o,l;const a=((o=(l=e.renderChild)===null||l===void 0?void 0:l.call(e,i,s))!==null&&o!==void 0?o:e.renderChildren([i])).split(` +`);return{...a,raw:d}}},addCommands(){return{insertTable:({rows:n=3,cols:e=3,withHeaderRow:t=!0}={})=>({tr:r,dispatch:i,editor:s})=>{const o=v0(s.schema,n,e,t);if(i){const l=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(M.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:n,dispatch:e})=>Pb(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>zb(n,e),deleteColumn:()=>({state:n,dispatch:e})=>{const t=Wn(n.selection.$from,r=>r.type.name==="table");return Bb(n,e&&(r=>{t&&ba(r,t.pos),e(r)}))},addRowBefore:()=>({state:n,dispatch:e})=>Fb(n,e),addRowAfter:()=>({state:n,dispatch:e})=>_b(n,e),deleteRow:()=>({state:n,dispatch:e})=>{const t=Wn(n.selection.$from,r=>r.type.name==="table");return Wb(n,e&&(r=>{t&&ba(r,t.pos),e(r)}))},deleteTable:()=>({state:n,dispatch:e})=>Yb(n,e),mergeCells:()=>({state:n,dispatch:e})=>sa(n,e),splitCell:()=>({state:n,dispatch:e})=>oa(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>jn("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>jn("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>Jb(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>sa(n,e)?!0:oa(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>Kb(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>aa(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>aa(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&bu(n),!0),setCellSelection:n=>({tr:e,dispatch:t})=>{if(t){const r=_.create(e.doc,n.anchorCell,n.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:dr,"Mod-Backspace":dr,Delete:dr,"Mod-Delete":dr}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[o0({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],g0({allowTableNodeSelection:this.options.allowTableNodeSelection}),I0()]},addNodeView(){const n=this.options.resizable&&this.editor.isEditable,e=this.options.View;return n||!e?null:({node:t,view:r,HTMLAttributes:i})=>{const s=F(this.options.HTMLAttributes,i);return new e(t,this.options.cellMinWidth,r,s)}},extendNodeSchema(n){const e={name:n.name,options:n.options,storage:n.storage};return{tableRole:$(A(n,"tableRole",e))}}});j.create({name:"tableKit",addExtensions(){const n=[];return this.options.table!==!1&&n.push(Ru.configure(this.options.table)),this.options.tableCell!==!1&&n.push(Au.configure(this.options.tableCell)),this.options.tableHeader!==!1&&n.push(Tu.configure(this.options.tableHeader)),this.options.tableRow!==!1&&n.push(Nu.configure(this.options.tableRow)),n}});const Lu=new WeakSet,Iu=new WeakSet;function kt(n){const e=n;return Lu.add(e),e}function Fs(n){return Array.isArray(n)&&Lu.has(n)}function Du(n){return n.flatMap(e=>e==null?[]:Array.isArray(e)&&Iu.has(e)&&!Fs(e)?Du(e):[e])}function D0(n,e){if(n==="slot")return 0;if(n instanceof Function){const i=n(e);return Array.isArray(i)&&!Fs(i)&&!Iu.has(i)?kt(i):i}const{children:t,...r}=e??{};if(n==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");if(Array.isArray(t)){if(Fs(t))return kt([n,r,t]);if(t.length===0)return kt([n,r]);const i=Du(t);return i.length===0?kt([n,r]):kt([n,r,...i])}return t!=null?kt([n,r,t]):kt([n,r])}const Fr=(n,e)=>D0(n,e),P0=(n,e)=>{var t;const{state:r}=n,{selection:i}=r;if(!i.empty)return!1;const{$from:s}=i;if(s.parentOffset!==0)return!1;const o=s.depth-1;if(o<0)return!1;const l=s.node(o),a=s.index(o);if(a===0)return!1;if(l.type===e)return n.commands.lift(e.name);const c=l.child(a-1);if(c.type!==e||!(!((t=c.lastChild)===null||t===void 0)&&t.isTextblock))return!1;const d=s.before()-1-1;return n.commands.command(({tr:u,dispatch:f})=>{if(!f)return!0;const h=s.parent.content,p=new C(h,0,0);return u.replace(d,s.after(),p),u.setSelection(M.create(u.doc,d+h.size)),u.scrollIntoView(),f(u),!0})},z0=/^\s*>\s$/,$0=U.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return Fr("blockquote",{...F(this.options.HTMLAttributes,n),children:Fr("slot",{})})},parseMarkdown:(n,e)=>{var t;const r=(t=e.parseBlockChildren)!==null&&t!==void 0?t:e.parseChildren;return e.createNode("blockquote",void 0,r(n.tokens||[]))},renderMarkdown:(n,e)=>{if(!n.content)return"";const t=">",r=[];return n.content.forEach((i,s)=>{var o,l;const a=((o=(l=e.renderChild)===null||l===void 0?void 0:l.call(e,i,s))!==null&&o!==void 0?o:e.renderChildren([i])).split(` `).map(c=>c.trim()===""?t:`${t} ${c}`);r.push(a.join(` `))}),r.join(` ${t} -`)},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>D0(this.editor,this.type)}},addInputRules(){return[ln({find:P0,type:this.type})]}}),$0=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,B0=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,H0=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,F0=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,_0=bt.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return Fr("strong",{...F(this.options.HTMLAttributes,n),children:Fr("slot",{})})},markdownTokenName:"strong",parseMarkdown:(n,e)=>e.applyMark("bold",e.parseInline(n.tokens||[])),markdownOptions:{htmlReopen:{open:"",close:""}},renderMarkdown:(n,e)=>`**${e.renderChildren(n)}**`,addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[$t({find:$0,type:this.type}),$t({find:H0,type:this.type})]},addPasteRules(){return[pt({find:B0,type:this.type}),pt({find:F0,type:this.type})]}}),V0=n=>{const e=/`([^`]+)`(?!`)$/.exec(n);return!e||e.index>0&&n[e.index-1]==="`"?null:{index:e.index,text:e[0],replaceWith:e[1]}},W0=n=>{const e=/`([^`]+)`(?!`)/g,t=[];let r;for(;(r=e.exec(n))!==null;)r.index>0&&n[r.index-1]==="`"||t.push({index:r.index,text:r[0],replaceWith:r[1]});return t};function j0(n){const e=new Set((n.match(/`+/g)||[]).map(r=>r.length));let t=1;for(;e.has(t);)t+=1;return t}const U0=bt.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",F(this.options.HTMLAttributes,n),0]},markdownTokenName:"codespan",parseMarkdown:(n,e)=>e.applyMark("code",[{type:"text",text:n.text||""}]),renderMarkdown:(n,e,t)=>{var r;if(!n.content)return"";const i=typeof(t==null||(r=t.meta)===null||r===void 0?void 0:r.markText)=="string"?t.meta.markText:"",s="`".repeat(j0(i)),o=i.startsWith("`")||i.endsWith("`")?" ":"";return`${s}${o}${e.renderChildren(n.content)}${o}${s}`},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[$t({find:V0,type:this.type})]},addPasteRules(){return[pt({find:W0,type:this.type})]}}),es=4,K0=/^```([a-z]+)?[\s\n]$/,q0=/^~~~([a-z]+)?[\s\n]$/,J0=U.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:es,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options;if(!t)return null;const r=[...((e=n.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(i=>i.startsWith(t)).map(i=>i.replace(t,""))[0];return r||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",F(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(n,e)=>{var t,r;return((t=n.raw)===null||t===void 0?void 0:t.startsWith("```"))===!1&&((r=n.raw)===null||r===void 0?void 0:r.startsWith("~~~"))===!1&&n.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:n.lang||null},n.text?[e.createTextNode(n.text)]:[])},renderMarkdown:(n,e)=>{var t;let r="";const i=((t=n.attrs)===null||t===void 0?void 0:t.language)||"";return n.content?r=[`\`\`\`${i}`,e.renderChildren(n.content),"```"].join(` +`)},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>P0(this.editor,this.type)}},addInputRules(){return[ln({find:z0,type:this.type})]}}),B0=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,H0=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,F0=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,_0=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,V0=bt.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return Fr("strong",{...F(this.options.HTMLAttributes,n),children:Fr("slot",{})})},markdownTokenName:"strong",parseMarkdown:(n,e)=>e.applyMark("bold",e.parseInline(n.tokens||[])),markdownOptions:{htmlReopen:{open:"",close:""}},renderMarkdown:(n,e)=>`**${e.renderChildren(n)}**`,addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[$t({find:B0,type:this.type}),$t({find:F0,type:this.type})]},addPasteRules(){return[pt({find:H0,type:this.type}),pt({find:_0,type:this.type})]}}),W0=n=>{const e=/`([^`]+)`(?!`)$/.exec(n);return!e||e.index>0&&n[e.index-1]==="`"?null:{index:e.index,text:e[0],replaceWith:e[1]}},j0=n=>{const e=/`([^`]+)`(?!`)/g,t=[];let r;for(;(r=e.exec(n))!==null;)r.index>0&&n[r.index-1]==="`"||t.push({index:r.index,text:r[0],replaceWith:r[1]});return t};function U0(n){const e=new Set((n.match(/`+/g)||[]).map(r=>r.length));let t=1;for(;e.has(t);)t+=1;return t}const K0=bt.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",F(this.options.HTMLAttributes,n),0]},markdownTokenName:"codespan",parseMarkdown:(n,e)=>e.applyMark("code",[{type:"text",text:n.text||""}]),renderMarkdown:(n,e,t)=>{var r;if(!n.content)return"";const i=typeof(t==null||(r=t.meta)===null||r===void 0?void 0:r.markText)=="string"?t.meta.markText:"",s="`".repeat(U0(i)),o=i.startsWith("`")||i.endsWith("`")?" ":"";return`${s}${o}${e.renderChildren(n.content)}${o}${s}`},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[$t({find:W0,type:this.type})]},addPasteRules(){return[pt({find:j0,type:this.type})]}}),es=4,q0=/^```([a-z]+)?[\s\n]$/,J0=/^~~~([a-z]+)?[\s\n]$/,G0=U.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:es,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options;if(!t)return null;const r=[...((e=n.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(i=>i.startsWith(t)).map(i=>i.replace(t,""))[0];return r||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",F(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(n,e)=>{var t,r;return((t=n.raw)===null||t===void 0?void 0:t.startsWith("```"))===!1&&((r=n.raw)===null||r===void 0?void 0:r.startsWith("~~~"))===!1&&n.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:n.lang||null},n.text?[e.createTextNode(n.text)]:[])},renderMarkdown:(n,e)=>{var t;let r="";const i=((t=n.attrs)===null||t===void 0?void 0:t.language)||"";return n.content?r=[`\`\`\`${i}`,e.renderChildren(n.content),"```"].join(` `):r=`\`\`\`${i} \`\`\``,r},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:n})=>{var e;if(!this.options.enableTabIndentation)return!1;const t=(e=this.options.tabSize)!==null&&e!==void 0?e:es,{state:r}=n,{selection:i}=r,{$from:s,empty:o}=i;if(s.parent.type!==this.type)return!1;const l=" ".repeat(t);return o?n.commands.insertContent(l):n.commands.command(({tr:a})=>{const{from:c,to:d}=i,u=r.doc.textBetween(c,d,` @@ -130,26 +130,26 @@ ${t} `).map(u=>{var f;const h=((f=u.match(/^ */))===null||f===void 0?void 0:f[0])||"",p=Math.min(h.length,t);return u.slice(p)}).join(` `);return l.replaceWith(a,c,r.schema.text(d)),!0})},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:i}=t;if(!i||r.parent.type!==this.type)return!1;const s=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(` -`);return!s||!o?!1:n.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowUp:({editor:n})=>{if(!this.options.exitOnArrowUp)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:i}=t;if(!i||r.parent.type!==this.type||r.parentOffset!==0)return!1;const s=r.before();return s>0?!1:n.commands.insertDefaultBlock({pos:s})},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=n,{selection:t,doc:r}=e,{$from:i,empty:s}=t;if(!s||i.parent.type!==this.type||i.parentOffset!==i.parent.nodeSize-2)return!1;const o=i.after();return o===void 0?!1:r.nodeAt(o)?n.commands.command(({tr:l})=>(l.setSelection(O.near(r.resolve(o))),!0)):n.commands.exitCode()}}},addInputRules(){return[Is({find:K0,type:this.type,getAttributes:n=>({language:n[1]})}),Is({find:q0,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new B({key:new W("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const t=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,s=i?.mode;if(!t||!s)return!1;const{tr:o,schema:l}=n.state,a=l.text(t.replace(/\r\n?/g,` -`));return o.replaceSelectionWith(this.type.create({language:s},a)),o.selection.$from.parent.type!==this.type&&o.setSelection(M.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),n.dispatch(o),!0}}})]}}),G0=U.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,` +`);return!s||!o?!1:n.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowUp:({editor:n})=>{if(!this.options.exitOnArrowUp)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:i}=t;if(!i||r.parent.type!==this.type||r.parentOffset!==0)return!1;const s=r.before();return s>0?!1:n.commands.insertDefaultBlock({pos:s})},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=n,{selection:t,doc:r}=e,{$from:i,empty:s}=t;if(!s||i.parent.type!==this.type||i.parentOffset!==i.parent.nodeSize-2)return!1;const o=i.after();return o===void 0?!1:r.nodeAt(o)?n.commands.command(({tr:l})=>(l.setSelection(O.near(r.resolve(o))),!0)):n.commands.exitCode()}}},addInputRules(){return[Is({find:q0,type:this.type,getAttributes:n=>({language:n[1]})}),Is({find:J0,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new B({key:new W("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const t=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,s=i?.mode;if(!t||!s)return!1;const{tr:o,schema:l}=n.state,a=l.text(t.replace(/\r\n?/g,` +`));return o.replaceSelectionWith(this.type.create({language:s},a)),o.selection.$from.parent.type!==this.type&&o.setSelection(M.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),n.dispatch(o),!0}}})]}}),Y0=U.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,` -`):""}),Y0=U.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",F(this.options.HTMLAttributes,n)]},renderText(){return` +`):""}),X0=U.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",F(this.options.HTMLAttributes,n)]},renderText(){return` `},renderMarkdown:()=>` -`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:i,storedMarks:s}=t;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,a=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:d})=>{if(d&&a&&o){const u=a.filter(f=>l.includes(f.type.name));c.ensureMarks(u)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),X0=U.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,F(this.options.HTMLAttributes,e),0]},parseMarkdown:(n,e)=>e.createNode("heading",{level:n.depth||1},e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>{var t;const r=!((t=n.attrs)===null||t===void 0)&&t.level?parseInt(n.attrs.level,10):1,i="#".repeat(r);return n.content?`${i} ${e.renderChildren(n.content)}`:""},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>Is({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),Q0=U.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",F(this.options.HTMLAttributes,n)]},markdownTokenName:"hr",parseMarkdown:(n,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{if(!Ly(e,e.schema.nodes[this.name]))return!1;const{selection:t}=e,{$to:r}=t,i=n();return Yd(t)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:s,tr:o,dispatch:l})=>{if(l){const{$to:a}=o.selection,c=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?o.setSelection(M.create(o.doc,a.pos+1)):a.nodeAfter.isBlock?o.setSelection(T.create(o.doc,a.pos)):o.setSelection(M.create(o.doc,a.pos));else{const d=s.schema.nodes[this.options.nextNodeType]||a.parent.type.contentMatch.defaultType,u=d?.create();u&&(o.insert(c,u),o.setSelection(M.create(o.doc,c+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[cu({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Z0=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,ek=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,tk=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,nk=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,rk=bt.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",F(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(n,e)=>e.applyMark("italic",e.parseInline(n.tokens||[])),markdownOptions:{htmlReopen:{open:"",close:""}},renderMarkdown:(n,e)=>`*${e.renderChildren(n)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[$t({find:Z0,type:this.type}),$t({find:tk,type:this.type})]},addPasteRules(){return[pt({find:ek,type:this.type}),pt({find:nk,type:this.type})]}}),ik="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",sk="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",_s="numeric",Vs="ascii",Ws="alpha",Mn="asciinumeric",kn="alphanumeric",js="domain",Pu="emoji",ok="scheme",lk="slashscheme",ts="whitespace";function ak(n,e){return n in e||(e[n]=[]),e[n]}function Et(n,e,t){e[_s]&&(e[Mn]=!0,e[kn]=!0),e[Vs]&&(e[Mn]=!0,e[Ws]=!0),e[Mn]&&(e[kn]=!0),e[Ws]&&(e[kn]=!0),e[kn]&&(e[js]=!0),e[Pu]&&(e[js]=!0);for(const r in e){const i=ak(r,t);i.indexOf(n)<0&&i.push(n)}}function ck(n,e){const t={};for(const r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function ge(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}ge.groups={};ge.prototype={accepts(){return!!this.t},go(n){const e=this,t=e.j[n];if(t)return t;for(let r=0;rn.ta(e,t,r,i),K=(n,e,t,r,i)=>n.tr(e,t,r,i),wa=(n,e,t,r,i)=>n.ts(e,t,r,i),x=(n,e,t,r,i)=>n.tt(e,t,r,i),We="WORD",Us="UWORD",zu="ASCIINUMERICAL",$u="ALPHANUMERICAL",Kn="LOCALHOST",Ks="TLD",qs="UTLD",vr="SCHEME",Jt="SLASH_SCHEME",Eo="NUM",Js="WS",Mo="NL",An="OPENBRACE",Tn="CLOSEBRACE",_r="OPENBRACKET",Vr="CLOSEBRACKET",Wr="OPENPAREN",jr="CLOSEPAREN",Ur="OPENANGLEBRACKET",Kr="CLOSEANGLEBRACKET",qr="FULLWIDTHLEFTPAREN",Jr="FULLWIDTHRIGHTPAREN",Gr="LEFTCORNERBRACKET",Yr="RIGHTCORNERBRACKET",Xr="LEFTWHITECORNERBRACKET",Qr="RIGHTWHITECORNERBRACKET",Zr="FULLWIDTHLESSTHAN",ei="FULLWIDTHGREATERTHAN",ti="AMPERSAND",ni="APOSTROPHE",ri="ASTERISK",rt="AT",ii="BACKSLASH",si="BACKTICK",oi="CARET",Mt="COLON",Ao="COMMA",li="DOLLAR",Ie="DOT",ai="EQUALS",To="EXCLAMATION",ve="HYPHEN",Nn="PERCENT",ci="PIPE",di="PLUS",ui="POUND",On="QUERY",No="QUOTE",Bu="FULLWIDTHMIDDLEDOT",Oo="SEMI",De="SLASH",Rn="TILDE",fi="UNDERSCORE",Hu="EMOJI",hi="SYM";var Fu=Object.freeze({__proto__:null,ALPHANUMERICAL:$u,AMPERSAND:ti,APOSTROPHE:ni,ASCIINUMERICAL:zu,ASTERISK:ri,AT:rt,BACKSLASH:ii,BACKTICK:si,CARET:oi,CLOSEANGLEBRACKET:Kr,CLOSEBRACE:Tn,CLOSEBRACKET:Vr,CLOSEPAREN:jr,COLON:Mt,COMMA:Ao,DOLLAR:li,DOT:Ie,EMOJI:Hu,EQUALS:ai,EXCLAMATION:To,FULLWIDTHGREATERTHAN:ei,FULLWIDTHLEFTPAREN:qr,FULLWIDTHLESSTHAN:Zr,FULLWIDTHMIDDLEDOT:Bu,FULLWIDTHRIGHTPAREN:Jr,HYPHEN:ve,LEFTCORNERBRACKET:Gr,LEFTWHITECORNERBRACKET:Xr,LOCALHOST:Kn,NL:Mo,NUM:Eo,OPENANGLEBRACKET:Ur,OPENBRACE:An,OPENBRACKET:_r,OPENPAREN:Wr,PERCENT:Nn,PIPE:ci,PLUS:di,POUND:ui,QUERY:On,QUOTE:No,RIGHTCORNERBRACKET:Yr,RIGHTWHITECORNERBRACKET:Qr,SCHEME:vr,SEMI:Oo,SLASH:De,SLASH_SCHEME:Jt,SYM:hi,TILDE:Rn,TLD:Ks,UNDERSCORE:fi,UTLD:qs,UWORD:Us,WORD:We,WS:Js});const He=/[a-z]/,hn=/\p{L}/u,ns=/\p{Emoji}/u,Fe=/\d/,rs=/\s/,Sa="\r",is=` -`,dk="️",uk="‍",ss="";let ur=null,fr=null;function fk(n=[]){const e={};ge.groups=e;const t=new ge;ur==null&&(ur=xa(ik)),fr==null&&(fr=xa(sk)),x(t,"'",ni),x(t,"{",An),x(t,"}",Tn),x(t,"[",_r),x(t,"]",Vr),x(t,"(",Wr),x(t,")",jr),x(t,"<",Ur),x(t,">",Kr),x(t,"(",qr),x(t,")",Jr),x(t,"「",Gr),x(t,"」",Yr),x(t,"『",Xr),x(t,"』",Qr),x(t,"<",Zr),x(t,">",ei),x(t,"&",ti),x(t,"*",ri),x(t,"@",rt),x(t,"`",si),x(t,"^",oi),x(t,":",Mt),x(t,",",Ao),x(t,"$",li),x(t,".",Ie),x(t,"=",ai),x(t,"!",To),x(t,"-",ve),x(t,"%",Nn),x(t,"|",ci),x(t,"+",di),x(t,"#",ui),x(t,"?",On),x(t,'"',No),x(t,"/",De),x(t,";",Oo),x(t,"~",Rn),x(t,"_",fi),x(t,"\\",ii),x(t,"・",Bu);const r=K(t,Fe,Eo,{[_s]:!0});K(r,Fe,r);const i=K(r,He,zu,{[Mn]:!0}),s=K(r,hn,$u,{[kn]:!0}),o=K(t,He,We,{[Vs]:!0});K(o,Fe,i),K(o,He,o),K(i,Fe,i),K(i,He,i);const l=K(t,hn,Us,{[Ws]:!0});K(l,He),K(l,Fe,s),K(l,hn,l),K(s,Fe,s),K(s,He),K(s,hn,s);const a=x(t,is,Mo,{[ts]:!0}),c=x(t,Sa,Js,{[ts]:!0}),d=K(t,rs,Js,{[ts]:!0});x(t,ss,d),x(c,is,a),x(c,ss,d),K(c,rs,d),x(d,Sa),x(d,is),K(d,rs,d),x(d,ss,d);const u=K(t,ns,Hu,{[Pu]:!0});x(u,"#"),K(u,ns,u),x(u,dk,u);const f=x(u,uk);x(f,"#"),K(f,ns,u);const h=[[He,o],[Fe,i]],p=[[He,null],[hn,l],[Fe,s]];for(let m=0;mm[0]>g[0]?1:-1);for(let m=0;m=0?b[js]=!0:He.test(g)?Fe.test(g)?b[Mn]=!0:b[Vs]=!0:b[_s]=!0,wa(t,g,g,b)}return wa(t,"localhost",Kn,{ascii:!0}),t.jd=new ge(hi),{start:t,tokens:Object.assign({groups:e},Fu)}}function _u(n,e){const t=hk(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=t.length,i=[];let s=0,o=0;for(;o=0&&(u+=t[o].length,f++),c+=t[o].length,s+=t[o].length,o++;s-=u,o-=f,c-=u,i.push({t:d.t,v:e.slice(s-c,s),s:s-c,e:s})}return i}function hk(n){const e=[],t=n.length;let r=0;for(;r56319||r+1===t||(s=n.charCodeAt(r+1))<56320||s>57343?n[r]:n.slice(r,r+2);e.push(o),r+=o.length}return e}function Ze(n,e,t,r,i){let s;const o=e.length;for(let l=0;l=0;)s++;if(s>0){e.push(t.join(""));for(let o=parseInt(n.substring(r,r+s),10);o>0;o--)t.pop();r+=s}else t.push(n[r]),r++}return e}const qn={defaultProtocol:"http",events:null,format:Ca,formatHref:Ca,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Ro(n,e=null){let t=Object.assign({},qn);n&&(t=Object.assign(t,n instanceof Ro?n.o:n));const r=t.ignoreTags,i=[];for(let s=0;st?r.substring(0,t)+"…":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n=qn.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){const e=this,t=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",t,this),i=n.get("tagName",t,e),s=this.toFormattedString(n),o={},l=n.get("className",t,e),a=n.get("target",t,e),c=n.get("rel",t,e),d=n.getObj("attributes",t,e),u=n.getObj("events",t,e);return o.href=r,l&&(o.class=l),a&&(o.target=a),c&&(o.rel=c),d&&Object.assign(o,d),{tagName:i,attributes:o,content:s,eventListeners:u}}};function Li(n,e){class t extends Vu{constructor(i,s){super(i,s),this.t=n}}for(const r in e)t.prototype[r]=e[r];return t.t=n,t}const pk=Li("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),va=Li("text"),mk=Li("nl"),hr=Li("url",{isLink:!0,toHref(n=qn.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==Kn&&n[1].t===Mt}}),Ce=n=>new ge(n);function gk({groups:n}){const e=n.domain.concat([ti,ri,rt,ii,si,oi,li,ai,ve,Eo,Nn,ci,di,ui,De,hi,Rn,fi]),t=[ni,Mt,Ao,Ie,To,Nn,On,No,Oo,Ur,Kr,An,Tn,Vr,_r,Wr,jr,qr,Jr,Gr,Yr,Xr,Qr,Zr,ei],r=[ti,ni,ri,ii,si,oi,li,ai,ve,An,Tn,Nn,ci,di,ui,On,De,hi,Rn,fi],i=Ce(),s=x(i,Rn);I(s,r,s),I(s,n.domain,s);const o=Ce(),l=Ce(),a=Ce();I(i,n.domain,o),I(i,n.scheme,l),I(i,n.slashscheme,a),I(o,r,s),I(o,n.domain,o);const c=x(o,rt);x(s,rt,c),x(l,rt,c),x(a,rt,c);const d=x(s,Ie);I(d,r,s),I(d,n.domain,s);const u=Ce();I(c,n.domain,u),I(u,n.domain,u);const f=x(u,Ie);I(f,n.domain,u);const h=Ce(pk);I(f,n.tld,h),I(f,n.utld,h),x(c,Kn,h);const p=x(u,ve);x(p,ve,p),I(p,n.domain,u),I(h,n.domain,u),x(h,Ie,f),x(h,ve,p);const m=x(o,ve),g=x(o,Ie);x(m,ve,m),I(m,n.domain,o),I(g,r,s),I(g,n.domain,o);const y=Ce(hr);I(g,n.tld,y),I(g,n.utld,y),I(y,n.domain,o),I(y,r,s),x(y,Ie,g),x(y,ve,m),x(y,rt,c);const b=x(y,Mt),k=Ce(hr);I(b,n.numeric,k);const S=Ce(hr),v=Ce();I(S,e,S),I(S,t,v),I(v,e,S),I(v,t,v),x(y,De,S),x(k,De,S);const L=x(l,Mt),E=x(a,Mt),R=x(E,De),D=x(R,De);I(l,n.domain,o),x(l,Ie,g),x(l,ve,m),I(a,n.domain,o),x(a,Ie,g),x(a,ve,m),I(L,n.domain,S),x(L,De,S),x(L,On,S),I(D,n.domain,S),I(D,e,S),x(D,De,S);const P=[[An,Tn],[_r,Vr],[Wr,jr],[Ur,Kr],[qr,Jr],[Gr,Yr],[Xr,Qr],[Zr,ei]];for(let Y=0;Y=0&&f++,i++,d++;if(f<0)i-=d,i0&&(s.push(ls(va,e,o)),o=[]),i-=f,d-=f;const h=u.t,p=t.slice(i-d,i);s.push(ls(h,e,p))}}return o.length>0&&s.push(ls(va,e,o)),s}function ls(n,e,t){const r=t[0].s,i=t[t.length-1].e,s=e.slice(r,i);return new n(s,t)}const bk=typeof console<"u"&&console&&console.warn||(()=>{}),kk="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",V={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function wk(){return ge.groups={},V.scanner=null,V.parser=null,V.tokenQueue=[],V.pluginQueue=[],V.customSchemes=[],V.initialized=!1,V}function Ea(n,e=!1){if(V.initialized&&bk(`linkifyjs: already initialized - will not register custom scheme "${n}" ${kk}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format. +`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:i,storedMarks:s}=t;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,a=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:d})=>{if(d&&a&&o){const u=a.filter(f=>l.includes(f.type.name));c.ensureMarks(u)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Q0=U.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,F(this.options.HTMLAttributes,e),0]},parseMarkdown:(n,e)=>e.createNode("heading",{level:n.depth||1},e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>{var t;const r=!((t=n.attrs)===null||t===void 0)&&t.level?parseInt(n.attrs.level,10):1,i="#".repeat(r);return n.content?`${i} ${e.renderChildren(n.content)}`:""},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>Is({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),Z0=U.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",F(this.options.HTMLAttributes,n)]},markdownTokenName:"hr",parseMarkdown:(n,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{if(!Ly(e,e.schema.nodes[this.name]))return!1;const{selection:t}=e,{$to:r}=t,i=n();return Yd(t)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:s,tr:o,dispatch:l})=>{if(l){const{$to:a}=o.selection,c=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?o.setSelection(M.create(o.doc,a.pos+1)):a.nodeAfter.isBlock?o.setSelection(T.create(o.doc,a.pos)):o.setSelection(M.create(o.doc,a.pos));else{const d=s.schema.nodes[this.options.nextNodeType]||a.parent.type.contentMatch.defaultType,u=d?.create();u&&(o.insert(c,u),o.setSelection(M.create(o.doc,c+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[cu({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),ek=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,tk=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,nk=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,rk=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,ik=bt.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",F(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(n,e)=>e.applyMark("italic",e.parseInline(n.tokens||[])),markdownOptions:{htmlReopen:{open:"",close:""}},renderMarkdown:(n,e)=>`*${e.renderChildren(n)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[$t({find:ek,type:this.type}),$t({find:nk,type:this.type})]},addPasteRules(){return[pt({find:tk,type:this.type}),pt({find:rk,type:this.type})]}}),sk="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",ok="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",_s="numeric",Vs="ascii",Ws="alpha",Mn="asciinumeric",kn="alphanumeric",js="domain",Pu="emoji",lk="scheme",ak="slashscheme",ts="whitespace";function ck(n,e){return n in e||(e[n]=[]),e[n]}function Et(n,e,t){e[_s]&&(e[Mn]=!0,e[kn]=!0),e[Vs]&&(e[Mn]=!0,e[Ws]=!0),e[Mn]&&(e[kn]=!0),e[Ws]&&(e[kn]=!0),e[kn]&&(e[js]=!0),e[Pu]&&(e[js]=!0);for(const r in e){const i=ck(r,t);i.indexOf(n)<0&&i.push(n)}}function dk(n,e){const t={};for(const r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function ge(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}ge.groups={};ge.prototype={accepts(){return!!this.t},go(n){const e=this,t=e.j[n];if(t)return t;for(let r=0;rn.ta(e,t,r,i),K=(n,e,t,r,i)=>n.tr(e,t,r,i),wa=(n,e,t,r,i)=>n.ts(e,t,r,i),x=(n,e,t,r,i)=>n.tt(e,t,r,i),We="WORD",Us="UWORD",zu="ASCIINUMERICAL",$u="ALPHANUMERICAL",Kn="LOCALHOST",Ks="TLD",qs="UTLD",vr="SCHEME",Jt="SLASH_SCHEME",Eo="NUM",Js="WS",Mo="NL",An="OPENBRACE",Tn="CLOSEBRACE",_r="OPENBRACKET",Vr="CLOSEBRACKET",Wr="OPENPAREN",jr="CLOSEPAREN",Ur="OPENANGLEBRACKET",Kr="CLOSEANGLEBRACKET",qr="FULLWIDTHLEFTPAREN",Jr="FULLWIDTHRIGHTPAREN",Gr="LEFTCORNERBRACKET",Yr="RIGHTCORNERBRACKET",Xr="LEFTWHITECORNERBRACKET",Qr="RIGHTWHITECORNERBRACKET",Zr="FULLWIDTHLESSTHAN",ei="FULLWIDTHGREATERTHAN",ti="AMPERSAND",ni="APOSTROPHE",ri="ASTERISK",rt="AT",ii="BACKSLASH",si="BACKTICK",oi="CARET",Mt="COLON",Ao="COMMA",li="DOLLAR",Ie="DOT",ai="EQUALS",To="EXCLAMATION",ve="HYPHEN",Nn="PERCENT",ci="PIPE",di="PLUS",ui="POUND",On="QUERY",No="QUOTE",Bu="FULLWIDTHMIDDLEDOT",Oo="SEMI",De="SLASH",Rn="TILDE",fi="UNDERSCORE",Hu="EMOJI",hi="SYM";var Fu=Object.freeze({__proto__:null,ALPHANUMERICAL:$u,AMPERSAND:ti,APOSTROPHE:ni,ASCIINUMERICAL:zu,ASTERISK:ri,AT:rt,BACKSLASH:ii,BACKTICK:si,CARET:oi,CLOSEANGLEBRACKET:Kr,CLOSEBRACE:Tn,CLOSEBRACKET:Vr,CLOSEPAREN:jr,COLON:Mt,COMMA:Ao,DOLLAR:li,DOT:Ie,EMOJI:Hu,EQUALS:ai,EXCLAMATION:To,FULLWIDTHGREATERTHAN:ei,FULLWIDTHLEFTPAREN:qr,FULLWIDTHLESSTHAN:Zr,FULLWIDTHMIDDLEDOT:Bu,FULLWIDTHRIGHTPAREN:Jr,HYPHEN:ve,LEFTCORNERBRACKET:Gr,LEFTWHITECORNERBRACKET:Xr,LOCALHOST:Kn,NL:Mo,NUM:Eo,OPENANGLEBRACKET:Ur,OPENBRACE:An,OPENBRACKET:_r,OPENPAREN:Wr,PERCENT:Nn,PIPE:ci,PLUS:di,POUND:ui,QUERY:On,QUOTE:No,RIGHTCORNERBRACKET:Yr,RIGHTWHITECORNERBRACKET:Qr,SCHEME:vr,SEMI:Oo,SLASH:De,SLASH_SCHEME:Jt,SYM:hi,TILDE:Rn,TLD:Ks,UNDERSCORE:fi,UTLD:qs,UWORD:Us,WORD:We,WS:Js});const He=/[a-z]/,hn=/\p{L}/u,ns=/\p{Emoji}/u,Fe=/\d/,rs=/\s/,Sa="\r",is=` +`,uk="️",fk="‍",ss="";let ur=null,fr=null;function hk(n=[]){const e={};ge.groups=e;const t=new ge;ur==null&&(ur=xa(sk)),fr==null&&(fr=xa(ok)),x(t,"'",ni),x(t,"{",An),x(t,"}",Tn),x(t,"[",_r),x(t,"]",Vr),x(t,"(",Wr),x(t,")",jr),x(t,"<",Ur),x(t,">",Kr),x(t,"(",qr),x(t,")",Jr),x(t,"「",Gr),x(t,"」",Yr),x(t,"『",Xr),x(t,"』",Qr),x(t,"<",Zr),x(t,">",ei),x(t,"&",ti),x(t,"*",ri),x(t,"@",rt),x(t,"`",si),x(t,"^",oi),x(t,":",Mt),x(t,",",Ao),x(t,"$",li),x(t,".",Ie),x(t,"=",ai),x(t,"!",To),x(t,"-",ve),x(t,"%",Nn),x(t,"|",ci),x(t,"+",di),x(t,"#",ui),x(t,"?",On),x(t,'"',No),x(t,"/",De),x(t,";",Oo),x(t,"~",Rn),x(t,"_",fi),x(t,"\\",ii),x(t,"・",Bu);const r=K(t,Fe,Eo,{[_s]:!0});K(r,Fe,r);const i=K(r,He,zu,{[Mn]:!0}),s=K(r,hn,$u,{[kn]:!0}),o=K(t,He,We,{[Vs]:!0});K(o,Fe,i),K(o,He,o),K(i,Fe,i),K(i,He,i);const l=K(t,hn,Us,{[Ws]:!0});K(l,He),K(l,Fe,s),K(l,hn,l),K(s,Fe,s),K(s,He),K(s,hn,s);const a=x(t,is,Mo,{[ts]:!0}),c=x(t,Sa,Js,{[ts]:!0}),d=K(t,rs,Js,{[ts]:!0});x(t,ss,d),x(c,is,a),x(c,ss,d),K(c,rs,d),x(d,Sa),x(d,is),K(d,rs,d),x(d,ss,d);const u=K(t,ns,Hu,{[Pu]:!0});x(u,"#"),K(u,ns,u),x(u,uk,u);const f=x(u,fk);x(f,"#"),K(f,ns,u);const h=[[He,o],[Fe,i]],p=[[He,null],[hn,l],[Fe,s]];for(let m=0;mm[0]>g[0]?1:-1);for(let m=0;m=0?b[js]=!0:He.test(g)?Fe.test(g)?b[Mn]=!0:b[Vs]=!0:b[_s]=!0,wa(t,g,g,b)}return wa(t,"localhost",Kn,{ascii:!0}),t.jd=new ge(hi),{start:t,tokens:Object.assign({groups:e},Fu)}}function _u(n,e){const t=pk(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=t.length,i=[];let s=0,o=0;for(;o=0&&(u+=t[o].length,f++),c+=t[o].length,s+=t[o].length,o++;s-=u,o-=f,c-=u,i.push({t:d.t,v:e.slice(s-c,s),s:s-c,e:s})}return i}function pk(n){const e=[],t=n.length;let r=0;for(;r56319||r+1===t||(s=n.charCodeAt(r+1))<56320||s>57343?n[r]:n.slice(r,r+2);e.push(o),r+=o.length}return e}function Ze(n,e,t,r,i){let s;const o=e.length;for(let l=0;l=0;)s++;if(s>0){e.push(t.join(""));for(let o=parseInt(n.substring(r,r+s),10);o>0;o--)t.pop();r+=s}else t.push(n[r]),r++}return e}const qn={defaultProtocol:"http",events:null,format:Ca,formatHref:Ca,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Ro(n,e=null){let t=Object.assign({},qn);n&&(t=Object.assign(t,n instanceof Ro?n.o:n));const r=t.ignoreTags,i=[];for(let s=0;st?r.substring(0,t)+"…":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n=qn.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){const e=this,t=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",t,this),i=n.get("tagName",t,e),s=this.toFormattedString(n),o={},l=n.get("className",t,e),a=n.get("target",t,e),c=n.get("rel",t,e),d=n.getObj("attributes",t,e),u=n.getObj("events",t,e);return o.href=r,l&&(o.class=l),a&&(o.target=a),c&&(o.rel=c),d&&Object.assign(o,d),{tagName:i,attributes:o,content:s,eventListeners:u}}};function Li(n,e){class t extends Vu{constructor(i,s){super(i,s),this.t=n}}for(const r in e)t.prototype[r]=e[r];return t.t=n,t}const mk=Li("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),va=Li("text"),gk=Li("nl"),hr=Li("url",{isLink:!0,toHref(n=qn.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==Kn&&n[1].t===Mt}}),Ce=n=>new ge(n);function yk({groups:n}){const e=n.domain.concat([ti,ri,rt,ii,si,oi,li,ai,ve,Eo,Nn,ci,di,ui,De,hi,Rn,fi]),t=[ni,Mt,Ao,Ie,To,Nn,On,No,Oo,Ur,Kr,An,Tn,Vr,_r,Wr,jr,qr,Jr,Gr,Yr,Xr,Qr,Zr,ei],r=[ti,ni,ri,ii,si,oi,li,ai,ve,An,Tn,Nn,ci,di,ui,On,De,hi,Rn,fi],i=Ce(),s=x(i,Rn);I(s,r,s),I(s,n.domain,s);const o=Ce(),l=Ce(),a=Ce();I(i,n.domain,o),I(i,n.scheme,l),I(i,n.slashscheme,a),I(o,r,s),I(o,n.domain,o);const c=x(o,rt);x(s,rt,c),x(l,rt,c),x(a,rt,c);const d=x(s,Ie);I(d,r,s),I(d,n.domain,s);const u=Ce();I(c,n.domain,u),I(u,n.domain,u);const f=x(u,Ie);I(f,n.domain,u);const h=Ce(mk);I(f,n.tld,h),I(f,n.utld,h),x(c,Kn,h);const p=x(u,ve);x(p,ve,p),I(p,n.domain,u),I(h,n.domain,u),x(h,Ie,f),x(h,ve,p);const m=x(o,ve),g=x(o,Ie);x(m,ve,m),I(m,n.domain,o),I(g,r,s),I(g,n.domain,o);const y=Ce(hr);I(g,n.tld,y),I(g,n.utld,y),I(y,n.domain,o),I(y,r,s),x(y,Ie,g),x(y,ve,m),x(y,rt,c);const b=x(y,Mt),k=Ce(hr);I(b,n.numeric,k);const S=Ce(hr),v=Ce();I(S,e,S),I(S,t,v),I(v,e,S),I(v,t,v),x(y,De,S),x(k,De,S);const L=x(l,Mt),E=x(a,Mt),R=x(E,De),D=x(R,De);I(l,n.domain,o),x(l,Ie,g),x(l,ve,m),I(a,n.domain,o),x(a,Ie,g),x(a,ve,m),I(L,n.domain,S),x(L,De,S),x(L,On,S),I(D,n.domain,S),I(D,e,S),x(D,De,S);const P=[[An,Tn],[_r,Vr],[Wr,jr],[Ur,Kr],[qr,Jr],[Gr,Yr],[Xr,Qr],[Zr,ei]];for(let Y=0;Y=0&&f++,i++,d++;if(f<0)i-=d,i0&&(s.push(ls(va,e,o)),o=[]),i-=f,d-=f;const h=u.t,p=t.slice(i-d,i);s.push(ls(h,e,p))}}return o.length>0&&s.push(ls(va,e,o)),s}function ls(n,e,t){const r=t[0].s,i=t[t.length-1].e,s=e.slice(r,i);return new n(s,t)}const kk=typeof console<"u"&&console&&console.warn||(()=>{}),wk="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",V={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Sk(){return ge.groups={},V.scanner=null,V.parser=null,V.tokenQueue=[],V.pluginQueue=[],V.customSchemes=[],V.initialized=!1,V}function Ea(n,e=!1){if(V.initialized&&kk(`linkifyjs: already initialized - will not register custom scheme "${n}" ${wk}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format. 1. Must only contain digits, lowercase ASCII letters or "-" 2. Cannot start or end with "-" -3. "-" cannot repeat`);V.customSchemes.push([n,e])}function Sk(){V.scanner=fk(V.customSchemes);for(let n=0;nu.mark.type===t);if(!a.length)return;const{nodeAfter:c}=s;if(c&&a.some(u=>u.mark.isInSet(c.marks)))return;const d=n.storedMarks;n.removeMark(l,e.to,t),n.setStoredMarks(d),n.selection.empty&&n.selection.from===e.to&&n.removeStoredMark(t)}function Ak(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function Tk(n){return new B({key:new W("autolink"),appendTransaction:(e,t,r)=>{const i=e.some(a=>a.docChanged)&&!t.doc.eq(r.doc),s=e.some(a=>a.getMeta("preventAutolink"));if(!i||s)return;const{tr:o}=r,l=jd(t.doc,[...e]);if(!e.some(Bm)){const a=[];l.steps.forEach((c,d)=>{if(!(c instanceof q)||!c.slice.size)return;const u=l.mapping.slice(d+1),f=u.map(c.from,1),h=u.map(c.from+c.slice.size,-1);fd.to-c.to),a.forEach(c=>Mk(o,c,n.type))}if(Ti(l).forEach(({newRange:a})=>{const c=Og(r.doc,a,f=>f.isTextblock);let d,u;if(c.length>1)d=c[0],u=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ");else if(c.length){const f=r.doc.textBetween(a.from,a.to," "," ");if(!Ck.test(f))return;d=c[0],u=r.doc.textBetween(d.pos,a.to,void 0," ")}if(d&&u){const f=u.split(xk).filter(Boolean);if(f.length<=0)return!1;const h=f[f.length-1],p=d.pos+u.lastIndexOf(h);if(!h)return!1;const m=Lo(h).map(g=>g.toObject(n.defaultProtocol));if(!Ak(m))return!1;m.filter(g=>g.isLink).map(g=>({...g,from:p+g.start+1,to:p+g.end+1})).filter(g=>r.schema.marks.code?!r.doc.rangeHasMark(g.from,g.to,r.schema.marks.code):!0).filter(g=>n.validate(g.value)).filter(g=>n.shouldAutoLink(g.value)).forEach(g=>{Ni(g.from,g.to,r.doc).some(y=>y.mark.type===n.type)||o.addMark(g.from,g.to,n.type.create({href:g.href}))})}}),!!o.steps.length)return o}})}function Nk(n){return new B({key:new W("handleClickLink"),props:{handleClick:(e,t,r)=>{if(r.button!==0||!e.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{const a=r.target;if(!a)return!1;const c=n.editor.view.dom;i=a.closest("a"),i&&!c.contains(i)&&(i=null)}if(!i)return!1;let s=!1;if(n.enableClickSelection&&(s=n.editor.commands.extendMarkRange(n.type.name)),n.openOnClick){var o,l;const a=Gd(e.state,n.type.name),c=(o=i.href)!==null&&o!==void 0?o:a.href,d=(l=i.target)!==null&&l!==void 0?l:a.target;c&&(window.open(c,d),s=!0)}return s}}})}const Ok=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,Rk=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function ju(n,e){let t=0;for(let r=e-1;r>=0&&n[r]==="\\";r-=1)t+=1;return t%2===1}function Lk(n,e){let t=0,r=0;for(;r0}function Uu(n,e,t){var r,i;const[,s,o]=e;return(e.index?n[e.index-1]:void 0)==="!"||ju(n,(r=e.index)!==null&&r!==void 0?r:0)||Lk(n,(i=e.index)!==null&&i!==void 0?i:0)?!1:!!s.trim()&&t(o)}function Ku(n){var e,t;const[r,i,s,,o,l,a]=n,c=(e=o??l)!==null&&e!==void 0?e:a;return{index:(t=n.index)!==null&&t!==void 0?t:0,text:r,replaceWith:i,data:{href:s,title:c||null,markdown:!0}}}function Ik(n,e){return n.index{const r=Ok.exec(t);return!r||!Uu(t,r,n.isAllowedHref)?null:Ku(r)},type:n.type,getAttributes:qu});return new er({find:e.find,handler:t=>{const r=e.handler(t);return r!==null&&t.state.tr.steps.length&&t.state.tr.setMeta("preventAutolink",!0),r}})}function Pk(n){const e=pt({find:t=>{var r,i;const s=[];for(const l of t.matchAll(Rk))Uu(t,l,n.isAllowedHref)&&s.push(Ku(l));const o=((r=(i=n.findPlainUrls)===null||i===void 0?void 0:i.call(n,t))!==null&&r!==void 0?r:[]).filter(l=>!s.some(a=>Ik(a,l)));return[...s,...o]},type:n.type,getAttributes:qu});return new lu({find:e.find,handler:t=>{var r;const i=e.handler(t);return i!==null&&t.state.tr.steps.length&&(!((r=t.match.data)===null||r===void 0)&&r.markdown)&&t.state.tr.setMeta("preventAutolink",!0),i}})}function zk(n){return new B({key:new W("handlePasteLink"),props:{handlePaste:(e,t,r)=>{const{shouldAutoLink:i}=n,{state:s}=e,{selection:o}=s,{empty:l}=o;if(l)return!1;let a="";r.content.forEach(d=>{a+=d.textContent});const c=Wu(a,{defaultProtocol:n.defaultProtocol}).find(d=>d.isLink&&d.value===a);return!a||!c||i!==void 0&&!i(c.value)?!1:n.editor.commands.setMark(n.type,{href:c.href})}}})}function _e(n,e){const t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const i=typeof r=="string"?r:r.scheme;i&&t.push(i)}),!n||n.replace(Ek,"").match(new RegExp(`^(?:(?:${t.map(r=>r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,"i"))}const $k=bt.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(n=>{if(typeof n=="string"){Ea(n);return}Ea(n.scheme,n.optionalSlashes)})},onDestroy(){wk()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(n,e)=>!!_e(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(n),t=/^[a-z][a-z0-9+.-]*:/i.test(n);if(e||t&&!n.includes("@"))return!0;const r=(n.includes("@")?n.split("@").pop():n).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){var n,e,t;return{href:{default:null,parseHTML(r){return r.getAttribute("href")}},target:{default:(n=this.options.HTMLAttributes.target)!==null&&n!==void 0?n:null},rel:{default:(e=this.options.HTMLAttributes.rel)!==null&&e!==void 0?e:null},class:{default:(t=this.options.HTMLAttributes.class)!==null&&t!==void 0?t:null},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{const e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!_e(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!_e(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",F(this.options.HTMLAttributes,n),0]:["a",F(this.options.HTMLAttributes,{...n,href:""}),0]},markdownTokenName:"link",parseMarkdown:(n,e)=>e.applyMark("link",e.parseInline(n.tokens||[]),{href:n.href,title:n.title||null}),renderMarkdown:(n,e)=>{var t,r,i,s;const o=(t=(r=n.attrs)===null||r===void 0?void 0:r.href)!==null&&t!==void 0?t:"",l=(i=(s=n.attrs)===null||s===void 0?void 0:s.title)!==null&&i!==void 0?i:"",a=e.renderChildren(n);return l?`[${a}](${o} "${l}")`:`[${a}](${o})`},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!_e(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{const{href:t}=n||{};return t&&!this.options.isAllowedUri(t,{defaultValidate:r=>!!_e(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addInputRules(){return this.options.markdownLinks?[Dk({type:this.type,isAllowedHref:n=>this.options.isAllowedUri(n,{defaultValidate:e=>!!_e(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){const n=e=>{const t=[];if(e){const{protocols:r,defaultProtocol:i}=this.options;Wu(e).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:o=>!!_e(o,r),protocols:r,defaultProtocol:i})).forEach(s=>{this.options.shouldAutoLink(s.value)&&t.push({text:s.value,data:{href:s.href},index:s.start})})}return t};return this.options.markdownLinks?[Pk({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:t=>!!_e(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:n})]:[pt({find:n,type:this.type,getAttributes:e=>{var t;return{href:(t=e.data)===null||t===void 0?void 0:t.href}}})]},addProseMirrorPlugins(){const n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(Tk({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!_e(i,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),n.push(Nk({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&n.push(zk({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),n}}),Bk="listItem",Ma="textStyle",Aa=/^\s*([-+*])\s$/,Ju=U.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",F(this.options.HTMLAttributes,n),0]},markdownTokenName:"list",parseMarkdown:(n,e)=>n.type!=="list"||n.ordered?[]:{type:"bulletList",content:n.items?e.parseChildren(n.items):[]},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,` -`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Bk,this.editor.getAttributes(Ma)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=ln({find:Aa,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=ln({find:Aa,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Ma),editor:this.editor})),[n]}}),Hk=(n,e,t)=>{const{selection:r}=n;if(!r.empty)return null;const{$from:i}=r;if(!i.parent.isTextblock||i.parentOffset!==i.parent.content.size)return null;let s=-1;for(let h=i.depth;h>0;h-=1)if(i.node(h).type.name===e){s=h;break}if(s<0)return null;const o=i.node(s),l=i.index(s);if(l+1>=o.childCount)return null;const a=o.child(l+1);if(!t.includes(a.type.name))return null;const c=n.schema.nodes[e];let d=!1;if(a.forEach(h=>{h.type===c&&h.childCount>1&&(d=!0)}),!d)return null;const u=n.doc.resolve(i.after()).nodeAfter;if(!u||!t.includes(u.type.name))return null;const f=[];return u.forEach(h=>{f.push(h)}),f.length===0?null:{listItemDepth:s,nestedList:u,nestedListPos:i.after(),insertPos:i.after(s),items:f}},Fk=(n,e,t,r)=>{const i=Hk(n,t,r);if(!i)return!1;const{selection:s}=n,{nestedList:o,nestedListPos:l,insertPos:a,items:c}=i,d=n.tr;d.delete(l,l+o.nodeSize);const u=d.mapping.map(a);return d.insert(u,w.from(c)),d.setSelection(s.map(d.doc,d.mapping)),e&&e(d),!0},_k=(n,e,t)=>Fk(n.state,n.view.dispatch,e,t),Gu=(n,e)=>j.create({name:`${n}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){const t=()=>_k(this.editor,n,e);return{Delete:t,"Mod-Delete":t}}}),Yu=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],pr="abcdefghijklmnopqrstuvwxyz",Xu=String.raw`\d+|[ivxlcdmIVXLCDM]+|${"[a-zA-Z]{1,2}"}`;function Di(n){let e=n,t="";for(const[r,i]of Yu)for(;e>=r;)t+=i,e-=r;return t}function Io(n){return Di(n).toUpperCase()}function Qu(n){const e=n.toLowerCase();let t=0,r=0;for(;t0?r:1}const t=parseInt(n,10);return Number.isNaN(t)?1:t}function jk(n,e){if(n==="numeric")return String(e);switch(n){case"a":return pi(e);case"A":return pi(e).toUpperCase();case"i":return Di(e);case"I":return Io(e);default:return String(e)}}function Uk(n){var e;if(n.length===0)return!1;const t=(e=Pi(n[0]))!==null&&e!==void 0?e:"numeric",r=Do(n[0]);if(r<1)return!1;for(let i=0;i{var t;if(n.type!=="list_item")return[];const r=(t=e.parseBlockChildren)!==null&&t!==void 0?t:e.parseChildren;let i=[];if(n.tokens&&n.tokens.length>0){if(Gk(n))return{type:"listItem",content:[{type:"paragraph",content:Yk(n.text||"",e)}]};if(n.tokens.some(s=>s.type==="paragraph"))i=r(n.tokens);else{const s=n.tokens[0];if(s&&s.type==="text"&&s.tokens&&s.tokens.length>0){if(i=[{type:"paragraph",content:e.parseInline(s.tokens)}],n.tokens.length>1){const o=r(n.tokens.slice(1));i.push(...o)}}else i=r(n.tokens)}}return i.length===0&&(i=[{type:"paragraph",content:[]}]),{type:"listItem",content:i}},renderMarkdown:(n,e,t)=>iu(n,e,r=>{if(r.parentType==="bulletList")return"- ";if(r.parentType==="orderedList"){var i,s;const o=((i=r.meta)===null||i===void 0||(i=i.parentAttrs)===null||i===void 0?void 0:i.start)||1;return Jk((s=r.meta)===null||s===void 0||(s=s.parentAttrs)===null||s===void 0?void 0:s.type,o-1+(r.index||0),". ")}return"- "},t,{alignNestedToPrefix:t?.parentType==="orderedList"}),addExtensions(){return[Gu(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Po=(n,e)=>{const{$from:t}=e.selection,r=ee(n,e.schema);let i=null,s=t.depth,o=t.pos,l=null;for(;s>0&&l===null;)i=t.node(s),i.type===r?l=s:(s-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},ef=(n,e)=>{const t=Po(n,e);if(!t)return!1;const[,r]=Fg(e,n,t.$pos.pos+4);return r},Xk=(n,e,t)=>{const{$anchor:r}=n.selection,i=Math.max(0,r.pos-2),s=n.doc.resolve(i).node();return!(!s||!t.includes(s.type.name))},Ta=(n,e,t)=>{if(n.commands.undoInputRule())return!0;if(n.state.selection.from!==n.state.selection.to)return!1;if(!Xe(n.state,e)&&Xk(n.state,e,t)){const{$anchor:s}=n.state.selection,o=n.state.doc.resolve(s.before()-1),l=[];o.node().descendants((d,u)=>{d.type.name===e&&l.push({node:d,pos:u})});const a=l.at(-1);if(!a)return!1;const c=n.state.doc.resolve(o.start()+a.pos+1);return n.chain().cut({from:s.start()-1,to:s.end()+1},c.end()).joinForward().run()}if(!Xe(n.state,e)||!Ug(n.state))return!1;const{$from:r}=n.state.selection,i=r.depth-1;return r.node(i).type!==n.schema.nodes[e]||r.index(i)!==0?!1:n.chain().liftListItem(e).run()},Qk=(n,e)=>{const t=ef(n,e),r=Po(n,e);return!r||!t?!1:t>r.depth},Zk=(n,e)=>{const t=ef(n,e),r=Po(n,e);return!r||!t?!1:t{if(!Xe(n.state,e)||!jg(n.state,e))return!1;const{selection:t}=n.state,{$from:r,$to:i}=t;return!t.empty&&r.sameParent(i)?!1:Qk(e,n.state)?n.chain().focus(n.state.selection.from+4).lift(e).joinBackward().run():Zk(e,n.state)?n.chain().joinForward().joinBackward().run():n.commands.joinItemForward()},ew=(n,e,t)=>{const{state:r}=n,{selection:i}=r;if(!i.empty)return!1;const{$from:s}=i;if(s.parentOffset!==0||!s.parent.isTextblock||Xe(r,e))return!1;const o=_g(s);if(!o||!t.includes(o.type.name))return!1;const l=o.lastChild;if(!l||l.type.name!==e)return!1;const a=s.parent;if(!l.canReplace(l.childCount,l.childCount,w.from(a)))return!1;const c=s.before(),d=s.after(),u=c-2;return n.commands.command(({tr:f,dispatch:h})=>(h&&(f.delete(c,d).insert(u,w.from(a)),f.setSelection(M.create(f.doc,u+1)),f.scrollIntoView()),!0))},tf=j.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&Na(n,t)&&(e=!0)}),e},"Mod-Delete":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&Na(n,t)&&(e=!0)}),e},Backspace:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&Ta(n,t,r)&&(e=!0)}),e},"Mod-Backspace":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&Ta(n,t,r)&&(e=!0)}),e},Tab:({editor:n})=>{for(const{itemName:e,wrapperNames:t}of this.options.listTypes)if(n.state.schema.nodes[e]!==void 0&&ew(n,e,t))return!0;return!1}}}}),mi=new RegExp(`^(\\s*)(${Xu})([.)])\\s+(.*)$`),tw=/^\s/,Gt={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function nw(n){return mi.test(n.trimStart())}function rw(n){const e=n.trimStart();return Gt.bulletItem.test(e)||nw(e)||Gt.heading.test(e)||Gt.thematicBreak.test(e)&&!e.startsWith("-")||/^>\s?/.test(e)||Gt.codeFence.test(e)||Gt.blockMath.test(e)}function iw(n){return Object.values(Gt).some(e=>e.test(n))}function sw(n){const e=[],t=[];let r=!1;return n.forEach(i=>{if(r){t.push(i);return}if(i.trim()===""){r=!0,t.push(i);return}if(e.length>0&&rw(i)){r=!0,t.push(i);return}e.push(i)}),{paragraphLines:e,blockLines:t}}function Oa(n){const e=[];let t=0,r=0;for(;tu.mark.type===t);if(!a.length)return;const{nodeAfter:c}=s;if(c&&a.some(u=>u.mark.isInSet(c.marks)))return;const d=n.storedMarks;n.removeMark(l,e.to,t),n.setStoredMarks(d),n.selection.empty&&n.selection.from===e.to&&n.removeStoredMark(t)}function Tk(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function Nk(n){return new B({key:new W("autolink"),appendTransaction:(e,t,r)=>{const i=e.some(a=>a.docChanged)&&!t.doc.eq(r.doc),s=e.some(a=>a.getMeta("preventAutolink"));if(!i||s)return;const{tr:o}=r,l=jd(t.doc,[...e]);if(!e.some(Bm)){const a=[];l.steps.forEach((c,d)=>{if(!(c instanceof q)||!c.slice.size)return;const u=l.mapping.slice(d+1),f=u.map(c.from,1),h=u.map(c.from+c.slice.size,-1);fd.to-c.to),a.forEach(c=>Ak(o,c,n.type))}if(Ti(l).forEach(({newRange:a})=>{const c=Og(r.doc,a,f=>f.isTextblock);let d,u;if(c.length>1)d=c[0],u=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ");else if(c.length){const f=r.doc.textBetween(a.from,a.to," "," ");if(!vk.test(f))return;d=c[0],u=r.doc.textBetween(d.pos,a.to,void 0," ")}if(d&&u){const f=u.split(Ck).filter(Boolean);if(f.length<=0)return!1;const h=f[f.length-1],p=d.pos+u.lastIndexOf(h);if(!h)return!1;const m=Lo(h).map(g=>g.toObject(n.defaultProtocol));if(!Tk(m))return!1;m.filter(g=>g.isLink).map(g=>({...g,from:p+g.start+1,to:p+g.end+1})).filter(g=>r.schema.marks.code?!r.doc.rangeHasMark(g.from,g.to,r.schema.marks.code):!0).filter(g=>n.validate(g.value)).filter(g=>n.shouldAutoLink(g.value)).forEach(g=>{Ni(g.from,g.to,r.doc).some(y=>y.mark.type===n.type)||o.addMark(g.from,g.to,n.type.create({href:g.href}))})}}),!!o.steps.length)return o}})}function Ok(n){return new B({key:new W("handleClickLink"),props:{handleClick:(e,t,r)=>{if(r.button!==0||!e.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{const a=r.target;if(!a)return!1;const c=n.editor.view.dom;i=a.closest("a"),i&&!c.contains(i)&&(i=null)}if(!i)return!1;let s=!1;if(n.enableClickSelection&&(s=n.editor.commands.extendMarkRange(n.type.name)),n.openOnClick){var o,l;const a=Gd(e.state,n.type.name),c=(o=i.href)!==null&&o!==void 0?o:a.href,d=(l=i.target)!==null&&l!==void 0?l:a.target;c&&(window.open(c,d),s=!0)}return s}}})}const Rk=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,Lk=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function ju(n,e){let t=0;for(let r=e-1;r>=0&&n[r]==="\\";r-=1)t+=1;return t%2===1}function Ik(n,e){let t=0,r=0;for(;r0}function Uu(n,e,t){var r,i;const[,s,o]=e;return(e.index?n[e.index-1]:void 0)==="!"||ju(n,(r=e.index)!==null&&r!==void 0?r:0)||Ik(n,(i=e.index)!==null&&i!==void 0?i:0)?!1:!!s.trim()&&t(o)}function Ku(n){var e,t;const[r,i,s,,o,l,a]=n,c=(e=o??l)!==null&&e!==void 0?e:a;return{index:(t=n.index)!==null&&t!==void 0?t:0,text:r,replaceWith:i,data:{href:s,title:c||null,markdown:!0}}}function Dk(n,e){return n.index{const r=Rk.exec(t);return!r||!Uu(t,r,n.isAllowedHref)?null:Ku(r)},type:n.type,getAttributes:qu});return new er({find:e.find,handler:t=>{const r=e.handler(t);return r!==null&&t.state.tr.steps.length&&t.state.tr.setMeta("preventAutolink",!0),r}})}function zk(n){const e=pt({find:t=>{var r,i;const s=[];for(const l of t.matchAll(Lk))Uu(t,l,n.isAllowedHref)&&s.push(Ku(l));const o=((r=(i=n.findPlainUrls)===null||i===void 0?void 0:i.call(n,t))!==null&&r!==void 0?r:[]).filter(l=>!s.some(a=>Dk(a,l)));return[...s,...o]},type:n.type,getAttributes:qu});return new lu({find:e.find,handler:t=>{var r;const i=e.handler(t);return i!==null&&t.state.tr.steps.length&&(!((r=t.match.data)===null||r===void 0)&&r.markdown)&&t.state.tr.setMeta("preventAutolink",!0),i}})}function $k(n){return new B({key:new W("handlePasteLink"),props:{handlePaste:(e,t,r)=>{const{shouldAutoLink:i}=n,{state:s}=e,{selection:o}=s,{empty:l}=o;if(l)return!1;let a="";r.content.forEach(d=>{a+=d.textContent});const c=Wu(a,{defaultProtocol:n.defaultProtocol}).find(d=>d.isLink&&d.value===a);return!a||!c||i!==void 0&&!i(c.value)?!1:n.editor.commands.setMark(n.type,{href:c.href})}}})}function _e(n,e){const t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const i=typeof r=="string"?r:r.scheme;i&&t.push(i)}),!n||n.replace(Mk,"").match(new RegExp(`^(?:(?:${t.map(r=>r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,"i"))}const Bk=bt.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(n=>{if(typeof n=="string"){Ea(n);return}Ea(n.scheme,n.optionalSlashes)})},onDestroy(){Sk()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(n,e)=>!!_e(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(n),t=/^[a-z][a-z0-9+.-]*:/i.test(n);if(e||t&&!n.includes("@"))return!0;const r=(n.includes("@")?n.split("@").pop():n).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){var n,e,t;return{href:{default:null,parseHTML(r){return r.getAttribute("href")}},target:{default:(n=this.options.HTMLAttributes.target)!==null&&n!==void 0?n:null},rel:{default:(e=this.options.HTMLAttributes.rel)!==null&&e!==void 0?e:null},class:{default:(t=this.options.HTMLAttributes.class)!==null&&t!==void 0?t:null},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{const e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!_e(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!_e(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",F(this.options.HTMLAttributes,n),0]:["a",F(this.options.HTMLAttributes,{...n,href:""}),0]},markdownTokenName:"link",parseMarkdown:(n,e)=>e.applyMark("link",e.parseInline(n.tokens||[]),{href:n.href,title:n.title||null}),renderMarkdown:(n,e)=>{var t,r,i,s;const o=(t=(r=n.attrs)===null||r===void 0?void 0:r.href)!==null&&t!==void 0?t:"",l=(i=(s=n.attrs)===null||s===void 0?void 0:s.title)!==null&&i!==void 0?i:"",a=e.renderChildren(n);return l?`[${a}](${o} "${l}")`:`[${a}](${o})`},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!_e(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{const{href:t}=n||{};return t&&!this.options.isAllowedUri(t,{defaultValidate:r=>!!_e(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addInputRules(){return this.options.markdownLinks?[Pk({type:this.type,isAllowedHref:n=>this.options.isAllowedUri(n,{defaultValidate:e=>!!_e(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){const n=e=>{const t=[];if(e){const{protocols:r,defaultProtocol:i}=this.options;Wu(e).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:o=>!!_e(o,r),protocols:r,defaultProtocol:i})).forEach(s=>{this.options.shouldAutoLink(s.value)&&t.push({text:s.value,data:{href:s.href},index:s.start})})}return t};return this.options.markdownLinks?[zk({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:t=>!!_e(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:n})]:[pt({find:n,type:this.type,getAttributes:e=>{var t;return{href:(t=e.data)===null||t===void 0?void 0:t.href}}})]},addProseMirrorPlugins(){const n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(Nk({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!_e(i,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),n.push(Ok({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&n.push($k({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),n}}),Hk="listItem",Ma="textStyle",Aa=/^\s*([-+*])\s$/,Ju=U.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",F(this.options.HTMLAttributes,n),0]},markdownTokenName:"list",parseMarkdown:(n,e)=>n.type!=="list"||n.ordered?[]:{type:"bulletList",content:n.items?e.parseChildren(n.items):[]},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,` +`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Hk,this.editor.getAttributes(Ma)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=ln({find:Aa,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=ln({find:Aa,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Ma),editor:this.editor})),[n]}}),Fk=(n,e,t)=>{const{selection:r}=n;if(!r.empty)return null;const{$from:i}=r;if(!i.parent.isTextblock||i.parentOffset!==i.parent.content.size)return null;let s=-1;for(let h=i.depth;h>0;h-=1)if(i.node(h).type.name===e){s=h;break}if(s<0)return null;const o=i.node(s),l=i.index(s);if(l+1>=o.childCount)return null;const a=o.child(l+1);if(!t.includes(a.type.name))return null;const c=n.schema.nodes[e];let d=!1;if(a.forEach(h=>{h.type===c&&h.childCount>1&&(d=!0)}),!d)return null;const u=n.doc.resolve(i.after()).nodeAfter;if(!u||!t.includes(u.type.name))return null;const f=[];return u.forEach(h=>{f.push(h)}),f.length===0?null:{listItemDepth:s,nestedList:u,nestedListPos:i.after(),insertPos:i.after(s),items:f}},_k=(n,e,t,r)=>{const i=Fk(n,t,r);if(!i)return!1;const{selection:s}=n,{nestedList:o,nestedListPos:l,insertPos:a,items:c}=i,d=n.tr;d.delete(l,l+o.nodeSize);const u=d.mapping.map(a);return d.insert(u,w.from(c)),d.setSelection(s.map(d.doc,d.mapping)),e&&e(d),!0},Vk=(n,e,t)=>_k(n.state,n.view.dispatch,e,t),Gu=(n,e)=>j.create({name:`${n}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){const t=()=>Vk(this.editor,n,e);return{Delete:t,"Mod-Delete":t}}}),Yu=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],pr="abcdefghijklmnopqrstuvwxyz",Xu=String.raw`\d+|[ivxlcdmIVXLCDM]+|${"[a-zA-Z]{1,2}"}`;function Di(n){let e=n,t="";for(const[r,i]of Yu)for(;e>=r;)t+=i,e-=r;return t}function Io(n){return Di(n).toUpperCase()}function Qu(n){const e=n.toLowerCase();let t=0,r=0;for(;t0?r:1}const t=parseInt(n,10);return Number.isNaN(t)?1:t}function Uk(n,e){if(n==="numeric")return String(e);switch(n){case"a":return pi(e);case"A":return pi(e).toUpperCase();case"i":return Di(e);case"I":return Io(e);default:return String(e)}}function Kk(n){var e;if(n.length===0)return!1;const t=(e=Pi(n[0]))!==null&&e!==void 0?e:"numeric",r=Do(n[0]);if(r<1)return!1;for(let i=0;i{var t;if(n.type!=="list_item")return[];const r=(t=e.parseBlockChildren)!==null&&t!==void 0?t:e.parseChildren;let i=[];if(n.tokens&&n.tokens.length>0){if(Yk(n))return{type:"listItem",content:[{type:"paragraph",content:Xk(n.text||"",e)}]};if(n.tokens.some(s=>s.type==="paragraph"))i=r(n.tokens);else{const s=n.tokens[0];if(s&&s.type==="text"&&s.tokens&&s.tokens.length>0){if(i=[{type:"paragraph",content:e.parseInline(s.tokens)}],n.tokens.length>1){const o=r(n.tokens.slice(1));i.push(...o)}}else i=r(n.tokens)}}return i.length===0&&(i=[{type:"paragraph",content:[]}]),{type:"listItem",content:i}},renderMarkdown:(n,e,t)=>iu(n,e,r=>{if(r.parentType==="bulletList")return"- ";if(r.parentType==="orderedList"){var i,s;const o=((i=r.meta)===null||i===void 0||(i=i.parentAttrs)===null||i===void 0?void 0:i.start)||1;return Gk((s=r.meta)===null||s===void 0||(s=s.parentAttrs)===null||s===void 0?void 0:s.type,o-1+(r.index||0),". ")}return"- "},t,{alignNestedToPrefix:t?.parentType==="orderedList"}),addExtensions(){return[Gu(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Po=(n,e)=>{const{$from:t}=e.selection,r=ee(n,e.schema);let i=null,s=t.depth,o=t.pos,l=null;for(;s>0&&l===null;)i=t.node(s),i.type===r?l=s:(s-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},ef=(n,e)=>{const t=Po(n,e);if(!t)return!1;const[,r]=Fg(e,n,t.$pos.pos+4);return r},Qk=(n,e,t)=>{const{$anchor:r}=n.selection,i=Math.max(0,r.pos-2),s=n.doc.resolve(i).node();return!(!s||!t.includes(s.type.name))},Ta=(n,e,t)=>{if(n.commands.undoInputRule())return!0;if(n.state.selection.from!==n.state.selection.to)return!1;if(!Xe(n.state,e)&&Qk(n.state,e,t)){const{$anchor:s}=n.state.selection,o=n.state.doc.resolve(s.before()-1),l=[];o.node().descendants((d,u)=>{d.type.name===e&&l.push({node:d,pos:u})});const a=l.at(-1);if(!a)return!1;const c=n.state.doc.resolve(o.start()+a.pos+1);return n.chain().cut({from:s.start()-1,to:s.end()+1},c.end()).joinForward().run()}if(!Xe(n.state,e)||!Ug(n.state))return!1;const{$from:r}=n.state.selection,i=r.depth-1;return r.node(i).type!==n.schema.nodes[e]||r.index(i)!==0?!1:n.chain().liftListItem(e).run()},Zk=(n,e)=>{const t=ef(n,e),r=Po(n,e);return!r||!t?!1:t>r.depth},ew=(n,e)=>{const t=ef(n,e),r=Po(n,e);return!r||!t?!1:t{if(!Xe(n.state,e)||!jg(n.state,e))return!1;const{selection:t}=n.state,{$from:r,$to:i}=t;return!t.empty&&r.sameParent(i)?!1:Zk(e,n.state)?n.chain().focus(n.state.selection.from+4).lift(e).joinBackward().run():ew(e,n.state)?n.chain().joinForward().joinBackward().run():n.commands.joinItemForward()},tw=(n,e,t)=>{const{state:r}=n,{selection:i}=r;if(!i.empty)return!1;const{$from:s}=i;if(s.parentOffset!==0||!s.parent.isTextblock||Xe(r,e))return!1;const o=_g(s);if(!o||!t.includes(o.type.name))return!1;const l=o.lastChild;if(!l||l.type.name!==e)return!1;const a=s.parent;if(!l.canReplace(l.childCount,l.childCount,w.from(a)))return!1;const c=s.before(),d=s.after(),u=c-2;return n.commands.command(({tr:f,dispatch:h})=>(h&&(f.delete(c,d).insert(u,w.from(a)),f.setSelection(M.create(f.doc,u+1)),f.scrollIntoView()),!0))},tf=j.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&Na(n,t)&&(e=!0)}),e},"Mod-Delete":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&Na(n,t)&&(e=!0)}),e},Backspace:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&Ta(n,t,r)&&(e=!0)}),e},"Mod-Backspace":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&Ta(n,t,r)&&(e=!0)}),e},Tab:({editor:n})=>{for(const{itemName:e,wrapperNames:t}of this.options.listTypes)if(n.state.schema.nodes[e]!==void 0&&tw(n,e,t))return!0;return!1}}}}),mi=new RegExp(`^(\\s*)(${Xu})([.)])\\s+(.*)$`),nw=/^\s/,Gt={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function rw(n){return mi.test(n.trimStart())}function iw(n){const e=n.trimStart();return Gt.bulletItem.test(e)||rw(e)||Gt.heading.test(e)||Gt.thematicBreak.test(e)&&!e.startsWith("-")||/^>\s?/.test(e)||Gt.codeFence.test(e)||Gt.blockMath.test(e)}function sw(n){return Object.values(Gt).some(e=>e.test(n))}function ow(n){const e=[],t=[];let r=!1;return n.forEach(i=>{if(r){t.push(i);return}if(i.trim()===""){r=!0,t.push(i);return}if(e.length>0&&iw(i)){r=!0,t.push(i);return}e.push(i)}),{paragraphLines:e,blockLines:t}}function Oa(n){const e=[];let t=0,r=0;for(;tr.trim().length>0);if(e.length===0)return null;const t=[];for(const r of e){const i=r.trim().match(ow);if(!i)return null;t.push({marker:i[1],content:i[3]})}return Uk(t.map(r=>r.marker))?{type:"orderedList",attrs:qk(t[0].marker),content:t.map(r=>({type:"listItem",content:[{type:"paragraph",content:[{type:"text",text:r.content}]}]}))}:null}function nf(n,e,t){const r=[];let i=0;for(;ir.trim().length>0);if(e.length===0)return null;const t=[];for(const r of e){const i=r.trim().match(lw);if(!i)return null;t.push({marker:i[1],content:i[3]})}return Kk(t.map(r=>r.marker))?{type:"orderedList",attrs:Jk(t[0].marker),content:t.map(r=>({type:"listItem",content:[{type:"paragraph",content:[{type:"text",text:r.content}]}]}))}:null}function nf(n,e,t){const r=[];let i=0;for(;ie;)f.push(n[u]),u+=1;if(f.length>0){const h=nf(f,Math.min(...f.map(p=>p.indent)),t);c.push({type:"list",ordered:!0,start:f[0].number,typeMarker:f[0].type,items:h,raw:f.map(p=>p.raw).join(` -`)})}r.push({type:"list_item",raw:s.raw,tokens:c}),i=u}else i+=1}return r}function aw(n,e){return n.map(t=>{if(t.type!=="list_item")return e.parseChildren([t])[0];const r=[];return t.tokens&&t.tokens.length>0&&t.tokens.forEach(i=>{if(i.type==="paragraph"||i.type==="list"||i.type==="blockquote"||i.type==="code")r.push(...e.parseChildren([i]));else if(i.type==="text"&&i.tokens){const s=e.parseChildren([i]);r.push({type:"paragraph",content:s})}else{const s=e.parseChildren([i]);s.length>0&&r.push(...s)}}),{type:"listItem",content:r}})}const cw=64;function Ra(n,e){const t=[];let r=0;for(;t.lengthn.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>{const e=n.getAttribute("type");if(e)return e;const t=n.getAttribute("style");if(t){const i=Da(t);if(i)return i}const r=n.querySelector("li");if(r){const i=r.getAttribute("style");if(i){const s=Da(i);if(s)return s}}return null}}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,type:t,...r}=n,i=F(this.options.HTMLAttributes,r);return e!==1&&(i.start=e),t&&t!=="1"&&(i.type=t),["ol",i,0]},markdownTokenName:"list",parseMarkdown:(n,e)=>{if(n.type!=="list"||!n.ordered)return[];const t=n.start||1,r=n.typeMarker,i=n.items?aw(n.items,e):[],s={};return t!==1&&(s.start=t),r&&(s.type=r),Object.keys(s).length>0?{type:"orderedList",attrs:s,content:i}:{type:"orderedList",content:i}},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,` -`):"",markdownTokenizer:{name:"orderedList",level:"block",start:()=>-1,tokenize:(n,e,t)=>{var r,i;const[s,o,l]=dw(n);if(s.length===0)return;const a=nf(s,s[0].indent,t);if(a.length!==0)return{type:"list",ordered:!0,start:((r=s[0])===null||r===void 0?void 0:r.number)||1,typeMarker:(i=s[0])===null||i===void 0?void 0:i.type,items:a,raw:l.slice(0,o).join(` -`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(uw,this.editor.getAttributes(La)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new B({props:{handlePaste:(n,e)=>{var t,r;const i=(t=e.clipboardData)===null||t===void 0?void 0:t.getData("text/html");if(i?.trim())return!1;const s=(r=e.clipboardData)===null||r===void 0?void 0:r.getData("text/plain");if(!s)return!1;const o=lw(s);if(!o)return!1;try{const l=n.state.schema.nodeFromJSON(o),a=n.state.tr.replaceSelectionWith(l);return n.dispatch(a),!0}catch{return!1}}}})]},addInputRules(){const n=(t,r)=>(!r.attrs.type||r.attrs.type==="1")&&r.childCount+r.attrs.start===+t[1];let e=ln({find:Ia,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:n});return(this.options.keepMarks||this.options.keepAttributes)&&(e=ln({find:Ia,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(La)}),joinPredicate:n,editor:this.editor})),[e]}}),fw=/^\s*(\[([( |x])?\])\s$/,hw="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0",pw=(n,e,t)=>{var r;return(t==null||(r=t.checkboxLabel)===null||r===void 0?void 0:r.call(t,n,e))||`Task item checkbox for ${n.textContent||"empty task item"}`},mw=U.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:n=>{const e=n.getAttribute("data-checked");return e===""||e==="true"},renderHTML:n=>({"data-checked":n.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:n=>{var e;return(e=n.querySelector("div"))!==null&&e!==void 0?e:n}}]},renderHTML({node:n,HTMLAttributes:e}){return["li",F(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:n.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(n,e)=>{const t=[];if(n.tokens&&n.tokens.length>0?t.push(e.createNode("paragraph",{},e.parseInline(n.tokens))):n.text?t.push(e.createNode("paragraph",{},[e.createNode("text",{text:n.text})])):t.push(e.createNode("paragraph",{},[])),n.nestedTokens&&n.nestedTokens.length>0){const r=e.parseChildren(n.nestedTokens);t.push(...r)}return e.createNode("taskItem",{checked:n.checked||!1},t)},renderMarkdown:(n,e)=>{var t;const r=`- [${!((t=n.attrs)===null||t===void 0)&&t.checked?"x":" "}] `;return iu(n,e,r)},addExtensions(){return this.options.nested?[Gu(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){const n={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...n,Tab:()=>this.editor.commands.sinkListItem(this.name)}:n},addNodeView(){return({node:n,HTMLAttributes:e,getPos:t,editor:r})=>{const i=document.createElement("li"),s=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div");o.style.cssText=hw;const c=u=>{const f=pw(u,u.attrs.checked,this.options.a11y);l.setAttribute("aria-label",f),o.textContent=f};c(n),s.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",u=>u.preventDefault()),l.addEventListener("change",u=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:f}=u.target;r.isEditable&&typeof t=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{const p=t();if(typeof p!="number")return!1;const m=h.doc.nodeAt(p);return h.setNodeMarkup(p,void 0,{...m?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(n,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([u,f])=>{i.setAttribute(u,f)}),i.dataset.checked=n.attrs.checked,l.checked=n.attrs.checked,s.append(l,o),i.append(s,a),Object.entries(e).forEach(([u,f])=>{i.setAttribute(u,f)});let d=new Set(Object.keys(e));return{dom:i,contentDOM:a,update:u=>{if(u.type!==this.type)return!1;i.dataset.checked=u.attrs.checked,l.checked=u.attrs.checked,c(u);const f=r.extensionManager.attributes,h=on(u,f),p=new Set(Object.keys(h)),m=this.options.HTMLAttributes;return d.forEach(g=>{p.has(g)||(g in m?i.setAttribute(g,m[g]):i.removeAttribute(g))}),Object.entries(h).forEach(([g,y])=>{y==null?g in m?i.setAttribute(g,m[g]):i.removeAttribute(g):i.setAttribute(g,y)}),d=p,!0}}}},addInputRules(){return[ln({find:fw,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),gw=U.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:n}){return["ul",F(this.options.HTMLAttributes,n,{"data-type":this.name}),0]},parseMarkdown:(n,e)=>e.createNode("taskList",{},e.parseChildren(n.items||[])),renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,` -`):"",markdownTokenizer:{name:"taskList",level:"block",start(n){var e;const t=(e=n.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))===null||e===void 0?void 0:e.index;return t!==void 0?t:-1},tokenize(n,e,t){const r=s=>{const o=ea(s,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:t.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},t);if(o){const l={type:"taskList",raw:o.raw,items:o.items},a=s.slice(o.raw.length);return a.trim()?[l,...t.blockTokens(a)]:[l]}return t.blockTokens(s)},i=ea(n,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:s=>({indentLevel:s[1].length,mainContent:s[4],checked:s[3].toLowerCase()==="x"}),createToken:(s,o)=>({type:"taskItem",raw:"",mainContent:s.mainContent,indentLevel:s.indentLevel,checked:s.checked,text:s.mainContent,tokens:t.inlineTokens(s.mainContent),nestedTokens:o}),customNestedParser:r},t);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});j.create({name:"listKit",addExtensions(){const n=[];return this.options.bulletList!==!1&&n.push(Ju.configure(this.options.bulletList)),this.options.listItem!==!1&&n.push(Zu.configure(this.options.listItem)),this.options.listKeymap!==!1&&n.push(tf.configure(this.options.listKeymap)),this.options.orderedList!==!1&&n.push(rf.configure(this.options.orderedList)),this.options.taskItem!==!1&&n.push(mw.configure(this.options.taskItem)),this.options.taskList!==!1&&n.push(gw.configure(this.options.taskList)),n}});const mr=" ",as=" ",yw=U.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",F(this.options.HTMLAttributes,n),0]},parseMarkdown:(n,e)=>{const t=n.tokens||[];if(t.length===1&&t[0].type==="image")return e.parseChildren([t[0]]);const r=e.parseInline(t);return t.length===1&&t[0].type==="text"&&(t[0].raw===mr||t[0].text===mr||t[0].raw===as||t[0].text===as)&&r.length===1&&r[0].type==="text"&&(r[0].text===mr||r[0].text===as)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(n,e,t)=>{if(!n)return"";const r=Array.isArray(n.content)?n.content:[];if(r.length===0){var i,s;const o=Array.isArray(t==null||(i=t.previousNode)===null||i===void 0?void 0:i.content)?t.previousNode.content:[];return(t==null||(s=t.previousNode)===null||s===void 0?void 0:s.type)==="paragraph"&&o.length===0?mr:""}return e.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),bw=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,kw=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,ww=bt.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",F(this.options.HTMLAttributes,n),0]},markdownTokenName:"del",parseMarkdown:(n,e)=>e.applyMark("strike",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`~~${e.renderChildren(n)}~~`,addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[$t({find:bw,type:this.type})]},addPasteRules(){return[pt({find:kw,type:this.type})]}}),Sw=U.create({name:"text",group:"inline",parseMarkdown:n=>({type:"text",text:n.text||""}),renderMarkdown:n=>n.text||""}),xw=bt.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",F(this.options.HTMLAttributes,n),0]},parseMarkdown(n,e){return e.applyMark(this.name||"underline",e.parseInline(n.tokens||[]))},renderMarkdown(n,e){return`++${e.renderChildren(n)}++`},markdownTokenizer:{name:"underline",level:"inline",start(n){return n.indexOf("++")},tokenize(n,e,t){const r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(n);if(!r)return;const i=r[2].trim();return{type:"underline",raw:r[0],text:i,tokens:t.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function Cw(n={}){return new B({view(e){return new vw(e,n)}})}class vw{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let s=o=>{this[i](o)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc)if(this.lastDragEvent){let r=this.computeTarget(this.lastDragEvent);r==this.cursorPos?this.updateOverlay():this.setCursor(r)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,i=this.editorView.dom,s=i.getBoundingClientRect(),o=s.width/i.offsetWidth,l=s.height/i.offsetHeight;if(t){let u=e.nodeBefore,f=e.nodeAfter;if(u||f){let h=this.editorView.nodeDOM(this.cursorPos-(u?u.nodeSize:0));if(h){let p=h.getBoundingClientRect(),m=u?p.bottom:p.top;u&&f&&(m=(m+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;r={left:p.left,right:p.right,top:m-g,bottom:m+g}}}}if(!r){let u=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*o;r={left:u.left-f,right:u.left+f,top:u.top,bottom:u.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,d;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,d=-pageYOffset;else{let u=a.getBoundingClientRect(),f=u.width/a.offsetWidth,h=u.height/a.offsetHeight;c=u.left-a.scrollLeft*f,d=u.top-a.scrollTop*h}this.element.style.left=(r.left-c)/o+"px",this.element.style.top=(r.top-d)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=r&&r.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,t,e):i;if(!t||s)return null;let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=vc(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}return o}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class J extends O{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return J.valid(r)?new J(r):O.near(r)}content(){return C.empty}eq(e){return e instanceof J&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new J(e.resolve(t.pos))}getBookmark(){return new zo(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!Ew(e)||!Mw(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&J.valid(e))return e;let i=e.pos,s=null;for(let o=e.depth;;o--){let l=e.node(o);if(t>0?e.indexAfter(o)0){s=l.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=t;let a=e.doc.resolve(i);if(J.valid(a))return a}for(;;){let o=t>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!T.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*t),r=!1;continue e}break}s=o,i+=t;let l=e.doc.resolve(i);if(J.valid(l))return l}return null}}}J.prototype.visible=!1;J.findFrom=J.findGapCursorFrom;O.jsonID("gapcursor",J);class zo{constructor(e){this.pos=e}map(e){return new zo(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return J.valid(t)?new J(t):O.near(t)}}function sf(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function Ew(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||sf(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Mw(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||sf(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Aw(){return new B({props:{decorations:Rw,createSelectionBetween(n,e,t){return e.pos==t.pos&&J.valid(t)?new J(t):null},handleClick:Nw,handleKeyDown:Tw,handleDOMEvents:{beforeinput:Ow}}})}const Tw=yo({ArrowLeft:gr("horiz",-1),ArrowRight:gr("horiz",1),ArrowUp:gr("vert",-1),ArrowDown:gr("vert",1)});function gr(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,s){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof M){if(!s.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=J.findGapCursorFrom(l,e,a);return c?(i&&i(r.tr.setSelection(new J(c))),!0):!1}}function Nw(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!J.valid(r))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&T.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new J(r))),!0)}function Ow(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof J))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let i=w.empty;for(let o=r.length-1;o>=0;o--)i=w.from(r[o].createAndFill(null,i));let s=n.state.tr.replace(t.pos,t.pos,new C(i,0,0));return s.setSelection(M.near(s.doc.resolve(t.pos+1))),n.dispatch(s),!1}function Rw(n){if(!(n.selection instanceof J))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",z.create(n.doc,[te.widget(n.selection.head,e,{key:"gapcursor"})])}j.create({name:"characterCount",addOptions(){return{limit:null,autoTrim:!0,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=n?.node||this.editor.state.doc;if((n?.mode||this.options.mode)==="textSize"){const t=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(t)}return e.nodeSize},this.storage.words=n=>{const e=n?.node||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new B({key:new W("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;const i=this.options.limit,s=this.options.autoTrim;if(i==null||i===0||s===!1){n=!0;return}const o=this.storage.characters({node:r.doc});if(o>i){const l=o-i,a=0,c=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const d=r.tr.deleteRange(a,c);return n=!0,d}n=!0},filterTransaction:(e,t)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:t.doc}),s=this.storage.characters({node:e.doc});if(s<=r||i>r&&s>r&&s<=i)return!0;if(i>r&&s>r&&s>i||!e.getMeta("paste"))return!1;const o=e.selection.$head.pos,l=o-(s-r),a=o;return e.deleteRange(l,a),!(this.storage.characters({node:e.doc})>r)}})]}});const Lw=j.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Cw(this.options)]}});j.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new B({key:new W("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:r}=this.editor,{anchor:i}=e,s=[];if(!t||!r)return z.create(n,[]);let o=0;this.options.mode==="deepest"&&n.descendants((a,c)=>{if(!a.isText){if(!(i>=c&&i<=c+a.nodeSize-1))return!1;o+=1}});let l=0;return n.descendants((a,c)=>{if(a.isText||!(i>=c&&i<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";s.push(te.node(c,c+a.nodeSize,{class:this.options.className}))}),z.create(n,s)}}})]}});const Iw=j.create({name:"gapCursor",addProseMirrorPlugins(){return[Aw()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=$(A(n,"allowGapCursor",t)))!==null&&e!==void 0?e:null}}}),of="placeholder",Pa=new W("tiptap__placeholder");function lf(n){const{editor:e,placeholder:t,dataAttribute:r,pos:i,node:s,isEmptyDoc:o,hasAnchor:l,classes:{emptyNode:a,emptyEditor:c}}=n,d=[a];return o&&d.push(c),te.node(i,i+s.nodeSize,{class:d.join(" "),[r]:typeof t=="function"?t({editor:e,node:s,pos:i,hasAnchor:l}):t})}function af(n,e){return typeof n=="function"?n(e):n}function cf({editor:n,options:e,dataAttribute:t,doc:r,selection:i,from:s,to:o}){const{anchor:l}=i,a=[],c=n.isEmpty;return r.nodesBetween(s,o,(d,u)=>{const f=l>=u&&l<=u+d.nodeSize,h=!d.isLeaf&&Zn(d);return d.type.isTextblock&&(f||!e.showOnlyCurrent)&&h&&a.push(lf({editor:n,isEmptyDoc:c,dataAttribute:t,hasAnchor:f,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:af(e.emptyNodeClass,{editor:n,node:d,pos:u,hasAnchor:f})},node:d,pos:u})),e.includeChildren}),a}function df({editor:n,options:e,dataAttribute:t,doc:r,selection:i}){if(!(n.isEditable||!e.showOnlyWhenEditable))return null;const{anchor:s}=i,o=[],l=n.isEmpty;if(e.showOnlyCurrent&&!e.includeChildren){const a=r.resolve(s),c=a.depth>0?a.node(1):a.nodeAfter,d=a.depth>0?a.before(1):s;if(c&&c.type.isTextblock&&Zn(c)){const u=s>=d&&s<=d+c.nodeSize;o.push(lf({editor:n,isEmptyDoc:l,dataAttribute:t,hasAnchor:u,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:af(e.emptyNodeClass,{editor:n,node:c,pos:d,hasAnchor:u})},node:c,pos:d}))}}else o.push(...cf({editor:n,options:e,dataAttribute:t,doc:r,selection:i,from:0,to:r.content.size}));return z.create(r,o)}function Ln(n,e){const t=n.resolve(e);if(t.depth===0){var r;const s=(r=t.nodeAfter)!==null&&r!==void 0?r:t.nodeBefore;if(!s)return{from:e,to:e};const o=t.nodeAfter?e:e-s.nodeSize;return{from:o,to:o+s.nodeSize}}const i=t.before(1);return{from:i,to:i+t.node(1).nodeSize}}function In(n,e){return{from:Math.max(0,e.from-1),to:Math.min(n.content.size,e.to-1)}}function Dw(n,e,t){const r=[];return n.forEach((i,s)=>{const o=s,l=o+i.nodeSize,a=o+1,c=l+1;ae&&r.push({from:o,to:l})}),r}function Pw(n){if(n.length===0)return[];const e=[...n].sort((r,i)=>r.from-i.from),t=[{...e[0]}];for(let r=1;re.from?t.push(In(n,Ln(n,Math.min(e.to,n.content.size+1)-1))):e.fromh.from>=c&&h.to<=d);u.length&&(l=l.remove(u));const f=cf({editor:t,options:r,dataAttribute:i,doc:s,selection:o,from:c,to:d});f.length&&(l=l.add(s,f))}return l}function Fw({editor:n,options:e,dataAttribute:t}){return{init(r,i){const s=df({editor:n,options:e,dataAttribute:t,doc:i.doc,selection:i.selection});return s??z.empty},apply(r,i,s,o){return!r.docChanged&&!r.selectionSet?i:Hw({decorations:i.map(r.mapping,r.doc),ranges:$w(r,s,o),editor:n,options:e,dataAttribute:t,doc:o.doc,selection:o.selection})}}}function _w(n){return n.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}function Vw({editor:n,options:e}){const t=e.dataAttribute?`data-${_w(e.dataAttribute)}`:`data-${of}`,r=e.showOnlyCurrent&&!e.includeChildren;return new B({key:Pa,...r?{}:{state:Fw({editor:n,options:e,dataAttribute:t})},props:{decorations:r?({doc:i,selection:s})=>df({editor:n,options:e,dataAttribute:t,doc:i,selection:s}):i=>{var s;return e.showOnlyWhenEditable&&!n.isEditable?z.empty:(s=Pa.getState(i))!==null&&s!==void 0?s:z.empty}}})}j.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:of,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[Vw({editor:this.editor,options:this.options})]}});function Gs(n,e){return!n.selection.empty&&!Yd(n.selection)&&e.isEditable}function Ww(n,e){return Gs(n,e)&&!e.isFocused&&!e.view.dragging}function jw(){var n;(n=window.getSelection())===null||n===void 0||n.removeAllRanges()}function Uw(n){n.focus()}j.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return[new B({key:new W("selection"),props:{decorations(t){return Ww(t,n)?z.create(t.doc,[te.inline(t.selection.from,t.selection.to,{class:e.className})]):null},handleDOMEvents:{blur(t){return Gs(t.state,n)&&jw(),!1},focus(t){return Gs(t.state,n)&&requestAnimationFrame(()=>{!n.isDestroyed&&t.hasFocus()&&Uw(t)}),!1}}}})]}});function za({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||e?.type===n}const Kw=j.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;const e=new W(this.name),t=this.options.node||((n=this.editor.schema.topNodeType.contentMatch.defaultType)===null||n===void 0?void 0:n.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(t).includes(i.name));return[new B({key:e,appendTransaction:(i,s,o)=>{const{doc:l,tr:a,schema:c}=o,d=e.getState(o),u=l.content.size,f=c.nodes[t];if(!i.some(h=>h.getMeta("skipTrailingNode"))&&d)return a.insert(u,f.create())},state:{init:(i,s)=>{const o=s.tr.doc.lastChild;return!za({node:o,types:r})},apply:(i,s)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return s;const o=i.doc.lastChild;return!za({node:o,types:r})}}})]}}),qw=j.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>Rd(n,e),redo:()=>({state:n,dispatch:e})=>Ld(n,e)}},addProseMirrorPlugins(){return[$m(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),Jw=j.create({name:"starterKit",addExtensions(){const n=[];if(this.options.bold!==!1&&n.push(_0.configure(this.options.bold)),this.options.blockquote!==!1&&n.push(z0.configure(this.options.blockquote)),this.options.bulletList!==!1&&n.push(Ju.configure(this.options.bulletList)),this.options.code!==!1&&n.push(U0.configure(this.options.code)),this.options.codeBlock!==!1&&n.push(J0.configure(this.options.codeBlock)),this.options.document!==!1&&n.push(G0.configure(this.options.document)),this.options.dropcursor!==!1&&n.push(Lw.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&n.push(Iw.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&n.push(Y0.configure(this.options.hardBreak)),this.options.heading!==!1&&n.push(X0.configure(this.options.heading)),this.options.undoRedo!==!1&&n.push(qw.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&n.push(Q0.configure(this.options.horizontalRule)),this.options.italic!==!1&&n.push(rk.configure(this.options.italic)),this.options.listItem!==!1&&n.push(Zu.configure(this.options.listItem)),this.options.listKeymap!==!1){var e;n.push(tf.configure((e=this.options)===null||e===void 0?void 0:e.listKeymap))}if(this.options.link!==!1){var t;n.push($k.configure((t=this.options)===null||t===void 0?void 0:t.link))}if(this.options.orderedList!==!1&&n.push(rf.configure(this.options.orderedList)),this.options.paragraph!==!1&&n.push(yw.configure(this.options.paragraph)),this.options.strike!==!1&&n.push(ww.configure(this.options.strike)),this.options.text!==!1&&n.push(Sw.configure(this.options.text)),this.options.underline!==!1){var r;n.push(xw.configure((r=this.options)===null||r===void 0?void 0:r.underline))}if(this.options.trailingNode!==!1){var i;n.push(Kw.configure((i=this.options)===null||i===void 0?void 0:i.trailingNode))}return n}});var Gw=Jw;const uf={language:"en",tabWysiwyg:"WYSIWYG",tabSource:"Source",toolbar:"Formatting",paragraph:"Paragraph",heading2:"Heading 2",heading3:"Heading 3",heading4:"Heading 4",bold:"Bold",italic:"Italic",bulletList:"Bullet list",orderedList:"Numbered list",link:"Link",blockquote:"Quote",insertTable:"Insert table",addRow:"Add row",deleteRow:"Delete row",addColumn:"Add column",deleteColumn:"Delete column",deleteTable:"Delete table",image:"Image",mediaLibrary:"Choose from Media Library",embed:"Embed video",rawHtml:"HTML block",undo:"Undo",redo:"Redo",linkUrl:"Link URL",linkApply:"Apply",linkRemove:"Remove link",linkInvalid:"Links must use http, https, mailto or a relative URL.",embedUrl:"YouTube URL",embedInsert:"Insert",embedInvalid:"This video URL is not supported. Paste a YouTube link.",embedProvider:"Provider",embedId:"Embed ID",embedIdInvalid:"Enter a valid ID for this embed provider.",embedFallbackImage:"Fallback image URL (optional)",embedFallbackPick:"Choose from Media Library",embedFallbackAlt:"Fallback alt text (optional)",embedCaption:"Caption (optional)",embedAspect:"Aspect ratio (optional)",embedHeight:"Height (optional)",embedGeneric:"Embed",cancel:"Cancel",uploading:"Uploading {name}…",uploadFailed:"Upload failed: {error}",uploadTimeout:"The upload of {name} took too long.",notAnImage:"Only JPEG, PNG, GIF and WebP images can be uploaded.",altText:"Alt text (required)",caption:"Caption (optional)",altRequired:"Enter the alt text, or mark the image as decorative.",insertImage:"Insert image",rawHtmlCard:"HTML block",editAsHtml:"Edit as HTML",embedCard:"Embedded video",preview:"Preview",previewFrame:"Post preview",heading1:"Heading 1",outline:"Outline",outlineShow:"Show outline",outlineHide:"Hide outline",outlineCount:{one:"{count} heading",other:"{count} headings"},outlineProblems:{one:"{count} problem",other:"{count} problems"},outlineEmpty:"No headings yet. Headings split the text into sections for readers and search engines.",flagSkipped:"Skipped level: H{from} → H{to}",flagEmpty:"Empty heading",flagLinkOnly:"Heading is only a link",flagH1:"H1 in the text: saved as H2",outlineLinks:"Links",flagGeneric:"Link text “{text}” does not say where it leads",linkRel:"Link attributes",relNofollow:"nofollow",relSponsored:"sponsored (paid)",relUgc:"ugc (user content)",relHint:"Only for links to other sites. Links within the site never get these.",genericWarning:"“{text}” does not say where the link leads. Use words that describe the target page.",fileName:"File name",fileNameHint:"Lowercase words joined with hyphens, e.g. lion-s-mane-in-the-forest.",decorative:"Decorative image (no alt text)"},Yw={language:"pl",tabWysiwyg:"WYSIWYG",tabSource:"Źródło",toolbar:"Formatowanie",paragraph:"Akapit",heading2:"Nagłówek 2",heading3:"Nagłówek 3",heading4:"Nagłówek 4",bold:"Pogrubienie",italic:"Kursywa",bulletList:"Lista punktowana",orderedList:"Lista numerowana",link:"Link",blockquote:"Cytat",insertTable:"Wstaw tabelę",addRow:"Dodaj wiersz",deleteRow:"Usuń wiersz",addColumn:"Dodaj kolumnę",deleteColumn:"Usuń kolumnę",deleteTable:"Usuń tabelę",image:"Obraz",mediaLibrary:"Wybierz z biblioteki mediów",embed:"Osadź wideo",rawHtml:"Blok HTML",undo:"Cofnij",redo:"Ponów",linkUrl:"Adres linku",linkApply:"Zastosuj",linkRemove:"Usuń link",linkInvalid:"Link musi używać http, https, mailto albo adresu względnego.",embedUrl:"Adres filmu YouTube",embedInsert:"Wstaw",embedInvalid:"Ten adres filmu nie jest obsługiwany. Wklej link do YouTube.",embedProvider:"Dostawca",embedId:"Identyfikator osadzenia",embedIdInvalid:"Wpisz poprawny identyfikator dla tego dostawcy.",embedFallbackImage:"Adres obrazu zastępczego (opcjonalny)",embedFallbackPick:"Wybierz z biblioteki mediów",embedFallbackAlt:"Tekst alternatywny obrazu (opcjonalny)",embedCaption:"Podpis (opcjonalny)",embedAspect:"Proporcje (opcjonalne)",embedHeight:"Wysokość (opcjonalna)",embedGeneric:"Osadź",cancel:"Anuluj",uploading:"Wysyłanie {name}…",uploadFailed:"Wysyłanie nie powiodło się: {error}",uploadTimeout:"Wysyłanie {name} trwało zbyt długo.",notAnImage:"Można wysłać tylko obrazy JPEG, PNG, GIF i WebP.",altText:"Tekst alternatywny (wymagany)",caption:"Podpis (opcjonalny)",altRequired:"Wpisz tekst alternatywny lub oznacz obraz jako dekoracyjny.",insertImage:"Wstaw obraz",rawHtmlCard:"Blok HTML",editAsHtml:"Edytuj jako HTML",embedCard:"Osadzone wideo",preview:"Podgląd",previewFrame:"Podgląd wpisu",heading1:"Nagłówek 1",outline:"Konspekt",outlineShow:"Pokaż konspekt",outlineHide:"Ukryj konspekt",outlineCount:{one:"{count} nagłówek",few:"{count} nagłówki",many:"{count} nagłówków",other:"{count} nagłówka"},outlineProblems:{one:"{count} problem",few:"{count} problemy",many:"{count} problemów",other:"{count} problemu"},outlineEmpty:"Brak nagłówków. Nagłówki dzielą tekst na części dla czytelników i wyszukiwarek.",flagSkipped:"Pominięty poziom: H{from} → H{to}",flagEmpty:"Pusty nagłówek",flagLinkOnly:"Nagłówek jest tylko linkiem",flagH1:"H1 w tekście: zostanie zapisany jako H2",outlineLinks:"Linki",flagGeneric:"Tekst linku „{text}” nie mówi, dokąd prowadzi",linkRel:"Atrybuty linku",relNofollow:"nofollow",relSponsored:"sponsored (płatny)",relUgc:"ugc (od użytkowników)",relHint:"Tylko dla linków do innych witryn. Linki w obrębie witryny nigdy ich nie dostają.",genericWarning:"„{text}” nie mówi, dokąd prowadzi link. Użyj słów opisujących stronę docelową.",fileName:"Nazwa pliku",fileNameHint:"Małe litery i łączniki, np. lwia-grzywa-w-lesie.",decorative:"Obraz dekoracyjny (bez tekstu alternatywnego)"},Xw={en:uf,pl:Yw};function Jn(n){const e=(n??"").toLowerCase().split(/[-_]/)[0]??"";return Xw[e]??uf}function Lt(n,e){return n.replace(/\{(\w+)\}/g,(t,r)=>e[r]??t)}function $a(n,e,t,r={}){let i="other";try{i=new Intl.PluralRules(n.language).select(t)}catch{}return Lt(e[i]??e.other,{...r,count:String(t)})}const Ys="blogeditor-edit-html",Qw=["footer","section","aside","header","nav","details","style","div","article","main","address","dl","iframe","video","audio","picture","object","embed","form","svg","math","script","noscript"],Zw=/[\x00-\x20\x7f]+/g,e1=/^([a-z][a-z0-9+.-]*):/i,t1=["http","https","mailto"];function Pe(n){if(n==null)return!1;const e=e1.exec(n.replace(Zw,""));if(e&&!t1.includes(e[1].toLowerCase()))return!1;try{return new URL(n,"https://journal.invalid/"),!0}catch{return!1}}const n1={orderedList:["start","type"],link:["href","target","rel","class","title"],image:["src","alt","title","width","height"],figureImage:["src","alt","title","width","height"],tableCell:["colspan","rowspan","colwidth"],tableHeader:["colspan","rowspan","colwidth"]},r1=["paragraph","heading","blockquote","bulletList","orderedList","listItem","codeBlock","horizontalRule","hardBreak","table","tableRow","tableCell","tableHeader","image","figure","figcaption","link"],i1=["class","title","alt","width","height","colspan","rowspan","start","rel","target"],s1=/^data-[a-z0-9][a-z0-9._-]*$/;function ff(n){return i1.includes(n)||s1.test(n)}function gi(n,e){const t={};let r=!1;for(const i of Array.from(n.attributes)){const s=i.name.toLowerCase();e.includes(s)||!ff(s)||(t[s]=i.value,r=!0)}return r?t:null}function hf(n){if(!n||typeof n!="object")return{};const e={};for(const[t,r]of Object.entries(n))!ff(t.toLowerCase())||typeof r!="string"||(e[t]=r);return e}const o1=j.create({name:"htmlAttributes",addGlobalAttributes(){return r1.map(n=>({types:[n],attributes:{htmlAttrs:{default:null,keepOnSplit:!1,parseHTML:e=>gi(e,n1[n]??[]),renderHTML:e=>hf(e.htmlAttrs)}}}))}}),l1=bt.create({name:"span",priority:40,addAttributes(){return{htmlAttrs:{default:null,parseHTML:n=>gi(n,[]),renderHTML:n=>hf(n.htmlAttrs)}}},parseHTML(){return[{tag:"span",getAttrs:n=>gi(n,[])?null:!1}]},renderHTML({HTMLAttributes:n}){return["span",n,0]}});let Ba;function $o(){return Ba??=document.implementation.createHTMLDocument(""),Ba}const a1=U.create({name:"rawHtml",group:"block",atom:!0,selectable:!0,draggable:!0,priority:10,addOptions(){return{labels:Jn("en")}},addAttributes(){return{html:{default:"",parseHTML:n=>n.outerHTML,renderHTML:()=>({})}}},parseHTML(){return[...Qw,"figure"].map(n=>({tag:n,priority:10}))},renderHTML({node:n}){const e=$o().createElement("template");return e.innerHTML=String(n.attrs.html??""),e.content},addCommands(){return{insertRawHtml:n=>({commands:e})=>e.insertContent({type:this.name,attrs:{html:n}})}},addNodeView(){const n=this.options.labels;return({node:e})=>{const t=document.createElement("div");t.className="blogeditor__raw",t.contentEditable="false";const r=document.createElement("div");r.className="blogeditor__card-head";const i=document.createElement("span");i.textContent=n.rawHtmlCard;const s=document.createElement("button");s.type="button",s.textContent=n.editAsHtml,r.append(i,s);const o=document.createElement("pre");o.className="blogeditor__raw-source",o.textContent=String(e.attrs.html??""),t.append(r,o);let l=e;return s.addEventListener("click",a=>{a.preventDefault(),t.dispatchEvent(new CustomEvent(Ys,{bubbles:!0,detail:{html:String(l.attrs.html??"")}}))}),{dom:t,update:a=>a.type!==l.type?!1:(l=a,o.textContent=String(a.attrs.html??""),!0),stopEvent:a=>a.target===s,ignoreMutation:()=>!0}}}}),c1=new Set(["data-embed","data-id","data-aspect","data-height"]),d1=new Set(["src","alt","width","height"]);function u1(n,e){const t=n.getAttribute("data-embed")??"",r=n.getAttribute("data-id")??"";if(!Co(e,t,r))return null;for(const h of Array.from(n.attributes))if(!c1.has(h.name.toLowerCase()))return null;const i=n.getAttribute("data-aspect")?.trim()??"";if(i!==""&&!$r(i))return null;const s=n.getAttribute("data-height")?.trim()??"";if(s!==""&&!Br(s))return null;let o=null,l=null,a=null,c=null,d=null,u=!1,f=!1;for(const h of Array.from(n.childNodes)){if(h.nodeType===3){if(/[^ \t\r\n\f]/.test(h.nodeValue??""))return null;continue}if(h.nodeType!==1)return null;const p=h;if(p.nodeName==="IMG"&&!u){for(const b of Array.from(p.attributes))if(!d1.has(b.name.toLowerCase()))return null;const m=p.getAttribute("src")?.trim()??"";if(!m||/^\s*data:/i.test(m)||!Pe(m))return null;u=!0,o=m,l=p.getAttribute("alt")??"";const g=p.getAttribute("width")?.trim()??"",y=p.getAttribute("height")?.trim()??"";a=g||null,c=y||null;continue}if(p.nodeName==="FIGCAPTION"&&!f){if(p.attributes.length>0||p.children.length>0)return null;f=!0,d=p.textContent??"";continue}return null}return{provider:t,id:r,aspect:i||null,height:s||null,fallbackSrc:o,fallbackAlt:l,fallbackWidth:a,fallbackHeight:c,caption:d&&d.trim()!==""?d:null}}const f1=U.create({name:"embed",group:"block",atom:!0,selectable:!0,draggable:!0,priority:70,addOptions(){return{labels:Jn("en"),providers:an}},addAttributes(){return{provider:{default:null,renderHTML:()=>({})},id:{default:null,renderHTML:()=>({})},aspect:{default:null,renderHTML:()=>({})},height:{default:null,renderHTML:()=>({})},fallbackSrc:{default:null,renderHTML:()=>({})},fallbackAlt:{default:null,renderHTML:()=>({})},fallbackWidth:{default:null,renderHTML:()=>({})},fallbackHeight:{default:null,renderHTML:()=>({})},caption:{default:null,renderHTML:()=>({})}}},parseHTML(){const n=this.options.providers;return[{tag:"figure[data-embed]",priority:70,getAttrs:e=>{const t=u1(e,n);return t?{...t}:!1}}]},renderHTML({node:n}){const e={"data-embed":String(n.attrs.provider??""),"data-id":String(n.attrs.id??"")},t=typeof n.attrs.aspect=="string"?n.attrs.aspect.trim():"";t&&$r(t)&&(e["data-aspect"]=t);const r=typeof n.attrs.height=="string"?n.attrs.height.trim():"";r&&Br(r)&&(e["data-height"]=r);const i=[],s=typeof n.attrs.fallbackSrc=="string"?n.attrs.fallbackSrc.trim():"";if(s&&Pe(s)){const l={src:s,alt:typeof n.attrs.fallbackAlt=="string"?n.attrs.fallbackAlt:""},a=typeof n.attrs.fallbackWidth=="string"?n.attrs.fallbackWidth.trim():"",c=typeof n.attrs.fallbackHeight=="string"?n.attrs.fallbackHeight.trim():"";a&&(l.width=a),c&&(l.height=c),i.push(["img",l])}const o=typeof n.attrs.caption=="string"?n.attrs.caption.trim():"";return o&&i.push(["figcaption",{},o]),i.length===0?["figure",e]:["figure",e,...i]},addCommands(){const n=this.options.providers;return{setEmbed:e=>({commands:t})=>{const r=String(e.provider??"").trim(),i=String(e.id??"").trim();if(!Co(n,r,i))return!1;const s=e.aspect&&$r(e.aspect)?e.aspect.trim():null,o=e.height&&Br(e.height)?e.height.trim():null,l=e.fallbackSrc?.trim()??"",a=l&&Pe(l)?l:null,c=a?e.fallbackAlt??"":null,d=a&&e.fallbackWidth?String(e.fallbackWidth).trim():null,u=a&&e.fallbackHeight?String(e.fallbackHeight).trim():null,f=e.caption?.trim()?e.caption.trim():null;return t.insertContent({type:this.name,attrs:{provider:r,id:i,aspect:s,height:o,fallbackSrc:a,fallbackAlt:c,fallbackWidth:d,fallbackHeight:u,caption:f}})}}},addNodeView(){const n=this.options.labels,e=this.options.providers;return({node:t})=>{const r=document.createElement("div");r.className="blogeditor__embed",r.contentEditable="false";const i=o=>{const l=String(o.attrs.provider??""),a=String(o.attrs.id??""),c=Qt(e,l),d=c?c.name:l,u=typeof o.attrs.aspect=="string"?o.attrs.aspect.trim():"",f=typeof o.attrs.height=="string"?o.attrs.height.trim():"",h=typeof o.attrs.fallbackSrc=="string"?o.attrs.fallbackSrc.trim():"",p=typeof o.attrs.fallbackAlt=="string"?o.attrs.fallbackAlt:"",m=typeof o.attrs.caption=="string"?o.attrs.caption.trim():"";if(r.replaceChildren(),!u&&!f&&!h&&!m){r.textContent=`${n.embedCard}: ${d} ${a}`;return}const g=document.createElement("div");g.className="blogeditor__embed-head";const y=document.createElement("span");y.textContent=`${n.embedCard}: ${d} ${a}`,g.append(y);const b=[u,f].filter(Boolean).join(" · ");if(b){const k=document.createElement("span");k.className="blogeditor__embed-badge",k.textContent=b,g.append(k)}if(r.append(g),h&&Pe(h)){const k=document.createElement("img");k.className="blogeditor__embed-thumb",k.setAttribute("src",h),k.setAttribute("alt",p),r.append(k)}if(m){const k=document.createElement("p");k.className="blogeditor__embed-caption",k.textContent=m,r.append(k)}};i(t);let s=t;return{dom:r,update:o=>o.type!==s.type?!1:(s=o,i(o),!0),ignoreMutation:()=>!0}}}});function h1(n){if(n.hasAttribute("data-embed"))return!1;const e=[];for(const i of Array.from(n.childNodes))if(i.nodeType===1)e.push(i);else{if(i.nodeType===3&&/[^ \t\r\n\f]/.test(i.nodeValue??""))return!1;if(i.nodeType!==3)return!1}if(e.length<1||e.length>2)return!1;const t=e[0];if(t.nodeName!=="IMG")return!1;const r=t.getAttribute("src");return!r||/^\s*data:/i.test(r)?!1:e.length===1||e[1].nodeName==="FIGCAPTION"}const p1=U.create({name:"figure",group:"block",content:"figureImage figcaption?",draggable:!0,isolating:!0,priority:60,parseHTML(){return[{tag:"figure",priority:60,getAttrs:n=>h1(n)?null:!1}]},renderHTML({HTMLAttributes:n}){return["figure",n,0]},addCommands(){return{setFigure:({src:n,alt:e,caption:t,width:r,height:i})=>({commands:s})=>{const o={src:n,alt:e};r!=null&&r!==""&&(o.width=String(r)),i!=null&&i!==""&&(o.height=String(i));const l=[{type:"figureImage",attrs:o}];return t&&l.push({type:"figcaption",content:[{type:"text",text:t}]}),s.insertContent({type:this.name,content:l})}}}}),m1=U.create({name:"figureImage",atom:!0,selectable:!1,priority:60,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:'img[src]:not([src^="data:"])',context:"figure/",priority:60}]},renderHTML({HTMLAttributes:n}){return["img",n]},addNodeView(){return typeof document>"u"?null:({node:n,getPos:e,HTMLAttributes:t,editor:r})=>{const i=document.createElement("img");i.draggable=!1;for(const[s,o]of Object.entries(t))o!=null&&s!=="width"&&s!=="height"&&i.setAttribute(s,String(o));return new du({element:i,editor:r,node:n,getPos:e,onResize:(s,o)=>{i.style.width=`${s}px`,i.style.height=`${o}px`},onCommit:(s,o)=>{const l=e();if(typeof l!="number")return;const a=r.state.doc.nodeAt(l);a&&r.view.dispatch(r.state.tr.setNodeMarkup(l,void 0,{...a.attrs,width:s,height:o}))},onUpdate:s=>{if(s.type!==n.type)return!1;for(const o of["src","alt","title"]){const l=s.attrs[o];l!=null?i.setAttribute(o,String(l)):i.removeAttribute(o)}return!0},options:{directions:["top-left","top-right","bottom-left","bottom-right"],min:{width:48,height:48},preserveAspectRatio:!0}})}}}),g1=U.create({name:"figcaption",content:"inline*",priority:60,parseHTML(){return[{tag:"figcaption",context:"figure/"}]},renderHTML({HTMLAttributes:n}){return["figcaption",n,0]}}),y1=Ru.extend({renderHTML({HTMLAttributes:n}){return["table",F(this.options.HTMLAttributes,n),["tbody",0]]}});function pf(n){const{align:e,...t}=n??{};return t}const b1=Au.extend({addAttributes(){return pf(this.parent?.())}}),k1=Tu.extend({addAttributes(){return pf(this.parent?.())}}),mf=[2,3,4];function w1(n){const e=n.includes(1);return[1,2,3,4,5,6].filter(t=>t>1||e)}const S1=U.create({name:"headingOneAsTwo",content:"inline*",parseHTML(){return[{tag:"h1",node:"heading",getAttrs:n=>({level:2,htmlAttrs:gi(n,[])})}]},renderHTML(){return["h2",0]}}),x1=bb.extend({addAttributes(){return{...this.parent?.(),width:{default:null},height:{default:null}}}});function C1(n=Jn("en"),e=mf,t=an){const r=w1(e);return[Gw.configure({trailingNode:!1,heading:{levels:r},link:{openOnClick:!1,HTMLAttributes:{target:null,rel:null,class:null},isAllowedUri:i=>Pe(i)}}),...r.includes(1)?[]:[S1],x1.configure({inline:!0,allowBase64:!1,resize:{enabled:!0,directions:["top-left","top-right","bottom-left","bottom-right"],minWidth:48,minHeight:48,alwaysPreserveAspectRatio:!0}}),y1,Nu,k1,b1,p1,m1,g1,f1.configure({labels:n,providers:t}),a1.configure({labels:n}),l1,o1]}const v1=80,E1={ą:"a",ć:"c",ę:"e",ł:"l",ń:"n",ó:"o",ś:"s",ź:"z",ż:"z"};function cs(n){let e="",t=!1;for(const r of n.toLowerCase()){const i=E1[r]??r;/^[a-z0-9]$/.test(i)?(e+=i,t=!1):t||(e+="-",t=!0)}return e=e.replace(/^-+|-+$/g,"").slice(0,v1).replace(/-+$/,""),e===""?"image":e}function M1(n){const e=n.replace(/\\/g,"/").split("/").pop()??"",t=e.lastIndexOf(".");if(t>=0){const r=e.slice(t).toLowerCase();if(/^\.[a-z0-9]+$/.test(r))return{stem:e.slice(0,t),ext:r}}return{stem:e,ext:""}}function A1(n,e,t){const r=document.createElement("div");r.className="blogeditor__form",r.dataset.form="image",r.hidden=!0;const i=(m,g)=>{const y=document.createElement("label"),b=document.createElement("span");b.textContent=g;const k=document.createElement("input");return k.type="text",k.name=m,k.autocomplete="off",y.append(b,k),{label:y,input:k}},s=i("fileName",n.fileName);s.label.classList.add("blogeditor__filename");const o=document.createElement("span");o.className="blogeditor__filename-row";const l=document.createElement("span");l.className="blogeditor__ext",o.append(s.input,l);const a=document.createElement("span");a.className="blogeditor__hint",a.textContent=n.fileNameHint,s.label.append(o,a),s.input.addEventListener("blur",()=>{s.input.value=cs(s.input.value)});const c=i("alt",n.altText),d=document.createElement("label");d.className="blogeditor__check";const u=document.createElement("input");u.type="checkbox",u.name="decorative",d.append(u,document.createTextNode(n.decorative)),u.addEventListener("change",()=>{u.checked&&(c.input.value=""),c.input.disabled=u.checked,u.checked&&(p.textContent="")});const f=i("caption",n.caption),h=(m,g,y)=>{const b=document.createElement("button");return b.type="button",b.dataset.action=m,b.textContent=g,b.addEventListener("click",y),b},p=document.createElement("p");return p.className="blogeditor__error",p.dataset.error="",p.setAttribute("aria-live","polite"),r.append(s.label,c.label,d,f.label,h("insert",n.insertImage,e),h("cancel",n.cancel,t),p),{root:r,error:p,open:m=>{const g=M1(m.name);s.input.value=cs(g.stem),l.textContent=g.ext,c.input.value="",c.input.disabled=!1,u.checked=!1,f.input.value="",p.textContent="",r.hidden=!1,c.input.focus()},choice:()=>{s.input.value=cs(s.input.value);const m=c.input.value.trim();return!u.checked&&m===""?(p.textContent=n.altRequired,null):(p.textContent="",{fileName:s.input.value+l.textContent,alt:u.checked?"":m,caption:f.input.value.trim(),decorative:u.checked})}}}const T1=300,N1=["m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3","M12 9v4","M12 17h.01"];function gf(n){return n.toLowerCase().replace(/[\p{P}\p{S}]+/gu,"").replace(/\s+/g," ").trim()}function yf(n,e){const t=gf(n);return t!==""&&e.includes(t)}function O1(n){const e=[],t=[];return n.state.doc.descendants((r,i)=>{if(r.type.name==="heading"){let s=0,o=0;r.descendants(l=>{if(!l.isText)return!0;const a=(l.text??"").replace(/\s+/g,"").length;return o+=a,l.marks.some(c=>c.type.name==="link")&&(s+=a),!1}),e.push({level:Number(r.attrs.level)||2,text:r.textContent.trim(),linkOnly:o>0&&s===o,pos:i})}if(r.isTextblock){let s="",o=null;const l=()=>{s.trim()!==""&&t.push(s),s="",o=null};return r.forEach(a=>{const c=a.isText?a.marks.find(d=>d.type.name==="link"):void 0;if(c&&c.attrs.href===o){s+=a.text??"";return}l(),c&&(s=a.text??"",o=c.attrs.href)}),l(),!1}return!0}),{headings:e,links:t}}function R1(n){const t=document.implementation.createHTMLDocument("").createElement("div");t.innerHTML=n;const r=[];for(const s of Array.from(t.querySelectorAll("h1, h2, h3, h4, h5, h6"))){const o=(s.textContent??"").replace(/\s+/g," ").trim(),l=Array.from(s.querySelectorAll("a")).map(a=>a.textContent??"").join("").replace(/\s+/g,"");r.push({level:Number(s.tagName.slice(1)),text:o,linkOnly:o!==""&&l.length===o.replace(/\s+/g,"").length,pos:-1})}const i=Array.from(t.querySelectorAll("a")).map(s=>s.textContent??"").filter(s=>s.trim()!=="");return{headings:r,links:i}}function L1(n,e,t){let r=1;return n.headings.map(i=>{const s=[];return i.level>r+1&&s.push(Lt(e.flagSkipped,{from:String(r),to:String(i.level)})),i.text===""?s.push(e.flagEmpty):i.linkOnly&&s.push(e.flagLinkOnly),i.level===1&&!t.allowsH1&&t.source&&s.push(e.flagH1),r=i.level,s})}function Bo(){const n="http://www.w3.org/2000/svg",e=document.createElementNS(n,"svg");e.setAttribute("class","blogeditor__alert"),e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("width","14"),e.setAttribute("height","14"),e.setAttribute("fill","none"),e.setAttribute("stroke","currentColor"),e.setAttribute("stroke-width","2"),e.setAttribute("stroke-linecap","round"),e.setAttribute("stroke-linejoin","round"),e.setAttribute("aria-hidden","true");for(const t of N1){const r=document.createElementNS(n,"path");r.setAttribute("d",t),e.append(r)}return e}function Ha(n){const e=document.createElement("span");return e.className="blogeditor__outline-flag",e.append(Bo(),document.createTextNode(n)),e}function I1(n){const{labels:e}=n,t=document.createElement("div");t.className="blogeditor__outline";const r=document.createElement("button");r.type="button",r.className="blogeditor__outline-toggle",r.setAttribute("aria-expanded","false"),r.title=e.outlineShow;const i=document.createElement("span");i.className="blogeditor__outline-summary";const s=document.createElement("span");s.className="blogeditor__outline-problems",s.hidden=!0,r.append(i,s);const o=document.createElement("div");o.className="blogeditor__outline-panel",o.hidden=!0,o.id=`blogeditor-outline-${Math.random().toString(36).slice(2)}`,r.setAttribute("aria-controls",o.id),r.addEventListener("click",()=>{const u=o.hidden;o.hidden=!u,r.setAttribute("aria-expanded",String(u)),r.title=u?e.outlineHide:e.outlineShow,u&&d()}),t.append(r,o);let l;const a=(u,f)=>{const h=L1(u,e,{allowsH1:n.allowsH1,source:f}),p=u.links.filter(y=>yf(y,n.genericAnchors)),m=h.reduce((y,b)=>y+b.length,0)+p.length;if(i.textContent=`${e.outline} · ${$a(e,e.outlineCount,u.headings.length)}`,s.hidden=m===0,s.replaceChildren(...m>0?[Bo(),document.createTextNode($a(e,e.outlineProblems,m))]:[]),o.hidden)return;const g=[];if(u.headings.length===0){const y=document.createElement("p");y.className="blogeditor__outline-empty",y.textContent=e.outlineEmpty,g.push(y)}else{const y=n.allowsH1?1:2,b=document.createElement("ol");b.className="blogeditor__outline-list",u.headings.forEach((k,S)=>{const v=document.createElement("li");v.className="blogeditor__outline-item",v.style.setProperty("--blogeditor-outline-depth",String(Math.max(0,k.level-y)));const L=document.createElement("button");L.type="button",L.className="blogeditor__outline-target";const E=document.createElement("span");E.className="blogeditor__outline-level",E.textContent=`H${k.level}`;const R=document.createElement("span");R.className=k.text===""?"blogeditor__outline-text blogeditor__outline-text--empty":"blogeditor__outline-text",R.textContent=k.text===""?e.flagEmpty:k.text,L.append(E,R),L.addEventListener("click",()=>c(k)),v.append(L);const D=k.text===""?h[S].filter(P=>P!==e.flagEmpty):h[S];if(D.length>0){const P=document.createElement("span");P.className="blogeditor__outline-flags",P.append(...D.map(Ha)),v.append(P)}b.append(v)}),g.push(b)}if(p.length>0){const y=document.createElement("div");y.className="blogeditor__outline-links";const b=document.createElement("p");b.className="blogeditor__outline-heading",b.textContent=e.outlineLinks,y.append(b,...p.map(k=>Ha(Lt(e.flagGeneric,{text:k.trim()})))),g.push(y)}o.replaceChildren(...g)},c=u=>{const f=n.editor();!f||u.pos<0||n.sourceText()!==null||f.chain().focus().setTextSelection(u.pos+1).scrollIntoView().run()},d=()=>{clearTimeout(l),l=void 0;const u=n.sourceText(),f=n.editor();u!==null?a(R1(u),!0):f&&a(O1(f),!1)};return{element:t,schedule:()=>{clearTimeout(l),l=setTimeout(d,T1)},refresh:d,stop:()=>{clearTimeout(l),l=void 0}}}const Xs=["nofollow","sponsored","ugc"];function Fa(n){const e=n.trim();if(!/^https?:\/\//i.test(e))return!1;try{return new URL(e).host!==""}catch{return!1}}function D1(n){if(typeof n!="string")return[];const e=n.toLowerCase().split(/\s+/);return Xs.filter(t=>e.includes(t))}function P1(n,e){const t=document.createElement("fieldset");t.className="blogeditor__rel";const r=document.createElement("legend");r.textContent=n.linkRel,t.append(r);const i=new Map,s={nofollow:n.relNofollow,sponsored:n.relSponsored,ugc:n.relUgc};for(const c of Xs){const d=document.createElement("label");d.className="blogeditor__check";const u=document.createElement("input");u.type="checkbox",u.name=`rel-${c}`,u.value=c,d.append(u,document.createTextNode(s[c])),t.append(d),i.set(c,u)}const o=document.createElement("p");o.className="blogeditor__hint",o.textContent=n.relHint,t.append(o);const l=document.createElement("p");return l.className="blogeditor__warning",l.dataset.warning="",l.setAttribute("aria-live","polite"),l.hidden=!0,{fieldset:t,warning:l,setUrl:c=>{const d=Fa(c);for(const u of i.values())u.disabled=!d;o.hidden=d},setRel:c=>{const d=D1(c);for(const[u,f]of i)f.checked=d.includes(u)},rel:c=>{if(!Fa(c))return null;const d=Xs.filter(u=>i.get(u).checked);return d.length>0?d.join(" "):null},setText:c=>{const d=yf(c,e);l.hidden=!d,l.replaceChildren(...d?[Bo(),document.createTextNode(Lt(n.genericWarning,{text:c.trim()}))]:[])}}}const z1="",$1="default-src 'none'; img-src * data:; style-src 'unsafe-inline'",B1=300,Dn={colors:{surface:"#ffffff",text:"#1a1a1a",muted:"#6b7280",border:"#e5e7eb",borderStrong:"#9ca3af",subtle:"#f6f7f9",primary:"#2563eb"},fontFamily:'system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif'},_a={surface:"--c-surface",text:"--c-text",muted:"--c-muted",border:"--c-border",borderStrong:"--c-border-strong",subtle:"--c-subtle",primary:"--c-primary"},H1="script, iframe, frame, frameset, object, embed, meta, base, link",F1=/^[A-Za-z]{2,3}(-[A-Za-z0-9]{1,8})*$/;function Va(n,e){const t=(n??"").trim();return t===""||t.length>200||/[<>{};\\]/.test(t)||t.includes("/*")?e:t}function _1(n){const e=getComputedStyle(n),t={...Dn.colors};for(const r of Object.keys(_a))t[r]=Va(e.getPropertyValue(_a[r]),Dn.colors[r]);return{colors:t,fontFamily:Va(e.fontFamily,Dn.fontFamily)}}function V1(n){return`https://img.youtube.com/vi/${n}/hqdefault.jpg`}function W1(n,e,t=an){const r=$o(),i=r.createElement("template");i.innerHTML=n;const s=i.content;for(const l of Array.from(s.querySelectorAll(H1)))l.remove();for(const l of Array.from(s.querySelectorAll("*")))for(const a of Array.from(l.attributes))a.name.toLowerCase().startsWith("on")&&l.removeAttribute(a.name);for(const l of Array.from(s.querySelectorAll("figure[data-embed]"))){const a=l.getAttribute("data-embed")??"",c=l.getAttribute("data-id")??"";if(!Co(t,a,c))continue;const u=Qt(t,a)?.name??a,f=l.querySelector("img[src]"),h=f?.getAttribute("src")?.trim()??"",p=l.querySelector("figcaption")?.textContent?.trim()??"";if(f&&h!==""&&Pe(h)){const S=r.createElement("figure");S.className="embed-card";const v=r.createElement("img");v.setAttribute("src",h),v.setAttribute("alt",f.getAttribute("alt")??"");const L=f.getAttribute("width"),E=f.getAttribute("height");L&&v.setAttribute("width",L),E&&v.setAttribute("height",E),v.setAttribute("referrerpolicy","no-referrer"),v.setAttribute("loading","lazy");const R=r.createElement("figcaption");R.textContent=p||`${e.embedCard}: ${u} ${c}`,S.append(v,R),l.replaceWith(S);continue}if(a==="youtube"&&l.childNodes.length===0){const S=r.createElement("figure");S.className="embed-card";const v=r.createElement("img");v.setAttribute("src",V1(c)),v.setAttribute("alt",""),v.setAttribute("referrerpolicy","no-referrer"),v.setAttribute("loading","lazy"),v.setAttribute("width","480"),v.setAttribute("height","360");const L=r.createElement("figcaption");L.textContent=`${e.embedCard}: ${u} ${c}`,S.append(v,L),l.replaceWith(S);continue}const m=r.createElement("figure");m.className="embed-card";const g=r.createElement("div");g.className="embed-card__placeholder";const y=l.getAttribute("data-aspect")?.trim()??"",b=l.getAttribute("data-height")?.trim()??"",k=[y,b].filter(Boolean).join(" · ");if(g.textContent=k?`${u}: ${c} (${k})`:`${u}: ${c}`,m.append(g),p){const S=r.createElement("figcaption");S.textContent=p,m.append(S)}l.replaceWith(m)}const o=r.createElement("div");return o.append(s),o.innerHTML}function j1(n,e){const t='"DM Mono", ui-monospace, SFMono-Regular, Menlo, monospace';return[`body{margin:0;padding:16px 20px;background:${n.surface};color:${n.text};font-family:${e};font-size:16px;line-height:1.7;overflow-wrap:anywhere}`,".post-body{max-width:72ch;margin-left:auto;margin-right:auto}","h1,h2,h3,h4{font-weight:600;margin:1.4em 0 0.5em}","h1{font-size:1.875em}h2{font-size:1.5em}h3{font-size:1.25em}h4{font-size:1.1em}","p,ul,ol,blockquote,table,figure,pre{margin:0 0 1em}","ul{list-style:disc;padding-left:1.5em}ol{list-style:decimal;padding-left:1.5em}",`a{color:${n.primary};text-decoration:underline}`,`blockquote{border-left:3px solid ${n.borderStrong};padding-left:1em;color:${n.muted}}`,`code{padding:0 4px;border-radius:4px;background:${n.subtle};font-family:${t};font-size:0.9em}`,`pre{padding:8px 12px;border-radius:8px;background:${n.subtle};font-family:${t};overflow:auto}`,"pre code{padding:0;background:transparent}",`hr{border:0;border-top:1px solid ${n.borderStrong}}`,"img{max-width:100%;height:auto}","table{border-collapse:collapse;width:100%}",`td,th{border:1px solid ${n.borderStrong};padding:4px 8px;vertical-align:top}`,`th{background:${n.subtle};font-weight:600;text-align:left}`,`figcaption{font-size:13px;color:${n.muted};margin-top:4px}`,`.embed-card{max-width:480px;border:1px solid ${n.border};border-radius:8px;overflow:hidden;background:${n.subtle}}`,".embed-card img{display:block;width:100%;height:auto;aspect-ratio:16/9;object-fit:cover}",`.embed-card__placeholder{padding:24px 16px;text-align:center;font-size:14px;color:${n.muted}}`,".embed-card figcaption{padding:8px 12px;margin:0}"].join(` -`)}function U1(n,e){const t=e.lang&&F1.test(e.lang)?` lang="${e.lang}"`:"",r={...Dn.colors,...e.colors},i=e.fontFamily||Dn.fontFamily;return`
${W1(n,e.labels,e.providers)}
`}const bf=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),kf=new Set(["script","style","textarea","title","xmp","iframe","noembed","noframes"]),wf=/^<\/?([a-zA-Z][^\s/>]*)/;function yi(n,e){let t="",r="";for(let i=e+1;i")return i+1;/\s/.test(s)||(r=s)}return-1}function Sf(n,e,t){const r=new RegExp(`])`,"ig");r.lastIndex=e;const i=r.exec(n);return i?yi(n,i.index):-1}function K1(n,e,t){const r=[t];let i=e;for(;r.length>0;){const s=n.indexOf("<",i);if(s<0)return-1;if(n.startsWith("",s+4);if(c<0)return-1;i=c+3;continue}const o=wf.exec(n.slice(s,s+64));if(!o){i=s+1;continue}const l=o[1].toLowerCase(),a=yi(n,s);if(a<0)return-1;if(i=a,n[s+1]==="/"){const c=r.lastIndexOf(l);c>=0&&(r.length=c);continue}if(!(bf.has(l)||n[a-2]==="/")){if(kf.has(l)){if(i=Sf(n,a,l),i<0)return-1;continue}r.push(l)}}return i}function q1(n){const e=[];let t=0;for(;t",t+4);if(i<0)return null;t=i+3}else if(n.startsWith("")}function Wa(n,e){const t=q1(n);if(!t)return null;const r=vt(n).innerHTML,i=t.map(c=>vt(c).innerHTML).join("");if(r!==i)return null;const s=Je.fromSchema(e),o=t.map(c=>{if(J1(c))return{html:c,nodes:[]};const d=[];return s.parseSlice(vt(c)).content.forEach(u=>d.push(u)),{html:c,nodes:d}}),l=[];let a="";for(const c of o){if(c.nodes.length===0){a+=c.html;continue}l.push({before:a,html:c.html,nodes:c.nodes}),a=""}return{blocks:l,trailing:a}}function G1(n){for(const e of Array.from(n.querySelectorAll("table"))){const t=Array.from(e.children).find(i=>i.nodeName==="TBODY"),r=t?.firstElementChild;if(t&&r&&r.children.length>0&&Array.from(r.children).every(i=>i.nodeName==="TH")){const i=e.ownerDocument.createElement("thead");i.append(r),e.insertBefore(i,t),t.children.length===0&&t.remove()}}for(const e of Array.from(n.querySelectorAll("td, th"))){const t=e.childNodes.length===1?e.firstChild:null;t&&t.nodeName==="P"&&t.attributes.length===0&&e.replaceChildren(...Array.from(t.childNodes))}}function Y1(n,e){if(n.type.name==="rawHtml")return String(n.attrs.html??"");const t=$o(),r=t.createElement("div");return r.appendChild(e.serializeNode(n,{document:t})),G1(r),r.innerHTML}function ds(n,e,t){if(t+n.length>e.length)return!1;for(let r=0;rr&&l-n[o-1].nodes.length>=i&&ds(n[o-1].nodes,e,l-n[o-1].nodes.length);)o--,l-=n[o].nodes.length,s.unshift({block:o,node:l});const a=o-r,c=l-i;if(a>0&&c>0){const d=c+1,u=new Int32Array((a+1)*d),f=(m,g)=>ds(n[r+m].nodes,e,i+g)&&i+g+n[r+m].nodes.length<=l;for(let m=a-1;m>=0;m--)for(let g=c-1;g>=0;g--){let y=Math.max(u[(m+1)*d+g],u[m*d+g+1]);if(f(m,g)){const b=n[r+m].nodes.length;y=Math.max(y,b+u[(m+1)*d+g+b])}u[m*d+g]=y}let h=0,p=0;for(;h=u[h*d+p+1]?h++:p++}}return t.concat(s)}function Q1(n,e){const t=mt.fromSchema(n.schema),r=[];n.state.doc.forEach(d=>r.push(d));const i=e?.blocks??[],s=X1(i,r);let o="",l=0,a=0;const c=(d,u)=>{if(u>a){d>l&&(o+=i[l].before);for(let f=a;f0||r.length===0)&&(o+=e.trailing),o}const pn=n=>n.isActive("table");function yr(n){return{command:`heading${n}`,glyph:`H${n}`,label:`heading${n}`,run:e=>e.chain().focus().toggleHeading({level:n}).run(),active:e=>e.isActive("heading",{level:n})}}function Z1(n){const e=/^heading([1-6])$/.exec(n);return e?Number(e[1]):0}const eS=[[{command:"paragraph",glyph:"P",label:"paragraph",run:n=>n.chain().focus().setParagraph().run(),active:n=>n.isActive("paragraph")},yr(1),yr(2),yr(3),yr(4)],[{command:"bold",glyph:"B",label:"bold",run:n=>n.chain().focus().toggleBold().run(),active:n=>n.isActive("bold")},{command:"italic",glyph:"I",label:"italic",run:n=>n.chain().focus().toggleItalic().run(),active:n=>n.isActive("italic")},{command:"link",glyph:"Link",label:"link",run:(n,e)=>e.openLink(),active:n=>n.isActive("link"),host:!0}],[{command:"bulletList",glyph:"•",label:"bulletList",run:n=>n.chain().focus().toggleBulletList().run(),active:n=>n.isActive("bulletList")},{command:"orderedList",glyph:"1.",label:"orderedList",run:n=>n.chain().focus().toggleOrderedList().run(),active:n=>n.isActive("orderedList")},{command:"blockquote",glyph:"“”",label:"blockquote",run:n=>n.chain().focus().toggleBlockquote().run(),active:n=>n.isActive("blockquote")}],[{command:"insertTable",glyph:"Table",label:"insertTable",run:n=>n.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},{command:"addRow",glyph:"+Row",label:"addRow",run:n=>n.chain().focus().addRowAfter().run(),enabled:pn},{command:"deleteRow",glyph:"−Row",label:"deleteRow",run:n=>n.chain().focus().deleteRow().run(),enabled:pn},{command:"addColumn",glyph:"+Col",label:"addColumn",run:n=>n.chain().focus().addColumnAfter().run(),enabled:pn},{command:"deleteColumn",glyph:"−Col",label:"deleteColumn",run:n=>n.chain().focus().deleteColumn().run(),enabled:pn},{command:"deleteTable",glyph:"×Table",label:"deleteTable",run:n=>n.chain().focus().deleteTable().run(),enabled:pn}],[{command:"image",glyph:"Image",label:"image",run:(n,e)=>e.pickImage(),host:!0},{command:"mediaLibrary",glyph:"Library",label:"mediaLibrary",run:(n,e)=>e.pickFromMediaLibrary(),host:!0},{command:"embed",glyph:"Video",label:"embed",run:(n,e)=>e.openEmbed(),host:!0},{command:"rawHtml",glyph:"HTML",label:"rawHtml",run:(n,e)=>e.insertRawHtml(),host:!0}],[{command:"undo",glyph:"Undo",label:"undo",run:n=>n.chain().focus().undo().run(),enabled:n=>n.can().undo()},{command:"redo",glyph:"Redo",label:"redo",run:n=>n.chain().focus().redo().run(),enabled:n=>n.can().redo()}]];function tS(n){const{labels:e}=n,t=document.createElement("div");t.className="blogeditor__bar";const r=document.createElement("div");r.className="blogeditor__tools",r.setAttribute("role","toolbar"),r.setAttribute("aria-label",e.toolbar);const i=[];for(const p of eS){const m=document.createElement("div");m.className="blogeditor__group";for(const g of p){const y=Z1(g.command);if(y>0&&!n.headingLevels.includes(y))continue;const b=document.createElement("button");b.type="button",b.dataset.command=g.command,b.textContent=g.glyph,b.title=e[g.label],b.setAttribute("aria-label",e[g.label]),b.addEventListener("mousedown",k=>k.preventDefault()),b.addEventListener("click",()=>{const k=n.editor();k&&(!g.host&&!k.isEditable||g.run(k,n))}),m.append(b),i.push({spec:g,button:b})}r.append(m)}const s=document.createElement("div");s.className="blogeditor__tabs",s.setAttribute("role","tablist");const o=(p,m)=>{const g=document.createElement("button");return g.type="button",g.dataset.tab=p,g.setAttribute("role","tab"),g.textContent=m,g.addEventListener("click",()=>n.showSource(p==="source")),s.append(g),g},l=o("wysiwyg",e.tabWysiwyg),a=o("source",e.tabSource),c=document.createElement("div");c.className="blogeditor__view";const d=document.createElement("button");d.type="button",d.dataset.command="preview",d.textContent=e.preview,d.title=e.preview,d.setAttribute("aria-label",e.preview),d.setAttribute("aria-pressed","false"),d.addEventListener("mousedown",p=>p.preventDefault()),d.addEventListener("click",()=>n.togglePreview()),c.append(d),t.append(r,s,c);let u=!1,f=!1;const h=()=>{const p=n.editor();for(const{spec:m,button:g}of i){m.active&&g.setAttribute("aria-pressed",String(!!p&&m.active(p)));const y=!!p&&!u&&!f&&(m.enabled?m.enabled(p):!0);g.disabled=!y}};return{element:t,refresh:h,selectTab:p=>{f=p,l.setAttribute("aria-selected",String(!p)),a.setAttribute("aria-selected",String(p)),h()},setDisabled:p=>{u=p,h()},setPreview:p=>{d.setAttribute("aria-pressed",String(p))}}}const ja="golem15-journal-blogeditor",nS="summer-change",rS="summer-upload",Ua="summer-upload-result",Ka="summer-media-pick",qa="summer-media-pick-result",xf=["image/jpeg","image/png","image/gif","image/webp"],iS=6e4,sS=["click here","here","more","read more","learn more","this link","link","kliknij tutaj","tutaj","tu","więcej","czytaj więcej","czytaj dalej","ten link"];function Ja(n){let e={};try{const i=n?JSON.parse(n):{};i&&typeof i=="object"&&!Array.isArray(i)&&(e=i)}catch{}const t=Array.isArray(e.headingLevels)?[...new Set(e.headingLevels.filter(i=>Number.isInteger(i)&&i>=1&&i<=6))].sort():[],r=Array.isArray(e.genericAnchors)?e.genericAnchors.filter(i=>typeof i=="string"):[...sS];return{headingLevels:t.length>0?t:[...mf],genericAnchors:[...new Set(r.map(gf).filter(i=>i!==""))],embedProviders:pb(e.embedProviders)}}class oS extends HTMLElement{static observedAttributes=["disabled","invalid","locale"];#x="";#C="";#M="";#A=null;#c="clean";#e;#r=Jn("en");#d;#T;#n;#N;#O;#s;#p;#t;#u;#l;#f=Ja(null);#R=!1;#h=new Map;#m=new Map;#g={width:null,height:null};#y=[];#b=!1;#L;#k;#w;#a;constructor(){if(super(),Object.prototype.hasOwnProperty.call(this,"value")){const e=this.value;delete this.value,this.value=e}}get value(){switch(this.#c){case"source":return this.#C;case"wysiwyg":return this.#e?Q1(this.#e,this.#A):this.#x;default:return this.#x}}set value(e){const t=typeof e=="string"?e:e==null?"":String(e);t!==this.value&&(this.#x=t,this.#c="clean",this.#n&&(this.#n.value=t),this.#P(t),this.#v(),this.#l?.schedule())}get editor(){return this.#e}connectedCallback(){if(this.#e)return;this.classList.add("blogeditor"),this.replaceChildren(),this.#r=Jn(this.getAttribute("ui-locale"));const e=this.#r;this.#f=Ja(this.getAttribute("options"));const t=this.#f;this.#d=tS({editor:()=>this.#e,labels:e,openLink:()=>this.#G(),openEmbed:()=>this.#ee(),pickImage:()=>this.#O?.click(),pickFromMediaLibrary:()=>this.#se(),insertRawHtml:()=>this.#te(),showSource:h=>this.showSource(h),togglePreview:()=>this.showPreview(!this.#b),headingLevels:t.headingLevels}),this.#s=this.#B("link",e.linkUrl,[["apply",e.linkApply,()=>this.#X()],["remove",e.linkRemove,()=>this.#F()],["cancel",e.cancel,()=>this.#i(this.#s)]]);const r=P1(e,t.genericAnchors);this.#p=r;const i=this.#s.root.querySelector("label");i.after(r.fieldset,r.warning),i.querySelector("input").addEventListener("input",h=>r.setUrl(h.target.value)),this.#t=this.#Q(t.embedProviders)?this.#Z(e,t.embedProviders):this.#B("embed",e.embedUrl,[["insert",e.embedInsert,()=>this.#I()],["cancel",e.cancel,()=>this.#i(this.#t)]]),this.#u=A1(e,()=>this.#ie(),()=>this.#U());const s=document.createElement("div");s.className="blogeditor__content",this.#T=s;const o=document.createElement("textarea");o.className="blogeditor__source",o.spellcheck=!1,o.hidden=!0,o.setAttribute("aria-label",e.tabSource),o.value=this.value,o.addEventListener("input",()=>this.#J()),this.#n=o;const l=document.createElement("p");l.className="blogeditor__status",l.setAttribute("role","status"),l.setAttribute("aria-live","polite"),this.#N=l;const a=document.createElement("input");a.type="file",a.accept=xf.join(","),a.multiple=!0,a.hidden=!0,a.addEventListener("change",()=>this.#ne()),this.#O=a;const c=document.createElement("div");c.className="blogeditor__main",c.append(s,o);const d=document.createElement("div");d.className="blogeditor__preview",d.hidden=!0,this.#k=d,this.#w=void 0;const u=document.createElement("div");u.className="blogeditor__panes",u.append(c,d),this.#L=u,this.#l=I1({labels:e,editor:()=>this.#e,sourceText:()=>this.#R&&this.#n?this.#n.value:null,allowsH1:t.headingLevels.includes(1),genericAnchors:t.genericAnchors}),this.append(this.#d.element,this.#s.root,this.#t.root,this.#u.root,u,this.#l.element,l,a),this.addEventListener(Ua,this.#W),this.addEventListener(qa,this.#K),this.addEventListener(Ys,this.#_);const f=this.value;this.#M=f,this.#e=new lb({element:s,injectCSS:!1,editable:!this.hasAttribute("disabled"),extensions:C1(e,t.headingLevels,t.embedProviders),content:f,editorProps:{handleDrop:(h,p,m,g)=>{if(g)return!1;const y=Array.from(p.dataTransfer?.files??[]).filter(Ga);return y.length===0?!1:(p.preventDefault(),this.#V(y),!0)}},onUpdate:({transaction:h,appendedTransactions:p})=>{!h.docChanged&&!p.some(m=>m.docChanged)||(this.#c="wysiwyg",this.#z(),this.#v(),this.#l?.schedule())},onTransaction:()=>this.#d?.refresh()}),this.#A=Wa(f,this.#e.schema),this.#$(),this.showSource(!1),this.#b&&this.showPreview(!0),this.#l.refresh()}disconnectedCallback(){this.removeEventListener(Ua,this.#W),this.removeEventListener(qa,this.#K),this.removeEventListener(Ys,this.#_);for(const{timer:e}of this.#h.values())clearTimeout(e);this.#h.clear(),this.#m.clear(),clearTimeout(this.#a),this.#a=void 0,this.#l?.stop(),this.#y=[],this.#c==="wysiwyg"&&this.#e&&(this.#x=this.value,this.#c="clean"),this.#e?.destroy(),this.#e=void 0}attributeChangedCallback(){this.#$(),this.#v()}showSource(e){!this.#n||!this.#T||(e?this.#n.value=this.value:this.#R&&this.#c==="source"&&this.#C!==this.#M&&this.#P(this.#C),this.#R=e,this.#n.hidden=!e,this.#T.hidden=e,e&&(this.#i(this.#s),this.#i(this.#t)),this.#d?.selectTab(e),this.#l?.refresh())}showPreview(e){this.#b=e,!(!this.#L||!this.#k)&&(this.#k.hidden=!e,this.#L.classList.toggle("blogeditor__panes--split",e),this.#d?.setPreview(e),e?this.#D():(clearTimeout(this.#a),this.#a=void 0))}#D(){if(clearTimeout(this.#a),this.#a=void 0,!this.#b)return;const e=this.#q();if(!e)return;const t=this.value,r=U1(t,{labels:this.#r,lang:this.getAttribute("locale"),providers:this.#f.embedProviders,..._1(this)});e.getAttribute("srcdoc")!==r&&(e.srcdoc=r)}#v(){!this.#b||!this.#w||(clearTimeout(this.#a),this.#a=setTimeout(()=>this.#D(),B1))}#q(){if(this.#w)return this.#w;if(!this.#k)return;const e=document.createElement("iframe");return e.setAttribute("sandbox",z1),e.setAttribute("referrerpolicy","no-referrer"),e.title=this.#r.previewFrame,this.#k.append(e),this.#w=e,e}#P(e){this.#M=e,this.#e&&(this.#e.chain().setMeta("addToHistory",!1).setContent(e,{emitUpdate:!1}).run(),this.#A=Wa(e,this.#e.schema))}#J(){this.#n&&(this.#C=this.#n.value,this.#c="source",this.#z(),this.#v(),this.#l?.schedule())}#z(){this.dispatchEvent(new CustomEvent(nS,{bubbles:!0,composed:!0,detail:{value:this.value}}))}#S(e){this.#N&&(this.#N.textContent=e)}#$(){const e=this.hasAttribute("disabled"),t=this.hasAttribute("invalid");this.#e&&this.#e.isEditable===e&&this.#e.setEditable(!e,!1),this.#d?.setDisabled(e),this.#n&&(this.#n.readOnly=e,t?this.#n.setAttribute("aria-invalid","true"):this.#n.removeAttribute("aria-invalid"));const r=this.#e?.view.dom;if(r){t?r.setAttribute("aria-invalid","true"):r.removeAttribute("aria-invalid");const i=this.getAttribute("locale");i?r.setAttribute("lang",i):r.removeAttribute("lang")}}#B(e,t,r){const i=document.createElement("div");i.className="blogeditor__form",i.dataset.form=e,i.hidden=!0;const s=document.createElement("label"),o=document.createElement("span");o.textContent=t;const l=document.createElement("input");l.type="text",l.name="url",l.autocomplete="off",l.addEventListener("keydown",d=>{d.key==="Enter"?(d.preventDefault(),r[0][2]()):d.key==="Escape"&&(d.preventDefault(),this.#i(c))}),s.append(o,l),i.append(s);for(const[d,u,f]of r)i.append(this.#E(d,u,f));const a=document.createElement("p");a.className="blogeditor__error",a.dataset.error="",a.setAttribute("aria-live","polite"),i.append(a);const c={root:i,error:a};return c}#E(e,t,r){const i=document.createElement("button");return i.type="button",i.dataset.action=e,i.textContent=t,i.addEventListener("click",r),i}#H(e,t=""){if(!e)return;for(const i of[this.#s,this.#t])i&&i!==e&&this.#i(i);e.error.textContent="",e.root.hidden=!1;const r=e.root.querySelector("input");r&&(r.value=t,r.focus())}#i(e){e&&(e.root.hidden=!0,e.error.textContent="")}#o(e,t="url"){return(e?.root.querySelector(`input[name="${t}"]`)?.value??"").trim()}#G(){const e=this.#e;if(!e?.isEditable)return;const t=e.getAttributes("link"),r=typeof t.href=="string"?t.href:"";this.#H(this.#s,r),this.#p?.setUrl(r),this.#p?.setRel(t.rel),this.#p?.setText(this.#Y())}#Y(){const e=this.#e;if(!e)return"";const{state:t}=e;let{from:r,to:i}=t.selection;if(e.isActive("link")){const s=t.schema.marks.link,o=t.doc.resolve(r),l=o.parent.childAfter(o.parentOffset);if(s&&l.node&&s.isInSet(l.node.marks)){const a=o.start();let c=a+l.offset,d=c+l.node.nodeSize;const u=e.getAttributes("link").href;o.parent.forEach((f,h)=>{const p=f.marks.find(y=>y.type===s);if(!p||p.attrs.href!==u)return;const m=a+h,g=m+f.nodeSize;g===c&&(c=m),m===d&&(d=g)}),r=c,i=d}}return t.doc.textBetween(r,i," ")}#X(){const e=this.#e;if(!e||!this.#s)return;const t=this.#o(this.#s);if(t===""){this.#F();return}if(!Pe(t)){this.#s.error.textContent=this.#r.linkInvalid;return}const r=this.#p?.rel(t)??null,{empty:i}=e.state.selection;i&&!e.isActive("link")?e.chain().focus().insertContent({type:"text",text:t,marks:[{type:"link",attrs:{href:t,rel:r}}]}).unsetMark("link").run():e.chain().focus().extendMarkRange("link").setLink({href:t,rel:r}).run(),this.#i(this.#s)}#F(){this.#e?.chain().focus().extendMarkRange("link").unsetLink().run(),this.#i(this.#s)}#Q(e){return e.length>1||e[0]?.key!=="youtube"||e[0]?.mode!=="url"}#Z(e,t){const r=document.createElement("div");r.className="blogeditor__form",r.dataset.form="embed",r.hidden=!0;const i=P=>{P.key==="Enter"?(P.preventDefault(),this.#I()):P.key==="Escape"&&(P.preventDefault(),this.#i(D))},s=document.createElement("label"),o=document.createElement("span");o.textContent=e.embedProvider;const l=document.createElement("select");l.name="provider";for(const P of t){const Y=document.createElement("option");Y.value=P.key,Y.textContent=P.name,l.append(Y)}s.append(o,l);const a=document.createElement("label");a.dataset.embedMode="url";const c=document.createElement("span");c.textContent=e.embedUrl;const d=document.createElement("input");d.type="text",d.name="url",d.autocomplete="off",d.addEventListener("keydown",i),a.append(c,d);const u=document.createElement("div");u.className="blogeditor__embed-fields",u.dataset.embedMode="id";const f=(P,Y,Re="")=>{const me=document.createElement("label"),xe=document.createElement("span");xe.textContent=Y;const Q=document.createElement("input");return Q.type="text",Q.name=P,Q.autocomplete="off",Re&&(Q.placeholder=Re),Q.addEventListener("keydown",i),me.append(xe,Q),{label:me,input:Q}},h=f("embedId",e.embedId),p=document.createElement("label"),m=document.createElement("span");m.textContent=e.embedFallbackImage;const g=document.createElement("div");g.className="blogeditor__embed-row";const y=document.createElement("input");y.type="text",y.name="fallbackSrc",y.autocomplete="off",y.addEventListener("keydown",i),y.addEventListener("input",()=>{this.#g={width:null,height:null}});const b=this.#E("pick-fallback",e.embedFallbackPick,()=>this.#oe());g.append(y,b),p.append(m,g);const k=f("fallbackAlt",e.embedFallbackAlt),S=f("caption",e.embedCaption),v=f("aspect",e.embedAspect,"16/9"),L=f("height",e.embedHeight,"420px");u.append(h.label,p,k.label,S.label,v.label,L.label);const E=()=>{const P=Qt(t,l.value)??t[0],Y=P?.mode==="url";a.hidden=!Y,u.hidden=Y,h.input.placeholder=P?.placeholder??"",D.error.textContent=""};l.addEventListener("change",E);const R=document.createElement("p");R.className="blogeditor__error",R.dataset.error="",R.setAttribute("aria-live","polite");const D={root:r,error:R};return r.append(s,a,u,this.#E("insert",e.embedInsert,()=>this.#I()),this.#E("cancel",e.cancel,()=>this.#i(D)),R),E(),D}#ee(){if(!this.#e?.isEditable)return;this.#g={width:null,height:null},this.#H(this.#t);const e=this.#t;if(!e)return;for(const r of Array.from(e.root.querySelectorAll("input")))r.value="";const t=e.root.querySelector('select[name="provider"]');t&&(t.dispatchEvent(new Event("change")),(Qt(this.#f.embedProviders,t.value)?.mode==="id"?e.root.querySelector('input[name="embedId"]'):e.root.querySelector('input[name="url"]'))?.focus())}#I(){if(!this.#e||!this.#t)return;const e=this.#t.root.querySelector('select[name="provider"]');if(!e){const c=mb(this.#o(this.#t));if(!c){this.#t.error.textContent=this.#r.embedInvalid;return}this.#e.chain().focus().setEmbed(c).run(),this.#i(this.#t);return}const t=Qt(this.#f.embedProviders,e.value);if(!t){this.#t.error.textContent=this.#r.embedIdInvalid;return}if(t.mode==="url"){const c=hu([t],this.#o(this.#t,"url"));if(!c){this.#t.error.textContent=this.#r.embedInvalid;return}this.#e.chain().focus().setEmbed(c).run(),this.#i(this.#t);return}const r=this.#o(this.#t,"embedId");if(!fu(this.#f.embedProviders,t.key,r)){this.#t.error.textContent=this.#r.embedIdInvalid;return}const i=this.#o(this.#t,"fallbackSrc");if(i!==""&&!Pe(i)){this.#t.error.textContent=this.#r.linkInvalid;return}const s=this.#o(this.#t,"aspect");if(s!==""&&!$r(s)){this.#t.error.textContent=this.#r.embedIdInvalid;return}const o=this.#o(this.#t,"height");if(o!==""&&!Br(o)){this.#t.error.textContent=this.#r.embedIdInvalid;return}const l=this.#o(this.#t,"fallbackAlt"),a=this.#o(this.#t,"caption");this.#e.chain().focus().setEmbed({provider:t.key,id:r,aspect:s||null,height:o||null,fallbackSrc:i||null,fallbackAlt:i?l:null,fallbackWidth:i?this.#g.width:null,fallbackHeight:i?this.#g.height:null,caption:a||null}).run(),this.#i(this.#t)}#te(){const e=this.#e;if(!e?.isEditable)return;const t=this.value,r="
";if(!e.chain().focus().insertRawHtml(r).run())return;const i=this.value;let s=0;for(;s{const t=e.detail?.html??"";this.showSource(!0);const r=this.#n;if(!r)return;r.focus();const i=t?r.value.indexOf(t):-1;i>=0&&r.setSelectionRange(i,i+t.length)};#ne(){const e=this.#O;if(!e)return;const t=Array.from(e.files??[]),r=t.filter(Ga);r.length{this.#h.delete(r)&&this.#S(Lt(this.#r.uploadTimeout,{name:i}))},iS);this.#h.set(r,{name:i,choice:t,timer:s}),this.#S(Lt(this.#r.uploading,{name:i})),this.dispatchEvent(new CustomEvent(rS,{bubbles:!0,composed:!0,detail:{id:r,file:e}}))}#W=e=>{const t=e.detail??{},r=typeof t.id=="string"?t.id:"",i=this.#h.get(r);if(!i)return;clearTimeout(i.timer),this.#h.delete(r);const s=typeof t.url=="string"?t.url:"";if(typeof t.error=="string"||!s||!Pe(s)){const c=typeof t.error=="string"&&t.error?t.error:i.name;this.#S(Lt(this.#r.uploadFailed,{error:c}));return}this.#S("");const o=this.#e;if(!o)return;const{alt:l,caption:a}=i.choice;a?o.chain().focus().setFigure({src:s,alt:l,caption:a}).run():o.chain().focus().setImage({src:s,alt:l}).run()};#j(){const e=this.#u,t=this.#y[0];!e||!e.root.hidden||!t||e.open(t)}#ie(){const e=this.#u,t=this.#y[0];if(!this.#e||!e||!t)return;const r=e.choice();if(!r)return;const i=r.fileName===t.name?t:new File([t],r.fileName,{type:t.type,lastModified:t.lastModified});this.#re(i,r),this.#U()}#U(){this.#y.shift(),this.#u&&(this.#u.root.hidden=!0),this.#j()}#se(){if(!this.#e?.isEditable)return;const e=us();this.#m.set(e,"insert"),this.dispatchEvent(new CustomEvent(Ka,{bubbles:!0,composed:!0,detail:{id:e,mode:"image",defaultFolder:"journal",showAlt:!0}}))}#oe(){if(!this.#e?.isEditable)return;const e=us();this.#m.set(e,"embedFallback"),this.dispatchEvent(new CustomEvent(Ka,{bubbles:!0,composed:!0,detail:{id:e,mode:"image",defaultFolder:"journal",showAlt:!0}}))}#K=e=>{const t=e.detail??{},r=typeof t.id=="string"?t.id:"",i=this.#m.get(r);if(!i||(this.#m.delete(r),t.cancelled===!0||!t.item))return;const s=typeof t.item.url=="string"?t.item.url.trim():"";if(!s||!Pe(s))return;const o=typeof t.item.alt=="string"?t.item.alt:"",l=typeof t.item.caption=="string"?t.item.caption.trim():"",a=typeof t.item.width=="number"&&t.item.width>0?String(t.item.width):null,c=typeof t.item.height=="number"&&t.item.height>0?String(t.item.height):null;if(i==="embedFallback"){const u=this.#t;if(!u)return;const f=u.root.querySelector('input[name="fallbackSrc"]');f&&(f.value=s);const h=u.root.querySelector('input[name="fallbackAlt"]');h&&o&&(h.value=o);const p=u.root.querySelector('input[name="caption"]');p&&l&&!p.value&&(p.value=l),this.#g={width:a,height:c};return}const d=this.#e;if(d)if(l)d.chain().focus().setFigure({src:s,alt:o,caption:l,width:a,height:c}).run();else{const u={src:s,alt:o};a&&(u.width=a),c&&(u.height=c),d.chain().focus().setImage(u).run()}}}function Ga(n){return xf.includes(n.type)}let Ya=0;function us(){const n=globalThis.crypto;if(n&&typeof n.randomUUID=="function")return n.randomUUID();if(n&&typeof n.getRandomValues=="function"){const e=n.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;const t=Array.from(e,r=>r.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}return Ya+=1,`upload-${Date.now().toString(36)}-${Ya}`}customElements.get(ja)||customElements.define(ja,oS);export{oS as BlogEditorElement,ja as TAG}; +`)})}r.push({type:"list_item",raw:s.raw,tokens:c}),i=u}else i+=1}return r}function cw(n,e){return n.map(t=>{if(t.type!=="list_item")return e.parseChildren([t])[0];const r=[];return t.tokens&&t.tokens.length>0&&t.tokens.forEach(i=>{if(i.type==="paragraph"||i.type==="list"||i.type==="blockquote"||i.type==="code")r.push(...e.parseChildren([i]));else if(i.type==="text"&&i.tokens){const s=e.parseChildren([i]);r.push({type:"paragraph",content:s})}else{const s=e.parseChildren([i]);s.length>0&&r.push(...s)}}),{type:"listItem",content:r}})}const dw=64;function Ra(n,e){const t=[];let r=0;for(;t.lengthn.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>{const e=n.getAttribute("type");if(e)return e;const t=n.getAttribute("style");if(t){const i=Da(t);if(i)return i}const r=n.querySelector("li");if(r){const i=r.getAttribute("style");if(i){const s=Da(i);if(s)return s}}return null}}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,type:t,...r}=n,i=F(this.options.HTMLAttributes,r);return e!==1&&(i.start=e),t&&t!=="1"&&(i.type=t),["ol",i,0]},markdownTokenName:"list",parseMarkdown:(n,e)=>{if(n.type!=="list"||!n.ordered)return[];const t=n.start||1,r=n.typeMarker,i=n.items?cw(n.items,e):[],s={};return t!==1&&(s.start=t),r&&(s.type=r),Object.keys(s).length>0?{type:"orderedList",attrs:s,content:i}:{type:"orderedList",content:i}},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,` +`):"",markdownTokenizer:{name:"orderedList",level:"block",start:()=>-1,tokenize:(n,e,t)=>{var r,i;const[s,o,l]=uw(n);if(s.length===0)return;const a=nf(s,s[0].indent,t);if(a.length!==0)return{type:"list",ordered:!0,start:((r=s[0])===null||r===void 0?void 0:r.number)||1,typeMarker:(i=s[0])===null||i===void 0?void 0:i.type,items:a,raw:l.slice(0,o).join(` +`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(fw,this.editor.getAttributes(La)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new B({props:{handlePaste:(n,e)=>{var t,r;const i=(t=e.clipboardData)===null||t===void 0?void 0:t.getData("text/html");if(i?.trim())return!1;const s=(r=e.clipboardData)===null||r===void 0?void 0:r.getData("text/plain");if(!s)return!1;const o=aw(s);if(!o)return!1;try{const l=n.state.schema.nodeFromJSON(o),a=n.state.tr.replaceSelectionWith(l);return n.dispatch(a),!0}catch{return!1}}}})]},addInputRules(){const n=(t,r)=>(!r.attrs.type||r.attrs.type==="1")&&r.childCount+r.attrs.start===+t[1];let e=ln({find:Ia,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:n});return(this.options.keepMarks||this.options.keepAttributes)&&(e=ln({find:Ia,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(La)}),joinPredicate:n,editor:this.editor})),[e]}}),hw=/^\s*(\[([( |x])?\])\s$/,pw="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0",mw=(n,e,t)=>{var r;return(t==null||(r=t.checkboxLabel)===null||r===void 0?void 0:r.call(t,n,e))||`Task item checkbox for ${n.textContent||"empty task item"}`},gw=U.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:n=>{const e=n.getAttribute("data-checked");return e===""||e==="true"},renderHTML:n=>({"data-checked":n.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:n=>{var e;return(e=n.querySelector("div"))!==null&&e!==void 0?e:n}}]},renderHTML({node:n,HTMLAttributes:e}){return["li",F(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:n.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(n,e)=>{const t=[];if(n.tokens&&n.tokens.length>0?t.push(e.createNode("paragraph",{},e.parseInline(n.tokens))):n.text?t.push(e.createNode("paragraph",{},[e.createNode("text",{text:n.text})])):t.push(e.createNode("paragraph",{},[])),n.nestedTokens&&n.nestedTokens.length>0){const r=e.parseChildren(n.nestedTokens);t.push(...r)}return e.createNode("taskItem",{checked:n.checked||!1},t)},renderMarkdown:(n,e)=>{var t;const r=`- [${!((t=n.attrs)===null||t===void 0)&&t.checked?"x":" "}] `;return iu(n,e,r)},addExtensions(){return this.options.nested?[Gu(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){const n={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...n,Tab:()=>this.editor.commands.sinkListItem(this.name)}:n},addNodeView(){return({node:n,HTMLAttributes:e,getPos:t,editor:r})=>{const i=document.createElement("li"),s=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div");o.style.cssText=pw;const c=u=>{const f=mw(u,u.attrs.checked,this.options.a11y);l.setAttribute("aria-label",f),o.textContent=f};c(n),s.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",u=>u.preventDefault()),l.addEventListener("change",u=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:f}=u.target;r.isEditable&&typeof t=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{const p=t();if(typeof p!="number")return!1;const m=h.doc.nodeAt(p);return h.setNodeMarkup(p,void 0,{...m?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(n,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([u,f])=>{i.setAttribute(u,f)}),i.dataset.checked=n.attrs.checked,l.checked=n.attrs.checked,s.append(l,o),i.append(s,a),Object.entries(e).forEach(([u,f])=>{i.setAttribute(u,f)});let d=new Set(Object.keys(e));return{dom:i,contentDOM:a,update:u=>{if(u.type!==this.type)return!1;i.dataset.checked=u.attrs.checked,l.checked=u.attrs.checked,c(u);const f=r.extensionManager.attributes,h=on(u,f),p=new Set(Object.keys(h)),m=this.options.HTMLAttributes;return d.forEach(g=>{p.has(g)||(g in m?i.setAttribute(g,m[g]):i.removeAttribute(g))}),Object.entries(h).forEach(([g,y])=>{y==null?g in m?i.setAttribute(g,m[g]):i.removeAttribute(g):i.setAttribute(g,y)}),d=p,!0}}}},addInputRules(){return[ln({find:hw,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),yw=U.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:n}){return["ul",F(this.options.HTMLAttributes,n,{"data-type":this.name}),0]},parseMarkdown:(n,e)=>e.createNode("taskList",{},e.parseChildren(n.items||[])),renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,` +`):"",markdownTokenizer:{name:"taskList",level:"block",start(n){var e;const t=(e=n.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))===null||e===void 0?void 0:e.index;return t!==void 0?t:-1},tokenize(n,e,t){const r=s=>{const o=ea(s,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:t.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},t);if(o){const l={type:"taskList",raw:o.raw,items:o.items},a=s.slice(o.raw.length);return a.trim()?[l,...t.blockTokens(a)]:[l]}return t.blockTokens(s)},i=ea(n,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:s=>({indentLevel:s[1].length,mainContent:s[4],checked:s[3].toLowerCase()==="x"}),createToken:(s,o)=>({type:"taskItem",raw:"",mainContent:s.mainContent,indentLevel:s.indentLevel,checked:s.checked,text:s.mainContent,tokens:t.inlineTokens(s.mainContent),nestedTokens:o}),customNestedParser:r},t);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});j.create({name:"listKit",addExtensions(){const n=[];return this.options.bulletList!==!1&&n.push(Ju.configure(this.options.bulletList)),this.options.listItem!==!1&&n.push(Zu.configure(this.options.listItem)),this.options.listKeymap!==!1&&n.push(tf.configure(this.options.listKeymap)),this.options.orderedList!==!1&&n.push(rf.configure(this.options.orderedList)),this.options.taskItem!==!1&&n.push(gw.configure(this.options.taskItem)),this.options.taskList!==!1&&n.push(yw.configure(this.options.taskList)),n}});const mr=" ",as=" ",bw=U.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",F(this.options.HTMLAttributes,n),0]},parseMarkdown:(n,e)=>{const t=n.tokens||[];if(t.length===1&&t[0].type==="image")return e.parseChildren([t[0]]);const r=e.parseInline(t);return t.length===1&&t[0].type==="text"&&(t[0].raw===mr||t[0].text===mr||t[0].raw===as||t[0].text===as)&&r.length===1&&r[0].type==="text"&&(r[0].text===mr||r[0].text===as)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(n,e,t)=>{if(!n)return"";const r=Array.isArray(n.content)?n.content:[];if(r.length===0){var i,s;const o=Array.isArray(t==null||(i=t.previousNode)===null||i===void 0?void 0:i.content)?t.previousNode.content:[];return(t==null||(s=t.previousNode)===null||s===void 0?void 0:s.type)==="paragraph"&&o.length===0?mr:""}return e.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),kw=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,ww=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Sw=bt.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",F(this.options.HTMLAttributes,n),0]},markdownTokenName:"del",parseMarkdown:(n,e)=>e.applyMark("strike",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`~~${e.renderChildren(n)}~~`,addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[$t({find:kw,type:this.type})]},addPasteRules(){return[pt({find:ww,type:this.type})]}}),xw=U.create({name:"text",group:"inline",parseMarkdown:n=>({type:"text",text:n.text||""}),renderMarkdown:n=>n.text||""}),Cw=bt.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",F(this.options.HTMLAttributes,n),0]},parseMarkdown(n,e){return e.applyMark(this.name||"underline",e.parseInline(n.tokens||[]))},renderMarkdown(n,e){return`++${e.renderChildren(n)}++`},markdownTokenizer:{name:"underline",level:"inline",start(n){return n.indexOf("++")},tokenize(n,e,t){const r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(n);if(!r)return;const i=r[2].trim();return{type:"underline",raw:r[0],text:i,tokens:t.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function vw(n={}){return new B({view(e){return new Ew(e,n)}})}class Ew{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let s=o=>{this[i](o)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc)if(this.lastDragEvent){let r=this.computeTarget(this.lastDragEvent);r==this.cursorPos?this.updateOverlay():this.setCursor(r)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,i=this.editorView.dom,s=i.getBoundingClientRect(),o=s.width/i.offsetWidth,l=s.height/i.offsetHeight;if(t){let u=e.nodeBefore,f=e.nodeAfter;if(u||f){let h=this.editorView.nodeDOM(this.cursorPos-(u?u.nodeSize:0));if(h){let p=h.getBoundingClientRect(),m=u?p.bottom:p.top;u&&f&&(m=(m+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;r={left:p.left,right:p.right,top:m-g,bottom:m+g}}}}if(!r){let u=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*o;r={left:u.left-f,right:u.left+f,top:u.top,bottom:u.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,d;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,d=-pageYOffset;else{let u=a.getBoundingClientRect(),f=u.width/a.offsetWidth,h=u.height/a.offsetHeight;c=u.left-a.scrollLeft*f,d=u.top-a.scrollTop*h}this.element.style.left=(r.left-c)/o+"px",this.element.style.top=(r.top-d)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=r&&r.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,t,e):i;if(!t||s)return null;let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=vc(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}return o}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class J extends O{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return J.valid(r)?new J(r):O.near(r)}content(){return C.empty}eq(e){return e instanceof J&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new J(e.resolve(t.pos))}getBookmark(){return new zo(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!Mw(e)||!Aw(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&J.valid(e))return e;let i=e.pos,s=null;for(let o=e.depth;;o--){let l=e.node(o);if(t>0?e.indexAfter(o)0){s=l.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=t;let a=e.doc.resolve(i);if(J.valid(a))return a}for(;;){let o=t>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!T.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*t),r=!1;continue e}break}s=o,i+=t;let l=e.doc.resolve(i);if(J.valid(l))return l}return null}}}J.prototype.visible=!1;J.findFrom=J.findGapCursorFrom;O.jsonID("gapcursor",J);class zo{constructor(e){this.pos=e}map(e){return new zo(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return J.valid(t)?new J(t):O.near(t)}}function sf(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function Mw(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||sf(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Aw(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||sf(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Tw(){return new B({props:{decorations:Lw,createSelectionBetween(n,e,t){return e.pos==t.pos&&J.valid(t)?new J(t):null},handleClick:Ow,handleKeyDown:Nw,handleDOMEvents:{beforeinput:Rw}}})}const Nw=yo({ArrowLeft:gr("horiz",-1),ArrowRight:gr("horiz",1),ArrowUp:gr("vert",-1),ArrowDown:gr("vert",1)});function gr(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,s){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof M){if(!s.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=J.findGapCursorFrom(l,e,a);return c?(i&&i(r.tr.setSelection(new J(c))),!0):!1}}function Ow(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!J.valid(r))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&T.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new J(r))),!0)}function Rw(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof J))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let i=w.empty;for(let o=r.length-1;o>=0;o--)i=w.from(r[o].createAndFill(null,i));let s=n.state.tr.replace(t.pos,t.pos,new C(i,0,0));return s.setSelection(M.near(s.doc.resolve(t.pos+1))),n.dispatch(s),!1}function Lw(n){if(!(n.selection instanceof J))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",z.create(n.doc,[te.widget(n.selection.head,e,{key:"gapcursor"})])}j.create({name:"characterCount",addOptions(){return{limit:null,autoTrim:!0,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=n?.node||this.editor.state.doc;if((n?.mode||this.options.mode)==="textSize"){const t=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(t)}return e.nodeSize},this.storage.words=n=>{const e=n?.node||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new B({key:new W("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;const i=this.options.limit,s=this.options.autoTrim;if(i==null||i===0||s===!1){n=!0;return}const o=this.storage.characters({node:r.doc});if(o>i){const l=o-i,a=0,c=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const d=r.tr.deleteRange(a,c);return n=!0,d}n=!0},filterTransaction:(e,t)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:t.doc}),s=this.storage.characters({node:e.doc});if(s<=r||i>r&&s>r&&s<=i)return!0;if(i>r&&s>r&&s>i||!e.getMeta("paste"))return!1;const o=e.selection.$head.pos,l=o-(s-r),a=o;return e.deleteRange(l,a),!(this.storage.characters({node:e.doc})>r)}})]}});const Iw=j.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[vw(this.options)]}});j.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new B({key:new W("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:r}=this.editor,{anchor:i}=e,s=[];if(!t||!r)return z.create(n,[]);let o=0;this.options.mode==="deepest"&&n.descendants((a,c)=>{if(!a.isText){if(!(i>=c&&i<=c+a.nodeSize-1))return!1;o+=1}});let l=0;return n.descendants((a,c)=>{if(a.isText||!(i>=c&&i<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";s.push(te.node(c,c+a.nodeSize,{class:this.options.className}))}),z.create(n,s)}}})]}});const Dw=j.create({name:"gapCursor",addProseMirrorPlugins(){return[Tw()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=$(A(n,"allowGapCursor",t)))!==null&&e!==void 0?e:null}}}),of="placeholder",Pa=new W("tiptap__placeholder");function lf(n){const{editor:e,placeholder:t,dataAttribute:r,pos:i,node:s,isEmptyDoc:o,hasAnchor:l,classes:{emptyNode:a,emptyEditor:c}}=n,d=[a];return o&&d.push(c),te.node(i,i+s.nodeSize,{class:d.join(" "),[r]:typeof t=="function"?t({editor:e,node:s,pos:i,hasAnchor:l}):t})}function af(n,e){return typeof n=="function"?n(e):n}function cf({editor:n,options:e,dataAttribute:t,doc:r,selection:i,from:s,to:o}){const{anchor:l}=i,a=[],c=n.isEmpty;return r.nodesBetween(s,o,(d,u)=>{const f=l>=u&&l<=u+d.nodeSize,h=!d.isLeaf&&Zn(d);return d.type.isTextblock&&(f||!e.showOnlyCurrent)&&h&&a.push(lf({editor:n,isEmptyDoc:c,dataAttribute:t,hasAnchor:f,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:af(e.emptyNodeClass,{editor:n,node:d,pos:u,hasAnchor:f})},node:d,pos:u})),e.includeChildren}),a}function df({editor:n,options:e,dataAttribute:t,doc:r,selection:i}){if(!(n.isEditable||!e.showOnlyWhenEditable))return null;const{anchor:s}=i,o=[],l=n.isEmpty;if(e.showOnlyCurrent&&!e.includeChildren){const a=r.resolve(s),c=a.depth>0?a.node(1):a.nodeAfter,d=a.depth>0?a.before(1):s;if(c&&c.type.isTextblock&&Zn(c)){const u=s>=d&&s<=d+c.nodeSize;o.push(lf({editor:n,isEmptyDoc:l,dataAttribute:t,hasAnchor:u,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:af(e.emptyNodeClass,{editor:n,node:c,pos:d,hasAnchor:u})},node:c,pos:d}))}}else o.push(...cf({editor:n,options:e,dataAttribute:t,doc:r,selection:i,from:0,to:r.content.size}));return z.create(r,o)}function Ln(n,e){const t=n.resolve(e);if(t.depth===0){var r;const s=(r=t.nodeAfter)!==null&&r!==void 0?r:t.nodeBefore;if(!s)return{from:e,to:e};const o=t.nodeAfter?e:e-s.nodeSize;return{from:o,to:o+s.nodeSize}}const i=t.before(1);return{from:i,to:i+t.node(1).nodeSize}}function In(n,e){return{from:Math.max(0,e.from-1),to:Math.min(n.content.size,e.to-1)}}function Pw(n,e,t){const r=[];return n.forEach((i,s)=>{const o=s,l=o+i.nodeSize,a=o+1,c=l+1;ae&&r.push({from:o,to:l})}),r}function zw(n){if(n.length===0)return[];const e=[...n].sort((r,i)=>r.from-i.from),t=[{...e[0]}];for(let r=1;re.from?t.push(In(n,Ln(n,Math.min(e.to,n.content.size+1)-1))):e.fromh.from>=c&&h.to<=d);u.length&&(l=l.remove(u));const f=cf({editor:t,options:r,dataAttribute:i,doc:s,selection:o,from:c,to:d});f.length&&(l=l.add(s,f))}return l}function _w({editor:n,options:e,dataAttribute:t}){return{init(r,i){const s=df({editor:n,options:e,dataAttribute:t,doc:i.doc,selection:i.selection});return s??z.empty},apply(r,i,s,o){return!r.docChanged&&!r.selectionSet?i:Fw({decorations:i.map(r.mapping,r.doc),ranges:Bw(r,s,o),editor:n,options:e,dataAttribute:t,doc:o.doc,selection:o.selection})}}}function Vw(n){return n.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}function Ww({editor:n,options:e}){const t=e.dataAttribute?`data-${Vw(e.dataAttribute)}`:`data-${of}`,r=e.showOnlyCurrent&&!e.includeChildren;return new B({key:Pa,...r?{}:{state:_w({editor:n,options:e,dataAttribute:t})},props:{decorations:r?({doc:i,selection:s})=>df({editor:n,options:e,dataAttribute:t,doc:i,selection:s}):i=>{var s;return e.showOnlyWhenEditable&&!n.isEditable?z.empty:(s=Pa.getState(i))!==null&&s!==void 0?s:z.empty}}})}j.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:of,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[Ww({editor:this.editor,options:this.options})]}});function Gs(n,e){return!n.selection.empty&&!Yd(n.selection)&&e.isEditable}function jw(n,e){return Gs(n,e)&&!e.isFocused&&!e.view.dragging}function Uw(){var n;(n=window.getSelection())===null||n===void 0||n.removeAllRanges()}function Kw(n){n.focus()}j.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return[new B({key:new W("selection"),props:{decorations(t){return jw(t,n)?z.create(t.doc,[te.inline(t.selection.from,t.selection.to,{class:e.className})]):null},handleDOMEvents:{blur(t){return Gs(t.state,n)&&Uw(),!1},focus(t){return Gs(t.state,n)&&requestAnimationFrame(()=>{!n.isDestroyed&&t.hasFocus()&&Kw(t)}),!1}}}})]}});function za({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||e?.type===n}const qw=j.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;const e=new W(this.name),t=this.options.node||((n=this.editor.schema.topNodeType.contentMatch.defaultType)===null||n===void 0?void 0:n.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(t).includes(i.name));return[new B({key:e,appendTransaction:(i,s,o)=>{const{doc:l,tr:a,schema:c}=o,d=e.getState(o),u=l.content.size,f=c.nodes[t];if(!i.some(h=>h.getMeta("skipTrailingNode"))&&d)return a.insert(u,f.create())},state:{init:(i,s)=>{const o=s.tr.doc.lastChild;return!za({node:o,types:r})},apply:(i,s)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return s;const o=i.doc.lastChild;return!za({node:o,types:r})}}})]}}),Jw=j.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>Rd(n,e),redo:()=>({state:n,dispatch:e})=>Ld(n,e)}},addProseMirrorPlugins(){return[$m(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),Gw=j.create({name:"starterKit",addExtensions(){const n=[];if(this.options.bold!==!1&&n.push(V0.configure(this.options.bold)),this.options.blockquote!==!1&&n.push($0.configure(this.options.blockquote)),this.options.bulletList!==!1&&n.push(Ju.configure(this.options.bulletList)),this.options.code!==!1&&n.push(K0.configure(this.options.code)),this.options.codeBlock!==!1&&n.push(G0.configure(this.options.codeBlock)),this.options.document!==!1&&n.push(Y0.configure(this.options.document)),this.options.dropcursor!==!1&&n.push(Iw.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&n.push(Dw.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&n.push(X0.configure(this.options.hardBreak)),this.options.heading!==!1&&n.push(Q0.configure(this.options.heading)),this.options.undoRedo!==!1&&n.push(Jw.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&n.push(Z0.configure(this.options.horizontalRule)),this.options.italic!==!1&&n.push(ik.configure(this.options.italic)),this.options.listItem!==!1&&n.push(Zu.configure(this.options.listItem)),this.options.listKeymap!==!1){var e;n.push(tf.configure((e=this.options)===null||e===void 0?void 0:e.listKeymap))}if(this.options.link!==!1){var t;n.push(Bk.configure((t=this.options)===null||t===void 0?void 0:t.link))}if(this.options.orderedList!==!1&&n.push(rf.configure(this.options.orderedList)),this.options.paragraph!==!1&&n.push(bw.configure(this.options.paragraph)),this.options.strike!==!1&&n.push(Sw.configure(this.options.strike)),this.options.text!==!1&&n.push(xw.configure(this.options.text)),this.options.underline!==!1){var r;n.push(Cw.configure((r=this.options)===null||r===void 0?void 0:r.underline))}if(this.options.trailingNode!==!1){var i;n.push(qw.configure((i=this.options)===null||i===void 0?void 0:i.trailingNode))}return n}});var Yw=Gw;const uf={language:"en",tabWysiwyg:"WYSIWYG",tabSource:"Source",toolbar:"Formatting",paragraph:"Paragraph",heading2:"Heading 2",heading3:"Heading 3",heading4:"Heading 4",bold:"Bold",italic:"Italic",bulletList:"Bullet list",orderedList:"Numbered list",link:"Link",blockquote:"Quote",insertTable:"Insert table",addRow:"Add row",deleteRow:"Delete row",addColumn:"Add column",deleteColumn:"Delete column",deleteTable:"Delete table",image:"Image",mediaLibrary:"Choose from Media Library",embed:"Embed video",rawHtml:"HTML block",undo:"Undo",redo:"Redo",linkUrl:"Link URL",linkApply:"Apply",linkRemove:"Remove link",linkInvalid:"Links must use http, https, mailto or a relative URL.",embedUrl:"YouTube URL",embedInsert:"Insert",embedInvalid:"This video URL is not supported. Paste a YouTube link.",embedProvider:"Provider",embedId:"Embed ID",embedIdInvalid:"Enter a valid ID for this embed provider.",embedFallbackImage:"Fallback image URL (optional)",embedFallbackPick:"Choose from Media Library",embedFallbackAlt:"Fallback alt text (optional)",embedCaption:"Caption (optional)",embedAspect:"Aspect ratio (optional)",embedAspectInvalid:"Enter a valid aspect ratio (e.g. 16/9 or 1.5).",embedHeight:"Height (optional)",embedHeightInvalid:"Enter a valid height in pixels (e.g. 420 or 420px).",embedGeneric:"Embed",cancel:"Cancel",uploading:"Uploading {name}…",uploadFailed:"Upload failed: {error}",uploadTimeout:"The upload of {name} took too long.",notAnImage:"Only JPEG, PNG, GIF and WebP images can be uploaded.",altText:"Alt text (required)",caption:"Caption (optional)",altRequired:"Enter the alt text, or mark the image as decorative.",insertImage:"Insert image",rawHtmlCard:"HTML block",editAsHtml:"Edit as HTML",embedCard:"Embedded video",preview:"Preview",previewFrame:"Post preview",heading1:"Heading 1",outline:"Outline",outlineShow:"Show outline",outlineHide:"Hide outline",outlineCount:{one:"{count} heading",other:"{count} headings"},outlineProblems:{one:"{count} problem",other:"{count} problems"},outlineEmpty:"No headings yet. Headings split the text into sections for readers and search engines.",flagSkipped:"Skipped level: H{from} → H{to}",flagEmpty:"Empty heading",flagLinkOnly:"Heading is only a link",flagH1:"H1 in the text: saved as H2",outlineLinks:"Links",flagGeneric:"Link text “{text}” does not say where it leads",linkRel:"Link attributes",relNofollow:"nofollow",relSponsored:"sponsored (paid)",relUgc:"ugc (user content)",relHint:"Only for links to other sites. Links within the site never get these.",genericWarning:"“{text}” does not say where the link leads. Use words that describe the target page.",fileName:"File name",fileNameHint:"Lowercase words joined with hyphens, e.g. lion-s-mane-in-the-forest.",decorative:"Decorative image (no alt text)"},Xw={language:"pl",tabWysiwyg:"WYSIWYG",tabSource:"Źródło",toolbar:"Formatowanie",paragraph:"Akapit",heading2:"Nagłówek 2",heading3:"Nagłówek 3",heading4:"Nagłówek 4",bold:"Pogrubienie",italic:"Kursywa",bulletList:"Lista punktowana",orderedList:"Lista numerowana",link:"Link",blockquote:"Cytat",insertTable:"Wstaw tabelę",addRow:"Dodaj wiersz",deleteRow:"Usuń wiersz",addColumn:"Dodaj kolumnę",deleteColumn:"Usuń kolumnę",deleteTable:"Usuń tabelę",image:"Obraz",mediaLibrary:"Wybierz z biblioteki mediów",embed:"Osadź wideo",rawHtml:"Blok HTML",undo:"Cofnij",redo:"Ponów",linkUrl:"Adres linku",linkApply:"Zastosuj",linkRemove:"Usuń link",linkInvalid:"Link musi używać http, https, mailto albo adresu względnego.",embedUrl:"Adres filmu YouTube",embedInsert:"Wstaw",embedInvalid:"Ten adres filmu nie jest obsługiwany. Wklej link do YouTube.",embedProvider:"Dostawca",embedId:"Identyfikator osadzenia",embedIdInvalid:"Wpisz poprawny identyfikator dla tego dostawcy.",embedFallbackImage:"Adres obrazu zastępczego (opcjonalny)",embedFallbackPick:"Wybierz z biblioteki mediów",embedFallbackAlt:"Tekst alternatywny obrazu (opcjonalny)",embedCaption:"Podpis (opcjonalny)",embedAspect:"Proporcje (opcjonalne)",embedAspectInvalid:"Wpisz poprawne proporcje (np. 16/9 lub 1.5).",embedHeight:"Wysokość (opcjonalna)",embedHeightInvalid:"Wpisz poprawną wysokość w pikselach (np. 420 lub 420px).",embedGeneric:"Osadź",cancel:"Anuluj",uploading:"Wysyłanie {name}…",uploadFailed:"Wysyłanie nie powiodło się: {error}",uploadTimeout:"Wysyłanie {name} trwało zbyt długo.",notAnImage:"Można wysłać tylko obrazy JPEG, PNG, GIF i WebP.",altText:"Tekst alternatywny (wymagany)",caption:"Podpis (opcjonalny)",altRequired:"Wpisz tekst alternatywny lub oznacz obraz jako dekoracyjny.",insertImage:"Wstaw obraz",rawHtmlCard:"Blok HTML",editAsHtml:"Edytuj jako HTML",embedCard:"Osadzone wideo",preview:"Podgląd",previewFrame:"Podgląd wpisu",heading1:"Nagłówek 1",outline:"Konspekt",outlineShow:"Pokaż konspekt",outlineHide:"Ukryj konspekt",outlineCount:{one:"{count} nagłówek",few:"{count} nagłówki",many:"{count} nagłówków",other:"{count} nagłówka"},outlineProblems:{one:"{count} problem",few:"{count} problemy",many:"{count} problemów",other:"{count} problemu"},outlineEmpty:"Brak nagłówków. Nagłówki dzielą tekst na części dla czytelników i wyszukiwarek.",flagSkipped:"Pominięty poziom: H{from} → H{to}",flagEmpty:"Pusty nagłówek",flagLinkOnly:"Nagłówek jest tylko linkiem",flagH1:"H1 w tekście: zostanie zapisany jako H2",outlineLinks:"Linki",flagGeneric:"Tekst linku „{text}” nie mówi, dokąd prowadzi",linkRel:"Atrybuty linku",relNofollow:"nofollow",relSponsored:"sponsored (płatny)",relUgc:"ugc (od użytkowników)",relHint:"Tylko dla linków do innych witryn. Linki w obrębie witryny nigdy ich nie dostają.",genericWarning:"„{text}” nie mówi, dokąd prowadzi link. Użyj słów opisujących stronę docelową.",fileName:"Nazwa pliku",fileNameHint:"Małe litery i łączniki, np. lwia-grzywa-w-lesie.",decorative:"Obraz dekoracyjny (bez tekstu alternatywnego)"},Qw={en:uf,pl:Xw};function Jn(n){const e=(n??"").toLowerCase().split(/[-_]/)[0]??"";return Qw[e]??uf}function Lt(n,e){return n.replace(/\{(\w+)\}/g,(t,r)=>e[r]??t)}function $a(n,e,t,r={}){let i="other";try{i=new Intl.PluralRules(n.language).select(t)}catch{}return Lt(e[i]??e.other,{...r,count:String(t)})}const Ys="blogeditor-edit-html",Zw=["footer","section","aside","header","nav","details","style","div","article","main","address","dl","iframe","video","audio","picture","object","embed","form","svg","math","script","noscript"],e1=/[\x00-\x20\x7f]+/g,t1=/^([a-z][a-z0-9+.-]*):/i,n1=["http","https","mailto"];function Pe(n){if(n==null)return!1;const e=t1.exec(n.replace(e1,""));if(e&&!n1.includes(e[1].toLowerCase()))return!1;try{return new URL(n,"https://journal.invalid/"),!0}catch{return!1}}const r1={orderedList:["start","type"],link:["href","target","rel","class","title"],image:["src","alt","title","width","height"],figureImage:["src","alt","title","width","height"],tableCell:["colspan","rowspan","colwidth"],tableHeader:["colspan","rowspan","colwidth"]},i1=["paragraph","heading","blockquote","bulletList","orderedList","listItem","codeBlock","horizontalRule","hardBreak","table","tableRow","tableCell","tableHeader","image","figure","figcaption","link"],s1=["class","title","alt","width","height","colspan","rowspan","start","rel","target"],o1=/^data-[a-z0-9][a-z0-9._-]*$/;function ff(n){return s1.includes(n)||o1.test(n)}function gi(n,e){const t={};let r=!1;for(const i of Array.from(n.attributes)){const s=i.name.toLowerCase();e.includes(s)||!ff(s)||(t[s]=i.value,r=!0)}return r?t:null}function hf(n){if(!n||typeof n!="object")return{};const e={};for(const[t,r]of Object.entries(n))!ff(t.toLowerCase())||typeof r!="string"||(e[t]=r);return e}const l1=j.create({name:"htmlAttributes",addGlobalAttributes(){return i1.map(n=>({types:[n],attributes:{htmlAttrs:{default:null,keepOnSplit:!1,parseHTML:e=>gi(e,r1[n]??[]),renderHTML:e=>hf(e.htmlAttrs)}}}))}}),a1=bt.create({name:"span",priority:40,addAttributes(){return{htmlAttrs:{default:null,parseHTML:n=>gi(n,[]),renderHTML:n=>hf(n.htmlAttrs)}}},parseHTML(){return[{tag:"span",getAttrs:n=>gi(n,[])?null:!1}]},renderHTML({HTMLAttributes:n}){return["span",n,0]}});let Ba;function $o(){return Ba??=document.implementation.createHTMLDocument(""),Ba}const c1=U.create({name:"rawHtml",group:"block",atom:!0,selectable:!0,draggable:!0,priority:10,addOptions(){return{labels:Jn("en")}},addAttributes(){return{html:{default:"",parseHTML:n=>n.outerHTML,renderHTML:()=>({})}}},parseHTML(){return[...Zw,"figure"].map(n=>({tag:n,priority:10}))},renderHTML({node:n}){const e=$o().createElement("template");return e.innerHTML=String(n.attrs.html??""),e.content},addCommands(){return{insertRawHtml:n=>({commands:e})=>e.insertContent({type:this.name,attrs:{html:n}})}},addNodeView(){const n=this.options.labels;return({node:e})=>{const t=document.createElement("div");t.className="blogeditor__raw",t.contentEditable="false";const r=document.createElement("div");r.className="blogeditor__card-head";const i=document.createElement("span");i.textContent=n.rawHtmlCard;const s=document.createElement("button");s.type="button",s.textContent=n.editAsHtml,r.append(i,s);const o=document.createElement("pre");o.className="blogeditor__raw-source",o.textContent=String(e.attrs.html??""),t.append(r,o);let l=e;return s.addEventListener("click",a=>{a.preventDefault(),t.dispatchEvent(new CustomEvent(Ys,{bubbles:!0,detail:{html:String(l.attrs.html??"")}}))}),{dom:t,update:a=>a.type!==l.type?!1:(l=a,o.textContent=String(a.attrs.html??""),!0),stopEvent:a=>a.target===s,ignoreMutation:()=>!0}}}}),d1=new Set(["data-embed","data-id","data-aspect","data-height"]),u1=new Set(["src","alt","width","height"]);function f1(n,e){const t=n.getAttribute("data-embed")??"",r=n.getAttribute("data-id")??"";if(!Co(e,t,r))return null;for(const h of Array.from(n.attributes))if(!d1.has(h.name.toLowerCase()))return null;const i=n.getAttribute("data-aspect")?.trim()??"";if(i!==""&&!$r(i))return null;const s=n.getAttribute("data-height")?.trim()??"";if(s!==""&&!Br(s))return null;let o=null,l=null,a=null,c=null,d=null,u=!1,f=!1;for(const h of Array.from(n.childNodes)){if(h.nodeType===3){if(/[^ \t\r\n\f]/.test(h.nodeValue??""))return null;continue}if(h.nodeType!==1)return null;const p=h;if(p.nodeName==="IMG"&&!u){for(const b of Array.from(p.attributes))if(!u1.has(b.name.toLowerCase()))return null;const m=p.getAttribute("src")?.trim()??"";if(!m||/^\s*data:/i.test(m)||!Pe(m))return null;u=!0,o=m,l=p.getAttribute("alt")??"";const g=p.getAttribute("width")?.trim()??"",y=p.getAttribute("height")?.trim()??"";a=g||null,c=y||null;continue}if(p.nodeName==="FIGCAPTION"&&!f){if(p.attributes.length>0||p.children.length>0)return null;f=!0,d=p.textContent??"";continue}return null}return{provider:t,id:r,aspect:i||null,height:s||null,fallbackSrc:o,fallbackAlt:l,fallbackWidth:a,fallbackHeight:c,caption:d&&d.trim()!==""?d:null}}const h1=U.create({name:"embed",group:"block",atom:!0,selectable:!0,draggable:!0,priority:70,addOptions(){return{labels:Jn("en"),providers:an}},addAttributes(){return{provider:{default:null,renderHTML:()=>({})},id:{default:null,renderHTML:()=>({})},aspect:{default:null,renderHTML:()=>({})},height:{default:null,renderHTML:()=>({})},fallbackSrc:{default:null,renderHTML:()=>({})},fallbackAlt:{default:null,renderHTML:()=>({})},fallbackWidth:{default:null,renderHTML:()=>({})},fallbackHeight:{default:null,renderHTML:()=>({})},caption:{default:null,renderHTML:()=>({})}}},parseHTML(){const n=this.options.providers;return[{tag:"figure[data-embed]",priority:70,getAttrs:e=>{const t=f1(e,n);return t?{...t}:!1}}]},renderHTML({node:n}){const e={"data-embed":String(n.attrs.provider??""),"data-id":String(n.attrs.id??"")},t=typeof n.attrs.aspect=="string"?n.attrs.aspect.trim():"";t&&$r(t)&&(e["data-aspect"]=t);const r=typeof n.attrs.height=="string"?n.attrs.height.trim():"";r&&Br(r)&&(e["data-height"]=r);const i=[],s=typeof n.attrs.fallbackSrc=="string"?n.attrs.fallbackSrc.trim():"";if(s&&Pe(s)){const l={src:s,alt:typeof n.attrs.fallbackAlt=="string"?n.attrs.fallbackAlt:""},a=typeof n.attrs.fallbackWidth=="string"?n.attrs.fallbackWidth.trim():"",c=typeof n.attrs.fallbackHeight=="string"?n.attrs.fallbackHeight.trim():"";a&&(l.width=a),c&&(l.height=c),i.push(["img",l])}const o=typeof n.attrs.caption=="string"?n.attrs.caption.trim():"";return o&&i.push(["figcaption",{},o]),i.length===0?["figure",e]:["figure",e,...i]},addCommands(){const n=this.options.providers;return{setEmbed:e=>({commands:t})=>{const r=String(e.provider??"").trim(),i=String(e.id??"").trim();if(!Co(n,r,i))return!1;const s=e.aspect&&$r(e.aspect)?e.aspect.trim():null,o=e.height&&Br(e.height)?e.height.trim():null,l=e.fallbackSrc?.trim()??"",a=l&&Pe(l)?l:null,c=a?e.fallbackAlt??"":null,d=a&&e.fallbackWidth?String(e.fallbackWidth).trim():null,u=a&&e.fallbackHeight?String(e.fallbackHeight).trim():null,f=e.caption?.trim()?e.caption.trim():null;return t.insertContent({type:this.name,attrs:{provider:r,id:i,aspect:s,height:o,fallbackSrc:a,fallbackAlt:c,fallbackWidth:d,fallbackHeight:u,caption:f}})}}},addNodeView(){const n=this.options.labels,e=this.options.providers;return({node:t})=>{const r=document.createElement("div");r.className="blogeditor__embed",r.contentEditable="false";const i=o=>{const l=String(o.attrs.provider??""),a=String(o.attrs.id??""),c=Qt(e,l),d=c?c.name:l,u=typeof o.attrs.aspect=="string"?o.attrs.aspect.trim():"",f=typeof o.attrs.height=="string"?o.attrs.height.trim():"",h=typeof o.attrs.fallbackSrc=="string"?o.attrs.fallbackSrc.trim():"",p=typeof o.attrs.fallbackAlt=="string"?o.attrs.fallbackAlt:"",m=typeof o.attrs.caption=="string"?o.attrs.caption.trim():"";if(r.replaceChildren(),!u&&!f&&!h&&!m){r.textContent=`${n.embedCard}: ${d} ${a}`;return}const g=document.createElement("div");g.className="blogeditor__embed-head";const y=document.createElement("span");y.textContent=`${n.embedCard}: ${d} ${a}`,g.append(y);const b=[u,f].filter(Boolean).join(" · ");if(b){const k=document.createElement("span");k.className="blogeditor__embed-badge",k.textContent=b,g.append(k)}if(r.append(g),h&&Pe(h)){const k=document.createElement("img");k.className="blogeditor__embed-thumb",k.setAttribute("src",h),k.setAttribute("alt",p),r.append(k)}if(m){const k=document.createElement("p");k.className="blogeditor__embed-caption",k.textContent=m,r.append(k)}};i(t);let s=t;return{dom:r,update:o=>o.type!==s.type?!1:(s=o,i(o),!0),ignoreMutation:()=>!0}}}});function p1(n){if(n.hasAttribute("data-embed"))return!1;const e=[];for(const i of Array.from(n.childNodes))if(i.nodeType===1)e.push(i);else{if(i.nodeType===3&&/[^ \t\r\n\f]/.test(i.nodeValue??""))return!1;if(i.nodeType!==3)return!1}if(e.length<1||e.length>2)return!1;const t=e[0];if(t.nodeName!=="IMG")return!1;const r=t.getAttribute("src");return!r||/^\s*data:/i.test(r)?!1:e.length===1||e[1].nodeName==="FIGCAPTION"}const m1=U.create({name:"figure",group:"block",content:"figureImage figcaption?",draggable:!0,isolating:!0,priority:60,parseHTML(){return[{tag:"figure",priority:60,getAttrs:n=>p1(n)?null:!1}]},renderHTML({HTMLAttributes:n}){return["figure",n,0]},addCommands(){return{setFigure:({src:n,alt:e,caption:t,width:r,height:i})=>({commands:s})=>{const o={src:n,alt:e};r!=null&&r!==""&&(o.width=String(r)),i!=null&&i!==""&&(o.height=String(i));const l=[{type:"figureImage",attrs:o}];return t&&l.push({type:"figcaption",content:[{type:"text",text:t}]}),s.insertContent({type:this.name,content:l})}}}}),g1=U.create({name:"figureImage",atom:!0,selectable:!1,priority:60,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:'img[src]:not([src^="data:"])',context:"figure/",priority:60}]},renderHTML({HTMLAttributes:n}){return["img",n]},addNodeView(){return typeof document>"u"?null:({node:n,getPos:e,HTMLAttributes:t,editor:r})=>{const i=document.createElement("img");i.draggable=!1;for(const[s,o]of Object.entries(t))o!=null&&s!=="width"&&s!=="height"&&i.setAttribute(s,String(o));return new du({element:i,editor:r,node:n,getPos:e,onResize:(s,o)=>{i.style.width=`${s}px`,i.style.height=`${o}px`},onCommit:(s,o)=>{const l=e();if(typeof l!="number")return;const a=r.state.doc.nodeAt(l);a&&r.view.dispatch(r.state.tr.setNodeMarkup(l,void 0,{...a.attrs,width:s,height:o}))},onUpdate:s=>{if(s.type!==n.type)return!1;for(const o of["src","alt","title"]){const l=s.attrs[o];l!=null?i.setAttribute(o,String(l)):i.removeAttribute(o)}return!0},options:{directions:["top-left","top-right","bottom-left","bottom-right"],min:{width:48,height:48},preserveAspectRatio:!0}})}}}),y1=U.create({name:"figcaption",content:"inline*",priority:60,parseHTML(){return[{tag:"figcaption",context:"figure/"}]},renderHTML({HTMLAttributes:n}){return["figcaption",n,0]}}),b1=Ru.extend({renderHTML({HTMLAttributes:n}){return["table",F(this.options.HTMLAttributes,n),["tbody",0]]}});function pf(n){const{align:e,...t}=n??{};return t}const k1=Au.extend({addAttributes(){return pf(this.parent?.())}}),w1=Tu.extend({addAttributes(){return pf(this.parent?.())}}),mf=[2,3,4];function S1(n){const e=n.includes(1);return[1,2,3,4,5,6].filter(t=>t>1||e)}const x1=U.create({name:"headingOneAsTwo",content:"inline*",parseHTML(){return[{tag:"h1",node:"heading",getAttrs:n=>({level:2,htmlAttrs:gi(n,[])})}]},renderHTML(){return["h2",0]}}),C1=kb.extend({addAttributes(){return{...this.parent?.(),width:{default:null},height:{default:null}}}});function v1(n=Jn("en"),e=mf,t=an){const r=S1(e);return[Yw.configure({trailingNode:!1,heading:{levels:r},link:{openOnClick:!1,HTMLAttributes:{target:null,rel:null,class:null},isAllowedUri:i=>Pe(i)}}),...r.includes(1)?[]:[x1],C1.configure({inline:!0,allowBase64:!1,resize:{enabled:!0,directions:["top-left","top-right","bottom-left","bottom-right"],minWidth:48,minHeight:48,alwaysPreserveAspectRatio:!0}}),b1,Nu,w1,k1,m1,g1,y1,h1.configure({labels:n,providers:t}),c1.configure({labels:n}),a1,l1]}const E1=80,M1={ą:"a",ć:"c",ę:"e",ł:"l",ń:"n",ó:"o",ś:"s",ź:"z",ż:"z"};function cs(n){let e="",t=!1;for(const r of n.toLowerCase()){const i=M1[r]??r;/^[a-z0-9]$/.test(i)?(e+=i,t=!1):t||(e+="-",t=!0)}return e=e.replace(/^-+|-+$/g,"").slice(0,E1).replace(/-+$/,""),e===""?"image":e}function A1(n){const e=n.replace(/\\/g,"/").split("/").pop()??"",t=e.lastIndexOf(".");if(t>=0){const r=e.slice(t).toLowerCase();if(/^\.[a-z0-9]+$/.test(r))return{stem:e.slice(0,t),ext:r}}return{stem:e,ext:""}}function T1(n,e,t){const r=document.createElement("div");r.className="blogeditor__form",r.dataset.form="image",r.hidden=!0;const i=(m,g)=>{const y=document.createElement("label"),b=document.createElement("span");b.textContent=g;const k=document.createElement("input");return k.type="text",k.name=m,k.autocomplete="off",y.append(b,k),{label:y,input:k}},s=i("fileName",n.fileName);s.label.classList.add("blogeditor__filename");const o=document.createElement("span");o.className="blogeditor__filename-row";const l=document.createElement("span");l.className="blogeditor__ext",o.append(s.input,l);const a=document.createElement("span");a.className="blogeditor__hint",a.textContent=n.fileNameHint,s.label.append(o,a),s.input.addEventListener("blur",()=>{s.input.value=cs(s.input.value)});const c=i("alt",n.altText),d=document.createElement("label");d.className="blogeditor__check";const u=document.createElement("input");u.type="checkbox",u.name="decorative",d.append(u,document.createTextNode(n.decorative)),u.addEventListener("change",()=>{u.checked&&(c.input.value=""),c.input.disabled=u.checked,u.checked&&(p.textContent="")});const f=i("caption",n.caption),h=(m,g,y)=>{const b=document.createElement("button");return b.type="button",b.dataset.action=m,b.textContent=g,b.addEventListener("click",y),b},p=document.createElement("p");return p.className="blogeditor__error",p.dataset.error="",p.setAttribute("aria-live","polite"),r.append(s.label,c.label,d,f.label,h("insert",n.insertImage,e),h("cancel",n.cancel,t),p),{root:r,error:p,open:m=>{const g=A1(m.name);s.input.value=cs(g.stem),l.textContent=g.ext,c.input.value="",c.input.disabled=!1,u.checked=!1,f.input.value="",p.textContent="",r.hidden=!1,c.input.focus()},choice:()=>{s.input.value=cs(s.input.value);const m=c.input.value.trim();return!u.checked&&m===""?(p.textContent=n.altRequired,null):(p.textContent="",{fileName:s.input.value+l.textContent,alt:u.checked?"":m,caption:f.input.value.trim(),decorative:u.checked})}}}const N1=300,O1=["m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3","M12 9v4","M12 17h.01"];function gf(n){return n.toLowerCase().replace(/[\p{P}\p{S}]+/gu,"").replace(/\s+/g," ").trim()}function yf(n,e){const t=gf(n);return t!==""&&e.includes(t)}function R1(n){const e=[],t=[];return n.state.doc.descendants((r,i)=>{if(r.type.name==="heading"){let s=0,o=0;r.descendants(l=>{if(!l.isText)return!0;const a=(l.text??"").replace(/\s+/g,"").length;return o+=a,l.marks.some(c=>c.type.name==="link")&&(s+=a),!1}),e.push({level:Number(r.attrs.level)||2,text:r.textContent.trim(),linkOnly:o>0&&s===o,pos:i})}if(r.isTextblock){let s="",o=null;const l=()=>{s.trim()!==""&&t.push(s),s="",o=null};return r.forEach(a=>{const c=a.isText?a.marks.find(d=>d.type.name==="link"):void 0;if(c&&c.attrs.href===o){s+=a.text??"";return}l(),c&&(s=a.text??"",o=c.attrs.href)}),l(),!1}return!0}),{headings:e,links:t}}function L1(n){const t=document.implementation.createHTMLDocument("").createElement("div");t.innerHTML=n;const r=[];for(const s of Array.from(t.querySelectorAll("h1, h2, h3, h4, h5, h6"))){const o=(s.textContent??"").replace(/\s+/g," ").trim(),l=Array.from(s.querySelectorAll("a")).map(a=>a.textContent??"").join("").replace(/\s+/g,"");r.push({level:Number(s.tagName.slice(1)),text:o,linkOnly:o!==""&&l.length===o.replace(/\s+/g,"").length,pos:-1})}const i=Array.from(t.querySelectorAll("a")).map(s=>s.textContent??"").filter(s=>s.trim()!=="");return{headings:r,links:i}}function I1(n,e,t){let r=1;return n.headings.map(i=>{const s=[];return i.level>r+1&&s.push(Lt(e.flagSkipped,{from:String(r),to:String(i.level)})),i.text===""?s.push(e.flagEmpty):i.linkOnly&&s.push(e.flagLinkOnly),i.level===1&&!t.allowsH1&&t.source&&s.push(e.flagH1),r=i.level,s})}function Bo(){const n="http://www.w3.org/2000/svg",e=document.createElementNS(n,"svg");e.setAttribute("class","blogeditor__alert"),e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("width","14"),e.setAttribute("height","14"),e.setAttribute("fill","none"),e.setAttribute("stroke","currentColor"),e.setAttribute("stroke-width","2"),e.setAttribute("stroke-linecap","round"),e.setAttribute("stroke-linejoin","round"),e.setAttribute("aria-hidden","true");for(const t of O1){const r=document.createElementNS(n,"path");r.setAttribute("d",t),e.append(r)}return e}function Ha(n){const e=document.createElement("span");return e.className="blogeditor__outline-flag",e.append(Bo(),document.createTextNode(n)),e}function D1(n){const{labels:e}=n,t=document.createElement("div");t.className="blogeditor__outline";const r=document.createElement("button");r.type="button",r.className="blogeditor__outline-toggle",r.setAttribute("aria-expanded","false"),r.title=e.outlineShow;const i=document.createElement("span");i.className="blogeditor__outline-summary";const s=document.createElement("span");s.className="blogeditor__outline-problems",s.hidden=!0,r.append(i,s);const o=document.createElement("div");o.className="blogeditor__outline-panel",o.hidden=!0,o.id=`blogeditor-outline-${Math.random().toString(36).slice(2)}`,r.setAttribute("aria-controls",o.id),r.addEventListener("click",()=>{const u=o.hidden;o.hidden=!u,r.setAttribute("aria-expanded",String(u)),r.title=u?e.outlineHide:e.outlineShow,u&&d()}),t.append(r,o);let l;const a=(u,f)=>{const h=I1(u,e,{allowsH1:n.allowsH1,source:f}),p=u.links.filter(y=>yf(y,n.genericAnchors)),m=h.reduce((y,b)=>y+b.length,0)+p.length;if(i.textContent=`${e.outline} · ${$a(e,e.outlineCount,u.headings.length)}`,s.hidden=m===0,s.replaceChildren(...m>0?[Bo(),document.createTextNode($a(e,e.outlineProblems,m))]:[]),o.hidden)return;const g=[];if(u.headings.length===0){const y=document.createElement("p");y.className="blogeditor__outline-empty",y.textContent=e.outlineEmpty,g.push(y)}else{const y=n.allowsH1?1:2,b=document.createElement("ol");b.className="blogeditor__outline-list",u.headings.forEach((k,S)=>{const v=document.createElement("li");v.className="blogeditor__outline-item",v.style.setProperty("--blogeditor-outline-depth",String(Math.max(0,k.level-y)));const L=document.createElement("button");L.type="button",L.className="blogeditor__outline-target";const E=document.createElement("span");E.className="blogeditor__outline-level",E.textContent=`H${k.level}`;const R=document.createElement("span");R.className=k.text===""?"blogeditor__outline-text blogeditor__outline-text--empty":"blogeditor__outline-text",R.textContent=k.text===""?e.flagEmpty:k.text,L.append(E,R),L.addEventListener("click",()=>c(k)),v.append(L);const D=k.text===""?h[S].filter(P=>P!==e.flagEmpty):h[S];if(D.length>0){const P=document.createElement("span");P.className="blogeditor__outline-flags",P.append(...D.map(Ha)),v.append(P)}b.append(v)}),g.push(b)}if(p.length>0){const y=document.createElement("div");y.className="blogeditor__outline-links";const b=document.createElement("p");b.className="blogeditor__outline-heading",b.textContent=e.outlineLinks,y.append(b,...p.map(k=>Ha(Lt(e.flagGeneric,{text:k.trim()})))),g.push(y)}o.replaceChildren(...g)},c=u=>{const f=n.editor();!f||u.pos<0||n.sourceText()!==null||f.chain().focus().setTextSelection(u.pos+1).scrollIntoView().run()},d=()=>{clearTimeout(l),l=void 0;const u=n.sourceText(),f=n.editor();u!==null?a(L1(u),!0):f&&a(R1(f),!1)};return{element:t,schedule:()=>{clearTimeout(l),l=setTimeout(d,N1)},refresh:d,stop:()=>{clearTimeout(l),l=void 0}}}const Xs=["nofollow","sponsored","ugc"];function Fa(n){const e=n.trim();if(!/^https?:\/\//i.test(e))return!1;try{return new URL(e).host!==""}catch{return!1}}function P1(n){if(typeof n!="string")return[];const e=n.toLowerCase().split(/\s+/);return Xs.filter(t=>e.includes(t))}function z1(n,e){const t=document.createElement("fieldset");t.className="blogeditor__rel";const r=document.createElement("legend");r.textContent=n.linkRel,t.append(r);const i=new Map,s={nofollow:n.relNofollow,sponsored:n.relSponsored,ugc:n.relUgc};for(const c of Xs){const d=document.createElement("label");d.className="blogeditor__check";const u=document.createElement("input");u.type="checkbox",u.name=`rel-${c}`,u.value=c,d.append(u,document.createTextNode(s[c])),t.append(d),i.set(c,u)}const o=document.createElement("p");o.className="blogeditor__hint",o.textContent=n.relHint,t.append(o);const l=document.createElement("p");return l.className="blogeditor__warning",l.dataset.warning="",l.setAttribute("aria-live","polite"),l.hidden=!0,{fieldset:t,warning:l,setUrl:c=>{const d=Fa(c);for(const u of i.values())u.disabled=!d;o.hidden=d},setRel:c=>{const d=P1(c);for(const[u,f]of i)f.checked=d.includes(u)},rel:c=>{if(!Fa(c))return null;const d=Xs.filter(u=>i.get(u).checked);return d.length>0?d.join(" "):null},setText:c=>{const d=yf(c,e);l.hidden=!d,l.replaceChildren(...d?[Bo(),document.createTextNode(Lt(n.genericWarning,{text:c.trim()}))]:[])}}}const $1="",B1="default-src 'none'; img-src * data:; style-src 'unsafe-inline'",H1=300,Dn={colors:{surface:"#ffffff",text:"#1a1a1a",muted:"#6b7280",border:"#e5e7eb",borderStrong:"#9ca3af",subtle:"#f6f7f9",primary:"#2563eb"},fontFamily:'system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif'},_a={surface:"--c-surface",text:"--c-text",muted:"--c-muted",border:"--c-border",borderStrong:"--c-border-strong",subtle:"--c-subtle",primary:"--c-primary"},F1="script, iframe, frame, frameset, object, embed, meta, base, link",_1=/^[A-Za-z]{2,3}(-[A-Za-z0-9]{1,8})*$/;function Va(n,e){const t=(n??"").trim();return t===""||t.length>200||/[<>{};\\]/.test(t)||t.includes("/*")?e:t}function V1(n){const e=getComputedStyle(n),t={...Dn.colors};for(const r of Object.keys(_a))t[r]=Va(e.getPropertyValue(_a[r]),Dn.colors[r]);return{colors:t,fontFamily:Va(e.fontFamily,Dn.fontFamily)}}function W1(n){return`https://img.youtube.com/vi/${n}/hqdefault.jpg`}function j1(n,e,t=an){const r=$o(),i=r.createElement("template");i.innerHTML=n;const s=i.content;for(const l of Array.from(s.querySelectorAll(F1)))l.remove();for(const l of Array.from(s.querySelectorAll("*")))for(const a of Array.from(l.attributes))a.name.toLowerCase().startsWith("on")&&l.removeAttribute(a.name);for(const l of Array.from(s.querySelectorAll("figure[data-embed]"))){const a=l.getAttribute("data-embed")??"",c=l.getAttribute("data-id")??"";if(!Co(t,a,c))continue;const u=Qt(t,a)?.name??a,f=l.querySelector("img[src]"),h=f?.getAttribute("src")?.trim()??"",p=l.querySelector("figcaption")?.textContent?.trim()??"";if(f&&h!==""&&Pe(h)){const S=r.createElement("figure");S.className="embed-card";const v=r.createElement("img");v.setAttribute("src",h),v.setAttribute("alt",f.getAttribute("alt")??"");const L=f.getAttribute("width"),E=f.getAttribute("height");L&&v.setAttribute("width",L),E&&v.setAttribute("height",E),v.setAttribute("referrerpolicy","no-referrer"),v.setAttribute("loading","lazy");const R=r.createElement("figcaption");R.textContent=p||`${e.embedCard}: ${u} ${c}`,S.append(v,R),l.replaceWith(S);continue}if(a==="youtube"&&l.childNodes.length===0){const S=r.createElement("figure");S.className="embed-card embed-card--youtube";const v=r.createElement("img");v.setAttribute("src",W1(c)),v.setAttribute("alt",""),v.setAttribute("referrerpolicy","no-referrer"),v.setAttribute("loading","lazy"),v.setAttribute("width","480"),v.setAttribute("height","360");const L=r.createElement("figcaption");L.textContent=`${e.embedCard}: ${u} ${c}`,S.append(v,L),l.replaceWith(S);continue}const m=r.createElement("figure");m.className="embed-card";const g=r.createElement("div");g.className="embed-card__placeholder";const y=l.getAttribute("data-aspect")?.trim()??"",b=l.getAttribute("data-height")?.trim()??"",k=[y,b].filter(Boolean).join(" · ");if(g.textContent=k?`${u}: ${c} (${k})`:`${u}: ${c}`,m.append(g),p){const S=r.createElement("figcaption");S.textContent=p,m.append(S)}l.replaceWith(m)}const o=r.createElement("div");return o.append(s),o.innerHTML}function U1(n,e){const t='"DM Mono", ui-monospace, SFMono-Regular, Menlo, monospace';return[`body{margin:0;padding:16px 20px;background:${n.surface};color:${n.text};font-family:${e};font-size:16px;line-height:1.7;overflow-wrap:anywhere}`,".post-body{max-width:72ch;margin-left:auto;margin-right:auto}","h1,h2,h3,h4{font-weight:600;margin:1.4em 0 0.5em}","h1{font-size:1.875em}h2{font-size:1.5em}h3{font-size:1.25em}h4{font-size:1.1em}","p,ul,ol,blockquote,table,figure,pre{margin:0 0 1em}","ul{list-style:disc;padding-left:1.5em}ol{list-style:decimal;padding-left:1.5em}",`a{color:${n.primary};text-decoration:underline}`,`blockquote{border-left:3px solid ${n.borderStrong};padding-left:1em;color:${n.muted}}`,`code{padding:0 4px;border-radius:4px;background:${n.subtle};font-family:${t};font-size:0.9em}`,`pre{padding:8px 12px;border-radius:8px;background:${n.subtle};font-family:${t};overflow:auto}`,"pre code{padding:0;background:transparent}",`hr{border:0;border-top:1px solid ${n.borderStrong}}`,"img{max-width:100%;height:auto}","table{border-collapse:collapse;width:100%}",`td,th{border:1px solid ${n.borderStrong};padding:4px 8px;vertical-align:top}`,`th{background:${n.subtle};font-weight:600;text-align:left}`,`figcaption{font-size:13px;color:${n.muted};margin-top:4px}`,`.embed-card{max-width:480px;border:1px solid ${n.border};border-radius:8px;overflow:hidden;background:${n.subtle}}`,".embed-card img{display:block;width:100%;height:auto}",".embed-card--youtube img{aspect-ratio:16/9;object-fit:cover}",`.embed-card__placeholder{padding:24px 16px;text-align:center;font-size:14px;color:${n.muted}}`,".embed-card figcaption{padding:8px 12px;margin:0}"].join(` +`)}function K1(n,e){const t=e.lang&&_1.test(e.lang)?` lang="${e.lang}"`:"",r={...Dn.colors,...e.colors},i=e.fontFamily||Dn.fontFamily;return`
${j1(n,e.labels,e.providers)}
`}const bf=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),kf=new Set(["script","style","textarea","title","xmp","iframe","noembed","noframes"]),wf=/^<\/?([a-zA-Z][^\s/>]*)/;function yi(n,e){let t="",r="";for(let i=e+1;i")return i+1;/\s/.test(s)||(r=s)}return-1}function Sf(n,e,t){const r=new RegExp(`])`,"ig");r.lastIndex=e;const i=r.exec(n);return i?yi(n,i.index):-1}function q1(n,e,t){const r=[t];let i=e;for(;r.length>0;){const s=n.indexOf("<",i);if(s<0)return-1;if(n.startsWith("",s+4);if(c<0)return-1;i=c+3;continue}const o=wf.exec(n.slice(s,s+64));if(!o){i=s+1;continue}const l=o[1].toLowerCase(),a=yi(n,s);if(a<0)return-1;if(i=a,n[s+1]==="/"){const c=r.lastIndexOf(l);c>=0&&(r.length=c);continue}if(!(bf.has(l)||n[a-2]==="/")){if(kf.has(l)){if(i=Sf(n,a,l),i<0)return-1;continue}r.push(l)}}return i}function J1(n){const e=[];let t=0;for(;t",t+4);if(i<0)return null;t=i+3}else if(n.startsWith("")}function Wa(n,e){const t=J1(n);if(!t)return null;const r=vt(n).innerHTML,i=t.map(c=>vt(c).innerHTML).join("");if(r!==i)return null;const s=Je.fromSchema(e),o=t.map(c=>{if(G1(c))return{html:c,nodes:[]};const d=[];return s.parseSlice(vt(c)).content.forEach(u=>d.push(u)),{html:c,nodes:d}}),l=[];let a="";for(const c of o){if(c.nodes.length===0){a+=c.html;continue}l.push({before:a,html:c.html,nodes:c.nodes}),a=""}return{blocks:l,trailing:a}}function Y1(n){for(const e of Array.from(n.querySelectorAll("table"))){const t=Array.from(e.children).find(i=>i.nodeName==="TBODY"),r=t?.firstElementChild;if(t&&r&&r.children.length>0&&Array.from(r.children).every(i=>i.nodeName==="TH")){const i=e.ownerDocument.createElement("thead");i.append(r),e.insertBefore(i,t),t.children.length===0&&t.remove()}}for(const e of Array.from(n.querySelectorAll("td, th"))){const t=e.childNodes.length===1?e.firstChild:null;t&&t.nodeName==="P"&&t.attributes.length===0&&e.replaceChildren(...Array.from(t.childNodes))}}function X1(n,e){if(n.type.name==="rawHtml")return String(n.attrs.html??"");const t=$o(),r=t.createElement("div");return r.appendChild(e.serializeNode(n,{document:t})),Y1(r),r.innerHTML}function ds(n,e,t){if(t+n.length>e.length)return!1;for(let r=0;rr&&l-n[o-1].nodes.length>=i&&ds(n[o-1].nodes,e,l-n[o-1].nodes.length);)o--,l-=n[o].nodes.length,s.unshift({block:o,node:l});const a=o-r,c=l-i;if(a>0&&c>0){const d=c+1,u=new Int32Array((a+1)*d),f=(m,g)=>ds(n[r+m].nodes,e,i+g)&&i+g+n[r+m].nodes.length<=l;for(let m=a-1;m>=0;m--)for(let g=c-1;g>=0;g--){let y=Math.max(u[(m+1)*d+g],u[m*d+g+1]);if(f(m,g)){const b=n[r+m].nodes.length;y=Math.max(y,b+u[(m+1)*d+g+b])}u[m*d+g]=y}let h=0,p=0;for(;h=u[h*d+p+1]?h++:p++}}return t.concat(s)}function Z1(n,e){const t=mt.fromSchema(n.schema),r=[];n.state.doc.forEach(d=>r.push(d));const i=e?.blocks??[],s=Q1(i,r);let o="",l=0,a=0;const c=(d,u)=>{if(u>a){d>l&&(o+=i[l].before);for(let f=a;f0||r.length===0)&&(o+=e.trailing),o}const pn=n=>n.isActive("table");function yr(n){return{command:`heading${n}`,glyph:`H${n}`,label:`heading${n}`,run:e=>e.chain().focus().toggleHeading({level:n}).run(),active:e=>e.isActive("heading",{level:n})}}function eS(n){const e=/^heading([1-6])$/.exec(n);return e?Number(e[1]):0}const tS=[[{command:"paragraph",glyph:"P",label:"paragraph",run:n=>n.chain().focus().setParagraph().run(),active:n=>n.isActive("paragraph")},yr(1),yr(2),yr(3),yr(4)],[{command:"bold",glyph:"B",label:"bold",run:n=>n.chain().focus().toggleBold().run(),active:n=>n.isActive("bold")},{command:"italic",glyph:"I",label:"italic",run:n=>n.chain().focus().toggleItalic().run(),active:n=>n.isActive("italic")},{command:"link",glyph:"Link",label:"link",run:(n,e)=>e.openLink(),active:n=>n.isActive("link"),host:!0}],[{command:"bulletList",glyph:"•",label:"bulletList",run:n=>n.chain().focus().toggleBulletList().run(),active:n=>n.isActive("bulletList")},{command:"orderedList",glyph:"1.",label:"orderedList",run:n=>n.chain().focus().toggleOrderedList().run(),active:n=>n.isActive("orderedList")},{command:"blockquote",glyph:"“”",label:"blockquote",run:n=>n.chain().focus().toggleBlockquote().run(),active:n=>n.isActive("blockquote")}],[{command:"insertTable",glyph:"Table",label:"insertTable",run:n=>n.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},{command:"addRow",glyph:"+Row",label:"addRow",run:n=>n.chain().focus().addRowAfter().run(),enabled:pn},{command:"deleteRow",glyph:"−Row",label:"deleteRow",run:n=>n.chain().focus().deleteRow().run(),enabled:pn},{command:"addColumn",glyph:"+Col",label:"addColumn",run:n=>n.chain().focus().addColumnAfter().run(),enabled:pn},{command:"deleteColumn",glyph:"−Col",label:"deleteColumn",run:n=>n.chain().focus().deleteColumn().run(),enabled:pn},{command:"deleteTable",glyph:"×Table",label:"deleteTable",run:n=>n.chain().focus().deleteTable().run(),enabled:pn}],[{command:"image",glyph:"Image",label:"image",run:(n,e)=>e.pickImage(),host:!0},{command:"mediaLibrary",glyph:"Library",label:"mediaLibrary",run:(n,e)=>e.pickFromMediaLibrary(),host:!0},{command:"embed",glyph:"Video",label:"embed",run:(n,e)=>e.openEmbed(),host:!0},{command:"rawHtml",glyph:"HTML",label:"rawHtml",run:(n,e)=>e.insertRawHtml(),host:!0}],[{command:"undo",glyph:"Undo",label:"undo",run:n=>n.chain().focus().undo().run(),enabled:n=>n.can().undo()},{command:"redo",glyph:"Redo",label:"redo",run:n=>n.chain().focus().redo().run(),enabled:n=>n.can().redo()}]];function nS(n){const{labels:e}=n,t=document.createElement("div");t.className="blogeditor__bar";const r=document.createElement("div");r.className="blogeditor__tools",r.setAttribute("role","toolbar"),r.setAttribute("aria-label",e.toolbar);const i=[];for(const p of tS){const m=document.createElement("div");m.className="blogeditor__group";for(const g of p){const y=eS(g.command);if(y>0&&!n.headingLevels.includes(y))continue;const b=document.createElement("button");b.type="button",b.dataset.command=g.command,b.textContent=g.glyph,b.title=e[g.label],b.setAttribute("aria-label",e[g.label]),b.addEventListener("mousedown",k=>k.preventDefault()),b.addEventListener("click",()=>{const k=n.editor();k&&(!g.host&&!k.isEditable||g.run(k,n))}),m.append(b),i.push({spec:g,button:b})}r.append(m)}const s=document.createElement("div");s.className="blogeditor__tabs",s.setAttribute("role","tablist");const o=(p,m)=>{const g=document.createElement("button");return g.type="button",g.dataset.tab=p,g.setAttribute("role","tab"),g.textContent=m,g.addEventListener("click",()=>n.showSource(p==="source")),s.append(g),g},l=o("wysiwyg",e.tabWysiwyg),a=o("source",e.tabSource),c=document.createElement("div");c.className="blogeditor__view";const d=document.createElement("button");d.type="button",d.dataset.command="preview",d.textContent=e.preview,d.title=e.preview,d.setAttribute("aria-label",e.preview),d.setAttribute("aria-pressed","false"),d.addEventListener("mousedown",p=>p.preventDefault()),d.addEventListener("click",()=>n.togglePreview()),c.append(d),t.append(r,s,c);let u=!1,f=!1;const h=()=>{const p=n.editor();for(const{spec:m,button:g}of i){m.active&&g.setAttribute("aria-pressed",String(!!p&&m.active(p)));const y=!!p&&!u&&!f&&(m.enabled?m.enabled(p):!0);g.disabled=!y}};return{element:t,refresh:h,selectTab:p=>{f=p,l.setAttribute("aria-selected",String(!p)),a.setAttribute("aria-selected",String(p)),h()},setDisabled:p=>{u=p,h()},setPreview:p=>{d.setAttribute("aria-pressed",String(p))}}}const ja="golem15-journal-blogeditor",rS="summer-change",iS="summer-upload",Ua="summer-upload-result",Ka="summer-media-pick",qa="summer-media-pick-result",xf=["image/jpeg","image/png","image/gif","image/webp"],sS=6e4,oS=["click here","here","more","read more","learn more","this link","link","kliknij tutaj","tutaj","tu","więcej","czytaj więcej","czytaj dalej","ten link"];function Ja(n){let e={};try{const i=n?JSON.parse(n):{};i&&typeof i=="object"&&!Array.isArray(i)&&(e=i)}catch{}const t=Array.isArray(e.headingLevels)?[...new Set(e.headingLevels.filter(i=>Number.isInteger(i)&&i>=1&&i<=6))].sort():[],r=Array.isArray(e.genericAnchors)?e.genericAnchors.filter(i=>typeof i=="string"):[...oS];return{headingLevels:t.length>0?t:[...mf],genericAnchors:[...new Set(r.map(gf).filter(i=>i!==""))],embedProviders:mb(e.embedProviders)}}class lS extends HTMLElement{static observedAttributes=["disabled","invalid","locale"];#x="";#C="";#M="";#A=null;#c="clean";#e;#r=Jn("en");#d;#T;#n;#N;#O;#s;#p;#t;#u;#l;#f=Ja(null);#R=!1;#h=new Map;#m=new Map;#g={width:null,height:null};#y=[];#b=!1;#L;#k;#w;#a;constructor(){if(super(),Object.prototype.hasOwnProperty.call(this,"value")){const e=this.value;delete this.value,this.value=e}}get value(){switch(this.#c){case"source":return this.#C;case"wysiwyg":return this.#e?Z1(this.#e,this.#A):this.#x;default:return this.#x}}set value(e){const t=typeof e=="string"?e:e==null?"":String(e);t!==this.value&&(this.#x=t,this.#c="clean",this.#n&&(this.#n.value=t),this.#P(t),this.#v(),this.#l?.schedule())}get editor(){return this.#e}connectedCallback(){if(this.#e)return;this.classList.add("blogeditor"),this.replaceChildren(),this.#r=Jn(this.getAttribute("ui-locale"));const e=this.#r;this.#f=Ja(this.getAttribute("options"));const t=this.#f;this.#d=nS({editor:()=>this.#e,labels:e,openLink:()=>this.#G(),openEmbed:()=>this.#ee(),pickImage:()=>this.#O?.click(),pickFromMediaLibrary:()=>this.#se(),insertRawHtml:()=>this.#te(),showSource:h=>this.showSource(h),togglePreview:()=>this.showPreview(!this.#b),headingLevels:t.headingLevels}),this.#s=this.#B("link",e.linkUrl,[["apply",e.linkApply,()=>this.#X()],["remove",e.linkRemove,()=>this.#F()],["cancel",e.cancel,()=>this.#i(this.#s)]]);const r=z1(e,t.genericAnchors);this.#p=r;const i=this.#s.root.querySelector("label");i.after(r.fieldset,r.warning),i.querySelector("input").addEventListener("input",h=>r.setUrl(h.target.value)),this.#t=this.#Q(t.embedProviders)?this.#Z(e,t.embedProviders):this.#B("embed",e.embedUrl,[["insert",e.embedInsert,()=>this.#I()],["cancel",e.cancel,()=>this.#i(this.#t)]]),this.#u=T1(e,()=>this.#ie(),()=>this.#U());const s=document.createElement("div");s.className="blogeditor__content",this.#T=s;const o=document.createElement("textarea");o.className="blogeditor__source",o.spellcheck=!1,o.hidden=!0,o.setAttribute("aria-label",e.tabSource),o.value=this.value,o.addEventListener("input",()=>this.#J()),this.#n=o;const l=document.createElement("p");l.className="blogeditor__status",l.setAttribute("role","status"),l.setAttribute("aria-live","polite"),this.#N=l;const a=document.createElement("input");a.type="file",a.accept=xf.join(","),a.multiple=!0,a.hidden=!0,a.addEventListener("change",()=>this.#ne()),this.#O=a;const c=document.createElement("div");c.className="blogeditor__main",c.append(s,o);const d=document.createElement("div");d.className="blogeditor__preview",d.hidden=!0,this.#k=d,this.#w=void 0;const u=document.createElement("div");u.className="blogeditor__panes",u.append(c,d),this.#L=u,this.#l=D1({labels:e,editor:()=>this.#e,sourceText:()=>this.#R&&this.#n?this.#n.value:null,allowsH1:t.headingLevels.includes(1),genericAnchors:t.genericAnchors}),this.append(this.#d.element,this.#s.root,this.#t.root,this.#u.root,u,this.#l.element,l,a),this.addEventListener(Ua,this.#W),this.addEventListener(qa,this.#K),this.addEventListener(Ys,this.#_);const f=this.value;this.#M=f,this.#e=new lb({element:s,injectCSS:!1,editable:!this.hasAttribute("disabled"),extensions:v1(e,t.headingLevels,t.embedProviders),content:f,editorProps:{handleDrop:(h,p,m,g)=>{if(g)return!1;const y=Array.from(p.dataTransfer?.files??[]).filter(Ga);return y.length===0?!1:(p.preventDefault(),this.#V(y),!0)}},onUpdate:({transaction:h,appendedTransactions:p})=>{!h.docChanged&&!p.some(m=>m.docChanged)||(this.#c="wysiwyg",this.#z(),this.#v(),this.#l?.schedule())},onTransaction:()=>this.#d?.refresh()}),this.#A=Wa(f,this.#e.schema),this.#$(),this.showSource(!1),this.#b&&this.showPreview(!0),this.#l.refresh()}disconnectedCallback(){this.removeEventListener(Ua,this.#W),this.removeEventListener(qa,this.#K),this.removeEventListener(Ys,this.#_);for(const{timer:e}of this.#h.values())clearTimeout(e);this.#h.clear(),this.#m.clear(),clearTimeout(this.#a),this.#a=void 0,this.#l?.stop(),this.#y=[],this.#c==="wysiwyg"&&this.#e&&(this.#x=this.value,this.#c="clean"),this.#e?.destroy(),this.#e=void 0}attributeChangedCallback(){this.#$(),this.#v()}showSource(e){!this.#n||!this.#T||(e?this.#n.value=this.value:this.#R&&this.#c==="source"&&this.#C!==this.#M&&this.#P(this.#C),this.#R=e,this.#n.hidden=!e,this.#T.hidden=e,e&&(this.#i(this.#s),this.#i(this.#t)),this.#d?.selectTab(e),this.#l?.refresh())}showPreview(e){this.#b=e,!(!this.#L||!this.#k)&&(this.#k.hidden=!e,this.#L.classList.toggle("blogeditor__panes--split",e),this.#d?.setPreview(e),e?this.#D():(clearTimeout(this.#a),this.#a=void 0))}#D(){if(clearTimeout(this.#a),this.#a=void 0,!this.#b)return;const e=this.#q();if(!e)return;const t=this.value,r=K1(t,{labels:this.#r,lang:this.getAttribute("locale"),providers:this.#f.embedProviders,...V1(this)});e.getAttribute("srcdoc")!==r&&(e.srcdoc=r)}#v(){!this.#b||!this.#w||(clearTimeout(this.#a),this.#a=setTimeout(()=>this.#D(),H1))}#q(){if(this.#w)return this.#w;if(!this.#k)return;const e=document.createElement("iframe");return e.setAttribute("sandbox",$1),e.setAttribute("referrerpolicy","no-referrer"),e.title=this.#r.previewFrame,this.#k.append(e),this.#w=e,e}#P(e){this.#M=e,this.#e&&(this.#e.chain().setMeta("addToHistory",!1).setContent(e,{emitUpdate:!1}).run(),this.#A=Wa(e,this.#e.schema))}#J(){this.#n&&(this.#C=this.#n.value,this.#c="source",this.#z(),this.#v(),this.#l?.schedule())}#z(){this.dispatchEvent(new CustomEvent(rS,{bubbles:!0,composed:!0,detail:{value:this.value}}))}#S(e){this.#N&&(this.#N.textContent=e)}#$(){const e=this.hasAttribute("disabled"),t=this.hasAttribute("invalid");this.#e&&this.#e.isEditable===e&&this.#e.setEditable(!e,!1),this.#d?.setDisabled(e),this.#n&&(this.#n.readOnly=e,t?this.#n.setAttribute("aria-invalid","true"):this.#n.removeAttribute("aria-invalid"));const r=this.#e?.view.dom;if(r){t?r.setAttribute("aria-invalid","true"):r.removeAttribute("aria-invalid");const i=this.getAttribute("locale");i?r.setAttribute("lang",i):r.removeAttribute("lang")}}#B(e,t,r){const i=document.createElement("div");i.className="blogeditor__form",i.dataset.form=e,i.hidden=!0;const s=document.createElement("label"),o=document.createElement("span");o.textContent=t;const l=document.createElement("input");l.type="text",l.name="url",l.autocomplete="off",l.addEventListener("keydown",d=>{d.key==="Enter"?(d.preventDefault(),r[0][2]()):d.key==="Escape"&&(d.preventDefault(),this.#i(c))}),s.append(o,l),i.append(s);for(const[d,u,f]of r)i.append(this.#E(d,u,f));const a=document.createElement("p");a.className="blogeditor__error",a.dataset.error="",a.setAttribute("aria-live","polite"),i.append(a);const c={root:i,error:a};return c}#E(e,t,r){const i=document.createElement("button");return i.type="button",i.dataset.action=e,i.textContent=t,i.addEventListener("click",r),i}#H(e,t=""){if(!e)return;for(const i of[this.#s,this.#t])i&&i!==e&&this.#i(i);e.error.textContent="",e.root.hidden=!1;const r=e.root.querySelector("input");r&&(r.value=t,r.focus())}#i(e){e&&(e.root.hidden=!0,e.error.textContent="")}#o(e,t="url"){return(e?.root.querySelector(`input[name="${t}"]`)?.value??"").trim()}#G(){const e=this.#e;if(!e?.isEditable)return;const t=e.getAttributes("link"),r=typeof t.href=="string"?t.href:"";this.#H(this.#s,r),this.#p?.setUrl(r),this.#p?.setRel(t.rel),this.#p?.setText(this.#Y())}#Y(){const e=this.#e;if(!e)return"";const{state:t}=e;let{from:r,to:i}=t.selection;if(e.isActive("link")){const s=t.schema.marks.link,o=t.doc.resolve(r),l=o.parent.childAfter(o.parentOffset);if(s&&l.node&&s.isInSet(l.node.marks)){const a=o.start();let c=a+l.offset,d=c+l.node.nodeSize;const u=e.getAttributes("link").href;o.parent.forEach((f,h)=>{const p=f.marks.find(y=>y.type===s);if(!p||p.attrs.href!==u)return;const m=a+h,g=m+f.nodeSize;g===c&&(c=m),m===d&&(d=g)}),r=c,i=d}}return t.doc.textBetween(r,i," ")}#X(){const e=this.#e;if(!e||!this.#s)return;const t=this.#o(this.#s);if(t===""){this.#F();return}if(!Pe(t)){this.#s.error.textContent=this.#r.linkInvalid;return}const r=this.#p?.rel(t)??null,{empty:i}=e.state.selection;i&&!e.isActive("link")?e.chain().focus().insertContent({type:"text",text:t,marks:[{type:"link",attrs:{href:t,rel:r}}]}).unsetMark("link").run():e.chain().focus().extendMarkRange("link").setLink({href:t,rel:r}).run(),this.#i(this.#s)}#F(){this.#e?.chain().focus().extendMarkRange("link").unsetLink().run(),this.#i(this.#s)}#Q(e){return e.length>1||e[0]?.key!=="youtube"||e[0]?.mode!=="url"}#Z(e,t){const r=document.createElement("div");r.className="blogeditor__form",r.dataset.form="embed",r.hidden=!0;const i=P=>{P.key==="Enter"?(P.preventDefault(),this.#I()):P.key==="Escape"&&(P.preventDefault(),this.#i(D))},s=document.createElement("label"),o=document.createElement("span");o.textContent=e.embedProvider;const l=document.createElement("select");l.name="provider";for(const P of t){const Y=document.createElement("option");Y.value=P.key,Y.textContent=P.name,l.append(Y)}s.append(o,l);const a=document.createElement("label");a.dataset.embedMode="url";const c=document.createElement("span");c.textContent=e.embedUrl;const d=document.createElement("input");d.type="text",d.name="url",d.autocomplete="off",d.addEventListener("keydown",i),a.append(c,d);const u=document.createElement("div");u.className="blogeditor__embed-fields",u.dataset.embedMode="id";const f=(P,Y,Re="")=>{const me=document.createElement("label"),xe=document.createElement("span");xe.textContent=Y;const Q=document.createElement("input");return Q.type="text",Q.name=P,Q.autocomplete="off",Re&&(Q.placeholder=Re),Q.addEventListener("keydown",i),me.append(xe,Q),{label:me,input:Q}},h=f("embedId",e.embedId),p=document.createElement("label"),m=document.createElement("span");m.textContent=e.embedFallbackImage;const g=document.createElement("div");g.className="blogeditor__embed-row";const y=document.createElement("input");y.type="text",y.name="fallbackSrc",y.autocomplete="off",y.addEventListener("keydown",i),y.addEventListener("input",()=>{this.#g={width:null,height:null}});const b=this.#E("pick-fallback",e.embedFallbackPick,()=>this.#oe());g.append(y,b),p.append(m,g);const k=f("fallbackAlt",e.embedFallbackAlt),S=f("caption",e.embedCaption),v=f("aspect",e.embedAspect,"16/9"),L=f("height",e.embedHeight,"420px");u.append(h.label,p,k.label,S.label,v.label,L.label);const E=()=>{const P=Qt(t,l.value)??t[0],Y=P?.mode==="url";a.hidden=!Y,u.hidden=Y,h.input.placeholder=P?.placeholder??"",D.error.textContent=""};l.addEventListener("change",E);const R=document.createElement("p");R.className="blogeditor__error",R.dataset.error="",R.setAttribute("aria-live","polite");const D={root:r,error:R};return r.append(s,a,u,this.#E("insert",e.embedInsert,()=>this.#I()),this.#E("cancel",e.cancel,()=>this.#i(D)),R),E(),D}#ee(){if(!this.#e?.isEditable)return;this.#g={width:null,height:null},this.#H(this.#t);const e=this.#t;if(!e)return;for(const r of Array.from(e.root.querySelectorAll("input")))r.value="";const t=e.root.querySelector('select[name="provider"]');t&&(t.dispatchEvent(new Event("change")),(Qt(this.#f.embedProviders,t.value)?.mode==="id"?e.root.querySelector('input[name="embedId"]'):e.root.querySelector('input[name="url"]'))?.focus())}#I(){if(!this.#e||!this.#t)return;const e=this.#t.root.querySelector('select[name="provider"]');if(!e){const c=gb(this.#o(this.#t));if(!c){this.#t.error.textContent=this.#r.embedInvalid;return}this.#e.chain().focus().setEmbed(c).run(),this.#i(this.#t);return}const t=Qt(this.#f.embedProviders,e.value);if(!t){this.#t.error.textContent=this.#r.embedIdInvalid;return}if(t.mode==="url"){const c=hu([t],this.#o(this.#t,"url"));if(!c){this.#t.error.textContent=this.#r.embedInvalid;return}this.#e.chain().focus().setEmbed(c).run(),this.#i(this.#t);return}const r=this.#o(this.#t,"embedId");if(!fu(this.#f.embedProviders,t.key,r)){this.#t.error.textContent=this.#r.embedIdInvalid;return}const i=this.#o(this.#t,"fallbackSrc");if(i!==""&&!Pe(i)){this.#t.error.textContent=this.#r.linkInvalid;return}const s=this.#o(this.#t,"aspect");if(s!==""&&!$r(s)){this.#t.error.textContent=this.#r.embedAspectInvalid;return}const o=this.#o(this.#t,"height");if(o!==""&&!Br(o)){this.#t.error.textContent=this.#r.embedHeightInvalid;return}const l=this.#o(this.#t,"fallbackAlt"),a=this.#o(this.#t,"caption");this.#e.chain().focus().setEmbed({provider:t.key,id:r,aspect:s||null,height:o||null,fallbackSrc:i||null,fallbackAlt:i?l:null,fallbackWidth:i?this.#g.width:null,fallbackHeight:i?this.#g.height:null,caption:a||null}).run(),this.#i(this.#t)}#te(){const e=this.#e;if(!e?.isEditable)return;const t=this.value,r="
";if(!e.chain().focus().insertRawHtml(r).run())return;const i=this.value;let s=0;for(;s{const t=e.detail?.html??"";this.showSource(!0);const r=this.#n;if(!r)return;r.focus();const i=t?r.value.indexOf(t):-1;i>=0&&r.setSelectionRange(i,i+t.length)};#ne(){const e=this.#O;if(!e)return;const t=Array.from(e.files??[]),r=t.filter(Ga);r.length{this.#h.delete(r)&&this.#S(Lt(this.#r.uploadTimeout,{name:i}))},sS);this.#h.set(r,{name:i,choice:t,timer:s}),this.#S(Lt(this.#r.uploading,{name:i})),this.dispatchEvent(new CustomEvent(iS,{bubbles:!0,composed:!0,detail:{id:r,file:e}}))}#W=e=>{const t=e.detail??{},r=typeof t.id=="string"?t.id:"",i=this.#h.get(r);if(!i)return;clearTimeout(i.timer),this.#h.delete(r);const s=typeof t.url=="string"?t.url:"";if(typeof t.error=="string"||!s||!Pe(s)){const c=typeof t.error=="string"&&t.error?t.error:i.name;this.#S(Lt(this.#r.uploadFailed,{error:c}));return}this.#S("");const o=this.#e;if(!o)return;const{alt:l,caption:a}=i.choice;a?o.chain().focus().setFigure({src:s,alt:l,caption:a}).run():o.chain().focus().setImage({src:s,alt:l}).run()};#j(){const e=this.#u,t=this.#y[0];!e||!e.root.hidden||!t||e.open(t)}#ie(){const e=this.#u,t=this.#y[0];if(!this.#e||!e||!t)return;const r=e.choice();if(!r)return;const i=r.fileName===t.name?t:new File([t],r.fileName,{type:t.type,lastModified:t.lastModified});this.#re(i,r),this.#U()}#U(){this.#y.shift(),this.#u&&(this.#u.root.hidden=!0),this.#j()}#se(){if(!this.#e?.isEditable)return;const e=us();this.#m.set(e,"insert"),this.dispatchEvent(new CustomEvent(Ka,{bubbles:!0,composed:!0,detail:{id:e,mode:"image",defaultFolder:"journal",showAlt:!0}}))}#oe(){if(!this.#e?.isEditable)return;const e=us();this.#m.set(e,"embedFallback"),this.dispatchEvent(new CustomEvent(Ka,{bubbles:!0,composed:!0,detail:{id:e,mode:"image",defaultFolder:"journal",showAlt:!0}}))}#K=e=>{const t=e.detail??{},r=typeof t.id=="string"?t.id:"",i=this.#m.get(r);if(!i||(this.#m.delete(r),t.cancelled===!0||!t.item))return;const s=typeof t.item.url=="string"?t.item.url.trim():"";if(!s||!Pe(s))return;const o=typeof t.item.alt=="string"?t.item.alt:"",l=typeof t.item.caption=="string"?t.item.caption.trim():"",a=typeof t.item.width=="number"&&t.item.width>0?String(t.item.width):null,c=typeof t.item.height=="number"&&t.item.height>0?String(t.item.height):null;if(i==="embedFallback"){const u=this.#t;if(!u)return;const f=u.root.querySelector('input[name="fallbackSrc"]');f&&(f.value=s);const h=u.root.querySelector('input[name="fallbackAlt"]');h&&o&&(h.value=o);const p=u.root.querySelector('input[name="caption"]');p&&l&&!p.value&&(p.value=l),this.#g={width:a,height:c};return}const d=this.#e;if(d)if(l)d.chain().focus().setFigure({src:s,alt:o,caption:l,width:a,height:c}).run();else{const u={src:s,alt:o};a&&(u.width=a),c&&(u.height=c),d.chain().focus().setImage(u).run()}}}function Ga(n){return xf.includes(n.type)}let Ya=0;function us(){const n=globalThis.crypto;if(n&&typeof n.randomUUID=="function")return n.randomUUID();if(n&&typeof n.getRandomValues=="function"){const e=n.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;const t=Array.from(e,r=>r.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}return Ya+=1,`upload-${Date.now().toString(36)}-${Ya}`}customElements.get(ja)||customElements.define(ja,lS);export{lS as BlogEditorElement,ja as TAG}; diff --git a/assets/src/blogeditor/element.ts b/assets/src/blogeditor/element.ts index 815e56f..dcc92df 100644 --- a/assets/src/blogeditor/element.ts +++ b/assets/src/blogeditor/element.ts @@ -798,12 +798,12 @@ export class BlogEditorElement extends HTMLElement { } const aspect = this.#inputOf(this.#embedForm, 'aspect') if (aspect !== '' && !isValidAspect(aspect)) { - this.#embedForm.error.textContent = this.#labels.embedIdInvalid + this.#embedForm.error.textContent = this.#labels.embedAspectInvalid return } const height = this.#inputOf(this.#embedForm, 'height') if (height !== '' && !isValidHeight(height)) { - this.#embedForm.error.textContent = this.#labels.embedIdInvalid + this.#embedForm.error.textContent = this.#labels.embedHeightInvalid return } const fallbackAlt = this.#inputOf(this.#embedForm, 'fallbackAlt') diff --git a/assets/src/blogeditor/embed.ts b/assets/src/blogeditor/embed.ts index 9ad2205..914eaa3 100644 --- a/assets/src/blogeditor/embed.ts +++ b/assets/src/blogeditor/embed.ts @@ -43,6 +43,7 @@ const YOUTUBE_HOSTS = new Set([ ]) const EMBED_KEY_RE = /^[a-z][a-z0-9_-]{0,31}$/ +const RESERVED_EMBED_KEYS = new Set(['constructor', 'prototype']) const EMBED_ASPECT_RE = /^[1-9][0-9]{0,3}(?:\s*\/\s*[1-9][0-9]{0,3}|\.[0-9]{1,4})?$/ const EMBED_HEIGHT_RE = /^[1-9][0-9]{0,3}(?:px)?$/ @@ -92,7 +93,7 @@ export function resolveEmbedProviders(raw: unknown): ResolvedEmbedProvider[] { if (!item || typeof item !== 'object' || Array.isArray(item)) continue const cfg = item as Record const key = typeof cfg.key === 'string' ? cfg.key.trim() : '' - if (!EMBED_KEY_RE.test(key) || seen.has(key)) continue + if (!EMBED_KEY_RE.test(key) || RESERVED_EMBED_KEYS.has(key) || seen.has(key)) continue const patternSrc = typeof cfg.idPattern === 'string' ? cfg.idPattern.trim() : '' if (!patternSrc) continue let idPattern: RegExp @@ -103,9 +104,11 @@ export function resolveEmbedProviders(raw: unknown): ResolvedEmbedProvider[] { continue } const name = typeof cfg.name === 'string' && cfg.name.trim() !== '' ? cfg.name.trim() : key + const idFromUrl = key === 'youtube' ? EMBED_PROVIDERS.youtube.idFromUrl : undefined const rawMode = typeof cfg.mode === 'string' ? cfg.mode.trim() : '' + // Only providers with a URL parser can operate in URL mode (WR-03). const mode: EmbedInputMode = - rawMode === 'url' || rawMode === 'id' ? rawMode : key === 'youtube' ? 'url' : 'id' + rawMode === 'url' && idFromUrl ? 'url' : rawMode === 'id' ? 'id' : idFromUrl ? 'url' : 'id' const placeholder = typeof cfg.placeholder === 'string' && cfg.placeholder.trim() !== '' ? cfg.placeholder.trim() : undefined const resolved: ResolvedEmbedProvider = { key, @@ -113,7 +116,7 @@ export function resolveEmbedProviders(raw: unknown): ResolvedEmbedProvider[] { idPattern, mode, ...(placeholder ? { placeholder } : {}), - ...(key === 'youtube' ? { idFromUrl: EMBED_PROVIDERS.youtube.idFromUrl } : {}), + ...(idFromUrl ? { idFromUrl } : {}), } seen.add(key) out.push(resolved) diff --git a/assets/src/blogeditor/labels.ts b/assets/src/blogeditor/labels.ts index 47eea05..7a16fbe 100644 --- a/assets/src/blogeditor/labels.ts +++ b/assets/src/blogeditor/labels.ts @@ -48,7 +48,9 @@ export interface Labels { embedFallbackAlt: string embedCaption: string embedAspect: string + embedAspectInvalid: string embedHeight: string + embedHeightInvalid: string embedGeneric: string cancel: string uploading: string @@ -133,7 +135,9 @@ const en: Labels = { embedFallbackAlt: 'Fallback alt text (optional)', embedCaption: 'Caption (optional)', embedAspect: 'Aspect ratio (optional)', + embedAspectInvalid: 'Enter a valid aspect ratio (e.g. 16/9 or 1.5).', embedHeight: 'Height (optional)', + embedHeightInvalid: 'Enter a valid height in pixels (e.g. 420 or 420px).', embedGeneric: 'Embed', cancel: 'Cancel', uploading: 'Uploading {name}…', @@ -215,7 +219,9 @@ const pl: Labels = { embedFallbackAlt: 'Tekst alternatywny obrazu (opcjonalny)', embedCaption: 'Podpis (opcjonalny)', embedAspect: 'Proporcje (opcjonalne)', + embedAspectInvalid: 'Wpisz poprawne proporcje (np. 16/9 lub 1.5).', embedHeight: 'Wysokość (opcjonalna)', + embedHeightInvalid: 'Wpisz poprawną wysokość w pikselach (np. 420 lub 420px).', embedGeneric: 'Osadź', cancel: 'Anuluj', uploading: 'Wysyłanie {name}…', diff --git a/assets/src/blogeditor/preview.ts b/assets/src/blogeditor/preview.ts index cb04a84..beeb1f4 100644 --- a/assets/src/blogeditor/preview.ts +++ b/assets/src/blogeditor/preview.ts @@ -161,7 +161,7 @@ export function previewBody( if (provider === 'youtube' && figure.childNodes.length === 0) { const card = doc.createElement('figure') - card.className = 'embed-card' + card.className = 'embed-card embed-card--youtube' const img = doc.createElement('img') img.setAttribute('src', youtubeThumbnail(id)) img.setAttribute('alt', '') @@ -220,7 +220,8 @@ function previewStyles(c: PreviewColors, font: string): string { `th{background:${c.subtle};font-weight:600;text-align:left}`, `figcaption{font-size:13px;color:${c.muted};margin-top:4px}`, `.embed-card{max-width:480px;border:1px solid ${c.border};border-radius:8px;overflow:hidden;background:${c.subtle}}`, - '.embed-card img{display:block;width:100%;height:auto;aspect-ratio:16/9;object-fit:cover}', + '.embed-card img{display:block;width:100%;height:auto}', + '.embed-card--youtube img{aspect-ratio:16/9;object-fit:cover}', `.embed-card__placeholder{padding:24px 16px;text-align:center;font-size:14px;color:${c.muted}}`, '.embed-card figcaption{padding:8px 12px;margin:0}', ].join('\n') diff --git a/classes/embed_registry.go b/classes/embed_registry.go index a27fc0c..edea65f 100644 --- a/classes/embed_registry.go +++ b/classes/embed_registry.go @@ -27,6 +27,13 @@ var ( embedAspectPattern = regexp.MustCompile(`^[1-9][0-9]{0,3}(?:\s*/\s*[1-9][0-9]{0,3}|\.[0-9]{1,4})?$`) embedHeightPattern = regexp.MustCompile(`^[1-9][0-9]{0,3}(?:px)?$`) + // reservedEmbedProviderKeys mirrors vue-journal-layer's prototype-property + // guard so Go, Blog Editor, and Nuxt enforce the exact same key allow-list. + reservedEmbedProviderKeys = map[string]bool{ + "constructor": true, + "prototype": true, + } + // defaultEmbedRegistry is the immutable youtube-only registry used when // callers invoke package-level HTML helpers without a backpack.App. defaultEmbedRegistry = NewEmbedRegistry() @@ -97,8 +104,8 @@ func (r *EmbedRegistry) Register(p EmbedProvider) error { return fmt.Errorf("embed provider: registry is nil") } p.Key = strings.TrimSpace(p.Key) - if !embedProviderKeyPattern.MatchString(p.Key) { - return fmt.Errorf("embed provider %q: key must match %s", p.Key, embedProviderKeyPattern.String()) + if !embedProviderKeyPattern.MatchString(p.Key) || reservedEmbedProviderKeys[p.Key] { + return fmt.Errorf("embed provider %q: key must match %s and must not be a reserved name", p.Key, embedProviderKeyPattern.String()) } p.IDPattern = strings.TrimSpace(p.IDPattern) if p.IDPattern == "" { diff --git a/classes/embed_registry_test.go b/classes/embed_registry_test.go index 1eb5140..516c4b4 100644 --- a/classes/embed_registry_test.go +++ b/classes/embed_registry_test.go @@ -127,6 +127,8 @@ journal: }{ {"path traversal key", EmbedProvider{Key: "../x", IDPattern: `^[a-z]+$`}, "../x"}, {"uppercase key", EmbedProvider{Key: "YouTube", IDPattern: `^[a-z]+$`}, "YouTube"}, + {"reserved constructor key", EmbedProvider{Key: "constructor", IDPattern: `^[a-z]+$`}, "constructor"}, + {"reserved prototype key", EmbedProvider{Key: "prototype", IDPattern: `^[a-z]+$`}, "prototype"}, {"empty key", EmbedProvider{Key: "", IDPattern: `^[a-z]+$`}, `""`}, {"missing pattern", EmbedProvider{Key: "viz", IDPattern: ""}, "viz"}, {"invalid regex", EmbedProvider{Key: "viz", IDPattern: `[unclosed`}, "viz"}, diff --git a/tests/blogeditor/embed.test.ts b/tests/blogeditor/embed.test.ts index 82c5648..c8fd4d7 100644 --- a/tests/blogeditor/embed.test.ts +++ b/tests/blogeditor/embed.test.ts @@ -315,10 +315,15 @@ describe('dynamic embed providers (Phase 38)', () => { { key: 'viz', name: 'Duplicate', idPattern: '^[0-9]+$' }, { key: '../bad', name: 'Bad Key', idPattern: '^[a-z]+$' }, { key: 'BadCase', name: 'Upper', idPattern: '^[a-z]+$' }, + { key: 'constructor', name: 'Reserved', idPattern: '^[a-z]+$' }, + { key: 'prototype', name: 'Reserved2', idPattern: '^[a-z]+$' }, { key: 'broken', name: 'Bad Regex', idPattern: '[unclosed' }, { key: 'empty', name: 'No Pattern', idPattern: '' }, + { key: 'custom_url', name: 'Custom URL', idPattern: '^[a-z0-9-]+$', mode: 'url' }, ]) - expect(resolved.map((p) => p.key)).toEqual(['youtube', 'viz']) + expect(resolved.map((p) => p.key)).toEqual(['youtube', 'viz', 'custom_url']) + // Custom providers without a URL parser degrade to 'id' mode (WR-03). + expect(resolved.find((p) => p.key === 'custom_url')?.mode).toBe('id') expect(validateEmbedId(resolved, 'viz', 'demo-1')).toBe(true) expect(validateEmbedId(resolved, 'viz', 'demo-1!')).toBe(false) expect(validateEmbedId(resolved, 'youtube', 'demo-1')).toBe(false) @@ -378,7 +383,15 @@ describe('dynamic embed providers (Phase 38)', () => { ) fill(embedForm.querySelector('input[name="embedId"]'), 'demo-1') + // Invalid aspect / height report dedicated error messages (WR-03). + fill(embedForm.querySelector('input[name="aspect"]'), '16:9') + click(embedForm.querySelector('[data-action="insert"]')) + expect(embedForm.querySelector('[data-error]')!.textContent).toBe(labelsFor('en').embedAspectInvalid) fill(embedForm.querySelector('input[name="aspect"]'), '4/3') + fill(embedForm.querySelector('input[name="height"]'), '420em') + click(embedForm.querySelector('[data-action="insert"]')) + expect(embedForm.querySelector('[data-error]')!.textContent).toBe(labelsFor('en').embedHeightInvalid) + fill(embedForm.querySelector('input[name="height"]'), '') click(embedForm.querySelector('[data-action="insert"]')) expect(form(el, 'embed')).toBeNull()