randmarcomps 1.487.0 → 1.488.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/randmarcomps.js +137 -110
- package/dist/randmarcomps.umd.cjs +36 -36
- package/package.json +1 -1
|
@@ -72,167 +72,167 @@
|
|
|
72
72
|
*
|
|
73
73
|
* This source code is licensed under the ISC license.
|
|
74
74
|
* See the LICENSE file in the root directory of this source tree.
|
|
75
|
-
*/const __iconNode$1g=[["path",{d:"M12
|
|
75
|
+
*/const __iconNode$1g=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],BookOpen=createLucideIcon("BookOpen",__iconNode$1g);/**
|
|
76
76
|
* @license lucide-react v0.479.0 - ISC
|
|
77
77
|
*
|
|
78
78
|
* This source code is licensed under the ISC license.
|
|
79
79
|
* See the LICENSE file in the root directory of this source tree.
|
|
80
|
-
*/const __iconNode$1f=[["path",{d:"
|
|
80
|
+
*/const __iconNode$1f=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],Bot=createLucideIcon("Bot",__iconNode$1f);/**
|
|
81
81
|
* @license lucide-react v0.479.0 - ISC
|
|
82
82
|
*
|
|
83
83
|
* This source code is licensed under the ISC license.
|
|
84
84
|
* See the LICENSE file in the root directory of this source tree.
|
|
85
|
-
*/const __iconNode$1e=[["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"
|
|
85
|
+
*/const __iconNode$1e=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]],CalendarDays=createLucideIcon("CalendarDays",__iconNode$1e);/**
|
|
86
86
|
* @license lucide-react v0.479.0 - ISC
|
|
87
87
|
*
|
|
88
88
|
* This source code is licensed under the ISC license.
|
|
89
89
|
* See the LICENSE file in the root directory of this source tree.
|
|
90
|
-
*/const __iconNode$1d=[["path",{d:"
|
|
90
|
+
*/const __iconNode$1d=[["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M17 14h-6",key:"bkmgh3"}],["path",{d:"M13 18H7",key:"bb0bb7"}],["path",{d:"M7 14h.01",key:"1qa3f1"}],["path",{d:"M17 18h.01",key:"1bdyru"}]],CalendarRange=createLucideIcon("CalendarRange",__iconNode$1d);/**
|
|
91
91
|
* @license lucide-react v0.479.0 - ISC
|
|
92
92
|
*
|
|
93
93
|
* This source code is licensed under the ISC license.
|
|
94
94
|
* See the LICENSE file in the root directory of this source tree.
|
|
95
|
-
*/const __iconNode$1c=[["path",{d:"
|
|
95
|
+
*/const __iconNode$1c=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],Calendar$1=createLucideIcon("Calendar",__iconNode$1c);/**
|
|
96
96
|
* @license lucide-react v0.479.0 - ISC
|
|
97
97
|
*
|
|
98
98
|
* This source code is licensed under the ISC license.
|
|
99
99
|
* See the LICENSE file in the root directory of this source tree.
|
|
100
|
-
*/const __iconNode$1b=[["
|
|
100
|
+
*/const __iconNode$1b=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],ChartLine=createLucideIcon("ChartLine",__iconNode$1b);/**
|
|
101
101
|
* @license lucide-react v0.479.0 - ISC
|
|
102
102
|
*
|
|
103
103
|
* This source code is licensed under the ISC license.
|
|
104
104
|
* See the LICENSE file in the root directory of this source tree.
|
|
105
|
-
*/const __iconNode$1a=[["
|
|
105
|
+
*/const __iconNode$1a=[["line",{x1:"12",x2:"12",y1:"20",y2:"10",key:"1vz5eb"}],["line",{x1:"18",x2:"18",y1:"20",y2:"4",key:"cun8e5"}],["line",{x1:"6",x2:"6",y1:"20",y2:"16",key:"hq0ia6"}]],ChartNoAxesColumnIncreasing=createLucideIcon("ChartNoAxesColumnIncreasing",__iconNode$1a);/**
|
|
106
106
|
* @license lucide-react v0.479.0 - ISC
|
|
107
107
|
*
|
|
108
108
|
* This source code is licensed under the ISC license.
|
|
109
109
|
* See the LICENSE file in the root directory of this source tree.
|
|
110
|
-
*/const __iconNode$19=[["path",{d:"
|
|
110
|
+
*/const __iconNode$19=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Check=createLucideIcon("Check",__iconNode$19);/**
|
|
111
111
|
* @license lucide-react v0.479.0 - ISC
|
|
112
112
|
*
|
|
113
113
|
* This source code is licensed under the ISC license.
|
|
114
114
|
* See the LICENSE file in the root directory of this source tree.
|
|
115
|
-
*/const __iconNode$18=[["path",{d:"
|
|
115
|
+
*/const __iconNode$18=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],ChevronDown=createLucideIcon("ChevronDown",__iconNode$18);/**
|
|
116
116
|
* @license lucide-react v0.479.0 - ISC
|
|
117
117
|
*
|
|
118
118
|
* This source code is licensed under the ISC license.
|
|
119
119
|
* See the LICENSE file in the root directory of this source tree.
|
|
120
|
-
*/const __iconNode$17=[["path",{d:"
|
|
120
|
+
*/const __iconNode$17=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],ChevronLeft=createLucideIcon("ChevronLeft",__iconNode$17);/**
|
|
121
121
|
* @license lucide-react v0.479.0 - ISC
|
|
122
122
|
*
|
|
123
123
|
* This source code is licensed under the ISC license.
|
|
124
124
|
* See the LICENSE file in the root directory of this source tree.
|
|
125
|
-
*/const __iconNode$16=[["path",{d:"
|
|
125
|
+
*/const __iconNode$16=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],ChevronRight=createLucideIcon("ChevronRight",__iconNode$16);/**
|
|
126
126
|
* @license lucide-react v0.479.0 - ISC
|
|
127
127
|
*
|
|
128
128
|
* This source code is licensed under the ISC license.
|
|
129
129
|
* See the LICENSE file in the root directory of this source tree.
|
|
130
|
-
*/const __iconNode$15=[["path",{d:"
|
|
130
|
+
*/const __iconNode$15=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],ChevronUp=createLucideIcon("ChevronUp",__iconNode$15);/**
|
|
131
131
|
* @license lucide-react v0.479.0 - ISC
|
|
132
132
|
*
|
|
133
133
|
* This source code is licensed under the ISC license.
|
|
134
134
|
* See the LICENSE file in the root directory of this source tree.
|
|
135
|
-
*/const __iconNode$14=[["path",{d:"
|
|
135
|
+
*/const __iconNode$14=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],ChevronsLeft=createLucideIcon("ChevronsLeft",__iconNode$14);/**
|
|
136
136
|
* @license lucide-react v0.479.0 - ISC
|
|
137
137
|
*
|
|
138
138
|
* This source code is licensed under the ISC license.
|
|
139
139
|
* See the LICENSE file in the root directory of this source tree.
|
|
140
|
-
*/const __iconNode$13=[["path",{d:"
|
|
140
|
+
*/const __iconNode$13=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],ChevronsRight=createLucideIcon("ChevronsRight",__iconNode$13);/**
|
|
141
141
|
* @license lucide-react v0.479.0 - ISC
|
|
142
142
|
*
|
|
143
143
|
* This source code is licensed under the ISC license.
|
|
144
144
|
* See the LICENSE file in the root directory of this source tree.
|
|
145
|
-
*/const __iconNode$12=[["
|
|
145
|
+
*/const __iconNode$12=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],ChevronsUpDown=createLucideIcon("ChevronsUpDown",__iconNode$12);/**
|
|
146
146
|
* @license lucide-react v0.479.0 - ISC
|
|
147
147
|
*
|
|
148
148
|
* This source code is licensed under the ISC license.
|
|
149
149
|
* See the LICENSE file in the root directory of this source tree.
|
|
150
|
-
*/const __iconNode$11=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["
|
|
150
|
+
*/const __iconNode$11=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],CircleAlert=createLucideIcon("CircleAlert",__iconNode$11);/**
|
|
151
151
|
* @license lucide-react v0.479.0 - ISC
|
|
152
152
|
*
|
|
153
153
|
* This source code is licensed under the ISC license.
|
|
154
154
|
* See the LICENSE file in the root directory of this source tree.
|
|
155
|
-
*/const __iconNode$10=[["
|
|
155
|
+
*/const __iconNode$10=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],CircleCheck=createLucideIcon("CircleCheck",__iconNode$10);/**
|
|
156
156
|
* @license lucide-react v0.479.0 - ISC
|
|
157
157
|
*
|
|
158
158
|
* This source code is licensed under the ISC license.
|
|
159
159
|
* See the LICENSE file in the root directory of this source tree.
|
|
160
|
-
*/const __iconNode$$=[["
|
|
160
|
+
*/const __iconNode$$=[["path",{d:"M10.1 2.182a10 10 0 0 1 3.8 0",key:"5ilxe3"}],["path",{d:"M13.9 21.818a10 10 0 0 1-3.8 0",key:"11zvb9"}],["path",{d:"M17.609 3.721a10 10 0 0 1 2.69 2.7",key:"1iw5b2"}],["path",{d:"M2.182 13.9a10 10 0 0 1 0-3.8",key:"c0bmvh"}],["path",{d:"M20.279 17.609a10 10 0 0 1-2.7 2.69",key:"1ruxm7"}],["path",{d:"M21.818 10.1a10 10 0 0 1 0 3.8",key:"qkgqxc"}],["path",{d:"M3.721 6.391a10 10 0 0 1 2.7-2.69",key:"1mcia2"}],["path",{d:"M6.391 20.279a10 10 0 0 1-2.69-2.7",key:"1fvljs"}]],CircleDashed=createLucideIcon("CircleDashed",__iconNode$$);/**
|
|
161
161
|
* @license lucide-react v0.479.0 - ISC
|
|
162
162
|
*
|
|
163
163
|
* This source code is licensed under the ISC license.
|
|
164
164
|
* See the LICENSE file in the root directory of this source tree.
|
|
165
|
-
*/const __iconNode$_=[["
|
|
165
|
+
*/const __iconNode$_=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Circle=createLucideIcon("Circle",__iconNode$_);/**
|
|
166
166
|
* @license lucide-react v0.479.0 - ISC
|
|
167
167
|
*
|
|
168
168
|
* This source code is licensed under the ISC license.
|
|
169
169
|
* See the LICENSE file in the root directory of this source tree.
|
|
170
|
-
*/const __iconNode$Z=[["path",{d:"
|
|
170
|
+
*/const __iconNode$Z=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]],ClipboardList=createLucideIcon("ClipboardList",__iconNode$Z);/**
|
|
171
171
|
* @license lucide-react v0.479.0 - ISC
|
|
172
172
|
*
|
|
173
173
|
* This source code is licensed under the ISC license.
|
|
174
174
|
* See the LICENSE file in the root directory of this source tree.
|
|
175
|
-
*/const __iconNode$Y=[["
|
|
175
|
+
*/const __iconNode$Y=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],CodeXml=createLucideIcon("CodeXml",__iconNode$Y);/**
|
|
176
176
|
* @license lucide-react v0.479.0 - ISC
|
|
177
177
|
*
|
|
178
178
|
* This source code is licensed under the ISC license.
|
|
179
179
|
* See the LICENSE file in the root directory of this source tree.
|
|
180
|
-
*/const __iconNode$X=[["
|
|
180
|
+
*/const __iconNode$X=[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]],Code$1=createLucideIcon("Code",__iconNode$X);/**
|
|
181
181
|
* @license lucide-react v0.479.0 - ISC
|
|
182
182
|
*
|
|
183
183
|
* This source code is licensed under the ISC license.
|
|
184
184
|
* See the LICENSE file in the root directory of this source tree.
|
|
185
|
-
*/const __iconNode$W=[["rect",{width:"
|
|
185
|
+
*/const __iconNode$W=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Copy=createLucideIcon("Copy",__iconNode$W);/**
|
|
186
186
|
* @license lucide-react v0.479.0 - ISC
|
|
187
187
|
*
|
|
188
188
|
* This source code is licensed under the ISC license.
|
|
189
189
|
* See the LICENSE file in the root directory of this source tree.
|
|
190
|
-
*/const __iconNode$V=[["
|
|
190
|
+
*/const __iconNode$V=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],CreditCard=createLucideIcon("CreditCard",__iconNode$V);/**
|
|
191
191
|
* @license lucide-react v0.479.0 - ISC
|
|
192
192
|
*
|
|
193
193
|
* This source code is licensed under the ISC license.
|
|
194
194
|
* See the LICENSE file in the root directory of this source tree.
|
|
195
|
-
*/const __iconNode$U=[["
|
|
195
|
+
*/const __iconNode$U=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],DollarSign=createLucideIcon("DollarSign",__iconNode$U);/**
|
|
196
196
|
* @license lucide-react v0.479.0 - ISC
|
|
197
197
|
*
|
|
198
198
|
* This source code is licensed under the ISC license.
|
|
199
199
|
* See the LICENSE file in the root directory of this source tree.
|
|
200
|
-
*/const __iconNode$T=[["path",{d:"
|
|
200
|
+
*/const __iconNode$T=[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]],Download=createLucideIcon("Download",__iconNode$T);/**
|
|
201
201
|
* @license lucide-react v0.479.0 - ISC
|
|
202
202
|
*
|
|
203
203
|
* This source code is licensed under the ISC license.
|
|
204
204
|
* See the LICENSE file in the root directory of this source tree.
|
|
205
|
-
*/const __iconNode$S=[["path",{d:"
|
|
205
|
+
*/const __iconNode$S=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],ExternalLink=createLucideIcon("ExternalLink",__iconNode$S);/**
|
|
206
206
|
* @license lucide-react v0.479.0 - ISC
|
|
207
207
|
*
|
|
208
208
|
* This source code is licensed under the ISC license.
|
|
209
209
|
* See the LICENSE file in the root directory of this source tree.
|
|
210
|
-
*/const __iconNode$R=[["path",{d:"
|
|
210
|
+
*/const __iconNode$R=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Eye=createLucideIcon("Eye",__iconNode$R);/**
|
|
211
211
|
* @license lucide-react v0.479.0 - ISC
|
|
212
212
|
*
|
|
213
213
|
* This source code is licensed under the ISC license.
|
|
214
214
|
* See the LICENSE file in the root directory of this source tree.
|
|
215
|
-
*/const __iconNode$Q=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]],
|
|
215
|
+
*/const __iconNode$Q=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],FileText=createLucideIcon("FileText",__iconNode$Q);/**
|
|
216
216
|
* @license lucide-react v0.479.0 - ISC
|
|
217
217
|
*
|
|
218
218
|
* This source code is licensed under the ISC license.
|
|
219
219
|
* See the LICENSE file in the root directory of this source tree.
|
|
220
|
-
*/const __iconNode$P=[["
|
|
220
|
+
*/const __iconNode$P=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]],File$1=createLucideIcon("File",__iconNode$P);/**
|
|
221
221
|
* @license lucide-react v0.479.0 - ISC
|
|
222
222
|
*
|
|
223
223
|
* This source code is licensed under the ISC license.
|
|
224
224
|
* See the LICENSE file in the root directory of this source tree.
|
|
225
|
-
*/const __iconNode$O=[["
|
|
225
|
+
*/const __iconNode$O=[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]],Filter=createLucideIcon("Filter",__iconNode$O);/**
|
|
226
226
|
* @license lucide-react v0.479.0 - ISC
|
|
227
227
|
*
|
|
228
228
|
* This source code is licensed under the ISC license.
|
|
229
229
|
* See the LICENSE file in the root directory of this source tree.
|
|
230
|
-
*/const __iconNode$N=[["
|
|
230
|
+
*/const __iconNode$N=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],Globe=createLucideIcon("Globe",__iconNode$N);/**
|
|
231
231
|
* @license lucide-react v0.479.0 - ISC
|
|
232
232
|
*
|
|
233
233
|
* This source code is licensed under the ISC license.
|
|
234
234
|
* See the LICENSE file in the root directory of this source tree.
|
|
235
|
-
*/const __iconNode$M=[["path",{d:"
|
|
235
|
+
*/const __iconNode$M=[["path",{d:"m11 17 2 2a1 1 0 1 0 3-3",key:"efffak"}],["path",{d:"m14 14 2.5 2.5a1 1 0 1 0 3-3l-3.88-3.88a3 3 0 0 0-4.24 0l-.88.88a1 1 0 1 1-3-3l2.81-2.81a5.79 5.79 0 0 1 7.06-.87l.47.28a2 2 0 0 0 1.42.25L21 4",key:"9pr0kb"}],["path",{d:"m21 3 1 11h-2",key:"1tisrp"}],["path",{d:"M3 3 2 14l6.5 6.5a1 1 0 1 0 3-3",key:"1uvwmv"}],["path",{d:"M3 4h8",key:"1ep09j"}]],Handshake=createLucideIcon("Handshake",__iconNode$M);/**
|
|
236
236
|
* @license lucide-react v0.479.0 - ISC
|
|
237
237
|
*
|
|
238
238
|
* This source code is licensed under the ISC license.
|
|
@@ -1194,7 +1194,7 @@ Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An err
|
|
|
1194
1194
|
|
|
1195
1195
|
Defaulting to \`null\`.`}var Root$2=Progress$1,Indicator=ProgressIndicator;const Progress=React__namespace.forwardRef(({className:e,value:t,...n},o)=>jsxRuntime.jsx(Root$2,{ref:o,className:cn("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",e),...n,children:jsxRuntime.jsx(Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));Progress.displayName=Root$2.displayName;function ManufacturerInventoryFinanceCard({manufacturer:e,isLoading:t}){const{data:n,isLoading:o,isFetching:l}=useGetV4ManufacturerByRouteManufacturerIdInventoryValueQuery({routeManufacturerId:(e==null?void 0:e.ManufacturerId)??""},{skip:!(e!=null&&e.ManufacturerId)}),d=(e==null?void 0:e.DefaultMaxInventoryValue)??0,f=(n||[]).reduce((_,S)=>_+(S.InventoryValue||0),0),g=d-f,b=Math.round(f/d*100);return t||o||l?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/2 mt-2"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16"})]}),jsxRuntime.jsx(Skeleton,{className:"h-2 w-full"})]})]})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsxs(CardTitle,{className:"flex items-center gap-2",children:[jsxRuntime.jsx(DollarSign,{className:"h-5 w-5 text-muted-foreground"}),"Inventory Finance"]}),jsxRuntime.jsx(CardDescription,{children:"Current inventory financial status"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[d!==0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Max Allowance"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(d)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Current value"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(f)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Available"}),jsxRuntime.jsx("span",{className:`font-bold ${g>=0?"text-emerald-600 dark:text-emerald-500":"text-red-600 dark:text-red-500"}`,children:formatMoney(g)})]})]}),d!==0&&jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Budget Usage"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsxs("span",{className:"text-sm font-medium",children:[b,"%"]}),b>80&&jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4 text-amber-500"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:b>80?"High usage alert":"Budget usage"})})]})})]}),jsxRuntime.jsx(Progress,{value:b,className:"h-2"})]})]})]})}function ManufacturerCreditFinanceCard({manufacturer:e,isLoading:t}){const n=(e==null?void 0:e.CreditLimit)??0,o=(e==null?void 0:e.OutstandingBalance)??0,l=n-o,d=Math.round(o/n*100);return t?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/2 mt-2"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16"})]}),jsxRuntime.jsx(Skeleton,{className:"h-2 w-full"})]})]})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsxs(CardTitle,{className:"flex items-center gap-2",children:[jsxRuntime.jsx(CreditCard,{className:"h-5 w-5 text-muted-foreground"}),"Credit Finance"]}),jsxRuntime.jsx(CardDescription,{children:"Current credit financial status"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Credit Limit"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(n)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Outstanding Balance"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(o)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Available Credit"}),jsxRuntime.jsx("span",{className:`font-bold ${l>=0?"text-emerald-600 dark:text-emerald-500":"text-red-600 dark:text-red-500"}`,children:formatMoney(l)})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Credit Usage"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsxs("span",{className:"text-sm font-medium",children:[d,"%"]}),d>80&&jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4 text-amber-500"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:d>80?"High credit usage alert":"Credit usage"})})]})})]}),jsxRuntime.jsx(Progress,{value:d,className:"h-2"})]})]})]})}function SalesChartCard({statistics:e,loading:t=!1,mode:n="month",chartHeight:o=300,className:l,size:d="default"}){return t?jsxRuntime.jsxs(Card,{className:cn("w-full",l),children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-7 w-48 rounded-md"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx("div",{style:{height:o},children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-md"})}),d==="default"&&n==="month"&&jsxRuntime.jsxs("div",{className:"mt-4 flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-10 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-40 rounded-md"})]})]})]}):jsxRuntime.jsxs(Card,{className:cn("w-full",l),children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:n==="week"?"Weekly Sales Performance":"Monthly Sales Performance"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(SalesChart,{statistics:e,mode:n,chartHeight:o,size:d})})]})}function ManufacturerOverviewPage({applicationId:e,readonly:t,withReports:n,manufacturer:o,userEmail:l}){const{data:d,isLoading:f,isError:g}=useGetV4PartnerByApplicationIdAccountManufacturerQuery({applicationId:e,withSpecification:!0},{skip:!!o}),[b,_]=React.useState({publicInfo:{hasUnsavedChanges:!1},qualifications:{hasUnsavedChanges:!1},billingInfo:{hasUnsavedChanges:!1}}),S=React.useCallback(()=>t?!1:b.publicInfo.hasUnsavedChanges||b.qualifications.hasUnsavedChanges||b.billingInfo.hasUnsavedChanges,[t,b]),R=React.useCallback((A,M)=>{_(I=>{var j;return((j=I[A])==null?void 0:j.hasUnsavedChanges)!==M.hasUnsavedChanges?(console.log(`Updating form state for ${A}:`,M.hasUnsavedChanges),{...I,[A]:M}):I})},[]),{NavigationGuardDialog:C}=useRouterNavigationGuard(S),E=o??d;return jsxRuntime.jsxs("div",{className:"@container",children:[g?jsxRuntime.jsx(Card,{className:"p-6",children:jsxRuntime.jsxs(Alert,{variant:"destructive",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Error"}),jsxRuntime.jsx(AlertDescription,{children:"There was an error loading your manufacturer information. Please try again later."})]})}):jsxRuntime.jsxs("div",{className:"space-y-6 mb-6",children:[jsxRuntime.jsx(SalesSummary,{fiscalYearMonthStart:E==null?void 0:E.FiscalYearMonthStart,salesData:E==null?void 0:E.SalesData,isLoading:f}),jsxRuntime.jsxs("div",{className:"grid @2xl:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChartCard,{statistics:(E==null?void 0:E.SalesStatistics)??[],loading:f}),jsxRuntime.jsx(ManufacturerResellerOrdersSection,{manufacturerId:(E==null?void 0:E.ManufacturerId)??"",activeOrders:(E==null?void 0:E.ActiveOrderDetails)??void 0,isLoading:f}),n&&jsxRuntime.jsx(ManufacturerInventoryFinanceCard,{manufacturer:E,isLoading:f}),n&&jsxRuntime.jsx(ManufacturerCreditFinanceCard,{manufacturer:E,isLoading:f}),n&&jsxRuntime.jsx(ManufacturerReorderingCard,{manufacturer:E??{},onSave:()=>{},loading:f,readonly:t}),n&&jsxRuntime.jsx(ManufacturerPublicInfoSection,{manufacturer:E,readonly:t,isLoading:f,onUnsavedChanges:A=>R("publicInfo",{hasUnsavedChanges:A})}),n&&jsxRuntime.jsx(OpenToWorkSection,{manufacturer:E,readonly:t,isLoading:f}),n&&jsxRuntime.jsx(ManufacturerBillingInfoSection,{manufacturer:E,readonly:t,isLoading:f,onUnsavedChanges:A=>R("billingInfo",{hasUnsavedChanges:A})}),n&&jsxRuntime.jsx(ManufacturerQualificationsSection,{manufacturer:E,readonly:t,isLoading:f,onUnsavedChanges:A=>R("qualifications",{hasUnsavedChanges:A})})]}),n&&jsxRuntime.jsx(ManufacturerReportsSection,{manufacturerId:(E==null?void 0:E.ManufacturerId)??"",userEmail:l,isLoading:f})]}),jsxRuntime.jsx(C,{})]})}function ManufacturerCategories({categories:e,activeCategory:t,onSelectCategory:n}){return jsxRuntime.jsx("div",{className:"grid",children:jsxRuntime.jsx("div",{className:"flex overflow-x-auto small-scrollbar pb-4",children:jsxRuntime.jsxs("div",{className:"flex gap-2 items-baseline",children:[jsxRuntime.jsx("p",{children:"Category filter:"}),e.map(o=>jsxRuntime.jsxs(Button$1,{onClick:()=>n(o.CategoryCode??""),variant:t===o.CategoryCode?"default":"outline",size:"sm",className:"px-3 py-1.5 text-xs whitespace-nowrap rounded-full",children:[o.CategoryName??"Undefined",o.QualificationRequired&&jsxRuntime.jsx(ShieldCheck,{className:`ml-1 w-5 h-5 ${t!==o.CategoryCode?"text-red-500":""}`})]},o.CategoryCode))]})})})}function CategoryStats(e){const{data:t,isLoading:n,isFetching:o}=useGetV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeQuery({routeResellerId:e.appID,manufacturerId:e.manufID,categoryCode:e.categoryCode});return jsxRuntime.jsx(Card,{className:"w-full",children:jsxRuntime.jsx(CardContent,{className:"p-4 space-y-1",children:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground mb-2",children:e.categoryName}),jsxRuntime.jsx(SalesChart,{statistics:(t==null?void 0:t.SalesStatistics)??[],loading:n||o,chartHeight:300})]})})})}function ManufacturerCategoriesStats(e){return(e.categories??[]).filter(n=>n.CategoryName).map(n=>jsxRuntime.jsx(CategoryStats,{appID:e.appID,manufID:e.manufID,categoryCode:n.CategoryCode,categoryName:n.CategoryName},`${e.manufID}-${n.CategoryCode}`))}const badgeVariants=cva("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground border border-input hover:bg-accent hover:text-accent-foreground",success:"bg-green-600 text-white hover:bg-green-700",warning:"bg-yellow-500 text-white hover:bg-yellow-600",info:"bg-blue-500 text-white hover:bg-blue-600",ghost:"bg-background hover:bg-accent hover:text-accent-foreground",randmarRed:"bg-randmar-red text-white hover:bg-randmar-red/80",randmarBlue:"bg-randmar-blue text-white hover:bg-randmar-blue/80",randmarPurple:"bg-randmar-purple text-white hover:bg-randmar-purple/80",randmarGreen:"bg-randmar-green text-black hover:bg-randmar-green/80",randmarBlack:"bg-randmar-black text-white hover:bg-randmar-black/80",randmarYellow:"bg-randmar-yellow text-black hover:bg-randmar-yellow/80"},size:{default:"h-6",sm:"h-5 text-[10px]",lg:"h-7 px-3"}},defaultVariants:{variant:"default",size:"default"}}),Badge=React__namespace.forwardRef(({className:e,variant:t,size:n,icon:o,children:l,...d},f)=>jsxRuntime.jsxs("div",{ref:f,className:cn(badgeVariants({variant:t,size:n}),e),...d,children:[o&&jsxRuntime.jsx("span",{className:"mr-1",children:o}),l]}));Badge.displayName="Badge";function ManufacturerCategorySummary({name:e="N/A",niche:t="N/A",productsNumber:n=0,autoreorder:o=!1,starred:l=!1,isLoading:d=!1,children:f}){return d?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{className:"pb-4",children:jsxRuntime.jsxs("div",{className:"flex items-start justify-between",children:[jsxRuntime.jsx("div",{className:"space-y-1 flex-1",children:jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-28 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-5 w-48 bg-muted rounded-md animate-pulse"})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end gap-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-12 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-5 w-5 bg-muted rounded-md animate-pulse"})]})]})}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-8 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-4 w-32 bg-muted rounded-md animate-pulse"})]}),jsxRuntime.jsxs("div",{className:"flex items-start justify-between gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-1 flex-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-16 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"h-4 w-4 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-4 w-6 bg-muted rounded-md animate-pulse"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-1 flex-1 flex flex-col items-end",children:[jsxRuntime.jsx("div",{className:"h-3 w-20 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"h-4 w-4 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-6 w-16 bg-muted rounded-md animate-pulse"})]})]})]})]})]}):jsxRuntime.jsx(Card,{children:jsxRuntime.jsxs(CardContent,{className:"grid grid-cols-[1fr_auto] items-start gap-4 pt-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-start gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Category Name"}),jsxRuntime.jsx("h3",{className:"text-lg font-semibold leading-none tracking-tight",children:e})]}),jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Niche"}),jsxRuntime.jsx("p",{className:"text-sm font-medium",children:t})]}),jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Products"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Package,{className:"h-4 w-4 text-muted-foreground"}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:n})]})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end justify-between gap-4 h-full",children:[f,jsxRuntime.jsxs("div",{className:"flex flex-col items-end gap-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Starred"}),l?jsxRuntime.jsx(Star,{className:"h-5 w-5 fill-yellow-400 text-yellow-400"}):jsxRuntime.jsx(Star,{className:"h-5 w-5 text-muted-foreground"})]}),jsxRuntime.jsxs("div",{className:"space-y-1 flex flex-col items-end",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Auto-reorder"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[o?jsxRuntime.jsx(RefreshCw,{className:"size-4 text-green-600"}):jsxRuntime.jsx(RefreshCwOff,{className:"size-4 text-amber-600"}),jsxRuntime.jsx(Badge,{variant:o?"default":"secondary",className:cn("text-xs",o?"text-green-600 bg-green-100 hover:bg-green-200":"text-amber-600 bg-amber-100 hover:bg-amber-200"),children:o?"Enabled":"Disabled"})]})]})]})]})})}function createSlot$1(e){const t=createSlotClone$1(e),n=React__namespace.forwardRef((o,l)=>{const{children:d,...f}=o,g=React__namespace.Children.toArray(d),b=g.find(isSlottable$1);if(b){const _=b.props.children,S=g.map(R=>R===b?React__namespace.Children.count(_)>1?React__namespace.Children.only(null):React__namespace.isValidElement(_)?_.props.children:null:R);return jsxRuntime.jsx(t,{...f,ref:l,children:React__namespace.isValidElement(_)?React__namespace.cloneElement(_,void 0,S):null})}return jsxRuntime.jsx(t,{...f,ref:l,children:d})});return n.displayName=`${e}.Slot`,n}function createSlotClone$1(e){const t=React__namespace.forwardRef((n,o)=>{const{children:l,...d}=n;if(React__namespace.isValidElement(l)){const f=getElementRef$1(l),g=mergeProps$1(d,l.props);return l.type!==React__namespace.Fragment&&(g.ref=o?composeRefs(o,f):f),React__namespace.cloneElement(l,g)}return React__namespace.Children.count(l)>1?React__namespace.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var SLOTTABLE_IDENTIFIER$2=Symbol("radix.slottable");function isSlottable$1(e){return React__namespace.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===SLOTTABLE_IDENTIFIER$2}function mergeProps$1(e,t){const n={...t};for(const o in t){const l=e[o],d=t[o];/^on[A-Z]/.test(o)?l&&d?n[o]=(...g)=>{const b=d(...g);return l(...g),b}:l&&(n[o]=l):o==="style"?n[o]={...l,...d}:o==="className"&&(n[o]=[l,d].filter(Boolean).join(" "))}return{...e,...n}}function getElementRef$1(e){var o,l;let t=(o=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(l=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:l.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var OPEN_KEYS=[" ","Enter","ArrowUp","ArrowDown"],SELECTION_KEYS=[" ","Enter"],SELECT_NAME="Select",[Collection$1,useCollection$1,createCollectionScope$1]=createCollection(SELECT_NAME),[createSelectContext]=createContextScope$2(SELECT_NAME,[createCollectionScope$1,createPopperScope]),usePopperScope$1=createPopperScope(),[SelectProvider,useSelectContext]=createSelectContext(SELECT_NAME),[SelectNativeOptionsProvider,useSelectNativeOptionsContext]=createSelectContext(SELECT_NAME),Select$2=e=>{const{__scopeSelect:t,children:n,open:o,defaultOpen:l,onOpenChange:d,value:f,defaultValue:g,onValueChange:b,dir:_,name:S,autoComplete:R,disabled:C,required:E,form:A}=e,M=usePopperScope$1(t),[I,j]=React__namespace.useState(null),[q,Q]=React__namespace.useState(null),[te,F]=React__namespace.useState(!1),V=useDirection(_),[ne,ae]=useControllableState({prop:o,defaultProp:l??!1,onChange:d,caller:SELECT_NAME}),[se,Oe]=useControllableState({prop:f,defaultProp:g,onChange:b,caller:SELECT_NAME}),Ne=React__namespace.useRef(null),oe=I?A||!!I.closest("form"):!0,[$e,Ae]=React__namespace.useState(new Set),je=Array.from($e).map(Be=>Be.props.value).join(";");return jsxRuntime.jsx(Root2$7,{...M,children:jsxRuntime.jsxs(SelectProvider,{required:E,scope:t,trigger:I,onTriggerChange:j,valueNode:q,onValueNodeChange:Q,valueNodeHasChildren:te,onValueNodeHasChildrenChange:F,contentId:useId(),value:se,onValueChange:Oe,open:ne,onOpenChange:ae,dir:V,triggerPointerDownPosRef:Ne,disabled:C,children:[jsxRuntime.jsx(Collection$1.Provider,{scope:t,children:jsxRuntime.jsx(SelectNativeOptionsProvider,{scope:e.__scopeSelect,onNativeOptionAdd:React__namespace.useCallback(Be=>{Ae(qe=>new Set(qe).add(Be))},[]),onNativeOptionRemove:React__namespace.useCallback(Be=>{Ae(qe=>{const Ve=new Set(qe);return Ve.delete(Be),Ve})},[]),children:n})}),oe?jsxRuntime.jsxs(SelectBubbleInput,{"aria-hidden":!0,required:E,tabIndex:-1,name:S,autoComplete:R,value:se,onChange:Be=>Oe(Be.target.value),disabled:C,form:A,children:[se===void 0?jsxRuntime.jsx("option",{value:""}):null,Array.from($e)]},je):null]})})};Select$2.displayName=SELECT_NAME;var TRIGGER_NAME$5="SelectTrigger",SelectTrigger$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:o=!1,...l}=e,d=usePopperScope$1(n),f=useSelectContext(TRIGGER_NAME$5,n),g=f.disabled||o,b=useComposedRefs(t,f.onTriggerChange),_=useCollection$1(n),S=React__namespace.useRef("touch"),[R,C,E]=useTypeaheadSearch(M=>{const I=_().filter(Q=>!Q.disabled),j=I.find(Q=>Q.value===f.value),q=findNextItem(I,M,j);q!==void 0&&f.onValueChange(q.value)}),A=M=>{g||(f.onOpenChange(!0),E()),M&&(f.triggerPointerDownPosRef.current={x:Math.round(M.pageX),y:Math.round(M.pageY)})};return jsxRuntime.jsx(Anchor,{asChild:!0,...d,children:jsxRuntime.jsx(Primitive$4.button,{type:"button",role:"combobox","aria-controls":f.contentId,"aria-expanded":f.open,"aria-required":f.required,"aria-autocomplete":"none",dir:f.dir,"data-state":f.open?"open":"closed",disabled:g,"data-disabled":g?"":void 0,"data-placeholder":shouldShowPlaceholder(f.value)?"":void 0,...l,ref:b,onClick:composeEventHandlers(l.onClick,M=>{M.currentTarget.focus(),S.current!=="mouse"&&A(M)}),onPointerDown:composeEventHandlers(l.onPointerDown,M=>{S.current=M.pointerType;const I=M.target;I.hasPointerCapture(M.pointerId)&&I.releasePointerCapture(M.pointerId),M.button===0&&M.ctrlKey===!1&&M.pointerType==="mouse"&&(A(M),M.preventDefault())}),onKeyDown:composeEventHandlers(l.onKeyDown,M=>{const I=R.current!=="";!(M.ctrlKey||M.altKey||M.metaKey)&&M.key.length===1&&C(M.key),!(I&&M.key===" ")&&OPEN_KEYS.includes(M.key)&&(A(),M.preventDefault())})})})});SelectTrigger$1.displayName=TRIGGER_NAME$5;var VALUE_NAME="SelectValue",SelectValue$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,className:o,style:l,children:d,placeholder:f="",...g}=e,b=useSelectContext(VALUE_NAME,n),{onValueNodeHasChildrenChange:_}=b,S=d!==void 0,R=useComposedRefs(t,b.onValueNodeChange);return useLayoutEffect2(()=>{_(S)},[_,S]),jsxRuntime.jsx(Primitive$4.span,{...g,ref:R,style:{pointerEvents:"none"},children:shouldShowPlaceholder(b.value)?jsxRuntime.jsx(jsxRuntime.Fragment,{children:f}):d})});SelectValue$1.displayName=VALUE_NAME;var ICON_NAME="SelectIcon",SelectIcon=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,children:o,...l}=e;return jsxRuntime.jsx(Primitive$4.span,{"aria-hidden":!0,...l,ref:t,children:o||"▼"})});SelectIcon.displayName=ICON_NAME;var PORTAL_NAME$2="SelectPortal",SelectPortal=e=>jsxRuntime.jsx(Portal$5,{asChild:!0,...e});SelectPortal.displayName=PORTAL_NAME$2;var CONTENT_NAME$4="SelectContent",SelectContent$1=React__namespace.forwardRef((e,t)=>{const n=useSelectContext(CONTENT_NAME$4,e.__scopeSelect),[o,l]=React__namespace.useState();if(useLayoutEffect2(()=>{l(new DocumentFragment)},[]),!n.open){const d=o;return d?ReactDOM__namespace.createPortal(jsxRuntime.jsx(SelectContentProvider,{scope:e.__scopeSelect,children:jsxRuntime.jsx(Collection$1.Slot,{scope:e.__scopeSelect,children:jsxRuntime.jsx("div",{children:e.children})})}),d):null}return jsxRuntime.jsx(SelectContentImpl,{...e,ref:t})});SelectContent$1.displayName=CONTENT_NAME$4;var CONTENT_MARGIN=10,[SelectContentProvider,useSelectContentContext]=createSelectContext(CONTENT_NAME$4),CONTENT_IMPL_NAME="SelectContentImpl",Slot$1=createSlot$1("SelectContent.RemoveScroll"),SelectContentImpl=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,position:o="item-aligned",onCloseAutoFocus:l,onEscapeKeyDown:d,onPointerDownOutside:f,side:g,sideOffset:b,align:_,alignOffset:S,arrowPadding:R,collisionBoundary:C,collisionPadding:E,sticky:A,hideWhenDetached:M,avoidCollisions:I,...j}=e,q=useSelectContext(CONTENT_NAME$4,n),[Q,te]=React__namespace.useState(null),[F,V]=React__namespace.useState(null),ne=useComposedRefs(t,et=>te(et)),[ae,se]=React__namespace.useState(null),[Oe,Ne]=React__namespace.useState(null),oe=useCollection$1(n),[$e,Ae]=React__namespace.useState(!1),je=React__namespace.useRef(!1);React__namespace.useEffect(()=>{if(Q)return hideOthers(Q)},[Q]),useFocusGuards();const Be=React__namespace.useCallback(et=>{const[at,...tt]=oe().map(Ge=>Ge.ref.current),[ot]=tt.slice(-1),lt=document.activeElement;for(const Ge of et)if(Ge===lt||(Ge==null||Ge.scrollIntoView({block:"nearest"}),Ge===at&&F&&(F.scrollTop=0),Ge===ot&&F&&(F.scrollTop=F.scrollHeight),Ge==null||Ge.focus(),document.activeElement!==lt))return},[oe,F]),qe=React__namespace.useCallback(()=>Be([ae,Q]),[Be,ae,Q]);React__namespace.useEffect(()=>{$e&&qe()},[$e,qe]);const{onOpenChange:Ve,triggerPointerDownPosRef:Le}=q;React__namespace.useEffect(()=>{if(Q){let et={x:0,y:0};const at=ot=>{var lt,Ge;et={x:Math.abs(Math.round(ot.pageX)-(((lt=Le.current)==null?void 0:lt.x)??0)),y:Math.abs(Math.round(ot.pageY)-(((Ge=Le.current)==null?void 0:Ge.y)??0))}},tt=ot=>{et.x<=10&&et.y<=10?ot.preventDefault():Q.contains(ot.target)||Ve(!1),document.removeEventListener("pointermove",at),Le.current=null};return Le.current!==null&&(document.addEventListener("pointermove",at),document.addEventListener("pointerup",tt,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",at),document.removeEventListener("pointerup",tt,{capture:!0})}}},[Q,Ve,Le]),React__namespace.useEffect(()=>{const et=()=>Ve(!1);return window.addEventListener("blur",et),window.addEventListener("resize",et),()=>{window.removeEventListener("blur",et),window.removeEventListener("resize",et)}},[Ve]);const[He,We]=useTypeaheadSearch(et=>{const at=oe().filter(lt=>!lt.disabled),tt=at.find(lt=>lt.ref.current===document.activeElement),ot=findNextItem(at,et,tt);ot&&setTimeout(()=>ot.ref.current.focus())}),ze=React__namespace.useCallback((et,at,tt)=>{const ot=!je.current&&!tt;(q.value!==void 0&&q.value===at||ot)&&(se(et),ot&&(je.current=!0))},[q.value]),Xe=React__namespace.useCallback(()=>Q==null?void 0:Q.focus(),[Q]),nt=React__namespace.useCallback((et,at,tt)=>{const ot=!je.current&&!tt;(q.value!==void 0&&q.value===at||ot)&&Ne(et)},[q.value]),Je=o==="popper"?SelectPopperPosition:SelectItemAlignedPosition,st=Je===SelectPopperPosition?{side:g,sideOffset:b,align:_,alignOffset:S,arrowPadding:R,collisionBoundary:C,collisionPadding:E,sticky:A,hideWhenDetached:M,avoidCollisions:I}:{};return jsxRuntime.jsx(SelectContentProvider,{scope:n,content:Q,viewport:F,onViewportChange:V,itemRefCallback:ze,selectedItem:ae,onItemLeave:Xe,itemTextRefCallback:nt,focusSelectedItem:qe,selectedItemText:Oe,position:o,isPositioned:$e,searchRef:He,children:jsxRuntime.jsx(ReactRemoveScroll,{as:Slot$1,allowPinchZoom:!0,children:jsxRuntime.jsx(FocusScope,{asChild:!0,trapped:q.open,onMountAutoFocus:et=>{et.preventDefault()},onUnmountAutoFocus:composeEventHandlers(l,et=>{var at;(at=q.trigger)==null||at.focus({preventScroll:!0}),et.preventDefault()}),children:jsxRuntime.jsx(DismissableLayer,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:d,onPointerDownOutside:f,onFocusOutside:et=>et.preventDefault(),onDismiss:()=>q.onOpenChange(!1),children:jsxRuntime.jsx(Je,{role:"listbox",id:q.contentId,"data-state":q.open?"open":"closed",dir:q.dir,onContextMenu:et=>et.preventDefault(),...j,...st,onPlaced:()=>Ae(!0),ref:ne,style:{display:"flex",flexDirection:"column",outline:"none",...j.style},onKeyDown:composeEventHandlers(j.onKeyDown,et=>{const at=et.ctrlKey||et.altKey||et.metaKey;if(et.key==="Tab"&&et.preventDefault(),!at&&et.key.length===1&&We(et.key),["ArrowUp","ArrowDown","Home","End"].includes(et.key)){let ot=oe().filter(lt=>!lt.disabled).map(lt=>lt.ref.current);if(["ArrowUp","End"].includes(et.key)&&(ot=ot.slice().reverse()),["ArrowUp","ArrowDown"].includes(et.key)){const lt=et.target,Ge=ot.indexOf(lt);ot=ot.slice(Ge+1)}setTimeout(()=>Be(ot)),et.preventDefault()}})})})})})})});SelectContentImpl.displayName=CONTENT_IMPL_NAME;var ITEM_ALIGNED_POSITION_NAME="SelectItemAlignedPosition",SelectItemAlignedPosition=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:o,...l}=e,d=useSelectContext(CONTENT_NAME$4,n),f=useSelectContentContext(CONTENT_NAME$4,n),[g,b]=React__namespace.useState(null),[_,S]=React__namespace.useState(null),R=useComposedRefs(t,ne=>S(ne)),C=useCollection$1(n),E=React__namespace.useRef(!1),A=React__namespace.useRef(!0),{viewport:M,selectedItem:I,selectedItemText:j,focusSelectedItem:q}=f,Q=React__namespace.useCallback(()=>{if(d.trigger&&d.valueNode&&g&&_&&M&&I&&j){const ne=d.trigger.getBoundingClientRect(),ae=_.getBoundingClientRect(),se=d.valueNode.getBoundingClientRect(),Oe=j.getBoundingClientRect();if(d.dir!=="rtl"){const lt=Oe.left-ae.left,Ge=se.left-lt,$t=ne.left-Ge,rt=ne.width+$t,Rt=Math.max(rt,ae.width),dt=window.innerWidth-CONTENT_MARGIN,It=clamp(Ge,[CONTENT_MARGIN,Math.max(CONTENT_MARGIN,dt-Rt)]);g.style.minWidth=rt+"px",g.style.left=It+"px"}else{const lt=ae.right-Oe.right,Ge=window.innerWidth-se.right-lt,$t=window.innerWidth-ne.right-Ge,rt=ne.width+$t,Rt=Math.max(rt,ae.width),dt=window.innerWidth-CONTENT_MARGIN,It=clamp(Ge,[CONTENT_MARGIN,Math.max(CONTENT_MARGIN,dt-Rt)]);g.style.minWidth=rt+"px",g.style.right=It+"px"}const Ne=C(),oe=window.innerHeight-CONTENT_MARGIN*2,$e=M.scrollHeight,Ae=window.getComputedStyle(_),je=parseInt(Ae.borderTopWidth,10),Be=parseInt(Ae.paddingTop,10),qe=parseInt(Ae.borderBottomWidth,10),Ve=parseInt(Ae.paddingBottom,10),Le=je+Be+$e+Ve+qe,He=Math.min(I.offsetHeight*5,Le),We=window.getComputedStyle(M),ze=parseInt(We.paddingTop,10),Xe=parseInt(We.paddingBottom,10),nt=ne.top+ne.height/2-CONTENT_MARGIN,Je=oe-nt,st=I.offsetHeight/2,et=I.offsetTop+st,at=je+Be+et,tt=Le-at;if(at<=nt){const lt=Ne.length>0&&I===Ne[Ne.length-1].ref.current;g.style.bottom="0px";const Ge=_.clientHeight-M.offsetTop-M.offsetHeight,$t=Math.max(Je,st+(lt?Xe:0)+Ge+qe),rt=at+$t;g.style.height=rt+"px"}else{const lt=Ne.length>0&&I===Ne[0].ref.current;g.style.top="0px";const $t=Math.max(nt,je+M.offsetTop+(lt?ze:0)+st)+tt;g.style.height=$t+"px",M.scrollTop=at-nt+M.offsetTop}g.style.margin=`${CONTENT_MARGIN}px 0`,g.style.minHeight=He+"px",g.style.maxHeight=oe+"px",o==null||o(),requestAnimationFrame(()=>E.current=!0)}},[C,d.trigger,d.valueNode,g,_,M,I,j,d.dir,o]);useLayoutEffect2(()=>Q(),[Q]);const[te,F]=React__namespace.useState();useLayoutEffect2(()=>{_&&F(window.getComputedStyle(_).zIndex)},[_]);const V=React__namespace.useCallback(ne=>{ne&&A.current===!0&&(Q(),q==null||q(),A.current=!1)},[Q,q]);return jsxRuntime.jsx(SelectViewportProvider,{scope:n,contentWrapper:g,shouldExpandOnScrollRef:E,onScrollButtonChange:V,children:jsxRuntime.jsx("div",{ref:b,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:te},children:jsxRuntime.jsx(Primitive$4.div,{...l,ref:R,style:{boxSizing:"border-box",maxHeight:"100%",...l.style}})})})});SelectItemAlignedPosition.displayName=ITEM_ALIGNED_POSITION_NAME;var POPPER_POSITION_NAME="SelectPopperPosition",SelectPopperPosition=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,align:o="start",collisionPadding:l=CONTENT_MARGIN,...d}=e,f=usePopperScope$1(n);return jsxRuntime.jsx(Content$2,{...f,...d,ref:t,align:o,collisionPadding:l,style:{boxSizing:"border-box",...d.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});SelectPopperPosition.displayName=POPPER_POSITION_NAME;var[SelectViewportProvider,useSelectViewportContext]=createSelectContext(CONTENT_NAME$4,{}),VIEWPORT_NAME="SelectViewport",SelectViewport=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:o,...l}=e,d=useSelectContentContext(VIEWPORT_NAME,n),f=useSelectViewportContext(VIEWPORT_NAME,n),g=useComposedRefs(t,d.onViewportChange),b=React__namespace.useRef(0);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),jsxRuntime.jsx(Collection$1.Slot,{scope:n,children:jsxRuntime.jsx(Primitive$4.div,{"data-radix-select-viewport":"",role:"presentation",...l,ref:g,style:{position:"relative",flex:1,overflow:"hidden auto",...l.style},onScroll:composeEventHandlers(l.onScroll,_=>{const S=_.currentTarget,{contentWrapper:R,shouldExpandOnScrollRef:C}=f;if(C!=null&&C.current&&R){const E=Math.abs(b.current-S.scrollTop);if(E>0){const A=window.innerHeight-CONTENT_MARGIN*2,M=parseFloat(R.style.minHeight),I=parseFloat(R.style.height),j=Math.max(M,I);if(j<A){const q=j+E,Q=Math.min(A,q),te=q-Q;R.style.height=Q+"px",R.style.bottom==="0px"&&(S.scrollTop=te>0?te:0,R.style.justifyContent="flex-end")}}}b.current=S.scrollTop})})})]})});SelectViewport.displayName=VIEWPORT_NAME;var GROUP_NAME="SelectGroup",[SelectGroupContextProvider,useSelectGroupContext]=createSelectContext(GROUP_NAME),SelectGroup$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...o}=e,l=useId();return jsxRuntime.jsx(SelectGroupContextProvider,{scope:n,id:l,children:jsxRuntime.jsx(Primitive$4.div,{role:"group","aria-labelledby":l,...o,ref:t})})});SelectGroup$1.displayName=GROUP_NAME;var LABEL_NAME="SelectLabel",SelectLabel$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...o}=e,l=useSelectGroupContext(LABEL_NAME,n);return jsxRuntime.jsx(Primitive$4.div,{id:l.id,...o,ref:t})});SelectLabel$1.displayName=LABEL_NAME;var ITEM_NAME$1="SelectItem",[SelectItemContextProvider,useSelectItemContext]=createSelectContext(ITEM_NAME$1),SelectItem$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,value:o,disabled:l=!1,textValue:d,...f}=e,g=useSelectContext(ITEM_NAME$1,n),b=useSelectContentContext(ITEM_NAME$1,n),_=g.value===o,[S,R]=React__namespace.useState(d??""),[C,E]=React__namespace.useState(!1),A=useComposedRefs(t,q=>{var Q;return(Q=b.itemRefCallback)==null?void 0:Q.call(b,q,o,l)}),M=useId(),I=React__namespace.useRef("touch"),j=()=>{l||(g.onValueChange(o),g.onOpenChange(!1))};if(o==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return jsxRuntime.jsx(SelectItemContextProvider,{scope:n,value:o,disabled:l,textId:M,isSelected:_,onItemTextChange:React__namespace.useCallback(q=>{R(Q=>Q||((q==null?void 0:q.textContent)??"").trim())},[]),children:jsxRuntime.jsx(Collection$1.ItemSlot,{scope:n,value:o,disabled:l,textValue:S,children:jsxRuntime.jsx(Primitive$4.div,{role:"option","aria-labelledby":M,"data-highlighted":C?"":void 0,"aria-selected":_&&C,"data-state":_?"checked":"unchecked","aria-disabled":l||void 0,"data-disabled":l?"":void 0,tabIndex:l?void 0:-1,...f,ref:A,onFocus:composeEventHandlers(f.onFocus,()=>E(!0)),onBlur:composeEventHandlers(f.onBlur,()=>E(!1)),onClick:composeEventHandlers(f.onClick,()=>{I.current!=="mouse"&&j()}),onPointerUp:composeEventHandlers(f.onPointerUp,()=>{I.current==="mouse"&&j()}),onPointerDown:composeEventHandlers(f.onPointerDown,q=>{I.current=q.pointerType}),onPointerMove:composeEventHandlers(f.onPointerMove,q=>{var Q;I.current=q.pointerType,l?(Q=b.onItemLeave)==null||Q.call(b):I.current==="mouse"&&q.currentTarget.focus({preventScroll:!0})}),onPointerLeave:composeEventHandlers(f.onPointerLeave,q=>{var Q;q.currentTarget===document.activeElement&&((Q=b.onItemLeave)==null||Q.call(b))}),onKeyDown:composeEventHandlers(f.onKeyDown,q=>{var te;((te=b.searchRef)==null?void 0:te.current)!==""&&q.key===" "||(SELECTION_KEYS.includes(q.key)&&j(),q.key===" "&&q.preventDefault())})})})})});SelectItem$1.displayName=ITEM_NAME$1;var ITEM_TEXT_NAME="SelectItemText",SelectItemText=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,className:o,style:l,...d}=e,f=useSelectContext(ITEM_TEXT_NAME,n),g=useSelectContentContext(ITEM_TEXT_NAME,n),b=useSelectItemContext(ITEM_TEXT_NAME,n),_=useSelectNativeOptionsContext(ITEM_TEXT_NAME,n),[S,R]=React__namespace.useState(null),C=useComposedRefs(t,j=>R(j),b.onItemTextChange,j=>{var q;return(q=g.itemTextRefCallback)==null?void 0:q.call(g,j,b.value,b.disabled)}),E=S==null?void 0:S.textContent,A=React__namespace.useMemo(()=>jsxRuntime.jsx("option",{value:b.value,disabled:b.disabled,children:E},b.value),[b.disabled,b.value,E]),{onNativeOptionAdd:M,onNativeOptionRemove:I}=_;return useLayoutEffect2(()=>(M(A),()=>I(A)),[M,I,A]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Primitive$4.span,{id:b.textId,...d,ref:C}),b.isSelected&&f.valueNode&&!f.valueNodeHasChildren?ReactDOM__namespace.createPortal(d.children,f.valueNode):null]})});SelectItemText.displayName=ITEM_TEXT_NAME;var ITEM_INDICATOR_NAME="SelectItemIndicator",SelectItemIndicator=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...o}=e;return useSelectItemContext(ITEM_INDICATOR_NAME,n).isSelected?jsxRuntime.jsx(Primitive$4.span,{"aria-hidden":!0,...o,ref:t}):null});SelectItemIndicator.displayName=ITEM_INDICATOR_NAME;var SCROLL_UP_BUTTON_NAME="SelectScrollUpButton",SelectScrollUpButton$1=React__namespace.forwardRef((e,t)=>{const n=useSelectContentContext(SCROLL_UP_BUTTON_NAME,e.__scopeSelect),o=useSelectViewportContext(SCROLL_UP_BUTTON_NAME,e.__scopeSelect),[l,d]=React__namespace.useState(!1),f=useComposedRefs(t,o.onScrollButtonChange);return useLayoutEffect2(()=>{if(n.viewport&&n.isPositioned){let g=function(){const _=b.scrollTop>0;d(_)};const b=n.viewport;return g(),b.addEventListener("scroll",g),()=>b.removeEventListener("scroll",g)}},[n.viewport,n.isPositioned]),l?jsxRuntime.jsx(SelectScrollButtonImpl,{...e,ref:f,onAutoScroll:()=>{const{viewport:g,selectedItem:b}=n;g&&b&&(g.scrollTop=g.scrollTop-b.offsetHeight)}}):null});SelectScrollUpButton$1.displayName=SCROLL_UP_BUTTON_NAME;var SCROLL_DOWN_BUTTON_NAME="SelectScrollDownButton",SelectScrollDownButton$1=React__namespace.forwardRef((e,t)=>{const n=useSelectContentContext(SCROLL_DOWN_BUTTON_NAME,e.__scopeSelect),o=useSelectViewportContext(SCROLL_DOWN_BUTTON_NAME,e.__scopeSelect),[l,d]=React__namespace.useState(!1),f=useComposedRefs(t,o.onScrollButtonChange);return useLayoutEffect2(()=>{if(n.viewport&&n.isPositioned){let g=function(){const _=b.scrollHeight-b.clientHeight,S=Math.ceil(b.scrollTop)<_;d(S)};const b=n.viewport;return g(),b.addEventListener("scroll",g),()=>b.removeEventListener("scroll",g)}},[n.viewport,n.isPositioned]),l?jsxRuntime.jsx(SelectScrollButtonImpl,{...e,ref:f,onAutoScroll:()=>{const{viewport:g,selectedItem:b}=n;g&&b&&(g.scrollTop=g.scrollTop+b.offsetHeight)}}):null});SelectScrollDownButton$1.displayName=SCROLL_DOWN_BUTTON_NAME;var SelectScrollButtonImpl=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:o,...l}=e,d=useSelectContentContext("SelectScrollButton",n),f=React__namespace.useRef(null),g=useCollection$1(n),b=React__namespace.useCallback(()=>{f.current!==null&&(window.clearInterval(f.current),f.current=null)},[]);return React__namespace.useEffect(()=>()=>b(),[b]),useLayoutEffect2(()=>{var S;const _=g().find(R=>R.ref.current===document.activeElement);(S=_==null?void 0:_.ref.current)==null||S.scrollIntoView({block:"nearest"})},[g]),jsxRuntime.jsx(Primitive$4.div,{"aria-hidden":!0,...l,ref:t,style:{flexShrink:0,...l.style},onPointerDown:composeEventHandlers(l.onPointerDown,()=>{f.current===null&&(f.current=window.setInterval(o,50))}),onPointerMove:composeEventHandlers(l.onPointerMove,()=>{var _;(_=d.onItemLeave)==null||_.call(d),f.current===null&&(f.current=window.setInterval(o,50))}),onPointerLeave:composeEventHandlers(l.onPointerLeave,()=>{b()})})}),SEPARATOR_NAME="SelectSeparator",SelectSeparator$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...o}=e;return jsxRuntime.jsx(Primitive$4.div,{"aria-hidden":!0,...o,ref:t})});SelectSeparator$1.displayName=SEPARATOR_NAME;var ARROW_NAME$1="SelectArrow",SelectArrow=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...o}=e,l=usePopperScope$1(n),d=useSelectContext(ARROW_NAME$1,n),f=useSelectContentContext(ARROW_NAME$1,n);return d.open&&f.position==="popper"?jsxRuntime.jsx(Arrow,{...l,...o,ref:t}):null});SelectArrow.displayName=ARROW_NAME$1;var BUBBLE_INPUT_NAME$1="SelectBubbleInput",SelectBubbleInput=React__namespace.forwardRef(({__scopeSelect:e,value:t,...n},o)=>{const l=React__namespace.useRef(null),d=useComposedRefs(o,l),f=usePrevious(t);return React__namespace.useEffect(()=>{const g=l.current;if(!g)return;const b=window.HTMLSelectElement.prototype,S=Object.getOwnPropertyDescriptor(b,"value").set;if(f!==t&&S){const R=new Event("change",{bubbles:!0});S.call(g,t),g.dispatchEvent(R)}},[f,t]),jsxRuntime.jsx(Primitive$4.select,{...n,style:{...VISUALLY_HIDDEN_STYLES,...n.style},ref:d,defaultValue:t})});SelectBubbleInput.displayName=BUBBLE_INPUT_NAME$1;function shouldShowPlaceholder(e){return e===""||e===void 0}function useTypeaheadSearch(e){const t=useCallbackRef$1(e),n=React__namespace.useRef(""),o=React__namespace.useRef(0),l=React__namespace.useCallback(f=>{const g=n.current+f;t(g),(function b(_){n.current=_,window.clearTimeout(o.current),_!==""&&(o.current=window.setTimeout(()=>b(""),1e3))})(g)},[t]),d=React__namespace.useCallback(()=>{n.current="",window.clearTimeout(o.current)},[]);return React__namespace.useEffect(()=>()=>window.clearTimeout(o.current),[]),[n,l,d]}function findNextItem(e,t,n){const l=t.length>1&&Array.from(t).every(_=>_===t[0])?t[0]:t,d=n?e.indexOf(n):-1;let f=wrapArray(e,Math.max(d,0));l.length===1&&(f=f.filter(_=>_!==n));const b=f.find(_=>_.textValue.toLowerCase().startsWith(l.toLowerCase()));return b!==n?b:void 0}function wrapArray(e,t){return e.map((n,o)=>e[(t+o)%e.length])}var Root2$3=Select$2,Trigger$2=SelectTrigger$1,Value=SelectValue$1,Icon=SelectIcon,Portal$1=SelectPortal,Content2$3=SelectContent$1,Viewport=SelectViewport,Group=SelectGroup$1,Label=SelectLabel$1,Item$2=SelectItem$1,ItemText=SelectItemText,ItemIndicator=SelectItemIndicator,ScrollUpButton=SelectScrollUpButton$1,ScrollDownButton=SelectScrollDownButton$1,Separator=SelectSeparator$1;const Select$1=Root2$3,SelectGroup=Group,SelectValue=Value,SelectTrigger=React__namespace.forwardRef(({className:e,children:t,...n},o)=>jsxRuntime.jsxs(Trigger$2,{ref:o,className:cn("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,jsxRuntime.jsx(Icon,{asChild:!0,children:jsxRuntime.jsx(ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));SelectTrigger.displayName=Trigger$2.displayName;const SelectScrollUpButton=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(ScrollUpButton,{ref:n,className:cn("flex cursor-default items-center justify-center py-1",e),...t,children:jsxRuntime.jsx(ChevronUp,{className:"h-4 w-4"})}));SelectScrollUpButton.displayName=ScrollUpButton.displayName;const SelectScrollDownButton=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(ScrollDownButton,{ref:n,className:cn("flex cursor-default items-center justify-center py-1",e),...t,children:jsxRuntime.jsx(ChevronDown,{className:"h-4 w-4"})}));SelectScrollDownButton.displayName=ScrollDownButton.displayName;const SelectContent=React__namespace.forwardRef(({className:e,children:t,position:n="popper",...o},l)=>jsxRuntime.jsx(Portal$1,{children:jsxRuntime.jsxs(Content2$3,{ref:l,className:cn("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md 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-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...o,children:[jsxRuntime.jsx(SelectScrollUpButton,{}),jsxRuntime.jsx(Viewport,{className:cn("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),jsxRuntime.jsx(SelectScrollDownButton,{})]})}));SelectContent.displayName=Content2$3.displayName;const SelectLabel=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Label,{ref:n,className:cn("px-2 py-1.5 text-sm font-semibold",e),...t}));SelectLabel.displayName=Label.displayName;const SelectItem=React__namespace.forwardRef(({className:e,children:t,...n},o)=>jsxRuntime.jsxs(Item$2,{ref:o,className:cn("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[jsxRuntime.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:jsxRuntime.jsx(ItemIndicator,{children:jsxRuntime.jsx(Check,{className:"h-4 w-4"})})}),jsxRuntime.jsx(ItemText,{children:t})]}));SelectItem.displayName=Item$2.displayName;const SelectSeparator=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Separator,{ref:n,className:cn("-mx-1 my-1 h-px bg-muted",e),...t}));SelectSeparator.displayName=Separator.displayName;function ManufacturerProducts({applicationId:e,manufacturer:t,shopifyHostName:n}){var Q,te,F,V,ne;const[o]=usePostV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeShopifyMutation(),[l,d]=React.useState(((te=(Q=t.Categories)==null?void 0:Q[0])==null?void 0:te.CategoryCode)||""),[f,g]=React.useState(!1),[b,_]=React.useState(!1),[S,R]=React.useState("percentile"),{toast:C}=useToast(),{data:E,isLoading:A,isFetching:M}=useGetV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeQuery({routeResellerId:e,manufacturerId:t.ManufacturerId,categoryCode:l??""},{skip:!t.ManufacturerId||!l}),I=async()=>{try{g(!0),_(!1),await o({routeResellerId:e,manufacturerId:t.ManufacturerId??"",categoryCode:l,shopifyHostName:n}).unwrap()&&C({title:"Success",description:"Category synced to Shopify successfully",variant:"success"})}catch(ae){console.error("Error syncing to Shopify:",ae),C({title:"Error",description:"Error syncing category to Shopify.",variant:"destructive"})}finally{g(!1)}},j=()=>{var ae,se;return((se=(ae=t.Categories)==null?void 0:ae.find(Oe=>Oe.CategoryCode===l))==null?void 0:se.CategoryName)||l},q=React.useMemo(()=>E!=null&&E.Products?[...E.Products].sort((ae,se)=>S==="price-asc"?(ae.MAP??0)-(se.MAP??0):S==="price-desc"?(se.MAP??0)-(ae.MAP??0):S==="name"?(ae.Title??"").localeCompare(se.Title??""):S==="percentile"?(se.OverallPercentileRank??0)-(ae.OverallPercentileRank??0):0):[],[E==null?void 0:E.Products,S]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"mb-4",children:[jsxRuntime.jsx(ManufacturerCategories,{categories:t.Categories||[],activeCategory:l,onSelectCategory:d}),jsxRuntime.jsx("div",{className:"mb-4 w-full",children:jsxRuntime.jsx(ManufacturerCategorySummary,{name:j(),niche:(E==null?void 0:E.Niche)||"",productsNumber:((F=E==null?void 0:E.Products)==null?void 0:F.length)||0,autoreorder:(E==null?void 0:E.AutoReorder)||!1,starred:(E==null?void 0:E.Starred)||!1,isLoading:A||M,children:n&&((V=t.Categories)==null?void 0:V.findIndex(ae=>ae.AvailableToBuy))!==-1&&jsxRuntime.jsx(Button$1,{className:"bg-green-600 hover:bg-green-700",disabled:f,onClick:()=>_(!0),children:f?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2 h-4 w-4"}),"Sync Category to Shopify"]})})})}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4",children:[jsxRuntime.jsx(ManufacturerCategoriesStats,{categories:[(ne=t.Categories)==null?void 0:ne.find(ae=>ae.CategoryCode===l)].filter(Boolean),manufID:t.ManufacturerId,appID:e}),jsxRuntime.jsx(ActiveOrdersCard,{orders:(E==null?void 0:E.ActiveOrderDetails)??void 0,loading:A||M})]})]}),jsxRuntime.jsx(ManufacturerCategories,{categories:t.Categories||[],activeCategory:l,onSelectCategory:d}),jsxRuntime.jsxs("div",{className:"flex justify-between items-center mt-7 mb-4",children:[jsxRuntime.jsx("h4",{className:"text-xl md:text-2xl text-foreground font-bold",children:"Products"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 ms-auto",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium text-muted-foreground",children:"Sort by:"}),jsxRuntime.jsxs(Select$1,{value:S,onValueChange:R,children:[jsxRuntime.jsx(SelectTrigger,{className:"w-[220px]",children:jsxRuntime.jsx(SelectValue,{})}),jsxRuntime.jsxs(SelectContent,{children:[jsxRuntime.jsx(SelectItem,{value:"price-asc",children:"MAP: Low to High"}),jsxRuntime.jsx(SelectItem,{value:"price-desc",children:"MAP: High to Low"}),jsxRuntime.jsx(SelectItem,{value:"name",children:"Name"}),jsxRuntime.jsx(SelectItem,{value:"percentile",children:"Best Selling"})]})]})]})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4 mb-4",children:A||M?Array.from({length:4}).map((ae,se)=>jsxRuntime.jsx(ProductCard,{},se)):q.length>0?q.map(ae=>jsxRuntime.jsx(ProductCard,{applicationId:e,product:ae,viewProductLink:`/${e}/Product/${ae.RandmarSKU}`,shopifyHostname:n},ae.RandmarSKU)):jsxRuntime.jsxs(Alert,{variant:"warning",className:"col-span-1 @md:col-span-2",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Warning"}),jsxRuntime.jsx(AlertDescription,{children:"No products found for this manufacturer category."})]})}),jsxRuntime.jsx(Dialog,{open:b,onOpenChange:_,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Confirm Sync to Shopify"}),jsxRuntime.jsxs(DialogDescription,{children:['Are you sure you want to sync the category "',j(),'" to Shopify? This will add all products in this category to your Shopify store.']})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>_(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{className:"bg-green-600 hover:bg-green-700",onClick:I,disabled:f,children:f?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):"Confirm Sync"})]})]})})]})}function PartnerRelationshipPage({applicationId:e,partnerId:t,userEmail:n,shopifyHostName:o,isSuperAdmin:l}){var q,Q,te;const{data:d}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:e}),{data:f,isLoading:g,isFetching:b}=useGetV4PartnerByRouteApplicationIdPartnerAndPartnerIdQuery({routeApplicationId:e,partnerId:t,withSpecification:!0}),{toast:_}=useToast(),[S]=usePostV4ResellerByRouteResellerIdManufacturerAndManufacturerIdShopifyMutation(),[R,C]=React.useState(!1),[E,A]=React.useState(!1),M=async()=>{try{C(!0),A(!1),await S({routeResellerId:e??"",manufacturerId:t??"",shopifyHostName:o}).unwrap()&&_({title:"Success",description:"Manufacturer synced to Shopify successfully",variant:"success"})}catch(F){console.error("Error syncing to Shopify:",F),_({title:"Error",description:"Error syncing manufacturer to Shopify.",variant:"destructive"})}finally{C(!1)}},I=()=>f!=null&&f.Manufacturer?"products":f!=null&&f.Reseller?"reseller-overview":"",j=usePartnershipAssistantPrompt(d,f);return jsxRuntime.jsxs("div",{className:"@container",children:[jsxRuntime.jsxs("div",{className:"grid gap-4 @2xl:grid-cols-2",children:[jsxRuntime.jsx(PartnerCard,{account:f,loading:g||b,withAbout:!0,withVoice:!1,action:" "}),jsxRuntime.jsxs("div",{className:"grid gap-4",children:[((f==null?void 0:f.Manufacturer)||g||b)&&jsxRuntime.jsx(ManufacturerCard,{manufacturer:f==null?void 0:f.Manufacturer,loading:g||b,mainAction:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[(f==null?void 0:f.Manufacturer)&&jsxRuntime.jsx(ManufacturerGetStartedButton,{applicationId:e,manufacturer:f==null?void 0:f.Manufacturer}),o&&((Q=(q=f==null?void 0:f.Manufacturer)==null?void 0:q.Categories)==null?void 0:Q.findIndex(F=>F.AvailableToBuy))!==-1&&jsxRuntime.jsxs(Dialog,{open:E,onOpenChange:A,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{className:"bg-green-600 hover:bg-green-700 ml-2",disabled:R,children:R?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2 h-4 w-4"}),"Sync Manufacturer to Shopify"]})})}),jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Confirm Sync to Shopify"}),jsxRuntime.jsxs(DialogDescription,{children:['Are you sure you want to sync the manufacturer "',(te=f==null?void 0:f.Manufacturer)==null?void 0:te.PublicName,'" to Shopify? This will add all products from this manufacturer to your Shopify store.']})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>A(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{className:"bg-green-600 hover:bg-green-700",onClick:M,disabled:R,children:R?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):"Confirm Sync"})]})]})]})]})}),(f==null?void 0:f.Reseller)&&jsxRuntime.jsx(ResellerCard,{reseller:f==null?void 0:f.Reseller,loading:g||b})]})]}),((f==null?void 0:f.Reseller)||(f==null?void 0:f.Manufacturer))&&!g&&!b&&jsxRuntime.jsx("div",{className:"max-w-6xl mx-auto p-4",children:jsxRuntime.jsxs(Tabs,{defaultValue:I(),className:"w-full",children:[jsxRuntime.jsxs(TabsList,{className:"inline-flex h-auto items-center justify-center rounded-none border-b bg-transparent p-0",children:[(f==null?void 0:f.Reseller)&&jsxRuntime.jsx(TabsTrigger,{value:"reseller-overview",className:"reseller-theme relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Reseller Overview"}),(f==null?void 0:f.Manufacturer)&&jsxRuntime.jsx(TabsTrigger,{value:"manufacturer-overview",className:"manufacturer-theme relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Manufacturer Overview"}),(f==null?void 0:f.Manufacturer)&&jsxRuntime.jsx(TabsTrigger,{value:"products",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Products"}),jsxRuntime.jsxs(TabsTrigger,{value:"assistant",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:[jsxRuntime.jsx(Bot,{className:"mr-2 w-4 h-4"}),"Assistant"]})]}),(f==null?void 0:f.Reseller)&&jsxRuntime.jsx(TabsContent,{value:"reseller-overview",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ResellerOverview,{readonly:!0,appID:f.ApplicationId||"",reseller:f==null?void 0:f.Reseller,userEmail:n,isSuperAdmin:l,withoutReports:!0})})}),(f==null?void 0:f.Manufacturer)&&jsxRuntime.jsx(TabsContent,{value:"manufacturer-overview",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ManufacturerOverviewPage,{readonly:!0,manufacturer:f==null?void 0:f.Manufacturer,applicationId:e,userEmail:n})})}),(f==null?void 0:f.Manufacturer)&&jsxRuntime.jsx(TabsContent,{value:"products",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ManufacturerProducts,{applicationId:e,manufacturer:f.Manufacturer,shopifyHostName:o})})}),jsxRuntime.jsx(TabsContent,{value:"assistant",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(AssistantInsight,{prompt:j,thinkingPlaceholderText:"Thinking about the relationship..."})})})]})}),(g||b)&&jsxRuntime.jsx("div",{className:"max-w-6xl mx-auto p-4 mt-4 flex justify-center items-center h-32",children:jsxRuntime.jsx(LoaderCircle,{className:"h-8 w-8 animate-spin text-primary"})})]})}const PublicInfo=({reseller:e,appID:t,isLoading:n,readonly:o,onUnsavedChanges:l})=>{const{toast:d}=useToast(),[f]=usePostV4PartnerByApplicationIdAccountResellerAndFieldNameMutation(),[g,b]=React.useState({}),_=React.useMemo(()=>({publicEmail:e.PublicEmail??"",contactName:e.ContactName??"",phone:e.Phone??"",website:e.Website??""}),[e]),{register:S,handleSubmit:R,reset:C,watch:E,formState:{errors:A,isSubmitting:M}}=useForm({defaultValues:_}),I=E(),j=React.useCallback(()=>g?JSON.stringify(I)!==JSON.stringify(g):!1,[I,g]);React.useEffect(()=>{l&&l(j())},[j,l]),React.useEffect(()=>{e&&Object.keys(e).length>0&&(C(_),b(_))},[e,C,_]);const q=async te=>{let F=!0,V=!1;const ne=Object.keys(te).map(ae=>({key:ae,keyApi:ae.charAt(0).toUpperCase()+ae.slice(1)}));for(const ae of ne){const se=te[ae.key],Oe=e[ae.keyApi];if(se!==Oe&&se!==void 0){V=!0;try{await f({applicationId:t,fieldName:ae.keyApi,newValue:String(se)}).unwrap()||(F=!1)}catch(Ne){console.error(`Error updating ${ae.keyApi}:`,Ne),F=!1}}}F&&V?(d({title:"Public info",description:"Information updated successfully",variant:"success"}),b({...te}),l&&l(!1)):F||d({title:"Updation error",description:"Failed to update",variant:"destructive"})},Q=te=>!te||te.trim()==="";return n?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Public Information"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-28"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-20"})})]})})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsxs(CardTitle,{className:"text-1xl font-bold",children:["Public Information ",o?"(read only)":""]})}),jsxRuntime.jsxs(CardContent,{children:[(Q(E("contactName"))||Q(E("publicEmail"))||Q(E("website"))||Q(E("phone")))&&jsxRuntime.jsxs(Alert,{variant:"destructive",className:"mb-6",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Missing information"}),jsxRuntime.jsx(AlertDescription,{children:"All fields are required to get started at working with Manufacturers."})]}),jsxRuntime.jsxs("form",{onSubmit:R(q),className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"contactName",children:"Main Representative *"}),jsxRuntime.jsx(Input,{id:"contactName",placeholder:"John Doe",readOnly:o,...S("contactName",{}),className:A.contactName||Q(E("contactName"))?"input-error-indicator":""}),A.contactName&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:A.contactName.message})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"publicEmail",children:"Public Email *"}),jsxRuntime.jsx(Input,{id:"publicEmail",placeholder:"contact@company.com",readOnly:o,...S("publicEmail",{pattern:{value:/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,message:"Invalid email address"}}),className:A.publicEmail||Q(E("publicEmail"))?"input-error-indicator":""}),A.publicEmail&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:A.publicEmail.message})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"website",children:"Website *"}),jsxRuntime.jsx(Input,{id:"website",placeholder:"https://company.com",readOnly:o,...S("website",{pattern:{value:/^.{7,}$/,message:"Must be at least 7 characters"}}),className:A.website||Q(E("website"))?"input-error-indicator":""}),A.website&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:A.website.message})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"phone",children:"Phone Number *"}),jsxRuntime.jsx(Input,{id:"phone",placeholder:"+1 (555) 123-4567",readOnly:o,...S("phone",{pattern:{value:/^.{7,}$/,message:"Must be at least 7 characters"}}),className:A.phone||Q(E("phone"))?"input-error-indicator":""}),A.phone&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:A.phone.message})]}),jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(Button$1,{type:"submit",disabled:M||o,className:o?"hidden":"",children:M?"Saving...":"Save"})})]})]})]})};function BillingCard({appID:e,reseller:t,isLoading:n,withoutReports:o,userEmail:l,isSuperAdmin:d}){const{toast:f}=useToast(),{Statement:g,CreditLimit:b}=t,[_,S]=React.useState(!1),[R,C]=React.useState(!1),[E,A]=React.useState(!1),[M,I]=React.useState(!1),[j,q]=React.useState(l||""),[Q,te]=React.useState(!1),[F,V]=React.useState((b==null?void 0:b.toString())||""),[ne,{isLoading:ae}]=usePostV4PartnerByApplicationIdAccountResellerCreditLimitMutation(),se=[{label:"0 - 30 Days",value:jsxRuntime.jsx(FormattedNumber,{value:(g==null?void 0:g.Over0)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:Calendar$1},{label:"31 - 45 Days",value:jsxRuntime.jsx(FormattedNumber,{value:(g==null?void 0:g.Over30)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CalendarDays},{label:"45+ Days",value:jsxRuntime.jsx(FormattedNumber,{value:(g==null?void 0:g.Over45)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CalendarRange},{label:"Total",value:jsxRuntime.jsx(FormattedNumber,{value:(g==null?void 0:g.Total)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:DollarSign},{label:"Credit Limit",value:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(FormattedNumber,{value:b||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),d&&jsxRuntime.jsx(Button$1,{size:"icon",variant:"outline",className:"ml-2",onClick:()=>{te(!0),V((b==null?void 0:b.toString())||"")},children:jsxRuntime.jsx(SquarePen,{})})]}),icon:CreditCard}],[Oe]=useLazyGetV4ResellerByRouteResellerIdDocumentAndDocumentNumberPdfQuery(),Ne=async je=>{je?S(!0):C(!0);try{const qe=(await Oe({routeResellerId:e,documentNumber:`ST${e}`})).data;if(!qe)throw new Error("No data received for download.");if(je)window.open(qe);else{const Ve=document.createElement("a");Ve.href=qe,Ve.download=`ST${e}.pdf`,document.body.appendChild(Ve),Ve.click(),Ve.remove()}f({title:"Success",description:"Statement downloaded successfully.",variant:"success"})}catch(Be){console.error("Download Error:",Be),f({title:"Error",description:"An error occurred while downloading the statement. Please try again.",variant:"destructive"})}finally{je?S(!1):C(!1)}},[oe]=usePostV4ResellerByRouteResellerIdDocumentStatementEmailMutation(),$e=async()=>{if(!j||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(j)){f({title:"Invalid Email",description:"Please enter a valid email address.",variant:"destructive"});return}A(!0);try{await oe({routeResellerId:e,emailAddress:j}).unwrap(),f({title:"Success",description:`Statement sent to ${j} successfully.`,variant:"success"}),I(!1)}catch(Be){console.error("Send Email Error:",Be),f({title:"Error",description:"An error occurred while sending the statement. Please try again.",variant:"destructive"})}finally{A(!1)}};if(n)return jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{className:"border-b p-6 md:p-5",children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-36"})}),jsxRuntime.jsxs(CardContent,{className:"p-6 md:p-5",children:[jsxRuntime.jsxs("div",{className:"grid sm:grid-cols-2 sm:divide-x divide-border",children:[jsxRuntime.jsx("div",{className:"space-y-6 sm:pe-4",children:[1,2,3].map(je=>jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"})]}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 ms-auto"})]},je))}),jsxRuntime.jsx("div",{className:"space-y-6 sm:ps-4 pt-6 sm:pt-0 mt-6 sm:mt-0 border-t sm:border-t-0 border-border",children:[1,2].map(je=>jsxRuntime.jsx("div",{className:je===2?"pt-6 mt-6 border-t border-border":"",children:jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"})]}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 ms-auto"})]})},je))})]}),jsxRuntime.jsxs("div",{className:"flex justify-end mt-6 gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-28"})]})]})]});const Ae=!o;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{className:"border-b p-6 md:p-5",children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Billing Overview"})}),jsxRuntime.jsxs(CardContent,{className:"p-6 md:p-5",children:[jsxRuntime.jsxs("div",{className:"grid sm:grid-cols-2 sm:divide-x divide-border",children:[jsxRuntime.jsx("div",{className:"space-y-6 sm:pe-4",children:se.slice(0,3).map((je,Be)=>jsxRuntime.jsx(BillingItem,{icon:je.icon,label:je.label,value:je.value},Be))}),jsxRuntime.jsx("div",{className:"space-y-6 sm:ps-4 pt-6 sm:pt-0 mt-6 sm:mt-0 border-t sm:border-t-0 border-border",children:se.slice(3).map((je,Be)=>jsxRuntime.jsx("div",{className:Be===1?"pt-6 mt-6 border-t border-border":"",children:jsxRuntime.jsx(BillingItem,{icon:je.icon,label:je.label,value:je.value})},Be))})]}),Ae&&jsxRuntime.jsxs("div",{className:"flex justify-end mt-6 gap-2",children:[jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"outline",size:"icon",onClick:()=>Ne(!0),disabled:_,children:_?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Printer,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Print Statement"})})]})}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"outline",size:"icon",onClick:()=>Ne(!1),disabled:R,children:R?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Download,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Download Statement"})})]})}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"outline",size:"icon",onClick:()=>I(!0),disabled:E,children:E?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Mail,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Email Statement"})})]})}),jsxRuntime.jsx(reactRouterDom.Link,{to:`${window.location.hostname==="dashboard.randmar.io"?"":"https://dashboard.randmar.io"}/${e}/PayInvoice`,target:window.location.hostname==="dashboard.randmar.io"?"_self":"_blank",children:jsxRuntime.jsxs(Button$1,{children:[jsxRuntime.jsx(CreditCard,{className:"mr-2 h-4 w-4"}),"Pay Invoices"]})})]})]})]}),jsxRuntime.jsx(Dialog,{open:M,onOpenChange:I,children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Send Statement by Email"}),jsxRuntime.jsx(DialogDescription,{children:"Enter the recipient's email address below. The statement will be sent as a PDF attachment."})]}),jsxRuntime.jsx("div",{className:"grid gap-4 py-4",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",className:"text-right",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",type:"email",value:j,onChange:je=>q(je.target.value),className:"col-span-3",placeholder:"recipient@example.com"})]})}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button$1,{type:"submit",onClick:$e,disabled:E||!j,children:E?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Send,{className:"mr-2 h-4 w-4"}),"Send"]})})})]})}),jsxRuntime.jsx(Dialog,{open:Q,onOpenChange:te,children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Edit Credit Limit"}),jsxRuntime.jsx(DialogDescription,{children:"Enter the new credit limit for this reseller."})]}),jsxRuntime.jsx("div",{className:"grid gap-4 py-4",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"creditLimit",className:"text-right",children:"Amount"}),jsxRuntime.jsx(Input,{id:"creditLimit",type:"number",value:F,onChange:je=>V(je.target.value),className:"col-span-3",placeholder:"0.00"})]})}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button$1,{type:"submit",onClick:async()=>{const je=Number(F);if(isNaN(je)){f({title:"Invalid Amount",description:"Please enter a valid number for credit limit.",variant:"destructive"});return}try{await ne({applicationId:e,newValue:je}).unwrap(),te(!1),f({title:"Success",description:"Credit limit updated successfully.",variant:"success"})}catch(Be){console.error("Update Credit Limit Error:",Be),f({title:"Error",description:"Failed to update credit limit. Please try again.",variant:"destructive"})}},disabled:ae,children:ae?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})})]})})]})}function BillingItem({icon:e,label:t,value:n}){return jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(e,{className:"size-4 text-muted-foreground"}),jsxRuntime.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:t})]}),jsxRuntime.jsx("span",{className:"text-base font-semibold ms-auto",children:n})]})}function ChangePricingTierModal({open:e,setOpen:t,tier:n,onTierChange:o,isLoading:l}){const d=()=>{t(!1)};return jsxRuntime.jsx(Dialog,{open:e,onOpenChange:t,children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsx(DialogTitle,{children:"Change Pricing Tier"})}),jsxRuntime.jsxs("div",{className:"grid gap-1.5 py-2",children:[jsxRuntime.jsxs("p",{className:"text-lg text-muted-foreground",children:["Requested Pricing Tier: ",jsxRuntime.jsx("span",{className:"font-bold",children:n})]}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"If your account qualifies, your pricing will update immediately."}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"If not, we'll review your request and notify you of the decision."})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:d,disabled:l,children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:o,disabled:l,children:l?"Loading...":`Apply for ${n}`})]})]})})}const getPricingText=e=>e===1?"The Best":e===2?"Fixed 12.5% GP on all items":e===3?"Advantageous":e===4?"Buying Group":e===5?"Cost":e,getShippingText=e=>e==="A"?"Free or Custom":e==="B"?"Fixed $10 anywhere":e==="C"?`Free shipping on $150+ orders to your location,
|
|
1196
1196
|
$15 for drop shipped orders under $1,500,
|
|
1197
|
-
$10 with opportunities under $1,000`:e==="D"?"$15 under $1,500":e==="E"?"Full shipping charges":e,getTermsText=e=>e==="STRIPE"?"Credit card payment":e==="NET30"?"Net 30 days":e,AccountTier=({isSuperAdmin:e,readonly:t,reseller:n,appID:o,isLoading:l})=>{const{toast:d}=useToast(),[f,g]=React.useState(!1),[b,_]=React.useState(""),[S,{isLoading:R}]=usePostV4PartnerByApplicationIdAccountResellerAndFieldNameMutation(),C=je=>je&&{Starter:"starter","E-Commerce":"ecommerce",Commercial:"commercial",Basics:"cws",Novexco:"novexco",COOPSCO:"coopsco","Jean Coutu":"jeancoutu",Exclusive:"exclusive"}[je]||"",E=je=>je&&{A:"free",B:"fixed",C:"dropshipped",D:"under1500",E:"fullcharges"}[je]||"",A=je=>je&&{1:"exclusive",2:"ecommerce",3:"commercial",4:"buyinggroup",5:"cost"}[je]||"",[M,I]=React.useState(C((n==null?void 0:n.Priority)??"")),[j,q]=React.useState(E((n==null?void 0:n.ShippingProfile)??"")),[Q,te]=React.useState(A(n==null?void 0:n.PriceProfile)),F=je=>({starter:"Starter",ecommerce:"E-Commerce",commercial:"Commercial",cws:"Basics",novexco:"Novexco",coopsco:"COOPSCO",jeancoutu:"Jean Coutu",exclusive:"Exclusive"})[je]||je,V=je=>({free:"A",fixed:"B",dropshipped:"C",under1500:"D",fullcharges:"E"})[je]||je,ne=je=>({exclusive:"1",ecommerce:"2",commercial:"3",buyinggroup:"4",cost:"5"})[je]||je;React.useEffect(()=>{I(C((n==null?void 0:n.Priority)??"")),q(E((n==null?void 0:n.ShippingProfile)??"")),te(A(n==null?void 0:n.PriceProfile))},[n]);const ae=async(je,Be,qe,Ve)=>{try{(await S({applicationId:o,fieldName:je,newValue:Be})).error?d({title:"Error",description:Ve,variant:"destructive"}):d({title:"Success",description:qe,variant:"success"})}catch{d({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}},se=async je=>{I(je);const Be=F(je);ae("Priority",Be,`Priority updated to ${Be}`,"Failed to update priority")},Oe=async je=>{q(je);const Be=V(je);ae("ShippingProfile",Be,`Shipping profile updated to ${Be}`,"Failed to update shipping profile")},Ne=async je=>{te(je);const Be=ne(je);ae("PriceProfile",Be,`Pricing profile updated to ${Be}`,"Failed to update pricing profile")},oe=async()=>{try{const je=await S({applicationId:o,fieldName:"Tier",newValue:b});je.error?d({title:"Error",description:"Failed to update reseller",variant:"destructive"}):je.data?d({title:"Success",description:`Pricing Tier changed to ${b}`,variant:"success"}):d({title:"Considered",description:"Request being considered",variant:"success"})}catch{d({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}finally{g(!1),_("")}},$e=[{name:"Terms",enabled:n.Priority==="Starter"},{name:"E-Commerce",enabled:n.Priority==="Commercial"},{name:"Commercial",enabled:n.Priority==="E-Commerce"},{name:"Exclusive",enabled:e}],Ae=je=>{_(je),g(!0)};return l?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{className:"pb-2",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-28"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-16 rounded-full"})]})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsxs("div",{className:"mb-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-40 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-56"})]}),jsxRuntime.jsx("div",{className:"grid gap-3",children:[1,2,3].map(je=>jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full shrink-0"}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full"})]})]},je))}),jsxRuntime.jsxs("div",{className:"flex gap-2 mt-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{className:"pb-2 pt-4 px-4 flex flex-row items-center justify-between",children:[jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Account Tier"}),jsxRuntime.jsx(Badge,{variant:"secondary",className:"bg-green-100 text-green-700 hover:bg-green-200 text-xs",children:"Active"})]}),jsxRuntime.jsxs(CardContent,{className:"pt-2 px-4 pb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-3 bg-primary/5 p-4 rounded-lg",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("h3",{className:"text-lg font-bold text-primary",children:[(n==null?void 0:n.Priority)||""," Tier"]}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Optimized for online retail"})]}),jsxRuntime.jsx(CircleCheck,{className:"h-6 w-6 text-green-600"})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 gap-2 mb-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Package2,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Pricing"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground truncate",children:getPricingText(n.PriceProfile||0)})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Truck,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Shipping"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:getShippingText(n.ShippingProfile||"").split(".")[0]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Calendar$1,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Payment terms"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:getTermsText((n==null?void 0:n.Terms)||"")})]})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[!t&&jsxRuntime.jsx(Button$1,{variant:"outline",className:"flex-1",asChild:!0,children:jsxRuntime.jsxs(reactRouterDom.Link,{to:"https://randmar.io/pricing",target:"_blank",children:[jsxRuntime.jsx(ExternalLink,{className:"h-4 w-4 mr-1"}),"Pricing Tiers"]})}),jsxRuntime.jsxs(Popover,{children:[jsxRuntime.jsx(PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{disabled:t,className:t?"hidden":"flex-1",children:["Upgrade Tier ",jsxRuntime.jsx(ChevronRight,{className:"h-3 w-3 ml-1"})]})}),jsxRuntime.jsx(PopoverContent,{className:"w-56 p-2",children:jsxRuntime.jsxs("div",{className:"grid gap-1",children:[jsxRuntime.jsx("h4",{className:"font-medium text-xs mb-1",children:"Select a tier"}),$e.map(je=>jsxRuntime.jsx(Button$1,{variant:"ghost",size:"sm",className:"w-full justify-start h-8",disabled:!je.enabled,onClick:()=>Ae(je.name),children:je.name},je.name))]})})]})]})]})]}),jsxRuntime.jsx(ChangePricingTierModal,{isLoading:R,open:f,setOpen:g,tier:b,onTierChange:oe}),e&&!t&&jsxRuntime.jsxs(Card,{className:"mt-4",children:[jsxRuntime.jsx(CardHeader,{className:"pb-2 pt-3 px-4",children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Admin Configuration"})}),jsxRuntime.jsx(CardContent,{className:"pt-2 px-4 pb-4",children:jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Priority"}),jsxRuntime.jsx(RadioGroup$1,{value:M,onValueChange:se,className:"grid grid-cols-2 @sm:grid-cols-3 @md:grid-cols-4 gap-1",children:[{value:"starter",label:"Starter"},{value:"ecommerce",label:"E-Commerce"},{value:"commercial",label:"Commercial"},{value:"cws",label:"CWS (Basics)"},{value:"novexco",label:"Novexco"},{value:"coopsco",label:"COOPSCO"},{value:"jeancoutu",label:"Jean Coutu"},{value:"exclusive",label:"Exclusive"}].map(je=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:je.value,id:`priority-${je.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`priority-${je.value}`,className:"cursor-pointer text-xs",children:je.label})]},je.value))})]}),jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Shipping Profile"}),jsxRuntime.jsx(RadioGroup$1,{value:j,onValueChange:Oe,className:"grid grid-cols-1 @md:grid-cols-2 gap-1",children:[{value:"free",label:"Free (A)"},{value:"fixed",label:"Fixed $10 Shipping (B)"},{value:"dropshipped",label:"$15 for drop shipped (C)"},{value:"under1500",label:"15$ under 1,500 (D)"},{value:"fullcharges",label:"Full shipping charges (E)"}].map(je=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:je.value,id:`shipping-${je.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`shipping-${je.value}`,className:"cursor-pointer text-xs",children:je.label})]},je.value))})]}),jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Pricing Profile"}),jsxRuntime.jsx(RadioGroup$1,{value:Q,onValueChange:Ne,className:"grid grid-cols-2 @sm:grid-cols-3 gap-1",children:[{value:"exclusive",label:"Exclusive (1)"},{value:"ecommerce",label:"E-Commerce (2)"},{value:"commercial",label:"Commercial (3)"},{value:"buyinggroup",label:"Buying Group (4)"},{value:"cost",label:"Cost (5)"}].map(je=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:je.value,id:`pricing-${je.value}`,className:"h-6 w-6 scale-50 antialiased"}),jsxRuntime.jsx(Label$2,{htmlFor:`pricing-${je.value}`,className:"cursor-pointer text-xs",children:je.label})]},je.value))})]})]})})]})]})};function OrderCategories({openOrders:e=[],isLoading:t=!1}){const n=(e==null?void 0:e.filter(M=>M.DocumentType==="Order"))||[],o=(e==null?void 0:e.filter(M=>M.DocumentType==="Shipment"))||[],l=n.filter(M=>M.WarehouseCode!=="3PLE"),d=l.reduce((M,I)=>M+(I.Quantity??0),0),f=l.reduce((M,I)=>M+(I.ExtendedPrice??0),0),g=n.filter(M=>M.WarehouseCode==="3PLE"),b=g.reduce((M,I)=>M+(I.Quantity??0),0),_=g.reduce((M,I)=>M+(I.ExtendedPrice??0),0),S=o.reduce((M,I)=>M+(I.Quantity??0),0),R=o.reduce((M,I)=>M+(I.ExtendedPrice??0),0),C=d+b+S,E=f+_+R,A=[{name:"All",icon:Package,color:"bg-blue-500",orders:C,amount:E},{name:"Processing",icon:RefreshCcw,color:"bg-yellow-500",orders:d,amount:f},{name:"Shipped",icon:Truck,color:"bg-green-500",orders:S,amount:R},{name:"Delayed",icon:CircleAlert,color:"bg-red-500",orders:b,amount:_}];return t?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-7 w-40"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-3.5",children:[1,2,3,4].map(M=>jsxRuntime.jsx(Card,{className:"overflow-hidden rounded-md rounded-b-lg border-0 shadow-md",children:jsxRuntime.jsxs(CardContent,{className:"p-0",children:[jsxRuntime.jsx("div",{className:"bg-gray-200 h-[3px]"}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-12"})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]})]})]})},M))})})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Order Categories"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-3.5",children:A.map(M=>jsxRuntime.jsx(Card,{className:"overflow-hidden rounded-md rounded-b-lg border-0 shadow-md",children:jsxRuntime.jsxs(CardContent,{className:"p-0",children:[jsxRuntime.jsx("div",{className:`${M.color} bg-opacity-60 h-[3px]`}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-base",children:M.name}),jsxRuntime.jsx("div",{className:`${M.color} bg-opacity-90 p-2 rounded-full`,children:jsxRuntime.jsx(M.icon,{className:"size-4 shrink-0 text-white"})})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Orders"}),jsxRuntime.jsx("p",{className:"text-xl font-bold",children:M.orders})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Amount"}),jsxRuntime.jsx("p",{className:"text-base font-semibold",children:jsxRuntime.jsx(FormattedNumber,{value:M.amount,style:"currency",currency:"CAD",currencyDisplay:"symbol"})})]})]})]})]})},M.name))})})]})}function ReportsSection({isLoading:e,userEmail:t,appID:n}){const{toast:o}=useToast(),[l,{isLoading:d}]=usePostV4ResellerByRouteResellerIdReportWalmartTrackingFileEmailMutation(),[f,{isLoading:g}]=usePostV4ResellerByRouteResellerIdReportAmazonTrackingFileEmailMutation(),[b,{isLoading:_}]=usePostV4ResellerByRouteResellerIdReportOpenOrdersEmailMutation(),[S,{isLoading:R}]=usePostV4ResellerByRouteResellerIdReportProductsEmailMutation(),[C,{isLoading:E}]=usePostV4ResellerByRouteResellerIdReportInvoicesEmailMutation(),[A,{isLoading:M}]=usePostV4ResellerByRouteResellerIdDocumentStatementEmailMutation(),[I,j]=React.useState(null),[q,Q]=React.useState(t),[te,F]=React.useState(!1),[V,ne]=React.useState("all"),{data:ae,isLoading:se}=useGetV4PartnerByRouteApplicationIdManufacturersQuery({routeApplicationId:n,withSpecification:!1}),Oe=[{name:"Products",reports:[{id:"Products",title:"Universal Product List",description:"A comprehensive overview of your product list with detailed specifications and pricing information.",icon:Package}]},{name:"Operation Details",reports:[{id:"OpenOrders",title:"Order Details",description:"A detailed report of all your orders and shipments, including status, tracking information, and delivery estimates.",icon:ShoppingCart},{id:"Invoices",title:"Invoices and Credits Report",description:"Detailed overview of your invoices and credits within a specific date range. It also contains reports about additional charges, serial numbers, and other relevant information.",icon:ScrollText},{id:"Statement",title:"Statement and RMAs Report",description:"A detailed report of all unpaid invoices and active RMAs.",icon:Banknote}]},{name:"Tracking Files",reports:[{id:"AmazonTrackingFile",title:"Amazon Tracking File",description:"Track products sold on Amazon marketplace with detailed sales and inventory information.",icon:ChartNoAxesColumnIncreasing},{id:"WalmartTrackingFile",title:"Walmart Tracking File",description:"Track products sold on Walmart marketplace with detailed sales and inventory information.",icon:ChartNoAxesColumnIncreasing}]}],Ne=async Ae=>{j(Ae),Ae.id==="Products"&&ne("all"),F(!0)},oe=async()=>{if(!(!I||!n))try{switch(I.id){case"Products":{const Ae={routeResellerId:n,emailAddress:q};V&&V!=="all"&&(Ae.manufacturerId=V),await S(Ae).unwrap();break}case"AmazonTrackingFile":await f({routeResellerId:n,emailAddress:q}).unwrap();break;case"WalmartTrackingFile":await l({routeResellerId:n,emailAddress:q}).unwrap();break;case"OpenOrders":await b({routeResellerId:n,emailAddress:q}).unwrap();break;case"Invoices":await C({routeResellerId:n,emailAddress:q}).unwrap();break;case"Statement":await A({routeResellerId:n,emailAddress:q}).unwrap();break;default:throw new Error("invalid report id")}o({title:"Report requested",description:`The ${I.title} will be sent to ${q} shortly.`,variant:"success"}),F(!1)}catch(Ae){console.error("Error requesting report:",Ae),o({title:"Error",description:"Failed to request report. Please try again.",variant:"destructive"})}},$e=_||R||g||d||M||E;return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Reports"}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"Download essential business reports, from your Product List to your Order Details."})]}),jsxRuntime.jsx(CardContent,{className:"space-y-6",children:e?jsxRuntime.jsx(jsxRuntime.Fragment,{children:[1,2,3].map(Ae=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-48"}),[1,2].map(je=>jsxRuntime.jsxs("div",{className:"flex items-start gap-4 p-4 border rounded-lg",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-9 rounded-full"}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full"})]}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"})]},je))]},Ae))}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:Oe.map(Ae=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold",children:Ae.name}),Ae.reports.map(je=>jsxRuntime.jsxs("div",{className:"flex items-start gap-4 p-4 border rounded-lg hover:bg-gray-100 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-2 rounded-full",children:jsxRuntime.jsx(je.icon,{className:"h-5 w-5 text-primary"})}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("h4",{className:"font-semibold text-sm",children:je.title}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:je.description})]}),jsxRuntime.jsxs(Button$1,{variant:"outline",size:"sm",className:"flex items-center gap-1",onClick:()=>Ne(je),children:[jsxRuntime.jsx(Download,{className:"h-4 w-4"}),"Request"]})]},je.id))]},Ae.name))})}),jsxRuntime.jsx(Dialog,{open:te,onOpenChange:F,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsxs(DialogTitle,{children:["Request ",I==null?void 0:I.title]}),jsxRuntime.jsx(DialogDescription,{children:"Enter the email address where you would like to receive the report."})]}),jsxRuntime.jsxs("div",{className:"py-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",value:q,onChange:Ae=>Q(Ae.target.value),placeholder:"your@email.com",className:"mt-2"})]}),(I==null?void 0:I.id)==="Products"&&jsxRuntime.jsxs("div",{className:"py-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"manufacturer",children:"Manufacturer"}),jsxRuntime.jsxs("select",{id:"manufacturer",className:"mt-2 block w-full rounded-md border border-input bg-background px-3 py-2 text-sm",value:V,onChange:Ae=>ne(Ae.target.value),disabled:se,children:[jsxRuntime.jsx("option",{value:"all",children:"All manufacturers"}),!se&&Array.isArray(ae)&&ae.slice().sort((Ae,je)=>(Ae.PublicName||Ae.Name||"").localeCompare(je.PublicName||je.Name||"")).map(Ae=>Ae!=null&&Ae.ManufacturerId?jsxRuntime.jsx("option",{value:Ae.ManufacturerId,children:(Ae.PublicName||Ae.Name||Ae.ManufacturerId)+(Ae.OpenToWork?" (Open to Work)":"")},Ae.ManufacturerId):null)]})]}),jsxRuntime.jsx(DialogDescription,{children:"The report will take around 5 minutes to generate."}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>F(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:oe,disabled:!q||$e,children:$e?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Report"})]})]})})]})}function QualificationBadge({qualification:e}){return!e.QualificationId||e.QualificationId==="Suspended"?null:e.QualificationId==="Do Not Sell"?jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs(Badge,{variant:"destructive",children:[jsxRuntime.jsx(X$1,{className:"h-3 w-3 mr-1"}),"Do Not Sell"]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Qualification"})})]})}):jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs(Badge,{variant:"info",className:e.DefaultOpportunityNumber?"pr-1":"",children:[jsxRuntime.jsx(BadgeCheck,{className:"h-3 w-3 mr-1"}),e.QualificationId,e.DefaultOpportunityNumber&&jsxRuntime.jsx(Badge,{variant:"secondary",size:"sm",className:"ml-1",children:e.DefaultOpportunityNumber})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Qualification"})})]})})}function SalesChart({statistics:e,mode:t="month",chartHeight:n,loading:o=!1,size:l="default"}){const[d,f]=React.useState([]),[g,b]=React.useState(!1),_=[{name:"dollarVolume",label:"Dollar Volume",color:"var(--primary)",yAxisId:"left",format:"money"},{name:"unitsSold",label:"Units Sold",color:"#888",units:" units",yAxisId:"right",format:"integer"}];return React.useEffect(()=>{if(o||!e){f([]);return}let S=[];if(t==="week"){const R=new Map;e.forEach(C=>{var A;const E=((A=C.Day)==null?void 0:A.toString())||"";if(E.length===8){const M=parseInt(E.substring(0,4),10),I=parseInt(E.substring(4,6),10)-1,j=parseInt(E.substring(6,8),10),q=new Date(M,I,j),Q=new Date(q);Q.setDate(q.getDate()-q.getDay());const te=`${Q.getFullYear()}-${String(Q.getMonth()+1).padStart(2,"0")}-${String(Q.getDate()).padStart(2,"0")}`,F=R.get(te)||{price:0,quantity:0};F.price+=C.ExtendedPrice||0,F.quantity+=C.Quantity||0,R.set(te,F)}}),S=Array.from(R).sort(([C],[E])=>C.localeCompare(E)).map(([C,E])=>({date:`${C.substring(5,7)}/${C.substring(8,10)}`,dollarVolume:E.price,unitsSold:E.quantity}))}else{const R=new Date,C=R.getFullYear(),E=R.getMonth(),A=R.getDate(),M=`${C}-${(E+1).toString().padStart(2,"0")}`,I=Array.from({length:12},(q,Q)=>{const te=new Date(C,E-(11-Q),1);return`${te.getFullYear()}-${(te.getMonth()+1).toString().padStart(2,"0")}`}),j=Object.fromEntries(I.map(q=>[q,{price:0,quantity:0}]));if(e.forEach(q=>{const Q=String(q.Day??0);if(Q.length!==8)return;const te=`${Q.substring(0,4)}-${Q.substring(4,6)}`;j[te]&&(j[te].price+=q.ExtendedPrice??0,j[te].quantity+=q.Quantity??0)}),S=I.map(q=>{const Q=j[q],[te,F]=q.split("-").map(Number);return{date:new Date(te,F-1).toLocaleString("default",{month:"short",year:"numeric"}),dollarVolume:Q.price,unitsSold:Q.quantity}}),g){const q=j[M];if(q&&q.price>0&&A>0){const Q=new Date(C,E+1,0).getDate();if(A<Q){const te=q.price/A,F=q.quantity/A,V=te*Q,ne=F*Q,ae=S[S.length-1];ae&&(ae.dollarVolume=V,ae.unitsSold=ne)}}}}f(S)},[e,t,g,o]),o?jsxRuntime.jsx("div",{style:{height:n},children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-md"})}):d.length===0?jsxRuntime.jsx("div",{style:{height:n},className:"flex items-center justify-center text-muted-foreground",children:"No sales data available."}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(AreaChart,{data:d,series:_,height:n,size:l}),l==="default"&&t==="month"&&jsxRuntime.jsxs("div",{className:"mt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Switch,{checked:g,onCheckedChange:b,id:"extrapolate-switch"}),jsxRuntime.jsx(Label$2,{htmlFor:"extrapolate-switch",children:"Extrapolate Current Month"})]}),g&&jsxRuntime.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["* Values for ",new Date().toLocaleString("default",{month:"long"})," are projected estimates."]})]})]})}function PartnerCardHeader({type:e,applicationId:t,publicName:n,name:o,location:l,link:d,linkNewTab:f=!0,children:g}){const[b,_]=React.useState(!1),S=C=>{C.preventDefault(),C.stopPropagation(),navigator.clipboard.writeText(t),_(!0),setTimeout(()=>_(!1),2e3)},R=jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"h-12 w-12 overflow-hidden rounded-md",children:jsxRuntime.jsx(PartnerLogo,{id:t,width:48,height:48},`partner_logo_${t}`)}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs text-primary",children:e}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"|"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{delayDuration:300,children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex cursor-pointer items-center gap-1",onClick:S,children:[jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:t}),b?jsxRuntime.jsx(Check,{className:"h-3 w-3 text-green-500"}):jsxRuntime.jsx(Copy,{className:"h-3 w-3 text-muted-foreground"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:b?"Copied!":"Copy ID"})})]})})]}),jsxRuntime.jsx("h3",{className:"font-semibold",children:n||"N/A"}),o&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:o}),l&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:l})]})]}),g&&jsxRuntime.jsx("div",{className:"flex flex-col items-end gap-2",children:g})]});return d?jsxRuntime.jsx(reactRouterDom.Link,{to:d,target:f?"_blank":"_self",children:R}):R}function ManufacturerCard({manufacturer:e,link:t,linkNewTab:n=!0,actions:o,mainAction:l,loading:d=!1,appID:f}){var te,F,V;const{toast:g}=useToast(),[b,{isLoading:_}]=usePostV4ResellerByRouteResellerIdReportProductsEmailMutation(),[S,R]=React.useState(!1),[C,E]=React.useState(""),{data:A}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:f||""},{skip:!f}),M=A==null?void 0:A.IsReseller;if(d||!e)return jsxRuntime.jsxs(Card,{className:"flex flex-col h-full",children:[jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-12 rounded-md"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-24 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-40 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-48"})]})]}),jsxRuntime.jsx(Skeleton,{className:"h-16 w-24"})]}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex flex-col space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-16 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-14 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-40"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-36"})]})]})]})}),jsxRuntime.jsxs(CardFooter,{className:"flex justify-between pt-2 gap-2 mt-auto",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-40"})]})]});const I=[e.City,e.Province,e.Country].filter(Boolean),j=I.length>0?I.join(", "):"",q=((te=e.Tags)==null?void 0:te.split(",").map(ne=>ne.trim()).filter(Boolean))||[],Q=async()=>{if(!(!(e!=null&&e.ManufacturerId)||!f||!C))try{await b({routeResellerId:f,emailAddress:C,manufacturerId:e.ManufacturerId}).unwrap(),g({title:"Report requested",description:`The Universal Product List for this manufacturer will be sent to ${C} shortly.`,variant:"success"}),R(!1)}catch(ne){console.error("Error requesting product list:",ne),g({title:"Error",description:"Failed to request product list. Please try again.",variant:"destructive"})}};return jsxRuntime.jsxs(Card,{className:"manufacturer-theme flex flex-col h-full",children:[jsxRuntime.jsx(PartnerCardHeader,{type:"Manufacturer",applicationId:e.ManufacturerId,publicName:e.PublicName,name:e.Name,location:j,link:t,linkNewTab:n,children:jsxRuntime.jsx("div",{className:"flex flex-col items-end gap-2",children:e.SalesStatistics&&e.SalesStatistics.length>0&&jsxRuntime.jsx("div",{className:"h-16 w-24",children:jsxRuntime.jsx(SalesChart,{statistics:e.SalesStatistics,size:"mini"})})})}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex",children:[jsxRuntime.jsxs("div",{className:"flex flex-col flex-1 space-y-2",children:[(!!((F=e.Qualification)!=null&&F.QualificationId)&&((V=e.Qualification)==null?void 0:V.QualificationId)!=="Suspended"||!!e.OpenToWork||!!e.OnHold&&e.OnHold!==0||q.length>0)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(QualificationBadge,{qualification:e.Qualification??{}}),!!e.OpenToWork&&jsxRuntime.jsxs(Badge,{variant:"success",children:[jsxRuntime.jsx(HardHat,{className:"h-3 w-3 mr-1"}),"Open To Work"]}),!!e.OnHold&&e.OnHold!==0&&jsxRuntime.jsx(Badge,{variant:"warning",children:"On Hold"}),q.map((ne,ae)=>jsxRuntime.jsx(Badge,{variant:"outline",children:ne},ae))]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[e.Phone&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`tel:${e.Phone}`,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Phone,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.Phone})]}),e.PublicEmail&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`mailto:${e.PublicEmail}`,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Mail,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.PublicEmail})]}),e.Website&&jsxRuntime.jsxs(reactRouterDom.Link,{to:e.Website,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Globe,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.Website})]}),e.CurrencyCode&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(DollarSign,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.CurrencyCode})]})]})]}),e.SalesData&&jsxRuntime.jsxs("div",{className:"border-l pl-2 ml-2 flex flex-col text-sm",children:[jsxRuntime.jsx("strong",{className:"",children:"YTD"}),jsxRuntime.jsx("p",{children:e.SalesData.SalesYearToDay?formatMoney(e.SalesData.SalesYearToDay):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"3 mo."}),jsxRuntime.jsx("p",{children:e.SalesData.SalesLast3Months?formatMoney(e.SalesData.SalesLast3Months):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"30 days"}),jsxRuntime.jsx("p",{children:e.SalesData.SalesLast30Days?formatMoney(e.SalesData.SalesLast30Days):"—"})]})]})}),(o||l||e.PublicResourcesLink||M&&f&&e.ManufacturerId)&&jsxRuntime.jsxs(CardFooter,{className:"flex pt-2 gap-2 justify-between mt-auto",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[o&&o,M&&f&&e.ManufacturerId&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{size:"icon",onClick:()=>R(!0),disabled:_,children:_?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Download,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Email Product List"})})]})}),e.PublicResourcesLink&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:e.PublicResourcesLink,target:"_blank",children:jsxRuntime.jsx(Button$1,{size:"icon",children:jsxRuntime.jsx(HardDriveDownload,{className:"h-4 w-4"})})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Public Resources Link"})})]})})]}),l&&jsxRuntime.jsx("div",{children:l})]}),jsxRuntime.jsx(Dialog,{open:S,onOpenChange:R,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Request Universal Product List"}),jsxRuntime.jsx(DialogDescription,{children:"Enter the email address where you would like to receive the report."})]}),jsxRuntime.jsxs("div",{className:"py-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",value:C,onChange:ne=>E(ne.target.value),placeholder:"your@email.com",className:"mt-2"})]}),jsxRuntime.jsx(DialogDescription,{children:"The report will take around 5 minutes to generate."}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>R(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:Q,disabled:!C||_,children:_?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Report"})]})]})})]})}function ProductInventoryButton({applicationId:e,randmarSku:t,inventory:n,buttonSize:o="default",buttonClassName:l}){var Ne;const d=React.useRef(null),f=useIntersectionObserver({elementRef:d,threshold:.1,rootMargin:"100px",freezeOnceVisible:!0}),{toast:g}=useToast(),[b,_]=React.useState(!1),[S,R]=React.useState(!1),[C,E]=React.useState(!1),{data:A,isLoading:M,isFetching:I}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:e},{skip:!e||!f}),{data:j,isLoading:q,isFetching:Q}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:e,randmarSku:t,withSpecification:!1},{skip:!!n||!f}),[te]=usePutV4ResellerByRouteResellerIdProductAndRandmarSkuRequisitionMutation(),F=n??((Ne=j==null?void 0:j.Distribution)==null?void 0:Ne.Inventory);React.useEffect(()=>{_(!1)},[t]);const{inventoryQuantity:V,totalIncomingQuantity:ne}=React.useMemo(()=>{if(!F||F.length===0)return{inventoryQuantity:0,totalIncomingQuantity:0};const oe=F.reduce((Ae,je)=>Ae+(je.AvailableQuantity||0),0),$e=F.reduce((Ae,je)=>Ae+(je.PurchaseOrderQuantity||0),0);return{inventoryQuantity:oe,totalIncomingQuantity:$e}},[F]);if(M||I||q||Q)return jsxRuntime.jsx("div",{ref:d,children:jsxRuntime.jsx(Skeleton,{className:cn("h-10 w-36 rounded-md",l)})});const se=()=>{C||!(A!=null&&A.IsReseller)||(E(!0),te({routeResellerId:e??"",randmarSku:t??""}).then(oe=>{oe.error||oe.data===!1?g({title:"Warning",description:"Reorder is pending or requires manual approval. Contact the Randmar team for details.",variant:"warning"}):g({title:"Success",description:"Qualification successfully submitted.",variant:"success"}),R(!1)}).catch(oe=>{console.error(oe),g({title:"Error",description:"Error submitting your qualification.",variant:"destructive"})}).finally(()=>{E(!1)}))};if(!F)return jsxRuntime.jsx("div",{ref:d,children:jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx("span",{tabIndex:0,children:jsxRuntime.jsxs(Button$1,{disabled:!0,size:o,variant:"outline",className:cn("text-sm",l),children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),"No data"]})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"No inventory data could be found for this product."})})]})})});if(A!=null&&A.IsReseller&&V<=0&&ne<=0)return jsxRuntime.jsx("div",{ref:d,children:jsxRuntime.jsxs(Dialog,{open:S,onOpenChange:R,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{variant:"outline",size:o,className:cn("text-sm reseller-theme text-primary",l),children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),"Request to stock"]})}),jsxRuntime.jsxs(DialogContent,{className:"max-w-md",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsx(DialogTitle,{children:"Request to stock"})}),jsxRuntime.jsx("p",{className:"py-4",children:"Are you sure you want to request this product to be stocked?"}),jsxRuntime.jsxs("div",{className:"flex justify-end gap-2",children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>R(!1),disabled:C,children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:se,disabled:C,children:C?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin mr-2"}),"Requesting..."]}):"Confirm"})]})]})]})});const Oe=V<=0&&ne>0;return jsxRuntime.jsx("div",{ref:d,children:jsxRuntime.jsxs(Dialog,{open:b,onOpenChange:_,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{variant:"outline",size:o,className:cn("text-sm",Oe?"manufacturer-theme text-primary":V>0?"text-green-700":"text-red-700",l),children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),Oe?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[formatNumber(ne)," Incoming"]}):V>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[formatNumber(V)," in stock"]}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Out of stock"})]})}),jsxRuntime.jsxs(DialogContent,{className:"max-w-4xl",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsxs(DialogTitle,{className:"flex items-center",children:[jsxRuntime.jsx(Warehouse,{className:"mr-2",size:18}),"Inventory Information"]})}),jsxRuntime.jsx(ProductInventoryGrid,{inventory:F})]})]})})}function OrdersCard({applicationId:e,orders:t=null,loading:n=!1,title:o="Order Details"}){const l=React.useMemo(()=>[{accessorKey:"OrderNumber",header:"Order Number",cell:({row:g})=>g.original.OrderNumber?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/GeneralDocument/${g.original.OrderNumber}`,className:"font-medium text-primary hover:underline",children:g.original.OrderNumber})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for order ",g.original.OrderNumber]})})]})}):"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"DocumentNumber",header:"Document Number",cell:({row:g})=>g.original.DocumentNumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"DocumentDate",header:"Document Date",cell:({row:g})=>formatYYYYMMDDIntToDateString(g.original.DocumentDate),enableSorting:!0,enableFiltering:!1},{accessorKey:"PONumber",header:"PO Number",cell:({row:g})=>g.original.PONumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"WarehouseCode",header:"Warehouse",cell:({row:g})=>g.original.WarehouseCode??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"MPN",header:"MPN",cell:({row:g})=>g.original.MPN?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/Product/${g.original.MPN}`,className:"font-medium text-primary hover:underline",children:g.original.MPN})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for MPN ",g.original.MPN]})})]})}):"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:g})=>g.original.Quantity??"N/A",enableSorting:!0,enableFiltering:!1},{accessorKey:"ShipToName",header:"Name",cell:({row:g})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:g.original.ShipToName??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"UnitPrice",header:"Unit Price",cell:({row:g})=>g.original.UnitPrice?formatMoney(g.original.UnitPrice):"N/A",enableSorting:!0,enableFiltering:!1},{id:"actions",header:"Actions",cell:({row:g})=>jsxRuntime.jsx("div",{className:"flex space-x-2",children:jsxRuntime.jsx(ProductInventoryButton,{applicationId:e,randmarSku:g.original.RandmarSKU??"",buttonSize:"sm"})})}],[e]),d=React.useMemo(()=>{const g={};if(t){const b=Array.from(new Set(t.map(A=>A.WarehouseCode).filter(A=>A!=null)));g.WarehouseCode=b;const _=Array.from(new Set(t.map(A=>A.ShipToName).filter(A=>A!=null)));g.ShipToName=_;const S=Array.from(new Set(t.map(A=>A.DocumentNumber).filter(A=>A!=null)));g.DocumentNumber=S;const R=Array.from(new Set(t.map(A=>A.OrderNumber).filter(A=>A!=null)));g.OrderNumber=R;const C=Array.from(new Set(t.map(A=>A.PONumber).filter(A=>A!=null)));g.PONumber=C;const E=Array.from(new Set(t.map(A=>A.MPN).filter(A=>A!=null)));g.MPN=E}return g},[t]),f=t||[];return n?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-48"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:o})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:l,data:f,uniqueValues:d})})]})}function ResellerOverview({appID:e,reseller:t,readonly:n,userEmail:o,isSuperAdmin:l,withoutReports:d=!1}){var q,Q,te,F;const{data:f,isLoading:g,isError:b}=useGetV4PartnerByApplicationIdAccountResellerQuery({applicationId:e??"",withSpecification:!0},{skip:!!t}),[_,S]=React.useState({publicInfo:{hasUnsavedChanges:!1}}),R=React.useCallback(()=>n?!1:_.publicInfo.hasUnsavedChanges,[n,_]),C=React.useCallback((V,ne)=>{S(ae=>{var se;return((se=ae[V])==null?void 0:se.hasUnsavedChanges)!==ne.hasUnsavedChanges?{...ae,[V]:ne}:ae})},[]),{NavigationGuardDialog:E}=useRouterNavigationGuard(R),A=t??f,M=!n||!!(A!=null&&A.Statement)&&(A.Statement.Total??0)>0,I=(A==null?void 0:A.QualifiedManufacturers)??[],j=(A==null?void 0:A.Qualifications)??[];return jsxRuntime.jsxs("div",{className:"@container",children:[b?jsxRuntime.jsx(Card,{className:"p-6",children:jsxRuntime.jsxs(Alert,{variant:"destructive",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Error"}),jsxRuntime.jsx(AlertDescription,{children:"There was an error loading your reseller information. Please try again later."})]})}):jsxRuntime.jsxs("div",{className:"space-y-6 mb-6",children:[jsxRuntime.jsx(SalesSummary,{fiscalYearMonthStart:(A==null?void 0:A.FiscalYearMonthStart)||1,salesData:A==null?void 0:A.SalesData,isLoading:g}),jsxRuntime.jsxs("div",{className:"grid @lg:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChartCard,{statistics:(A==null?void 0:A.SalesStatistics)??[],loading:g}),jsxRuntime.jsx(OrderCategories,{openOrders:(A==null?void 0:A.ActiveOrderDetails)??[],isLoading:g}),M&&jsxRuntime.jsx(BillingCard,{appID:e,reseller:A||{},withoutReports:d,isLoading:g,userEmail:o,isSuperAdmin:l}),jsxRuntime.jsx(PublicInfo,{reseller:A||{},appID:e??"",isLoading:g,readonly:n,onUnsavedChanges:V=>C("publicInfo",{hasUnsavedChanges:V})}),jsxRuntime.jsx(AccountTier,{isSuperAdmin:l,readonly:n,reseller:A||{},appID:e??"",isLoading:g})]}),g||I.length>0?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Manufacturers you are qualified for"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid @lg:grid-cols-2 gap-4",children:g?Array.from({length:2}).map((V,ne)=>jsxRuntime.jsx(ManufacturerCard,{loading:!0},ne)):I.map(V=>jsxRuntime.jsx(ManufacturerCard,{manufacturer:V,link:`https://dashboard.randmar.io/${e}/Partner/${V.ManufacturerId}`},V.ManufacturerId))})})]}):j.length>0&&jsxRuntime.jsx(ResellerQualificationsCard,{qualifications:j}),(((q=A==null?void 0:A.Opportunities)==null?void 0:q.length)??0)>0&&jsxRuntime.jsx(OpportunitiesTable,{applicationId:e,opportunities:A==null?void 0:A.Opportunities,loading:g}),(((Q=A==null?void 0:A.ActiveOrderDetails)==null?void 0:Q.length)??0)>0&&jsxRuntime.jsx(OrdersCard,{applicationId:e,title:"Active Orders",orders:A==null?void 0:A.ActiveOrderDetails,loading:g}),(((te=A==null?void 0:A.CompletedOrderDetails)==null?void 0:te.length)??0)>0&&jsxRuntime.jsx(OrdersCard,{applicationId:e,title:"Completed Orders",orders:A==null?void 0:A.CompletedOrderDetails,loading:g}),(((F=A==null?void 0:A.Returns)==null?void 0:F.length)??0)>0&&jsxRuntime.jsx(ReturnsTable,{applicationId:e,returns:A==null?void 0:A.Returns,loading:g}),!d&&jsxRuntime.jsx(ReportsSection,{appID:e,userEmail:o,isLoading:g})]}),jsxRuntime.jsx(E,{})]})}const alertVariants=cva("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",success:"border-green-500/50 bg-green-50 text-green-700 dark:border-green-500 dark:bg-green-950 dark:text-green-400 [&>svg]:text-green-500",warning:"border-yellow-500/50 bg-yellow-50 text-yellow-700 dark:border-yellow-500 dark:bg-yellow-950 dark:text-yellow-400 [&>svg]:text-yellow-500",info:"border-blue-500/50 bg-blue-50 text-blue-700 dark:border-blue-500 dark:bg-blue-950 dark:text-blue-400 [&>svg]:text-blue-500"}},defaultVariants:{variant:"default"}}),Alert=React__namespace.forwardRef(({className:e,variant:t,...n},o)=>jsxRuntime.jsx("div",{ref:o,role:"alert",className:cn(alertVariants({variant:t}),e),...n}));Alert.displayName="Alert";const AlertTitle=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("h5",{ref:n,className:cn("mb-1 font-medium leading-none tracking-tight",e),...t}));AlertTitle.displayName="AlertTitle";const AlertDescription=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("text-sm [&_p]:leading-relaxed",e),...t}));AlertDescription.displayName="AlertDescription";/**
|
|
1197
|
+
$10 with opportunities under $1,000`:e==="D"?"$15 under $1,500":e==="E"?"Full shipping charges":e,getTermsText=e=>e==="STRIPE"?"Credit card payment":e==="NET30"?"Net 30 days":e,AccountTier=({isSuperAdmin:e,readonly:t,reseller:n,appID:o,isLoading:l})=>{const{toast:d}=useToast(),[f,g]=React.useState(!1),[b,_]=React.useState(""),[S,{isLoading:R}]=usePostV4PartnerByApplicationIdAccountResellerAndFieldNameMutation(),C=je=>je&&{Starter:"starter","E-Commerce":"ecommerce",Commercial:"commercial",Basics:"cws",Novexco:"novexco",COOPSCO:"coopsco","Jean Coutu":"jeancoutu",Exclusive:"exclusive"}[je]||"",E=je=>je&&{A:"free",B:"fixed",C:"dropshipped",D:"under1500",E:"fullcharges"}[je]||"",A=je=>je&&{1:"exclusive",2:"ecommerce",3:"commercial",4:"buyinggroup",5:"cost"}[je]||"",[M,I]=React.useState(C((n==null?void 0:n.Priority)??"")),[j,q]=React.useState(E((n==null?void 0:n.ShippingProfile)??"")),[Q,te]=React.useState(A(n==null?void 0:n.PriceProfile)),F=je=>({starter:"Starter",ecommerce:"E-Commerce",commercial:"Commercial",cws:"Basics",novexco:"Novexco",coopsco:"COOPSCO",jeancoutu:"Jean Coutu",exclusive:"Exclusive"})[je]||je,V=je=>({free:"A",fixed:"B",dropshipped:"C",under1500:"D",fullcharges:"E"})[je]||je,ne=je=>({exclusive:"1",ecommerce:"2",commercial:"3",buyinggroup:"4",cost:"5"})[je]||je;React.useEffect(()=>{I(C((n==null?void 0:n.Priority)??"")),q(E((n==null?void 0:n.ShippingProfile)??"")),te(A(n==null?void 0:n.PriceProfile))},[n]);const ae=async(je,Be,qe,Ve)=>{try{(await S({applicationId:o,fieldName:je,newValue:Be})).error?d({title:"Error",description:Ve,variant:"destructive"}):d({title:"Success",description:qe,variant:"success"})}catch{d({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}},se=async je=>{I(je);const Be=F(je);ae("Priority",Be,`Priority updated to ${Be}`,"Failed to update priority")},Oe=async je=>{q(je);const Be=V(je);ae("ShippingProfile",Be,`Shipping profile updated to ${Be}`,"Failed to update shipping profile")},Ne=async je=>{te(je);const Be=ne(je);ae("PriceProfile",Be,`Pricing profile updated to ${Be}`,"Failed to update pricing profile")},oe=async()=>{try{const je=await S({applicationId:o,fieldName:"Tier",newValue:b});je.error?d({title:"Error",description:"Failed to update reseller",variant:"destructive"}):je.data?d({title:"Success",description:`Pricing Tier changed to ${b}`,variant:"success"}):d({title:"Considered",description:"Request being considered",variant:"success"})}catch{d({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}finally{g(!1),_("")}},$e=[{name:"Terms",enabled:n.Priority==="Starter"},{name:"E-Commerce",enabled:n.Priority==="Commercial"},{name:"Commercial",enabled:n.Priority==="E-Commerce"},{name:"Exclusive",enabled:e}],Ae=je=>{_(je),g(!0)};return l?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{className:"pb-2",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-28"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-16 rounded-full"})]})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsxs("div",{className:"mb-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-40 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-56"})]}),jsxRuntime.jsx("div",{className:"grid gap-3",children:[1,2,3].map(je=>jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full shrink-0"}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full"})]})]},je))}),jsxRuntime.jsxs("div",{className:"flex gap-2 mt-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{className:"pb-2 pt-4 px-4 flex flex-row items-center justify-between",children:[jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Account Tier"}),jsxRuntime.jsx(Badge,{variant:"secondary",className:"bg-green-100 text-green-700 hover:bg-green-200 text-xs",children:"Active"})]}),jsxRuntime.jsxs(CardContent,{className:"pt-2 px-4 pb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-3 bg-primary/5 p-4 rounded-lg",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("h3",{className:"text-lg font-bold text-primary",children:[(n==null?void 0:n.Priority)||""," Tier"]}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Optimized for online retail"})]}),jsxRuntime.jsx(CircleCheck,{className:"h-6 w-6 text-green-600"})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 gap-2 mb-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Package2,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Pricing"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground truncate",children:getPricingText(n.PriceProfile||0)})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Truck,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Shipping"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:getShippingText(n.ShippingProfile||"").split(".")[0]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Calendar$1,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Payment terms"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:getTermsText((n==null?void 0:n.Terms)||"")})]})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[!t&&jsxRuntime.jsx(Button$1,{variant:"outline",className:"flex-1",asChild:!0,children:jsxRuntime.jsxs(reactRouterDom.Link,{to:"https://randmar.io/pricing",target:"_blank",children:[jsxRuntime.jsx(ExternalLink,{className:"h-4 w-4 mr-1"}),"Pricing Tiers"]})}),jsxRuntime.jsxs(Popover,{children:[jsxRuntime.jsx(PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{disabled:t,className:t?"hidden":"flex-1",children:["Upgrade Tier ",jsxRuntime.jsx(ChevronRight,{className:"h-3 w-3 ml-1"})]})}),jsxRuntime.jsx(PopoverContent,{className:"w-56 p-2",children:jsxRuntime.jsxs("div",{className:"grid gap-1",children:[jsxRuntime.jsx("h4",{className:"font-medium text-xs mb-1",children:"Select a tier"}),$e.map(je=>jsxRuntime.jsx(Button$1,{variant:"ghost",size:"sm",className:"w-full justify-start h-8",disabled:!je.enabled,onClick:()=>Ae(je.name),children:je.name},je.name))]})})]})]})]})]}),jsxRuntime.jsx(ChangePricingTierModal,{isLoading:R,open:f,setOpen:g,tier:b,onTierChange:oe}),e&&!t&&jsxRuntime.jsxs(Card,{className:"mt-4",children:[jsxRuntime.jsx(CardHeader,{className:"pb-2 pt-3 px-4",children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Admin Configuration"})}),jsxRuntime.jsx(CardContent,{className:"pt-2 px-4 pb-4",children:jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Priority"}),jsxRuntime.jsx(RadioGroup$1,{value:M,onValueChange:se,className:"grid grid-cols-2 @sm:grid-cols-3 @md:grid-cols-4 gap-1",children:[{value:"starter",label:"Starter"},{value:"ecommerce",label:"E-Commerce"},{value:"commercial",label:"Commercial"},{value:"cws",label:"CWS (Basics)"},{value:"novexco",label:"Novexco"},{value:"coopsco",label:"COOPSCO"},{value:"jeancoutu",label:"Jean Coutu"},{value:"exclusive",label:"Exclusive"}].map(je=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:je.value,id:`priority-${je.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`priority-${je.value}`,className:"cursor-pointer text-xs",children:je.label})]},je.value))})]}),jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Shipping Profile"}),jsxRuntime.jsx(RadioGroup$1,{value:j,onValueChange:Oe,className:"grid grid-cols-1 @md:grid-cols-2 gap-1",children:[{value:"free",label:"Free (A)"},{value:"fixed",label:"Fixed $10 Shipping (B)"},{value:"dropshipped",label:"$15 for drop shipped (C)"},{value:"under1500",label:"15$ under 1,500 (D)"},{value:"fullcharges",label:"Full shipping charges (E)"}].map(je=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:je.value,id:`shipping-${je.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`shipping-${je.value}`,className:"cursor-pointer text-xs",children:je.label})]},je.value))})]}),jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Pricing Profile"}),jsxRuntime.jsx(RadioGroup$1,{value:Q,onValueChange:Ne,className:"grid grid-cols-2 @sm:grid-cols-3 gap-1",children:[{value:"exclusive",label:"Exclusive (1)"},{value:"ecommerce",label:"E-Commerce (2)"},{value:"commercial",label:"Commercial (3)"},{value:"buyinggroup",label:"Buying Group (4)"},{value:"cost",label:"Cost (5)"}].map(je=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:je.value,id:`pricing-${je.value}`,className:"h-6 w-6 scale-50 antialiased"}),jsxRuntime.jsx(Label$2,{htmlFor:`pricing-${je.value}`,className:"cursor-pointer text-xs",children:je.label})]},je.value))})]})]})})]})]})};function OrderCategories({openOrders:e=[],isLoading:t=!1}){const n=(e==null?void 0:e.filter(M=>M.DocumentType==="Order"))||[],o=(e==null?void 0:e.filter(M=>M.DocumentType==="Shipment"))||[],l=n.filter(M=>M.WarehouseCode!=="3PLE"),d=l.reduce((M,I)=>M+(I.Quantity??0),0),f=l.reduce((M,I)=>M+(I.ExtendedPrice??0),0),g=n.filter(M=>M.WarehouseCode==="3PLE"),b=g.reduce((M,I)=>M+(I.Quantity??0),0),_=g.reduce((M,I)=>M+(I.ExtendedPrice??0),0),S=o.reduce((M,I)=>M+(I.Quantity??0),0),R=o.reduce((M,I)=>M+(I.ExtendedPrice??0),0),C=d+b+S,E=f+_+R,A=[{name:"All",icon:Package,color:"bg-blue-500",orders:C,amount:E},{name:"Processing",icon:RefreshCcw,color:"bg-yellow-500",orders:d,amount:f},{name:"Shipped",icon:Truck,color:"bg-green-500",orders:S,amount:R},{name:"Delayed",icon:CircleAlert,color:"bg-red-500",orders:b,amount:_}];return t?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-7 w-40"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-3.5",children:[1,2,3,4].map(M=>jsxRuntime.jsx(Card,{className:"overflow-hidden rounded-md rounded-b-lg border-0 shadow-md",children:jsxRuntime.jsxs(CardContent,{className:"p-0",children:[jsxRuntime.jsx("div",{className:"bg-gray-200 h-[3px]"}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-12"})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]})]})]})},M))})})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Order Categories"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-3.5",children:A.map(M=>jsxRuntime.jsx(Card,{className:"overflow-hidden rounded-md rounded-b-lg border-0 shadow-md",children:jsxRuntime.jsxs(CardContent,{className:"p-0",children:[jsxRuntime.jsx("div",{className:`${M.color} bg-opacity-60 h-[3px]`}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-base",children:M.name}),jsxRuntime.jsx("div",{className:`${M.color} bg-opacity-90 p-2 rounded-full`,children:jsxRuntime.jsx(M.icon,{className:"size-4 shrink-0 text-white"})})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Orders"}),jsxRuntime.jsx("p",{className:"text-xl font-bold",children:M.orders})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Amount"}),jsxRuntime.jsx("p",{className:"text-base font-semibold",children:jsxRuntime.jsx(FormattedNumber,{value:M.amount,style:"currency",currency:"CAD",currencyDisplay:"symbol"})})]})]})]})]})},M.name))})})]})}function ReportsSection({isLoading:e,userEmail:t,appID:n}){const{toast:o}=useToast(),[l,{isLoading:d}]=usePostV4ResellerByRouteResellerIdReportWalmartTrackingFileEmailMutation(),[f,{isLoading:g}]=usePostV4ResellerByRouteResellerIdReportAmazonTrackingFileEmailMutation(),[b,{isLoading:_}]=usePostV4ResellerByRouteResellerIdReportOpenOrdersEmailMutation(),[S,{isLoading:R}]=usePostV4ResellerByRouteResellerIdReportProductsEmailMutation(),[C,{isLoading:E}]=usePostV4ResellerByRouteResellerIdReportInvoicesEmailMutation(),[A,{isLoading:M}]=usePostV4ResellerByRouteResellerIdDocumentStatementEmailMutation(),[I,j]=React.useState(null),[q,Q]=React.useState(t),[te,F]=React.useState(!1),[V,ne]=React.useState("all"),{data:ae,isLoading:se}=useGetV4PartnerByRouteApplicationIdManufacturersQuery({routeApplicationId:n,withSpecification:!1}),Oe=[{name:"Products",reports:[{id:"Products",title:"Universal Product List",description:"A comprehensive overview of your product list with detailed specifications and pricing information.",icon:Package}]},{name:"Operation Details",reports:[{id:"OpenOrders",title:"Order Details",description:"A detailed report of all your orders and shipments, including status, tracking information, and delivery estimates.",icon:ShoppingCart},{id:"Invoices",title:"Invoices and Credits Report",description:"Detailed overview of your invoices and credits within a specific date range. It also contains reports about additional charges, serial numbers, and other relevant information.",icon:ScrollText},{id:"Statement",title:"Statement and RMAs Report",description:"A detailed report of all unpaid invoices and active RMAs.",icon:Banknote}]},{name:"Tracking Files",reports:[{id:"AmazonTrackingFile",title:"Amazon Tracking File",description:"Track products sold on Amazon marketplace with detailed sales and inventory information.",icon:ChartNoAxesColumnIncreasing},{id:"WalmartTrackingFile",title:"Walmart Tracking File",description:"Track products sold on Walmart marketplace with detailed sales and inventory information.",icon:ChartNoAxesColumnIncreasing}]}],Ne=async Ae=>{j(Ae),Ae.id==="Products"&&ne("all"),F(!0)},oe=async()=>{if(!(!I||!n))try{switch(I.id){case"Products":{const Ae={routeResellerId:n,emailAddress:q};V&&V!=="all"&&(Ae.manufacturerId=V),await S(Ae).unwrap();break}case"AmazonTrackingFile":await f({routeResellerId:n,emailAddress:q}).unwrap();break;case"WalmartTrackingFile":await l({routeResellerId:n,emailAddress:q}).unwrap();break;case"OpenOrders":await b({routeResellerId:n,emailAddress:q}).unwrap();break;case"Invoices":await C({routeResellerId:n,emailAddress:q}).unwrap();break;case"Statement":await A({routeResellerId:n,emailAddress:q}).unwrap();break;default:throw new Error("invalid report id")}o({title:"Report requested",description:`The ${I.title} will be sent to ${q} shortly.`,variant:"success"}),F(!1)}catch(Ae){console.error("Error requesting report:",Ae),o({title:"Error",description:"Failed to request report. Please try again.",variant:"destructive"})}},$e=_||R||g||d||M||E;return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Reports"}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"Download essential business reports, from your Product List to your Order Details."})]}),jsxRuntime.jsx(CardContent,{className:"space-y-6",children:e?jsxRuntime.jsx(jsxRuntime.Fragment,{children:[1,2,3].map(Ae=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-48"}),[1,2].map(je=>jsxRuntime.jsxs("div",{className:"flex items-start gap-4 p-4 border rounded-lg",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-9 rounded-full"}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full"})]}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"})]},je))]},Ae))}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:Oe.map(Ae=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold",children:Ae.name}),Ae.reports.map(je=>jsxRuntime.jsxs("div",{className:"flex items-start gap-4 p-4 border rounded-lg hover:bg-gray-100 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-2 rounded-full",children:jsxRuntime.jsx(je.icon,{className:"h-5 w-5 text-primary"})}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("h4",{className:"font-semibold text-sm",children:je.title}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:je.description})]}),jsxRuntime.jsxs(Button$1,{variant:"outline",size:"sm",className:"flex items-center gap-1",onClick:()=>Ne(je),children:[jsxRuntime.jsx(Download,{className:"h-4 w-4"}),"Request"]})]},je.id))]},Ae.name))})}),jsxRuntime.jsx(Dialog,{open:te,onOpenChange:F,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsxs(DialogTitle,{children:["Request ",I==null?void 0:I.title]}),jsxRuntime.jsx(DialogDescription,{children:"Enter the email address where you would like to receive the report."})]}),jsxRuntime.jsxs("div",{className:"py-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",value:q,onChange:Ae=>Q(Ae.target.value),placeholder:"your@email.com",className:"mt-2"})]}),(I==null?void 0:I.id)==="Products"&&jsxRuntime.jsxs("div",{className:"py-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"manufacturer",children:"Manufacturer"}),jsxRuntime.jsxs("select",{id:"manufacturer",className:"mt-2 block w-full rounded-md border border-input bg-background px-3 py-2 text-sm",value:V,onChange:Ae=>ne(Ae.target.value),disabled:se,children:[jsxRuntime.jsx("option",{value:"all",children:"All manufacturers"}),!se&&Array.isArray(ae)&&ae.slice().sort((Ae,je)=>(Ae.PublicName||Ae.Name||"").localeCompare(je.PublicName||je.Name||"")).map(Ae=>Ae!=null&&Ae.ManufacturerId?jsxRuntime.jsx("option",{value:Ae.ManufacturerId,children:(Ae.PublicName||Ae.Name||Ae.ManufacturerId)+(Ae.OpenToWork?" (Open to Work)":"")},Ae.ManufacturerId):null)]})]}),jsxRuntime.jsx(DialogDescription,{children:"The report will take around 5 minutes to generate."}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>F(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:oe,disabled:!q||$e,children:$e?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Report"})]})]})})]})}function QualificationBadge({qualification:e}){return!e.QualificationId||e.QualificationId==="Suspended"?null:e.QualificationId==="Do Not Sell"?jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs(Badge,{variant:"destructive",children:[jsxRuntime.jsx(X$1,{className:"h-3 w-3 mr-1"}),"Do Not Sell"]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Qualification"})})]})}):jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs(Badge,{variant:"info",className:e.DefaultOpportunityNumber?"pr-1":"",children:[jsxRuntime.jsx(BadgeCheck,{className:"h-3 w-3 mr-1"}),e.QualificationId,e.DefaultOpportunityNumber&&jsxRuntime.jsx(Badge,{variant:"secondary",size:"sm",className:"ml-1",children:e.DefaultOpportunityNumber})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Qualification"})})]})})}function SalesChart({statistics:e,mode:t="month",chartHeight:n,loading:o=!1,size:l="default"}){const[d,f]=React.useState([]),[g,b]=React.useState(!1),_=[{name:"dollarVolume",label:"Dollar Volume",color:"var(--primary)",yAxisId:"left",format:"money"},{name:"unitsSold",label:"Units Sold",color:"#888",units:" units",yAxisId:"right",format:"integer"}];return React.useEffect(()=>{if(o||!e){f([]);return}let S=[];if(t==="week"){const R=new Map;e.forEach(C=>{var A;const E=((A=C.Day)==null?void 0:A.toString())||"";if(E.length===8){const M=parseInt(E.substring(0,4),10),I=parseInt(E.substring(4,6),10)-1,j=parseInt(E.substring(6,8),10),q=new Date(M,I,j),Q=new Date(q);Q.setDate(q.getDate()-q.getDay());const te=`${Q.getFullYear()}-${String(Q.getMonth()+1).padStart(2,"0")}-${String(Q.getDate()).padStart(2,"0")}`,F=R.get(te)||{price:0,quantity:0};F.price+=C.ExtendedPrice||0,F.quantity+=C.Quantity||0,R.set(te,F)}}),S=Array.from(R).sort(([C],[E])=>C.localeCompare(E)).map(([C,E])=>({date:`${C.substring(5,7)}/${C.substring(8,10)}`,dollarVolume:E.price,unitsSold:E.quantity}))}else{const R=new Date,C=R.getFullYear(),E=R.getMonth(),A=R.getDate(),M=`${C}-${(E+1).toString().padStart(2,"0")}`,I=Array.from({length:12},(q,Q)=>{const te=new Date(C,E-(11-Q),1);return`${te.getFullYear()}-${(te.getMonth()+1).toString().padStart(2,"0")}`}),j=Object.fromEntries(I.map(q=>[q,{price:0,quantity:0}]));if(e.forEach(q=>{const Q=String(q.Day??0);if(Q.length!==8)return;const te=`${Q.substring(0,4)}-${Q.substring(4,6)}`;j[te]&&(j[te].price+=q.ExtendedPrice??0,j[te].quantity+=q.Quantity??0)}),S=I.map(q=>{const Q=j[q],[te,F]=q.split("-").map(Number);return{date:new Date(te,F-1).toLocaleString("default",{month:"short",year:"numeric"}),dollarVolume:Q.price,unitsSold:Q.quantity}}),g){const q=j[M];if(q&&q.price>0&&A>0){const Q=new Date(C,E+1,0).getDate();if(A<Q){const te=q.price/A,F=q.quantity/A,V=te*Q,ne=F*Q,ae=S[S.length-1];ae&&(ae.dollarVolume=V,ae.unitsSold=ne)}}}}f(S)},[e,t,g,o]),o?jsxRuntime.jsx("div",{style:{height:n},children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-md"})}):d.length===0?jsxRuntime.jsx("div",{style:{height:n},className:"flex items-center justify-center text-muted-foreground",children:"No sales data available."}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(AreaChart,{data:d,series:_,height:n,size:l}),l==="default"&&t==="month"&&jsxRuntime.jsxs("div",{className:"mt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Switch,{checked:g,onCheckedChange:b,id:"extrapolate-switch"}),jsxRuntime.jsx(Label$2,{htmlFor:"extrapolate-switch",children:"Extrapolate Current Month"})]}),g&&jsxRuntime.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["* Values for ",new Date().toLocaleString("default",{month:"long"})," are projected estimates."]})]})]})}function PartnerCardHeader({type:e,applicationId:t,publicName:n,name:o,location:l,link:d,linkNewTab:f=!0,children:g}){const[b,_]=React.useState(!1),S=C=>{C.preventDefault(),C.stopPropagation(),navigator.clipboard.writeText(t),_(!0),setTimeout(()=>_(!1),2e3)},R=jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"h-12 w-12 overflow-hidden rounded-md",children:jsxRuntime.jsx(PartnerLogo,{id:t,width:48,height:48},`partner_logo_${t}`)}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs text-primary",children:e}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"|"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{delayDuration:300,children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex cursor-pointer items-center gap-1",onClick:S,children:[jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:t}),b?jsxRuntime.jsx(Check,{className:"h-3 w-3 text-green-500"}):jsxRuntime.jsx(Copy,{className:"h-3 w-3 text-muted-foreground"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:b?"Copied!":"Copy ID"})})]})})]}),jsxRuntime.jsx("h3",{className:"font-semibold",children:n||"N/A"}),o&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:o}),l&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:l})]})]}),g&&jsxRuntime.jsx("div",{className:"flex flex-col items-end gap-2",children:g})]});return d?jsxRuntime.jsx(reactRouterDom.Link,{to:d,target:f?"_blank":"_self",children:R}):R}function ManufacturerCard({manufacturer:e,link:t,linkNewTab:n=!0,actions:o,mainAction:l,loading:d=!1,appID:f}){var te,F,V;const{toast:g}=useToast(),[b,{isLoading:_}]=usePostV4ResellerByRouteResellerIdReportProductsEmailMutation(),[S,R]=React.useState(!1),[C,E]=React.useState(""),{data:A}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:f||""},{skip:!f}),M=A==null?void 0:A.IsReseller;if(d||!e)return jsxRuntime.jsxs(Card,{className:"flex flex-col h-full",children:[jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-12 rounded-md"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-24 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-40 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-48"})]})]}),jsxRuntime.jsx(Skeleton,{className:"h-16 w-24"})]}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex flex-col space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-16 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-14 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-40"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-36"})]})]})]})}),jsxRuntime.jsxs(CardFooter,{className:"flex justify-between pt-2 gap-2 mt-auto",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-40"})]})]});const I=[e.City,e.Province,e.Country].filter(Boolean),j=I.length>0?I.join(", "):"",q=((te=e.Tags)==null?void 0:te.split(",").map(ne=>ne.trim()).filter(Boolean))||[],Q=async()=>{if(!(!(e!=null&&e.ManufacturerId)||!f||!C))try{await b({routeResellerId:f,emailAddress:C,manufacturerId:e.ManufacturerId}).unwrap(),g({title:"Report requested",description:`The Universal Product List for this manufacturer will be sent to ${C} shortly.`,variant:"success"}),R(!1)}catch(ne){console.error("Error requesting product list:",ne),g({title:"Error",description:"Failed to request product list. Please try again.",variant:"destructive"})}};return jsxRuntime.jsxs(Card,{className:"manufacturer-theme flex flex-col h-full",children:[jsxRuntime.jsx(PartnerCardHeader,{type:"Manufacturer",applicationId:e.ManufacturerId,publicName:e.PublicName,name:e.Name,location:j,link:t,linkNewTab:n,children:jsxRuntime.jsx("div",{className:"flex flex-col items-end gap-2",children:e.SalesStatistics&&e.SalesStatistics.length>0&&jsxRuntime.jsx("div",{className:"h-16 w-24",children:jsxRuntime.jsx(SalesChart,{statistics:e.SalesStatistics,size:"mini"})})})}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex",children:[jsxRuntime.jsxs("div",{className:"flex flex-col flex-1 space-y-2",children:[(!!((F=e.Qualification)!=null&&F.QualificationId)&&((V=e.Qualification)==null?void 0:V.QualificationId)!=="Suspended"||!!e.OpenToWork||!!e.OnHold&&e.OnHold!==0||q.length>0)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(QualificationBadge,{qualification:e.Qualification??{}}),!!e.OpenToWork&&jsxRuntime.jsxs(Badge,{variant:"success",children:[jsxRuntime.jsx(HardHat,{className:"h-3 w-3 mr-1"}),"Open To Work"]}),!!e.OnHold&&e.OnHold!==0&&jsxRuntime.jsx(Badge,{variant:"warning",children:"On Hold"}),q.map((ne,ae)=>jsxRuntime.jsx(Badge,{variant:"outline",children:ne},ae))]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[e.Phone&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`tel:${e.Phone}`,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Phone,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.Phone})]}),e.PublicEmail&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`mailto:${e.PublicEmail}`,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Mail,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.PublicEmail})]}),e.Website&&jsxRuntime.jsxs(reactRouterDom.Link,{to:e.Website,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Globe,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.Website})]}),e.CurrencyCode&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(DollarSign,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.CurrencyCode})]})]})]}),e.SalesData&&jsxRuntime.jsxs("div",{className:"border-l pl-2 ml-2 flex flex-col text-sm",children:[jsxRuntime.jsx("strong",{className:"",children:"YTD"}),jsxRuntime.jsx("p",{children:e.SalesData.SalesYearToDay?formatMoney(e.SalesData.SalesYearToDay):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"3 mo."}),jsxRuntime.jsx("p",{children:e.SalesData.SalesLast3Months?formatMoney(e.SalesData.SalesLast3Months):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"30 days"}),jsxRuntime.jsx("p",{children:e.SalesData.SalesLast30Days?formatMoney(e.SalesData.SalesLast30Days):"—"})]})]})}),(o||l||e.PublicResourcesLink||M&&f&&e.ManufacturerId||t)&&jsxRuntime.jsxs(CardFooter,{className:"flex pt-2 gap-2 justify-between mt-auto",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[o&&o,M&&f&&e.ManufacturerId&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{size:"icon",onClick:()=>R(!0),disabled:_,children:_?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Download,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Email Product List"})})]})}),e.PublicResourcesLink&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:e.PublicResourcesLink,target:"_blank",children:jsxRuntime.jsx(Button$1,{size:"icon",children:jsxRuntime.jsx(BookOpen,{className:"h-4 w-4"})})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Public Resources Link"})})]})})]}),(l||t)&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[t&&jsxRuntime.jsx(reactRouterDom.Link,{to:t,target:n?"_blank":"_self",children:jsxRuntime.jsx(Button$1,{variant:"outline",className:"whitespace-nowrap",children:"View manufacturer"})}),l&&jsxRuntime.jsx("div",{children:l})]})]}),jsxRuntime.jsx(Dialog,{open:S,onOpenChange:R,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Request Universal Product List"}),jsxRuntime.jsx(DialogDescription,{children:"Enter the email address where you would like to receive the report."})]}),jsxRuntime.jsxs("div",{className:"py-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",value:C,onChange:ne=>E(ne.target.value),placeholder:"your@email.com",className:"mt-2"})]}),jsxRuntime.jsx(DialogDescription,{children:"The report will take around 5 minutes to generate."}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>R(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:Q,disabled:!C||_,children:_?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Report"})]})]})})]})}function ProductInventoryButton({applicationId:e,randmarSku:t,inventory:n,buttonSize:o="default",buttonClassName:l}){var Ne;const d=React.useRef(null),f=useIntersectionObserver({elementRef:d,threshold:.1,rootMargin:"100px",freezeOnceVisible:!0}),{toast:g}=useToast(),[b,_]=React.useState(!1),[S,R]=React.useState(!1),[C,E]=React.useState(!1),{data:A,isLoading:M,isFetching:I}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:e},{skip:!e||!f}),{data:j,isLoading:q,isFetching:Q}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:e,randmarSku:t,withSpecification:!1},{skip:!!n||!f}),[te]=usePutV4ResellerByRouteResellerIdProductAndRandmarSkuRequisitionMutation(),F=n??((Ne=j==null?void 0:j.Distribution)==null?void 0:Ne.Inventory);React.useEffect(()=>{_(!1)},[t]);const{inventoryQuantity:V,totalIncomingQuantity:ne}=React.useMemo(()=>{if(!F||F.length===0)return{inventoryQuantity:0,totalIncomingQuantity:0};const oe=F.reduce((Ae,je)=>Ae+(je.AvailableQuantity||0),0),$e=F.reduce((Ae,je)=>Ae+(je.PurchaseOrderQuantity||0),0);return{inventoryQuantity:oe,totalIncomingQuantity:$e}},[F]);if(M||I||q||Q)return jsxRuntime.jsx("div",{ref:d,children:jsxRuntime.jsx(Skeleton,{className:cn("h-10 w-36 rounded-md",l)})});const se=()=>{C||!(A!=null&&A.IsReseller)||(E(!0),te({routeResellerId:e??"",randmarSku:t??""}).then(oe=>{oe.error||oe.data===!1?g({title:"Warning",description:"Reorder is pending or requires manual approval. Contact the Randmar team for details.",variant:"warning"}):g({title:"Success",description:"Qualification successfully submitted.",variant:"success"}),R(!1)}).catch(oe=>{console.error(oe),g({title:"Error",description:"Error submitting your qualification.",variant:"destructive"})}).finally(()=>{E(!1)}))};if(!F)return jsxRuntime.jsx("div",{ref:d,children:jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx("span",{tabIndex:0,children:jsxRuntime.jsxs(Button$1,{disabled:!0,size:o,variant:"outline",className:cn("text-sm",l),children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),"No data"]})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"No inventory data could be found for this product."})})]})})});if(A!=null&&A.IsReseller&&V<=0&&ne<=0)return jsxRuntime.jsx("div",{ref:d,children:jsxRuntime.jsxs(Dialog,{open:S,onOpenChange:R,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{variant:"outline",size:o,className:cn("text-sm reseller-theme text-primary",l),children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),"Request to stock"]})}),jsxRuntime.jsxs(DialogContent,{className:"max-w-md",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsx(DialogTitle,{children:"Request to stock"})}),jsxRuntime.jsx("p",{className:"py-4",children:"Are you sure you want to request this product to be stocked?"}),jsxRuntime.jsxs("div",{className:"flex justify-end gap-2",children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>R(!1),disabled:C,children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:se,disabled:C,children:C?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin mr-2"}),"Requesting..."]}):"Confirm"})]})]})]})});const Oe=V<=0&&ne>0;return jsxRuntime.jsx("div",{ref:d,children:jsxRuntime.jsxs(Dialog,{open:b,onOpenChange:_,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{variant:"outline",size:o,className:cn("text-sm",Oe?"manufacturer-theme text-primary":V>0?"text-green-700":"text-red-700",l),children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),Oe?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[formatNumber(ne)," Incoming"]}):V>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[formatNumber(V)," in stock"]}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Out of stock"})]})}),jsxRuntime.jsxs(DialogContent,{className:"max-w-4xl",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsxs(DialogTitle,{className:"flex items-center",children:[jsxRuntime.jsx(Warehouse,{className:"mr-2",size:18}),"Inventory Information"]})}),jsxRuntime.jsx(ProductInventoryGrid,{inventory:F})]})]})})}function OrdersCard({applicationId:e,orders:t=null,loading:n=!1,title:o="Order Details"}){const l=React.useMemo(()=>[{accessorKey:"OrderNumber",header:"Order Number",cell:({row:g})=>g.original.OrderNumber?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/GeneralDocument/${g.original.OrderNumber}`,className:"font-medium text-primary hover:underline",children:g.original.OrderNumber})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for order ",g.original.OrderNumber]})})]})}):"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"DocumentNumber",header:"Document Number",cell:({row:g})=>g.original.DocumentNumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"DocumentDate",header:"Document Date",cell:({row:g})=>formatYYYYMMDDIntToDateString(g.original.DocumentDate),enableSorting:!0,enableFiltering:!1},{accessorKey:"PONumber",header:"PO Number",cell:({row:g})=>g.original.PONumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"WarehouseCode",header:"Warehouse",cell:({row:g})=>g.original.WarehouseCode??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"MPN",header:"MPN",cell:({row:g})=>g.original.MPN?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/Product/${g.original.MPN}`,className:"font-medium text-primary hover:underline",children:g.original.MPN})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for MPN ",g.original.MPN]})})]})}):"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:g})=>g.original.Quantity??"N/A",enableSorting:!0,enableFiltering:!1},{accessorKey:"ShipToName",header:"Name",cell:({row:g})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:g.original.ShipToName??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"UnitPrice",header:"Unit Price",cell:({row:g})=>g.original.UnitPrice?formatMoney(g.original.UnitPrice):"N/A",enableSorting:!0,enableFiltering:!1},{id:"actions",header:"Actions",cell:({row:g})=>jsxRuntime.jsx("div",{className:"flex space-x-2",children:jsxRuntime.jsx(ProductInventoryButton,{applicationId:e,randmarSku:g.original.RandmarSKU??"",buttonSize:"sm"})})}],[e]),d=React.useMemo(()=>{const g={};if(t){const b=Array.from(new Set(t.map(A=>A.WarehouseCode).filter(A=>A!=null)));g.WarehouseCode=b;const _=Array.from(new Set(t.map(A=>A.ShipToName).filter(A=>A!=null)));g.ShipToName=_;const S=Array.from(new Set(t.map(A=>A.DocumentNumber).filter(A=>A!=null)));g.DocumentNumber=S;const R=Array.from(new Set(t.map(A=>A.OrderNumber).filter(A=>A!=null)));g.OrderNumber=R;const C=Array.from(new Set(t.map(A=>A.PONumber).filter(A=>A!=null)));g.PONumber=C;const E=Array.from(new Set(t.map(A=>A.MPN).filter(A=>A!=null)));g.MPN=E}return g},[t]),f=t||[];return n?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-48"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:o})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:l,data:f,uniqueValues:d})})]})}function ResellerOverview({appID:e,reseller:t,readonly:n,userEmail:o,isSuperAdmin:l,withoutReports:d=!1}){var q,Q,te,F;const{data:f,isLoading:g,isError:b}=useGetV4PartnerByApplicationIdAccountResellerQuery({applicationId:e??"",withSpecification:!0},{skip:!!t}),[_,S]=React.useState({publicInfo:{hasUnsavedChanges:!1}}),R=React.useCallback(()=>n?!1:_.publicInfo.hasUnsavedChanges,[n,_]),C=React.useCallback((V,ne)=>{S(ae=>{var se;return((se=ae[V])==null?void 0:se.hasUnsavedChanges)!==ne.hasUnsavedChanges?{...ae,[V]:ne}:ae})},[]),{NavigationGuardDialog:E}=useRouterNavigationGuard(R),A=t??f,M=!n||!!(A!=null&&A.Statement)&&(A.Statement.Total??0)>0,I=(A==null?void 0:A.QualifiedManufacturers)??[],j=(A==null?void 0:A.Qualifications)??[];return jsxRuntime.jsxs("div",{className:"@container",children:[b?jsxRuntime.jsx(Card,{className:"p-6",children:jsxRuntime.jsxs(Alert,{variant:"destructive",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Error"}),jsxRuntime.jsx(AlertDescription,{children:"There was an error loading your reseller information. Please try again later."})]})}):jsxRuntime.jsxs("div",{className:"space-y-6 mb-6",children:[jsxRuntime.jsx(SalesSummary,{fiscalYearMonthStart:(A==null?void 0:A.FiscalYearMonthStart)||1,salesData:A==null?void 0:A.SalesData,isLoading:g}),jsxRuntime.jsxs("div",{className:"grid @lg:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChartCard,{statistics:(A==null?void 0:A.SalesStatistics)??[],loading:g}),jsxRuntime.jsx(OrderCategories,{openOrders:(A==null?void 0:A.ActiveOrderDetails)??[],isLoading:g}),M&&jsxRuntime.jsx(BillingCard,{appID:e,reseller:A||{},withoutReports:d,isLoading:g,userEmail:o,isSuperAdmin:l}),jsxRuntime.jsx(PublicInfo,{reseller:A||{},appID:e??"",isLoading:g,readonly:n,onUnsavedChanges:V=>C("publicInfo",{hasUnsavedChanges:V})}),jsxRuntime.jsx(AccountTier,{isSuperAdmin:l,readonly:n,reseller:A||{},appID:e??"",isLoading:g})]}),g||I.length>0?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Manufacturers you are qualified for"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid @lg:grid-cols-2 gap-4",children:g?Array.from({length:2}).map((V,ne)=>jsxRuntime.jsx(ManufacturerCard,{loading:!0},ne)):I.map(V=>jsxRuntime.jsx(ManufacturerCard,{manufacturer:V,link:`https://dashboard.randmar.io/${e}/Partner/${V.ManufacturerId}`},V.ManufacturerId))})})]}):j.length>0&&jsxRuntime.jsx(ResellerQualificationsCard,{qualifications:j}),(((q=A==null?void 0:A.Opportunities)==null?void 0:q.length)??0)>0&&jsxRuntime.jsx(OpportunitiesTable,{applicationId:e,opportunities:A==null?void 0:A.Opportunities,loading:g}),(((Q=A==null?void 0:A.ActiveOrderDetails)==null?void 0:Q.length)??0)>0&&jsxRuntime.jsx(OrdersCard,{applicationId:e,title:"Active Orders",orders:A==null?void 0:A.ActiveOrderDetails,loading:g}),(((te=A==null?void 0:A.CompletedOrderDetails)==null?void 0:te.length)??0)>0&&jsxRuntime.jsx(OrdersCard,{applicationId:e,title:"Completed Orders",orders:A==null?void 0:A.CompletedOrderDetails,loading:g}),(((F=A==null?void 0:A.Returns)==null?void 0:F.length)??0)>0&&jsxRuntime.jsx(ReturnsTable,{applicationId:e,returns:A==null?void 0:A.Returns,loading:g}),!d&&jsxRuntime.jsx(ReportsSection,{appID:e,userEmail:o,isLoading:g})]}),jsxRuntime.jsx(E,{})]})}const alertVariants=cva("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",success:"border-green-500/50 bg-green-50 text-green-700 dark:border-green-500 dark:bg-green-950 dark:text-green-400 [&>svg]:text-green-500",warning:"border-yellow-500/50 bg-yellow-50 text-yellow-700 dark:border-yellow-500 dark:bg-yellow-950 dark:text-yellow-400 [&>svg]:text-yellow-500",info:"border-blue-500/50 bg-blue-50 text-blue-700 dark:border-blue-500 dark:bg-blue-950 dark:text-blue-400 [&>svg]:text-blue-500"}},defaultVariants:{variant:"default"}}),Alert=React__namespace.forwardRef(({className:e,variant:t,...n},o)=>jsxRuntime.jsx("div",{ref:o,role:"alert",className:cn(alertVariants({variant:t}),e),...n}));Alert.displayName="Alert";const AlertTitle=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("h5",{ref:n,className:cn("mb-1 font-medium leading-none tracking-tight",e),...t}));AlertTitle.displayName="AlertTitle";const AlertDescription=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("text-sm [&_p]:leading-relaxed",e),...t}));AlertDescription.displayName="AlertDescription";/**
|
|
1198
1198
|
* table-core
|
|
1199
1199
|
*
|
|
1200
1200
|
* Copyright (c) TanStack
|
|
@@ -1278,11 +1278,11 @@ For more information, see https://radix-ui.com/primitives/docs/components/alert-
|
|
|
1278
1278
|
`)}}ContentMatch.empty=new ContentMatch(!0);class TokenStream{constructor(t,n){this.string=t,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=t.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(t){return this.next==t&&(this.pos++||!0)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}}function parseExpr(e){let t=[];do t.push(parseExprSeq(e));while(e.eat("|"));return t.length==1?t[0]:{type:"choice",exprs:t}}function parseExprSeq(e){let t=[];do t.push(parseExprSubscript(e));while(e.next&&e.next!=")"&&e.next!="|");return t.length==1?t[0]:{type:"seq",exprs:t}}function parseExprSubscript(e){let t=parseExprAtom(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else if(e.eat("{"))t=parseExprRange(e,t);else break;return t}function parseNum(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function parseExprRange(e,t){let n=parseNum(e),o=n;return e.eat(",")&&(e.next!="}"?o=parseNum(e):o=-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:o,expr:t}}function resolveName(e,t){let n=e.nodeTypes,o=n[t];if(o)return[o];let l=[];for(let d in n){let f=n[d];f.isInGroup(t)&&l.push(f)}return l.length==0&&e.err("No node type or group '"+t+"' found"),l}function parseExprAtom(e){if(e.eat("(")){let t=parseExpr(e);return e.eat(")")||e.err("Missing closing paren"),t}else if(/\W/.test(e.next))e.err("Unexpected token '"+e.next+"'");else{let t=resolveName(e,e.next).map(n=>(e.inline==null?e.inline=n.isInline:e.inline!=n.isInline&&e.err("Mixing inline and block content"),{type:"name",value:n}));return e.pos++,t.length==1?t[0]:{type:"choice",exprs:t}}}function nfa(e){let t=[[]];return l(d(e,0),n()),t;function n(){return t.push([])-1}function o(f,g,b){let _={term:b,to:g};return t[f].push(_),_}function l(f,g){f.forEach(b=>b.to=g)}function d(f,g){if(f.type=="choice")return f.exprs.reduce((b,_)=>b.concat(d(_,g)),[]);if(f.type=="seq")for(let b=0;;b++){let _=d(f.exprs[b],g);if(b==f.exprs.length-1)return _;l(_,g=n())}else if(f.type=="star"){let b=n();return o(g,b),l(d(f.expr,b),b),[o(b)]}else if(f.type=="plus"){let b=n();return l(d(f.expr,g),b),l(d(f.expr,b),b),[o(b)]}else{if(f.type=="opt")return[o(g)].concat(d(f.expr,g));if(f.type=="range"){let b=g;for(let _=0;_<f.min;_++){let S=n();l(d(f.expr,b),S),b=S}if(f.max==-1)l(d(f.expr,b),b);else for(let _=f.min;_<f.max;_++){let S=n();o(b,S),l(d(f.expr,b),S),b=S}return[o(b)]}else{if(f.type=="name")return[o(g,void 0,f.value)];throw new Error("Unknown expr type")}}}}function cmp(e,t){return t-e}function nullFrom(e,t){let n=[];return o(t),n.sort(cmp);function o(l){let d=e[l];if(d.length==1&&!d[0].term)return o(d[0].to);n.push(l);for(let f=0;f<d.length;f++){let{term:g,to:b}=d[f];!g&&n.indexOf(b)==-1&&o(b)}}}function dfa(e){let t=Object.create(null);return n(nullFrom(e,0));function n(o){let l=[];o.forEach(f=>{e[f].forEach(({term:g,to:b})=>{if(!g)return;let _;for(let S=0;S<l.length;S++)l[S][0]==g&&(_=l[S][1]);nullFrom(e,b).forEach(S=>{_||l.push([g,_=[]]),_.indexOf(S)==-1&&_.push(S)})})});let d=t[o.join(",")]=new ContentMatch(o.indexOf(e.length-1)>-1);for(let f=0;f<l.length;f++){let g=l[f][1].sort(cmp);d.next.push({type:l[f][0],next:t[g.join(",")]||n(g)})}return d}}function checkForDeadEnds(e,t){for(let n=0,o=[e];n<o.length;n++){let l=o[n],d=!l.validEnd,f=[];for(let g=0;g<l.next.length;g++){let{type:b,next:_}=l.next[g];f.push(b.name),d&&!(b.isText||b.hasRequiredAttrs())&&(d=!1),o.indexOf(_)==-1&&o.push(_)}d&&t.err("Only non-generatable nodes ("+f.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function defaultAttrs(e){let t=Object.create(null);for(let n in e){let o=e[n];if(!o.hasDefault)return null;t[n]=o.default}return t}function computeAttrs(e,t){let n=Object.create(null);for(let o in e){let l=t&&t[o];if(l===void 0){let d=e[o];if(d.hasDefault)l=d.default;else throw new RangeError("No value supplied for attribute "+o)}n[o]=l}return n}function checkAttrs(e,t,n,o){for(let l in t)if(!(l in e))throw new RangeError(`Unsupported attribute ${l} for ${n} of type ${l}`);for(let l in e){let d=e[l];d.validate&&d.validate(t[l])}}function initAttrs(e,t){let n=Object.create(null);if(t)for(let o in t)n[o]=new Attribute(e,o,t[o]);return n}let NodeType$1=class $r{constructor(t,n,o){this.name=t,this.schema=n,this.spec=o,this.markSet=null,this.groups=o.group?o.group.split(" "):[],this.attrs=initAttrs(t,o.attrs),this.defaultAttrs=defaultAttrs(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(o.inline||t=="text"),this.isText=t=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==ContentMatch.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(t){return this.groups.indexOf(t)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){return!t&&this.defaultAttrs?this.defaultAttrs:computeAttrs(this.attrs,t)}create(t=null,n,o){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Node$2(this,this.computeAttrs(t),Fragment.from(n),Mark$1.setFrom(o))}createChecked(t=null,n,o){return n=Fragment.from(n),this.checkContent(n),new Node$2(this,this.computeAttrs(t),n,Mark$1.setFrom(o))}createAndFill(t=null,n,o){if(t=this.computeAttrs(t),n=Fragment.from(n),n.size){let f=this.contentMatch.fillBefore(n);if(!f)return null;n=f.append(n)}let l=this.contentMatch.matchFragment(n),d=l&&l.fillBefore(Fragment.empty,!0);return d?new Node$2(this,t,n.append(d),Mark$1.setFrom(o)):null}validContent(t){let n=this.contentMatch.matchFragment(t);if(!n||!n.validEnd)return!1;for(let o=0;o<t.childCount;o++)if(!this.allowsMarks(t.child(o).marks))return!1;return!0}checkContent(t){if(!this.validContent(t))throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0,50)}`)}checkAttrs(t){checkAttrs(this.attrs,t,"node",this.name)}allowsMarkType(t){return this.markSet==null||this.markSet.indexOf(t)>-1}allowsMarks(t){if(this.markSet==null)return!0;for(let n=0;n<t.length;n++)if(!this.allowsMarkType(t[n].type))return!1;return!0}allowedMarks(t){if(this.markSet==null)return t;let n;for(let o=0;o<t.length;o++)this.allowsMarkType(t[o].type)?n&&n.push(t[o]):n||(n=t.slice(0,o));return n?n.length?n:Mark$1.none:t}static compile(t,n){let o=Object.create(null);t.forEach((d,f)=>o[d]=new $r(d,n,f));let l=n.spec.topNode||"doc";if(!o[l])throw new RangeError("Schema is missing its top node type ('"+l+"')");if(!o.text)throw new RangeError("Every schema needs a 'text' type");for(let d in o.text.attrs)throw new RangeError("The text node type should not have attributes");return o}};function validateType(e,t,n){let o=n.split("|");return l=>{let d=l===null?"null":typeof l;if(o.indexOf(d)<0)throw new RangeError(`Expected value of type ${o} for attribute ${t} on type ${e}, got ${d}`)}}class Attribute{constructor(t,n,o){this.hasDefault=Object.prototype.hasOwnProperty.call(o,"default"),this.default=o.default,this.validate=typeof o.validate=="string"?validateType(t,n,o.validate):o.validate}get isRequired(){return!this.hasDefault}}class MarkType{constructor(t,n,o,l){this.name=t,this.rank=n,this.schema=o,this.spec=l,this.attrs=initAttrs(t,l.attrs),this.excluded=null;let d=defaultAttrs(this.attrs);this.instance=d?new Mark$1(this,d):null}create(t=null){return!t&&this.instance?this.instance:new Mark$1(this,computeAttrs(this.attrs,t))}static compile(t,n){let o=Object.create(null),l=0;return t.forEach((d,f)=>o[d]=new MarkType(d,l++,n,f)),o}removeFromSet(t){for(var n=0;n<t.length;n++)t[n].type==this&&(t=t.slice(0,n).concat(t.slice(n+1)),n--);return t}isInSet(t){for(let n=0;n<t.length;n++)if(t[n].type==this)return t[n]}checkAttrs(t){checkAttrs(this.attrs,t,"mark",this.name)}excludes(t){return this.excluded.indexOf(t)>-1}}class Schema{constructor(t){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let l in t)n[l]=t[l];n.nodes=OrderedMap.from(t.nodes),n.marks=OrderedMap.from(t.marks||{}),this.nodes=NodeType$1.compile(this.spec.nodes,this),this.marks=MarkType.compile(this.spec.marks,this);let o=Object.create(null);for(let l in this.nodes){if(l in this.marks)throw new RangeError(l+" can not be both a node and a mark");let d=this.nodes[l],f=d.spec.content||"",g=d.spec.marks;if(d.contentMatch=o[f]||(o[f]=ContentMatch.parse(f,this.nodes)),d.inlineContent=d.contentMatch.inlineContent,d.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!d.isInline||!d.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=d}d.markSet=g=="_"?null:g?gatherMarks(this,g.split(" ")):g==""||!d.inlineContent?[]:null}for(let l in this.marks){let d=this.marks[l],f=d.spec.excludes;d.excluded=f==null?[d]:f==""?[]:gatherMarks(this,f.split(" "))}this.nodeFromJSON=l=>Node$2.fromJSON(this,l),this.markFromJSON=l=>Mark$1.fromJSON(this,l),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(t,n=null,o,l){if(typeof t=="string")t=this.nodeType(t);else if(t instanceof NodeType$1){if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}else throw new RangeError("Invalid node type: "+t);return t.createChecked(n,o,l)}text(t,n){let o=this.nodes.text;return new TextNode(o,o.defaultAttrs,t,Mark$1.setFrom(n))}mark(t,n){return typeof t=="string"&&(t=this.marks[t]),t.create(n)}nodeType(t){let n=this.nodes[t];if(!n)throw new RangeError("Unknown node type: "+t);return n}}function gatherMarks(e,t){let n=[];for(let o=0;o<t.length;o++){let l=t[o],d=e.marks[l],f=d;if(d)n.push(d);else for(let g in e.marks){let b=e.marks[g];(l=="_"||b.spec.group&&b.spec.group.split(" ").indexOf(l)>-1)&&n.push(f=b)}if(!f)throw new SyntaxError("Unknown mark type: '"+t[o]+"'")}return n}function isTagRule(e){return e.tag!=null}function isStyleRule(e){return e.style!=null}class DOMParser{constructor(t,n){this.schema=t,this.rules=n,this.tags=[],this.styles=[];let o=this.matchedStyles=[];n.forEach(l=>{if(isTagRule(l))this.tags.push(l);else if(isStyleRule(l)){let d=/[^=]*/.exec(l.style)[0];o.indexOf(d)<0&&o.push(d),this.styles.push(l)}}),this.normalizeLists=!this.tags.some(l=>{if(!/^(ul|ol)\b/.test(l.tag)||!l.node)return!1;let d=t.nodes[l.node];return d.contentMatch.matchType(d)})}parse(t,n={}){let o=new ParseContext(this,n,!1);return o.addAll(t,Mark$1.none,n.from,n.to),o.finish()}parseSlice(t,n={}){let o=new ParseContext(this,n,!0);return o.addAll(t,Mark$1.none,n.from,n.to),Slice.maxOpen(o.finish())}matchTag(t,n,o){for(let l=o?this.tags.indexOf(o)+1:0;l<this.tags.length;l++){let d=this.tags[l];if(matches(t,d.tag)&&(d.namespace===void 0||t.namespaceURI==d.namespace)&&(!d.context||n.matchesContext(d.context))){if(d.getAttrs){let f=d.getAttrs(t);if(f===!1)continue;d.attrs=f||void 0}return d}}}matchStyle(t,n,o,l){for(let d=l?this.styles.indexOf(l)+1:0;d<this.styles.length;d++){let f=this.styles[d],g=f.style;if(!(g.indexOf(t)!=0||f.context&&!o.matchesContext(f.context)||g.length>t.length&&(g.charCodeAt(t.length)!=61||g.slice(t.length+1)!=n))){if(f.getAttrs){let b=f.getAttrs(n);if(b===!1)continue;f.attrs=b||void 0}return f}}}static schemaRules(t){let n=[];function o(l){let d=l.priority==null?50:l.priority,f=0;for(;f<n.length;f++){let g=n[f];if((g.priority==null?50:g.priority)<d)break}n.splice(f,0,l)}for(let l in t.marks){let d=t.marks[l].spec.parseDOM;d&&d.forEach(f=>{o(f=copy(f)),f.mark||f.ignore||f.clearMark||(f.mark=l)})}for(let l in t.nodes){let d=t.nodes[l].spec.parseDOM;d&&d.forEach(f=>{o(f=copy(f)),f.node||f.ignore||f.mark||(f.node=l)})}return n}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new DOMParser(t,DOMParser.schemaRules(t)))}}const blockTags={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},ignoreTags={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},listTags={ol:!0,ul:!0},OPT_PRESERVE_WS=1,OPT_PRESERVE_WS_FULL=2,OPT_OPEN_LEFT=4;function wsOptionsFor(e,t,n){return t!=null?(t?OPT_PRESERVE_WS:0)|(t==="full"?OPT_PRESERVE_WS_FULL:0):e&&e.whitespace=="pre"?OPT_PRESERVE_WS|OPT_PRESERVE_WS_FULL:n&~OPT_OPEN_LEFT}class NodeContext{constructor(t,n,o,l,d,f){this.type=t,this.attrs=n,this.marks=o,this.solid=l,this.options=f,this.content=[],this.activeMarks=Mark$1.none,this.match=d||(f&OPT_OPEN_LEFT?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(Fragment.from(t));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let o=this.type.contentMatch,l;return(l=o.findWrapping(t.type))?(this.match=o,l):null}}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&OPT_PRESERVE_WS)){let o=this.content[this.content.length-1],l;if(o&&o.isText&&(l=/[ \t\r\n\u000c]+$/.exec(o.text))){let d=o;o.text.length==l[0].length?this.content.pop():this.content[this.content.length-1]=d.withText(d.text.slice(0,d.text.length-l[0].length))}}let n=Fragment.from(this.content);return!t&&this.match&&(n=n.append(this.match.fillBefore(Fragment.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!blockTags.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class ParseContext{constructor(t,n,o){this.parser=t,this.options=n,this.isOpen=o,this.open=0,this.localPreserveWS=!1;let l=n.topNode,d,f=wsOptionsFor(null,n.preserveWhitespace,0)|(o?OPT_OPEN_LEFT:0);l?d=new NodeContext(l.type,l.attrs,Mark$1.none,!0,n.topMatch||l.type.contentMatch,f):o?d=new NodeContext(null,null,Mark$1.none,!0,null,f):d=new NodeContext(t.schema.topNodeType,null,Mark$1.none,!0,null,f),this.nodes=[d],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t,n){t.nodeType==3?this.addTextNode(t,n):t.nodeType==1&&this.addElement(t,n)}addTextNode(t,n){let o=t.nodeValue,l=this.top,d=l.options&OPT_PRESERVE_WS_FULL?"full":this.localPreserveWS||(l.options&OPT_PRESERVE_WS)>0,{schema:f}=this.parser;if(d==="full"||l.inlineContext(t)||/[^ \t\r\n\u000c]/.test(o)){if(d)if(d==="full")o=o.replace(/\r\n?/g,`
|
|
1279
1279
|
`);else if(f.linebreakReplacement&&/[\r\n]/.test(o)&&this.top.findWrapping(f.linebreakReplacement.create())){let g=o.split(/\r?\n|\r/);for(let b=0;b<g.length;b++)b&&this.insertNode(f.linebreakReplacement.create(),n,!0),g[b]&&this.insertNode(f.text(g[b]),n,!/\S/.test(g[b]));o=""}else o=o.replace(/\r?\n|\r/g," ");else if(o=o.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(o)&&this.open==this.nodes.length-1){let g=l.content[l.content.length-1],b=t.previousSibling;(!g||b&&b.nodeName=="BR"||g.isText&&/[ \t\r\n\u000c]$/.test(g.text))&&(o=o.slice(1))}o&&this.insertNode(f.text(o),n,!/\S/.test(o)),this.findInText(t)}else this.findInside(t)}addElement(t,n,o){let l=this.localPreserveWS,d=this.top;(t.tagName=="PRE"||/pre/.test(t.style&&t.style.whiteSpace))&&(this.localPreserveWS=!0);let f=t.nodeName.toLowerCase(),g;listTags.hasOwnProperty(f)&&this.parser.normalizeLists&&normalizeList(t);let b=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(g=this.parser.matchTag(t,this,o));e:if(b?b.ignore:ignoreTags.hasOwnProperty(f))this.findInside(t),this.ignoreFallback(t,n);else if(!b||b.skip||b.closeParent){b&&b.closeParent?this.open=Math.max(0,this.open-1):b&&b.skip.nodeType&&(t=b.skip);let _,S=this.needsBlock;if(blockTags.hasOwnProperty(f))d.content.length&&d.content[0].isInline&&this.open&&(this.open--,d=this.top),_=!0,d.type||(this.needsBlock=!0);else if(!t.firstChild){this.leafFallback(t,n);break e}let R=b&&b.skip?n:this.readStyles(t,n);R&&this.addAll(t,R),_&&this.sync(d),this.needsBlock=S}else{let _=this.readStyles(t,n);_&&this.addElementByRule(t,b,_,b.consuming===!1?g:void 0)}this.localPreserveWS=l}leafFallback(t,n){t.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode(`
|
|
1280
1280
|
`),n)}ignoreFallback(t,n){t.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(t,n){let o=t.style;if(o&&o.length)for(let l=0;l<this.parser.matchedStyles.length;l++){let d=this.parser.matchedStyles[l],f=o.getPropertyValue(d);if(f)for(let g=void 0;;){let b=this.parser.matchStyle(d,f,this,g);if(!b)break;if(b.ignore)return null;if(b.clearMark?n=n.filter(_=>!b.clearMark(_)):n=n.concat(this.parser.schema.marks[b.mark].create(b.attrs)),b.consuming===!1)g=b;else break}}return n}addElementByRule(t,n,o,l){let d,f;if(n.node)if(f=this.parser.schema.nodes[n.node],f.isLeaf)this.insertNode(f.create(n.attrs),o,t.nodeName=="BR")||this.leafFallback(t,o);else{let b=this.enter(f,n.attrs||null,o,n.preserveWhitespace);b&&(d=!0,o=b)}else{let b=this.parser.schema.marks[n.mark];o=o.concat(b.create(n.attrs))}let g=this.top;if(f&&f.isLeaf)this.findInside(t);else if(l)this.addElement(t,o,l);else if(n.getContent)this.findInside(t),n.getContent(t,this.parser.schema).forEach(b=>this.insertNode(b,o,!1));else{let b=t;typeof n.contentElement=="string"?b=t.querySelector(n.contentElement):typeof n.contentElement=="function"?b=n.contentElement(t):n.contentElement&&(b=n.contentElement),this.findAround(t,b,!0),this.addAll(b,o),this.findAround(t,b,!1)}d&&this.sync(g)&&this.open--}addAll(t,n,o,l){let d=o||0;for(let f=o?t.childNodes[o]:t.firstChild,g=l==null?null:t.childNodes[l];f!=g;f=f.nextSibling,++d)this.findAtPoint(t,d),this.addDOM(f,n);this.findAtPoint(t,d)}findPlace(t,n,o){let l,d;for(let f=this.open,g=0;f>=0;f--){let b=this.nodes[f],_=b.findWrapping(t);if(_&&(!l||l.length>_.length+g)&&(l=_,d=b,!_.length))break;if(b.solid){if(o)break;g+=2}}if(!l)return null;this.sync(d);for(let f=0;f<l.length;f++)n=this.enterInner(l[f],null,n,!1);return n}insertNode(t,n,o){if(t.isInline&&this.needsBlock&&!this.top.type){let d=this.textblockFromContext();d&&(n=this.enterInner(d,null,n))}let l=this.findPlace(t,n,o);if(l){this.closeExtra();let d=this.top;d.match&&(d.match=d.match.matchType(t.type));let f=Mark$1.none;for(let g of l.concat(t.marks))(d.type?d.type.allowsMarkType(g.type):markMayApply(g.type,t.type))&&(f=g.addToSet(f));return d.content.push(t.mark(f)),!0}return!1}enter(t,n,o,l){let d=this.findPlace(t.create(n),o,!1);return d&&(d=this.enterInner(t,n,o,!0,l)),d}enterInner(t,n,o,l=!1,d){this.closeExtra();let f=this.top;f.match=f.match&&f.match.matchType(t);let g=wsOptionsFor(t,d,f.options);f.options&OPT_OPEN_LEFT&&f.content.length==0&&(g|=OPT_OPEN_LEFT);let b=Mark$1.none;return o=o.filter(_=>(f.type?f.type.allowsMarkType(_.type):markMayApply(_.type,t))?(b=_.addToSet(b),!1):!0),this.nodes.push(new NodeContext(t,n,b,l,null,g)),this.open++,o}closeExtra(t=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(t));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(t){for(let n=this.open;n>=0;n--){if(this.nodes[n]==t)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=OPT_PRESERVE_WS)}return!1}get currentPos(){this.closeExtra();let t=0;for(let n=this.open;n>=0;n--){let o=this.nodes[n].content;for(let l=o.length-1;l>=0;l--)t+=o[l].nodeSize;n&&t++}return t}findAtPoint(t,n){if(this.find)for(let o=0;o<this.find.length;o++)this.find[o].node==t&&this.find[o].offset==n&&(this.find[o].pos=this.currentPos)}findInside(t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&t.nodeType==1&&t.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(t,n,o){if(t!=n&&this.find)for(let l=0;l<this.find.length;l++)this.find[l].pos==null&&t.nodeType==1&&t.contains(this.find[l].node)&&n.compareDocumentPosition(this.find[l].node)&(o?2:4)&&(this.find[l].pos=this.currentPos)}findInText(t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==t&&(this.find[n].pos=this.currentPos-(t.nodeValue.length-this.find[n].offset))}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let n=t.split("/"),o=this.options.context,l=!this.isOpen&&(!o||o.parent.type==this.nodes[0].type),d=-(o?o.depth+1:0)+(l?0:1),f=(g,b)=>{for(;g>=0;g--){let _=n[g];if(_==""){if(g==n.length-1||g==0)continue;for(;b>=d;b--)if(f(g-1,b))return!0;return!1}else{let S=b>0||b==0&&l?this.nodes[b].type:o&&b>=d?o.node(b-d).type:null;if(!S||S.name!=_&&!S.isInGroup(_))return!1;b--}}return!0};return f(n.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let n=t.depth;n>=0;n--){let o=t.node(n).contentMatchAt(t.indexAfter(n)).defaultType;if(o&&o.isTextblock&&o.defaultAttrs)return o}for(let n in this.parser.schema.nodes){let o=this.parser.schema.nodes[n];if(o.isTextblock&&o.defaultAttrs)return o}}}function normalizeList(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let o=t.nodeType==1?t.nodeName.toLowerCase():null;o&&listTags.hasOwnProperty(o)&&n?(n.appendChild(t),t=n):o=="li"?n=t:o&&(n=null)}}function matches(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function copy(e){let t={};for(let n in e)t[n]=e[n];return t}function markMayApply(e,t){let n=t.schema.nodes;for(let o in n){let l=n[o];if(!l.allowsMarkType(e))continue;let d=[],f=g=>{d.push(g);for(let b=0;b<g.edgeCount;b++){let{type:_,next:S}=g.edge(b);if(_==t||d.indexOf(S)<0&&f(S))return!0}};if(f(l.contentMatch))return!0}}class DOMSerializer{constructor(t,n){this.nodes=t,this.marks=n}serializeFragment(t,n={},o){o||(o=doc$1(n).createDocumentFragment());let l=o,d=[];return t.forEach(f=>{if(d.length||f.marks.length){let g=0,b=0;for(;g<d.length&&b<f.marks.length;){let _=f.marks[b];if(!this.marks[_.type.name]){b++;continue}if(!_.eq(d[g][0])||_.type.spec.spanning===!1)break;g++,b++}for(;g<d.length;)l=d.pop()[1];for(;b<f.marks.length;){let _=f.marks[b++],S=this.serializeMark(_,f.isInline,n);S&&(d.push([_,l]),l.appendChild(S.dom),l=S.contentDOM||S.dom)}}l.appendChild(this.serializeNodeInner(f,n))}),o}serializeNodeInner(t,n){let{dom:o,contentDOM:l}=renderSpec(doc$1(n),this.nodes[t.type.name](t),null,t.attrs);if(l){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,n,l)}return o}serializeNode(t,n={}){let o=this.serializeNodeInner(t,n);for(let l=t.marks.length-1;l>=0;l--){let d=this.serializeMark(t.marks[l],t.isInline,n);d&&((d.contentDOM||d.dom).appendChild(o),o=d.dom)}return o}serializeMark(t,n,o={}){let l=this.marks[t.type.name];return l&&renderSpec(doc$1(o),l(t,n),null,t.attrs)}static renderSpec(t,n,o=null,l){return renderSpec(t,n,o,l)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new DOMSerializer(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let n=gatherToDOM(t.nodes);return n.text||(n.text=o=>o.text),n}static marksFromSchema(t){return gatherToDOM(t.marks)}}function gatherToDOM(e){let t={};for(let n in e){let o=e[n].spec.toDOM;o&&(t[n]=o)}return t}function doc$1(e){return e.document||window.document}const suspiciousAttributeCache=new WeakMap;function suspiciousAttributes(e){let t=suspiciousAttributeCache.get(e);return t===void 0&&suspiciousAttributeCache.set(e,t=suspiciousAttributesInner(e)),t}function suspiciousAttributesInner(e){let t=null;function n(o){if(o&&typeof o=="object")if(Array.isArray(o))if(typeof o[0]=="string")t||(t=[]),t.push(o);else for(let l=0;l<o.length;l++)n(o[l]);else for(let l in o)n(o[l])}return n(e),t}function renderSpec(e,t,n,o){if(typeof t=="string")return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let l=t[0],d;if(typeof l!="string")throw new RangeError("Invalid array passed to renderSpec");if(o&&(d=suspiciousAttributes(o))&&d.indexOf(t)>-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 f=l.indexOf(" ");f>0&&(n=l.slice(0,f),l=l.slice(f+1));let g,b=n?e.createElementNS(n,l):e.createElement(l),_=t[1],S=1;if(_&&typeof _=="object"&&_.nodeType==null&&!Array.isArray(_)){S=2;for(let R in _)if(_[R]!=null){let C=R.indexOf(" ");C>0?b.setAttributeNS(R.slice(0,C),R.slice(C+1),_[R]):R=="style"&&b.style?b.style.cssText=_[R]:b.setAttribute(R,_[R])}}for(let R=S;R<t.length;R++){let C=t[R];if(C===0){if(R<t.length-1||R>S)throw new RangeError("Content hole must be the only child of its parent node");return{dom:b,contentDOM:b}}else{let{dom:E,contentDOM:A}=renderSpec(e,C,n,o);if(b.appendChild(E),A){if(g)throw new RangeError("Multiple content holes");g=A}}}return{dom:b,contentDOM:g}}const lower16=65535,factor16=Math.pow(2,16);function makeRecover(e,t){return e+t*factor16}function recoverIndex(e){return e&lower16}function recoverOffset(e){return(e-(e&lower16))/factor16}const DEL_BEFORE=1,DEL_AFTER=2,DEL_ACROSS=4,DEL_SIDE=8;class MapResult{constructor(t,n,o){this.pos=t,this.delInfo=n,this.recover=o}get deleted(){return(this.delInfo&DEL_SIDE)>0}get deletedBefore(){return(this.delInfo&(DEL_BEFORE|DEL_ACROSS))>0}get deletedAfter(){return(this.delInfo&(DEL_AFTER|DEL_ACROSS))>0}get deletedAcross(){return(this.delInfo&DEL_ACROSS)>0}}class StepMap{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&StepMap.empty)return StepMap.empty}recover(t){let n=0,o=recoverIndex(t);if(!this.inverted)for(let l=0;l<o;l++)n+=this.ranges[l*3+2]-this.ranges[l*3+1];return this.ranges[o*3]+n+recoverOffset(t)}mapResult(t,n=1){return this._map(t,n,!1)}map(t,n=1){return this._map(t,n,!0)}_map(t,n,o){let l=0,d=this.inverted?2:1,f=this.inverted?1:2;for(let g=0;g<this.ranges.length;g+=3){let b=this.ranges[g]-(this.inverted?l:0);if(b>t)break;let _=this.ranges[g+d],S=this.ranges[g+f],R=b+_;if(t<=R){let C=_?t==b?-1:t==R?1:n:n,E=b+l+(C<0?0:S);if(o)return E;let A=t==(n<0?b:R)?null:makeRecover(g/3,t-b),M=t==b?DEL_AFTER:t==R?DEL_BEFORE:DEL_ACROSS;return(n<0?t!=b:t!=R)&&(M|=DEL_SIDE),new MapResult(E,M,A)}l+=S-_}return o?t+l:new MapResult(t+l,0,null)}touches(t,n){let o=0,l=recoverIndex(n),d=this.inverted?2:1,f=this.inverted?1:2;for(let g=0;g<this.ranges.length;g+=3){let b=this.ranges[g]-(this.inverted?o:0);if(b>t)break;let _=this.ranges[g+d],S=b+_;if(t<=S&&g==l*3)return!0;o+=this.ranges[g+f]-_}return!1}forEach(t){let n=this.inverted?2:1,o=this.inverted?1:2;for(let l=0,d=0;l<this.ranges.length;l+=3){let f=this.ranges[l],g=f-(this.inverted?d:0),b=f+(this.inverted?0:d),_=this.ranges[l+n],S=this.ranges[l+o];t(g,g+_,b,b+S),d+=S-_}}invert(){return new StepMap(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return t==0?StepMap.empty:new StepMap(t<0?[0,-t,0]:[0,0,t])}}StepMap.empty=new StepMap([]);class Mapping{constructor(t,n,o=0,l=t?t.length:0){this.mirror=n,this.from=o,this.to=l,this._maps=t||[],this.ownData=!(t||n)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new Mapping(this._maps,this.mirror,t,n)}appendMap(t,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(t),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(t){for(let n=0,o=this._maps.length;n<t._maps.length;n++){let l=t.getMirror(n);this.appendMap(t._maps[n],l!=null&&l<n?o+l:void 0)}}getMirror(t){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==t)return this.mirror[n+(n%2?-1:1)]}}setMirror(t,n){this.mirror||(this.mirror=[]),this.mirror.push(t,n)}appendMappingInverted(t){for(let n=t.maps.length-1,o=this._maps.length+t._maps.length;n>=0;n--){let l=t.getMirror(n);this.appendMap(t._maps[n].invert(),l!=null&&l>n?o-l-1:void 0)}}invert(){let t=new Mapping;return t.appendMappingInverted(this),t}map(t,n=1){if(this.mirror)return this._map(t,n,!0);for(let o=this.from;o<this.to;o++)t=this._maps[o].map(t,n);return t}mapResult(t,n=1){return this._map(t,n,!1)}_map(t,n,o){let l=0;for(let d=this.from;d<this.to;d++){let f=this._maps[d],g=f.mapResult(t,n);if(g.recover!=null){let b=this.getMirror(d);if(b!=null&&b>d&&b<this.to){d=b,t=this._maps[b].recover(g.recover);continue}}l|=g.delInfo,t=g.pos}return o?t:new MapResult(t,l,null)}}const stepsByID=Object.create(null);class Step{getMap(){return StepMap.empty}merge(t){return null}static fromJSON(t,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let o=stepsByID[n.stepType];if(!o)throw new RangeError(`No step type ${n.stepType} defined`);return o.fromJSON(t,n)}static jsonID(t,n){if(t in stepsByID)throw new RangeError("Duplicate use of step JSON ID "+t);return stepsByID[t]=n,n.prototype.jsonID=t,n}}class StepResult{constructor(t,n){this.doc=t,this.failed=n}static ok(t){return new StepResult(t,null)}static fail(t){return new StepResult(null,t)}static fromReplace(t,n,o,l){try{return StepResult.ok(t.replace(n,o,l))}catch(d){if(d instanceof ReplaceError)return StepResult.fail(d.message);throw d}}}function mapFragment(e,t,n){let o=[];for(let l=0;l<e.childCount;l++){let d=e.child(l);d.content.size&&(d=d.copy(mapFragment(d.content,t,d))),d.isInline&&(d=t(d,n,l)),o.push(d)}return Fragment.fromArray(o)}class AddMarkStep extends Step{constructor(t,n,o){super(),this.from=t,this.to=n,this.mark=o}apply(t){let n=t.slice(this.from,this.to),o=t.resolve(this.from),l=o.node(o.sharedDepth(this.to)),d=new Slice(mapFragment(n.content,(f,g)=>!f.isAtom||!g.type.allowsMarkType(this.mark.type)?f:f.mark(this.mark.addToSet(f.marks)),l),n.openStart,n.openEnd);return StepResult.fromReplace(t,this.from,this.to,d)}invert(){return new RemoveMarkStep(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),o=t.mapResult(this.to,-1);return n.deleted&&o.deleted||n.pos>=o.pos?null:new AddMarkStep(n.pos,o.pos,this.mark)}merge(t){return t instanceof AddMarkStep&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new AddMarkStep(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new AddMarkStep(n.from,n.to,t.markFromJSON(n.mark))}}Step.jsonID("addMark",AddMarkStep);class RemoveMarkStep extends Step{constructor(t,n,o){super(),this.from=t,this.to=n,this.mark=o}apply(t){let n=t.slice(this.from,this.to),o=new Slice(mapFragment(n.content,l=>l.mark(this.mark.removeFromSet(l.marks)),t),n.openStart,n.openEnd);return StepResult.fromReplace(t,this.from,this.to,o)}invert(){return new AddMarkStep(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),o=t.mapResult(this.to,-1);return n.deleted&&o.deleted||n.pos>=o.pos?null:new RemoveMarkStep(n.pos,o.pos,this.mark)}merge(t){return t instanceof RemoveMarkStep&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new RemoveMarkStep(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new RemoveMarkStep(n.from,n.to,t.markFromJSON(n.mark))}}Step.jsonID("removeMark",RemoveMarkStep);class AddNodeMarkStep extends Step{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return StepResult.fail("No node at mark step's position");let o=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return StepResult.fromReplace(t,this.pos,this.pos+1,new Slice(Fragment.from(o),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);if(n){let o=this.mark.addToSet(n.marks);if(o.length==n.marks.length){for(let l=0;l<n.marks.length;l++)if(!n.marks[l].isInSet(o))return new AddNodeMarkStep(this.pos,n.marks[l]);return new AddNodeMarkStep(this.pos,this.mark)}}return new RemoveNodeMarkStep(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new AddNodeMarkStep(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new AddNodeMarkStep(n.pos,t.markFromJSON(n.mark))}}Step.jsonID("addNodeMark",AddNodeMarkStep);class RemoveNodeMarkStep extends Step{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return StepResult.fail("No node at mark step's position");let o=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return StepResult.fromReplace(t,this.pos,this.pos+1,new Slice(Fragment.from(o),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new AddNodeMarkStep(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new RemoveNodeMarkStep(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new RemoveNodeMarkStep(n.pos,t.markFromJSON(n.mark))}}Step.jsonID("removeNodeMark",RemoveNodeMarkStep);class ReplaceStep extends Step{constructor(t,n,o,l=!1){super(),this.from=t,this.to=n,this.slice=o,this.structure=l}apply(t){return this.structure&&contentBetween(t,this.from,this.to)?StepResult.fail("Structure replace would overwrite content"):StepResult.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new StepMap([this.from,this.to-this.from,this.slice.size])}invert(t){return new ReplaceStep(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.from,1),o=t.mapResult(this.to,-1);return n.deletedAcross&&o.deletedAcross?null:new ReplaceStep(n.pos,Math.max(n.pos,o.pos),this.slice,this.structure)}merge(t){if(!(t instanceof ReplaceStep)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?Slice.empty:new Slice(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new ReplaceStep(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?Slice.empty:new Slice(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new ReplaceStep(t.from,this.to,n,this.structure)}else return null}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new ReplaceStep(n.from,n.to,Slice.fromJSON(t,n.slice),!!n.structure)}}Step.jsonID("replace",ReplaceStep);class ReplaceAroundStep extends Step{constructor(t,n,o,l,d,f,g=!1){super(),this.from=t,this.to=n,this.gapFrom=o,this.gapTo=l,this.slice=d,this.insert=f,this.structure=g}apply(t){if(this.structure&&(contentBetween(t,this.from,this.gapFrom)||contentBetween(t,this.gapTo,this.to)))return StepResult.fail("Structure gap-replace would overwrite content");let n=t.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return StepResult.fail("Gap is not a flat range");let o=this.slice.insertAt(this.insert,n.content);return o?StepResult.fromReplace(t,this.from,this.to,o):StepResult.fail("Content does not fit in gap")}getMap(){return new StepMap([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new ReplaceAroundStep(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),o=t.mapResult(this.to,-1),l=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),d=this.to==this.gapTo?o.pos:t.map(this.gapTo,1);return n.deletedAcross&&o.deletedAcross||l<n.pos||d>o.pos?null:new ReplaceAroundStep(n.pos,o.pos,l,d,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ReplaceAroundStep(n.from,n.to,n.gapFrom,n.gapTo,Slice.fromJSON(t,n.slice),n.insert,!!n.structure)}}Step.jsonID("replaceAround",ReplaceAroundStep);function contentBetween(e,t,n){let o=e.resolve(t),l=n-t,d=o.depth;for(;l>0&&d>0&&o.indexAfter(d)==o.node(d).childCount;)d--,l--;if(l>0){let f=o.node(d).maybeChild(o.indexAfter(d));for(;l>0;){if(!f||f.isLeaf)return!0;f=f.firstChild,l--}}return!1}function addMark(e,t,n,o){let l=[],d=[],f,g;e.doc.nodesBetween(t,n,(b,_,S)=>{if(!b.isInline)return;let R=b.marks;if(!o.isInSet(R)&&S.type.allowsMarkType(o.type)){let C=Math.max(_,t),E=Math.min(_+b.nodeSize,n),A=o.addToSet(R);for(let M=0;M<R.length;M++)R[M].isInSet(A)||(f&&f.to==C&&f.mark.eq(R[M])?f.to=E:l.push(f=new RemoveMarkStep(C,E,R[M])));g&&g.to==C?g.to=E:d.push(g=new AddMarkStep(C,E,o))}}),l.forEach(b=>e.step(b)),d.forEach(b=>e.step(b))}function removeMark(e,t,n,o){let l=[],d=0;e.doc.nodesBetween(t,n,(f,g)=>{if(!f.isInline)return;d++;let b=null;if(o instanceof MarkType){let _=f.marks,S;for(;S=o.isInSet(_);)(b||(b=[])).push(S),_=S.removeFromSet(_)}else o?o.isInSet(f.marks)&&(b=[o]):b=f.marks;if(b&&b.length){let _=Math.min(g+f.nodeSize,n);for(let S=0;S<b.length;S++){let R=b[S],C;for(let E=0;E<l.length;E++){let A=l[E];A.step==d-1&&R.eq(l[E].style)&&(C=A)}C?(C.to=_,C.step=d):l.push({style:R,from:Math.max(g,t),to:_,step:d})}}}),l.forEach(f=>e.step(new RemoveMarkStep(f.from,f.to,f.style)))}function clearIncompatible(e,t,n,o=n.contentMatch,l=!0){let d=e.doc.nodeAt(t),f=[],g=t+1;for(let b=0;b<d.childCount;b++){let _=d.child(b),S=g+_.nodeSize,R=o.matchType(_.type);if(!R)f.push(new ReplaceStep(g,S,Slice.empty));else{o=R;for(let C=0;C<_.marks.length;C++)n.allowsMarkType(_.marks[C].type)||e.step(new RemoveMarkStep(g,S,_.marks[C]));if(l&&_.isText&&n.whitespace!="pre"){let C,E=/\r?\n|\r/g,A;for(;C=E.exec(_.text);)A||(A=new Slice(Fragment.from(n.schema.text(" ",n.allowedMarks(_.marks))),0,0)),f.push(new ReplaceStep(g+C.index,g+C.index+C[0].length,A))}}g=S}if(!o.validEnd){let b=o.fillBefore(Fragment.empty,!0);e.replace(g,g,new Slice(b,0,0))}for(let b=f.length-1;b>=0;b--)e.step(f[b])}function canCut(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function liftTarget(e){let n=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let o=e.depth,l=0,d=0;;--o){let f=e.$from.node(o),g=e.$from.index(o)+l,b=e.$to.indexAfter(o)-d;if(o<e.depth&&f.canReplace(g,b,n))return o;if(o==0||f.type.spec.isolating||!canCut(f,g,b))break;g&&(l=1),b<f.childCount&&(d=1)}return null}function lift$2(e,t,n){let{$from:o,$to:l,depth:d}=t,f=o.before(d+1),g=l.after(d+1),b=f,_=g,S=Fragment.empty,R=0;for(let A=d,M=!1;A>n;A--)M||o.index(A)>0?(M=!0,S=Fragment.from(o.node(A).copy(S)),R++):b--;let C=Fragment.empty,E=0;for(let A=d,M=!1;A>n;A--)M||l.after(A+1)<l.end(A)?(M=!0,C=Fragment.from(l.node(A).copy(C)),E++):_++;e.step(new ReplaceAroundStep(b,_,f,g,new Slice(S.append(C),R,E),S.size-R,!0))}function findWrapping(e,t,n=null,o=e){let l=findWrappingOutside(e,t),d=l&&findWrappingInside(o,t);return d?l.map(withAttrs).concat({type:t,attrs:n}).concat(d.map(withAttrs)):null}function withAttrs(e){return{type:e,attrs:null}}function findWrappingOutside(e,t){let{parent:n,startIndex:o,endIndex:l}=e,d=n.contentMatchAt(o).findWrapping(t);if(!d)return null;let f=d.length?d[0]:t;return n.canReplaceWith(o,l,f)?d:null}function findWrappingInside(e,t){let{parent:n,startIndex:o,endIndex:l}=e,d=n.child(o),f=t.contentMatch.findWrapping(d.type);if(!f)return null;let b=(f.length?f[f.length-1]:t).contentMatch;for(let _=o;b&&_<l;_++)b=b.matchType(n.child(_).type);return!b||!b.validEnd?null:f}function wrap(e,t,n){let o=Fragment.empty;for(let f=n.length-1;f>=0;f--){if(o.size){let g=n[f].type.contentMatch.matchFragment(o);if(!g||!g.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}o=Fragment.from(n[f].type.create(n[f].attrs,o))}let l=t.start,d=t.end;e.step(new ReplaceAroundStep(l,d,l,d,new Slice(o,0,0),n.length,!0))}function setBlockType$1(e,t,n,o,l){if(!o.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let d=e.steps.length;e.doc.nodesBetween(t,n,(f,g)=>{let b=typeof l=="function"?l(f):l;if(f.isTextblock&&!f.hasMarkup(o,b)&&canChangeType(e.doc,e.mapping.slice(d).map(g),o)){let _=null;if(o.schema.linebreakReplacement){let E=o.whitespace=="pre",A=!!o.contentMatch.matchType(o.schema.linebreakReplacement);E&&!A?_=!1:!E&&A&&(_=!0)}_===!1&&replaceLinebreaks(e,f,g,d),clearIncompatible(e,e.mapping.slice(d).map(g,1),o,void 0,_===null);let S=e.mapping.slice(d),R=S.map(g,1),C=S.map(g+f.nodeSize,1);return e.step(new ReplaceAroundStep(R,C,R+1,C-1,new Slice(Fragment.from(o.create(b,null,f.marks)),0,0),1,!0)),_===!0&&replaceNewlines(e,f,g,d),!1}})}function replaceNewlines(e,t,n,o){t.forEach((l,d)=>{if(l.isText){let f,g=/\r?\n|\r/g;for(;f=g.exec(l.text);){let b=e.mapping.slice(o).map(n+1+d+f.index);e.replaceWith(b,b+1,t.type.schema.linebreakReplacement.create())}}})}function replaceLinebreaks(e,t,n,o){t.forEach((l,d)=>{if(l.type==l.type.schema.linebreakReplacement){let f=e.mapping.slice(o).map(n+1+d);e.replaceWith(f,f+1,t.type.schema.text(`
|
|
1281
|
-
`))}})}function canChangeType(e,t,n){let o=e.resolve(t),l=o.index();return o.parent.canReplaceWith(l,l+1,n)}function setNodeMarkup(e,t,n,o,l){let d=e.doc.nodeAt(t);if(!d)throw new RangeError("No node at given position");n||(n=d.type);let f=n.create(o,null,l||d.marks);if(d.isLeaf)return e.replaceWith(t,t+d.nodeSize,f);if(!n.validContent(d.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new ReplaceAroundStep(t,t+d.nodeSize,t+1,t+d.nodeSize-1,new Slice(Fragment.from(f),0,0),1,!0))}function canSplit(e,t,n=1,o){let l=e.resolve(t),d=l.depth-n,f=o&&o[o.length-1]||l.parent;if(d<0||l.parent.type.spec.isolating||!l.parent.canReplace(l.index(),l.parent.childCount)||!f.type.validContent(l.parent.content.cutByIndex(l.index(),l.parent.childCount)))return!1;for(let _=l.depth-1,S=n-2;_>d;_--,S--){let R=l.node(_),C=l.index(_);if(R.type.spec.isolating)return!1;let E=R.content.cutByIndex(C,R.childCount),A=o&&o[S+1];A&&(E=E.replaceChild(0,A.type.create(A.attrs)));let M=o&&o[S]||R;if(!R.canReplace(C+1,R.childCount)||!M.type.validContent(E))return!1}let g=l.indexAfter(d),b=o&&o[0];return l.node(d).canReplaceWith(g,g,b?b.type:l.node(d+1).type)}function split(e,t,n=1,o){let l=e.doc.resolve(t),d=Fragment.empty,f=Fragment.empty;for(let g=l.depth,b=l.depth-n,_=n-1;g>b;g--,_--){d=Fragment.from(l.node(g).copy(d));let S=o&&o[_];f=Fragment.from(S?S.type.create(S.attrs,f):l.node(g).copy(f))}e.step(new ReplaceStep(t,t,new Slice(d.append(f),n,n),!0))}function canJoin(e,t){let n=e.resolve(t),o=n.index();return joinable(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(o,o+1)}function canAppendWithSubstitutedLinebreaks(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:o}=e.type.schema;for(let l=0;l<t.childCount;l++){let d=t.child(l),f=d.type==o?e.type.schema.nodes.text:d.type;if(n=n.matchType(f),!n||!e.type.allowsMarks(d.marks))return!1}return n.validEnd}function joinable(e,t){return!!(e&&t&&!e.isLeaf&&canAppendWithSubstitutedLinebreaks(e,t))}function joinPoint(e,t,n=-1){let o=e.resolve(t);for(let l=o.depth;;l--){let d,f,g=o.index(l);if(l==o.depth?(d=o.nodeBefore,f=o.nodeAfter):n>0?(d=o.node(l+1),g++,f=o.node(l).maybeChild(g)):(d=o.node(l).maybeChild(g-1),f=o.node(l+1)),d&&!d.isTextblock&&joinable(d,f)&&o.node(l).canReplace(g,g+1))return t;if(l==0)break;t=n<0?o.before(l):o.after(l)}}function join(e,t,n){let o=null,{linebreakReplacement:l}=e.doc.type.schema,d=e.doc.resolve(t-n),f=d.node().type;if(l&&f.inlineContent){let S=f.whitespace=="pre",R=!!f.contentMatch.matchType(l);S&&!R?o=!1:!S&&R&&(o=!0)}let g=e.steps.length;if(o===!1){let S=e.doc.resolve(t+n);replaceLinebreaks(e,S.node(),S.before(),g)}f.inlineContent&&clearIncompatible(e,t+n-1,f,d.node().contentMatchAt(d.index()),o==null);let b=e.mapping.slice(g),_=b.map(t-n);if(e.step(new ReplaceStep(_,b.map(t+n,-1),Slice.empty,!0)),o===!0){let S=e.doc.resolve(_);replaceNewlines(e,S.node(),S.before(),e.steps.length)}return e}function insertPoint(e,t,n){let o=e.resolve(t);if(o.parent.canReplaceWith(o.index(),o.index(),n))return t;if(o.parentOffset==0)for(let l=o.depth-1;l>=0;l--){let d=o.index(l);if(o.node(l).canReplaceWith(d,d,n))return o.before(l+1);if(d>0)return null}if(o.parentOffset==o.parent.content.size)for(let l=o.depth-1;l>=0;l--){let d=o.indexAfter(l);if(o.node(l).canReplaceWith(d,d,n))return o.after(l+1);if(d<o.node(l).childCount)return null}return null}function dropPoint(e,t,n){let o=e.resolve(t);if(!n.content.size)return t;let l=n.content;for(let d=0;d<n.openStart;d++)l=l.firstChild.content;for(let d=1;d<=(n.openStart==0&&n.size?2:1);d++)for(let f=o.depth;f>=0;f--){let g=f==o.depth?0:o.pos<=(o.start(f+1)+o.end(f+1))/2?-1:1,b=o.index(f)+(g>0?1:0),_=o.node(f),S=!1;if(d==1)S=_.canReplace(b,b,l);else{let R=_.contentMatchAt(b).findWrapping(l.firstChild.type);S=R&&_.canReplaceWith(b,b,R[0])}if(S)return g==0?o.pos:g<0?o.before(f+1):o.after(f+1)}return null}function replaceStep(e,t,n=t,o=Slice.empty){if(t==n&&!o.size)return null;let l=e.resolve(t),d=e.resolve(n);return fitsTrivially(l,d,o)?new ReplaceStep(t,n,o):new Fitter(l,d,o).fit()}function fitsTrivially(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}class Fitter{constructor(t,n,o){this.$from=t,this.$to=n,this.unplaced=o,this.frontier=[],this.placed=Fragment.empty;for(let l=0;l<=t.depth;l++){let d=t.node(l);this.frontier.push({type:d.type,match:d.contentMatchAt(t.indexAfter(l))})}for(let l=t.depth;l>0;l--)this.placed=Fragment.from(t.node(l).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let _=this.findFittable();_?this.placeNodes(_):this.openMore()||this.dropNode()}let t=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,o=this.$from,l=this.close(t<0?this.$to:o.doc.resolve(t));if(!l)return null;let d=this.placed,f=o.depth,g=l.depth;for(;f&&g&&d.childCount==1;)d=d.firstChild.content,f--,g--;let b=new Slice(d,f,g);return t>-1?new ReplaceAroundStep(o.pos,t,this.$to.pos,this.$to.end(),b,n):b.size||o.pos!=this.$to.pos?new ReplaceStep(o.pos,l.pos,b):null}findFittable(){let t=this.unplaced.openStart;for(let n=this.unplaced.content,o=0,l=this.unplaced.openEnd;o<t;o++){let d=n.firstChild;if(n.childCount>1&&(l=0),d.type.spec.isolating&&l<=o){t=o;break}n=d.content}for(let n=1;n<=2;n++)for(let o=n==1?t:this.unplaced.openStart;o>=0;o--){let l,d=null;o?(d=contentAt(this.unplaced.content,o-1).firstChild,l=d.content):l=this.unplaced.content;let f=l.firstChild;for(let g=this.depth;g>=0;g--){let{type:b,match:_}=this.frontier[g],S,R=null;if(n==1&&(f?_.matchType(f.type)||(R=_.fillBefore(Fragment.from(f),!1)):d&&b.compatibleContent(d.type)))return{sliceDepth:o,frontierDepth:g,parent:d,inject:R};if(n==2&&f&&(S=_.findWrapping(f.type)))return{sliceDepth:o,frontierDepth:g,parent:d,wrap:S};if(d&&_.matchType(d.type))break}}}openMore(){let{content:t,openStart:n,openEnd:o}=this.unplaced,l=contentAt(t,n);return!l.childCount||l.firstChild.isLeaf?!1:(this.unplaced=new Slice(t,n+1,Math.max(o,l.size+n>=t.size-o?n+1:0)),!0)}dropNode(){let{content:t,openStart:n,openEnd:o}=this.unplaced,l=contentAt(t,n);if(l.childCount<=1&&n>0){let d=t.size-n<=n+l.size;this.unplaced=new Slice(dropFromFragment(t,n-1,1),n-1,d?n-1:o)}else this.unplaced=new Slice(dropFromFragment(t,n,1),n,o)}placeNodes({sliceDepth:t,frontierDepth:n,parent:o,inject:l,wrap:d}){for(;this.depth>n;)this.closeFrontierNode();if(d)for(let M=0;M<d.length;M++)this.openFrontierNode(d[M]);let f=this.unplaced,g=o?o.content:f.content,b=f.openStart-t,_=0,S=[],{match:R,type:C}=this.frontier[n];if(l){for(let M=0;M<l.childCount;M++)S.push(l.child(M));R=R.matchFragment(l)}let E=g.size+t-(f.content.size-f.openEnd);for(;_<g.childCount;){let M=g.child(_),I=R.matchType(M.type);if(!I)break;_++,(_>1||b==0||M.content.size)&&(R=I,S.push(closeNodeStart(M.mark(C.allowedMarks(M.marks)),_==1?b:0,_==g.childCount?E:-1)))}let A=_==g.childCount;A||(E=-1),this.placed=addToFragment(this.placed,n,Fragment.from(S)),this.frontier[n].match=R,A&&E<0&&o&&o.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let M=0,I=g;M<E;M++){let j=I.lastChild;this.frontier.push({type:j.type,match:j.contentMatchAt(j.childCount)}),I=j.content}this.unplaced=A?t==0?Slice.empty:new Slice(dropFromFragment(f.content,t-1,1),t-1,E<0?f.openEnd:t-1):new Slice(dropFromFragment(f.content,t,_),f.openStart,f.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t=this.frontier[this.depth],n;if(!t.type.isTextblock||!contentAfterFits(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:o}=this.$to,l=this.$to.after(o);for(;o>1&&l==this.$to.end(--o);)++l;return l}findCloseLevel(t){e:for(let n=Math.min(this.depth,t.depth);n>=0;n--){let{match:o,type:l}=this.frontier[n],d=n<t.depth&&t.end(n+1)==t.pos+(t.depth-(n+1)),f=contentAfterFits(t,n,l,o,d);if(f){for(let g=n-1;g>=0;g--){let{match:b,type:_}=this.frontier[g],S=contentAfterFits(t,g,_,b,!0);if(!S||S.childCount)continue e}return{depth:n,fit:f,move:d?t.doc.resolve(t.after(n+1)):t}}}}close(t){let n=this.findCloseLevel(t);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=addToFragment(this.placed,n.depth,n.fit)),t=n.move;for(let o=n.depth+1;o<=t.depth;o++){let l=t.node(o),d=l.type.contentMatch.fillBefore(l.content,!0,t.index(o));this.openFrontierNode(l.type,l.attrs,d)}return t}openFrontierNode(t,n=null,o){let l=this.frontier[this.depth];l.match=l.match.matchType(t),this.placed=addToFragment(this.placed,this.depth,Fragment.from(t.create(n,o))),this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(Fragment.empty,!0);n.childCount&&(this.placed=addToFragment(this.placed,this.frontier.length,n))}}function dropFromFragment(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(dropFromFragment(e.firstChild.content,t-1,n)))}function addToFragment(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(addToFragment(e.lastChild.content,t-1,n)))}function contentAt(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function closeNodeStart(e,t,n){if(t<=0)return e;let o=e.content;return t>1&&(o=o.replaceChild(0,closeNodeStart(o.firstChild,t-1,o.childCount==1?n-1:0))),t>0&&(o=e.type.contentMatch.fillBefore(o).append(o),n<=0&&(o=o.append(e.type.contentMatch.matchFragment(o).fillBefore(Fragment.empty,!0)))),e.copy(o)}function contentAfterFits(e,t,n,o,l){let d=e.node(t),f=l?e.indexAfter(t):e.index(t);if(f==d.childCount&&!n.compatibleContent(d.type))return null;let g=o.fillBefore(d.content,!0,f);return g&&!invalidMarks(n,d.content,f)?g:null}function invalidMarks(e,t,n){for(let o=n;o<t.childCount;o++)if(!e.allowsMarks(t.child(o).marks))return!0;return!1}function definesContent(e){return e.spec.defining||e.spec.definingForContent}function replaceRange(e,t,n,o){if(!o.size)return e.deleteRange(t,n);let l=e.doc.resolve(t),d=e.doc.resolve(n);if(fitsTrivially(l,d,o))return e.step(new ReplaceStep(t,n,o));let f=coveredDepths(l,d);f[f.length-1]==0&&f.pop();let g=-(l.depth+1);f.unshift(g);for(let C=l.depth,E=l.pos-1;C>0;C--,E--){let A=l.node(C).type.spec;if(A.defining||A.definingAsContext||A.isolating)break;f.indexOf(C)>-1?g=C:l.before(C)==E&&f.splice(1,0,-C)}let b=f.indexOf(g),_=[],S=o.openStart;for(let C=o.content,E=0;;E++){let A=C.firstChild;if(_.push(A),E==o.openStart)break;C=A.content}for(let C=S-1;C>=0;C--){let E=_[C],A=definesContent(E.type);if(A&&!E.sameMarkup(l.node(Math.abs(g)-1)))S=C;else if(A||!E.type.isTextblock)break}for(let C=o.openStart;C>=0;C--){let E=(C+S+1)%(o.openStart+1),A=_[E];if(A)for(let M=0;M<f.length;M++){let I=f[(M+b)%f.length],j=!0;I<0&&(j=!1,I=-I);let q=l.node(I-1),Q=l.index(I-1);if(q.canReplaceWith(Q,Q,A.type,A.marks))return e.replace(l.before(I),j?d.after(I):n,new Slice(closeFragment(o.content,0,o.openStart,E),E,o.openEnd))}}let R=e.steps.length;for(let C=f.length-1;C>=0&&(e.replace(t,n,o),!(e.steps.length>R));C--){let E=f[C];E<0||(t=l.before(E),n=d.after(E))}}function closeFragment(e,t,n,o,l){if(t<n){let d=e.firstChild;e=e.replaceChild(0,d.copy(closeFragment(d.content,t+1,n,o,d)))}if(t>o){let d=l.contentMatchAt(0),f=d.fillBefore(e).append(e);e=f.append(d.matchFragment(f).fillBefore(Fragment.empty,!0))}return e}function replaceRangeWith(e,t,n,o){if(!o.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let l=insertPoint(e.doc,t,o.type);l!=null&&(t=n=l)}e.replaceRange(t,n,new Slice(Fragment.from(o),0,0))}function deleteRange$1(e,t,n){let o=e.doc.resolve(t),l=e.doc.resolve(n),d=coveredDepths(o,l);for(let f=0;f<d.length;f++){let g=d[f],b=f==d.length-1;if(b&&g==0||o.node(g).type.contentMatch.validEnd)return e.delete(o.start(g),l.end(g));if(g>0&&(b||o.node(g-1).canReplace(o.index(g-1),l.indexAfter(g-1))))return e.delete(o.before(g),l.after(g))}for(let f=1;f<=o.depth&&f<=l.depth;f++)if(t-o.start(f)==o.depth-f&&n>o.end(f)&&l.end(f)-n!=l.depth-f&&o.start(f-1)==l.start(f-1)&&o.node(f-1).canReplace(o.index(f-1),l.index(f-1)))return e.delete(o.before(f),n);e.delete(t,n)}function coveredDepths(e,t){let n=[],o=Math.min(e.depth,t.depth);for(let l=o;l>=0;l--){let d=e.start(l);if(d<e.pos-(e.depth-l)||t.end(l)>t.pos+(t.depth-l)||e.node(l).type.spec.isolating||t.node(l).type.spec.isolating)break;(d==t.start(l)||l==e.depth&&l==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&l&&t.start(l-1)==d-1)&&n.push(l)}return n}class AttrStep extends Step{constructor(t,n,o){super(),this.pos=t,this.attr=n,this.value=o}apply(t){let n=t.nodeAt(this.pos);if(!n)return StepResult.fail("No node at attribute step's position");let o=Object.create(null);for(let d in n.attrs)o[d]=n.attrs[d];o[this.attr]=this.value;let l=n.type.create(o,null,n.marks);return StepResult.fromReplace(t,this.pos,this.pos+1,new Slice(Fragment.from(l),0,n.isLeaf?0:1))}getMap(){return StepMap.empty}invert(t){return new AttrStep(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new AttrStep(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new AttrStep(n.pos,n.attr,n.value)}}Step.jsonID("attr",AttrStep);class DocAttrStep extends Step{constructor(t,n){super(),this.attr=t,this.value=n}apply(t){let n=Object.create(null);for(let l in t.attrs)n[l]=t.attrs[l];n[this.attr]=this.value;let o=t.type.create(n,t.content,t.marks);return StepResult.ok(o)}getMap(){return StepMap.empty}invert(t){return new DocAttrStep(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new DocAttrStep(n.attr,n.value)}}Step.jsonID("docAttr",DocAttrStep);let TransformError=class extends Error{};TransformError=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},TransformError.prototype=Object.create(Error.prototype),TransformError.prototype.constructor=TransformError,TransformError.prototype.name="TransformError";class Transform{constructor(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new Mapping}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let n=this.maybeStep(t);if(n.failed)throw new TransformError(n.failed);return this}maybeStep(t){let n=t.apply(this.doc);return n.failed||this.addStep(t,n.doc),n}get docChanged(){return this.steps.length>0}addStep(t,n){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=n}replace(t,n=t,o=Slice.empty){let l=replaceStep(this.doc,t,n,o);return l&&this.step(l),this}replaceWith(t,n,o){return this.replace(t,n,new Slice(Fragment.from(o),0,0))}delete(t,n){return this.replace(t,n,Slice.empty)}insert(t,n){return this.replaceWith(t,t,n)}replaceRange(t,n,o){return replaceRange(this,t,n,o),this}replaceRangeWith(t,n,o){return replaceRangeWith(this,t,n,o),this}deleteRange(t,n){return deleteRange$1(this,t,n),this}lift(t,n){return lift$2(this,t,n),this}join(t,n=1){return join(this,t,n),this}wrap(t,n){return wrap(this,t,n),this}setBlockType(t,n=t,o,l=null){return setBlockType$1(this,t,n,o,l),this}setNodeMarkup(t,n,o=null,l){return setNodeMarkup(this,t,n,o,l),this}setNodeAttribute(t,n,o){return this.step(new AttrStep(t,n,o)),this}setDocAttribute(t,n){return this.step(new DocAttrStep(t,n)),this}addNodeMark(t,n){return this.step(new AddNodeMarkStep(t,n)),this}removeNodeMark(t,n){let o=this.doc.nodeAt(t);if(!o)throw new RangeError("No node at position "+t);if(n instanceof Mark$1)n.isInSet(o.marks)&&this.step(new RemoveNodeMarkStep(t,n));else{let l=o.marks,d,f=[];for(;d=n.isInSet(l);)f.push(new RemoveNodeMarkStep(t,d)),l=d.removeFromSet(l);for(let g=f.length-1;g>=0;g--)this.step(f[g])}return this}split(t,n=1,o){return split(this,t,n,o),this}addMark(t,n,o){return addMark(this,t,n,o),this}removeMark(t,n,o){return removeMark(this,t,n,o),this}clearIncompatible(t,n,o){return clearIncompatible(this,t,n,o),this}}const classesById=Object.create(null);class Selection{constructor(t,n,o){this.$anchor=t,this.$head=n,this.ranges=o||[new SelectionRange(t.min(n),t.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let t=this.ranges;for(let n=0;n<t.length;n++)if(t[n].$from.pos!=t[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,n=Slice.empty){let o=n.content.lastChild,l=null;for(let g=0;g<n.openEnd;g++)l=o,o=o.lastChild;let d=t.steps.length,f=this.ranges;for(let g=0;g<f.length;g++){let{$from:b,$to:_}=f[g],S=t.mapping.slice(d);t.replaceRange(S.map(b.pos),S.map(_.pos),g?Slice.empty:n),g==0&&selectionToInsertionEnd$1(t,d,(o?o.isInline:l&&l.isTextblock)?-1:1)}}replaceWith(t,n){let o=t.steps.length,l=this.ranges;for(let d=0;d<l.length;d++){let{$from:f,$to:g}=l[d],b=t.mapping.slice(o),_=b.map(f.pos),S=b.map(g.pos);d?t.deleteRange(_,S):(t.replaceRangeWith(_,S,n),selectionToInsertionEnd$1(t,o,n.isInline?-1:1))}}static findFrom(t,n,o=!1){let l=t.parent.inlineContent?new TextSelection(t):findSelectionIn(t.node(0),t.parent,t.pos,t.index(),n,o);if(l)return l;for(let d=t.depth-1;d>=0;d--){let f=n<0?findSelectionIn(t.node(0),t.node(d),t.before(d+1),t.index(d),n,o):findSelectionIn(t.node(0),t.node(d),t.after(d+1),t.index(d)+1,n,o);if(f)return f}return null}static near(t,n=1){return this.findFrom(t,n)||this.findFrom(t,-n)||new AllSelection(t.node(0))}static atStart(t){return findSelectionIn(t,t,0,0,1)||new AllSelection(t)}static atEnd(t){return findSelectionIn(t,t,t.content.size,t.childCount,-1)||new AllSelection(t)}static fromJSON(t,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let o=classesById[n.type];if(!o)throw new RangeError(`No selection type ${n.type} defined`);return o.fromJSON(t,n)}static jsonID(t,n){if(t in classesById)throw new RangeError("Duplicate use of selection JSON ID "+t);return classesById[t]=n,n.prototype.jsonID=t,n}getBookmark(){return TextSelection.between(this.$anchor,this.$head).getBookmark()}}Selection.prototype.visible=!0;class SelectionRange{constructor(t,n){this.$from=t,this.$to=n}}let warnedAboutTextSelection=!1;function checkTextSelection(e){!warnedAboutTextSelection&&!e.parent.inlineContent&&(warnedAboutTextSelection=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class TextSelection extends Selection{constructor(t,n=t){checkTextSelection(t),checkTextSelection(n),super(t,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let o=t.resolve(n.map(this.head));if(!o.parent.inlineContent)return Selection.near(o);let l=t.resolve(n.map(this.anchor));return new TextSelection(l.parent.inlineContent?l:o,o)}replace(t,n=Slice.empty){if(super.replace(t,n),n==Slice.empty){let o=this.$from.marksAcross(this.$to);o&&t.ensureMarks(o)}}eq(t){return t instanceof TextSelection&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new TextBookmark(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new TextSelection(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,o=n){let l=t.resolve(n);return new this(l,o==n?l:t.resolve(o))}static between(t,n,o){let l=t.pos-n.pos;if((!o||l)&&(o=l>=0?1:-1),!n.parent.inlineContent){let d=Selection.findFrom(n,o,!0)||Selection.findFrom(n,-o,!0);if(d)n=d.$head;else return Selection.near(n,o)}return t.parent.inlineContent||(l==0?t=n:(t=(Selection.findFrom(t,-o,!0)||Selection.findFrom(t,o,!0)).$anchor,t.pos<n.pos!=l<0&&(t=n))),new TextSelection(t,n)}}Selection.jsonID("text",TextSelection);class TextBookmark{constructor(t,n){this.anchor=t,this.head=n}map(t){return new TextBookmark(t.map(this.anchor),t.map(this.head))}resolve(t){return TextSelection.between(t.resolve(this.anchor),t.resolve(this.head))}}class NodeSelection extends Selection{constructor(t){let n=t.nodeAfter,o=t.node(0).resolve(t.pos+n.nodeSize);super(t,o),this.node=n}map(t,n){let{deleted:o,pos:l}=n.mapResult(this.anchor),d=t.resolve(l);return o?Selection.near(d):new NodeSelection(d)}content(){return new Slice(Fragment.from(this.node),0,0)}eq(t){return t instanceof NodeSelection&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new NodeBookmark(this.anchor)}static fromJSON(t,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new NodeSelection(t.resolve(n.anchor))}static create(t,n){return new NodeSelection(t.resolve(n))}static isSelectable(t){return!t.isText&&t.type.spec.selectable!==!1}}NodeSelection.prototype.visible=!1,Selection.jsonID("node",NodeSelection);class NodeBookmark{constructor(t){this.anchor=t}map(t){let{deleted:n,pos:o}=t.mapResult(this.anchor);return n?new TextBookmark(o,o):new NodeBookmark(o)}resolve(t){let n=t.resolve(this.anchor),o=n.nodeAfter;return o&&NodeSelection.isSelectable(o)?new NodeSelection(n):Selection.near(n)}}class AllSelection extends Selection{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,n=Slice.empty){if(n==Slice.empty){t.delete(0,t.doc.content.size);let o=Selection.atStart(t.doc);o.eq(t.selection)||t.setSelection(o)}else super.replace(t,n)}toJSON(){return{type:"all"}}static fromJSON(t){return new AllSelection(t)}map(t){return new AllSelection(t)}eq(t){return t instanceof AllSelection}getBookmark(){return AllBookmark}}Selection.jsonID("all",AllSelection);const AllBookmark={map(){return this},resolve(e){return new AllSelection(e)}};function findSelectionIn(e,t,n,o,l,d=!1){if(t.inlineContent)return TextSelection.create(e,n);for(let f=o-(l>0?0:1);l>0?f<t.childCount:f>=0;f+=l){let g=t.child(f);if(g.isAtom){if(!d&&NodeSelection.isSelectable(g))return NodeSelection.create(e,n-(l<0?g.nodeSize:0))}else{let b=findSelectionIn(e,g,n+l,l<0?g.childCount:0,l,d);if(b)return b}n+=g.nodeSize*l}return null}function selectionToInsertionEnd$1(e,t,n){let o=e.steps.length-1;if(o<t)return;let l=e.steps[o];if(!(l instanceof ReplaceStep||l instanceof ReplaceAroundStep))return;let d=e.mapping.maps[o],f;d.forEach((g,b,_,S)=>{f==null&&(f=S)}),e.setSelection(Selection.near(e.doc.resolve(f),n))}const UPDATED_SEL=1,UPDATED_MARKS=2,UPDATED_SCROLL=4;class Transaction extends Transform{constructor(t){super(t.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=t.selection,this.storedMarks=t.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(t){if(t.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=t,this.curSelectionFor=this.steps.length,this.updated=(this.updated|UPDATED_SEL)&~UPDATED_MARKS,this.storedMarks=null,this}get selectionSet(){return(this.updated&UPDATED_SEL)>0}setStoredMarks(t){return this.storedMarks=t,this.updated|=UPDATED_MARKS,this}ensureMarks(t){return Mark$1.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this}addStoredMark(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&UPDATED_MARKS)>0}addStep(t,n){super.addStep(t,n),this.updated=this.updated&~UPDATED_MARKS,this.storedMarks=null}setTime(t){return this.time=t,this}replaceSelection(t){return this.selection.replace(this,t),this}replaceSelectionWith(t,n=!0){let o=this.selection;return n&&(t=t.mark(this.storedMarks||(o.empty?o.$from.marks():o.$from.marksAcross(o.$to)||Mark$1.none))),o.replaceWith(this,t),this}deleteSelection(){return this.selection.replace(this),this}insertText(t,n,o){let l=this.doc.type.schema;if(n==null)return t?this.replaceSelectionWith(l.text(t),!0):this.deleteSelection();{if(o==null&&(o=n),!t)return this.deleteRange(n,o);let d=this.storedMarks;if(!d){let f=this.doc.resolve(n);d=o==n?f.marks():f.marksAcross(this.doc.resolve(o))}return this.replaceRangeWith(n,o,l.text(t,d)),!this.selection.empty&&this.selection.to==n+t.length&&this.setSelection(Selection.near(this.selection.$to)),this}}setMeta(t,n){return this.meta[typeof t=="string"?t:t.key]=n,this}getMeta(t){return this.meta[typeof t=="string"?t:t.key]}get isGeneric(){for(let t in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=UPDATED_SCROLL,this}get scrolledIntoView(){return(this.updated&UPDATED_SCROLL)>0}}function bind(e,t){return!t||!e?e:e.bind(t)}class FieldDesc{constructor(t,n,o){this.name=t,this.init=bind(n.init,o),this.apply=bind(n.apply,o)}}const baseFields=[new FieldDesc("doc",{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new FieldDesc("selection",{init(e,t){return e.selection||Selection.atStart(t.doc)},apply(e){return e.selection}}),new FieldDesc("storedMarks",{init(e){return e.storedMarks||null},apply(e,t,n,o){return o.selection.$cursor?e.storedMarks:null}}),new FieldDesc("scrollToSelection",{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})];class Configuration{constructor(t,n){this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=baseFields.slice(),n&&n.forEach(o=>{if(this.pluginsByKey[o.key])throw new RangeError("Adding different instances of a keyed plugin ("+o.key+")");this.plugins.push(o),this.pluginsByKey[o.key]=o,o.spec.state&&this.fields.push(new FieldDesc(o.key,o.spec.state,o))})}}class EditorState{constructor(t){this.config=t}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(t){return this.applyTransaction(t).state}filterTransaction(t,n=-1){for(let o=0;o<this.config.plugins.length;o++)if(o!=n){let l=this.config.plugins[o];if(l.spec.filterTransaction&&!l.spec.filterTransaction.call(l,t,this))return!1}return!0}applyTransaction(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};let n=[t],o=this.applyInner(t),l=null;for(;;){let d=!1;for(let f=0;f<this.config.plugins.length;f++){let g=this.config.plugins[f];if(g.spec.appendTransaction){let b=l?l[f].n:0,_=l?l[f].state:this,S=b<n.length&&g.spec.appendTransaction.call(g,b?n.slice(b):n,_,o);if(S&&o.filterTransaction(S,f)){if(S.setMeta("appendedTransaction",t),!l){l=[];for(let R=0;R<this.config.plugins.length;R++)l.push(R<f?{state:o,n:n.length}:{state:this,n:0})}n.push(S),o=o.applyInner(S),d=!0}l&&(l[f]={state:o,n:n.length})}}if(!d)return{state:o,transactions:n}}}applyInner(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new EditorState(this.config),o=this.config.fields;for(let l=0;l<o.length;l++){let d=o[l];n[d.name]=d.apply(t,this[d.name],this,n)}return n}get tr(){return new Transaction(this)}static create(t){let n=new Configuration(t.doc?t.doc.type.schema:t.schema,t.plugins),o=new EditorState(n);for(let l=0;l<n.fields.length;l++)o[n.fields[l].name]=n.fields[l].init(t,o);return o}reconfigure(t){let n=new Configuration(this.schema,t.plugins),o=n.fields,l=new EditorState(n);for(let d=0;d<o.length;d++){let f=o[d].name;l[f]=this.hasOwnProperty(f)?this[f]:o[d].init(t,l)}return l}toJSON(t){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(o=>o.toJSON())),t&&typeof t=="object")for(let o in t){if(o=="doc"||o=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let l=t[o],d=l.spec.state;d&&d.toJSON&&(n[o]=d.toJSON.call(l,this[l.key]))}return n}static fromJSON(t,n,o){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let l=new Configuration(t.schema,t.plugins),d=new EditorState(l);return l.fields.forEach(f=>{if(f.name=="doc")d.doc=Node$2.fromJSON(t.schema,n.doc);else if(f.name=="selection")d.selection=Selection.fromJSON(d.doc,n.selection);else if(f.name=="storedMarks")n.storedMarks&&(d.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(o)for(let g in o){let b=o[g],_=b.spec.state;if(b.key==f.name&&_&&_.fromJSON&&Object.prototype.hasOwnProperty.call(n,g)){d[f.name]=_.fromJSON.call(b,t,n[g],d);return}}d[f.name]=f.init(t,d)}}),d}}function bindProps(e,t,n){for(let o in e){let l=e[o];l instanceof Function?l=l.bind(t):o=="handleDOMEvents"&&(l=bindProps(l,t,{})),n[o]=l}return n}class Plugin{constructor(t){this.spec=t,this.props={},t.props&&bindProps(t.props,this,this.props),this.key=t.key?t.key.key:createKey("plugin")}getState(t){return t[this.key]}}const keys=Object.create(null);function createKey(e){return e in keys?e+"$"+ ++keys[e]:(keys[e]=0,e+"$")}class PluginKey{constructor(t="key"){this.key=createKey(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const domIndex=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},parentNode=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t};let reusedRange=null;const textRange=function(e,t,n){let o=reusedRange||(reusedRange=document.createRange());return o.setEnd(e,n??e.nodeValue.length),o.setStart(e,t||0),o},clearReusedRange=function(){reusedRange=null},isEquivalentPosition=function(e,t,n,o){return n&&(scanFor(e,t,n,o,-1)||scanFor(e,t,n,o,1))},atomElements=/^(img|br|input|textarea|hr)$/i;function scanFor(e,t,n,o,l){for(var d;;){if(e==n&&t==o)return!0;if(t==(l<0?0:nodeSize(e))){let f=e.parentNode;if(!f||f.nodeType!=1||hasBlockDesc(e)||atomElements.test(e.nodeName)||e.contentEditable=="false")return!1;t=domIndex(e)+(l<0?0:1),e=f}else if(e.nodeType==1){let f=e.childNodes[t+(l<0?-1:0)];if(f.nodeType==1&&f.contentEditable=="false")if(!((d=f.pmViewDesc)===null||d===void 0)&&d.ignoreForSelection)t+=l;else return!1;else e=f,t=l<0?nodeSize(e):0}else return!1}}function nodeSize(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function textNodeBefore$1(e,t){for(;;){if(e.nodeType==3&&t)return e;if(e.nodeType==1&&t>0){if(e.contentEditable=="false")return null;e=e.childNodes[t-1],t=nodeSize(e)}else if(e.parentNode&&!hasBlockDesc(e))t=domIndex(e),e=e.parentNode;else return null}}function textNodeAfter$1(e,t){for(;;){if(e.nodeType==3&&t<e.nodeValue.length)return e;if(e.nodeType==1&&t<e.childNodes.length){if(e.contentEditable=="false")return null;e=e.childNodes[t],t=0}else if(e.parentNode&&!hasBlockDesc(e))t=domIndex(e)+1,e=e.parentNode;else return null}}function isOnEdge(e,t,n){for(let o=t==0,l=t==nodeSize(e);o||l;){if(e==n)return!0;let d=domIndex(e);if(e=e.parentNode,!e)return!1;o=o&&d==0,l=l&&d==nodeSize(e)}}function hasBlockDesc(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const selectionCollapsed=function(e){return e.focusNode&&isEquivalentPosition(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function keyEvent(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}function deepActiveElement(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function caretFromPoint(e,t,n){if(e.caretPositionFromPoint)try{let o=e.caretPositionFromPoint(t,n);if(o)return{node:o.offsetNode,offset:Math.min(nodeSize(o.offsetNode),o.offset)}}catch{}if(e.caretRangeFromPoint){let o=e.caretRangeFromPoint(t,n);if(o)return{node:o.startContainer,offset:Math.min(nodeSize(o.startContainer),o.startOffset)}}}const nav=typeof navigator<"u"?navigator:null,doc=typeof document<"u"?document:null,agent=nav&&nav.userAgent||"",ie_edge=/Edge\/(\d+)/.exec(agent),ie_upto10=/MSIE \d/.exec(agent),ie_11up=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(agent),ie$1=!!(ie_upto10||ie_11up||ie_edge),ie_version=ie_upto10?document.documentMode:ie_11up?+ie_11up[1]:ie_edge?+ie_edge[1]:0,gecko=!ie$1&&/gecko\/(\d+)/i.test(agent);gecko&&+(/Firefox\/(\d+)/.exec(agent)||[0,0])[1];const _chrome=!ie$1&&/Chrome\/(\d+)/.exec(agent),chrome=!!_chrome,chrome_version=_chrome?+_chrome[1]:0,safari=!ie$1&&!!nav&&/Apple Computer/.test(nav.vendor),ios=safari&&(/Mobile\/\w+/.test(agent)||!!nav&&nav.maxTouchPoints>2),mac$2=ios||(nav?/Mac/.test(nav.platform):!1),windows$1=nav?/Win/.test(nav.platform):!1,android=/Android \d/.test(agent),webkit=!!doc&&"webkitFontSmoothing"in doc.documentElement.style,webkit_version=webkit?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function windowRect(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function getSide(e,t){return typeof e=="number"?e:e[t]}function clientRect(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,o=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*o}}function scrollRectIntoView(e,t,n){let o=e.someProp("scrollThreshold")||0,l=e.someProp("scrollMargin")||5,d=e.dom.ownerDocument;for(let f=n||e.dom;f;){if(f.nodeType!=1){f=parentNode(f);continue}let g=f,b=g==d.body,_=b?windowRect(d):clientRect(g),S=0,R=0;if(t.top<_.top+getSide(o,"top")?R=-(_.top-t.top+getSide(l,"top")):t.bottom>_.bottom-getSide(o,"bottom")&&(R=t.bottom-t.top>_.bottom-_.top?t.top+getSide(l,"top")-_.top:t.bottom-_.bottom+getSide(l,"bottom")),t.left<_.left+getSide(o,"left")?S=-(_.left-t.left+getSide(l,"left")):t.right>_.right-getSide(o,"right")&&(S=t.right-_.right+getSide(l,"right")),S||R)if(b)d.defaultView.scrollBy(S,R);else{let E=g.scrollLeft,A=g.scrollTop;R&&(g.scrollTop+=R),S&&(g.scrollLeft+=S);let M=g.scrollLeft-E,I=g.scrollTop-A;t={left:t.left-M,top:t.top-I,right:t.right-M,bottom:t.bottom-I}}let C=b?"fixed":getComputedStyle(f).position;if(/^(fixed|sticky)$/.test(C))break;f=C=="absolute"?f.offsetParent:parentNode(f)}}function storeScrollPos(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),o,l;for(let d=(t.left+t.right)/2,f=n+1;f<Math.min(innerHeight,t.bottom);f+=5){let g=e.root.elementFromPoint(d,f);if(!g||g==e.dom||!e.dom.contains(g))continue;let b=g.getBoundingClientRect();if(b.top>=n-20){o=g,l=b.top;break}}return{refDOM:o,refTop:l,stack:scrollStack(e.dom)}}function scrollStack(e){let t=[],n=e.ownerDocument;for(let o=e;o&&(t.push({dom:o,top:o.scrollTop,left:o.scrollLeft}),e!=n);o=parentNode(o));return t}function resetScrollPos({refDOM:e,refTop:t,stack:n}){let o=e?e.getBoundingClientRect().top:0;restoreScrollStack(n,o==0?0:o-t)}function restoreScrollStack(e,t){for(let n=0;n<e.length;n++){let{dom:o,top:l,left:d}=e[n];o.scrollTop!=l+t&&(o.scrollTop=l+t),o.scrollLeft!=d&&(o.scrollLeft=d)}}let preventScrollSupported=null;function focusPreventScroll(e){if(e.setActive)return e.setActive();if(preventScrollSupported)return e.focus(preventScrollSupported);let t=scrollStack(e);e.focus(preventScrollSupported==null?{get preventScroll(){return preventScrollSupported={preventScroll:!0},!0}}:void 0),preventScrollSupported||(preventScrollSupported=!1,restoreScrollStack(t,0))}function findOffsetInNode(e,t){let n,o=2e8,l,d=0,f=t.top,g=t.top,b,_;for(let S=e.firstChild,R=0;S;S=S.nextSibling,R++){let C;if(S.nodeType==1)C=S.getClientRects();else if(S.nodeType==3)C=textRange(S).getClientRects();else continue;for(let E=0;E<C.length;E++){let A=C[E];if(A.top<=f&&A.bottom>=g){f=Math.max(A.bottom,f),g=Math.min(A.top,g);let M=A.left>t.left?A.left-t.left:A.right<t.left?t.left-A.right:0;if(M<o){n=S,o=M,l=M&&n.nodeType==3?{left:A.right<t.left?A.right:A.left,top:t.top}:t,S.nodeType==1&&M&&(d=R+(t.left>=(A.left+A.right)/2?1:0));continue}}else A.top>t.top&&!b&&A.left<=t.left&&A.right>=t.left&&(b=S,_={left:Math.max(A.left,Math.min(A.right,t.left)),top:A.top});!n&&(t.left>=A.right&&t.top>=A.top||t.left>=A.left&&t.top>=A.bottom)&&(d=R+1)}}return!n&&b&&(n=b,l=_,o=0),n&&n.nodeType==3?findOffsetInText(n,l):!n||o&&n.nodeType==1?{node:e,offset:d}:findOffsetInNode(n,l)}function findOffsetInText(e,t){let n=e.nodeValue.length,o=document.createRange();for(let l=0;l<n;l++){o.setEnd(e,l+1),o.setStart(e,l);let d=singleRect(o,1);if(d.top!=d.bottom&&inRect(t,d))return{node:e,offset:l+(t.left>=(d.left+d.right)/2?1:0)}}return{node:e,offset:0}}function inRect(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function targetKludge(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}function posFromElement(e,t,n){let{node:o,offset:l}=findOffsetInNode(t,n),d=-1;if(o.nodeType==1&&!o.firstChild){let f=o.getBoundingClientRect();d=f.left!=f.right&&n.left>(f.left+f.right)/2?1:-1}return e.docView.posFromDOM(o,l,d)}function posFromCaret(e,t,n,o){let l=-1;for(let d=t,f=!1;d!=e.dom;){let g=e.docView.nearestDesc(d,!0),b;if(!g)return null;if(g.dom.nodeType==1&&(g.node.isBlock&&g.parent||!g.contentDOM)&&((b=g.dom.getBoundingClientRect()).width||b.height)&&(g.node.isBlock&&g.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(g.dom.nodeName)&&(!f&&b.left>o.left||b.top>o.top?l=g.posBefore:(!f&&b.right<o.left||b.bottom<o.top)&&(l=g.posAfter),f=!0),!g.contentDOM&&l<0&&!g.node.isText))return(g.node.isBlock?o.top<(b.top+b.bottom)/2:o.left<(b.left+b.right)/2)?g.posBefore:g.posAfter;d=g.dom.parentNode}return l>-1?l:e.docView.posFromDOM(t,n,-1)}function elementFromPoint(e,t,n){let o=e.childNodes.length;if(o&&n.top<n.bottom)for(let l=Math.max(0,Math.min(o-1,Math.floor(o*(t.top-n.top)/(n.bottom-n.top))-2)),d=l;;){let f=e.childNodes[d];if(f.nodeType==1){let g=f.getClientRects();for(let b=0;b<g.length;b++){let _=g[b];if(inRect(t,_))return elementFromPoint(f,t,_)}}if((d=(d+1)%o)==l)break}return e}function posAtCoords(e,t){let n=e.dom.ownerDocument,o,l=0,d=caretFromPoint(n,t.left,t.top);d&&({node:o,offset:l}=d);let f=(e.root.elementFromPoint?e.root:n).elementFromPoint(t.left,t.top),g;if(!f||!e.dom.contains(f.nodeType!=1?f.parentNode:f)){let _=e.dom.getBoundingClientRect();if(!inRect(t,_)||(f=elementFromPoint(e.dom,t,_),!f))return null}if(safari)for(let _=f;o&&_;_=parentNode(_))_.draggable&&(o=void 0);if(f=targetKludge(f,t),o){if(gecko&&o.nodeType==1&&(l=Math.min(l,o.childNodes.length),l<o.childNodes.length)){let S=o.childNodes[l],R;S.nodeName=="IMG"&&(R=S.getBoundingClientRect()).right<=t.left&&R.bottom>t.top&&l++}let _;webkit&&l&&o.nodeType==1&&(_=o.childNodes[l-1]).nodeType==1&&_.contentEditable=="false"&&_.getBoundingClientRect().top>=t.top&&l--,o==e.dom&&l==o.childNodes.length-1&&o.lastChild.nodeType==1&&t.top>o.lastChild.getBoundingClientRect().bottom?g=e.state.doc.content.size:(l==0||o.nodeType!=1||o.childNodes[l-1].nodeName!="BR")&&(g=posFromCaret(e,o,l,t))}g==null&&(g=posFromElement(e,f,t));let b=e.docView.nearestDesc(f,!0);return{pos:g,inside:b?b.posAtStart-b.border:-1}}function nonZero(e){return e.top<e.bottom||e.left<e.right}function singleRect(e,t){let n=e.getClientRects();if(n.length){let o=n[t<0?0:n.length-1];if(nonZero(o))return o}return Array.prototype.find.call(n,nonZero)||e.getBoundingClientRect()}const BIDI=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function coordsAtPos(e,t,n){let{node:o,offset:l,atom:d}=e.docView.domFromPos(t,n<0?-1:1),f=webkit||gecko;if(o.nodeType==3)if(f&&(BIDI.test(o.nodeValue)||(n<0?!l:l==o.nodeValue.length))){let b=singleRect(textRange(o,l,l),n);if(gecko&&l&&/\s/.test(o.nodeValue[l-1])&&l<o.nodeValue.length){let _=singleRect(textRange(o,l-1,l-1),-1);if(_.top==b.top){let S=singleRect(textRange(o,l,l+1),-1);if(S.top!=b.top)return flattenV(S,S.left<_.left)}}return b}else{let b=l,_=l,S=n<0?1:-1;return n<0&&!l?(_++,S=-1):n>=0&&l==o.nodeValue.length?(b--,S=1):n<0?b--:_++,flattenV(singleRect(textRange(o,b,_),S),S<0)}if(!e.state.doc.resolve(t-(d||0)).parent.inlineContent){if(d==null&&l&&(n<0||l==nodeSize(o))){let b=o.childNodes[l-1];if(b.nodeType==1)return flattenH(b.getBoundingClientRect(),!1)}if(d==null&&l<nodeSize(o)){let b=o.childNodes[l];if(b.nodeType==1)return flattenH(b.getBoundingClientRect(),!0)}return flattenH(o.getBoundingClientRect(),n>=0)}if(d==null&&l&&(n<0||l==nodeSize(o))){let b=o.childNodes[l-1],_=b.nodeType==3?textRange(b,nodeSize(b)-(f?0:1)):b.nodeType==1&&(b.nodeName!="BR"||!b.nextSibling)?b:null;if(_)return flattenV(singleRect(_,1),!1)}if(d==null&&l<nodeSize(o)){let b=o.childNodes[l];for(;b.pmViewDesc&&b.pmViewDesc.ignoreForCoords;)b=b.nextSibling;let _=b?b.nodeType==3?textRange(b,0,f?0:1):b.nodeType==1?b:null:null;if(_)return flattenV(singleRect(_,-1),!0)}return flattenV(singleRect(o.nodeType==3?textRange(o):o,-n),n>=0)}function flattenV(e,t){if(e.width==0)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function flattenH(e,t){if(e.height==0)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function withFlushedState(e,t,n){let o=e.state,l=e.root.activeElement;o!=t&&e.updateState(t),l!=e.dom&&e.focus();try{return n()}finally{o!=t&&e.updateState(o),l!=e.dom&&l&&l.focus()}}function endOfTextblockVertical(e,t,n){let o=t.selection,l=n=="up"?o.$from:o.$to;return withFlushedState(e,t,()=>{let{node:d}=e.docView.domFromPos(l.pos,n=="up"?-1:1);for(;;){let g=e.docView.nearestDesc(d,!0);if(!g)break;if(g.node.isBlock){d=g.contentDOM||g.dom;break}d=g.dom.parentNode}let f=coordsAtPos(e,l.pos,1);for(let g=d.firstChild;g;g=g.nextSibling){let b;if(g.nodeType==1)b=g.getClientRects();else if(g.nodeType==3)b=textRange(g,0,g.nodeValue.length).getClientRects();else continue;for(let _=0;_<b.length;_++){let S=b[_];if(S.bottom>S.top+1&&(n=="up"?f.top-S.top>(S.bottom-f.top)*2:S.bottom-f.bottom>(f.bottom-S.top)*2))return!1}}return!0})}const maybeRTL=/[\u0590-\u08ac]/;function endOfTextblockHorizontal(e,t,n){let{$head:o}=t.selection;if(!o.parent.isTextblock)return!1;let l=o.parentOffset,d=!l,f=l==o.parent.content.size,g=e.domSelection();return g?!maybeRTL.test(o.parent.textContent)||!g.modify?n=="left"||n=="backward"?d:f:withFlushedState(e,t,()=>{let{focusNode:b,focusOffset:_,anchorNode:S,anchorOffset:R}=e.domSelectionRange(),C=g.caretBidiLevel;g.modify("move",n,"character");let E=o.depth?e.docView.domAfterPos(o.before()):e.dom,{focusNode:A,focusOffset:M}=e.domSelectionRange(),I=A&&!E.contains(A.nodeType==1?A:A.parentNode)||b==A&&_==M;try{g.collapse(S,R),b&&(b!=S||_!=R)&&g.extend&&g.extend(b,_)}catch{}return C!=null&&(g.caretBidiLevel=C),I}):o.pos==o.start()||o.pos==o.end()}let cachedState=null,cachedDir=null,cachedResult=!1;function endOfTextblock(e,t,n){return cachedState==t&&cachedDir==n?cachedResult:(cachedState=t,cachedDir=n,cachedResult=n=="up"||n=="down"?endOfTextblockVertical(e,t,n):endOfTextblockHorizontal(e,t,n))}const NOT_DIRTY=0,CHILD_DIRTY=1,CONTENT_DIRTY=2,NODE_DIRTY=3;class ViewDesc{constructor(t,n,o,l){this.parent=t,this.children=n,this.dom=o,this.contentDOM=l,this.dirty=NOT_DIRTY,o.pmViewDesc=this}matchesWidget(t){return!1}matchesMark(t){return!1}matchesNode(t,n,o){return!1}matchesHack(t){return!1}parseRule(){return null}stopEvent(t){return!1}get size(){let t=0;for(let n=0;n<this.children.length;n++)t+=this.children[n].size;return t}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let t=0;t<this.children.length;t++)this.children[t].destroy()}posBeforeChild(t){for(let n=0,o=this.posAtStart;;n++){let l=this.children[n];if(l==t)return o;o+=l.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(t,n,o){if(this.contentDOM&&this.contentDOM.contains(t.nodeType==1?t:t.parentNode))if(o<0){let d,f;if(t==this.contentDOM)d=t.childNodes[n-1];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;d=t.previousSibling}for(;d&&!((f=d.pmViewDesc)&&f.parent==this);)d=d.previousSibling;return d?this.posBeforeChild(f)+f.size:this.posAtStart}else{let d,f;if(t==this.contentDOM)d=t.childNodes[n];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;d=t.nextSibling}for(;d&&!((f=d.pmViewDesc)&&f.parent==this);)d=d.nextSibling;return d?this.posBeforeChild(f):this.posAtEnd}let l;if(t==this.dom&&this.contentDOM)l=n>domIndex(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))l=t.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let d=t;;d=d.parentNode){if(d==this.dom){l=!1;break}if(d.previousSibling)break}if(l==null&&n==t.childNodes.length)for(let d=t;;d=d.parentNode){if(d==this.dom){l=!0;break}if(d.nextSibling)break}}return l??o>0?this.posAtEnd:this.posAtStart}nearestDesc(t,n=!1){for(let o=!0,l=t;l;l=l.parentNode){let d=this.getDesc(l),f;if(d&&(!n||d.node))if(o&&(f=d.nodeDOM)&&!(f.nodeType==1?f.contains(t.nodeType==1?t:t.parentNode):f==t))o=!1;else return d}}getDesc(t){let n=t.pmViewDesc;for(let o=n;o;o=o.parent)if(o==this)return n}posFromDOM(t,n,o){for(let l=t;l;l=l.parentNode){let d=this.getDesc(l);if(d)return d.localPosFromDOM(t,n,o)}return-1}descAt(t){for(let n=0,o=0;n<this.children.length;n++){let l=this.children[n],d=o+l.size;if(o==t&&d!=o){for(;!l.border&&l.children.length;)for(let f=0;f<l.children.length;f++){let g=l.children[f];if(g.size){l=g;break}}return l}if(t<d)return l.descAt(t-o-l.border);o=d}}domFromPos(t,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let o=0,l=0;for(let d=0;o<this.children.length;o++){let f=this.children[o],g=d+f.size;if(g>t||f instanceof TrailingHackViewDesc){l=t-d;break}d=g}if(l)return this.children[o].domFromPos(l-this.children[o].border,n);for(let d;o&&!(d=this.children[o-1]).size&&d instanceof WidgetViewDesc&&d.side>=0;o--);if(n<=0){let d,f=!0;for(;d=o?this.children[o-1]:null,!(!d||d.dom.parentNode==this.contentDOM);o--,f=!1);return d&&n&&f&&!d.border&&!d.domAtom?d.domFromPos(d.size,n):{node:this.contentDOM,offset:d?domIndex(d.dom)+1:0}}else{let d,f=!0;for(;d=o<this.children.length?this.children[o]:null,!(!d||d.dom.parentNode==this.contentDOM);o++,f=!1);return d&&f&&!d.border&&!d.domAtom?d.domFromPos(0,n):{node:this.contentDOM,offset:d?domIndex(d.dom):this.contentDOM.childNodes.length}}}parseRange(t,n,o=0){if(this.children.length==0)return{node:this.contentDOM,from:t,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let l=-1,d=-1;for(let f=o,g=0;;g++){let b=this.children[g],_=f+b.size;if(l==-1&&t<=_){let S=f+b.border;if(t>=S&&n<=_-b.border&&b.node&&b.contentDOM&&this.contentDOM.contains(b.contentDOM))return b.parseRange(t,n,S);t=f;for(let R=g;R>0;R--){let C=this.children[R-1];if(C.size&&C.dom.parentNode==this.contentDOM&&!C.emptyChildAt(1)){l=domIndex(C.dom)+1;break}t-=C.size}l==-1&&(l=0)}if(l>-1&&(_>n||g==this.children.length-1)){n=_;for(let S=g+1;S<this.children.length;S++){let R=this.children[S];if(R.size&&R.dom.parentNode==this.contentDOM&&!R.emptyChildAt(-1)){d=domIndex(R.dom);break}n+=R.size}d==-1&&(d=this.contentDOM.childNodes.length);break}f=_}return{node:this.contentDOM,from:t,to:n,fromOffset:l,toOffset:d}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[t<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(t)}domAfterPos(t){let{node:n,offset:o}=this.domFromPos(t,0);if(n.nodeType!=1||o==n.childNodes.length)throw new RangeError("No node after pos "+t);return n.childNodes[o]}setSelection(t,n,o,l=!1){let d=Math.min(t,n),f=Math.max(t,n);for(let E=0,A=0;E<this.children.length;E++){let M=this.children[E],I=A+M.size;if(d>A&&f<I)return M.setSelection(t-A-M.border,n-A-M.border,o,l);A=I}let g=this.domFromPos(t,t?-1:1),b=n==t?g:this.domFromPos(n,n?-1:1),_=o.root.getSelection(),S=o.domSelectionRange(),R=!1;if((gecko||safari)&&t==n){let{node:E,offset:A}=g;if(E.nodeType==3){if(R=!!(A&&E.nodeValue[A-1]==`
|
|
1281
|
+
`))}})}function canChangeType(e,t,n){let o=e.resolve(t),l=o.index();return o.parent.canReplaceWith(l,l+1,n)}function setNodeMarkup(e,t,n,o,l){let d=e.doc.nodeAt(t);if(!d)throw new RangeError("No node at given position");n||(n=d.type);let f=n.create(o,null,l||d.marks);if(d.isLeaf)return e.replaceWith(t,t+d.nodeSize,f);if(!n.validContent(d.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new ReplaceAroundStep(t,t+d.nodeSize,t+1,t+d.nodeSize-1,new Slice(Fragment.from(f),0,0),1,!0))}function canSplit(e,t,n=1,o){let l=e.resolve(t),d=l.depth-n,f=o&&o[o.length-1]||l.parent;if(d<0||l.parent.type.spec.isolating||!l.parent.canReplace(l.index(),l.parent.childCount)||!f.type.validContent(l.parent.content.cutByIndex(l.index(),l.parent.childCount)))return!1;for(let _=l.depth-1,S=n-2;_>d;_--,S--){let R=l.node(_),C=l.index(_);if(R.type.spec.isolating)return!1;let E=R.content.cutByIndex(C,R.childCount),A=o&&o[S+1];A&&(E=E.replaceChild(0,A.type.create(A.attrs)));let M=o&&o[S]||R;if(!R.canReplace(C+1,R.childCount)||!M.type.validContent(E))return!1}let g=l.indexAfter(d),b=o&&o[0];return l.node(d).canReplaceWith(g,g,b?b.type:l.node(d+1).type)}function split(e,t,n=1,o){let l=e.doc.resolve(t),d=Fragment.empty,f=Fragment.empty;for(let g=l.depth,b=l.depth-n,_=n-1;g>b;g--,_--){d=Fragment.from(l.node(g).copy(d));let S=o&&o[_];f=Fragment.from(S?S.type.create(S.attrs,f):l.node(g).copy(f))}e.step(new ReplaceStep(t,t,new Slice(d.append(f),n,n),!0))}function canJoin(e,t){let n=e.resolve(t),o=n.index();return joinable(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(o,o+1)}function canAppendWithSubstitutedLinebreaks(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:o}=e.type.schema;for(let l=0;l<t.childCount;l++){let d=t.child(l),f=d.type==o?e.type.schema.nodes.text:d.type;if(n=n.matchType(f),!n||!e.type.allowsMarks(d.marks))return!1}return n.validEnd}function joinable(e,t){return!!(e&&t&&!e.isLeaf&&canAppendWithSubstitutedLinebreaks(e,t))}function joinPoint(e,t,n=-1){let o=e.resolve(t);for(let l=o.depth;;l--){let d,f,g=o.index(l);if(l==o.depth?(d=o.nodeBefore,f=o.nodeAfter):n>0?(d=o.node(l+1),g++,f=o.node(l).maybeChild(g)):(d=o.node(l).maybeChild(g-1),f=o.node(l+1)),d&&!d.isTextblock&&joinable(d,f)&&o.node(l).canReplace(g,g+1))return t;if(l==0)break;t=n<0?o.before(l):o.after(l)}}function join(e,t,n){let o=null,{linebreakReplacement:l}=e.doc.type.schema,d=e.doc.resolve(t-n),f=d.node().type;if(l&&f.inlineContent){let S=f.whitespace=="pre",R=!!f.contentMatch.matchType(l);S&&!R?o=!1:!S&&R&&(o=!0)}let g=e.steps.length;if(o===!1){let S=e.doc.resolve(t+n);replaceLinebreaks(e,S.node(),S.before(),g)}f.inlineContent&&clearIncompatible(e,t+n-1,f,d.node().contentMatchAt(d.index()),o==null);let b=e.mapping.slice(g),_=b.map(t-n);if(e.step(new ReplaceStep(_,b.map(t+n,-1),Slice.empty,!0)),o===!0){let S=e.doc.resolve(_);replaceNewlines(e,S.node(),S.before(),e.steps.length)}return e}function insertPoint(e,t,n){let o=e.resolve(t);if(o.parent.canReplaceWith(o.index(),o.index(),n))return t;if(o.parentOffset==0)for(let l=o.depth-1;l>=0;l--){let d=o.index(l);if(o.node(l).canReplaceWith(d,d,n))return o.before(l+1);if(d>0)return null}if(o.parentOffset==o.parent.content.size)for(let l=o.depth-1;l>=0;l--){let d=o.indexAfter(l);if(o.node(l).canReplaceWith(d,d,n))return o.after(l+1);if(d<o.node(l).childCount)return null}return null}function dropPoint(e,t,n){let o=e.resolve(t);if(!n.content.size)return t;let l=n.content;for(let d=0;d<n.openStart;d++)l=l.firstChild.content;for(let d=1;d<=(n.openStart==0&&n.size?2:1);d++)for(let f=o.depth;f>=0;f--){let g=f==o.depth?0:o.pos<=(o.start(f+1)+o.end(f+1))/2?-1:1,b=o.index(f)+(g>0?1:0),_=o.node(f),S=!1;if(d==1)S=_.canReplace(b,b,l);else{let R=_.contentMatchAt(b).findWrapping(l.firstChild.type);S=R&&_.canReplaceWith(b,b,R[0])}if(S)return g==0?o.pos:g<0?o.before(f+1):o.after(f+1)}return null}function replaceStep(e,t,n=t,o=Slice.empty){if(t==n&&!o.size)return null;let l=e.resolve(t),d=e.resolve(n);return fitsTrivially(l,d,o)?new ReplaceStep(t,n,o):new Fitter(l,d,o).fit()}function fitsTrivially(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}class Fitter{constructor(t,n,o){this.$from=t,this.$to=n,this.unplaced=o,this.frontier=[],this.placed=Fragment.empty;for(let l=0;l<=t.depth;l++){let d=t.node(l);this.frontier.push({type:d.type,match:d.contentMatchAt(t.indexAfter(l))})}for(let l=t.depth;l>0;l--)this.placed=Fragment.from(t.node(l).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let _=this.findFittable();_?this.placeNodes(_):this.openMore()||this.dropNode()}let t=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,o=this.$from,l=this.close(t<0?this.$to:o.doc.resolve(t));if(!l)return null;let d=this.placed,f=o.depth,g=l.depth;for(;f&&g&&d.childCount==1;)d=d.firstChild.content,f--,g--;let b=new Slice(d,f,g);return t>-1?new ReplaceAroundStep(o.pos,t,this.$to.pos,this.$to.end(),b,n):b.size||o.pos!=this.$to.pos?new ReplaceStep(o.pos,l.pos,b):null}findFittable(){let t=this.unplaced.openStart;for(let n=this.unplaced.content,o=0,l=this.unplaced.openEnd;o<t;o++){let d=n.firstChild;if(n.childCount>1&&(l=0),d.type.spec.isolating&&l<=o){t=o;break}n=d.content}for(let n=1;n<=2;n++)for(let o=n==1?t:this.unplaced.openStart;o>=0;o--){let l,d=null;o?(d=contentAt(this.unplaced.content,o-1).firstChild,l=d.content):l=this.unplaced.content;let f=l.firstChild;for(let g=this.depth;g>=0;g--){let{type:b,match:_}=this.frontier[g],S,R=null;if(n==1&&(f?_.matchType(f.type)||(R=_.fillBefore(Fragment.from(f),!1)):d&&b.compatibleContent(d.type)))return{sliceDepth:o,frontierDepth:g,parent:d,inject:R};if(n==2&&f&&(S=_.findWrapping(f.type)))return{sliceDepth:o,frontierDepth:g,parent:d,wrap:S};if(d&&_.matchType(d.type))break}}}openMore(){let{content:t,openStart:n,openEnd:o}=this.unplaced,l=contentAt(t,n);return!l.childCount||l.firstChild.isLeaf?!1:(this.unplaced=new Slice(t,n+1,Math.max(o,l.size+n>=t.size-o?n+1:0)),!0)}dropNode(){let{content:t,openStart:n,openEnd:o}=this.unplaced,l=contentAt(t,n);if(l.childCount<=1&&n>0){let d=t.size-n<=n+l.size;this.unplaced=new Slice(dropFromFragment(t,n-1,1),n-1,d?n-1:o)}else this.unplaced=new Slice(dropFromFragment(t,n,1),n,o)}placeNodes({sliceDepth:t,frontierDepth:n,parent:o,inject:l,wrap:d}){for(;this.depth>n;)this.closeFrontierNode();if(d)for(let M=0;M<d.length;M++)this.openFrontierNode(d[M]);let f=this.unplaced,g=o?o.content:f.content,b=f.openStart-t,_=0,S=[],{match:R,type:C}=this.frontier[n];if(l){for(let M=0;M<l.childCount;M++)S.push(l.child(M));R=R.matchFragment(l)}let E=g.size+t-(f.content.size-f.openEnd);for(;_<g.childCount;){let M=g.child(_),I=R.matchType(M.type);if(!I)break;_++,(_>1||b==0||M.content.size)&&(R=I,S.push(closeNodeStart(M.mark(C.allowedMarks(M.marks)),_==1?b:0,_==g.childCount?E:-1)))}let A=_==g.childCount;A||(E=-1),this.placed=addToFragment(this.placed,n,Fragment.from(S)),this.frontier[n].match=R,A&&E<0&&o&&o.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let M=0,I=g;M<E;M++){let j=I.lastChild;this.frontier.push({type:j.type,match:j.contentMatchAt(j.childCount)}),I=j.content}this.unplaced=A?t==0?Slice.empty:new Slice(dropFromFragment(f.content,t-1,1),t-1,E<0?f.openEnd:t-1):new Slice(dropFromFragment(f.content,t,_),f.openStart,f.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t=this.frontier[this.depth],n;if(!t.type.isTextblock||!contentAfterFits(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:o}=this.$to,l=this.$to.after(o);for(;o>1&&l==this.$to.end(--o);)++l;return l}findCloseLevel(t){e:for(let n=Math.min(this.depth,t.depth);n>=0;n--){let{match:o,type:l}=this.frontier[n],d=n<t.depth&&t.end(n+1)==t.pos+(t.depth-(n+1)),f=contentAfterFits(t,n,l,o,d);if(f){for(let g=n-1;g>=0;g--){let{match:b,type:_}=this.frontier[g],S=contentAfterFits(t,g,_,b,!0);if(!S||S.childCount)continue e}return{depth:n,fit:f,move:d?t.doc.resolve(t.after(n+1)):t}}}}close(t){let n=this.findCloseLevel(t);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=addToFragment(this.placed,n.depth,n.fit)),t=n.move;for(let o=n.depth+1;o<=t.depth;o++){let l=t.node(o),d=l.type.contentMatch.fillBefore(l.content,!0,t.index(o));this.openFrontierNode(l.type,l.attrs,d)}return t}openFrontierNode(t,n=null,o){let l=this.frontier[this.depth];l.match=l.match.matchType(t),this.placed=addToFragment(this.placed,this.depth,Fragment.from(t.create(n,o))),this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(Fragment.empty,!0);n.childCount&&(this.placed=addToFragment(this.placed,this.frontier.length,n))}}function dropFromFragment(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(dropFromFragment(e.firstChild.content,t-1,n)))}function addToFragment(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(addToFragment(e.lastChild.content,t-1,n)))}function contentAt(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function closeNodeStart(e,t,n){if(t<=0)return e;let o=e.content;return t>1&&(o=o.replaceChild(0,closeNodeStart(o.firstChild,t-1,o.childCount==1?n-1:0))),t>0&&(o=e.type.contentMatch.fillBefore(o).append(o),n<=0&&(o=o.append(e.type.contentMatch.matchFragment(o).fillBefore(Fragment.empty,!0)))),e.copy(o)}function contentAfterFits(e,t,n,o,l){let d=e.node(t),f=l?e.indexAfter(t):e.index(t);if(f==d.childCount&&!n.compatibleContent(d.type))return null;let g=o.fillBefore(d.content,!0,f);return g&&!invalidMarks(n,d.content,f)?g:null}function invalidMarks(e,t,n){for(let o=n;o<t.childCount;o++)if(!e.allowsMarks(t.child(o).marks))return!0;return!1}function definesContent(e){return e.spec.defining||e.spec.definingForContent}function replaceRange(e,t,n,o){if(!o.size)return e.deleteRange(t,n);let l=e.doc.resolve(t),d=e.doc.resolve(n);if(fitsTrivially(l,d,o))return e.step(new ReplaceStep(t,n,o));let f=coveredDepths(l,d);f[f.length-1]==0&&f.pop();let g=-(l.depth+1);f.unshift(g);for(let C=l.depth,E=l.pos-1;C>0;C--,E--){let A=l.node(C).type.spec;if(A.defining||A.definingAsContext||A.isolating)break;f.indexOf(C)>-1?g=C:l.before(C)==E&&f.splice(1,0,-C)}let b=f.indexOf(g),_=[],S=o.openStart;for(let C=o.content,E=0;;E++){let A=C.firstChild;if(_.push(A),E==o.openStart)break;C=A.content}for(let C=S-1;C>=0;C--){let E=_[C],A=definesContent(E.type);if(A&&!E.sameMarkup(l.node(Math.abs(g)-1)))S=C;else if(A||!E.type.isTextblock)break}for(let C=o.openStart;C>=0;C--){let E=(C+S+1)%(o.openStart+1),A=_[E];if(A)for(let M=0;M<f.length;M++){let I=f[(M+b)%f.length],j=!0;I<0&&(j=!1,I=-I);let q=l.node(I-1),Q=l.index(I-1);if(q.canReplaceWith(Q,Q,A.type,A.marks))return e.replace(l.before(I),j?d.after(I):n,new Slice(closeFragment(o.content,0,o.openStart,E),E,o.openEnd))}}let R=e.steps.length;for(let C=f.length-1;C>=0&&(e.replace(t,n,o),!(e.steps.length>R));C--){let E=f[C];E<0||(t=l.before(E),n=d.after(E))}}function closeFragment(e,t,n,o,l){if(t<n){let d=e.firstChild;e=e.replaceChild(0,d.copy(closeFragment(d.content,t+1,n,o,d)))}if(t>o){let d=l.contentMatchAt(0),f=d.fillBefore(e).append(e);e=f.append(d.matchFragment(f).fillBefore(Fragment.empty,!0))}return e}function replaceRangeWith(e,t,n,o){if(!o.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let l=insertPoint(e.doc,t,o.type);l!=null&&(t=n=l)}e.replaceRange(t,n,new Slice(Fragment.from(o),0,0))}function deleteRange$1(e,t,n){let o=e.doc.resolve(t),l=e.doc.resolve(n),d=coveredDepths(o,l);for(let f=0;f<d.length;f++){let g=d[f],b=f==d.length-1;if(b&&g==0||o.node(g).type.contentMatch.validEnd)return e.delete(o.start(g),l.end(g));if(g>0&&(b||o.node(g-1).canReplace(o.index(g-1),l.indexAfter(g-1))))return e.delete(o.before(g),l.after(g))}for(let f=1;f<=o.depth&&f<=l.depth;f++)if(t-o.start(f)==o.depth-f&&n>o.end(f)&&l.end(f)-n!=l.depth-f&&o.start(f-1)==l.start(f-1)&&o.node(f-1).canReplace(o.index(f-1),l.index(f-1)))return e.delete(o.before(f),n);e.delete(t,n)}function coveredDepths(e,t){let n=[],o=Math.min(e.depth,t.depth);for(let l=o;l>=0;l--){let d=e.start(l);if(d<e.pos-(e.depth-l)||t.end(l)>t.pos+(t.depth-l)||e.node(l).type.spec.isolating||t.node(l).type.spec.isolating)break;(d==t.start(l)||l==e.depth&&l==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&l&&t.start(l-1)==d-1)&&n.push(l)}return n}class AttrStep extends Step{constructor(t,n,o){super(),this.pos=t,this.attr=n,this.value=o}apply(t){let n=t.nodeAt(this.pos);if(!n)return StepResult.fail("No node at attribute step's position");let o=Object.create(null);for(let d in n.attrs)o[d]=n.attrs[d];o[this.attr]=this.value;let l=n.type.create(o,null,n.marks);return StepResult.fromReplace(t,this.pos,this.pos+1,new Slice(Fragment.from(l),0,n.isLeaf?0:1))}getMap(){return StepMap.empty}invert(t){return new AttrStep(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new AttrStep(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new AttrStep(n.pos,n.attr,n.value)}}Step.jsonID("attr",AttrStep);class DocAttrStep extends Step{constructor(t,n){super(),this.attr=t,this.value=n}apply(t){let n=Object.create(null);for(let l in t.attrs)n[l]=t.attrs[l];n[this.attr]=this.value;let o=t.type.create(n,t.content,t.marks);return StepResult.ok(o)}getMap(){return StepMap.empty}invert(t){return new DocAttrStep(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new DocAttrStep(n.attr,n.value)}}Step.jsonID("docAttr",DocAttrStep);let TransformError=class extends Error{};TransformError=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},TransformError.prototype=Object.create(Error.prototype),TransformError.prototype.constructor=TransformError,TransformError.prototype.name="TransformError";class Transform{constructor(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new Mapping}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let n=this.maybeStep(t);if(n.failed)throw new TransformError(n.failed);return this}maybeStep(t){let n=t.apply(this.doc);return n.failed||this.addStep(t,n.doc),n}get docChanged(){return this.steps.length>0}addStep(t,n){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=n}replace(t,n=t,o=Slice.empty){let l=replaceStep(this.doc,t,n,o);return l&&this.step(l),this}replaceWith(t,n,o){return this.replace(t,n,new Slice(Fragment.from(o),0,0))}delete(t,n){return this.replace(t,n,Slice.empty)}insert(t,n){return this.replaceWith(t,t,n)}replaceRange(t,n,o){return replaceRange(this,t,n,o),this}replaceRangeWith(t,n,o){return replaceRangeWith(this,t,n,o),this}deleteRange(t,n){return deleteRange$1(this,t,n),this}lift(t,n){return lift$2(this,t,n),this}join(t,n=1){return join(this,t,n),this}wrap(t,n){return wrap(this,t,n),this}setBlockType(t,n=t,o,l=null){return setBlockType$1(this,t,n,o,l),this}setNodeMarkup(t,n,o=null,l){return setNodeMarkup(this,t,n,o,l),this}setNodeAttribute(t,n,o){return this.step(new AttrStep(t,n,o)),this}setDocAttribute(t,n){return this.step(new DocAttrStep(t,n)),this}addNodeMark(t,n){return this.step(new AddNodeMarkStep(t,n)),this}removeNodeMark(t,n){let o=this.doc.nodeAt(t);if(!o)throw new RangeError("No node at position "+t);if(n instanceof Mark$1)n.isInSet(o.marks)&&this.step(new RemoveNodeMarkStep(t,n));else{let l=o.marks,d,f=[];for(;d=n.isInSet(l);)f.push(new RemoveNodeMarkStep(t,d)),l=d.removeFromSet(l);for(let g=f.length-1;g>=0;g--)this.step(f[g])}return this}split(t,n=1,o){return split(this,t,n,o),this}addMark(t,n,o){return addMark(this,t,n,o),this}removeMark(t,n,o){return removeMark(this,t,n,o),this}clearIncompatible(t,n,o){return clearIncompatible(this,t,n,o),this}}const classesById=Object.create(null);class Selection{constructor(t,n,o){this.$anchor=t,this.$head=n,this.ranges=o||[new SelectionRange(t.min(n),t.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let t=this.ranges;for(let n=0;n<t.length;n++)if(t[n].$from.pos!=t[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,n=Slice.empty){let o=n.content.lastChild,l=null;for(let g=0;g<n.openEnd;g++)l=o,o=o.lastChild;let d=t.steps.length,f=this.ranges;for(let g=0;g<f.length;g++){let{$from:b,$to:_}=f[g],S=t.mapping.slice(d);t.replaceRange(S.map(b.pos),S.map(_.pos),g?Slice.empty:n),g==0&&selectionToInsertionEnd$1(t,d,(o?o.isInline:l&&l.isTextblock)?-1:1)}}replaceWith(t,n){let o=t.steps.length,l=this.ranges;for(let d=0;d<l.length;d++){let{$from:f,$to:g}=l[d],b=t.mapping.slice(o),_=b.map(f.pos),S=b.map(g.pos);d?t.deleteRange(_,S):(t.replaceRangeWith(_,S,n),selectionToInsertionEnd$1(t,o,n.isInline?-1:1))}}static findFrom(t,n,o=!1){let l=t.parent.inlineContent?new TextSelection(t):findSelectionIn(t.node(0),t.parent,t.pos,t.index(),n,o);if(l)return l;for(let d=t.depth-1;d>=0;d--){let f=n<0?findSelectionIn(t.node(0),t.node(d),t.before(d+1),t.index(d),n,o):findSelectionIn(t.node(0),t.node(d),t.after(d+1),t.index(d)+1,n,o);if(f)return f}return null}static near(t,n=1){return this.findFrom(t,n)||this.findFrom(t,-n)||new AllSelection(t.node(0))}static atStart(t){return findSelectionIn(t,t,0,0,1)||new AllSelection(t)}static atEnd(t){return findSelectionIn(t,t,t.content.size,t.childCount,-1)||new AllSelection(t)}static fromJSON(t,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let o=classesById[n.type];if(!o)throw new RangeError(`No selection type ${n.type} defined`);return o.fromJSON(t,n)}static jsonID(t,n){if(t in classesById)throw new RangeError("Duplicate use of selection JSON ID "+t);return classesById[t]=n,n.prototype.jsonID=t,n}getBookmark(){return TextSelection.between(this.$anchor,this.$head).getBookmark()}}Selection.prototype.visible=!0;class SelectionRange{constructor(t,n){this.$from=t,this.$to=n}}let warnedAboutTextSelection=!1;function checkTextSelection(e){!warnedAboutTextSelection&&!e.parent.inlineContent&&(warnedAboutTextSelection=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class TextSelection extends Selection{constructor(t,n=t){checkTextSelection(t),checkTextSelection(n),super(t,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let o=t.resolve(n.map(this.head));if(!o.parent.inlineContent)return Selection.near(o);let l=t.resolve(n.map(this.anchor));return new TextSelection(l.parent.inlineContent?l:o,o)}replace(t,n=Slice.empty){if(super.replace(t,n),n==Slice.empty){let o=this.$from.marksAcross(this.$to);o&&t.ensureMarks(o)}}eq(t){return t instanceof TextSelection&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new TextBookmark(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new TextSelection(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,o=n){let l=t.resolve(n);return new this(l,o==n?l:t.resolve(o))}static between(t,n,o){let l=t.pos-n.pos;if((!o||l)&&(o=l>=0?1:-1),!n.parent.inlineContent){let d=Selection.findFrom(n,o,!0)||Selection.findFrom(n,-o,!0);if(d)n=d.$head;else return Selection.near(n,o)}return t.parent.inlineContent||(l==0?t=n:(t=(Selection.findFrom(t,-o,!0)||Selection.findFrom(t,o,!0)).$anchor,t.pos<n.pos!=l<0&&(t=n))),new TextSelection(t,n)}}Selection.jsonID("text",TextSelection);class TextBookmark{constructor(t,n){this.anchor=t,this.head=n}map(t){return new TextBookmark(t.map(this.anchor),t.map(this.head))}resolve(t){return TextSelection.between(t.resolve(this.anchor),t.resolve(this.head))}}class NodeSelection extends Selection{constructor(t){let n=t.nodeAfter,o=t.node(0).resolve(t.pos+n.nodeSize);super(t,o),this.node=n}map(t,n){let{deleted:o,pos:l}=n.mapResult(this.anchor),d=t.resolve(l);return o?Selection.near(d):new NodeSelection(d)}content(){return new Slice(Fragment.from(this.node),0,0)}eq(t){return t instanceof NodeSelection&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new NodeBookmark(this.anchor)}static fromJSON(t,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new NodeSelection(t.resolve(n.anchor))}static create(t,n){return new NodeSelection(t.resolve(n))}static isSelectable(t){return!t.isText&&t.type.spec.selectable!==!1}}NodeSelection.prototype.visible=!1,Selection.jsonID("node",NodeSelection);class NodeBookmark{constructor(t){this.anchor=t}map(t){let{deleted:n,pos:o}=t.mapResult(this.anchor);return n?new TextBookmark(o,o):new NodeBookmark(o)}resolve(t){let n=t.resolve(this.anchor),o=n.nodeAfter;return o&&NodeSelection.isSelectable(o)?new NodeSelection(n):Selection.near(n)}}class AllSelection extends Selection{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,n=Slice.empty){if(n==Slice.empty){t.delete(0,t.doc.content.size);let o=Selection.atStart(t.doc);o.eq(t.selection)||t.setSelection(o)}else super.replace(t,n)}toJSON(){return{type:"all"}}static fromJSON(t){return new AllSelection(t)}map(t){return new AllSelection(t)}eq(t){return t instanceof AllSelection}getBookmark(){return AllBookmark}}Selection.jsonID("all",AllSelection);const AllBookmark={map(){return this},resolve(e){return new AllSelection(e)}};function findSelectionIn(e,t,n,o,l,d=!1){if(t.inlineContent)return TextSelection.create(e,n);for(let f=o-(l>0?0:1);l>0?f<t.childCount:f>=0;f+=l){let g=t.child(f);if(g.isAtom){if(!d&&NodeSelection.isSelectable(g))return NodeSelection.create(e,n-(l<0?g.nodeSize:0))}else{let b=findSelectionIn(e,g,n+l,l<0?g.childCount:0,l,d);if(b)return b}n+=g.nodeSize*l}return null}function selectionToInsertionEnd$1(e,t,n){let o=e.steps.length-1;if(o<t)return;let l=e.steps[o];if(!(l instanceof ReplaceStep||l instanceof ReplaceAroundStep))return;let d=e.mapping.maps[o],f;d.forEach((g,b,_,S)=>{f==null&&(f=S)}),e.setSelection(Selection.near(e.doc.resolve(f),n))}const UPDATED_SEL=1,UPDATED_MARKS=2,UPDATED_SCROLL=4;class Transaction extends Transform{constructor(t){super(t.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=t.selection,this.storedMarks=t.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(t){if(t.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=t,this.curSelectionFor=this.steps.length,this.updated=(this.updated|UPDATED_SEL)&~UPDATED_MARKS,this.storedMarks=null,this}get selectionSet(){return(this.updated&UPDATED_SEL)>0}setStoredMarks(t){return this.storedMarks=t,this.updated|=UPDATED_MARKS,this}ensureMarks(t){return Mark$1.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this}addStoredMark(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&UPDATED_MARKS)>0}addStep(t,n){super.addStep(t,n),this.updated=this.updated&~UPDATED_MARKS,this.storedMarks=null}setTime(t){return this.time=t,this}replaceSelection(t){return this.selection.replace(this,t),this}replaceSelectionWith(t,n=!0){let o=this.selection;return n&&(t=t.mark(this.storedMarks||(o.empty?o.$from.marks():o.$from.marksAcross(o.$to)||Mark$1.none))),o.replaceWith(this,t),this}deleteSelection(){return this.selection.replace(this),this}insertText(t,n,o){let l=this.doc.type.schema;if(n==null)return t?this.replaceSelectionWith(l.text(t),!0):this.deleteSelection();{if(o==null&&(o=n),!t)return this.deleteRange(n,o);let d=this.storedMarks;if(!d){let f=this.doc.resolve(n);d=o==n?f.marks():f.marksAcross(this.doc.resolve(o))}return this.replaceRangeWith(n,o,l.text(t,d)),!this.selection.empty&&this.selection.to==n+t.length&&this.setSelection(Selection.near(this.selection.$to)),this}}setMeta(t,n){return this.meta[typeof t=="string"?t:t.key]=n,this}getMeta(t){return this.meta[typeof t=="string"?t:t.key]}get isGeneric(){for(let t in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=UPDATED_SCROLL,this}get scrolledIntoView(){return(this.updated&UPDATED_SCROLL)>0}}function bind(e,t){return!t||!e?e:e.bind(t)}class FieldDesc{constructor(t,n,o){this.name=t,this.init=bind(n.init,o),this.apply=bind(n.apply,o)}}const baseFields=[new FieldDesc("doc",{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new FieldDesc("selection",{init(e,t){return e.selection||Selection.atStart(t.doc)},apply(e){return e.selection}}),new FieldDesc("storedMarks",{init(e){return e.storedMarks||null},apply(e,t,n,o){return o.selection.$cursor?e.storedMarks:null}}),new FieldDesc("scrollToSelection",{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})];class Configuration{constructor(t,n){this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=baseFields.slice(),n&&n.forEach(o=>{if(this.pluginsByKey[o.key])throw new RangeError("Adding different instances of a keyed plugin ("+o.key+")");this.plugins.push(o),this.pluginsByKey[o.key]=o,o.spec.state&&this.fields.push(new FieldDesc(o.key,o.spec.state,o))})}}class EditorState{constructor(t){this.config=t}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(t){return this.applyTransaction(t).state}filterTransaction(t,n=-1){for(let o=0;o<this.config.plugins.length;o++)if(o!=n){let l=this.config.plugins[o];if(l.spec.filterTransaction&&!l.spec.filterTransaction.call(l,t,this))return!1}return!0}applyTransaction(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};let n=[t],o=this.applyInner(t),l=null;for(;;){let d=!1;for(let f=0;f<this.config.plugins.length;f++){let g=this.config.plugins[f];if(g.spec.appendTransaction){let b=l?l[f].n:0,_=l?l[f].state:this,S=b<n.length&&g.spec.appendTransaction.call(g,b?n.slice(b):n,_,o);if(S&&o.filterTransaction(S,f)){if(S.setMeta("appendedTransaction",t),!l){l=[];for(let R=0;R<this.config.plugins.length;R++)l.push(R<f?{state:o,n:n.length}:{state:this,n:0})}n.push(S),o=o.applyInner(S),d=!0}l&&(l[f]={state:o,n:n.length})}}if(!d)return{state:o,transactions:n}}}applyInner(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new EditorState(this.config),o=this.config.fields;for(let l=0;l<o.length;l++){let d=o[l];n[d.name]=d.apply(t,this[d.name],this,n)}return n}get tr(){return new Transaction(this)}static create(t){let n=new Configuration(t.doc?t.doc.type.schema:t.schema,t.plugins),o=new EditorState(n);for(let l=0;l<n.fields.length;l++)o[n.fields[l].name]=n.fields[l].init(t,o);return o}reconfigure(t){let n=new Configuration(this.schema,t.plugins),o=n.fields,l=new EditorState(n);for(let d=0;d<o.length;d++){let f=o[d].name;l[f]=this.hasOwnProperty(f)?this[f]:o[d].init(t,l)}return l}toJSON(t){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(o=>o.toJSON())),t&&typeof t=="object")for(let o in t){if(o=="doc"||o=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let l=t[o],d=l.spec.state;d&&d.toJSON&&(n[o]=d.toJSON.call(l,this[l.key]))}return n}static fromJSON(t,n,o){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let l=new Configuration(t.schema,t.plugins),d=new EditorState(l);return l.fields.forEach(f=>{if(f.name=="doc")d.doc=Node$2.fromJSON(t.schema,n.doc);else if(f.name=="selection")d.selection=Selection.fromJSON(d.doc,n.selection);else if(f.name=="storedMarks")n.storedMarks&&(d.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(o)for(let g in o){let b=o[g],_=b.spec.state;if(b.key==f.name&&_&&_.fromJSON&&Object.prototype.hasOwnProperty.call(n,g)){d[f.name]=_.fromJSON.call(b,t,n[g],d);return}}d[f.name]=f.init(t,d)}}),d}}function bindProps(e,t,n){for(let o in e){let l=e[o];l instanceof Function?l=l.bind(t):o=="handleDOMEvents"&&(l=bindProps(l,t,{})),n[o]=l}return n}class Plugin{constructor(t){this.spec=t,this.props={},t.props&&bindProps(t.props,this,this.props),this.key=t.key?t.key.key:createKey("plugin")}getState(t){return t[this.key]}}const keys=Object.create(null);function createKey(e){return e in keys?e+"$"+ ++keys[e]:(keys[e]=0,e+"$")}class PluginKey{constructor(t="key"){this.key=createKey(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const domIndex=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},parentNode=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t};let reusedRange=null;const textRange=function(e,t,n){let o=reusedRange||(reusedRange=document.createRange());return o.setEnd(e,n??e.nodeValue.length),o.setStart(e,t||0),o},clearReusedRange=function(){reusedRange=null},isEquivalentPosition=function(e,t,n,o){return n&&(scanFor(e,t,n,o,-1)||scanFor(e,t,n,o,1))},atomElements=/^(img|br|input|textarea|hr)$/i;function scanFor(e,t,n,o,l){for(var d;;){if(e==n&&t==o)return!0;if(t==(l<0?0:nodeSize(e))){let f=e.parentNode;if(!f||f.nodeType!=1||hasBlockDesc(e)||atomElements.test(e.nodeName)||e.contentEditable=="false")return!1;t=domIndex(e)+(l<0?0:1),e=f}else if(e.nodeType==1){let f=e.childNodes[t+(l<0?-1:0)];if(f.nodeType==1&&f.contentEditable=="false")if(!((d=f.pmViewDesc)===null||d===void 0)&&d.ignoreForSelection)t+=l;else return!1;else e=f,t=l<0?nodeSize(e):0}else return!1}}function nodeSize(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function textNodeBefore$1(e,t){for(;;){if(e.nodeType==3&&t)return e;if(e.nodeType==1&&t>0){if(e.contentEditable=="false")return null;e=e.childNodes[t-1],t=nodeSize(e)}else if(e.parentNode&&!hasBlockDesc(e))t=domIndex(e),e=e.parentNode;else return null}}function textNodeAfter$1(e,t){for(;;){if(e.nodeType==3&&t<e.nodeValue.length)return e;if(e.nodeType==1&&t<e.childNodes.length){if(e.contentEditable=="false")return null;e=e.childNodes[t],t=0}else if(e.parentNode&&!hasBlockDesc(e))t=domIndex(e)+1,e=e.parentNode;else return null}}function isOnEdge(e,t,n){for(let o=t==0,l=t==nodeSize(e);o||l;){if(e==n)return!0;let d=domIndex(e);if(e=e.parentNode,!e)return!1;o=o&&d==0,l=l&&d==nodeSize(e)}}function hasBlockDesc(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const selectionCollapsed=function(e){return e.focusNode&&isEquivalentPosition(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function keyEvent(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}function deepActiveElement(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function caretFromPoint(e,t,n){if(e.caretPositionFromPoint)try{let o=e.caretPositionFromPoint(t,n);if(o)return{node:o.offsetNode,offset:Math.min(nodeSize(o.offsetNode),o.offset)}}catch{}if(e.caretRangeFromPoint){let o=e.caretRangeFromPoint(t,n);if(o)return{node:o.startContainer,offset:Math.min(nodeSize(o.startContainer),o.startOffset)}}}const nav=typeof navigator<"u"?navigator:null,doc=typeof document<"u"?document:null,agent=nav&&nav.userAgent||"",ie_edge=/Edge\/(\d+)/.exec(agent),ie_upto10=/MSIE \d/.exec(agent),ie_11up=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(agent),ie$1=!!(ie_upto10||ie_11up||ie_edge),ie_version=ie_upto10?document.documentMode:ie_11up?+ie_11up[1]:ie_edge?+ie_edge[1]:0,gecko=!ie$1&&/gecko\/(\d+)/i.test(agent);gecko&&+(/Firefox\/(\d+)/.exec(agent)||[0,0])[1];const _chrome=!ie$1&&/Chrome\/(\d+)/.exec(agent),chrome=!!_chrome,chrome_version=_chrome?+_chrome[1]:0,safari=!ie$1&&!!nav&&/Apple Computer/.test(nav.vendor),ios=safari&&(/Mobile\/\w+/.test(agent)||!!nav&&nav.maxTouchPoints>2),mac$2=ios||(nav?/Mac/.test(nav.platform):!1),windows$1=nav?/Win/.test(nav.platform):!1,android=/Android \d/.test(agent),webkit=!!doc&&"webkitFontSmoothing"in doc.documentElement.style,webkit_version=webkit?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function windowRect(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function getSide(e,t){return typeof e=="number"?e:e[t]}function clientRect(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,o=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*o}}function scrollRectIntoView(e,t,n){let o=e.someProp("scrollThreshold")||0,l=e.someProp("scrollMargin")||5,d=e.dom.ownerDocument;for(let f=n||e.dom;f;){if(f.nodeType!=1){f=parentNode(f);continue}let g=f,b=g==d.body,_=b?windowRect(d):clientRect(g),S=0,R=0;if(t.top<_.top+getSide(o,"top")?R=-(_.top-t.top+getSide(l,"top")):t.bottom>_.bottom-getSide(o,"bottom")&&(R=t.bottom-t.top>_.bottom-_.top?t.top+getSide(l,"top")-_.top:t.bottom-_.bottom+getSide(l,"bottom")),t.left<_.left+getSide(o,"left")?S=-(_.left-t.left+getSide(l,"left")):t.right>_.right-getSide(o,"right")&&(S=t.right-_.right+getSide(l,"right")),S||R)if(b)d.defaultView.scrollBy(S,R);else{let E=g.scrollLeft,A=g.scrollTop;R&&(g.scrollTop+=R),S&&(g.scrollLeft+=S);let M=g.scrollLeft-E,I=g.scrollTop-A;t={left:t.left-M,top:t.top-I,right:t.right-M,bottom:t.bottom-I}}let C=b?"fixed":getComputedStyle(f).position;if(/^(fixed|sticky)$/.test(C))break;f=C=="absolute"?f.offsetParent:parentNode(f)}}function storeScrollPos(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),o,l;for(let d=(t.left+t.right)/2,f=n+1;f<Math.min(innerHeight,t.bottom);f+=5){let g=e.root.elementFromPoint(d,f);if(!g||g==e.dom||!e.dom.contains(g))continue;let b=g.getBoundingClientRect();if(b.top>=n-20){o=g,l=b.top;break}}return{refDOM:o,refTop:l,stack:scrollStack(e.dom)}}function scrollStack(e){let t=[],n=e.ownerDocument;for(let o=e;o&&(t.push({dom:o,top:o.scrollTop,left:o.scrollLeft}),e!=n);o=parentNode(o));return t}function resetScrollPos({refDOM:e,refTop:t,stack:n}){let o=e?e.getBoundingClientRect().top:0;restoreScrollStack(n,o==0?0:o-t)}function restoreScrollStack(e,t){for(let n=0;n<e.length;n++){let{dom:o,top:l,left:d}=e[n];o.scrollTop!=l+t&&(o.scrollTop=l+t),o.scrollLeft!=d&&(o.scrollLeft=d)}}let preventScrollSupported=null;function focusPreventScroll(e){if(e.setActive)return e.setActive();if(preventScrollSupported)return e.focus(preventScrollSupported);let t=scrollStack(e);e.focus(preventScrollSupported==null?{get preventScroll(){return preventScrollSupported={preventScroll:!0},!0}}:void 0),preventScrollSupported||(preventScrollSupported=!1,restoreScrollStack(t,0))}function findOffsetInNode(e,t){let n,o=2e8,l,d=0,f=t.top,g=t.top,b,_;for(let S=e.firstChild,R=0;S;S=S.nextSibling,R++){let C;if(S.nodeType==1)C=S.getClientRects();else if(S.nodeType==3)C=textRange(S).getClientRects();else continue;for(let E=0;E<C.length;E++){let A=C[E];if(A.top<=f&&A.bottom>=g){f=Math.max(A.bottom,f),g=Math.min(A.top,g);let M=A.left>t.left?A.left-t.left:A.right<t.left?t.left-A.right:0;if(M<o){n=S,o=M,l=M&&n.nodeType==3?{left:A.right<t.left?A.right:A.left,top:t.top}:t,S.nodeType==1&&M&&(d=R+(t.left>=(A.left+A.right)/2?1:0));continue}}else A.top>t.top&&!b&&A.left<=t.left&&A.right>=t.left&&(b=S,_={left:Math.max(A.left,Math.min(A.right,t.left)),top:A.top});!n&&(t.left>=A.right&&t.top>=A.top||t.left>=A.left&&t.top>=A.bottom)&&(d=R+1)}}return!n&&b&&(n=b,l=_,o=0),n&&n.nodeType==3?findOffsetInText(n,l):!n||o&&n.nodeType==1?{node:e,offset:d}:findOffsetInNode(n,l)}function findOffsetInText(e,t){let n=e.nodeValue.length,o=document.createRange(),l;for(let d=0;d<n;d++){o.setEnd(e,d+1),o.setStart(e,d);let f=singleRect(o,1);if(f.top!=f.bottom&&inRect(t,f)){l={node:e,offset:d+(t.left>=(f.left+f.right)/2?1:0)};break}}return o.detach(),l||{node:e,offset:0}}function inRect(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function targetKludge(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}function posFromElement(e,t,n){let{node:o,offset:l}=findOffsetInNode(t,n),d=-1;if(o.nodeType==1&&!o.firstChild){let f=o.getBoundingClientRect();d=f.left!=f.right&&n.left>(f.left+f.right)/2?1:-1}return e.docView.posFromDOM(o,l,d)}function posFromCaret(e,t,n,o){let l=-1;for(let d=t,f=!1;d!=e.dom;){let g=e.docView.nearestDesc(d,!0),b;if(!g)return null;if(g.dom.nodeType==1&&(g.node.isBlock&&g.parent||!g.contentDOM)&&((b=g.dom.getBoundingClientRect()).width||b.height)&&(g.node.isBlock&&g.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(g.dom.nodeName)&&(!f&&b.left>o.left||b.top>o.top?l=g.posBefore:(!f&&b.right<o.left||b.bottom<o.top)&&(l=g.posAfter),f=!0),!g.contentDOM&&l<0&&!g.node.isText))return(g.node.isBlock?o.top<(b.top+b.bottom)/2:o.left<(b.left+b.right)/2)?g.posBefore:g.posAfter;d=g.dom.parentNode}return l>-1?l:e.docView.posFromDOM(t,n,-1)}function elementFromPoint(e,t,n){let o=e.childNodes.length;if(o&&n.top<n.bottom)for(let l=Math.max(0,Math.min(o-1,Math.floor(o*(t.top-n.top)/(n.bottom-n.top))-2)),d=l;;){let f=e.childNodes[d];if(f.nodeType==1){let g=f.getClientRects();for(let b=0;b<g.length;b++){let _=g[b];if(inRect(t,_))return elementFromPoint(f,t,_)}}if((d=(d+1)%o)==l)break}return e}function posAtCoords(e,t){let n=e.dom.ownerDocument,o,l=0,d=caretFromPoint(n,t.left,t.top);d&&({node:o,offset:l}=d);let f=(e.root.elementFromPoint?e.root:n).elementFromPoint(t.left,t.top),g;if(!f||!e.dom.contains(f.nodeType!=1?f.parentNode:f)){let _=e.dom.getBoundingClientRect();if(!inRect(t,_)||(f=elementFromPoint(e.dom,t,_),!f))return null}if(safari)for(let _=f;o&&_;_=parentNode(_))_.draggable&&(o=void 0);if(f=targetKludge(f,t),o){if(gecko&&o.nodeType==1&&(l=Math.min(l,o.childNodes.length),l<o.childNodes.length)){let S=o.childNodes[l],R;S.nodeName=="IMG"&&(R=S.getBoundingClientRect()).right<=t.left&&R.bottom>t.top&&l++}let _;webkit&&l&&o.nodeType==1&&(_=o.childNodes[l-1]).nodeType==1&&_.contentEditable=="false"&&_.getBoundingClientRect().top>=t.top&&l--,o==e.dom&&l==o.childNodes.length-1&&o.lastChild.nodeType==1&&t.top>o.lastChild.getBoundingClientRect().bottom?g=e.state.doc.content.size:(l==0||o.nodeType!=1||o.childNodes[l-1].nodeName!="BR")&&(g=posFromCaret(e,o,l,t))}g==null&&(g=posFromElement(e,f,t));let b=e.docView.nearestDesc(f,!0);return{pos:g,inside:b?b.posAtStart-b.border:-1}}function nonZero(e){return e.top<e.bottom||e.left<e.right}function singleRect(e,t){let n=e.getClientRects();if(n.length){let o=n[t<0?0:n.length-1];if(nonZero(o))return o}return Array.prototype.find.call(n,nonZero)||e.getBoundingClientRect()}const BIDI=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function coordsAtPos(e,t,n){let{node:o,offset:l,atom:d}=e.docView.domFromPos(t,n<0?-1:1),f=webkit||gecko;if(o.nodeType==3)if(f&&(BIDI.test(o.nodeValue)||(n<0?!l:l==o.nodeValue.length))){let b=singleRect(textRange(o,l,l),n);if(gecko&&l&&/\s/.test(o.nodeValue[l-1])&&l<o.nodeValue.length){let _=singleRect(textRange(o,l-1,l-1),-1);if(_.top==b.top){let S=singleRect(textRange(o,l,l+1),-1);if(S.top!=b.top)return flattenV(S,S.left<_.left)}}return b}else{let b=l,_=l,S=n<0?1:-1;return n<0&&!l?(_++,S=-1):n>=0&&l==o.nodeValue.length?(b--,S=1):n<0?b--:_++,flattenV(singleRect(textRange(o,b,_),S),S<0)}if(!e.state.doc.resolve(t-(d||0)).parent.inlineContent){if(d==null&&l&&(n<0||l==nodeSize(o))){let b=o.childNodes[l-1];if(b.nodeType==1)return flattenH(b.getBoundingClientRect(),!1)}if(d==null&&l<nodeSize(o)){let b=o.childNodes[l];if(b.nodeType==1)return flattenH(b.getBoundingClientRect(),!0)}return flattenH(o.getBoundingClientRect(),n>=0)}if(d==null&&l&&(n<0||l==nodeSize(o))){let b=o.childNodes[l-1],_=b.nodeType==3?textRange(b,nodeSize(b)-(f?0:1)):b.nodeType==1&&(b.nodeName!="BR"||!b.nextSibling)?b:null;if(_)return flattenV(singleRect(_,1),!1)}if(d==null&&l<nodeSize(o)){let b=o.childNodes[l];for(;b.pmViewDesc&&b.pmViewDesc.ignoreForCoords;)b=b.nextSibling;let _=b?b.nodeType==3?textRange(b,0,f?0:1):b.nodeType==1?b:null:null;if(_)return flattenV(singleRect(_,-1),!0)}return flattenV(singleRect(o.nodeType==3?textRange(o):o,-n),n>=0)}function flattenV(e,t){if(e.width==0)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function flattenH(e,t){if(e.height==0)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function withFlushedState(e,t,n){let o=e.state,l=e.root.activeElement;o!=t&&e.updateState(t),l!=e.dom&&e.focus();try{return n()}finally{o!=t&&e.updateState(o),l!=e.dom&&l&&l.focus()}}function endOfTextblockVertical(e,t,n){let o=t.selection,l=n=="up"?o.$from:o.$to;return withFlushedState(e,t,()=>{let{node:d}=e.docView.domFromPos(l.pos,n=="up"?-1:1);for(;;){let g=e.docView.nearestDesc(d,!0);if(!g)break;if(g.node.isBlock){d=g.contentDOM||g.dom;break}d=g.dom.parentNode}let f=coordsAtPos(e,l.pos,1);for(let g=d.firstChild;g;g=g.nextSibling){let b;if(g.nodeType==1)b=g.getClientRects();else if(g.nodeType==3)b=textRange(g,0,g.nodeValue.length).getClientRects();else continue;for(let _=0;_<b.length;_++){let S=b[_];if(S.bottom>S.top+1&&(n=="up"?f.top-S.top>(S.bottom-f.top)*2:S.bottom-f.bottom>(f.bottom-S.top)*2))return!1}}return!0})}const maybeRTL=/[\u0590-\u08ac]/;function endOfTextblockHorizontal(e,t,n){let{$head:o}=t.selection;if(!o.parent.isTextblock)return!1;let l=o.parentOffset,d=!l,f=l==o.parent.content.size,g=e.domSelection();return g?!maybeRTL.test(o.parent.textContent)||!g.modify?n=="left"||n=="backward"?d:f:withFlushedState(e,t,()=>{let{focusNode:b,focusOffset:_,anchorNode:S,anchorOffset:R}=e.domSelectionRange(),C=g.caretBidiLevel;g.modify("move",n,"character");let E=o.depth?e.docView.domAfterPos(o.before()):e.dom,{focusNode:A,focusOffset:M}=e.domSelectionRange(),I=A&&!E.contains(A.nodeType==1?A:A.parentNode)||b==A&&_==M;try{g.collapse(S,R),b&&(b!=S||_!=R)&&g.extend&&g.extend(b,_)}catch{}return C!=null&&(g.caretBidiLevel=C),I}):o.pos==o.start()||o.pos==o.end()}let cachedState=null,cachedDir=null,cachedResult=!1;function endOfTextblock(e,t,n){return cachedState==t&&cachedDir==n?cachedResult:(cachedState=t,cachedDir=n,cachedResult=n=="up"||n=="down"?endOfTextblockVertical(e,t,n):endOfTextblockHorizontal(e,t,n))}const NOT_DIRTY=0,CHILD_DIRTY=1,CONTENT_DIRTY=2,NODE_DIRTY=3;class ViewDesc{constructor(t,n,o,l){this.parent=t,this.children=n,this.dom=o,this.contentDOM=l,this.dirty=NOT_DIRTY,o.pmViewDesc=this}matchesWidget(t){return!1}matchesMark(t){return!1}matchesNode(t,n,o){return!1}matchesHack(t){return!1}parseRule(){return null}stopEvent(t){return!1}get size(){let t=0;for(let n=0;n<this.children.length;n++)t+=this.children[n].size;return t}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let t=0;t<this.children.length;t++)this.children[t].destroy()}posBeforeChild(t){for(let n=0,o=this.posAtStart;;n++){let l=this.children[n];if(l==t)return o;o+=l.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(t,n,o){if(this.contentDOM&&this.contentDOM.contains(t.nodeType==1?t:t.parentNode))if(o<0){let d,f;if(t==this.contentDOM)d=t.childNodes[n-1];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;d=t.previousSibling}for(;d&&!((f=d.pmViewDesc)&&f.parent==this);)d=d.previousSibling;return d?this.posBeforeChild(f)+f.size:this.posAtStart}else{let d,f;if(t==this.contentDOM)d=t.childNodes[n];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;d=t.nextSibling}for(;d&&!((f=d.pmViewDesc)&&f.parent==this);)d=d.nextSibling;return d?this.posBeforeChild(f):this.posAtEnd}let l;if(t==this.dom&&this.contentDOM)l=n>domIndex(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))l=t.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let d=t;;d=d.parentNode){if(d==this.dom){l=!1;break}if(d.previousSibling)break}if(l==null&&n==t.childNodes.length)for(let d=t;;d=d.parentNode){if(d==this.dom){l=!0;break}if(d.nextSibling)break}}return l??o>0?this.posAtEnd:this.posAtStart}nearestDesc(t,n=!1){for(let o=!0,l=t;l;l=l.parentNode){let d=this.getDesc(l),f;if(d&&(!n||d.node))if(o&&(f=d.nodeDOM)&&!(f.nodeType==1?f.contains(t.nodeType==1?t:t.parentNode):f==t))o=!1;else return d}}getDesc(t){let n=t.pmViewDesc;for(let o=n;o;o=o.parent)if(o==this)return n}posFromDOM(t,n,o){for(let l=t;l;l=l.parentNode){let d=this.getDesc(l);if(d)return d.localPosFromDOM(t,n,o)}return-1}descAt(t){for(let n=0,o=0;n<this.children.length;n++){let l=this.children[n],d=o+l.size;if(o==t&&d!=o){for(;!l.border&&l.children.length;)for(let f=0;f<l.children.length;f++){let g=l.children[f];if(g.size){l=g;break}}return l}if(t<d)return l.descAt(t-o-l.border);o=d}}domFromPos(t,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let o=0,l=0;for(let d=0;o<this.children.length;o++){let f=this.children[o],g=d+f.size;if(g>t||f instanceof TrailingHackViewDesc){l=t-d;break}d=g}if(l)return this.children[o].domFromPos(l-this.children[o].border,n);for(let d;o&&!(d=this.children[o-1]).size&&d instanceof WidgetViewDesc&&d.side>=0;o--);if(n<=0){let d,f=!0;for(;d=o?this.children[o-1]:null,!(!d||d.dom.parentNode==this.contentDOM);o--,f=!1);return d&&n&&f&&!d.border&&!d.domAtom?d.domFromPos(d.size,n):{node:this.contentDOM,offset:d?domIndex(d.dom)+1:0}}else{let d,f=!0;for(;d=o<this.children.length?this.children[o]:null,!(!d||d.dom.parentNode==this.contentDOM);o++,f=!1);return d&&f&&!d.border&&!d.domAtom?d.domFromPos(0,n):{node:this.contentDOM,offset:d?domIndex(d.dom):this.contentDOM.childNodes.length}}}parseRange(t,n,o=0){if(this.children.length==0)return{node:this.contentDOM,from:t,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let l=-1,d=-1;for(let f=o,g=0;;g++){let b=this.children[g],_=f+b.size;if(l==-1&&t<=_){let S=f+b.border;if(t>=S&&n<=_-b.border&&b.node&&b.contentDOM&&this.contentDOM.contains(b.contentDOM))return b.parseRange(t,n,S);t=f;for(let R=g;R>0;R--){let C=this.children[R-1];if(C.size&&C.dom.parentNode==this.contentDOM&&!C.emptyChildAt(1)){l=domIndex(C.dom)+1;break}t-=C.size}l==-1&&(l=0)}if(l>-1&&(_>n||g==this.children.length-1)){n=_;for(let S=g+1;S<this.children.length;S++){let R=this.children[S];if(R.size&&R.dom.parentNode==this.contentDOM&&!R.emptyChildAt(-1)){d=domIndex(R.dom);break}n+=R.size}d==-1&&(d=this.contentDOM.childNodes.length);break}f=_}return{node:this.contentDOM,from:t,to:n,fromOffset:l,toOffset:d}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[t<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(t)}domAfterPos(t){let{node:n,offset:o}=this.domFromPos(t,0);if(n.nodeType!=1||o==n.childNodes.length)throw new RangeError("No node after pos "+t);return n.childNodes[o]}setSelection(t,n,o,l=!1){let d=Math.min(t,n),f=Math.max(t,n);for(let E=0,A=0;E<this.children.length;E++){let M=this.children[E],I=A+M.size;if(d>A&&f<I)return M.setSelection(t-A-M.border,n-A-M.border,o,l);A=I}let g=this.domFromPos(t,t?-1:1),b=n==t?g:this.domFromPos(n,n?-1:1),_=o.root.getSelection(),S=o.domSelectionRange(),R=!1;if((gecko||safari)&&t==n){let{node:E,offset:A}=g;if(E.nodeType==3){if(R=!!(A&&E.nodeValue[A-1]==`
|
|
1282
1282
|
`),R&&A==E.nodeValue.length)for(let M=E,I;M;M=M.parentNode){if(I=M.nextSibling){I.nodeName=="BR"&&(g=b={node:I.parentNode,offset:domIndex(I)+1});break}let j=M.pmViewDesc;if(j&&j.node&&j.node.isBlock)break}}else{let M=E.childNodes[A-1];R=M&&(M.nodeName=="BR"||M.contentEditable=="false")}}if(gecko&&S.focusNode&&S.focusNode!=b.node&&S.focusNode.nodeType==1){let E=S.focusNode.childNodes[S.focusOffset];E&&E.contentEditable=="false"&&(l=!0)}if(!(l||R&&safari)&&isEquivalentPosition(g.node,g.offset,S.anchorNode,S.anchorOffset)&&isEquivalentPosition(b.node,b.offset,S.focusNode,S.focusOffset))return;let C=!1;if((_.extend||t==n)&&!(R&&gecko)){_.collapse(g.node,g.offset);try{t!=n&&_.extend(b.node,b.offset),C=!0}catch{}}if(!C){if(t>n){let A=g;g=b,b=A}let E=document.createRange();E.setEnd(b.node,b.offset),E.setStart(g.node,g.offset),_.removeAllRanges(),_.addRange(E)}}ignoreMutation(t){return!this.contentDOM&&t.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,n){for(let o=0,l=0;l<this.children.length;l++){let d=this.children[l],f=o+d.size;if(o==f?t<=f&&n>=o:t<f&&n>o){let g=o+d.border,b=f-d.border;if(t>=g&&n<=b){this.dirty=t==o||n==f?CONTENT_DIRTY:CHILD_DIRTY,t==g&&n==b&&(d.contentLost||d.dom.parentNode!=this.contentDOM)?d.dirty=NODE_DIRTY:d.markDirty(t-g,n-g);return}else d.dirty=d.dom==d.contentDOM&&d.dom.parentNode==this.contentDOM&&!d.children.length?CONTENT_DIRTY:NODE_DIRTY}o=f}this.dirty=CONTENT_DIRTY}markParentsDirty(){let t=1;for(let n=this.parent;n;n=n.parent,t++){let o=t==1?CONTENT_DIRTY:CHILD_DIRTY;n.dirty<o&&(n.dirty=o)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(t){return!1}}class WidgetViewDesc extends ViewDesc{constructor(t,n,o,l){let d,f=n.type.toDOM;if(typeof f=="function"&&(f=f(o,()=>{if(!d)return l;if(d.parent)return d.parent.posBeforeChild(d)})),!n.type.spec.raw){if(f.nodeType!=1){let g=document.createElement("span");g.appendChild(f),f=g}f.contentEditable="false",f.classList.add("ProseMirror-widget")}super(t,[],f,null),this.widget=n,this.widget=n,d=this}matchesWidget(t){return this.dirty==NOT_DIRTY&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){let n=this.widget.spec.stopEvent;return n?n(t):!1}ignoreMutation(t){return t.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 CompositionViewDesc extends ViewDesc{constructor(t,n,o,l){super(t,[],n,null),this.textDOM=o,this.text=l}get size(){return this.text.length}localPosFromDOM(t,n){return t!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return t.type==="characterData"&&t.target.nodeValue==t.oldValue}}class MarkViewDesc extends ViewDesc{constructor(t,n,o,l,d){super(t,[],o,l),this.mark=n,this.spec=d}static create(t,n,o,l){let d=l.nodeViews[n.type.name],f=d&&d(n,l,o);return(!f||!f.dom)&&(f=DOMSerializer.renderSpec(document,n.type.spec.toDOM(n,o),null,n.attrs)),new MarkViewDesc(t,n,f.dom,f.contentDOM||f.dom,f)}parseRule(){return this.dirty&NODE_DIRTY||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return this.dirty!=NODE_DIRTY&&this.mark.eq(t)}markDirty(t,n){if(super.markDirty(t,n),this.dirty!=NOT_DIRTY){let o=this.parent;for(;!o.node;)o=o.parent;o.dirty<this.dirty&&(o.dirty=this.dirty),this.dirty=NOT_DIRTY}}slice(t,n,o){let l=MarkViewDesc.create(this.parent,this.mark,!0,o),d=this.children,f=this.size;n<f&&(d=replaceNodes(d,n,f,o)),t>0&&(d=replaceNodes(d,0,t,o));for(let g=0;g<d.length;g++)d[g].parent=l;return l.children=d,l}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class NodeViewDesc extends ViewDesc{constructor(t,n,o,l,d,f,g,b,_){super(t,[],d,f),this.node=n,this.outerDeco=o,this.innerDeco=l,this.nodeDOM=g}static create(t,n,o,l,d,f){let g=d.nodeViews[n.type.name],b,_=g&&g(n,d,()=>{if(!b)return f;if(b.parent)return b.parent.posBeforeChild(b)},o,l),S=_&&_.dom,R=_&&_.contentDOM;if(n.isText){if(!S)S=document.createTextNode(n.text);else if(S.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else S||({dom:S,contentDOM:R}=DOMSerializer.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!R&&!n.isText&&S.nodeName!="BR"&&(S.hasAttribute("contenteditable")||(S.contentEditable="false"),n.type.spec.draggable&&(S.draggable=!0));let C=S;return S=applyOuterDeco(S,o,n),_?b=new CustomNodeViewDesc(t,n,o,l,S,R||null,C,_,d,f+1):n.isText?new TextViewDesc(t,n,o,l,S,C,d):new NodeViewDesc(t,n,o,l,S,R||null,C,d,f+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(t.preserveWhitespace="full"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let o=this.children[n];if(this.dom.contains(o.dom.parentNode)){t.contentElement=o.dom.parentNode;break}}t.contentElement||(t.getContent=()=>Fragment.empty)}return t}matchesNode(t,n,o){return this.dirty==NOT_DIRTY&&t.eq(this.node)&&sameOuterDeco(n,this.outerDeco)&&o.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,n){let o=this.node.inlineContent,l=n,d=t.composing?this.localCompositionInfo(t,n):null,f=d&&d.pos>-1?d:null,g=d&&d.pos<0,b=new ViewTreeUpdater(this,f&&f.node,t);iterDeco(this.node,this.innerDeco,(_,S,R)=>{_.spec.marks?b.syncToMarks(_.spec.marks,o,t):_.type.side>=0&&!R&&b.syncToMarks(S==this.node.childCount?Mark$1.none:this.node.child(S).marks,o,t),b.placeWidget(_,t,l)},(_,S,R,C)=>{b.syncToMarks(_.marks,o,t);let E;b.findNodeMatch(_,S,R,C)||g&&t.state.selection.from>l&&t.state.selection.to<l+_.nodeSize&&(E=b.findIndexWithChild(d.node))>-1&&b.updateNodeAt(_,S,R,E,t)||b.updateNextNode(_,S,R,t,C,l)||b.addNode(_,S,R,t,l),l+=_.nodeSize}),b.syncToMarks([],o,t),this.node.isTextblock&&b.addTextblockHacks(),b.destroyRest(),(b.changed||this.dirty==CONTENT_DIRTY)&&(f&&this.protectLocalComposition(t,f),renderDescs(this.contentDOM,this.children,t),ios&&iosHacks(this.dom))}localCompositionInfo(t,n){let{from:o,to:l}=t.state.selection;if(!(t.state.selection instanceof TextSelection)||o<n||l>n+this.node.content.size)return null;let d=t.input.compositionNode;if(!d||!this.dom.contains(d.parentNode))return null;if(this.node.inlineContent){let f=d.nodeValue,g=findTextInFragment(this.node.content,f,o-n,l-n);return g<0?null:{node:d,pos:g,text:f}}else return{node:d,pos:-1,text:""}}protectLocalComposition(t,{node:n,pos:o,text:l}){if(this.getDesc(n))return;let d=n;for(;d.parentNode!=this.contentDOM;d=d.parentNode){for(;d.previousSibling;)d.parentNode.removeChild(d.previousSibling);for(;d.nextSibling;)d.parentNode.removeChild(d.nextSibling);d.pmViewDesc&&(d.pmViewDesc=void 0)}let f=new CompositionViewDesc(this,d,n,l);t.input.compositionNodes.push(f),this.children=replaceNodes(this.children,o,o+l.length,t,f)}update(t,n,o,l){return this.dirty==NODE_DIRTY||!t.sameMarkup(this.node)?!1:(this.updateInner(t,n,o,l),!0)}updateInner(t,n,o,l){this.updateOuterDeco(n),this.node=t,this.innerDeco=o,this.contentDOM&&this.updateChildren(l,this.posAtStart),this.dirty=NOT_DIRTY}updateOuterDeco(t){if(sameOuterDeco(t,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,o=this.dom;this.dom=patchOuterDeco(this.dom,this.nodeDOM,computeOuterDeco(this.outerDeco,this.node,n),computeOuterDeco(t,this.node,n)),this.dom!=o&&(o.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=t}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 docViewDesc(e,t,n,o,l){applyOuterDeco(o,t,e);let d=new NodeViewDesc(void 0,e,t,n,o,o,o,l,0);return d.contentDOM&&d.updateChildren(l,0),d}class TextViewDesc extends NodeViewDesc{constructor(t,n,o,l,d,f,g){super(t,n,o,l,d,null,f,g,0)}parseRule(){let t=this.nodeDOM.parentNode;for(;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}}update(t,n,o,l){return this.dirty==NODE_DIRTY||this.dirty!=NOT_DIRTY&&!this.inParent()||!t.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=NOT_DIRTY||t.text!=this.node.text)&&t.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=t.text,l.trackWrites==this.nodeDOM&&(l.trackWrites=null)),this.node=t,this.dirty=NOT_DIRTY,!0)}inParent(){let t=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==t)return!0;return!1}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,n,o){return t==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(t,n,o)}ignoreMutation(t){return t.type!="characterData"&&t.type!="selection"}slice(t,n,o){let l=this.node.cut(t,n),d=document.createTextNode(l.text);return new TextViewDesc(this.parent,l,this.outerDeco,this.innerDeco,d,d,o)}markDirty(t,n){super.markDirty(t,n),this.dom!=this.nodeDOM&&(t==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=NODE_DIRTY)}get domAtom(){return!1}isText(t){return this.node.text==t}}class TrailingHackViewDesc extends ViewDesc{parseRule(){return{ignore:!0}}matchesHack(t){return this.dirty==NOT_DIRTY&&this.dom.nodeName==t}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class CustomNodeViewDesc extends NodeViewDesc{constructor(t,n,o,l,d,f,g,b,_,S){super(t,n,o,l,d,f,g,_,S),this.spec=b}update(t,n,o,l){if(this.dirty==NODE_DIRTY)return!1;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){let d=this.spec.update(t,n,o);return d&&this.updateInner(t,n,o,l),d}else return!this.contentDOM&&!t.isLeaf?!1:super.update(t,n,o,l)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,n,o,l){this.spec.setSelection?this.spec.setSelection(t,n,o.root):super.setSelection(t,n,o,l)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(t){return this.spec.stopEvent?this.spec.stopEvent(t):!1}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}}function renderDescs(e,t,n){let o=e.firstChild,l=!1;for(let d=0;d<t.length;d++){let f=t[d],g=f.dom;if(g.parentNode==e){for(;g!=o;)o=rm(o),l=!0;o=o.nextSibling}else l=!0,e.insertBefore(g,o);if(f instanceof MarkViewDesc){let b=o?o.previousSibling:e.lastChild;renderDescs(f.contentDOM,f.children,n),o=b?b.nextSibling:e.firstChild}}for(;o;)o=rm(o),l=!0;l&&n.trackWrites==e&&(n.trackWrites=null)}const OuterDecoLevel=function(e){e&&(this.nodeName=e)};OuterDecoLevel.prototype=Object.create(null);const noDeco=[new OuterDecoLevel];function computeOuterDeco(e,t,n){if(e.length==0)return noDeco;let o=n?noDeco[0]:new OuterDecoLevel,l=[o];for(let d=0;d<e.length;d++){let f=e[d].type.attrs;if(f){f.nodeName&&l.push(o=new OuterDecoLevel(f.nodeName));for(let g in f){let b=f[g];b!=null&&(n&&l.length==1&&l.push(o=new OuterDecoLevel(t.isInline?"span":"div")),g=="class"?o.class=(o.class?o.class+" ":"")+b:g=="style"?o.style=(o.style?o.style+";":"")+b:g!="nodeName"&&(o[g]=b))}}}return l}function patchOuterDeco(e,t,n,o){if(n==noDeco&&o==noDeco)return t;let l=t;for(let d=0;d<o.length;d++){let f=o[d],g=n[d];if(d){let b;g&&g.nodeName==f.nodeName&&l!=e&&(b=l.parentNode)&&b.nodeName.toLowerCase()==f.nodeName||(b=document.createElement(f.nodeName),b.pmIsDeco=!0,b.appendChild(l),g=noDeco[0]),l=b}patchAttributes(l,g||noDeco[0],f)}return l}function patchAttributes(e,t,n){for(let o in t)o!="class"&&o!="style"&&o!="nodeName"&&!(o in n)&&e.removeAttribute(o);for(let o in n)o!="class"&&o!="style"&&o!="nodeName"&&n[o]!=t[o]&&e.setAttribute(o,n[o]);if(t.class!=n.class){let o=t.class?t.class.split(" ").filter(Boolean):[],l=n.class?n.class.split(" ").filter(Boolean):[];for(let d=0;d<o.length;d++)l.indexOf(o[d])==-1&&e.classList.remove(o[d]);for(let d=0;d<l.length;d++)o.indexOf(l[d])==-1&&e.classList.add(l[d]);e.classList.length==0&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let o=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,l;for(;l=o.exec(t.style);)e.style.removeProperty(l[1])}n.style&&(e.style.cssText+=n.style)}}function applyOuterDeco(e,t,n){return patchOuterDeco(e,e,noDeco,computeOuterDeco(t,n,e.nodeType!=1))}function sameOuterDeco(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function rm(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class ViewTreeUpdater{constructor(t,n,o){this.lock=n,this.view=o,this.index=0,this.stack=[],this.changed=!1,this.top=t,this.preMatch=preMatch(t.node.content,t)}destroyBetween(t,n){if(t!=n){for(let o=t;o<n;o++)this.top.children[o].destroy();this.top.children.splice(t,n-t),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,n,o){let l=0,d=this.stack.length>>1,f=Math.min(d,t.length);for(;l<f&&(l==d-1?this.top:this.stack[l+1<<1]).matchesMark(t[l])&&t[l].type.spec.spanning!==!1;)l++;for(;l<d;)this.destroyRest(),this.top.dirty=NOT_DIRTY,this.index=this.stack.pop(),this.top=this.stack.pop(),d--;for(;d<t.length;){this.stack.push(this.top,this.index+1);let g=-1;for(let b=this.index;b<Math.min(this.index+3,this.top.children.length);b++){let _=this.top.children[b];if(_.matchesMark(t[d])&&!this.isLocked(_.dom)){g=b;break}}if(g>-1)g>this.index&&(this.changed=!0,this.destroyBetween(this.index,g)),this.top=this.top.children[this.index];else{let b=MarkViewDesc.create(this.top,t[d],n,o);this.top.children.splice(this.index,0,b),this.top=b,this.changed=!0}this.index=0,d++}}findNodeMatch(t,n,o,l){let d=-1,f;if(l>=this.preMatch.index&&(f=this.preMatch.matches[l-this.preMatch.index]).parent==this.top&&f.matchesNode(t,n,o))d=this.top.children.indexOf(f,this.index);else for(let g=this.index,b=Math.min(this.top.children.length,g+5);g<b;g++){let _=this.top.children[g];if(_.matchesNode(t,n,o)&&!this.preMatch.matched.has(_)){d=g;break}}return d<0?!1:(this.destroyBetween(this.index,d),this.index++,!0)}updateNodeAt(t,n,o,l,d){let f=this.top.children[l];return f.dirty==NODE_DIRTY&&f.dom==f.contentDOM&&(f.dirty=CONTENT_DIRTY),f.update(t,n,o,d)?(this.destroyBetween(this.index,l),this.index++,!0):!1}findIndexWithChild(t){for(;;){let n=t.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let o=t.pmViewDesc;if(o){for(let l=this.index;l<this.top.children.length;l++)if(this.top.children[l]==o)return l}return-1}t=n}}updateNextNode(t,n,o,l,d,f){for(let g=this.index;g<this.top.children.length;g++){let b=this.top.children[g];if(b instanceof NodeViewDesc){let _=this.preMatch.matched.get(b);if(_!=null&&_!=d)return!1;let S=b.dom,R,C=this.isLocked(S)&&!(t.isText&&b.node&&b.node.isText&&b.nodeDOM.nodeValue==t.text&&b.dirty!=NODE_DIRTY&&sameOuterDeco(n,b.outerDeco));if(!C&&b.update(t,n,o,l))return this.destroyBetween(this.index,g),b.dom!=S&&(this.changed=!0),this.index++,!0;if(!C&&(R=this.recreateWrapper(b,t,n,o,l,f)))return this.destroyBetween(this.index,g),this.top.children[this.index]=R,R.contentDOM&&(R.dirty=CONTENT_DIRTY,R.updateChildren(l,f+1),R.dirty=NOT_DIRTY),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(t,n,o,l,d,f){if(t.dirty||n.isAtom||!t.children.length||!t.node.content.eq(n.content)||!sameOuterDeco(o,t.outerDeco)||!l.eq(t.innerDeco))return null;let g=NodeViewDesc.create(this.top,n,o,l,d,f);if(g.contentDOM){g.children=t.children,t.children=[];for(let b of g.children)b.parent=g}return t.destroy(),g}addNode(t,n,o,l,d){let f=NodeViewDesc.create(this.top,t,n,o,l,d);f.contentDOM&&f.updateChildren(l,d+1),this.top.children.splice(this.index++,0,f),this.changed=!0}placeWidget(t,n,o){let l=this.index<this.top.children.length?this.top.children[this.index]:null;if(l&&l.matchesWidget(t)&&(t==l.widget||!l.widget.type.toDOM.parentNode))this.index++;else{let d=new WidgetViewDesc(this.top,t,n,o);this.top.children.splice(this.index++,0,d),this.changed=!0}}addTextblockHacks(){let t=this.top.children[this.index-1],n=this.top;for(;t instanceof MarkViewDesc;)n=t,t=n.children[n.children.length-1];(!t||!(t instanceof TextViewDesc)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text))&&((safari||chrome)&&t&&t.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(t,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(t))this.index++;else{let o=document.createElement(t);t=="IMG"&&(o.className="ProseMirror-separator",o.alt=""),t=="BR"&&(o.className="ProseMirror-trailingBreak");let l=new TrailingHackViewDesc(this.top,[],o,null);n!=this.top?n.children.push(l):n.children.splice(this.index++,0,l),this.changed=!0}}isLocked(t){return this.lock&&(t==this.lock||t.nodeType==1&&t.contains(this.lock.parentNode))}}function preMatch(e,t){let n=t,o=n.children.length,l=e.childCount,d=new Map,f=[];e:for(;l>0;){let g;for(;;)if(o){let _=n.children[o-1];if(_ instanceof MarkViewDesc)n=_,o=_.children.length;else{g=_,o--;break}}else{if(n==t)break e;o=n.parent.children.indexOf(n),n=n.parent}let b=g.node;if(b){if(b!=e.child(l-1))break;--l,d.set(g,l),f.push(g)}}return{index:l,matched:d,matches:f.reverse()}}function compareSide(e,t){return e.type.side-t.type.side}function iterDeco(e,t,n,o){let l=t.locals(e),d=0;if(l.length==0){for(let _=0;_<e.childCount;_++){let S=e.child(_);o(S,l,t.forChild(d,S),_),d+=S.nodeSize}return}let f=0,g=[],b=null;for(let _=0;;){let S,R;for(;f<l.length&&l[f].to==d;){let I=l[f++];I.widget&&(S?(R||(R=[S])).push(I):S=I)}if(S)if(R){R.sort(compareSide);for(let I=0;I<R.length;I++)n(R[I],_,!!b)}else n(S,_,!!b);let C,E;if(b)E=-1,C=b,b=null;else if(_<e.childCount)E=_,C=e.child(_++);else break;for(let I=0;I<g.length;I++)g[I].to<=d&&g.splice(I--,1);for(;f<l.length&&l[f].from<=d&&l[f].to>d;)g.push(l[f++]);let A=d+C.nodeSize;if(C.isText){let I=A;f<l.length&&l[f].from<I&&(I=l[f].from);for(let j=0;j<g.length;j++)g[j].to<I&&(I=g[j].to);I<A&&(b=C.cut(I-d),C=C.cut(0,I-d),A=I,E=-1)}else for(;f<l.length&&l[f].to<A;)f++;let M=C.isInline&&!C.isLeaf?g.filter(I=>!I.inline):g.slice();o(C,M,t.forChild(d,C),E),d=A}}function iosHacks(e){if(e.nodeName=="UL"||e.nodeName=="OL"){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}function findTextInFragment(e,t,n,o){for(let l=0,d=0;l<e.childCount&&d<=o;){let f=e.child(l++),g=d;if(d+=f.nodeSize,!f.isText)continue;let b=f.text;for(;l<e.childCount;){let _=e.child(l++);if(d+=_.nodeSize,!_.isText)break;b+=_.text}if(d>=n){if(d>=o&&b.slice(o-t.length-g,o-g)==t)return o-t.length;let _=g<o?b.lastIndexOf(t,o-g-1):-1;if(_>=0&&_+t.length+g>=n)return g+_;if(n==o&&b.length>=o+t.length-g&&b.slice(o-g,o-g+t.length)==t)return o}}return-1}function replaceNodes(e,t,n,o,l){let d=[];for(let f=0,g=0;f<e.length;f++){let b=e[f],_=g,S=g+=b.size;_>=n||S<=t?d.push(b):(_<t&&d.push(b.slice(0,t-_,o)),l&&(d.push(l),l=void 0),S>n&&d.push(b.slice(n-_,b.size,o)))}return d}function selectionFromDOM(e,t=null){let n=e.domSelectionRange(),o=e.state.doc;if(!n.focusNode)return null;let l=e.docView.nearestDesc(n.focusNode),d=l&&l.size==0,f=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(f<0)return null;let g=o.resolve(f),b,_;if(selectionCollapsed(n)){for(b=f;l&&!l.node;)l=l.parent;let R=l.node;if(l&&R.isAtom&&NodeSelection.isSelectable(R)&&l.parent&&!(R.isInline&&isOnEdge(n.focusNode,n.focusOffset,l.dom))){let C=l.posBefore;_=new NodeSelection(f==C?g:o.resolve(C))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let R=f,C=f;for(let E=0;E<n.rangeCount;E++){let A=n.getRangeAt(E);R=Math.min(R,e.docView.posFromDOM(A.startContainer,A.startOffset,1)),C=Math.max(C,e.docView.posFromDOM(A.endContainer,A.endOffset,-1))}if(R<0)return null;[b,f]=C==e.state.selection.anchor?[C,R]:[R,C],g=o.resolve(f)}else b=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(b<0)return null}let S=o.resolve(b);if(!_){let R=t=="pointer"||e.state.selection.head<g.pos&&!d?1:-1;_=selectionBetween(e,S,g,R)}return _}function editorOwnsSelection(e){return e.editable?e.hasFocus():hasSelection(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function selectionToDOM(e,t=!1){let n=e.state.selection;if(syncNodeSelection(e,n),!!editorOwnsSelection(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&chrome){let o=e.domSelectionRange(),l=e.domObserver.currentSelection;if(o.anchorNode&&l.anchorNode&&isEquivalentPosition(o.anchorNode,o.anchorOffset,l.anchorNode,l.anchorOffset)){e.input.mouseDown.delayedSelectionSync=!0,e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)selectCursorWrapper(e);else{let{anchor:o,head:l}=n,d,f;brokenSelectBetweenUneditable&&!(n instanceof TextSelection)&&(n.$from.parent.inlineContent||(d=temporarilyEditableNear(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(f=temporarilyEditableNear(e,n.to))),e.docView.setSelection(o,l,e,t),brokenSelectBetweenUneditable&&(d&&resetEditable(d),f&&resetEditable(f)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&removeClassOnSelectionChange(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}const brokenSelectBetweenUneditable=safari||chrome&&chrome_version<63;function temporarilyEditableNear(e,t){let{node:n,offset:o}=e.docView.domFromPos(t,0),l=o<n.childNodes.length?n.childNodes[o]:null,d=o?n.childNodes[o-1]:null;if(safari&&l&&l.contentEditable=="false")return setEditable(l);if((!l||l.contentEditable=="false")&&(!d||d.contentEditable=="false")){if(l)return setEditable(l);if(d)return setEditable(d)}}function setEditable(e){return e.contentEditable="true",safari&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function resetEditable(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function removeClassOnSelectionChange(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),o=n.anchorNode,l=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{(n.anchorNode!=o||n.anchorOffset!=l)&&(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!editorOwnsSelection(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}function selectCursorWrapper(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,o=n.nodeName=="IMG";o?t.collapse(n.parentNode,domIndex(n)+1):t.collapse(n,0),!o&&!e.state.selection.visible&&ie$1&&ie_version<=11&&(n.disabled=!0,n.disabled=!1)}function syncNodeSelection(e,t){if(t instanceof NodeSelection){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(clearNodeSelection(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else clearNodeSelection(e)}function clearNodeSelection(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function selectionBetween(e,t,n,o){return e.someProp("createSelectionBetween",l=>l(e,t,n))||TextSelection.between(t,n,o)}function hasFocusAndSelection(e){return e.editable&&!e.hasFocus()?!1:hasSelection(e)}function hasSelection(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function anchorInRightPlace(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return isEquivalentPosition(t.node,t.offset,n.anchorNode,n.anchorOffset)}function moveSelectionBlock(e,t){let{$anchor:n,$head:o}=e.selection,l=t>0?n.max(o):n.min(o),d=l.parent.inlineContent?l.depth?e.doc.resolve(t>0?l.after():l.before()):null:l;return d&&Selection.findFrom(d,t)}function apply(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function selectHorizontally(e,t,n){let o=e.state.selection;if(o instanceof TextSelection)if(n.indexOf("s")>-1){let{$head:l}=o,d=l.textOffset?null:t<0?l.nodeBefore:l.nodeAfter;if(!d||d.isText||!d.isLeaf)return!1;let f=e.state.doc.resolve(l.pos+d.nodeSize*(t<0?-1:1));return apply(e,new TextSelection(o.$anchor,f))}else if(o.empty){if(e.endOfTextblock(t>0?"forward":"backward")){let l=moveSelectionBlock(e.state,t);return l&&l instanceof NodeSelection?apply(e,l):!1}else if(!(mac$2&&n.indexOf("m")>-1)){let l=o.$head,d=l.textOffset?null:t<0?l.nodeBefore:l.nodeAfter,f;if(!d||d.isText)return!1;let g=t<0?l.pos-d.nodeSize:l.pos;return d.isAtom||(f=e.docView.descAt(g))&&!f.contentDOM?NodeSelection.isSelectable(d)?apply(e,new NodeSelection(t<0?e.state.doc.resolve(l.pos-d.nodeSize):l)):webkit?apply(e,new TextSelection(e.state.doc.resolve(t<0?g:g+d.nodeSize))):!1:!1}}else return!1;else{if(o instanceof NodeSelection&&o.node.isInline)return apply(e,new TextSelection(t>0?o.$to:o.$from));{let l=moveSelectionBlock(e.state,t);return l?apply(e,l):!1}}}function nodeLen(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function isIgnorable(e,t){let n=e.pmViewDesc;return n&&n.size==0&&(t<0||e.nextSibling||e.nodeName!="BR")}function skipIgnoredNodes(e,t){return t<0?skipIgnoredNodesBefore(e):skipIgnoredNodesAfter(e)}function skipIgnoredNodesBefore(e){let t=e.domSelectionRange(),n=t.focusNode,o=t.focusOffset;if(!n)return;let l,d,f=!1;for(gecko&&n.nodeType==1&&o<nodeLen(n)&&isIgnorable(n.childNodes[o],-1)&&(f=!0);;)if(o>0){if(n.nodeType!=1)break;{let g=n.childNodes[o-1];if(isIgnorable(g,-1))l=n,d=--o;else if(g.nodeType==3)n=g,o=n.nodeValue.length;else break}}else{if(isBlockNode(n))break;{let g=n.previousSibling;for(;g&&isIgnorable(g,-1);)l=n.parentNode,d=domIndex(g),g=g.previousSibling;if(g)n=g,o=nodeLen(n);else{if(n=n.parentNode,n==e.dom)break;o=0}}}f?setSelFocus(e,n,o):l&&setSelFocus(e,l,d)}function skipIgnoredNodesAfter(e){let t=e.domSelectionRange(),n=t.focusNode,o=t.focusOffset;if(!n)return;let l=nodeLen(n),d,f;for(;;)if(o<l){if(n.nodeType!=1)break;let g=n.childNodes[o];if(isIgnorable(g,1))d=n,f=++o;else break}else{if(isBlockNode(n))break;{let g=n.nextSibling;for(;g&&isIgnorable(g,1);)d=g.parentNode,f=domIndex(g)+1,g=g.nextSibling;if(g)n=g,o=0,l=nodeLen(n);else{if(n=n.parentNode,n==e.dom)break;o=l=0}}}d&&setSelFocus(e,d,f)}function isBlockNode(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function textNodeAfter(e,t){for(;e&&t==e.childNodes.length&&!hasBlockDesc(e);)t=domIndex(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;e=n,t=0}}function textNodeBefore(e,t){for(;e&&!t&&!hasBlockDesc(e);)t=domIndex(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;e=n,t=e.childNodes.length}}function setSelFocus(e,t,n){if(t.nodeType!=3){let d,f;(f=textNodeAfter(t,n))?(t=f,n=0):(d=textNodeBefore(t,n))&&(t=d,n=d.nodeValue.length)}let o=e.domSelection();if(!o)return;if(selectionCollapsed(o)){let d=document.createRange();d.setEnd(t,n),d.setStart(t,n),o.removeAllRanges(),o.addRange(d)}else o.extend&&o.extend(t,n);e.domObserver.setCurSelection();let{state:l}=e;setTimeout(()=>{e.state==l&&selectionToDOM(e)},50)}function findDirection(e,t){let n=e.state.doc.resolve(t);if(!(chrome||windows$1)&&n.parent.inlineContent){let l=e.coordsAtPos(t);if(t>n.start()){let d=e.coordsAtPos(t-1),f=(d.top+d.bottom)/2;if(f>l.top&&f<l.bottom&&Math.abs(d.left-l.left)>1)return d.left<l.left?"ltr":"rtl"}if(t<n.end()){let d=e.coordsAtPos(t+1),f=(d.top+d.bottom)/2;if(f>l.top&&f<l.bottom&&Math.abs(d.left-l.left)>1)return d.left>l.left?"ltr":"rtl"}}return getComputedStyle(e.dom).direction=="rtl"?"rtl":"ltr"}function selectVertically(e,t,n){let o=e.state.selection;if(o instanceof TextSelection&&!o.empty||n.indexOf("s")>-1||mac$2&&n.indexOf("m")>-1)return!1;let{$from:l,$to:d}=o;if(!l.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let f=moveSelectionBlock(e.state,t);if(f&&f instanceof NodeSelection)return apply(e,f)}if(!l.parent.inlineContent){let f=t<0?l:d,g=o instanceof AllSelection?Selection.near(f,t):Selection.findFrom(f,t);return g?apply(e,g):!1}return!1}function stopNativeHorizontalDelete(e,t){if(!(e.state.selection instanceof TextSelection))return!0;let{$head:n,$anchor:o,empty:l}=e.state.selection;if(!n.sameParent(o))return!0;if(!l)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let d=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(d&&!d.isText){let f=e.state.tr;return t<0?f.delete(n.pos-d.nodeSize,n.pos):f.delete(n.pos,n.pos+d.nodeSize),e.dispatch(f),!0}return!1}function switchEditable(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function safariDownArrowBug(e){if(!safari||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&t.nodeType==1&&n==0&&t.firstChild&&t.firstChild.contentEditable=="false"){let o=t.firstChild;switchEditable(e,o,"true"),setTimeout(()=>switchEditable(e,o,"false"),20)}return!1}function getMods(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}function captureKeyDown(e,t){let n=t.keyCode,o=getMods(t);if(n==8||mac$2&&n==72&&o=="c")return stopNativeHorizontalDelete(e,-1)||skipIgnoredNodes(e,-1);if(n==46&&!t.shiftKey||mac$2&&n==68&&o=="c")return stopNativeHorizontalDelete(e,1)||skipIgnoredNodes(e,1);if(n==13||n==27)return!0;if(n==37||mac$2&&n==66&&o=="c"){let l=n==37?findDirection(e,e.state.selection.from)=="ltr"?-1:1:-1;return selectHorizontally(e,l,o)||skipIgnoredNodes(e,l)}else if(n==39||mac$2&&n==70&&o=="c"){let l=n==39?findDirection(e,e.state.selection.from)=="ltr"?1:-1:1;return selectHorizontally(e,l,o)||skipIgnoredNodes(e,l)}else{if(n==38||mac$2&&n==80&&o=="c")return selectVertically(e,-1,o)||skipIgnoredNodes(e,-1);if(n==40||mac$2&&n==78&&o=="c")return safariDownArrowBug(e)||selectVertically(e,1,o)||skipIgnoredNodes(e,1);if(o==(mac$2?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function serializeForClipboard(e,t){e.someProp("transformCopied",E=>{t=E(t,e)});let n=[],{content:o,openStart:l,openEnd:d}=t;for(;l>1&&d>1&&o.childCount==1&&o.firstChild.childCount==1;){l--,d--;let E=o.firstChild;n.push(E.type.name,E.attrs!=E.type.defaultAttrs?E.attrs:null),o=E.content}let f=e.someProp("clipboardSerializer")||DOMSerializer.fromSchema(e.state.schema),g=detachedDoc(),b=g.createElement("div");b.appendChild(f.serializeFragment(o,{document:g}));let _=b.firstChild,S,R=0;for(;_&&_.nodeType==1&&(S=wrapMap[_.nodeName.toLowerCase()]);){for(let E=S.length-1;E>=0;E--){let A=g.createElement(S[E]);for(;b.firstChild;)A.appendChild(b.firstChild);b.appendChild(A),R++}_=b.firstChild}_&&_.nodeType==1&&_.setAttribute("data-pm-slice",`${l} ${d}${R?` -${R}`:""} ${JSON.stringify(n)}`);let C=e.someProp("clipboardTextSerializer",E=>E(t,e))||t.content.textBetween(0,t.content.size,`
|
|
1283
1283
|
|
|
1284
1284
|
`);return{dom:b,text:C,slice:t}}function parseFromClipboard(e,t,n,o,l){let d=l.parent.type.spec.code,f,g;if(!n&&!t)return null;let b=!!t&&(o||d||!n);if(b){if(e.someProp("transformPastedText",C=>{t=C(t,d||o,e)}),d)return g=new Slice(Fragment.from(e.state.schema.text(t.replace(/\r\n?/g,`
|
|
1285
|
-
`))),0,0),e.someProp("transformPasted",C=>{g=C(g,e,!0)}),g;let R=e.someProp("clipboardTextParser",C=>C(t,l,o,e));if(R)g=R;else{let C=l.marks(),{schema:E}=e.state,A=DOMSerializer.fromSchema(E);f=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(M=>{let I=f.appendChild(document.createElement("p"));M&&I.appendChild(A.serializeNode(E.text(M,C)))})}}else e.someProp("transformPastedHTML",R=>{n=R(n,e)}),f=readHTML(n),webkit&&restoreReplacedSpaces(f);let _=f&&f.querySelector("[data-pm-slice]"),S=_&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(_.getAttribute("data-pm-slice")||"");if(S&&S[3])for(let R=+S[3];R>0;R--){let C=f.firstChild;for(;C&&C.nodeType!=1;)C=C.nextSibling;if(!C)break;f=C}if(g||(g=(e.someProp("clipboardParser")||e.someProp("domParser")||DOMParser.fromSchema(e.state.schema)).parseSlice(f,{preserveWhitespace:!!(b||S),context:l,ruleFromNode(C){return C.nodeName=="BR"&&!C.nextSibling&&C.parentNode&&!inlineParents.test(C.parentNode.nodeName)?{ignore:!0}:null}})),S)g=addContext(closeSlice(g,+S[1],+S[2]),S[4]);else if(g=Slice.maxOpen(normalizeSiblings(g.content,l),!0),g.openStart||g.openEnd){let R=0,C=0;for(let E=g.content.firstChild;R<g.openStart&&!E.type.spec.isolating;R++,E=E.firstChild);for(let E=g.content.lastChild;C<g.openEnd&&!E.type.spec.isolating;C++,E=E.lastChild);g=closeSlice(g,R,C)}return e.someProp("transformPasted",R=>{g=R(g,e,b)}),g}const inlineParents=/^(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 normalizeSiblings(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let l=t.node(n).contentMatchAt(t.index(n)),d,f=[];if(e.forEach(g=>{if(!f)return;let b=l.findWrapping(g.type),_;if(!b)return f=null;if(_=f.length&&d.length&&addToSibling(b,d,g,f[f.length-1],0))f[f.length-1]=_;else{f.length&&(f[f.length-1]=closeRight(f[f.length-1],d.length));let S=withWrappers(g,b);f.push(S),l=l.matchType(S.type),d=b}}),f)return Fragment.from(f)}return e}function withWrappers(e,t,n=0){for(let o=t.length-1;o>=n;o--)e=t[o].create(null,Fragment.from(e));return e}function addToSibling(e,t,n,o,l){if(l<e.length&&l<t.length&&e[l]==t[l]){let d=addToSibling(e,t,n,o.lastChild,l+1);if(d)return o.copy(o.content.replaceChild(o.childCount-1,d));if(o.contentMatchAt(o.childCount).matchType(l==e.length-1?n.type:e[l+1]))return o.copy(o.content.append(Fragment.from(withWrappers(n,e,l+1))))}}function closeRight(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,closeRight(e.lastChild,t-1)),o=e.contentMatchAt(e.childCount).fillBefore(Fragment.empty,!0);return e.copy(n.append(o))}function closeRange(e,t,n,o,l,d){let f=t<0?e.firstChild:e.lastChild,g=f.content;return e.childCount>1&&(d=0),l<o-1&&(g=closeRange(g,t,n,o,l+1,d)),l>=n&&(g=t<0?f.contentMatchAt(0).fillBefore(g,d<=l).append(g):g.append(f.contentMatchAt(f.childCount).fillBefore(Fragment.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,f.copy(g))}function closeSlice(e,t,n){return t<e.openStart&&(e=new Slice(closeRange(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new Slice(closeRange(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const wrapMap={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let _detachedDoc=null;function detachedDoc(){return _detachedDoc||(_detachedDoc=document.implementation.createHTMLDocument("title"))}let _policy=null;function maybeWrapTrusted(e){let t=window.trustedTypes;return t?(_policy||(_policy=t.defaultPolicy||t.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),_policy.createHTML(e)):e}function readHTML(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=detachedDoc().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(e),l;if((l=o&&wrapMap[o[1].toLowerCase()])&&(e=l.map(d=>"<"+d+">").join("")+e+l.map(d=>"</"+d+">").reverse().join("")),n.innerHTML=maybeWrapTrusted(e),l)for(let d=0;d<l.length;d++)n=n.querySelector(l[d])||n;return n}function restoreReplacedSpaces(e){let t=e.querySelectorAll(chrome?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let o=t[n];o.childNodes.length==1&&o.textContent==" "&&o.parentNode&&o.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),o)}}function addContext(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,o;try{o=JSON.parse(t)}catch{return e}let{content:l,openStart:d,openEnd:f}=e;for(let g=o.length-2;g>=0;g-=2){let b=n.nodes[o[g]];if(!b||b.hasRequiredAttrs())break;l=Fragment.from(b.create(o[g+1],l)),d++,f++}return new Slice(l,d,f)}const handlers={},editHandlers={},passiveHandlers={touchstart:!0,touchmove:!0};class InputState{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.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function initInput(e){for(let t in handlers){let n=handlers[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=o=>{eventBelongsToView(e,o)&&!runCustomHandler(e,o)&&(e.editable||!(o.type in editHandlers))&&n(e,o)},passiveHandlers[t]?{passive:!0}:void 0)}safari&&e.dom.addEventListener("input",()=>null),ensureListeners(e)}function setSelectionOrigin(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function destroyInput(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function ensureListeners(e){e.someProp("handleDOMEvents",t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=o=>runCustomHandler(e,o))})}function runCustomHandler(e,t){return e.someProp("handleDOMEvents",n=>{let o=n[t.type];return o?o(e,t)||t.defaultPrevented:!1})}function eventBelongsToView(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function dispatchEvent(e,t){!runCustomHandler(e,t)&&handlers[t.type]&&(e.editable||!(t.type in editHandlers))&&handlers[t.type](e,t)}editHandlers.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!inOrNearComposition(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(android&&chrome&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),ios&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let o=Date.now();e.input.lastIOSEnter=o,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==o&&(e.someProp("handleKeyDown",l=>l(e,keyEvent(13,"Enter"))),e.input.lastIOSEnter=0)},200)}else e.someProp("handleKeyDown",o=>o(e,n))||captureKeyDown(e,n)?n.preventDefault():setSelectionOrigin(e,"key")},editHandlers.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},editHandlers.keypress=(e,t)=>{let n=t;if(inOrNearComposition(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||mac$2&&n.metaKey)return;if(e.someProp("handleKeyPress",l=>l(e,n))){n.preventDefault();return}let o=e.state.selection;if(!(o instanceof TextSelection)||!o.$from.sameParent(o.$to)){let l=String.fromCharCode(n.charCode),d=()=>e.state.tr.insertText(l).scrollIntoView();!/[\r\n]/.test(l)&&!e.someProp("handleTextInput",f=>f(e,o.$from.pos,o.$to.pos,l,d))&&e.dispatch(d()),n.preventDefault()}};function eventCoords(e){return{left:e.clientX,top:e.clientY}}function isNear(e,t){let n=t.x-e.clientX,o=t.y-e.clientY;return n*n+o*o<100}function runHandlerOnContext(e,t,n,o,l){if(o==-1)return!1;let d=e.state.doc.resolve(o);for(let f=d.depth+1;f>0;f--)if(e.someProp(t,g=>f>d.depth?g(e,n,d.nodeAfter,d.before(f),l,!0):g(e,n,d.node(f),d.before(f),l,!1)))return!0;return!1}function updateSelection(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let o=e.state.tr.setSelection(t);o.setMeta("pointer",!0),e.dispatch(o)}function selectClickedLeaf(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),o=n.nodeAfter;return o&&o.isAtom&&NodeSelection.isSelectable(o)?(updateSelection(e,new NodeSelection(n)),!0):!1}function selectClickedNode(e,t){if(t==-1)return!1;let n=e.state.selection,o,l;n instanceof NodeSelection&&(o=n.node);let d=e.state.doc.resolve(t);for(let f=d.depth+1;f>0;f--){let g=f>d.depth?d.nodeAfter:d.node(f);if(NodeSelection.isSelectable(g)){o&&n.$from.depth>0&&f>=n.$from.depth&&d.before(n.$from.depth+1)==n.$from.pos?l=d.before(n.$from.depth):l=d.before(f);break}}return l!=null?(updateSelection(e,NodeSelection.create(e.state.doc,l)),!0):!1}function handleSingleClick(e,t,n,o,l){return runHandlerOnContext(e,"handleClickOn",t,n,o)||e.someProp("handleClick",d=>d(e,t,o))||(l?selectClickedNode(e,n):selectClickedLeaf(e,n))}function handleDoubleClick(e,t,n,o){return runHandlerOnContext(e,"handleDoubleClickOn",t,n,o)||e.someProp("handleDoubleClick",l=>l(e,t,o))}function handleTripleClick(e,t,n,o){return runHandlerOnContext(e,"handleTripleClickOn",t,n,o)||e.someProp("handleTripleClick",l=>l(e,t,o))||defaultTripleClick(e,n,o)}function defaultTripleClick(e,t,n){if(n.button!=0)return!1;let o=e.state.doc;if(t==-1)return o.inlineContent?(updateSelection(e,TextSelection.create(o,0,o.content.size)),!0):!1;let l=o.resolve(t);for(let d=l.depth+1;d>0;d--){let f=d>l.depth?l.nodeAfter:l.node(d),g=l.before(d);if(f.inlineContent)updateSelection(e,TextSelection.create(o,g+1,g+1+f.content.size));else if(NodeSelection.isSelectable(f))updateSelection(e,NodeSelection.create(o,g));else continue;return!0}}function forceDOMFlush(e){return endComposition(e)}const selectNodeModifier=mac$2?"metaKey":"ctrlKey";handlers.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let o=forceDOMFlush(e),l=Date.now(),d="singleClick";l-e.input.lastClick.time<500&&isNear(n,e.input.lastClick)&&!n[selectNodeModifier]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type=="singleClick"?d="doubleClick":e.input.lastClick.type=="doubleClick"&&(d="tripleClick")),e.input.lastClick={time:l,x:n.clientX,y:n.clientY,type:d,button:n.button};let f=e.posAtCoords(eventCoords(n));f&&(d=="singleClick"?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new MouseDown(e,f,n,!!o)):(d=="doubleClick"?handleDoubleClick:handleTripleClick)(e,f.pos,f.inside,n)?n.preventDefault():setSelectionOrigin(e,"pointer"))};class MouseDown{constructor(t,n,o,l){this.view=t,this.pos=n,this.event=o,this.flushed=l,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!o[selectNodeModifier],this.allowDefault=o.shiftKey;let d,f;if(n.inside>-1)d=t.state.doc.nodeAt(n.inside),f=n.inside;else{let S=t.state.doc.resolve(n.pos);d=S.parent,f=S.depth?S.before():0}const g=l?null:o.target,b=g?t.docView.nearestDesc(g,!0):null;this.target=b&&b.nodeDOM.nodeType==1?b.nodeDOM:null;let{selection:_}=t.state;(o.button==0&&d.type.spec.draggable&&d.type.spec.selectable!==!1||_ instanceof NodeSelection&&_.from<=f&&_.to>f)&&(this.mightDrag={node:d,pos:f,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&gecko&&!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()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),setSelectionOrigin(t,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>selectionToDOM(this.view)),this.view.input.mouseDown=null}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(eventCoords(t))),this.updateAllowDefault(t),this.allowDefault||!n?setSelectionOrigin(this.view,"pointer"):handleSingleClick(this.view,n.pos,n.inside,t,this.selectNode)?t.preventDefault():t.button==0&&(this.flushed||safari&&this.mightDrag&&!this.mightDrag.node.isAtom||chrome&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(updateSelection(this.view,Selection.near(this.view.state.doc.resolve(n.pos))),t.preventDefault()):setSelectionOrigin(this.view,"pointer")}move(t){this.updateAllowDefault(t),setSelectionOrigin(this.view,"pointer"),t.buttons==0&&this.done()}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}}handlers.touchstart=e=>{e.input.lastTouch=Date.now(),forceDOMFlush(e),setSelectionOrigin(e,"pointer")},handlers.touchmove=e=>{e.input.lastTouch=Date.now(),setSelectionOrigin(e,"pointer")},handlers.contextmenu=e=>forceDOMFlush(e);function inOrNearComposition(e,t){return e.composing?!0:safari&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}const timeoutComposition=android?5e3:-1;editHandlers.compositionstart=editHandlers.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof TextSelection&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(o=>o.type.spec.inclusive===!1)))e.markCursor=e.state.storedMarks||n.marks(),endComposition(e,!0),e.markCursor=null;else if(endComposition(e,!t.selection.empty),gecko&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let o=e.domSelectionRange();for(let l=o.focusNode,d=o.focusOffset;l&&l.nodeType==1&&d!=0;){let f=d<0?l.lastChild:l.childNodes[d-1];if(!f)break;if(f.nodeType==3){let g=e.domSelection();g&&g.collapse(f,f.nodeValue.length);break}else l=f,d=-1}}e.input.composing=!0}scheduleComposeEnd(e,timeoutComposition)},editHandlers.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,scheduleComposeEnd(e,20))};function scheduleComposeEnd(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>endComposition(e),t))}function clearComposition(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=timestampFromCustomEvent());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function findCompositionNode(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=textNodeBefore$1(t.focusNode,t.focusOffset),o=textNodeAfter$1(t.focusNode,t.focusOffset);if(n&&o&&n!=o){let l=o.pmViewDesc,d=e.domObserver.lastChangedTextNode;if(n==d||o==d)return d;if(!l||!l.isText(o.nodeValue))return o;if(e.input.compositionNode==o){let f=n.pmViewDesc;if(!(!f||!f.isText(n.nodeValue)))return o}}return n||o}function timestampFromCustomEvent(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}function endComposition(e,t=!1){if(!(android&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),clearComposition(e),t||e.docView&&e.docView.dirty){let n=selectionFromDOM(e),o=e.state.selection;return n&&!n.eq(o)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!o.$from.node(o.$from.sharedDepth(o.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function captureCopy(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let o=getSelection(),l=document.createRange();l.selectNodeContents(t),e.dom.blur(),o.removeAllRanges(),o.addRange(l),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}const brokenClipboardAPI=ie$1&&ie_version<15||ios&&webkit_version<604;handlers.copy=editHandlers.cut=(e,t)=>{let n=t,o=e.state.selection,l=n.type=="cut";if(o.empty)return;let d=brokenClipboardAPI?null:n.clipboardData,f=o.content(),{dom:g,text:b}=serializeForClipboard(e,f);d?(n.preventDefault(),d.clearData(),d.setData("text/html",g.innerHTML),d.setData("text/plain",b)):captureCopy(e,g),l&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function sliceSingleNode(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function capturePaste(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,o=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(o.contentEditable="true"),o.style.cssText="position: fixed; left: -10000px; top: 10px",o.focus();let l=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),o.parentNode&&o.parentNode.removeChild(o),n?doPaste(e,o.value,null,l,t):doPaste(e,o.textContent,o.innerHTML,l,t)},50)}function doPaste(e,t,n,o,l){let d=parseFromClipboard(e,t,n,o,e.state.selection.$from);if(e.someProp("handlePaste",b=>b(e,l,d||Slice.empty)))return!0;if(!d)return!1;let f=sliceSingleNode(d),g=f?e.state.tr.replaceSelectionWith(f,o):e.state.tr.replaceSelection(d);return e.dispatch(g.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function getText$1(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}editHandlers.paste=(e,t)=>{let n=t;if(e.composing&&!android)return;let o=brokenClipboardAPI?null:n.clipboardData,l=e.input.shiftKey&&e.input.lastKeyCode!=45;o&&doPaste(e,getText$1(o),o.getData("text/html"),l,n)?n.preventDefault():capturePaste(e,n)};class Dragging{constructor(t,n,o){this.slice=t,this.move=n,this.node=o}}const dragCopyModifier=mac$2?"altKey":"ctrlKey";function dragMoves(e,t){let n=e.someProp("dragCopies",o=>!o(t));return n??!t[dragCopyModifier]}handlers.dragstart=(e,t)=>{let n=t,o=e.input.mouseDown;if(o&&o.done(),!n.dataTransfer)return;let l=e.state.selection,d=l.empty?null:e.posAtCoords(eventCoords(n)),f;if(!(d&&d.pos>=l.from&&d.pos<=(l instanceof NodeSelection?l.to-1:l.to))){if(o&&o.mightDrag)f=NodeSelection.create(e.state.doc,o.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let R=e.docView.nearestDesc(n.target,!0);R&&R.node.type.spec.draggable&&R!=e.docView&&(f=NodeSelection.create(e.state.doc,R.posBefore))}}let g=(f||e.state.selection).content(),{dom:b,text:_,slice:S}=serializeForClipboard(e,g);(!n.dataTransfer.files.length||!chrome||chrome_version>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(brokenClipboardAPI?"Text":"text/html",b.innerHTML),n.dataTransfer.effectAllowed="copyMove",brokenClipboardAPI||n.dataTransfer.setData("text/plain",_),e.dragging=new Dragging(S,dragMoves(e,n),f)},handlers.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},editHandlers.dragover=editHandlers.dragenter=(e,t)=>t.preventDefault(),editHandlers.drop=(e,t)=>{let n=t,o=e.dragging;if(e.dragging=null,!n.dataTransfer)return;let l=e.posAtCoords(eventCoords(n));if(!l)return;let d=e.state.doc.resolve(l.pos),f=o&&o.slice;f?e.someProp("transformPasted",A=>{f=A(f,e,!1)}):f=parseFromClipboard(e,getText$1(n.dataTransfer),brokenClipboardAPI?null:n.dataTransfer.getData("text/html"),!1,d);let g=!!(o&&dragMoves(e,n));if(e.someProp("handleDrop",A=>A(e,n,f||Slice.empty,g))){n.preventDefault();return}if(!f)return;n.preventDefault();let b=f?dropPoint(e.state.doc,d.pos,f):d.pos;b==null&&(b=d.pos);let _=e.state.tr;if(g){let{node:A}=o;A?A.replace(_):_.deleteSelection()}let S=_.mapping.map(b),R=f.openStart==0&&f.openEnd==0&&f.content.childCount==1,C=_.doc;if(R?_.replaceRangeWith(S,S,f.content.firstChild):_.replaceRange(S,S,f),_.doc.eq(C))return;let E=_.doc.resolve(S);if(R&&NodeSelection.isSelectable(f.content.firstChild)&&E.nodeAfter&&E.nodeAfter.sameMarkup(f.content.firstChild))_.setSelection(new NodeSelection(E));else{let A=_.mapping.map(b);_.mapping.maps[_.mapping.maps.length-1].forEach((M,I,j,q)=>A=q),_.setSelection(selectionBetween(e,E,_.doc.resolve(A)))}e.focus(),e.dispatch(_.setMeta("uiEvent","drop"))},handlers.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&selectionToDOM(e)},20))},handlers.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},handlers.beforeinput=(e,t)=>{if(chrome&&android&&t.inputType=="deleteContentBackward"){e.domObserver.flushSoon();let{domChangeCount:o}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=o||(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",d=>d(e,keyEvent(8,"Backspace")))))return;let{$cursor:l}=e.state.selection;l&&l.pos>0&&e.dispatch(e.state.tr.delete(l.pos-1,l.pos).scrollIntoView())},50)}};for(let e in editHandlers)handlers[e]=editHandlers[e];function compareObjs(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class WidgetType{constructor(t,n){this.toDOM=t,this.spec=n||noSpec,this.side=this.spec.side||0}map(t,n,o,l){let{pos:d,deleted:f}=t.mapResult(n.from+l,this.side<0?-1:1);return f?null:new Decoration(d-o,d-o,this)}valid(){return!0}eq(t){return this==t||t instanceof WidgetType&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&compareObjs(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}}class InlineType{constructor(t,n){this.attrs=t,this.spec=n||noSpec}map(t,n,o,l){let d=t.map(n.from+l,this.spec.inclusiveStart?-1:1)-o,f=t.map(n.to+l,this.spec.inclusiveEnd?1:-1)-o;return d>=f?null:new Decoration(d,f,this)}valid(t,n){return n.from<n.to}eq(t){return this==t||t instanceof InlineType&&compareObjs(this.attrs,t.attrs)&&compareObjs(this.spec,t.spec)}static is(t){return t.type instanceof InlineType}destroy(){}}class NodeType{constructor(t,n){this.attrs=t,this.spec=n||noSpec}map(t,n,o,l){let d=t.mapResult(n.from+l,1);if(d.deleted)return null;let f=t.mapResult(n.to+l,-1);return f.deleted||f.pos<=d.pos?null:new Decoration(d.pos-o,f.pos-o,this)}valid(t,n){let{index:o,offset:l}=t.content.findIndex(n.from),d;return l==n.from&&!(d=t.child(o)).isText&&l+d.nodeSize==n.to}eq(t){return this==t||t instanceof NodeType&&compareObjs(this.attrs,t.attrs)&&compareObjs(this.spec,t.spec)}destroy(){}}class Decoration{constructor(t,n,o){this.from=t,this.to=n,this.type=o}copy(t,n){return new Decoration(t,n,this.type)}eq(t,n=0){return this.type.eq(t.type)&&this.from+n==t.from&&this.to+n==t.to}map(t,n,o){return this.type.map(t,this,n,o)}static widget(t,n,o){return new Decoration(t,t,new WidgetType(n,o))}static inline(t,n,o,l){return new Decoration(t,n,new InlineType(o,l))}static node(t,n,o,l){return new Decoration(t,n,new NodeType(o,l))}get spec(){return this.type.spec}get inline(){return this.type instanceof InlineType}get widget(){return this.type instanceof WidgetType}}const none=[],noSpec={};class DecorationSet{constructor(t,n){this.local=t.length?t:none,this.children=n.length?n:none}static create(t,n){return n.length?buildTree(n,t,0,noSpec):empty}find(t,n,o){let l=[];return this.findInner(t??0,n??1e9,l,0,o),l}findInner(t,n,o,l,d){for(let f=0;f<this.local.length;f++){let g=this.local[f];g.from<=n&&g.to>=t&&(!d||d(g.spec))&&o.push(g.copy(g.from+l,g.to+l))}for(let f=0;f<this.children.length;f+=3)if(this.children[f]<n&&this.children[f+1]>t){let g=this.children[f]+1;this.children[f+2].findInner(t-g,n-g,o,l+g,d)}}map(t,n,o){return this==empty||t.maps.length==0?this:this.mapInner(t,n,0,0,o||noSpec)}mapInner(t,n,o,l,d){let f;for(let g=0;g<this.local.length;g++){let b=this.local[g].map(t,o,l);b&&b.type.valid(n,b)?(f||(f=[])).push(b):d.onRemove&&d.onRemove(this.local[g].spec)}return this.children.length?mapChildren(this.children,f||[],t,n,o,l,d):f?new DecorationSet(f.sort(byPos),none):empty}add(t,n){return n.length?this==empty?DecorationSet.create(t,n):this.addInner(t,n,0):this}addInner(t,n,o){let l,d=0;t.forEach((g,b)=>{let _=b+o,S;if(S=takeSpansForNode(n,g,_)){for(l||(l=this.children.slice());d<l.length&&l[d]<b;)d+=3;l[d]==b?l[d+2]=l[d+2].addInner(g,S,_+1):l.splice(d,0,b,b+g.nodeSize,buildTree(S,g,_+1,noSpec)),d+=3}});let f=moveSpans(d?withoutNulls(n):n,-o);for(let g=0;g<f.length;g++)f[g].type.valid(t,f[g])||f.splice(g--,1);return new DecorationSet(f.length?this.local.concat(f).sort(byPos):this.local,l||this.children)}remove(t){return t.length==0||this==empty?this:this.removeInner(t,0)}removeInner(t,n){let o=this.children,l=this.local;for(let d=0;d<o.length;d+=3){let f,g=o[d]+n,b=o[d+1]+n;for(let S=0,R;S<t.length;S++)(R=t[S])&&R.from>g&&R.to<b&&(t[S]=null,(f||(f=[])).push(R));if(!f)continue;o==this.children&&(o=this.children.slice());let _=o[d+2].removeInner(f,g+1);_!=empty?o[d+2]=_:(o.splice(d,3),d-=3)}if(l.length){for(let d=0,f;d<t.length;d++)if(f=t[d])for(let g=0;g<l.length;g++)l[g].eq(f,n)&&(l==this.local&&(l=this.local.slice()),l.splice(g--,1))}return o==this.children&&l==this.local?this:l.length||o.length?new DecorationSet(l,o):empty}forChild(t,n){if(this==empty)return this;if(n.isLeaf)return DecorationSet.empty;let o,l;for(let g=0;g<this.children.length;g+=3)if(this.children[g]>=t){this.children[g]==t&&(o=this.children[g+2]);break}let d=t+1,f=d+n.content.size;for(let g=0;g<this.local.length;g++){let b=this.local[g];if(b.from<f&&b.to>d&&b.type instanceof InlineType){let _=Math.max(d,b.from)-d,S=Math.min(f,b.to)-d;_<S&&(l||(l=[])).push(b.copy(_,S))}}if(l){let g=new DecorationSet(l.sort(byPos),none);return o?new DecorationGroup([g,o]):g}return o||empty}eq(t){if(this==t)return!0;if(!(t instanceof DecorationSet)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(t.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=t.children[n]||this.children[n+1]!=t.children[n+1]||!this.children[n+2].eq(t.children[n+2]))return!1;return!0}locals(t){return removeOverlap(this.localsInner(t))}localsInner(t){if(this==empty)return none;if(t.inlineContent||!this.local.some(InlineType.is))return this.local;let n=[];for(let o=0;o<this.local.length;o++)this.local[o].type instanceof InlineType||n.push(this.local[o]);return n}forEachSet(t){t(this)}}DecorationSet.empty=new DecorationSet([],[]),DecorationSet.removeOverlap=removeOverlap;const empty=DecorationSet.empty;class DecorationGroup{constructor(t){this.members=t}map(t,n){const o=this.members.map(l=>l.map(t,n,noSpec));return DecorationGroup.from(o)}forChild(t,n){if(n.isLeaf)return DecorationSet.empty;let o=[];for(let l=0;l<this.members.length;l++){let d=this.members[l].forChild(t,n);d!=empty&&(d instanceof DecorationGroup?o=o.concat(d.members):o.push(d))}return DecorationGroup.from(o)}eq(t){if(!(t instanceof DecorationGroup)||t.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(t.members[n]))return!1;return!0}locals(t){let n,o=!0;for(let l=0;l<this.members.length;l++){let d=this.members[l].localsInner(t);if(d.length)if(!n)n=d;else{o&&(n=n.slice(),o=!1);for(let f=0;f<d.length;f++)n.push(d[f])}}return n?removeOverlap(o?n:n.sort(byPos)):none}static from(t){switch(t.length){case 0:return empty;case 1:return t[0];default:return new DecorationGroup(t.every(n=>n instanceof DecorationSet)?t:t.reduce((n,o)=>n.concat(o instanceof DecorationSet?o:o.members),[]))}}forEachSet(t){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(t)}}function mapChildren(e,t,n,o,l,d,f){let g=e.slice();for(let _=0,S=d;_<n.maps.length;_++){let R=0;n.maps[_].forEach((C,E,A,M)=>{let I=M-A-(E-C);for(let j=0;j<g.length;j+=3){let q=g[j+1];if(q<0||C>q+S-R)continue;let Q=g[j]+S-R;E>=Q?g[j+1]=C<=Q?-2:-1:C>=S&&I&&(g[j]+=I,g[j+1]+=I)}R+=I}),S=n.maps[_].map(S,-1)}let b=!1;for(let _=0;_<g.length;_+=3)if(g[_+1]<0){if(g[_+1]==-2){b=!0,g[_+1]=-1;continue}let S=n.map(e[_]+d),R=S-l;if(R<0||R>=o.content.size){b=!0;continue}let C=n.map(e[_+1]+d,-1),E=C-l,{index:A,offset:M}=o.content.findIndex(R),I=o.maybeChild(A);if(I&&M==R&&M+I.nodeSize==E){let j=g[_+2].mapInner(n,I,S+1,e[_]+d+1,f);j!=empty?(g[_]=R,g[_+1]=E,g[_+2]=j):(g[_+1]=-2,b=!0)}else b=!0}if(b){let _=mapAndGatherRemainingDecorations(g,e,t,n,l,d,f),S=buildTree(_,o,0,f);t=S.local;for(let R=0;R<g.length;R+=3)g[R+1]<0&&(g.splice(R,3),R-=3);for(let R=0,C=0;R<S.children.length;R+=3){let E=S.children[R];for(;C<g.length&&g[C]<E;)C+=3;g.splice(C,0,S.children[R],S.children[R+1],S.children[R+2])}}return new DecorationSet(t.sort(byPos),g)}function moveSpans(e,t){if(!t||!e.length)return e;let n=[];for(let o=0;o<e.length;o++){let l=e[o];n.push(new Decoration(l.from+t,l.to+t,l.type))}return n}function mapAndGatherRemainingDecorations(e,t,n,o,l,d,f){function g(b,_){for(let S=0;S<b.local.length;S++){let R=b.local[S].map(o,l,_);R?n.push(R):f.onRemove&&f.onRemove(b.local[S].spec)}for(let S=0;S<b.children.length;S+=3)g(b.children[S+2],b.children[S]+_+1)}for(let b=0;b<e.length;b+=3)e[b+1]==-1&&g(e[b+2],t[b]+d+1);return n}function takeSpansForNode(e,t,n){if(t.isLeaf)return null;let o=n+t.nodeSize,l=null;for(let d=0,f;d<e.length;d++)(f=e[d])&&f.from>n&&f.to<o&&((l||(l=[])).push(f),e[d]=null);return l}function withoutNulls(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function buildTree(e,t,n,o){let l=[],d=!1;t.forEach((g,b)=>{let _=takeSpansForNode(e,g,b+n);if(_){d=!0;let S=buildTree(_,g,n+b+1,o);S!=empty&&l.push(b,b+g.nodeSize,S)}});let f=moveSpans(d?withoutNulls(e):e,-n).sort(byPos);for(let g=0;g<f.length;g++)f[g].type.valid(t,f[g])||(o.onRemove&&o.onRemove(f[g].spec),f.splice(g--,1));return f.length||l.length?new DecorationSet(f,l):empty}function byPos(e,t){return e.from-t.from||e.to-t.to}function removeOverlap(e){let t=e;for(let n=0;n<t.length-1;n++){let o=t[n];if(o.from!=o.to)for(let l=n+1;l<t.length;l++){let d=t[l];if(d.from==o.from){d.to!=o.to&&(t==e&&(t=e.slice()),t[l]=d.copy(d.from,o.to),insertAhead(t,l+1,d.copy(o.to,d.to)));continue}else{d.from<o.to&&(t==e&&(t=e.slice()),t[n]=o.copy(o.from,d.from),insertAhead(t,l,o.copy(d.from,o.to)));break}}}return t}function insertAhead(e,t,n){for(;t<e.length&&byPos(n,e[t])>0;)t++;e.splice(t,0,n)}function viewDecorations(e){let t=[];return e.someProp("decorations",n=>{let o=n(e.state);o&&o!=empty&&t.push(o)}),e.cursorWrapper&&t.push(DecorationSet.create(e.state.doc,[e.cursorWrapper.deco])),DecorationGroup.from(t)}const observeOptions={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},useCharData=ie$1&&ie_version<=11;let SelectionState$1=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset}};class DOMObserver{constructor(t,n){this.view=t,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new SelectionState$1,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(o=>{for(let l=0;l<o.length;l++)this.queue.push(o[l]);ie$1&&ie_version<=11&&o.some(l=>l.type=="childList"&&l.removedNodes.length||l.type=="characterData"&&l.oldValue.length>l.target.nodeValue.length)?this.flushSoon():this.flush()}),useCharData&&(this.onCharData=o=>{this.queue.push({target:o.target,type:"characterData",oldValue:o.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,observeOptions)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let t=this.observer.takeRecords();if(t.length){for(let n=0;n<t.length;n++)this.queue.push(t[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(hasFocusAndSelection(this.view)){if(this.suppressingSelectionUpdates)return selectionToDOM(this.view);if(ie$1&&ie_version<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&isEquivalentPosition(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(t){if(!t.focusNode)return!0;let n=new Set,o;for(let d=t.focusNode;d;d=parentNode(d))n.add(d);for(let d=t.anchorNode;d;d=parentNode(d))if(n.has(d)){o=d;break}let l=o&&this.view.docView.nearestDesc(o);if(l&&l.ignoreMutation({type:"selection",target:o.nodeType==3?o.parentNode:o}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let o=t.domSelectionRange(),l=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(o)&&hasFocusAndSelection(t)&&!this.ignoreSelectionChange(o),d=-1,f=-1,g=!1,b=[];if(t.editable)for(let S=0;S<n.length;S++){let R=this.registerMutation(n[S],b);R&&(d=d<0?R.from:Math.min(R.from,d),f=f<0?R.to:Math.max(R.to,f),R.typeOver&&(g=!0))}if(gecko&&b.length){let S=b.filter(R=>R.nodeName=="BR");if(S.length==2){let[R,C]=S;R.parentNode&&R.parentNode.parentNode==C.parentNode?C.remove():R.remove()}else{let{focusNode:R}=this.currentSelection;for(let C of S){let E=C.parentNode;E&&E.nodeName=="LI"&&(!R||blockParent(t,R)!=E)&&C.remove()}}}let _=null;d<0&&l&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&selectionCollapsed(o)&&(_=selectionFromDOM(t))&&_.eq(Selection.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,selectionToDOM(t),this.currentSelection.set(o),t.scrollToSelection()):(d>-1||l)&&(d>-1&&(t.docView.markDirty(d,f),checkCSS(t)),this.handleDOMChange(d,f,g,b),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(o)||selectionToDOM(t),this.currentSelection.set(o))}registerMutation(t,n){if(n.indexOf(t.target)>-1)return null;let o=this.view.docView.nearestDesc(t.target);if(t.type=="attributes"&&(o==this.view.docView||t.attributeName=="contenteditable"||t.attributeName=="style"&&!t.oldValue&&!t.target.getAttribute("style"))||!o||o.ignoreMutation(t))return null;if(t.type=="childList"){for(let S=0;S<t.addedNodes.length;S++){let R=t.addedNodes[S];n.push(R),R.nodeType==3&&(this.lastChangedTextNode=R)}if(o.contentDOM&&o.contentDOM!=o.dom&&!o.contentDOM.contains(t.target))return{from:o.posBefore,to:o.posAfter};let l=t.previousSibling,d=t.nextSibling;if(ie$1&&ie_version<=11&&t.addedNodes.length)for(let S=0;S<t.addedNodes.length;S++){let{previousSibling:R,nextSibling:C}=t.addedNodes[S];(!R||Array.prototype.indexOf.call(t.addedNodes,R)<0)&&(l=R),(!C||Array.prototype.indexOf.call(t.addedNodes,C)<0)&&(d=C)}let f=l&&l.parentNode==t.target?domIndex(l)+1:0,g=o.localPosFromDOM(t.target,f,-1),b=d&&d.parentNode==t.target?domIndex(d):t.target.childNodes.length,_=o.localPosFromDOM(t.target,b,1);return{from:g,to:_}}else return t.type=="attributes"?{from:o.posAtStart-o.border,to:o.posAtEnd+o.border}:(this.lastChangedTextNode=t.target,{from:o.posAtStart,to:o.posAtEnd,typeOver:t.target.nodeValue==t.oldValue})}}let cssChecked=new WeakMap,cssCheckWarned=!1;function checkCSS(e){if(!cssChecked.has(e)&&(cssChecked.set(e,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=gecko,cssCheckWarned)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),cssCheckWarned=!0}}function rangeToSelectionRange(e,t){let n=t.startContainer,o=t.startOffset,l=t.endContainer,d=t.endOffset,f=e.domAtPos(e.state.selection.anchor);return isEquivalentPosition(f.node,f.offset,l,d)&&([n,o,l,d]=[l,d,n,o]),{anchorNode:n,anchorOffset:o,focusNode:l,focusOffset:d}}function safariShadowSelectionRange(e,t){if(t.getComposedRanges){let l=t.getComposedRanges(e.root)[0];if(l)return rangeToSelectionRange(e,l)}let n;function o(l){l.preventDefault(),l.stopImmediatePropagation(),n=l.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",o,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",o,!0),n?rangeToSelectionRange(e,n):null}function blockParent(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let o=e.docView.nearestDesc(n,!0);if(o&&o.node.isBlock)return n}return null}function parseBetween(e,t,n){let{node:o,fromOffset:l,toOffset:d,from:f,to:g}=e.docView.parseRange(t,n),b=e.domSelectionRange(),_,S=b.anchorNode;if(S&&e.dom.contains(S.nodeType==1?S:S.parentNode)&&(_=[{node:S,offset:b.anchorOffset}],selectionCollapsed(b)||_.push({node:b.focusNode,offset:b.focusOffset})),chrome&&e.input.lastKeyCode===8)for(let I=d;I>l;I--){let j=o.childNodes[I-1],q=j.pmViewDesc;if(j.nodeName=="BR"&&!q){d=I;break}if(!q||q.size)break}let R=e.state.doc,C=e.someProp("domParser")||DOMParser.fromSchema(e.state.schema),E=R.resolve(f),A=null,M=C.parse(o,{topNode:E.parent,topMatch:E.parent.contentMatchAt(E.index()),topOpen:!0,from:l,to:d,preserveWhitespace:E.parent.type.whitespace=="pre"?"full":!0,findPositions:_,ruleFromNode,context:E});if(_&&_[0].pos!=null){let I=_[0].pos,j=_[1]&&_[1].pos;j==null&&(j=I),A={anchor:I+f,head:j+f}}return{doc:M,sel:A,from:f,to:g}}function ruleFromNode(e){let t=e.pmViewDesc;if(t)return t.parseRule();if(e.nodeName=="BR"&&e.parentNode){if(safari&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(e.parentNode.lastChild==e||safari&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}const isInline=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function readDOMChange(e,t,n,o,l){let d=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let ne=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,ae=selectionFromDOM(e,ne);if(ae&&!e.state.selection.eq(ae)){if(chrome&&android&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",Oe=>Oe(e,keyEvent(13,"Enter"))))return;let se=e.state.tr.setSelection(ae);ne=="pointer"?se.setMeta("pointer",!0):ne=="key"&&se.scrollIntoView(),d&&se.setMeta("composition",d),e.dispatch(se)}return}let f=e.state.doc.resolve(t),g=f.sharedDepth(n);t=f.before(g+1),n=e.state.doc.resolve(n).after(g+1);let b=e.state.selection,_=parseBetween(e,t,n),S=e.state.doc,R=S.slice(_.from,_.to),C,E;e.input.lastKeyCode===8&&Date.now()-100<e.input.lastKeyCodeTime?(C=e.state.selection.to,E="end"):(C=e.state.selection.from,E="start"),e.input.lastKeyCode=null;let A=findDiff(R.content,_.doc.content,_.from,C,E);if(A&&e.input.domChangeCount++,(ios&&e.input.lastIOSEnter>Date.now()-225||android)&&l.some(ne=>ne.nodeType==1&&!isInline.test(ne.nodeName))&&(!A||A.endA>=A.endB)&&e.someProp("handleKeyDown",ne=>ne(e,keyEvent(13,"Enter")))){e.input.lastIOSEnter=0;return}if(!A)if(o&&b instanceof TextSelection&&!b.empty&&b.$head.sameParent(b.$anchor)&&!e.composing&&!(_.sel&&_.sel.anchor!=_.sel.head))A={start:b.from,endA:b.to,endB:b.to};else{if(_.sel){let ne=resolveSelection(e,e.state.doc,_.sel);if(ne&&!ne.eq(e.state.selection)){let ae=e.state.tr.setSelection(ne);d&&ae.setMeta("composition",d),e.dispatch(ae)}}return}e.state.selection.from<e.state.selection.to&&A.start==A.endB&&e.state.selection instanceof TextSelection&&(A.start>e.state.selection.from&&A.start<=e.state.selection.from+2&&e.state.selection.from>=_.from?A.start=e.state.selection.from:A.endA<e.state.selection.to&&A.endA>=e.state.selection.to-2&&e.state.selection.to<=_.to&&(A.endB+=e.state.selection.to-A.endA,A.endA=e.state.selection.to)),ie$1&&ie_version<=11&&A.endB==A.start+1&&A.endA==A.start&&A.start>_.from&&_.doc.textBetween(A.start-_.from-1,A.start-_.from+1)==" "&&(A.start--,A.endA--,A.endB--);let M=_.doc.resolveNoCache(A.start-_.from),I=_.doc.resolveNoCache(A.endB-_.from),j=S.resolve(A.start),q=M.sameParent(I)&&M.parent.inlineContent&&j.end()>=A.endA;if((ios&&e.input.lastIOSEnter>Date.now()-225&&(!q||l.some(ne=>ne.nodeName=="DIV"||ne.nodeName=="P"))||!q&&M.pos<_.doc.content.size&&(!M.sameParent(I)||!M.parent.inlineContent)&&M.pos<I.pos&&!/\S/.test(_.doc.textBetween(M.pos,I.pos,"","")))&&e.someProp("handleKeyDown",ne=>ne(e,keyEvent(13,"Enter")))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>A.start&&looksLikeBackspace(S,A.start,A.endA,M,I)&&e.someProp("handleKeyDown",ne=>ne(e,keyEvent(8,"Backspace")))){android&&chrome&&e.domObserver.suppressSelectionUpdates();return}chrome&&A.endB==A.start&&(e.input.lastChromeDelete=Date.now()),android&&!q&&M.start()!=I.start()&&I.parentOffset==0&&M.depth==I.depth&&_.sel&&_.sel.anchor==_.sel.head&&_.sel.head==A.endA&&(A.endB-=2,I=_.doc.resolveNoCache(A.endB-_.from),setTimeout(()=>{e.someProp("handleKeyDown",function(ne){return ne(e,keyEvent(13,"Enter"))})},20));let Q=A.start,te=A.endA,F=ne=>{let ae=ne||e.state.tr.replace(Q,te,_.doc.slice(A.start-_.from,A.endB-_.from));if(_.sel){let se=resolveSelection(e,ae.doc,_.sel);se&&!(chrome&&e.composing&&se.empty&&(A.start!=A.endB||e.input.lastChromeDelete<Date.now()-100)&&(se.head==Q||se.head==ae.mapping.map(te)-1)||ie$1&&se.empty&&se.head==Q)&&ae.setSelection(se)}return d&&ae.setMeta("composition",d),ae.scrollIntoView()},V;if(q)if(M.pos==I.pos){ie$1&&ie_version<=11&&M.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>selectionToDOM(e),20));let ne=F(e.state.tr.delete(Q,te)),ae=S.resolve(A.start).marksAcross(S.resolve(A.endA));ae&&ne.ensureMarks(ae),e.dispatch(ne)}else if(A.endA==A.endB&&(V=isMarkChange(M.parent.content.cut(M.parentOffset,I.parentOffset),j.parent.content.cut(j.parentOffset,A.endA-j.start())))){let ne=F(e.state.tr);V.type=="add"?ne.addMark(Q,te,V.mark):ne.removeMark(Q,te,V.mark),e.dispatch(ne)}else if(M.parent.child(M.index()).isText&&M.index()==I.index()-(I.textOffset?0:1)){let ne=M.parent.textBetween(M.parentOffset,I.parentOffset),ae=()=>F(e.state.tr.insertText(ne,Q,te));e.someProp("handleTextInput",se=>se(e,Q,te,ne,ae))||e.dispatch(ae())}else e.dispatch(F());else e.dispatch(F())}function resolveSelection(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:selectionBetween(e,t.resolve(n.anchor),t.resolve(n.head))}function isMarkChange(e,t){let n=e.firstChild.marks,o=t.firstChild.marks,l=n,d=o,f,g,b;for(let S=0;S<o.length;S++)l=o[S].removeFromSet(l);for(let S=0;S<n.length;S++)d=n[S].removeFromSet(d);if(l.length==1&&d.length==0)g=l[0],f="add",b=S=>S.mark(g.addToSet(S.marks));else if(l.length==0&&d.length==1)g=d[0],f="remove",b=S=>S.mark(g.removeFromSet(S.marks));else return null;let _=[];for(let S=0;S<t.childCount;S++)_.push(b(t.child(S)));if(Fragment.from(_).eq(e))return{mark:g,type:f}}function looksLikeBackspace(e,t,n,o,l){if(n-t<=l.pos-o.pos||skipClosingAndOpening(o,!0,!1)<l.pos)return!1;let d=e.resolve(t);if(!o.parent.isTextblock){let g=d.nodeAfter;return g!=null&&n==t+g.nodeSize}if(d.parentOffset<d.parent.content.size||!d.parent.isTextblock)return!1;let f=e.resolve(skipClosingAndOpening(d,!0,!0));return!f.parent.isTextblock||f.pos>n||skipClosingAndOpening(f,!0,!1)<n?!1:o.parent.content.cut(o.parentOffset).eq(f.parent.content)}function skipClosingAndOpening(e,t,n){let o=e.depth,l=t?e.end():e.pos;for(;o>0&&(t||e.indexAfter(o)==e.node(o).childCount);)o--,l++,t=!1;if(n){let d=e.node(o).maybeChild(e.indexAfter(o));for(;d&&!d.isLeaf;)d=d.firstChild,l++}return l}function findDiff(e,t,n,o,l){let d=e.findDiffStart(t,n);if(d==null)return null;let{a:f,b:g}=e.findDiffEnd(t,n+e.size,n+t.size);if(l=="end"){let b=Math.max(0,d-Math.min(f,g));o-=f+b-d}if(f<d&&e.size<t.size){let b=o<=d&&o>=f?d-o:0;d-=b,d&&d<t.size&&isSurrogatePair(t.textBetween(d-1,d+1))&&(d+=b?1:-1),g=d+(g-f),f=d}else if(g<d){let b=o<=d&&o>=g?d-o:0;d-=b,d&&d<e.size&&isSurrogatePair(e.textBetween(d-1,d+1))&&(d+=b?1:-1),f=d+(f-g),g=d}return{start:d,endA:f,endB:g}}function isSurrogatePair(e){if(e.length!=2)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}class EditorView{constructor(t,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new InputState,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(checkStateComponent),this.dispatch=this.dispatch.bind(this),this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):typeof t=="function"?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=getEditable(this),updateCursorWrapper(this),this.nodeViews=buildNodeViews(this),this.docView=docViewDesc(this.state.doc,computeDocDeco(this),viewDecorations(this),this.dom,this),this.domObserver=new DOMObserver(this,(o,l,d,f)=>readDOMChange(this,o,l,d,f)),this.domObserver.start(),initInput(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let t=this._props;this._props={};for(let n in t)this._props[n]=t[n];this._props.state=this.state}return this._props}update(t){t.handleDOMEvents!=this._props.handleDOMEvents&&ensureListeners(this);let n=this._props;this._props=t,t.plugins&&(t.plugins.forEach(checkStateComponent),this.directPlugins=t.plugins),this.updateStateInner(t.state,n)}setProps(t){let n={};for(let o in this._props)n[o]=this._props[o];n.state=this.state;for(let o in t)n[o]=t[o];this.update(n)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,n){var o;let l=this.state,d=!1,f=!1;t.storedMarks&&this.composing&&(clearComposition(this),f=!0),this.state=t;let g=l.plugins!=t.plugins||this._props.plugins!=n.plugins;if(g||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let E=buildNodeViews(this);changedNodeViews(E,this.nodeViews)&&(this.nodeViews=E,d=!0)}(g||n.handleDOMEvents!=this._props.handleDOMEvents)&&ensureListeners(this),this.editable=getEditable(this),updateCursorWrapper(this);let b=viewDecorations(this),_=computeDocDeco(this),S=l.plugins!=t.plugins&&!l.doc.eq(t.doc)?"reset":t.scrollToSelection>l.scrollToSelection?"to selection":"preserve",R=d||!this.docView.matchesNode(t.doc,_,b);(R||!t.selection.eq(l.selection))&&(f=!0);let C=S=="preserve"&&f&&this.dom.style.overflowAnchor==null&&storeScrollPos(this);if(f){this.domObserver.stop();let E=R&&(ie$1||chrome)&&!this.composing&&!l.selection.empty&&!t.selection.empty&&selectionContextChanged(l.selection,t.selection);if(R){let A=chrome?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=findCompositionNode(this)),(d||!this.docView.update(t.doc,_,b,this))&&(this.docView.updateOuterDeco(_),this.docView.destroy(),this.docView=docViewDesc(t.doc,_,b,this.dom,this)),A&&!this.trackWrites&&(E=!0)}E||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&anchorInRightPlace(this))?selectionToDOM(this,E):(syncNodeSelection(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(l),!((o=this.dragging)===null||o===void 0)&&o.node&&!l.doc.eq(t.doc)&&this.updateDraggedNode(this.dragging,l),S=="reset"?this.dom.scrollTop=0:S=="to selection"?this.scrollToSelection():C&&resetScrollPos(C)}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(!(!t||!this.dom.contains(t.nodeType==1?t:t.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof NodeSelection){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&scrollRectIntoView(this,n.getBoundingClientRect(),t)}else scrollRectIntoView(this,this.coordsAtPos(this.state.selection.head,1),t)}}destroyPluginViews(){let t;for(;t=this.pluginViews.pop();)t.destroy&&t.destroy()}updatePluginViews(t){if(!t||t.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let o=this.directPlugins[n];o.spec.view&&this.pluginViews.push(o.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let o=this.state.plugins[n];o.spec.view&&this.pluginViews.push(o.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let o=this.pluginViews[n];o.update&&o.update(this,t)}}updateDraggedNode(t,n){let o=t.node,l=-1;if(this.state.doc.nodeAt(o.from)==o.node)l=o.from;else{let d=o.from+(this.state.doc.content.size-n.doc.content.size);(d>0&&this.state.doc.nodeAt(d))==o.node&&(l=d)}this.dragging=new Dragging(t.slice,t.move,l<0?void 0:NodeSelection.create(this.state.doc,l))}someProp(t,n){let o=this._props&&this._props[t],l;if(o!=null&&(l=n?n(o):o))return l;for(let f=0;f<this.directPlugins.length;f++){let g=this.directPlugins[f].props[t];if(g!=null&&(l=n?n(g):g))return l}let d=this.state.plugins;if(d)for(let f=0;f<d.length;f++){let g=d[f].props[t];if(g!=null&&(l=n?n(g):g))return l}}hasFocus(){if(ie$1){let t=this.root.activeElement;if(t==this.dom)return!0;if(!t||!this.dom.contains(t))return!1;for(;t&&this.dom!=t&&this.dom.contains(t);){if(t.contentEditable=="false")return!1;t=t.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&focusPreventScroll(this.dom),selectionToDOM(this),this.domObserver.start()}get root(){let t=this._root;if(t==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return t||document}updateRoot(){this._root=null}posAtCoords(t){return posAtCoords(this,t)}coordsAtPos(t,n=1){return coordsAtPos(this,t,n)}domAtPos(t,n=0){return this.docView.domFromPos(t,n)}nodeDOM(t){let n=this.docView.descAt(t);return n?n.nodeDOM:null}posAtDOM(t,n,o=-1){let l=this.docView.posFromDOM(t,n,o);if(l==null)throw new RangeError("DOM position not inside the editor");return l}endOfTextblock(t,n){return endOfTextblock(this,n||this.state,t)}pasteHTML(t,n){return doPaste(this,"",t,!1,n||new ClipboardEvent("paste"))}pasteText(t,n){return doPaste(this,t,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(t){return serializeForClipboard(this,t)}destroy(){this.docView&&(destroyInput(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],viewDecorations(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,clearReusedRange())}get isDestroyed(){return this.docView==null}dispatchEvent(t){return dispatchEvent(this,t)}domSelectionRange(){let t=this.domSelection();return t?safari&&this.root.nodeType===11&&deepActiveElement(this.dom.ownerDocument)==this.dom&&safariShadowSelectionRange(this,t)||t:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}EditorView.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function computeDocDeco(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(e.state)),n)for(let o in n)o=="class"?t.class+=" "+n[o]:o=="style"?t.style=(t.style?t.style+";":"")+n[o]:!t[o]&&o!="contenteditable"&&o!="nodeName"&&(t[o]=String(n[o]))}),t.translate||(t.translate="no"),[Decoration.node(0,e.state.doc.content.size,t)]}function updateCursorWrapper(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:Decoration.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function getEditable(e){return!e.someProp("editable",t=>t(e.state)===!1)}function selectionContextChanged(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function buildNodeViews(e){let t=Object.create(null);function n(o){for(let l in o)Object.prototype.hasOwnProperty.call(t,l)||(t[l]=o[l])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function changedNodeViews(e,t){let n=0,o=0;for(let l in e){if(e[l]!=t[l])return!0;n++}for(let l in t)o++;return n!=o}function checkStateComponent(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}for(var base={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},shift={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},mac$1=typeof navigator<"u"&&/Mac/.test(navigator.platform),ie=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),i=0;i<10;i++)base[48+i]=base[96+i]=String(i);for(var i=1;i<=24;i++)base[i+111]="F"+i;for(var i=65;i<=90;i++)base[i]=String.fromCharCode(i+32),shift[i]=String.fromCharCode(i);for(var code in base)shift.hasOwnProperty(code)||(shift[code]=base[code]);function keyName(e){var t=mac$1&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||ie&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",n=!t&&e.key||(e.shiftKey?shift:base)[e.keyCode]||e.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const mac=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),windows=typeof navigator<"u"&&/Win/.test(navigator.platform);function normalizeKeyName$1(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n=="Space"&&(n=" ");let o,l,d,f;for(let g=0;g<t.length-1;g++){let b=t[g];if(/^(cmd|meta|m)$/i.test(b))f=!0;else if(/^a(lt)?$/i.test(b))o=!0;else if(/^(c|ctrl|control)$/i.test(b))l=!0;else if(/^s(hift)?$/i.test(b))d=!0;else if(/^mod$/i.test(b))mac?f=!0:l=!0;else throw new Error("Unrecognized modifier name: "+b)}return o&&(n="Alt-"+n),l&&(n="Ctrl-"+n),f&&(n="Meta-"+n),d&&(n="Shift-"+n),n}function normalize(e){let t=Object.create(null);for(let n in e)t[normalizeKeyName$1(n)]=e[n];return t}function modifiers(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function keymap(e){return new Plugin({props:{handleKeyDown:keydownHandler(e)}})}function keydownHandler(e){let t=normalize(e);return function(n,o){let l=keyName(o),d,f=t[modifiers(l,o)];if(f&&f(n.state,n.dispatch,n))return!0;if(l.length==1&&l!=" "){if(o.shiftKey){let g=t[modifiers(l,o,!1)];if(g&&g(n.state,n.dispatch,n))return!0}if((o.altKey||o.metaKey||o.ctrlKey)&&!(windows&&o.ctrlKey&&o.altKey)&&(d=base[o.keyCode])&&d!=l){let g=t[modifiers(d,o)];if(g&&g(n.state,n.dispatch,n))return!0}}return!1}}const deleteSelection$1=(e,t)=>e.selection.empty?!1:(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function atBlockStart(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}const joinBackward$1=(e,t,n)=>{let o=atBlockStart(e,n);if(!o)return!1;let l=findCutBefore(o);if(!l){let f=o.blockRange(),g=f&&liftTarget(f);return g==null?!1:(t&&t(e.tr.lift(f,g).scrollIntoView()),!0)}let d=l.nodeBefore;if(deleteBarrier(e,l,t,-1))return!0;if(o.parent.content.size==0&&(textblockAt(d,"end")||NodeSelection.isSelectable(d)))for(let f=o.depth;;f--){let g=replaceStep(e.doc,o.before(f),o.after(f),Slice.empty);if(g&&g.slice.size<g.to-g.from){if(t){let b=e.tr.step(g);b.setSelection(textblockAt(d,"end")?Selection.findFrom(b.doc.resolve(b.mapping.map(l.pos,-1)),-1):NodeSelection.create(b.doc,l.pos-d.nodeSize)),t(b.scrollIntoView())}return!0}if(f==1||o.node(f-1).childCount>1)break}return d.isAtom&&l.depth==o.depth-1?(t&&t(e.tr.delete(l.pos-d.nodeSize,l.pos).scrollIntoView()),!0):!1},joinTextblockBackward$1=(e,t,n)=>{let o=atBlockStart(e,n);if(!o)return!1;let l=findCutBefore(o);return l?joinTextblocksAround(e,l,t):!1},joinTextblockForward$1=(e,t,n)=>{let o=atBlockEnd(e,n);if(!o)return!1;let l=findCutAfter(o);return l?joinTextblocksAround(e,l,t):!1};function joinTextblocksAround(e,t,n){let o=t.nodeBefore,l=o,d=t.pos-1;for(;!l.isTextblock;d--){if(l.type.spec.isolating)return!1;let S=l.lastChild;if(!S)return!1;l=S}let f=t.nodeAfter,g=f,b=t.pos+1;for(;!g.isTextblock;b++){if(g.type.spec.isolating)return!1;let S=g.firstChild;if(!S)return!1;g=S}let _=replaceStep(e.doc,d,b,Slice.empty);if(!_||_.from!=d||_ instanceof ReplaceStep&&_.slice.size>=b-d)return!1;if(n){let S=e.tr.step(_);S.setSelection(TextSelection.create(S.doc,d)),n(S.scrollIntoView())}return!0}function textblockAt(e,t,n=!1){for(let o=e;o;o=t=="start"?o.firstChild:o.lastChild){if(o.isTextblock)return!0;if(n&&o.childCount!=1)return!1}return!1}const selectNodeBackward$1=(e,t,n)=>{let{$head:o,empty:l}=e.selection,d=o;if(!l)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):o.parentOffset>0)return!1;d=findCutBefore(o)}let f=d&&d.nodeBefore;return!f||!NodeSelection.isSelectable(f)?!1:(t&&t(e.tr.setSelection(NodeSelection.create(e.doc,d.pos-f.nodeSize)).scrollIntoView()),!0)};function findCutBefore(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function atBlockEnd(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}const joinForward$1=(e,t,n)=>{let o=atBlockEnd(e,n);if(!o)return!1;let l=findCutAfter(o);if(!l)return!1;let d=l.nodeAfter;if(deleteBarrier(e,l,t,1))return!0;if(o.parent.content.size==0&&(textblockAt(d,"start")||NodeSelection.isSelectable(d))){let f=replaceStep(e.doc,o.before(),o.after(),Slice.empty);if(f&&f.slice.size<f.to-f.from){if(t){let g=e.tr.step(f);g.setSelection(textblockAt(d,"start")?Selection.findFrom(g.doc.resolve(g.mapping.map(l.pos)),1):NodeSelection.create(g.doc,g.mapping.map(l.pos))),t(g.scrollIntoView())}return!0}}return d.isAtom&&l.depth==o.depth-1?(t&&t(e.tr.delete(l.pos,l.pos+d.nodeSize).scrollIntoView()),!0):!1},selectNodeForward$1=(e,t,n)=>{let{$head:o,empty:l}=e.selection,d=o;if(!l)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):o.parentOffset<o.parent.content.size)return!1;d=findCutAfter(o)}let f=d&&d.nodeAfter;return!f||!NodeSelection.isSelectable(f)?!1:(t&&t(e.tr.setSelection(NodeSelection.create(e.doc,d.pos)).scrollIntoView()),!0)};function findCutAfter(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}const joinUp$1=(e,t)=>{let n=e.selection,o=n instanceof NodeSelection,l;if(o){if(n.node.isTextblock||!canJoin(e.doc,n.from))return!1;l=n.from}else if(l=joinPoint(e.doc,n.from,-1),l==null)return!1;if(t){let d=e.tr.join(l);o&&d.setSelection(NodeSelection.create(d.doc,l-e.doc.resolve(l).nodeBefore.nodeSize)),t(d.scrollIntoView())}return!0},joinDown$1=(e,t)=>{let n=e.selection,o;if(n instanceof NodeSelection){if(n.node.isTextblock||!canJoin(e.doc,n.to))return!1;o=n.to}else if(o=joinPoint(e.doc,n.to,1),o==null)return!1;return t&&t(e.tr.join(o).scrollIntoView()),!0},lift$1=(e,t)=>{let{$from:n,$to:o}=e.selection,l=n.blockRange(o),d=l&&liftTarget(l);return d==null?!1:(t&&t(e.tr.lift(l,d).scrollIntoView()),!0)},newlineInCode$1=(e,t)=>{let{$head:n,$anchor:o}=e.selection;return!n.parent.type.spec.code||!n.sameParent(o)?!1:(t&&t(e.tr.insertText(`
|
|
1285
|
+
`))),0,0),e.someProp("transformPasted",C=>{g=C(g,e,!0)}),g;let R=e.someProp("clipboardTextParser",C=>C(t,l,o,e));if(R)g=R;else{let C=l.marks(),{schema:E}=e.state,A=DOMSerializer.fromSchema(E);f=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(M=>{let I=f.appendChild(document.createElement("p"));M&&I.appendChild(A.serializeNode(E.text(M,C)))})}}else e.someProp("transformPastedHTML",R=>{n=R(n,e)}),f=readHTML(n),webkit&&restoreReplacedSpaces(f);let _=f&&f.querySelector("[data-pm-slice]"),S=_&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(_.getAttribute("data-pm-slice")||"");if(S&&S[3])for(let R=+S[3];R>0;R--){let C=f.firstChild;for(;C&&C.nodeType!=1;)C=C.nextSibling;if(!C)break;f=C}if(g||(g=(e.someProp("clipboardParser")||e.someProp("domParser")||DOMParser.fromSchema(e.state.schema)).parseSlice(f,{preserveWhitespace:!!(b||S),context:l,ruleFromNode(C){return C.nodeName=="BR"&&!C.nextSibling&&C.parentNode&&!inlineParents.test(C.parentNode.nodeName)?{ignore:!0}:null}})),S)g=addContext(closeSlice(g,+S[1],+S[2]),S[4]);else if(g=Slice.maxOpen(normalizeSiblings(g.content,l),!0),g.openStart||g.openEnd){let R=0,C=0;for(let E=g.content.firstChild;R<g.openStart&&!E.type.spec.isolating;R++,E=E.firstChild);for(let E=g.content.lastChild;C<g.openEnd&&!E.type.spec.isolating;C++,E=E.lastChild);g=closeSlice(g,R,C)}return e.someProp("transformPasted",R=>{g=R(g,e,b)}),g}const inlineParents=/^(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 normalizeSiblings(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let l=t.node(n).contentMatchAt(t.index(n)),d,f=[];if(e.forEach(g=>{if(!f)return;let b=l.findWrapping(g.type),_;if(!b)return f=null;if(_=f.length&&d.length&&addToSibling(b,d,g,f[f.length-1],0))f[f.length-1]=_;else{f.length&&(f[f.length-1]=closeRight(f[f.length-1],d.length));let S=withWrappers(g,b);f.push(S),l=l.matchType(S.type),d=b}}),f)return Fragment.from(f)}return e}function withWrappers(e,t,n=0){for(let o=t.length-1;o>=n;o--)e=t[o].create(null,Fragment.from(e));return e}function addToSibling(e,t,n,o,l){if(l<e.length&&l<t.length&&e[l]==t[l]){let d=addToSibling(e,t,n,o.lastChild,l+1);if(d)return o.copy(o.content.replaceChild(o.childCount-1,d));if(o.contentMatchAt(o.childCount).matchType(l==e.length-1?n.type:e[l+1]))return o.copy(o.content.append(Fragment.from(withWrappers(n,e,l+1))))}}function closeRight(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,closeRight(e.lastChild,t-1)),o=e.contentMatchAt(e.childCount).fillBefore(Fragment.empty,!0);return e.copy(n.append(o))}function closeRange(e,t,n,o,l,d){let f=t<0?e.firstChild:e.lastChild,g=f.content;return e.childCount>1&&(d=0),l<o-1&&(g=closeRange(g,t,n,o,l+1,d)),l>=n&&(g=t<0?f.contentMatchAt(0).fillBefore(g,d<=l).append(g):g.append(f.contentMatchAt(f.childCount).fillBefore(Fragment.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,f.copy(g))}function closeSlice(e,t,n){return t<e.openStart&&(e=new Slice(closeRange(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new Slice(closeRange(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const wrapMap={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let _detachedDoc=null;function detachedDoc(){return _detachedDoc||(_detachedDoc=document.implementation.createHTMLDocument("title"))}let _policy=null;function maybeWrapTrusted(e){let t=window.trustedTypes;return t?(_policy||(_policy=t.defaultPolicy||t.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),_policy.createHTML(e)):e}function readHTML(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=detachedDoc().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(e),l;if((l=o&&wrapMap[o[1].toLowerCase()])&&(e=l.map(d=>"<"+d+">").join("")+e+l.map(d=>"</"+d+">").reverse().join("")),n.innerHTML=maybeWrapTrusted(e),l)for(let d=0;d<l.length;d++)n=n.querySelector(l[d])||n;return n}function restoreReplacedSpaces(e){let t=e.querySelectorAll(chrome?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let o=t[n];o.childNodes.length==1&&o.textContent==" "&&o.parentNode&&o.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),o)}}function addContext(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,o;try{o=JSON.parse(t)}catch{return e}let{content:l,openStart:d,openEnd:f}=e;for(let g=o.length-2;g>=0;g-=2){let b=n.nodes[o[g]];if(!b||b.hasRequiredAttrs())break;l=Fragment.from(b.create(o[g+1],l)),d++,f++}return new Slice(l,d,f)}const handlers={},editHandlers={},passiveHandlers={touchstart:!0,touchmove:!0};class InputState{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.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function initInput(e){for(let t in handlers){let n=handlers[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=o=>{eventBelongsToView(e,o)&&!runCustomHandler(e,o)&&(e.editable||!(o.type in editHandlers))&&n(e,o)},passiveHandlers[t]?{passive:!0}:void 0)}safari&&e.dom.addEventListener("input",()=>null),ensureListeners(e)}function setSelectionOrigin(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function destroyInput(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function ensureListeners(e){e.someProp("handleDOMEvents",t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=o=>runCustomHandler(e,o))})}function runCustomHandler(e,t){return e.someProp("handleDOMEvents",n=>{let o=n[t.type];return o?o(e,t)||t.defaultPrevented:!1})}function eventBelongsToView(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function dispatchEvent(e,t){!runCustomHandler(e,t)&&handlers[t.type]&&(e.editable||!(t.type in editHandlers))&&handlers[t.type](e,t)}editHandlers.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!inOrNearComposition(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(android&&chrome&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),ios&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let o=Date.now();e.input.lastIOSEnter=o,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==o&&(e.someProp("handleKeyDown",l=>l(e,keyEvent(13,"Enter"))),e.input.lastIOSEnter=0)},200)}else e.someProp("handleKeyDown",o=>o(e,n))||captureKeyDown(e,n)?n.preventDefault():setSelectionOrigin(e,"key")},editHandlers.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},editHandlers.keypress=(e,t)=>{let n=t;if(inOrNearComposition(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||mac$2&&n.metaKey)return;if(e.someProp("handleKeyPress",l=>l(e,n))){n.preventDefault();return}let o=e.state.selection;if(!(o instanceof TextSelection)||!o.$from.sameParent(o.$to)){let l=String.fromCharCode(n.charCode),d=()=>e.state.tr.insertText(l).scrollIntoView();!/[\r\n]/.test(l)&&!e.someProp("handleTextInput",f=>f(e,o.$from.pos,o.$to.pos,l,d))&&e.dispatch(d()),n.preventDefault()}};function eventCoords(e){return{left:e.clientX,top:e.clientY}}function isNear(e,t){let n=t.x-e.clientX,o=t.y-e.clientY;return n*n+o*o<100}function runHandlerOnContext(e,t,n,o,l){if(o==-1)return!1;let d=e.state.doc.resolve(o);for(let f=d.depth+1;f>0;f--)if(e.someProp(t,g=>f>d.depth?g(e,n,d.nodeAfter,d.before(f),l,!0):g(e,n,d.node(f),d.before(f),l,!1)))return!0;return!1}function updateSelection(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let o=e.state.tr.setSelection(t);o.setMeta("pointer",!0),e.dispatch(o)}function selectClickedLeaf(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),o=n.nodeAfter;return o&&o.isAtom&&NodeSelection.isSelectable(o)?(updateSelection(e,new NodeSelection(n)),!0):!1}function selectClickedNode(e,t){if(t==-1)return!1;let n=e.state.selection,o,l;n instanceof NodeSelection&&(o=n.node);let d=e.state.doc.resolve(t);for(let f=d.depth+1;f>0;f--){let g=f>d.depth?d.nodeAfter:d.node(f);if(NodeSelection.isSelectable(g)){o&&n.$from.depth>0&&f>=n.$from.depth&&d.before(n.$from.depth+1)==n.$from.pos?l=d.before(n.$from.depth):l=d.before(f);break}}return l!=null?(updateSelection(e,NodeSelection.create(e.state.doc,l)),!0):!1}function handleSingleClick(e,t,n,o,l){return runHandlerOnContext(e,"handleClickOn",t,n,o)||e.someProp("handleClick",d=>d(e,t,o))||(l?selectClickedNode(e,n):selectClickedLeaf(e,n))}function handleDoubleClick(e,t,n,o){return runHandlerOnContext(e,"handleDoubleClickOn",t,n,o)||e.someProp("handleDoubleClick",l=>l(e,t,o))}function handleTripleClick(e,t,n,o){return runHandlerOnContext(e,"handleTripleClickOn",t,n,o)||e.someProp("handleTripleClick",l=>l(e,t,o))||defaultTripleClick(e,n,o)}function defaultTripleClick(e,t,n){if(n.button!=0)return!1;let o=e.state.doc;if(t==-1)return o.inlineContent?(updateSelection(e,TextSelection.create(o,0,o.content.size)),!0):!1;let l=o.resolve(t);for(let d=l.depth+1;d>0;d--){let f=d>l.depth?l.nodeAfter:l.node(d),g=l.before(d);if(f.inlineContent)updateSelection(e,TextSelection.create(o,g+1,g+1+f.content.size));else if(NodeSelection.isSelectable(f))updateSelection(e,NodeSelection.create(o,g));else continue;return!0}}function forceDOMFlush(e){return endComposition(e)}const selectNodeModifier=mac$2?"metaKey":"ctrlKey";handlers.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let o=forceDOMFlush(e),l=Date.now(),d="singleClick";l-e.input.lastClick.time<500&&isNear(n,e.input.lastClick)&&!n[selectNodeModifier]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type=="singleClick"?d="doubleClick":e.input.lastClick.type=="doubleClick"&&(d="tripleClick")),e.input.lastClick={time:l,x:n.clientX,y:n.clientY,type:d,button:n.button};let f=e.posAtCoords(eventCoords(n));f&&(d=="singleClick"?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new MouseDown(e,f,n,!!o)):(d=="doubleClick"?handleDoubleClick:handleTripleClick)(e,f.pos,f.inside,n)?n.preventDefault():setSelectionOrigin(e,"pointer"))};class MouseDown{constructor(t,n,o,l){this.view=t,this.pos=n,this.event=o,this.flushed=l,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!o[selectNodeModifier],this.allowDefault=o.shiftKey;let d,f;if(n.inside>-1)d=t.state.doc.nodeAt(n.inside),f=n.inside;else{let S=t.state.doc.resolve(n.pos);d=S.parent,f=S.depth?S.before():0}const g=l?null:o.target,b=g?t.docView.nearestDesc(g,!0):null;this.target=b&&b.nodeDOM.nodeType==1?b.nodeDOM:null;let{selection:_}=t.state;(o.button==0&&d.type.spec.draggable&&d.type.spec.selectable!==!1||_ instanceof NodeSelection&&_.from<=f&&_.to>f)&&(this.mightDrag={node:d,pos:f,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&gecko&&!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()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),setSelectionOrigin(t,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>selectionToDOM(this.view)),this.view.input.mouseDown=null}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(eventCoords(t))),this.updateAllowDefault(t),this.allowDefault||!n?setSelectionOrigin(this.view,"pointer"):handleSingleClick(this.view,n.pos,n.inside,t,this.selectNode)?t.preventDefault():t.button==0&&(this.flushed||safari&&this.mightDrag&&!this.mightDrag.node.isAtom||chrome&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(updateSelection(this.view,Selection.near(this.view.state.doc.resolve(n.pos))),t.preventDefault()):setSelectionOrigin(this.view,"pointer")}move(t){this.updateAllowDefault(t),setSelectionOrigin(this.view,"pointer"),t.buttons==0&&this.done()}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}}handlers.touchstart=e=>{e.input.lastTouch=Date.now(),forceDOMFlush(e),setSelectionOrigin(e,"pointer")},handlers.touchmove=e=>{e.input.lastTouch=Date.now(),setSelectionOrigin(e,"pointer")},handlers.contextmenu=e=>forceDOMFlush(e);function inOrNearComposition(e,t){return e.composing?!0:safari&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}const timeoutComposition=android?5e3:-1;editHandlers.compositionstart=editHandlers.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof TextSelection&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(o=>o.type.spec.inclusive===!1)||chrome&&windows$1&&selectionBeforeUneditable(e)))e.markCursor=e.state.storedMarks||n.marks(),endComposition(e,!0),e.markCursor=null;else if(endComposition(e,!t.selection.empty),gecko&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let o=e.domSelectionRange();for(let l=o.focusNode,d=o.focusOffset;l&&l.nodeType==1&&d!=0;){let f=d<0?l.lastChild:l.childNodes[d-1];if(!f)break;if(f.nodeType==3){let g=e.domSelection();g&&g.collapse(f,f.nodeValue.length);break}else l=f,d=-1}}e.input.composing=!0}scheduleComposeEnd(e,timeoutComposition)};function selectionBeforeUneditable(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||t.nodeType!=1||n>=t.childNodes.length)return!1;let o=t.childNodes[n];return o.nodeType==1&&o.contentEditable=="false"}editHandlers.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,scheduleComposeEnd(e,20))};function scheduleComposeEnd(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>endComposition(e),t))}function clearComposition(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=timestampFromCustomEvent());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function findCompositionNode(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=textNodeBefore$1(t.focusNode,t.focusOffset),o=textNodeAfter$1(t.focusNode,t.focusOffset);if(n&&o&&n!=o){let l=o.pmViewDesc,d=e.domObserver.lastChangedTextNode;if(n==d||o==d)return d;if(!l||!l.isText(o.nodeValue))return o;if(e.input.compositionNode==o){let f=n.pmViewDesc;if(!(!f||!f.isText(n.nodeValue)))return o}}return n||o}function timestampFromCustomEvent(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}function endComposition(e,t=!1){if(!(android&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),clearComposition(e),t||e.docView&&e.docView.dirty){let n=selectionFromDOM(e),o=e.state.selection;return n&&!n.eq(o)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!o.$from.node(o.$from.sharedDepth(o.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function captureCopy(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let o=getSelection(),l=document.createRange();l.selectNodeContents(t),e.dom.blur(),o.removeAllRanges(),o.addRange(l),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}const brokenClipboardAPI=ie$1&&ie_version<15||ios&&webkit_version<604;handlers.copy=editHandlers.cut=(e,t)=>{let n=t,o=e.state.selection,l=n.type=="cut";if(o.empty)return;let d=brokenClipboardAPI?null:n.clipboardData,f=o.content(),{dom:g,text:b}=serializeForClipboard(e,f);d?(n.preventDefault(),d.clearData(),d.setData("text/html",g.innerHTML),d.setData("text/plain",b)):captureCopy(e,g),l&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function sliceSingleNode(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function capturePaste(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,o=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(o.contentEditable="true"),o.style.cssText="position: fixed; left: -10000px; top: 10px",o.focus();let l=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),o.parentNode&&o.parentNode.removeChild(o),n?doPaste(e,o.value,null,l,t):doPaste(e,o.textContent,o.innerHTML,l,t)},50)}function doPaste(e,t,n,o,l){let d=parseFromClipboard(e,t,n,o,e.state.selection.$from);if(e.someProp("handlePaste",b=>b(e,l,d||Slice.empty)))return!0;if(!d)return!1;let f=sliceSingleNode(d),g=f?e.state.tr.replaceSelectionWith(f,o):e.state.tr.replaceSelection(d);return e.dispatch(g.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function getText$1(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}editHandlers.paste=(e,t)=>{let n=t;if(e.composing&&!android)return;let o=brokenClipboardAPI?null:n.clipboardData,l=e.input.shiftKey&&e.input.lastKeyCode!=45;o&&doPaste(e,getText$1(o),o.getData("text/html"),l,n)?n.preventDefault():capturePaste(e,n)};class Dragging{constructor(t,n,o){this.slice=t,this.move=n,this.node=o}}const dragCopyModifier=mac$2?"altKey":"ctrlKey";function dragMoves(e,t){let n=e.someProp("dragCopies",o=>!o(t));return n??!t[dragCopyModifier]}handlers.dragstart=(e,t)=>{let n=t,o=e.input.mouseDown;if(o&&o.done(),!n.dataTransfer)return;let l=e.state.selection,d=l.empty?null:e.posAtCoords(eventCoords(n)),f;if(!(d&&d.pos>=l.from&&d.pos<=(l instanceof NodeSelection?l.to-1:l.to))){if(o&&o.mightDrag)f=NodeSelection.create(e.state.doc,o.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let R=e.docView.nearestDesc(n.target,!0);R&&R.node.type.spec.draggable&&R!=e.docView&&(f=NodeSelection.create(e.state.doc,R.posBefore))}}let g=(f||e.state.selection).content(),{dom:b,text:_,slice:S}=serializeForClipboard(e,g);(!n.dataTransfer.files.length||!chrome||chrome_version>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(brokenClipboardAPI?"Text":"text/html",b.innerHTML),n.dataTransfer.effectAllowed="copyMove",brokenClipboardAPI||n.dataTransfer.setData("text/plain",_),e.dragging=new Dragging(S,dragMoves(e,n),f)},handlers.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},editHandlers.dragover=editHandlers.dragenter=(e,t)=>t.preventDefault(),editHandlers.drop=(e,t)=>{try{handleDrop(e,t,e.dragging)}finally{e.dragging=null}};function handleDrop(e,t,n){if(!t.dataTransfer)return;let o=e.posAtCoords(eventCoords(t));if(!o)return;let l=e.state.doc.resolve(o.pos),d=n&&n.slice;d?e.someProp("transformPasted",E=>{d=E(d,e,!1)}):d=parseFromClipboard(e,getText$1(t.dataTransfer),brokenClipboardAPI?null:t.dataTransfer.getData("text/html"),!1,l);let f=!!(n&&dragMoves(e,t));if(e.someProp("handleDrop",E=>E(e,t,d||Slice.empty,f))){t.preventDefault();return}if(!d)return;t.preventDefault();let g=d?dropPoint(e.state.doc,l.pos,d):l.pos;g==null&&(g=l.pos);let b=e.state.tr;if(f){let{node:E}=n;E?E.replace(b):b.deleteSelection()}let _=b.mapping.map(g),S=d.openStart==0&&d.openEnd==0&&d.content.childCount==1,R=b.doc;if(S?b.replaceRangeWith(_,_,d.content.firstChild):b.replaceRange(_,_,d),b.doc.eq(R))return;let C=b.doc.resolve(_);if(S&&NodeSelection.isSelectable(d.content.firstChild)&&C.nodeAfter&&C.nodeAfter.sameMarkup(d.content.firstChild))b.setSelection(new NodeSelection(C));else{let E=b.mapping.map(g);b.mapping.maps[b.mapping.maps.length-1].forEach((A,M,I,j)=>E=j),b.setSelection(selectionBetween(e,C,b.doc.resolve(E)))}e.focus(),e.dispatch(b.setMeta("uiEvent","drop"))}handlers.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&selectionToDOM(e)},20))},handlers.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},handlers.beforeinput=(e,t)=>{if(chrome&&android&&t.inputType=="deleteContentBackward"){e.domObserver.flushSoon();let{domChangeCount:o}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=o||(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",d=>d(e,keyEvent(8,"Backspace")))))return;let{$cursor:l}=e.state.selection;l&&l.pos>0&&e.dispatch(e.state.tr.delete(l.pos-1,l.pos).scrollIntoView())},50)}};for(let e in editHandlers)handlers[e]=editHandlers[e];function compareObjs(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class WidgetType{constructor(t,n){this.toDOM=t,this.spec=n||noSpec,this.side=this.spec.side||0}map(t,n,o,l){let{pos:d,deleted:f}=t.mapResult(n.from+l,this.side<0?-1:1);return f?null:new Decoration(d-o,d-o,this)}valid(){return!0}eq(t){return this==t||t instanceof WidgetType&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&compareObjs(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}}class InlineType{constructor(t,n){this.attrs=t,this.spec=n||noSpec}map(t,n,o,l){let d=t.map(n.from+l,this.spec.inclusiveStart?-1:1)-o,f=t.map(n.to+l,this.spec.inclusiveEnd?1:-1)-o;return d>=f?null:new Decoration(d,f,this)}valid(t,n){return n.from<n.to}eq(t){return this==t||t instanceof InlineType&&compareObjs(this.attrs,t.attrs)&&compareObjs(this.spec,t.spec)}static is(t){return t.type instanceof InlineType}destroy(){}}class NodeType{constructor(t,n){this.attrs=t,this.spec=n||noSpec}map(t,n,o,l){let d=t.mapResult(n.from+l,1);if(d.deleted)return null;let f=t.mapResult(n.to+l,-1);return f.deleted||f.pos<=d.pos?null:new Decoration(d.pos-o,f.pos-o,this)}valid(t,n){let{index:o,offset:l}=t.content.findIndex(n.from),d;return l==n.from&&!(d=t.child(o)).isText&&l+d.nodeSize==n.to}eq(t){return this==t||t instanceof NodeType&&compareObjs(this.attrs,t.attrs)&&compareObjs(this.spec,t.spec)}destroy(){}}class Decoration{constructor(t,n,o){this.from=t,this.to=n,this.type=o}copy(t,n){return new Decoration(t,n,this.type)}eq(t,n=0){return this.type.eq(t.type)&&this.from+n==t.from&&this.to+n==t.to}map(t,n,o){return this.type.map(t,this,n,o)}static widget(t,n,o){return new Decoration(t,t,new WidgetType(n,o))}static inline(t,n,o,l){return new Decoration(t,n,new InlineType(o,l))}static node(t,n,o,l){return new Decoration(t,n,new NodeType(o,l))}get spec(){return this.type.spec}get inline(){return this.type instanceof InlineType}get widget(){return this.type instanceof WidgetType}}const none=[],noSpec={};class DecorationSet{constructor(t,n){this.local=t.length?t:none,this.children=n.length?n:none}static create(t,n){return n.length?buildTree(n,t,0,noSpec):empty}find(t,n,o){let l=[];return this.findInner(t??0,n??1e9,l,0,o),l}findInner(t,n,o,l,d){for(let f=0;f<this.local.length;f++){let g=this.local[f];g.from<=n&&g.to>=t&&(!d||d(g.spec))&&o.push(g.copy(g.from+l,g.to+l))}for(let f=0;f<this.children.length;f+=3)if(this.children[f]<n&&this.children[f+1]>t){let g=this.children[f]+1;this.children[f+2].findInner(t-g,n-g,o,l+g,d)}}map(t,n,o){return this==empty||t.maps.length==0?this:this.mapInner(t,n,0,0,o||noSpec)}mapInner(t,n,o,l,d){let f;for(let g=0;g<this.local.length;g++){let b=this.local[g].map(t,o,l);b&&b.type.valid(n,b)?(f||(f=[])).push(b):d.onRemove&&d.onRemove(this.local[g].spec)}return this.children.length?mapChildren(this.children,f||[],t,n,o,l,d):f?new DecorationSet(f.sort(byPos),none):empty}add(t,n){return n.length?this==empty?DecorationSet.create(t,n):this.addInner(t,n,0):this}addInner(t,n,o){let l,d=0;t.forEach((g,b)=>{let _=b+o,S;if(S=takeSpansForNode(n,g,_)){for(l||(l=this.children.slice());d<l.length&&l[d]<b;)d+=3;l[d]==b?l[d+2]=l[d+2].addInner(g,S,_+1):l.splice(d,0,b,b+g.nodeSize,buildTree(S,g,_+1,noSpec)),d+=3}});let f=moveSpans(d?withoutNulls(n):n,-o);for(let g=0;g<f.length;g++)f[g].type.valid(t,f[g])||f.splice(g--,1);return new DecorationSet(f.length?this.local.concat(f).sort(byPos):this.local,l||this.children)}remove(t){return t.length==0||this==empty?this:this.removeInner(t,0)}removeInner(t,n){let o=this.children,l=this.local;for(let d=0;d<o.length;d+=3){let f,g=o[d]+n,b=o[d+1]+n;for(let S=0,R;S<t.length;S++)(R=t[S])&&R.from>g&&R.to<b&&(t[S]=null,(f||(f=[])).push(R));if(!f)continue;o==this.children&&(o=this.children.slice());let _=o[d+2].removeInner(f,g+1);_!=empty?o[d+2]=_:(o.splice(d,3),d-=3)}if(l.length){for(let d=0,f;d<t.length;d++)if(f=t[d])for(let g=0;g<l.length;g++)l[g].eq(f,n)&&(l==this.local&&(l=this.local.slice()),l.splice(g--,1))}return o==this.children&&l==this.local?this:l.length||o.length?new DecorationSet(l,o):empty}forChild(t,n){if(this==empty)return this;if(n.isLeaf)return DecorationSet.empty;let o,l;for(let g=0;g<this.children.length;g+=3)if(this.children[g]>=t){this.children[g]==t&&(o=this.children[g+2]);break}let d=t+1,f=d+n.content.size;for(let g=0;g<this.local.length;g++){let b=this.local[g];if(b.from<f&&b.to>d&&b.type instanceof InlineType){let _=Math.max(d,b.from)-d,S=Math.min(f,b.to)-d;_<S&&(l||(l=[])).push(b.copy(_,S))}}if(l){let g=new DecorationSet(l.sort(byPos),none);return o?new DecorationGroup([g,o]):g}return o||empty}eq(t){if(this==t)return!0;if(!(t instanceof DecorationSet)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(t.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=t.children[n]||this.children[n+1]!=t.children[n+1]||!this.children[n+2].eq(t.children[n+2]))return!1;return!0}locals(t){return removeOverlap(this.localsInner(t))}localsInner(t){if(this==empty)return none;if(t.inlineContent||!this.local.some(InlineType.is))return this.local;let n=[];for(let o=0;o<this.local.length;o++)this.local[o].type instanceof InlineType||n.push(this.local[o]);return n}forEachSet(t){t(this)}}DecorationSet.empty=new DecorationSet([],[]),DecorationSet.removeOverlap=removeOverlap;const empty=DecorationSet.empty;class DecorationGroup{constructor(t){this.members=t}map(t,n){const o=this.members.map(l=>l.map(t,n,noSpec));return DecorationGroup.from(o)}forChild(t,n){if(n.isLeaf)return DecorationSet.empty;let o=[];for(let l=0;l<this.members.length;l++){let d=this.members[l].forChild(t,n);d!=empty&&(d instanceof DecorationGroup?o=o.concat(d.members):o.push(d))}return DecorationGroup.from(o)}eq(t){if(!(t instanceof DecorationGroup)||t.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(t.members[n]))return!1;return!0}locals(t){let n,o=!0;for(let l=0;l<this.members.length;l++){let d=this.members[l].localsInner(t);if(d.length)if(!n)n=d;else{o&&(n=n.slice(),o=!1);for(let f=0;f<d.length;f++)n.push(d[f])}}return n?removeOverlap(o?n:n.sort(byPos)):none}static from(t){switch(t.length){case 0:return empty;case 1:return t[0];default:return new DecorationGroup(t.every(n=>n instanceof DecorationSet)?t:t.reduce((n,o)=>n.concat(o instanceof DecorationSet?o:o.members),[]))}}forEachSet(t){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(t)}}function mapChildren(e,t,n,o,l,d,f){let g=e.slice();for(let _=0,S=d;_<n.maps.length;_++){let R=0;n.maps[_].forEach((C,E,A,M)=>{let I=M-A-(E-C);for(let j=0;j<g.length;j+=3){let q=g[j+1];if(q<0||C>q+S-R)continue;let Q=g[j]+S-R;E>=Q?g[j+1]=C<=Q?-2:-1:C>=S&&I&&(g[j]+=I,g[j+1]+=I)}R+=I}),S=n.maps[_].map(S,-1)}let b=!1;for(let _=0;_<g.length;_+=3)if(g[_+1]<0){if(g[_+1]==-2){b=!0,g[_+1]=-1;continue}let S=n.map(e[_]+d),R=S-l;if(R<0||R>=o.content.size){b=!0;continue}let C=n.map(e[_+1]+d,-1),E=C-l,{index:A,offset:M}=o.content.findIndex(R),I=o.maybeChild(A);if(I&&M==R&&M+I.nodeSize==E){let j=g[_+2].mapInner(n,I,S+1,e[_]+d+1,f);j!=empty?(g[_]=R,g[_+1]=E,g[_+2]=j):(g[_+1]=-2,b=!0)}else b=!0}if(b){let _=mapAndGatherRemainingDecorations(g,e,t,n,l,d,f),S=buildTree(_,o,0,f);t=S.local;for(let R=0;R<g.length;R+=3)g[R+1]<0&&(g.splice(R,3),R-=3);for(let R=0,C=0;R<S.children.length;R+=3){let E=S.children[R];for(;C<g.length&&g[C]<E;)C+=3;g.splice(C,0,S.children[R],S.children[R+1],S.children[R+2])}}return new DecorationSet(t.sort(byPos),g)}function moveSpans(e,t){if(!t||!e.length)return e;let n=[];for(let o=0;o<e.length;o++){let l=e[o];n.push(new Decoration(l.from+t,l.to+t,l.type))}return n}function mapAndGatherRemainingDecorations(e,t,n,o,l,d,f){function g(b,_){for(let S=0;S<b.local.length;S++){let R=b.local[S].map(o,l,_);R?n.push(R):f.onRemove&&f.onRemove(b.local[S].spec)}for(let S=0;S<b.children.length;S+=3)g(b.children[S+2],b.children[S]+_+1)}for(let b=0;b<e.length;b+=3)e[b+1]==-1&&g(e[b+2],t[b]+d+1);return n}function takeSpansForNode(e,t,n){if(t.isLeaf)return null;let o=n+t.nodeSize,l=null;for(let d=0,f;d<e.length;d++)(f=e[d])&&f.from>n&&f.to<o&&((l||(l=[])).push(f),e[d]=null);return l}function withoutNulls(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function buildTree(e,t,n,o){let l=[],d=!1;t.forEach((g,b)=>{let _=takeSpansForNode(e,g,b+n);if(_){d=!0;let S=buildTree(_,g,n+b+1,o);S!=empty&&l.push(b,b+g.nodeSize,S)}});let f=moveSpans(d?withoutNulls(e):e,-n).sort(byPos);for(let g=0;g<f.length;g++)f[g].type.valid(t,f[g])||(o.onRemove&&o.onRemove(f[g].spec),f.splice(g--,1));return f.length||l.length?new DecorationSet(f,l):empty}function byPos(e,t){return e.from-t.from||e.to-t.to}function removeOverlap(e){let t=e;for(let n=0;n<t.length-1;n++){let o=t[n];if(o.from!=o.to)for(let l=n+1;l<t.length;l++){let d=t[l];if(d.from==o.from){d.to!=o.to&&(t==e&&(t=e.slice()),t[l]=d.copy(d.from,o.to),insertAhead(t,l+1,d.copy(o.to,d.to)));continue}else{d.from<o.to&&(t==e&&(t=e.slice()),t[n]=o.copy(o.from,d.from),insertAhead(t,l,o.copy(d.from,o.to)));break}}}return t}function insertAhead(e,t,n){for(;t<e.length&&byPos(n,e[t])>0;)t++;e.splice(t,0,n)}function viewDecorations(e){let t=[];return e.someProp("decorations",n=>{let o=n(e.state);o&&o!=empty&&t.push(o)}),e.cursorWrapper&&t.push(DecorationSet.create(e.state.doc,[e.cursorWrapper.deco])),DecorationGroup.from(t)}const observeOptions={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},useCharData=ie$1&&ie_version<=11;let SelectionState$1=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset}};class DOMObserver{constructor(t,n){this.view=t,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new SelectionState$1,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(o=>{for(let l=0;l<o.length;l++)this.queue.push(o[l]);ie$1&&ie_version<=11&&o.some(l=>l.type=="childList"&&l.removedNodes.length||l.type=="characterData"&&l.oldValue.length>l.target.nodeValue.length)?this.flushSoon():this.flush()}),useCharData&&(this.onCharData=o=>{this.queue.push({target:o.target,type:"characterData",oldValue:o.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,observeOptions)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let t=this.observer.takeRecords();if(t.length){for(let n=0;n<t.length;n++)this.queue.push(t[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(hasFocusAndSelection(this.view)){if(this.suppressingSelectionUpdates)return selectionToDOM(this.view);if(ie$1&&ie_version<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&isEquivalentPosition(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(t){if(!t.focusNode)return!0;let n=new Set,o;for(let d=t.focusNode;d;d=parentNode(d))n.add(d);for(let d=t.anchorNode;d;d=parentNode(d))if(n.has(d)){o=d;break}let l=o&&this.view.docView.nearestDesc(o);if(l&&l.ignoreMutation({type:"selection",target:o.nodeType==3?o.parentNode:o}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let o=t.domSelectionRange(),l=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(o)&&hasFocusAndSelection(t)&&!this.ignoreSelectionChange(o),d=-1,f=-1,g=!1,b=[];if(t.editable)for(let S=0;S<n.length;S++){let R=this.registerMutation(n[S],b);R&&(d=d<0?R.from:Math.min(R.from,d),f=f<0?R.to:Math.max(R.to,f),R.typeOver&&(g=!0))}if(gecko&&b.length){let S=b.filter(R=>R.nodeName=="BR");if(S.length==2){let[R,C]=S;R.parentNode&&R.parentNode.parentNode==C.parentNode?C.remove():R.remove()}else{let{focusNode:R}=this.currentSelection;for(let C of S){let E=C.parentNode;E&&E.nodeName=="LI"&&(!R||blockParent(t,R)!=E)&&C.remove()}}}else if((chrome||safari)&&b.some(S=>S.nodeName=="BR")&&(t.input.lastKeyCode==8||t.input.lastKeyCode==46)){for(let S of b)if(S.nodeName=="BR"&&S.parentNode){let R=S.nextSibling;R&&R.nodeType==1&&R.contentEditable=="false"&&S.parentNode.removeChild(S)}}let _=null;d<0&&l&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&selectionCollapsed(o)&&(_=selectionFromDOM(t))&&_.eq(Selection.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,selectionToDOM(t),this.currentSelection.set(o),t.scrollToSelection()):(d>-1||l)&&(d>-1&&(t.docView.markDirty(d,f),checkCSS(t)),this.handleDOMChange(d,f,g,b),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(o)||selectionToDOM(t),this.currentSelection.set(o))}registerMutation(t,n){if(n.indexOf(t.target)>-1)return null;let o=this.view.docView.nearestDesc(t.target);if(t.type=="attributes"&&(o==this.view.docView||t.attributeName=="contenteditable"||t.attributeName=="style"&&!t.oldValue&&!t.target.getAttribute("style"))||!o||o.ignoreMutation(t))return null;if(t.type=="childList"){for(let S=0;S<t.addedNodes.length;S++){let R=t.addedNodes[S];n.push(R),R.nodeType==3&&(this.lastChangedTextNode=R)}if(o.contentDOM&&o.contentDOM!=o.dom&&!o.contentDOM.contains(t.target))return{from:o.posBefore,to:o.posAfter};let l=t.previousSibling,d=t.nextSibling;if(ie$1&&ie_version<=11&&t.addedNodes.length)for(let S=0;S<t.addedNodes.length;S++){let{previousSibling:R,nextSibling:C}=t.addedNodes[S];(!R||Array.prototype.indexOf.call(t.addedNodes,R)<0)&&(l=R),(!C||Array.prototype.indexOf.call(t.addedNodes,C)<0)&&(d=C)}let f=l&&l.parentNode==t.target?domIndex(l)+1:0,g=o.localPosFromDOM(t.target,f,-1),b=d&&d.parentNode==t.target?domIndex(d):t.target.childNodes.length,_=o.localPosFromDOM(t.target,b,1);return{from:g,to:_}}else return t.type=="attributes"?{from:o.posAtStart-o.border,to:o.posAtEnd+o.border}:(this.lastChangedTextNode=t.target,{from:o.posAtStart,to:o.posAtEnd,typeOver:t.target.nodeValue==t.oldValue})}}let cssChecked=new WeakMap,cssCheckWarned=!1;function checkCSS(e){if(!cssChecked.has(e)&&(cssChecked.set(e,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=gecko,cssCheckWarned)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),cssCheckWarned=!0}}function rangeToSelectionRange(e,t){let n=t.startContainer,o=t.startOffset,l=t.endContainer,d=t.endOffset,f=e.domAtPos(e.state.selection.anchor);return isEquivalentPosition(f.node,f.offset,l,d)&&([n,o,l,d]=[l,d,n,o]),{anchorNode:n,anchorOffset:o,focusNode:l,focusOffset:d}}function safariShadowSelectionRange(e,t){if(t.getComposedRanges){let l=t.getComposedRanges(e.root)[0];if(l)return rangeToSelectionRange(e,l)}let n;function o(l){l.preventDefault(),l.stopImmediatePropagation(),n=l.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",o,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",o,!0),n?rangeToSelectionRange(e,n):null}function blockParent(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let o=e.docView.nearestDesc(n,!0);if(o&&o.node.isBlock)return n}return null}function parseBetween(e,t,n){let{node:o,fromOffset:l,toOffset:d,from:f,to:g}=e.docView.parseRange(t,n),b=e.domSelectionRange(),_,S=b.anchorNode;if(S&&e.dom.contains(S.nodeType==1?S:S.parentNode)&&(_=[{node:S,offset:b.anchorOffset}],selectionCollapsed(b)||_.push({node:b.focusNode,offset:b.focusOffset})),chrome&&e.input.lastKeyCode===8)for(let I=d;I>l;I--){let j=o.childNodes[I-1],q=j.pmViewDesc;if(j.nodeName=="BR"&&!q){d=I;break}if(!q||q.size)break}let R=e.state.doc,C=e.someProp("domParser")||DOMParser.fromSchema(e.state.schema),E=R.resolve(f),A=null,M=C.parse(o,{topNode:E.parent,topMatch:E.parent.contentMatchAt(E.index()),topOpen:!0,from:l,to:d,preserveWhitespace:E.parent.type.whitespace=="pre"?"full":!0,findPositions:_,ruleFromNode,context:E});if(_&&_[0].pos!=null){let I=_[0].pos,j=_[1]&&_[1].pos;j==null&&(j=I),A={anchor:I+f,head:j+f}}return{doc:M,sel:A,from:f,to:g}}function ruleFromNode(e){let t=e.pmViewDesc;if(t)return t.parseRule();if(e.nodeName=="BR"&&e.parentNode){if(safari&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(e.parentNode.lastChild==e||safari&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}const isInline=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function readDOMChange(e,t,n,o,l){let d=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let ne=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,ae=selectionFromDOM(e,ne);if(ae&&!e.state.selection.eq(ae)){if(chrome&&android&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",Oe=>Oe(e,keyEvent(13,"Enter"))))return;let se=e.state.tr.setSelection(ae);ne=="pointer"?se.setMeta("pointer",!0):ne=="key"&&se.scrollIntoView(),d&&se.setMeta("composition",d),e.dispatch(se)}return}let f=e.state.doc.resolve(t),g=f.sharedDepth(n);t=f.before(g+1),n=e.state.doc.resolve(n).after(g+1);let b=e.state.selection,_=parseBetween(e,t,n),S=e.state.doc,R=S.slice(_.from,_.to),C,E;e.input.lastKeyCode===8&&Date.now()-100<e.input.lastKeyCodeTime?(C=e.state.selection.to,E="end"):(C=e.state.selection.from,E="start"),e.input.lastKeyCode=null;let A=findDiff(R.content,_.doc.content,_.from,C,E);if(A&&e.input.domChangeCount++,(ios&&e.input.lastIOSEnter>Date.now()-225||android)&&l.some(ne=>ne.nodeType==1&&!isInline.test(ne.nodeName))&&(!A||A.endA>=A.endB)&&e.someProp("handleKeyDown",ne=>ne(e,keyEvent(13,"Enter")))){e.input.lastIOSEnter=0;return}if(!A)if(o&&b instanceof TextSelection&&!b.empty&&b.$head.sameParent(b.$anchor)&&!e.composing&&!(_.sel&&_.sel.anchor!=_.sel.head))A={start:b.from,endA:b.to,endB:b.to};else{if(_.sel){let ne=resolveSelection(e,e.state.doc,_.sel);if(ne&&!ne.eq(e.state.selection)){let ae=e.state.tr.setSelection(ne);d&&ae.setMeta("composition",d),e.dispatch(ae)}}return}e.state.selection.from<e.state.selection.to&&A.start==A.endB&&e.state.selection instanceof TextSelection&&(A.start>e.state.selection.from&&A.start<=e.state.selection.from+2&&e.state.selection.from>=_.from?A.start=e.state.selection.from:A.endA<e.state.selection.to&&A.endA>=e.state.selection.to-2&&e.state.selection.to<=_.to&&(A.endB+=e.state.selection.to-A.endA,A.endA=e.state.selection.to)),ie$1&&ie_version<=11&&A.endB==A.start+1&&A.endA==A.start&&A.start>_.from&&_.doc.textBetween(A.start-_.from-1,A.start-_.from+1)==" "&&(A.start--,A.endA--,A.endB--);let M=_.doc.resolveNoCache(A.start-_.from),I=_.doc.resolveNoCache(A.endB-_.from),j=S.resolve(A.start),q=M.sameParent(I)&&M.parent.inlineContent&&j.end()>=A.endA;if((ios&&e.input.lastIOSEnter>Date.now()-225&&(!q||l.some(ne=>ne.nodeName=="DIV"||ne.nodeName=="P"))||!q&&M.pos<_.doc.content.size&&(!M.sameParent(I)||!M.parent.inlineContent)&&M.pos<I.pos&&!/\S/.test(_.doc.textBetween(M.pos,I.pos,"","")))&&e.someProp("handleKeyDown",ne=>ne(e,keyEvent(13,"Enter")))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>A.start&&looksLikeBackspace(S,A.start,A.endA,M,I)&&e.someProp("handleKeyDown",ne=>ne(e,keyEvent(8,"Backspace")))){android&&chrome&&e.domObserver.suppressSelectionUpdates();return}chrome&&A.endB==A.start&&(e.input.lastChromeDelete=Date.now()),android&&!q&&M.start()!=I.start()&&I.parentOffset==0&&M.depth==I.depth&&_.sel&&_.sel.anchor==_.sel.head&&_.sel.head==A.endA&&(A.endB-=2,I=_.doc.resolveNoCache(A.endB-_.from),setTimeout(()=>{e.someProp("handleKeyDown",function(ne){return ne(e,keyEvent(13,"Enter"))})},20));let Q=A.start,te=A.endA,F=ne=>{let ae=ne||e.state.tr.replace(Q,te,_.doc.slice(A.start-_.from,A.endB-_.from));if(_.sel){let se=resolveSelection(e,ae.doc,_.sel);se&&!(chrome&&e.composing&&se.empty&&(A.start!=A.endB||e.input.lastChromeDelete<Date.now()-100)&&(se.head==Q||se.head==ae.mapping.map(te)-1)||ie$1&&se.empty&&se.head==Q)&&ae.setSelection(se)}return d&&ae.setMeta("composition",d),ae.scrollIntoView()},V;if(q)if(M.pos==I.pos){ie$1&&ie_version<=11&&M.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>selectionToDOM(e),20));let ne=F(e.state.tr.delete(Q,te)),ae=S.resolve(A.start).marksAcross(S.resolve(A.endA));ae&&ne.ensureMarks(ae),e.dispatch(ne)}else if(A.endA==A.endB&&(V=isMarkChange(M.parent.content.cut(M.parentOffset,I.parentOffset),j.parent.content.cut(j.parentOffset,A.endA-j.start())))){let ne=F(e.state.tr);V.type=="add"?ne.addMark(Q,te,V.mark):ne.removeMark(Q,te,V.mark),e.dispatch(ne)}else if(M.parent.child(M.index()).isText&&M.index()==I.index()-(I.textOffset?0:1)){let ne=M.parent.textBetween(M.parentOffset,I.parentOffset),ae=()=>F(e.state.tr.insertText(ne,Q,te));e.someProp("handleTextInput",se=>se(e,Q,te,ne,ae))||e.dispatch(ae())}else e.dispatch(F());else e.dispatch(F())}function resolveSelection(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:selectionBetween(e,t.resolve(n.anchor),t.resolve(n.head))}function isMarkChange(e,t){let n=e.firstChild.marks,o=t.firstChild.marks,l=n,d=o,f,g,b;for(let S=0;S<o.length;S++)l=o[S].removeFromSet(l);for(let S=0;S<n.length;S++)d=n[S].removeFromSet(d);if(l.length==1&&d.length==0)g=l[0],f="add",b=S=>S.mark(g.addToSet(S.marks));else if(l.length==0&&d.length==1)g=d[0],f="remove",b=S=>S.mark(g.removeFromSet(S.marks));else return null;let _=[];for(let S=0;S<t.childCount;S++)_.push(b(t.child(S)));if(Fragment.from(_).eq(e))return{mark:g,type:f}}function looksLikeBackspace(e,t,n,o,l){if(n-t<=l.pos-o.pos||skipClosingAndOpening(o,!0,!1)<l.pos)return!1;let d=e.resolve(t);if(!o.parent.isTextblock){let g=d.nodeAfter;return g!=null&&n==t+g.nodeSize}if(d.parentOffset<d.parent.content.size||!d.parent.isTextblock)return!1;let f=e.resolve(skipClosingAndOpening(d,!0,!0));return!f.parent.isTextblock||f.pos>n||skipClosingAndOpening(f,!0,!1)<n?!1:o.parent.content.cut(o.parentOffset).eq(f.parent.content)}function skipClosingAndOpening(e,t,n){let o=e.depth,l=t?e.end():e.pos;for(;o>0&&(t||e.indexAfter(o)==e.node(o).childCount);)o--,l++,t=!1;if(n){let d=e.node(o).maybeChild(e.indexAfter(o));for(;d&&!d.isLeaf;)d=d.firstChild,l++}return l}function findDiff(e,t,n,o,l){let d=e.findDiffStart(t,n);if(d==null)return null;let{a:f,b:g}=e.findDiffEnd(t,n+e.size,n+t.size);if(l=="end"){let b=Math.max(0,d-Math.min(f,g));o-=f+b-d}if(f<d&&e.size<t.size){let b=o<=d&&o>=f?d-o:0;d-=b,d&&d<t.size&&isSurrogatePair(t.textBetween(d-1,d+1))&&(d+=b?1:-1),g=d+(g-f),f=d}else if(g<d){let b=o<=d&&o>=g?d-o:0;d-=b,d&&d<e.size&&isSurrogatePair(e.textBetween(d-1,d+1))&&(d+=b?1:-1),f=d+(f-g),g=d}return{start:d,endA:f,endB:g}}function isSurrogatePair(e){if(e.length!=2)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}class EditorView{constructor(t,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new InputState,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(checkStateComponent),this.dispatch=this.dispatch.bind(this),this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):typeof t=="function"?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=getEditable(this),updateCursorWrapper(this),this.nodeViews=buildNodeViews(this),this.docView=docViewDesc(this.state.doc,computeDocDeco(this),viewDecorations(this),this.dom,this),this.domObserver=new DOMObserver(this,(o,l,d,f)=>readDOMChange(this,o,l,d,f)),this.domObserver.start(),initInput(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let t=this._props;this._props={};for(let n in t)this._props[n]=t[n];this._props.state=this.state}return this._props}update(t){t.handleDOMEvents!=this._props.handleDOMEvents&&ensureListeners(this);let n=this._props;this._props=t,t.plugins&&(t.plugins.forEach(checkStateComponent),this.directPlugins=t.plugins),this.updateStateInner(t.state,n)}setProps(t){let n={};for(let o in this._props)n[o]=this._props[o];n.state=this.state;for(let o in t)n[o]=t[o];this.update(n)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,n){var o;let l=this.state,d=!1,f=!1;t.storedMarks&&this.composing&&(clearComposition(this),f=!0),this.state=t;let g=l.plugins!=t.plugins||this._props.plugins!=n.plugins;if(g||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let E=buildNodeViews(this);changedNodeViews(E,this.nodeViews)&&(this.nodeViews=E,d=!0)}(g||n.handleDOMEvents!=this._props.handleDOMEvents)&&ensureListeners(this),this.editable=getEditable(this),updateCursorWrapper(this);let b=viewDecorations(this),_=computeDocDeco(this),S=l.plugins!=t.plugins&&!l.doc.eq(t.doc)?"reset":t.scrollToSelection>l.scrollToSelection?"to selection":"preserve",R=d||!this.docView.matchesNode(t.doc,_,b);(R||!t.selection.eq(l.selection))&&(f=!0);let C=S=="preserve"&&f&&this.dom.style.overflowAnchor==null&&storeScrollPos(this);if(f){this.domObserver.stop();let E=R&&(ie$1||chrome)&&!this.composing&&!l.selection.empty&&!t.selection.empty&&selectionContextChanged(l.selection,t.selection);if(R){let A=chrome?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=findCompositionNode(this)),(d||!this.docView.update(t.doc,_,b,this))&&(this.docView.updateOuterDeco(_),this.docView.destroy(),this.docView=docViewDesc(t.doc,_,b,this.dom,this)),A&&!this.trackWrites&&(E=!0)}E||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&anchorInRightPlace(this))?selectionToDOM(this,E):(syncNodeSelection(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(l),!((o=this.dragging)===null||o===void 0)&&o.node&&!l.doc.eq(t.doc)&&this.updateDraggedNode(this.dragging,l),S=="reset"?this.dom.scrollTop=0:S=="to selection"?this.scrollToSelection():C&&resetScrollPos(C)}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(!(!t||!this.dom.contains(t.nodeType==1?t:t.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof NodeSelection){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&scrollRectIntoView(this,n.getBoundingClientRect(),t)}else scrollRectIntoView(this,this.coordsAtPos(this.state.selection.head,1),t)}}destroyPluginViews(){let t;for(;t=this.pluginViews.pop();)t.destroy&&t.destroy()}updatePluginViews(t){if(!t||t.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let o=this.directPlugins[n];o.spec.view&&this.pluginViews.push(o.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let o=this.state.plugins[n];o.spec.view&&this.pluginViews.push(o.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let o=this.pluginViews[n];o.update&&o.update(this,t)}}updateDraggedNode(t,n){let o=t.node,l=-1;if(this.state.doc.nodeAt(o.from)==o.node)l=o.from;else{let d=o.from+(this.state.doc.content.size-n.doc.content.size);(d>0&&this.state.doc.nodeAt(d))==o.node&&(l=d)}this.dragging=new Dragging(t.slice,t.move,l<0?void 0:NodeSelection.create(this.state.doc,l))}someProp(t,n){let o=this._props&&this._props[t],l;if(o!=null&&(l=n?n(o):o))return l;for(let f=0;f<this.directPlugins.length;f++){let g=this.directPlugins[f].props[t];if(g!=null&&(l=n?n(g):g))return l}let d=this.state.plugins;if(d)for(let f=0;f<d.length;f++){let g=d[f].props[t];if(g!=null&&(l=n?n(g):g))return l}}hasFocus(){if(ie$1){let t=this.root.activeElement;if(t==this.dom)return!0;if(!t||!this.dom.contains(t))return!1;for(;t&&this.dom!=t&&this.dom.contains(t);){if(t.contentEditable=="false")return!1;t=t.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&focusPreventScroll(this.dom),selectionToDOM(this),this.domObserver.start()}get root(){let t=this._root;if(t==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return t||document}updateRoot(){this._root=null}posAtCoords(t){return posAtCoords(this,t)}coordsAtPos(t,n=1){return coordsAtPos(this,t,n)}domAtPos(t,n=0){return this.docView.domFromPos(t,n)}nodeDOM(t){let n=this.docView.descAt(t);return n?n.nodeDOM:null}posAtDOM(t,n,o=-1){let l=this.docView.posFromDOM(t,n,o);if(l==null)throw new RangeError("DOM position not inside the editor");return l}endOfTextblock(t,n){return endOfTextblock(this,n||this.state,t)}pasteHTML(t,n){return doPaste(this,"",t,!1,n||new ClipboardEvent("paste"))}pasteText(t,n){return doPaste(this,t,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(t){return serializeForClipboard(this,t)}destroy(){this.docView&&(destroyInput(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],viewDecorations(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,clearReusedRange())}get isDestroyed(){return this.docView==null}dispatchEvent(t){return dispatchEvent(this,t)}domSelectionRange(){let t=this.domSelection();return t?safari&&this.root.nodeType===11&&deepActiveElement(this.dom.ownerDocument)==this.dom&&safariShadowSelectionRange(this,t)||t:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}EditorView.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function computeDocDeco(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(e.state)),n)for(let o in n)o=="class"?t.class+=" "+n[o]:o=="style"?t.style=(t.style?t.style+";":"")+n[o]:!t[o]&&o!="contenteditable"&&o!="nodeName"&&(t[o]=String(n[o]))}),t.translate||(t.translate="no"),[Decoration.node(0,e.state.doc.content.size,t)]}function updateCursorWrapper(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:Decoration.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function getEditable(e){return!e.someProp("editable",t=>t(e.state)===!1)}function selectionContextChanged(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function buildNodeViews(e){let t=Object.create(null);function n(o){for(let l in o)Object.prototype.hasOwnProperty.call(t,l)||(t[l]=o[l])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function changedNodeViews(e,t){let n=0,o=0;for(let l in e){if(e[l]!=t[l])return!0;n++}for(let l in t)o++;return n!=o}function checkStateComponent(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}for(var base={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},shift={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},mac$1=typeof navigator<"u"&&/Mac/.test(navigator.platform),ie=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),i=0;i<10;i++)base[48+i]=base[96+i]=String(i);for(var i=1;i<=24;i++)base[i+111]="F"+i;for(var i=65;i<=90;i++)base[i]=String.fromCharCode(i+32),shift[i]=String.fromCharCode(i);for(var code in base)shift.hasOwnProperty(code)||(shift[code]=base[code]);function keyName(e){var t=mac$1&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||ie&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",n=!t&&e.key||(e.shiftKey?shift:base)[e.keyCode]||e.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const mac=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),windows=typeof navigator<"u"&&/Win/.test(navigator.platform);function normalizeKeyName$1(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n=="Space"&&(n=" ");let o,l,d,f;for(let g=0;g<t.length-1;g++){let b=t[g];if(/^(cmd|meta|m)$/i.test(b))f=!0;else if(/^a(lt)?$/i.test(b))o=!0;else if(/^(c|ctrl|control)$/i.test(b))l=!0;else if(/^s(hift)?$/i.test(b))d=!0;else if(/^mod$/i.test(b))mac?f=!0:l=!0;else throw new Error("Unrecognized modifier name: "+b)}return o&&(n="Alt-"+n),l&&(n="Ctrl-"+n),f&&(n="Meta-"+n),d&&(n="Shift-"+n),n}function normalize(e){let t=Object.create(null);for(let n in e)t[normalizeKeyName$1(n)]=e[n];return t}function modifiers(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function keymap(e){return new Plugin({props:{handleKeyDown:keydownHandler(e)}})}function keydownHandler(e){let t=normalize(e);return function(n,o){let l=keyName(o),d,f=t[modifiers(l,o)];if(f&&f(n.state,n.dispatch,n))return!0;if(l.length==1&&l!=" "){if(o.shiftKey){let g=t[modifiers(l,o,!1)];if(g&&g(n.state,n.dispatch,n))return!0}if((o.altKey||o.metaKey||o.ctrlKey)&&!(windows&&o.ctrlKey&&o.altKey)&&(d=base[o.keyCode])&&d!=l){let g=t[modifiers(d,o)];if(g&&g(n.state,n.dispatch,n))return!0}}return!1}}const deleteSelection$1=(e,t)=>e.selection.empty?!1:(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function atBlockStart(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}const joinBackward$1=(e,t,n)=>{let o=atBlockStart(e,n);if(!o)return!1;let l=findCutBefore(o);if(!l){let f=o.blockRange(),g=f&&liftTarget(f);return g==null?!1:(t&&t(e.tr.lift(f,g).scrollIntoView()),!0)}let d=l.nodeBefore;if(deleteBarrier(e,l,t,-1))return!0;if(o.parent.content.size==0&&(textblockAt(d,"end")||NodeSelection.isSelectable(d)))for(let f=o.depth;;f--){let g=replaceStep(e.doc,o.before(f),o.after(f),Slice.empty);if(g&&g.slice.size<g.to-g.from){if(t){let b=e.tr.step(g);b.setSelection(textblockAt(d,"end")?Selection.findFrom(b.doc.resolve(b.mapping.map(l.pos,-1)),-1):NodeSelection.create(b.doc,l.pos-d.nodeSize)),t(b.scrollIntoView())}return!0}if(f==1||o.node(f-1).childCount>1)break}return d.isAtom&&l.depth==o.depth-1?(t&&t(e.tr.delete(l.pos-d.nodeSize,l.pos).scrollIntoView()),!0):!1},joinTextblockBackward$1=(e,t,n)=>{let o=atBlockStart(e,n);if(!o)return!1;let l=findCutBefore(o);return l?joinTextblocksAround(e,l,t):!1},joinTextblockForward$1=(e,t,n)=>{let o=atBlockEnd(e,n);if(!o)return!1;let l=findCutAfter(o);return l?joinTextblocksAround(e,l,t):!1};function joinTextblocksAround(e,t,n){let o=t.nodeBefore,l=o,d=t.pos-1;for(;!l.isTextblock;d--){if(l.type.spec.isolating)return!1;let S=l.lastChild;if(!S)return!1;l=S}let f=t.nodeAfter,g=f,b=t.pos+1;for(;!g.isTextblock;b++){if(g.type.spec.isolating)return!1;let S=g.firstChild;if(!S)return!1;g=S}let _=replaceStep(e.doc,d,b,Slice.empty);if(!_||_.from!=d||_ instanceof ReplaceStep&&_.slice.size>=b-d)return!1;if(n){let S=e.tr.step(_);S.setSelection(TextSelection.create(S.doc,d)),n(S.scrollIntoView())}return!0}function textblockAt(e,t,n=!1){for(let o=e;o;o=t=="start"?o.firstChild:o.lastChild){if(o.isTextblock)return!0;if(n&&o.childCount!=1)return!1}return!1}const selectNodeBackward$1=(e,t,n)=>{let{$head:o,empty:l}=e.selection,d=o;if(!l)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):o.parentOffset>0)return!1;d=findCutBefore(o)}let f=d&&d.nodeBefore;return!f||!NodeSelection.isSelectable(f)?!1:(t&&t(e.tr.setSelection(NodeSelection.create(e.doc,d.pos-f.nodeSize)).scrollIntoView()),!0)};function findCutBefore(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function atBlockEnd(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}const joinForward$1=(e,t,n)=>{let o=atBlockEnd(e,n);if(!o)return!1;let l=findCutAfter(o);if(!l)return!1;let d=l.nodeAfter;if(deleteBarrier(e,l,t,1))return!0;if(o.parent.content.size==0&&(textblockAt(d,"start")||NodeSelection.isSelectable(d))){let f=replaceStep(e.doc,o.before(),o.after(),Slice.empty);if(f&&f.slice.size<f.to-f.from){if(t){let g=e.tr.step(f);g.setSelection(textblockAt(d,"start")?Selection.findFrom(g.doc.resolve(g.mapping.map(l.pos)),1):NodeSelection.create(g.doc,g.mapping.map(l.pos))),t(g.scrollIntoView())}return!0}}return d.isAtom&&l.depth==o.depth-1?(t&&t(e.tr.delete(l.pos,l.pos+d.nodeSize).scrollIntoView()),!0):!1},selectNodeForward$1=(e,t,n)=>{let{$head:o,empty:l}=e.selection,d=o;if(!l)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):o.parentOffset<o.parent.content.size)return!1;d=findCutAfter(o)}let f=d&&d.nodeAfter;return!f||!NodeSelection.isSelectable(f)?!1:(t&&t(e.tr.setSelection(NodeSelection.create(e.doc,d.pos)).scrollIntoView()),!0)};function findCutAfter(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}const joinUp$1=(e,t)=>{let n=e.selection,o=n instanceof NodeSelection,l;if(o){if(n.node.isTextblock||!canJoin(e.doc,n.from))return!1;l=n.from}else if(l=joinPoint(e.doc,n.from,-1),l==null)return!1;if(t){let d=e.tr.join(l);o&&d.setSelection(NodeSelection.create(d.doc,l-e.doc.resolve(l).nodeBefore.nodeSize)),t(d.scrollIntoView())}return!0},joinDown$1=(e,t)=>{let n=e.selection,o;if(n instanceof NodeSelection){if(n.node.isTextblock||!canJoin(e.doc,n.to))return!1;o=n.to}else if(o=joinPoint(e.doc,n.to,1),o==null)return!1;return t&&t(e.tr.join(o).scrollIntoView()),!0},lift$1=(e,t)=>{let{$from:n,$to:o}=e.selection,l=n.blockRange(o),d=l&&liftTarget(l);return d==null?!1:(t&&t(e.tr.lift(l,d).scrollIntoView()),!0)},newlineInCode$1=(e,t)=>{let{$head:n,$anchor:o}=e.selection;return!n.parent.type.spec.code||!n.sameParent(o)?!1:(t&&t(e.tr.insertText(`
|
|
1286
1286
|
`).scrollIntoView()),!0)};function defaultBlockAt$1(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const exitCode$1=(e,t)=>{let{$head:n,$anchor:o}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(o))return!1;let l=n.node(-1),d=n.indexAfter(-1),f=defaultBlockAt$1(l.contentMatchAt(d));if(!f||!l.canReplaceWith(d,d,f))return!1;if(t){let g=n.after(),b=e.tr.replaceWith(g,g,f.createAndFill());b.setSelection(Selection.near(b.doc.resolve(g),1)),t(b.scrollIntoView())}return!0},createParagraphNear$1=(e,t)=>{let n=e.selection,{$from:o,$to:l}=n;if(n instanceof AllSelection||o.parent.inlineContent||l.parent.inlineContent)return!1;let d=defaultBlockAt$1(l.parent.contentMatchAt(l.indexAfter()));if(!d||!d.isTextblock)return!1;if(t){let f=(!o.parentOffset&&l.index()<l.parent.childCount?o:l).pos,g=e.tr.insert(f,d.createAndFill());g.setSelection(TextSelection.create(g.doc,f+1)),t(g.scrollIntoView())}return!0},liftEmptyBlock$1=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let d=n.before();if(canSplit(e.doc,d))return t&&t(e.tr.split(d).scrollIntoView()),!0}let o=n.blockRange(),l=o&&liftTarget(o);return l==null?!1:(t&&t(e.tr.lift(o,l).scrollIntoView()),!0)};function splitBlockAs(e){return(t,n)=>{let{$from:o,$to:l}=t.selection;if(t.selection instanceof NodeSelection&&t.selection.node.isBlock)return!o.parentOffset||!canSplit(t.doc,o.pos)?!1:(n&&n(t.tr.split(o.pos).scrollIntoView()),!0);if(!o.depth)return!1;let d=[],f,g,b=!1,_=!1;for(let E=o.depth;;E--)if(o.node(E).isBlock){b=o.end(E)==o.pos+(o.depth-E),_=o.start(E)==o.pos-(o.depth-E),g=defaultBlockAt$1(o.node(E-1).contentMatchAt(o.indexAfter(E-1))),d.unshift(b&&g?{type:g}:null),f=E;break}else{if(E==1)return!1;d.unshift(null)}let S=t.tr;(t.selection instanceof TextSelection||t.selection instanceof AllSelection)&&S.deleteSelection();let R=S.mapping.map(o.pos),C=canSplit(S.doc,R,d.length,d);if(C||(d[0]=g?{type:g}:null,C=canSplit(S.doc,R,d.length,d)),!C)return!1;if(S.split(R,d.length,d),!b&&_&&o.node(f).type!=g){let E=S.mapping.map(o.before(f)),A=S.doc.resolve(E);g&&o.node(f-1).canReplaceWith(A.index(),A.index()+1,g)&&S.setNodeMarkup(S.mapping.map(o.before(f)),g)}return n&&n(S.scrollIntoView()),!0}}const splitBlock$1=splitBlockAs(),selectParentNode$1=(e,t)=>{let{$from:n,to:o}=e.selection,l,d=n.sharedDepth(o);return d==0?!1:(l=n.before(d),t&&t(e.tr.setSelection(NodeSelection.create(e.doc,l))),!0)};function joinMaybeClear(e,t,n){let o=t.nodeBefore,l=t.nodeAfter,d=t.index();return!o||!l||!o.type.compatibleContent(l.type)?!1:!o.content.size&&t.parent.canReplace(d-1,d)?(n&&n(e.tr.delete(t.pos-o.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(d,d+1)||!(l.isTextblock||canJoin(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function deleteBarrier(e,t,n,o){let l=t.nodeBefore,d=t.nodeAfter,f,g,b=l.type.spec.isolating||d.type.spec.isolating;if(!b&&joinMaybeClear(e,t,n))return!0;let _=!b&&t.parent.canReplace(t.index(),t.index()+1);if(_&&(f=(g=l.contentMatchAt(l.childCount)).findWrapping(d.type))&&g.matchType(f[0]||d.type).validEnd){if(n){let E=t.pos+d.nodeSize,A=Fragment.empty;for(let j=f.length-1;j>=0;j--)A=Fragment.from(f[j].create(null,A));A=Fragment.from(l.copy(A));let M=e.tr.step(new ReplaceAroundStep(t.pos-1,E,t.pos,E,new Slice(A,1,0),f.length,!0)),I=M.doc.resolve(E+2*f.length);I.nodeAfter&&I.nodeAfter.type==l.type&&canJoin(M.doc,I.pos)&&M.join(I.pos),n(M.scrollIntoView())}return!0}let S=d.type.spec.isolating||o>0&&b?null:Selection.findFrom(t,1),R=S&&S.$from.blockRange(S.$to),C=R&&liftTarget(R);if(C!=null&&C>=t.depth)return n&&n(e.tr.lift(R,C).scrollIntoView()),!0;if(_&&textblockAt(d,"start",!0)&&textblockAt(l,"end")){let E=l,A=[];for(;A.push(E),!E.isTextblock;)E=E.lastChild;let M=d,I=1;for(;!M.isTextblock;M=M.firstChild)I++;if(E.canReplace(E.childCount,E.childCount,M.content)){if(n){let j=Fragment.empty;for(let Q=A.length-1;Q>=0;Q--)j=Fragment.from(A[Q].copy(j));let q=e.tr.step(new ReplaceAroundStep(t.pos-A.length,t.pos+d.nodeSize,t.pos+I,t.pos+d.nodeSize-I,new Slice(j,A.length,0),0,!0));n(q.scrollIntoView())}return!0}}return!1}function selectTextblockSide(e){return function(t,n){let o=t.selection,l=e<0?o.$from:o.$to,d=l.depth;for(;l.node(d).isInline;){if(!d)return!1;d--}return l.node(d).isTextblock?(n&&n(t.tr.setSelection(TextSelection.create(t.doc,e<0?l.start(d):l.end(d)))),!0):!1}}const selectTextblockStart$1=selectTextblockSide(-1),selectTextblockEnd$1=selectTextblockSide(1);function wrapIn$1(e,t=null){return function(n,o){let{$from:l,$to:d}=n.selection,f=l.blockRange(d),g=f&&findWrapping(f,e,t);return g?(o&&o(n.tr.wrap(f,g).scrollIntoView()),!0):!1}}function setBlockType(e,t=null){return function(n,o){let l=!1;for(let d=0;d<n.selection.ranges.length&&!l;d++){let{$from:{pos:f},$to:{pos:g}}=n.selection.ranges[d];n.doc.nodesBetween(f,g,(b,_)=>{if(l)return!1;if(!(!b.isTextblock||b.hasMarkup(e,t)))if(b.type==e)l=!0;else{let S=n.doc.resolve(_),R=S.index();l=S.parent.canReplaceWith(R,R+1,e)}})}if(!l)return!1;if(o){let d=n.tr;for(let f=0;f<n.selection.ranges.length;f++){let{$from:{pos:g},$to:{pos:b}}=n.selection.ranges[f];d.setBlockType(g,b,e,t)}o(d.scrollIntoView())}return!0}}function chainCommands(...e){return function(t,n,o){for(let l=0;l<e.length;l++)if(e[l](t,n,o))return!0;return!1}}chainCommands(deleteSelection$1,joinBackward$1,selectNodeBackward$1),chainCommands(deleteSelection$1,joinForward$1,selectNodeForward$1),chainCommands(newlineInCode$1,createParagraphNear$1,liftEmptyBlock$1,splitBlock$1),typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function wrapInList$1(e,t=null){return function(n,o){let{$from:l,$to:d}=n.selection,f=l.blockRange(d);if(!f)return!1;let g=o?n.tr:null;return wrapRangeInList(g,f,e,t)?(o&&o(g.scrollIntoView()),!0):!1}}function wrapRangeInList(e,t,n,o=null){let l=!1,d=t,f=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&t.startIndex==0){if(t.$from.index(t.depth-1)==0)return!1;let b=f.resolve(t.start-2);d=new NodeRange(b,b,t.depth),t.endIndex<t.parent.childCount&&(t=new NodeRange(t.$from,f.resolve(t.$to.end(t.depth)),t.depth)),l=!0}let g=findWrapping(d,n,o,t);return g?(e&&doWrapInList(e,t,g,l,n),!0):!1}function doWrapInList(e,t,n,o,l){let d=Fragment.empty;for(let S=n.length-1;S>=0;S--)d=Fragment.from(n[S].type.create(n[S].attrs,d));e.step(new ReplaceAroundStep(t.start-(o?2:0),t.end,t.start,t.end,new Slice(d,0,0),n.length,!0));let f=0;for(let S=0;S<n.length;S++)n[S].type==l&&(f=S+1);let g=n.length-f,b=t.start+n.length-(o?2:0),_=t.parent;for(let S=t.startIndex,R=t.endIndex,C=!0;S<R;S++,C=!1)!C&&canSplit(e.doc,b,g)&&(e.split(b,g),b+=2*g),b+=_.child(S).nodeSize;return e}function liftListItem$1(e){return function(t,n){let{$from:o,$to:l}=t.selection,d=o.blockRange(l,f=>f.childCount>0&&f.firstChild.type==e);return d?n?o.node(d.depth-1).type==e?liftToOuterList(t,n,e,d):liftOutOfList(t,n,d):!0:!1}}function liftToOuterList(e,t,n,o){let l=e.tr,d=o.end,f=o.$to.end(o.depth);d<f&&(l.step(new ReplaceAroundStep(d-1,f,d,f,new Slice(Fragment.from(n.create(null,o.parent.copy())),1,0),1,!0)),o=new NodeRange(l.doc.resolve(o.$from.pos),l.doc.resolve(f),o.depth));const g=liftTarget(o);if(g==null)return!1;l.lift(o,g);let b=l.doc.resolve(l.mapping.map(d,-1)-1);return canJoin(l.doc,b.pos)&&b.nodeBefore.type==b.nodeAfter.type&&l.join(b.pos),t(l.scrollIntoView()),!0}function liftOutOfList(e,t,n){let o=e.tr,l=n.parent;for(let E=n.end,A=n.endIndex-1,M=n.startIndex;A>M;A--)E-=l.child(A).nodeSize,o.delete(E-1,E+1);let d=o.doc.resolve(n.start),f=d.nodeAfter;if(o.mapping.map(n.end)!=n.start+d.nodeAfter.nodeSize)return!1;let g=n.startIndex==0,b=n.endIndex==l.childCount,_=d.node(-1),S=d.index(-1);if(!_.canReplace(S+(g?0:1),S+1,f.content.append(b?Fragment.empty:Fragment.from(l))))return!1;let R=d.pos,C=R+f.nodeSize;return o.step(new ReplaceAroundStep(R-(g?1:0),C+(b?1:0),R+1,C-1,new Slice((g?Fragment.empty:Fragment.from(l.copy(Fragment.empty))).append(b?Fragment.empty:Fragment.from(l.copy(Fragment.empty))),g?0:1,b?0:1),g?0:1)),t(o.scrollIntoView()),!0}function sinkListItem$1(e){return function(t,n){let{$from:o,$to:l}=t.selection,d=o.blockRange(l,_=>_.childCount>0&&_.firstChild.type==e);if(!d)return!1;let f=d.startIndex;if(f==0)return!1;let g=d.parent,b=g.child(f-1);if(b.type!=e)return!1;if(n){let _=b.lastChild&&b.lastChild.type==g.type,S=Fragment.from(_?e.create():null),R=new Slice(Fragment.from(e.create(null,Fragment.from(g.type.create(null,S)))),_?3:1,0),C=d.start,E=d.end;n(t.tr.step(new ReplaceAroundStep(C-(_?3:1),E,C,E,R,1,!0)).scrollIntoView())}return!0}}function createChainableState(e){const{state:t,transaction:n}=e;let{selection:o}=n,{doc:l}=n,{storedMarks:d}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return d},get selection(){return o},get doc(){return l},get tr(){return o=n.selection,l=n.doc,d=n.storedMarks,n}}}class CommandManager{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:n,state:o}=this,{view:l}=n,{tr:d}=o,f=this.buildProps(d);return Object.fromEntries(Object.entries(t).map(([g,b])=>[g,(...S)=>{const R=b(...S)(f);return!d.getMeta("preventDispatch")&&!this.hasCustomState&&l.dispatch(d),R}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,n=!0){const{rawCommands:o,editor:l,state:d}=this,{view:f}=l,g=[],b=!!t,_=t||d.tr,S=()=>(!b&&n&&!_.getMeta("preventDispatch")&&!this.hasCustomState&&f.dispatch(_),g.every(C=>C===!0)),R={...Object.fromEntries(Object.entries(o).map(([C,E])=>[C,(...M)=>{const I=this.buildProps(_,n),j=E(...M)(I);return g.push(j),R}])),run:S};return R}createCan(t){const{rawCommands:n,state:o}=this,l=!1,d=t||o.tr,f=this.buildProps(d,l);return{...Object.fromEntries(Object.entries(n).map(([b,_])=>[b,(...S)=>_(...S)({...f,dispatch:void 0})])),chain:()=>this.createChain(d,l)}}buildProps(t,n=!0){const{rawCommands:o,editor:l,state:d}=this,{view:f}=l,g={tr:t,editor:l,view:f,state:createChainableState({state:d,transaction:t}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(t,n),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(o).map(([b,_])=>[b,(...S)=>_(...S)(g)]))}};return g}}class EventEmitter{constructor(){this.callbacks={}}on(t,n){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(n),this}emit(t,...n){const o=this.callbacks[t];return o&&o.forEach(l=>l.apply(this,n)),this}off(t,n){const o=this.callbacks[t];return o&&(n?this.callbacks[t]=o.filter(l=>l!==n):delete this.callbacks[t]),this}once(t,n){const o=(...l)=>{this.off(t,o),n.apply(this,l)};return this.on(t,o)}removeAllListeners(){this.callbacks={}}}function getExtensionField(e,t,n){return e.config[t]===void 0&&e.parent?getExtensionField(e.parent,t,n):typeof e.config[t]=="function"?e.config[t].bind({...n,parent:e.parent?getExtensionField(e.parent,t,n):null}):e.config[t]}function splitExtensions(e){const t=e.filter(l=>l.type==="extension"),n=e.filter(l=>l.type==="node"),o=e.filter(l=>l.type==="mark");return{baseExtensions:t,nodeExtensions:n,markExtensions:o}}function getAttributesFromExtensions(e){const t=[],{nodeExtensions:n,markExtensions:o}=splitExtensions(e),l=[...n,...o],d={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return e.forEach(f=>{const g={name:f.name,options:f.options,storage:f.storage,extensions:l},b=getExtensionField(f,"addGlobalAttributes",g);if(!b)return;b().forEach(S=>{S.types.forEach(R=>{Object.entries(S.attributes).forEach(([C,E])=>{t.push({type:R,name:C,attribute:{...d,...E}})})})})}),l.forEach(f=>{const g={name:f.name,options:f.options,storage:f.storage},b=getExtensionField(f,"addAttributes",g);if(!b)return;const _=b();Object.entries(_).forEach(([S,R])=>{const C={...d,...R};typeof(C==null?void 0:C.default)=="function"&&(C.default=C.default()),C!=null&&C.isRequired&&(C==null?void 0:C.default)===void 0&&delete C.default,t.push({type:f.name,name:S,attribute:C})})}),t}function getNodeType(e,t){if(typeof e=="string"){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}function mergeAttributes(...e){return e.filter(t=>!!t).reduce((t,n)=>{const o={...t};return Object.entries(n).forEach(([l,d])=>{if(!o[l]){o[l]=d;return}if(l==="class"){const g=d?String(d).split(" "):[],b=o[l]?o[l].split(" "):[],_=g.filter(S=>!b.includes(S));o[l]=[...b,..._].join(" ")}else if(l==="style"){const g=d?d.split(";").map(S=>S.trim()).filter(Boolean):[],b=o[l]?o[l].split(";").map(S=>S.trim()).filter(Boolean):[],_=new Map;b.forEach(S=>{const[R,C]=S.split(":").map(E=>E.trim());_.set(R,C)}),g.forEach(S=>{const[R,C]=S.split(":").map(E=>E.trim());_.set(R,C)}),o[l]=Array.from(_.entries()).map(([S,R])=>`${S}: ${R}`).join("; ")}else o[l]=d}),o},{})}function getRenderedAttributes(e,t){return t.filter(n=>n.type===e.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(e.attrs)||{}:{[n.name]:e.attrs[n.name]}).reduce((n,o)=>mergeAttributes(n,o),{})}function isFunction(e){return typeof e=="function"}function callOrReturn(e,t=void 0,...n){return isFunction(e)?t?e.bind(t)(...n):e(...n):e}function isEmptyObject(e={}){return Object.keys(e).length===0&&e.constructor===Object}function fromString(e){return typeof e!="string"?e:e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):e==="true"?!0:e==="false"?!1:e}function injectExtensionAttributesToParseRule(e,t){return"style"in e?e:{...e,getAttrs:n=>{const o=e.getAttrs?e.getAttrs(n):e.attrs;if(o===!1)return!1;const l=t.reduce((d,f)=>{const g=f.attribute.parseHTML?f.attribute.parseHTML(n):fromString(n.getAttribute(f.name));return g==null?d:{...d,[f.name]:g}},{});return{...o,...l}}}}function cleanUpSchemaItem(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>t==="attrs"&&isEmptyObject(n)?!1:n!=null))}function getSchemaByResolvedExtensions(e,t){var n;const o=getAttributesFromExtensions(e),{nodeExtensions:l,markExtensions:d}=splitExtensions(e),f=(n=l.find(_=>getExtensionField(_,"topNode")))===null||n===void 0?void 0:n.name,g=Object.fromEntries(l.map(_=>{const S=o.filter(j=>j.type===_.name),R={name:_.name,options:_.options,storage:_.storage,editor:t},C=e.reduce((j,q)=>{const Q=getExtensionField(q,"extendNodeSchema",R);return{...j,...Q?Q(_):{}}},{}),E=cleanUpSchemaItem({...C,content:callOrReturn(getExtensionField(_,"content",R)),marks:callOrReturn(getExtensionField(_,"marks",R)),group:callOrReturn(getExtensionField(_,"group",R)),inline:callOrReturn(getExtensionField(_,"inline",R)),atom:callOrReturn(getExtensionField(_,"atom",R)),selectable:callOrReturn(getExtensionField(_,"selectable",R)),draggable:callOrReturn(getExtensionField(_,"draggable",R)),code:callOrReturn(getExtensionField(_,"code",R)),whitespace:callOrReturn(getExtensionField(_,"whitespace",R)),linebreakReplacement:callOrReturn(getExtensionField(_,"linebreakReplacement",R)),defining:callOrReturn(getExtensionField(_,"defining",R)),isolating:callOrReturn(getExtensionField(_,"isolating",R)),attrs:Object.fromEntries(S.map(j=>{var q;return[j.name,{default:(q=j==null?void 0:j.attribute)===null||q===void 0?void 0:q.default}]}))}),A=callOrReturn(getExtensionField(_,"parseHTML",R));A&&(E.parseDOM=A.map(j=>injectExtensionAttributesToParseRule(j,S)));const M=getExtensionField(_,"renderHTML",R);M&&(E.toDOM=j=>M({node:j,HTMLAttributes:getRenderedAttributes(j,S)}));const I=getExtensionField(_,"renderText",R);return I&&(E.toText=I),[_.name,E]})),b=Object.fromEntries(d.map(_=>{const S=o.filter(I=>I.type===_.name),R={name:_.name,options:_.options,storage:_.storage,editor:t},C=e.reduce((I,j)=>{const q=getExtensionField(j,"extendMarkSchema",R);return{...I,...q?q(_):{}}},{}),E=cleanUpSchemaItem({...C,inclusive:callOrReturn(getExtensionField(_,"inclusive",R)),excludes:callOrReturn(getExtensionField(_,"excludes",R)),group:callOrReturn(getExtensionField(_,"group",R)),spanning:callOrReturn(getExtensionField(_,"spanning",R)),code:callOrReturn(getExtensionField(_,"code",R)),attrs:Object.fromEntries(S.map(I=>{var j;return[I.name,{default:(j=I==null?void 0:I.attribute)===null||j===void 0?void 0:j.default}]}))}),A=callOrReturn(getExtensionField(_,"parseHTML",R));A&&(E.parseDOM=A.map(I=>injectExtensionAttributesToParseRule(I,S)));const M=getExtensionField(_,"renderHTML",R);return M&&(E.toDOM=I=>M({mark:I,HTMLAttributes:getRenderedAttributes(I,S)})),[_.name,E]}));return new Schema({topNode:f,nodes:g,marks:b})}function getSchemaTypeByName(e,t){return t.nodes[e]||t.marks[e]||null}function isExtensionRulesEnabled(e,t){return Array.isArray(t)?t.some(n=>(typeof n=="string"?n:n.name)===e.name):t}function getHTMLFromFragment(e,t){const n=DOMSerializer.fromSchema(t).serializeFragment(e),l=document.implementation.createHTMLDocument().createElement("div");return l.appendChild(n),l.innerHTML}const getTextContentFromNodes=(e,t=500)=>{let n="";const o=e.parentOffset;return e.parent.nodesBetween(Math.max(0,o-t),o,(l,d,f,g)=>{var b,_;const S=((_=(b=l.type.spec).toText)===null||_===void 0?void 0:_.call(b,{node:l,pos:d,parent:f,index:g}))||l.textContent||"%leaf%";n+=l.isAtom&&!l.isText?S:S.slice(0,Math.max(0,o-d))}),n};function isRegExp(e){return Object.prototype.toString.call(e)==="[object RegExp]"}class InputRule{constructor(t){this.find=t.find,this.handler=t.handler}}const inputRuleMatcherHandler=(e,t)=>{if(isRegExp(t))return t.exec(e);const n=t(e);if(!n)return null;const o=[n.text];return o.index=n.index,o.input=e,o.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),o.push(n.replaceWith)),o};function run$1(e){var t;const{editor:n,from:o,to:l,text:d,rules:f,plugin:g}=e,{view:b}=n;if(b.composing)return!1;const _=b.state.doc.resolve(o);if(_.parent.type.spec.code||!((t=_.nodeBefore||_.nodeAfter)===null||t===void 0)&&t.marks.find(C=>C.type.spec.code))return!1;let S=!1;const R=getTextContentFromNodes(_)+d;return f.forEach(C=>{if(S)return;const E=inputRuleMatcherHandler(R,C.find);if(!E)return;const A=b.state.tr,M=createChainableState({state:b.state,transaction:A}),I={from:o-(E[0].length-d.length),to:l},{commands:j,chain:q,can:Q}=new CommandManager({editor:n,state:M});C.handler({state:M,range:I,match:E,commands:j,chain:q,can:Q})===null||!A.steps.length||(A.setMeta(g,{transform:A,from:o,to:l,text:d}),b.dispatch(A),S=!0)}),S}function inputRulesPlugin(e){const{editor:t,rules:n}=e,o=new Plugin({state:{init(){return null},apply(l,d,f){const g=l.getMeta(o);if(g)return g;const b=l.getMeta("applyInputRules");return!!b&&setTimeout(()=>{let{text:S}=b;typeof S=="string"?S=S:S=getHTMLFromFragment(Fragment.from(S),f.schema);const{from:R}=b,C=R+S.length;run$1({editor:t,from:R,to:C,text:S,rules:n,plugin:o})}),l.selectionSet||l.docChanged?null:d}},props:{handleTextInput(l,d,f,g){return run$1({editor:t,from:d,to:f,text:g,rules:n,plugin:o})},handleDOMEvents:{compositionend:l=>(setTimeout(()=>{const{$cursor:d}=l.state.selection;d&&run$1({editor:t,from:d.pos,to:d.pos,text:"",rules:n,plugin:o})}),!1)},handleKeyDown(l,d){if(d.key!=="Enter")return!1;const{$cursor:f}=l.state.selection;return f?run$1({editor:t,from:f.pos,to:f.pos,text:`
|
|
1287
1287
|
`,rules:n,plugin:o}):!1}},isInputRules:!0});return o}function getType(e){return Object.prototype.toString.call(e).slice(8,-1)}function isPlainObject(e){return getType(e)!=="Object"?!1:e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function mergeDeep(e,t){const n={...e};return isPlainObject(e)&&isPlainObject(t)&&Object.keys(t).forEach(o=>{isPlainObject(t[o])&&isPlainObject(e[o])?n[o]=mergeDeep(e[o],t[o]):n[o]=t[o]}),n}class Mark{constructor(t={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=callOrReturn(getExtensionField(this,"addOptions",{name:this.name}))),this.storage=callOrReturn(getExtensionField(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new Mark(t)}configure(t={}){const n=this.extend({...this.config,addOptions:()=>mergeDeep(this.options,t)});return n.name=this.name,n.parent=this.parent,n}extend(t={}){const n=new Mark(t);return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=callOrReturn(getExtensionField(n,"addOptions",{name:n.name})),n.storage=callOrReturn(getExtensionField(n,"addStorage",{name:n.name,options:n.options})),n}static handleExit({editor:t,mark:n}){const{tr:o}=t.state,l=t.state.selection.$from;if(l.pos===l.end()){const f=l.marks();if(!!!f.find(_=>(_==null?void 0:_.type.name)===n.name))return!1;const b=f.find(_=>(_==null?void 0:_.type.name)===n.name);return b&&o.removeStoredMark(b),o.insertText(" ",l.pos),t.view.dispatch(o),!0}return!1}}function isNumber(e){return typeof e=="number"}class PasteRule{constructor(t){this.find=t.find,this.handler=t.handler}}const pasteRuleMatcherHandler=(e,t,n)=>{if(isRegExp(t))return[...e.matchAll(t)];const o=t(e,n);return o?o.map(l=>{const d=[l.text];return d.index=l.index,d.input=e,d.data=l.data,l.replaceWith&&(l.text.includes(l.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),d.push(l.replaceWith)),d}):[]};function run(e){const{editor:t,state:n,from:o,to:l,rule:d,pasteEvent:f,dropEvent:g}=e,{commands:b,chain:_,can:S}=new CommandManager({editor:t,state:n}),R=[];return n.doc.nodesBetween(o,l,(E,A)=>{if(!E.isTextblock||E.type.spec.code)return;const M=Math.max(o,A),I=Math.min(l,A+E.content.size),j=E.textBetween(M-A,I-A,void 0,"");pasteRuleMatcherHandler(j,d.find,f).forEach(Q=>{if(Q.index===void 0)return;const te=M+Q.index+1,F=te+Q[0].length,V={from:n.tr.mapping.map(te),to:n.tr.mapping.map(F)},ne=d.handler({state:n,range:V,match:Q,commands:b,chain:_,can:S,pasteEvent:f,dropEvent:g});R.push(ne)})}),R.every(E=>E!==null)}let tiptapDragFromOtherEditor=null;const createClipboardPasteEvent=e=>{var t;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(t=n.clipboardData)===null||t===void 0||t.setData("text/html",e),n};function pasteRulesPlugin(e){const{editor:t,rules:n}=e;let o=null,l=!1,d=!1,f=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,g;try{g=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{g=null}const b=({state:S,from:R,to:C,rule:E,pasteEvt:A})=>{const M=S.tr,I=createChainableState({state:S,transaction:M});if(!(!run({editor:t,state:I,from:Math.max(R-1,0),to:C.b-1,rule:E,pasteEvent:A,dropEvent:g})||!M.steps.length)){try{g=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{g=null}return f=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,M}};return n.map(S=>new Plugin({view(R){const C=A=>{var M;o=!((M=R.dom.parentElement)===null||M===void 0)&&M.contains(A.target)?R.dom.parentElement:null,o&&(tiptapDragFromOtherEditor=t)},E=()=>{tiptapDragFromOtherEditor&&(tiptapDragFromOtherEditor=null)};return window.addEventListener("dragstart",C),window.addEventListener("dragend",E),{destroy(){window.removeEventListener("dragstart",C),window.removeEventListener("dragend",E)}}},props:{handleDOMEvents:{drop:(R,C)=>{if(d=o===R.dom.parentElement,g=C,!d){const E=tiptapDragFromOtherEditor;E!=null&&E.isEditable&&setTimeout(()=>{const A=E.state.selection;A&&E.commands.deleteRange({from:A.from,to:A.to})},10)}return!1},paste:(R,C)=>{var E;const A=(E=C.clipboardData)===null||E===void 0?void 0:E.getData("text/html");return f=C,l=!!(A!=null&&A.includes("data-pm-slice")),!1}}},appendTransaction:(R,C,E)=>{const A=R[0],M=A.getMeta("uiEvent")==="paste"&&!l,I=A.getMeta("uiEvent")==="drop"&&!d,j=A.getMeta("applyPasteRules"),q=!!j;if(!M&&!I&&!q)return;if(q){let{text:F}=j;typeof F=="string"?F=F:F=getHTMLFromFragment(Fragment.from(F),E.schema);const{from:V}=j,ne=V+F.length,ae=createClipboardPasteEvent(F);return b({rule:S,state:E,from:V,to:{b:ne},pasteEvt:ae})}const Q=C.doc.content.findDiffStart(E.doc.content),te=C.doc.content.findDiffEnd(E.doc.content);if(!(!isNumber(Q)||!te||Q===te.b))return b({rule:S,state:E,from:Q,to:te,pasteEvt:f})}}))}function findDuplicates(e){const t=e.filter((n,o)=>e.indexOf(n)!==o);return Array.from(new Set(t))}class ExtensionManager{constructor(t,n){this.splittableMarks=[],this.editor=n,this.extensions=ExtensionManager.resolve(t),this.schema=getSchemaByResolvedExtensions(this.extensions,n),this.setupExtensions()}static resolve(t){const n=ExtensionManager.sort(ExtensionManager.flatten(t)),o=findDuplicates(n.map(l=>l.name));return o.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${o.map(l=>`'${l}'`).join(", ")}]. This can lead to issues.`),n}static flatten(t){return t.map(n=>{const o={name:n.name,options:n.options,storage:n.storage},l=getExtensionField(n,"addExtensions",o);return l?[n,...this.flatten(l())]:n}).flat(10)}static sort(t){return t.sort((o,l)=>{const d=getExtensionField(o,"priority")||100,f=getExtensionField(l,"priority")||100;return d>f?-1:d<f?1:0})}get commands(){return this.extensions.reduce((t,n)=>{const o={name:n.name,options:n.options,storage:n.storage,editor:this.editor,type:getSchemaTypeByName(n.name,this.schema)},l=getExtensionField(n,"addCommands",o);return l?{...t,...l()}:t},{})}get plugins(){const{editor:t}=this,n=ExtensionManager.sort([...this.extensions].reverse()),o=[],l=[],d=n.map(f=>{const g={name:f.name,options:f.options,storage:f.storage,editor:t,type:getSchemaTypeByName(f.name,this.schema)},b=[],_=getExtensionField(f,"addKeyboardShortcuts",g);let S={};if(f.type==="mark"&&getExtensionField(f,"exitable",g)&&(S.ArrowRight=()=>Mark.handleExit({editor:t,mark:f})),_){const M=Object.fromEntries(Object.entries(_()).map(([I,j])=>[I,()=>j({editor:t})]));S={...S,...M}}const R=keymap(S);b.push(R);const C=getExtensionField(f,"addInputRules",g);isExtensionRulesEnabled(f,t.options.enableInputRules)&&C&&o.push(...C());const E=getExtensionField(f,"addPasteRules",g);isExtensionRulesEnabled(f,t.options.enablePasteRules)&&E&&l.push(...E());const A=getExtensionField(f,"addProseMirrorPlugins",g);if(A){const M=A();b.push(...M)}return b}).flat();return[inputRulesPlugin({editor:t,rules:o}),...pasteRulesPlugin({editor:t,rules:l}),...d]}get attributes(){return getAttributesFromExtensions(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:n}=splitExtensions(this.extensions);return Object.fromEntries(n.filter(o=>!!getExtensionField(o,"addNodeView")).map(o=>{const l=this.attributes.filter(b=>b.type===o.name),d={name:o.name,options:o.options,storage:o.storage,editor:t,type:getNodeType(o.name,this.schema)},f=getExtensionField(o,"addNodeView",d);if(!f)return[];const g=(b,_,S,R,C)=>{const E=getRenderedAttributes(b,l);return f()({node:b,view:_,getPos:S,decorations:R,innerDecorations:C,editor:t,extension:o,HTMLAttributes:E})};return[o.name,g]}))}setupExtensions(){this.extensions.forEach(t=>{var n;this.editor.extensionStorage[t.name]=t.storage;const o={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:getSchemaTypeByName(t.name,this.schema)};t.type==="mark"&&(!((n=callOrReturn(getExtensionField(t,"keepOnSplit",o)))!==null&&n!==void 0)||n)&&this.splittableMarks.push(t.name);const l=getExtensionField(t,"onBeforeCreate",o),d=getExtensionField(t,"onCreate",o),f=getExtensionField(t,"onUpdate",o),g=getExtensionField(t,"onSelectionUpdate",o),b=getExtensionField(t,"onTransaction",o),_=getExtensionField(t,"onFocus",o),S=getExtensionField(t,"onBlur",o),R=getExtensionField(t,"onDestroy",o);l&&this.editor.on("beforeCreate",l),d&&this.editor.on("create",d),f&&this.editor.on("update",f),g&&this.editor.on("selectionUpdate",g),b&&this.editor.on("transaction",b),_&&this.editor.on("focus",_),S&&this.editor.on("blur",S),R&&this.editor.on("destroy",R)})}}class Extension{constructor(t={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=callOrReturn(getExtensionField(this,"addOptions",{name:this.name}))),this.storage=callOrReturn(getExtensionField(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new Extension(t)}configure(t={}){const n=this.extend({...this.config,addOptions:()=>mergeDeep(this.options,t)});return n.name=this.name,n.parent=this.parent,n}extend(t={}){const n=new Extension({...this.config,...t});return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=callOrReturn(getExtensionField(n,"addOptions",{name:n.name})),n.storage=callOrReturn(getExtensionField(n,"addStorage",{name:n.name,options:n.options})),n}}function getTextBetween(e,t,n){const{from:o,to:l}=t,{blockSeparator:d=`
|
|
1288
1288
|
|