From f08798a3857f35df7470f5d435b9ae23bd2e8f5d Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 14 May 2026 18:42:13 +0100 Subject: [PATCH 01/23] Add spec for Medium-style body editor Replace CKEditor 5 with a Tiptap-based body editor to fix two paste bugs: typography lost from Word/Docs/Notion paste, and markdown rendered literally. Approach: custom Django form widget, hidden textarea + Tiptap mount, smart paste pipeline (Office normaliser + markdown detect), no inline image upload in v1. --- ...6-05-14-medium-style-body-editor-design.md | 562 ++++++++++++++++++ 1 file changed, 562 insertions(+) create mode 100644 docs/superpowers/specs/2026-05-14-medium-style-body-editor-design.md diff --git a/docs/superpowers/specs/2026-05-14-medium-style-body-editor-design.md b/docs/superpowers/specs/2026-05-14-medium-style-body-editor-design.md new file mode 100644 index 0000000..970e70b --- /dev/null +++ b/docs/superpowers/specs/2026-05-14-medium-style-body-editor-design.md @@ -0,0 +1,562 @@ +# Medium-style body editor — design + +**Date:** 2026-05-14 +**Author:** Ephraim Kanyandula +**Status:** Draft — awaiting review + +## Problem + +Two related bugs report against `https://nyasablog.com/blog/create/`: + +1. **Pasted rich text loses typography.** Pasting from Word / Google Docs / + Notion strips formatting because CKEditor 5's current toolbar configuration + has no plugins for the inbound features, and the server-side sanitiser + (`blog/templatetags/sanitize.py`) intentionally drops `style=` attributes. +2. **Pasted markdown renders literally.** Pasting `## Heading` or `**bold**` + stores `## Heading` / `**bold**` as plain text; the detail page shows the + syntax characters because nothing converts markdown → HTML. + +Both bugs trace to the same root: the current editor has no smart paste +pipeline. Configuring more CKEditor plugins would partly close the first gap +but does not solve the second, and CKEditor is the wrong substrate for a +Medium-style UX (bubble toolbar, slash menu) that the project wants anyway. + +## Scope + +**In scope:** Replace the `{{ form.body }}` widget — the CKEditor 5 mount on +`create_blog.html:32` and `edit_blog.html` — with a Tiptap-based body editor. + +**Out of scope:** Title input, featured image upload (sidebar dropzone), slug +generation, category / tag / status form fields, Publish / Save Draft +buttons, mobile API serialisers. + +## Goals + +- Pasting from Word / Google Docs / Notion keeps **semantic** typography + (headings, lists, emphasis, links) while dropping presentational styles. +- Pasting raw markdown text converts to formatted HTML. +- Editor surface looks and feels Medium-like: a floating bubble toolbar on + text selection, a slash menu for inserting block elements. +- Existing posts (HTML stored by old CKEditor) render unchanged. +- No regression to the sanitiser pipeline, the body-search `body_plain` field, + or the API `body` field. + +## Non-goals + +- Inline image upload inside the body. Body images are deferred to v2. + Existing posts with `` tags continue to render; new posts cannot add + body images via the editor in v1. +- Auto-save drafts. Worth a separate spec. +- Embed blocks (YouTube, X, gist). Worth a separate spec and a server-side + oEmbed / iframe-whitelist design. +- Real-time collaboration, inline comments on drafts. +- Redesign of the surrounding page layout. + +## Approach + +**Custom Django form widget rendering a Tiptap mount point.** The widget is +a `forms.Textarea` subclass that renders a hidden ` + +
+ +
+
+ +``` + +### Form (`blog/forms.py`) + +```python +from blog.widgets import TiptapWidget + + +class CreateBlogPostForm(forms.ModelForm): + class Meta: + model = BlogPost + fields = ["title", "body", "image", "category", "tags", "status"] + widgets = { + "tags": forms.CheckboxSelectMultiple(), + "body": TiptapWidget(), + } + + +class UpdateBlogPostForm(forms.ModelForm): + class Meta: + model = BlogPost + fields = ["title", "body", "image", "category", "tags", "status"] + widgets = { + "tags": forms.CheckboxSelectMultiple(), + "body": TiptapWidget(), + } + + def save(self, commit=True): + if not self.cleaned_data.get("image"): + self.cleaned_data["image"] = self.instance.image + return super().save(commit=commit) +``` + +`{{ form.media }}` already lives in `create_blog.html:6`; it pulls +`tiptap.css` + `tiptap.js` automatically. Templates do not change. + +### Model (`blog/models.py`) + +```python +class BlogPost(models.Model): + ... + body = models.TextField(max_length=20000, blank=True) +``` + +### Migration (`blog/migrations/0010_alter_blogpost_body.py`) + +```python +class Migration(migrations.Migration): + dependencies = [("blog", "0009_alter_blogpost_body")] + operations = [ + migrations.AlterField( + model_name="blogpost", + name="body", + field=models.TextField(blank=True, max_length=20000), + ), + ] +``` + +Reversible. SQLite and Postgres both treat as no-op at the column level. + +### Removing CKEditor + +```python +# mysite/settings.py — delete +INSTALLED_APPS = [..., "django_ckeditor_5", ...] # remove entry +CKEDITOR_5_CONFIGS = {...} # remove block +CK_EDITOR_5_UPLOAD_FILE_VIEW_NAME = "..." # remove line +``` + +```python +# mysite/urls.py — delete +path("ckeditor5/", include("django_ckeditor_5.urls")), +``` + +``` +# requirements.txt — delete +django-ckeditor-5 +``` + +Existing post HTML is vendor-neutral (`

`, ``, `
`, +``, ``); CKEditor uninstall does not affect stored content. Verified +against the sanitiser's `ALLOWED_TAGS`. + +## Paste handling + +### Pipeline + +``` +clipboard event + │ + ▼ +smartPasteHandler(view, event) Tiptap editorProps.handlePaste + │ + ▼ inspect view.state.selection.$from.parent + │ + in code block? → return false (paste as plain text) + │ + ▼ inspect clipboardData + │ + has HTML and looks like Office/Docs/Notion? + │ yes → normaliseOfficeHtml → insert HTML → return true + ▼ + plain text only and looks like markdown? + │ yes → marked.parse → insert HTML → return true + ▼ + clipboard has image files? + │ yes → drop (v1: no inline image upload) → return true + ▼ + else → return false (Tiptap default) +``` + +### Office / Docs / Notion HTML normalisation + +`normaliseOfficeHtml(html)` strips ` +

Heading

+

Body text with a link.

+``` + +`src/tiptap/__tests__/fixtures/notion-paste.html`: +```html +

Heading

Body with bold and a link.

+``` + +- [ ] **Step 2: Write failing tests** + +`src/tiptap/__tests__/normalise.test.js`: +```js +import { describe, it, expect } from "vitest"; +import { readFileSync } from "node:fs"; +import { resolve, dirname } from "node:path"; +import { fileURLToPath } from "node:url"; +import { normaliseOfficeHtml, looksLikeOfficeHtml } from "../paste.js"; + +const here = dirname(fileURLToPath(import.meta.url)); +const fixture = (name) => readFileSync(resolve(here, "fixtures", name), "utf8"); + +describe("looksLikeOfficeHtml", () => { + it("detects Google Docs paste via docs-internal-guid", () => { + expect(looksLikeOfficeHtml(fixture("google-docs-paste.html"))).toBe(true); + }); + it("detects Word paste via mso- and office namespaces", () => { + expect(looksLikeOfficeHtml(fixture("word-paste.html"))).toBe(true); + }); + it("detects Notion paste via data-pm-slice", () => { + expect(looksLikeOfficeHtml(fixture("notion-paste.html"))).toBe(true); + }); + it("returns false for plain HTML", () => { + expect(looksLikeOfficeHtml("

hello

")).toBe(false); + }); +}); + +describe("normaliseOfficeHtml", () => { + it("strips style and class attributes", () => { + const out = normaliseOfficeHtml(fixture("google-docs-paste.html")); + expect(out).not.toMatch(/style=/); + expect(out).not.toMatch(/class=/); + }); + it("promotes with font-weight:bold context to ", () => { + const out = normaliseOfficeHtml(fixture("google-docs-paste.html")); + expect(out).toContain(""); + expect(out).toContain("Headline"); + }); + it("preserves targets", () => { + const out = normaliseOfficeHtml(fixture("google-docs-paste.html")); + expect(out).toContain('href="https://example.com"'); + }); + it("removes Office namespaced tags from Word paste", () => { + const out = normaliseOfficeHtml(fixture("word-paste.html")); + expect(out).not.toMatch(/, , , ', + author=self.user, category=self.category, status='published', + ) + r = self.client.get(reverse('detail', kwargs={'slug': post.slug})) + self.assertEqual(r.status_code, 200) + self.assertNotIn(b'', + author=self.user, category=self.category, status='published', + ) + r = self.client.get(reverse('blog:detail', args=[post.slug])) + self.assertEqual(r.status_code, 200) + self.assertNotIn(b'') + self.assertNotIn('', r.content) From 8adba849244c53f43dc7298f124216ae55e95dd2 Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 14 May 2026 22:36:51 +0100 Subject: [PATCH 15/23] Remove django-ckeditor-5 (replaced by Tiptap) --- blog/migrations/0009_alter_blogpost_body.py | 5 ++--- mysite/settings.py | 18 ------------------ mysite/urls.py | 3 --- personal/migrations/0004_page.py | 3 +-- requirements.txt | 1 - 5 files changed, 3 insertions(+), 27 deletions(-) diff --git a/blog/migrations/0009_alter_blogpost_body.py b/blog/migrations/0009_alter_blogpost_body.py index 7b54825..c1dba8d 100644 --- a/blog/migrations/0009_alter_blogpost_body.py +++ b/blog/migrations/0009_alter_blogpost_body.py @@ -1,7 +1,6 @@ # Generated by Django 5.2.12 on 2026-04-02 19:45 -import django_ckeditor_5.fields -from django.db import migrations +from django.db import migrations, models class Migration(migrations.Migration): @@ -14,6 +13,6 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='blogpost', name='body', - field=django_ckeditor_5.fields.CKEditor5Field(blank=True, max_length=20000), + field=models.TextField(blank=True, max_length=20000), ), ] diff --git a/mysite/settings.py b/mysite/settings.py index a4bb4f1..ce8beb3 100644 --- a/mysite/settings.py +++ b/mysite/settings.py @@ -39,8 +39,6 @@ 'personal', 'account', 'blog', - 'django_ckeditor_5', - 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', @@ -238,20 +236,4 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' -# CKEditor 5 -CKEDITOR_5_CONFIGS = { - 'default': { - 'toolbar': [ - 'heading', '|', - 'bold', 'italic', 'underline', 'strikethrough', '|', - 'bulletedList', 'numberedList', '|', - 'blockQuote', 'codeBlock', '|', - 'link', 'imageUpload', '|', - 'undo', 'redo', - ], - 'height': '400px', - 'width': '100%', - }, -} -CK_EDITOR_5_UPLOAD_FILE_VIEW_NAME = "ck_editor_5_upload_file" diff --git a/mysite/urls.py b/mysite/urls.py index bddaac2..5bb29f0 100644 --- a/mysite/urls.py +++ b/mysite/urls.py @@ -84,9 +84,6 @@ def robots_txt(request): path('contact/', contact_screen_view, name= "contact"), path('api/', api_screen_view, name= "api"), - # CKEditor 5 - path('ckeditor5/', include('django_ckeditor_5.urls')), - # REST FRAMEWORK URLS path('api/blog/', include('blog.api.urls', 'blog_api')), path('api/account/', include('account.api.urls', 'account_api')), diff --git a/personal/migrations/0004_page.py b/personal/migrations/0004_page.py index 6a2cd0a..3f29880 100644 --- a/personal/migrations/0004_page.py +++ b/personal/migrations/0004_page.py @@ -1,6 +1,5 @@ # Generated by Django 5.2.12 on 2026-05-04 08:39 -import django_ckeditor_5.fields from django.db import migrations, models @@ -17,7 +16,7 @@ class Migration(migrations.Migration): ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('slug', models.SlugField(unique=True)), ('title', models.CharField(max_length=120)), - ('body', django_ckeditor_5.fields.CKEditor5Field()), + ('body', models.TextField()), ('is_published', models.BooleanField(default=True)), ('updated_at', models.DateTimeField(auto_now=True)), ], diff --git a/requirements.txt b/requirements.txt index b2f474a..40a569c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,6 @@ boto3==1.42.82 botocore==1.42.82 Django==5.2.14 django-anymail[postmark]==15.0 -django-ckeditor-5==0.2.20 django-storages==1.12.3 djangorestframework==3.17.1 gunicorn==25.3.0 From 9083597c1db3dd96ae43f3813db00f6887cdb4f0 Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 14 May 2026 22:38:02 +0100 Subject: [PATCH 16/23] Build Tiptap editor bundle --- static/blog/tiptap.js | 152 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 static/blog/tiptap.js diff --git a/static/blog/tiptap.js b/static/blog/tiptap.js new file mode 100644 index 0000000..12416f1 --- /dev/null +++ b/static/blog/tiptap.js @@ -0,0 +1,152 @@ +(()=>{var Xp=Object.defineProperty;var Qp=(n,e,t)=>e in n?Xp(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var G=(n,e,t)=>Qp(n,typeof e!="symbol"?e+"":e,t);function Ce(n){this.content=n}Ce.prototype={constructor:Ce,find:function(n){for(var e=0;e>1}};Ce.from=function(n){if(n instanceof Ce)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Ce(e)};var gs=Ce;function cc(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),o=e.child(r);if(i==o){t+=i.nodeSize;continue}if(!i.sameMarkup(o))return t;if(i.isText&&i.text!=o.text){for(let s=0;i.text[s]==o.text[s];s++)t++;return t}if(i.content.size||o.content.size){let s=cc(i.content,o.content,t+1);if(s!=null)return s}t+=i.nodeSize}}function uc(n,e,t,r){for(let i=n.childCount,o=e.childCount;;){if(i==0||o==0)return i==o?null:{a:t,b:r};let s=n.child(--i),l=e.child(--o),a=s.nodeSize;if(s==l){t-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:t,b:r};if(s.isText&&s.text!=l.text){let c=0,u=Math.min(s.text.length,l.text.length);for(;ce&&r(a,i+l,o||null,s)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,i+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let o="",s=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(s?s=!1:o+=r),o+=c},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),o=1);oe)for(let o=0,s=0;se&&((st)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,t-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,t-s-1))),r.push(l),i+=l.nodeSize),s=a}return new n(r,i)}cutByIndex(e,t){return e==t?n.empty:e==0&&t==this.content.length?this:new n(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),o=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new n(i,o)}addToStart(e){return new n([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new n(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;tthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let i=this.child(t),o=r+i.nodeSize;if(o>=e)return o==e?Ci(t+1,o):Ci(t,r);r=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return n.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return n.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return n.empty;let t,r=0;for(let i=0;ithis.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(o)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;tr.type.rank-i.type.rank),t}};W.none=[];var on=class extends Error{},M=class n{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=dc(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return r&&new n(r,this.openStart,this.openEnd)}removeBetween(e,t){return new n(fc(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return n.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new n(w.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.lastChild)i++;return new n(e,r,i)}};M.empty=new M(w.empty,0,0);function fc(n,e,t){let{index:r,offset:i}=n.findIndex(e),o=n.maybeChild(r),{index:s,offset:l}=n.findIndex(t);if(i==e||o.isText){if(l!=t&&!n.child(s).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=s)throw new RangeError("Removing non-flat range");return n.replaceChild(r,o.copy(fc(o.content,e-i-1,t-i-1)))}function dc(n,e,t,r,i,o){let{index:s,offset:l}=n.findIndex(e),a=n.maybeChild(s);if(l==e||a.isText)return o&&r<=0&&i<=0&&!o.canReplace(s,s,t)?(console.log("bail"),null):n.cut(0,e).append(t).append(n.cut(e));let c=dc(a.content,e-l-1,t,s==0?r-1:0,s==n.childCount-1?i-1:0,a);return c&&n.replaceChild(s,a.copy(c))}function Zp(n,e,t){if(t.openStart>n.depth)throw new on("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new on("Inconsistent open depths");return pc(n,e,t,0)}function pc(n,e,t,r){let i=n.index(r),o=n.node(r);if(i==e.index(r)&&r=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function yr(n,e,t,r){let i=(e||n).node(t),o=0,s=e?e.index(t):i.childCount;n&&(o=n.index(t),n.depth>t?o++:n.textOffset&&(nn(n.nodeAfter,r),o++));for(let l=o;li&&bs(n,e,i+1),s=r.depth>i&&bs(t,r,i+1),l=[];return yr(null,n,i,l),o&&s&&e.index(i)==t.index(i)?(hc(o,s),nn(rn(o,mc(n,e,t,r,i+1)),l)):(o&&nn(rn(o,Oi(n,e,i+1)),l),yr(e,t,i,l),s&&nn(rn(s,Oi(t,r,i+1)),l)),yr(r,null,i,l),new w(l)}function Oi(n,e,t){let r=[];if(yr(null,n,t,r),n.depth>t){let i=bs(n,e,t+1);nn(rn(i,Oi(n,e,t+1)),r)}return yr(e,null,t,r),new w(r)}function eh(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let o=t-1;o>=0;o--)i=e.node(o).copy(w.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}var Ai=class n{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let o=0;o0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new sn(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,o=t;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(o),c=o-a;if(r.push(s,l,i+a),!c||(s=s.child(l),s.isText))break;o=c-1,i+=a+1}return new n(t,r,o)}static resolveCached(e,t){let r=ec.get(e);if(r)for(let o=0;oe&&this.nodesBetween(e,t,o=>(r.isInSet(o.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),gc(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=w.empty,i=0,o=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,o),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=i;at.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=w.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,i,r);return o.type.checkAttrs(o.attrs),o}};qe.prototype.text=void 0;var xs=class n extends qe{constructor(e,t,r,i){if(super(e,t,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):gc(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new n(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new n(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function gc(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}var ln=class n{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new vs(e,t);if(r.next==null)return n.empty;let i=yc(r);r.next&&r.err("Unexpected trailing text");let o=ch(ah(i));return uh(o,r),o}matchType(e){for(let t=0;tc.createAndFill()));for(let c=0;c=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i{let o=i+(r.validEnd?"*":" ")+" ";for(let s=0;s"+e.indexOf(r.next[s].next);return o}).join(` +`)}};ln.empty=new ln(!0);var vs=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}};function yc(n){let e=[];do e.push(rh(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function rh(n){let e=[];do e.push(ih(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function ih(n){let e=lh(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=oh(n,e);else break;return e}function tc(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function oh(n,e){let t=tc(n),r=t;return n.eat(",")&&(n.next!="}"?r=tc(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function sh(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let o in t){let s=t[o];s.isInGroup(e)&&i.push(s)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function lh(n){if(n.eat("(")){let e=yc(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=sh(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function ah(n){let e=[[]];return i(o(n,0),t()),e;function t(){return e.push([])-1}function r(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function i(s,l){s.forEach(a=>a.to=l)}function o(s,l){if(s.type=="choice")return s.exprs.reduce((a,c)=>a.concat(o(c,l)),[]);if(s.type=="seq")for(let a=0;;a++){let c=o(s.exprs[a],l);if(a==s.exprs.length-1)return c;i(c,l=t())}else if(s.type=="star"){let a=t();return r(l,a),i(o(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=t();return i(o(s.expr,l),a),i(o(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(o(s.expr,l));if(s.type=="range"){let a=l;for(let c=0;c{n[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u{c||i.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let o=e[r.join(",")]=new ln(r.indexOf(n.length-1)>-1);for(let s=0;s-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:xc(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new qe(this,this.computeAttrs(e),w.from(t),W.setFrom(r))}createChecked(e=null,t,r){return t=w.from(t),this.checkContent(t),new qe(this,this.computeAttrs(e),t,W.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=w.from(t),t.size){let s=this.contentMatch.fillBefore(t);if(!s)return null;t=s.append(t)}let i=this.contentMatch.matchFragment(t),o=i&&i.fillBefore(w.empty,!0);return o?new qe(this,e,t.append(o),W.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;tr[o]=new n(o,t,s));let i=t.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function fh(n,e,t){let r=t.split("|");return i=>{let o=i===null?"null":typeof i;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${o}`)}}var ws=class{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?fh(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}},kr=class n{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=wc(e,i.attrs),this.excluded=null;let o=kc(this.attrs);this.instance=o?new W(this,o):null}create(e=null){return!e&&this.instance?this.instance:new W(this,xc(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((o,s)=>r[o]=new n(o,i++,t,s)),r}removeFromSet(e){for(var t=0;t-1}},xr=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=gs.from(e.nodes),t.marks=gs.from(e.marks||{}),this.nodes=Ni.compile(this.spec.nodes,this),this.marks=kr.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let o=this.nodes[i],s=o.spec.content||"",l=o.spec.marks;if(o.contentMatch=r[s]||(r[s]=ln.parse(s,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=l=="_"?null:l?rc(this,l.split(" ")):l==""||!o.inlineContent?[]:null}for(let i in this.marks){let o=this.marks[i],s=o.spec.excludes;o.excluded=s==null?[o]:s==""?[]:rc(this,s.split(" "))}this.nodeFromJSON=i=>qe.fromJSON(this,i),this.markFromJSON=i=>W.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Ni){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,i)}text(e,t){let r=this.nodes.text;return new xs(r,r.defaultAttrs,e,W.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}};function rc(n,e){let t=[];for(let r=0;r-1)&&t.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function dh(n){return n.tag!=null}function ph(n){return n.style!=null}var St=class n{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(dh(i))this.tags.push(i);else if(ph(i)){let o=/[^=]*/.exec(i.style)[0];r.indexOf(o)<0&&r.push(o),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let o=e.nodes[i.node];return o.contentMatch.matchType(o)})}parse(e,t={}){let r=new Di(this,t,!1);return r.addAll(e,W.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Di(this,t,!0);return r.addAll(e,W.none,t.from,t.to),M.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;ie.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(s.getAttrs){let a=s.getAttrs(t);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let t=[];function r(i){let o=i.priority==null?50:i.priority,s=0;for(;s{r(s=oc(s)),s.mark||s.ignore||s.clearMark||(s.mark=i)})}for(let i in e.nodes){let o=e.nodes[i].spec.parseDOM;o&&o.forEach(s=>{r(s=oc(s)),s.node||s.ignore||s.mark||(s.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new n(e,n.schemaRules(e)))}},Sc={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},hh={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Cc={ol:!0,ul:!0},vr=1,Ss=2,br=4;function ic(n,e,t){return e!=null?(e?vr:0)|(e==="full"?Ss:0):n&&n.whitespace=="pre"?vr|Ss:t&~br}var Hn=class{constructor(e,t,r,i,o,s){this.type=e,this.attrs=t,this.marks=r,this.solid=i,this.options=s,this.content=[],this.activeMarks=W.none,this.match=o||(s&br?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(w.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&vr)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-i[0].length))}}let t=w.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(w.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Sc.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},Di=class{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=t.topNode,o,s=ic(null,t.preserveWhitespace,0)|(r?br:0);i?o=new Hn(i.type,i.attrs,W.none,!0,t.topMatch||i.type.contentMatch,s):r?o=new Hn(null,null,W.none,!0,null,s):o=new Hn(e.schema.topNodeType,null,W.none,!0,null,s),this.nodes=[o],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,i=this.top,o=i.options&Ss?"full":this.localPreserveWS||(i.options&vr)>0,{schema:s}=this.parser;if(o==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(o)if(o==="full")r=r.replace(/\r\n?/g,` +`);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,i){let o,s;if(t.node)if(s=this.parser.schema.nodes[t.node],s.isLeaf)this.insertNode(s.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(s,t.attrs||null,r,t.preserveWhitespace);a&&(o=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}o&&this.sync(l)&&this.open--}addAll(e,t,r,i){let o=r||0;for(let s=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];s!=l;s=s.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(s,t);this.findAtPoint(e,o)}findPlace(e,t,r){let i,o;for(let s=this.open,l=0;s>=0;s--){let a=this.nodes[s],c=a.findWrapping(e);if(c&&(!i||i.length>c.length+l)&&(i=c,o=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!i)return null;this.sync(o);for(let s=0;s(s.type?s.type.allowsMarkType(c.type):sc(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Hn(e,t,a,i,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=vr)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(i?0:1),s=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=o;a--)if(s(l-1,a))return!0;return!1}else{let u=a>0||a==0&&i?this.nodes[a].type:r&&a>=o?r.node(a-o).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return s(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}};function mh(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Cc.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function gh(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function oc(n){let e={};for(let t in n)e[t]=n[t];return e}function sc(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let o=[],s=l=>{o.push(l);for(let a=0;a{if(o.length||s.marks.length){let l=0,a=0;for(;l=0;i--){let o=this.serializeMark(e.marks[i],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&Ti(Ei(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return typeof t=="string"?{dom:e.createTextNode(t)}:Ti(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new n(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=lc(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return lc(e.marks)}};function lc(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Ei(n){return n.document||window.document}var ac=new WeakMap;function yh(n){let e=ac.get(n);return e===void 0&&ac.set(n,e=bh(n)),e}function bh(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=i.indexOf(" ");s>0&&(t=i.slice(0,s),i=i.slice(s+1));let l,a=t?n.createElementNS(t,i):n.createElement(i),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let f in c)if(c[f]!=null){let d=f.indexOf(" ");d>0?a.setAttributeNS(f.slice(0,d),f.slice(d+1),c[f]):f=="style"&&a.style?a.style.cssText=c[f]:a.setAttribute(f,c[f])}}for(let f=u;fu)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else if(typeof d=="string")a.appendChild(n.createTextNode(d));else{let{dom:p,contentDOM:h}=Ti(n,d,t,r);if(a.appendChild(p),h){if(l)throw new RangeError("Multiple content holes");l=h}}}return{dom:a,contentDOM:l}}var Mc=65535,Oc=Math.pow(2,16);function kh(n,e){return n+e*Oc}function Ec(n){return n&Mc}function xh(n){return(n-(n&Mc))/Oc}var Ac=1,Nc=2,Ri=4,Dc=8,Cr=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Dc)>0}get deletedBefore(){return(this.delInfo&(Ac|Ri))>0}get deletedAfter(){return(this.delInfo&(Nc|Ri))>0}get deletedAcross(){return(this.delInfo&Ri)>0}},Et=class n{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&n.empty)return n.empty}recover(e){let t=0,r=Ec(e);if(!this.inverted)for(let i=0;ie)break;let c=this.ranges[l+o],u=this.ranges[l+s],f=a+c;if(e<=f){let d=c?e==a?-1:e==f?1:t:t,p=a+i+(d<0?0:u);if(r)return p;let h=e==(t<0?a:f)?null:kh(l/3,e-a),m=e==a?Nc:e==f?Ac:Ri;return(t<0?e!=a:e!=f)&&(m|=Dc),new Cr(p,m,h)}i+=u-c}return r?e+i:new Cr(e+i,0,null)}touches(e,t){let r=0,i=Ec(t),o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;le)break;let c=this.ranges[l+o],u=a+c;if(e<=u&&l==i*3)return!0;r+=this.ranges[l+s]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new n;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;ro&&a!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),t.openStart,t.openEnd);return be.fromReplace(e,this.from,this.to,o)}invert(){return new an(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new n(t.pos,r.pos,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new n(t.from,t.to,e.markFromJSON(t.mark))}};he.jsonID("addMark",Tr);var an=class n extends he{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new M(As(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return be.fromReplace(e,this.from,this.to,r)}invert(){return new Tr(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new n(t.pos,r.pos,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new n(t.from,t.to,e.markFromJSON(t.mark))}};he.jsonID("removeMark",an);var Mr=class n extends he{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return be.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return be.fromReplace(e,this.pos,this.pos+1,new M(w.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;ir.pos?null:new n(t.pos,r.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new n(t.from,t.to,t.gapFrom,t.gapTo,M.fromJSON(e,t.slice),t.insert,!!t.structure)}};he.jsonID("replaceAround",ce);function Ms(n,e,t){let r=n.resolve(e),i=t-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let s=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function vh(n,e,t,r){let i=[],o=[],s,l;n.doc.nodesBetween(e,t,(a,c,u)=>{if(!a.isInline)return;let f=a.marks;if(!r.isInSet(f)&&u.type.allowsMarkType(r.type)){let d=Math.max(c,e),p=Math.min(c+a.nodeSize,t),h=r.addToSet(f);for(let m=0;mn.step(a)),o.forEach(a=>n.step(a))}function wh(n,e,t,r){let i=[],o=0;n.doc.nodesBetween(e,t,(s,l)=>{if(!s.isInline)return;o++;let a=null;if(r instanceof kr){let c=s.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,t);for(let u=0;un.step(new an(s.from,s.to,s.style)))}function Ns(n,e,t,r=t.contentMatch,i=!0){let o=n.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a=0;a--)n.step(s[a])}function Sh(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Tt(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,i=0,o=0;;--r){let s=n.$from.node(r),l=n.$from.index(r)+i,a=n.$to.indexAfter(r)-o;if(rt;h--)m||r.index(h)>0?(m=!0,u=w.from(r.node(h).copy(u)),f++):a--;let d=w.empty,p=0;for(let h=o,m=!1;h>t;h--)m||i.after(h+1)=0;s--){if(r.size){let l=t[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=w.from(t[s].type.create(t[s].attrs,r))}let i=e.start,o=e.end;n.step(new ce(i,o,i,o,new M(r,0,0),t.length,!0))}function Oh(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=n.steps.length;n.doc.nodesBetween(e,t,(s,l)=>{let a=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(r,a)&&Ah(n.doc,n.mapping.slice(o).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",h=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!h?c=!1:!p&&h&&(c=!0)}c===!1&&Ic(n,s,l,o),Ns(n,n.mapping.slice(o).map(l,1),r,void 0,c===null);let u=n.mapping.slice(o),f=u.map(l,1),d=u.map(l+s.nodeSize,1);return n.step(new ce(f,d,f+1,d-1,new M(w.from(r.create(a,null,s.marks)),0,0),1,!0)),c===!0&&Rc(n,s,l,o),!1}})}function Rc(n,e,t,r){e.forEach((i,o)=>{if(i.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(i.text);){let a=n.mapping.slice(r).map(t+1+o+s.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Ic(n,e,t,r){e.forEach((i,o)=>{if(i.type==i.type.schema.linebreakReplacement){let s=n.mapping.slice(r).map(t+1+o);n.replaceWith(s,s+1,e.type.schema.text(` +`))}})}function Ah(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function Nh(n,e,t,r,i){let o=n.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");t||(t=o.type);let s=t.create(r,null,i||o.marks);if(o.isLeaf)return n.replaceWith(e,e+o.nodeSize,s);if(!t.validContent(o.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new ce(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new M(w.from(s),0,0),1,!0))}function Ue(n,e,t=1,r){let i=n.resolve(e),o=i.depth-t,s=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,u=t-2;c>o;c--,u--){let f=i.node(c),d=i.index(c);if(f.type.spec.isolating)return!1;let p=f.content.cutByIndex(d,f.childCount),h=r&&r[u+1];h&&(p=p.replaceChild(0,h.type.create(h.attrs)));let m=r&&r[u]||f;if(!f.canReplace(d+1,f.childCount)||!m.type.validContent(p))return!1}let l=i.indexAfter(o),a=r&&r[0];return i.node(o).canReplaceWith(l,l,a?a.type:i.node(o+1).type)}function Dh(n,e,t=1,r){let i=n.doc.resolve(e),o=w.empty,s=w.empty;for(let l=i.depth,a=i.depth-t,c=t-1;l>a;l--,c--){o=w.from(i.node(l).copy(o));let u=r&&r[c];s=w.from(u?u.type.create(u.attrs,s):i.node(l).copy(s))}n.step(new ke(e,e,new M(o.append(s),t,t),!0))}function ot(n,e){let t=n.resolve(e),r=t.index();return Pc(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function Rh(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let i=0;i0?(o=r.node(i+1),l++,s=r.node(i).maybeChild(l)):(o=r.node(i).maybeChild(l-1),s=r.node(i+1)),o&&!o.isTextblock&&Pc(o,s)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=t<0?r.before(i):r.after(i)}}function Ih(n,e,t){let r=null,{linebreakReplacement:i}=n.doc.type.schema,o=n.doc.resolve(e-t),s=o.node().type;if(i&&s.inlineContent){let u=s.whitespace=="pre",f=!!s.contentMatch.matchType(i);u&&!f?r=!1:!u&&f&&(r=!0)}let l=n.steps.length;if(r===!1){let u=n.doc.resolve(e+t);Ic(n,u.node(),u.before(),l)}s.inlineContent&&Ns(n,e+t-1,s,o.node().contentMatchAt(o.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new ke(c,a.map(e+t,-1),M.empty,!0)),r===!0){let u=n.doc.resolve(c);Rc(n,u.node(),u.before(),n.steps.length)}return n}function Ph(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let o=r.index(i);if(r.node(i).canReplaceWith(o,o,t))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,t))return r.after(i+1);if(o=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,a=r.index(s)+(l>0?1:0),c=r.node(s),u=!1;if(o==1)u=c.canReplace(a,a,i);else{let f=c.contentMatchAt(a).findWrapping(i.firstChild.type);u=f&&c.canReplaceWith(a,a,f[0])}if(u)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}function Or(n,e,t=e,r=M.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),o=n.resolve(t);return Lc(i,o,r)?new ke(e,t,r):new Os(i,o,r).fit()}function Lc(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}var Os=class{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=w.empty;for(let i=0;i<=e.depth;i++){let o=e.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=w.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let o=this.placed,s=r.depth,l=i.depth;for(;s&&l&&o.childCount==1;)o=o.firstChild.content,s--,l--;let a=new M(o,s,l);return e>-1?new ce(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new ke(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r1&&(i=0),o.type.spec.isolating&&i<=r){e=r;break}t=o.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=Es(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,f=null;if(t==1&&(s?c.matchType(s.type)||(f=c.fillBefore(w.from(s),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:l,parent:o,inject:f};if(t==2&&s&&(u=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:o,wrap:u};if(o&&c.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Es(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new M(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Es(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new M(wr(e,t-1,1),t-1,o?t-1:r)}else this.unplaced=new M(wr(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let m=0;m1||a==0||m.content.size)&&(f=g,u.push(Bc(m.mark(d.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?p:-1)))}let h=c==l.childCount;h||(p=-1),this.placed=Sr(this.placed,t,w.from(u)),this.frontier[t].match=f,h&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],o=t=0;l--){let{match:a,type:c}=this.frontier[l],u=Ts(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:s,move:o?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Sr(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Sr(this.placed,this.depth,w.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(w.empty,!0);t.childCount&&(this.placed=Sr(this.placed,this.frontier.length,t))}};function wr(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(wr(n.firstChild.content,e-1,t)))}function Sr(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Sr(n.lastChild.content,e-1,t)))}function Es(n,e){for(let t=0;t1&&(r=r.replaceChild(0,Bc(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(w.empty,!0)))),n.copy(r)}function Ts(n,e,t,r,i){let o=n.node(e),s=i?n.indexAfter(e):n.index(e);if(s==o.childCount&&!t.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,s);return l&&!Lh(t,o.content,s)?l:null}function Lh(n,e,t){for(let r=t;r0;d--,p--){let h=i.node(d).type.spec;if(h.defining||h.definingAsContext||h.isolating)break;s.indexOf(d)>-1?l=d:i.before(d)==p&&s.splice(1,0,-d)}let a=s.indexOf(l),c=[],u=r.openStart;for(let d=r.content,p=0;;p++){let h=d.firstChild;if(c.push(h),p==r.openStart)break;d=h.content}for(let d=u-1;d>=0;d--){let p=c[d],h=Bh(p.type);if(h&&!p.sameMarkup(i.node(Math.abs(l)-1)))u=d;else if(h||!p.type.isTextblock)break}for(let d=r.openStart;d>=0;d--){let p=(d+u+1)%(r.openStart+1),h=c[p];if(h)for(let m=0;m=0&&(n.replace(e,t,r),!(n.steps.length>f));d--){let p=s[d];p<0||(e=i.before(p),t=o.after(p))}}function zc(n,e,t,r,i){if(er){let o=i.contentMatchAt(0),s=o.fillBefore(n).append(n);n=s.append(o.matchFragment(s).fillBefore(w.empty,!0))}return n}function $h(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=Ph(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new M(w.from(r),0,0))}function Fh(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let s=r.sharedDepth(t),l=!1;for(let a=r.depth;a>s;a--)r.node(a).type.spec.isolating&&(l=!0);for(let a=i.depth;a>s;a--)i.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=r.depth;a>0&&e==r.start(a);a--)e=r.before(a);for(let a=i.depth;a>0&&t==i.start(a);a--)t=i.before(a);r=n.doc.resolve(e),i=n.doc.resolve(t)}}let o=$c(r,i);for(let s=0;s0&&(a||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return n.delete(r.before(l),i.after(l))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&t>r.end(s)&&i.end(s)-t!=i.depth-s&&r.start(s-1)==i.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),i.index(s-1)))return n.delete(r.before(s),t);n.delete(e,t)}function $c(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let o=n.start(i);if(oe.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&t.push(i)}return t}var Ii=class n extends he{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return be.fail("No node at attribute step's position");let r=Object.create(null);for(let o in t.attrs)r[o]=t.attrs[o];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return be.fromReplace(e,this.pos,this.pos+1,new M(w.from(i),0,t.isLeaf?0:1))}getMap(){return Et.empty}invert(e){return new n(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new n(t.pos,t.attr,t.value)}};he.jsonID("attr",Ii);var Pi=class n extends he{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return be.ok(r)}getMap(){return Et.empty}invert(e){return new n(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new n(t.attr,t.value)}};he.jsonID("docAttr",Pi);var jn=class extends Error{};jn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};jn.prototype=Object.create(Error.prototype);jn.prototype.constructor=jn;jn.prototype.name="TransformError";var Wn=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Er}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new jn(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let r=0;r{e=Math.min(e,l),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=M.empty){let i=Or(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new M(w.from(r),0,0))}delete(e,t){return this.replace(e,t,M.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return zh(this,e,t,r),this}replaceRangeWith(e,t,r){return $h(this,e,t,r),this}deleteRange(e,t){return Fh(this,e,t),this}lift(e,t){return Ch(this,e,t),this}join(e,t=1){return Ih(this,e,t),this}wrap(e,t){return Mh(this,e,t),this}setBlockType(e,t=e,r,i=null){return Oh(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return Nh(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new Ii(e,t,r)),this}setDocAttribute(e,t){return this.step(new Pi(e,t)),this}addNodeMark(e,t){return this.step(new Mr(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof W)t.isInSet(r.marks)&&this.step(new Vn(e,t));else{let i=r.marks,o,s=[];for(;o=t.isInSet(i);)s.push(new Vn(e,o)),i=o.removeFromSet(i);for(let l=s.length-1;l>=0;l--)this.step(s[l])}return this}split(e,t=1,r){return Dh(this,e,t,r),this}addMark(e,t,r){return vh(this,e,t,r),this}removeMark(e,t,r){return wh(this,e,t,r),this}clearIncompatible(e,t,r){return Ns(this,e,t,r),this}};var Ds=Object.create(null),L=class{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new zi(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t=0;o--){let s=t<0?Un(e.node(0),e.node(o),e.before(o+1),e.index(o),t,r):Un(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,r);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Re(e.node(0))}static atStart(e){return Un(e,e,0,0,1)||new Re(e)}static atEnd(e){return Un(e,e,e.content.size,e.childCount,-1)||new Re(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Ds[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Ds)throw new RangeError("Duplicate use of selection JSON ID "+e);return Ds[e]=t,t.prototype.jsonID=e,t}getBookmark(){return P.between(this.$anchor,this.$head).getBookmark()}};L.prototype.visible=!0;var zi=class{constructor(e,t){this.$from=e,this.$to=t}},Fc=!1;function Hc(n){!Fc&&!n.parent.inlineContent&&(Fc=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}var P=class n extends L{constructor(e,t=e){Hc(e),Hc(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return L.near(r);let i=e.resolve(t.map(this.anchor));return new n(i.parent.inlineContent?i:r,r)}replace(e,t=M.empty){if(super.replace(e,t),t==M.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof n&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new $i(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new n(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let o=L.findFrom(t,r,!0)||L.findFrom(t,-r,!0);if(o)t=o.$head;else return L.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(L.findFrom(e,-r,!0)||L.findFrom(e,r,!0)).$anchor,e.pos0?0:1);i>0?s=0;s+=i){let l=e.child(s);if(l.isAtom){if(!o&&D.isSelectable(l))return D.create(n,t-(i<0?l.nodeSize:0))}else{let a=Un(n,l,t+i,i<0?l.childCount:0,i,o);if(a)return a}t+=l.nodeSize*i}return null}function Vc(n,e,t){let r=n.steps.length-1;if(r{s==null&&(s=u)}),n.setSelection(L.near(n.doc.resolve(s),t))}var jc=1,Bi=2,Wc=4,Ps=class extends Wn{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Bi,this}ensureMarks(e){return W.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Bi)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Bi,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||W.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),!e)return this.deleteRange(t,r);let o=this.storedMarks;if(!o){let s=this.doc.resolve(t);o=r==t?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,i.text(e,o)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(L.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Wc,this}get scrolledIntoView(){return(this.updated&Wc)>0}};function _c(n,e){return!e||!n?n:n.bind(e)}var cn=class{constructor(e,t,r){this.name=e,this.init=_c(t.init,r),this.apply=_c(t.apply,r)}},Vh=[new cn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new cn("selection",{init(n,e){return n.selection||L.atStart(e.doc)},apply(n){return n.selection}}),new cn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new cn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})],Ar=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Vh.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new cn(r.key,r.spec.state,r))})}},Fi=class n{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],o=i.spec.state;o&&o.toJSON&&(t[r]=o.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new Ar(e.schema,e.plugins),o=new n(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=qe.fromJSON(e.schema,t.doc);else if(s.name=="selection")o.selection=L.fromJSON(o.doc,t.selection);else if(s.name=="storedMarks")t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){o[s.name]=c.fromJSON.call(a,e,t[l],o);return}}o[s.name]=s.init(e,o)}}),o}};function qc(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=qc(i,e,{})),t[r]=i}return t}var q=class{constructor(e){this.spec=e,this.props={},e.props&&qc(e.props,this,this.props),this.key=e.key?e.key.key:Uc("plugin")}getState(e){return e[this.key]}},Rs=Object.create(null);function Uc(n){return n in Rs?n+"$"+ ++Rs[n]:(Rs[n]=0,n+"$")}var re=class{constructor(e="key"){this.key=Uc(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var xe=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Xn=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e},Hs=null,Ot=function(n,e,t){let r=Hs||(Hs=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},jh=function(){Hs=null},gn=function(n,e,t,r){return t&&(Kc(n,e,t,r,-1)||Kc(n,e,t,r,1))},Wh=/^(img|br|input|textarea|hr)$/i;function Kc(n,e,t,r,i){for(var o;;){if(n==t&&e==r)return!0;if(e==(i<0?0:Je(n))){let s=n.parentNode;if(!s||s.nodeType!=1||zr(n)||Wh.test(n.nodeName)||n.contentEditable=="false")return!1;e=xe(n)+(i<0?0:1),n=s}else if(n.nodeType==1){let s=n.childNodes[e+(i<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((o=s.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)e+=i;else return!1;else n=s,e=i<0?Je(n):0}else return!1}}function Je(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function _h(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=Je(n)}else if(n.parentNode&&!zr(n))e=xe(n),n=n.parentNode;else return null}}function qh(n,e){for(;;){if(n.nodeType==3&&e2),Ke=Qn||(dt?/Mac/.test(dt.platform):!1),Ou=dt?/Win/.test(dt.platform):!1,At=/Android \d/.test(Ut),$r=!!Jc&&"webkitFontSmoothing"in Jc.documentElement.style,Gh=$r?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Yh(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function Mt(n,e){return typeof n=="number"?n:n[e]}function Xh(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Gc(n,e,t){let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,o=n.dom.ownerDocument;for(let s=t||n.dom;s;){if(s.nodeType!=1){s=Xn(s);continue}let l=s,a=l==o.body,c=a?Yh(o):Xh(l),u=0,f=0;if(e.topc.bottom-Mt(r,"bottom")&&(f=e.bottom-e.top>c.bottom-c.top?e.top+Mt(i,"top")-c.top:e.bottom-c.bottom+Mt(i,"bottom")),e.leftc.right-Mt(r,"right")&&(u=e.right-c.right+Mt(i,"right")),u||f)if(a)o.defaultView.scrollBy(u,f);else{let p=l.scrollLeft,h=l.scrollTop;f&&(l.scrollTop+=f),u&&(l.scrollLeft+=u);let m=l.scrollLeft-p,g=l.scrollTop-h;e={left:e.left-m,top:e.top-g,right:e.right-m,bottom:e.bottom-g}}let d=a?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(d))break;s=d=="absolute"?s.offsetParent:Xn(s)}}function Qh(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,i;for(let o=(e.left+e.right)/2,s=t+1;s=t-20){r=l,i=a.top;break}}return{refDOM:r,refTop:i,stack:Au(n.dom)}}function Au(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Xn(r));return e}function Zh({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Nu(t,r==0?0:r-e)}function Nu(n,e){for(let t=0;t=l){s=Math.max(h.bottom,s),l=Math.min(h.top,l);let m=h.left>e.left?h.left-e.left:h.right=(h.left+h.right)/2?1:0));continue}}else h.top>e.top&&!a&&h.left<=e.left&&h.right>=e.left&&(a=u,c={left:Math.max(h.left,Math.min(h.right,e.left)),top:h.top});!t&&(e.left>=h.right&&e.top>=h.top||e.left>=h.left&&e.top>=h.bottom)&&(o=f+1)}}return!t&&a&&(t=a,i=c,r=0),t&&t.nodeType==3?tm(t,i):!t||r&&t.nodeType==1?{node:n,offset:o}:Du(t,i)}function tm(n,e){let t=n.nodeValue.length,r=document.createRange(),i;for(let o=0;o=(s.left+s.right)/2?1:0)};break}}return r.detach(),i||{node:n,offset:0}}function il(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function nm(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left(s.left+s.right)/2?1:-1}return n.docView.posFromDOM(r,i,o)}function im(n,e,t,r){let i=-1;for(let o=e,s=!1;o!=n.dom;){let l=n.docView.nearestDesc(o,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!s&&a.left>r.left||a.top>r.top?i=l.posBefore:(!s&&a.right-1?i:n.docView.posFromDOM(e,t,-1)}function Ru(n,e,t){let r=n.childNodes.length;if(r&&t.tope.top&&i++}let c;$r&&i&&r.nodeType==1&&(c=r.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==n.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(l=im(n,r,i,e))}l==null&&(l=rm(n,s,e));let a=n.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Yc(n){return n.top=0&&i==r.nodeValue.length?(a--,u=1):t<0?a--:c++,Nr(Vt(Ot(r,a,c),u),u<0)}if(!n.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(t<0||i==Je(r))){let a=r.childNodes[i-1];if(a.nodeType==1)return Ls(a.getBoundingClientRect(),!1)}if(o==null&&i=0)}if(o==null&&i&&(t<0||i==Je(r))){let a=r.childNodes[i-1],c=a.nodeType==3?Ot(a,Je(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Nr(Vt(c,1),!1)}if(o==null&&i=0)}function Nr(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function Ls(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function Pu(n,e,t){let r=n.state,i=n.root.activeElement;r!=e&&n.updateState(e),i!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),i!=n.dom&&i&&i.focus()}}function lm(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return Pu(n,e,()=>{let{node:o}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(o,!0);if(!l)break;if(l.node.isBlock){o=l.contentDOM||l.dom;break}o=l.dom.parentNode}let s=Iu(n,i.pos,1);for(let l=o.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Ot(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;cu.top+1&&(t=="up"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}var am=/[\u0590-\u08ac]/;function cm(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=!i,s=i==r.parent.content.size,l=n.domSelection();return l?!am.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?o:s:Pu(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:f}=n.domSelectionRange(),d=l.caretBidiLevel;l.modify("move",t,"character");let p=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:h,focusOffset:m}=n.domSelectionRange(),g=h&&!p.contains(h.nodeType==1?h:h.parentNode)||a==h&&c==m;try{l.collapse(u,f),a&&(a!=u||c!=f)&&l.extend&&l.extend(a,c)}catch{}return d!=null&&(l.caretBidiLevel=d),g}):r.pos==r.start()||r.pos==r.end()}var Xc=null,Qc=null,Zc=!1;function um(n,e,t){return Xc==e&&Qc==t?Zc:(Xc=e,Qc=t,Zc=t=="up"||t=="down"?lm(n,e,t):cm(n,e,t))}var Ye=0,eu=1,fn=2,pt=3,yn=class{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=Ye,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;txe(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),s;if(o&&(!t||o.node))if(r&&(s=o.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return o}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let i=e;i;i=i.parentNode){let o=this.getDesc(i);if(o)return o.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;te||s instanceof ji){i=e-o;break}o=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof Hi&&o.side>=0;r--);if(t<=0){let o,s=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,s=!1);return o&&t&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?xe(o.dom)+1:0}}else{let o,s=!0;for(;o=r=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=s;for(let f=l;f>0;f--){let d=this.children[f-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){i=xe(d.dom)+1;break}e-=d.size}i==-1&&(i=0)}if(i>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;uh&&st){let h=l;l=a,a=h}let p=document.createRange();p.setEnd(a.node,a.offset),p.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,i=0;i=r:er){let l=r+o.border,a=s-o.border;if(e>=l&&t<=a){this.dirty=e==r||t==s?fn:eu,e==l&&t==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=pt:o.markDirty(e-l,t-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?fn:pt}r=s}this.dirty=fn}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?fn:eu;t.dirty{if(!o)return i;if(o.parent)return o.parent.posBeforeChild(o)})),!t.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return this.dirty==Ye&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},_s=class extends yn{constructor(e,t,r,i){super(e,[],t,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},Zn=class n extends yn{constructor(e,t,r,i,o){super(e,[],r,i),this.mark=t,this.spec=o}static create(e,t,r,i){let o=i.nodeViews[t.type.name],s=o&&o(t,i,r);return(!s||!s.dom)&&(s=Ct.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new n(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&pt||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=pt&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Ye){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(o=Js(o,0,e,r));for(let l=0;l{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,i),u=c&&c.dom,f=c&&c.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:f}=Ct.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!f&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let d=u;return u=zu(u,r,t),c?a=new qs(e,t,r,i,u,f||null,d,c,o,s+1):t.isText?new Vi(e,t,r,i,u,d,o):new n(e,t,r,i,u,f||null,d,o,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>w.empty)}return e}matchesNode(e,t,r){return this.dirty==Ye&&e.eq(this.node)&&Wi(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,i=t,o=e.composing?this.localCompositionInfo(e,t):null,s=o&&o.pos>-1?o:null,l=o&&o.pos<0,a=new Ks(this,s&&s.node,e);hm(this.node,this.innerDeco,(c,u,f)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e,u):c.type.side>=0&&!f&&a.syncToMarks(u==this.node.childCount?W.none:this.node.child(u).marks,r,e,u),a.placeWidget(c,e,i)},(c,u,f,d)=>{a.syncToMarks(c.marks,r,e,d);let p;a.findNodeMatch(c,u,f,d)||l&&e.state.selection.from>i&&e.state.selection.to-1&&a.updateNodeAt(c,u,f,p,e)||a.updateNextNode(c,u,f,e,d,i)||a.addNode(c,u,f,e,i),i+=c.nodeSize}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==fn)&&(s&&this.protectLocalComposition(e,s),Lu(this.contentDOM,this.children,e),Qn&&mm(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof P)||rt+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let s=o.nodeValue,l=gm(this.node.content,s,r-t,i-t);return l<0?null:{node:o,pos:l,text:s}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:i}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let s=new _s(this,o,t,i);e.input.compositionNodes.push(s),this.children=Js(this.children,r,r+i.length,e,s)}update(e,t,r,i){return this.dirty==pt||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,i),!0)}updateInner(e,t,r,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Ye}updateOuterDeco(e){if(Wi(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Bu(this.dom,this.nodeDOM,Us(this.outerDeco,this.node,t),Us(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function tu(n,e,t,r,i){zu(r,e,n);let o=new qt(void 0,n,e,t,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}var Vi=class n extends qt{constructor(e,t,r,i,o,s,l){super(e,t,r,i,o,null,s,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,i){return this.dirty==pt||this.dirty!=Ye&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Ye||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Ye,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let i=this.node.cut(e,t),o=document.createTextNode(i.text);return new n(this.parent,i,this.outerDeco,this.innerDeco,o,o,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=pt)}get domAtom(){return!1}isText(e){return this.node.text==e}},ji=class extends yn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ye&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},qs=class extends qt{constructor(e,t,r,i,o,s,l,a,c,u){super(e,t,r,i,o,s,l,c,u),this.spec=a}update(e,t,r,i){if(this.dirty==pt)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,t,r);return o&&this.updateInner(e,t,r,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,i){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function Lu(n,e,t){let r=n.firstChild,i=!1;for(let o=0;o>1,l=Math.min(s,e.length);for(;o-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let u=Zn.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,r,i){let o=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,r))o=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof Zn)t=c,r=c.children.length;else{l=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(i-1))break;--i,o.set(l,i),s.push(l)}}return{index:i,matched:o,matches:s.reverse()}}function pm(n,e){return n.type.side-e.type.side}function hm(n,e,t,r){let i=e.locals(n),o=0;if(i.length==0){for(let c=0;co;)l.push(i[s++]);let h=o+d.nodeSize;if(d.isText){let g=h;s!g.inline):l.slice();r(d,m,e.forChild(o,d),p),o=h}}function mm(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function gm(n,e,t,r){for(let i=0,o=0;i=t){if(o>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Js(n,e,t,r,i){let o=[];for(let s=0,l=0;s=t||u<=e?o.push(a):(ct&&o.push(a.slice(t-c,a.size,r)))}return o}function ol(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),o=i&&i.size==0,s=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,c;if(Yi(t)){for(a=s;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&D.isSelectable(f)&&i.parent&&!(f.isInline&&Uh(t.focusNode,t.focusOffset,i.dom))){let d=i.posBefore;c=new D(s==d?l:r.resolve(d))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=s,d=s;for(let p=0;p{(t.anchorNode!=r||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!$u(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function bm(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,r=t.nodeName=="IMG";r?e.collapse(t.parentNode,xe(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&Fe&&_t<=11&&(t.disabled=!0,t.disabled=!1)}function Fu(n,e){if(e instanceof D){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(su(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else su(n)}function su(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function sl(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||P.between(e,t,r)}function lu(n){return n.editable&&!n.hasFocus()?!1:Hu(n)}function Hu(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function km(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return gn(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Gs(n,e){let{$anchor:t,$head:r}=n.selection,i=e>0?t.max(r):t.min(r),o=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return o&&L.findFrom(o,e)}function jt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function au(n,e,t){let r=n.state.selection;if(r instanceof P)if(t.indexOf("s")>-1){let{$head:i}=r,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let s=n.state.doc.resolve(i.pos+o.nodeSize*(e<0?-1:1));return jt(n,new P(r.$anchor,s))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=Gs(n.state,e);return i&&i instanceof D?jt(n,i):!1}else if(!(Ke&&t.indexOf("m")>-1)){let i=r.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!o||o.isText)return!1;let l=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(s=n.docView.descAt(l))&&!s.contentDOM?D.isSelectable(o)?jt(n,new D(e<0?n.state.doc.resolve(i.pos-o.nodeSize):i)):$r?jt(n,new P(n.state.doc.resolve(e<0?l:l+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof D&&r.node.isInline)return jt(n,new P(e>0?r.$to:r.$from));{let i=Gs(n.state,e);return i?jt(n,i):!1}}}function _i(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Rr(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Jn(n,e){return e<0?xm(n):vm(n)}function xm(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,o,s=!1;for(Ge&&t.nodeType==1&&r<_i(t)&&Rr(t.childNodes[r],-1)&&(s=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Rr(l,-1))i=t,o=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(Vu(t))break;{let l=t.previousSibling;for(;l&&Rr(l,-1);)i=t.parentNode,o=xe(l),l=l.previousSibling;if(l)t=l,r=_i(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}s?Ys(n,t,r):i&&Ys(n,i,o)}function vm(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=_i(t),o,s;for(;;)if(r{n.state==i&&Nt(n)},50)}function cu(n,e){let t=n.state.doc.resolve(e);if(!(ve||Ou)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let o=n.coordsAtPos(e-1),s=(o.top+o.bottom)/2;if(s>i.top&&s1)return o.lefti.top&&s1)return o.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function uu(n,e,t){let r=n.state.selection;if(r instanceof P&&!r.empty||t.indexOf("s")>-1||Ke&&t.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let s=Gs(n.state,e);if(s&&s instanceof D)return jt(n,s)}if(!i.parent.inlineContent){let s=e<0?i:o,l=r instanceof Re?L.near(s,e):L.findFrom(s,e);return l?jt(n,l):!1}return!1}function fu(n,e){if(!(n.state.selection instanceof P))return!0;let{$head:t,$anchor:r,empty:i}=n.state.selection;if(!t.sameParent(r))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(o&&!o.isText){let s=n.state.tr;return e<0?s.delete(t.pos-o.nodeSize,t.pos):s.delete(t.pos,t.pos+o.nodeSize),n.dispatch(s),!0}return!1}function du(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Cm(n){if(!Me||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;du(n,r,"true"),setTimeout(()=>du(n,r,"false"),20)}return!1}function Em(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Tm(n,e){let t=e.keyCode,r=Em(e);if(t==8||Ke&&t==72&&r=="c")return fu(n,-1)||Jn(n,-1);if(t==46&&!e.shiftKey||Ke&&t==68&&r=="c")return fu(n,1)||Jn(n,1);if(t==13||t==27)return!0;if(t==37||Ke&&t==66&&r=="c"){let i=t==37?cu(n,n.state.selection.from)=="ltr"?-1:1:-1;return au(n,i,r)||Jn(n,i)}else if(t==39||Ke&&t==70&&r=="c"){let i=t==39?cu(n,n.state.selection.from)=="ltr"?1:-1:1;return au(n,i,r)||Jn(n,i)}else{if(t==38||Ke&&t==80&&r=="c")return uu(n,-1,r)||Jn(n,-1);if(t==40||Ke&&t==78&&r=="c")return Cm(n)||uu(n,1,r)||Jn(n,1);if(r==(Ke?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function ll(n,e){n.someProp("transformCopied",p=>{e=p(e,n)});let t=[],{content:r,openStart:i,openEnd:o}=e;for(;i>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,o--;let p=r.firstChild;t.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let s=n.someProp("clipboardSerializer")||Ct.fromSchema(n.state.schema),l=Ku(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,u,f=0;for(;c&&c.nodeType==1&&(u=Uu[c.nodeName.toLowerCase()]);){for(let p=u.length-1;p>=0;p--){let h=l.createElement(u[p]);for(;a.firstChild;)h.appendChild(a.firstChild);a.appendChild(h),f++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${o}${f?` -${f}`:""} ${JSON.stringify(t)}`);let d=n.someProp("clipboardTextSerializer",p=>p(e,n))||e.content.textBetween(0,e.content.size,` + +`);return{dom:a,text:d,slice:e}}function ju(n,e,t,r,i){let o=i.parent.type.spec.code,s,l;if(!t&&!e)return null;let a=!!e&&(r||o||!t);if(a){if(n.someProp("transformPastedText",d=>{e=d(e,o||r,n)}),o)return l=new M(w.from(n.state.schema.text(e.replace(/\r\n?/g,` +`))),0,0),n.someProp("transformPasted",d=>{l=d(l,n,!0)}),l;let f=n.someProp("clipboardTextParser",d=>d(e,i,r,n));if(f)l=f;else{let d=i.marks(),{schema:p}=n.state,h=Ct.fromSchema(p);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=s.appendChild(document.createElement("p"));m&&g.appendChild(h.serializeNode(p.text(m,d)))})}}else n.someProp("transformPastedHTML",f=>{t=f(t,n)}),s=Nm(t),$r&&Dm(s);let c=s&&s.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let f=+u[3];f>0;f--){let d=s.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;s=d}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||St.fromSchema(n.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||u),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!Mm.test(d.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Rm(pu(l,+u[1],+u[2]),u[4]);else if(l=M.maxOpen(Om(l.content,i),!0),l.openStart||l.openEnd){let f=0,d=0;for(let p=l.content.firstChild;f{l=f(l,n,a)}),l}var Mm=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Om(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),o,s=[];if(n.forEach(l=>{if(!s)return;let a=i.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&o.length&&_u(a,o,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=qu(s[s.length-1],o.length));let u=Wu(l,a);s.push(u),i=i.matchType(u.type),o=a}}),s)return w.from(s)}return n}function Wu(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,w.from(n));return n}function _u(n,e,t,r,i){if(i1&&(o=0),i=t&&(l=e<0?s.contentMatchAt(0).fillBefore(l,o<=i).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(w.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,s.copy(l))}function pu(n,e,t){return et})),zs.createHTML(n)):n}function Nm(n){let e=/^(\s*]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Ku().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&Uu[r[1].toLowerCase()])&&(n=i.map(o=>"<"+o+">").join("")+n+i.map(o=>"").reverse().join("")),t.innerHTML=Am(n),i)for(let o=0;o=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;i=w.from(a.create(r[l+1],i)),o++,s++}return new M(i,o,s)}var Ie={},Pe={},Im={touchstart:!0,touchmove:!0},Qs=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function Pm(n){for(let e in Ie){let t=Ie[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{Bm(n,r)&&!al(n,r)&&(n.editable||!(r.type in Pe))&&t(n,r)},Im[e]?{passive:!0}:void 0)}Me&&n.dom.addEventListener("input",()=>null),Zs(n)}function Wt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Lm(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function Zs(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>al(n,r))})}function al(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function Bm(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function zm(n,e){!al(n,e)&&Ie[e.type]&&(n.editable||!(e.type in Pe))&&Ie[e.type](n,e)}Pe.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Gu(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(At&&ve&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Qn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",i=>i(n,un(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||Tm(n,t)?t.preventDefault():Wt(n,"key")};Pe.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Pe.keypress=(n,e)=>{let t=e;if(Gu(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Ke&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof P)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode),o=()=>n.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,i,o))&&n.dispatch(o()),t.preventDefault()}};function Xi(n){return{left:n.clientX,top:n.clientY}}function $m(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function cl(n,e,t,r,i){if(r==-1)return!1;let o=n.state.doc.resolve(r);for(let s=o.depth+1;s>0;s--)if(n.someProp(e,l=>s>o.depth?l(n,t,o.nodeAfter,o.before(s),i,!0):l(n,t,o.node(s),o.before(s),i,!1)))return!0;return!1}function Yn(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);t=="pointer"&&r.setMeta("pointer",!0),n.dispatch(r)}function Fm(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&D.isSelectable(r)?(Yn(n,new D(t),"pointer"),!0):!1}function Hm(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof D&&(r=t.node);let o=n.state.doc.resolve(e);for(let s=o.depth+1;s>0;s--){let l=s>o.depth?o.nodeAfter:o.node(s);if(D.isSelectable(l)){r&&t.$from.depth>0&&s>=t.$from.depth&&o.before(t.$from.depth+1)==t.$from.pos?i=o.before(t.$from.depth):i=o.before(s);break}}return i!=null?(Yn(n,D.create(n.state.doc,i),"pointer"),!0):!1}function Vm(n,e,t,r,i){return cl(n,"handleClickOn",e,t,r)||n.someProp("handleClick",o=>o(n,e,r))||(i?Hm(n,t):Fm(n,t))}function jm(n,e,t,r){return cl(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function Wm(n,e,t,r){return cl(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||_m(n,t,r)}function _m(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(Yn(n,P.create(r,0,r.content.size),"pointer"),!0):!1;let i=r.resolve(e);for(let o=i.depth+1;o>0;o--){let s=o>i.depth?i.nodeAfter:i.node(o),l=i.before(o);if(s.inlineContent)Yn(n,P.create(r,l+1,l+1+s.content.size),"pointer");else if(D.isSelectable(s))Yn(n,D.create(r,l),"pointer");else continue;return!0}}function ul(n){return qi(n)}var Ju=Ke?"metaKey":"ctrlKey";Ie.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=ul(n),i=Date.now(),o="singleClick";i-n.input.lastClick.time<500&&$m(t,n.input.lastClick)&&!t[Ju]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?o="doubleClick":n.input.lastClick.type=="doubleClick"&&(o="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:o,button:t.button};let s=n.posAtCoords(Xi(t));s&&(o=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new el(n,s,t,!!r)):(o=="doubleClick"?jm:Wm)(n,s.pos,s.inside,t)?t.preventDefault():Wt(n,"pointer"))};var el=class{constructor(e,t,r,i){this.view=e,this.pos=t,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Ju],this.allowDefault=r.shiftKey;let o,s;if(t.inside>-1)o=e.state.doc.nodeAt(t.inside),s=t.inside;else{let u=e.state.doc.resolve(t.pos);o=u.parent,s=u.depth?u.before():0}let l=i?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;r.button==0&&(o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof D&&c.from<=s&&c.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ge&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Wt(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Nt(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Xi(e))),this.updateAllowDefault(e),this.allowDefault||!t?Wt(this.view,"pointer"):Vm(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Me&&this.mightDrag&&!this.mightDrag.node.isAtom||ve&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Yn(this.view,L.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):Wt(this.view,"pointer")}move(e){this.updateAllowDefault(e),Wt(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}};Ie.touchstart=n=>{n.input.lastTouch=Date.now(),ul(n),Wt(n,"pointer")};Ie.touchmove=n=>{n.input.lastTouch=Date.now(),Wt(n,"pointer")};Ie.contextmenu=n=>ul(n);function Gu(n,e){return n.composing?!0:Me&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}var qm=At?5e3:-1;Pe.compositionstart=Pe.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof P&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||ve&&Ou&&Um(n)))n.markCursor=n.state.storedMarks||t.marks(),qi(n,!0),n.markCursor=null;else if(qi(n,!e.selection.empty),Ge&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,o=r.focusOffset;i&&i.nodeType==1&&o!=0;){let s=o<0?i.lastChild:i.childNodes[o-1];if(!s)break;if(s.nodeType==3){let l=n.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else i=s,o=-1}}n.input.composing=!0}Yu(n,qm)};function Um(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let r=e.childNodes[t];return r.nodeType==1&&r.contentEditable=="false"}Pe.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Yu(n,20))};function Yu(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>qi(n),e))}function Xu(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Jm());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Km(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=_h(e.focusNode,e.focusOffset),r=qh(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let i=r.pmViewDesc,o=n.domObserver.lastChangedTextNode;if(t==o||r==o)return o;if(!i||!i.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return r}}return t||r}function Jm(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function qi(n,e=!1){if(!(At&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Xu(n),e||n.docView&&n.docView.dirty){let t=ol(n),r=n.state.selection;return t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function Gm(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}var Ir=Fe&&_t<15||Qn&&Gh<604;Ie.copy=Pe.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let o=Ir?null:t.clipboardData,s=r.content(),{dom:l,text:a}=ll(n,s);o?(t.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):Gm(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Ym(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Xm(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?Pr(n,r.value,null,i,e):Pr(n,r.textContent,r.innerHTML,i,e)},50)}function Pr(n,e,t,r,i){let o=ju(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,i,o||M.empty)))return!0;if(!o)return!1;let s=Ym(o),l=s?n.state.tr.replaceSelectionWith(s,r):n.state.tr.replaceSelection(o);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Qu(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Pe.paste=(n,e)=>{let t=e;if(n.composing&&!At)return;let r=Ir?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Pr(n,Qu(r),r.getData("text/html"),i,t)?t.preventDefault():Xm(n,t)};var Ui=class{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}},Qm=Ke?"altKey":"ctrlKey";function Zu(n,e){let t;return n.someProp("dragCopies",r=>{t=t||r(e)}),t!=null?!t:!e[Qm]}Ie.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,o=i.empty?null:n.posAtCoords(Xi(t)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof D?i.to-1:i.to))){if(r&&r.mightDrag)s=D.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let f=n.docView.nearestDesc(t.target,!0);f&&f.node.type.spec.draggable&&f!=n.docView&&(s=D.create(n.state.doc,f.posBefore))}}let l=(s||n.state.selection).content(),{dom:a,text:c,slice:u}=ll(n,l);(!t.dataTransfer.files.length||!ve||Mu>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Ir?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Ir||t.dataTransfer.setData("text/plain",c),n.dragging=new Ui(u,Zu(n,t),s)};Ie.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Pe.dragover=Pe.dragenter=(n,e)=>e.preventDefault();Pe.drop=(n,e)=>{try{Zm(n,e,n.dragging)}finally{n.dragging=null}};function Zm(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(Xi(e));if(!r)return;let i=n.state.doc.resolve(r.pos),o=t&&t.slice;o?n.someProp("transformPasted",p=>{o=p(o,n,!1)}):o=ju(n,Qu(e.dataTransfer),Ir?null:e.dataTransfer.getData("text/html"),!1,i);let s=!!(t&&Zu(n,e));if(n.someProp("handleDrop",p=>p(n,e,o||M.empty,s))){e.preventDefault();return}if(!o)return;e.preventDefault();let l=o?Li(n.state.doc,i.pos,o):i.pos;l==null&&(l=i.pos);let a=n.state.tr;if(s){let{node:p}=t;p?p.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=a.doc;if(u?a.replaceRangeWith(c,c,o.content.firstChild):a.replaceRange(c,c,o),a.doc.eq(f))return;let d=a.doc.resolve(c);if(u&&D.isSelectable(o.content.firstChild)&&d.nodeAfter&&d.nodeAfter.sameMarkup(o.content.firstChild))a.setSelection(new D(d));else{let p=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((h,m,g,b)=>p=b),a.setSelection(sl(n,d,a.doc.resolve(p)))}n.focus(),n.dispatch(a.setMeta("uiEvent","drop"))}Ie.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Nt(n)},20))};Ie.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};Ie.beforeinput=(n,e)=>{if(ve&&At&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",o=>o(n,un(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in Pe)Ie[n]=Pe[n];function Lr(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}var Ki=class n{constructor(e,t){this.toDOM=e,this.spec=t||hn,this.side=this.spec.side||0}map(e,t,r,i){let{pos:o,deleted:s}=e.mapResult(t.from+i,this.side<0?-1:1);return s?null:new Xe(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof n&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Lr(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},pn=class n{constructor(e,t){this.attrs=e,this.spec=t||hn}map(e,t,r,i){let o=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,s=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return o>=s?null:new Xe(o,s,this)}valid(e,t){return t.from=e&&(!o||o(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let s=0;se){let l=this.children[s]+1;this.children[s+2].findInner(e-l,t-l,r,i+l,o)}}map(e,t,r){return this==Ee||e.maps.length==0?this:this.mapInner(e,t,0,0,r||hn)}mapInner(e,t,r,i,o){let s;for(let l=0;l{let c=a+r,u;if(u=tf(t,l,c)){for(i||(i=this.children.slice());ol&&f.to=e){this.children[l]==e&&(r=this.children[l+2]);break}let o=e+1,s=o+t.content.size;for(let l=0;lo&&a.type instanceof pn){let c=Math.max(o,a.from)-o,u=Math.min(s,a.to)-o;ci.map(e,t,hn));return n.from(r)}forChild(e,t){if(t.isLeaf)return Te.empty;let r=[];for(let i=0;it instanceof Te)?e:e.reduce((t,r)=>t.concat(r instanceof Te?r:r.members),[]))}}forEachSet(e){for(let t=0;t{let g=m-h-(p-d);for(let b=0;bC+u-f)continue;let v=l[b]+u-f;p>=v?l[b+1]=d<=v?-2:-1:d>=u&&g&&(l[b]+=g,l[b+1]+=g)}f+=g}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c=r.content.size){a=!0;continue}let d=t.map(n[c+1]+o,-1),p=d-i,{index:h,offset:m}=r.content.findIndex(f),g=r.maybeChild(h);if(g&&m==f&&m+g.nodeSize==p){let b=l[c+2].mapInner(t,g,u+1,n[c]+o+1,s);b!=Ee?(l[c]=f,l[c+1]=p,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=tg(l,n,e,t,i,o,s),u=Gi(c,r,0,s);e=u.local;for(let f=0;ft&&s.to{let c=tf(n,l,a+t);if(c){o=!0;let u=Gi(c,l,t+a+1,r);u!=Ee&&i.push(a,a+l.nodeSize,u)}});let s=ef(o?nf(n):n,-t).sort(mn);for(let l=0;l0;)e++;n.splice(e,0,t)}function $s(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=Ee&&e.push(r)}),n.cursorWrapper&&e.push(Te.create(n.state.doc,[n.cursorWrapper.deco])),Ji.from(e)}var ng={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},rg=Fe&&_t<=11,nl=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},rl=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new nl,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;ii.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():Me&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),rg&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,ng)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;tthis.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(lu(this.view)){if(this.suppressingSelectionUpdates)return Nt(this.view);if(Fe&&_t<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&gn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let o=e.focusNode;o;o=Xn(o))t.add(o);for(let o=e.anchorNode;o;o=Xn(o))if(t.has(o)){r=o;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&lu(e)&&!this.ignoreSelectionChange(r),o=-1,s=-1,l=!1,a=[];if(e.editable)for(let u=0;uu.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let u of a)if(u.nodeName=="BR"&&u.parentNode){let f=u.nextSibling;for(;f&&f.nodeType==1;){if(f.contentEditable=="false"){u.parentNode.removeChild(u);break}f=f.firstChild}}}else if(Ge&&a.length){let u=a.filter(f=>f.nodeName=="BR");if(u.length==2){let[f,d]=u;f.parentNode&&f.parentNode.parentNode==d.parentNode?d.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let d of u){let p=d.parentNode;p&&p.nodeName=="LI"&&(!f||sg(e,f)!=p)&&d.remove()}}}let c=null;o<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||i)&&(o>-1&&(e.docView.markDirty(o,s),ig(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,lg(e,a)),this.handleDOMChange(o,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Nt(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;ui;g--){let b=r.childNodes[g-1],C=b.pmViewDesc;if(b.nodeName=="BR"&&!C){o=g;break}if(!C||C.size)break}let f=n.state.doc,d=n.someProp("domParser")||St.fromSchema(n.state.schema),p=f.resolve(s),h=null,m=d.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:o,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:cg,context:p});if(c&&c[0].pos!=null){let g=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=g),h={anchor:g+s,head:b+s}}return{doc:m,sel:h,from:s,to:l}}function cg(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(Me&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||Me&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}var ug=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function fg(n,e,t,r,i){let o=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let S=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,A=ol(n,S);if(A&&!n.state.selection.eq(A)){if(ve&&At&&n.input.lastKeyCode===13&&Date.now()-100H(n,un(13,"Enter"))))return;let R=n.state.tr.setSelection(A);S=="pointer"?R.setMeta("pointer",!0):S=="key"&&R.scrollIntoView(),o&&R.setMeta("composition",o),n.dispatch(R)}return}let s=n.state.doc.resolve(e),l=s.sharedDepth(t);e=s.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=ag(n,e,t),u=n.state.doc,f=u.slice(c.from,c.to),d,p;n.input.lastKeyCode===8&&Date.now()-100Date.now()-225||At)&&i.some(S=>S.nodeType==1&&!ug.test(S.nodeName))&&(!h||h.endA>=h.endB)&&n.someProp("handleKeyDown",S=>S(n,un(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!h)if(r&&a instanceof P&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))h={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let S=ku(n,n.state.doc,c.sel);if(S&&!S.eq(n.state.selection)){let A=n.state.tr.setSelection(S);o&&A.setMeta("composition",o),n.dispatch(A)}}return}n.state.selection.fromn.state.selection.from&&h.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?h.start=n.state.selection.from:h.endA=n.state.selection.to-2&&n.state.selection.to<=c.to&&(h.endB+=n.state.selection.to-h.endA,h.endA=n.state.selection.to)),Fe&&_t<=11&&h.endB==h.start+1&&h.endA==h.start&&h.start>c.from&&c.doc.textBetween(h.start-c.from-1,h.start-c.from+1)==" \xA0"&&(h.start--,h.endA--,h.endB--);let m=c.doc.resolveNoCache(h.start-c.from),g=c.doc.resolveNoCache(h.endB-c.from),b=u.resolve(h.start),C=m.sameParent(g)&&m.parent.inlineContent&&b.end()>=h.endA;if((Qn&&n.input.lastIOSEnter>Date.now()-225&&(!C||i.some(S=>S.nodeName=="DIV"||S.nodeName=="P"))||!C&&m.posS(n,un(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>h.start&&pg(u,h.start,h.endA,m,g)&&n.someProp("handleKeyDown",S=>S(n,un(8,"Backspace")))){At&&ve&&n.domObserver.suppressSelectionUpdates();return}ve&&h.endB==h.start&&(n.input.lastChromeDelete=Date.now()),At&&!C&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==h.endA&&(h.endB-=2,g=c.doc.resolveNoCache(h.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(S){return S(n,un(13,"Enter"))})},20));let v=h.start,y=h.endA,T=S=>{let A=S||n.state.tr.replace(v,y,c.doc.slice(h.start-c.from,h.endB-c.from));if(c.sel){let R=ku(n,A.doc,c.sel);R&&!(ve&&n.composing&&R.empty&&(h.start!=h.endB||n.input.lastChromeDeleteNt(n),20));let S=T(n.state.tr.delete(v,y)),A=u.resolve(h.start).marksAcross(u.resolve(h.endA));A&&S.ensureMarks(A),n.dispatch(S)}else if(h.endA==h.endB&&(x=dg(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,h.endA-b.start())))){let S=T(n.state.tr);x.type=="add"?S.addMark(v,y,x.mark):S.removeMark(v,y,x.mark),n.dispatch(S)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let S=m.parent.textBetween(m.parentOffset,g.parentOffset),A=()=>T(n.state.tr.insertText(S,v,y));n.someProp("handleTextInput",R=>R(n,v,y,S,A))||n.dispatch(A())}else n.dispatch(T());else n.dispatch(T())}function ku(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:sl(n,e.resolve(t.anchor),e.resolve(t.head))}function dg(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,i=t,o=r,s,l,a;for(let u=0;uu.mark(l.addToSet(u.marks));else if(i.length==0&&o.length==1)l=o[0],s="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;ut||Fs(s,!0,!1)0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,i++,e=!1;if(t){let o=n.node(r).maybeChild(n.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,i++}return i}function hg(n,e,t,r,i){let o=n.findDiffStart(e,t);if(o==null)return null;let{a:s,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(i=="end"){let a=Math.max(0,o-Math.min(s,l));r-=s+a-o}if(s=s?o-r:0;o-=a,o&&o=l?o-r:0;o-=a,o&&o=56320&&e<=57343&&t>=55296&&t<=56319}var Br=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Qs,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Eu),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Su(this),wu(this),this.nodeViews=Cu(this),this.docView=tu(this.state.doc,vu(this),$s(this),this.dom,this),this.domObserver=new rl(this,(r,i,o,s)=>fg(this,r,i,o,s)),this.domObserver.start(),Pm(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Zs(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Eu),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let i=this.state,o=!1,s=!1;e.storedMarks&&this.composing&&(Xu(this),s=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let p=Cu(this);gg(p,this.nodeViews)&&(this.nodeViews=p,o=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Zs(this),this.editable=Su(this),wu(this);let a=$s(this),c=vu(this),u=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",f=o||!this.docView.matchesNode(e.doc,c,a);(f||!e.selection.eq(i.selection))&&(s=!0);let d=u=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Qh(this);if(s){this.domObserver.stop();let p=f&&(Fe||ve)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&mg(i.selection,e.selection);if(f){let h=ve?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Km(this)),(o||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=tu(e.doc,c,a,this.dom,this)),h&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&km(this))?Nt(this,p):(Fu(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():d&&Zh(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof D){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Gc(this,t.getBoundingClientRect(),e)}else Gc(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t0&&ot.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return om(this,e)}coordsAtPos(e,t=1){return Iu(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let i=this.docView.posFromDOM(e,t,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return um(this,t||this.state,e)}pasteHTML(e,t){return Pr(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Pr(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return ll(this,e)}destroy(){this.docView&&(Lm(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],$s(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,jh())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return zm(this,e)}domSelectionRange(){let e=this.domSelection();return e?Me&&this.root.nodeType===11&&Kh(this.dom.ownerDocument)==this.dom&&og(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};Br.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function vu(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[Xe.node(0,n.state.doc.content.size,e)]}function wu(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:Xe.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Su(n){return!n.someProp("editable",e=>e(n.state)===!1)}function mg(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Cu(n){let e=Object.create(null);function t(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function gg(n,e){let t=0,r=0;for(let i in n){if(n[i]!=e[i])return!0;t++}for(let i in e)r++;return t!=r}function Eu(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Dt={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Zi={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},yg=typeof navigator<"u"&&/Mac/.test(navigator.platform),bg=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(ue=0;ue<10;ue++)Dt[48+ue]=Dt[96+ue]=String(ue);var ue;for(ue=1;ue<=24;ue++)Dt[ue+111]="F"+ue;var ue;for(ue=65;ue<=90;ue++)Dt[ue]=String.fromCharCode(ue+32),Zi[ue]=String.fromCharCode(ue);var ue;for(Qi in Dt)Zi.hasOwnProperty(Qi)||(Zi[Qi]=Dt[Qi]);var Qi;function rf(n){var e=yg&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||bg&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Zi:Dt)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}var kg=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),xg=typeof navigator<"u"&&/Win/.test(navigator.platform);function vg(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,o,s;for(let l=0;ln.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function lf(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}var ml=(n,e,t)=>{let r=lf(n,t);if(!r)return!1;let i=yl(r);if(!i){let s=r.blockRange(),l=s&&Tt(s);return l==null?!1:(e&&e(n.tr.lift(s,l).scrollIntoView()),!0)}let o=i.nodeBefore;if(gf(n,i,e,-1))return!0;if(r.parent.content.size==0&&(er(o,"end")||D.isSelectable(o)))for(let s=r.depth;;s--){let l=Or(n.doc,r.before(s),r.after(s),M.empty);if(l&&l.slice.size1)break}return o.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos-o.nodeSize,i.pos).scrollIntoView()),!0):!1},af=(n,e,t)=>{let r=lf(n,t);if(!r)return!1;let i=yl(r);return i?uf(n,i,e):!1},cf=(n,e,t)=>{let r=ff(n,t);if(!r)return!1;let i=xl(r);return i?uf(n,i,e):!1};function uf(n,e,t){let r=e.nodeBefore,i=r,o=e.pos-1;for(;!i.isTextblock;o--){if(i.type.spec.isolating)return!1;let u=i.lastChild;if(!u)return!1;i=u}let s=e.nodeAfter,l=s,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=Or(n.doc,o,a,M.empty);if(!c||c.from!=o||c instanceof ke&&c.slice.size>=a-o)return!1;if(t){let u=n.tr.step(c);u.setSelection(P.create(u.doc,o)),t(u.scrollIntoView())}return!0}function er(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}var gl=(n,e,t)=>{let{$head:r,empty:i}=n.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;o=yl(r)}let s=o&&o.nodeBefore;return!s||!D.isSelectable(s)?!1:(e&&e(n.tr.setSelection(D.create(n.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function yl(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function ff(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset{let r=ff(n,t);if(!r)return!1;let i=xl(r);if(!i)return!1;let o=i.nodeAfter;if(gf(n,i,e,1))return!0;if(r.parent.content.size==0&&(er(o,"start")||D.isSelectable(o))){let s=Or(n.doc,r.before(),r.after(),M.empty);if(s&&s.slice.size{let{$head:r,empty:i}=n.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset=0;e--){let t=n.node(e);if(n.index(e)+1{let t=n.selection,r=t instanceof D,i;if(r){if(t.node.isTextblock||!ot(n.doc,t.from))return!1;i=t.from}else if(i=qn(n.doc,t.from,-1),i==null)return!1;if(e){let o=n.tr.join(i);r&&o.setSelection(D.create(o.doc,i-n.doc.resolve(i).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0},pf=(n,e)=>{let t=n.selection,r;if(t instanceof D){if(t.node.isTextblock||!ot(n.doc,t.to))return!1;r=t.to}else if(r=qn(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},hf=(n,e)=>{let{$from:t,$to:r}=n.selection,i=t.blockRange(r),o=i&&Tt(i);return o==null?!1:(e&&e(n.tr.lift(i,o).scrollIntoView()),!0)},vl=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(` +`).scrollIntoView()),!0)};function wl(n){for(let e=0;e{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let i=t.node(-1),o=t.indexAfter(-1),s=wl(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,s.createAndFill());a.setSelection(L.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Cl=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof Re||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=wl(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let s=(!r.parentOffset&&i.index(){let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let o=t.before();if(Ue(n.doc,o))return e&&e(n.tr.split(o).scrollIntoView()),!0}let r=t.blockRange(),i=r&&Tt(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function Sg(n){return(e,t)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof D&&e.selection.node.isBlock)return!r.parentOffset||!Ue(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let o=[],s,l,a=!1,c=!1;for(let p=r.depth;;p--)if(r.node(p).isBlock){a=r.end(p)==r.pos+(r.depth-p),c=r.start(p)==r.pos-(r.depth-p),l=wl(r.node(p-1).contentMatchAt(r.indexAfter(p-1)));let m=n&&n(i.parent,a,r);o.unshift(m||(a&&l?{type:l}:null)),s=p;break}else{if(p==1)return!1;o.unshift(null)}let u=e.tr;(e.selection instanceof P||e.selection instanceof Re)&&u.deleteSelection();let f=u.mapping.map(r.pos),d=Ue(u.doc,f,o.length,o);if(d||(o[0]=l?{type:l}:null,d=Ue(u.doc,f,o.length,o)),!d)return!1;if(u.split(f,o.length,o),!a&&c&&r.node(s).type!=l){let p=u.mapping.map(r.before(s)),h=u.doc.resolve(p);l&&r.node(s-1).canReplaceWith(h.index(),h.index()+1,l)&&u.setNodeMarkup(u.mapping.map(r.before(s)),l)}return t&&t(u.scrollIntoView()),!0}}var Cg=Sg();var mf=(n,e)=>{let{$from:t,to:r}=n.selection,i,o=t.sharedDepth(r);return o==0?!1:(i=t.before(o),e&&e(n.tr.setSelection(D.create(n.doc,i))),!0)},Eg=(n,e)=>(e&&e(n.tr.setSelection(new Re(n.doc))),!0);function Tg(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,o=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(o-1,o)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(i.isTextblock||ot(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function gf(n,e,t,r){let i=e.nodeBefore,o=e.nodeAfter,s,l,a=i.type.spec.isolating||o.type.spec.isolating;if(!a&&Tg(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(l=i.contentMatchAt(i.childCount)).findWrapping(o.type))&&l.matchType(s[0]||o.type).validEnd){if(t){let p=e.pos+o.nodeSize,h=w.empty;for(let b=s.length-1;b>=0;b--)h=w.from(s[b].create(null,h));h=w.from(i.copy(h));let m=n.tr.step(new ce(e.pos-1,p,e.pos,p,new M(h,1,0),s.length,!0)),g=m.doc.resolve(p+2*s.length);g.nodeAfter&&g.nodeAfter.type==i.type&&ot(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let u=o.type.spec.isolating||r>0&&a?null:L.findFrom(e,1),f=u&&u.$from.blockRange(u.$to),d=f&&Tt(f);if(d!=null&&d>=e.depth)return t&&t(n.tr.lift(f,d).scrollIntoView()),!0;if(c&&er(o,"start",!0)&&er(i,"end")){let p=i,h=[];for(;h.push(p),!p.isTextblock;)p=p.lastChild;let m=o,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(p.canReplace(p.childCount,p.childCount,m.content)){if(t){let b=w.empty;for(let v=h.length-1;v>=0;v--)b=w.from(h[v].copy(b));let C=n.tr.step(new ce(e.pos-h.length,e.pos+o.nodeSize,e.pos+g,e.pos+o.nodeSize-g,new M(b,h.length,0),0,!0));t(C.scrollIntoView())}return!0}}return!1}function yf(n){return function(e,t){let r=e.selection,i=n<0?r.$from:r.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return i.node(o).isTextblock?(t&&t(e.tr.setSelection(P.create(e.doc,n<0?i.start(o):i.end(o)))),!0):!1}}var Tl=yf(-1),Ml=yf(1);function bf(n,e=null){return function(t,r){let{$from:i,$to:o}=t.selection,s=i.blockRange(o),l=s&&_n(s,n,e);return l?(r&&r(t.tr.wrap(s,l).scrollIntoView()),!0):!1}}function Ol(n,e=null){return function(t,r){let i=!1;for(let o=0;o{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)i=!0;else{let u=t.doc.resolve(c),f=u.index();i=u.parent.canReplaceWith(f,f+1,n)}})}if(!i)return!1;if(r){let o=t.tr;for(let s=0;s=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=s.resolve(e.start-2);o=new sn(a,a,e.depth),e.endIndex=0;u--)o=w.from(t[u].type.create(t[u].attrs,o));n.step(new ce(e.start-(r?2:0),e.end,e.start,e.end,new M(o,0,0),t.length,!0));let s=0;for(let u=0;us.childCount>0&&s.firstChild.type==n);return o?t?r.node(o.depth-1).type==n?Ng(e,t,n,o):Dg(e,t,o):!0:!1}}function Ng(n,e,t,r){let i=n.tr,o=r.end,s=r.$to.end(r.depth);om;h--)p-=i.child(h).nodeSize,r.delete(p-1,p+1);let o=r.doc.resolve(t.start),s=o.nodeAfter;if(r.mapping.map(t.end)!=t.start+o.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==i.childCount,c=o.node(-1),u=o.index(-1);if(!c.canReplace(u+(l?0:1),u+1,s.content.append(a?w.empty:w.from(i))))return!1;let f=o.pos,d=f+s.nodeSize;return r.step(new ce(f-(l?1:0),d+(a?1:0),f+1,d-1,new M((l?w.empty:w.from(i.copy(w.empty))).append(a?w.empty:w.from(i.copy(w.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function vf(n){return function(e,t){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==n);if(!o)return!1;let s=o.startIndex;if(s==0)return!1;let l=o.parent,a=l.child(s-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=w.from(c?n.create():null),f=new M(w.from(n.create(null,w.from(l.type.create(null,u)))),c?3:1,0),d=o.start,p=o.end;t(e.tr.step(new ce(d-(c?3:1),p,d,p,f,1,!0)).scrollIntoView())}return!0}}function co(n){let{state:e,transaction:t}=n,{selection:r}=t,{doc:i}=t,{storedMarks:o}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return o},get selection(){return r},get doc(){return i},get tr(){return r=t.selection,i=t.doc,o=t.storedMarks,t}}}var tr=class{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:e,editor:t,state:r}=this,{view:i}=t,{tr:o}=r,s=this.buildProps(o);return Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...u)=>{let f=a(...u)(s);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(o),f}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){let{rawCommands:r,editor:i,state:o}=this,{view:s}=i,l=[],a=!!e,c=e||o.tr,u=()=>(!a&&t&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(c),l.every(d=>d===!0)),f={...Object.fromEntries(Object.entries(r).map(([d,p])=>[d,(...m)=>{let g=this.buildProps(c,t),b=p(...m)(g);return l.push(b),f}])),run:u};return f}createCan(e){let{rawCommands:t,state:r}=this,i=!1,o=e||r.tr,s=this.buildProps(o,i);return{...Object.fromEntries(Object.entries(t).map(([a,c])=>[a,(...u)=>c(...u)({...s,dispatch:void 0})])),chain:()=>this.createChain(o,i)}}buildProps(e,t=!0){let{rawCommands:r,editor:i,state:o}=this,{view:s}=i,l={tr:e,editor:i,view:s,state:co({state:o,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([a,c])=>[a,(...u)=>c(...u)(l)]))}};return l}},Il=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let r=this.callbacks[e];return r&&r.forEach(i=>i.apply(this,t)),this}off(e,t){let r=this.callbacks[e];return r&&(t?this.callbacks[e]=r.filter(i=>i!==t):delete this.callbacks[e]),this}once(e,t){let r=(...i)=>{this.off(e,r),t.apply(this,i)};return this.on(e,r)}removeAllListeners(){this.callbacks={}}};function O(n,e,t){return n.config[e]===void 0&&n.parent?O(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?O(n.parent,e,t):null}):n.config[e]}function uo(n){let e=n.filter(i=>i.type==="extension"),t=n.filter(i=>i.type==="node"),r=n.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function Nf(n){let e=[],{nodeExtensions:t,markExtensions:r}=uo(n),i=[...t,...r],o={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return n.forEach(s=>{let l={name:s.name,options:s.options,storage:s.storage,extensions:i},a=O(s,"addGlobalAttributes",l);if(!a)return;a().forEach(u=>{u.types.forEach(f=>{Object.entries(u.attributes).forEach(([d,p])=>{e.push({type:f,name:d,attribute:{...o,...p}})})})})}),i.forEach(s=>{let l={name:s.name,options:s.options,storage:s.storage},a=O(s,"addAttributes",l);if(!a)return;let c=a();Object.entries(c).forEach(([u,f])=>{let d={...o,...f};typeof d?.default=="function"&&(d.default=d.default()),d?.isRequired&&d?.default===void 0&&delete d.default,e.push({type:s.name,name:u,attribute:d})})}),e}function me(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}function j(...n){return n.filter(e=>!!e).reduce((e,t)=>{let r={...e};return Object.entries(t).forEach(([i,o])=>{if(!r[i]){r[i]=o;return}if(i==="class"){let l=o?String(o).split(" "):[],a=r[i]?r[i].split(" "):[],c=l.filter(u=>!a.includes(u));r[i]=[...a,...c].join(" ")}else if(i==="style"){let l=o?o.split(";").map(u=>u.trim()).filter(Boolean):[],a=r[i]?r[i].split(";").map(u=>u.trim()).filter(Boolean):[],c=new Map;a.forEach(u=>{let[f,d]=u.split(":").map(p=>p.trim());c.set(f,d)}),l.forEach(u=>{let[f,d]=u.split(":").map(p=>p.trim());c.set(f,d)}),r[i]=Array.from(c.entries()).map(([u,f])=>`${u}: ${f}`).join("; ")}else r[i]=o}),r},{})}function Pl(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>j(t,r),{})}function Df(n){return typeof n=="function"}function $(n,e=void 0,...t){return Df(n)?e?n.bind(e)(...t):n(...t):n}function Rg(n={}){return Object.keys(n).length===0&&n.constructor===Object}function Ig(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function wf(n,e){return"style"in n?n:{...n,getAttrs:t=>{let r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;let i=e.reduce((o,s)=>{let l=s.attribute.parseHTML?s.attribute.parseHTML(t):Ig(t.getAttribute(s.name));return l==null?o:{...o,[s.name]:l}},{});return{...r,...i}}}}function Sf(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&Rg(t)?!1:t!=null))}function Pg(n,e){var t;let r=Nf(n),{nodeExtensions:i,markExtensions:o}=uo(n),s=(t=i.find(c=>O(c,"topNode")))===null||t===void 0?void 0:t.name,l=Object.fromEntries(i.map(c=>{let u=r.filter(b=>b.type===c.name),f={name:c.name,options:c.options,storage:c.storage,editor:e},d=n.reduce((b,C)=>{let v=O(C,"extendNodeSchema",f);return{...b,...v?v(c):{}}},{}),p=Sf({...d,content:$(O(c,"content",f)),marks:$(O(c,"marks",f)),group:$(O(c,"group",f)),inline:$(O(c,"inline",f)),atom:$(O(c,"atom",f)),selectable:$(O(c,"selectable",f)),draggable:$(O(c,"draggable",f)),code:$(O(c,"code",f)),whitespace:$(O(c,"whitespace",f)),linebreakReplacement:$(O(c,"linebreakReplacement",f)),defining:$(O(c,"defining",f)),isolating:$(O(c,"isolating",f)),attrs:Object.fromEntries(u.map(b=>{var C;return[b.name,{default:(C=b?.attribute)===null||C===void 0?void 0:C.default}]}))}),h=$(O(c,"parseHTML",f));h&&(p.parseDOM=h.map(b=>wf(b,u)));let m=O(c,"renderHTML",f);m&&(p.toDOM=b=>m({node:b,HTMLAttributes:Pl(b,u)}));let g=O(c,"renderText",f);return g&&(p.toText=g),[c.name,p]})),a=Object.fromEntries(o.map(c=>{let u=r.filter(g=>g.type===c.name),f={name:c.name,options:c.options,storage:c.storage,editor:e},d=n.reduce((g,b)=>{let C=O(b,"extendMarkSchema",f);return{...g,...C?C(c):{}}},{}),p=Sf({...d,inclusive:$(O(c,"inclusive",f)),excludes:$(O(c,"excludes",f)),group:$(O(c,"group",f)),spanning:$(O(c,"spanning",f)),code:$(O(c,"code",f)),attrs:Object.fromEntries(u.map(g=>{var b;return[g.name,{default:(b=g?.attribute)===null||b===void 0?void 0:b.default}]}))}),h=$(O(c,"parseHTML",f));h&&(p.parseDOM=h.map(g=>wf(g,u)));let m=O(c,"renderHTML",f);return m&&(p.toDOM=g=>m({mark:g,HTMLAttributes:Pl(g,u)})),[c.name,p]}));return new xr({topNode:s,nodes:l,marks:a})}function Nl(n,e){return e.nodes[n]||e.marks[n]||null}function Cf(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function Hl(n,e){let t=Ct.fromSchema(e).serializeFragment(n),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(t),i.innerHTML}var Lg=(n,e=500)=>{let t="",r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(i,o,s,l)=>{var a,c;let u=((c=(a=i.type.spec).toText)===null||c===void 0?void 0:c.call(a,{node:i,pos:o,parent:s,index:l}))||i.textContent||"%leaf%";t+=i.isAtom&&!i.isText?u:u.slice(0,Math.max(0,r-o))}),t};function Vl(n){return Object.prototype.toString.call(n)==="[object RegExp]"}var nr=class{constructor(e){this.find=e.find,this.handler=e.handler}},Bg=(n,e)=>{if(Vl(e))return e.exec(n);let t=e(n);if(!t)return null;let r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function to(n){var e;let{editor:t,from:r,to:i,text:o,rules:s,plugin:l}=n,{view:a}=t;if(a.composing)return!1;let c=a.state.doc.resolve(r);if(c.parent.type.spec.code||!((e=c.nodeBefore||c.nodeAfter)===null||e===void 0)&&e.marks.find(d=>d.type.spec.code))return!1;let u=!1,f=Lg(c)+o;return s.forEach(d=>{if(u)return;let p=Bg(f,d.find);if(!p)return;let h=a.state.tr,m=co({state:a.state,transaction:h}),g={from:r-(p[0].length-o.length),to:i},{commands:b,chain:C,can:v}=new tr({editor:t,state:m});d.handler({state:m,range:g,match:p,commands:b,chain:C,can:v})===null||!h.steps.length||(h.setMeta(l,{transform:h,from:r,to:i,text:o}),a.dispatch(h),u=!0)}),u}function zg(n){let{editor:e,rules:t}=n,r=new q({state:{init(){return null},apply(i,o,s){let l=i.getMeta(r);if(l)return l;let a=i.getMeta("applyInputRules");return!!a&&setTimeout(()=>{let{text:u}=a;typeof u=="string"?u=u:u=Hl(w.from(u),s.schema);let{from:f}=a,d=f+u.length;to({editor:e,from:f,to:d,text:u,rules:t,plugin:r})}),i.selectionSet||i.docChanged?null:o}},props:{handleTextInput(i,o,s,l){return to({editor:e,from:o,to:s,text:l,rules:t,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{let{$cursor:o}=i.state.selection;o&&to({editor:e,from:o.pos,to:o.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(i,o){if(o.key!=="Enter")return!1;let{$cursor:s}=i.state.selection;return s?to({editor:e,from:s.pos,to:s.pos,text:` +`,rules:t,plugin:r}):!1}},isInputRules:!0});return r}function $g(n){return Object.prototype.toString.call(n).slice(8,-1)}function no(n){return $g(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function fo(n,e){let t={...n};return no(n)&&no(e)&&Object.keys(e).forEach(r=>{no(e[r])&&no(n[r])?t[r]=fo(n[r],e[r]):t[r]=e[r]}),t}var Le=class n{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=$(O(this,"addOptions",{name:this.name}))),this.storage=$(O(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new n(e)}configure(e={}){let t=this.extend({...this.config,addOptions:()=>fo(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){let t=new n(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=$(O(t,"addOptions",{name:t.name})),t.storage=$(O(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){let{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){let s=i.marks();if(!!!s.find(c=>c?.type.name===t.name))return!1;let a=s.find(c=>c?.type.name===t.name);return a&&r.removeStoredMark(a),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}};function Fg(n){return typeof n=="number"}var Ll=class{constructor(e){this.find=e.find,this.handler=e.handler}},Hg=(n,e,t)=>{if(Vl(e))return[...n.matchAll(e)];let r=e(n,t);return r?r.map(i=>{let o=[i.text];return o.index=i.index,o.input=n,o.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),o.push(i.replaceWith)),o}):[]};function Vg(n){let{editor:e,state:t,from:r,to:i,rule:o,pasteEvent:s,dropEvent:l}=n,{commands:a,chain:c,can:u}=new tr({editor:e,state:t}),f=[];return t.doc.nodesBetween(r,i,(p,h)=>{if(!p.isTextblock||p.type.spec.code)return;let m=Math.max(r,h),g=Math.min(i,h+p.content.size),b=p.textBetween(m-h,g-h,void 0,"\uFFFC");Hg(b,o.find,s).forEach(v=>{if(v.index===void 0)return;let y=m+v.index+1,T=y+v[0].length,x={from:t.tr.mapping.map(y),to:t.tr.mapping.map(T)},S=o.handler({state:t,range:x,match:v,commands:a,chain:c,can:u,pasteEvent:s,dropEvent:l});f.push(S)})}),f.every(p=>p!==null)}var ro=null,jg=n=>{var e;let t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)===null||e===void 0||e.setData("text/html",n),t};function Wg(n){let{editor:e,rules:t}=n,r=null,i=!1,o=!1,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}let a=({state:u,from:f,to:d,rule:p,pasteEvt:h})=>{let m=u.tr,g=co({state:u,transaction:m});if(!(!Vg({editor:e,state:g,from:Math.max(f-1,0),to:d.b-1,rule:p,pasteEvent:h,dropEvent:l})||!m.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,m}};return t.map(u=>new q({view(f){let d=h=>{var m;r=!((m=f.dom.parentElement)===null||m===void 0)&&m.contains(h.target)?f.dom.parentElement:null,r&&(ro=e)},p=()=>{ro&&(ro=null)};return window.addEventListener("dragstart",d),window.addEventListener("dragend",p),{destroy(){window.removeEventListener("dragstart",d),window.removeEventListener("dragend",p)}}},props:{handleDOMEvents:{drop:(f,d)=>{if(o=r===f.dom.parentElement,l=d,!o){let p=ro;p?.isEditable&&setTimeout(()=>{let h=p.state.selection;h&&p.commands.deleteRange({from:h.from,to:h.to})},10)}return!1},paste:(f,d)=>{var p;let h=(p=d.clipboardData)===null||p===void 0?void 0:p.getData("text/html");return s=d,i=!!h?.includes("data-pm-slice"),!1}}},appendTransaction:(f,d,p)=>{let h=f[0],m=h.getMeta("uiEvent")==="paste"&&!i,g=h.getMeta("uiEvent")==="drop"&&!o,b=h.getMeta("applyPasteRules"),C=!!b;if(!m&&!g&&!C)return;if(C){let{text:T}=b;typeof T=="string"?T=T:T=Hl(w.from(T),p.schema);let{from:x}=b,S=x+T.length,A=jg(T);return a({rule:u,state:p,from:x,to:{b:S},pasteEvt:A})}let v=d.doc.content.findDiffStart(p.doc.content),y=d.doc.content.findDiffEnd(p.doc.content);if(!(!Fg(v)||!y||v===y.b))return a({rule:u,state:p,from:v,to:y,pasteEvt:s})}}))}function _g(n){let e=n.filter((t,r)=>n.indexOf(t)!==r);return Array.from(new Set(e))}var Bl=class n{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=n.resolve(e),this.schema=Pg(this.extensions,t),this.setupExtensions()}static resolve(e){let t=n.sort(n.flatten(e)),r=_g(t.map(i=>i.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(i=>`'${i}'`).join(", ")}]. This can lead to issues.`),t}static flatten(e){return e.map(t=>{let r={name:t.name,options:t.options,storage:t.storage},i=O(t,"addExtensions",r);return i?[t,...this.flatten(i())]:t}).flat(10)}static sort(e){return e.sort((r,i)=>{let o=O(r,"priority")||100,s=O(i,"priority")||100;return o>s?-1:o{let r={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:Nl(t.name,this.schema)},i=O(t,"addCommands",r);return i?{...e,...i()}:e},{})}get plugins(){let{editor:e}=this,t=n.sort([...this.extensions].reverse()),r=[],i=[],o=t.map(s=>{let l={name:s.name,options:s.options,storage:s.storage,editor:e,type:Nl(s.name,this.schema)},a=[],c=O(s,"addKeyboardShortcuts",l),u={};if(s.type==="mark"&&O(s,"exitable",l)&&(u.ArrowRight=()=>Le.handleExit({editor:e,mark:s})),c){let m=Object.fromEntries(Object.entries(c()).map(([g,b])=>[g,()=>b({editor:e})]));u={...u,...m}}let f=of(u);a.push(f);let d=O(s,"addInputRules",l);Cf(s,e.options.enableInputRules)&&d&&r.push(...d());let p=O(s,"addPasteRules",l);Cf(s,e.options.enablePasteRules)&&p&&i.push(...p());let h=O(s,"addProseMirrorPlugins",l);if(h){let m=h();a.push(...m)}return a}).flat();return[zg({editor:e,rules:r}),...Wg({editor:e,rules:i}),...o]}get attributes(){return Nf(this.extensions)}get nodeViews(){let{editor:e}=this,{nodeExtensions:t}=uo(this.extensions);return Object.fromEntries(t.filter(r=>!!O(r,"addNodeView")).map(r=>{let i=this.attributes.filter(a=>a.type===r.name),o={name:r.name,options:r.options,storage:r.storage,editor:e,type:me(r.name,this.schema)},s=O(r,"addNodeView",o);if(!s)return[];let l=(a,c,u,f,d)=>{let p=Pl(a,i);return s()({node:a,view:c,getPos:u,decorations:f,innerDecorations:d,editor:e,extension:r,HTMLAttributes:p})};return[r.name,l]}))}setupExtensions(){this.extensions.forEach(e=>{var t;this.editor.extensionStorage[e.name]=e.storage;let r={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:Nl(e.name,this.schema)};e.type==="mark"&&(!((t=$(O(e,"keepOnSplit",r)))!==null&&t!==void 0)||t)&&this.splittableMarks.push(e.name);let i=O(e,"onBeforeCreate",r),o=O(e,"onCreate",r),s=O(e,"onUpdate",r),l=O(e,"onSelectionUpdate",r),a=O(e,"onTransaction",r),c=O(e,"onFocus",r),u=O(e,"onBlur",r),f=O(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),o&&this.editor.on("create",o),s&&this.editor.on("update",s),l&&this.editor.on("selectionUpdate",l),a&&this.editor.on("transaction",a),c&&this.editor.on("focus",c),u&&this.editor.on("blur",u),f&&this.editor.on("destroy",f)})}},ie=class n{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=$(O(this,"addOptions",{name:this.name}))),this.storage=$(O(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new n(e)}configure(e={}){let t=this.extend({...this.config,addOptions:()=>fo(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){let t=new n({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=$(O(t,"addOptions",{name:t.name})),t.storage=$(O(t,"addStorage",{name:t.name,options:t.options})),t}};function Rf(n,e,t){let{from:r,to:i}=e,{blockSeparator:o=` + +`,textSerializers:s={}}=t||{},l="";return n.nodesBetween(r,i,(a,c,u,f)=>{var d;a.isBlock&&c>r&&(l+=o);let p=s?.[a.type.name];if(p)return u&&(l+=p({node:a,pos:c,parent:u,index:f,range:e})),!1;a.isText&&(l+=(d=a?.text)===null||d===void 0?void 0:d.slice(Math.max(r,c)-c,i-c))}),l}function If(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}var qg=ie.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new q({key:new re("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:i}=e,{ranges:o}=i,s=Math.min(...o.map(u=>u.$from.pos)),l=Math.max(...o.map(u=>u.$to.pos)),a=If(t);return Rf(r,{from:s,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),Ug=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window?.getSelection())===null||t===void 0||t.removeAllRanges())}),!0),Kg=(n=!1)=>({commands:e})=>e.setContent("",n),Jg=()=>({state:n,tr:e,dispatch:t})=>{let{selection:r}=e,{ranges:i}=r;return t&&i.forEach(({$from:o,$to:s})=>{n.doc.nodesBetween(o.pos,s.pos,(l,a)=>{if(l.type.isText)return;let{doc:c,mapping:u}=e,f=c.resolve(u.map(a)),d=c.resolve(u.map(a+l.nodeSize)),p=f.blockRange(d);if(!p)return;let h=Tt(p);if(l.type.isTextblock){let{defaultType:m}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(p.start,m)}(h||h===0)&&e.lift(p,h)})}),!0},Gg=n=>e=>n(e),Yg=()=>({state:n,dispatch:e})=>Cl(n,e),Xg=(n,e)=>({editor:t,tr:r})=>{let{state:i}=t,o=i.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);let s=r.mapping.map(e);return r.insert(s,o.content),r.setSelection(new P(r.doc.resolve(Math.max(s-1,0)))),!0},Qg=()=>({tr:n,dispatch:e})=>{let{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;let i=n.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===r.type){if(e){let l=i.before(o),a=i.after(o);n.delete(l,a).scrollIntoView()}return!0}return!1},Zg=n=>({tr:e,state:t,dispatch:r})=>{let i=me(n,t.schema),o=e.selection.$anchor;for(let s=o.depth;s>0;s-=1)if(o.node(s).type===i){if(r){let a=o.before(s),c=o.after(s);e.delete(a,c).scrollIntoView()}return!0}return!1},ey=n=>({tr:e,dispatch:t})=>{let{from:r,to:i}=n;return t&&e.delete(r,i),!0},ty=()=>({state:n,dispatch:e})=>eo(n,e),ny=()=>({commands:n})=>n.keyboardShortcut("Enter"),ry=()=>({state:n,dispatch:e})=>Sl(n,e);function so(n,e,t={strict:!0}){let r=Object.keys(e);return r.length?r.every(i=>t.strict?e[i]===n[i]:Vl(e[i])?e[i].test(n[i]):e[i]===n[i]):!0}function Pf(n,e,t={}){return n.find(r=>r.type===e&&so(Object.fromEntries(Object.keys(t).map(i=>[i,r.attrs[i]])),t))}function Ef(n,e,t={}){return!!Pf(n,e,t)}function jl(n,e,t){var r;if(!n||!e)return;let i=n.parent.childAfter(n.parentOffset);if((!i.node||!i.node.marks.some(u=>u.type===e))&&(i=n.parent.childBefore(n.parentOffset)),!i.node||!i.node.marks.some(u=>u.type===e)||(t=t||((r=i.node.marks[0])===null||r===void 0?void 0:r.attrs),!Pf([...i.node.marks],e,t)))return;let s=i.index,l=n.start()+i.offset,a=s+1,c=l+i.node.nodeSize;for(;s>0&&Ef([...n.parent.child(s-1).marks],e,t);)s-=1,l-=n.parent.child(s).nodeSize;for(;a({tr:t,state:r,dispatch:i})=>{let o=Jt(n,r.schema),{doc:s,selection:l}=t,{$from:a,from:c,to:u}=l;if(i){let f=jl(a,o,e);if(f&&f.from<=c&&f.to>=u){let d=P.create(s,f.from,f.to);t.setSelection(d)}}return!0},oy=n=>e=>{let t=typeof n=="function"?n(e):n;for(let r=0;r({editor:t,view:r,tr:i,dispatch:o})=>{e={scrollIntoView:!0,...e};let s=()=>{(lo()||Tf())&&r.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),sy()&&!lo()&&!Tf()&&r.dom.focus({preventScroll:!0}))})};if(r.hasFocus()&&n===null||n===!1)return!0;if(o&&n===null&&!po(t.state.selection))return s(),!0;let l=Lf(i.doc,n)||t.state.selection,a=t.state.selection.eq(l);return o&&(a||i.setSelection(l),a&&i.storedMarks&&i.setStoredMarks(i.storedMarks),s()),!0},ay=(n,e)=>t=>n.every((r,i)=>e(r,{...t,index:i})),cy=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),Bf=n=>{let e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){let r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&Bf(r)}return n};function io(n){let e=`${n}`,t=new window.DOMParser().parseFromString(e,"text/html").body;return Bf(t)}function Fr(n,e,t){if(n instanceof qe||n instanceof w)return n;t={slice:!0,parseOptions:{},...t};let r=typeof n=="object"&&n!==null,i=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return w.fromArray(n.map(l=>e.nodeFromJSON(l)));let s=e.nodeFromJSON(n);return t.errorOnInvalidContent&&s.check(),s}catch(o){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",o),Fr("",e,t)}if(i){if(t.errorOnInvalidContent){let s=!1,l="",a=new xr({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(s=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?St.fromSchema(a).parseSlice(io(n),t.parseOptions):St.fromSchema(a).parse(io(n),t.parseOptions),t.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}let o=St.fromSchema(e);return t.slice?o.parseSlice(io(n),t.parseOptions).content:o.parse(io(n),t.parseOptions)}return Fr("",e,t)}function uy(n,e,t){let r=n.steps.length-1;if(r{s===0&&(s=u)}),n.setSelection(L.near(n.doc.resolve(s),t))}var fy=n=>!("type"in n),dy=(n,e,t)=>({tr:r,dispatch:i,editor:o})=>{var s;if(i){t={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l,a=g=>{o.emit("contentError",{editor:o,error:g,disableCollaboration:()=>{o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{Fr(e,o.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){a(g)}try{l=Fr(e,o.schema,{parseOptions:c,errorOnInvalidContent:(s=t.errorOnInvalidContent)!==null&&s!==void 0?s:o.options.enableContentCheck})}catch(g){return a(g),!1}let{from:u,to:f}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},d=!0,p=!0;if((fy(l)?l:[l]).forEach(g=>{g.check(),d=d?g.isText&&g.marks.length===0:!1,p=p?g.isBlock:!1}),u===f&&p){let{parent:g}=r.doc.resolve(u);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(u-=1,f+=1)}let m;if(d){if(Array.isArray(e))m=e.map(g=>g.text||"").join("");else if(e instanceof w){let g="";e.forEach(b=>{b.text&&(g+=b.text)}),m=g}else typeof e=="object"&&e&&e.text?m=e.text:m=e;r.insertText(m,u,f)}else m=l,r.replaceWith(u,f,m);t.updateSelection&&uy(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:m}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:m})}return!0},py=()=>({state:n,dispatch:e})=>df(n,e),hy=()=>({state:n,dispatch:e})=>pf(n,e),my=()=>({state:n,dispatch:e})=>ml(n,e),gy=()=>({state:n,dispatch:e})=>bl(n,e),yy=()=>({state:n,dispatch:e,tr:t})=>{try{let r=qn(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},by=()=>({state:n,dispatch:e,tr:t})=>{try{let r=qn(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},ky=()=>({state:n,dispatch:e})=>af(n,e),xy=()=>({state:n,dispatch:e})=>cf(n,e);function zf(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function vy(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t==="Space"&&(t=" ");let r,i,o,s;for(let l=0;l({editor:e,view:t,tr:r,dispatch:i})=>{let o=vy(n).split(/-(?!$)/),s=o.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a?.steps.forEach(c=>{let u=c.map(r.mapping);u&&i&&r.maybeStep(u)}),!0};function Hr(n,e,t={}){let{from:r,to:i,empty:o}=n.selection,s=e?me(e,n.schema):null,l=[];n.doc.nodesBetween(r,i,(f,d)=>{if(f.isText)return;let p=Math.max(r,d),h=Math.min(i,d+f.nodeSize);l.push({node:f,from:p,to:h})});let a=i-r,c=l.filter(f=>s?s.name===f.node.type.name:!0).filter(f=>so(f.node.attrs,t,{strict:!1}));return o?!!c.length:c.reduce((f,d)=>f+d.to-d.from,0)>=a}var Sy=(n,e={})=>({state:t,dispatch:r})=>{let i=me(n,t.schema);return Hr(t,i,e)?hf(t,r):!1},Cy=()=>({state:n,dispatch:e})=>El(n,e),Ey=n=>({state:e,dispatch:t})=>{let r=me(n,e.schema);return xf(r)(e,t)},Ty=()=>({state:n,dispatch:e})=>vl(n,e);function ho(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function Mf(n,e){let t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,i)=>(t.includes(i)||(r[i]=n[i]),r),{})}var My=(n,e)=>({tr:t,state:r,dispatch:i})=>{let o=null,s=null,l=ho(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(o=me(n,r.schema)),l==="mark"&&(s=Jt(n,r.schema)),i&&t.selection.ranges.forEach(a=>{r.doc.nodesBetween(a.$from.pos,a.$to.pos,(c,u)=>{o&&o===c.type&&t.setNodeMarkup(u,void 0,Mf(c.attrs,e)),s&&c.marks.length&&c.marks.forEach(f=>{s===f.type&&t.addMark(u,u+c.nodeSize,s.create(Mf(f.attrs,e)))})})}),!0):!1},Oy=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),Ay=()=>({tr:n,dispatch:e})=>{if(e){let t=new Re(n.doc);n.setSelection(t)}return!0},Ny=()=>({state:n,dispatch:e})=>gl(n,e),Dy=()=>({state:n,dispatch:e})=>kl(n,e),Ry=()=>({state:n,dispatch:e})=>mf(n,e),Iy=()=>({state:n,dispatch:e})=>Ml(n,e),Py=()=>({state:n,dispatch:e})=>Tl(n,e);function zl(n,e,t={},r={}){return Fr(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}var Ly=(n,e=!1,t={},r={})=>({editor:i,tr:o,dispatch:s,commands:l})=>{var a,c;let{doc:u}=o;if(t.preserveWhitespace!=="full"){let f=zl(n,i.schema,t,{errorOnInvalidContent:(a=r.errorOnInvalidContent)!==null&&a!==void 0?a:i.options.enableContentCheck});return s&&o.replaceWith(0,u.content.size,f).setMeta("preventUpdate",!e),!0}return s&&o.setMeta("preventUpdate",!e),l.insertContentAt({from:0,to:u.content.size},n,{parseOptions:t,errorOnInvalidContent:(c=r.errorOnInvalidContent)!==null&&c!==void 0?c:i.options.enableContentCheck})};function $f(n,e){let t=Jt(e,n.schema),{from:r,to:i,empty:o}=n.selection,s=[];o?(n.storedMarks&&s.push(...n.storedMarks),s.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,i,a=>{s.push(...a.marks)});let l=s.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function Ff(n,e){let t=new Wn(n);return e.forEach(r=>{r.steps.forEach(i=>{t.step(i)})}),t}function By(n){for(let e=0;e{t(i)&&r.push({node:i,pos:o})}),r}function zy(n,e){for(let t=n.depth;t>0;t-=1){let r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function Wl(n){return e=>zy(e.$from,n)}function $y(n,e){let t={from:0,to:n.content.size};return Rf(n,t,e)}function Fy(n,e){let t=me(e,n.schema),{from:r,to:i}=n.selection,o=[];n.doc.nodesBetween(r,i,l=>{o.push(l)});let s=o.reverse().find(l=>l.type.name===t.name);return s?{...s.attrs}:{}}function _l(n,e){let t=ho(typeof e=="string"?e:e.name,n.schema);return t==="node"?Fy(n,e):t==="mark"?$f(n,e):{}}function Hy(n,e=JSON.stringify){let t={};return n.filter(r=>{let i=e(r);return Object.prototype.hasOwnProperty.call(t,i)?!1:t[i]=!0})}function Vy(n){let e=Hy(n);return e.length===1?e:e.filter((t,r)=>!e.filter((o,s)=>s!==r).some(o=>t.oldRange.from>=o.oldRange.from&&t.oldRange.to<=o.oldRange.to&&t.newRange.from>=o.newRange.from&&t.newRange.to<=o.newRange.to))}function Vf(n){let{mapping:e,steps:t}=n,r=[];return e.maps.forEach((i,o)=>{let s=[];if(i.ranges.length)i.forEach((l,a)=>{s.push({from:l,to:a})});else{let{from:l,to:a}=t[o];if(l===void 0||a===void 0)return;s.push({from:l,to:a})}s.forEach(({from:l,to:a})=>{let c=e.slice(o).map(l,-1),u=e.slice(o).map(a),f=e.invert().map(c,-1),d=e.invert().map(u);r.push({oldRange:{from:f,to:d},newRange:{from:c,to:u}})})}),Vy(r)}function mo(n,e,t){let r=[];return n===e?t.resolve(n).marks().forEach(i=>{let o=t.resolve(n),s=jl(o,i.type);s&&r.push({mark:i,...s})}):t.nodesBetween(n,e,(i,o)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(s=>({from:o,to:o+i.nodeSize,mark:s})))}),r}function oo(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{let i=n.find(o=>o.type===e&&o.name===r);return i?i.attribute.keepOnSplit:!1}))}function $l(n,e,t={}){let{empty:r,ranges:i}=n.selection,o=e?Jt(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(f=>o?o.name===f.type.name:!0).find(f=>so(f.attrs,t,{strict:!1}));let s=0,l=[];if(i.forEach(({$from:f,$to:d})=>{let p=f.pos,h=d.pos;n.doc.nodesBetween(p,h,(m,g)=>{if(!m.isText&&!m.marks.length)return;let b=Math.max(p,g),C=Math.min(h,g+m.nodeSize),v=C-b;s+=v,l.push(...m.marks.map(y=>({mark:y,from:b,to:C})))})}),s===0)return!1;let a=l.filter(f=>o?o.name===f.mark.type.name:!0).filter(f=>so(f.mark.attrs,t,{strict:!1})).reduce((f,d)=>f+d.to-d.from,0),c=l.filter(f=>o?f.mark.type!==o&&f.mark.type.excludes(o):!0).reduce((f,d)=>f+d.to-d.from,0);return(a>0?a+c:a)>=s}function jy(n,e,t={}){if(!e)return Hr(n,null,t)||$l(n,null,t);let r=ho(e,n.schema);return r==="node"?Hr(n,e,t):r==="mark"?$l(n,e,t):!1}function Of(n,e){let{nodeExtensions:t}=uo(e),r=t.find(s=>s.name===n);if(!r)return!1;let i={name:r.name,options:r.options,storage:r.storage},o=$(O(r,"group",i));return typeof o!="string"?!1:o.split(" ").includes("list")}function ql(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var r;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return/^\s*$/m.test((r=n.text)!==null&&r!==void 0?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let i=!0;return n.content.forEach(o=>{i!==!1&&(ql(o,{ignoreWhitespace:t,checkChildren:e})||(i=!1))}),i}return!1}function go(n){return n instanceof D}function jf(n,e,t){let i=n.state.doc.content.size,o=Rt(e,0,i),s=Rt(t,0,i),l=n.coordsAtPos(o),a=n.coordsAtPos(s,-1),c=Math.min(l.top,a.top),u=Math.max(l.bottom,a.bottom),f=Math.min(l.left,a.left),d=Math.max(l.right,a.right),p=d-f,h=u-c,b={top:c,bottom:u,left:f,right:d,width:p,height:h,x:f,y:c};return{...b,toJSON:()=>b}}function Wy(n,e,t){var r;let{selection:i}=e,o=null;if(po(i)&&(o=i.$cursor),o){let l=(r=n.storedMarks)!==null&&r!==void 0?r:o.marks();return!!t.isInSet(l)||!l.some(a=>a.type.excludes(t))}let{ranges:s}=i;return s.some(({$from:l,$to:a})=>{let c=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,a.pos,(u,f,d)=>{if(c)return!1;if(u.isInline){let p=!d||d.type.allowsMarkType(t),h=!!t.isInSet(u.marks)||!u.marks.some(m=>m.type.excludes(t));c=p&&h}return!c}),c})}var _y=(n,e={})=>({tr:t,state:r,dispatch:i})=>{let{selection:o}=t,{empty:s,ranges:l}=o,a=Jt(n,r.schema);if(i)if(s){let c=$f(r,a);t.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{let u=c.$from.pos,f=c.$to.pos;r.doc.nodesBetween(u,f,(d,p)=>{let h=Math.max(p,u),m=Math.min(p+d.nodeSize,f);d.marks.find(b=>b.type===a)?d.marks.forEach(b=>{a===b.type&&t.addMark(h,m,a.create({...b.attrs,...e}))}):t.addMark(h,m,a.create(e))})});return Wy(r,t,a)},qy=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),Uy=(n,e={})=>({state:t,dispatch:r,chain:i})=>{let o=me(n,t.schema),s;return t.selection.$anchor.sameParent(t.selection.$head)&&(s=t.selection.$anchor.parent.attrs),o.isTextblock?i().command(({commands:l})=>Ol(o,{...s,...e})(t)?!0:l.clearNodes()).command(({state:l})=>Ol(o,{...s,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Ky=n=>({tr:e,dispatch:t})=>{if(t){let{doc:r}=e,i=Rt(n,0,r.content.size),o=D.create(r,i);e.setSelection(o)}return!0},Jy=n=>({tr:e,dispatch:t})=>{if(t){let{doc:r}=e,{from:i,to:o}=typeof n=="number"?{from:n,to:n}:n,s=P.atStart(r).from,l=P.atEnd(r).to,a=Rt(i,s,l),c=Rt(o,s,l),u=P.create(r,a,c);e.setSelection(u)}return!0},Gy=n=>({state:e,dispatch:t})=>{let r=me(n,e.schema);return vf(r)(e,t)};function Af(n,e){let t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){let r=t.filter(i=>e?.includes(i.type.name));n.tr.ensureMarks(r)}}var Yy=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:i})=>{let{selection:o,doc:s}=e,{$from:l,$to:a}=o,c=i.extensionManager.attributes,u=oo(c,l.node().type.name,l.node().attrs);if(o instanceof D&&o.node.isBlock)return!l.parentOffset||!Ue(s,l.pos)?!1:(r&&(n&&Af(t,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;let f=a.parentOffset===a.parent.content.size,d=l.depth===0?void 0:By(l.node(-1).contentMatchAt(l.indexAfter(-1))),p=f&&d?[{type:d,attrs:u}]:void 0,h=Ue(e.doc,e.mapping.map(l.pos),1,p);if(!p&&!h&&Ue(e.doc,e.mapping.map(l.pos),1,d?[{type:d}]:void 0)&&(h=!0,p=d?[{type:d,attrs:u}]:void 0),r){if(h&&(o instanceof P&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,p),d&&!f&&!l.parentOffset&&l.parent.type!==d)){let m=e.mapping.map(l.before()),g=e.doc.resolve(m);l.node(-1).canReplaceWith(g.index(),g.index()+1,d)&&e.setNodeMarkup(e.mapping.map(l.before()),d)}n&&Af(t,i.extensionManager.splittableMarks),e.scrollIntoView()}return h},Xy=(n,e={})=>({tr:t,state:r,dispatch:i,editor:o})=>{var s;let l=me(n,r.schema),{$from:a,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||a.depth<2||!a.sameParent(c))return!1;let f=a.node(-1);if(f.type!==l)return!1;let d=o.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(i){let b=w.empty,C=a.index(-1)?1:a.index(-2)?2:3;for(let A=a.depth-C;A>=a.depth-3;A-=1)b=w.from(a.node(A).copy(b));let v=a.indexAfter(-1){if(S>-1)return!1;A.isTextblock&&A.content.size===0&&(S=R+1)}),S>-1&&t.setSelection(P.near(t.doc.resolve(S))),t.scrollIntoView()}return!0}let p=c.pos===a.end()?f.contentMatchAt(0).defaultType:null,h={...oo(d,f.type.name,f.attrs),...e},m={...oo(d,a.node().type.name,a.node().attrs),...e};t.delete(a.pos,c.pos);let g=p?[{type:l,attrs:h},{type:p,attrs:m}]:[{type:l,attrs:h}];if(!Ue(t.doc,a.pos,2))return!1;if(i){let{selection:b,storedMarks:C}=r,{splittableMarks:v}=o.extensionManager,y=C||b.$to.parentOffset&&b.$from.marks();if(t.split(a.pos,2,g).scrollIntoView(),!y||!i)return!0;let T=y.filter(x=>v.includes(x.type.name));t.ensureMarks(T)}return!0},Dl=(n,e)=>{let t=Wl(s=>s.type===e)(n.selection);if(!t)return!0;let r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;let i=n.doc.nodeAt(r);return t.node.type===i?.type&&ot(n.doc,t.pos)&&n.join(t.pos),!0},Rl=(n,e)=>{let t=Wl(s=>s.type===e)(n.selection);if(!t)return!0;let r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;let i=n.doc.nodeAt(r);return t.node.type===i?.type&&ot(n.doc,r)&&n.join(r),!0},Qy=(n,e,t,r={})=>({editor:i,tr:o,state:s,dispatch:l,chain:a,commands:c,can:u})=>{let{extensions:f,splittableMarks:d}=i.extensionManager,p=me(n,s.schema),h=me(e,s.schema),{selection:m,storedMarks:g}=s,{$from:b,$to:C}=m,v=b.blockRange(C),y=g||m.$to.parentOffset&&m.$from.marks();if(!v)return!1;let T=Wl(x=>Of(x.type.name,f))(m);if(v.depth>=1&&T&&v.depth-T.depth<=1){if(T.node.type===p)return c.liftListItem(h);if(Of(T.node.type.name,f)&&p.validContent(T.node.content)&&l)return a().command(()=>(o.setNodeMarkup(T.pos,p),!0)).command(()=>Dl(o,p)).command(()=>Rl(o,p)).run()}return!t||!y||!l?a().command(()=>u().wrapInList(p,r)?!0:c.clearNodes()).wrapInList(p,r).command(()=>Dl(o,p)).command(()=>Rl(o,p)).run():a().command(()=>{let x=u().wrapInList(p,r),S=y.filter(A=>d.includes(A.type.name));return o.ensureMarks(S),x?!0:c.clearNodes()}).wrapInList(p,r).command(()=>Dl(o,p)).command(()=>Rl(o,p)).run()},Zy=(n,e={},t={})=>({state:r,commands:i})=>{let{extendEmptyMarkRange:o=!1}=t,s=Jt(n,r.schema);return $l(r,s,e)?i.unsetMark(s,{extendEmptyMarkRange:o}):i.setMark(s,e)},e0=(n,e,t={})=>({state:r,commands:i})=>{let o=me(n,r.schema),s=me(e,r.schema),l=Hr(r,o,t),a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?i.setNode(s,a):i.setNode(o,{...a,...t})},t0=(n,e={})=>({state:t,commands:r})=>{let i=me(n,t.schema);return Hr(t,i,e)?r.lift(i):r.wrapIn(i,e)},n0=()=>({state:n,dispatch:e})=>{let t=n.plugins;for(let r=0;r=0;a-=1)s.step(l.steps[a].invert(l.docs[a]));if(o.text){let a=s.doc.resolve(o.from).marks();s.replaceWith(o.from,o.to,n.schema.text(o.text,a))}else s.delete(o.from,o.to)}return!0}}return!1},r0=()=>({tr:n,dispatch:e})=>{let{selection:t}=n,{empty:r,ranges:i}=t;return r||e&&i.forEach(o=>{n.removeMark(o.$from.pos,o.$to.pos)}),!0},i0=(n,e={})=>({tr:t,state:r,dispatch:i})=>{var o;let{extendEmptyMarkRange:s=!1}=e,{selection:l}=t,a=Jt(n,r.schema),{$from:c,empty:u,ranges:f}=l;if(!i)return!0;if(u&&s){let{from:d,to:p}=l,h=(o=c.marks().find(g=>g.type===a))===null||o===void 0?void 0:o.attrs,m=jl(c,a,h);m&&(d=m.from,p=m.to),t.removeMark(d,p,a)}else f.forEach(d=>{t.removeMark(d.$from.pos,d.$to.pos,a)});return t.removeStoredMark(a),!0},o0=(n,e={})=>({tr:t,state:r,dispatch:i})=>{let o=null,s=null,l=ho(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(o=me(n,r.schema)),l==="mark"&&(s=Jt(n,r.schema)),i&&t.selection.ranges.forEach(a=>{let c=a.$from.pos,u=a.$to.pos,f,d,p,h;t.selection.empty?r.doc.nodesBetween(c,u,(m,g)=>{o&&o===m.type&&(p=Math.max(g,c),h=Math.min(g+m.nodeSize,u),f=g,d=m)}):r.doc.nodesBetween(c,u,(m,g)=>{g=c&&g<=u&&(o&&o===m.type&&t.setNodeMarkup(g,void 0,{...m.attrs,...e}),s&&m.marks.length&&m.marks.forEach(b=>{if(s===b.type){let C=Math.max(g,c),v=Math.min(g+m.nodeSize,u);t.addMark(C,v,s.create({...b.attrs,...e}))}}))}),d&&(f!==void 0&&t.setNodeMarkup(f,void 0,{...d.attrs,...e}),s&&d.marks.length&&d.marks.forEach(m=>{s===m.type&&t.addMark(p,h,s.create({...m.attrs,...e}))}))}),!0):!1},s0=(n,e={})=>({state:t,dispatch:r})=>{let i=me(n,t.schema);return bf(i,e)(t,r)},l0=(n,e={})=>({state:t,dispatch:r})=>{let i=me(n,t.schema);return kf(i,e)(t,r)},a0=Object.freeze({__proto__:null,blur:Ug,clearContent:Kg,clearNodes:Jg,command:Gg,createParagraphNear:Yg,cut:Xg,deleteCurrentNode:Qg,deleteNode:Zg,deleteRange:ey,deleteSelection:ty,enter:ny,exitCode:ry,extendMarkRange:iy,first:oy,focus:ly,forEach:ay,insertContent:cy,insertContentAt:dy,joinBackward:my,joinDown:hy,joinForward:gy,joinItemBackward:yy,joinItemForward:by,joinTextblockBackward:ky,joinTextblockForward:xy,joinUp:py,keyboardShortcut:wy,lift:Sy,liftEmptyBlock:Cy,liftListItem:Ey,newlineInCode:Ty,resetAttributes:My,scrollIntoView:Oy,selectAll:Ay,selectNodeBackward:Ny,selectNodeForward:Dy,selectParentNode:Ry,selectTextblockEnd:Iy,selectTextblockStart:Py,setContent:Ly,setMark:_y,setMeta:qy,setNode:Uy,setNodeSelection:Ky,setTextSelection:Jy,sinkListItem:Gy,splitBlock:Yy,splitListItem:Xy,toggleList:Qy,toggleMark:Zy,toggleNode:e0,toggleWrap:t0,undoInputRule:n0,unsetAllMarks:r0,unsetMark:i0,updateAttributes:o0,wrapIn:s0,wrapInList:l0}),c0=ie.create({name:"commands",addCommands(){return{...a0}}}),u0=ie.create({name:"drop",addProseMirrorPlugins(){return[new q({key:new re("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),f0=ie.create({name:"editable",addProseMirrorPlugins(){return[new q({key:new re("editable"),props:{editable:()=>this.editor.options.editable}})]}}),d0=new re("focusEvents"),p0=ie.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:n}=this;return[new q({key:d0,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;let r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;let r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),h0=ie.create({name:"keymap",addKeyboardShortcuts(){let n=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:l})=>{let{selection:a,doc:c}=l,{empty:u,$anchor:f}=a,{pos:d,parent:p}=f,h=f.parent.isTextblock&&d>0?l.doc.resolve(d-1):f,m=h.parent.type.spec.isolating,g=f.pos-f.parentOffset,b=m&&h.parent.childCount===1?g===f.pos:L.atStart(c).from===d;return!u||!p.type.isTextblock||p.textContent.length||!b||b&&f.parent.type.name==="paragraph"?!1:s.clearNodes()}),()=>s.deleteSelection(),()=>s.joinBackward(),()=>s.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:s})=>[()=>s.deleteSelection(),()=>s.deleteCurrentNode(),()=>s.joinForward(),()=>s.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},o={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return lo()||zf()?o:i},addProseMirrorPlugins(){return[new q({key:new re("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(m=>m.getMeta("composition")))return;let r=n.some(m=>m.docChanged)&&!e.doc.eq(t.doc),i=n.some(m=>m.getMeta("preventClearDocument"));if(!r||i)return;let{empty:o,from:s,to:l}=e.selection,a=L.atStart(e.doc).from,c=L.atEnd(e.doc).to;if(o||!(s===a&&l===c)||!ql(t.doc))return;let d=t.tr,p=co({state:t,transaction:d}),{commands:h}=new tr({editor:this.editor,state:p});if(h.clearNodes(),!!d.steps.length)return d}})]}}),m0=ie.create({name:"paste",addProseMirrorPlugins(){return[new q({key:new re("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),g0=ie.create({name:"tabindex",addProseMirrorPlugins(){return[new q({key:new re("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});var Fl=class n{get name(){return this.node.type.name}constructor(e,t,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,this.currentNode=i}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;let e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new n(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new n(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new n(e,this.editor)}get children(){let e=[];return this.node.content.forEach((t,r)=>{let i=t.isBlock&&!t.isTextblock,o=t.isAtom&&!t.isText,s=this.pos+r+(o?0:1);if(s<0||s>this.resolvedPos.doc.nodeSize-2)return;let l=this.resolvedPos.doc.resolve(s);if(!i&&l.depth<=this.depth)return;let a=new n(l,this.editor,i,i?t:null);i&&(a.actualDepth=this.depth+1),e.push(new n(l,this.editor,i,i?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(t).length>0){let o=i.node.attrs,s=Object.keys(t);for(let l=0;l{r&&i.length>0||(s.node.type.name===e&&o.every(a=>t[a]===s.node.attrs[a])&&i.push(s),!(r&&i.length>0)&&(i=i.concat(s.querySelectorAll(e,t,r))))}),i}setAttribute(e){let{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},y0=`.ProseMirror { + position: relative; +} + +.ProseMirror { + word-wrap: break-word; + white-space: pre-wrap; + white-space: break-spaces; + -webkit-font-variant-ligatures: none; + font-variant-ligatures: none; + font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */ +} + +.ProseMirror [contenteditable="false"] { + white-space: normal; +} + +.ProseMirror [contenteditable="false"] [contenteditable="true"] { + white-space: pre-wrap; +} + +.ProseMirror pre { + white-space: pre-wrap; +} + +img.ProseMirror-separator { + display: inline !important; + border: none !important; + margin: 0 !important; + width: 0 !important; + height: 0 !important; +} + +.ProseMirror-gapcursor { + display: none; + pointer-events: none; + position: absolute; + margin: 0; +} + +.ProseMirror-gapcursor:after { + content: ""; + display: block; + position: absolute; + top: -2px; + width: 20px; + border-top: 1px solid black; + animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite; +} + +@keyframes ProseMirror-cursor-blink { + to { + visibility: hidden; + } +} + +.ProseMirror-hideselection *::selection { + background: transparent; +} + +.ProseMirror-hideselection *::-moz-selection { + background: transparent; +} + +.ProseMirror-hideselection * { + caret-color: transparent; +} + +.ProseMirror-focused .ProseMirror-gapcursor { + display: block; +} + +.tippy-box[data-animation=fade][data-state=hidden] { + opacity: 0 +}`;function b0(n,e,t){let r=document.querySelector(`style[data-tiptap-style${t?`-${t}`:""}]`);if(r!==null)return r;let i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute(`data-tiptap-style${t?`-${t}`:""}`,""),i.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(i),i}var ao=class extends Il{constructor(e={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:t})=>{throw t},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),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)),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=b0(y0,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,t){let r=Df(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],i=this.state.reconfigure({plugins:r});return this.view.updateState(i),i}unregisterPlugin(e){if(this.isDestroyed)return;let t=this.state.plugins,r=t;if([].concat(e).forEach(o=>{let s=typeof o=="string"?`${o}$`:o.key;r=r.filter(l=>!l.key.startsWith(s))}),t.length===r.length)return;let i=this.state.reconfigure({plugins:r});return this.view.updateState(i),i}createExtensionManager(){var e,t;let i=[...this.options.enableCoreExtensions?[f0,qg.configure({blockSeparator:(t=(e=this.options.coreExtensionOptions)===null||e===void 0?void 0:e.clipboardTextSerializer)===null||t===void 0?void 0:t.blockSeparator}),c0,p0,h0,g0,u0,m0].filter(o=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[o.name]!==!1:!0):[],...this.options.extensions].filter(o=>["extension","node","mark"].includes(o?.type));this.extensionManager=new Bl(i,this)}createCommandManager(){this.commandManager=new tr({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var e;let t;try{t=zl(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(s){if(!(s instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(s.message))throw s;this.emit("contentError",{editor:this,error:s,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(l=>l.name!=="collaboration"),this.createExtensionManager()}}),t=zl(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}let r=Lf(t,this.options.autofocus);this.view=new Br(this.options.element,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)===null||e===void 0?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:Fi.create({doc:t,selection:r||void 0})});let i=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(i),this.createNodeViews(),this.prependClass();let o=this.view.dom;o.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;let t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(s=>{var l;return(l=this.capturedTransaction)===null||l===void 0?void 0:l.step(s)});return}let t=this.state.apply(e),r=!this.state.selection.eq(t.selection);this.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});let i=e.getMeta("focus"),o=e.getMeta("blur");i&&this.emit("focus",{editor:this,event:i.event,transaction:e}),o&&this.emit("blur",{editor:this,event:o.event,transaction:e}),!(!e.docChanged||e.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return _l(this.state,e)}isActive(e,t){let r=typeof e=="string"?e:null,i=typeof e=="string"?t:e;return jy(this.state,r,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Hl(this.state.doc.content,this.schema)}getText(e){let{blockSeparator:t=` + +`,textSerializers:r={}}=e||{};return $y(this.state.doc,{blockSeparator:t,textSerializers:{...If(this.schema),...r}})}get isEmpty(){return ql(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){let e=this.view.dom;e&&e.editor&&delete e.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}$node(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(e,t))||null}$nodes(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(e,t))||null}$pos(e){let t=this.state.doc.resolve(e);return new Fl(t,this)}get $doc(){return this.$pos(0)}};function ht(n){return new nr({find:n.find,handler:({state:e,range:t,match:r})=>{let i=$(n.getAttributes,void 0,r);if(i===!1||i===null)return null;let{tr:o}=e,s=r[r.length-1],l=r[0];if(s){let a=l.search(/\S/),c=t.from+l.indexOf(s),u=c+s.length;if(mo(t.from,t.to,e.doc).filter(p=>p.mark.type.excluded.find(m=>m===n.type&&m!==p.mark.type)).filter(p=>p.to>c).length)return null;ut.from&&o.delete(t.from+a,c);let d=t.from+a+s.length;o.addMark(t.from+a,d,n.type.create(i||{})),o.removeStoredMark(n.type)}}})}function Wf(n){return new nr({find:n.find,handler:({state:e,range:t,match:r})=>{let i=$(n.getAttributes,void 0,r)||{},{tr:o}=e,s=t.from,l=t.to,a=n.type.create(i);if(r[1]){let c=r[0].lastIndexOf(r[1]),u=s+c;u>l?u=l:l=u+r[1].length;let f=r[0][r[0].length-1];o.insertText(f,s+r[0].length-1),o.replaceWith(u,l,a)}else if(r[0]){let c=n.type.isInline?s:s-1;o.insert(c,n.type.create(i)).delete(o.mapping.map(s),o.mapping.map(l))}o.scrollIntoView()}})}function Vr(n){return new nr({find:n.find,handler:({state:e,range:t,match:r})=>{let i=e.doc.resolve(t.from),o=$(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,o)}})}function Gt(n){return new nr({find:n.find,handler:({state:e,range:t,match:r,chain:i})=>{let o=$(n.getAttributes,void 0,r)||{},s=e.tr.delete(t.from,t.to),a=s.doc.resolve(t.from).blockRange(),c=a&&_n(a,n.type,o);if(!c)return null;if(s.wrap(a,c),n.keepMarks&&n.editor){let{selection:f,storedMarks:d}=e,{splittableMarks:p}=n.editor.extensionManager,h=d||f.$to.parentOffset&&f.$from.marks();if(h){let m=h.filter(g=>p.includes(g.type.name));s.ensureMarks(m)}}if(n.keepAttributes){let f=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(f,o).run()}let u=s.doc.resolve(t.from-1).nodeBefore;u&&u.type===n.type&&ot(s.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,u))&&s.join(t.from-1)}})}var Z=class n{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=$(O(this,"addOptions",{name:this.name}))),this.storage=$(O(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new n(e)}configure(e={}){let t=this.extend({...this.config,addOptions:()=>fo(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){let t=new n(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=$(O(t,"addOptions",{name:t.name})),t.storage=$(O(t,"addStorage",{name:t.name,options:t.options})),t}};function Qe(n){return new Ll({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:i})=>{let o=$(n.getAttributes,void 0,r,i);if(o===!1||o===null)return null;let{tr:s}=e,l=r[r.length-1],a=r[0],c=t.to;if(l){let u=a.search(/\S/),f=t.from+a.indexOf(l),d=f+l.length;if(mo(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(g=>g===n.type&&g!==h.mark.type)).filter(h=>h.to>f).length)return null;dt.from&&s.delete(t.from+u,f),c=t.from+u+l.length,s.addMark(t.from+u,c,n.type.create(o||{})),s.removeStoredMark(n.type)}}})}function _f(n,e){let{selection:t}=n,{$from:r}=t;if(t instanceof D){let o=r.index();return r.parent.canReplaceWith(o,o+1,e)}let i=r.depth;for(;i>=0;){let o=r.index(i);if(r.node(i).contentMatchAt(o).matchType(e))return!0;i-=1}return!1}function qf(n){return n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var k0=/^\s*>\s$/,Uf=Z.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return["blockquote",j(this.options.HTMLAttributes,n),0]},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Gt({find:k0,type:this.type})]}});var x0=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,v0=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,w0=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,S0=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Kf=Le.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return["strong",j(this.options.HTMLAttributes,n),0]},addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[ht({find:x0,type:this.type}),ht({find:w0,type:this.type})]},addPasteRules(){return[Qe({find:v0,type:this.type}),Qe({find:S0,type:this.type})]}});var C0="listItem",Jf="textStyle",Gf=/^\s*([-+*])\s$/,Yf=Z.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",j(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(C0,this.editor.getAttributes(Jf)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=Gt({find:Gf,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Gt({find:Gf,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Jf),editor:this.editor})),[n]}});var E0=/(^|[^`])`([^`]+)`(?!`)/,T0=/(^|[^`])`([^`]+)`(?!`)/g,Xf=Le.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",j(this.options.HTMLAttributes,n),0]},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[ht({find:E0,type:this.type})]},addPasteRules(){return[Qe({find:T0,type:this.type})]}});var M0=/^```([a-z]+)?[\s\n]$/,O0=/^~~~([a-z]+)?[\s\n]$/,Qf=Z.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;let{languageClassPrefix:t}=this.options,o=[...((e=n.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(s=>s.startsWith(t)).map(s=>s.replace(t,""))[0];return o||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",j(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:e}=n,{selection:t}=e,{$from:r,empty:i}=t;if(!i||r.parent.type!==this.type)return!1;let o=r.parentOffset===r.parent.nodeSize-2,s=r.parent.textContent.endsWith(` + +`);return!o||!s?!1:n.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;let{state:e}=n,{selection:t,doc:r}=e,{$from:i,empty:o}=t;if(!o||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;let l=i.after();return l===void 0?!1:r.nodeAt(l)?n.commands.command(({tr:c})=>(c.setSelection(L.near(r.resolve(l))),!0)):n.commands.exitCode()}}},addInputRules(){return[Vr({find:M0,type:this.type,getAttributes:n=>({language:n[1]})}),Vr({find:O0,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new q({key:new re("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;let t=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,o=i?.mode;if(!t||!o)return!1;let{tr:s,schema:l}=n.state,a=l.text(t.replace(/\r\n?/g,` +`));return s.replaceSelectionWith(this.type.create({language:o},a)),s.selection.$from.parent.type!==this.type&&s.setSelection(P.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),n.dispatch(s),!0}}})]}});var Zf=Z.create({name:"doc",topNode:!0,content:"block+"});function ed(n={}){return new q({view(e){return new Ul(e,n)}})}var Ul=class{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let o=s=>{this[i](s)};return e.dom.addEventListener(i,o),{name:i,handler:o}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,i=this.editorView.dom,o=i.getBoundingClientRect(),s=o.width/i.offsetWidth,l=o.height/i.offsetHeight;if(t){let f=e.nodeBefore,d=e.nodeAfter;if(f||d){let p=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(p){let h=p.getBoundingClientRect(),m=f?h.bottom:h.top;f&&d&&(m=(m+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;r={left:h.left,right:h.right,top:m-g,bottom:m+g}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),d=this.width/2*s;r={left:f.left-d,right:f.left+d,top:f.top,bottom:f.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let f=a.getBoundingClientRect(),d=f.width/a.offsetWidth,p=f.height/a.offsetHeight;c=f.left-a.scrollLeft*d,u=f.top-a.scrollTop*p}this.element.style.left=(r.left-c)/s+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=r&&r.type.spec.disableDropCursor,o=typeof i=="function"?i(this.editorView,t,e):i;if(t&&!o){let s=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Li(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}};var td=ie.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[ed(this.options)]}});var Oe=class n extends L{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return n.valid(r)?new n(r):L.near(r)}content(){return M.empty}eq(e){return e instanceof n&&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 n(e.resolve(t.pos))}getBookmark(){return new Kl(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!A0(e)||!N0(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&&n.valid(e))return e;let i=e.pos,o=null;for(let s=e.depth;;s--){let l=e.node(s);if(t>0?e.indexAfter(s)0){o=l.child(t>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=t;let a=e.doc.resolve(i);if(n.valid(a))return a}for(;;){let s=t>0?o.firstChild:o.lastChild;if(!s){if(o.isAtom&&!o.isText&&!D.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*t),r=!1;continue e}break}o=s,i+=t;let l=e.doc.resolve(i);if(n.valid(l))return l}return null}}};Oe.prototype.visible=!1;Oe.findFrom=Oe.findGapCursorFrom;L.jsonID("gapcursor",Oe);var Kl=class n{constructor(e){this.pos=e}map(e){return new n(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return Oe.valid(t)?new Oe(t):L.near(t)}};function nd(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function A0(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||nd(i.type))return!0;if(i.inlineContent)return!1}}return!0}function N0(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||nd(i.type))return!0;if(i.inlineContent)return!1}}return!0}function rd(){return new q({props:{decorations:P0,createSelectionBetween(n,e,t){return e.pos==t.pos&&Oe.valid(t)?new Oe(t):null},handleClick:R0,handleKeyDown:D0,handleDOMEvents:{beforeinput:I0}}})}var D0=pl({ArrowLeft:yo("horiz",-1),ArrowRight:yo("horiz",1),ArrowUp:yo("vert",-1),ArrowDown:yo("vert",1)});function yo(n,e){let t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,o){let s=r.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof P){if(!o.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=Oe.findGapCursorFrom(l,e,a);return c?(i&&i(r.tr.setSelection(new Oe(c))),!0):!1}}function R0(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!Oe.valid(r))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&D.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new Oe(r))),!0)}function I0(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof Oe))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 s=r.length-1;s>=0;s--)i=w.from(r[s].createAndFill(null,i));let o=n.state.tr.replace(t.pos,t.pos,new M(i,0,0));return o.setSelection(P.near(o.doc.resolve(t.pos+1))),n.dispatch(o),!1}function P0(n){if(!(n.selection instanceof Oe))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Te.create(n.doc,[Xe.widget(n.selection.head,e,{key:"gapcursor"})])}var id=ie.create({name:"gapCursor",addProseMirrorPlugins(){return[rd()]},extendNodeSchema(n){var e;let t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=$(O(n,"allowGapCursor",t)))!==null&&e!==void 0?e:null}}});var od=Z.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",j(this.options.HTMLAttributes,n)]},renderText(){return` +`},addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{let{selection:i,storedMarks:o}=t;if(i.$from.parent.type.spec.isolating)return!1;let{keepMarks:s}=this.options,{splittableMarks:l}=r.extensionManager,a=o||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&a&&s){let f=a.filter(d=>l.includes(d.type.name));c.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var sd=Z.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]}`,j(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>Vr({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}});var bo=200,we=function(){};we.prototype.append=function(e){return e.length?(e=we.from(e),!this.length&&e||e.length=t?we.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};we.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};we.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};we.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(o,s){return i.push(e(o,s))},t,r),i};we.from=function(e){return e instanceof we?e:e&&e.length?new ld(e):we.empty};var ld=function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,o){return i==0&&o==this.length?this:new e(this.values.slice(i,o))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,o,s,l){for(var a=o;a=s;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=bo)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=bo)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(we);we.empty=new ld([]);var L0=function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return rl&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,o)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,o,s){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(o,l)-l,s+l)===!1||o=o?this.right.slice(r-o,i-o):this.left.slice(r,o).append(this.right.slice(0,i-o))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(we),Jl=we;var B0=500,kn=class n{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,o;t&&(i=this.remapping(r,this.items.length),o=i.maps.length);let s=e.tr,l,a,c=[],u=[];return this.items.forEach((f,d)=>{if(!f.step){i||(i=this.remapping(r,d+1),o=i.maps.length),o--,u.push(f);return}if(i){u.push(new mt(f.map));let p=f.step.map(i.slice(o)),h;p&&s.maybeStep(p).doc&&(h=s.mapping.maps[s.mapping.maps.length-1],c.push(new mt(h,void 0,void 0,c.length+u.length))),o--,h&&i.appendMap(h,o)}else s.maybeStep(f.step);if(f.selection)return l=i?f.selection.map(i.slice(o)):f.selection,a=new n(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,t,r,i){let o=[],s=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let u=0;u$0&&(l=z0(l,c),s-=c),new n(l.append(o),s)}remapping(e,t){let r=new Er;return this.items.forEach((i,o)=>{let s=i.mirrorOffset!=null&&o-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,s)},e,t),r}addMaps(e){return this.eventCount==0?this:new n(this.items.append(e.map(t=>new mt(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-t),o=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(d=>{d.selection&&l--},i);let a=t;this.items.forEach(d=>{let p=o.getMirror(--a);if(p==null)return;s=Math.min(s,p);let h=o.maps[p];if(d.step){let m=e.steps[p].invert(e.docs[p]),g=d.selection&&d.selection.map(o.slice(a+1,p));g&&l++,r.push(new mt(h,m,g))}else r.push(new mt(h))},i);let c=[];for(let d=t;dB0&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,i=[],o=0;return this.items.forEach((s,l)=>{if(l>=e)i.push(s),s.selection&&o++;else if(s.step){let a=s.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let u=s.selection&&s.selection.map(t.slice(r));u&&o++;let f=new mt(c.invert(),a,u),d,p=i.length-1;(d=i.length&&i[p].merge(f))?i[p]=d:i.push(f)}}else s.map&&r--},this.items.length,0),new n(Jl.from(i.reverse()),o)}};kn.empty=new kn(Jl.empty,0);function z0(n,e){let t;return n.forEach((r,i)=>{if(r.selection&&e--==0)return t=i,!1}),n.slice(t)}var mt=class n{constructor(e,t,r,i){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new n(t.getMap().invert(),t,this.selection)}}},gt=class{constructor(e,t,r,i,o){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=i,this.prevComposition=o}},$0=20;function F0(n,e,t,r){let i=t.getMeta(bn),o;if(i)return i.historyState;t.getMeta(j0)&&(n=new gt(n.done,n.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(s&&s.getMeta(bn))return s.getMeta(bn).redo?new gt(n.done.addTransform(t,void 0,r,ko(e)),n.undone,ad(t.mapping.maps),n.prevTime,n.prevComposition):new gt(n.done,n.undone.addTransform(t,void 0,r,ko(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!s&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!H0(t,n.prevRanges)),c=s?Gl(n.prevRanges,t.mapping):ad(t.mapping.maps);return new gt(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,ko(e)),kn.empty,c,t.time,l??n.prevComposition)}else return(o=t.getMeta("rebased"))?new gt(n.done.rebased(t,o),n.undone.rebased(t,o),Gl(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new gt(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Gl(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function H0(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,i)=>{for(let o=0;o=e[o]&&(t=!0)}),t}function ad(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,i,o,s)=>e.push(o,s));return e}function Gl(n,e){if(!n)return null;let t=[];for(let r=0;r{let i=bn.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(r){let o=V0(i,t,n);o&&r(e?o.scrollIntoView():o)}return!0}}var Xl=xo(!1,!0),Ql=xo(!0,!0),Kv=xo(!1,!1),Jv=xo(!0,!1);var fd=ie.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>Xl(n,e),redo:()=>({state:n,dispatch:e})=>Ql(n,e)}},addProseMirrorPlugins(){return[ud(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});var dd=Z.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",j(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{if(!_f(e,e.schema.nodes[this.name]))return!1;let{selection:t}=e,{$from:r,$to:i}=t,o=n();return r.parentOffset===0?o.insertContentAt({from:Math.max(r.pos-1,0),to:i.pos},{type:this.name}):go(t)?o.insertContentAt(i.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({tr:s,dispatch:l})=>{var a;if(l){let{$to:c}=s.selection,u=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?s.setSelection(P.create(s.doc,c.pos+1)):c.nodeAfter.isBlock?s.setSelection(D.create(s.doc,c.pos)):s.setSelection(P.create(s.doc,c.pos));else{let f=(a=c.parent.type.contentMatch.defaultType)===null||a===void 0?void 0:a.create();f&&(s.insert(u,f),s.setSelection(P.create(s.doc,u+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Wf({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});var W0=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,_0=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,q0=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,U0=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,pd=Le.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",j(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[ht({find:W0,type:this.type}),ht({find:q0,type:this.type})]},addPasteRules(){return[Qe({find:_0,type:this.type}),Qe({find:U0,type:this.type})]}});var hd=Z.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",j(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}});var K0="listItem",md="textStyle",gd=/^(\d+)\.\s$/,yd=Z.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){let{start:e,...t}=n;return e===1?["ol",j(this.options.HTMLAttributes,t),0]:["ol",j(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(K0,this.editor.getAttributes(md)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=Gt({find:gd,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Gt({find:gd,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(md)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}});var bd=Z.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",j(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var J0=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,G0=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,kd=Le.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",j(this.options.HTMLAttributes,n),0]},addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[ht({find:J0,type:this.type})]},addPasteRules(){return[Qe({find:G0,type:this.type})]}});var xd=Z.create({name:"text",group:"inline"});var vd=ie.create({name:"starterKit",addExtensions(){let n=[];return this.options.bold!==!1&&n.push(Kf.configure(this.options.bold)),this.options.blockquote!==!1&&n.push(Uf.configure(this.options.blockquote)),this.options.bulletList!==!1&&n.push(Yf.configure(this.options.bulletList)),this.options.code!==!1&&n.push(Xf.configure(this.options.code)),this.options.codeBlock!==!1&&n.push(Qf.configure(this.options.codeBlock)),this.options.document!==!1&&n.push(Zf.configure(this.options.document)),this.options.dropcursor!==!1&&n.push(td.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&n.push(id.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&n.push(od.configure(this.options.hardBreak)),this.options.heading!==!1&&n.push(sd.configure(this.options.heading)),this.options.history!==!1&&n.push(fd.configure(this.options.history)),this.options.horizontalRule!==!1&&n.push(dd.configure(this.options.horizontalRule)),this.options.italic!==!1&&n.push(pd.configure(this.options.italic)),this.options.listItem!==!1&&n.push(hd.configure(this.options.listItem)),this.options.orderedList!==!1&&n.push(yd.configure(this.options.orderedList)),this.options.paragraph!==!1&&n.push(bd.configure(this.options.paragraph)),this.options.strike!==!1&&n.push(kd.configure(this.options.strike)),this.options.text!==!1&&n.push(xd.configure(this.options.text)),n}});var wd=Le.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",j(this.options.HTMLAttributes,n),0]},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()}}});var Y0="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5m\xF6gensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",X0="\u03B5\u03BB1\u03C52\u0431\u04331\u0435\u043B3\u0434\u0435\u0442\u04384\u0435\u044E2\u043A\u0430\u0442\u043E\u043B\u0438\u043A6\u043E\u043C3\u043C\u043A\u04342\u043E\u043D1\u0441\u043A\u0432\u04306\u043E\u043D\u043B\u0430\u0439\u043D5\u0440\u04333\u0440\u0443\u04412\u04442\u0441\u0430\u0439\u04423\u0440\u04313\u0443\u043A\u04403\u049B\u0430\u04373\u0570\u0561\u05753\u05D9\u05E9\u05E8\u05D0\u05DC5\u05E7\u05D5\u05DD3\u0627\u0628\u0648\u0638\u0628\u064A5\u0631\u0627\u0645\u0643\u06485\u0644\u0627\u0631\u062F\u06464\u0628\u062D\u0631\u064A\u06465\u062C\u0632\u0627\u0626\u06315\u0633\u0639\u0648\u062F\u064A\u06296\u0639\u0644\u064A\u0627\u06465\u0645\u063A\u0631\u06285\u0645\u0627\u0631\u0627\u062A5\u06CC\u0631\u0627\u06465\u0628\u0627\u0631\u062A2\u0632\u0627\u06314\u064A\u062A\u06433\u06BE\u0627\u0631\u062A5\u062A\u0648\u0646\u06334\u0633\u0648\u062F\u0627\u06463\u0631\u064A\u06295\u0634\u0628\u0643\u06294\u0639\u0631\u0627\u06422\u06282\u0645\u0627\u06464\u0641\u0644\u0633\u0637\u064A\u06466\u0642\u0637\u06313\u0643\u0627\u062B\u0648\u0644\u064A\u06436\u0648\u06453\u0645\u0635\u06312\u0644\u064A\u0633\u064A\u06275\u0648\u0631\u064A\u062A\u0627\u0646\u064A\u06277\u0642\u06394\u0647\u0645\u0631\u0627\u06475\u067E\u0627\u06A9\u0633\u062A\u0627\u06467\u0680\u0627\u0631\u062A4\u0915\u0949\u092E3\u0928\u0947\u091F3\u092D\u093E\u0930\u09240\u092E\u094D3\u094B\u09245\u0938\u0902\u0917\u0920\u09285\u09AC\u09BE\u0982\u09B2\u09BE5\u09AD\u09BE\u09B0\u09A42\u09F0\u09A44\u0A2D\u0A3E\u0A30\u0A244\u0AAD\u0ABE\u0AB0\u0AA44\u0B2D\u0B3E\u0B30\u0B244\u0B87\u0BA8\u0BCD\u0BA4\u0BBF\u0BAF\u0BBE6\u0BB2\u0B99\u0BCD\u0B95\u0BC86\u0B9A\u0BBF\u0B99\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0BC2\u0BB0\u0BCD11\u0C2D\u0C3E\u0C30\u0C24\u0C4D5\u0CAD\u0CBE\u0CB0\u0CA44\u0D2D\u0D3E\u0D30\u0D24\u0D025\u0DBD\u0D82\u0D9A\u0DCF4\u0E04\u0E2D\u0E213\u0E44\u0E17\u0E223\u0EA5\u0EB2\u0EA73\u10D2\u10D42\u307F\u3093\u306A3\u30A2\u30DE\u30BE\u30F34\u30AF\u30E9\u30A6\u30C94\u30B0\u30FC\u30B0\u30EB4\u30B3\u30E02\u30B9\u30C8\u30A23\u30BB\u30FC\u30EB3\u30D5\u30A1\u30C3\u30B7\u30E7\u30F36\u30DD\u30A4\u30F3\u30C84\u4E16\u754C2\u4E2D\u4FE11\u56FD1\u570B1\u6587\u7F513\u4E9A\u9A6C\u900A3\u4F01\u4E1A2\u4F5B\u5C712\u4FE1\u606F2\u5065\u5EB72\u516B\u53662\u516C\u53F81\u76CA2\u53F0\u6E7E1\u70632\u5546\u57CE1\u5E971\u68072\u5609\u91CC0\u5927\u9152\u5E975\u5728\u7EBF2\u5927\u62FF2\u5929\u4E3B\u65593\u5A31\u4E502\u5BB6\u96FB2\u5E7F\u4E1C2\u5FAE\u535A2\u6148\u55842\u6211\u7231\u4F603\u624B\u673A2\u62DB\u80582\u653F\u52A11\u5E9C2\u65B0\u52A0\u57612\u95FB2\u65F6\u5C1A2\u66F8\u7C4D2\u673A\u67842\u6DE1\u9A6C\u95213\u6E38\u620F2\u6FB3\u95802\u70B9\u770B2\u79FB\u52A82\u7EC4\u7EC7\u673A\u67844\u7F51\u57401\u5E971\u7AD91\u7EDC2\u8054\u901A2\u8C37\u6B4C2\u8D2D\u72692\u901A\u8CA92\u96C6\u56E22\u96FB\u8A0A\u76C8\u79D14\u98DE\u5229\u6D663\u98DF\u54C12\u9910\u53852\u9999\u683C\u91CC\u62C93\u6E2F2\uB2F7\uB1371\uCEF42\uC0BC\uC1312\uD55C\uAD6D2",oa="numeric",sa="ascii",la="alpha",_r="asciinumeric",Wr="alphanumeric",aa="domain",Od="emoji",Q0="scheme",Z0="slashscheme",Zl="whitespace";function eb(n,e){return n in e||(e[n]=[]),e[n]}function xn(n,e,t){e[oa]&&(e[_r]=!0,e[Wr]=!0),e[sa]&&(e[_r]=!0,e[la]=!0),e[_r]&&(e[Wr]=!0),e[la]&&(e[Wr]=!0),e[Wr]&&(e[aa]=!0),e[Od]&&(e[aa]=!0);for(let r in e){let i=eb(r,t);i.indexOf(n)<0&&i.push(n)}}function tb(n,e){let t={};for(let r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function He(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}He.groups={};He.prototype={accepts(){return!!this.t},go(n){let e=this,t=e.j[n];if(t)return t;for(let r=0;rn.ta(e,t,r,i),oe=(n,e,t,r,i)=>n.tr(e,t,r,i),Sd=(n,e,t,r,i)=>n.ts(e,t,r,i),E=(n,e,t,r,i)=>n.tt(e,t,r,i),Lt="WORD",ca="UWORD",Ad="ASCIINUMERICAL",Nd="ALPHANUMERICAL",Yr="LOCALHOST",ua="TLD",fa="UTLD",Co="SCHEME",rr="SLASH_SCHEME",pa="NUM",da="WS",ha="NL",qr="OPENBRACE",Ur="CLOSEBRACE",Eo="OPENBRACKET",To="CLOSEBRACKET",Mo="OPENPAREN",Oo="CLOSEPAREN",Ao="OPENANGLEBRACKET",No="CLOSEANGLEBRACKET",Do="FULLWIDTHLEFTPAREN",Ro="FULLWIDTHRIGHTPAREN",Io="LEFTCORNERBRACKET",Po="RIGHTCORNERBRACKET",Lo="LEFTWHITECORNERBRACKET",Bo="RIGHTWHITECORNERBRACKET",zo="FULLWIDTHLESSTHAN",$o="FULLWIDTHGREATERTHAN",Fo="AMPERSAND",Ho="APOSTROPHE",Vo="ASTERISK",Xt="AT",jo="BACKSLASH",Wo="BACKTICK",_o="CARET",vn="COLON",ma="COMMA",qo="DOLLAR",yt="DOT",Uo="EQUALS",ga="EXCLAMATION",et="HYPHEN",Kr="PERCENT",Ko="PIPE",Jo="PLUS",Go="POUND",Jr="QUERY",ya="QUOTE",Dd="FULLWIDTHMIDDLEDOT",ba="SEMI",bt="SLASH",Gr="TILDE",Yo="UNDERSCORE",Rd="EMOJI",Xo="SYM",Id=Object.freeze({__proto__:null,ALPHANUMERICAL:Nd,AMPERSAND:Fo,APOSTROPHE:Ho,ASCIINUMERICAL:Ad,ASTERISK:Vo,AT:Xt,BACKSLASH:jo,BACKTICK:Wo,CARET:_o,CLOSEANGLEBRACKET:No,CLOSEBRACE:Ur,CLOSEBRACKET:To,CLOSEPAREN:Oo,COLON:vn,COMMA:ma,DOLLAR:qo,DOT:yt,EMOJI:Rd,EQUALS:Uo,EXCLAMATION:ga,FULLWIDTHGREATERTHAN:$o,FULLWIDTHLEFTPAREN:Do,FULLWIDTHLESSTHAN:zo,FULLWIDTHMIDDLEDOT:Dd,FULLWIDTHRIGHTPAREN:Ro,HYPHEN:et,LEFTCORNERBRACKET:Io,LEFTWHITECORNERBRACKET:Lo,LOCALHOST:Yr,NL:ha,NUM:pa,OPENANGLEBRACKET:Ao,OPENBRACE:qr,OPENBRACKET:Eo,OPENPAREN:Mo,PERCENT:Kr,PIPE:Ko,PLUS:Jo,POUND:Go,QUERY:Jr,QUOTE:ya,RIGHTCORNERBRACKET:Po,RIGHTWHITECORNERBRACKET:Bo,SCHEME:Co,SEMI:ba,SLASH:bt,SLASH_SCHEME:rr,SYM:Xo,TILDE:Gr,TLD:ua,UNDERSCORE:Yo,UTLD:fa,UWORD:ca,WORD:Lt,WS:da}),It=/[a-z]/,jr=/\p{L}/u,ea=/\p{Emoji}/u;var Pt=/\d/,ta=/\s/;var Cd="\r",na=` +`,nb="\uFE0F",rb="\u200D",ra="\uFFFC",vo=null,wo=null;function ib(n=[]){let e={};He.groups=e;let t=new He;vo==null&&(vo=Ed(Y0)),wo==null&&(wo=Ed(X0)),E(t,"'",Ho),E(t,"{",qr),E(t,"}",Ur),E(t,"[",Eo),E(t,"]",To),E(t,"(",Mo),E(t,")",Oo),E(t,"<",Ao),E(t,">",No),E(t,"\uFF08",Do),E(t,"\uFF09",Ro),E(t,"\u300C",Io),E(t,"\u300D",Po),E(t,"\u300E",Lo),E(t,"\u300F",Bo),E(t,"\uFF1C",zo),E(t,"\uFF1E",$o),E(t,"&",Fo),E(t,"*",Vo),E(t,"@",Xt),E(t,"`",Wo),E(t,"^",_o),E(t,":",vn),E(t,",",ma),E(t,"$",qo),E(t,".",yt),E(t,"=",Uo),E(t,"!",ga),E(t,"-",et),E(t,"%",Kr),E(t,"|",Ko),E(t,"+",Jo),E(t,"#",Go),E(t,"?",Jr),E(t,'"',ya),E(t,"/",bt),E(t,";",ba),E(t,"~",Gr),E(t,"_",Yo),E(t,"\\",jo),E(t,"\u30FB",Dd);let r=oe(t,Pt,pa,{[oa]:!0});oe(r,Pt,r);let i=oe(r,It,Ad,{[_r]:!0}),o=oe(r,jr,Nd,{[Wr]:!0}),s=oe(t,It,Lt,{[sa]:!0});oe(s,Pt,i),oe(s,It,s),oe(i,Pt,i),oe(i,It,i);let l=oe(t,jr,ca,{[la]:!0});oe(l,It),oe(l,Pt,o),oe(l,jr,l),oe(o,Pt,o),oe(o,It),oe(o,jr,o);let a=E(t,na,ha,{[Zl]:!0}),c=E(t,Cd,da,{[Zl]:!0}),u=oe(t,ta,da,{[Zl]:!0});E(t,ra,u),E(c,na,a),E(c,ra,u),oe(c,ta,u),E(u,Cd),E(u,na),oe(u,ta,u),E(u,ra,u);let f=oe(t,ea,Rd,{[Od]:!0});E(f,"#"),oe(f,ea,f),E(f,nb,f);let d=E(f,rb);E(d,"#"),oe(d,ea,f);let p=[[It,s],[Pt,i]],h=[[It,null],[jr,l],[Pt,o]];for(let m=0;mm[0]>g[0]?1:-1);for(let m=0;m=0?C[aa]=!0:It.test(g)?Pt.test(g)?C[_r]=!0:C[sa]=!0:C[oa]=!0,Sd(t,g,g,C)}return Sd(t,"localhost",Yr,{ascii:!0}),t.jd=new He(Xo),{start:t,tokens:Object.assign({groups:e},Id)}}function Pd(n,e){let t=ob(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=t.length,i=[],o=0,s=0;for(;s=0&&(f+=t[s].length,d++),c+=t[s].length,o+=t[s].length,s++;o-=f,s-=d,c-=f,i.push({t:u.t,v:e.slice(o-c,o),s:o-c,e:o})}return i}function ob(n){let e=[],t=n.length,r=0;for(;r56319||r+1===t||(o=n.charCodeAt(r+1))<56320||o>57343?n[r]:n.slice(r,r+2);e.push(s),r+=s.length}return e}function Yt(n,e,t,r,i){let o,s=e.length;for(let l=0;l=0;)o++;if(o>0){e.push(t.join(""));for(let s=parseInt(n.substring(r,r+o),10);s>0;s--)t.pop();r+=o}else t.push(n[r]),r++}return e}var Xr={defaultProtocol:"http",events:null,format:Td,formatHref:Td,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function ka(n,e=null){let t=Object.assign({},Xr);n&&(t=Object.assign(t,n instanceof ka?n.o:n));let r=t.ignoreTags,i=[];for(let o=0;ot?r.substring(0,t)+"\u2026":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=Xr.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){let e=this,t=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",t,this),i=n.get("tagName",t,e),o=this.toFormattedString(n),s={},l=n.get("className",t,e),a=n.get("target",t,e),c=n.get("rel",t,e),u=n.getObj("attributes",t,e),f=n.getObj("events",t,e);return s.href=r,l&&(s.class=l),a&&(s.target=a),c&&(s.rel=c),u&&Object.assign(s,u),{tagName:i,attributes:s,content:o,eventListeners:f}}};function Qo(n,e){class t extends Ld{constructor(i,o){super(i,o),this.t=n}}for(let r in e)t.prototype[r]=e[r];return t.t=n,t}var sb=Qo("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Md=Qo("text"),lb=Qo("nl"),So=Qo("url",{isLink:!0,toHref(n=Xr.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){let n=this.tk;return n.length>=2&&n[0].t!==Yr&&n[1].t===vn}});var Ze=n=>new He(n);function ab({groups:n}){let e=n.domain.concat([Fo,Vo,Xt,jo,Wo,_o,qo,Uo,et,pa,Kr,Ko,Jo,Go,bt,Xo,Gr,Yo]),t=[Ho,vn,ma,yt,ga,Kr,Jr,ya,ba,Ao,No,qr,Ur,To,Eo,Mo,Oo,Do,Ro,Io,Po,Lo,Bo,zo,$o],r=[Fo,Ho,Vo,jo,Wo,_o,qo,Uo,et,qr,Ur,Kr,Ko,Jo,Go,Jr,bt,Xo,Gr,Yo],i=Ze(),o=E(i,Gr);F(o,r,o),F(o,n.domain,o);let s=Ze(),l=Ze(),a=Ze();F(i,n.domain,s),F(i,n.scheme,l),F(i,n.slashscheme,a),F(s,r,o),F(s,n.domain,s);let c=E(s,Xt);E(o,Xt,c),E(l,Xt,c),E(a,Xt,c);let u=E(o,yt);F(u,r,o),F(u,n.domain,o);let f=Ze();F(c,n.domain,f),F(f,n.domain,f);let d=E(f,yt);F(d,n.domain,f);let p=Ze(sb);F(d,n.tld,p),F(d,n.utld,p),E(c,Yr,p);let h=E(f,et);E(h,et,h),F(h,n.domain,f),F(p,n.domain,f),E(p,yt,d),E(p,et,h);let m=E(s,et),g=E(s,yt);E(m,et,m),F(m,n.domain,s),F(g,r,o),F(g,n.domain,s);let b=Ze(So);F(g,n.tld,b),F(g,n.utld,b),F(b,n.domain,s),F(b,r,o),E(b,yt,g),E(b,et,m),E(b,Xt,c);let C=E(b,vn),v=Ze(So);F(C,n.numeric,v);let y=Ze(So),T=Ze();F(y,e,y),F(y,t,T),F(T,e,y),F(T,t,T),E(b,bt,y),E(v,bt,y);let x=E(l,vn),S=E(a,vn),A=E(S,bt),R=E(A,bt);F(l,n.domain,s),E(l,yt,g),E(l,et,m),F(a,n.domain,s),E(a,yt,g),E(a,et,m),F(x,n.domain,y),E(x,bt,y),E(x,Jr,y),F(R,n.domain,y),F(R,e,y),E(R,bt,y);let H=[[qr,Ur],[Eo,To],[Mo,Oo],[Ao,No],[Do,Ro],[Io,Po],[Lo,Bo],[zo,$o]];for(let _=0;_=0&&d++,i++,u++;if(d<0)i-=u,i0&&(o.push(ia(Md,e,s)),s=[]),i-=d,u-=d;let p=f.t,h=t.slice(i-u,i);o.push(ia(p,e,h))}}return s.length>0&&o.push(ia(Md,e,s)),o}function ia(n,e,t){let r=t[0].s,i=t[t.length-1].e,o=e.slice(r,i);return new n(o,t)}var ub=typeof console<"u"&&console&&console.warn||(()=>{}),fb="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",X={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Bd(){return He.groups={},X.scanner=null,X.parser=null,X.tokenQueue=[],X.pluginQueue=[],X.customSchemes=[],X.initialized=!1,X}function xa(n,e=!1){if(X.initialized&&ub(`linkifyjs: already initialized - will not register custom scheme "${n}" ${fb}`),!/^[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`);X.customSchemes.push([n,e])}function db(){X.scanner=ib(X.customSchemes);for(let n=0;n{let i=e.some(c=>c.docChanged)&&!t.doc.eq(r.doc),o=e.some(c=>c.getMeta("preventAutolink"));if(!i||o)return;let{tr:s}=r,l=Ff(t.doc,[...e]);if(Vf(l).forEach(({newRange:c})=>{let u=Hf(r.doc,c,p=>p.isTextblock),f,d;if(u.length>1)f=u[0],d=r.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(u.length){let p=r.doc.textBetween(c.from,c.to," "," ");if(!hb.test(p))return;f=u[0],d=r.doc.textBetween(f.pos,c.to,void 0," ")}if(f&&d){let p=d.split(pb).filter(Boolean);if(p.length<=0)return!1;let h=p[p.length-1],m=f.pos+d.lastIndexOf(h);if(!h)return!1;let g=Zo(h).map(b=>b.toObject(n.defaultProtocol));if(!gb(g))return!1;g.filter(b=>b.isLink).map(b=>({...b,from:m+b.start+1,to:m+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>n.validate(b.value)).filter(b=>n.shouldAutoLink(b.value)).forEach(b=>{mo(b.from,b.to,r.doc).some(C=>C.mark.type===n.type)||s.addMark(b.from,b.to,n.type.create({href:b.href}))})}}),!!s.steps.length)return s}})}function bb(n){return new q({key:new re("handleClickLink"),props:{handleClick:(e,t,r)=>{var i,o;if(r.button!==0||!e.editable)return!1;let s=r.target,l=[];for(;s.nodeName!=="DIV";)l.push(s),s=s.parentNode;if(!l.find(d=>d.nodeName==="A"))return!1;let a=_l(e.state,n.type.name),c=r.target,u=(i=c?.href)!==null&&i!==void 0?i:a.href,f=(o=c?.target)!==null&&o!==void 0?o:a.target;return c&&u?(window.open(u,f),!0):!1}}})}function kb(n){return new q({key:new re("handlePasteLink"),props:{handlePaste:(e,t,r)=>{let{state:i}=e,{selection:o}=i,{empty:s}=o;if(s)return!1;let l="";r.content.forEach(c=>{l+=c.textContent});let a=va(l,{defaultProtocol:n.defaultProtocol}).find(c=>c.isLink&&c.value===l);return!l||!a?!1:n.editor.commands.setMark(n.type,{href:a.href})}}})}function wn(n,e){let t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{let i=typeof r=="string"?r:r.scheme;i&&t.push(i)}),!n||n.replace(mb,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var zd=Le.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"){xa(n);return}xa(n.scheme,n.optionalSlashes)})},onDestroy(){Bd()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(n,e)=>!!wn(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>!!n}},addAttributes(){return{href:{default:null,parseHTML(n){return n.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{let e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!wn(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=>!!wn(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",j(this.options.HTMLAttributes,n),0]:["a",j(this.options.HTMLAttributes,{...n,href:""}),0]},addCommands(){return{setLink:n=>({chain:e})=>{let{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!wn(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})=>{let{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!wn(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run():!1},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Qe({find:n=>{let e=[];if(n){let{protocols:t,defaultProtocol:r}=this.options,i=va(n).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:s=>!!wn(s,t),protocols:t,defaultProtocol:r}));i.length&&i.forEach(o=>e.push({text:o.value,data:{href:o.href},index:o.start}))}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){let n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(yb({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!wn(i,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&n.push(bb({type:this.type})),this.options.linkOnPaste&&n.push(kb({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),n}});var se="top",de="bottom",fe="right",le="left",es="auto",Qt=[se,de,fe,le],Bt="start",Sn="end",$d="clippingParents",ts="viewport",ir="popper",Fd="reference",Sa=Qt.reduce(function(n,e){return n.concat([e+"-"+Bt,e+"-"+Sn])},[]),ns=[].concat(Qt,[es]).reduce(function(n,e){return n.concat([e,e+"-"+Bt,e+"-"+Sn])},[]),xb="beforeRead",vb="read",wb="afterRead",Sb="beforeMain",Cb="main",Eb="afterMain",Tb="beforeWrite",Mb="write",Ob="afterWrite",Hd=[xb,vb,wb,Sb,Cb,Eb,Tb,Mb,Ob];function ge(n){return n?(n.nodeName||"").toLowerCase():null}function ee(n){if(n==null)return window;if(n.toString()!=="[object Window]"){var e=n.ownerDocument;return e&&e.defaultView||window}return n}function tt(n){var e=ee(n).Element;return n instanceof e||n instanceof Element}function pe(n){var e=ee(n).HTMLElement;return n instanceof e||n instanceof HTMLElement}function or(n){if(typeof ShadowRoot>"u")return!1;var e=ee(n).ShadowRoot;return n instanceof e||n instanceof ShadowRoot}function Ab(n){var e=n.state;Object.keys(e.elements).forEach(function(t){var r=e.styles[t]||{},i=e.attributes[t]||{},o=e.elements[t];!pe(o)||!ge(o)||(Object.assign(o.style,r),Object.keys(i).forEach(function(s){var l=i[s];l===!1?o.removeAttribute(s):o.setAttribute(s,l===!0?"":l)}))})}function Nb(n){var e=n.state,t={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,t.popper),e.styles=t,e.elements.arrow&&Object.assign(e.elements.arrow.style,t.arrow),function(){Object.keys(e.elements).forEach(function(r){var i=e.elements[r],o=e.attributes[r]||{},s=Object.keys(e.styles.hasOwnProperty(r)?e.styles[r]:t[r]),l=s.reduce(function(a,c){return a[c]="",a},{});!pe(i)||!ge(i)||(Object.assign(i.style,l),Object.keys(o).forEach(function(a){i.removeAttribute(a)}))})}}var Qr={name:"applyStyles",enabled:!0,phase:"write",fn:Ab,effect:Nb,requires:["computeStyles"]};function ye(n){return n.split("-")[0]}var st=Math.max,Cn=Math.min,zt=Math.round;function sr(){var n=navigator.userAgentData;return n!=null&&n.brands&&Array.isArray(n.brands)?n.brands.map(function(e){return e.brand+"/"+e.version}).join(" "):navigator.userAgent}function Zr(){return!/^((?!chrome|android).)*safari/i.test(sr())}function nt(n,e,t){e===void 0&&(e=!1),t===void 0&&(t=!1);var r=n.getBoundingClientRect(),i=1,o=1;e&&pe(n)&&(i=n.offsetWidth>0&&zt(r.width)/n.offsetWidth||1,o=n.offsetHeight>0&&zt(r.height)/n.offsetHeight||1);var s=tt(n)?ee(n):window,l=s.visualViewport,a=!Zr()&&t,c=(r.left+(a&&l?l.offsetLeft:0))/i,u=(r.top+(a&&l?l.offsetTop:0))/o,f=r.width/i,d=r.height/o;return{width:f,height:d,top:u,right:c+f,bottom:u+d,left:c,x:c,y:u}}function En(n){var e=nt(n),t=n.offsetWidth,r=n.offsetHeight;return Math.abs(e.width-t)<=1&&(t=e.width),Math.abs(e.height-r)<=1&&(r=e.height),{x:n.offsetLeft,y:n.offsetTop,width:t,height:r}}function ei(n,e){var t=e.getRootNode&&e.getRootNode();if(n.contains(e))return!0;if(t&&or(t)){var r=e;do{if(r&&n.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function Be(n){return ee(n).getComputedStyle(n)}function Ca(n){return["table","td","th"].indexOf(ge(n))>=0}function Se(n){return((tt(n)?n.ownerDocument:n.document)||window.document).documentElement}function $t(n){return ge(n)==="html"?n:n.assignedSlot||n.parentNode||(or(n)?n.host:null)||Se(n)}function Vd(n){return!pe(n)||Be(n).position==="fixed"?null:n.offsetParent}function Db(n){var e=/firefox/i.test(sr()),t=/Trident/i.test(sr());if(t&&pe(n)){var r=Be(n);if(r.position==="fixed")return null}var i=$t(n);for(or(i)&&(i=i.host);pe(i)&&["html","body"].indexOf(ge(i))<0;){var o=Be(i);if(o.transform!=="none"||o.perspective!=="none"||o.contain==="paint"||["transform","perspective"].indexOf(o.willChange)!==-1||e&&o.willChange==="filter"||e&&o.filter&&o.filter!=="none")return i;i=i.parentNode}return null}function lt(n){for(var e=ee(n),t=Vd(n);t&&Ca(t)&&Be(t).position==="static";)t=Vd(t);return t&&(ge(t)==="html"||ge(t)==="body"&&Be(t).position==="static")?e:t||Db(n)||e}function Tn(n){return["top","bottom"].indexOf(n)>=0?"x":"y"}function Mn(n,e,t){return st(n,Cn(e,t))}function jd(n,e,t){var r=Mn(n,e,t);return r>t?t:r}function ti(){return{top:0,right:0,bottom:0,left:0}}function ni(n){return Object.assign({},ti(),n)}function ri(n,e){return e.reduce(function(t,r){return t[r]=n,t},{})}var Rb=function(e,t){return e=typeof e=="function"?e(Object.assign({},t.rects,{placement:t.placement})):e,ni(typeof e!="number"?e:ri(e,Qt))};function Ib(n){var e,t=n.state,r=n.name,i=n.options,o=t.elements.arrow,s=t.modifiersData.popperOffsets,l=ye(t.placement),a=Tn(l),c=[le,fe].indexOf(l)>=0,u=c?"height":"width";if(!(!o||!s)){var f=Rb(i.padding,t),d=En(o),p=a==="y"?se:le,h=a==="y"?de:fe,m=t.rects.reference[u]+t.rects.reference[a]-s[a]-t.rects.popper[u],g=s[a]-t.rects.reference[a],b=lt(o),C=b?a==="y"?b.clientHeight||0:b.clientWidth||0:0,v=m/2-g/2,y=f[p],T=C-d[u]-f[h],x=C/2-d[u]/2+v,S=Mn(y,x,T),A=a;t.modifiersData[r]=(e={},e[A]=S,e.centerOffset=S-x,e)}}function Pb(n){var e=n.state,t=n.options,r=t.element,i=r===void 0?"[data-popper-arrow]":r;i!=null&&(typeof i=="string"&&(i=e.elements.popper.querySelector(i),!i)||ei(e.elements.popper,i)&&(e.elements.arrow=i))}var Wd={name:"arrow",enabled:!0,phase:"main",fn:Ib,effect:Pb,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function rt(n){return n.split("-")[1]}var Lb={top:"auto",right:"auto",bottom:"auto",left:"auto"};function Bb(n,e){var t=n.x,r=n.y,i=e.devicePixelRatio||1;return{x:zt(t*i)/i||0,y:zt(r*i)/i||0}}function _d(n){var e,t=n.popper,r=n.popperRect,i=n.placement,o=n.variation,s=n.offsets,l=n.position,a=n.gpuAcceleration,c=n.adaptive,u=n.roundOffsets,f=n.isFixed,d=s.x,p=d===void 0?0:d,h=s.y,m=h===void 0?0:h,g=typeof u=="function"?u({x:p,y:m}):{x:p,y:m};p=g.x,m=g.y;var b=s.hasOwnProperty("x"),C=s.hasOwnProperty("y"),v=le,y=se,T=window;if(c){var x=lt(t),S="clientHeight",A="clientWidth";if(x===ee(t)&&(x=Se(t),Be(x).position!=="static"&&l==="absolute"&&(S="scrollHeight",A="scrollWidth")),x=x,i===se||(i===le||i===fe)&&o===Sn){y=de;var R=f&&x===T&&T.visualViewport?T.visualViewport.height:x[S];m-=R-r.height,m*=a?1:-1}if(i===le||(i===se||i===de)&&o===Sn){v=fe;var H=f&&x===T&&T.visualViewport?T.visualViewport.width:x[A];p-=H-r.width,p*=a?1:-1}}var _=Object.assign({position:l},c&&Lb),I=u===!0?Bb({x:p,y:m},ee(t)):{x:p,y:m};if(p=I.x,m=I.y,a){var z;return Object.assign({},_,(z={},z[y]=C?"0":"",z[v]=b?"0":"",z.transform=(T.devicePixelRatio||1)<=1?"translate("+p+"px, "+m+"px)":"translate3d("+p+"px, "+m+"px, 0)",z))}return Object.assign({},_,(e={},e[y]=C?m+"px":"",e[v]=b?p+"px":"",e.transform="",e))}function zb(n){var e=n.state,t=n.options,r=t.gpuAcceleration,i=r===void 0?!0:r,o=t.adaptive,s=o===void 0?!0:o,l=t.roundOffsets,a=l===void 0?!0:l,c={placement:ye(e.placement),variation:rt(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:i,isFixed:e.options.strategy==="fixed"};e.modifiersData.popperOffsets!=null&&(e.styles.popper=Object.assign({},e.styles.popper,_d(Object.assign({},c,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:s,roundOffsets:a})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,_d(Object.assign({},c,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:a})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})}var qd={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:zb,data:{}};var rs={passive:!0};function $b(n){var e=n.state,t=n.instance,r=n.options,i=r.scroll,o=i===void 0?!0:i,s=r.resize,l=s===void 0?!0:s,a=ee(e.elements.popper),c=[].concat(e.scrollParents.reference,e.scrollParents.popper);return o&&c.forEach(function(u){u.addEventListener("scroll",t.update,rs)}),l&&a.addEventListener("resize",t.update,rs),function(){o&&c.forEach(function(u){u.removeEventListener("scroll",t.update,rs)}),l&&a.removeEventListener("resize",t.update,rs)}}var Ud={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:$b,data:{}};var Fb={left:"right",right:"left",bottom:"top",top:"bottom"};function lr(n){return n.replace(/left|right|bottom|top/g,function(e){return Fb[e]})}var Hb={start:"end",end:"start"};function is(n){return n.replace(/start|end/g,function(e){return Hb[e]})}function On(n){var e=ee(n),t=e.pageXOffset,r=e.pageYOffset;return{scrollLeft:t,scrollTop:r}}function An(n){return nt(Se(n)).left+On(n).scrollLeft}function Ea(n,e){var t=ee(n),r=Se(n),i=t.visualViewport,o=r.clientWidth,s=r.clientHeight,l=0,a=0;if(i){o=i.width,s=i.height;var c=Zr();(c||!c&&e==="fixed")&&(l=i.offsetLeft,a=i.offsetTop)}return{width:o,height:s,x:l+An(n),y:a}}function Ta(n){var e,t=Se(n),r=On(n),i=(e=n.ownerDocument)==null?void 0:e.body,o=st(t.scrollWidth,t.clientWidth,i?i.scrollWidth:0,i?i.clientWidth:0),s=st(t.scrollHeight,t.clientHeight,i?i.scrollHeight:0,i?i.clientHeight:0),l=-r.scrollLeft+An(n),a=-r.scrollTop;return Be(i||t).direction==="rtl"&&(l+=st(t.clientWidth,i?i.clientWidth:0)-o),{width:o,height:s,x:l,y:a}}function Nn(n){var e=Be(n),t=e.overflow,r=e.overflowX,i=e.overflowY;return/auto|scroll|overlay|hidden/.test(t+i+r)}function ss(n){return["html","body","#document"].indexOf(ge(n))>=0?n.ownerDocument.body:pe(n)&&Nn(n)?n:ss($t(n))}function Zt(n,e){var t;e===void 0&&(e=[]);var r=ss(n),i=r===((t=n.ownerDocument)==null?void 0:t.body),o=ee(r),s=i?[o].concat(o.visualViewport||[],Nn(r)?r:[]):r,l=e.concat(s);return i?l:l.concat(Zt($t(s)))}function ar(n){return Object.assign({},n,{left:n.x,top:n.y,right:n.x+n.width,bottom:n.y+n.height})}function Vb(n,e){var t=nt(n,!1,e==="fixed");return t.top=t.top+n.clientTop,t.left=t.left+n.clientLeft,t.bottom=t.top+n.clientHeight,t.right=t.left+n.clientWidth,t.width=n.clientWidth,t.height=n.clientHeight,t.x=t.left,t.y=t.top,t}function Kd(n,e,t){return e===ts?ar(Ea(n,t)):tt(e)?Vb(e,t):ar(Ta(Se(n)))}function jb(n){var e=Zt($t(n)),t=["absolute","fixed"].indexOf(Be(n).position)>=0,r=t&&pe(n)?lt(n):n;return tt(r)?e.filter(function(i){return tt(i)&&ei(i,r)&&ge(i)!=="body"}):[]}function Ma(n,e,t,r){var i=e==="clippingParents"?jb(n):[].concat(e),o=[].concat(i,[t]),s=o[0],l=o.reduce(function(a,c){var u=Kd(n,c,r);return a.top=st(u.top,a.top),a.right=Cn(u.right,a.right),a.bottom=Cn(u.bottom,a.bottom),a.left=st(u.left,a.left),a},Kd(n,s,r));return l.width=l.right-l.left,l.height=l.bottom-l.top,l.x=l.left,l.y=l.top,l}function ii(n){var e=n.reference,t=n.element,r=n.placement,i=r?ye(r):null,o=r?rt(r):null,s=e.x+e.width/2-t.width/2,l=e.y+e.height/2-t.height/2,a;switch(i){case se:a={x:s,y:e.y-t.height};break;case de:a={x:s,y:e.y+e.height};break;case fe:a={x:e.x+e.width,y:l};break;case le:a={x:e.x-t.width,y:l};break;default:a={x:e.x,y:e.y}}var c=i?Tn(i):null;if(c!=null){var u=c==="y"?"height":"width";switch(o){case Bt:a[c]=a[c]-(e[u]/2-t[u]/2);break;case Sn:a[c]=a[c]+(e[u]/2-t[u]/2);break;default:}}return a}function at(n,e){e===void 0&&(e={});var t=e,r=t.placement,i=r===void 0?n.placement:r,o=t.strategy,s=o===void 0?n.strategy:o,l=t.boundary,a=l===void 0?$d:l,c=t.rootBoundary,u=c===void 0?ts:c,f=t.elementContext,d=f===void 0?ir:f,p=t.altBoundary,h=p===void 0?!1:p,m=t.padding,g=m===void 0?0:m,b=ni(typeof g!="number"?g:ri(g,Qt)),C=d===ir?Fd:ir,v=n.rects.popper,y=n.elements[h?C:d],T=Ma(tt(y)?y:y.contextElement||Se(n.elements.popper),a,u,s),x=nt(n.elements.reference),S=ii({reference:x,element:v,strategy:"absolute",placement:i}),A=ar(Object.assign({},v,S)),R=d===ir?A:x,H={top:T.top-R.top+b.top,bottom:R.bottom-T.bottom+b.bottom,left:T.left-R.left+b.left,right:R.right-T.right+b.right},_=n.modifiersData.offset;if(d===ir&&_){var I=_[i];Object.keys(H).forEach(function(z){var Q=[fe,de].indexOf(z)>=0?1:-1,te=[se,de].indexOf(z)>=0?"y":"x";H[z]+=I[te]*Q})}return H}function Oa(n,e){e===void 0&&(e={});var t=e,r=t.placement,i=t.boundary,o=t.rootBoundary,s=t.padding,l=t.flipVariations,a=t.allowedAutoPlacements,c=a===void 0?ns:a,u=rt(r),f=u?l?Sa:Sa.filter(function(h){return rt(h)===u}):Qt,d=f.filter(function(h){return c.indexOf(h)>=0});d.length===0&&(d=f);var p=d.reduce(function(h,m){return h[m]=at(n,{placement:m,boundary:i,rootBoundary:o,padding:s})[ye(m)],h},{});return Object.keys(p).sort(function(h,m){return p[h]-p[m]})}function Wb(n){if(ye(n)===es)return[];var e=lr(n);return[is(n),e,is(e)]}function _b(n){var e=n.state,t=n.options,r=n.name;if(!e.modifiersData[r]._skip){for(var i=t.mainAxis,o=i===void 0?!0:i,s=t.altAxis,l=s===void 0?!0:s,a=t.fallbackPlacements,c=t.padding,u=t.boundary,f=t.rootBoundary,d=t.altBoundary,p=t.flipVariations,h=p===void 0?!0:p,m=t.allowedAutoPlacements,g=e.options.placement,b=ye(g),C=b===g,v=a||(C||!h?[lr(g)]:Wb(g)),y=[g].concat(v).reduce(function(it,Ne){return it.concat(ye(Ne)===es?Oa(e,{placement:Ne,boundary:u,rootBoundary:f,padding:c,flipVariations:h,allowedAutoPlacements:m}):Ne)},[]),T=e.rects.reference,x=e.rects.popper,S=new Map,A=!0,R=y[0],H=0;H=0,te=Q?"width":"height",Y=at(e,{placement:_,boundary:u,rootBoundary:f,altBoundary:d,padding:c}),ae=Q?z?fe:le:z?de:se;T[te]>x[te]&&(ae=lr(ae));var ne=lr(ae),Ae=[];if(o&&Ae.push(Y[I]<=0),l&&Ae.push(Y[ae]<=0,Y[ne]<=0),Ae.every(function(it){return it})){R=_,A=!1;break}S.set(_,Ae)}if(A)for(var ze=h?3:1,$e=function(Ne){var xt=y.find(function(Ln){var vt=S.get(Ln);if(vt)return vt.slice(0,Ne).every(function(Bn){return Bn})});if(xt)return R=xt,"break"},Ve=ze;Ve>0;Ve--){var je=$e(Ve);if(je==="break")break}e.placement!==R&&(e.modifiersData[r]._skip=!0,e.placement=R,e.reset=!0)}}var Jd={name:"flip",enabled:!0,phase:"main",fn:_b,requiresIfExists:["offset"],data:{_skip:!1}};function Gd(n,e,t){return t===void 0&&(t={x:0,y:0}),{top:n.top-e.height-t.y,right:n.right-e.width+t.x,bottom:n.bottom-e.height+t.y,left:n.left-e.width-t.x}}function Yd(n){return[se,fe,de,le].some(function(e){return n[e]>=0})}function qb(n){var e=n.state,t=n.name,r=e.rects.reference,i=e.rects.popper,o=e.modifiersData.preventOverflow,s=at(e,{elementContext:"reference"}),l=at(e,{altBoundary:!0}),a=Gd(s,r),c=Gd(l,i,o),u=Yd(a),f=Yd(c);e.modifiersData[t]={referenceClippingOffsets:a,popperEscapeOffsets:c,isReferenceHidden:u,hasPopperEscaped:f},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":f})}var Xd={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:qb};function Ub(n,e,t){var r=ye(n),i=[le,se].indexOf(r)>=0?-1:1,o=typeof t=="function"?t(Object.assign({},e,{placement:n})):t,s=o[0],l=o[1];return s=s||0,l=(l||0)*i,[le,fe].indexOf(r)>=0?{x:l,y:s}:{x:s,y:l}}function Kb(n){var e=n.state,t=n.options,r=n.name,i=t.offset,o=i===void 0?[0,0]:i,s=ns.reduce(function(u,f){return u[f]=Ub(f,e.rects,o),u},{}),l=s[e.placement],a=l.x,c=l.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=a,e.modifiersData.popperOffsets.y+=c),e.modifiersData[r]=s}var Qd={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:Kb};function Jb(n){var e=n.state,t=n.name;e.modifiersData[t]=ii({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}var Zd={name:"popperOffsets",enabled:!0,phase:"read",fn:Jb,data:{}};function Aa(n){return n==="x"?"y":"x"}function Gb(n){var e=n.state,t=n.options,r=n.name,i=t.mainAxis,o=i===void 0?!0:i,s=t.altAxis,l=s===void 0?!1:s,a=t.boundary,c=t.rootBoundary,u=t.altBoundary,f=t.padding,d=t.tether,p=d===void 0?!0:d,h=t.tetherOffset,m=h===void 0?0:h,g=at(e,{boundary:a,rootBoundary:c,padding:f,altBoundary:u}),b=ye(e.placement),C=rt(e.placement),v=!C,y=Tn(b),T=Aa(y),x=e.modifiersData.popperOffsets,S=e.rects.reference,A=e.rects.popper,R=typeof m=="function"?m(Object.assign({},e.rects,{placement:e.placement})):m,H=typeof R=="number"?{mainAxis:R,altAxis:R}:Object.assign({mainAxis:0,altAxis:0},R),_=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,I={x:0,y:0};if(x){if(o){var z,Q=y==="y"?se:le,te=y==="y"?de:fe,Y=y==="y"?"height":"width",ae=x[y],ne=ae+g[Q],Ae=ae-g[te],ze=p?-A[Y]/2:0,$e=C===Bt?S[Y]:A[Y],Ve=C===Bt?-A[Y]:-S[Y],je=e.elements.arrow,it=p&&je?En(je):{width:0,height:0},Ne=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:ti(),xt=Ne[Q],Ln=Ne[te],vt=Mn(0,S[Y],it[Y]),Bn=v?S[Y]/2-ze-vt-xt-H.mainAxis:$e-vt-xt-H.mainAxis,Ft=v?-S[Y]/2+ze+vt+Ln+H.mainAxis:Ve+vt+Ln+H.mainAxis,zn=e.elements.arrow&<(e.elements.arrow),pi=zn?y==="y"?zn.clientTop||0:zn.clientLeft||0:0,dr=(z=_?.[y])!=null?z:0,hi=ae+Bn-dr-pi,mi=ae+Ft-dr,pr=Mn(p?Cn(ne,hi):ne,ae,p?st(Ae,mi):Ae);x[y]=pr,I[y]=pr-ae}if(l){var hr,gi=y==="x"?se:le,yi=y==="x"?de:fe,wt=x[T],Ht=T==="y"?"height":"width",mr=wt+g[gi],en=wt-g[yi],gr=[se,le].indexOf(b)!==-1,bi=(hr=_?.[T])!=null?hr:0,ki=gr?mr:wt-S[Ht]-A[Ht]-bi+H.altAxis,xi=gr?wt+S[Ht]+A[Ht]-bi-H.altAxis:en,vi=p&&gr?jd(ki,wt,xi):Mn(p?ki:mr,wt,p?xi:en);x[T]=vi,I[T]=vi-wt}e.modifiersData[r]=I}}var ep={name:"preventOverflow",enabled:!0,phase:"main",fn:Gb,requiresIfExists:["offset"]};function Na(n){return{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}}function Da(n){return n===ee(n)||!pe(n)?On(n):Na(n)}function Yb(n){var e=n.getBoundingClientRect(),t=zt(e.width)/n.offsetWidth||1,r=zt(e.height)/n.offsetHeight||1;return t!==1||r!==1}function Ra(n,e,t){t===void 0&&(t=!1);var r=pe(e),i=pe(e)&&Yb(e),o=Se(e),s=nt(n,i,t),l={scrollLeft:0,scrollTop:0},a={x:0,y:0};return(r||!r&&!t)&&((ge(e)!=="body"||Nn(o))&&(l=Da(e)),pe(e)?(a=nt(e,!0),a.x+=e.clientLeft,a.y+=e.clientTop):o&&(a.x=An(o))),{x:s.left+l.scrollLeft-a.x,y:s.top+l.scrollTop-a.y,width:s.width,height:s.height}}function Xb(n){var e=new Map,t=new Set,r=[];n.forEach(function(o){e.set(o.name,o)});function i(o){t.add(o.name);var s=[].concat(o.requires||[],o.requiresIfExists||[]);s.forEach(function(l){if(!t.has(l)){var a=e.get(l);a&&i(a)}}),r.push(o)}return n.forEach(function(o){t.has(o.name)||i(o)}),r}function Ia(n){var e=Xb(n);return Hd.reduce(function(t,r){return t.concat(e.filter(function(i){return i.phase===r}))},[])}function Pa(n){var e;return function(){return e||(e=new Promise(function(t){Promise.resolve().then(function(){e=void 0,t(n())})})),e}}function La(n){var e=n.reduce(function(t,r){var i=t[r.name];return t[r.name]=i?Object.assign({},i,r,{options:Object.assign({},i.options,r.options),data:Object.assign({},i.data,r.data)}):r,t},{});return Object.keys(e).map(function(t){return e[t]})}var tp={placement:"bottom",modifiers:[],strategy:"absolute"};function np(){for(var n=arguments.length,e=new Array(n),t=0;t-1}function yp(n,e){return typeof n=="function"?n.apply(void 0,e):n}function ip(n,e){if(e===0)return n;var t;return function(r){clearTimeout(t),t=setTimeout(function(){n(r)},e)}}function tk(n){return n.split(/\s+/).filter(Boolean)}function cr(n){return[].concat(n)}function op(n,e){n.indexOf(e)===-1&&n.push(e)}function nk(n){return n.filter(function(e,t){return n.indexOf(e)===t})}function rk(n){return n.split("-")[0]}function as(n){return[].slice.call(n)}function sp(n){return Object.keys(n).reduce(function(e,t){return n[t]!==void 0&&(e[t]=n[t]),e},{})}function oi(){return document.createElement("div")}function cs(n){return["Element","Fragment"].some(function(e){return Wa(n,e)})}function ik(n){return Wa(n,"NodeList")}function ok(n){return Wa(n,"MouseEvent")}function sk(n){return!!(n&&n._tippy&&n._tippy.reference===n)}function lk(n){return cs(n)?[n]:ik(n)?as(n):Array.isArray(n)?n:as(document.querySelectorAll(n))}function $a(n,e){n.forEach(function(t){t&&(t.style.transitionDuration=e+"ms")})}function lp(n,e){n.forEach(function(t){t&&t.setAttribute("data-state",e)})}function ak(n){var e,t=cr(n),r=t[0];return r!=null&&(e=r.ownerDocument)!=null&&e.body?r.ownerDocument:document}function ck(n,e){var t=e.clientX,r=e.clientY;return n.every(function(i){var o=i.popperRect,s=i.popperState,l=i.props,a=l.interactiveBorder,c=rk(s.placement),u=s.modifiersData.offset;if(!u)return!0;var f=c==="bottom"?u.top.y:0,d=c==="top"?u.bottom.y:0,p=c==="right"?u.left.x:0,h=c==="left"?u.right.x:0,m=o.top-r+f>a,g=r-o.bottom-d>a,b=o.left-t+p>a,C=t-o.right-h>a;return m||g||b||C})}function Fa(n,e,t){var r=e+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(i){n[r](i,t)})}function ap(n,e){for(var t=e;t;){var r;if(n.contains(t))return!0;t=t.getRootNode==null||(r=t.getRootNode())==null?void 0:r.host}return!1}var kt={isTouch:!1},cp=0;function uk(){kt.isTouch||(kt.isTouch=!0,window.performance&&document.addEventListener("mousemove",bp))}function bp(){var n=performance.now();n-cp<20&&(kt.isTouch=!1,document.removeEventListener("mousemove",bp)),cp=n}function fk(){var n=document.activeElement;if(sk(n)){var e=n._tippy;n.blur&&!e.state.isVisible&&n.blur()}}function dk(){document.addEventListener("touchstart",uk,Dn),window.addEventListener("blur",fk)}var pk=typeof window<"u"&&typeof document<"u",hk=pk?!!window.msCrypto:!1;var mk={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},gk={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},ct=Object.assign({appendTo:gp,aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:function(){},onBeforeUpdate:function(){},onCreate:function(){},onDestroy:function(){},onHidden:function(){},onHide:function(){},onMount:function(){},onShow:function(){},onShown:function(){},onTrigger:function(){},onUntrigger:function(){},onClickOutside:function(){},placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:"mouseenter focus",triggerTarget:null},mk,gk),yk=Object.keys(ct),bk=function(e){var t=Object.keys(e);t.forEach(function(r){ct[r]=e[r]})};function kp(n){var e=n.plugins||[],t=e.reduce(function(r,i){var o=i.name,s=i.defaultValue;if(o){var l;r[o]=n[o]!==void 0?n[o]:(l=ct[o])!=null?l:s}return r},{});return Object.assign({},n,t)}function kk(n,e){var t=e?Object.keys(kp(Object.assign({},ct,{plugins:e}))):yk,r=t.reduce(function(i,o){var s=(n.getAttribute("data-tippy-"+o)||"").trim();if(!s)return i;if(o==="content")i[o]=s;else try{i[o]=JSON.parse(s)}catch{i[o]=s}return i},{});return r}function up(n,e){var t=Object.assign({},e,{content:yp(e.content,[n])},e.ignoreAttributes?{}:kk(n,e.plugins));return t.aria=Object.assign({},ct.aria,t.aria),t.aria={expanded:t.aria.expanded==="auto"?e.interactive:t.aria.expanded,content:t.aria.content==="auto"?e.interactive?null:"describedby":t.aria.content},t}var xk=function(){return"innerHTML"};function Va(n,e){n[xk()]=e}function fp(n){var e=oi();return n===!0?e.className=hp:(e.className=mp,cs(n)?e.appendChild(n):Va(e,n)),e}function dp(n,e){cs(e.content)?(Va(n,""),n.appendChild(e.content)):typeof e.content!="function"&&(e.allowHTML?Va(n,e.content):n.textContent=e.content)}function ja(n){var e=n.firstElementChild,t=as(e.children);return{box:e,content:t.find(function(r){return r.classList.contains(pp)}),arrow:t.find(function(r){return r.classList.contains(hp)||r.classList.contains(mp)}),backdrop:t.find(function(r){return r.classList.contains(ek)})}}function xp(n){var e=oi(),t=oi();t.className=Zb,t.setAttribute("data-state","hidden"),t.setAttribute("tabindex","-1");var r=oi();r.className=pp,r.setAttribute("data-state","hidden"),dp(r,n.props),e.appendChild(t),t.appendChild(r),i(n.props,n.props);function i(o,s){var l=ja(e),a=l.box,c=l.content,u=l.arrow;s.theme?a.setAttribute("data-theme",s.theme):a.removeAttribute("data-theme"),typeof s.animation=="string"?a.setAttribute("data-animation",s.animation):a.removeAttribute("data-animation"),s.inertia?a.setAttribute("data-inertia",""):a.removeAttribute("data-inertia"),a.style.maxWidth=typeof s.maxWidth=="number"?s.maxWidth+"px":s.maxWidth,s.role?a.setAttribute("role",s.role):a.removeAttribute("role"),(o.content!==s.content||o.allowHTML!==s.allowHTML)&&dp(c,n.props),s.arrow?u?o.arrow!==s.arrow&&(a.removeChild(u),a.appendChild(fp(s.arrow))):a.appendChild(fp(s.arrow)):u&&a.removeChild(u)}return{popper:e,onUpdate:i}}xp.$$tippy=!0;var vk=1,ls=[],Ha=[];function wk(n,e){var t=up(n,Object.assign({},ct,kp(sp(e)))),r,i,o,s=!1,l=!1,a=!1,c=!1,u,f,d,p=[],h=ip(hi,t.interactiveDebounce),m,g=vk++,b=null,C=nk(t.plugins),v={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},y={id:g,reference:n,popper:oi(),popperInstance:b,props:t,state:v,plugins:C,clearDelayTimeouts:ki,setProps:xi,setContent:vi,show:qp,hide:Up,hideWithInteractivity:Kp,enable:gr,disable:bi,unmount:Jp,destroy:Gp};if(!t.render)return y;var T=t.render(y),x=T.popper,S=T.onUpdate;x.setAttribute("data-tippy-root",""),x.id="tippy-"+y.id,y.popper=x,n._tippy=y,x._tippy=y;var A=C.map(function(k){return k.fn(y)}),R=n.hasAttribute("aria-expanded");return zn(),ze(),ae(),ne("onCreate",[y]),t.showOnCreate&&mr(),x.addEventListener("mouseenter",function(){y.props.interactive&&y.state.isVisible&&y.clearDelayTimeouts()}),x.addEventListener("mouseleave",function(){y.props.interactive&&y.props.trigger.indexOf("mouseenter")>=0&&Q().addEventListener("mousemove",h)}),y;function H(){var k=y.props.touch;return Array.isArray(k)?k:[k,0]}function _(){return H()[0]==="hold"}function I(){var k;return!!((k=y.props.render)!=null&&k.$$tippy)}function z(){return m||n}function Q(){var k=z().parentNode;return k?ak(k):document}function te(){return ja(x)}function Y(k){return y.state.isMounted&&!y.state.isVisible||kt.isTouch||u&&u.type==="focus"?0:za(y.props.delay,k?0:1,ct.delay)}function ae(k){k===void 0&&(k=!1),x.style.pointerEvents=y.props.interactive&&!k?"":"none",x.style.zIndex=""+y.props.zIndex}function ne(k,N,B){if(B===void 0&&(B=!0),A.forEach(function(V){V[k]&&V[k].apply(V,N)}),B){var K;(K=y.props)[k].apply(K,N)}}function Ae(){var k=y.props.aria;if(k.content){var N="aria-"+k.content,B=x.id,K=cr(y.props.triggerTarget||n);K.forEach(function(V){var De=V.getAttribute(N);if(y.state.isVisible)V.setAttribute(N,De?De+" "+B:B);else{var _e=De&&De.replace(B,"").trim();_e?V.setAttribute(N,_e):V.removeAttribute(N)}})}}function ze(){if(!(R||!y.props.aria.expanded)){var k=cr(y.props.triggerTarget||n);k.forEach(function(N){y.props.interactive?N.setAttribute("aria-expanded",y.state.isVisible&&N===z()?"true":"false"):N.removeAttribute("aria-expanded")})}}function $e(){Q().removeEventListener("mousemove",h),ls=ls.filter(function(k){return k!==h})}function Ve(k){if(!(kt.isTouch&&(a||k.type==="mousedown"))){var N=k.composedPath&&k.composedPath()[0]||k.target;if(!(y.props.interactive&&ap(x,N))){if(cr(y.props.triggerTarget||n).some(function(B){return ap(B,N)})){if(kt.isTouch||y.state.isVisible&&y.props.trigger.indexOf("click")>=0)return}else ne("onClickOutside",[y,k]);y.props.hideOnClick===!0&&(y.clearDelayTimeouts(),y.hide(),l=!0,setTimeout(function(){l=!1}),y.state.isMounted||xt())}}}function je(){a=!0}function it(){a=!1}function Ne(){var k=Q();k.addEventListener("mousedown",Ve,!0),k.addEventListener("touchend",Ve,Dn),k.addEventListener("touchstart",it,Dn),k.addEventListener("touchmove",je,Dn)}function xt(){var k=Q();k.removeEventListener("mousedown",Ve,!0),k.removeEventListener("touchend",Ve,Dn),k.removeEventListener("touchstart",it,Dn),k.removeEventListener("touchmove",je,Dn)}function Ln(k,N){Bn(k,function(){!y.state.isVisible&&x.parentNode&&x.parentNode.contains(x)&&N()})}function vt(k,N){Bn(k,N)}function Bn(k,N){var B=te().box;function K(V){V.target===B&&(Fa(B,"remove",K),N())}if(k===0)return N();Fa(B,"remove",f),Fa(B,"add",K),f=K}function Ft(k,N,B){B===void 0&&(B=!1);var K=cr(y.props.triggerTarget||n);K.forEach(function(V){V.addEventListener(k,N,B),p.push({node:V,eventType:k,handler:N,options:B})})}function zn(){_()&&(Ft("touchstart",dr,{passive:!0}),Ft("touchend",mi,{passive:!0})),tk(y.props.trigger).forEach(function(k){if(k!=="manual")switch(Ft(k,dr),k){case"mouseenter":Ft("mouseleave",mi);break;case"focus":Ft(hk?"focusout":"blur",pr);break;case"focusin":Ft("focusout",pr);break}})}function pi(){p.forEach(function(k){var N=k.node,B=k.eventType,K=k.handler,V=k.options;N.removeEventListener(B,K,V)}),p=[]}function dr(k){var N,B=!1;if(!(!y.state.isEnabled||hr(k)||l)){var K=((N=u)==null?void 0:N.type)==="focus";u=k,m=k.currentTarget,ze(),!y.state.isVisible&&ok(k)&&ls.forEach(function(V){return V(k)}),k.type==="click"&&(y.props.trigger.indexOf("mouseenter")<0||s)&&y.props.hideOnClick!==!1&&y.state.isVisible?B=!0:mr(k),k.type==="click"&&(s=!B),B&&!K&&en(k)}}function hi(k){var N=k.target,B=z().contains(N)||x.contains(N);if(!(k.type==="mousemove"&&B)){var K=Ht().concat(x).map(function(V){var De,_e=V._tippy,$n=(De=_e.popperInstance)==null?void 0:De.state;return $n?{popperRect:V.getBoundingClientRect(),popperState:$n,props:t}:null}).filter(Boolean);ck(K,k)&&($e(),en(k))}}function mi(k){var N=hr(k)||y.props.trigger.indexOf("click")>=0&&s;if(!N){if(y.props.interactive){y.hideWithInteractivity(k);return}en(k)}}function pr(k){y.props.trigger.indexOf("focusin")<0&&k.target!==z()||y.props.interactive&&k.relatedTarget&&x.contains(k.relatedTarget)||en(k)}function hr(k){return kt.isTouch?_()!==k.type.indexOf("touch")>=0:!1}function gi(){yi();var k=y.props,N=k.popperOptions,B=k.placement,K=k.offset,V=k.getReferenceClientRect,De=k.moveTransition,_e=I()?ja(x).arrow:null,$n=V?{getBoundingClientRect:V,contextElement:V.contextElement||z()}:n,Za={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(wi){var Fn=wi.state;if(I()){var Yp=te(),ms=Yp.box;["placement","reference-hidden","escaped"].forEach(function(Si){Si==="placement"?ms.setAttribute("data-placement",Fn.placement):Fn.attributes.popper["data-popper-"+Si]?ms.setAttribute("data-"+Si,""):ms.removeAttribute("data-"+Si)}),Fn.attributes.popper={}}}},tn=[{name:"offset",options:{offset:K}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!De}},Za];I()&&_e&&tn.push({name:"arrow",options:{element:_e,padding:3}}),tn.push.apply(tn,N?.modifiers||[]),y.popperInstance=Ba($n,x,Object.assign({},N,{placement:B,onFirstUpdate:d,modifiers:tn}))}function yi(){y.popperInstance&&(y.popperInstance.destroy(),y.popperInstance=null)}function wt(){var k=y.props.appendTo,N,B=z();y.props.interactive&&k===gp||k==="parent"?N=B.parentNode:N=yp(k,[B]),N.contains(x)||N.appendChild(x),y.state.isMounted=!0,gi()}function Ht(){return as(x.querySelectorAll("[data-tippy-root]"))}function mr(k){y.clearDelayTimeouts(),k&&ne("onTrigger",[y,k]),Ne();var N=Y(!0),B=H(),K=B[0],V=B[1];kt.isTouch&&K==="hold"&&V&&(N=V),N?r=setTimeout(function(){y.show()},N):y.show()}function en(k){if(y.clearDelayTimeouts(),ne("onUntrigger",[y,k]),!y.state.isVisible){xt();return}if(!(y.props.trigger.indexOf("mouseenter")>=0&&y.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(k.type)>=0&&s)){var N=Y(!1);N?i=setTimeout(function(){y.state.isVisible&&y.hide()},N):o=requestAnimationFrame(function(){y.hide()})}}function gr(){y.state.isEnabled=!0}function bi(){y.hide(),y.state.isEnabled=!1}function ki(){clearTimeout(r),clearTimeout(i),cancelAnimationFrame(o)}function xi(k){if(!y.state.isDestroyed){ne("onBeforeUpdate",[y,k]),pi();var N=y.props,B=up(n,Object.assign({},N,sp(k),{ignoreAttributes:!0}));y.props=B,zn(),N.interactiveDebounce!==B.interactiveDebounce&&($e(),h=ip(hi,B.interactiveDebounce)),N.triggerTarget&&!B.triggerTarget?cr(N.triggerTarget).forEach(function(K){K.removeAttribute("aria-expanded")}):B.triggerTarget&&n.removeAttribute("aria-expanded"),ze(),ae(),S&&S(N,B),y.popperInstance&&(gi(),Ht().forEach(function(K){requestAnimationFrame(K._tippy.popperInstance.forceUpdate)})),ne("onAfterUpdate",[y,k])}}function vi(k){y.setProps({content:k})}function qp(){var k=y.state.isVisible,N=y.state.isDestroyed,B=!y.state.isEnabled,K=kt.isTouch&&!y.props.touch,V=za(y.props.duration,0,ct.duration);if(!(k||N||B||K)&&!z().hasAttribute("disabled")&&(ne("onShow",[y],!1),y.props.onShow(y)!==!1)){if(y.state.isVisible=!0,I()&&(x.style.visibility="visible"),ae(),Ne(),y.state.isMounted||(x.style.transition="none"),I()){var De=te(),_e=De.box,$n=De.content;$a([_e,$n],0)}d=function(){var tn;if(!(!y.state.isVisible||c)){if(c=!0,x.offsetHeight,x.style.transition=y.props.moveTransition,I()&&y.props.animation){var hs=te(),wi=hs.box,Fn=hs.content;$a([wi,Fn],V),lp([wi,Fn],"visible")}Ae(),ze(),op(Ha,y),(tn=y.popperInstance)==null||tn.forceUpdate(),ne("onMount",[y]),y.props.animation&&I()&&vt(V,function(){y.state.isShown=!0,ne("onShown",[y])})}},wt()}}function Up(){var k=!y.state.isVisible,N=y.state.isDestroyed,B=!y.state.isEnabled,K=za(y.props.duration,1,ct.duration);if(!(k||N||B)&&(ne("onHide",[y],!1),y.props.onHide(y)!==!1)){if(y.state.isVisible=!1,y.state.isShown=!1,c=!1,s=!1,I()&&(x.style.visibility="hidden"),$e(),xt(),ae(!0),I()){var V=te(),De=V.box,_e=V.content;y.props.animation&&($a([De,_e],K),lp([De,_e],"hidden"))}Ae(),ze(),y.props.animation?I()&&Ln(K,y.unmount):y.unmount()}}function Kp(k){Q().addEventListener("mousemove",h),op(ls,h),h(k)}function Jp(){y.state.isVisible&&y.hide(),y.state.isMounted&&(yi(),Ht().forEach(function(k){k._tippy.unmount()}),x.parentNode&&x.parentNode.removeChild(x),Ha=Ha.filter(function(k){return k!==y}),y.state.isMounted=!1,ne("onHidden",[y]))}function Gp(){y.state.isDestroyed||(y.clearDelayTimeouts(),y.unmount(),pi(),delete n._tippy,y.state.isDestroyed=!0,ne("onDestroy",[y]))}}function si(n,e){e===void 0&&(e={});var t=ct.plugins.concat(e.plugins||[]);dk();var r=Object.assign({},e,{plugins:t}),i=lk(n);if(0)var o,s;var l=i.reduce(function(a,c){var u=c&&wk(c,r);return u&&a.push(u),a},[]);return cs(n)?l[0]:l}si.defaultProps=ct;si.setDefaultProps=bk;si.currentInput=kt;var FE=Object.assign({},Qr,{effect:function(e){var t=e.state,r={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(t.elements.popper.style,r.popper),t.styles=r,t.elements.arrow&&Object.assign(t.elements.arrow.style,r.arrow)}});si.setDefaultProps({render:xp});var vp=si;var _a=class{constructor({editor:e,element:t,view:r,tippyOptions:i={},updateDelay:o=250,shouldShow:s}){this.preventHide=!1,this.shouldShow=({view:l,state:a,from:c,to:u})=>{let{doc:f,selection:d}=a,{empty:p}=d,h=!f.textBetween(c,u).length&&po(a.selection),m=this.element.contains(document.activeElement);return!(!(l.hasFocus()||m)||p||h||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:l})=>{var a;if(this.preventHide){this.preventHide=!1;return}l?.relatedTarget&&(!((a=this.element.parentNode)===null||a===void 0)&&a.contains(l.relatedTarget))||l?.relatedTarget!==this.editor.view.dom&&this.hide()},this.tippyBlurHandler=l=>{this.blurHandler({event:l})},this.handleDebouncedUpdate=(l,a)=>{let c=!a?.selection.eq(l.state.selection),u=!a?.doc.eq(l.state.doc);!c&&!u||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(l,c,u,a)},this.updateDelay))},this.updateHandler=(l,a,c,u)=>{var f,d,p;let{state:h,composing:m}=l,{selection:g}=h;if(m||!a&&!c)return;this.createTooltip();let{ranges:C}=g,v=Math.min(...C.map(x=>x.$from.pos)),y=Math.max(...C.map(x=>x.$to.pos));if(!((f=this.shouldShow)===null||f===void 0?void 0:f.call(this,{editor:this.editor,element:this.element,view:l,state:h,oldState:u,from:v,to:y}))){this.hide();return}(d=this.tippy)===null||d===void 0||d.setProps({getReferenceClientRect:((p=this.tippyOptions)===null||p===void 0?void 0:p.getReferenceClientRect)||(()=>{if(go(h.selection)){let x=l.nodeDOM(v);if(x){let S=x.dataset.nodeViewWrapper?x:x.querySelector("[data-node-view-wrapper]");if(S&&(x=S.firstChild),x)return x.getBoundingClientRect()}}return jf(l,v,y)})}),this.show()},this.editor=e,this.element=t,this.view=r,this.updateDelay=o,s&&(this.shouldShow=s),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.tippyOptions=i,this.element.remove(),this.element.style.visibility="visible"}createTooltip(){let{element:e}=this.editor.options,t=!!e.parentElement;this.element.tabIndex=0,!(this.tippy||!t)&&(this.tippy=vp(e,{duration:0,getReferenceClientRect:null,content:this.element,interactive:!0,trigger:"manual",placement:"top",hideOnClick:"toggle",...this.tippyOptions}),this.tippy.popper.firstChild&&this.tippy.popper.firstChild.addEventListener("blur",this.tippyBlurHandler))}update(e,t){let{state:r}=e,i=r.selection.from!==r.selection.to;if(this.updateDelay>0&&i){this.handleDebouncedUpdate(e,t);return}let o=!t?.selection.eq(e.state.selection),s=!t?.doc.eq(e.state.doc);this.updateHandler(e,o,s,t)}show(){var e;(e=this.tippy)===null||e===void 0||e.show()}hide(){var e;(e=this.tippy)===null||e===void 0||e.hide()}destroy(){var e,t;!((e=this.tippy)===null||e===void 0)&&e.popper.firstChild&&this.tippy.popper.firstChild.removeEventListener("blur",this.tippyBlurHandler),(t=this.tippy)===null||t===void 0||t.destroy(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler)}},Sk=n=>new q({key:typeof n.pluginKey=="string"?new re(n.pluginKey):n.pluginKey,view:e=>new _a({view:e,...n})}),wp=ie.create({name:"bubbleMenu",addOptions(){return{element:null,tippyOptions:{},pluginKey:"bubbleMenu",updateDelay:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[Sk({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,tippyOptions:this.options.tippyOptions,updateDelay:this.options.updateDelay,shouldShow:this.options.shouldShow})]:[]}});function Ck(n){var e;let{char:t,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:o,startOfLine:s,$position:l}=n,a=r&&!i,c=qf(t),u=new RegExp(`\\s${c}$`),f=s?"^":"",d=i?"":c,p=a?new RegExp(`${f}${c}.*?(?=\\s${d}|$)`,"gm"):new RegExp(`${f}(?:^)?${c}[^\\s${d}]*`,"gm"),h=((e=l.nodeBefore)===null||e===void 0?void 0:e.isText)&&l.nodeBefore.text;if(!h)return null;let m=l.pos-h.length,g=Array.from(h.matchAll(p)).pop();if(!g||g.input===void 0||g.index===void 0)return null;let b=g.input.slice(Math.max(0,g.index-1),g.index),C=new RegExp(`^[${o?.join("")}\0]?$`).test(b);if(o!==null&&!C)return null;let v=m+g.index,y=v+g[0].length;return a&&u.test(h.slice(y-1,y+1))&&(g[0]+=" ",y+=1),v=l.pos?{range:{from:v,to:y},query:g[0].slice(t.length),text:g[0]}:null}var Ek=new re("suggestion");function Sp({pluginKey:n=Ek,editor:e,char:t="@",allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:o=[" "],startOfLine:s=!1,decorationTag:l="span",decorationClass:a="suggestion",decorationContent:c="",decorationEmptyClass:u="is-empty",command:f=()=>null,items:d=()=>[],render:p=()=>({}),allow:h=()=>!0,findSuggestionMatch:m=Ck}){let g,b=p?.(),C=new q({key:n,view(){return{update:async(v,y)=>{var T,x,S,A,R,H,_;let I=(T=this.key)===null||T===void 0?void 0:T.getState(y),z=(x=this.key)===null||x===void 0?void 0:x.getState(v.state),Q=I.active&&z.active&&I.range.from!==z.range.from,te=!I.active&&z.active,Y=I.active&&!z.active,ae=!te&&!Y&&I.query!==z.query,ne=te||Q&&ae,Ae=ae||Q,ze=Y||Q&&ae;if(!ne&&!Ae&&!ze)return;let $e=ze&&!ne?I:z,Ve=v.dom.querySelector(`[data-decoration-id="${$e.decorationId}"]`);g={editor:e,range:$e.range,query:$e.query,text:$e.text,items:[],command:je=>f({editor:e,range:$e.range,props:je}),decorationNode:Ve,clientRect:Ve?()=>{var je;let{decorationId:it}=(je=this.key)===null||je===void 0?void 0:je.getState(e.state),Ne=v.dom.querySelector(`[data-decoration-id="${it}"]`);return Ne?.getBoundingClientRect()||null}:null},ne&&((S=b?.onBeforeStart)===null||S===void 0||S.call(b,g)),Ae&&((A=b?.onBeforeUpdate)===null||A===void 0||A.call(b,g)),(Ae||ne)&&(g.items=await d({editor:e,query:$e.query})),ze&&((R=b?.onExit)===null||R===void 0||R.call(b,g)),Ae&&((H=b?.onUpdate)===null||H===void 0||H.call(b,g)),ne&&((_=b?.onStart)===null||_===void 0||_.call(b,g))},destroy:()=>{var v;g&&((v=b?.onExit)===null||v===void 0||v.call(b,g))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(v,y,T,x){let{isEditable:S}=e,{composing:A}=e.view,{selection:R}=v,{empty:H,from:_}=R,I={...y};if(I.composing=A,S&&(H||e.view.composing)){(_y.range.to)&&!A&&!y.composing&&(I.active=!1);let z=m({char:t,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:o,startOfLine:s,$position:R.$from}),Q=`id_${Math.floor(Math.random()*4294967295)}`;z&&h({editor:e,state:x,range:z.range,isActive:y.active})?(I.active=!0,I.decorationId=y.decorationId?y.decorationId:Q,I.range=z.range,I.query=z.query,I.text=z.text):I.active=!1}else I.active=!1;return I.active||(I.decorationId=null,I.range={from:0,to:0},I.query=null,I.text=null),I}},props:{handleKeyDown(v,y){var T;let{active:x,range:S}=C.getState(v.state);return x&&((T=b?.onKeyDown)===null||T===void 0?void 0:T.call(b,{view:v,event:y,range:S}))||!1},decorations(v){let{active:y,range:T,decorationId:x,query:S}=C.getState(v);if(!y)return null;let A=!S?.length,R=[a];return A&&R.push(u),Te.create(v.doc,[Xe.inline(T.from,T.to,{nodeName:l,class:R.join(" "),"data-decoration-id":x,"data-decoration-content":c})])}}});return C}var Tk=[{label:"Heading 2",command:n=>n.chain().focus().toggleHeading({level:2}).run()},{label:"Heading 3",command:n=>n.chain().focus().toggleHeading({level:3}).run()},{label:"Quote",command:n=>n.chain().focus().toggleBlockquote().run()},{label:"Code block",command:n=>n.chain().focus().toggleCodeBlock().run()},{label:"Divider",command:n=>n.chain().focus().setHorizontalRule().run()}];function Mk(){let n=document.createElement("div");return n.className="slash-menu",n.setAttribute("role","listbox"),document.body.appendChild(n),n}function us(n,e,t,r){n.innerHTML="",e.forEach((i,o)=>{let s=document.createElement("button");s.type="button",s.textContent=i.label,s.className="slash-menu__item"+(o===t?" is-selected":""),s.addEventListener("mousedown",l=>{l.preventDefault(),r(i)}),n.appendChild(s)})}function Cp(n,e){let t=e();if(!t){n.style.display="none";return}n.style.display="block",n.style.position="absolute",n.style.top=`${t.bottom+window.scrollY+4}px`,n.style.left=`${t.left+window.scrollX}px`}var Ep=ie.create({name:"slashMenu",addOptions(){return{suggestion:{char:"/",startOfLine:!1,command:({editor:n,range:e,props:t})=>{n.chain().focus().deleteRange(e).run(),t.command(n)},items:({query:n})=>Tk.filter(e=>e.label.toLowerCase().includes(n.toLowerCase())).slice(0,6),render:()=>{let n,e=[],t=0,r=null,i;return{onStart:o=>{n=Mk(),e=o.items,t=0,r=o.clientRect,i=o.command,us(n,e,t,i),Cp(n,r)},onUpdate:o=>{e=o.items,t=0,r=o.clientRect,i=o.command,us(n,e,t,i),Cp(n,r)},onKeyDown:({event:o})=>o.key==="ArrowDown"?(t=(t+1)%e.length,us(n,e,t,i),!0):o.key==="ArrowUp"?(t=(t-1+e.length)%e.length,us(n,e,t,i),!0):o.key==="Enter"?(e[t]&&i(e[t]),!0):o.key==="Escape"?(n.remove(),!0):!1,onExit:()=>{n?.remove()}}}}}},addProseMirrorPlugins(){return[Sp({editor:this.editor,...this.options.suggestion})]}});function Ka(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Pn=Ka();function Dp(n){Pn=n}var Rp=/[&<>"']/,Ok=new RegExp(Rp.source,"g"),Ip=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Ak=new RegExp(Ip.source,"g"),Nk={"&":"&","<":"<",">":">",'"':""","'":"'"},Tp=n=>Nk[n];function We(n,e){if(e){if(Rp.test(n))return n.replace(Ok,Tp)}else if(Ip.test(n))return n.replace(Ak,Tp);return n}var Dk=/(^|[^\[])\^/g;function J(n,e){let t=typeof n=="string"?n:n.source;e=e||"";let r={replace:(i,o)=>{let s=typeof o=="string"?o:o.source;return s=s.replace(Dk,"$1"),t=t.replace(i,s),r},getRegex:()=>new RegExp(t,e)};return r}function Mp(n){try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}var ci={exec:()=>null};function Op(n,e){let t=n.replace(/\|/g,(o,s,l)=>{let a=!1,c=s;for(;--c>=0&&l[c]==="\\";)a=!a;return a?"|":" |"}),r=t.split(/ \|/),i=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length{let o=i.match(/^\s+/);if(o===null)return i;let[s]=o;return s.length>=r.length?i.slice(r.length):i}).join(` +`)}var ur=class{constructor(e){G(this,"options");G(this,"rules");G(this,"lexer");this.options=e||Pn}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let r=t[0].replace(/^(?: {1,4}| {0,3}\t)/gm,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?r:li(r,` +`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let r=t[0],i=Ik(r,t[3]||"");return{type:"code",raw:r,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:i}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let r=t[2].trim();if(/#$/.test(r)){let i=li(r,"#");(this.options.pedantic||!i||/ $/.test(i))&&(r=i.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:li(t[0],` +`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let r=li(t[0],` +`).split(` +`),i="",o="",s=[];for(;r.length>0;){let l=!1,a=[],c;for(c=0;c/.test(r[c]))a.push(r[c]),l=!0;else if(!l)a.push(r[c]);else break;r=r.slice(c);let u=a.join(` +`),f=u.replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,` + $1`).replace(/^ {0,3}>[ \t]?/gm,"");i=i?`${i} +${u}`:u,o=o?`${o} +${f}`:f;let d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(f,s,!0),this.lexer.state.top=d,r.length===0)break;let p=s[s.length-1];if(p?.type==="code")break;if(p?.type==="blockquote"){let h=p,m=h.raw+` +`+r.join(` +`),g=this.blockquote(m);s[s.length-1]=g,i=i.substring(0,i.length-h.raw.length)+g.raw,o=o.substring(0,o.length-h.text.length)+g.text;break}else if(p?.type==="list"){let h=p,m=h.raw+` +`+r.join(` +`),g=this.list(m);s[s.length-1]=g,i=i.substring(0,i.length-p.raw.length)+g.raw,o=o.substring(0,o.length-h.raw.length)+g.raw,r=m.substring(s[s.length-1].raw.length).split(` +`);continue}}return{type:"blockquote",raw:i,tokens:s,text:o}}}list(e){let t=this.rules.block.list.exec(e);if(t){let r=t[1].trim(),i=r.length>1,o={type:"list",raw:"",ordered:i,start:i?+r.slice(0,-1):"",loose:!1,items:[]};r=i?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=i?r:"[*+-]");let s=new RegExp(`^( {0,3}${r})((?:[ ][^\\n]*)?(?:\\n|$))`),l=!1;for(;e;){let a=!1,c="",u="";if(!(t=s.exec(e))||this.rules.block.hr.test(e))break;c=t[0],e=e.substring(c.length);let f=t[2].split(` +`,1)[0].replace(/^\t+/,b=>" ".repeat(3*b.length)),d=e.split(` +`,1)[0],p=!f.trim(),h=0;if(this.options.pedantic?(h=2,u=f.trimStart()):p?h=t[1].length+1:(h=t[2].search(/[^ ]/),h=h>4?1:h,u=f.slice(h),h+=t[1].length),p&&/^[ \t]*$/.test(d)&&(c+=d+` +`,e=e.substring(d.length+1),a=!0),!a){let b=new RegExp(`^ {0,${Math.min(3,h-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),C=new RegExp(`^ {0,${Math.min(3,h-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),v=new RegExp(`^ {0,${Math.min(3,h-1)}}(?:\`\`\`|~~~)`),y=new RegExp(`^ {0,${Math.min(3,h-1)}}#`),T=new RegExp(`^ {0,${Math.min(3,h-1)}}<(?:[a-z].*>|!--)`,"i");for(;e;){let x=e.split(` +`,1)[0],S;if(d=x,this.options.pedantic?(d=d.replace(/^ {1,4}(?=( {4})*[^ ])/g," "),S=d):S=d.replace(/\t/g," "),v.test(d)||y.test(d)||T.test(d)||b.test(d)||C.test(d))break;if(S.search(/[^ ]/)>=h||!d.trim())u+=` +`+S.slice(h);else{if(p||f.replace(/\t/g," ").search(/[^ ]/)>=4||v.test(f)||y.test(f)||C.test(f))break;u+=` +`+d}!p&&!d.trim()&&(p=!0),c+=x+` +`,e=e.substring(x.length+1),f=S.slice(h)}}o.loose||(l?o.loose=!0:/\n[ \t]*\n[ \t]*$/.test(c)&&(l=!0));let m=null,g;this.options.gfm&&(m=/^\[[ xX]\] /.exec(u),m&&(g=m[0]!=="[ ] ",u=u.replace(/^\[[ xX]\] +/,""))),o.items.push({type:"list_item",raw:c,task:!!m,checked:g,loose:!1,text:u,tokens:[]}),o.raw+=c}o.items[o.items.length-1].raw=o.items[o.items.length-1].raw.trimEnd(),o.items[o.items.length-1].text=o.items[o.items.length-1].text.trimEnd(),o.raw=o.raw.trimEnd();for(let a=0;af.type==="space"),u=c.length>0&&c.some(f=>/\n.*\n/.test(f.raw));o.loose=u}if(o.loose)for(let a=0;a$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",o=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:r,raw:t[0],href:i,title:o}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!/[:|]/.test(t[2]))return;let r=Op(t[1]),i=t[2].replace(/^\||\| *$/g,"").split("|"),o=t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,"").split(` +`):[],s={type:"table",raw:t[0],header:[],align:[],rows:[]};if(r.length===i.length){for(let l of i)/^ *-+: *$/.test(l)?s.align.push("right"):/^ *:-+: *$/.test(l)?s.align.push("center"):/^ *:-+ *$/.test(l)?s.align.push("left"):s.align.push(null);for(let l=0;l({text:a,tokens:this.lexer.inline(a),header:!1,align:s.align[c]})));return s}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let r=t[1].charAt(t[1].length-1)===` +`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:r,tokens:this.lexer.inline(r)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:We(t[1])}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&/^/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let r=t[2].trim();if(!this.options.pedantic&&/^$/.test(r))return;let s=li(r.slice(0,-1),"\\");if((r.length-s.length)%2===0)return}else{let s=Rk(t[2],"()");if(s>-1){let a=(t[0].indexOf("!")===0?5:4)+t[1].length+s;t[2]=t[2].substring(0,s),t[0]=t[0].substring(0,a).trim(),t[3]=""}}let i=t[2],o="";if(this.options.pedantic){let s=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(i);s&&(i=s[1],o=s[3])}else o=t[3]?t[3].slice(1,-1):"";return i=i.trim(),/^$/.test(r)?i=i.slice(1):i=i.slice(1,-1)),Ap(t,{href:i&&i.replace(this.rules.inline.anyPunctuation,"$1"),title:o&&o.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer)}}reflink(e,t){let r;if((r=this.rules.inline.reflink.exec(e))||(r=this.rules.inline.nolink.exec(e))){let i=(r[2]||r[1]).replace(/\s+/g," "),o=t[i.toLowerCase()];if(!o){let s=r[0].charAt(0);return{type:"text",raw:s,text:s}}return Ap(r,o,r[0],this.lexer)}}emStrong(e,t,r=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(!i||i[3]&&r.match(/[\p{L}\p{N}]/u))return;if(!(i[1]||i[2]||"")||!r||this.rules.inline.punctuation.exec(r)){let s=[...i[0]].length-1,l,a,c=s,u=0,f=i[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(f.lastIndex=0,t=t.slice(-1*e.length+s);(i=f.exec(t))!=null;){if(l=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!l)continue;if(a=[...l].length,i[3]||i[4]){c+=a;continue}else if((i[5]||i[6])&&s%3&&!((s+a)%3)){u+=a;continue}if(c-=a,c>0)continue;a=Math.min(a,a+c+u);let d=[...i[0]][0].length,p=e.slice(0,s+i.index+d+a);if(Math.min(s,a)%2){let m=p.slice(1,-1);return{type:"em",raw:p,text:m,tokens:this.lexer.inlineTokens(m)}}let h=p.slice(2,-2);return{type:"strong",raw:p,text:h,tokens:this.lexer.inlineTokens(h)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let r=t[2].replace(/\n/g," "),i=/[^ ]/.test(r),o=/^ /.test(r)&&/ $/.test(r);return i&&o&&(r=r.substring(1,r.length-1)),r=We(r,!0),{type:"codespan",raw:t[0],text:r}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let r,i;return t[2]==="@"?(r=We(t[1]),i="mailto:"+r):(r=We(t[1]),i=r),{type:"link",raw:t[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let r,i;if(t[2]==="@")r=We(t[0]),i="mailto:"+r;else{let o;do o=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(o!==t[0]);r=We(t[0]),t[1]==="www."?i="http://"+t[0]:i=t[0]}return{type:"link",raw:t[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let r;return this.lexer.state.inRawBlock?r=t[0]:r=We(t[0]),{type:"text",raw:t[0],text:r}}}},Pk=/^(?:[ \t]*(?:\n|$))+/,Lk=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Bk=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,fi=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,zk=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Pp=/(?:[*+-]|\d{1,9}[.)])/,Lp=J(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,Pp).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).getRegex(),Ja=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,$k=/^[^\n]+/,Ga=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Fk=J(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Ga).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Hk=J(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Pp).getRegex(),ps="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Ya=/|$))/,Vk=J("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|\\n*|$)|\\n*|$)|)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Ya).replace("tag",ps).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Bp=J(Ja).replace("hr",fi).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",ps).getRegex(),jk=J(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Bp).getRegex(),Xa={blockquote:jk,code:Lk,def:Fk,fences:Bk,heading:zk,hr:fi,html:Vk,lheading:Lp,list:Hk,newline:Pk,paragraph:Bp,table:ci,text:$k},Np=J("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",fi).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",ps).getRegex(),Wk={...Xa,table:Np,paragraph:J(Ja).replace("hr",fi).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Np).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",ps).getRegex()},_k={...Xa,html:J(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ya).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:ci,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:J(Ja).replace("hr",fi).replace("heading",` *#{1,6} *[^ +]`).replace("lheading",Lp).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},zp=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,qk=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,$p=/^( {2,}|\\)\n(?!\s*$)/,Uk=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\]*?>/g,Gk=J(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,di).getRegex(),Yk=J("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,di).getRegex(),Xk=J("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,di).getRegex(),Qk=J(/\\([punct])/,"gu").replace(/punct/g,di).getRegex(),Zk=J(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),ex=J(Ya).replace("(?:-->|$)","-->").getRegex(),tx=J("^comment|^|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^").replace("comment",ex).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ds=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,nx=J(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",ds).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Fp=J(/^!?\[(label)\]\[(ref)\]/).replace("label",ds).replace("ref",Ga).getRegex(),Hp=J(/^!?\[(ref)\](?:\[\])?/).replace("ref",Ga).getRegex(),rx=J("reflink|nolink(?!\\()","g").replace("reflink",Fp).replace("nolink",Hp).getRegex(),Qa={_backpedal:ci,anyPunctuation:Qk,autolink:Zk,blockSkip:Jk,br:$p,code:qk,del:ci,emStrongLDelim:Gk,emStrongRDelimAst:Yk,emStrongRDelimUnd:Xk,escape:zp,link:nx,nolink:Hp,punctuation:Kk,reflink:Fp,reflinkSearch:rx,tag:tx,text:Uk,url:ci},ix={...Qa,link:J(/^!?\[(label)\]\((.*?)\)/).replace("label",ds).getRegex(),reflink:J(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ds).getRegex()},qa={...Qa,escape:J(zp).replace("])","~|])").getRegex(),url:J(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\(i=l.call({lexer:this},e,t))?(e=e.substring(i.raw.length),t.push(i),!0):!1))){if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length),i.raw.length===1&&t.length>0?t[t.length-1].raw+=` +`:t.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length),o=t[t.length-1],o&&(o.type==="paragraph"||o.type==="text")?(o.raw+=` +`+i.raw,o.text+=` +`+i.text,this.inlineQueue[this.inlineQueue.length-1].src=o.text):t.push(i);continue}if(i=this.tokenizer.fences(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.heading(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.hr(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.blockquote(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.list(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.html(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length),o=t[t.length-1],o&&(o.type==="paragraph"||o.type==="text")?(o.raw+=` +`+i.raw,o.text+=` +`+i.raw,this.inlineQueue[this.inlineQueue.length-1].src=o.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title});continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),t.push(i);continue}if(s=e,this.options.extensions&&this.options.extensions.startBlock){let l=1/0,a=e.slice(1),c;this.options.extensions.startBlock.forEach(u=>{c=u.call({lexer:this},a),typeof c=="number"&&c>=0&&(l=Math.min(l,c))}),l<1/0&&l>=0&&(s=e.substring(0,l+1))}if(this.state.top&&(i=this.tokenizer.paragraph(s))){o=t[t.length-1],r&&o?.type==="paragraph"?(o.raw+=` +`+i.raw,o.text+=` +`+i.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):t.push(i),r=s.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length),o=t[t.length-1],o&&o.type==="text"?(o.raw+=` +`+i.raw,o.text+=` +`+i.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):t.push(i);continue}if(e){let l="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(l);break}else throw new Error(l)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let r,i,o,s=e,l,a,c;if(this.tokens.links){let u=Object.keys(this.tokens.links);if(u.length>0)for(;(l=this.tokenizer.rules.inline.reflinkSearch.exec(s))!=null;)u.includes(l[0].slice(l[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,l.index)+"["+"a".repeat(l[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(l=this.tokenizer.rules.inline.blockSkip.exec(s))!=null;)s=s.slice(0,l.index)+"["+"a".repeat(l[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(l=this.tokenizer.rules.inline.anyPunctuation.exec(s))!=null;)s=s.slice(0,l.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;e;)if(a||(c=""),a=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(u=>(r=u.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))){if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),i=t[t.length-1],i&&r.type==="text"&&i.type==="text"?(i.raw+=r.raw,i.text+=r.text):t.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length),i=t[t.length-1],i&&r.type==="text"&&i.type==="text"?(i.raw+=r.raw,i.text+=r.text):t.push(r);continue}if(r=this.tokenizer.emStrong(e,s,c)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.del(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.autolink(e)){e=e.substring(r.raw.length),t.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}if(o=e,this.options.extensions&&this.options.extensions.startInline){let u=1/0,f=e.slice(1),d;this.options.extensions.startInline.forEach(p=>{d=p.call({lexer:this},f),typeof d=="number"&&d>=0&&(u=Math.min(u,d))}),u<1/0&&u>=0&&(o=e.substring(0,u+1))}if(r=this.tokenizer.inlineText(o)){e=e.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(c=r.raw.slice(-1)),a=!0,i=t[t.length-1],i&&i.type==="text"?(i.raw+=r.raw,i.text+=r.text):t.push(r);continue}if(e){let u="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw new Error(u)}}return t}},fr=class{constructor(e){G(this,"options");G(this,"parser");this.options=e||Pn}space(e){return""}code({text:e,lang:t,escaped:r}){let i=(t||"").match(/^\S*/)?.[0],o=e.replace(/\n$/,"")+` +`;return i?'
'+(r?o:We(o,!0))+`
+`:"
"+(r?o:We(o,!0))+`
+`}blockquote({tokens:e}){return`
+${this.parser.parse(e)}
+`}html({text:e}){return e}heading({tokens:e,depth:t}){return`${this.parser.parseInline(e)} +`}hr(e){return`
+`}list(e){let t=e.ordered,r=e.start,i="";for(let l=0;l +`+i+" +`}listitem(e){let t="";if(e.task){let r=this.checkbox({checked:!!e.checked});e.loose?e.tokens.length>0&&e.tokens[0].type==="paragraph"?(e.tokens[0].text=r+" "+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&e.tokens[0].tokens[0].type==="text"&&(e.tokens[0].tokens[0].text=r+" "+e.tokens[0].tokens[0].text)):e.tokens.unshift({type:"text",raw:r+" ",text:r+" "}):t+=r+" "}return t+=this.parser.parse(e.tokens,!!e.loose),`
  • ${t}
  • +`}checkbox({checked:e}){return"'}paragraph({tokens:e}){return`

    ${this.parser.parseInline(e)}

    +`}table(e){let t="",r="";for(let o=0;o${i}`),` + +`+t+` +`+i+`
    +`}tablerow({text:e}){return` +${e} +`}tablecell(e){let t=this.parser.parseInline(e.tokens),r=e.header?"th":"td";return(e.align?`<${r} align="${e.align}">`:`<${r}>`)+t+` +`}strong({tokens:e}){return`${this.parser.parseInline(e)}`}em({tokens:e}){return`${this.parser.parseInline(e)}`}codespan({text:e}){return`${e}`}br(e){return"
    "}del({tokens:e}){return`${this.parser.parseInline(e)}`}link({href:e,title:t,tokens:r}){let i=this.parser.parseInline(r),o=Mp(e);if(o===null)return i;e=o;let s='
    ",s}image({href:e,title:t,text:r}){let i=Mp(e);if(i===null)return r;e=i;let o=`${r}{let l=o[s].flat(1/0);r=r.concat(this.walkTokens(l,t))}):o.tokens&&(r=r.concat(this.walkTokens(o.tokens,t)))}}return r}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(r=>{let i={...r};if(i.async=this.defaults.async||i.async||!1,r.extensions&&(r.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if("renderer"in o){let s=t.renderers[o.name];s?t.renderers[o.name]=function(...l){let a=o.renderer.apply(this,l);return a===!1&&(a=s.apply(this,l)),a}:t.renderers[o.name]=o.renderer}if("tokenizer"in o){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=t[o.level];s?s.unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}"childTokens"in o&&o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),i.extensions=t),r.renderer){let o=this.defaults.renderer||new fr(this.defaults);for(let s in r.renderer){if(!(s in o))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let l=s,a=r.renderer[l],c=o[l];o[l]=(...u)=>{let f=a.apply(o,u);return f===!1&&(f=c.apply(o,u)),f||""}}i.renderer=o}if(r.tokenizer){let o=this.defaults.tokenizer||new ur(this.defaults);for(let s in r.tokenizer){if(!(s in o))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let l=s,a=r.tokenizer[l],c=o[l];o[l]=(...u)=>{let f=a.apply(o,u);return f===!1&&(f=c.apply(o,u)),f}}i.tokenizer=o}if(r.hooks){let o=this.defaults.hooks||new Rn;for(let s in r.hooks){if(!(s in o))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let l=s,a=r.hooks[l],c=o[l];Rn.passThroughHooks.has(s)?o[l]=u=>{if(this.defaults.async)return Promise.resolve(a.call(o,u)).then(d=>c.call(o,d));let f=a.call(o,u);return c.call(o,f)}:o[l]=(...u)=>{let f=a.apply(o,u);return f===!1&&(f=c.apply(o,u)),f}}i.hooks=o}if(r.walkTokens){let o=this.defaults.walkTokens,s=r.walkTokens;i.walkTokens=function(l){let a=[];return a.push(s.call(this,l)),o&&(a=a.concat(o.call(this,l))),a}}this.defaults={...this.defaults,...i}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return ut.lex(e,t??this.defaults)}parser(e,t){return ft.parse(e,t??this.defaults)}parseMarkdown(e){return(r,i)=>{let o={...i},s={...this.defaults,...o},l=this.onError(!!s.silent,!!s.async);if(this.defaults.async===!0&&o.async===!1)return l(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof r>"u"||r===null)return l(new Error("marked(): input parameter is undefined or null"));if(typeof r!="string")return l(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(r)+", string expected"));s.hooks&&(s.hooks.options=s,s.hooks.block=e);let a=s.hooks?s.hooks.provideLexer():e?ut.lex:ut.lexInline,c=s.hooks?s.hooks.provideParser():e?ft.parse:ft.parseInline;if(s.async)return Promise.resolve(s.hooks?s.hooks.preprocess(r):r).then(u=>a(u,s)).then(u=>s.hooks?s.hooks.processAllTokens(u):u).then(u=>s.walkTokens?Promise.all(this.walkTokens(u,s.walkTokens)).then(()=>u):u).then(u=>c(u,s)).then(u=>s.hooks?s.hooks.postprocess(u):u).catch(l);try{s.hooks&&(r=s.hooks.preprocess(r));let u=a(r,s);s.hooks&&(u=s.hooks.processAllTokens(u)),s.walkTokens&&this.walkTokens(u,s.walkTokens);let f=c(u,s);return s.hooks&&(f=s.hooks.postprocess(f)),f}catch(u){return l(u)}}}onError(e,t){return r=>{if(r.message+=` +Please report this to https://github.com/markedjs/marked.`,e){let i="

    An error occurred:

    "+We(r.message+"",!0)+"
    ";return t?Promise.resolve(i):i}if(t)return Promise.reject(r);throw r}}},In=new Ua;function U(n,e){return In.parse(n,e)}U.options=U.setOptions=function(n){return In.setOptions(n),U.defaults=In.defaults,Dp(U.defaults),U};U.getDefaults=Ka;U.defaults=Pn;U.use=function(...n){return In.use(...n),U.defaults=In.defaults,Dp(U.defaults),U};U.walkTokens=function(n,e){return In.walkTokens(n,e)};U.parseInline=In.parseInline;U.Parser=ft;U.parser=ft.parse;U.Renderer=fr;U.TextRenderer=ui;U.Lexer=ut;U.lexer=ut.lex;U.Tokenizer=ur;U.Hooks=Rn;U.parse=U;var QE=U.options,ZE=U.setOptions,eT=U.use,tT=U.walkTokens,nT=U.parseInline;var rT=ft.parse,iT=ut.lex;var sx=/(^|\n)(#{1,6}\s|>\s|[*-]\s|\d+\.\s|```|---|\*\*[^*]+\*\*|__[^_]+__)|\[[^\]]+\]\([^)]+\)/;function lx(n){return n?sx.test(n):!1}function Vp(n,e){n.pasteHTML(e)}function Wp(n,e){if(n.state?.selection?.$from?.parent?.type?.name==="codeBlock")return!1;let r=e.clipboardData;if(!r)return!1;let i=r.getData("text/html"),o=r.getData("text/plain"),s=r.files||[];return i&&cx(i)?(Vp(n,fx(i)),e.preventDefault(),!0):!i&&o&&lx(o)?(Vp(n,U.parse(o,{breaks:!0,gfm:!0}).trim()),e.preventDefault(),!0):!i&&!o&&s.length>0&&s[0].type?.startsWith("image/")?(e.preventDefault(),!0):!1}var ax=["urn:schemas-microsoft-com:office","mso-","MsoNormal","docs-internal-guid-","data-pm-slice"];function cx(n){return n?ax.some(e=>n.includes(e)):!1}var ux=new Set(["h1","h2","h3","h4","h5","h6","p","br","hr","strong","em","u","s","code","pre","blockquote","ul","ol","li","a","img"]);function jp(n){for(;n.firstChild;)n.parentNode.insertBefore(n.firstChild,n);n.remove()}function fx(n){let e=new DOMParser().parseFromString(n,"text/html");return e.querySelectorAll("style, meta, link, script").forEach(t=>t.remove()),[...e.querySelectorAll("*")].forEach(t=>{let r=t.tagName.toLowerCase();(r.startsWith("o:")||r.startsWith("w:"))&&t.remove()}),[...e.querySelectorAll("*")].forEach(t=>{t.removeAttribute("style"),t.removeAttribute("class"),t.removeAttribute("dir"),t.removeAttribute("lang"),[...t.attributes].forEach(r=>{(r.name.startsWith("mso-")||r.name.startsWith("data-pm-"))&&t.removeAttribute(r.name)})}),e.querySelectorAll("b").forEach(t=>{let r=e.createElement("strong");for(;t.firstChild;)r.appendChild(t.firstChild);t.replaceWith(r)}),e.querySelectorAll("i").forEach(t=>{let r=e.createElement("em");for(;t.firstChild;)r.appendChild(t.firstChild);t.replaceWith(r)}),e.querySelectorAll("font, span").forEach(jp),[...e.body.querySelectorAll("*")].forEach(t=>{ux.has(t.tagName.toLowerCase())||jp(t)}),e.body.innerHTML.trim()}function dx(n,e){n.addEventListener("click",t=>{let r=t.target.closest("[data-cmd]");if(!r)return;t.preventDefault();let[i,o]=r.dataset.cmd.split(":"),s=e.chain().focus();if(i==="setLink"){let l=window.prompt("Link URL");if(!l)return;s.setLink({href:l}).run();return}o?s[i]({level:Number(o)}).run():s[i]().run()})}function px(n){let e=n.querySelector("[data-tiptap-input]"),t=n.querySelector("[data-editor]"),r=n.querySelector("[data-bubble]"),i=new ao({element:t,extensions:[vd.configure({heading:{levels:[2,3]}}),wd,zd.configure({openOnClick:!1,autolink:!0,HTMLAttributes:{rel:"noopener noreferrer"}}),wp.configure({element:r}),Ep],content:e.value,editorProps:{attributes:{class:"prose prose-lg max-w-none focus:outline-none"},handlePaste:(s,l)=>Wp({state:s.state,pasteHTML:a=>i.commands.insertContent(a)},l)},onUpdate:({editor:s})=>{e.value=s.getHTML()}});dx(r,i);let o=e.closest("form");return o&&o.addEventListener("submit",()=>{e.value=i.getHTML()}),i}function _p(){document.querySelectorAll(".tiptap-shell").forEach(px)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",_p):_p();})(); From 5d212685717c0939c4bf790a7775bf4fe652fa8b Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 14 May 2026 23:22:14 +0100 Subject: [PATCH 17/23] Make Tiptap editor 500px-tall clickable surface --- static/blog/tiptap.css | 2 ++ 1 file changed, 2 insertions(+) diff --git a/static/blog/tiptap.css b/static/blog/tiptap.css index 4429f06..4370d90 100644 --- a/static/blog/tiptap.css +++ b/static/blog/tiptap.css @@ -17,6 +17,8 @@ [data-editor] { outline: none; + min-height: 500px; + cursor: text; } [data-editor] p { margin: 0 0 1em; line-height: 1.7; } From 935946c8f61e4e86f2602d012a344be2a568f71c Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 14 May 2026 23:30:50 +0100 Subject: [PATCH 18/23] Pad Tiptap editor (2.5rem/3rem) and suppress inner focus ring --- static/blog/tiptap.css | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/static/blog/tiptap.css b/static/blog/tiptap.css index 4370d90..d74d646 100644 --- a/static/blog/tiptap.css +++ b/static/blog/tiptap.css @@ -11,7 +11,7 @@ .tiptap-root { border: 1px solid var(--md-sys-color-outline-variant, #ccc); border-radius: 12px; - padding: 1.5rem; + padding: 2.5rem 3rem; background: var(--md-sys-color-surface, #fff); } @@ -21,6 +21,15 @@ cursor: text; } +[data-editor] .ProseMirror { + outline: none; +} + +[data-editor] .ProseMirror:focus, +[data-editor] .ProseMirror:focus-visible { + outline: none; +} + [data-editor] p { margin: 0 0 1em; line-height: 1.7; } [data-editor] h1, [data-editor] h2, From c80558df3151d48e088c9f43a7d50b059f9b3122 Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 14 May 2026 23:36:28 +0100 Subject: [PATCH 19/23] Let Tiptap manage bubble-menu visibility (was display:none-blocked) --- static/blog/tiptap.css | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/static/blog/tiptap.css b/static/blog/tiptap.css index d74d646..a377868 100644 --- a/static/blog/tiptap.css +++ b/static/blog/tiptap.css @@ -51,7 +51,8 @@ [data-editor] pre { background: rgba(0,0,0,0.06); padding: 1em; border-radius: 8px; overflow-x: auto; } [data-editor] hr { border: 0; border-top: 1px solid var(--md-sys-color-outline-variant, #ccc); margin: 2em 0; } -/* Bubble toolbar */ +/* Bubble toolbar — Tiptap manages visibility (visibility: hidden by default, + shown on selection). Don't apply display:none or it can't be positioned. */ .bubble-menu { display: flex; gap: 0.25rem; @@ -60,8 +61,8 @@ padding: 0.25rem; border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); + z-index: 1000; } -.bubble-menu[aria-hidden="true"] { display: none; } .bubble-menu button { background: transparent; color: inherit; From 9fc9db9409175a8a90603aa5164ab68ffaf68844 Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 14 May 2026 23:36:37 +0100 Subject: [PATCH 20/23] Drop initial aria-hidden on bubble menu (Tiptap toggles visibility) --- blog/templates/blog/widgets/tiptap.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blog/templates/blog/widgets/tiptap.html b/blog/templates/blog/widgets/tiptap.html index 9f4a2c5..1cd3a56 100644 --- a/blog/templates/blog/widgets/tiptap.html +++ b/blog/templates/blog/widgets/tiptap.html @@ -5,7 +5,7 @@ hidden>{{ widget.value|default_if_none:"" }}
    -