diff --git a/README.md b/README.md
index 9c73ed8..91bcadf 100644
--- a/README.md
+++ b/README.md
@@ -66,8 +66,8 @@
-
-
登录 / 注册 — 居中卡片式表单,简洁无干扰
+
+
发帖 — TipTap 富文本编辑器,支持本地上传图片
---
@@ -80,7 +80,7 @@
|------|------|
| **三栏布局** | 左栏板块菜单(可折叠)+ 中间虚拟滚动帖列表 + 右栏热门/通知/在线 |
| **虚拟滚动** | `@tanstack/react-virtual` 驱动帖列表与楼层回复,长列表依然流畅 |
-| **已读 / 未读** | 未读高亮、角标提醒、批量标记已读 |
+| **帖子排序** | 最新发帖 / 最新回复 / 热门讨论,一键切换 Feed 排序 |
| **主题切换** | 浅色 / 暗色一键切换,跟随 `prefers-color-scheme` 与本地记忆 |
| **响应式** | 平板 / 手机自动收起侧栏,搜索、发帖、登录触手可及 |
| **高密度排版** | V2EX / NGA 风格信息密度,一屏浏览更多内容 |
@@ -89,11 +89,13 @@
- 用户注册 / 登录(bcrypt + JWT Cookie)
- 普通用户 / 管理员两级权限,**首个注册用户自动成为管理员**
-- 板块管理、发帖、Markdown / 富文本、标签、置顶
+- 板块管理、发帖、TipTap 富文本编辑、正文图片本地上传、标签、置顶
+- 帖子修订历史:编辑后保留版本记录,支持 diff 对比查看
+- 可配置编辑时限:管理员设定普通用户修改帖子的有效窗口
- 楼层式评论,支持回复指定楼层、@ 高亮、引用回复
- 点赞、收藏、热门帖、最新动态
-- 管理员后台:删帖、删评论、禁言、SQLite 一键备份
-- 内置敏感词过滤、发帖 / 评论限流
+- 管理员后台:删帖、删评论、禁言、论坛参数配置、敏感词管理、SQLite 一键备份
+- 内置敏感词过滤、发帖 / 评论 / 注册 / 登录限流(后台可配)
### 部署体验
@@ -168,7 +170,7 @@ cd .. && go build -trimpath -ldflags "-s -w" -o dist/jiang13 ./cmd/jiang13
| 层级 | 技术 |
|------|------|
| **后端** | Go 1.26 · Gin · GORM · SQLite |
-| **前端** | React 18 · Radix UI · Tailwind CSS · TanStack Virtual |
+| **前端** | React 18 · TipTap · Radix UI · Tailwind CSS · TanStack Virtual |
| **构建** | Vite → `go:embed` 内嵌 SPA,单二进制发布 |
| **认证** | bcrypt · JWT Cookie |
@@ -224,6 +226,7 @@ data/
├── filter_words.txt # 敏感词配置
├── .jwt_secret # JWT 密钥(自动生成)
├── uploads/avatars/ # 用户头像
+├── uploads/posts/ # 帖子正文图片
└── jiang13_backup_*.db # 后台导出的备份
```
@@ -235,9 +238,10 @@ data/
| 类型 | 示例 |
|------|------|
-| ✅ 已可用 | 三栏布局、暗色主题、虚拟滚动、楼层评论 |
-| ✅ 管理后台 | React SPA:`/admin/dashboard` 仪表盘、帖子置顶、用户禁言等 |
-| 📋 计划中 | 通知已读优化、邮件提醒 |
+| ✅ 已可用 | 三栏布局、暗色主题、虚拟滚动、Feed 排序、楼层评论 |
+| ✅ 发帖体验 | TipTap 富文本、正文图片上传、修订历史、可配置编辑时限 |
+| ✅ 管理后台 | React SPA:仪表盘、帖子置顶、用户禁言、论坛参数与敏感词配置 |
+| 📋 计划中 | 通知动态优化、邮件提醒 |
完整列表见 **[路线图 ROADMAP.md](ROADMAP.md)**。发现问题请提交 [Issues](https://git.iioio.com/freefire/jiang13-forum/issues),认领任务请参考 [CONTRIBUTING.md](CONTRIBUTING.md)。
diff --git a/ROADMAP.md b/ROADMAP.md
index 7098d9b..383385f 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -27,7 +27,7 @@ _当前无已记录缺陷。发现新问题请提交 [Issue](https://git.iioio.c
| 优先级 | 功能 | 说明 |
|--------|------|------|
-| 中 | 通知已读状态优化 | 右栏通知点击后的已读同步 |
+| 中 | 通知动态优化 | 右栏最新动态的展示与交互 |
| 低 | 帖子搜索增强 | 标题/正文/作者组合筛选 |
| 低 | 邮件通知 | 回复提醒(需 SMTP 配置) |
@@ -48,7 +48,11 @@ _当前无公开认领任务。_
- [x] 浅色 / 暗色主题切换
- [x] 移动端响应式适配
- [x] 用户注册登录、JWT 鉴权
-- [x] 板块管理、发帖、Markdown 编辑
+- [x] 板块管理、发帖、TipTap 富文本编辑
+- [x] 帖子正文图片本地上传
+- [x] 帖子修订历史与 diff 对比
+- [x] Feed 排序(最新发帖 / 最新回复 / 热门讨论)
+- [x] 可配置编辑时限与论坛参数(限流、字数上限等)
- [x] 楼层式评论、引用回复、@ 高亮
- [x] 点赞、收藏、热门帖
- [x] 敏感词过滤、发帖限流
@@ -64,4 +68,4 @@ _当前无公开认领任务。_
---
-_最后更新:2026-06-15_
+_最后更新:2026-06-16_
diff --git a/config/config.go b/config/config.go
index 7e81730..ffa0ed7 100644
--- a/config/config.go
+++ b/config/config.go
@@ -34,6 +34,10 @@ func Parse() (*Config, error) {
if err := os.MkdirAll(uploadDir, 0755); err != nil {
return nil, fmt.Errorf("创建上传目录失败: %w", err)
}
+ postImgDir := filepath.Join(*dataDir, "uploads", "posts")
+ if err := os.MkdirAll(postImgDir, 0755); err != nil {
+ return nil, fmt.Errorf("创建帖子图片目录失败: %w", err)
+ }
cfg := &Config{
Port: *port,
@@ -61,11 +65,21 @@ func (c *Config) DBPath() string {
return filepath.Join(c.DataDir, "jiang13.db")
}
-// UploadDir 返回头像上传目录
-func (c *Config) UploadDir() string {
+// AvatarUploadDir 返回头像上传目录
+func (c *Config) AvatarUploadDir() string {
return filepath.Join(c.DataDir, "uploads", "avatars")
}
+// PostImageUploadDir 返回帖子正文图片上传目录
+func (c *Config) PostImageUploadDir() string {
+ return filepath.Join(c.DataDir, "uploads", "posts")
+}
+
+// UploadDir 返回头像上传目录(兼容旧调用)
+func (c *Config) UploadDir() string {
+ return c.AvatarUploadDir()
+}
+
// FilterWordsPath 返回敏感词配置文件路径
func (c *Config) FilterWordsPath() string {
return filepath.Join(c.DataDir, "filter_words.txt")
diff --git a/embed_static/static/spa/assets/AdminCommentsPage-DgkfVIER.js b/embed_static/static/spa/assets/AdminCommentsPage-Z5_wmIqo.js
similarity index 93%
rename from embed_static/static/spa/assets/AdminCommentsPage-DgkfVIER.js
rename to embed_static/static/spa/assets/AdminCommentsPage-Z5_wmIqo.js
index 28b7705..fa20e6e 100644
--- a/embed_static/static/spa/assets/AdminCommentsPage-DgkfVIER.js
+++ b/embed_static/static/spa/assets/AdminCommentsPage-Z5_wmIqo.js
@@ -1 +1 @@
-import{e as A,r as i,j as e}from"./react-vendor-CFzzFOsg.js";import{d as D,S as C,B as d,a as m,n as c}from"./index-L-Mx2Hle.js";import{B as N}from"./badge-e5OBoJ6g.js";import{A as y,a as b,b as k,c as S,d as _,e as z,f as B,g as E,h as P}from"./alert-dialog-Q1fPYDxo.js";import"./ui-vendor-DGgNN2YO.js";function G(){const j=A(),{ready:r}=D(),[o,g]=i.useState([]),[p,h]=i.useState(!0),[a,u]=i.useState(1),[l,f]=i.useState(1),n=(s=a)=>{h(!0),m.adminComments(s).then(t=>{g(t.comments??[]),u(t.page),f(t.total_pages)}).catch(t=>c.error(t.message)).finally(()=>h(!1))};i.useEffect(()=>{r&&n(1)},[r]);const v=async s=>{try{await m.adminDeleteComment(s),c.success("评论已删除"),n()}catch(t){c.error(t instanceof Error?t.message:"删除失败")}};return r?e.jsxs("div",{className:"admin-page",children:[e.jsxs("div",{className:"admin-page-head",children:[e.jsx("h1",{children:"评论管理"}),e.jsx("p",{children:"查看与删除楼层评论"})]}),e.jsx("div",{className:"admin-card",children:p?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(C,{size:"lg"})}):e.jsxs(e.Fragment,{children:[e.jsxs("table",{className:"admin-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"ID"}),e.jsx("th",{children:"楼层"}),e.jsx("th",{children:"帖子"}),e.jsx("th",{children:"作者"}),e.jsx("th",{children:"内容"}),e.jsx("th",{children:"私密"}),e.jsx("th",{children:"时间"}),e.jsx("th",{children:"操作"})]})}),e.jsx("tbody",{children:o.map(s=>{var t,x;return e.jsxs("tr",{children:[e.jsx("td",{children:s.id}),e.jsxs("td",{children:["#",s.floor]}),e.jsx("td",{children:e.jsx("button",{type:"button",className:"admin-text-link",onClick:()=>j(`/post/${s.post_id}`),children:((t=s.post)==null?void 0:t.title)??`#${s.post_id}`})}),e.jsx("td",{children:((x=s.user)==null?void 0:x.nickname)||s.guest_nick||"游客"}),e.jsx("td",{className:"max-w-[200px] truncate",children:s.content}),e.jsx("td",{children:s.is_private?e.jsx(N,{variant:"secondary",children:"是"}):"—"}),e.jsx("td",{children:new Date(s.created_at).toLocaleString("zh-CN")}),e.jsx("td",{children:e.jsxs(y,{children:[e.jsx(b,{asChild:!0,children:e.jsx(d,{size:"sm",variant:"ghost",className:"text-destructive",children:"删除"})}),e.jsxs(k,{children:[e.jsxs(S,{children:[e.jsx(_,{children:"确定删除该评论?"}),e.jsx(z,{children:"此操作不可恢复。"})]}),e.jsxs(B,{children:[e.jsx(E,{children:"取消"}),e.jsx(P,{onClick:()=>v(s.id),children:"删除"})]})]})]})})]},s.id)})})]}),o.length===0&&e.jsx("div",{className:"admin-empty",children:"暂无评论"}),l>1&&e.jsxs("div",{className:"admin-pagination",children:[e.jsx(d,{size:"sm",variant:"outline",disabled:a<=1,onClick:()=>n(a-1),children:"上一页"}),e.jsxs("span",{children:["第 ",a," / ",l," 页"]}),e.jsx(d,{size:"sm",variant:"outline",disabled:a>=l,onClick:()=>n(a+1),children:"下一页"})]})]})})]}):null}export{G as default};
+import{e as A,r as i,j as e}from"./react-vendor-CFzzFOsg.js";import{e as D,S as C,B as d,a as m,n as c}from"./index-5C0q-ZMs.js";import{B as N}from"./badge-DB-zL5ml.js";import{A as y,a as b,b as k,c as S,d as _,e as z,f as B,g as E,h as P}from"./alert-dialog-BoQ7HSUR.js";import"./ui-vendor-BtpOfToU.js";function G(){const j=A(),{ready:r}=D(),[o,g]=i.useState([]),[p,h]=i.useState(!0),[a,u]=i.useState(1),[l,f]=i.useState(1),n=(s=a)=>{h(!0),m.adminComments(s).then(t=>{g(t.comments??[]),u(t.page),f(t.total_pages)}).catch(t=>c.error(t.message)).finally(()=>h(!1))};i.useEffect(()=>{r&&n(1)},[r]);const v=async s=>{try{await m.adminDeleteComment(s),c.success("评论已删除"),n()}catch(t){c.error(t instanceof Error?t.message:"删除失败")}};return r?e.jsxs("div",{className:"admin-page",children:[e.jsxs("div",{className:"admin-page-head",children:[e.jsx("h1",{children:"评论管理"}),e.jsx("p",{children:"查看与删除楼层评论"})]}),e.jsx("div",{className:"admin-card",children:p?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(C,{size:"lg"})}):e.jsxs(e.Fragment,{children:[e.jsxs("table",{className:"admin-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"ID"}),e.jsx("th",{children:"楼层"}),e.jsx("th",{children:"帖子"}),e.jsx("th",{children:"作者"}),e.jsx("th",{children:"内容"}),e.jsx("th",{children:"私密"}),e.jsx("th",{children:"时间"}),e.jsx("th",{children:"操作"})]})}),e.jsx("tbody",{children:o.map(s=>{var t,x;return e.jsxs("tr",{children:[e.jsx("td",{children:s.id}),e.jsxs("td",{children:["#",s.floor]}),e.jsx("td",{children:e.jsx("button",{type:"button",className:"admin-text-link",onClick:()=>j(`/post/${s.post_id}`),children:((t=s.post)==null?void 0:t.title)??`#${s.post_id}`})}),e.jsx("td",{children:((x=s.user)==null?void 0:x.nickname)||s.guest_nick||"游客"}),e.jsx("td",{className:"max-w-[200px] truncate",children:s.content}),e.jsx("td",{children:s.is_private?e.jsx(N,{variant:"secondary",children:"是"}):"—"}),e.jsx("td",{children:new Date(s.created_at).toLocaleString("zh-CN")}),e.jsx("td",{children:e.jsxs(y,{children:[e.jsx(b,{asChild:!0,children:e.jsx(d,{size:"sm",variant:"ghost",className:"text-destructive",children:"删除"})}),e.jsxs(k,{children:[e.jsxs(S,{children:[e.jsx(_,{children:"确定删除该评论?"}),e.jsx(z,{children:"此操作不可恢复。"})]}),e.jsxs(B,{children:[e.jsx(E,{children:"取消"}),e.jsx(P,{onClick:()=>v(s.id),children:"删除"})]})]})]})})]},s.id)})})]}),o.length===0&&e.jsx("div",{className:"admin-empty",children:"暂无评论"}),l>1&&e.jsxs("div",{className:"admin-pagination",children:[e.jsx(d,{size:"sm",variant:"outline",disabled:a<=1,onClick:()=>n(a-1),children:"上一页"}),e.jsxs("span",{children:["第 ",a," / ",l," 页"]}),e.jsx(d,{size:"sm",variant:"outline",disabled:a>=l,onClick:()=>n(a+1),children:"下一页"})]})]})})]}):null}export{G as default};
diff --git a/embed_static/static/spa/assets/AdminDashboardPage-BPcWHcOy.js b/embed_static/static/spa/assets/AdminDashboardPage-DvIYRHwe.js
similarity index 94%
rename from embed_static/static/spa/assets/AdminDashboardPage-BPcWHcOy.js
rename to embed_static/static/spa/assets/AdminDashboardPage-DvIYRHwe.js
index 88f1404..72d7d30 100644
--- a/embed_static/static/spa/assets/AdminDashboardPage-BPcWHcOy.js
+++ b/embed_static/static/spa/assets/AdminDashboardPage-DvIYRHwe.js
@@ -1 +1 @@
-import{e as h,r as n,j as s}from"./react-vendor-CFzzFOsg.js";import{d as o,a as x,S as j}from"./index-L-Mx2Hle.js";import{B as u}from"./badge-e5OBoJ6g.js";import"./ui-vendor-DGgNN2YO.js";function f(){const l=h(),{ready:t}=o(),[e,d]=n.useState(null),[r,c]=n.useState(!0);if(n.useEffect(()=>{t&&x.adminDashboard().then(d).finally(()=>c(!1))},[t]),!t||r)return s.jsx("div",{className:"flex justify-center py-16",children:s.jsx(j,{size:"lg"})});if(!e)return null;const m=[{label:"注册用户",value:e.users,cls:"admin-stat-users"},{label:"帖子总数",value:e.posts,cls:"admin-stat-posts"},{label:"板块数量",value:e.boards,cls:"admin-stat-boards"},{label:"评论总数",value:e.comments,cls:"admin-stat-comments"},{label:"当前在线",value:e.online,cls:"admin-stat-online"}];return s.jsxs("div",{className:"admin-page",children:[s.jsxs("div",{className:"admin-page-head",children:[s.jsx("h1",{children:"仪表盘"}),s.jsx("p",{children:"论坛运行概览与最新帖子"})]}),s.jsx("div",{className:"admin-stat-grid",children:m.map(a=>s.jsxs("div",{className:`admin-stat-card ${a.cls}`,children:[s.jsx("div",{className:"admin-stat-value",children:a.value}),s.jsx("div",{className:"admin-stat-label",children:a.label})]},a.label))}),s.jsxs("div",{className:"admin-card",children:[s.jsxs("div",{className:"admin-card-head",children:[s.jsx("span",{children:"最新帖子"}),s.jsx("button",{type:"button",className:"admin-text-link",onClick:()=>l("/admin/posts"),children:"查看全部 →"})]}),s.jsxs("table",{className:"admin-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"ID"}),s.jsx("th",{children:"标题"}),s.jsx("th",{children:"作者"}),s.jsx("th",{children:"置顶"}),s.jsx("th",{children:"时间"})]})}),s.jsx("tbody",{children:e.recent_posts.map(a=>{var i;return s.jsxs("tr",{children:[s.jsx("td",{children:a.id}),s.jsx("td",{children:s.jsx("button",{type:"button",className:"admin-text-link",onClick:()=>l(`/post/${a.id}`),children:a.title})}),s.jsx("td",{children:((i=a.user)==null?void 0:i.nickname)??"—"}),s.jsx("td",{children:a.pinned?s.jsx(u,{variant:"orange",children:"是"}):"—"}),s.jsx("td",{children:new Date(a.created_at).toLocaleString("zh-CN")})]},a.id)})})]}),e.recent_posts.length===0&&s.jsx("div",{className:"admin-empty",children:"暂无帖子"})]})]})}export{f as default};
+import{e as h,r as n,j as s}from"./react-vendor-CFzzFOsg.js";import{e as o,a as x,S as j}from"./index-5C0q-ZMs.js";import{B as u}from"./badge-DB-zL5ml.js";import"./ui-vendor-BtpOfToU.js";function f(){const l=h(),{ready:t}=o(),[e,d]=n.useState(null),[r,c]=n.useState(!0);if(n.useEffect(()=>{t&&x.adminDashboard().then(d).finally(()=>c(!1))},[t]),!t||r)return s.jsx("div",{className:"flex justify-center py-16",children:s.jsx(j,{size:"lg"})});if(!e)return null;const m=[{label:"注册用户",value:e.users,cls:"admin-stat-users"},{label:"帖子总数",value:e.posts,cls:"admin-stat-posts"},{label:"板块数量",value:e.boards,cls:"admin-stat-boards"},{label:"评论总数",value:e.comments,cls:"admin-stat-comments"},{label:"当前在线",value:e.online,cls:"admin-stat-online"}];return s.jsxs("div",{className:"admin-page",children:[s.jsxs("div",{className:"admin-page-head",children:[s.jsx("h1",{children:"仪表盘"}),s.jsx("p",{children:"论坛运行概览与最新帖子"})]}),s.jsx("div",{className:"admin-stat-grid",children:m.map(a=>s.jsxs("div",{className:`admin-stat-card ${a.cls}`,children:[s.jsx("div",{className:"admin-stat-value",children:a.value}),s.jsx("div",{className:"admin-stat-label",children:a.label})]},a.label))}),s.jsxs("div",{className:"admin-card",children:[s.jsxs("div",{className:"admin-card-head",children:[s.jsx("span",{children:"最新帖子"}),s.jsx("button",{type:"button",className:"admin-text-link",onClick:()=>l("/admin/posts"),children:"查看全部 →"})]}),s.jsxs("table",{className:"admin-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"ID"}),s.jsx("th",{children:"标题"}),s.jsx("th",{children:"作者"}),s.jsx("th",{children:"置顶"}),s.jsx("th",{children:"时间"})]})}),s.jsx("tbody",{children:e.recent_posts.map(a=>{var i;return s.jsxs("tr",{children:[s.jsx("td",{children:a.id}),s.jsx("td",{children:s.jsx("button",{type:"button",className:"admin-text-link",onClick:()=>l(`/post/${a.id}`),children:a.title})}),s.jsx("td",{children:((i=a.user)==null?void 0:i.nickname)??"—"}),s.jsx("td",{children:a.pinned?s.jsx(u,{variant:"orange",children:"是"}):"—"}),s.jsx("td",{children:new Date(a.created_at).toLocaleString("zh-CN")})]},a.id)})})]}),e.recent_posts.length===0&&s.jsx("div",{className:"admin-empty",children:"暂无帖子"})]})]})}export{f as default};
diff --git a/embed_static/static/spa/assets/AdminPostsPage-D3j3Buvt.js b/embed_static/static/spa/assets/AdminPostsPage-D3j3Buvt.js
deleted file mode 100644
index 34a90cf..0000000
--- a/embed_static/static/spa/assets/AdminPostsPage-D3j3Buvt.js
+++ /dev/null
@@ -1 +0,0 @@
-import{e as w,r as i,j as e}from"./react-vendor-CFzzFOsg.js";import{d as P,B as n,S,a as o,n as r}from"./index-L-Mx2Hle.js";import{I as z}from"./input-CIPYpxcv.js";import{B as v}from"./badge-e5OBoJ6g.js";import{A as E,a as _,b as L,c as F,d as B,e as I,f as T,g as G,h as H}from"./alert-dialog-Q1fPYDxo.js";import{c as K}from"./feedCache-D2GnU_BI.js";import{l as O,ac as R,E as $}from"./ui-vendor-DGgNN2YO.js";function X(){const p=w(),{ready:h}=P(),[j,k]=i.useState([]),[y,m]=i.useState(!0),[c,A]=i.useState(1),[x,D]=i.useState(1),[g,u]=i.useState(""),[d,f]=i.useState(""),l=(s=c,t=d)=>{m(!0),o.adminPosts({page:s,keyword:t}).then(a=>{k(a.posts??[]),A(a.page),D(a.total_pages)}).catch(a=>r.error(a.message)).finally(()=>m(!1))};i.useEffect(()=>{h&&l(1,d)},[h,d]);const N=async s=>{try{const t=await o.adminPinPost(s.id,!s.pinned);K(),window.dispatchEvent(new Event("posts-refresh")),r.success(t.message),l()}catch(t){r.error(t instanceof Error?t.message:"操作失败")}},b=async s=>{try{const t=await o.adminLockPost(s.id,!s.edit_locked);r.success(t.message),l()}catch(t){r.error(t instanceof Error?t.message:"操作失败")}},C=async s=>{try{await o.adminDeletePost(s),r.success("帖子已删除"),l()}catch(t){r.error(t instanceof Error?t.message:"删除失败")}};return h?e.jsxs("div",{className:"admin-page",children:[e.jsxs("div",{className:"admin-page-head",children:[e.jsx("h1",{children:"帖子管理"}),e.jsx("p",{children:"置顶、删除帖子,搜索标题关键词"})]}),e.jsxs("form",{className:"admin-search-bar",onSubmit:s=>{s.preventDefault(),f(g.trim())},children:[e.jsx(z,{value:g,onChange:s=>u(s.target.value),placeholder:"搜索帖子标题…"}),e.jsxs(n,{type:"submit",children:[e.jsx(O,{size:16}),"搜索"]}),d&&e.jsx(n,{type:"button",variant:"outline",onClick:()=>{u(""),f("")},children:"清除"})]}),e.jsx("div",{className:"admin-card",children:y?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(S,{size:"lg"})}):e.jsxs(e.Fragment,{children:[e.jsxs("table",{className:"admin-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"ID"}),e.jsx("th",{children:"标题"}),e.jsx("th",{children:"板块"}),e.jsx("th",{children:"作者"}),e.jsx("th",{children:"置顶"}),e.jsx("th",{children:"锁定"}),e.jsx("th",{children:"点赞"}),e.jsx("th",{children:"浏览"}),e.jsx("th",{children:"时间"}),e.jsx("th",{children:"操作"})]})}),e.jsx("tbody",{children:j.map(s=>{var t,a;return e.jsxs("tr",{children:[e.jsx("td",{children:s.id}),e.jsx("td",{className:"max-w-[220px] truncate",children:e.jsx("button",{type:"button",className:"admin-text-link",onClick:()=>p(`/post/${s.id}`),children:s.title})}),e.jsx("td",{children:((t=s.board)==null?void 0:t.name)??"—"}),e.jsx("td",{children:((a=s.user)==null?void 0:a.nickname)??"—"}),e.jsx("td",{children:s.pinned?e.jsx(v,{variant:"orange",children:"是"}):"—"}),e.jsx("td",{children:s.edit_locked?e.jsx(v,{variant:"destructive",children:"是"}):"—"}),e.jsx("td",{children:s.like_count}),e.jsx("td",{children:s.view_count}),e.jsx("td",{children:new Date(s.created_at).toLocaleString("zh-CN")}),e.jsx("td",{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(n,{size:"sm",variant:"outline",onClick:()=>N(s),children:s.pinned?"取消置顶":"置顶"}),e.jsx(n,{size:"sm",variant:"outline",onClick:()=>b(s),children:s.edit_locked?e.jsxs(e.Fragment,{children:[e.jsx(R,{size:14})," 解锁"]}):e.jsxs(e.Fragment,{children:[e.jsx($,{size:14})," 锁定"]})}),e.jsxs(E,{children:[e.jsx(_,{asChild:!0,children:e.jsx(n,{size:"sm",variant:"ghost",className:"text-destructive",children:"删除"})}),e.jsxs(L,{children:[e.jsxs(F,{children:[e.jsx(B,{children:"确定删除该帖子?"}),e.jsx(I,{children:"相关评论也将一并删除,不可恢复。"})]}),e.jsxs(T,{children:[e.jsx(G,{children:"取消"}),e.jsx(H,{onClick:()=>C(s.id),children:"删除"})]})]})]})]})})]},s.id)})})]}),j.length===0&&e.jsx("div",{className:"admin-empty",children:"没有找到帖子"}),x>1&&e.jsxs("div",{className:"admin-pagination",children:[e.jsx(n,{size:"sm",variant:"outline",disabled:c<=1,onClick:()=>l(c-1),children:"上一页"}),e.jsxs("span",{children:["第 ",c," / ",x," 页"]}),e.jsx(n,{size:"sm",variant:"outline",disabled:c>=x,onClick:()=>l(c+1),children:"下一页"})]})]})})]}):null}export{X as default};
diff --git a/embed_static/static/spa/assets/AdminPostsPage-D7MOxCPU.js b/embed_static/static/spa/assets/AdminPostsPage-D7MOxCPU.js
new file mode 100644
index 0000000..0a37729
--- /dev/null
+++ b/embed_static/static/spa/assets/AdminPostsPage-D7MOxCPU.js
@@ -0,0 +1 @@
+import{e as _,r as i,j as e}from"./react-vendor-CFzzFOsg.js";import{e as P,B as n,S as z,a as m,n as r}from"./index-5C0q-ZMs.js";import{I as E}from"./input-CE0PJTgJ.js";import{B as j}from"./badge-DB-zL5ml.js";import{A as L,a as T,b as F,c as B,d as I,e as G,f as H,g as K,h as O}from"./alert-dialog-BoQ7HSUR.js";import{c as R}from"./feedCache-D2GnU_BI.js";import{i as $}from"./content-BrFHUpp8.js";import{l as q,ac as J,E as M}from"./ui-vendor-BtpOfToU.js";function N(o){const c=new Date(o);return Number.isNaN(c.getTime())?o:c.toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function se(){const o=_(),{ready:c}=P(),[u,k]=i.useState([]),[b,g]=i.useState(!0),[d,w]=i.useState(1),[x,A]=i.useState(1),[f,p]=i.useState(""),[h,v]=i.useState(""),l=(s=d,t=h)=>{g(!0),m.adminPosts({page:s,keyword:t}).then(a=>{k(a.posts??[]),w(a.page),A(a.total_pages)}).catch(a=>r.error(a.message)).finally(()=>g(!1))};i.useEffect(()=>{c&&l(1,h)},[c,h]);const D=async s=>{try{const t=await m.adminPinPost(s.id,!s.pinned);R(),window.dispatchEvent(new Event("posts-refresh")),r.success(t.message),l()}catch(t){r.error(t instanceof Error?t.message:"操作失败")}},C=async s=>{try{const t=await m.adminLockPost(s.id,!s.edit_locked);r.success(t.message),l()}catch(t){r.error(t instanceof Error?t.message:"操作失败")}},S=async s=>{try{await m.adminDeletePost(s),r.success("帖子已删除"),l()}catch(t){r.error(t instanceof Error?t.message:"删除失败")}};return c?e.jsxs("div",{className:"admin-page",children:[e.jsxs("div",{className:"admin-page-head",children:[e.jsx("h1",{children:"帖子管理"}),e.jsx("p",{children:"置顶、锁定编辑、删除帖子;支持按标题、标签或正文关键词搜索"})]}),e.jsxs("form",{className:"admin-search-bar",onSubmit:s=>{s.preventDefault(),v(f.trim())},children:[e.jsx(E,{value:f,onChange:s=>p(s.target.value),placeholder:"搜索标题、标签或正文…"}),e.jsxs(n,{type:"submit",children:[e.jsx(q,{size:16}),"搜索"]}),h&&e.jsx(n,{type:"button",variant:"outline",onClick:()=>{p(""),v("")},children:"清除"})]}),e.jsx("div",{className:"admin-card",children:b?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(z,{size:"lg"})}):e.jsxs(e.Fragment,{children:[e.jsxs("table",{className:"admin-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"ID"}),e.jsx("th",{children:"标题"}),e.jsx("th",{children:"板块"}),e.jsx("th",{children:"作者"}),e.jsx("th",{children:"标签"}),e.jsx("th",{children:"评论"}),e.jsx("th",{children:"置顶"}),e.jsx("th",{children:"锁定"}),e.jsx("th",{children:"点赞"}),e.jsx("th",{children:"浏览"}),e.jsx("th",{children:"时间"}),e.jsx("th",{children:"操作"})]})}),e.jsx("tbody",{children:u.map(s=>{var a,y;const t=s.updated_at&&$(s.created_at,s.updated_at);return e.jsxs("tr",{children:[e.jsx("td",{children:s.id}),e.jsxs("td",{className:"max-w-[200px] truncate",children:[e.jsx("button",{type:"button",className:"admin-text-link",onClick:()=>o(`/post/${s.id}`),children:s.title}),t&&e.jsx(j,{variant:"secondary",className:"ml-1",children:"已编辑"})]}),e.jsx("td",{children:((a=s.board)==null?void 0:a.name)??"—"}),e.jsx("td",{children:((y=s.user)==null?void 0:y.nickname)??"—"}),e.jsx("td",{className:"max-w-[120px] truncate text-muted-foreground",children:s.tags||"—"}),e.jsx("td",{children:s.comment_count??0}),e.jsx("td",{children:s.pinned?e.jsx(j,{variant:"orange",children:"是"}):"—"}),e.jsx("td",{children:s.edit_locked?e.jsx(j,{variant:"destructive",children:"是"}):"—"}),e.jsx("td",{children:s.like_count}),e.jsx("td",{children:s.view_count}),e.jsxs("td",{className:"text-sm whitespace-nowrap",children:[e.jsx("span",{children:N(s.created_at)}),t&&s.updated_at&&e.jsxs("span",{className:"block text-muted-foreground text-xs",children:["改于 ",N(s.updated_at)]})]}),e.jsx("td",{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(n,{size:"sm",variant:"outline",onClick:()=>D(s),children:s.pinned?"取消置顶":"置顶"}),e.jsx(n,{size:"sm",variant:"outline",onClick:()=>C(s),children:s.edit_locked?e.jsxs(e.Fragment,{children:[e.jsx(J,{size:14})," 解锁"]}):e.jsxs(e.Fragment,{children:[e.jsx(M,{size:14})," 锁定"]})}),e.jsxs(L,{children:[e.jsx(T,{asChild:!0,children:e.jsx(n,{size:"sm",variant:"ghost",className:"text-destructive",children:"删除"})}),e.jsxs(F,{children:[e.jsxs(B,{children:[e.jsx(I,{children:"确定删除该帖子?"}),e.jsx(G,{children:"相关评论也将一并删除,不可恢复。"})]}),e.jsxs(H,{children:[e.jsx(K,{children:"取消"}),e.jsx(O,{onClick:()=>S(s.id),children:"删除"})]})]})]})]})})]},s.id)})})]}),u.length===0&&e.jsx("div",{className:"admin-empty",children:"没有找到帖子"}),x>1&&e.jsxs("div",{className:"admin-pagination",children:[e.jsx(n,{size:"sm",variant:"outline",disabled:d<=1,onClick:()=>l(d-1),children:"上一页"}),e.jsxs("span",{children:["第 ",d," / ",x," 页"]}),e.jsx(n,{size:"sm",variant:"outline",disabled:d>=x,onClick:()=>l(d+1),children:"下一页"})]})]})})]}):null}export{se as default};
diff --git a/embed_static/static/spa/assets/AdminSettingsPage-BvAGktom.js b/embed_static/static/spa/assets/AdminSettingsPage-BvAGktom.js
new file mode 100644
index 0000000..b548cc4
--- /dev/null
+++ b/embed_static/static/spa/assets/AdminSettingsPage-BvAGktom.js
@@ -0,0 +1,3 @@
+import{r as t,j as s}from"./react-vendor-CFzzFOsg.js";import{e as B,a as u,S as z,B as g,n as d,i as I}from"./index-5C0q-ZMs.js";import{I as L}from"./input-CE0PJTgJ.js";import{T as M}from"./textarea-VyK9_GFn.js";import{am as A,an as W,ao as Y,ap as $}from"./ui-vendor-BtpOfToU.js";const f=[{id:"rule",title:"编辑规则",summary:"控制普通用户修改自己帖子的时限",rows:[{key:"post_edit_window_hours",label:"可编辑时限",unit:"小时",hint:"0 = 不限",min:0}]},{id:"rate",title:"操作限流",summary:"同一用户或 IP 在窗口期内的最大请求次数",rows:[{key:"rate_limit_window_sec",label:"限流窗口",unit:"秒",min:10},{key:"rate_limit_post",label:"发帖",unit:"次",min:1},{key:"rate_limit_comment",label:"评论",unit:"次",min:1},{key:"rate_limit_register",label:"注册",unit:"次",min:1},{key:"rate_limit_login",label:"登录",unit:"次",min:1}]},{id:"content",title:"内容长度",summary:"发帖与评论的字数上限,服务端强制校验",rows:[{key:"post_title_max",label:"帖子标题",unit:"字",min:1},{key:"post_tags_max",label:"帖子标签",unit:"字",hint:"0 = 不限",min:0},{key:"post_content_max",label:"帖子正文",unit:"字",hint:"0 = 不限",min:0},{key:"comment_max",label:"评论内容",unit:"字",min:1}]},{id:"search",title:"搜索与列表",summary:"关键词长度与帖子列表分页",rows:[{key:"search_keyword_min",label:"关键词最短",unit:"字",min:0},{key:"search_keyword_max",label:"关键词最长",unit:"字",min:1},{key:"page_size_default",label:"默认每页",unit:"条",min:1},{key:"page_size_max",label:"最大每页",unit:"条",min:1}]},{id:"user",title:"用户账号",summary:"注册、改密与头像上传限制",rows:[{key:"password_min_len",label:"密码最短",unit:"位",min:4},{key:"avatar_max_mb",label:"头像上限",unit:"MB",min:1}]}],D=[{id:"limits",label:"论坛限制",icon:A},{id:"filter",label:"敏感词",icon:W},{id:"system",label:"系统维护",icon:Y}];function H({sections:r,limits:l,onChange:c}){return s.jsx("div",{className:"admin-settings-sections",children:r.map(a=>s.jsxs("section",{className:"admin-settings-section",id:`settings-${a.id}`,children:[s.jsxs("div",{className:"admin-settings-section-head",children:[s.jsx("h3",{children:a.title}),s.jsx("p",{children:a.summary})]}),s.jsx("div",{className:"admin-settings-table",role:"group","aria-label":a.title,children:a.rows.map(i=>s.jsxs("div",{className:"admin-settings-row",children:[s.jsx("label",{htmlFor:`limit-${i.key}`,className:"admin-settings-row-label",children:i.label}),s.jsxs("div",{className:"admin-settings-row-input",children:[s.jsx(L,{id:`limit-${i.key}`,type:"number",min:i.min??0,value:l[i.key],onChange:m=>c(i.key,m.target.value),className:"admin-settings-input"}),i.unit&&s.jsx("span",{className:"admin-settings-unit",children:i.unit})]}),s.jsx("span",{className:"admin-settings-row-hint",children:i.hint??""})]},i.key))})]},a.id))})}function R(){const{ready:r}=B(),[l,c]=t.useState(null),[a,i]=t.useState(null),[m,j]=t.useState(""),[o,_]=t.useState("limits"),[N,v]=t.useState(!0),[k,p]=t.useState(!1),[S,y]=t.useState(!1),[w,b]=t.useState(!1);t.useEffect(()=>{r&&u.adminSettings().then(e=>{c(e),i(e.limits),j(e.filter_words)}).finally(()=>v(!1))},[r]);const C=(e,n)=>{const h=parseInt(n,10);Number.isNaN(h)||i(x=>x&&{...x,[e]:h})},F=async()=>{if(a){y(!0);try{const e=await u.adminUpdateForumSettings(a);d.success(e.message),I(),i(e.limits),c(n=>n&&{...n,limits:e.limits})}catch(e){d.error(e instanceof Error?e.message:"保存失败")}finally{y(!1)}}},T=async()=>{b(!0);try{const e=await u.adminUpdateFilterWords(m);d.success(e.message),c(n=>n&&{...n,filter_words:m,filter_word_count:e.word_count})}catch(e){d.error(e instanceof Error?e.message:"保存失败")}finally{b(!1)}},E=async()=>{p(!0);try{const e=await u.adminBackup();d.success(e.message),window.location.href=e.download}catch(e){d.error(e instanceof Error?e.message:"备份失败")}finally{p(!1)}};return!r||N?s.jsx("div",{className:"flex justify-center py-16",children:s.jsx(z,{size:"lg"})}):!l||!a?null:s.jsxs("div",{className:"admin-settings-page",children:[s.jsxs("header",{className:"admin-page-head",children:[s.jsx("h1",{children:"系统设置"}),s.jsx("p",{children:"管理论坛运行规则、敏感词过滤与数据维护"})]}),s.jsx("nav",{className:"admin-settings-tabs","aria-label":"设置分类",children:D.map(({id:e,label:n,icon:h})=>s.jsxs("button",{type:"button",className:`admin-settings-tab${o===e?" active":""}`,onClick:()=>_(e),"aria-selected":o===e,children:[s.jsx(h,{size:15}),n]},e))}),o==="limits"&&s.jsxs("div",{className:"admin-settings-panel",children:[s.jsxs("div",{className:"admin-card admin-settings-card",children:[s.jsxs("div",{className:"admin-card-head",children:[s.jsx("span",{children:"论坛限制"}),s.jsxs("span",{className:"admin-settings-card-badge",children:["共 ",f.length," 组"]})]}),s.jsx("div",{className:"admin-card-body",children:s.jsx(H,{sections:f,limits:a,onChange:C})})]}),s.jsxs("div",{className:"admin-settings-bar",children:[s.jsx("p",{children:"修改后请点击保存,新规则立即对全部用户生效"}),s.jsx(g,{onClick:F,loading:S,children:"保存论坛限制"})]})]}),o==="filter"&&s.jsxs("div",{className:"admin-settings-panel",children:[s.jsxs("div",{className:"admin-card admin-settings-card",children:[s.jsxs("div",{className:"admin-card-head",children:[s.jsx("span",{children:"敏感词过滤"}),s.jsxs("span",{className:"admin-settings-card-badge",children:[l.filter_word_count," 个词条"]})]}),s.jsxs("div",{className:"admin-card-body admin-settings-filter-body",children:[s.jsxs("p",{className:"admin-settings-filter-tip",children:["每行一个词,",s.jsx("code",{children:"#"})," 开头为注释。保存后写入 ",s.jsx("code",{children:"filter_words.txt"})," 并立即生效。"]}),s.jsx(M,{rows:16,value:m,onChange:e=>j(e.target.value),className:"admin-settings-filter-textarea",spellCheck:!1,placeholder:`# 示例
+违禁词
+广告刷单`})]})]}),s.jsxs("div",{className:"admin-settings-bar",children:[s.jsx("p",{children:"敏感词会在发帖、评论、昵称等文本中自动替换为 *"}),s.jsx(g,{onClick:T,loading:w,children:"保存敏感词"})]})]}),o==="system"&&s.jsxs("div",{className:"admin-settings-panel",children:[s.jsxs("div",{className:"admin-card admin-settings-card",children:[s.jsx("div",{className:"admin-card-head",children:"运行信息"}),s.jsx("div",{className:"admin-card-body",children:s.jsxs("dl",{className:"admin-settings-info",children:[s.jsxs("div",{className:"admin-settings-info-row",children:[s.jsx("dt",{children:"数据目录"}),s.jsx("dd",{children:s.jsx("code",{children:l.data_dir})})]}),s.jsxs("div",{className:"admin-settings-info-row",children:[s.jsx("dt",{children:"数据库"}),s.jsx("dd",{children:s.jsx("code",{children:l.db_path})})]}),s.jsxs("div",{className:"admin-settings-info-row",children:[s.jsx("dt",{children:"敏感词文件"}),s.jsx("dd",{children:s.jsx("code",{children:l.filter_path})})]}),s.jsxs("div",{className:"admin-settings-info-row",children:[s.jsx("dt",{children:"监听端口"}),s.jsx("dd",{children:l.port})]})]})})]}),s.jsxs("div",{className:"admin-card admin-settings-card",children:[s.jsx("div",{className:"admin-card-head",children:"数据备份"}),s.jsxs("div",{className:"admin-card-body admin-settings-backup-body",children:[s.jsx("p",{children:"导出当前 SQLite 数据库副本,便于迁移或灾难恢复。"}),s.jsxs("p",{className:"admin-settings-backup-name",children:["文件名:",s.jsx("code",{children:"jiang13_backup_YYYYMMDD_HHMMSS.db"})]}),s.jsxs(g,{onClick:E,loading:k,children:[s.jsx($,{size:16}),"立即备份并下载"]})]})]})]})]})}export{R as default};
diff --git a/embed_static/static/spa/assets/AdminSettingsPage-DXmt4ZWZ.js b/embed_static/static/spa/assets/AdminSettingsPage-DXmt4ZWZ.js
deleted file mode 100644
index 71576ad..0000000
--- a/embed_static/static/spa/assets/AdminSettingsPage-DXmt4ZWZ.js
+++ /dev/null
@@ -1 +0,0 @@
-import{r as a,j as s}from"./react-vendor-CFzzFOsg.js";import{d as _,a as c,S as N,B as x,n}from"./index-L-Mx2Hle.js";import{I as v}from"./input-CIPYpxcv.js";import{am as y}from"./ui-vendor-DGgNN2YO.js";function F(){const{ready:r}=_(),[d,l]=a.useState(null),[j,p]=a.useState(!0),[f,o]=a.useState(!1),[m,h]=a.useState("24"),[g,u]=a.useState(!1);a.useEffect(()=>{r&&c.adminSettings().then(e=>{l(e),h(String(e.post_edit_window_hours??24))}).finally(()=>p(!1))},[r]);const w=async()=>{const e=parseInt(m,10);if(Number.isNaN(e)||e<0){n.warning("请输入有效的小时数(0 表示不限)");return}u(!0);try{const i=await c.adminUpdateForumSettings({post_edit_window_hours:e});n.success(i.message),l(t=>t&&{...t,post_edit_window_hours:i.post_edit_window_hours})}catch(i){n.error(i instanceof Error?i.message:"保存失败")}finally{u(!1)}},S=async()=>{o(!0);try{const e=await c.adminBackup();n.success(e.message),window.location.href=e.download}catch(e){n.error(e instanceof Error?e.message:"备份失败")}finally{o(!1)}};return!r||j?s.jsx("div",{className:"flex justify-center py-16",children:s.jsx(N,{size:"lg"})}):d?s.jsxs("div",{className:"admin-page",children:[s.jsxs("div",{className:"admin-page-head",children:[s.jsx("h1",{children:"系统设置"}),s.jsx("p",{children:"数据目录、敏感词配置与数据库备份"})]}),s.jsxs("div",{className:"admin-card",children:[s.jsx("div",{className:"admin-card-head",children:"论坛规则"}),s.jsx("p",{className:"admin-card-desc",children:"设置普通用户发布后可编辑帖子的时限。超过时限后仅管理员可编辑。设为 0 表示不限时。"}),s.jsxs("div",{className:"admin-form-row",children:[s.jsx("label",{htmlFor:"edit-window-hours",children:"编辑时限(小时)"}),s.jsx(v,{id:"edit-window-hours",type:"number",min:0,value:m,onChange:e=>h(e.target.value),className:"max-w-[120px]"}),s.jsx(x,{onClick:w,loading:g,children:"保存"})]})]}),s.jsxs("div",{className:"admin-card",children:[s.jsx("div",{className:"admin-card-head",children:"运行信息"}),s.jsxs("dl",{className:"admin-dl",children:[s.jsx("dt",{children:"数据目录"}),s.jsx("dd",{children:s.jsx("code",{children:d.data_dir})}),s.jsx("dt",{children:"数据库路径"}),s.jsx("dd",{children:s.jsx("code",{children:d.db_path})}),s.jsx("dt",{children:"敏感词配置"}),s.jsx("dd",{children:s.jsx("code",{children:d.filter_path})}),s.jsx("dt",{children:"监听端口"}),s.jsx("dd",{children:d.port})]})]}),s.jsxs("div",{className:"admin-card",children:[s.jsx("div",{className:"admin-card-head",children:"数据备份"}),s.jsxs("p",{className:"admin-card-desc",children:["导出当前 SQLite 数据库副本,文件名格式为 ",s.jsx("code",{children:"jiang13_backup_YYYYMMDD_HHMMSS.db"})]}),s.jsxs(x,{onClick:S,loading:f,children:[s.jsx(y,{size:16}),"立即备份并下载"]})]})]}):null}export{F as default};
diff --git a/embed_static/static/spa/assets/AdminUsersPage-C9r9nOl4.js b/embed_static/static/spa/assets/AdminUsersPage-Ny3GZNbL.js
similarity index 92%
rename from embed_static/static/spa/assets/AdminUsersPage-C9r9nOl4.js
rename to embed_static/static/spa/assets/AdminUsersPage-Ny3GZNbL.js
index f1d04a5..c3e2c41 100644
--- a/embed_static/static/spa/assets/AdminUsersPage-C9r9nOl4.js
+++ b/embed_static/static/spa/assets/AdminUsersPage-Ny3GZNbL.js
@@ -1 +1 @@
-import{r as i,j as e}from"./react-vendor-CFzzFOsg.js";import{d as v,S as y,B as l,a as j,n as r}from"./index-L-Mx2Hle.js";import{B as h}from"./badge-e5OBoJ6g.js";import"./ui-vendor-DGgNN2YO.js";function z(){const{ready:d}=v(),[o,m]=i.useState([]),[g,x]=i.useState(!0),[n,p]=i.useState(1),[c,f]=i.useState(1),t=(s=n)=>{x(!0),j.adminUsers(s).then(a=>{m(a.users??[]),p(a.page),f(a.total_pages)}).catch(a=>r.error(a.message)).finally(()=>x(!1))};i.useEffect(()=>{d&&t(1)},[d]);const u=async s=>{if(s.role==="admin"){r.warning("不能禁言管理员");return}try{const a=await j.adminBanUser(s.id,!s.banned);r.success(a.message),t()}catch(a){r.error(a instanceof Error?a.message:"操作失败")}};return d?e.jsxs("div",{className:"admin-page",children:[e.jsxs("div",{className:"admin-page-head",children:[e.jsx("h1",{children:"用户管理"}),e.jsx("p",{children:"查看注册用户,禁言或解除禁言"})]}),e.jsx("div",{className:"admin-card",children:g?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(y,{size:"lg"})}):e.jsxs(e.Fragment,{children:[e.jsxs("table",{className:"admin-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"ID"}),e.jsx("th",{children:"用户名"}),e.jsx("th",{children:"昵称"}),e.jsx("th",{children:"角色"}),e.jsx("th",{children:"状态"}),e.jsx("th",{children:"注册时间"}),e.jsx("th",{children:"操作"})]})}),e.jsx("tbody",{children:o.map(s=>e.jsxs("tr",{children:[e.jsx("td",{children:s.id}),e.jsx("td",{children:s.username}),e.jsx("td",{children:s.nickname}),e.jsx("td",{children:s.role==="admin"?e.jsx(h,{variant:"orange",children:"管理员"}):e.jsx(h,{variant:"secondary",children:"用户"})}),e.jsx("td",{children:s.banned?e.jsx(h,{variant:"destructive",children:"已禁言"}):"正常"}),e.jsx("td",{children:s.created_at?new Date(s.created_at).toLocaleString("zh-CN"):"—"}),e.jsx("td",{children:s.role!=="admin"&&e.jsx(l,{size:"sm",variant:"outline",onClick:()=>u(s),children:s.banned?"解除禁言":"禁言"})})]},s.id))})]}),o.length===0&&e.jsx("div",{className:"admin-empty",children:"暂无用户"}),c>1&&e.jsxs("div",{className:"admin-pagination",children:[e.jsx(l,{size:"sm",variant:"outline",disabled:n<=1,onClick:()=>t(n-1),children:"上一页"}),e.jsxs("span",{children:["第 ",n," / ",c," 页"]}),e.jsx(l,{size:"sm",variant:"outline",disabled:n>=c,onClick:()=>t(n+1),children:"下一页"})]})]})})]}):null}export{z as default};
+import{r as i,j as e}from"./react-vendor-CFzzFOsg.js";import{e as v,S as y,B as l,a as j,n as r}from"./index-5C0q-ZMs.js";import{B as h}from"./badge-DB-zL5ml.js";import"./ui-vendor-BtpOfToU.js";function z(){const{ready:d}=v(),[o,m]=i.useState([]),[g,x]=i.useState(!0),[n,p]=i.useState(1),[c,f]=i.useState(1),t=(s=n)=>{x(!0),j.adminUsers(s).then(a=>{m(a.users??[]),p(a.page),f(a.total_pages)}).catch(a=>r.error(a.message)).finally(()=>x(!1))};i.useEffect(()=>{d&&t(1)},[d]);const u=async s=>{if(s.role==="admin"){r.warning("不能禁言管理员");return}try{const a=await j.adminBanUser(s.id,!s.banned);r.success(a.message),t()}catch(a){r.error(a instanceof Error?a.message:"操作失败")}};return d?e.jsxs("div",{className:"admin-page",children:[e.jsxs("div",{className:"admin-page-head",children:[e.jsx("h1",{children:"用户管理"}),e.jsx("p",{children:"查看注册用户,禁言或解除禁言"})]}),e.jsx("div",{className:"admin-card",children:g?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(y,{size:"lg"})}):e.jsxs(e.Fragment,{children:[e.jsxs("table",{className:"admin-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"ID"}),e.jsx("th",{children:"用户名"}),e.jsx("th",{children:"昵称"}),e.jsx("th",{children:"角色"}),e.jsx("th",{children:"状态"}),e.jsx("th",{children:"注册时间"}),e.jsx("th",{children:"操作"})]})}),e.jsx("tbody",{children:o.map(s=>e.jsxs("tr",{children:[e.jsx("td",{children:s.id}),e.jsx("td",{children:s.username}),e.jsx("td",{children:s.nickname}),e.jsx("td",{children:s.role==="admin"?e.jsx(h,{variant:"orange",children:"管理员"}):e.jsx(h,{variant:"secondary",children:"用户"})}),e.jsx("td",{children:s.banned?e.jsx(h,{variant:"destructive",children:"已禁言"}):"正常"}),e.jsx("td",{children:s.created_at?new Date(s.created_at).toLocaleString("zh-CN"):"—"}),e.jsx("td",{children:s.role!=="admin"&&e.jsx(l,{size:"sm",variant:"outline",onClick:()=>u(s),children:s.banned?"解除禁言":"禁言"})})]},s.id))})]}),o.length===0&&e.jsx("div",{className:"admin-empty",children:"暂无用户"}),c>1&&e.jsxs("div",{className:"admin-pagination",children:[e.jsx(l,{size:"sm",variant:"outline",disabled:n<=1,onClick:()=>t(n-1),children:"上一页"}),e.jsxs("span",{children:["第 ",n," / ",c," 页"]}),e.jsx(l,{size:"sm",variant:"outline",disabled:n>=c,onClick:()=>t(n+1),children:"下一页"})]})]})})]}):null}export{z as default};
diff --git a/embed_static/static/spa/assets/BoardsManagePage-CQfZWFTe.js b/embed_static/static/spa/assets/BoardsManagePage-CQfZWFTe.js
deleted file mode 100644
index 4571d19..0000000
--- a/embed_static/static/spa/assets/BoardsManagePage-CQfZWFTe.js
+++ /dev/null
@@ -1 +0,0 @@
-import{r as l,j as e,e as Q}from"./react-vendor-CFzzFOsg.js";import{_ as U,Z as W,u as Y,a as $,F as ee,b as g,c as b,d as y,e as N,f as w,o as se,s as R}from"./form-xbbJUieP.js";import{c as n,d as ae,S as F,B as h,a as f,n as c}from"./index-L-Mx2Hle.js";import{I as A}from"./input-CIPYpxcv.js";import{B as te}from"./badge-e5OBoJ6g.js";import{a4 as re,a5 as le,a6 as S,a7 as ne,X as oe,a8 as _,a9 as k,aa as B,m as ie}from"./ui-vendor-DGgNN2YO.js";import{A as de,a as ce,b as me,c as xe,d as he,e as pe,f as fe,g as je,h as ue}from"./alert-dialog-Q1fPYDxo.js";function ge(s){return U(W,s)}const E=l.forwardRef(({className:s,...a},r)=>e.jsx("textarea",{className:n("flex min-h-[60px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:r,...a}));E.displayName="Textarea";const z=l.forwardRef(({className:s,...a},r)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:r,className:n("w-full caption-bottom text-sm",s),...a})}));z.displayName="Table";const H=l.forwardRef(({className:s,...a},r)=>e.jsx("thead",{ref:r,className:n("[&_tr]:border-b",s),...a}));H.displayName="TableHeader";const I=l.forwardRef(({className:s,...a},r)=>e.jsx("tbody",{ref:r,className:n("[&_tr:last-child]:border-0",s),...a}));I.displayName="TableBody";const v=l.forwardRef(({className:s,...a},r)=>e.jsx("tr",{ref:r,className:n("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",s),...a}));v.displayName="TableRow";const i=l.forwardRef(({className:s,...a},r)=>e.jsx("th",{ref:r,className:n("h-10 px-3 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",s),...a}));i.displayName="TableHead";const d=l.forwardRef(({className:s,...a},r)=>e.jsx("td",{ref:r,className:n("p-3 align-middle [&:has([role=checkbox])]:pr-0",s),...a}));d.displayName="TableCell";const be=re,ye=le,O=l.forwardRef(({className:s,...a},r)=>e.jsx(k,{ref:r,className:n("fixed inset-0 z-[110] bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...a}));O.displayName=k.displayName;const L=l.forwardRef(({className:s,children:a,...r},j)=>e.jsxs(ye,{children:[e.jsx(O,{}),e.jsxs(S,{ref:j,className:n("fixed left-[50%] top-[50%] z-[110] grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",s),...r,children:[a,e.jsxs(ne,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(oe,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"关闭"})]})]})]}));L.displayName=S.displayName;const P=({className:s,...a})=>e.jsx("div",{className:n("flex flex-col space-y-1.5 text-center sm:text-left",s),...a});P.displayName="DialogHeader";const M=({className:s,...a})=>e.jsx("div",{className:n("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...a});M.displayName="DialogFooter";const Z=l.forwardRef(({className:s,...a},r)=>e.jsx(_,{ref:r,className:n("text-lg font-semibold leading-none tracking-tight",s),...a}));Z.displayName=_.displayName;const Ne=l.forwardRef(({className:s,...a},r)=>e.jsx(B,{ref:r,className:n("text-sm text-muted-foreground",s),...a}));Ne.displayName=B.displayName;const we=se({name:R().min(1,"请输入名称").max(64),description:R().max(500).optional(),sort_order:ge().min(0)});function Se(){Q();const{ready:s}=ae(),[a,r]=l.useState([]),[j,D]=l.useState(!0),[G,m]=l.useState(!1),[p,T]=l.useState(null),[V,C]=l.useState(!1),o=Y({resolver:$(we),defaultValues:{name:"",description:"",sort_order:1}}),u=()=>{D(!0),f.boards().then(t=>r(t.boards??[])).catch(t=>c.error(t.message)).finally(()=>D(!1))};l.useEffect(()=>{s&&u()},[s]);const X=()=>{T(null),o.reset({name:"",description:"",sort_order:a.length+1}),m(!0)},q=t=>{T(t),o.reset({name:t.name,description:t.description??"",sort_order:t.sort_order}),m(!0)},J=async t=>{C(!0);try{p?(await f.updateBoard(p.id,t),c.success("板块已更新")):(await f.createBoard(t),c.success("板块已创建")),m(!1),u(),window.dispatchEvent(new Event("boards-refresh"))}catch(x){c.error(x instanceof Error?x.message:"操作失败")}finally{C(!1)}},K=async t=>{try{await f.deleteBoard(t),c.success("板块已删除"),u(),window.dispatchEvent(new Event("boards-refresh"))}catch(x){c.error(x instanceof Error?x.message:"删除失败")}};return s?e.jsxs("div",{className:"admin-page",children:[e.jsx("div",{className:"admin-page-head",children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e.jsxs("div",{children:[e.jsx("h1",{children:"板块管理"}),e.jsx("p",{children:"创建、编辑或删除论坛板块,用户发帖前需先有板块"})]}),e.jsxs(h,{onClick:X,children:[e.jsx(ie,{}),"新建板块"]})]})}),e.jsx("div",{className:"admin-card",children:j?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(F,{size:"lg"})}):e.jsxs(e.Fragment,{children:[e.jsxs(z,{children:[e.jsx(H,{children:e.jsxs(v,{children:[e.jsx(i,{className:"w-[60px]",children:"ID"}),e.jsx(i,{children:"名称"}),e.jsx(i,{children:"简介"}),e.jsx(i,{className:"w-[70px]",children:"排序"}),e.jsx(i,{className:"w-[80px]",children:"帖子数"}),e.jsx(i,{className:"w-[160px]",children:"操作"})]})}),e.jsx(I,{children:a.map(t=>e.jsxs(v,{children:[e.jsx(d,{children:t.id}),e.jsx(d,{children:e.jsx("strong",{children:t.name})}),e.jsx(d,{className:"max-w-[200px] truncate",children:t.description}),e.jsx(d,{children:t.sort_order}),e.jsx(d,{children:e.jsx(te,{variant:"secondary",children:t.post_count??0})}),e.jsx(d,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(h,{variant:"ghost",size:"sm",onClick:()=>q(t),children:"编辑"}),e.jsxs(de,{children:[e.jsx(ce,{asChild:!0,children:e.jsx(h,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",children:"删除"})}),e.jsxs(me,{children:[e.jsxs(xe,{children:[e.jsx(he,{children:"确定删除该板块?"}),e.jsx(pe,{children:"删除后该板块下的帖子将无法通过板块筛选,此操作不可撤销。"})]}),e.jsxs(fe,{children:[e.jsx(je,{children:"取消"}),e.jsx(ue,{onClick:()=>K(t.id),children:"删除"})]})]})]})]})})]},t.id))})]}),a.length===0&&e.jsx("div",{className:"empty-state",children:e.jsx("p",{children:"还没有板块,点击右上角创建第一个"})})]})}),e.jsx(be,{open:G,onOpenChange:m,children:e.jsxs(L,{children:[e.jsx(P,{children:e.jsx(Z,{children:p?"编辑板块":"新建板块"})}),e.jsx(ee,{...o,children:e.jsxs("form",{onSubmit:o.handleSubmit(J),className:"space-y-4",children:[e.jsx(g,{control:o.control,name:"name",render:({field:t})=>e.jsxs(b,{children:[e.jsx(y,{children:"板块名称"}),e.jsx(N,{children:e.jsx(A,{maxLength:64,placeholder:"如:技术交流",...t})}),e.jsx(w,{})]})}),e.jsx(g,{control:o.control,name:"description",render:({field:t})=>e.jsxs(b,{children:[e.jsx(y,{children:"简介"}),e.jsx(N,{children:e.jsx(E,{rows:3,maxLength:500,placeholder:"板块说明(可选)",...t})}),e.jsx(w,{})]})}),e.jsx(g,{control:o.control,name:"sort_order",render:({field:t})=>e.jsxs(b,{children:[e.jsx(y,{children:"排序"}),e.jsx(N,{children:e.jsx(A,{type:"number",min:0,...t})}),e.jsx(w,{})]})}),e.jsxs(M,{children:[e.jsx(h,{type:"button",variant:"outline",onClick:()=>m(!1),children:"取消"}),e.jsx(h,{type:"submit",loading:V,children:p?"保存":"创建"})]})]})})]})})]}):e.jsx("div",{className:"flex justify-center py-16",children:e.jsx(F,{size:"lg"})})}export{Se as default};
diff --git a/embed_static/static/spa/assets/BoardsManagePage-DQXzBsE1.js b/embed_static/static/spa/assets/BoardsManagePage-DQXzBsE1.js
new file mode 100644
index 0000000..04db729
--- /dev/null
+++ b/embed_static/static/spa/assets/BoardsManagePage-DQXzBsE1.js
@@ -0,0 +1 @@
+import{r as n,j as e,e as K}from"./react-vendor-CFzzFOsg.js";import{_ as Q,Z as U,u as W,a as Y,F as $,b as g,c as y,d as N,e as b,f as w,o as ee,s as R}from"./form-OSLy-cSS.js";import{c as l,e as se,S as F,B as h,a as j,n as c}from"./index-5C0q-ZMs.js";import{I as A}from"./input-CE0PJTgJ.js";import{T as ae}from"./textarea-VyK9_GFn.js";import{B as te}from"./badge-DB-zL5ml.js";import{a4 as re,a5 as ne,a6 as S,a7 as le,X as oe,a8 as _,a9 as B,aa as E,m as ie}from"./ui-vendor-BtpOfToU.js";import{A as de,a as ce,b as me,c as xe,d as he,e as pe,f as je,g as fe,h as ue}from"./alert-dialog-BoQ7HSUR.js";function ge(s){return Q(U,s)}const k=n.forwardRef(({className:s,...t},r)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:r,className:l("w-full caption-bottom text-sm",s),...t})}));k.displayName="Table";const z=n.forwardRef(({className:s,...t},r)=>e.jsx("thead",{ref:r,className:l("[&_tr]:border-b",s),...t}));z.displayName="TableHeader";const H=n.forwardRef(({className:s,...t},r)=>e.jsx("tbody",{ref:r,className:l("[&_tr:last-child]:border-0",s),...t}));H.displayName="TableBody";const v=n.forwardRef(({className:s,...t},r)=>e.jsx("tr",{ref:r,className:l("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",s),...t}));v.displayName="TableRow";const i=n.forwardRef(({className:s,...t},r)=>e.jsx("th",{ref:r,className:l("h-10 px-3 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",s),...t}));i.displayName="TableHead";const d=n.forwardRef(({className:s,...t},r)=>e.jsx("td",{ref:r,className:l("p-3 align-middle [&:has([role=checkbox])]:pr-0",s),...t}));d.displayName="TableCell";const ye=re,Ne=ne,I=n.forwardRef(({className:s,...t},r)=>e.jsx(B,{ref:r,className:l("fixed inset-0 z-[110] bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...t}));I.displayName=B.displayName;const O=n.forwardRef(({className:s,children:t,...r},f)=>e.jsxs(Ne,{children:[e.jsx(I,{}),e.jsxs(S,{ref:f,className:l("fixed left-[50%] top-[50%] z-[110] grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",s),...r,children:[t,e.jsxs(le,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(oe,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"关闭"})]})]})]}));O.displayName=S.displayName;const L=({className:s,...t})=>e.jsx("div",{className:l("flex flex-col space-y-1.5 text-center sm:text-left",s),...t});L.displayName="DialogHeader";const P=({className:s,...t})=>e.jsx("div",{className:l("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...t});P.displayName="DialogFooter";const M=n.forwardRef(({className:s,...t},r)=>e.jsx(_,{ref:r,className:l("text-lg font-semibold leading-none tracking-tight",s),...t}));M.displayName=_.displayName;const be=n.forwardRef(({className:s,...t},r)=>e.jsx(E,{ref:r,className:l("text-sm text-muted-foreground",s),...t}));be.displayName=E.displayName;const we=ee({name:R().min(1,"请输入名称").max(64),description:R().max(500).optional(),sort_order:ge().min(0)});function _e(){K();const{ready:s}=se(),[t,r]=n.useState([]),[f,D]=n.useState(!0),[Z,m]=n.useState(!1),[p,T]=n.useState(null),[G,C]=n.useState(!1),o=W({resolver:Y(we),defaultValues:{name:"",description:"",sort_order:1}}),u=()=>{D(!0),j.boards().then(a=>r(a.boards??[])).catch(a=>c.error(a.message)).finally(()=>D(!1))};n.useEffect(()=>{s&&u()},[s]);const V=()=>{T(null),o.reset({name:"",description:"",sort_order:t.length+1}),m(!0)},X=a=>{T(a),o.reset({name:a.name,description:a.description??"",sort_order:a.sort_order}),m(!0)},q=async a=>{C(!0);try{p?(await j.updateBoard(p.id,a),c.success("板块已更新")):(await j.createBoard(a),c.success("板块已创建")),m(!1),u(),window.dispatchEvent(new Event("boards-refresh"))}catch(x){c.error(x instanceof Error?x.message:"操作失败")}finally{C(!1)}},J=async a=>{try{await j.deleteBoard(a),c.success("板块已删除"),u(),window.dispatchEvent(new Event("boards-refresh"))}catch(x){c.error(x instanceof Error?x.message:"删除失败")}};return s?e.jsxs("div",{className:"admin-page",children:[e.jsx("div",{className:"admin-page-head",children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e.jsxs("div",{children:[e.jsx("h1",{children:"板块管理"}),e.jsx("p",{children:"创建、编辑或删除论坛板块,用户发帖前需先有板块"})]}),e.jsxs(h,{onClick:V,children:[e.jsx(ie,{}),"新建板块"]})]})}),e.jsx("div",{className:"admin-card",children:f?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(F,{size:"lg"})}):e.jsxs(e.Fragment,{children:[e.jsxs(k,{children:[e.jsx(z,{children:e.jsxs(v,{children:[e.jsx(i,{className:"w-[60px]",children:"ID"}),e.jsx(i,{children:"名称"}),e.jsx(i,{children:"简介"}),e.jsx(i,{className:"w-[70px]",children:"排序"}),e.jsx(i,{className:"w-[80px]",children:"帖子数"}),e.jsx(i,{className:"w-[160px]",children:"操作"})]})}),e.jsx(H,{children:t.map(a=>e.jsxs(v,{children:[e.jsx(d,{children:a.id}),e.jsx(d,{children:e.jsx("strong",{children:a.name})}),e.jsx(d,{className:"max-w-[200px] truncate",children:a.description}),e.jsx(d,{children:a.sort_order}),e.jsx(d,{children:e.jsx(te,{variant:"secondary",children:a.post_count??0})}),e.jsx(d,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(h,{variant:"ghost",size:"sm",onClick:()=>X(a),children:"编辑"}),e.jsxs(de,{children:[e.jsx(ce,{asChild:!0,children:e.jsx(h,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",children:"删除"})}),e.jsxs(me,{children:[e.jsxs(xe,{children:[e.jsx(he,{children:"确定删除该板块?"}),e.jsx(pe,{children:"删除后该板块下的帖子将无法通过板块筛选,此操作不可撤销。"})]}),e.jsxs(je,{children:[e.jsx(fe,{children:"取消"}),e.jsx(ue,{onClick:()=>J(a.id),children:"删除"})]})]})]})]})})]},a.id))})]}),t.length===0&&e.jsx("div",{className:"empty-state",children:e.jsx("p",{children:"还没有板块,点击右上角创建第一个"})})]})}),e.jsx(ye,{open:Z,onOpenChange:m,children:e.jsxs(O,{children:[e.jsx(L,{children:e.jsx(M,{children:p?"编辑板块":"新建板块"})}),e.jsx($,{...o,children:e.jsxs("form",{onSubmit:o.handleSubmit(q),className:"space-y-4",children:[e.jsx(g,{control:o.control,name:"name",render:({field:a})=>e.jsxs(y,{children:[e.jsx(N,{children:"板块名称"}),e.jsx(b,{children:e.jsx(A,{maxLength:64,placeholder:"如:技术交流",...a})}),e.jsx(w,{})]})}),e.jsx(g,{control:o.control,name:"description",render:({field:a})=>e.jsxs(y,{children:[e.jsx(N,{children:"简介"}),e.jsx(b,{children:e.jsx(ae,{rows:3,maxLength:500,placeholder:"板块说明(可选)",...a})}),e.jsx(w,{})]})}),e.jsx(g,{control:o.control,name:"sort_order",render:({field:a})=>e.jsxs(y,{children:[e.jsx(N,{children:"排序"}),e.jsx(b,{children:e.jsx(A,{type:"number",min:0,...a})}),e.jsx(w,{})]})}),e.jsxs(P,{children:[e.jsx(h,{type:"button",variant:"outline",onClick:()=>m(!1),children:"取消"}),e.jsx(h,{type:"submit",loading:G,children:p?"保存":"创建"})]})]})})]})})]}):e.jsx("div",{className:"flex justify-center py-16",children:e.jsx(F,{size:"lg"})})}export{_e as default};
diff --git a/embed_static/static/spa/assets/ComposePage-BFRWOfPd.js b/embed_static/static/spa/assets/ComposePage-DPJpUz3A.js
similarity index 63%
rename from embed_static/static/spa/assets/ComposePage-BFRWOfPd.js
rename to embed_static/static/spa/assets/ComposePage-DPJpUz3A.js
index 4f0f90a..5d5ce44 100644
--- a/embed_static/static/spa/assets/ComposePage-BFRWOfPd.js
+++ b/embed_static/static/spa/assets/ComposePage-DPJpUz3A.js
@@ -1,4 +1,4 @@
-import{r as D,k as wt,j as w,a as Jd,m as Kd,e as Gd,w as Yd,i as Xd}from"./react-vendor-CFzzFOsg.js";import{u as Qd,a as rn,n as Pe,S as jo}from"./index-L-Mx2Hle.js";import{P as Zd,i as eh}from"./postContent-D-mW2yDF.js";import{g as th,p as nh}from"./markdown-vendor-DxR1h-Bq.js";import{O as Ea,Q as rh,V as ih,W as sh,Y as oh,Z as lh,_ as ah,$ as ch,a0 as uh,a1 as dh,a2 as hh,A as fh,x as ph,a3 as mh}from"./ui-vendor-DGgNN2YO.js";var Ta={exports:{}},Aa={};/**
+import{r as D,k as vt,j as w,a as Ud,m as qd,e as Jd,w as Kd,i as Gd}from"./react-vendor-CFzzFOsg.js";import{a as zt,n as Oe,u as Yd,d as Xd,S as Ho}from"./index-5C0q-ZMs.js";import{P as Qd,i as Zd}from"./postContent-ClrHK1rL.js";import{p as eh}from"./purify-vendor-Cx4rtWv4.js";import{O as Ma,Q as th,V as nh,W as rh,Y as ih,Z as sh,_ as oh,$ as lh,a0 as ah,a1 as ch,a2 as uh,A as dh,x as hh,a3 as fh}from"./ui-vendor-BtpOfToU.js";var Ca={exports:{}},Ea={};/**
* @license React
* use-sync-external-store-shim.production.js
*
@@ -6,21 +6,21 @@ import{r as D,k as wt,j as w,a as Jd,m as Kd,e as Gd,w as Yd,i as Xd}from"./reac
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
- */var Wt=D;function gh(n,e){return n===e&&(n!==0||1/n===1/e)||n!==n&&e!==e}var yh=typeof Object.is=="function"?Object.is:gh,bh=Wt.useState,kh=Wt.useEffect,Sh=Wt.useLayoutEffect,xh=Wt.useDebugValue;function wh(n,e){var t=e(),r=bh({inst:{value:t,getSnapshot:e}}),i=r[0].inst,s=r[1];return Sh(function(){i.value=t,i.getSnapshot=e,Li(i)&&s({inst:i})},[n,t,e]),kh(function(){return Li(i)&&s({inst:i}),n(function(){Li(i)&&s({inst:i})})},[n]),xh(t),t}function Li(n){var e=n.getSnapshot;n=n.value;try{var t=e();return!yh(n,t)}catch{return!0}}function vh(n,e){return e()}var Mh=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?vh:wh;Aa.useSyncExternalStore=Wt.useSyncExternalStore!==void 0?Wt.useSyncExternalStore:Mh;Ta.exports=Aa;var Xs=Ta.exports;function ee(n){this.content=n}ee.prototype={constructor:ee,find:function(n){for(var e=0;e>1}};ee.from=function(n){if(n instanceof ee)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new ee(e)};function Na(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),s=e.child(r);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){let o=i.text,l=s.text,a=0;for(;o[a]==l[a];a++)t++;return a&&a0&&f>0&&c[d-1]==u[f-1];)d--,f--,t--,r--;return d&&f&&d=56320&&n<57344}function Ia(n){return n>=55296&&n<56320}let S=class ce{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;re&&r(a,i+l,s||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,i+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let s="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),s=1);se)for(let s=0,o=0;oe&&((ot)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),r.push(l),i+=l.nodeSize),o=a}return new ce(r,i)}cutByIndex(e,t){return e==t?ce.empty:e==0&&t==this.content.length?this:new ce(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new ce(i,s)}addToStart(e){return new ce([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new ce(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),s=r+i.nodeSize;if(s>=e)return s==e?ir(t+1,s):ir(t,r);r=s}}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 ce.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return ce.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return ce.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(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;tr.type.rank-i.type.rank),t}};B.none=[];let Fn=class extends Error{},E=class Lt{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=Pa(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return r&&new Lt(r,this.openStart,this.openEnd)}removeBetween(e,t){return new Lt(Da(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 Lt.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 Lt(S.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new Lt(e,r,i)}};E.empty=new E(S.empty,0,0);function Da(n,e,t){let{index:r,offset:i}=n.findIndex(e),s=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(i==e||s.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(Da(s.content,e-i-1,t-i-1)))}function Pa(n,e,t,r,i,s){let{index:o,offset:l}=n.findIndex(e),a=n.maybeChild(o);if(l==e||a.isText)return s&&r<=0&&i<=0&&!s.canReplace(o,o,t)?null:n.cut(0,e).append(t).append(n.cut(e));let c=Pa(a.content,e-l-1,t,o==0?r-1:0,o==n.childCount-1?i-1:0,a);return c&&n.replaceChild(o,a.copy(c))}function Ch(n,e,t){if(t.openStart>n.depth)throw new Fn("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Fn("Inconsistent open depths");return La(n,e,t,0)}function La(n,e,t,r){let i=n.index(r),s=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 En(n,e,t,r){let i=(e||n).node(t),s=0,o=e?e.index(t):i.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(yt(n.nodeAfter,r),s++));for(let l=s;li&&ms(n,e,i+1),o=r.depth>i&&ms(t,r,i+1),l=[];return En(null,n,i,l),s&&o&&e.index(i)==t.index(i)?(za(s,o),yt(bt(s,Ba(n,e,t,r,i+1)),l)):(s&&yt(bt(s,Pr(n,e,i+1)),l),En(e,t,i,l),o&&yt(bt(o,Pr(t,r,i+1)),l)),En(r,null,i,l),new S(l)}function Pr(n,e,t){let r=[];if(En(null,n,t,r),n.depth>t){let i=ms(n,e,t+1);yt(bt(i,Pr(n,e,t+1)),r)}return En(e,null,t,r),new S(r)}function Eh(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)i=e.node(s).copy(S.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class Hn{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 s=0;s0;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 Lr(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,s=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(s),c=s-a;if(r.push(o,l,i+a),!c||(o=o.child(l),o.isText))break;s=c-1,i+=a+1}return new Hn(t,r,s)}static resolveCached(e,t){let r=_o.get(e);if(r)for(let s=0;se&&this.nodesBetween(e,t,s=>(r.isInSet(s.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()+")"),$a(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=S.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),l=o&&o.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=S.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,i,r);return s.type.checkAttrs(s.attrs),s}};tt.prototype.text=void 0;class zr extends tt{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):$a(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 zr(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new zr(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 $a(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class vt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Oh(e,t);if(r.next==null)return vt.empty;let i=Fa(r);r.next&&r.err("Unexpected trailing text");let s=Bh(zh(i));return $h(s,r),s}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 s=i+(r.validEnd?"*":" ")+" ";for(let o=0;o"+e.indexOf(r.next[o].next);return s}).join(`
-`)}}vt.empty=new vt(!0);class Oh{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 Fa(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=Dh(n,e);else break;return e}function Wo(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Dh(n,e){let t=Wo(n),r=t;return n.eat(",")&&(n.next!="}"?r=Wo(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function Ph(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let s in t){let o=t[s];o.isInGroup(e)&&i.push(o)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function Lh(n){if(n.eat("(")){let e=Fa(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=Ph(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 zh(n){let e=[[]];return i(s(n,0),t()),e;function t(){return e.push([])-1}function r(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function i(o,l){o.forEach(a=>a.to=l)}function s(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(s(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=s(o.exprs[a],l);if(a==o.exprs.length-1)return c;i(c,l=t())}else if(o.type=="star"){let a=t();return r(l,a),i(s(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=t();return i(s(o.expr,l),a),i(s(o.expr,a),a),[r(a)]}else{if(o.type=="opt")return[r(l)].concat(s(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c{n[o].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 s=e[r.join(",")]=new vt(r.indexOf(n.length-1)>-1);for(let o=0;o-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:ja(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new tt(this,this.computeAttrs(e),S.from(t),B.setFrom(r))}createChecked(e=null,t,r){return t=S.from(t),this.checkContent(t),new tt(this,this.computeAttrs(e),t,B.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=S.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let i=this.contentMatch.matchFragment(t),s=i&&i.fillBefore(S.empty,!0);return s?new tt(this,e,t.append(s),B.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[s]=new Ua(s,t,o));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 s 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 s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${s}`)}}class Hh{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}}class xi{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=Wa(e,i.attrs),this.excluded=null;let s=Va(this.attrs);this.instance=s?new B(this,s):null}create(e=null){return!e&&this.instance?this.instance:new B(this,ja(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new xi(s,i++,t,o)),r}removeFromSet(e){for(var t=0;t-1}}class qa{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=ee.from(e.nodes),t.marks=ee.from(e.marks||{}),this.nodes=qo.compile(this.spec.nodes,this),this.marks=xi.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 s=this.nodes[i],o=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=r[o]||(r[o]=vt.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?Jo(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:Jo(this,o.split(" "))}this.nodeFromJSON=i=>tt.fromJSON(this,i),this.markFromJSON=i=>B.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 qo){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 zr(r,r.defaultAttrs,e,B.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 Jo(n,e){let t=[];for(let r=0;r-1)&&t.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function Vh(n){return n.tag!=null}function jh(n){return n.style!=null}let Tn=class ys{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(Vh(i))this.tags.push(i);else if(jh(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let r=new Go(this,t,!1);return r.addAll(e,B.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Go(this,t,!0);return r.addAll(e,B.none,t.from,t.to),E.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(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function r(i){let s=i.priority==null?50:i.priority,o=0;for(;o{r(o=Yo(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{r(o=Yo(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new ys(e,ys.schemaRules(e)))}};const Ja={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},_h={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ka={ol:!0,ul:!0},Vn=1,bs=2,An=4;function Ko(n,e,t){return e!=null?(e?Vn:0)|(e==="full"?bs:0):n&&n.whitespace=="pre"?Vn|bs:t&~An}class sr{constructor(e,t,r,i,s,o){this.type=e,this.attrs=t,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=B.none,this.match=s||(o&An?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(S.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Vn)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let t=S.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(S.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Ja.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Go{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=t.topNode,s,o=Ko(null,t.preserveWhitespace,0)|(r?An:0);i?s=new sr(i.type,i.attrs,B.none,!0,t.topMatch||i.type.contentMatch,o):r?s=new sr(null,null,B.none,!0,null,o):s=new sr(e.schema.topNodeType,null,B.none,!0,null,o),this.nodes=[s],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,s=i.options&bs?"full":this.localPreserveWS||(i.options&Vn)>0,{schema:o}=this.parser;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,`
-`);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a!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 s,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(o,t.attrs||null,r,t.preserveWhitespace);a&&(s=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(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)}s&&this.sync(l)&&this.open--}addAll(e,t,r,i){let s=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,t);this.findAtPoint(e,s)}findPlace(e,t,r){let i,s;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],c=a.findWrapping(e);if(c&&(!i||i.length>c.length+l)&&(i=c,s=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!i)return null;this.sync(s);for(let o=0;o(o.type?o.type.allowsMarkType(c.type):Xo(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new sr(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|=Vn)}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),s=-(r?r.depth+1:0)+(i?0:1),o=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=s;a--)if(o(l-1,a))return!0;return!1}else{let u=a>0||a==0&&i?this.nodes[a].type:r&&a>=s?r.node(a-s).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function Wh(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Ka.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function Uh(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Yo(n){let e={};for(let t in n)e[t]=n[t];return e}function Xo(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let s=[],o=l=>{s.push(l);for(let a=0;a{if(s.length||o.marks.length){let l=0,a=0;for(;l=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&xr(or(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return typeof t=="string"?{dom:e.createTextNode(t)}:xr(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Nt(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Qo(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Qo(e.marks)}}function Qo(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function or(n){return n.document||window.document}const Zo=new WeakMap;function qh(n){let e=Zo.get(n);return e===void 0&&Zo.set(n,e=Jh(n)),e}function Jh(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 o=i.indexOf(" ");o>0&&(t=i.slice(0,o),i=i.slice(o+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 d in c)if(c[d]!=null){let f=d.indexOf(" ");f>0?a.setAttributeNS(d.slice(0,f),d.slice(f+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;du)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else if(typeof f=="string")a.appendChild(n.createTextNode(f));else{let{dom:h,contentDOM:p}=xr(n,f,t,r);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const Ga=65535,Ya=Math.pow(2,16);function Kh(n,e){return n+e*Ya}function el(n){return n&Ga}function Gh(n){return(n-(n&Ga))/Ya}const Xa=1,Qa=2,wr=4,Za=8;let ks=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Za)>0}get deletedBefore(){return(this.delInfo&(Xa|wr))>0}get deletedAfter(){return(this.delInfo&(Qa|wr))>0}get deletedAcross(){return(this.delInfo&wr)>0}},Mt=class zt{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&zt.empty)return zt.empty}recover(e){let t=0,r=el(e);if(!this.inverted)for(let i=0;ie)break;let c=this.ranges[l+s],u=this.ranges[l+o],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:t:t,h=a+i+(f<0?0:u);if(r)return h;let p=e==(t<0?a:d)?null:Kh(l/3,e-a),m=e==a?Qa:e==d?Xa:wr;return(t<0?e!=a:e!=d)&&(m|=Za),new ks(h,m,p)}i+=u-c}return r?e+i:new ks(e+i,0,null)}touches(e,t){let r=0,i=el(t),s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;le)break;let c=this.ranges[l+s],u=a+c;if(e<=u&&l==i*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=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 jn;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;rs&&a!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),t.openStart,t.openEnd);return de.fromReplace(e,this.from,this.to,s)}invert(){return new tn(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 un(t.pos,r.pos,this.mark)}merge(e){return e instanceof un&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new un(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 un(t.from,t.to,e.markFromJSON(t.mark))}};oe.jsonID("addMark",Zs);let tn=class dn extends oe{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 E(Qs(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return de.fromReplace(e,this.from,this.to,r)}invert(){return new Zs(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 dn(t.pos,r.pos,this.mark)}merge(e){return e instanceof dn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new dn(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 dn(t.from,t.to,e.markFromJSON(t.mark))}};oe.jsonID("removeMark",tn);let eo=class hn extends oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return de.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return de.fromReplace(e,this.pos,this.pos+1,new E(S.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;ir.pos?null:new vr(t.pos,r.pos,i,s,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 vr(t.from,t.to,t.gapFrom,t.gapTo,E.fromJSON(e,t.slice),t.insert,!!t.structure)}};oe.jsonID("replaceAround",ke);function xs(n,e,t){let r=n.resolve(e),i=t-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function Yh(n,e,t,r){let i=[],s=[],o,l;n.doc.nodesBetween(e,t,(a,c,u)=>{if(!a.isInline)return;let d=a.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,t),p=r.addToSet(d);for(let m=0;mn.step(a)),s.forEach(a=>n.step(a))}function Xh(n,e,t,r){let i=[],s=0;n.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;s++;let a=null;if(r instanceof xi){let c=o.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(o.marks)&&(a=[r]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,t);for(let u=0;un.step(new tn(o.from,o.to,o.style)))}function to(n,e,t,r=t.contentMatch,i=!0){let s=n.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a=0;a--)n.step(o[a])}function Qh(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function nn(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,i=0,s=0;;--r){let o=n.$from.node(r),l=n.$from.index(r)+i,a=n.$to.indexAfter(r)-s;if(rt;p--)m||r.index(p)>0?(m=!0,u=S.from(r.node(p).copy(u)),d++):a--;let f=S.empty,h=0;for(let p=s,m=!1;p>t;p--)m||i.after(p+1)=0;o--){if(r.size){let l=t[o].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=S.from(t[o].type.create(t[o].attrs,r))}let i=e.start,s=e.end;n.step(new ke(i,s,i,s,new E(r,0,0),t.length,!0))}function rf(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(o,l)=>{let a=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,a)&&sf(n.doc,n.mapping.slice(s).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&tc(n,o,l,s),to(n,n.mapping.slice(s).map(l,1),r,void 0,c===null);let u=n.mapping.slice(s),d=u.map(l,1),f=u.map(l+o.nodeSize,1);return n.step(new ke(d,f,d+1,f-1,new E(S.from(r.create(a,null,o.marks)),0,0),1,!0)),c===!0&&ec(n,o,l,s),!1}})}function ec(n,e,t,r){e.forEach((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let a=n.mapping.slice(r).map(t+1+s+o.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function tc(n,e,t,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=n.mapping.slice(r).map(t+1+s);n.replaceWith(o,o+1,e.type.schema.text(`
-`))}})}function sf(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function of(n,e,t,r,i){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let o=t.create(r,null,i||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,o);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new ke(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new E(S.from(o),0,0),1,!0))}function je(n,e,t=1,r){let i=n.resolve(e),s=i.depth-t,o=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,u=t-2;c>s;c--,u--){let d=i.node(c),f=i.index(c);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(f,d.childCount),p=r&&r[u+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[u]||d;if(!d.canReplace(f+1,d.childCount)||!m.type.validContent(h))return!1}let l=i.indexAfter(s),a=r&&r[0];return i.node(s).canReplaceWith(l,l,a?a.type:i.node(s+1).type)}function lf(n,e,t=1,r){let i=n.doc.resolve(e),s=S.empty,o=S.empty;for(let l=i.depth,a=i.depth-t,c=t-1;l>a;l--,c--){s=S.from(i.node(l).copy(s));let u=r&&r[c];o=S.from(u?u.type.create(u.attrs,o):i.node(l).copy(o))}n.step(new Ee(e,e,new E(s.append(o),t,t),!0))}function lt(n,e){let t=n.resolve(e),r=t.index();return nc(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function af(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?(s=r.node(i+1),l++,o=r.node(i).maybeChild(l)):(s=r.node(i).maybeChild(l-1),o=r.node(i+1)),s&&!s.isTextblock&&nc(s,o)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=t<0?r.before(i):r.after(i)}}function cf(n,e,t){let r=null,{linebreakReplacement:i}=n.doc.type.schema,s=n.doc.resolve(e-t),o=s.node().type;if(i&&o.inlineContent){let u=o.whitespace=="pre",d=!!o.contentMatch.matchType(i);u&&!d?r=!1:!u&&d&&(r=!0)}let l=n.steps.length;if(r===!1){let u=n.doc.resolve(e+t);tc(n,u.node(),u.before(),l)}o.inlineContent&&to(n,e+t-1,o,s.node().contentMatchAt(s.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new Ee(c,a.map(e+t,-1),E.empty,!0)),r===!0){let u=n.doc.resolve(c);ec(n,u.node(),u.before(),n.steps.length)}return n}function uf(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 s=r.index(i);if(r.node(i).canReplaceWith(s,s,t))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,t))return r.after(i+1);if(s=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,a=r.index(o)+(l>0?1:0),c=r.node(o),u=!1;if(s==1)u=c.canReplace(a,a,i);else{let d=c.contentMatchAt(a).findWrapping(i.firstChild.type);u=d&&c.canReplaceWith(a,a,d[0])}if(u)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function vi(n,e,t=e,r=E.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),s=n.resolve(t);return ic(i,s,r)?new Ee(e,t,r):new df(i,s,r).fit()}function ic(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class df{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=S.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=S.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 s=this.placed,o=r.depth,l=i.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let a=new E(s,o,l);return e>-1?new ke(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new Ee(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),s.type.spec.isolating&&i<=r){e=r;break}t=s.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=$i(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(t==1&&(o?c.matchType(o.type)||(d=c.fillBefore(S.from(o),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:d};if(t==2&&o&&(u=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:s,wrap:u};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=$i(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new E(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=$i(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new E(fn(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new E(fn(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let m=0;m1||a==0||m.content.size)&&(d=g,u.push(sc(m.mark(f.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=pn(this.placed,t,S.from(u)),this.frontier[t].match=d,p&&h<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],s=t=0;l--){let{match:a,type:c}=this.frontier[l],u=Fi(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:o,move:s?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=pn(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=pn(this.placed,this.depth,S.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(S.empty,!0);t.childCount&&(this.placed=pn(this.placed,this.frontier.length,t))}}function fn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(fn(n.firstChild.content,e-1,t)))}function pn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(pn(n.lastChild.content,e-1,t)))}function $i(n,e){for(let t=0;t1&&(r=r.replaceChild(0,sc(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(S.empty,!0)))),n.copy(r)}function Fi(n,e,t,r,i){let s=n.node(e),o=i?n.indexAfter(e):n.index(e);if(o==s.childCount&&!t.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,o);return l&&!hf(t,s.content,o)?l:null}function hf(n,e,t){for(let r=t;r0;f--,h--){let p=i.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(f)>-1?l=f:i.before(f)==h&&o.splice(1,0,-f)}let a=o.indexOf(l),c=[],u=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=u-1;f>=0;f--){let h=c[f],p=ff(h.type);if(p&&!h.sameMarkup(i.node(Math.abs(l)-1)))u=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+u+1)%(r.openStart+1),p=c[h];if(p)for(let m=0;m=0&&(n.replace(e,t,r),!(n.steps.length>d));f--){let h=o[f];h<0||(e=i.before(h),t=s.after(h))}}function oc(n,e,t,r,i){if(er){let s=i.contentMatchAt(0),o=s.fillBefore(n).append(n);n=o.append(s.matchFragment(o).fillBefore(S.empty,!0))}return n}function mf(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=uf(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new E(S.from(r),0,0))}function gf(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 o=r.sharedDepth(t),l=!1;for(let a=r.depth;a>o;a--)r.node(a).type.spec.isolating&&(l=!0);for(let a=i.depth;a>o;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 s=lc(r,i);for(let o=0;o0&&(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 o=1;o<=r.depth&&o<=i.depth;o++)if(e-r.start(o)==r.depth-o&&t>r.end(o)&&i.end(o)-t!=i.depth-o&&r.start(o-1)==i.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),i.index(o-1)))return n.delete(r.before(o),t);n.delete(e,t)}function lc(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let s=n.start(i);if(se.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&t.push(i)}return t}let ac=class Mr extends oe{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 de.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return de.fromReplace(e,this.pos,this.pos+1,new E(S.from(i),0,t.isLeaf?0:1))}getMap(){return Mt.empty}invert(e){return new Mr(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 Mr(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 Mr(t.pos,t.attr,t.value)}};oe.jsonID("attr",ac);let cc=class ws extends oe{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 de.ok(r)}getMap(){return Mt.empty}invert(e){return new ws(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 ws(t.attr,t.value)}};oe.jsonID("docAttr",cc);let Ut=class extends Error{};Ut=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Ut.prototype=Object.create(Error.prototype);Ut.prototype.constructor=Ut;Ut.prototype.name="TransformError";class uc{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new jn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Ut(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=E.empty){let i=vi(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new E(S.from(r),0,0))}delete(e,t){return this.replace(e,t,E.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return pf(this,e,t,r),this}replaceRangeWith(e,t,r){return mf(this,e,t,r),this}deleteRange(e,t){return gf(this,e,t),this}lift(e,t){return Zh(this,e,t),this}join(e,t=1){return cf(this,e,t),this}wrap(e,t){return nf(this,e,t),this}setBlockType(e,t=e,r,i=null){return rf(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return of(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new ac(e,t,r)),this}setDocAttribute(e,t){return this.step(new cc(e,t)),this}addNodeMark(e,t){return this.step(new eo(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 B)t.isInSet(r.marks)&&this.step(new Br(e,t));else{let i=r.marks,s,o=[];for(;s=t.isInSet(i);)o.push(new Br(e,s)),i=s.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,t=1,r){return lf(this,e,t,r),this}addMark(e,t,r){return Yh(this,e,t,r),this}removeMark(e,t,r){return Xh(this,e,t,r),this}clearIncompatible(e,t,r){return to(this,e,t,r),this}}const Hi=Object.create(null);let P=class{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new yf(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;s--){let o=t<0?Bt(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):Bt(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new _e(e.node(0))}static atStart(e){return Bt(e,e,0,0,1)||new _e(e)}static atEnd(e){return Bt(e,e,e.content.size,e.childCount,-1)||new _e(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Hi[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 Hi)throw new RangeError("Duplicate use of selection JSON ID "+e);return Hi[e]=t,t.prototype.jsonID=e,t}getBookmark(){return I.between(this.$anchor,this.$head).getBookmark()}};P.prototype.visible=!0;let yf=class{constructor(e,t){this.$from=e,this.$to=t}},nl=!1;function rl(n){!nl&&!n.parent.inlineContent&&(nl=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}let I=class mn extends P{constructor(e,t=e){rl(e),rl(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 P.near(r);let i=e.resolve(t.map(this.anchor));return new mn(i.parent.inlineContent?i:r,r)}replace(e,t=E.empty){if(super.replace(e,t),t==E.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof mn&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new dc(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 mn(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 s=P.findFrom(t,r,!0)||P.findFrom(t,-r,!0);if(s)t=s.$head;else return P.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(P.findFrom(e,-r,!0)||P.findFrom(e,r,!0)).$anchor,e.pos0?0:1);i>0?o=0;o+=i){let l=e.child(o);if(l.isAtom){if(!s&&N.isSelectable(l))return N.create(n,t-(i<0?l.nodeSize:0))}else{let a=Bt(n,l,t+i,i<0?l.childCount:0,i,s);if(a)return a}t+=l.nodeSize*i}return null}function il(n,e,t){let r=n.steps.length-1;if(r{o==null&&(o=u)}),n.setSelection(P.near(n.doc.resolve(o),t))}const sl=1,lr=2,ol=4;class Sf extends uc{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|=lr,this}ensureMarks(e){return B.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&lr)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~lr,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)||B.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 s=this.storedMarks;if(!s){let o=this.doc.resolve(t);s=r==t?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,i.text(e,s)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(P.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|=ol,this}get scrolledIntoView(){return(this.updated&ol)>0}}function ll(n,e){return!e||!n?n:n.bind(e)}let yn=class{constructor(e,t,r){this.name=e,this.init=ll(t.init,r),this.apply=ll(t.apply,r)}};const xf=[new yn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new yn("selection",{init(n,e){return n.selection||P.atStart(e.doc)},apply(n){return n.selection}}),new yn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new yn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Vi{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=xf.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 yn(r.key,r.spec.state,r))})}}class _t{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],s=i.spec.state;s&&s.toJSON&&(t[r]=s.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 Vi(e.schema,e.plugins),s=new _t(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=tt.fromJSON(e.schema,t.doc);else if(o.name=="selection")s.selection=P.fromJSON(s.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(s.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==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){s[o.name]=c.fromJSON.call(a,e,t[l],s);return}}s[o.name]=o.init(e,s)}}),s}}function pc(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=pc(i,e,{})),t[r]=i}return t}class V{constructor(e){this.spec=e,this.props={},e.props&&pc(e.props,this,this.props),this.key=e.key?e.key.key:mc("plugin")}getState(e){return e[this.key]}}const ji=Object.create(null);function mc(n){return n in ji?n+"$"+ ++ji[n]:(ji[n]=0,n+"$")}class G{constructor(e="key"){this.key=mc(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const gc=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function yc(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const bc=(n,e,t)=>{let r=yc(n,t);if(!r)return!1;let i=ro(r);if(!i){let o=r.blockRange(),l=o&&nn(o);return l==null?!1:(e&&e(n.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(Tc(n,i,e,-1))return!0;if(r.parent.content.size==0&&(qt(s,"end")||N.isSelectable(s)))for(let o=r.depth;;o--){let l=vi(n.doc,r.before(o),r.after(o),E.empty);if(l&&l.slice.size1)break}return s.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},wf=(n,e,t)=>{let r=yc(n,t);if(!r)return!1;let i=ro(r);return i?kc(n,i,e):!1},vf=(n,e,t)=>{let r=xc(n,t);if(!r)return!1;let i=io(r);return i?kc(n,i,e):!1};function kc(n,e,t){let r=e.nodeBefore,i=r,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let u=i.lastChild;if(!u)return!1;i=u}let o=e.nodeAfter,l=o,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=vi(n.doc,s,a,E.empty);if(!c||c.from!=s||c instanceof Ee&&c.slice.size>=a-s)return!1;if(t){let u=n.tr.step(c);u.setSelection(I.create(u.doc,s)),t(u.scrollIntoView())}return!0}function qt(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}const Sc=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;s=ro(r)}let o=s&&s.nodeBefore;return!o||!N.isSelectable(o)?!1:(e&&e(n.tr.setSelection(N.create(n.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function ro(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 xc(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset{let r=xc(n,t);if(!r)return!1;let i=io(r);if(!i)return!1;let s=i.nodeAfter;if(Tc(n,i,e,1))return!0;if(r.parent.content.size==0&&(qt(s,"start")||N.isSelectable(s))){let o=vi(n.doc,r.before(),r.after(),E.empty);if(o&&o.slice.size{let{$head:r,empty:i}=n.selection,s=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 N,i;if(r){if(t.node.isTextblock||!lt(n.doc,t.from))return!1;i=t.from}else if(i=wi(n.doc,t.from,-1),i==null)return!1;if(e){let s=n.tr.join(i);r&&s.setSelection(N.create(s.doc,i-n.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},Cf=(n,e)=>{let t=n.selection,r;if(t instanceof N){if(t.node.isTextblock||!lt(n.doc,t.to))return!1;r=t.to}else if(r=wi(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},Ef=(n,e)=>{let{$from:t,$to:r}=n.selection,i=t.blockRange(r),s=i&&nn(i);return s==null?!1:(e&&e(n.tr.lift(i,s).scrollIntoView()),!0)},Mc=(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 so(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),s=t.indexAfter(-1),o=so(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,o.createAndFill());a.setSelection(P.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Cc=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof _e||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=so(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!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 s=t.before();if(je(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),i=r&&nn(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function Af(n){return(e,t)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof N&&e.selection.node.isBlock)return!r.parentOffset||!je(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],o,l,a=!1,c=!1;for(let h=r.depth;;h--)if(r.node(h).isBlock){a=r.end(h)==r.pos+(r.depth-h),c=r.start(h)==r.pos-(r.depth-h),l=so(r.node(h-1).contentMatchAt(r.indexAfter(h-1))),s.unshift(a&&l?{type:l}:null),o=h;break}else{if(h==1)return!1;s.unshift(null)}let u=e.tr;(e.selection instanceof I||e.selection instanceof _e)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=je(u.doc,d,s.length,s);if(f||(s[0]=l?{type:l}:null,f=je(u.doc,d,s.length,s)),!f)return!1;if(u.split(d,s.length,s),!a&&c&&r.node(o).type!=l){let h=u.mapping.map(r.before(o)),p=u.doc.resolve(h);l&&r.node(o-1).canReplaceWith(p.index(),p.index()+1,l)&&u.setNodeMarkup(u.mapping.map(r.before(o)),l)}return t&&t(u.scrollIntoView()),!0}}const Nf=Af(),Of=(n,e)=>{let{$from:t,to:r}=n.selection,i,s=t.sharedDepth(r);return s==0?!1:(i=t.before(s),e&&e(n.tr.setSelection(N.create(n.doc,i))),!0)};function Rf(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||lt(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Tc(n,e,t,r){let i=e.nodeBefore,s=e.nodeAfter,o,l,a=i.type.spec.isolating||s.type.spec.isolating;if(!a&&Rf(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(t){let h=e.pos+s.nodeSize,p=S.empty;for(let y=o.length-1;y>=0;y--)p=S.from(o[y].create(null,p));p=S.from(i.copy(p));let m=n.tr.step(new ke(e.pos-1,h,e.pos,h,new E(p,1,0),o.length,!0)),g=m.doc.resolve(h+2*o.length);g.nodeAfter&&g.nodeAfter.type==i.type&<(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let u=s.type.spec.isolating||r>0&&a?null:P.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),f=d&&nn(d);if(f!=null&&f>=e.depth)return t&&t(n.tr.lift(d,f).scrollIntoView()),!0;if(c&&qt(s,"start",!0)&&qt(i,"end")){let h=i,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let m=s,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(t){let y=S.empty;for(let M=p.length-1;M>=0;M--)y=S.from(p[M].copy(y));let b=n.tr.step(new ke(e.pos-p.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new E(y,p.length,0),0,!0));t(b.scrollIntoView())}return!0}}return!1}function Ac(n){return function(e,t){let r=e.selection,i=n<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(t&&t(e.tr.setSelection(I.create(e.doc,n<0?i.start(s):i.end(s)))),!0):!1}}const If=Ac(-1),Df=Ac(1);function Pf(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=o&&no(o,n,e);return l?(r&&r(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function al(n,e=null){return function(t,r){let i=!1;for(let s=0;s{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)i=!0;else{let u=t.doc.resolve(c),d=u.index();i=u.parent.canReplaceWith(d,d+1,n)}})}if(!i)return!1;if(r){let s=t.tr;for(let o=0;o=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=o.resolve(e.start-2);s=new Lr(a,a,e.depth),e.endIndex=0;u--)s=S.from(t[u].type.create(t[u].attrs,s));n.step(new ke(e.start-(r?2:0),e.end,e.start,e.end,new E(s,0,0),t.length,!0));let o=0;for(let u=0;uo.childCount>0&&o.firstChild.type==n);return s?t?r.node(s.depth-1).type==n?Ff(e,t,n,s):Hf(e,t,s):!0:!1}}function Ff(n,e,t,r){let i=n.tr,s=r.end,o=r.$to.end(r.depth);sm;p--)h-=i.child(p).nodeSize,r.delete(h-1,h+1);let s=r.doc.resolve(t.start),o=s.nodeAfter;if(r.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==i.childCount,c=s.node(-1),u=s.index(-1);if(!c.canReplace(u+(l?0:1),u+1,o.content.append(a?S.empty:S.from(i))))return!1;let d=s.pos,f=d+o.nodeSize;return r.step(new ke(d-(l?1:0),f+(a?1:0),d+1,f-1,new E((l?S.empty:S.from(i.copy(S.empty))).append(a?S.empty:S.from(i.copy(S.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,s=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==n);if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let l=s.parent,a=l.child(o-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=S.from(c?n.create():null),d=new E(S.from(n.create(null,S.from(l.type.create(null,u)))),c?3:1,0),f=s.start,h=s.end;t(e.tr.step(new ke(f-(c?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}const te=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Jt=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let vs=null;const Fe=function(n,e,t){let r=vs||(vs=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},jf=function(){vs=null},Ct=function(n,e,t,r){return t&&(cl(n,e,t,r,-1)||cl(n,e,t,r,1))},_f=/^(img|br|input|textarea|hr)$/i;function cl(n,e,t,r,i){for(var s;;){if(n==t&&e==r)return!0;if(e==(i<0?0:ve(n))){let o=n.parentNode;if(!o||o.nodeType!=1||Zn(n)||_f.test(n.nodeName)||n.contentEditable=="false")return!1;e=te(n)+(i<0?0:1),n=o}else if(n.nodeType==1){let o=n.childNodes[e+(i<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((s=o.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=i;else return!1;else n=o,e=i<0?ve(n):0}else return!1}}function ve(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Wf(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=ve(n)}else if(n.parentNode&&!Zn(n))e=te(n),n=n.parentNode;else return null}}function Uf(n,e){for(;;){if(n.nodeType==3&&e2),we=Kt||(Ie?/Mac/.test(Ie.platform):!1),Rc=Ie?/Win/.test(Ie.platform):!1,He=/Android \d/.test(at),er=!!ul&&"webkitFontSmoothing"in ul.documentElement.style,Gf=er?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Yf(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 Le(n,e){return typeof n=="number"?n:n[e]}function Xf(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 dl(n,e,t){let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let o=t||n.dom;o;){if(o.nodeType!=1){o=Jt(o);continue}let l=o,a=l==s.body,c=a?Yf(s):Xf(l),u=0,d=0;if(e.topc.bottom-Le(r,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+Le(i,"top")-c.top:e.bottom-c.bottom+Le(i,"bottom")),e.leftc.right-Le(r,"right")&&(u=e.right-c.right+Le(i,"right")),u||d)if(a)s.defaultView.scrollBy(u,d);else{let h=l.scrollLeft,p=l.scrollTop;d&&(l.scrollTop+=d),u&&(l.scrollLeft+=u);let m=l.scrollLeft-h,g=l.scrollTop-p;e={left:e.left-m,top:e.top-g,right:e.right-m,bottom:e.bottom-g}}let f=a?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(f))break;o=f=="absolute"?o.offsetParent:Jt(o)}}function Qf(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,i;for(let s=(e.left+e.right)/2,o=t+1;o=t-20){r=l,i=a.top;break}}return{refDOM:r,refTop:i,stack:Ic(n.dom)}}function Ic(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Jt(r));return e}function Zf({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Dc(t,r==0?0:r-e)}function Dc(n,e){for(let t=0;t=l){o=Math.max(p.bottom,o),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(s=d+1)}}return!t&&a&&(t=a,i=c,r=0),t&&t.nodeType==3?tp(t,i):!t||r&&t.nodeType==1?{node:n,offset:s}:Pc(t,i)}function tp(n,e){let t=n.nodeValue.length,r=document.createRange(),i;for(let s=0;s=(o.left+o.right)/2?1:0)};break}}return r.detach(),i||{node:n,offset:0}}function lo(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function np(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left(o.left+o.right)/2?1:-1}return n.docView.posFromDOM(r,i,s)}function ip(n,e,t,r){let i=-1;for(let s=e,o=!1;s!=n.dom;){let l=n.docView.nearestDesc(s,!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)&&(!o&&a.left>r.left||a.top>r.top?i=l.posBefore:(!o&&a.right-1?i:n.docView.posFromDOM(e,t,-1)}function Lc(n,e,t){let r=n.childNodes.length;if(r&&t.tope.top&&i++}let c;er&&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=ip(n,r,i,e))}l==null&&(l=rp(n,o,e));let a=n.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function hl(n){return n.top=0&&i==r.nodeValue.length?(a--,u=1):t<0?a--:c++,sn(Ge(Fe(r,a,c),u),u<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(t<0||i==ve(r))){let a=r.childNodes[i-1];if(a.nodeType==1)return _i(a.getBoundingClientRect(),!1)}if(s==null&&i=0)}if(s==null&&i&&(t<0||i==ve(r))){let a=r.childNodes[i-1],c=a.nodeType==3?Fe(a,ve(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return sn(Ge(c,1),!1)}if(s==null&&i=0)}function sn(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 _i(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 Bc(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 lp(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return Bc(n,e,()=>{let{node:s}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let o=zc(n,i.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Fe(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;cu.top+1&&(t=="up"?o.top-u.top>(u.bottom-o.top)*2:u.bottom-o.bottom>(o.bottom-u.top)*2))return!1}}return!0})}const ap=/[\u0590-\u08ac]/;function cp(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,o=i==r.parent.content.size,l=n.domSelection();return l?!ap.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:o:Bc(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=n.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let h=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:p,focusOffset:m}=n.domSelectionRange(),g=p&&!h.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==m;try{l.collapse(u,d),a&&(a!=u||c!=d)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),g}):r.pos==r.start()||r.pos==r.end()}let fl=null,pl=null,ml=!1;function up(n,e,t){return fl==e&&pl==t?ml:(fl=e,pl=t,ml=t=="up"||t=="down"?lp(n,e,t):cp(n,e,t))}const Ce=0,gl=1,ht=2,De=3;class tr{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=Ce,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;tte(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 s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.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 s=this.getDesc(i),o;if(s&&(!t||s.node))if(r&&(o=s.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return s}}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 s=this.getDesc(i);if(s)return s.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;te||o instanceof Fc){i=e-s;break}s=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof $c&&s.side>=0;r--);if(t<=0){let s,o=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,o=!1);return s&&t&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?te(s.dom)+1:0}}else{let s,o=!0;for(;s=r=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=o;for(let d=l;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){i=te(f.dom)+1;break}e-=f.size}i==-1&&(i=0)}if(i>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;up&&ot){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}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+s.border,a=o-s.border;if(e>=l&&t<=a){this.dirty=e==r||t==o?ht:gl,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=De:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?ht:De}r=o}this.dirty=ht}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?ht:gl;t.dirty{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==Ce&&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}}class dp extends tr{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}}class Et extends tr{constructor(e,t,r,i,s){super(e,[],r,i),this.mark=t,this.spec=s}static create(e,t,r,i){let s=i.nodeViews[t.type.name],o=s&&s(t,i,r);return(!o||!o.dom)&&(o=Nt.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new Et(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&De||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=De&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Ce){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(s=As(s,0,e,r));for(let l=0;l{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},r,i),u=c&&c.dom,d=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:d}=Nt.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!d&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let f=u;return u=jc(u,r,t),c?a=new hp(e,t,r,i,u,d||null,f,c,s,o+1):t.isText?new Ci(e,t,r,i,u,f,s):new rt(e,t,r,i,u,d||null,f,s,o+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=()=>S.empty)}return e}matchesNode(e,t,r){return this.dirty==Ce&&e.eq(this.node)&&$r(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,s=e.composing?this.localCompositionInfo(e,t):null,o=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new pp(this,o&&o.node,e);yp(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e,u):c.type.side>=0&&!d&&a.syncToMarks(u==this.node.childCount?B.none:this.node.child(u).marks,r,e,u),a.placeWidget(c,e,i)},(c,u,d,f)=>{a.syncToMarks(c.marks,r,e,f);let h;a.findNodeMatch(c,u,d,f)||l&&e.state.selection.from>i&&e.state.selection.to-1&&a.updateNodeAt(c,u,d,h,e)||a.updateNextNode(c,u,d,e,f,i)||a.addNode(c,u,d,e,i),i+=c.nodeSize}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==ht)&&(o&&this.protectLocalComposition(e,o),Hc(this.contentDOM,this.children,e),Kt&&bp(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof I)||rt+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let o=s.nodeValue,l=kp(this.node.content,o,r-t,i-t);return l<0?null:{node:s,pos:l,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:i}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new dp(this,s,t,i);e.input.compositionNodes.push(o),this.children=As(this.children,r,r+i.length,e,o)}update(e,t,r,i){return this.dirty==De||!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=Ce}updateOuterDeco(e){if($r(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Vc(this.dom,this.nodeDOM,Ts(this.outerDeco,this.node,t),Ts(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 yl(n,e,t,r,i){jc(r,e,n);let s=new rt(void 0,n,e,t,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class Ci extends rt{constructor(e,t,r,i,s,o,l){super(e,t,r,i,s,null,o,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==De||this.dirty!=Ce&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Ce||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=Ce,!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),s=document.createTextNode(i.text);return new Ci(this.parent,i,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=De)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Fc extends tr{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ce&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class hp extends rt{constructor(e,t,r,i,s,o,l,a,c,u){super(e,t,r,i,s,o,l,c,u),this.spec=a}update(e,t,r,i){if(this.dirty==De)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,r);return s&&this.updateInner(e,t,r,i),s}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 Hc(n,e,t){let r=n.firstChild,i=!1;for(let s=0;s>1,l=Math.min(o,e.length);for(;s-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let u=Et.create(this.top,e[o],t,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,r,i){let s=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,r))s=this.top.children.indexOf(o,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 Et)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,s.set(l,i),o.push(l)}}return{index:i,matched:s,matches:o.reverse()}}function gp(n,e){return n.type.side-e.type.side}function yp(n,e,t,r){let i=e.locals(n),s=0;if(i.length==0){for(let c=0;cs;)l.push(i[o++]);let p=s+f.nodeSize;if(f.isText){let g=p;o!g.inline):l.slice();r(f,m,e.forChild(s,f),h),s=p}}function bp(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 kp(n,e,t,r){for(let i=0,s=0;i=t){if(s>=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 As(n,e,t,r,i){let s=[];for(let o=0,l=0;o=t||u<=e?s.push(a):(ct&&s.push(a.slice(t-c,a.size,r)))}return s}function ao(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),s=i&&i.size==0,o=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,c;if(Mi(t)){for(a=o;i&&!i.node;)i=i.parent;let d=i.node;if(i&&d.isAtom&&N.isSelectable(d)&&i.parent&&!(d.isInline&&qf(t.focusNode,t.focusOffset,i.dom))){let f=i.posBefore;c=new N(o==f?l:r.resolve(f))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let d=o,f=o;for(let h=0;h{(t.anchorNode!=r||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!_c(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function xp(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,r=t.nodeName=="IMG";r?e.collapse(t.parentNode,te(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&be&&nt<=11&&(t.disabled=!0,t.disabled=!1)}function Wc(n,e){if(e instanceof N){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(wl(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else wl(n)}function wl(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function co(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||I.between(e,t,r)}function vl(n){return n.editable&&!n.hasFocus()?!1:Uc(n)}function Uc(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 wp(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Ct(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Ns(n,e){let{$anchor:t,$head:r}=n.selection,i=e>0?t.max(r):t.min(r),s=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return s&&P.findFrom(s,e)}function Xe(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Ml(n,e,t){let r=n.state.selection;if(r instanceof I)if(t.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=n.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return Xe(n,new I(r.$anchor,o))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=Ns(n.state,e);return i&&i instanceof N?Xe(n,i):!1}else if(!(we&&t.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let l=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=n.docView.descAt(l))&&!o.contentDOM?N.isSelectable(s)?Xe(n,new N(e<0?n.state.doc.resolve(i.pos-s.nodeSize):i)):er?Xe(n,new I(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof N&&r.node.isInline)return Xe(n,new I(e>0?r.$to:r.$from));{let i=Ns(n.state,e);return i?Xe(n,i):!1}}}function Fr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function On(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Pt(n,e){return e<0?vp(n):Mp(n)}function vp(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,s,o=!1;for(Me&&t.nodeType==1&&r0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(On(l,-1))i=t,s=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(qc(t))break;{let l=t.previousSibling;for(;l&&On(l,-1);)i=t.parentNode,s=te(l),l=l.previousSibling;if(l)t=l,r=Fr(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}o?Os(n,t,r):i&&Os(n,i,s)}function Mp(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=Fr(t),s,o;for(;;)if(r{n.state==i&&We(n)},50)}function Cl(n,e){let t=n.state.doc.resolve(e);if(!(Q||Rc)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>i.top&&o1)return s.lefti.top&&o1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function El(n,e,t){let r=n.state.selection;if(r instanceof I&&!r.empty||t.indexOf("s")>-1||we&&t.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=Ns(n.state,e);if(o&&o instanceof N)return Xe(n,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=r instanceof _e?P.near(o,e):P.findFrom(o,e);return l?Xe(n,l):!1}return!1}function Tl(n,e){if(!(n.state.selection instanceof I))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 s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let o=n.state.tr;return e<0?o.delete(t.pos-s.nodeSize,t.pos):o.delete(t.pos,t.pos+s.nodeSize),n.dispatch(o),!0}return!1}function Al(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Tp(n){if(!se||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Al(n,r,"true"),setTimeout(()=>Al(n,r,"false"),20)}return!1}function Ap(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Np(n,e){let t=e.keyCode,r=Ap(e);if(t==8||we&&t==72&&r=="c")return Tl(n,-1)||Pt(n,-1);if(t==46&&!e.shiftKey||we&&t==68&&r=="c")return Tl(n,1)||Pt(n,1);if(t==13||t==27)return!0;if(t==37||we&&t==66&&r=="c"){let i=t==37?Cl(n,n.state.selection.from)=="ltr"?-1:1:-1;return Ml(n,i,r)||Pt(n,i)}else if(t==39||we&&t==70&&r=="c"){let i=t==39?Cl(n,n.state.selection.from)=="ltr"?1:-1:1;return Ml(n,i,r)||Pt(n,i)}else{if(t==38||we&&t==80&&r=="c")return El(n,-1,r)||Pt(n,-1);if(t==40||we&&t==78&&r=="c")return Tp(n)||El(n,1,r)||Pt(n,1);if(r==(we?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function uo(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let o=n.someProp("clipboardSerializer")||Nt.fromSchema(n.state.schema),l=Qc(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=Xc[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=l.createElement(u[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),d++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${s}${d?` -${d}`:""} ${JSON.stringify(t)}`);let f=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
+ */var qt=D;function ph(n,e){return n===e&&(n!==0||1/n===1/e)||n!==n&&e!==e}var mh=typeof Object.is=="function"?Object.is:ph,gh=qt.useState,yh=qt.useEffect,bh=qt.useLayoutEffect,kh=qt.useDebugValue;function Sh(n,e){var t=e(),r=gh({inst:{value:t,getSnapshot:e}}),i=r[0].inst,s=r[1];return bh(function(){i.value=t,i.getSnapshot=e,Li(i)&&s({inst:i})},[n,t,e]),yh(function(){return Li(i)&&s({inst:i}),n(function(){Li(i)&&s({inst:i})})},[n]),kh(t),t}function Li(n){var e=n.getSnapshot;n=n.value;try{var t=e();return!mh(n,t)}catch{return!0}}function xh(n,e){return e()}var wh=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?xh:Sh;Ea.useSyncExternalStore=qt.useSyncExternalStore!==void 0?qt.useSyncExternalStore:wh;Ca.exports=Ea;var Gs=Ca.exports;function te(n){this.content=n}te.prototype={constructor:te,find:function(n){for(var e=0;e>1}};te.from=function(n){if(n instanceof te)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new te(e)};function Ta(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),s=e.child(r);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){let o=i.text,l=s.text,a=0;for(;o[a]==l[a];a++)t++;return a&&a0&&f>0&&c[d-1]==u[f-1];)d--,f--,t--,r--;return d&&f&&d=56320&&n<57344}function Oa(n){return n>=55296&&n<56320}let S=class ce{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;re&&r(a,i+l,s||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,i+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let s="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),s=1);se)for(let s=0,o=0;oe&&((ot)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),r.push(l),i+=l.nodeSize),o=a}return new ce(r,i)}cutByIndex(e,t){return e==t?ce.empty:e==0&&t==this.content.length?this:new ce(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new ce(i,s)}addToStart(e){return new ce([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new ce(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),s=r+i.nodeSize;if(s>=e)return s==e?ir(t+1,s):ir(t,r);r=s}}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 ce.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return ce.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return ce.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(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;tr.type.rank-i.type.rank),t}};$.none=[];let Fn=class extends Error{},C=class Bt{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=Ia(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return r&&new Bt(r,this.openStart,this.openEnd)}removeBetween(e,t){return new Bt(Ra(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 Bt.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 Bt(S.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new Bt(e,r,i)}};C.empty=new C(S.empty,0,0);function Ra(n,e,t){let{index:r,offset:i}=n.findIndex(e),s=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(i==e||s.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(Ra(s.content,e-i-1,t-i-1)))}function Ia(n,e,t,r,i,s){let{index:o,offset:l}=n.findIndex(e),a=n.maybeChild(o);if(l==e||a.isText)return s&&r<=0&&i<=0&&!s.canReplace(o,o,t)?null:n.cut(0,e).append(t).append(n.cut(e));let c=Ia(a.content,e-l-1,t,o==0?r-1:0,o==n.childCount-1?i-1:0,a);return c&&n.replaceChild(o,a.copy(c))}function vh(n,e,t){if(t.openStart>n.depth)throw new Fn("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Fn("Inconsistent open depths");return Da(n,e,t,0)}function Da(n,e,t,r){let i=n.index(r),s=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 Tn(n,e,t,r){let i=(e||n).node(t),s=0,o=e?e.index(t):i.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(bt(n.nodeAfter,r),s++));for(let l=s;li&&ms(n,e,i+1),o=r.depth>i&&ms(t,r,i+1),l=[];return Tn(null,n,i,l),s&&o&&e.index(i)==t.index(i)?(Pa(s,o),bt(kt(s,La(n,e,t,r,i+1)),l)):(s&&bt(kt(s,Pr(n,e,i+1)),l),Tn(e,t,i,l),o&&bt(kt(o,Pr(t,r,i+1)),l)),Tn(r,null,i,l),new S(l)}function Pr(n,e,t){let r=[];if(Tn(null,n,t,r),n.depth>t){let i=ms(n,e,t+1);bt(kt(i,Pr(n,e,t+1)),r)}return Tn(e,null,t,r),new S(r)}function Mh(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)i=e.node(s).copy(S.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class Hn{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 s=0;s0;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 Lr(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,s=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(s),c=s-a;if(r.push(o,l,i+a),!c||(o=o.child(l),o.isText))break;s=c-1,i+=a+1}return new Hn(t,r,s)}static resolveCached(e,t){let r=Vo.get(e);if(r)for(let s=0;se&&this.nodesBetween(e,t,s=>(r.isInSet(s.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()+")"),za(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=S.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),l=o&&o.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=S.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,i,r);return s.type.checkAttrs(s.attrs),s}}Ne.prototype.text=void 0;class zr extends Ne{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):za(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 zr(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new zr(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 za(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Mt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Ah(e,t);if(r.next==null)return Mt.empty;let i=Ba(r);r.next&&r.err("Unexpected trailing text");let s=Lh(Ph(i));return zh(s,r),s}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 s=i+(r.validEnd?"*":" ")+" ";for(let o=0;o"+e.indexOf(r.next[o].next);return s}).join(`
+`)}}Mt.empty=new Mt(!0);class Ah{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 Ba(n){let e=[];do e.push(Nh(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Nh(n){let e=[];do e.push(Oh(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Oh(n){let e=Dh(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=Rh(n,e);else break;return e}function jo(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Rh(n,e){let t=jo(n),r=t;return n.eat(",")&&(n.next!="}"?r=jo(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function Ih(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let s in t){let o=t[s];o.isInGroup(e)&&i.push(o)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function Dh(n){if(n.eat("(")){let e=Ba(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=Ih(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 Ph(n){let e=[[]];return i(s(n,0),t()),e;function t(){return e.push([])-1}function r(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function i(o,l){o.forEach(a=>a.to=l)}function s(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(s(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=s(o.exprs[a],l);if(a==o.exprs.length-1)return c;i(c,l=t())}else if(o.type=="star"){let a=t();return r(l,a),i(s(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=t();return i(s(o.expr,l),a),i(s(o.expr,a),a),[r(a)]}else{if(o.type=="opt")return[r(l)].concat(s(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c{n[o].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 s=e[r.join(",")]=new Mt(r.indexOf(n.length-1)>-1);for(let o=0;o-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:Ha(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Ne(this,this.computeAttrs(e),S.from(t),$.setFrom(r))}createChecked(e=null,t,r){return t=S.from(t),this.checkContent(t),new Ne(this,this.computeAttrs(e),t,$.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=S.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let i=this.contentMatch.matchFragment(t),s=i&&i.fillBefore(S.empty,!0);return s?new Ne(this,e,t.append(s),$.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[s]=new _a(s,t,o));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 s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Bh(n,e,t){let r=t.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${s}`)}}class $h{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Bh(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class xi{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=ja(e,i.attrs),this.excluded=null;let s=Fa(this.attrs);this.instance=s?new $(this,s):null}create(e=null){return!e&&this.instance?this.instance:new $(this,Ha(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new xi(s,i++,t,o)),r}removeFromSet(e){for(var t=0;t-1}}class Wa{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=te.from(e.nodes),t.marks=te.from(e.marks||{}),this.nodes=Wo.compile(this.spec.nodes,this),this.marks=xi.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 s=this.nodes[i],o=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=r[o]||(r[o]=Mt.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?Uo(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:Uo(this,o.split(" "))}this.nodeFromJSON=i=>Ne.fromJSON(this,i),this.markFromJSON=i=>$.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 Wo){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 zr(r,r.defaultAttrs,e,$.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 Uo(n,e){let t=[];for(let r=0;r-1)&&t.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function Fh(n){return n.tag!=null}function Hh(n){return n.style!=null}class nt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(Fh(i))this.tags.push(i);else if(Hh(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let r=new Jo(this,t,!1);return r.addAll(e,$.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Jo(this,t,!0);return r.addAll(e,$.none,t.from,t.to),C.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(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function r(i){let s=i.priority==null?50:i.priority,o=0;for(;o{r(o=Ko(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{r(o=Ko(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new nt(e,nt.schemaRules(e)))}}const Ua={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},Vh={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},qa={ol:!0,ul:!0},Vn=1,gs=2,An=4;function qo(n,e,t){return e!=null?(e?Vn:0)|(e==="full"?gs:0):n&&n.whitespace=="pre"?Vn|gs:t&~An}class sr{constructor(e,t,r,i,s,o){this.type=e,this.attrs=t,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=$.none,this.match=s||(o&An?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(S.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Vn)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let t=S.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(S.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Ua.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Jo{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=t.topNode,s,o=qo(null,t.preserveWhitespace,0)|(r?An:0);i?s=new sr(i.type,i.attrs,$.none,!0,t.topMatch||i.type.contentMatch,o):r?s=new sr(null,null,$.none,!0,null,o):s=new sr(e.schema.topNodeType,null,$.none,!0,null,o),this.nodes=[s],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,s=i.options&gs?"full":this.localPreserveWS||(i.options&Vn)>0,{schema:o}=this.parser;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,`
+`);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a!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 s,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(o,t.attrs||null,r,t.preserveWhitespace);a&&(s=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(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)}s&&this.sync(l)&&this.open--}addAll(e,t,r,i){let s=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,t);this.findAtPoint(e,s)}findPlace(e,t,r){let i,s;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],c=a.findWrapping(e);if(c&&(!i||i.length>c.length+l)&&(i=c,s=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!i)return null;this.sync(s);for(let o=0;o(o.type?o.type.allowsMarkType(c.type):Go(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new sr(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|=Vn)}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),s=-(r?r.depth+1:0)+(i?0:1),o=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=s;a--)if(o(l-1,a))return!0;return!1}else{let u=a>0||a==0&&i?this.nodes[a].type:r&&a>=s?r.node(a-s).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function jh(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&qa.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function _h(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Ko(n){let e={};for(let t in n)e[t]=n[t];return e}function Go(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let s=[],o=l=>{s.push(l);for(let a=0;a{if(s.length||o.marks.length){let l=0,a=0;for(;l=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&xr(or(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return typeof t=="string"?{dom:e.createTextNode(t)}:xr(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Ot(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Yo(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Yo(e.marks)}}function Yo(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function or(n){return n.document||window.document}const Xo=new WeakMap;function Wh(n){let e=Xo.get(n);return e===void 0&&Xo.set(n,e=Uh(n)),e}function Uh(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 o=i.indexOf(" ");o>0&&(t=i.slice(0,o),i=i.slice(o+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 d in c)if(c[d]!=null){let f=d.indexOf(" ");f>0?a.setAttributeNS(d.slice(0,f),d.slice(f+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;du)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else if(typeof f=="string")a.appendChild(n.createTextNode(f));else{let{dom:h,contentDOM:p}=xr(n,f,t,r);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const Ja=65535,Ka=Math.pow(2,16);function qh(n,e){return n+e*Ka}function Qo(n){return n&Ja}function Jh(n){return(n-(n&Ja))/Ka}const Ga=1,Ya=2,wr=4,Xa=8;let ys=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Xa)>0}get deletedBefore(){return(this.delInfo&(Ga|wr))>0}get deletedAfter(){return(this.delInfo&(Ya|wr))>0}get deletedAcross(){return(this.delInfo&wr)>0}},Ct=class $t{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&$t.empty)return $t.empty}recover(e){let t=0,r=Qo(e);if(!this.inverted)for(let i=0;ie)break;let c=this.ranges[l+s],u=this.ranges[l+o],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:t:t,h=a+i+(f<0?0:u);if(r)return h;let p=e==(t<0?a:d)?null:qh(l/3,e-a),m=e==a?Ya:e==d?Ga:wr;return(t<0?e!=a:e!=d)&&(m|=Xa),new ys(h,m,p)}i+=u-c}return r?e+i:new ys(e+i,0,null)}touches(e,t){let r=0,i=Qo(t),s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;le)break;let c=this.ranges[l+s],u=a+c;if(e<=u&&l==i*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=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 jn;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;rs&&a!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),t.openStart,t.openEnd);return de.fromReplace(e,this.from,this.to,s)}invert(){return new rn(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 dn(t.pos,r.pos,this.mark)}merge(e){return e instanceof dn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new dn(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 dn(t.from,t.to,e.markFromJSON(t.mark))}};le.jsonID("addMark",Xs);let rn=class hn extends le{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 C(Ys(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return de.fromReplace(e,this.from,this.to,r)}invert(){return new Xs(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 hn(t.pos,r.pos,this.mark)}merge(e){return e instanceof hn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new hn(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 hn(t.from,t.to,e.markFromJSON(t.mark))}};le.jsonID("removeMark",rn);let Qs=class fn extends le{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return de.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return de.fromReplace(e,this.pos,this.pos+1,new C(S.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;ir.pos?null:new vr(t.pos,r.pos,i,s,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 vr(t.from,t.to,t.gapFrom,t.gapTo,C.fromJSON(e,t.slice),t.insert,!!t.structure)}};le.jsonID("replaceAround",ke);function ks(n,e,t){let r=n.resolve(e),i=t-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function Kh(n,e,t,r){let i=[],s=[],o,l;n.doc.nodesBetween(e,t,(a,c,u)=>{if(!a.isInline)return;let d=a.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,t),p=r.addToSet(d);for(let m=0;mn.step(a)),s.forEach(a=>n.step(a))}function Gh(n,e,t,r){let i=[],s=0;n.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;s++;let a=null;if(r instanceof xi){let c=o.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(o.marks)&&(a=[r]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,t);for(let u=0;un.step(new rn(o.from,o.to,o.style)))}function Zs(n,e,t,r=t.contentMatch,i=!0){let s=n.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a=0;a--)n.step(o[a])}function Yh(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function sn(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,i=0,s=0;;--r){let o=n.$from.node(r),l=n.$from.index(r)+i,a=n.$to.indexAfter(r)-s;if(rt;p--)m||r.index(p)>0?(m=!0,u=S.from(r.node(p).copy(u)),d++):a--;let f=S.empty,h=0;for(let p=s,m=!1;p>t;p--)m||i.after(p+1)=0;o--){if(r.size){let l=t[o].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=S.from(t[o].type.create(t[o].attrs,r))}let i=e.start,s=e.end;n.step(new ke(i,s,i,s,new C(r,0,0),t.length,!0))}function tf(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(o,l)=>{let a=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,a)&&nf(n.doc,n.mapping.slice(s).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&Za(n,o,l,s),Zs(n,n.mapping.slice(s).map(l,1),r,void 0,c===null);let u=n.mapping.slice(s),d=u.map(l,1),f=u.map(l+o.nodeSize,1);return n.step(new ke(d,f,d+1,f-1,new C(S.from(r.create(a,null,o.marks)),0,0),1,!0)),c===!0&&Qa(n,o,l,s),!1}})}function Qa(n,e,t,r){e.forEach((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let a=n.mapping.slice(r).map(t+1+s+o.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Za(n,e,t,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=n.mapping.slice(r).map(t+1+s);n.replaceWith(o,o+1,e.type.schema.text(`
+`))}})}function nf(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function rf(n,e,t,r,i){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let o=t.create(r,null,i||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,o);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new ke(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new C(S.from(o),0,0),1,!0))}function _e(n,e,t=1,r){let i=n.resolve(e),s=i.depth-t,o=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,u=t-2;c>s;c--,u--){let d=i.node(c),f=i.index(c);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(f,d.childCount),p=r&&r[u+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[u]||d;if(!d.canReplace(f+1,d.childCount)||!m.type.validContent(h))return!1}let l=i.indexAfter(s),a=r&&r[0];return i.node(s).canReplaceWith(l,l,a?a.type:i.node(s+1).type)}function sf(n,e,t=1,r){let i=n.doc.resolve(e),s=S.empty,o=S.empty;for(let l=i.depth,a=i.depth-t,c=t-1;l>a;l--,c--){s=S.from(i.node(l).copy(s));let u=r&&r[c];o=S.from(u?u.type.create(u.attrs,o):i.node(l).copy(o))}n.step(new Te(e,e,new C(s.append(o),t,t),!0))}function at(n,e){let t=n.resolve(e),r=t.index();return ec(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function of(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?(s=r.node(i+1),l++,o=r.node(i).maybeChild(l)):(s=r.node(i).maybeChild(l-1),o=r.node(i+1)),s&&!s.isTextblock&&ec(s,o)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=t<0?r.before(i):r.after(i)}}function lf(n,e,t){let r=null,{linebreakReplacement:i}=n.doc.type.schema,s=n.doc.resolve(e-t),o=s.node().type;if(i&&o.inlineContent){let u=o.whitespace=="pre",d=!!o.contentMatch.matchType(i);u&&!d?r=!1:!u&&d&&(r=!0)}let l=n.steps.length;if(r===!1){let u=n.doc.resolve(e+t);Za(n,u.node(),u.before(),l)}o.inlineContent&&Zs(n,e+t-1,o,s.node().contentMatchAt(s.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new Te(c,a.map(e+t,-1),C.empty,!0)),r===!0){let u=n.doc.resolve(c);Qa(n,u.node(),u.before(),n.steps.length)}return n}function af(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 s=r.index(i);if(r.node(i).canReplaceWith(s,s,t))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,t))return r.after(i+1);if(s=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,a=r.index(o)+(l>0?1:0),c=r.node(o),u=!1;if(s==1)u=c.canReplace(a,a,i);else{let d=c.contentMatchAt(a).findWrapping(i.firstChild.type);u=d&&c.canReplaceWith(a,a,d[0])}if(u)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function vi(n,e,t=e,r=C.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),s=n.resolve(t);return nc(i,s,r)?new Te(e,t,r):new cf(i,s,r).fit()}function nc(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class cf{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=S.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=S.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 s=this.placed,o=r.depth,l=i.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let a=new C(s,o,l);return e>-1?new ke(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new Te(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),s.type.spec.isolating&&i<=r){e=r;break}t=s.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=$i(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(t==1&&(o?c.matchType(o.type)||(d=c.fillBefore(S.from(o),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:d};if(t==2&&o&&(u=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:s,wrap:u};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=$i(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new C(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=$i(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new C(pn(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new C(pn(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let m=0;m1||a==0||m.content.size)&&(d=g,u.push(rc(m.mark(f.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=mn(this.placed,t,S.from(u)),this.frontier[t].match=d,p&&h<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],s=t=0;l--){let{match:a,type:c}=this.frontier[l],u=Fi(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:o,move:s?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=mn(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=mn(this.placed,this.depth,S.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(S.empty,!0);t.childCount&&(this.placed=mn(this.placed,this.frontier.length,t))}}function pn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(pn(n.firstChild.content,e-1,t)))}function mn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(mn(n.lastChild.content,e-1,t)))}function $i(n,e){for(let t=0;t1&&(r=r.replaceChild(0,rc(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(S.empty,!0)))),n.copy(r)}function Fi(n,e,t,r,i){let s=n.node(e),o=i?n.indexAfter(e):n.index(e);if(o==s.childCount&&!t.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,o);return l&&!uf(t,s.content,o)?l:null}function uf(n,e,t){for(let r=t;r0;f--,h--){let p=i.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(f)>-1?l=f:i.before(f)==h&&o.splice(1,0,-f)}let a=o.indexOf(l),c=[],u=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=u-1;f>=0;f--){let h=c[f],p=df(h.type);if(p&&!h.sameMarkup(i.node(Math.abs(l)-1)))u=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+u+1)%(r.openStart+1),p=c[h];if(p)for(let m=0;m=0&&(n.replace(e,t,r),!(n.steps.length>d));f--){let h=o[f];h<0||(e=i.before(h),t=s.after(h))}}function ic(n,e,t,r,i){if(er){let s=i.contentMatchAt(0),o=s.fillBefore(n).append(n);n=o.append(s.matchFragment(o).fillBefore(S.empty,!0))}return n}function ff(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=af(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new C(S.from(r),0,0))}function pf(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 o=r.sharedDepth(t),l=!1;for(let a=r.depth;a>o;a--)r.node(a).type.spec.isolating&&(l=!0);for(let a=i.depth;a>o;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 s=sc(r,i);for(let o=0;o0&&(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 o=1;o<=r.depth&&o<=i.depth;o++)if(e-r.start(o)==r.depth-o&&t>r.end(o)&&i.end(o)-t!=i.depth-o&&r.start(o-1)==i.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),i.index(o-1)))return n.delete(r.before(o),t);n.delete(e,t)}function sc(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let s=n.start(i);if(se.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&t.push(i)}return t}let oc=class Mr extends le{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 de.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return de.fromReplace(e,this.pos,this.pos+1,new C(S.from(i),0,t.isLeaf?0:1))}getMap(){return Ct.empty}invert(e){return new Mr(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 Mr(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 Mr(t.pos,t.attr,t.value)}};le.jsonID("attr",oc);let lc=class Ss extends le{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 de.ok(r)}getMap(){return Ct.empty}invert(e){return new Ss(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 Ss(t.attr,t.value)}};le.jsonID("docAttr",lc);let Jt=class extends Error{};Jt=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Jt.prototype=Object.create(Error.prototype);Jt.prototype.constructor=Jt;Jt.prototype.name="TransformError";class ac{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new jn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Jt(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=C.empty){let i=vi(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new C(S.from(r),0,0))}delete(e,t){return this.replace(e,t,C.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return hf(this,e,t,r),this}replaceRangeWith(e,t,r){return ff(this,e,t,r),this}deleteRange(e,t){return pf(this,e,t),this}lift(e,t){return Xh(this,e,t),this}join(e,t=1){return lf(this,e,t),this}wrap(e,t){return ef(this,e,t),this}setBlockType(e,t=e,r,i=null){return tf(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return rf(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new oc(e,t,r)),this}setDocAttribute(e,t){return this.step(new lc(e,t)),this}addNodeMark(e,t){return this.step(new Qs(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 $)t.isInSet(r.marks)&&this.step(new Br(e,t));else{let i=r.marks,s,o=[];for(;s=t.isInSet(i);)o.push(new Br(e,s)),i=s.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,t=1,r){return sf(this,e,t,r),this}addMark(e,t,r){return Kh(this,e,t,r),this}removeMark(e,t,r){return Gh(this,e,t,r),this}clearIncompatible(e,t,r){return Zs(this,e,t,r),this}}const Hi=Object.create(null);let P=class{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new mf(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;s--){let o=t<0?Ft(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):Ft(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new We(e.node(0))}static atStart(e){return Ft(e,e,0,0,1)||new We(e)}static atEnd(e){return Ft(e,e,e.content.size,e.childCount,-1)||new We(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Hi[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 Hi)throw new RangeError("Duplicate use of selection JSON ID "+e);return Hi[e]=t,t.prototype.jsonID=e,t}getBookmark(){return R.between(this.$anchor,this.$head).getBookmark()}};P.prototype.visible=!0;let mf=class{constructor(e,t){this.$from=e,this.$to=t}},el=!1;function tl(n){!el&&!n.parent.inlineContent&&(el=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}let R=class gn extends P{constructor(e,t=e){tl(e),tl(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 P.near(r);let i=e.resolve(t.map(this.anchor));return new gn(i.parent.inlineContent?i:r,r)}replace(e,t=C.empty){if(super.replace(e,t),t==C.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof gn&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new cc(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 gn(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 s=P.findFrom(t,r,!0)||P.findFrom(t,-r,!0);if(s)t=s.$head;else return P.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(P.findFrom(e,-r,!0)||P.findFrom(e,r,!0)).$anchor,e.pos0?0:1);i>0?o=0;o+=i){let l=e.child(o);if(l.isAtom){if(!s&&N.isSelectable(l))return N.create(n,t-(i<0?l.nodeSize:0))}else{let a=Ft(n,l,t+i,i<0?l.childCount:0,i,s);if(a)return a}t+=l.nodeSize*i}return null}function nl(n,e,t){let r=n.steps.length-1;if(r{o==null&&(o=u)}),n.setSelection(P.near(n.doc.resolve(o),t))}const rl=1,lr=2,il=4;class bf extends ac{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|=lr,this}ensureMarks(e){return $.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&lr)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~lr,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)||$.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 s=this.storedMarks;if(!s){let o=this.doc.resolve(t);s=r==t?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,i.text(e,s)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(P.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|=il,this}get scrolledIntoView(){return(this.updated&il)>0}}function sl(n,e){return!e||!n?n:n.bind(e)}let bn=class{constructor(e,t,r){this.name=e,this.init=sl(t.init,r),this.apply=sl(t.apply,r)}};const kf=[new bn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new bn("selection",{init(n,e){return n.selection||P.atStart(e.doc)},apply(n){return n.selection}}),new bn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new bn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Vi{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=kf.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 bn(r.key,r.spec.state,r))})}}class Ut{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],s=i.spec.state;s&&s.toJSON&&(t[r]=s.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 Vi(e.schema,e.plugins),s=new Ut(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=Ne.fromJSON(e.schema,t.doc);else if(o.name=="selection")s.selection=P.fromJSON(s.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(s.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==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){s[o.name]=c.fromJSON.call(a,e,t[l],s);return}}s[o.name]=o.init(e,s)}}),s}}function hc(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=hc(i,e,{})),t[r]=i}return t}class j{constructor(e){this.spec=e,this.props={},e.props&&hc(e.props,this,this.props),this.key=e.key?e.key.key:fc("plugin")}getState(e){return e[this.key]}}const ji=Object.create(null);function fc(n){return n in ji?n+"$"+ ++ji[n]:(ji[n]=0,n+"$")}class G{constructor(e="key"){this.key=fc(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const pc=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function mc(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const gc=(n,e,t)=>{let r=mc(n,t);if(!r)return!1;let i=to(r);if(!i){let o=r.blockRange(),l=o&&sn(o);return l==null?!1:(e&&e(n.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(Cc(n,i,e,-1))return!0;if(r.parent.content.size==0&&(Kt(s,"end")||N.isSelectable(s)))for(let o=r.depth;;o--){let l=vi(n.doc,r.before(o),r.after(o),C.empty);if(l&&l.slice.size1)break}return s.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},Sf=(n,e,t)=>{let r=mc(n,t);if(!r)return!1;let i=to(r);return i?yc(n,i,e):!1},xf=(n,e,t)=>{let r=kc(n,t);if(!r)return!1;let i=no(r);return i?yc(n,i,e):!1};function yc(n,e,t){let r=e.nodeBefore,i=r,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let u=i.lastChild;if(!u)return!1;i=u}let o=e.nodeAfter,l=o,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=vi(n.doc,s,a,C.empty);if(!c||c.from!=s||c instanceof Te&&c.slice.size>=a-s)return!1;if(t){let u=n.tr.step(c);u.setSelection(R.create(u.doc,s)),t(u.scrollIntoView())}return!0}function Kt(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}const bc=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;s=to(r)}let o=s&&s.nodeBefore;return!o||!N.isSelectable(o)?!1:(e&&e(n.tr.setSelection(N.create(n.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function to(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 kc(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset{let r=kc(n,t);if(!r)return!1;let i=no(r);if(!i)return!1;let s=i.nodeAfter;if(Cc(n,i,e,1))return!0;if(r.parent.content.size==0&&(Kt(s,"start")||N.isSelectable(s))){let o=vi(n.doc,r.before(),r.after(),C.empty);if(o&&o.slice.size{let{$head:r,empty:i}=n.selection,s=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 N,i;if(r){if(t.node.isTextblock||!at(n.doc,t.from))return!1;i=t.from}else if(i=wi(n.doc,t.from,-1),i==null)return!1;if(e){let s=n.tr.join(i);r&&s.setSelection(N.create(s.doc,i-n.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},vf=(n,e)=>{let t=n.selection,r;if(t instanceof N){if(t.node.isTextblock||!at(n.doc,t.to))return!1;r=t.to}else if(r=wi(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},Mf=(n,e)=>{let{$from:t,$to:r}=n.selection,i=t.blockRange(r),s=i&&sn(i);return s==null?!1:(e&&e(n.tr.lift(i,s).scrollIntoView()),!0)},wc=(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 ro(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),s=t.indexAfter(-1),o=ro(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,o.createAndFill());a.setSelection(P.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},vc=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof We||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=ro(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!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 s=t.before();if(_e(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),i=r&&sn(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function Ef(n){return(e,t)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof N&&e.selection.node.isBlock)return!r.parentOffset||!_e(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],o,l,a=!1,c=!1;for(let h=r.depth;;h--)if(r.node(h).isBlock){a=r.end(h)==r.pos+(r.depth-h),c=r.start(h)==r.pos-(r.depth-h),l=ro(r.node(h-1).contentMatchAt(r.indexAfter(h-1))),s.unshift(a&&l?{type:l}:null),o=h;break}else{if(h==1)return!1;s.unshift(null)}let u=e.tr;(e.selection instanceof R||e.selection instanceof We)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=_e(u.doc,d,s.length,s);if(f||(s[0]=l?{type:l}:null,f=_e(u.doc,d,s.length,s)),!f)return!1;if(u.split(d,s.length,s),!a&&c&&r.node(o).type!=l){let h=u.mapping.map(r.before(o)),p=u.doc.resolve(h);l&&r.node(o-1).canReplaceWith(p.index(),p.index()+1,l)&&u.setNodeMarkup(u.mapping.map(r.before(o)),l)}return t&&t(u.scrollIntoView()),!0}}const Tf=Ef(),Af=(n,e)=>{let{$from:t,to:r}=n.selection,i,s=t.sharedDepth(r);return s==0?!1:(i=t.before(s),e&&e(n.tr.setSelection(N.create(n.doc,i))),!0)};function Nf(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||at(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Cc(n,e,t,r){let i=e.nodeBefore,s=e.nodeAfter,o,l,a=i.type.spec.isolating||s.type.spec.isolating;if(!a&&Nf(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(t){let h=e.pos+s.nodeSize,p=S.empty;for(let y=o.length-1;y>=0;y--)p=S.from(o[y].create(null,p));p=S.from(i.copy(p));let m=n.tr.step(new ke(e.pos-1,h,e.pos,h,new C(p,1,0),o.length,!0)),g=m.doc.resolve(h+2*o.length);g.nodeAfter&&g.nodeAfter.type==i.type&&at(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let u=s.type.spec.isolating||r>0&&a?null:P.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),f=d&&sn(d);if(f!=null&&f>=e.depth)return t&&t(n.tr.lift(d,f).scrollIntoView()),!0;if(c&&Kt(s,"start",!0)&&Kt(i,"end")){let h=i,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let m=s,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(t){let y=S.empty;for(let v=p.length-1;v>=0;v--)y=S.from(p[v].copy(y));let b=n.tr.step(new ke(e.pos-p.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new C(y,p.length,0),0,!0));t(b.scrollIntoView())}return!0}}return!1}function Ec(n){return function(e,t){let r=e.selection,i=n<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(t&&t(e.tr.setSelection(R.create(e.doc,n<0?i.start(s):i.end(s)))),!0):!1}}const Of=Ec(-1),Rf=Ec(1);function If(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=o&&eo(o,n,e);return l?(r&&r(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function ol(n,e=null){return function(t,r){let i=!1;for(let s=0;s{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)i=!0;else{let u=t.doc.resolve(c),d=u.index();i=u.parent.canReplaceWith(d,d+1,n)}})}if(!i)return!1;if(r){let s=t.tr;for(let o=0;o=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=o.resolve(e.start-2);s=new Lr(a,a,e.depth),e.endIndex=0;u--)s=S.from(t[u].type.create(t[u].attrs,s));n.step(new ke(e.start-(r?2:0),e.end,e.start,e.end,new C(s,0,0),t.length,!0));let o=0;for(let u=0;uo.childCount>0&&o.firstChild.type==n);return s?t?r.node(s.depth-1).type==n?Bf(e,t,n,s):$f(e,t,s):!0:!1}}function Bf(n,e,t,r){let i=n.tr,s=r.end,o=r.$to.end(r.depth);sm;p--)h-=i.child(p).nodeSize,r.delete(h-1,h+1);let s=r.doc.resolve(t.start),o=s.nodeAfter;if(r.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==i.childCount,c=s.node(-1),u=s.index(-1);if(!c.canReplace(u+(l?0:1),u+1,o.content.append(a?S.empty:S.from(i))))return!1;let d=s.pos,f=d+o.nodeSize;return r.step(new ke(d-(l?1:0),f+(a?1:0),d+1,f-1,new C((l?S.empty:S.from(i.copy(S.empty))).append(a?S.empty:S.from(i.copy(S.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function Ff(n){return function(e,t){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==n);if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let l=s.parent,a=l.child(o-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=S.from(c?n.create():null),d=new C(S.from(n.create(null,S.from(l.type.create(null,u)))),c?3:1,0),f=s.start,h=s.end;t(e.tr.step(new ke(f-(c?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}const ne=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Gt=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let xs=null;const He=function(n,e,t){let r=xs||(xs=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},Hf=function(){xs=null},Et=function(n,e,t,r){return t&&(ll(n,e,t,r,-1)||ll(n,e,t,r,1))},Vf=/^(img|br|input|textarea|hr)$/i;function ll(n,e,t,r,i){for(var s;;){if(n==t&&e==r)return!0;if(e==(i<0?0:Me(n))){let o=n.parentNode;if(!o||o.nodeType!=1||Zn(n)||Vf.test(n.nodeName)||n.contentEditable=="false")return!1;e=ne(n)+(i<0?0:1),n=o}else if(n.nodeType==1){let o=n.childNodes[e+(i<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((s=o.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=i;else return!1;else n=o,e=i<0?Me(n):0}else return!1}}function Me(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function jf(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=Me(n)}else if(n.parentNode&&!Zn(n))e=ne(n),n=n.parentNode;else return null}}function _f(n,e){for(;;){if(n.nodeType==3&&e2),ve=Yt||(Pe?/Mac/.test(Pe.platform):!1),Nc=Pe?/Win/.test(Pe.platform):!1,Ve=/Android \d/.test(ct),er=!!al&&"webkitFontSmoothing"in al.documentElement.style,Jf=er?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Kf(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 ze(n,e){return typeof n=="number"?n:n[e]}function Gf(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 cl(n,e,t){let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let o=t||n.dom;o;){if(o.nodeType!=1){o=Gt(o);continue}let l=o,a=l==s.body,c=a?Kf(s):Gf(l),u=0,d=0;if(e.topc.bottom-ze(r,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+ze(i,"top")-c.top:e.bottom-c.bottom+ze(i,"bottom")),e.leftc.right-ze(r,"right")&&(u=e.right-c.right+ze(i,"right")),u||d)if(a)s.defaultView.scrollBy(u,d);else{let h=l.scrollLeft,p=l.scrollTop;d&&(l.scrollTop+=d),u&&(l.scrollLeft+=u);let m=l.scrollLeft-h,g=l.scrollTop-p;e={left:e.left-m,top:e.top-g,right:e.right-m,bottom:e.bottom-g}}let f=a?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(f))break;o=f=="absolute"?o.offsetParent:Gt(o)}}function Yf(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,i;for(let s=(e.left+e.right)/2,o=t+1;o=t-20){r=l,i=a.top;break}}return{refDOM:r,refTop:i,stack:Oc(n.dom)}}function Oc(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Gt(r));return e}function Xf({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Rc(t,r==0?0:r-e)}function Rc(n,e){for(let t=0;t=l){o=Math.max(p.bottom,o),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(s=d+1)}}return!t&&a&&(t=a,i=c,r=0),t&&t.nodeType==3?Zf(t,i):!t||r&&t.nodeType==1?{node:n,offset:s}:Ic(t,i)}function Zf(n,e){let t=n.nodeValue.length,r=document.createRange(),i;for(let s=0;s=(o.left+o.right)/2?1:0)};break}}return r.detach(),i||{node:n,offset:0}}function so(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function ep(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left(o.left+o.right)/2?1:-1}return n.docView.posFromDOM(r,i,s)}function np(n,e,t,r){let i=-1;for(let s=e,o=!1;s!=n.dom;){let l=n.docView.nearestDesc(s,!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)&&(!o&&a.left>r.left||a.top>r.top?i=l.posBefore:(!o&&a.right-1?i:n.docView.posFromDOM(e,t,-1)}function Dc(n,e,t){let r=n.childNodes.length;if(r&&t.tope.top&&i++}let c;er&&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=np(n,r,i,e))}l==null&&(l=tp(n,o,e));let a=n.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function ul(n){return n.top=0&&i==r.nodeValue.length?(a--,u=1):t<0?a--:c++,on(Ye(He(r,a,c),u),u<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(t<0||i==Me(r))){let a=r.childNodes[i-1];if(a.nodeType==1)return _i(a.getBoundingClientRect(),!1)}if(s==null&&i=0)}if(s==null&&i&&(t<0||i==Me(r))){let a=r.childNodes[i-1],c=a.nodeType==3?He(a,Me(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return on(Ye(c,1),!1)}if(s==null&&i=0)}function on(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 _i(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 Lc(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 sp(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return Lc(n,e,()=>{let{node:s}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let o=Pc(n,i.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=He(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;cu.top+1&&(t=="up"?o.top-u.top>(u.bottom-o.top)*2:u.bottom-o.bottom>(o.bottom-u.top)*2))return!1}}return!0})}const op=/[\u0590-\u08ac]/;function lp(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,o=i==r.parent.content.size,l=n.domSelection();return l?!op.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:o:Lc(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=n.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let h=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:p,focusOffset:m}=n.domSelectionRange(),g=p&&!h.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==m;try{l.collapse(u,d),a&&(a!=u||c!=d)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),g}):r.pos==r.start()||r.pos==r.end()}let dl=null,hl=null,fl=!1;function ap(n,e,t){return dl==e&&hl==t?fl:(dl=e,hl=t,fl=t=="up"||t=="down"?sp(n,e,t):lp(n,e,t))}const Ee=0,pl=1,ft=2,Le=3;class tr{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=Ee,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;tne(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 s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.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 s=this.getDesc(i),o;if(s&&(!t||s.node))if(r&&(o=s.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return s}}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 s=this.getDesc(i);if(s)return s.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;te||o instanceof Bc){i=e-s;break}s=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof zc&&s.side>=0;r--);if(t<=0){let s,o=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,o=!1);return s&&t&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?ne(s.dom)+1:0}}else{let s,o=!0;for(;s=r=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=o;for(let d=l;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){i=ne(f.dom)+1;break}e-=f.size}i==-1&&(i=0)}if(i>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;up&&ot){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}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+s.border,a=o-s.border;if(e>=l&&t<=a){this.dirty=e==r||t==o?ft:pl,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=Le:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?ft:Le}r=o}this.dirty=ft}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?ft:pl;t.dirty{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==Ee&&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}}class cp extends tr{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}}class Tt extends tr{constructor(e,t,r,i,s){super(e,[],r,i),this.mark=t,this.spec=s}static create(e,t,r,i){let s=i.nodeViews[t.type.name],o=s&&s(t,i,r);return(!o||!o.dom)&&(o=Ot.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new Tt(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Le||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Le&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Ee){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(s=Es(s,0,e,r));for(let l=0;l{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},r,i),u=c&&c.dom,d=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:d}=Ot.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!d&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let f=u;return u=Hc(u,r,t),c?a=new up(e,t,r,i,u,d||null,f,c,s,o+1):t.isText?new Ci(e,t,r,i,u,f,s):new it(e,t,r,i,u,d||null,f,s,o+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=()=>S.empty)}return e}matchesNode(e,t,r){return this.dirty==Ee&&e.eq(this.node)&&$r(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,s=e.composing?this.localCompositionInfo(e,t):null,o=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new hp(this,o&&o.node,e);mp(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e,u):c.type.side>=0&&!d&&a.syncToMarks(u==this.node.childCount?$.none:this.node.child(u).marks,r,e,u),a.placeWidget(c,e,i)},(c,u,d,f)=>{a.syncToMarks(c.marks,r,e,f);let h;a.findNodeMatch(c,u,d,f)||l&&e.state.selection.from>i&&e.state.selection.to-1&&a.updateNodeAt(c,u,d,h,e)||a.updateNextNode(c,u,d,e,f,i)||a.addNode(c,u,d,e,i),i+=c.nodeSize}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==ft)&&(o&&this.protectLocalComposition(e,o),$c(this.contentDOM,this.children,e),Yt&&gp(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof R)||rt+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let o=s.nodeValue,l=yp(this.node.content,o,r-t,i-t);return l<0?null:{node:s,pos:l,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:i}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new cp(this,s,t,i);e.input.compositionNodes.push(o),this.children=Es(this.children,r,r+i.length,e,o)}update(e,t,r,i){return this.dirty==Le||!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=Ee}updateOuterDeco(e){if($r(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Fc(this.dom,this.nodeDOM,Cs(this.outerDeco,this.node,t),Cs(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 ml(n,e,t,r,i){Hc(r,e,n);let s=new it(void 0,n,e,t,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class Ci extends it{constructor(e,t,r,i,s,o,l){super(e,t,r,i,s,null,o,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==Le||this.dirty!=Ee&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Ee||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=Ee,!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),s=document.createTextNode(i.text);return new Ci(this.parent,i,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Le)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Bc extends tr{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ee&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class up extends it{constructor(e,t,r,i,s,o,l,a,c,u){super(e,t,r,i,s,o,l,c,u),this.spec=a}update(e,t,r,i){if(this.dirty==Le)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,r);return s&&this.updateInner(e,t,r,i),s}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 $c(n,e,t){let r=n.firstChild,i=!1;for(let s=0;s>1,l=Math.min(o,e.length);for(;s-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let u=Tt.create(this.top,e[o],t,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,r,i){let s=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,r))s=this.top.children.indexOf(o,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 Tt)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,s.set(l,i),o.push(l)}}return{index:i,matched:s,matches:o.reverse()}}function pp(n,e){return n.type.side-e.type.side}function mp(n,e,t,r){let i=e.locals(n),s=0;if(i.length==0){for(let c=0;cs;)l.push(i[o++]);let p=s+f.nodeSize;if(f.isText){let g=p;o!g.inline):l.slice();r(f,m,e.forChild(s,f),h),s=p}}function gp(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 yp(n,e,t,r){for(let i=0,s=0;i=t){if(s>=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 Es(n,e,t,r,i){let s=[];for(let o=0,l=0;o=t||u<=e?s.push(a):(ct&&s.push(a.slice(t-c,a.size,r)))}return s}function oo(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),s=i&&i.size==0,o=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,c;if(Mi(t)){for(a=o;i&&!i.node;)i=i.parent;let d=i.node;if(i&&d.isAtom&&N.isSelectable(d)&&i.parent&&!(d.isInline&&Wf(t.focusNode,t.focusOffset,i.dom))){let f=i.posBefore;c=new N(o==f?l:r.resolve(f))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let d=o,f=o;for(let h=0;h{(t.anchorNode!=r||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Vc(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function kp(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,r=t.nodeName=="IMG";r?e.collapse(t.parentNode,ne(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&be&&rt<=11&&(t.disabled=!0,t.disabled=!1)}function jc(n,e){if(e instanceof N){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Sl(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Sl(n)}function Sl(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function lo(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||R.between(e,t,r)}function xl(n){return n.editable&&!n.hasFocus()?!1:_c(n)}function _c(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 Sp(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Et(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Ts(n,e){let{$anchor:t,$head:r}=n.selection,i=e>0?t.max(r):t.min(r),s=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return s&&P.findFrom(s,e)}function Qe(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function wl(n,e,t){let r=n.state.selection;if(r instanceof R)if(t.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=n.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return Qe(n,new R(r.$anchor,o))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=Ts(n.state,e);return i&&i instanceof N?Qe(n,i):!1}else if(!(ve&&t.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let l=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=n.docView.descAt(l))&&!o.contentDOM?N.isSelectable(s)?Qe(n,new N(e<0?n.state.doc.resolve(i.pos-s.nodeSize):i)):er?Qe(n,new R(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof N&&r.node.isInline)return Qe(n,new R(e>0?r.$to:r.$from));{let i=Ts(n.state,e);return i?Qe(n,i):!1}}}function Fr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function On(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Lt(n,e){return e<0?xp(n):wp(n)}function xp(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,s,o=!1;for(Ce&&t.nodeType==1&&r0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(On(l,-1))i=t,s=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(Wc(t))break;{let l=t.previousSibling;for(;l&&On(l,-1);)i=t.parentNode,s=ne(l),l=l.previousSibling;if(l)t=l,r=Fr(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}o?As(n,t,r):i&&As(n,i,s)}function wp(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=Fr(t),s,o;for(;;)if(r{n.state==i&&Ue(n)},50)}function vl(n,e){let t=n.state.doc.resolve(e);if(!(Q||Nc)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>i.top&&o1)return s.lefti.top&&o1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Ml(n,e,t){let r=n.state.selection;if(r instanceof R&&!r.empty||t.indexOf("s")>-1||ve&&t.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=Ts(n.state,e);if(o&&o instanceof N)return Qe(n,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=r instanceof We?P.near(o,e):P.findFrom(o,e);return l?Qe(n,l):!1}return!1}function Cl(n,e){if(!(n.state.selection instanceof R))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 s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let o=n.state.tr;return e<0?o.delete(t.pos-s.nodeSize,t.pos):o.delete(t.pos,t.pos+s.nodeSize),n.dispatch(o),!0}return!1}function El(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Cp(n){if(!oe||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;El(n,r,"true"),setTimeout(()=>El(n,r,"false"),20)}return!1}function Ep(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Tp(n,e){let t=e.keyCode,r=Ep(e);if(t==8||ve&&t==72&&r=="c")return Cl(n,-1)||Lt(n,-1);if(t==46&&!e.shiftKey||ve&&t==68&&r=="c")return Cl(n,1)||Lt(n,1);if(t==13||t==27)return!0;if(t==37||ve&&t==66&&r=="c"){let i=t==37?vl(n,n.state.selection.from)=="ltr"?-1:1:-1;return wl(n,i,r)||Lt(n,i)}else if(t==39||ve&&t==70&&r=="c"){let i=t==39?vl(n,n.state.selection.from)=="ltr"?1:-1:1;return wl(n,i,r)||Lt(n,i)}else{if(t==38||ve&&t==80&&r=="c")return Ml(n,-1,r)||Lt(n,-1);if(t==40||ve&&t==78&&r=="c")return Cp(n)||Ml(n,1,r)||Lt(n,1);if(r==(ve?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function ao(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let o=n.someProp("clipboardSerializer")||Ot.fromSchema(n.state.schema),l=Yc(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=Gc[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=l.createElement(u[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),d++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${s}${d?` -${d}`:""} ${JSON.stringify(t)}`);let f=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
-`);return{dom:a,text:f,slice:e}}function Jc(n,e,t,r,i){let s=i.parent.type.spec.code,o,l;if(!t&&!e)return null;let a=!!e&&(r||s||!t);if(a){if(n.someProp("transformPastedText",f=>{e=f(e,s||r,n)}),s)return l=new E(S.from(n.state.schema.text(e.replace(/\r\n?/g,`
-`))),0,0),n.someProp("transformPasted",f=>{l=f(l,n,!0)}),l;let d=n.someProp("clipboardTextParser",f=>f(e,i,r,n));if(d)l=d;else{let f=i.marks(),{schema:h}=n.state,p=Nt.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(h.text(m,f)))})}}else n.someProp("transformPastedHTML",d=>{t=d(t,n)}),o=Dp(t),er&&Pp(o);let c=o&&o.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let f=o.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;o=f}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Tn.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||u),context:i,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!Op.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Lp(Nl(l,+u[1],+u[2]),u[4]);else if(l=E.maxOpen(Rp(l.content,i),!0),l.openStart||l.openEnd){let d=0,f=0;for(let h=l.content.firstChild;d{l=d(l,n,a)}),l}const Op=/^(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 Rp(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)),s,o=[];if(n.forEach(l=>{if(!o)return;let a=i.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&s.length&&Gc(a,s,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=Yc(o[o.length-1],s.length));let u=Kc(l,a);o.push(u),i=i.matchType(u.type),s=a}}),o)return S.from(o)}return n}function Kc(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,S.from(n));return n}function Gc(n,e,t,r,i){if(i1&&(s=0),i=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(S.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(l))}function Nl(n,e,t){return et})),Ui.createHTML(n)):n}function Dp(n){let e=/^(\s*]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Qc().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&Xc[r[1].toLowerCase()])&&(n=i.map(s=>"<"+s+">").join("")+n+i.map(s=>""+s+">").reverse().join("")),t.innerHTML=Ip(n),i)for(let s=0;s=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;i=S.from(a.create(r[l+1],i)),s++,o++}return new E(i,s,o)}const pe={},me={},zp={touchstart:!0,touchmove:!0};class Bp{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 $p(n){for(let e in pe){let t=pe[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{Hp(n,r)&&!ho(n,r)&&(n.editable||!(r.type in me))&&t(n,r)},zp[e]?{passive:!0}:void 0)}se&&n.dom.addEventListener("input",()=>null),Is(n)}function Ve(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Fp(n){n.input.mouseDown&&n.input.mouseDown.done(),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 Is(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>ho(n,r))})}function ho(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function Hp(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 Vp(n,e){!ho(n,e)&&pe[e.type]&&(n.editable||!(e.type in me))&&pe[e.type](n,e)}me.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!nu(n)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(He&&Q&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Kt&&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,dt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||Np(n,t)?t.preventDefault():Ve(n,"key")};me.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};me.keypress=(n,e)=>{let t=e;if(nu(n)||!t.charCode||t.ctrlKey&&!t.altKey||we&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof I)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode),s=()=>n.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",o=>o(n,r.$from.pos,r.$to.pos,i,s))&&n.dispatch(s()),t.preventDefault()}};function nr(n){return{left:n.clientX,top:n.clientY}}function jp(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function fo(n,e,t,r,i){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let o=s.depth+1;o>0;o--)if(n.someProp(e,l=>o>s.depth?l(n,t,s.nodeAfter,s.before(o),i,!0):l(n,t,s.node(o),s.before(o),i,!1)))return!0;return!1}function rr(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function _p(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&N.isSelectable(r)?(rr(n,new N(t)),!0):!1}function Wp(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof N&&(r=t.node);let s=n.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if(N.isSelectable(l)){r&&t.$from.depth>0&&o>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?i=s.before(t.$from.depth):i=s.before(o);break}}return i!=null?(rr(n,N.create(n.state.doc,i)),!0):!1}function Up(n,e,t,r,i){return fo(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(i?Wp(n,t):_p(n,t))}function qp(n,e,t,r){return fo(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function Jp(n,e,t,r){return fo(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||Kp(n,t,r)}function Kp(n,e,t){if(t.button!=0)return!1;let r=Zc(n,e,!0),i=n.state.doc;return r?(rr(n,r),r instanceof I&&i.eq(n.state.doc)&&(n.input.mouseDown=new Yp(n,r)),!0):!1}function Zc(n,e,t){let r=n.state.doc;if(e==-1)return r.inlineContent?I.create(r,0,r.content.size):null;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),l=i.before(s);if(o.inlineContent)return I.create(r,l+1,l+1+o.content.size);if(t&&N.isSelectable(o))return N.create(r,l)}return null}function po(n){return Hr(n)}const eu=we?"metaKey":"ctrlKey";pe.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=po(n),i=Date.now(),s="singleClick";i-n.input.lastClick.time<500&&jp(t,n.input.lastClick)&&!t[eu]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:s,button:t.button},n.input.mouseDown&&n.input.mouseDown.done();let o=n.posAtCoords(nr(t));o&&(s=="singleClick"?n.input.mouseDown=new Gp(n,o,t,!!r):(s=="doubleClick"?qp:Jp)(n,o.pos,o.inside,t)?t.preventDefault():Ve(n,"pointer"))};class tu{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}}class Gp extends tu{constructor(e,t,r,i){super(e),this.pos=t,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!r[eu],this.allowDefault=r.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let u=e.state.doc.resolve(t.pos);s=u.parent,o=u.depth?u.before():0}const 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&&(s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof N&&c.from<=o&&c.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Me&&!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()),Ve(e,"pointer")}done(){super.done(),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(()=>{this.view.isDestroyed||We(this.view)})}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(nr(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ve(this.view,"pointer"):Up(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||se&&this.mightDrag&&!this.mightDrag.node.isAtom||Q&&!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)?(rr(this.view,P.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Ve(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ve(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}}class Yp extends tu{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),Ve(this.view,"pointer");let t=this.view.posAtCoords(nr(e)),r=t&&Zc(this.view,t.inside,!1);if(!r)return;let{doc:i}=this.view.state,s=this.startSelection,[o,l]=r.from{n.input.lastTouch=Date.now(),po(n),Ve(n,"pointer")};pe.touchmove=n=>{n.input.lastTouch=Date.now(),Ve(n,"pointer")};pe.contextmenu=n=>po(n);function nu(n,e){return n.composing?!0:se&&Math.abs(Date.now()-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const Xp=He?5e3:-1;me.compositionstart=me.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof I&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Q&&Rc&&Qp(n)))n.markCursor=n.state.storedMarks||t.marks(),Hr(n,!0),n.markCursor=null;else if(Hr(n,!e.selection.empty),Me&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&i.nodeType==1&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(o.nodeType==3){let l=n.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,s=-1}}n.input.composing=!0}ru(n,Xp)};function Qp(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"}me.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now(),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++,ru(n,20))};function ru(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Hr(n),e))}function iu(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Zp(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Wf(e.focusNode,e.focusOffset),r=Uf(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let i=r.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(t==s||r==s)return s;if(!i||!i.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return r}}return t||r}function Hr(n,e=!1){if(!(He&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),iu(n),e||n.docView&&n.docView.dirty){let t=ao(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 em(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)}const _n=be&&nt<15||Kt&&Gf<604;pe.copy=me.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let s=_n?null:t.clipboardData,o=r.content(),{dom:l,text:a}=uo(n,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):em(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function tm(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function nm(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?Wn(n,r.value,null,i,e):Wn(n,r.textContent,r.innerHTML,i,e)},50)}function Wn(n,e,t,r,i){let s=Jc(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,i,s||E.empty)))return!0;if(!s)return!1;let o=tm(s),l=o?n.state.tr.replaceSelectionWith(o,r):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function su(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," "):""}me.paste=(n,e)=>{let t=e;if(n.composing&&!He)return;let r=_n?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Wn(n,su(r),r.getData("text/html"),i,t)?t.preventDefault():nm(n,t)};class ou{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const rm=we?"altKey":"ctrlKey";function lu(n,e){let t;return n.someProp("dragCopies",r=>{t=t||r(e)}),t!=null?!t:!e[rm]}pe.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,s=i.empty?null:n.posAtCoords(nr(t)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof N?i.to-1:i.to))){if(r&&r.mightDrag)o=N.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let d=n.docView.nearestDesc(t.target,!0);d&&d.node.type.spec.draggable&&d!=n.docView&&(o=N.create(n.state.doc,d.posBefore))}}let l=(o||n.state.selection).content(),{dom:a,text:c,slice:u}=uo(n,l);(!t.dataTransfer.files.length||!Q||Oc>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(_n?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",_n||t.dataTransfer.setData("text/plain",c),n.dragging=new ou(u,lu(n,t),o)};pe.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};me.dragover=me.dragenter=(n,e)=>e.preventDefault();me.drop=(n,e)=>{try{im(n,e,n.dragging)}finally{n.dragging=null}};function im(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(nr(e));if(!r)return;let i=n.state.doc.resolve(r.pos),s=t&&t.slice;s?n.someProp("transformPasted",h=>{s=h(s,n,!1)}):s=Jc(n,su(e.dataTransfer),_n?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(t&&lu(n,e));if(n.someProp("handleDrop",h=>h(n,e,s||E.empty,o))){e.preventDefault();return}if(!s)return;e.preventDefault();let l=s?rc(n.state.doc,i.pos,s):i.pos;l==null&&(l=i.pos);let a=n.state.tr;if(o){let{node:h}=t;h?h.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,d=a.doc;if(u?a.replaceRangeWith(c,c,s.content.firstChild):a.replaceRange(c,c,s),a.doc.eq(d))return;let f=a.doc.resolve(c);if(u&&N.isSelectable(s.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(s.content.firstChild))a.setSelection(new N(f));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,m,g,y)=>h=y),a.setSelection(co(n,f,a.doc.resolve(h)))}n.focus(),n.dispatch(a.setMeta("uiEvent","drop"))}pe.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())&&We(n)},20))};pe.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)};pe.beforeinput=(n,e)=>{if(Q&&He&&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",s=>s(n,dt(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 me)pe[n]=me[n];function Un(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class Vr{constructor(e,t){this.toDOM=e,this.spec=t||kt,this.side=this.spec.side||0}map(e,t,r,i){let{pos:s,deleted:o}=e.mapResult(t.from+i,this.side<0?-1:1);return o?null:new he(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Vr&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Un(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class it{constructor(e,t){this.attrs=e,this.spec=t||kt}map(e,t,r,i){let s=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=o?null:new he(s,o,this)}valid(e,t){return t.from=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let o=0;oe){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,r,i+l,s)}}map(e,t,r){return this==ie||e.maps.length==0?this:this.mapInner(e,t,0,0,r||kt)}mapInner(e,t,r,i,s){let o;for(let l=0;l{let c=a+r,u;if(u=cu(t,l,c)){for(i||(i=this.children.slice());sl&&d.to=e){this.children[l]==e&&(r=this.children[l+2]);break}let s=e+1,o=s+t.content.size;for(let l=0;ls&&a.type instanceof it){let c=Math.max(s,a.from)-s,u=Math.min(o,a.to)-s;ci.map(e,t,kt));return et.from(r)}forChild(e,t){if(t.isLeaf)return F.empty;let r=[];for(let i=0;i