randmarcomps 1.486.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.
@@ -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 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$1g);/**
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:"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$1f);/**
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:"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$1e);/**
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:"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$1d);/**
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:"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$1c);/**
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=[["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$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=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Check=createLucideIcon("Check",__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:"m6 9 6 6 6-6",key:"qrunsl"}]],ChevronDown=createLucideIcon("ChevronDown",__iconNode$19);/**
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:"m15 18-6-6 6-6",key:"1wnfg3"}]],ChevronLeft=createLucideIcon("ChevronLeft",__iconNode$18);/**
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:"m9 18 6-6-6-6",key:"mthhwq"}]],ChevronRight=createLucideIcon("ChevronRight",__iconNode$17);/**
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:"m18 15-6-6-6 6",key:"153udz"}]],ChevronUp=createLucideIcon("ChevronUp",__iconNode$16);/**
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:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],ChevronsLeft=createLucideIcon("ChevronsLeft",__iconNode$15);/**
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:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],ChevronsRight=createLucideIcon("ChevronsRight",__iconNode$14);/**
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:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],ChevronsUpDown=createLucideIcon("ChevronsUpDown",__iconNode$13);/**
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=[["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$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"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],CircleCheck=createLucideIcon("CircleCheck",__iconNode$11);/**
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=[["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$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$$=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Circle=createLucideIcon("Circle",__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$_=[["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$_);/**
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:"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$Z);/**
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=[["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$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=[["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$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:"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$W);/**
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=[["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$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=[["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$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:"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$T);/**
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:"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$S);/**
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:"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$R);/**
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"}]],File$1=createLucideIcon("File",__iconNode$Q);/**
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=[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]],Filter=createLucideIcon("Filter",__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=[["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$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=[["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$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:"M12 2v8",key:"1q4o3n"}],["path",{d:"m16 6-4 4-4-4",key:"6wukr"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 18h.01",key:"h775k"}]],HardDriveDownload=createLucideIcon("HardDriveDownload",__iconNode$M);/**
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.
@@ -512,7 +512,7 @@
512
512
  `)},getCurrentUseCounter=function(){var e=parseInt(document.body.getAttribute(lockAttribute)||"0",10);return isFinite(e)?e:0},useLockAttribute=function(){React__namespace.useEffect(function(){return document.body.setAttribute(lockAttribute,(getCurrentUseCounter()+1).toString()),function(){var e=getCurrentUseCounter()-1;e<=0?document.body.removeAttribute(lockAttribute):document.body.setAttribute(lockAttribute,e.toString())}},[])},RemoveScrollBar=function(e){var t=e.noRelative,n=e.noImportant,o=e.gapMode,l=o===void 0?"margin":o;useLockAttribute();var d=React__namespace.useMemo(function(){return getGapWidth(l)},[l]);return React__namespace.createElement(Style,{styles:getStyles(d,!t,l,n?"":"!important")})},passiveSupported$1=!1;if(typeof window<"u")try{var options=Object.defineProperty({},"passive",{get:function(){return passiveSupported$1=!0,!0}});window.addEventListener("test",options,options),window.removeEventListener("test",options,options)}catch{passiveSupported$1=!1}var nonPassive=passiveSupported$1?{passive:!1}:!1,alwaysContainsScroll=function(e){return e.tagName==="TEXTAREA"},elementCanBeScrolled=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!alwaysContainsScroll(e)&&n[t]==="visible")},elementCouldBeVScrolled=function(e){return elementCanBeScrolled(e,"overflowY")},elementCouldBeHScrolled=function(e){return elementCanBeScrolled(e,"overflowX")},locationCouldBeScrolled=function(e,t){var n=t.ownerDocument,o=t;do{typeof ShadowRoot<"u"&&o instanceof ShadowRoot&&(o=o.host);var l=elementCouldBeScrolled(e,o);if(l){var d=getScrollVariables(e,o),f=d[1],g=d[2];if(f>g)return!0}o=o.parentNode}while(o&&o!==n.body);return!1},getVScrollVariables=function(e){var t=e.scrollTop,n=e.scrollHeight,o=e.clientHeight;return[t,n,o]},getHScrollVariables=function(e){var t=e.scrollLeft,n=e.scrollWidth,o=e.clientWidth;return[t,n,o]},elementCouldBeScrolled=function(e,t){return e==="v"?elementCouldBeVScrolled(t):elementCouldBeHScrolled(t)},getScrollVariables=function(e,t){return e==="v"?getVScrollVariables(t):getHScrollVariables(t)},getDirectionFactor=function(e,t){return e==="h"&&t==="rtl"?-1:1},handleScroll=function(e,t,n,o,l){var d=getDirectionFactor(e,window.getComputedStyle(t).direction),f=d*o,g=n.target,b=t.contains(g),_=!1,S=f>0,R=0,C=0;do{if(!g)break;var E=getScrollVariables(e,g),A=E[0],M=E[1],I=E[2],j=M-I-d*A;(A||j)&&elementCouldBeScrolled(e,g)&&(R+=j,C+=A);var q=g.parentNode;g=q&&q.nodeType===Node.DOCUMENT_FRAGMENT_NODE?q.host:q}while(!b&&g!==document.body||b&&(t.contains(g)||t===g));return(S&&Math.abs(R)<1||!S&&Math.abs(C)<1)&&(_=!0),_},getTouchXY=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},getDeltaXY=function(e){return[e.deltaX,e.deltaY]},extractRef=function(e){return e&&"current"in e?e.current:e},deltaCompare=function(e,t){return e[0]===t[0]&&e[1]===t[1]},generateStyle=function(e){return`
513
513
  .block-interactivity-`.concat(e,` {pointer-events: none;}
514
514
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
515
- `)},idCounter$1=0,lockStack=[];function RemoveScrollSideCar(e){var t=React__namespace.useRef([]),n=React__namespace.useRef([0,0]),o=React__namespace.useRef(),l=React__namespace.useState(idCounter$1++)[0],d=React__namespace.useState(styleSingleton)[0],f=React__namespace.useRef(e);React__namespace.useEffect(function(){f.current=e},[e]),React__namespace.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(l));var M=__spreadArray([e.lockRef.current],(e.shards||[]).map(extractRef),!0).filter(Boolean);return M.forEach(function(I){return I.classList.add("allow-interactivity-".concat(l))}),function(){document.body.classList.remove("block-interactivity-".concat(l)),M.forEach(function(I){return I.classList.remove("allow-interactivity-".concat(l))})}}},[e.inert,e.lockRef.current,e.shards]);var g=React__namespace.useCallback(function(M,I){if("touches"in M&&M.touches.length===2||M.type==="wheel"&&M.ctrlKey)return!f.current.allowPinchZoom;var j=getTouchXY(M),q=n.current,Q="deltaX"in M?M.deltaX:q[0]-j[0],te="deltaY"in M?M.deltaY:q[1]-j[1],F,V=M.target,ne=Math.abs(Q)>Math.abs(te)?"h":"v";if("touches"in M&&ne==="h"&&V.type==="range")return!1;var ae=locationCouldBeScrolled(ne,V);if(!ae)return!0;if(ae?F=ne:(F=ne==="v"?"h":"v",ae=locationCouldBeScrolled(ne,V)),!ae)return!1;if(!o.current&&"changedTouches"in M&&(Q||te)&&(o.current=F),!F)return!0;var se=o.current||F;return handleScroll(se,I,M,se==="h"?Q:te)},[]),b=React__namespace.useCallback(function(M){var I=M;if(!(!lockStack.length||lockStack[lockStack.length-1]!==d)){var j="deltaY"in I?getDeltaXY(I):getTouchXY(I),q=t.current.filter(function(F){return F.name===I.type&&(F.target===I.target||I.target===F.shadowParent)&&deltaCompare(F.delta,j)})[0];if(q&&q.should){I.cancelable&&I.preventDefault();return}if(!q){var Q=(f.current.shards||[]).map(extractRef).filter(Boolean).filter(function(F){return F.contains(I.target)}),te=Q.length>0?g(I,Q[0]):!f.current.noIsolation;te&&I.cancelable&&I.preventDefault()}}},[]),_=React__namespace.useCallback(function(M,I,j,q){var Q={name:M,delta:I,target:j,should:q,shadowParent:getOutermostShadowParent(j)};t.current.push(Q),setTimeout(function(){t.current=t.current.filter(function(te){return te!==Q})},1)},[]),S=React__namespace.useCallback(function(M){n.current=getTouchXY(M),o.current=void 0},[]),R=React__namespace.useCallback(function(M){_(M.type,getDeltaXY(M),M.target,g(M,e.lockRef.current))},[]),C=React__namespace.useCallback(function(M){_(M.type,getTouchXY(M),M.target,g(M,e.lockRef.current))},[]);React__namespace.useEffect(function(){return lockStack.push(d),e.setCallbacks({onScrollCapture:R,onWheelCapture:R,onTouchMoveCapture:C}),document.addEventListener("wheel",b,nonPassive),document.addEventListener("touchmove",b,nonPassive),document.addEventListener("touchstart",S,nonPassive),function(){lockStack=lockStack.filter(function(M){return M!==d}),document.removeEventListener("wheel",b,nonPassive),document.removeEventListener("touchmove",b,nonPassive),document.removeEventListener("touchstart",S,nonPassive)}},[]);var E=e.removeScrollBar,A=e.inert;return React__namespace.createElement(React__namespace.Fragment,null,A?React__namespace.createElement(d,{styles:generateStyle(l)}):null,E?React__namespace.createElement(RemoveScrollBar,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function getOutermostShadowParent(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const SideCar=exportSidecar(effectCar,RemoveScrollSideCar);var ReactRemoveScroll=React__namespace.forwardRef(function(e,t){return React__namespace.createElement(RemoveScroll,__assign$1({},e,{ref:t,sideCar:SideCar}))});ReactRemoveScroll.classNames=RemoveScroll.classNames;var getDefaultParent=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},counterMap=new WeakMap,uncontrolledNodes=new WeakMap,markerMap={},lockCount=0,unwrapHost=function(e){return e&&(e.host||unwrapHost(e.parentNode))},correctTargets=function(e,t){return t.map(function(n){if(e.contains(n))return n;var o=unwrapHost(n);return o&&e.contains(o)?o:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},applyAttributeToOthers=function(e,t,n,o){var l=correctTargets(t,Array.isArray(e)?e:[e]);markerMap[n]||(markerMap[n]=new WeakMap);var d=markerMap[n],f=[],g=new Set,b=new Set(l),_=function(R){!R||g.has(R)||(g.add(R),_(R.parentNode))};l.forEach(_);var S=function(R){!R||b.has(R)||Array.prototype.forEach.call(R.children,function(C){if(g.has(C))S(C);else try{var E=C.getAttribute(o),A=E!==null&&E!=="false",M=(counterMap.get(C)||0)+1,I=(d.get(C)||0)+1;counterMap.set(C,M),d.set(C,I),f.push(C),M===1&&A&&uncontrolledNodes.set(C,!0),I===1&&C.setAttribute(n,"true"),A||C.setAttribute(o,"true")}catch(j){console.error("aria-hidden: cannot operate on ",C,j)}})};return S(t),g.clear(),lockCount++,function(){f.forEach(function(R){var C=counterMap.get(R)-1,E=d.get(R)-1;counterMap.set(R,C),d.set(R,E),C||(uncontrolledNodes.has(R)||R.removeAttribute(o),uncontrolledNodes.delete(R)),E||R.removeAttribute(n)}),lockCount--,lockCount||(counterMap=new WeakMap,counterMap=new WeakMap,uncontrolledNodes=new WeakMap,markerMap={})}},hideOthers=function(e,t,n){n===void 0&&(n="data-aria-hidden");var o=Array.from(Array.isArray(e)?e:[e]),l=getDefaultParent(e);return l?(o.push.apply(o,Array.from(l.querySelectorAll("[aria-live], script"))),applyAttributeToOthers(o,l,n,"aria-hidden")):function(){return null}};function createSlot$4(e){const t=createSlotClone$4(e),n=React__namespace.forwardRef((o,l)=>{const{children:d,...f}=o,g=React__namespace.Children.toArray(d),b=g.find(isSlottable$4);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$4(e){const t=React__namespace.forwardRef((n,o)=>{const{children:l,...d}=n;if(React__namespace.isValidElement(l)){const f=getElementRef$4(l),g=mergeProps$4(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$6=Symbol("radix.slottable");function isSlottable$4(e){return React__namespace.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===SLOTTABLE_IDENTIFIER$6}function mergeProps$4(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$4(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 DIALOG_NAME="Dialog",[createDialogContext,createDialogScope]=createContextScope$2(DIALOG_NAME),[DialogProvider,useDialogContext]=createDialogContext(DIALOG_NAME),Dialog$1=e=>{const{__scopeDialog:t,children:n,open:o,defaultOpen:l,onOpenChange:d,modal:f=!0}=e,g=React__namespace.useRef(null),b=React__namespace.useRef(null),[_,S]=useControllableState({prop:o,defaultProp:l??!1,onChange:d,caller:DIALOG_NAME});return jsxRuntime.jsx(DialogProvider,{scope:t,triggerRef:g,contentRef:b,contentId:useId(),titleId:useId(),descriptionId:useId(),open:_,onOpenChange:S,onOpenToggle:React__namespace.useCallback(()=>S(R=>!R),[S]),modal:f,children:n})};Dialog$1.displayName=DIALOG_NAME;var TRIGGER_NAME$9="DialogTrigger",DialogTrigger$1=React__namespace.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,l=useDialogContext(TRIGGER_NAME$9,n),d=useComposedRefs(t,l.triggerRef);return jsxRuntime.jsx(Primitive$4.button,{type:"button","aria-haspopup":"dialog","aria-expanded":l.open,"aria-controls":l.contentId,"data-state":getState$5(l.open),...o,ref:d,onClick:composeEventHandlers(e.onClick,l.onOpenToggle)})});DialogTrigger$1.displayName=TRIGGER_NAME$9;var PORTAL_NAME$6="DialogPortal",[PortalProvider$3,usePortalContext$3]=createDialogContext(PORTAL_NAME$6,{forceMount:void 0}),DialogPortal$1=e=>{const{__scopeDialog:t,forceMount:n,children:o,container:l}=e,d=useDialogContext(PORTAL_NAME$6,t);return jsxRuntime.jsx(PortalProvider$3,{scope:t,forceMount:n,children:React__namespace.Children.map(o,f=>jsxRuntime.jsx(Presence,{present:n||d.open,children:jsxRuntime.jsx(Portal$5,{asChild:!0,container:l,children:f})}))})};DialogPortal$1.displayName=PORTAL_NAME$6;var OVERLAY_NAME$1="DialogOverlay",DialogOverlay$1=React__namespace.forwardRef((e,t)=>{const n=usePortalContext$3(OVERLAY_NAME$1,e.__scopeDialog),{forceMount:o=n.forceMount,...l}=e,d=useDialogContext(OVERLAY_NAME$1,e.__scopeDialog);return d.modal?jsxRuntime.jsx(Presence,{present:o||d.open,children:jsxRuntime.jsx(DialogOverlayImpl,{...l,ref:t})}):null});DialogOverlay$1.displayName=OVERLAY_NAME$1;var Slot$4=createSlot$4("DialogOverlay.RemoveScroll"),DialogOverlayImpl=React__namespace.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,l=useDialogContext(OVERLAY_NAME$1,n);return jsxRuntime.jsx(ReactRemoveScroll,{as:Slot$4,allowPinchZoom:!0,shards:[l.contentRef],children:jsxRuntime.jsx(Primitive$4.div,{"data-state":getState$5(l.open),...o,ref:t,style:{pointerEvents:"auto",...o.style}})})}),CONTENT_NAME$a="DialogContent",DialogContent$1=React__namespace.forwardRef((e,t)=>{const n=usePortalContext$3(CONTENT_NAME$a,e.__scopeDialog),{forceMount:o=n.forceMount,...l}=e,d=useDialogContext(CONTENT_NAME$a,e.__scopeDialog);return jsxRuntime.jsx(Presence,{present:o||d.open,children:d.modal?jsxRuntime.jsx(DialogContentModal,{...l,ref:t}):jsxRuntime.jsx(DialogContentNonModal,{...l,ref:t})})});DialogContent$1.displayName=CONTENT_NAME$a;var DialogContentModal=React__namespace.forwardRef((e,t)=>{const n=useDialogContext(CONTENT_NAME$a,e.__scopeDialog),o=React__namespace.useRef(null),l=useComposedRefs(t,n.contentRef,o);return React__namespace.useEffect(()=>{const d=o.current;if(d)return hideOthers(d)},[]),jsxRuntime.jsx(DialogContentImpl,{...e,ref:l,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:composeEventHandlers(e.onCloseAutoFocus,d=>{var f;d.preventDefault(),(f=n.triggerRef.current)==null||f.focus()}),onPointerDownOutside:composeEventHandlers(e.onPointerDownOutside,d=>{const f=d.detail.originalEvent,g=f.button===0&&f.ctrlKey===!0;(f.button===2||g)&&d.preventDefault()}),onFocusOutside:composeEventHandlers(e.onFocusOutside,d=>d.preventDefault())})}),DialogContentNonModal=React__namespace.forwardRef((e,t)=>{const n=useDialogContext(CONTENT_NAME$a,e.__scopeDialog),o=React__namespace.useRef(!1),l=React__namespace.useRef(!1);return jsxRuntime.jsx(DialogContentImpl,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:d=>{var f,g;(f=e.onCloseAutoFocus)==null||f.call(e,d),d.defaultPrevented||(o.current||(g=n.triggerRef.current)==null||g.focus(),d.preventDefault()),o.current=!1,l.current=!1},onInteractOutside:d=>{var b,_;(b=e.onInteractOutside)==null||b.call(e,d),d.defaultPrevented||(o.current=!0,d.detail.originalEvent.type==="pointerdown"&&(l.current=!0));const f=d.target;((_=n.triggerRef.current)==null?void 0:_.contains(f))&&d.preventDefault(),d.detail.originalEvent.type==="focusin"&&l.current&&d.preventDefault()}})}),DialogContentImpl=React__namespace.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:o,onOpenAutoFocus:l,onCloseAutoFocus:d,...f}=e,g=useDialogContext(CONTENT_NAME$a,n),b=React__namespace.useRef(null),_=useComposedRefs(t,b);return useFocusGuards(),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(FocusScope,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:l,onUnmountAutoFocus:d,children:jsxRuntime.jsx(DismissableLayer,{role:"dialog",id:g.contentId,"aria-describedby":g.descriptionId,"aria-labelledby":g.titleId,"data-state":getState$5(g.open),...f,ref:_,onDismiss:()=>g.onOpenChange(!1)})}),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(TitleWarning,{titleId:g.titleId}),jsxRuntime.jsx(DescriptionWarning$1,{contentRef:b,descriptionId:g.descriptionId})]})]})}),TITLE_NAME$2="DialogTitle",DialogTitle$1=React__namespace.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,l=useDialogContext(TITLE_NAME$2,n);return jsxRuntime.jsx(Primitive$4.h2,{id:l.titleId,...o,ref:t})});DialogTitle$1.displayName=TITLE_NAME$2;var DESCRIPTION_NAME$2="DialogDescription",DialogDescription$1=React__namespace.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,l=useDialogContext(DESCRIPTION_NAME$2,n);return jsxRuntime.jsx(Primitive$4.p,{id:l.descriptionId,...o,ref:t})});DialogDescription$1.displayName=DESCRIPTION_NAME$2;var CLOSE_NAME$2="DialogClose",DialogClose$1=React__namespace.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,l=useDialogContext(CLOSE_NAME$2,n);return jsxRuntime.jsx(Primitive$4.button,{type:"button",...o,ref:t,onClick:composeEventHandlers(e.onClick,()=>l.onOpenChange(!1))})});DialogClose$1.displayName=CLOSE_NAME$2;function getState$5(e){return e?"open":"closed"}var TITLE_WARNING_NAME="DialogTitleWarning",[WarningProvider,useWarningContext]=createContext2(TITLE_WARNING_NAME,{contentName:CONTENT_NAME$a,titleName:TITLE_NAME$2,docsSlug:"dialog"}),TitleWarning=({titleId:e})=>{const t=useWarningContext(TITLE_WARNING_NAME),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
515
+ `)},idCounter$1=0,lockStack=[];function RemoveScrollSideCar(e){var t=React__namespace.useRef([]),n=React__namespace.useRef([0,0]),o=React__namespace.useRef(),l=React__namespace.useState(idCounter$1++)[0],d=React__namespace.useState(styleSingleton)[0],f=React__namespace.useRef(e);React__namespace.useEffect(function(){f.current=e},[e]),React__namespace.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(l));var M=__spreadArray([e.lockRef.current],(e.shards||[]).map(extractRef),!0).filter(Boolean);return M.forEach(function(I){return I.classList.add("allow-interactivity-".concat(l))}),function(){document.body.classList.remove("block-interactivity-".concat(l)),M.forEach(function(I){return I.classList.remove("allow-interactivity-".concat(l))})}}},[e.inert,e.lockRef.current,e.shards]);var g=React__namespace.useCallback(function(M,I){if("touches"in M&&M.touches.length===2||M.type==="wheel"&&M.ctrlKey)return!f.current.allowPinchZoom;var j=getTouchXY(M),q=n.current,Q="deltaX"in M?M.deltaX:q[0]-j[0],te="deltaY"in M?M.deltaY:q[1]-j[1],F,V=M.target,ne=Math.abs(Q)>Math.abs(te)?"h":"v";if("touches"in M&&ne==="h"&&V.type==="range")return!1;var ae=window.getSelection(),se=ae&&ae.anchorNode,Oe=se?se===V||se.contains(V):!1;if(Oe)return!1;var Ne=locationCouldBeScrolled(ne,V);if(!Ne)return!0;if(Ne?F=ne:(F=ne==="v"?"h":"v",Ne=locationCouldBeScrolled(ne,V)),!Ne)return!1;if(!o.current&&"changedTouches"in M&&(Q||te)&&(o.current=F),!F)return!0;var oe=o.current||F;return handleScroll(oe,I,M,oe==="h"?Q:te)},[]),b=React__namespace.useCallback(function(M){var I=M;if(!(!lockStack.length||lockStack[lockStack.length-1]!==d)){var j="deltaY"in I?getDeltaXY(I):getTouchXY(I),q=t.current.filter(function(F){return F.name===I.type&&(F.target===I.target||I.target===F.shadowParent)&&deltaCompare(F.delta,j)})[0];if(q&&q.should){I.cancelable&&I.preventDefault();return}if(!q){var Q=(f.current.shards||[]).map(extractRef).filter(Boolean).filter(function(F){return F.contains(I.target)}),te=Q.length>0?g(I,Q[0]):!f.current.noIsolation;te&&I.cancelable&&I.preventDefault()}}},[]),_=React__namespace.useCallback(function(M,I,j,q){var Q={name:M,delta:I,target:j,should:q,shadowParent:getOutermostShadowParent(j)};t.current.push(Q),setTimeout(function(){t.current=t.current.filter(function(te){return te!==Q})},1)},[]),S=React__namespace.useCallback(function(M){n.current=getTouchXY(M),o.current=void 0},[]),R=React__namespace.useCallback(function(M){_(M.type,getDeltaXY(M),M.target,g(M,e.lockRef.current))},[]),C=React__namespace.useCallback(function(M){_(M.type,getTouchXY(M),M.target,g(M,e.lockRef.current))},[]);React__namespace.useEffect(function(){return lockStack.push(d),e.setCallbacks({onScrollCapture:R,onWheelCapture:R,onTouchMoveCapture:C}),document.addEventListener("wheel",b,nonPassive),document.addEventListener("touchmove",b,nonPassive),document.addEventListener("touchstart",S,nonPassive),function(){lockStack=lockStack.filter(function(M){return M!==d}),document.removeEventListener("wheel",b,nonPassive),document.removeEventListener("touchmove",b,nonPassive),document.removeEventListener("touchstart",S,nonPassive)}},[]);var E=e.removeScrollBar,A=e.inert;return React__namespace.createElement(React__namespace.Fragment,null,A?React__namespace.createElement(d,{styles:generateStyle(l)}):null,E?React__namespace.createElement(RemoveScrollBar,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function getOutermostShadowParent(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const SideCar=exportSidecar(effectCar,RemoveScrollSideCar);var ReactRemoveScroll=React__namespace.forwardRef(function(e,t){return React__namespace.createElement(RemoveScroll,__assign$1({},e,{ref:t,sideCar:SideCar}))});ReactRemoveScroll.classNames=RemoveScroll.classNames;var getDefaultParent=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},counterMap=new WeakMap,uncontrolledNodes=new WeakMap,markerMap={},lockCount=0,unwrapHost=function(e){return e&&(e.host||unwrapHost(e.parentNode))},correctTargets=function(e,t){return t.map(function(n){if(e.contains(n))return n;var o=unwrapHost(n);return o&&e.contains(o)?o:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},applyAttributeToOthers=function(e,t,n,o){var l=correctTargets(t,Array.isArray(e)?e:[e]);markerMap[n]||(markerMap[n]=new WeakMap);var d=markerMap[n],f=[],g=new Set,b=new Set(l),_=function(R){!R||g.has(R)||(g.add(R),_(R.parentNode))};l.forEach(_);var S=function(R){!R||b.has(R)||Array.prototype.forEach.call(R.children,function(C){if(g.has(C))S(C);else try{var E=C.getAttribute(o),A=E!==null&&E!=="false",M=(counterMap.get(C)||0)+1,I=(d.get(C)||0)+1;counterMap.set(C,M),d.set(C,I),f.push(C),M===1&&A&&uncontrolledNodes.set(C,!0),I===1&&C.setAttribute(n,"true"),A||C.setAttribute(o,"true")}catch(j){console.error("aria-hidden: cannot operate on ",C,j)}})};return S(t),g.clear(),lockCount++,function(){f.forEach(function(R){var C=counterMap.get(R)-1,E=d.get(R)-1;counterMap.set(R,C),d.set(R,E),C||(uncontrolledNodes.has(R)||R.removeAttribute(o),uncontrolledNodes.delete(R)),E||R.removeAttribute(n)}),lockCount--,lockCount||(counterMap=new WeakMap,counterMap=new WeakMap,uncontrolledNodes=new WeakMap,markerMap={})}},hideOthers=function(e,t,n){n===void 0&&(n="data-aria-hidden");var o=Array.from(Array.isArray(e)?e:[e]),l=getDefaultParent(e);return l?(o.push.apply(o,Array.from(l.querySelectorAll("[aria-live], script"))),applyAttributeToOthers(o,l,n,"aria-hidden")):function(){return null}};function createSlot$4(e){const t=createSlotClone$4(e),n=React__namespace.forwardRef((o,l)=>{const{children:d,...f}=o,g=React__namespace.Children.toArray(d),b=g.find(isSlottable$4);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$4(e){const t=React__namespace.forwardRef((n,o)=>{const{children:l,...d}=n;if(React__namespace.isValidElement(l)){const f=getElementRef$4(l),g=mergeProps$4(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$6=Symbol("radix.slottable");function isSlottable$4(e){return React__namespace.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===SLOTTABLE_IDENTIFIER$6}function mergeProps$4(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$4(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 DIALOG_NAME="Dialog",[createDialogContext,createDialogScope]=createContextScope$2(DIALOG_NAME),[DialogProvider,useDialogContext]=createDialogContext(DIALOG_NAME),Dialog$1=e=>{const{__scopeDialog:t,children:n,open:o,defaultOpen:l,onOpenChange:d,modal:f=!0}=e,g=React__namespace.useRef(null),b=React__namespace.useRef(null),[_,S]=useControllableState({prop:o,defaultProp:l??!1,onChange:d,caller:DIALOG_NAME});return jsxRuntime.jsx(DialogProvider,{scope:t,triggerRef:g,contentRef:b,contentId:useId(),titleId:useId(),descriptionId:useId(),open:_,onOpenChange:S,onOpenToggle:React__namespace.useCallback(()=>S(R=>!R),[S]),modal:f,children:n})};Dialog$1.displayName=DIALOG_NAME;var TRIGGER_NAME$9="DialogTrigger",DialogTrigger$1=React__namespace.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,l=useDialogContext(TRIGGER_NAME$9,n),d=useComposedRefs(t,l.triggerRef);return jsxRuntime.jsx(Primitive$4.button,{type:"button","aria-haspopup":"dialog","aria-expanded":l.open,"aria-controls":l.contentId,"data-state":getState$5(l.open),...o,ref:d,onClick:composeEventHandlers(e.onClick,l.onOpenToggle)})});DialogTrigger$1.displayName=TRIGGER_NAME$9;var PORTAL_NAME$6="DialogPortal",[PortalProvider$3,usePortalContext$3]=createDialogContext(PORTAL_NAME$6,{forceMount:void 0}),DialogPortal$1=e=>{const{__scopeDialog:t,forceMount:n,children:o,container:l}=e,d=useDialogContext(PORTAL_NAME$6,t);return jsxRuntime.jsx(PortalProvider$3,{scope:t,forceMount:n,children:React__namespace.Children.map(o,f=>jsxRuntime.jsx(Presence,{present:n||d.open,children:jsxRuntime.jsx(Portal$5,{asChild:!0,container:l,children:f})}))})};DialogPortal$1.displayName=PORTAL_NAME$6;var OVERLAY_NAME$1="DialogOverlay",DialogOverlay$1=React__namespace.forwardRef((e,t)=>{const n=usePortalContext$3(OVERLAY_NAME$1,e.__scopeDialog),{forceMount:o=n.forceMount,...l}=e,d=useDialogContext(OVERLAY_NAME$1,e.__scopeDialog);return d.modal?jsxRuntime.jsx(Presence,{present:o||d.open,children:jsxRuntime.jsx(DialogOverlayImpl,{...l,ref:t})}):null});DialogOverlay$1.displayName=OVERLAY_NAME$1;var Slot$4=createSlot$4("DialogOverlay.RemoveScroll"),DialogOverlayImpl=React__namespace.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,l=useDialogContext(OVERLAY_NAME$1,n);return jsxRuntime.jsx(ReactRemoveScroll,{as:Slot$4,allowPinchZoom:!0,shards:[l.contentRef],children:jsxRuntime.jsx(Primitive$4.div,{"data-state":getState$5(l.open),...o,ref:t,style:{pointerEvents:"auto",...o.style}})})}),CONTENT_NAME$a="DialogContent",DialogContent$1=React__namespace.forwardRef((e,t)=>{const n=usePortalContext$3(CONTENT_NAME$a,e.__scopeDialog),{forceMount:o=n.forceMount,...l}=e,d=useDialogContext(CONTENT_NAME$a,e.__scopeDialog);return jsxRuntime.jsx(Presence,{present:o||d.open,children:d.modal?jsxRuntime.jsx(DialogContentModal,{...l,ref:t}):jsxRuntime.jsx(DialogContentNonModal,{...l,ref:t})})});DialogContent$1.displayName=CONTENT_NAME$a;var DialogContentModal=React__namespace.forwardRef((e,t)=>{const n=useDialogContext(CONTENT_NAME$a,e.__scopeDialog),o=React__namespace.useRef(null),l=useComposedRefs(t,n.contentRef,o);return React__namespace.useEffect(()=>{const d=o.current;if(d)return hideOthers(d)},[]),jsxRuntime.jsx(DialogContentImpl,{...e,ref:l,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:composeEventHandlers(e.onCloseAutoFocus,d=>{var f;d.preventDefault(),(f=n.triggerRef.current)==null||f.focus()}),onPointerDownOutside:composeEventHandlers(e.onPointerDownOutside,d=>{const f=d.detail.originalEvent,g=f.button===0&&f.ctrlKey===!0;(f.button===2||g)&&d.preventDefault()}),onFocusOutside:composeEventHandlers(e.onFocusOutside,d=>d.preventDefault())})}),DialogContentNonModal=React__namespace.forwardRef((e,t)=>{const n=useDialogContext(CONTENT_NAME$a,e.__scopeDialog),o=React__namespace.useRef(!1),l=React__namespace.useRef(!1);return jsxRuntime.jsx(DialogContentImpl,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:d=>{var f,g;(f=e.onCloseAutoFocus)==null||f.call(e,d),d.defaultPrevented||(o.current||(g=n.triggerRef.current)==null||g.focus(),d.preventDefault()),o.current=!1,l.current=!1},onInteractOutside:d=>{var b,_;(b=e.onInteractOutside)==null||b.call(e,d),d.defaultPrevented||(o.current=!0,d.detail.originalEvent.type==="pointerdown"&&(l.current=!0));const f=d.target;((_=n.triggerRef.current)==null?void 0:_.contains(f))&&d.preventDefault(),d.detail.originalEvent.type==="focusin"&&l.current&&d.preventDefault()}})}),DialogContentImpl=React__namespace.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:o,onOpenAutoFocus:l,onCloseAutoFocus:d,...f}=e,g=useDialogContext(CONTENT_NAME$a,n),b=React__namespace.useRef(null),_=useComposedRefs(t,b);return useFocusGuards(),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(FocusScope,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:l,onUnmountAutoFocus:d,children:jsxRuntime.jsx(DismissableLayer,{role:"dialog",id:g.contentId,"aria-describedby":g.descriptionId,"aria-labelledby":g.titleId,"data-state":getState$5(g.open),...f,ref:_,onDismiss:()=>g.onOpenChange(!1)})}),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(TitleWarning,{titleId:g.titleId}),jsxRuntime.jsx(DescriptionWarning$1,{contentRef:b,descriptionId:g.descriptionId})]})]})}),TITLE_NAME$2="DialogTitle",DialogTitle$1=React__namespace.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,l=useDialogContext(TITLE_NAME$2,n);return jsxRuntime.jsx(Primitive$4.h2,{id:l.titleId,...o,ref:t})});DialogTitle$1.displayName=TITLE_NAME$2;var DESCRIPTION_NAME$2="DialogDescription",DialogDescription$1=React__namespace.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,l=useDialogContext(DESCRIPTION_NAME$2,n);return jsxRuntime.jsx(Primitive$4.p,{id:l.descriptionId,...o,ref:t})});DialogDescription$1.displayName=DESCRIPTION_NAME$2;var CLOSE_NAME$2="DialogClose",DialogClose$1=React__namespace.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,l=useDialogContext(CLOSE_NAME$2,n);return jsxRuntime.jsx(Primitive$4.button,{type:"button",...o,ref:t,onClick:composeEventHandlers(e.onClick,()=>l.onOpenChange(!1))})});DialogClose$1.displayName=CLOSE_NAME$2;function getState$5(e){return e?"open":"closed"}var TITLE_WARNING_NAME="DialogTitleWarning",[WarningProvider,useWarningContext]=createContext2(TITLE_WARNING_NAME,{contentName:CONTENT_NAME$a,titleName:TITLE_NAME$2,docsSlug:"dialog"}),TitleWarning=({titleId:e})=>{const t=useWarningContext(TITLE_WARNING_NAME),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
516
516
 
517
517
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
518
518
 
@@ -1155,7 +1155,7 @@ ${e}</tr>
1155
1155
  `}tablecell(e){const t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
1156
1156
  `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${escape2(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){const o=this.parser.parseInline(n),l=cleanUrl(e);if(l===null)return o;e=l;let d='<a href="'+e+'"';return t&&(d+=' title="'+escape2(t)+'"'),d+=">"+o+"</a>",d}image({href:e,title:t,text:n,tokens:o}){o&&(n=this.parser.parseInline(o,this.parser.textRenderer));const l=cleanUrl(e);if(l===null)return escape2(n);e=l;let d=`<img src="${e}" alt="${n}"`;return t&&(d+=` title="${escape2(t)}"`),d+=">",d}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:escape2(e.text)}},_TextRenderer=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}},_Parser=class vr{constructor(t){en(this,"options");en(this,"renderer");en(this,"textRenderer");this.options=t||_defaults,this.options.renderer=this.options.renderer||new _Renderer,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new _TextRenderer}static parse(t,n){return new vr(n).parse(t)}static parseInline(t,n){return new vr(n).parseInline(t)}parse(t,n=!0){var l,d;let o="";for(let f=0;f<t.length;f++){const g=t[f];if((d=(l=this.options.extensions)==null?void 0:l.renderers)!=null&&d[g.type]){const _=g,S=this.options.extensions.renderers[_.type].call({parser:this},_);if(S!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(_.type)){o+=S||"";continue}}const b=g;switch(b.type){case"space":{o+=this.renderer.space(b);continue}case"hr":{o+=this.renderer.hr(b);continue}case"heading":{o+=this.renderer.heading(b);continue}case"code":{o+=this.renderer.code(b);continue}case"table":{o+=this.renderer.table(b);continue}case"blockquote":{o+=this.renderer.blockquote(b);continue}case"list":{o+=this.renderer.list(b);continue}case"html":{o+=this.renderer.html(b);continue}case"paragraph":{o+=this.renderer.paragraph(b);continue}case"text":{let _=b,S=this.renderer.text(_);for(;f+1<t.length&&t[f+1].type==="text";)_=t[++f],S+=`
1157
1157
  `+this.renderer.text(_);n?o+=this.renderer.paragraph({type:"paragraph",raw:S,text:S,tokens:[{type:"text",raw:S,text:S,escaped:!0}]}):o+=S;continue}default:{const _='Token with "'+b.type+'" type was not found.';if(this.options.silent)return console.error(_),"";throw new Error(_)}}}return o}parseInline(t,n=this.renderer){var l,d;let o="";for(let f=0;f<t.length;f++){const g=t[f];if((d=(l=this.options.extensions)==null?void 0:l.renderers)!=null&&d[g.type]){const _=this.options.extensions.renderers[g.type].call({parser:this},g);if(_!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(g.type)){o+=_||"";continue}}const b=g;switch(b.type){case"escape":{o+=n.text(b);break}case"html":{o+=n.html(b);break}case"link":{o+=n.link(b);break}case"image":{o+=n.image(b);break}case"strong":{o+=n.strong(b);break}case"em":{o+=n.em(b);break}case"codespan":{o+=n.codespan(b);break}case"br":{o+=n.br(b);break}case"del":{o+=n.del(b);break}case"text":{o+=n.text(b);break}default:{const _='Token with "'+b.type+'" type was not found.';if(this.options.silent)return console.error(_),"";throw new Error(_)}}}return o}},_Hooks=(dn=class{constructor(e){en(this,"options");en(this,"block");this.options=e||_defaults}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}provideLexer(){return this.block?_Lexer.lex:_Lexer.lexInline}provideParser(){return this.block?_Parser.parse:_Parser.parseInline}},en(dn,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"])),dn),Marked=class{constructor(...e){en(this,"defaults",_getDefaults());en(this,"options",this.setOptions);en(this,"parse",this.parseMarkdown(!0));en(this,"parseInline",this.parseMarkdown(!1));en(this,"Parser",_Parser);en(this,"Renderer",_Renderer);en(this,"TextRenderer",_TextRenderer);en(this,"Lexer",_Lexer);en(this,"Tokenizer",_Tokenizer);en(this,"Hooks",_Hooks);this.use(...e)}walkTokens(e,t){var o,l;let n=[];for(const d of e)switch(n=n.concat(t.call(this,d)),d.type){case"table":{const f=d;for(const g of f.header)n=n.concat(this.walkTokens(g.tokens,t));for(const g of f.rows)for(const b of g)n=n.concat(this.walkTokens(b.tokens,t));break}case"list":{const f=d;n=n.concat(this.walkTokens(f.items,t));break}default:{const f=d;(l=(o=this.defaults.extensions)==null?void 0:o.childTokens)!=null&&l[f.type]?this.defaults.extensions.childTokens[f.type].forEach(g=>{const b=f[g].flat(1/0);n=n.concat(this.walkTokens(b,t))}):f.tokens&&(n=n.concat(this.walkTokens(f.tokens,t)))}}return n}use(...e){const t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{const o={...n};if(o.async=this.defaults.async||o.async||!1,n.extensions&&(n.extensions.forEach(l=>{if(!l.name)throw new Error("extension name required");if("renderer"in l){const d=t.renderers[l.name];d?t.renderers[l.name]=function(...f){let g=l.renderer.apply(this,f);return g===!1&&(g=d.apply(this,f)),g}:t.renderers[l.name]=l.renderer}if("tokenizer"in l){if(!l.level||l.level!=="block"&&l.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const d=t[l.level];d?d.unshift(l.tokenizer):t[l.level]=[l.tokenizer],l.start&&(l.level==="block"?t.startBlock?t.startBlock.push(l.start):t.startBlock=[l.start]:l.level==="inline"&&(t.startInline?t.startInline.push(l.start):t.startInline=[l.start]))}"childTokens"in l&&l.childTokens&&(t.childTokens[l.name]=l.childTokens)}),o.extensions=t),n.renderer){const l=this.defaults.renderer||new _Renderer(this.defaults);for(const d in n.renderer){if(!(d in l))throw new Error(`renderer '${d}' does not exist`);if(["options","parser"].includes(d))continue;const f=d,g=n.renderer[f],b=l[f];l[f]=(..._)=>{let S=g.apply(l,_);return S===!1&&(S=b.apply(l,_)),S||""}}o.renderer=l}if(n.tokenizer){const l=this.defaults.tokenizer||new _Tokenizer(this.defaults);for(const d in n.tokenizer){if(!(d in l))throw new Error(`tokenizer '${d}' does not exist`);if(["options","rules","lexer"].includes(d))continue;const f=d,g=n.tokenizer[f],b=l[f];l[f]=(..._)=>{let S=g.apply(l,_);return S===!1&&(S=b.apply(l,_)),S}}o.tokenizer=l}if(n.hooks){const l=this.defaults.hooks||new _Hooks;for(const d in n.hooks){if(!(d in l))throw new Error(`hook '${d}' does not exist`);if(["options","block"].includes(d))continue;const f=d,g=n.hooks[f],b=l[f];_Hooks.passThroughHooks.has(d)?l[f]=_=>{if(this.defaults.async)return Promise.resolve(g.call(l,_)).then(R=>b.call(l,R));const S=g.call(l,_);return b.call(l,S)}:l[f]=(..._)=>{let S=g.apply(l,_);return S===!1&&(S=b.apply(l,_)),S}}o.hooks=l}if(n.walkTokens){const l=this.defaults.walkTokens,d=n.walkTokens;o.walkTokens=function(f){let g=[];return g.push(d.call(this,f)),l&&(g=g.concat(l.call(this,f))),g}}this.defaults={...this.defaults,...o}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return _Lexer.lex(e,t??this.defaults)}parser(e,t){return _Parser.parse(e,t??this.defaults)}parseMarkdown(e){return(n,o)=>{const l={...o},d={...this.defaults,...l},f=this.onError(!!d.silent,!!d.async);if(this.defaults.async===!0&&l.async===!1)return f(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||n===null)return f(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return f(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));d.hooks&&(d.hooks.options=d,d.hooks.block=e);const g=d.hooks?d.hooks.provideLexer():e?_Lexer.lex:_Lexer.lexInline,b=d.hooks?d.hooks.provideParser():e?_Parser.parse:_Parser.parseInline;if(d.async)return Promise.resolve(d.hooks?d.hooks.preprocess(n):n).then(_=>g(_,d)).then(_=>d.hooks?d.hooks.processAllTokens(_):_).then(_=>d.walkTokens?Promise.all(this.walkTokens(_,d.walkTokens)).then(()=>_):_).then(_=>b(_,d)).then(_=>d.hooks?d.hooks.postprocess(_):_).catch(f);try{d.hooks&&(n=d.hooks.preprocess(n));let _=g(n,d);d.hooks&&(_=d.hooks.processAllTokens(_)),d.walkTokens&&this.walkTokens(_,d.walkTokens);let S=b(_,d);return d.hooks&&(S=d.hooks.postprocess(S)),S}catch(_){return f(_)}}}onError(e,t){return n=>{if(n.message+=`
1158
- Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+escape2(n.message+"",!0)+"</pre>";return t?Promise.resolve(o):o}if(t)return Promise.reject(n);throw n}}},markedInstance=new Marked;function marked(e,t){return markedInstance.parse(e,t)}marked.options=marked.setOptions=function(e){return markedInstance.setOptions(e),marked.defaults=markedInstance.defaults,changeDefaults(marked.defaults),marked},marked.getDefaults=_getDefaults,marked.defaults=_defaults,marked.use=function(...e){return markedInstance.use(...e),marked.defaults=markedInstance.defaults,changeDefaults(marked.defaults),marked},marked.walkTokens=function(e,t){return markedInstance.walkTokens(e,t)},marked.parseInline=markedInstance.parseInline,marked.Parser=_Parser,marked.parser=_Parser.parse,marked.Renderer=_Renderer,marked.TextRenderer=_TextRenderer,marked.Lexer=_Lexer,marked.lexer=_Lexer.lex,marked.Tokenizer=_Tokenizer,marked.Hooks=_Hooks,marked.parse=marked,marked.options,marked.setOptions,marked.use,marked.walkTokens,marked.parseInline,_Parser.parse,_Lexer.lex;/*! @license DOMPurify 3.3.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.0/LICENSE */const{entries,setPrototypeOf,isFrozen,getPrototypeOf,getOwnPropertyDescriptor}=Object;let{freeze,seal,create}=Object,{apply:apply$1,construct}=typeof Reflect<"u"&&Reflect;freeze||(freeze=function(t){return t}),seal||(seal=function(t){return t}),apply$1||(apply$1=function(t,n){for(var o=arguments.length,l=new Array(o>2?o-2:0),d=2;d<o;d++)l[d-2]=arguments[d];return t.apply(n,l)}),construct||(construct=function(t){for(var n=arguments.length,o=new Array(n>1?n-1:0),l=1;l<n;l++)o[l-1]=arguments[l];return new t(...o)});const arrayForEach=unapply(Array.prototype.forEach),arrayLastIndexOf=unapply(Array.prototype.lastIndexOf),arrayPop=unapply(Array.prototype.pop),arrayPush=unapply(Array.prototype.push),arraySplice=unapply(Array.prototype.splice),stringToLowerCase=unapply(String.prototype.toLowerCase),stringToString=unapply(String.prototype.toString),stringMatch=unapply(String.prototype.match),stringReplace=unapply(String.prototype.replace),stringIndexOf=unapply(String.prototype.indexOf),stringTrim=unapply(String.prototype.trim),objectHasOwnProperty=unapply(Object.prototype.hasOwnProperty),regExpTest=unapply(RegExp.prototype.test),typeErrorCreate=unconstruct(TypeError);function unapply(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,o=new Array(n>1?n-1:0),l=1;l<n;l++)o[l-1]=arguments[l];return apply$1(e,t,o)}}function unconstruct(e){return function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return construct(e,n)}}function addToSet(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:stringToLowerCase;setPrototypeOf&&setPrototypeOf(e,null);let o=t.length;for(;o--;){let l=t[o];if(typeof l=="string"){const d=n(l);d!==l&&(isFrozen(t)||(t[o]=d),l=d)}e[l]=!0}return e}function cleanArray(e){for(let t=0;t<e.length;t++)objectHasOwnProperty(e,t)||(e[t]=null);return e}function clone(e){const t=create(null);for(const[n,o]of entries(e))objectHasOwnProperty(e,n)&&(Array.isArray(o)?t[n]=cleanArray(o):o&&typeof o=="object"&&o.constructor===Object?t[n]=clone(o):t[n]=o);return t}function lookupGetter(e,t){for(;e!==null;){const o=getOwnPropertyDescriptor(e,t);if(o){if(o.get)return unapply(o.get);if(typeof o.value=="function")return unapply(o.value)}e=getPrototypeOf(e)}function n(){return null}return n}const html$1=freeze(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),svg$1=freeze(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),svgFilters=freeze(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),svgDisallowed=freeze(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),mathMl$1=freeze(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),mathMlDisallowed=freeze(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),text$1=freeze(["#text"]),html=freeze(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),svg=freeze(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),mathMl=freeze(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),xml=freeze(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),MUSTACHE_EXPR=seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm),ERB_EXPR=seal(/<%[\w\W]*|[\w\W]*%>/gm),TMPLIT_EXPR=seal(/\$\{[\w\W]*/gm),DATA_ATTR=seal(/^data-[\-\w.\u00B7-\uFFFF]+$/),ARIA_ATTR=seal(/^aria-[\-\w]+$/),IS_ALLOWED_URI=seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),IS_SCRIPT_OR_DATA=seal(/^(?:\w+script|data):/i),ATTR_WHITESPACE=seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),DOCTYPE_NAME=seal(/^html$/i),CUSTOM_ELEMENT=seal(/^[a-z][.\w]*(-[.\w]+)+$/i);var EXPRESSIONS=Object.freeze({__proto__:null,ARIA_ATTR,ATTR_WHITESPACE,CUSTOM_ELEMENT,DATA_ATTR,DOCTYPE_NAME,ERB_EXPR,IS_ALLOWED_URI,IS_SCRIPT_OR_DATA,MUSTACHE_EXPR,TMPLIT_EXPR});const NODE_TYPE={element:1,text:3,progressingInstruction:7,comment:8,document:9},getGlobal=function e(){return typeof window>"u"?null:window},_createTrustedTypesPolicy=function e(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let o=null;const l="data-tt-policy-suffix";n&&n.hasAttribute(l)&&(o=n.getAttribute(l));const d="dompurify"+(o?"#"+o:"");try{return t.createPolicy(d,{createHTML(f){return f},createScriptURL(f){return f}})}catch{return console.warn("TrustedTypes policy "+d+" could not be created."),null}},_createHooksMap=function e(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function createDOMPurify(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:getGlobal();const t=Xt=>createDOMPurify(Xt);if(t.version="3.3.0",t.removed=[],!e||!e.document||e.document.nodeType!==NODE_TYPE.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const o=n,l=o.currentScript,{DocumentFragment:d,HTMLTemplateElement:f,Node:g,Element:b,NodeFilter:_,NamedNodeMap:S=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:R,DOMParser:C,trustedTypes:E}=e,A=b.prototype,M=lookupGetter(A,"cloneNode"),I=lookupGetter(A,"remove"),j=lookupGetter(A,"nextSibling"),q=lookupGetter(A,"childNodes"),Q=lookupGetter(A,"parentNode");if(typeof f=="function"){const Xt=n.createElement("template");Xt.content&&Xt.content.ownerDocument&&(n=Xt.content.ownerDocument)}let te,F="";const{implementation:V,createNodeIterator:ne,createDocumentFragment:ae,getElementsByTagName:se}=n,{importNode:Oe}=o;let Ne=_createHooksMap();t.isSupported=typeof entries=="function"&&typeof Q=="function"&&V&&V.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:oe,ERB_EXPR:$e,TMPLIT_EXPR:Ae,DATA_ATTR:je,ARIA_ATTR:Be,IS_SCRIPT_OR_DATA:qe,ATTR_WHITESPACE:Ve,CUSTOM_ELEMENT:Le}=EXPRESSIONS;let{IS_ALLOWED_URI:He}=EXPRESSIONS,We=null;const ze=addToSet({},[...html$1,...svg$1,...svgFilters,...mathMl$1,...text$1]);let Xe=null;const nt=addToSet({},[...html,...svg,...mathMl,...xml]);let Je=Object.seal(create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),st=null,et=null;const at=Object.seal(create(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let tt=!0,ot=!0,lt=!1,Ge=!0,$t=!1,rt=!0,Rt=!1,dt=!1,It=!1,Mt=!1,Ct=!1,Ke=!1,Ye=!0,Ze=!1;const ct="user-content-";let mt=!0,ft=!1,yt={},Ht=null;const Kt=addToSet({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let un=null;const hn=addToSet({},["audio","video","img","source","image","track"]);let qt=null;const An=addToSet({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),xn="http://www.w3.org/1998/Math/MathML",Rn="http://www.w3.org/2000/svg",vn="http://www.w3.org/1999/xhtml";let Pn=vn,Mn=!1,$n=null;const Vn=addToSet({},[xn,Rn,vn],stringToString);let Jt=addToSet({},["mi","mo","mn","ms","mtext"]),Zt=addToSet({},["annotation-xml"]);const Ut=addToSet({},["title","style","font","a","script"]);let tn=null;const Yt=["application/xhtml+xml","text/html"],an="text/html";let mn=null,On=null;const Fn=n.createElement("form"),Cn=function(it){return it instanceof RegExp||it instanceof Function},Bn=function(){let it=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(On&&On===it)){if((!it||typeof it!="object")&&(it={}),it=clone(it),tn=Yt.indexOf(it.PARSER_MEDIA_TYPE)===-1?an:it.PARSER_MEDIA_TYPE,mn=tn==="application/xhtml+xml"?stringToString:stringToLowerCase,We=objectHasOwnProperty(it,"ALLOWED_TAGS")?addToSet({},it.ALLOWED_TAGS,mn):ze,Xe=objectHasOwnProperty(it,"ALLOWED_ATTR")?addToSet({},it.ALLOWED_ATTR,mn):nt,$n=objectHasOwnProperty(it,"ALLOWED_NAMESPACES")?addToSet({},it.ALLOWED_NAMESPACES,stringToString):Vn,qt=objectHasOwnProperty(it,"ADD_URI_SAFE_ATTR")?addToSet(clone(An),it.ADD_URI_SAFE_ATTR,mn):An,un=objectHasOwnProperty(it,"ADD_DATA_URI_TAGS")?addToSet(clone(hn),it.ADD_DATA_URI_TAGS,mn):hn,Ht=objectHasOwnProperty(it,"FORBID_CONTENTS")?addToSet({},it.FORBID_CONTENTS,mn):Kt,st=objectHasOwnProperty(it,"FORBID_TAGS")?addToSet({},it.FORBID_TAGS,mn):clone({}),et=objectHasOwnProperty(it,"FORBID_ATTR")?addToSet({},it.FORBID_ATTR,mn):clone({}),yt=objectHasOwnProperty(it,"USE_PROFILES")?it.USE_PROFILES:!1,tt=it.ALLOW_ARIA_ATTR!==!1,ot=it.ALLOW_DATA_ATTR!==!1,lt=it.ALLOW_UNKNOWN_PROTOCOLS||!1,Ge=it.ALLOW_SELF_CLOSE_IN_ATTR!==!1,$t=it.SAFE_FOR_TEMPLATES||!1,rt=it.SAFE_FOR_XML!==!1,Rt=it.WHOLE_DOCUMENT||!1,Mt=it.RETURN_DOM||!1,Ct=it.RETURN_DOM_FRAGMENT||!1,Ke=it.RETURN_TRUSTED_TYPE||!1,It=it.FORCE_BODY||!1,Ye=it.SANITIZE_DOM!==!1,Ze=it.SANITIZE_NAMED_PROPS||!1,mt=it.KEEP_CONTENT!==!1,ft=it.IN_PLACE||!1,He=it.ALLOWED_URI_REGEXP||IS_ALLOWED_URI,Pn=it.NAMESPACE||vn,Jt=it.MATHML_TEXT_INTEGRATION_POINTS||Jt,Zt=it.HTML_INTEGRATION_POINTS||Zt,Je=it.CUSTOM_ELEMENT_HANDLING||{},it.CUSTOM_ELEMENT_HANDLING&&Cn(it.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Je.tagNameCheck=it.CUSTOM_ELEMENT_HANDLING.tagNameCheck),it.CUSTOM_ELEMENT_HANDLING&&Cn(it.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Je.attributeNameCheck=it.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),it.CUSTOM_ELEMENT_HANDLING&&typeof it.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(Je.allowCustomizedBuiltInElements=it.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),$t&&(ot=!1),Ct&&(Mt=!0),yt&&(We=addToSet({},text$1),Xe=[],yt.html===!0&&(addToSet(We,html$1),addToSet(Xe,html)),yt.svg===!0&&(addToSet(We,svg$1),addToSet(Xe,svg),addToSet(Xe,xml)),yt.svgFilters===!0&&(addToSet(We,svgFilters),addToSet(Xe,svg),addToSet(Xe,xml)),yt.mathMl===!0&&(addToSet(We,mathMl$1),addToSet(Xe,mathMl),addToSet(Xe,xml))),it.ADD_TAGS&&(typeof it.ADD_TAGS=="function"?at.tagCheck=it.ADD_TAGS:(We===ze&&(We=clone(We)),addToSet(We,it.ADD_TAGS,mn))),it.ADD_ATTR&&(typeof it.ADD_ATTR=="function"?at.attributeCheck=it.ADD_ATTR:(Xe===nt&&(Xe=clone(Xe)),addToSet(Xe,it.ADD_ATTR,mn))),it.ADD_URI_SAFE_ATTR&&addToSet(qt,it.ADD_URI_SAFE_ATTR,mn),it.FORBID_CONTENTS&&(Ht===Kt&&(Ht=clone(Ht)),addToSet(Ht,it.FORBID_CONTENTS,mn)),mt&&(We["#text"]=!0),Rt&&addToSet(We,["html","head","body"]),We.table&&(addToSet(We,["tbody"]),delete st.tbody),it.TRUSTED_TYPES_POLICY){if(typeof it.TRUSTED_TYPES_POLICY.createHTML!="function")throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof it.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');te=it.TRUSTED_TYPES_POLICY,F=te.createHTML("")}else te===void 0&&(te=_createTrustedTypesPolicy(E,l)),te!==null&&typeof F=="string"&&(F=te.createHTML(""));freeze&&freeze(it),On=it}},qn=addToSet({},[...svg$1,...svgFilters,...svgDisallowed]),Un=addToSet({},[...mathMl$1,...mathMlDisallowed]),sr=function(it){let Dt=Q(it);(!Dt||!Dt.tagName)&&(Dt={namespaceURI:Pn,tagName:"template"});const Wt=stringToLowerCase(it.tagName),pn=stringToLowerCase(Dt.tagName);return $n[it.namespaceURI]?it.namespaceURI===Rn?Dt.namespaceURI===vn?Wt==="svg":Dt.namespaceURI===xn?Wt==="svg"&&(pn==="annotation-xml"||Jt[pn]):!!qn[Wt]:it.namespaceURI===xn?Dt.namespaceURI===vn?Wt==="math":Dt.namespaceURI===Rn?Wt==="math"&&Zt[pn]:!!Un[Wt]:it.namespaceURI===vn?Dt.namespaceURI===Rn&&!Zt[pn]||Dt.namespaceURI===xn&&!Jt[pn]?!1:!Un[Wt]&&(Ut[Wt]||!qn[Wt]):!!(tn==="application/xhtml+xml"&&$n[it.namespaceURI]):!1},wn=function(it){arrayPush(t.removed,{element:it});try{Q(it).removeChild(it)}catch{I(it)}},Dn=function(it,Dt){try{arrayPush(t.removed,{attribute:Dt.getAttributeNode(it),from:Dt})}catch{arrayPush(t.removed,{attribute:null,from:Dt})}if(Dt.removeAttribute(it),it==="is")if(Mt||Ct)try{wn(Dt)}catch{}else try{Dt.setAttribute(it,"")}catch{}},Zn=function(it){let Dt=null,Wt=null;if(It)it="<remove></remove>"+it;else{const gn=stringMatch(it,/^[\r\n\t ]+/);Wt=gn&&gn[0]}tn==="application/xhtml+xml"&&Pn===vn&&(it='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+it+"</body></html>");const pn=te?te.createHTML(it):it;if(Pn===vn)try{Dt=new C().parseFromString(pn,tn)}catch{}if(!Dt||!Dt.documentElement){Dt=V.createDocument(Pn,"template",null);try{Dt.documentElement.innerHTML=Mn?F:pn}catch{}}const bn=Dt.body||Dt.documentElement;return it&&Wt&&bn.insertBefore(n.createTextNode(Wt),bn.childNodes[0]||null),Pn===vn?se.call(Dt,Rt?"html":"body")[0]:Rt?Dt.documentElement:bn},er=function(it){return ne.call(it.ownerDocument||it,it,_.SHOW_ELEMENT|_.SHOW_COMMENT|_.SHOW_TEXT|_.SHOW_PROCESSING_INSTRUCTION|_.SHOW_CDATA_SECTION,null)},Kn=function(it){return it instanceof R&&(typeof it.nodeName!="string"||typeof it.textContent!="string"||typeof it.removeChild!="function"||!(it.attributes instanceof S)||typeof it.removeAttribute!="function"||typeof it.setAttribute!="function"||typeof it.namespaceURI!="string"||typeof it.insertBefore!="function"||typeof it.hasChildNodes!="function")},or=function(it){return typeof g=="function"&&it instanceof g};function kn(Xt,it,Dt){arrayForEach(Xt,Wt=>{Wt.call(t,it,Dt,On)})}const lr=function(it){let Dt=null;if(kn(Ne.beforeSanitizeElements,it,null),Kn(it))return wn(it),!0;const Wt=mn(it.nodeName);if(kn(Ne.uponSanitizeElement,it,{tagName:Wt,allowedTags:We}),rt&&it.hasChildNodes()&&!or(it.firstElementChild)&&regExpTest(/<[/\w!]/g,it.innerHTML)&&regExpTest(/<[/\w!]/g,it.textContent)||it.nodeType===NODE_TYPE.progressingInstruction||rt&&it.nodeType===NODE_TYPE.comment&&regExpTest(/<[/\w]/g,it.data))return wn(it),!0;if(!(at.tagCheck instanceof Function&&at.tagCheck(Wt))&&(!We[Wt]||st[Wt])){if(!st[Wt]&&tr(Wt)&&(Je.tagNameCheck instanceof RegExp&&regExpTest(Je.tagNameCheck,Wt)||Je.tagNameCheck instanceof Function&&Je.tagNameCheck(Wt)))return!1;if(mt&&!Ht[Wt]){const pn=Q(it)||it.parentNode,bn=q(it)||it.childNodes;if(bn&&pn){const gn=bn.length;for(let Sn=gn-1;Sn>=0;--Sn){const In=M(bn[Sn],!0);In.__removalCount=(it.__removalCount||0)+1,pn.insertBefore(In,j(it))}}}return wn(it),!0}return it instanceof b&&!sr(it)||(Wt==="noscript"||Wt==="noembed"||Wt==="noframes")&&regExpTest(/<\/no(script|embed|frames)/i,it.innerHTML)?(wn(it),!0):($t&&it.nodeType===NODE_TYPE.text&&(Dt=it.textContent,arrayForEach([oe,$e,Ae],pn=>{Dt=stringReplace(Dt,pn," ")}),it.textContent!==Dt&&(arrayPush(t.removed,{element:it.cloneNode()}),it.textContent=Dt)),kn(Ne.afterSanitizeElements,it,null),!1)},cr=function(it,Dt,Wt){if(Ye&&(Dt==="id"||Dt==="name")&&(Wt in n||Wt in Fn))return!1;if(!(ot&&!et[Dt]&&regExpTest(je,Dt))){if(!(tt&&regExpTest(Be,Dt))){if(!(at.attributeCheck instanceof Function&&at.attributeCheck(Dt,it))){if(!Xe[Dt]||et[Dt]){if(!(tr(it)&&(Je.tagNameCheck instanceof RegExp&&regExpTest(Je.tagNameCheck,it)||Je.tagNameCheck instanceof Function&&Je.tagNameCheck(it))&&(Je.attributeNameCheck instanceof RegExp&&regExpTest(Je.attributeNameCheck,Dt)||Je.attributeNameCheck instanceof Function&&Je.attributeNameCheck(Dt,it))||Dt==="is"&&Je.allowCustomizedBuiltInElements&&(Je.tagNameCheck instanceof RegExp&&regExpTest(Je.tagNameCheck,Wt)||Je.tagNameCheck instanceof Function&&Je.tagNameCheck(Wt))))return!1}else if(!qt[Dt]){if(!regExpTest(He,stringReplace(Wt,Ve,""))){if(!((Dt==="src"||Dt==="xlink:href"||Dt==="href")&&it!=="script"&&stringIndexOf(Wt,"data:")===0&&un[it])){if(!(lt&&!regExpTest(qe,stringReplace(Wt,Ve,"")))){if(Wt)return!1}}}}}}}return!0},tr=function(it){return it!=="annotation-xml"&&stringMatch(it,Le)},nr=function(it){kn(Ne.beforeSanitizeAttributes,it,null);const{attributes:Dt}=it;if(!Dt||Kn(it))return;const Wt={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Xe,forceKeepAttr:void 0};let pn=Dt.length;for(;pn--;){const bn=Dt[pn],{name:gn,namespaceURI:Sn,value:In}=bn,Hn=mn(gn),zt=In;let yn=gn==="value"?zt:stringTrim(zt);if(Wt.attrName=Hn,Wt.attrValue=yn,Wt.keepAttr=!0,Wt.forceKeepAttr=void 0,kn(Ne.uponSanitizeAttribute,it,Wt),yn=Wt.attrValue,Ze&&(Hn==="id"||Hn==="name")&&(Dn(gn,it),yn=ct+yn),rt&&regExpTest(/((--!?|])>)|<\/(style|title|textarea)/i,yn)){Dn(gn,it);continue}if(Hn==="attributename"&&stringMatch(yn,"href")){Dn(gn,it);continue}if(Wt.forceKeepAttr)continue;if(!Wt.keepAttr){Dn(gn,it);continue}if(!Ge&&regExpTest(/\/>/i,yn)){Dn(gn,it);continue}$t&&arrayForEach([oe,$e,Ae],dr=>{yn=stringReplace(yn,dr," ")});const En=mn(it.nodeName);if(!cr(En,Hn,yn)){Dn(gn,it);continue}if(te&&typeof E=="object"&&typeof E.getAttributeType=="function"&&!Sn)switch(E.getAttributeType(En,Hn)){case"TrustedHTML":{yn=te.createHTML(yn);break}case"TrustedScriptURL":{yn=te.createScriptURL(yn);break}}if(yn!==zt)try{Sn?it.setAttributeNS(Sn,gn,yn):it.setAttribute(gn,yn),Kn(it)?wn(it):arrayPop(t.removed)}catch{Dn(gn,it)}}kn(Ne.afterSanitizeAttributes,it,null)},ur=function Xt(it){let Dt=null;const Wt=er(it);for(kn(Ne.beforeSanitizeShadowDOM,it,null);Dt=Wt.nextNode();)kn(Ne.uponSanitizeShadowNode,Dt,null),lr(Dt),nr(Dt),Dt.content instanceof d&&Xt(Dt.content);kn(Ne.afterSanitizeShadowDOM,it,null)};return t.sanitize=function(Xt){let it=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},Dt=null,Wt=null,pn=null,bn=null;if(Mn=!Xt,Mn&&(Xt="<!-->"),typeof Xt!="string"&&!or(Xt))if(typeof Xt.toString=="function"){if(Xt=Xt.toString(),typeof Xt!="string")throw typeErrorCreate("dirty is not a string, aborting")}else throw typeErrorCreate("toString is not a function");if(!t.isSupported)return Xt;if(dt||Bn(it),t.removed=[],typeof Xt=="string"&&(ft=!1),ft){if(Xt.nodeName){const In=mn(Xt.nodeName);if(!We[In]||st[In])throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place")}}else if(Xt instanceof g)Dt=Zn("<!---->"),Wt=Dt.ownerDocument.importNode(Xt,!0),Wt.nodeType===NODE_TYPE.element&&Wt.nodeName==="BODY"||Wt.nodeName==="HTML"?Dt=Wt:Dt.appendChild(Wt);else{if(!Mt&&!$t&&!Rt&&Xt.indexOf("<")===-1)return te&&Ke?te.createHTML(Xt):Xt;if(Dt=Zn(Xt),!Dt)return Mt?null:Ke?F:""}Dt&&It&&wn(Dt.firstChild);const gn=er(ft?Xt:Dt);for(;pn=gn.nextNode();)lr(pn),nr(pn),pn.content instanceof d&&ur(pn.content);if(ft)return Xt;if(Mt){if(Ct)for(bn=ae.call(Dt.ownerDocument);Dt.firstChild;)bn.appendChild(Dt.firstChild);else bn=Dt;return(Xe.shadowroot||Xe.shadowrootmode)&&(bn=Oe.call(o,bn,!0)),bn}let Sn=Rt?Dt.outerHTML:Dt.innerHTML;return Rt&&We["!doctype"]&&Dt.ownerDocument&&Dt.ownerDocument.doctype&&Dt.ownerDocument.doctype.name&&regExpTest(DOCTYPE_NAME,Dt.ownerDocument.doctype.name)&&(Sn="<!DOCTYPE "+Dt.ownerDocument.doctype.name+`>
1158
+ Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+escape2(n.message+"",!0)+"</pre>";return t?Promise.resolve(o):o}if(t)return Promise.reject(n);throw n}}},markedInstance=new Marked;function marked(e,t){return markedInstance.parse(e,t)}marked.options=marked.setOptions=function(e){return markedInstance.setOptions(e),marked.defaults=markedInstance.defaults,changeDefaults(marked.defaults),marked},marked.getDefaults=_getDefaults,marked.defaults=_defaults,marked.use=function(...e){return markedInstance.use(...e),marked.defaults=markedInstance.defaults,changeDefaults(marked.defaults),marked},marked.walkTokens=function(e,t){return markedInstance.walkTokens(e,t)},marked.parseInline=markedInstance.parseInline,marked.Parser=_Parser,marked.parser=_Parser.parse,marked.Renderer=_Renderer,marked.TextRenderer=_TextRenderer,marked.Lexer=_Lexer,marked.lexer=_Lexer.lex,marked.Tokenizer=_Tokenizer,marked.Hooks=_Hooks,marked.parse=marked,marked.options,marked.setOptions,marked.use,marked.walkTokens,marked.parseInline,_Parser.parse,_Lexer.lex;/*! @license DOMPurify 3.3.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.0/LICENSE */const{entries,setPrototypeOf,isFrozen,getPrototypeOf,getOwnPropertyDescriptor}=Object;let{freeze,seal,create}=Object,{apply:apply$1,construct}=typeof Reflect<"u"&&Reflect;freeze||(freeze=function(t){return t}),seal||(seal=function(t){return t}),apply$1||(apply$1=function(t,n){for(var o=arguments.length,l=new Array(o>2?o-2:0),d=2;d<o;d++)l[d-2]=arguments[d];return t.apply(n,l)}),construct||(construct=function(t){for(var n=arguments.length,o=new Array(n>1?n-1:0),l=1;l<n;l++)o[l-1]=arguments[l];return new t(...o)});const arrayForEach=unapply(Array.prototype.forEach),arrayLastIndexOf=unapply(Array.prototype.lastIndexOf),arrayPop=unapply(Array.prototype.pop),arrayPush=unapply(Array.prototype.push),arraySplice=unapply(Array.prototype.splice),stringToLowerCase=unapply(String.prototype.toLowerCase),stringToString=unapply(String.prototype.toString),stringMatch=unapply(String.prototype.match),stringReplace=unapply(String.prototype.replace),stringIndexOf=unapply(String.prototype.indexOf),stringTrim=unapply(String.prototype.trim),objectHasOwnProperty=unapply(Object.prototype.hasOwnProperty),regExpTest=unapply(RegExp.prototype.test),typeErrorCreate=unconstruct(TypeError);function unapply(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,o=new Array(n>1?n-1:0),l=1;l<n;l++)o[l-1]=arguments[l];return apply$1(e,t,o)}}function unconstruct(e){return function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return construct(e,n)}}function addToSet(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:stringToLowerCase;setPrototypeOf&&setPrototypeOf(e,null);let o=t.length;for(;o--;){let l=t[o];if(typeof l=="string"){const d=n(l);d!==l&&(isFrozen(t)||(t[o]=d),l=d)}e[l]=!0}return e}function cleanArray(e){for(let t=0;t<e.length;t++)objectHasOwnProperty(e,t)||(e[t]=null);return e}function clone(e){const t=create(null);for(const[n,o]of entries(e))objectHasOwnProperty(e,n)&&(Array.isArray(o)?t[n]=cleanArray(o):o&&typeof o=="object"&&o.constructor===Object?t[n]=clone(o):t[n]=o);return t}function lookupGetter(e,t){for(;e!==null;){const o=getOwnPropertyDescriptor(e,t);if(o){if(o.get)return unapply(o.get);if(typeof o.value=="function")return unapply(o.value)}e=getPrototypeOf(e)}function n(){return null}return n}const html$1=freeze(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),svg$1=freeze(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),svgFilters=freeze(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),svgDisallowed=freeze(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),mathMl$1=freeze(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),mathMlDisallowed=freeze(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),text$1=freeze(["#text"]),html=freeze(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),svg=freeze(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),mathMl=freeze(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),xml=freeze(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),MUSTACHE_EXPR=seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm),ERB_EXPR=seal(/<%[\w\W]*|[\w\W]*%>/gm),TMPLIT_EXPR=seal(/\$\{[\w\W]*/gm),DATA_ATTR=seal(/^data-[\-\w.\u00B7-\uFFFF]+$/),ARIA_ATTR=seal(/^aria-[\-\w]+$/),IS_ALLOWED_URI=seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),IS_SCRIPT_OR_DATA=seal(/^(?:\w+script|data):/i),ATTR_WHITESPACE=seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),DOCTYPE_NAME=seal(/^html$/i),CUSTOM_ELEMENT=seal(/^[a-z][.\w]*(-[.\w]+)+$/i);var EXPRESSIONS=Object.freeze({__proto__:null,ARIA_ATTR,ATTR_WHITESPACE,CUSTOM_ELEMENT,DATA_ATTR,DOCTYPE_NAME,ERB_EXPR,IS_ALLOWED_URI,IS_SCRIPT_OR_DATA,MUSTACHE_EXPR,TMPLIT_EXPR});const NODE_TYPE={element:1,text:3,progressingInstruction:7,comment:8,document:9},getGlobal=function e(){return typeof window>"u"?null:window},_createTrustedTypesPolicy=function e(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let o=null;const l="data-tt-policy-suffix";n&&n.hasAttribute(l)&&(o=n.getAttribute(l));const d="dompurify"+(o?"#"+o:"");try{return t.createPolicy(d,{createHTML(f){return f},createScriptURL(f){return f}})}catch{return console.warn("TrustedTypes policy "+d+" could not be created."),null}},_createHooksMap=function e(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function createDOMPurify(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:getGlobal();const t=Xt=>createDOMPurify(Xt);if(t.version="3.3.0",t.removed=[],!e||!e.document||e.document.nodeType!==NODE_TYPE.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const o=n,l=o.currentScript,{DocumentFragment:d,HTMLTemplateElement:f,Node:g,Element:b,NodeFilter:_,NamedNodeMap:S=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:R,DOMParser:C,trustedTypes:E}=e,A=b.prototype,M=lookupGetter(A,"cloneNode"),I=lookupGetter(A,"remove"),j=lookupGetter(A,"nextSibling"),q=lookupGetter(A,"childNodes"),Q=lookupGetter(A,"parentNode");if(typeof f=="function"){const Xt=n.createElement("template");Xt.content&&Xt.content.ownerDocument&&(n=Xt.content.ownerDocument)}let te,F="";const{implementation:V,createNodeIterator:ne,createDocumentFragment:ae,getElementsByTagName:se}=n,{importNode:Oe}=o;let Ne=_createHooksMap();t.isSupported=typeof entries=="function"&&typeof Q=="function"&&V&&V.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:oe,ERB_EXPR:$e,TMPLIT_EXPR:Ae,DATA_ATTR:je,ARIA_ATTR:Be,IS_SCRIPT_OR_DATA:qe,ATTR_WHITESPACE:Ve,CUSTOM_ELEMENT:Le}=EXPRESSIONS;let{IS_ALLOWED_URI:He}=EXPRESSIONS,We=null;const ze=addToSet({},[...html$1,...svg$1,...svgFilters,...mathMl$1,...text$1]);let Xe=null;const nt=addToSet({},[...html,...svg,...mathMl,...xml]);let Je=Object.seal(create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),st=null,et=null;const at=Object.seal(create(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let tt=!0,ot=!0,lt=!1,Ge=!0,$t=!1,rt=!0,Rt=!1,dt=!1,It=!1,Mt=!1,Ct=!1,Ke=!1,Ye=!0,Ze=!1;const ct="user-content-";let mt=!0,ft=!1,yt={},Ht=null;const Kt=addToSet({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let un=null;const hn=addToSet({},["audio","video","img","source","image","track"]);let qt=null;const An=addToSet({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),xn="http://www.w3.org/1998/Math/MathML",Rn="http://www.w3.org/2000/svg",vn="http://www.w3.org/1999/xhtml";let Pn=vn,Mn=!1,$n=null;const Vn=addToSet({},[xn,Rn,vn],stringToString);let Jt=addToSet({},["mi","mo","mn","ms","mtext"]),Qt=addToSet({},["annotation-xml"]);const Ut=addToSet({},["title","style","font","a","script"]);let tn=null;const Yt=["application/xhtml+xml","text/html"],an="text/html";let mn=null,On=null;const Fn=n.createElement("form"),Cn=function(it){return it instanceof RegExp||it instanceof Function},Bn=function(){let it=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(On&&On===it)){if((!it||typeof it!="object")&&(it={}),it=clone(it),tn=Yt.indexOf(it.PARSER_MEDIA_TYPE)===-1?an:it.PARSER_MEDIA_TYPE,mn=tn==="application/xhtml+xml"?stringToString:stringToLowerCase,We=objectHasOwnProperty(it,"ALLOWED_TAGS")?addToSet({},it.ALLOWED_TAGS,mn):ze,Xe=objectHasOwnProperty(it,"ALLOWED_ATTR")?addToSet({},it.ALLOWED_ATTR,mn):nt,$n=objectHasOwnProperty(it,"ALLOWED_NAMESPACES")?addToSet({},it.ALLOWED_NAMESPACES,stringToString):Vn,qt=objectHasOwnProperty(it,"ADD_URI_SAFE_ATTR")?addToSet(clone(An),it.ADD_URI_SAFE_ATTR,mn):An,un=objectHasOwnProperty(it,"ADD_DATA_URI_TAGS")?addToSet(clone(hn),it.ADD_DATA_URI_TAGS,mn):hn,Ht=objectHasOwnProperty(it,"FORBID_CONTENTS")?addToSet({},it.FORBID_CONTENTS,mn):Kt,st=objectHasOwnProperty(it,"FORBID_TAGS")?addToSet({},it.FORBID_TAGS,mn):clone({}),et=objectHasOwnProperty(it,"FORBID_ATTR")?addToSet({},it.FORBID_ATTR,mn):clone({}),yt=objectHasOwnProperty(it,"USE_PROFILES")?it.USE_PROFILES:!1,tt=it.ALLOW_ARIA_ATTR!==!1,ot=it.ALLOW_DATA_ATTR!==!1,lt=it.ALLOW_UNKNOWN_PROTOCOLS||!1,Ge=it.ALLOW_SELF_CLOSE_IN_ATTR!==!1,$t=it.SAFE_FOR_TEMPLATES||!1,rt=it.SAFE_FOR_XML!==!1,Rt=it.WHOLE_DOCUMENT||!1,Mt=it.RETURN_DOM||!1,Ct=it.RETURN_DOM_FRAGMENT||!1,Ke=it.RETURN_TRUSTED_TYPE||!1,It=it.FORCE_BODY||!1,Ye=it.SANITIZE_DOM!==!1,Ze=it.SANITIZE_NAMED_PROPS||!1,mt=it.KEEP_CONTENT!==!1,ft=it.IN_PLACE||!1,He=it.ALLOWED_URI_REGEXP||IS_ALLOWED_URI,Pn=it.NAMESPACE||vn,Jt=it.MATHML_TEXT_INTEGRATION_POINTS||Jt,Qt=it.HTML_INTEGRATION_POINTS||Qt,Je=it.CUSTOM_ELEMENT_HANDLING||{},it.CUSTOM_ELEMENT_HANDLING&&Cn(it.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Je.tagNameCheck=it.CUSTOM_ELEMENT_HANDLING.tagNameCheck),it.CUSTOM_ELEMENT_HANDLING&&Cn(it.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Je.attributeNameCheck=it.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),it.CUSTOM_ELEMENT_HANDLING&&typeof it.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(Je.allowCustomizedBuiltInElements=it.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),$t&&(ot=!1),Ct&&(Mt=!0),yt&&(We=addToSet({},text$1),Xe=[],yt.html===!0&&(addToSet(We,html$1),addToSet(Xe,html)),yt.svg===!0&&(addToSet(We,svg$1),addToSet(Xe,svg),addToSet(Xe,xml)),yt.svgFilters===!0&&(addToSet(We,svgFilters),addToSet(Xe,svg),addToSet(Xe,xml)),yt.mathMl===!0&&(addToSet(We,mathMl$1),addToSet(Xe,mathMl),addToSet(Xe,xml))),it.ADD_TAGS&&(typeof it.ADD_TAGS=="function"?at.tagCheck=it.ADD_TAGS:(We===ze&&(We=clone(We)),addToSet(We,it.ADD_TAGS,mn))),it.ADD_ATTR&&(typeof it.ADD_ATTR=="function"?at.attributeCheck=it.ADD_ATTR:(Xe===nt&&(Xe=clone(Xe)),addToSet(Xe,it.ADD_ATTR,mn))),it.ADD_URI_SAFE_ATTR&&addToSet(qt,it.ADD_URI_SAFE_ATTR,mn),it.FORBID_CONTENTS&&(Ht===Kt&&(Ht=clone(Ht)),addToSet(Ht,it.FORBID_CONTENTS,mn)),mt&&(We["#text"]=!0),Rt&&addToSet(We,["html","head","body"]),We.table&&(addToSet(We,["tbody"]),delete st.tbody),it.TRUSTED_TYPES_POLICY){if(typeof it.TRUSTED_TYPES_POLICY.createHTML!="function")throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof it.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');te=it.TRUSTED_TYPES_POLICY,F=te.createHTML("")}else te===void 0&&(te=_createTrustedTypesPolicy(E,l)),te!==null&&typeof F=="string"&&(F=te.createHTML(""));freeze&&freeze(it),On=it}},qn=addToSet({},[...svg$1,...svgFilters,...svgDisallowed]),Un=addToSet({},[...mathMl$1,...mathMlDisallowed]),sr=function(it){let Dt=Q(it);(!Dt||!Dt.tagName)&&(Dt={namespaceURI:Pn,tagName:"template"});const Wt=stringToLowerCase(it.tagName),pn=stringToLowerCase(Dt.tagName);return $n[it.namespaceURI]?it.namespaceURI===Rn?Dt.namespaceURI===vn?Wt==="svg":Dt.namespaceURI===xn?Wt==="svg"&&(pn==="annotation-xml"||Jt[pn]):!!qn[Wt]:it.namespaceURI===xn?Dt.namespaceURI===vn?Wt==="math":Dt.namespaceURI===Rn?Wt==="math"&&Qt[pn]:!!Un[Wt]:it.namespaceURI===vn?Dt.namespaceURI===Rn&&!Qt[pn]||Dt.namespaceURI===xn&&!Jt[pn]?!1:!Un[Wt]&&(Ut[Wt]||!qn[Wt]):!!(tn==="application/xhtml+xml"&&$n[it.namespaceURI]):!1},wn=function(it){arrayPush(t.removed,{element:it});try{Q(it).removeChild(it)}catch{I(it)}},Dn=function(it,Dt){try{arrayPush(t.removed,{attribute:Dt.getAttributeNode(it),from:Dt})}catch{arrayPush(t.removed,{attribute:null,from:Dt})}if(Dt.removeAttribute(it),it==="is")if(Mt||Ct)try{wn(Dt)}catch{}else try{Dt.setAttribute(it,"")}catch{}},Zn=function(it){let Dt=null,Wt=null;if(It)it="<remove></remove>"+it;else{const gn=stringMatch(it,/^[\r\n\t ]+/);Wt=gn&&gn[0]}tn==="application/xhtml+xml"&&Pn===vn&&(it='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+it+"</body></html>");const pn=te?te.createHTML(it):it;if(Pn===vn)try{Dt=new C().parseFromString(pn,tn)}catch{}if(!Dt||!Dt.documentElement){Dt=V.createDocument(Pn,"template",null);try{Dt.documentElement.innerHTML=Mn?F:pn}catch{}}const bn=Dt.body||Dt.documentElement;return it&&Wt&&bn.insertBefore(n.createTextNode(Wt),bn.childNodes[0]||null),Pn===vn?se.call(Dt,Rt?"html":"body")[0]:Rt?Dt.documentElement:bn},er=function(it){return ne.call(it.ownerDocument||it,it,_.SHOW_ELEMENT|_.SHOW_COMMENT|_.SHOW_TEXT|_.SHOW_PROCESSING_INSTRUCTION|_.SHOW_CDATA_SECTION,null)},Kn=function(it){return it instanceof R&&(typeof it.nodeName!="string"||typeof it.textContent!="string"||typeof it.removeChild!="function"||!(it.attributes instanceof S)||typeof it.removeAttribute!="function"||typeof it.setAttribute!="function"||typeof it.namespaceURI!="string"||typeof it.insertBefore!="function"||typeof it.hasChildNodes!="function")},or=function(it){return typeof g=="function"&&it instanceof g};function kn(Xt,it,Dt){arrayForEach(Xt,Wt=>{Wt.call(t,it,Dt,On)})}const lr=function(it){let Dt=null;if(kn(Ne.beforeSanitizeElements,it,null),Kn(it))return wn(it),!0;const Wt=mn(it.nodeName);if(kn(Ne.uponSanitizeElement,it,{tagName:Wt,allowedTags:We}),rt&&it.hasChildNodes()&&!or(it.firstElementChild)&&regExpTest(/<[/\w!]/g,it.innerHTML)&&regExpTest(/<[/\w!]/g,it.textContent)||it.nodeType===NODE_TYPE.progressingInstruction||rt&&it.nodeType===NODE_TYPE.comment&&regExpTest(/<[/\w]/g,it.data))return wn(it),!0;if(!(at.tagCheck instanceof Function&&at.tagCheck(Wt))&&(!We[Wt]||st[Wt])){if(!st[Wt]&&tr(Wt)&&(Je.tagNameCheck instanceof RegExp&&regExpTest(Je.tagNameCheck,Wt)||Je.tagNameCheck instanceof Function&&Je.tagNameCheck(Wt)))return!1;if(mt&&!Ht[Wt]){const pn=Q(it)||it.parentNode,bn=q(it)||it.childNodes;if(bn&&pn){const gn=bn.length;for(let Sn=gn-1;Sn>=0;--Sn){const In=M(bn[Sn],!0);In.__removalCount=(it.__removalCount||0)+1,pn.insertBefore(In,j(it))}}}return wn(it),!0}return it instanceof b&&!sr(it)||(Wt==="noscript"||Wt==="noembed"||Wt==="noframes")&&regExpTest(/<\/no(script|embed|frames)/i,it.innerHTML)?(wn(it),!0):($t&&it.nodeType===NODE_TYPE.text&&(Dt=it.textContent,arrayForEach([oe,$e,Ae],pn=>{Dt=stringReplace(Dt,pn," ")}),it.textContent!==Dt&&(arrayPush(t.removed,{element:it.cloneNode()}),it.textContent=Dt)),kn(Ne.afterSanitizeElements,it,null),!1)},cr=function(it,Dt,Wt){if(Ye&&(Dt==="id"||Dt==="name")&&(Wt in n||Wt in Fn))return!1;if(!(ot&&!et[Dt]&&regExpTest(je,Dt))){if(!(tt&&regExpTest(Be,Dt))){if(!(at.attributeCheck instanceof Function&&at.attributeCheck(Dt,it))){if(!Xe[Dt]||et[Dt]){if(!(tr(it)&&(Je.tagNameCheck instanceof RegExp&&regExpTest(Je.tagNameCheck,it)||Je.tagNameCheck instanceof Function&&Je.tagNameCheck(it))&&(Je.attributeNameCheck instanceof RegExp&&regExpTest(Je.attributeNameCheck,Dt)||Je.attributeNameCheck instanceof Function&&Je.attributeNameCheck(Dt,it))||Dt==="is"&&Je.allowCustomizedBuiltInElements&&(Je.tagNameCheck instanceof RegExp&&regExpTest(Je.tagNameCheck,Wt)||Je.tagNameCheck instanceof Function&&Je.tagNameCheck(Wt))))return!1}else if(!qt[Dt]){if(!regExpTest(He,stringReplace(Wt,Ve,""))){if(!((Dt==="src"||Dt==="xlink:href"||Dt==="href")&&it!=="script"&&stringIndexOf(Wt,"data:")===0&&un[it])){if(!(lt&&!regExpTest(qe,stringReplace(Wt,Ve,"")))){if(Wt)return!1}}}}}}}return!0},tr=function(it){return it!=="annotation-xml"&&stringMatch(it,Le)},nr=function(it){kn(Ne.beforeSanitizeAttributes,it,null);const{attributes:Dt}=it;if(!Dt||Kn(it))return;const Wt={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Xe,forceKeepAttr:void 0};let pn=Dt.length;for(;pn--;){const bn=Dt[pn],{name:gn,namespaceURI:Sn,value:In}=bn,Hn=mn(gn),zt=In;let yn=gn==="value"?zt:stringTrim(zt);if(Wt.attrName=Hn,Wt.attrValue=yn,Wt.keepAttr=!0,Wt.forceKeepAttr=void 0,kn(Ne.uponSanitizeAttribute,it,Wt),yn=Wt.attrValue,Ze&&(Hn==="id"||Hn==="name")&&(Dn(gn,it),yn=ct+yn),rt&&regExpTest(/((--!?|])>)|<\/(style|title|textarea)/i,yn)){Dn(gn,it);continue}if(Hn==="attributename"&&stringMatch(yn,"href")){Dn(gn,it);continue}if(Wt.forceKeepAttr)continue;if(!Wt.keepAttr){Dn(gn,it);continue}if(!Ge&&regExpTest(/\/>/i,yn)){Dn(gn,it);continue}$t&&arrayForEach([oe,$e,Ae],dr=>{yn=stringReplace(yn,dr," ")});const En=mn(it.nodeName);if(!cr(En,Hn,yn)){Dn(gn,it);continue}if(te&&typeof E=="object"&&typeof E.getAttributeType=="function"&&!Sn)switch(E.getAttributeType(En,Hn)){case"TrustedHTML":{yn=te.createHTML(yn);break}case"TrustedScriptURL":{yn=te.createScriptURL(yn);break}}if(yn!==zt)try{Sn?it.setAttributeNS(Sn,gn,yn):it.setAttribute(gn,yn),Kn(it)?wn(it):arrayPop(t.removed)}catch{Dn(gn,it)}}kn(Ne.afterSanitizeAttributes,it,null)},ur=function Xt(it){let Dt=null;const Wt=er(it);for(kn(Ne.beforeSanitizeShadowDOM,it,null);Dt=Wt.nextNode();)kn(Ne.uponSanitizeShadowNode,Dt,null),lr(Dt),nr(Dt),Dt.content instanceof d&&Xt(Dt.content);kn(Ne.afterSanitizeShadowDOM,it,null)};return t.sanitize=function(Xt){let it=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},Dt=null,Wt=null,pn=null,bn=null;if(Mn=!Xt,Mn&&(Xt="<!-->"),typeof Xt!="string"&&!or(Xt))if(typeof Xt.toString=="function"){if(Xt=Xt.toString(),typeof Xt!="string")throw typeErrorCreate("dirty is not a string, aborting")}else throw typeErrorCreate("toString is not a function");if(!t.isSupported)return Xt;if(dt||Bn(it),t.removed=[],typeof Xt=="string"&&(ft=!1),ft){if(Xt.nodeName){const In=mn(Xt.nodeName);if(!We[In]||st[In])throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place")}}else if(Xt instanceof g)Dt=Zn("<!---->"),Wt=Dt.ownerDocument.importNode(Xt,!0),Wt.nodeType===NODE_TYPE.element&&Wt.nodeName==="BODY"||Wt.nodeName==="HTML"?Dt=Wt:Dt.appendChild(Wt);else{if(!Mt&&!$t&&!Rt&&Xt.indexOf("<")===-1)return te&&Ke?te.createHTML(Xt):Xt;if(Dt=Zn(Xt),!Dt)return Mt?null:Ke?F:""}Dt&&It&&wn(Dt.firstChild);const gn=er(ft?Xt:Dt);for(;pn=gn.nextNode();)lr(pn),nr(pn),pn.content instanceof d&&ur(pn.content);if(ft)return Xt;if(Mt){if(Ct)for(bn=ae.call(Dt.ownerDocument);Dt.firstChild;)bn.appendChild(Dt.firstChild);else bn=Dt;return(Xe.shadowroot||Xe.shadowrootmode)&&(bn=Oe.call(o,bn,!0)),bn}let Sn=Rt?Dt.outerHTML:Dt.innerHTML;return Rt&&We["!doctype"]&&Dt.ownerDocument&&Dt.ownerDocument.doctype&&Dt.ownerDocument.doctype.name&&regExpTest(DOCTYPE_NAME,Dt.ownerDocument.doctype.name)&&(Sn="<!DOCTYPE "+Dt.ownerDocument.doctype.name+`>
1159
1159
  `+Sn),$t&&arrayForEach([oe,$e,Ae],In=>{Sn=stringReplace(Sn,In," ")}),te&&Ke?te.createHTML(Sn):Sn},t.setConfig=function(){let Xt=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Bn(Xt),dt=!0},t.clearConfig=function(){On=null,dt=!1},t.isValidAttribute=function(Xt,it,Dt){On||Bn({});const Wt=mn(Xt),pn=mn(it);return cr(Wt,pn,Dt)},t.addHook=function(Xt,it){typeof it=="function"&&arrayPush(Ne[Xt],it)},t.removeHook=function(Xt,it){if(it!==void 0){const Dt=arrayLastIndexOf(Ne[Xt],it);return Dt===-1?void 0:arraySplice(Ne[Xt],Dt,1)[0]}return arrayPop(Ne[Xt])},t.removeHooks=function(Xt){Ne[Xt]=[]},t.removeAllHooks=function(){Ne=_createHooksMap()},t}var purify=createDOMPurify();function markdownToSafeHTML(e){const t=marked(e,{async:!1});return purify.sanitize(t,{ALLOWED_TAGS:["h1","h2","h3","h4","h5","h6","b","strong","i","em","u","s","sub","sup","mark","blockquote","q","ul","ol","li","dl","dt","dd","p","div","span","br","hr","table","thead","tbody","tfoot","tr","th","td"]})}function SkeletonMessage({botStatus:e}){return jsxRuntime.jsxs("div",{className:"flex items-start gap-2",children:[jsxRuntime.jsx("div",{className:"h-8 w-8 mt-1 rounded-full bg-gray-300 animate-pulse flex-shrink-0"}),jsxRuntime.jsxs("div",{className:"flex flex-col max-w-[70%]",children:[jsxRuntime.jsx("p",{className:"mb-1",children:"Assistant"}),jsxRuntime.jsxs("div",{className:"flex items-end gap-2",children:[jsxRuntime.jsx("div",{className:"rounded-md p-3 break-words bg-white border rounded-tl-none",children:jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx("div",{className:"h-2 w-2 rounded-full bg-primary animate-pulse"}),jsxRuntime.jsx("div",{className:"h-2 w-2 rounded-full bg-primary animate-pulse delay-150"}),jsxRuntime.jsx("div",{className:"h-2 w-2 rounded-full bg-primary animate-pulse delay-300"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:e})]})}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:new Date().toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})})]})]})]})}function ChatMessages({messages:e,appID:t,botStatus:n,isAssistantChat:o}){const l=(()=>{const d=new Set;let f=null;for(const g of e){const b=(g.senderName??"").trim();b&&(f===b?d.add(g.id):f=b)}return d})();return jsxRuntime.jsxs("div",{children:[e.map(d=>{var g;const f=d.fromPartnerID===t;return jsxRuntime.jsx("div",{className:cn("flex items-start gap-2 mt-2 mb-2",f&&"flex-row-reverse"),children:jsxRuntime.jsxs("div",{className:"flex flex-col max-w-[70%]",children:[!l.has(d.id)&&!!((g=d.senderName)!=null&&g.trim())&&jsxRuntime.jsx("p",{className:cn("mb-1 flex",f&&"flex-row-reverse"),children:d.senderName}),jsxRuntime.jsxs("div",{className:cn("flex items-baseline gap-2",f&&"flex-row-reverse"),children:[jsxRuntime.jsx("div",{className:cn("rounded-md p-3 break-words [&_li]:ml-6 [&_li]:list-disc [&_h1]:text-lg [&_h1]:font-bold [&_h1]:mt-4 [&_h2]:font-bold [&_h2]:mt-4 [&_h3]:mt-4 ",f?"bg-primary text-white rounded-tr-none":"bg-white border rounded-tl-none"),children:parser(markdownToSafeHTML(d.content))}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:(()=>{const b=new Date(d.timestamp);return isToday(b)?b.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}):isYesterday(b)?`Yesterday, ${b.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})}`:`${b.toLocaleDateString([],{month:"short",day:"numeric"})} ${b.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})}`})()})]})]})},d.id)}),n!==""&&jsxRuntime.jsx(SkeletonMessage,{botStatus:n}),e.length===0&&!o&&jsxRuntime.jsxs("div",{className:"mt-1 text-xl",children:[jsxRuntime.jsx(Send,{className:"w-full h-32"}),jsxRuntime.jsx("p",{className:"text-center",children:"No messages yet... Say hello!"})]}),e.length===0&&n===""&&o&&jsxRuntime.jsxs("div",{className:"text-center py-8",children:[jsxRuntime.jsx("p",{children:"The Randmar Assistant is ready to help you. Ask anything about products, orders, carts, shipments and tracking numbers."}),jsxRuntime.jsx("p",{children:jsxRuntime.jsx("strong",{children:'Try it now, type "my open orders"!'})})]})]})}const Textarea=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("textarea",{className:cn("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:n,...t}));Textarea.displayName="Textarea";function ChatMainArea({activeChat:e,activeChatObj:t,appID:n,messagesEndRef:o,inputRef:l,content:d,setContent:f,handleSendMessage:g,isPostBizDevConvoLoading:b,acceptChat:_}){return jsxRuntime.jsx("div",{className:"flex-5 flex flex-col",children:e?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center p-4 border-b",children:[jsxRuntime.jsx(Avatar,{className:"h-8 w-8 flex-shrink-0 rounded-none",children:jsxRuntime.jsx(PartnerLogo,{id:e[0]===n?e[1]:e[0],width:72,height:72})}),jsxRuntime.jsx("div",{className:"ml-3 font-medium",children:t==null?void 0:t.name})]}),t!=null&&t.pending&&t.partner1==n?jsxRuntime.jsx("p",{className:"mt-8 p-2 mx-auto",children:"This conversation is awaiting approval by the other party — please check back later."}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(ScrollArea,{className:"flex-1 pl-2 pr-2 bg-slate-50",children:[jsxRuntime.jsx("div",{className:(t==null?void 0:t.messages)===null?" opacity-0":"",children:jsxRuntime.jsx(ChatMessages,{messages:(t==null?void 0:t.messages)??[],appID:n,isAssistantChat:!1,botStatus:""})}),jsxRuntime.jsx("div",{ref:o})]}),jsxRuntime.jsxs("div",{className:"p-4 border-t border-r flex",children:[(t==null?void 0:t.pending)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Button$1,{disabled:b,onClick:()=>_(),children:[jsxRuntime.jsx(Handshake,{}),"Accept Conversation Request"]}),jsxRuntime.jsxs(Button$1,{disabled:!0,className:"ml-2",children:[jsxRuntime.jsx(ThumbsDown,{}),"Block Partner"]})]}),jsxRuntime.jsx(Textarea,{ref:l,placeholder:"Type a message...",value:d,onChange:S=>f(S.target.value),onKeyDown:S=>{S.key!=="Enter"||S.shiftKey||(S.preventDefault(),g())},className:t!=null&&t.pending?"collapse":"flex-1 resize-none field-sizing-content max-h-[30em]",disabled:t==null?void 0:t.pending}),jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsx(Button$1,{size:"icon",variant:"default",className:t!=null&&t.pending?"collapse":"ml-2 h-8 w-8",disabled:t==null?void 0:t.pending,onClick:g,children:jsxRuntime.jsx(Send,{className:"h-6 w-6"})})})]})]})]}):jsxRuntime.jsxs("div",{className:"flex flex-col m-auto text-xl",children:[jsxRuntime.jsx(MousePointerClick,{className:"w-full h-32"}),jsxRuntime.jsx("p",{children:"Select a chat from the left menu to start messaging"})]})})}function ChatRightSidebar({activeChatObj:e,appID:t,sendChatToAssistant:n,isAnalyzingPartnership:o,analyzePartnership:l}){const d=e?[e.partner1,e.partner2]:void 0;return jsxRuntime.jsx("div",{className:"flex border-l flex-1",children:jsxRuntime.jsxs("div",{className:"flex flex-col p-4 border-b gap-2",children:[jsxRuntime.jsx("p",{className:"h-9 font-medium text-base/9",children:"Actions"}),jsxRuntime.jsx(reactRouterDom.Link,{className:"w-full",inert:d===void 0,to:`/${t}/Partner/${(d==null?void 0:d[0])===t?d[1]:d==null?void 0:d[0]}`,children:jsxRuntime.jsx(Button$1,{className:"w-full",disabled:d===void 0,children:"View Partner"})}),jsxRuntime.jsx(Button$1,{disabled:((e==null?void 0:e.messages)??[]).length<1,onClick:()=>n(e.messages),children:"Export to Randmar Assistant"}),jsxRuntime.jsx(Button$1,{disabled:d===void 0||o,onClick:l,children:o?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Analyzing..."]}):"Analyze Partnership"}),jsxRuntime.jsx(PartnerActions,{userId:t,partnerId:(d==null?void 0:d[0])===t?d[1]:(d==null?void 0:d[0])||"",isAdmin:!1}),jsxRuntime.jsx(PeopleSection,{appID:t,activeChatObj:e}),jsxRuntime.jsx(LinkSection,{appID:t,activeChatObj:e})]})})}const PeopleSection=({appID:e,activeChatObj:t})=>{const n=(t==null?void 0:t.conversationID)??-1,o=!t||n===-1,{data:l,isLoading:d,isError:f,refetch:g,isFetching:b}=useGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdPeopleQuery({routeApplicationId:e,conversationId:n},{skip:o}),_=l??[];return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("p",{className:"font-medium pt-2 border-t",children:"People"}),o?jsxRuntime.jsx("p",{className:"font-light",children:"Select a chat to see participants."}):d||b?jsxRuntime.jsx("p",{children:"Loading people..."}):f?jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsx("p",{className:"text-sm text-destructive",children:"Could not load people."}),jsxRuntime.jsx(Button$1,{variant:"secondary",size:"sm",onClick:()=>g(),children:"Retry"})]}):_.length===0?jsxRuntime.jsx("p",{className:"font-light",children:"No participants found."}):jsxRuntime.jsx("ul",{className:"flex flex-col gap-2",children:_.map((S,R)=>{const C=S.ApplicationId??`${S.Name??"person"}-${R}`,E=S.LastAuthentication?new Date(S.LastAuthentication).toLocaleString():void 0;return jsxRuntime.jsxs("li",{className:"rounded border px-3 py-2 text-sm",children:[jsxRuntime.jsx("p",{className:"font-medium leading-tight",children:S.Name??"Unknown person"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:S.Role??"Role unavailable"}),E?jsxRuntime.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last auth ",E]}):null]},C)})})]})},LinkSection=({appID:e,activeChatObj:t})=>{const[n,o]=React.useState(!1),l=t==null?void 0:t.conversationID,d=l===void 0||l===-1,{data:f,isLoading:g}=useGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdLinksQuery({routeApplicationId:e,conversationId:l??-1},{skip:d}),[b]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdLinkMutation(),[_]=useDeleteV4PartnerByRouteApplicationIdBusinessDevelopmentConversationLinkAndLinkIdMutation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("p",{className:"font-medium pt-2 border-t",children:"Links"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[g?jsxRuntime.jsx("p",{children:"Loading links..."}):(f==null?void 0:f.length)===0?jsxRuntime.jsx("p",{children:"No links attached."}):null,f==null?void 0:f.map(S=>jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("a",{href:S.URL,target:"_blank",rel:"noopener noreferrer",className:"text-randmar-red underline break-all",children:S.Title}),jsxRuntime.jsx(Button$1,{variant:"secondary",size:"icon",onClick:()=>_({routeApplicationId:e,linkId:S.LinkId}),children:jsxRuntime.jsx(Trash2,{className:"h-4 w-4"})})]},S.LinkId))]}),jsxRuntime.jsxs(Dialog,{open:n,onOpenChange:o,children:[jsxRuntime.jsx(DialogTrigger$1,{asChild:!0,children:jsxRuntime.jsx(Button$1,{className:"p-0",disabled:d,children:"Add Link"})}),jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle$1,{children:"Add Link"}),jsxRuntime.jsx(DialogDescription$1,{children:"Please enter the details for the new link."})]}),jsxRuntime.jsxs("form",{className:"space-y-4",onSubmit:S=>{S.preventDefault();const R=document.getElementById("link-title").value,C=document.getElementById("link-url").value;l===void 0||l===-1||(b({routeApplicationId:e,conversationId:l,createLinkRequest:{Title:R,Url:C}}),o(!1))},children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"link-title",children:"Title"}),jsxRuntime.jsx(Input,{id:"link-title",required:!0,minLength:2})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"link-url",children:"URL"}),jsxRuntime.jsx(Input,{id:"link-url",type:"url",required:!0,minLength:2,placeholder:"https://"})]}),jsxRuntime.jsx(Button$1,{type:"submit",disabled:d,children:"Add Link"})]})]})]})]})},UserSetupForm=e=>{const[t]=usePostV4UserByFieldNameMutation(),[n,o]=React.useState(""),[l,d]=React.useState(""),[f,g]=React.useState(!1),[b]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation();return jsxRuntime.jsxs("div",{className:"mx-auto mt-2",children:[jsxRuntime.jsx("p",{className:"mb-4",children:"Before you can start chatting, please set up your profile."}),jsxRuntime.jsxs("form",{className:"space-y-2",onSubmit:_=>{f||(g(!0),_.preventDefault(),t({fieldName:"Name",newValue:n}).then(()=>{b({routeApplicationId:e.appID,partnerId:"2"})}),t({fieldName:"Role",newValue:l}))},children:[jsxRuntime.jsx(Label$2,{htmlFor:"name",children:"Name"}),jsxRuntime.jsx(Input,{id:"name",required:!0,minLength:2,value:n,onChange:_=>o(_.target.value)}),jsxRuntime.jsx(Label$2,{htmlFor:"role",children:"Role"}),jsxRuntime.jsx(Input,{id:"role",required:!0,minLength:2,value:l,onChange:_=>d(_.target.value)}),jsxRuntime.jsx(Button$1,{type:"submit",disabled:f,children:f?"Saving...":"Save"})]})]})},sortChats=(e,t)=>e.unread>0&&t.unread===0?-1:t.unread>0&&e.unread===0?1:e.name.localeCompare(t.name);function ChatLayout({appID:e,inputRef:t,className:n}){const{setHasUnreads:o}=useChat(),{data:l,refetch:d}=useGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationsQuery({routeApplicationId:e}),[f,g]=React.useState(!1),[b,{isLoading:_}]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation(),S=React.useRef(null),[R]=useLazyGetV4PartnerByApplicationIdAccountQuery(),{sendPrompt:C}=useGemini({outputFormat:"text",useProModel:!0}),[E,A]=React.useState(!1),[M]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation(),[I]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdReadMutation(),[j]=useLazyGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdMessagesQuery(),[q]=useLazyGetV4PartnerByRouteApplicationIdPartnerAndPartnerIdQuery(),[Q,te]=React.useState(!1);React.useEffect(()=>{l&&(oe(dt=>{const It=l.map(Mt=>{var Ke;const Ct=dt.find(Ye=>Ye.conversationID===Mt.ConversationId);return{partner1:Mt.Participant1,partner2:Mt.Participant2,name:((Ke=Mt.Participant)==null?void 0:Ke.PublicName)??"missing public name",unread:(Ct==null?void 0:Ct.unread)??0,pending:Mt.Status!=="Approved",messages:(Ct==null?void 0:Ct.messages)??null,conversationID:Mt.ConversationId,lastMessageTime:Mt.LastMessageTime??null}});return It.sort(sortChats),It}),g(!0),setTimeout(()=>{var dt;return(dt=Le.current)==null?void 0:dt.focus()},50))},[l,e]);const[F,V]=React.useState(void 0),[ne,ae]=React.useState(""),[se,Oe]=React.useState(null),[Ne,oe]=React.useState([]),[$e,Ae]=React.useState(null),je=React.useRef(null),Be=React.useRef(null),[qe,Ve]=React.useState([]),Le=t||Be,He=React.useRef(null),{toast:We}=useToast(),ze=()=>Ne.find(dt=>dt.partner1===(F==null?void 0:F[0])&&dt.partner2===(F==null?void 0:F[1]));function Xe(){const dt=ze();dt&&I({routeApplicationId:e,conversationId:dt.conversationID})}const nt=dt=>Ve(It=>[...It,dt]);React.useEffect(()=>{if(qe.length==0)return;console.log(qe.length,"unprocessedMessages detected");const dt=(Mt,Ct)=>Ct.partner1===Mt.toPartnerID&&Ct.partner2===Mt.fromPartnerID||Ct.partner2===Mt.toPartnerID&&Ct.partner1===Mt.fromPartnerID;let It=!1;qe.forEach(Mt=>{if(!Ne.some(Ct=>dt(Mt,Ct))){console.log("message received for unknown convo ID - need to refetch!"),It=!0;return}oe(Ct=>Ct.map(Ke=>{if(!dt(Mt,Ke))return Ke;const Ye=Ke.messages??[];if(Ye.some(mt=>mt.id===Mt.id))return Ke;let Ze=1;const ct=document.activeElement&&document.activeElement===Le.current;return(F==null?void 0:F[0])==Ke.partner1&&F[1]==Ke.partner2&&ct&&(ct&&(Ze=0,Xe()),setTimeout(()=>{var mt;return(mt=je.current)==null?void 0:mt.scrollIntoView({behavior:"smooth"})},50)),{...Ke,pending:!1,unread:Ke.unread+Ze,messages:[...Ye,Mt]}}).sort(sortChats))}),console.log("need refetch:",It),It&&d(),Ve([])},[qe,Ve,oe,V,F]),React.useEffect(()=>{const dt=new HubConnectionBuilder().withUrl("https://api.randmar.io/hub",{accessTokenFactory:()=>localStorage.getItem("access_token"),headers:{"X-Impersonated-Id":e}}).configureLogging(LogLevel.Information).withAutomaticReconnect().withHubProtocol(new JsonHubProtocol).build();return dt.on("ReceiveMessage",nt),dt.start().catch(It=>console.error("Error connecting to SignalR hub:",It)),Ae(dt),()=>{dt&&dt.stop()}},[e]),React.useEffect(()=>{var It;!F||!ze()||((It=Le.current)==null||It.focus(),setTimeout(()=>{var Mt;return(Mt=je.current)==null?void 0:Mt.scrollIntoView({behavior:"smooth"})},50))},[F]),React.useEffect(()=>{if(!F)return;const dt=ze();dt&&dt.conversationID!==-1&&(async()=>{var It;try{const Ct=((It=(await j({routeApplicationId:e,conversationId:dt.conversationID})).data)==null?void 0:It.map(Ke=>({id:"history"+Ke.MessageId,fromPartnerID:Ke.SenderId,toPartnerID:Ke.SenderId==dt.partner1?dt.partner2:dt.partner1,senderName:Ke.SenderName??"missing name",timestamp:new Date(Ke.SentDate+"Z").getTime(),content:Ke.Content??"no content"})))??[];oe(Ke=>Ke.map(Ye=>Ye.conversationID===dt.conversationID?{...Ye,messages:Ct}:Ye).sort(sortChats))}catch(Mt){console.error("Error fetching conversation messages:",Mt)}})()},[F,j,e]),React.useEffect(()=>{if(!F)return;const dt=ze();if(!dt)return;const It=document.activeElement&&document.activeElement===Le.current;dt.unread>0&&It&&(Xe(),oe(Mt=>Mt.map(Ct=>Ct.partner1===F[0]&&Ct.partner2===F[1]?{...Ct,unread:0}:Ct)))},[F,Ne]);const{sendMessage:Je}=useChat(),st=React.useCallback(dt=>{Je(`We have been talking with another Randmar partner and would like you to have the conversation as context for follow-up questions. Please acknowledge your reception of this chat history (one line summary of recent messages will do) and let me know that you're ready to answer questions: ${JSON.stringify(dt,null,2)}`)},[Je]),et=React.useCallback(async()=>{if(F)try{te(!0);const dt=await R({applicationId:e}),It=F[0]===e?F[1]:F[0],Mt=await q({routeApplicationId:e,partnerId:It,withSpecification:!0}),Ct=buildPartnershipAssistantPrompt(dt.data,Mt.data);Ct?Je(Ct):We({title:"Missing data",description:"We couldn't load enough data to analyze this partnership yet. Please try again shortly.",variant:"destructive"})}catch(dt){console.error("Error preparing partnership analysis:",dt),We({title:"Error",description:"Could not analyze the partnership. Please try again later.",variant:"destructive"})}finally{te(!1)}},[F,R,q,Je,We,e]);React.useEffect(()=>{o(Ne.some(dt=>dt.unread>0))},[Ne,o]);const at=(dt,It)=>{It=It.replace(/\n/g,`
1160
1160
  `),console.log("doSend",It),console.log("target",dt);const Mt={id:crypto.randomUUID(),senderName:(lt==null?void 0:lt.Name)??(lt==null?void 0:lt.EmailAddress)??"User",fromPartnerID:e,toPartnerID:dt.partner1===e?dt.partner2:dt.partner1,content:It,timestamp:Date.now()};nt(Mt),$e.invoke("NewMessage",Mt).catch(Ct=>console.error("Error sending message:",Ct)),ae(""),He.current&&(He.current.value="")},tt=()=>{const dt=ne.trim();!Rt||!dt||!F||!$e||(Rt.unread>0&&(Xe(),oe(It=>It.map(Mt=>Mt.partner1===F[0]&&Mt.partner2===F[1]?{...Mt,unread:0}:Mt))),at(Rt,dt))},ot=(dt,It)=>Oe([dt,It]);React.useEffect(()=>{if(se===null)return;const dt=Ne.find(Mt=>Mt.conversationID===se[0]);if(!dt||(V([dt.partner1,dt.partner2]),!$e))return;const It=se[1];Oe(null),It&&at(dt,It)},[se,Ne,V,$e]);const{data:lt,isLoading:Ge}=useGetV4UserQuery();if(!f||Ge)return jsxRuntime.jsx(LoaderCircle,{className:"h-12 w-12 animate-spin mx-auto mb-4"});if(!(lt!=null&&lt.Name))return jsxRuntime.jsx(UserSetupForm,{appID:(lt==null?void 0:lt.ApplicationId)??""});const $t=async()=>{var dt,It,Mt,Ct,Ke;S.current&&(S.current.disabled=!0),A(!0);try{const Ye=await R({applicationId:e}),Ze=((dt=Ye.data)==null?void 0:dt.About)??"a new business venture",ct=[];(It=Ye.data)!=null&&It.IsManufacturer&&ct.push("Manufacturer"),(Mt=Ye.data)!=null&&Mt.IsReseller&&ct.push("Reseller"),(Ct=Ye.data)!=null&&Ct.IsSalesAgency&&ct.push("Sales Agency");const ft=`
1161
1161
  Your task is to draft a ready-to-send opening message from a user to the Randmar team.
@@ -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
@@ -1221,13 +1221,13 @@ $10 with opportunities under $1,000`:e==="D"?"$15 under $1,500":e==="E"?"Full sh
1221
1221
  ---
1222
1222
  ${qe}`:je;try{await V({applicationId:e,comment:Ve,emailAddress:Be||void 0}).unwrap(),F({title:"Feedback sent",description:"Thanks for helping us improve."}),_(!1),R(""),E(""),M(!1),j(null)}catch(Le){console.error("Failed to send feedback",Le),F({title:"Feedback could not be sent",description:"Please try again in a moment.",variant:"destructive"})}};return jsxRuntime.jsxs("header",{className:"flex h-16 items-center gap-4 border-b sidebar-foreground bg-sidebar px-6 fixed top-0 right-0 z-50 lg:left-64 left-0 border-sidebar-border",children:[jsxRuntime.jsx(SidebarTrigger,{className:"lg:hidden",children:jsxRuntime.jsx(Menu$1,{className:"h-6 w-6"})}),jsxRuntime.jsx("div",{className:"flex flex-1 items-center gap-4",children:jsxRuntime.jsx("div",{className:"relative w-full max-w-sm",children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("button",{type:"button",className:"absolute left-2 top-1/2 -translate-y-1/2",onClick:Oe,"aria-label":"Search",children:jsxRuntime.jsx(Search,{className:"h-4 w-4 text-muted-foreground"})}),jsxRuntime.jsx(Input,{placeholder:l??"Search...",className:"w-full pl-8 bg-white text-black",value:f,onChange:Ae=>g(Ae.target.value),onKeyDown:Ne,ref:d},"topbar-search")]})})}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsxs(Dialog,{open:b,onOpenChange:_,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{type:"button",variant:"outline",size:"sm",className:"gap-2",children:[jsxRuntime.jsx(MessageSquare,{className:"h-4 w-4"}),"Feedback"]})}),jsxRuntime.jsx(DialogContent,{className:"w-[min(95vw,980px)] max-w-4xl overflow-hidden border border-border/40 bg-background p-0 shadow-[0_35px_120px_rgba(15,23,42,0.45)]",children:jsxRuntime.jsxs("form",{className:"flex max-h-[85vh] flex-col gap-6 overflow-y-auto bg-background p-6 sm:p-8",onSubmit:oe,children:[jsxRuntime.jsxs("div",{className:"relative overflow-hidden rounded-[32px] bg-gradient-to-br from-slate-950 via-slate-900 to-indigo-950 p-6 text-white shadow-[0_20px_45px_rgba(15,23,42,0.55)] sm:p-8",children:[jsxRuntime.jsxs("div",{className:"pointer-events-none absolute inset-0 opacity-70",children:[jsxRuntime.jsx("div",{className:"absolute -left-14 top-10 h-32 w-32 rounded-full bg-white/10 blur-3xl","aria-hidden":"true"}),jsxRuntime.jsx("div",{className:"absolute right-0 top-1/2 h-40 w-40 -translate-y-1/2 rounded-full bg-indigo-400/20 blur-3xl","aria-hidden":"true"}),jsxRuntime.jsx("div",{className:"absolute bottom-0 left-1/3 h-44 w-44 translate-y-1/3 rounded-full bg-sky-300/20 blur-3xl","aria-hidden":"true"})]}),jsxRuntime.jsxs("div",{className:"relative flex flex-col gap-5",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 text-xs uppercase tracking-wide text-white/80",children:[jsxRuntime.jsx(Badge,{variant:"outline",className:"w-max border-white/30 bg-white/10 text-white",children:"Partner feedback desk"}),jsxRuntime.jsx("p",{className:"text-white/70",children:"Product & operations review every submission"})]}),jsxRuntime.jsxs(DialogHeader,{className:"space-y-3 text-left text-white",children:[jsxRuntime.jsx(DialogTitle,{className:"text-3xl leading-tight sm:text-4xl",children:"Share your perspective"}),jsxRuntime.jsx(DialogDescription,{className:"text-base text-white/80",children:"Clear context helps us triage, scope, and respond. Please highlight the scenario, desired outcome, and any urgency we should be aware of."})]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{className:"space-y-2 rounded-2xl border bg-muted/60 p-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs text-muted-foreground",children:[jsxRuntime.jsx("p",{className:"font-semibold uppercase tracking-wide text-foreground",children:"Select an intent"}),jsxRuntime.jsx("p",{children:I?`Currently tagged as ${se}.`:"Choosing a category routes the note to the right team."})]}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:FEEDBACK_INTENT_OPTIONS.map(Ae=>jsxRuntime.jsx(Button$1,{type:"button",variant:I===Ae.value?"default":"outline",size:"sm",className:cn("rounded-full px-3 text-xs transition-all",I===Ae.value?"shadow-lg shadow-primary/30":"bg-background hover:-translate-y-[1px]"),"aria-pressed":I===Ae.value,onClick:()=>j(je=>je===Ae.value?null:Ae.value),children:Ae.label},Ae.value))}),I&&jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:($e=FEEDBACK_INTENT_OPTIONS.find(Ae=>Ae.value===I))==null?void 0:$e.description})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"topbar-feedback-message",className:"text-sm font-semibold",children:"What should we know?"}),jsxRuntime.jsx(Textarea,{id:"topbar-feedback-message",rows:4,value:S,onChange:Ae=>R(Ae.target.value),maxLength:FEEDBACK_MAX_LENGTH,placeholder:"Describe the situation, expected outcome, and any supporting context.",className:"resize-none rounded-2xl border-2 border-dashed border-muted/80 bg-gradient-to-br from-muted/40 to-background focus-visible:border-primary focus-visible:ring-primary/40"}),jsxRuntime.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[jsxRuntime.jsx("span",{children:ae?`${ae}/${FEEDBACK_MAX_LENGTH} characters`:"Up to 800 characters is plenty."}),jsxRuntime.jsx("span",{children:I?`Intent: ${se}`:"Include context, impact, and urgency if applicable."})]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-3 rounded-2xl border bg-background p-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs(Label$2,{htmlFor:"topbar-feedback-email",className:"flex items-center gap-2 text-sm font-semibold",children:[jsxRuntime.jsx(Mail,{className:"h-4 w-4"}),"Request a follow-up"]}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Include an email if you'd like us to provide updates or clarify details."})]}),jsxRuntime.jsx(Switch,{id:"feedback-follow-up",checked:A,onCheckedChange:Ae=>M(!!Ae),"aria-label":"Toggle follow-up preference"})]}),A&&jsxRuntime.jsx(Input,{id:"topbar-feedback-email",type:"email",value:C,onChange:Ae=>E(Ae.target.value),placeholder:"you@example.com"}),jsxRuntime.jsxs("div",{className:"rounded-xl bg-muted px-3 py-2 text-[11px] text-muted-foreground",children:["We use this email solely for this conversation. The page URL you were on (",q,") is attached automatically for added context."]})]}),jsxRuntime.jsx(Separator$1,{}),jsxRuntime.jsxs(DialogFooter,{className:"gap-3",children:[jsxRuntime.jsx(Button$1,{type:"button",variant:"outline",onClick:()=>_(!1),disabled:ne,children:"Cancel"}),jsxRuntime.jsx(Button$1,{type:"submit",disabled:ne,children:ne?"Sending...":"Send Feedback"})]})]})})]}),o,t&&jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs(Button$1,{variant:"ghost",size:"icon",className:"h-9 w-9",onClick:t,children:[jsxRuntime.jsx(LogOut,{className:"h-4 w-4 text-sidebar-foreground"}),jsxRuntime.jsx("span",{className:"sr-only",children:"Sign out"})]})})]})]})});Topbar.displayName="Topbar";function ActiveOrdersCard({orders:e,loading:t=!1}){const n=React.useMemo(()=>{if(!e||e.length===0)return{all:{orders:0,amount:0},processing:{orders:0,amount:0},shipped:{orders:0,amount:0},delayed:{orders:0,amount:0}};const l=e.filter(I=>I.DocumentType==="Order"),d=e.filter(I=>I.DocumentType==="Shipment"),f=l.filter(I=>I.WarehouseCode!=="3PLE"),g=f.reduce((I,j)=>I+(j.Quantity||0),0),b=f.reduce((I,j)=>I+(j.ExtendedPrice||0),0),_=l.filter(I=>I.WarehouseCode==="3PLE"),S=_.reduce((I,j)=>I+(j.Quantity||0),0),R=_.reduce((I,j)=>I+(j.ExtendedPrice||0),0),C=d.length,E=d.reduce((I,j)=>I+(j.ExtendedPrice||0),0),A=g+S+C,M=b+R+E;return{all:{orders:A,amount:M},processing:{orders:g,amount:b},shipped:{orders:C,amount:E},delayed:{orders:S,amount:R}}},[e]),o=[{name:"All",icon:Package,color:"bg-blue-500",textColor:"text-blue-600",orders:n.all.orders,amount:n.all.amount},{name:"Processing",icon:RefreshCcw,color:"bg-yellow-500",textColor:"text-yellow-600",orders:n.processing.orders,amount:n.processing.amount},{name:"Shipped",icon:Truck,color:"bg-green-500",textColor:"text-green-600",orders:n.shipped.orders,amount:n.shipped.amount},{name:"Delayed",icon:CircleAlert,color:"bg-red-500",textColor:"text-red-600",orders:n.delayed.orders,amount:n.delayed.amount}];return t?jsxRuntime.jsxs(Card,{className:"@container",children:[jsxRuntime.jsx(CardHeader,{className:"pb-0",children:jsxRuntime.jsx(CardTitle,{className:"text-lg font-bold",children:"Active Orders"})}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-4 p-4",children:[1,2,3,4].map(l=>jsxRuntime.jsxs("div",{className:"overflow-hidden rounded-md border",children:[jsxRuntime.jsx("div",{className:"bg-slate-200 dark:bg-slate-700 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-16 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-7 w-12"})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-16 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]})]})]},l))})]}):jsxRuntime.jsxs(Card,{className:"@container",children:[jsxRuntime.jsx(CardHeader,{className:"pb-0",children:jsxRuntime.jsx(CardTitle,{className:"text-lg font-bold",children:"Active Orders"})}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-4 p-4",children:o.map(l=>jsxRuntime.jsxs("div",{className:"overflow-hidden rounded-md border",children:[jsxRuntime.jsx("div",{className:`${l.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:l.name}),jsxRuntime.jsx("div",{className:`${l.color} bg-opacity-90 p-2 rounded-full`,children:jsxRuntime.jsx(l.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:l.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:formatMoney(l.amount)})]})]})]})]},l.name))})]})}var __create=Object.create,__getProtoOf=Object.getPrototypeOf,__defProp=Object.defineProperty,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__toESM=(e,t,n)=>{n=e!=null?__create(__getProtoOf(e)):{};const o=__defProp(n,"default",{value:e,enumerable:!0});for(let l of __getOwnPropNames(e))__hasOwnProp.call(o,l)||__defProp(o,l,{get:()=>e[l],enumerable:!0});return o},__commonJS=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),require_xhtml=__commonJS((e,t)=>{t.exports={quot:'"',amp:"&",apos:"'",lt:"<",gt:">",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",frasl:"⁄",euro:"€",image:"ℑ",weierp:"℘",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦"}}),require_acorn=__commonJS((e,t)=>{(function(n,o){typeof e=="object"&&typeof t<"u"?o(e):typeof define=="function"&&define.amd?define(["exports"],o):(n=typeof globalThis<"u"?globalThis:n||self,o(n.acorn={}))})(e,function(n){var o=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,370,1,81,2,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,10,1,2,0,49,6,4,4,14,9,5351,0,7,14,13835,9,87,9,39,4,60,6,26,9,1014,0,2,54,8,3,82,0,12,1,19628,1,4706,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,983,6,110,6,6,9,4759,9,787719,239],l=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,68,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,349,41,7,1,79,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,4026,582,8634,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,689,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,43,8,8936,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,757,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4153,7,221,3,5761,15,7472,16,621,2467,541,1507,4938,6,4191],d="‌‍·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛࢘-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᫎᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‌‍‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・",f="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢎࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೝೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲈᲐ-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꟊꟐꟑꟓꟕ-ꟙꟲ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",g={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},b="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",_={5:b,"5module":b+" export import",6:b+" const class extends export import super"},S=/^in(stanceof)?$/,R=new RegExp("["+f+"]"),C=new RegExp("["+f+d+"]");function E(z,ge){for(var Fe=65536,Ue=0;Ue<ge.length;Ue+=2){if(Fe+=ge[Ue],Fe>z)return!1;if(Fe+=ge[Ue+1],Fe>=z)return!0}return!1}function A(z,ge){return z<65?z===36:z<91?!0:z<97?z===95:z<123?!0:z<=65535?z>=170&&R.test(String.fromCharCode(z)):ge===!1?!1:E(z,l)}function M(z,ge){return z<48?z===36:z<58?!0:z<65?!1:z<91?!0:z<97?z===95:z<123?!0:z<=65535?z>=170&&C.test(String.fromCharCode(z)):ge===!1?!1:E(z,l)||E(z,o)}var I=function(ge,Fe){Fe===void 0&&(Fe={}),this.label=ge,this.keyword=Fe.keyword,this.beforeExpr=!!Fe.beforeExpr,this.startsExpr=!!Fe.startsExpr,this.isLoop=!!Fe.isLoop,this.isAssign=!!Fe.isAssign,this.prefix=!!Fe.prefix,this.postfix=!!Fe.postfix,this.binop=Fe.binop||null,this.updateContext=null};function j(z,ge){return new I(z,{beforeExpr:!0,binop:ge})}var q={beforeExpr:!0},Q={startsExpr:!0},te={};function F(z,ge){return ge===void 0&&(ge={}),ge.keyword=z,te[z]=new I(z,ge)}var V={num:new I("num",Q),regexp:new I("regexp",Q),string:new I("string",Q),name:new I("name",Q),privateId:new I("privateId",Q),eof:new I("eof"),bracketL:new I("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new I("]"),braceL:new I("{",{beforeExpr:!0,startsExpr:!0}),braceR:new I("}"),parenL:new I("(",{beforeExpr:!0,startsExpr:!0}),parenR:new I(")"),comma:new I(",",q),semi:new I(";",q),colon:new I(":",q),dot:new I("."),question:new I("?",q),questionDot:new I("?."),arrow:new I("=>",q),template:new I("template"),invalidTemplate:new I("invalidTemplate"),ellipsis:new I("...",q),backQuote:new I("`",Q),dollarBraceL:new I("${",{beforeExpr:!0,startsExpr:!0}),eq:new I("=",{beforeExpr:!0,isAssign:!0}),assign:new I("_=",{beforeExpr:!0,isAssign:!0}),incDec:new I("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new I("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:j("||",1),logicalAND:j("&&",2),bitwiseOR:j("|",3),bitwiseXOR:j("^",4),bitwiseAND:j("&",5),equality:j("==/!=/===/!==",6),relational:j("</>/<=/>=",7),bitShift:j("<</>>/>>>",8),plusMin:new I("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:j("%",10),star:j("*",10),slash:j("/",10),starstar:new I("**",{beforeExpr:!0}),coalesce:j("??",1),_break:F("break"),_case:F("case",q),_catch:F("catch"),_continue:F("continue"),_debugger:F("debugger"),_default:F("default",q),_do:F("do",{isLoop:!0,beforeExpr:!0}),_else:F("else",q),_finally:F("finally"),_for:F("for",{isLoop:!0}),_function:F("function",Q),_if:F("if"),_return:F("return",q),_switch:F("switch"),_throw:F("throw",q),_try:F("try"),_var:F("var"),_const:F("const"),_while:F("while",{isLoop:!0}),_with:F("with"),_new:F("new",{beforeExpr:!0,startsExpr:!0}),_this:F("this",Q),_super:F("super",Q),_class:F("class",Q),_extends:F("extends",q),_export:F("export"),_import:F("import",Q),_null:F("null",Q),_true:F("true",Q),_false:F("false",Q),_in:F("in",{beforeExpr:!0,binop:7}),_instanceof:F("instanceof",{beforeExpr:!0,binop:7}),_typeof:F("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:F("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:F("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},ne=/\r\n?|\n|\u2028|\u2029/,ae=new RegExp(ne.source,"g");function se(z){return z===10||z===13||z===8232||z===8233}function Oe(z,ge,Fe){Fe===void 0&&(Fe=z.length);for(var Ue=ge;Ue<Fe;Ue++){var Qe=z.charCodeAt(Ue);if(se(Qe))return Ue<Fe-1&&Qe===13&&z.charCodeAt(Ue+1)===10?Ue+2:Ue+1}return-1}var Ne=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,oe=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,$e=Object.prototype,Ae=$e.hasOwnProperty,je=$e.toString,Be=Object.hasOwn||function(z,ge){return Ae.call(z,ge)},qe=Array.isArray||function(z){return je.call(z)==="[object Array]"},Ve=Object.create(null);function Le(z){return Ve[z]||(Ve[z]=new RegExp("^(?:"+z.replace(/ /g,"|")+")$"))}function He(z){return z<=65535?String.fromCharCode(z):(z-=65536,String.fromCharCode((z>>10)+55296,(z&1023)+56320))}var We=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,ze=function(ge,Fe){this.line=ge,this.column=Fe};ze.prototype.offset=function(ge){return new ze(this.line,this.column+ge)};var Xe=function(ge,Fe,Ue){this.start=Fe,this.end=Ue,ge.sourceFile!==null&&(this.source=ge.sourceFile)};function nt(z,ge){for(var Fe=1,Ue=0;;){var Qe=Oe(z,Ue,ge);if(Qe<0)return new ze(Fe,ge-Ue);++Fe,Ue=Qe}}var Je={ecmaVersion:null,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},st=!1;function et(z){var ge={};for(var Fe in Je)ge[Fe]=z&&Be(z,Fe)?z[Fe]:Je[Fe];if(ge.ecmaVersion==="latest"?ge.ecmaVersion=1e8:ge.ecmaVersion==null?(!st&&typeof console=="object"&&console.warn&&(st=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
1223
1223
  Defaulting to 2020, but this will stop working in the future.`)),ge.ecmaVersion=11):ge.ecmaVersion>=2015&&(ge.ecmaVersion-=2009),ge.allowReserved==null&&(ge.allowReserved=ge.ecmaVersion<5),(!z||z.allowHashBang==null)&&(ge.allowHashBang=ge.ecmaVersion>=14),qe(ge.onToken)){var Ue=ge.onToken;ge.onToken=function(Qe){return Ue.push(Qe)}}return qe(ge.onComment)&&(ge.onComment=at(ge,ge.onComment)),ge}function at(z,ge){return function(Fe,Ue,Qe,ut,pt,Vt){var Ft={type:Fe?"Block":"Line",value:Ue,start:Qe,end:ut};z.locations&&(Ft.loc=new Xe(this,pt,Vt)),z.ranges&&(Ft.range=[Qe,ut]),ge.push(Ft)}}var tt=1,ot=2,lt=4,Ge=8,$t=16,rt=32,Rt=64,dt=128,It=256,Mt=tt|ot|It;function Ct(z,ge){return ot|(z?lt:0)|(ge?Ge:0)}var Ke=0,Ye=1,Ze=2,ct=3,mt=4,ft=5,yt=function(ge,Fe,Ue){this.options=ge=et(ge),this.sourceFile=ge.sourceFile,this.keywords=Le(_[ge.ecmaVersion>=6?6:ge.sourceType==="module"?"5module":5]);var Qe="";ge.allowReserved!==!0&&(Qe=g[ge.ecmaVersion>=6?6:ge.ecmaVersion===5?5:3],ge.sourceType==="module"&&(Qe+=" await")),this.reservedWords=Le(Qe);var ut=(Qe?Qe+" ":"")+g.strict;this.reservedWordsStrict=Le(ut),this.reservedWordsStrictBind=Le(ut+" "+g.strictBind),this.input=String(Fe),this.containsEsc=!1,Ue?(this.pos=Ue,this.lineStart=this.input.lastIndexOf(`
1224
- `,Ue-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(ne).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=V.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=ge.sourceType==="module",this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&ge.allowHashBang&&this.input.slice(0,2)==="#!"&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(tt),this.regexpState=null,this.privateNameStack=[]},Ht={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},inClassStaticBlock:{configurable:!0}};yt.prototype.parse=function(){var ge=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(ge)},Ht.inFunction.get=function(){return(this.currentVarScope().flags&ot)>0},Ht.inGenerator.get=function(){return(this.currentVarScope().flags&Ge)>0&&!this.currentVarScope().inClassFieldInit},Ht.inAsync.get=function(){return(this.currentVarScope().flags&lt)>0&&!this.currentVarScope().inClassFieldInit},Ht.canAwait.get=function(){for(var z=this.scopeStack.length-1;z>=0;z--){var ge=this.scopeStack[z];if(ge.inClassFieldInit||ge.flags&It)return!1;if(ge.flags&ot)return(ge.flags&lt)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction},Ht.allowSuper.get=function(){var z=this.currentThisScope(),ge=z.flags,Fe=z.inClassFieldInit;return(ge&Rt)>0||Fe||this.options.allowSuperOutsideMethod},Ht.allowDirectSuper.get=function(){return(this.currentThisScope().flags&dt)>0},Ht.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},Ht.allowNewDotTarget.get=function(){var z=this.currentThisScope(),ge=z.flags,Fe=z.inClassFieldInit;return(ge&(ot|It))>0||Fe},Ht.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&It)>0},yt.extend=function(){for(var ge=[],Fe=arguments.length;Fe--;)ge[Fe]=arguments[Fe];for(var Ue=this,Qe=0;Qe<ge.length;Qe++)Ue=ge[Qe](Ue);return Ue},yt.parse=function(ge,Fe){return new this(Fe,ge).parse()},yt.parseExpressionAt=function(ge,Fe,Ue){var Qe=new this(Ue,ge,Fe);return Qe.nextToken(),Qe.parseExpression()},yt.tokenizer=function(ge,Fe){return new this(Fe,ge)},Object.defineProperties(yt.prototype,Ht);var Kt=yt.prototype,un=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;Kt.strictDirective=function(z){if(this.options.ecmaVersion<5)return!1;for(;;){oe.lastIndex=z,z+=oe.exec(this.input)[0].length;var ge=un.exec(this.input.slice(z));if(!ge)return!1;if((ge[1]||ge[2])==="use strict"){oe.lastIndex=z+ge[0].length;var Fe=oe.exec(this.input),Ue=Fe.index+Fe[0].length,Qe=this.input.charAt(Ue);return Qe===";"||Qe==="}"||ne.test(Fe[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(Qe)||Qe==="!"&&this.input.charAt(Ue+1)==="=")}z+=ge[0].length,oe.lastIndex=z,z+=oe.exec(this.input)[0].length,this.input[z]===";"&&z++}},Kt.eat=function(z){return this.type===z?(this.next(),!0):!1},Kt.isContextual=function(z){return this.type===V.name&&this.value===z&&!this.containsEsc},Kt.eatContextual=function(z){return this.isContextual(z)?(this.next(),!0):!1},Kt.expectContextual=function(z){this.eatContextual(z)||this.unexpected()},Kt.canInsertSemicolon=function(){return this.type===V.eof||this.type===V.braceR||ne.test(this.input.slice(this.lastTokEnd,this.start))},Kt.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},Kt.semicolon=function(){!this.eat(V.semi)&&!this.insertSemicolon()&&this.unexpected()},Kt.afterTrailingComma=function(z,ge){if(this.type===z)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),ge||this.next(),!0},Kt.expect=function(z){this.eat(z)||this.unexpected()},Kt.unexpected=function(z){this.raise(z??this.start,"Unexpected token")};var hn=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};Kt.checkPatternErrors=function(z,ge){if(z){z.trailingComma>-1&&this.raiseRecoverable(z.trailingComma,"Comma is not permitted after the rest element");var Fe=ge?z.parenthesizedAssign:z.parenthesizedBind;Fe>-1&&this.raiseRecoverable(Fe,ge?"Assigning to rvalue":"Parenthesized pattern")}},Kt.checkExpressionErrors=function(z,ge){if(!z)return!1;var Fe=z.shorthandAssign,Ue=z.doubleProto;if(!ge)return Fe>=0||Ue>=0;Fe>=0&&this.raise(Fe,"Shorthand property assignments are valid only in destructuring patterns"),Ue>=0&&this.raiseRecoverable(Ue,"Redefinition of __proto__ property")},Kt.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos)&&this.raise(this.yieldPos,"Yield expression cannot be a default value"),this.awaitPos&&this.raise(this.awaitPos,"Await expression cannot be a default value")},Kt.isSimpleAssignTarget=function(z){return z.type==="ParenthesizedExpression"?this.isSimpleAssignTarget(z.expression):z.type==="Identifier"||z.type==="MemberExpression"};var qt=yt.prototype;qt.parseTopLevel=function(z){var ge=Object.create(null);for(z.body||(z.body=[]);this.type!==V.eof;){var Fe=this.parseStatement(null,!0,ge);z.body.push(Fe)}if(this.inModule)for(var Ue=0,Qe=Object.keys(this.undefinedExports);Ue<Qe.length;Ue+=1){var ut=Qe[Ue];this.raiseRecoverable(this.undefinedExports[ut].start,"Export '"+ut+"' is not defined")}return this.adaptDirectivePrologue(z.body),this.next(),z.sourceType=this.options.sourceType,this.finishNode(z,"Program")};var An={kind:"loop"},xn={kind:"switch"};qt.isLet=function(z){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;oe.lastIndex=this.pos;var ge=oe.exec(this.input),Fe=this.pos+ge[0].length,Ue=this.input.charCodeAt(Fe);if(Ue===91||Ue===92)return!0;if(z)return!1;if(Ue===123||Ue>55295&&Ue<56320)return!0;if(A(Ue,!0)){for(var Qe=Fe+1;M(Ue=this.input.charCodeAt(Qe),!0);)++Qe;if(Ue===92||Ue>55295&&Ue<56320)return!0;var ut=this.input.slice(Fe,Qe);if(!S.test(ut))return!0}return!1},qt.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;oe.lastIndex=this.pos;var z=oe.exec(this.input),ge=this.pos+z[0].length,Fe;return!ne.test(this.input.slice(this.pos,ge))&&this.input.slice(ge,ge+8)==="function"&&(ge+8===this.input.length||!(M(Fe=this.input.charCodeAt(ge+8))||Fe>55295&&Fe<56320))},qt.parseStatement=function(z,ge,Fe){var Ue=this.type,Qe=this.startNode(),ut;switch(this.isLet(z)&&(Ue=V._var,ut="let"),Ue){case V._break:case V._continue:return this.parseBreakContinueStatement(Qe,Ue.keyword);case V._debugger:return this.parseDebuggerStatement(Qe);case V._do:return this.parseDoStatement(Qe);case V._for:return this.parseForStatement(Qe);case V._function:return z&&(this.strict||z!=="if"&&z!=="label")&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(Qe,!1,!z);case V._class:return z&&this.unexpected(),this.parseClass(Qe,!0);case V._if:return this.parseIfStatement(Qe);case V._return:return this.parseReturnStatement(Qe);case V._switch:return this.parseSwitchStatement(Qe);case V._throw:return this.parseThrowStatement(Qe);case V._try:return this.parseTryStatement(Qe);case V._const:case V._var:return ut=ut||this.value,z&&ut!=="var"&&this.unexpected(),this.parseVarStatement(Qe,ut);case V._while:return this.parseWhileStatement(Qe);case V._with:return this.parseWithStatement(Qe);case V.braceL:return this.parseBlock(!0,Qe);case V.semi:return this.parseEmptyStatement(Qe);case V._export:case V._import:if(this.options.ecmaVersion>10&&Ue===V._import){oe.lastIndex=this.pos;var pt=oe.exec(this.input),Vt=this.pos+pt[0].length,Ft=this.input.charCodeAt(Vt);if(Ft===40||Ft===46)return this.parseExpressionStatement(Qe,this.parseExpression())}return this.options.allowImportExportEverywhere||(ge||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),Ue===V._import?this.parseImport(Qe):this.parseExport(Qe,Fe);default:if(this.isAsyncFunction())return z&&this.unexpected(),this.next(),this.parseFunctionStatement(Qe,!0,!z);var nn=this.value,Qt=this.parseExpression();return Ue===V.name&&Qt.type==="Identifier"&&this.eat(V.colon)?this.parseLabeledStatement(Qe,nn,Qt,z):this.parseExpressionStatement(Qe,Qt)}},qt.parseBreakContinueStatement=function(z,ge){var Fe=ge==="break";this.next(),this.eat(V.semi)||this.insertSemicolon()?z.label=null:this.type!==V.name?this.unexpected():(z.label=this.parseIdent(),this.semicolon());for(var Ue=0;Ue<this.labels.length;++Ue){var Qe=this.labels[Ue];if((z.label==null||Qe.name===z.label.name)&&(Qe.kind!=null&&(Fe||Qe.kind==="loop")||z.label&&Fe))break}return Ue===this.labels.length&&this.raise(z.start,"Unsyntactic "+ge),this.finishNode(z,Fe?"BreakStatement":"ContinueStatement")},qt.parseDebuggerStatement=function(z){return this.next(),this.semicolon(),this.finishNode(z,"DebuggerStatement")},qt.parseDoStatement=function(z){return this.next(),this.labels.push(An),z.body=this.parseStatement("do"),this.labels.pop(),this.expect(V._while),z.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(V.semi):this.semicolon(),this.finishNode(z,"DoWhileStatement")},qt.parseForStatement=function(z){this.next();var ge=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(An),this.enterScope(0),this.expect(V.parenL),this.type===V.semi)return ge>-1&&this.unexpected(ge),this.parseFor(z,null);var Fe=this.isLet();if(this.type===V._var||this.type===V._const||Fe){var Ue=this.startNode(),Qe=Fe?"let":this.value;return this.next(),this.parseVar(Ue,!0,Qe),this.finishNode(Ue,"VariableDeclaration"),(this.type===V._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&Ue.declarations.length===1?(this.options.ecmaVersion>=9&&(this.type===V._in?ge>-1&&this.unexpected(ge):z.await=ge>-1),this.parseForIn(z,Ue)):(ge>-1&&this.unexpected(ge),this.parseFor(z,Ue))}var ut=this.isContextual("let"),pt=!1,Vt=this.containsEsc,Ft=new hn,nn=this.start,Qt=ge>-1?this.parseExprSubscripts(Ft,"await"):this.parseExpression(!0,Ft);return this.type===V._in||(pt=this.options.ecmaVersion>=6&&this.isContextual("of"))?(ge>-1?(this.type===V._in&&this.unexpected(ge),z.await=!0):pt&&this.options.ecmaVersion>=8&&(Qt.start===nn&&!Vt&&Qt.type==="Identifier"&&Qt.name==="async"?this.unexpected():this.options.ecmaVersion>=9&&(z.await=!1)),ut&&pt&&this.raise(Qt.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(Qt,!1,Ft),this.checkLValPattern(Qt),this.parseForIn(z,Qt)):(this.checkExpressionErrors(Ft,!0),ge>-1&&this.unexpected(ge),this.parseFor(z,Qt))},qt.parseFunctionStatement=function(z,ge,Fe){return this.next(),this.parseFunction(z,vn|(Fe?0:Pn),!1,ge)},qt.parseIfStatement=function(z){return this.next(),z.test=this.parseParenExpression(),z.consequent=this.parseStatement("if"),z.alternate=this.eat(V._else)?this.parseStatement("if"):null,this.finishNode(z,"IfStatement")},qt.parseReturnStatement=function(z){return!this.inFunction&&!this.options.allowReturnOutsideFunction&&this.raise(this.start,"'return' outside of function"),this.next(),this.eat(V.semi)||this.insertSemicolon()?z.argument=null:(z.argument=this.parseExpression(),this.semicolon()),this.finishNode(z,"ReturnStatement")},qt.parseSwitchStatement=function(z){this.next(),z.discriminant=this.parseParenExpression(),z.cases=[],this.expect(V.braceL),this.labels.push(xn),this.enterScope(0);for(var ge,Fe=!1;this.type!==V.braceR;)if(this.type===V._case||this.type===V._default){var Ue=this.type===V._case;ge&&this.finishNode(ge,"SwitchCase"),z.cases.push(ge=this.startNode()),ge.consequent=[],this.next(),Ue?ge.test=this.parseExpression():(Fe&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),Fe=!0,ge.test=null),this.expect(V.colon)}else ge||this.unexpected(),ge.consequent.push(this.parseStatement(null));return this.exitScope(),ge&&this.finishNode(ge,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(z,"SwitchStatement")},qt.parseThrowStatement=function(z){return this.next(),ne.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),z.argument=this.parseExpression(),this.semicolon(),this.finishNode(z,"ThrowStatement")};var Rn=[];qt.parseCatchClauseParam=function(){var z=this.parseBindingAtom(),ge=z.type==="Identifier";return this.enterScope(ge?rt:0),this.checkLValPattern(z,ge?mt:Ze),this.expect(V.parenR),z},qt.parseTryStatement=function(z){if(this.next(),z.block=this.parseBlock(),z.handler=null,this.type===V._catch){var ge=this.startNode();this.next(),this.eat(V.parenL)?ge.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),ge.param=null,this.enterScope(0)),ge.body=this.parseBlock(!1),this.exitScope(),z.handler=this.finishNode(ge,"CatchClause")}return z.finalizer=this.eat(V._finally)?this.parseBlock():null,!z.handler&&!z.finalizer&&this.raise(z.start,"Missing catch or finally clause"),this.finishNode(z,"TryStatement")},qt.parseVarStatement=function(z,ge,Fe){return this.next(),this.parseVar(z,!1,ge,Fe),this.semicolon(),this.finishNode(z,"VariableDeclaration")},qt.parseWhileStatement=function(z){return this.next(),z.test=this.parseParenExpression(),this.labels.push(An),z.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(z,"WhileStatement")},qt.parseWithStatement=function(z){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),z.object=this.parseParenExpression(),z.body=this.parseStatement("with"),this.finishNode(z,"WithStatement")},qt.parseEmptyStatement=function(z){return this.next(),this.finishNode(z,"EmptyStatement")},qt.parseLabeledStatement=function(z,ge,Fe,Ue){for(var Qe=0,ut=this.labels;Qe<ut.length;Qe+=1){var pt=ut[Qe];pt.name===ge&&this.raise(Fe.start,"Label '"+ge+"' is already declared")}for(var Vt=this.type.isLoop?"loop":this.type===V._switch?"switch":null,Ft=this.labels.length-1;Ft>=0;Ft--){var nn=this.labels[Ft];if(nn.statementStart===z.start)nn.statementStart=this.start,nn.kind=Vt;else break}return this.labels.push({name:ge,kind:Vt,statementStart:this.start}),z.body=this.parseStatement(Ue?Ue.indexOf("label")===-1?Ue+"label":Ue:"label"),this.labels.pop(),z.label=Fe,this.finishNode(z,"LabeledStatement")},qt.parseExpressionStatement=function(z,ge){return z.expression=ge,this.semicolon(),this.finishNode(z,"ExpressionStatement")},qt.parseBlock=function(z,ge,Fe){for(z===void 0&&(z=!0),ge===void 0&&(ge=this.startNode()),ge.body=[],this.expect(V.braceL),z&&this.enterScope(0);this.type!==V.braceR;){var Ue=this.parseStatement(null);ge.body.push(Ue)}return Fe&&(this.strict=!1),this.next(),z&&this.exitScope(),this.finishNode(ge,"BlockStatement")},qt.parseFor=function(z,ge){return z.init=ge,this.expect(V.semi),z.test=this.type===V.semi?null:this.parseExpression(),this.expect(V.semi),z.update=this.type===V.parenR?null:this.parseExpression(),this.expect(V.parenR),z.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(z,"ForStatement")},qt.parseForIn=function(z,ge){var Fe=this.type===V._in;return this.next(),ge.type==="VariableDeclaration"&&ge.declarations[0].init!=null&&(!Fe||this.options.ecmaVersion<8||this.strict||ge.kind!=="var"||ge.declarations[0].id.type!=="Identifier")&&this.raise(ge.start,(Fe?"for-in":"for-of")+" loop variable declaration may not have an initializer"),z.left=ge,z.right=Fe?this.parseExpression():this.parseMaybeAssign(),this.expect(V.parenR),z.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(z,Fe?"ForInStatement":"ForOfStatement")},qt.parseVar=function(z,ge,Fe,Ue){for(z.declarations=[],z.kind=Fe;;){var Qe=this.startNode();if(this.parseVarId(Qe,Fe),this.eat(V.eq)?Qe.init=this.parseMaybeAssign(ge):!Ue&&Fe==="const"&&!(this.type===V._in||this.options.ecmaVersion>=6&&this.isContextual("of"))?this.unexpected():!Ue&&Qe.id.type!=="Identifier"&&!(ge&&(this.type===V._in||this.isContextual("of")))?this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):Qe.init=null,z.declarations.push(this.finishNode(Qe,"VariableDeclarator")),!this.eat(V.comma))break}return z},qt.parseVarId=function(z,ge){z.id=this.parseBindingAtom(),this.checkLValPattern(z.id,ge==="var"?Ye:Ze,!1)};var vn=1,Pn=2,Mn=4;qt.parseFunction=function(z,ge,Fe,Ue,Qe){this.initFunction(z),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!Ue)&&(this.type===V.star&&ge&Pn&&this.unexpected(),z.generator=this.eat(V.star)),this.options.ecmaVersion>=8&&(z.async=!!Ue),ge&vn&&(z.id=ge&Mn&&this.type!==V.name?null:this.parseIdent(),z.id&&!(ge&Pn)&&this.checkLValSimple(z.id,this.strict||z.generator||z.async?this.treatFunctionsAsVar?Ye:Ze:ct));var ut=this.yieldPos,pt=this.awaitPos,Vt=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Ct(z.async,z.generator)),ge&vn||(z.id=this.type===V.name?this.parseIdent():null),this.parseFunctionParams(z),this.parseFunctionBody(z,Fe,!1,Qe),this.yieldPos=ut,this.awaitPos=pt,this.awaitIdentPos=Vt,this.finishNode(z,ge&vn?"FunctionDeclaration":"FunctionExpression")},qt.parseFunctionParams=function(z){this.expect(V.parenL),z.params=this.parseBindingList(V.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},qt.parseClass=function(z,ge){this.next();var Fe=this.strict;this.strict=!0,this.parseClassId(z,ge),this.parseClassSuper(z);var Ue=this.enterClassBody(),Qe=this.startNode(),ut=!1;for(Qe.body=[],this.expect(V.braceL);this.type!==V.braceR;){var pt=this.parseClassElement(z.superClass!==null);pt&&(Qe.body.push(pt),pt.type==="MethodDefinition"&&pt.kind==="constructor"?(ut&&this.raiseRecoverable(pt.start,"Duplicate constructor in the same class"),ut=!0):pt.key&&pt.key.type==="PrivateIdentifier"&&$n(Ue,pt)&&this.raiseRecoverable(pt.key.start,"Identifier '#"+pt.key.name+"' has already been declared"))}return this.strict=Fe,this.next(),z.body=this.finishNode(Qe,"ClassBody"),this.exitClassBody(),this.finishNode(z,ge?"ClassDeclaration":"ClassExpression")},qt.parseClassElement=function(z){if(this.eat(V.semi))return null;var ge=this.options.ecmaVersion,Fe=this.startNode(),Ue="",Qe=!1,ut=!1,pt="method",Vt=!1;if(this.eatContextual("static")){if(ge>=13&&this.eat(V.braceL))return this.parseClassStaticBlock(Fe),Fe;this.isClassElementNameStart()||this.type===V.star?Vt=!0:Ue="static"}if(Fe.static=Vt,!Ue&&ge>=8&&this.eatContextual("async")&&((this.isClassElementNameStart()||this.type===V.star)&&!this.canInsertSemicolon()?ut=!0:Ue="async"),!Ue&&(ge>=9||!ut)&&this.eat(V.star)&&(Qe=!0),!Ue&&!ut&&!Qe){var Ft=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?pt=Ft:Ue=Ft)}if(Ue?(Fe.computed=!1,Fe.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),Fe.key.name=Ue,this.finishNode(Fe.key,"Identifier")):this.parseClassElementName(Fe),ge<13||this.type===V.parenL||pt!=="method"||Qe||ut){var nn=!Fe.static&&Vn(Fe,"constructor"),Qt=nn&&z;nn&&pt!=="method"&&this.raise(Fe.key.start,"Constructor can't have get/set modifier"),Fe.kind=nn?"constructor":pt,this.parseClassMethod(Fe,Qe,ut,Qt)}else this.parseClassField(Fe);return Fe},qt.isClassElementNameStart=function(){return this.type===V.name||this.type===V.privateId||this.type===V.num||this.type===V.string||this.type===V.bracketL||this.type.keyword},qt.parseClassElementName=function(z){this.type===V.privateId?(this.value==="constructor"&&this.raise(this.start,"Classes can't have an element named '#constructor'"),z.computed=!1,z.key=this.parsePrivateIdent()):this.parsePropertyName(z)},qt.parseClassMethod=function(z,ge,Fe,Ue){var Qe=z.key;z.kind==="constructor"?(ge&&this.raise(Qe.start,"Constructor can't be a generator"),Fe&&this.raise(Qe.start,"Constructor can't be an async method")):z.static&&Vn(z,"prototype")&&this.raise(Qe.start,"Classes may not have a static property named prototype");var ut=z.value=this.parseMethod(ge,Fe,Ue);return z.kind==="get"&&ut.params.length!==0&&this.raiseRecoverable(ut.start,"getter should have no params"),z.kind==="set"&&ut.params.length!==1&&this.raiseRecoverable(ut.start,"setter should have exactly one param"),z.kind==="set"&&ut.params[0].type==="RestElement"&&this.raiseRecoverable(ut.params[0].start,"Setter cannot use rest params"),this.finishNode(z,"MethodDefinition")},qt.parseClassField=function(z){if(Vn(z,"constructor")?this.raise(z.key.start,"Classes can't have a field named 'constructor'"):z.static&&Vn(z,"prototype")&&this.raise(z.key.start,"Classes can't have a static field named 'prototype'"),this.eat(V.eq)){var ge=this.currentThisScope(),Fe=ge.inClassFieldInit;ge.inClassFieldInit=!0,z.value=this.parseMaybeAssign(),ge.inClassFieldInit=Fe}else z.value=null;return this.semicolon(),this.finishNode(z,"PropertyDefinition")},qt.parseClassStaticBlock=function(z){z.body=[];var ge=this.labels;for(this.labels=[],this.enterScope(It|Rt);this.type!==V.braceR;){var Fe=this.parseStatement(null);z.body.push(Fe)}return this.next(),this.exitScope(),this.labels=ge,this.finishNode(z,"StaticBlock")},qt.parseClassId=function(z,ge){this.type===V.name?(z.id=this.parseIdent(),ge&&this.checkLValSimple(z.id,Ze,!1)):(ge===!0&&this.unexpected(),z.id=null)},qt.parseClassSuper=function(z){z.superClass=this.eat(V._extends)?this.parseExprSubscripts(null,!1):null},qt.enterClassBody=function(){var z={declared:Object.create(null),used:[]};return this.privateNameStack.push(z),z.declared},qt.exitClassBody=function(){var z=this.privateNameStack.pop(),ge=z.declared,Fe=z.used;if(this.options.checkPrivateFields)for(var Ue=this.privateNameStack.length,Qe=Ue===0?null:this.privateNameStack[Ue-1],ut=0;ut<Fe.length;++ut){var pt=Fe[ut];Be(ge,pt.name)||(Qe?Qe.used.push(pt):this.raiseRecoverable(pt.start,"Private field '#"+pt.name+"' must be declared in an enclosing class"))}};function $n(z,ge){var Fe=ge.key.name,Ue=z[Fe],Qe="true";return ge.type==="MethodDefinition"&&(ge.kind==="get"||ge.kind==="set")&&(Qe=(ge.static?"s":"i")+ge.kind),Ue==="iget"&&Qe==="iset"||Ue==="iset"&&Qe==="iget"||Ue==="sget"&&Qe==="sset"||Ue==="sset"&&Qe==="sget"?(z[Fe]="true",!1):Ue?!0:(z[Fe]=Qe,!1)}function Vn(z,ge){var Fe=z.computed,Ue=z.key;return!Fe&&(Ue.type==="Identifier"&&Ue.name===ge||Ue.type==="Literal"&&Ue.value===ge)}qt.parseExportAllDeclaration=function(z,ge){return this.options.ecmaVersion>=11&&(this.eatContextual("as")?(z.exported=this.parseModuleExportName(),this.checkExport(ge,z.exported,this.lastTokStart)):z.exported=null),this.expectContextual("from"),this.type!==V.string&&this.unexpected(),z.source=this.parseExprAtom(),this.semicolon(),this.finishNode(z,"ExportAllDeclaration")},qt.parseExport=function(z,ge){if(this.next(),this.eat(V.star))return this.parseExportAllDeclaration(z,ge);if(this.eat(V._default))return this.checkExport(ge,"default",this.lastTokStart),z.declaration=this.parseExportDefaultDeclaration(),this.finishNode(z,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())z.declaration=this.parseExportDeclaration(z),z.declaration.type==="VariableDeclaration"?this.checkVariableExport(ge,z.declaration.declarations):this.checkExport(ge,z.declaration.id,z.declaration.id.start),z.specifiers=[],z.source=null;else{if(z.declaration=null,z.specifiers=this.parseExportSpecifiers(ge),this.eatContextual("from"))this.type!==V.string&&this.unexpected(),z.source=this.parseExprAtom();else{for(var Fe=0,Ue=z.specifiers;Fe<Ue.length;Fe+=1){var Qe=Ue[Fe];this.checkUnreserved(Qe.local),this.checkLocalExport(Qe.local),Qe.local.type==="Literal"&&this.raise(Qe.local.start,"A string literal cannot be used as an exported binding without `from`.")}z.source=null}this.semicolon()}return this.finishNode(z,"ExportNamedDeclaration")},qt.parseExportDeclaration=function(z){return this.parseStatement(null)},qt.parseExportDefaultDeclaration=function(){var z;if(this.type===V._function||(z=this.isAsyncFunction())){var ge=this.startNode();return this.next(),z&&this.next(),this.parseFunction(ge,vn|Mn,!1,z)}else if(this.type===V._class){var Fe=this.startNode();return this.parseClass(Fe,"nullableID")}else{var Ue=this.parseMaybeAssign();return this.semicolon(),Ue}},qt.checkExport=function(z,ge,Fe){z&&(typeof ge!="string"&&(ge=ge.type==="Identifier"?ge.name:ge.value),Be(z,ge)&&this.raiseRecoverable(Fe,"Duplicate export '"+ge+"'"),z[ge]=!0)},qt.checkPatternExport=function(z,ge){var Fe=ge.type;if(Fe==="Identifier")this.checkExport(z,ge,ge.start);else if(Fe==="ObjectPattern")for(var Ue=0,Qe=ge.properties;Ue<Qe.length;Ue+=1){var ut=Qe[Ue];this.checkPatternExport(z,ut)}else if(Fe==="ArrayPattern")for(var pt=0,Vt=ge.elements;pt<Vt.length;pt+=1){var Ft=Vt[pt];Ft&&this.checkPatternExport(z,Ft)}else Fe==="Property"?this.checkPatternExport(z,ge.value):Fe==="AssignmentPattern"?this.checkPatternExport(z,ge.left):Fe==="RestElement"&&this.checkPatternExport(z,ge.argument)},qt.checkVariableExport=function(z,ge){if(z)for(var Fe=0,Ue=ge;Fe<Ue.length;Fe+=1){var Qe=Ue[Fe];this.checkPatternExport(z,Qe.id)}},qt.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()},qt.parseExportSpecifier=function(z){var ge=this.startNode();return ge.local=this.parseModuleExportName(),ge.exported=this.eatContextual("as")?this.parseModuleExportName():ge.local,this.checkExport(z,ge.exported,ge.exported.start),this.finishNode(ge,"ExportSpecifier")},qt.parseExportSpecifiers=function(z){var ge=[],Fe=!0;for(this.expect(V.braceL);!this.eat(V.braceR);){if(Fe)Fe=!1;else if(this.expect(V.comma),this.afterTrailingComma(V.braceR))break;ge.push(this.parseExportSpecifier(z))}return ge},qt.parseImport=function(z){return this.next(),this.type===V.string?(z.specifiers=Rn,z.source=this.parseExprAtom()):(z.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),z.source=this.type===V.string?this.parseExprAtom():this.unexpected()),this.semicolon(),this.finishNode(z,"ImportDeclaration")},qt.parseImportSpecifier=function(){var z=this.startNode();return z.imported=this.parseModuleExportName(),this.eatContextual("as")?z.local=this.parseIdent():(this.checkUnreserved(z.imported),z.local=z.imported),this.checkLValSimple(z.local,Ze),this.finishNode(z,"ImportSpecifier")},qt.parseImportDefaultSpecifier=function(){var z=this.startNode();return z.local=this.parseIdent(),this.checkLValSimple(z.local,Ze),this.finishNode(z,"ImportDefaultSpecifier")},qt.parseImportNamespaceSpecifier=function(){var z=this.startNode();return this.next(),this.expectContextual("as"),z.local=this.parseIdent(),this.checkLValSimple(z.local,Ze),this.finishNode(z,"ImportNamespaceSpecifier")},qt.parseImportSpecifiers=function(){var z=[],ge=!0;if(this.type===V.name&&(z.push(this.parseImportDefaultSpecifier()),!this.eat(V.comma)))return z;if(this.type===V.star)return z.push(this.parseImportNamespaceSpecifier()),z;for(this.expect(V.braceL);!this.eat(V.braceR);){if(ge)ge=!1;else if(this.expect(V.comma),this.afterTrailingComma(V.braceR))break;z.push(this.parseImportSpecifier())}return z},qt.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===V.string){var z=this.parseLiteral(this.value);return We.test(z.value)&&this.raise(z.start,"An export name cannot include a lone surrogate."),z}return this.parseIdent(!0)},qt.adaptDirectivePrologue=function(z){for(var ge=0;ge<z.length&&this.isDirectiveCandidate(z[ge]);++ge)z[ge].directive=z[ge].expression.raw.slice(1,-1)},qt.isDirectiveCandidate=function(z){return this.options.ecmaVersion>=5&&z.type==="ExpressionStatement"&&z.expression.type==="Literal"&&typeof z.expression.value=="string"&&(this.input[z.start]==='"'||this.input[z.start]==="'")};var Jt=yt.prototype;Jt.toAssignable=function(z,ge,Fe){if(this.options.ecmaVersion>=6&&z)switch(z.type){case"Identifier":this.inAsync&&z.name==="await"&&this.raise(z.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":z.type="ObjectPattern",Fe&&this.checkPatternErrors(Fe,!0);for(var Ue=0,Qe=z.properties;Ue<Qe.length;Ue+=1){var ut=Qe[Ue];this.toAssignable(ut,ge),ut.type==="RestElement"&&(ut.argument.type==="ArrayPattern"||ut.argument.type==="ObjectPattern")&&this.raise(ut.argument.start,"Unexpected token")}break;case"Property":z.kind!=="init"&&this.raise(z.key.start,"Object pattern can't contain getter or setter"),this.toAssignable(z.value,ge);break;case"ArrayExpression":z.type="ArrayPattern",Fe&&this.checkPatternErrors(Fe,!0),this.toAssignableList(z.elements,ge);break;case"SpreadElement":z.type="RestElement",this.toAssignable(z.argument,ge),z.argument.type==="AssignmentPattern"&&this.raise(z.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":z.operator!=="="&&this.raise(z.left.end,"Only '=' operator can be used for specifying default value."),z.type="AssignmentPattern",delete z.operator,this.toAssignable(z.left,ge);break;case"ParenthesizedExpression":this.toAssignable(z.expression,ge,Fe);break;case"ChainExpression":this.raiseRecoverable(z.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!ge)break;default:this.raise(z.start,"Assigning to rvalue")}else Fe&&this.checkPatternErrors(Fe,!0);return z},Jt.toAssignableList=function(z,ge){for(var Fe=z.length,Ue=0;Ue<Fe;Ue++){var Qe=z[Ue];Qe&&this.toAssignable(Qe,ge)}if(Fe){var ut=z[Fe-1];this.options.ecmaVersion===6&&ge&&ut&&ut.type==="RestElement"&&ut.argument.type!=="Identifier"&&this.unexpected(ut.argument.start)}return z},Jt.parseSpread=function(z){var ge=this.startNode();return this.next(),ge.argument=this.parseMaybeAssign(!1,z),this.finishNode(ge,"SpreadElement")},Jt.parseRestBinding=function(){var z=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==V.name&&this.unexpected(),z.argument=this.parseBindingAtom(),this.finishNode(z,"RestElement")},Jt.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case V.bracketL:var z=this.startNode();return this.next(),z.elements=this.parseBindingList(V.bracketR,!0,!0),this.finishNode(z,"ArrayPattern");case V.braceL:return this.parseObj(!0)}return this.parseIdent()},Jt.parseBindingList=function(z,ge,Fe,Ue){for(var Qe=[],ut=!0;!this.eat(z);)if(ut?ut=!1:this.expect(V.comma),ge&&this.type===V.comma)Qe.push(null);else{if(Fe&&this.afterTrailingComma(z))break;if(this.type===V.ellipsis){var pt=this.parseRestBinding();this.parseBindingListItem(pt),Qe.push(pt),this.type===V.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(z);break}else Qe.push(this.parseAssignableListItem(Ue))}return Qe},Jt.parseAssignableListItem=function(z){var ge=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(ge),ge},Jt.parseBindingListItem=function(z){return z},Jt.parseMaybeDefault=function(z,ge,Fe){if(Fe=Fe||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(V.eq))return Fe;var Ue=this.startNodeAt(z,ge);return Ue.left=Fe,Ue.right=this.parseMaybeAssign(),this.finishNode(Ue,"AssignmentPattern")},Jt.checkLValSimple=function(z,ge,Fe){ge===void 0&&(ge=Ke);var Ue=ge!==Ke;switch(z.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(z.name)&&this.raiseRecoverable(z.start,(Ue?"Binding ":"Assigning to ")+z.name+" in strict mode"),Ue&&(ge===Ze&&z.name==="let"&&this.raiseRecoverable(z.start,"let is disallowed as a lexically bound name"),Fe&&(Be(Fe,z.name)&&this.raiseRecoverable(z.start,"Argument name clash"),Fe[z.name]=!0),ge!==ft&&this.declareName(z.name,ge,z.start));break;case"ChainExpression":this.raiseRecoverable(z.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":Ue&&this.raiseRecoverable(z.start,"Binding member expression");break;case"ParenthesizedExpression":return Ue&&this.raiseRecoverable(z.start,"Binding parenthesized expression"),this.checkLValSimple(z.expression,ge,Fe);default:this.raise(z.start,(Ue?"Binding":"Assigning to")+" rvalue")}},Jt.checkLValPattern=function(z,ge,Fe){switch(ge===void 0&&(ge=Ke),z.type){case"ObjectPattern":for(var Ue=0,Qe=z.properties;Ue<Qe.length;Ue+=1){var ut=Qe[Ue];this.checkLValInnerPattern(ut,ge,Fe)}break;case"ArrayPattern":for(var pt=0,Vt=z.elements;pt<Vt.length;pt+=1){var Ft=Vt[pt];Ft&&this.checkLValInnerPattern(Ft,ge,Fe)}break;default:this.checkLValSimple(z,ge,Fe)}},Jt.checkLValInnerPattern=function(z,ge,Fe){switch(ge===void 0&&(ge=Ke),z.type){case"Property":this.checkLValInnerPattern(z.value,ge,Fe);break;case"AssignmentPattern":this.checkLValPattern(z.left,ge,Fe);break;case"RestElement":this.checkLValPattern(z.argument,ge,Fe);break;default:this.checkLValPattern(z,ge,Fe)}};var Zt=function(ge,Fe,Ue,Qe,ut){this.token=ge,this.isExpr=!!Fe,this.preserveSpace=!!Ue,this.override=Qe,this.generator=!!ut},Ut={b_stat:new Zt("{",!1),b_expr:new Zt("{",!0),b_tmpl:new Zt("${",!1),p_stat:new Zt("(",!1),p_expr:new Zt("(",!0),q_tmpl:new Zt("`",!0,!0,function(z){return z.tryReadTemplateToken()}),f_stat:new Zt("function",!1),f_expr:new Zt("function",!0),f_expr_gen:new Zt("function",!0,!1,null,!0),f_gen:new Zt("function",!1,!1,null,!0)},tn=yt.prototype;tn.initialContext=function(){return[Ut.b_stat]},tn.curContext=function(){return this.context[this.context.length-1]},tn.braceIsBlock=function(z){var ge=this.curContext();return ge===Ut.f_expr||ge===Ut.f_stat?!0:z===V.colon&&(ge===Ut.b_stat||ge===Ut.b_expr)?!ge.isExpr:z===V._return||z===V.name&&this.exprAllowed?ne.test(this.input.slice(this.lastTokEnd,this.start)):z===V._else||z===V.semi||z===V.eof||z===V.parenR||z===V.arrow?!0:z===V.braceL?ge===Ut.b_stat:z===V._var||z===V._const||z===V.name?!1:!this.exprAllowed},tn.inGeneratorContext=function(){for(var z=this.context.length-1;z>=1;z--){var ge=this.context[z];if(ge.token==="function")return ge.generator}return!1},tn.updateContext=function(z){var ge,Fe=this.type;Fe.keyword&&z===V.dot?this.exprAllowed=!1:(ge=Fe.updateContext)?ge.call(this,z):this.exprAllowed=Fe.beforeExpr},tn.overrideContext=function(z){this.curContext()!==z&&(this.context[this.context.length-1]=z)},V.parenR.updateContext=V.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var z=this.context.pop();z===Ut.b_stat&&this.curContext().token==="function"&&(z=this.context.pop()),this.exprAllowed=!z.isExpr},V.braceL.updateContext=function(z){this.context.push(this.braceIsBlock(z)?Ut.b_stat:Ut.b_expr),this.exprAllowed=!0},V.dollarBraceL.updateContext=function(){this.context.push(Ut.b_tmpl),this.exprAllowed=!0},V.parenL.updateContext=function(z){var ge=z===V._if||z===V._for||z===V._with||z===V._while;this.context.push(ge?Ut.p_stat:Ut.p_expr),this.exprAllowed=!0},V.incDec.updateContext=function(){},V._function.updateContext=V._class.updateContext=function(z){z.beforeExpr&&z!==V._else&&!(z===V.semi&&this.curContext()!==Ut.p_stat)&&!(z===V._return&&ne.test(this.input.slice(this.lastTokEnd,this.start)))&&!((z===V.colon||z===V.braceL)&&this.curContext()===Ut.b_stat)?this.context.push(Ut.f_expr):this.context.push(Ut.f_stat),this.exprAllowed=!1},V.colon.updateContext=function(){this.curContext().token==="function"&&this.context.pop(),this.exprAllowed=!0},V.backQuote.updateContext=function(){this.curContext()===Ut.q_tmpl?this.context.pop():this.context.push(Ut.q_tmpl),this.exprAllowed=!1},V.star.updateContext=function(z){if(z===V._function){var ge=this.context.length-1;this.context[ge]===Ut.f_expr?this.context[ge]=Ut.f_expr_gen:this.context[ge]=Ut.f_gen}this.exprAllowed=!0},V.name.updateContext=function(z){var ge=!1;this.options.ecmaVersion>=6&&z!==V.dot&&(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())&&(ge=!0),this.exprAllowed=ge};var Yt=yt.prototype;Yt.checkPropClash=function(z,ge,Fe){if(!(this.options.ecmaVersion>=9&&z.type==="SpreadElement")&&!(this.options.ecmaVersion>=6&&(z.computed||z.method||z.shorthand))){var Ue=z.key,Qe;switch(Ue.type){case"Identifier":Qe=Ue.name;break;case"Literal":Qe=String(Ue.value);break;default:return}var ut=z.kind;if(this.options.ecmaVersion>=6){Qe==="__proto__"&&ut==="init"&&(ge.proto&&(Fe?Fe.doubleProto<0&&(Fe.doubleProto=Ue.start):this.raiseRecoverable(Ue.start,"Redefinition of __proto__ property")),ge.proto=!0);return}Qe="$"+Qe;var pt=ge[Qe];if(pt){var Vt;ut==="init"?Vt=this.strict&&pt.init||pt.get||pt.set:Vt=pt.init||pt[ut],Vt&&this.raiseRecoverable(Ue.start,"Redefinition of property")}else pt=ge[Qe]={init:!1,get:!1,set:!1};pt[ut]=!0}},Yt.parseExpression=function(z,ge){var Fe=this.start,Ue=this.startLoc,Qe=this.parseMaybeAssign(z,ge);if(this.type===V.comma){var ut=this.startNodeAt(Fe,Ue);for(ut.expressions=[Qe];this.eat(V.comma);)ut.expressions.push(this.parseMaybeAssign(z,ge));return this.finishNode(ut,"SequenceExpression")}return Qe},Yt.parseMaybeAssign=function(z,ge,Fe){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(z);this.exprAllowed=!1}var Ue=!1,Qe=-1,ut=-1,pt=-1;ge?(Qe=ge.parenthesizedAssign,ut=ge.trailingComma,pt=ge.doubleProto,ge.parenthesizedAssign=ge.trailingComma=-1):(ge=new hn,Ue=!0);var Vt=this.start,Ft=this.startLoc;(this.type===V.parenL||this.type===V.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=z==="await");var nn=this.parseMaybeConditional(z,ge);if(Fe&&(nn=Fe.call(this,nn,Vt,Ft)),this.type.isAssign){var Qt=this.startNodeAt(Vt,Ft);return Qt.operator=this.value,this.type===V.eq&&(nn=this.toAssignable(nn,!1,ge)),Ue||(ge.parenthesizedAssign=ge.trailingComma=ge.doubleProto=-1),ge.shorthandAssign>=nn.start&&(ge.shorthandAssign=-1),this.type===V.eq?this.checkLValPattern(nn):this.checkLValSimple(nn),Qt.left=nn,this.next(),Qt.right=this.parseMaybeAssign(z),pt>-1&&(ge.doubleProto=pt),this.finishNode(Qt,"AssignmentExpression")}else Ue&&this.checkExpressionErrors(ge,!0);return Qe>-1&&(ge.parenthesizedAssign=Qe),ut>-1&&(ge.trailingComma=ut),nn},Yt.parseMaybeConditional=function(z,ge){var Fe=this.start,Ue=this.startLoc,Qe=this.parseExprOps(z,ge);if(this.checkExpressionErrors(ge))return Qe;if(this.eat(V.question)){var ut=this.startNodeAt(Fe,Ue);return ut.test=Qe,ut.consequent=this.parseMaybeAssign(),this.expect(V.colon),ut.alternate=this.parseMaybeAssign(z),this.finishNode(ut,"ConditionalExpression")}return Qe},Yt.parseExprOps=function(z,ge){var Fe=this.start,Ue=this.startLoc,Qe=this.parseMaybeUnary(ge,!1,!1,z);return this.checkExpressionErrors(ge)||Qe.start===Fe&&Qe.type==="ArrowFunctionExpression"?Qe:this.parseExprOp(Qe,Fe,Ue,-1,z)},Yt.parseExprOp=function(z,ge,Fe,Ue,Qe){var ut=this.type.binop;if(ut!=null&&(!Qe||this.type!==V._in)&&ut>Ue){var pt=this.type===V.logicalOR||this.type===V.logicalAND,Vt=this.type===V.coalesce;Vt&&(ut=V.logicalAND.binop);var Ft=this.value;this.next();var nn=this.start,Qt=this.startLoc,_n=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,Qe),nn,Qt,ut,Qe),Gn=this.buildBinary(ge,Fe,z,_n,Ft,pt||Vt);return(pt&&this.type===V.coalesce||Vt&&(this.type===V.logicalOR||this.type===V.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(Gn,ge,Fe,Ue,Qe)}return z},Yt.buildBinary=function(z,ge,Fe,Ue,Qe,ut){Ue.type==="PrivateIdentifier"&&this.raise(Ue.start,"Private identifier can only be left side of binary expression");var pt=this.startNodeAt(z,ge);return pt.left=Fe,pt.operator=Qe,pt.right=Ue,this.finishNode(pt,ut?"LogicalExpression":"BinaryExpression")},Yt.parseMaybeUnary=function(z,ge,Fe,Ue){var Qe=this.start,ut=this.startLoc,pt;if(this.isContextual("await")&&this.canAwait)pt=this.parseAwait(Ue),ge=!0;else if(this.type.prefix){var Vt=this.startNode(),Ft=this.type===V.incDec;Vt.operator=this.value,Vt.prefix=!0,this.next(),Vt.argument=this.parseMaybeUnary(null,!0,Ft,Ue),this.checkExpressionErrors(z,!0),Ft?this.checkLValSimple(Vt.argument):this.strict&&Vt.operator==="delete"&&an(Vt.argument)?this.raiseRecoverable(Vt.start,"Deleting local variable in strict mode"):Vt.operator==="delete"&&mn(Vt.argument)?this.raiseRecoverable(Vt.start,"Private fields can not be deleted"):ge=!0,pt=this.finishNode(Vt,Ft?"UpdateExpression":"UnaryExpression")}else if(!ge&&this.type===V.privateId)(Ue||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),pt=this.parsePrivateIdent(),this.type!==V._in&&this.unexpected();else{if(pt=this.parseExprSubscripts(z,Ue),this.checkExpressionErrors(z))return pt;for(;this.type.postfix&&!this.canInsertSemicolon();){var nn=this.startNodeAt(Qe,ut);nn.operator=this.value,nn.prefix=!1,nn.argument=pt,this.checkLValSimple(pt),this.next(),pt=this.finishNode(nn,"UpdateExpression")}}if(!Fe&&this.eat(V.starstar))if(ge)this.unexpected(this.lastTokStart);else return this.buildBinary(Qe,ut,pt,this.parseMaybeUnary(null,!1,!1,Ue),"**",!1);else return pt};function an(z){return z.type==="Identifier"||z.type==="ParenthesizedExpression"&&an(z.expression)}function mn(z){return z.type==="MemberExpression"&&z.property.type==="PrivateIdentifier"||z.type==="ChainExpression"&&mn(z.expression)||z.type==="ParenthesizedExpression"&&mn(z.expression)}Yt.parseExprSubscripts=function(z,ge){var Fe=this.start,Ue=this.startLoc,Qe=this.parseExprAtom(z,ge);if(Qe.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return Qe;var ut=this.parseSubscripts(Qe,Fe,Ue,!1,ge);return z&&ut.type==="MemberExpression"&&(z.parenthesizedAssign>=ut.start&&(z.parenthesizedAssign=-1),z.parenthesizedBind>=ut.start&&(z.parenthesizedBind=-1),z.trailingComma>=ut.start&&(z.trailingComma=-1)),ut},Yt.parseSubscripts=function(z,ge,Fe,Ue,Qe){for(var ut=this.options.ecmaVersion>=8&&z.type==="Identifier"&&z.name==="async"&&this.lastTokEnd===z.end&&!this.canInsertSemicolon()&&z.end-z.start===5&&this.potentialArrowAt===z.start,pt=!1;;){var Vt=this.parseSubscript(z,ge,Fe,Ue,ut,pt,Qe);if(Vt.optional&&(pt=!0),Vt===z||Vt.type==="ArrowFunctionExpression"){if(pt){var Ft=this.startNodeAt(ge,Fe);Ft.expression=Vt,Vt=this.finishNode(Ft,"ChainExpression")}return Vt}z=Vt}},Yt.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(V.arrow)},Yt.parseSubscriptAsyncArrow=function(z,ge,Fe,Ue){return this.parseArrowExpression(this.startNodeAt(z,ge),Fe,!0,Ue)},Yt.parseSubscript=function(z,ge,Fe,Ue,Qe,ut,pt){var Vt=this.options.ecmaVersion>=11,Ft=Vt&&this.eat(V.questionDot);Ue&&Ft&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var nn=this.eat(V.bracketL);if(nn||Ft&&this.type!==V.parenL&&this.type!==V.backQuote||this.eat(V.dot)){var Qt=this.startNodeAt(ge,Fe);Qt.object=z,nn?(Qt.property=this.parseExpression(),this.expect(V.bracketR)):this.type===V.privateId&&z.type!=="Super"?Qt.property=this.parsePrivateIdent():Qt.property=this.parseIdent(this.options.allowReserved!=="never"),Qt.computed=!!nn,Vt&&(Qt.optional=Ft),z=this.finishNode(Qt,"MemberExpression")}else if(!Ue&&this.eat(V.parenL)){var _n=new hn,Gn=this.yieldPos,rr=this.awaitPos,Yn=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var gr=this.parseExprList(V.parenR,this.options.ecmaVersion>=8,!1,_n);if(Qe&&!Ft&&this.shouldParseAsyncArrow())return this.checkPatternErrors(_n,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=Gn,this.awaitPos=rr,this.awaitIdentPos=Yn,this.parseSubscriptAsyncArrow(ge,Fe,gr,pt);this.checkExpressionErrors(_n,!0),this.yieldPos=Gn||this.yieldPos,this.awaitPos=rr||this.awaitPos,this.awaitIdentPos=Yn||this.awaitIdentPos;var Jn=this.startNodeAt(ge,Fe);Jn.callee=z,Jn.arguments=gr,Vt&&(Jn.optional=Ft),z=this.finishNode(Jn,"CallExpression")}else if(this.type===V.backQuote){(Ft||ut)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var Xn=this.startNodeAt(ge,Fe);Xn.tag=z,Xn.quasi=this.parseTemplate({isTagged:!0}),z=this.finishNode(Xn,"TaggedTemplateExpression")}return z},Yt.parseExprAtom=function(z,ge,Fe){this.type===V.slash&&this.readRegexp();var Ue,Qe=this.potentialArrowAt===this.start;switch(this.type){case V._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),Ue=this.startNode(),this.next(),this.type===V.parenL&&!this.allowDirectSuper&&this.raise(Ue.start,"super() call outside constructor of a subclass"),this.type!==V.dot&&this.type!==V.bracketL&&this.type!==V.parenL&&this.unexpected(),this.finishNode(Ue,"Super");case V._this:return Ue=this.startNode(),this.next(),this.finishNode(Ue,"ThisExpression");case V.name:var ut=this.start,pt=this.startLoc,Vt=this.containsEsc,Ft=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!Vt&&Ft.name==="async"&&!this.canInsertSemicolon()&&this.eat(V._function))return this.overrideContext(Ut.f_expr),this.parseFunction(this.startNodeAt(ut,pt),0,!1,!0,ge);if(Qe&&!this.canInsertSemicolon()){if(this.eat(V.arrow))return this.parseArrowExpression(this.startNodeAt(ut,pt),[Ft],!1,ge);if(this.options.ecmaVersion>=8&&Ft.name==="async"&&this.type===V.name&&!Vt&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc))return Ft=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(V.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(ut,pt),[Ft],!0,ge)}return Ft;case V.regexp:var nn=this.value;return Ue=this.parseLiteral(nn.value),Ue.regex={pattern:nn.pattern,flags:nn.flags},Ue;case V.num:case V.string:return this.parseLiteral(this.value);case V._null:case V._true:case V._false:return Ue=this.startNode(),Ue.value=this.type===V._null?null:this.type===V._true,Ue.raw=this.type.keyword,this.next(),this.finishNode(Ue,"Literal");case V.parenL:var Qt=this.start,_n=this.parseParenAndDistinguishExpression(Qe,ge);return z&&(z.parenthesizedAssign<0&&!this.isSimpleAssignTarget(_n)&&(z.parenthesizedAssign=Qt),z.parenthesizedBind<0&&(z.parenthesizedBind=Qt)),_n;case V.bracketL:return Ue=this.startNode(),this.next(),Ue.elements=this.parseExprList(V.bracketR,!0,!0,z),this.finishNode(Ue,"ArrayExpression");case V.braceL:return this.overrideContext(Ut.b_expr),this.parseObj(!1,z);case V._function:return Ue=this.startNode(),this.next(),this.parseFunction(Ue,0);case V._class:return this.parseClass(this.startNode(),!1);case V._new:return this.parseNew();case V.backQuote:return this.parseTemplate();case V._import:return this.options.ecmaVersion>=11?this.parseExprImport(Fe):this.unexpected();default:return this.parseExprAtomDefault()}},Yt.parseExprAtomDefault=function(){this.unexpected()},Yt.parseExprImport=function(z){var ge=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===V.parenL&&!z)return this.parseDynamicImport(ge);if(this.type===V.dot){var Fe=this.startNodeAt(ge.start,ge.loc&&ge.loc.start);return Fe.name="import",ge.meta=this.finishNode(Fe,"Identifier"),this.parseImportMeta(ge)}else this.unexpected()},Yt.parseDynamicImport=function(z){if(this.next(),z.source=this.parseMaybeAssign(),!this.eat(V.parenR)){var ge=this.start;this.eat(V.comma)&&this.eat(V.parenR)?this.raiseRecoverable(ge,"Trailing comma is not allowed in import()"):this.unexpected(ge)}return this.finishNode(z,"ImportExpression")},Yt.parseImportMeta=function(z){this.next();var ge=this.containsEsc;return z.property=this.parseIdent(!0),z.property.name!=="meta"&&this.raiseRecoverable(z.property.start,"The only valid meta property for import is 'import.meta'"),ge&&this.raiseRecoverable(z.start,"'import.meta' must not contain escaped characters"),this.options.sourceType!=="module"&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(z.start,"Cannot use 'import.meta' outside a module"),this.finishNode(z,"MetaProperty")},Yt.parseLiteral=function(z){var ge=this.startNode();return ge.value=z,ge.raw=this.input.slice(this.start,this.end),ge.raw.charCodeAt(ge.raw.length-1)===110&&(ge.bigint=ge.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(ge,"Literal")},Yt.parseParenExpression=function(){this.expect(V.parenL);var z=this.parseExpression();return this.expect(V.parenR),z},Yt.shouldParseArrow=function(z){return!this.canInsertSemicolon()},Yt.parseParenAndDistinguishExpression=function(z,ge){var Fe=this.start,Ue=this.startLoc,Qe,ut=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var pt=this.start,Vt=this.startLoc,Ft=[],nn=!0,Qt=!1,_n=new hn,Gn=this.yieldPos,rr=this.awaitPos,Yn;for(this.yieldPos=0,this.awaitPos=0;this.type!==V.parenR;)if(nn?nn=!1:this.expect(V.comma),ut&&this.afterTrailingComma(V.parenR,!0)){Qt=!0;break}else if(this.type===V.ellipsis){Yn=this.start,Ft.push(this.parseParenItem(this.parseRestBinding())),this.type===V.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else Ft.push(this.parseMaybeAssign(!1,_n,this.parseParenItem));var gr=this.lastTokEnd,Jn=this.lastTokEndLoc;if(this.expect(V.parenR),z&&this.shouldParseArrow(Ft)&&this.eat(V.arrow))return this.checkPatternErrors(_n,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=Gn,this.awaitPos=rr,this.parseParenArrowList(Fe,Ue,Ft,ge);(!Ft.length||Qt)&&this.unexpected(this.lastTokStart),Yn&&this.unexpected(Yn),this.checkExpressionErrors(_n,!0),this.yieldPos=Gn||this.yieldPos,this.awaitPos=rr||this.awaitPos,Ft.length>1?(Qe=this.startNodeAt(pt,Vt),Qe.expressions=Ft,this.finishNodeAt(Qe,"SequenceExpression",gr,Jn)):Qe=Ft[0]}else Qe=this.parseParenExpression();if(this.options.preserveParens){var Xn=this.startNodeAt(Fe,Ue);return Xn.expression=Qe,this.finishNode(Xn,"ParenthesizedExpression")}else return Qe},Yt.parseParenItem=function(z){return z},Yt.parseParenArrowList=function(z,ge,Fe,Ue){return this.parseArrowExpression(this.startNodeAt(z,ge),Fe,!1,Ue)};var On=[];Yt.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var z=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===V.dot){var ge=this.startNodeAt(z.start,z.loc&&z.loc.start);ge.name="new",z.meta=this.finishNode(ge,"Identifier"),this.next();var Fe=this.containsEsc;return z.property=this.parseIdent(!0),z.property.name!=="target"&&this.raiseRecoverable(z.property.start,"The only valid meta property for new is 'new.target'"),Fe&&this.raiseRecoverable(z.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(z.start,"'new.target' can only be used in functions and class static block"),this.finishNode(z,"MetaProperty")}var Ue=this.start,Qe=this.startLoc;return z.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),Ue,Qe,!0,!1),this.eat(V.parenL)?z.arguments=this.parseExprList(V.parenR,this.options.ecmaVersion>=8,!1):z.arguments=On,this.finishNode(z,"NewExpression")},Yt.parseTemplateElement=function(z){var ge=z.isTagged,Fe=this.startNode();return this.type===V.invalidTemplate?(ge||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),Fe.value={raw:this.value.replace(/\r\n?/g,`
1224
+ `,Ue-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(ne).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=V.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=ge.sourceType==="module",this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&ge.allowHashBang&&this.input.slice(0,2)==="#!"&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(tt),this.regexpState=null,this.privateNameStack=[]},Ht={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},inClassStaticBlock:{configurable:!0}};yt.prototype.parse=function(){var ge=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(ge)},Ht.inFunction.get=function(){return(this.currentVarScope().flags&ot)>0},Ht.inGenerator.get=function(){return(this.currentVarScope().flags&Ge)>0&&!this.currentVarScope().inClassFieldInit},Ht.inAsync.get=function(){return(this.currentVarScope().flags&lt)>0&&!this.currentVarScope().inClassFieldInit},Ht.canAwait.get=function(){for(var z=this.scopeStack.length-1;z>=0;z--){var ge=this.scopeStack[z];if(ge.inClassFieldInit||ge.flags&It)return!1;if(ge.flags&ot)return(ge.flags&lt)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction},Ht.allowSuper.get=function(){var z=this.currentThisScope(),ge=z.flags,Fe=z.inClassFieldInit;return(ge&Rt)>0||Fe||this.options.allowSuperOutsideMethod},Ht.allowDirectSuper.get=function(){return(this.currentThisScope().flags&dt)>0},Ht.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},Ht.allowNewDotTarget.get=function(){var z=this.currentThisScope(),ge=z.flags,Fe=z.inClassFieldInit;return(ge&(ot|It))>0||Fe},Ht.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&It)>0},yt.extend=function(){for(var ge=[],Fe=arguments.length;Fe--;)ge[Fe]=arguments[Fe];for(var Ue=this,Qe=0;Qe<ge.length;Qe++)Ue=ge[Qe](Ue);return Ue},yt.parse=function(ge,Fe){return new this(Fe,ge).parse()},yt.parseExpressionAt=function(ge,Fe,Ue){var Qe=new this(Ue,ge,Fe);return Qe.nextToken(),Qe.parseExpression()},yt.tokenizer=function(ge,Fe){return new this(Fe,ge)},Object.defineProperties(yt.prototype,Ht);var Kt=yt.prototype,un=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;Kt.strictDirective=function(z){if(this.options.ecmaVersion<5)return!1;for(;;){oe.lastIndex=z,z+=oe.exec(this.input)[0].length;var ge=un.exec(this.input.slice(z));if(!ge)return!1;if((ge[1]||ge[2])==="use strict"){oe.lastIndex=z+ge[0].length;var Fe=oe.exec(this.input),Ue=Fe.index+Fe[0].length,Qe=this.input.charAt(Ue);return Qe===";"||Qe==="}"||ne.test(Fe[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(Qe)||Qe==="!"&&this.input.charAt(Ue+1)==="=")}z+=ge[0].length,oe.lastIndex=z,z+=oe.exec(this.input)[0].length,this.input[z]===";"&&z++}},Kt.eat=function(z){return this.type===z?(this.next(),!0):!1},Kt.isContextual=function(z){return this.type===V.name&&this.value===z&&!this.containsEsc},Kt.eatContextual=function(z){return this.isContextual(z)?(this.next(),!0):!1},Kt.expectContextual=function(z){this.eatContextual(z)||this.unexpected()},Kt.canInsertSemicolon=function(){return this.type===V.eof||this.type===V.braceR||ne.test(this.input.slice(this.lastTokEnd,this.start))},Kt.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},Kt.semicolon=function(){!this.eat(V.semi)&&!this.insertSemicolon()&&this.unexpected()},Kt.afterTrailingComma=function(z,ge){if(this.type===z)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),ge||this.next(),!0},Kt.expect=function(z){this.eat(z)||this.unexpected()},Kt.unexpected=function(z){this.raise(z??this.start,"Unexpected token")};var hn=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};Kt.checkPatternErrors=function(z,ge){if(z){z.trailingComma>-1&&this.raiseRecoverable(z.trailingComma,"Comma is not permitted after the rest element");var Fe=ge?z.parenthesizedAssign:z.parenthesizedBind;Fe>-1&&this.raiseRecoverable(Fe,ge?"Assigning to rvalue":"Parenthesized pattern")}},Kt.checkExpressionErrors=function(z,ge){if(!z)return!1;var Fe=z.shorthandAssign,Ue=z.doubleProto;if(!ge)return Fe>=0||Ue>=0;Fe>=0&&this.raise(Fe,"Shorthand property assignments are valid only in destructuring patterns"),Ue>=0&&this.raiseRecoverable(Ue,"Redefinition of __proto__ property")},Kt.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos)&&this.raise(this.yieldPos,"Yield expression cannot be a default value"),this.awaitPos&&this.raise(this.awaitPos,"Await expression cannot be a default value")},Kt.isSimpleAssignTarget=function(z){return z.type==="ParenthesizedExpression"?this.isSimpleAssignTarget(z.expression):z.type==="Identifier"||z.type==="MemberExpression"};var qt=yt.prototype;qt.parseTopLevel=function(z){var ge=Object.create(null);for(z.body||(z.body=[]);this.type!==V.eof;){var Fe=this.parseStatement(null,!0,ge);z.body.push(Fe)}if(this.inModule)for(var Ue=0,Qe=Object.keys(this.undefinedExports);Ue<Qe.length;Ue+=1){var ut=Qe[Ue];this.raiseRecoverable(this.undefinedExports[ut].start,"Export '"+ut+"' is not defined")}return this.adaptDirectivePrologue(z.body),this.next(),z.sourceType=this.options.sourceType,this.finishNode(z,"Program")};var An={kind:"loop"},xn={kind:"switch"};qt.isLet=function(z){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;oe.lastIndex=this.pos;var ge=oe.exec(this.input),Fe=this.pos+ge[0].length,Ue=this.input.charCodeAt(Fe);if(Ue===91||Ue===92)return!0;if(z)return!1;if(Ue===123||Ue>55295&&Ue<56320)return!0;if(A(Ue,!0)){for(var Qe=Fe+1;M(Ue=this.input.charCodeAt(Qe),!0);)++Qe;if(Ue===92||Ue>55295&&Ue<56320)return!0;var ut=this.input.slice(Fe,Qe);if(!S.test(ut))return!0}return!1},qt.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;oe.lastIndex=this.pos;var z=oe.exec(this.input),ge=this.pos+z[0].length,Fe;return!ne.test(this.input.slice(this.pos,ge))&&this.input.slice(ge,ge+8)==="function"&&(ge+8===this.input.length||!(M(Fe=this.input.charCodeAt(ge+8))||Fe>55295&&Fe<56320))},qt.parseStatement=function(z,ge,Fe){var Ue=this.type,Qe=this.startNode(),ut;switch(this.isLet(z)&&(Ue=V._var,ut="let"),Ue){case V._break:case V._continue:return this.parseBreakContinueStatement(Qe,Ue.keyword);case V._debugger:return this.parseDebuggerStatement(Qe);case V._do:return this.parseDoStatement(Qe);case V._for:return this.parseForStatement(Qe);case V._function:return z&&(this.strict||z!=="if"&&z!=="label")&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(Qe,!1,!z);case V._class:return z&&this.unexpected(),this.parseClass(Qe,!0);case V._if:return this.parseIfStatement(Qe);case V._return:return this.parseReturnStatement(Qe);case V._switch:return this.parseSwitchStatement(Qe);case V._throw:return this.parseThrowStatement(Qe);case V._try:return this.parseTryStatement(Qe);case V._const:case V._var:return ut=ut||this.value,z&&ut!=="var"&&this.unexpected(),this.parseVarStatement(Qe,ut);case V._while:return this.parseWhileStatement(Qe);case V._with:return this.parseWithStatement(Qe);case V.braceL:return this.parseBlock(!0,Qe);case V.semi:return this.parseEmptyStatement(Qe);case V._export:case V._import:if(this.options.ecmaVersion>10&&Ue===V._import){oe.lastIndex=this.pos;var pt=oe.exec(this.input),Vt=this.pos+pt[0].length,Ft=this.input.charCodeAt(Vt);if(Ft===40||Ft===46)return this.parseExpressionStatement(Qe,this.parseExpression())}return this.options.allowImportExportEverywhere||(ge||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),Ue===V._import?this.parseImport(Qe):this.parseExport(Qe,Fe);default:if(this.isAsyncFunction())return z&&this.unexpected(),this.next(),this.parseFunctionStatement(Qe,!0,!z);var nn=this.value,Zt=this.parseExpression();return Ue===V.name&&Zt.type==="Identifier"&&this.eat(V.colon)?this.parseLabeledStatement(Qe,nn,Zt,z):this.parseExpressionStatement(Qe,Zt)}},qt.parseBreakContinueStatement=function(z,ge){var Fe=ge==="break";this.next(),this.eat(V.semi)||this.insertSemicolon()?z.label=null:this.type!==V.name?this.unexpected():(z.label=this.parseIdent(),this.semicolon());for(var Ue=0;Ue<this.labels.length;++Ue){var Qe=this.labels[Ue];if((z.label==null||Qe.name===z.label.name)&&(Qe.kind!=null&&(Fe||Qe.kind==="loop")||z.label&&Fe))break}return Ue===this.labels.length&&this.raise(z.start,"Unsyntactic "+ge),this.finishNode(z,Fe?"BreakStatement":"ContinueStatement")},qt.parseDebuggerStatement=function(z){return this.next(),this.semicolon(),this.finishNode(z,"DebuggerStatement")},qt.parseDoStatement=function(z){return this.next(),this.labels.push(An),z.body=this.parseStatement("do"),this.labels.pop(),this.expect(V._while),z.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(V.semi):this.semicolon(),this.finishNode(z,"DoWhileStatement")},qt.parseForStatement=function(z){this.next();var ge=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(An),this.enterScope(0),this.expect(V.parenL),this.type===V.semi)return ge>-1&&this.unexpected(ge),this.parseFor(z,null);var Fe=this.isLet();if(this.type===V._var||this.type===V._const||Fe){var Ue=this.startNode(),Qe=Fe?"let":this.value;return this.next(),this.parseVar(Ue,!0,Qe),this.finishNode(Ue,"VariableDeclaration"),(this.type===V._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&Ue.declarations.length===1?(this.options.ecmaVersion>=9&&(this.type===V._in?ge>-1&&this.unexpected(ge):z.await=ge>-1),this.parseForIn(z,Ue)):(ge>-1&&this.unexpected(ge),this.parseFor(z,Ue))}var ut=this.isContextual("let"),pt=!1,Vt=this.containsEsc,Ft=new hn,nn=this.start,Zt=ge>-1?this.parseExprSubscripts(Ft,"await"):this.parseExpression(!0,Ft);return this.type===V._in||(pt=this.options.ecmaVersion>=6&&this.isContextual("of"))?(ge>-1?(this.type===V._in&&this.unexpected(ge),z.await=!0):pt&&this.options.ecmaVersion>=8&&(Zt.start===nn&&!Vt&&Zt.type==="Identifier"&&Zt.name==="async"?this.unexpected():this.options.ecmaVersion>=9&&(z.await=!1)),ut&&pt&&this.raise(Zt.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(Zt,!1,Ft),this.checkLValPattern(Zt),this.parseForIn(z,Zt)):(this.checkExpressionErrors(Ft,!0),ge>-1&&this.unexpected(ge),this.parseFor(z,Zt))},qt.parseFunctionStatement=function(z,ge,Fe){return this.next(),this.parseFunction(z,vn|(Fe?0:Pn),!1,ge)},qt.parseIfStatement=function(z){return this.next(),z.test=this.parseParenExpression(),z.consequent=this.parseStatement("if"),z.alternate=this.eat(V._else)?this.parseStatement("if"):null,this.finishNode(z,"IfStatement")},qt.parseReturnStatement=function(z){return!this.inFunction&&!this.options.allowReturnOutsideFunction&&this.raise(this.start,"'return' outside of function"),this.next(),this.eat(V.semi)||this.insertSemicolon()?z.argument=null:(z.argument=this.parseExpression(),this.semicolon()),this.finishNode(z,"ReturnStatement")},qt.parseSwitchStatement=function(z){this.next(),z.discriminant=this.parseParenExpression(),z.cases=[],this.expect(V.braceL),this.labels.push(xn),this.enterScope(0);for(var ge,Fe=!1;this.type!==V.braceR;)if(this.type===V._case||this.type===V._default){var Ue=this.type===V._case;ge&&this.finishNode(ge,"SwitchCase"),z.cases.push(ge=this.startNode()),ge.consequent=[],this.next(),Ue?ge.test=this.parseExpression():(Fe&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),Fe=!0,ge.test=null),this.expect(V.colon)}else ge||this.unexpected(),ge.consequent.push(this.parseStatement(null));return this.exitScope(),ge&&this.finishNode(ge,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(z,"SwitchStatement")},qt.parseThrowStatement=function(z){return this.next(),ne.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),z.argument=this.parseExpression(),this.semicolon(),this.finishNode(z,"ThrowStatement")};var Rn=[];qt.parseCatchClauseParam=function(){var z=this.parseBindingAtom(),ge=z.type==="Identifier";return this.enterScope(ge?rt:0),this.checkLValPattern(z,ge?mt:Ze),this.expect(V.parenR),z},qt.parseTryStatement=function(z){if(this.next(),z.block=this.parseBlock(),z.handler=null,this.type===V._catch){var ge=this.startNode();this.next(),this.eat(V.parenL)?ge.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),ge.param=null,this.enterScope(0)),ge.body=this.parseBlock(!1),this.exitScope(),z.handler=this.finishNode(ge,"CatchClause")}return z.finalizer=this.eat(V._finally)?this.parseBlock():null,!z.handler&&!z.finalizer&&this.raise(z.start,"Missing catch or finally clause"),this.finishNode(z,"TryStatement")},qt.parseVarStatement=function(z,ge,Fe){return this.next(),this.parseVar(z,!1,ge,Fe),this.semicolon(),this.finishNode(z,"VariableDeclaration")},qt.parseWhileStatement=function(z){return this.next(),z.test=this.parseParenExpression(),this.labels.push(An),z.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(z,"WhileStatement")},qt.parseWithStatement=function(z){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),z.object=this.parseParenExpression(),z.body=this.parseStatement("with"),this.finishNode(z,"WithStatement")},qt.parseEmptyStatement=function(z){return this.next(),this.finishNode(z,"EmptyStatement")},qt.parseLabeledStatement=function(z,ge,Fe,Ue){for(var Qe=0,ut=this.labels;Qe<ut.length;Qe+=1){var pt=ut[Qe];pt.name===ge&&this.raise(Fe.start,"Label '"+ge+"' is already declared")}for(var Vt=this.type.isLoop?"loop":this.type===V._switch?"switch":null,Ft=this.labels.length-1;Ft>=0;Ft--){var nn=this.labels[Ft];if(nn.statementStart===z.start)nn.statementStart=this.start,nn.kind=Vt;else break}return this.labels.push({name:ge,kind:Vt,statementStart:this.start}),z.body=this.parseStatement(Ue?Ue.indexOf("label")===-1?Ue+"label":Ue:"label"),this.labels.pop(),z.label=Fe,this.finishNode(z,"LabeledStatement")},qt.parseExpressionStatement=function(z,ge){return z.expression=ge,this.semicolon(),this.finishNode(z,"ExpressionStatement")},qt.parseBlock=function(z,ge,Fe){for(z===void 0&&(z=!0),ge===void 0&&(ge=this.startNode()),ge.body=[],this.expect(V.braceL),z&&this.enterScope(0);this.type!==V.braceR;){var Ue=this.parseStatement(null);ge.body.push(Ue)}return Fe&&(this.strict=!1),this.next(),z&&this.exitScope(),this.finishNode(ge,"BlockStatement")},qt.parseFor=function(z,ge){return z.init=ge,this.expect(V.semi),z.test=this.type===V.semi?null:this.parseExpression(),this.expect(V.semi),z.update=this.type===V.parenR?null:this.parseExpression(),this.expect(V.parenR),z.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(z,"ForStatement")},qt.parseForIn=function(z,ge){var Fe=this.type===V._in;return this.next(),ge.type==="VariableDeclaration"&&ge.declarations[0].init!=null&&(!Fe||this.options.ecmaVersion<8||this.strict||ge.kind!=="var"||ge.declarations[0].id.type!=="Identifier")&&this.raise(ge.start,(Fe?"for-in":"for-of")+" loop variable declaration may not have an initializer"),z.left=ge,z.right=Fe?this.parseExpression():this.parseMaybeAssign(),this.expect(V.parenR),z.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(z,Fe?"ForInStatement":"ForOfStatement")},qt.parseVar=function(z,ge,Fe,Ue){for(z.declarations=[],z.kind=Fe;;){var Qe=this.startNode();if(this.parseVarId(Qe,Fe),this.eat(V.eq)?Qe.init=this.parseMaybeAssign(ge):!Ue&&Fe==="const"&&!(this.type===V._in||this.options.ecmaVersion>=6&&this.isContextual("of"))?this.unexpected():!Ue&&Qe.id.type!=="Identifier"&&!(ge&&(this.type===V._in||this.isContextual("of")))?this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):Qe.init=null,z.declarations.push(this.finishNode(Qe,"VariableDeclarator")),!this.eat(V.comma))break}return z},qt.parseVarId=function(z,ge){z.id=this.parseBindingAtom(),this.checkLValPattern(z.id,ge==="var"?Ye:Ze,!1)};var vn=1,Pn=2,Mn=4;qt.parseFunction=function(z,ge,Fe,Ue,Qe){this.initFunction(z),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!Ue)&&(this.type===V.star&&ge&Pn&&this.unexpected(),z.generator=this.eat(V.star)),this.options.ecmaVersion>=8&&(z.async=!!Ue),ge&vn&&(z.id=ge&Mn&&this.type!==V.name?null:this.parseIdent(),z.id&&!(ge&Pn)&&this.checkLValSimple(z.id,this.strict||z.generator||z.async?this.treatFunctionsAsVar?Ye:Ze:ct));var ut=this.yieldPos,pt=this.awaitPos,Vt=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Ct(z.async,z.generator)),ge&vn||(z.id=this.type===V.name?this.parseIdent():null),this.parseFunctionParams(z),this.parseFunctionBody(z,Fe,!1,Qe),this.yieldPos=ut,this.awaitPos=pt,this.awaitIdentPos=Vt,this.finishNode(z,ge&vn?"FunctionDeclaration":"FunctionExpression")},qt.parseFunctionParams=function(z){this.expect(V.parenL),z.params=this.parseBindingList(V.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},qt.parseClass=function(z,ge){this.next();var Fe=this.strict;this.strict=!0,this.parseClassId(z,ge),this.parseClassSuper(z);var Ue=this.enterClassBody(),Qe=this.startNode(),ut=!1;for(Qe.body=[],this.expect(V.braceL);this.type!==V.braceR;){var pt=this.parseClassElement(z.superClass!==null);pt&&(Qe.body.push(pt),pt.type==="MethodDefinition"&&pt.kind==="constructor"?(ut&&this.raiseRecoverable(pt.start,"Duplicate constructor in the same class"),ut=!0):pt.key&&pt.key.type==="PrivateIdentifier"&&$n(Ue,pt)&&this.raiseRecoverable(pt.key.start,"Identifier '#"+pt.key.name+"' has already been declared"))}return this.strict=Fe,this.next(),z.body=this.finishNode(Qe,"ClassBody"),this.exitClassBody(),this.finishNode(z,ge?"ClassDeclaration":"ClassExpression")},qt.parseClassElement=function(z){if(this.eat(V.semi))return null;var ge=this.options.ecmaVersion,Fe=this.startNode(),Ue="",Qe=!1,ut=!1,pt="method",Vt=!1;if(this.eatContextual("static")){if(ge>=13&&this.eat(V.braceL))return this.parseClassStaticBlock(Fe),Fe;this.isClassElementNameStart()||this.type===V.star?Vt=!0:Ue="static"}if(Fe.static=Vt,!Ue&&ge>=8&&this.eatContextual("async")&&((this.isClassElementNameStart()||this.type===V.star)&&!this.canInsertSemicolon()?ut=!0:Ue="async"),!Ue&&(ge>=9||!ut)&&this.eat(V.star)&&(Qe=!0),!Ue&&!ut&&!Qe){var Ft=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?pt=Ft:Ue=Ft)}if(Ue?(Fe.computed=!1,Fe.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),Fe.key.name=Ue,this.finishNode(Fe.key,"Identifier")):this.parseClassElementName(Fe),ge<13||this.type===V.parenL||pt!=="method"||Qe||ut){var nn=!Fe.static&&Vn(Fe,"constructor"),Zt=nn&&z;nn&&pt!=="method"&&this.raise(Fe.key.start,"Constructor can't have get/set modifier"),Fe.kind=nn?"constructor":pt,this.parseClassMethod(Fe,Qe,ut,Zt)}else this.parseClassField(Fe);return Fe},qt.isClassElementNameStart=function(){return this.type===V.name||this.type===V.privateId||this.type===V.num||this.type===V.string||this.type===V.bracketL||this.type.keyword},qt.parseClassElementName=function(z){this.type===V.privateId?(this.value==="constructor"&&this.raise(this.start,"Classes can't have an element named '#constructor'"),z.computed=!1,z.key=this.parsePrivateIdent()):this.parsePropertyName(z)},qt.parseClassMethod=function(z,ge,Fe,Ue){var Qe=z.key;z.kind==="constructor"?(ge&&this.raise(Qe.start,"Constructor can't be a generator"),Fe&&this.raise(Qe.start,"Constructor can't be an async method")):z.static&&Vn(z,"prototype")&&this.raise(Qe.start,"Classes may not have a static property named prototype");var ut=z.value=this.parseMethod(ge,Fe,Ue);return z.kind==="get"&&ut.params.length!==0&&this.raiseRecoverable(ut.start,"getter should have no params"),z.kind==="set"&&ut.params.length!==1&&this.raiseRecoverable(ut.start,"setter should have exactly one param"),z.kind==="set"&&ut.params[0].type==="RestElement"&&this.raiseRecoverable(ut.params[0].start,"Setter cannot use rest params"),this.finishNode(z,"MethodDefinition")},qt.parseClassField=function(z){if(Vn(z,"constructor")?this.raise(z.key.start,"Classes can't have a field named 'constructor'"):z.static&&Vn(z,"prototype")&&this.raise(z.key.start,"Classes can't have a static field named 'prototype'"),this.eat(V.eq)){var ge=this.currentThisScope(),Fe=ge.inClassFieldInit;ge.inClassFieldInit=!0,z.value=this.parseMaybeAssign(),ge.inClassFieldInit=Fe}else z.value=null;return this.semicolon(),this.finishNode(z,"PropertyDefinition")},qt.parseClassStaticBlock=function(z){z.body=[];var ge=this.labels;for(this.labels=[],this.enterScope(It|Rt);this.type!==V.braceR;){var Fe=this.parseStatement(null);z.body.push(Fe)}return this.next(),this.exitScope(),this.labels=ge,this.finishNode(z,"StaticBlock")},qt.parseClassId=function(z,ge){this.type===V.name?(z.id=this.parseIdent(),ge&&this.checkLValSimple(z.id,Ze,!1)):(ge===!0&&this.unexpected(),z.id=null)},qt.parseClassSuper=function(z){z.superClass=this.eat(V._extends)?this.parseExprSubscripts(null,!1):null},qt.enterClassBody=function(){var z={declared:Object.create(null),used:[]};return this.privateNameStack.push(z),z.declared},qt.exitClassBody=function(){var z=this.privateNameStack.pop(),ge=z.declared,Fe=z.used;if(this.options.checkPrivateFields)for(var Ue=this.privateNameStack.length,Qe=Ue===0?null:this.privateNameStack[Ue-1],ut=0;ut<Fe.length;++ut){var pt=Fe[ut];Be(ge,pt.name)||(Qe?Qe.used.push(pt):this.raiseRecoverable(pt.start,"Private field '#"+pt.name+"' must be declared in an enclosing class"))}};function $n(z,ge){var Fe=ge.key.name,Ue=z[Fe],Qe="true";return ge.type==="MethodDefinition"&&(ge.kind==="get"||ge.kind==="set")&&(Qe=(ge.static?"s":"i")+ge.kind),Ue==="iget"&&Qe==="iset"||Ue==="iset"&&Qe==="iget"||Ue==="sget"&&Qe==="sset"||Ue==="sset"&&Qe==="sget"?(z[Fe]="true",!1):Ue?!0:(z[Fe]=Qe,!1)}function Vn(z,ge){var Fe=z.computed,Ue=z.key;return!Fe&&(Ue.type==="Identifier"&&Ue.name===ge||Ue.type==="Literal"&&Ue.value===ge)}qt.parseExportAllDeclaration=function(z,ge){return this.options.ecmaVersion>=11&&(this.eatContextual("as")?(z.exported=this.parseModuleExportName(),this.checkExport(ge,z.exported,this.lastTokStart)):z.exported=null),this.expectContextual("from"),this.type!==V.string&&this.unexpected(),z.source=this.parseExprAtom(),this.semicolon(),this.finishNode(z,"ExportAllDeclaration")},qt.parseExport=function(z,ge){if(this.next(),this.eat(V.star))return this.parseExportAllDeclaration(z,ge);if(this.eat(V._default))return this.checkExport(ge,"default",this.lastTokStart),z.declaration=this.parseExportDefaultDeclaration(),this.finishNode(z,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())z.declaration=this.parseExportDeclaration(z),z.declaration.type==="VariableDeclaration"?this.checkVariableExport(ge,z.declaration.declarations):this.checkExport(ge,z.declaration.id,z.declaration.id.start),z.specifiers=[],z.source=null;else{if(z.declaration=null,z.specifiers=this.parseExportSpecifiers(ge),this.eatContextual("from"))this.type!==V.string&&this.unexpected(),z.source=this.parseExprAtom();else{for(var Fe=0,Ue=z.specifiers;Fe<Ue.length;Fe+=1){var Qe=Ue[Fe];this.checkUnreserved(Qe.local),this.checkLocalExport(Qe.local),Qe.local.type==="Literal"&&this.raise(Qe.local.start,"A string literal cannot be used as an exported binding without `from`.")}z.source=null}this.semicolon()}return this.finishNode(z,"ExportNamedDeclaration")},qt.parseExportDeclaration=function(z){return this.parseStatement(null)},qt.parseExportDefaultDeclaration=function(){var z;if(this.type===V._function||(z=this.isAsyncFunction())){var ge=this.startNode();return this.next(),z&&this.next(),this.parseFunction(ge,vn|Mn,!1,z)}else if(this.type===V._class){var Fe=this.startNode();return this.parseClass(Fe,"nullableID")}else{var Ue=this.parseMaybeAssign();return this.semicolon(),Ue}},qt.checkExport=function(z,ge,Fe){z&&(typeof ge!="string"&&(ge=ge.type==="Identifier"?ge.name:ge.value),Be(z,ge)&&this.raiseRecoverable(Fe,"Duplicate export '"+ge+"'"),z[ge]=!0)},qt.checkPatternExport=function(z,ge){var Fe=ge.type;if(Fe==="Identifier")this.checkExport(z,ge,ge.start);else if(Fe==="ObjectPattern")for(var Ue=0,Qe=ge.properties;Ue<Qe.length;Ue+=1){var ut=Qe[Ue];this.checkPatternExport(z,ut)}else if(Fe==="ArrayPattern")for(var pt=0,Vt=ge.elements;pt<Vt.length;pt+=1){var Ft=Vt[pt];Ft&&this.checkPatternExport(z,Ft)}else Fe==="Property"?this.checkPatternExport(z,ge.value):Fe==="AssignmentPattern"?this.checkPatternExport(z,ge.left):Fe==="RestElement"&&this.checkPatternExport(z,ge.argument)},qt.checkVariableExport=function(z,ge){if(z)for(var Fe=0,Ue=ge;Fe<Ue.length;Fe+=1){var Qe=Ue[Fe];this.checkPatternExport(z,Qe.id)}},qt.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()},qt.parseExportSpecifier=function(z){var ge=this.startNode();return ge.local=this.parseModuleExportName(),ge.exported=this.eatContextual("as")?this.parseModuleExportName():ge.local,this.checkExport(z,ge.exported,ge.exported.start),this.finishNode(ge,"ExportSpecifier")},qt.parseExportSpecifiers=function(z){var ge=[],Fe=!0;for(this.expect(V.braceL);!this.eat(V.braceR);){if(Fe)Fe=!1;else if(this.expect(V.comma),this.afterTrailingComma(V.braceR))break;ge.push(this.parseExportSpecifier(z))}return ge},qt.parseImport=function(z){return this.next(),this.type===V.string?(z.specifiers=Rn,z.source=this.parseExprAtom()):(z.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),z.source=this.type===V.string?this.parseExprAtom():this.unexpected()),this.semicolon(),this.finishNode(z,"ImportDeclaration")},qt.parseImportSpecifier=function(){var z=this.startNode();return z.imported=this.parseModuleExportName(),this.eatContextual("as")?z.local=this.parseIdent():(this.checkUnreserved(z.imported),z.local=z.imported),this.checkLValSimple(z.local,Ze),this.finishNode(z,"ImportSpecifier")},qt.parseImportDefaultSpecifier=function(){var z=this.startNode();return z.local=this.parseIdent(),this.checkLValSimple(z.local,Ze),this.finishNode(z,"ImportDefaultSpecifier")},qt.parseImportNamespaceSpecifier=function(){var z=this.startNode();return this.next(),this.expectContextual("as"),z.local=this.parseIdent(),this.checkLValSimple(z.local,Ze),this.finishNode(z,"ImportNamespaceSpecifier")},qt.parseImportSpecifiers=function(){var z=[],ge=!0;if(this.type===V.name&&(z.push(this.parseImportDefaultSpecifier()),!this.eat(V.comma)))return z;if(this.type===V.star)return z.push(this.parseImportNamespaceSpecifier()),z;for(this.expect(V.braceL);!this.eat(V.braceR);){if(ge)ge=!1;else if(this.expect(V.comma),this.afterTrailingComma(V.braceR))break;z.push(this.parseImportSpecifier())}return z},qt.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===V.string){var z=this.parseLiteral(this.value);return We.test(z.value)&&this.raise(z.start,"An export name cannot include a lone surrogate."),z}return this.parseIdent(!0)},qt.adaptDirectivePrologue=function(z){for(var ge=0;ge<z.length&&this.isDirectiveCandidate(z[ge]);++ge)z[ge].directive=z[ge].expression.raw.slice(1,-1)},qt.isDirectiveCandidate=function(z){return this.options.ecmaVersion>=5&&z.type==="ExpressionStatement"&&z.expression.type==="Literal"&&typeof z.expression.value=="string"&&(this.input[z.start]==='"'||this.input[z.start]==="'")};var Jt=yt.prototype;Jt.toAssignable=function(z,ge,Fe){if(this.options.ecmaVersion>=6&&z)switch(z.type){case"Identifier":this.inAsync&&z.name==="await"&&this.raise(z.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":z.type="ObjectPattern",Fe&&this.checkPatternErrors(Fe,!0);for(var Ue=0,Qe=z.properties;Ue<Qe.length;Ue+=1){var ut=Qe[Ue];this.toAssignable(ut,ge),ut.type==="RestElement"&&(ut.argument.type==="ArrayPattern"||ut.argument.type==="ObjectPattern")&&this.raise(ut.argument.start,"Unexpected token")}break;case"Property":z.kind!=="init"&&this.raise(z.key.start,"Object pattern can't contain getter or setter"),this.toAssignable(z.value,ge);break;case"ArrayExpression":z.type="ArrayPattern",Fe&&this.checkPatternErrors(Fe,!0),this.toAssignableList(z.elements,ge);break;case"SpreadElement":z.type="RestElement",this.toAssignable(z.argument,ge),z.argument.type==="AssignmentPattern"&&this.raise(z.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":z.operator!=="="&&this.raise(z.left.end,"Only '=' operator can be used for specifying default value."),z.type="AssignmentPattern",delete z.operator,this.toAssignable(z.left,ge);break;case"ParenthesizedExpression":this.toAssignable(z.expression,ge,Fe);break;case"ChainExpression":this.raiseRecoverable(z.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!ge)break;default:this.raise(z.start,"Assigning to rvalue")}else Fe&&this.checkPatternErrors(Fe,!0);return z},Jt.toAssignableList=function(z,ge){for(var Fe=z.length,Ue=0;Ue<Fe;Ue++){var Qe=z[Ue];Qe&&this.toAssignable(Qe,ge)}if(Fe){var ut=z[Fe-1];this.options.ecmaVersion===6&&ge&&ut&&ut.type==="RestElement"&&ut.argument.type!=="Identifier"&&this.unexpected(ut.argument.start)}return z},Jt.parseSpread=function(z){var ge=this.startNode();return this.next(),ge.argument=this.parseMaybeAssign(!1,z),this.finishNode(ge,"SpreadElement")},Jt.parseRestBinding=function(){var z=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==V.name&&this.unexpected(),z.argument=this.parseBindingAtom(),this.finishNode(z,"RestElement")},Jt.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case V.bracketL:var z=this.startNode();return this.next(),z.elements=this.parseBindingList(V.bracketR,!0,!0),this.finishNode(z,"ArrayPattern");case V.braceL:return this.parseObj(!0)}return this.parseIdent()},Jt.parseBindingList=function(z,ge,Fe,Ue){for(var Qe=[],ut=!0;!this.eat(z);)if(ut?ut=!1:this.expect(V.comma),ge&&this.type===V.comma)Qe.push(null);else{if(Fe&&this.afterTrailingComma(z))break;if(this.type===V.ellipsis){var pt=this.parseRestBinding();this.parseBindingListItem(pt),Qe.push(pt),this.type===V.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(z);break}else Qe.push(this.parseAssignableListItem(Ue))}return Qe},Jt.parseAssignableListItem=function(z){var ge=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(ge),ge},Jt.parseBindingListItem=function(z){return z},Jt.parseMaybeDefault=function(z,ge,Fe){if(Fe=Fe||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(V.eq))return Fe;var Ue=this.startNodeAt(z,ge);return Ue.left=Fe,Ue.right=this.parseMaybeAssign(),this.finishNode(Ue,"AssignmentPattern")},Jt.checkLValSimple=function(z,ge,Fe){ge===void 0&&(ge=Ke);var Ue=ge!==Ke;switch(z.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(z.name)&&this.raiseRecoverable(z.start,(Ue?"Binding ":"Assigning to ")+z.name+" in strict mode"),Ue&&(ge===Ze&&z.name==="let"&&this.raiseRecoverable(z.start,"let is disallowed as a lexically bound name"),Fe&&(Be(Fe,z.name)&&this.raiseRecoverable(z.start,"Argument name clash"),Fe[z.name]=!0),ge!==ft&&this.declareName(z.name,ge,z.start));break;case"ChainExpression":this.raiseRecoverable(z.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":Ue&&this.raiseRecoverable(z.start,"Binding member expression");break;case"ParenthesizedExpression":return Ue&&this.raiseRecoverable(z.start,"Binding parenthesized expression"),this.checkLValSimple(z.expression,ge,Fe);default:this.raise(z.start,(Ue?"Binding":"Assigning to")+" rvalue")}},Jt.checkLValPattern=function(z,ge,Fe){switch(ge===void 0&&(ge=Ke),z.type){case"ObjectPattern":for(var Ue=0,Qe=z.properties;Ue<Qe.length;Ue+=1){var ut=Qe[Ue];this.checkLValInnerPattern(ut,ge,Fe)}break;case"ArrayPattern":for(var pt=0,Vt=z.elements;pt<Vt.length;pt+=1){var Ft=Vt[pt];Ft&&this.checkLValInnerPattern(Ft,ge,Fe)}break;default:this.checkLValSimple(z,ge,Fe)}},Jt.checkLValInnerPattern=function(z,ge,Fe){switch(ge===void 0&&(ge=Ke),z.type){case"Property":this.checkLValInnerPattern(z.value,ge,Fe);break;case"AssignmentPattern":this.checkLValPattern(z.left,ge,Fe);break;case"RestElement":this.checkLValPattern(z.argument,ge,Fe);break;default:this.checkLValPattern(z,ge,Fe)}};var Qt=function(ge,Fe,Ue,Qe,ut){this.token=ge,this.isExpr=!!Fe,this.preserveSpace=!!Ue,this.override=Qe,this.generator=!!ut},Ut={b_stat:new Qt("{",!1),b_expr:new Qt("{",!0),b_tmpl:new Qt("${",!1),p_stat:new Qt("(",!1),p_expr:new Qt("(",!0),q_tmpl:new Qt("`",!0,!0,function(z){return z.tryReadTemplateToken()}),f_stat:new Qt("function",!1),f_expr:new Qt("function",!0),f_expr_gen:new Qt("function",!0,!1,null,!0),f_gen:new Qt("function",!1,!1,null,!0)},tn=yt.prototype;tn.initialContext=function(){return[Ut.b_stat]},tn.curContext=function(){return this.context[this.context.length-1]},tn.braceIsBlock=function(z){var ge=this.curContext();return ge===Ut.f_expr||ge===Ut.f_stat?!0:z===V.colon&&(ge===Ut.b_stat||ge===Ut.b_expr)?!ge.isExpr:z===V._return||z===V.name&&this.exprAllowed?ne.test(this.input.slice(this.lastTokEnd,this.start)):z===V._else||z===V.semi||z===V.eof||z===V.parenR||z===V.arrow?!0:z===V.braceL?ge===Ut.b_stat:z===V._var||z===V._const||z===V.name?!1:!this.exprAllowed},tn.inGeneratorContext=function(){for(var z=this.context.length-1;z>=1;z--){var ge=this.context[z];if(ge.token==="function")return ge.generator}return!1},tn.updateContext=function(z){var ge,Fe=this.type;Fe.keyword&&z===V.dot?this.exprAllowed=!1:(ge=Fe.updateContext)?ge.call(this,z):this.exprAllowed=Fe.beforeExpr},tn.overrideContext=function(z){this.curContext()!==z&&(this.context[this.context.length-1]=z)},V.parenR.updateContext=V.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var z=this.context.pop();z===Ut.b_stat&&this.curContext().token==="function"&&(z=this.context.pop()),this.exprAllowed=!z.isExpr},V.braceL.updateContext=function(z){this.context.push(this.braceIsBlock(z)?Ut.b_stat:Ut.b_expr),this.exprAllowed=!0},V.dollarBraceL.updateContext=function(){this.context.push(Ut.b_tmpl),this.exprAllowed=!0},V.parenL.updateContext=function(z){var ge=z===V._if||z===V._for||z===V._with||z===V._while;this.context.push(ge?Ut.p_stat:Ut.p_expr),this.exprAllowed=!0},V.incDec.updateContext=function(){},V._function.updateContext=V._class.updateContext=function(z){z.beforeExpr&&z!==V._else&&!(z===V.semi&&this.curContext()!==Ut.p_stat)&&!(z===V._return&&ne.test(this.input.slice(this.lastTokEnd,this.start)))&&!((z===V.colon||z===V.braceL)&&this.curContext()===Ut.b_stat)?this.context.push(Ut.f_expr):this.context.push(Ut.f_stat),this.exprAllowed=!1},V.colon.updateContext=function(){this.curContext().token==="function"&&this.context.pop(),this.exprAllowed=!0},V.backQuote.updateContext=function(){this.curContext()===Ut.q_tmpl?this.context.pop():this.context.push(Ut.q_tmpl),this.exprAllowed=!1},V.star.updateContext=function(z){if(z===V._function){var ge=this.context.length-1;this.context[ge]===Ut.f_expr?this.context[ge]=Ut.f_expr_gen:this.context[ge]=Ut.f_gen}this.exprAllowed=!0},V.name.updateContext=function(z){var ge=!1;this.options.ecmaVersion>=6&&z!==V.dot&&(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())&&(ge=!0),this.exprAllowed=ge};var Yt=yt.prototype;Yt.checkPropClash=function(z,ge,Fe){if(!(this.options.ecmaVersion>=9&&z.type==="SpreadElement")&&!(this.options.ecmaVersion>=6&&(z.computed||z.method||z.shorthand))){var Ue=z.key,Qe;switch(Ue.type){case"Identifier":Qe=Ue.name;break;case"Literal":Qe=String(Ue.value);break;default:return}var ut=z.kind;if(this.options.ecmaVersion>=6){Qe==="__proto__"&&ut==="init"&&(ge.proto&&(Fe?Fe.doubleProto<0&&(Fe.doubleProto=Ue.start):this.raiseRecoverable(Ue.start,"Redefinition of __proto__ property")),ge.proto=!0);return}Qe="$"+Qe;var pt=ge[Qe];if(pt){var Vt;ut==="init"?Vt=this.strict&&pt.init||pt.get||pt.set:Vt=pt.init||pt[ut],Vt&&this.raiseRecoverable(Ue.start,"Redefinition of property")}else pt=ge[Qe]={init:!1,get:!1,set:!1};pt[ut]=!0}},Yt.parseExpression=function(z,ge){var Fe=this.start,Ue=this.startLoc,Qe=this.parseMaybeAssign(z,ge);if(this.type===V.comma){var ut=this.startNodeAt(Fe,Ue);for(ut.expressions=[Qe];this.eat(V.comma);)ut.expressions.push(this.parseMaybeAssign(z,ge));return this.finishNode(ut,"SequenceExpression")}return Qe},Yt.parseMaybeAssign=function(z,ge,Fe){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(z);this.exprAllowed=!1}var Ue=!1,Qe=-1,ut=-1,pt=-1;ge?(Qe=ge.parenthesizedAssign,ut=ge.trailingComma,pt=ge.doubleProto,ge.parenthesizedAssign=ge.trailingComma=-1):(ge=new hn,Ue=!0);var Vt=this.start,Ft=this.startLoc;(this.type===V.parenL||this.type===V.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=z==="await");var nn=this.parseMaybeConditional(z,ge);if(Fe&&(nn=Fe.call(this,nn,Vt,Ft)),this.type.isAssign){var Zt=this.startNodeAt(Vt,Ft);return Zt.operator=this.value,this.type===V.eq&&(nn=this.toAssignable(nn,!1,ge)),Ue||(ge.parenthesizedAssign=ge.trailingComma=ge.doubleProto=-1),ge.shorthandAssign>=nn.start&&(ge.shorthandAssign=-1),this.type===V.eq?this.checkLValPattern(nn):this.checkLValSimple(nn),Zt.left=nn,this.next(),Zt.right=this.parseMaybeAssign(z),pt>-1&&(ge.doubleProto=pt),this.finishNode(Zt,"AssignmentExpression")}else Ue&&this.checkExpressionErrors(ge,!0);return Qe>-1&&(ge.parenthesizedAssign=Qe),ut>-1&&(ge.trailingComma=ut),nn},Yt.parseMaybeConditional=function(z,ge){var Fe=this.start,Ue=this.startLoc,Qe=this.parseExprOps(z,ge);if(this.checkExpressionErrors(ge))return Qe;if(this.eat(V.question)){var ut=this.startNodeAt(Fe,Ue);return ut.test=Qe,ut.consequent=this.parseMaybeAssign(),this.expect(V.colon),ut.alternate=this.parseMaybeAssign(z),this.finishNode(ut,"ConditionalExpression")}return Qe},Yt.parseExprOps=function(z,ge){var Fe=this.start,Ue=this.startLoc,Qe=this.parseMaybeUnary(ge,!1,!1,z);return this.checkExpressionErrors(ge)||Qe.start===Fe&&Qe.type==="ArrowFunctionExpression"?Qe:this.parseExprOp(Qe,Fe,Ue,-1,z)},Yt.parseExprOp=function(z,ge,Fe,Ue,Qe){var ut=this.type.binop;if(ut!=null&&(!Qe||this.type!==V._in)&&ut>Ue){var pt=this.type===V.logicalOR||this.type===V.logicalAND,Vt=this.type===V.coalesce;Vt&&(ut=V.logicalAND.binop);var Ft=this.value;this.next();var nn=this.start,Zt=this.startLoc,_n=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,Qe),nn,Zt,ut,Qe),Gn=this.buildBinary(ge,Fe,z,_n,Ft,pt||Vt);return(pt&&this.type===V.coalesce||Vt&&(this.type===V.logicalOR||this.type===V.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(Gn,ge,Fe,Ue,Qe)}return z},Yt.buildBinary=function(z,ge,Fe,Ue,Qe,ut){Ue.type==="PrivateIdentifier"&&this.raise(Ue.start,"Private identifier can only be left side of binary expression");var pt=this.startNodeAt(z,ge);return pt.left=Fe,pt.operator=Qe,pt.right=Ue,this.finishNode(pt,ut?"LogicalExpression":"BinaryExpression")},Yt.parseMaybeUnary=function(z,ge,Fe,Ue){var Qe=this.start,ut=this.startLoc,pt;if(this.isContextual("await")&&this.canAwait)pt=this.parseAwait(Ue),ge=!0;else if(this.type.prefix){var Vt=this.startNode(),Ft=this.type===V.incDec;Vt.operator=this.value,Vt.prefix=!0,this.next(),Vt.argument=this.parseMaybeUnary(null,!0,Ft,Ue),this.checkExpressionErrors(z,!0),Ft?this.checkLValSimple(Vt.argument):this.strict&&Vt.operator==="delete"&&an(Vt.argument)?this.raiseRecoverable(Vt.start,"Deleting local variable in strict mode"):Vt.operator==="delete"&&mn(Vt.argument)?this.raiseRecoverable(Vt.start,"Private fields can not be deleted"):ge=!0,pt=this.finishNode(Vt,Ft?"UpdateExpression":"UnaryExpression")}else if(!ge&&this.type===V.privateId)(Ue||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),pt=this.parsePrivateIdent(),this.type!==V._in&&this.unexpected();else{if(pt=this.parseExprSubscripts(z,Ue),this.checkExpressionErrors(z))return pt;for(;this.type.postfix&&!this.canInsertSemicolon();){var nn=this.startNodeAt(Qe,ut);nn.operator=this.value,nn.prefix=!1,nn.argument=pt,this.checkLValSimple(pt),this.next(),pt=this.finishNode(nn,"UpdateExpression")}}if(!Fe&&this.eat(V.starstar))if(ge)this.unexpected(this.lastTokStart);else return this.buildBinary(Qe,ut,pt,this.parseMaybeUnary(null,!1,!1,Ue),"**",!1);else return pt};function an(z){return z.type==="Identifier"||z.type==="ParenthesizedExpression"&&an(z.expression)}function mn(z){return z.type==="MemberExpression"&&z.property.type==="PrivateIdentifier"||z.type==="ChainExpression"&&mn(z.expression)||z.type==="ParenthesizedExpression"&&mn(z.expression)}Yt.parseExprSubscripts=function(z,ge){var Fe=this.start,Ue=this.startLoc,Qe=this.parseExprAtom(z,ge);if(Qe.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return Qe;var ut=this.parseSubscripts(Qe,Fe,Ue,!1,ge);return z&&ut.type==="MemberExpression"&&(z.parenthesizedAssign>=ut.start&&(z.parenthesizedAssign=-1),z.parenthesizedBind>=ut.start&&(z.parenthesizedBind=-1),z.trailingComma>=ut.start&&(z.trailingComma=-1)),ut},Yt.parseSubscripts=function(z,ge,Fe,Ue,Qe){for(var ut=this.options.ecmaVersion>=8&&z.type==="Identifier"&&z.name==="async"&&this.lastTokEnd===z.end&&!this.canInsertSemicolon()&&z.end-z.start===5&&this.potentialArrowAt===z.start,pt=!1;;){var Vt=this.parseSubscript(z,ge,Fe,Ue,ut,pt,Qe);if(Vt.optional&&(pt=!0),Vt===z||Vt.type==="ArrowFunctionExpression"){if(pt){var Ft=this.startNodeAt(ge,Fe);Ft.expression=Vt,Vt=this.finishNode(Ft,"ChainExpression")}return Vt}z=Vt}},Yt.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(V.arrow)},Yt.parseSubscriptAsyncArrow=function(z,ge,Fe,Ue){return this.parseArrowExpression(this.startNodeAt(z,ge),Fe,!0,Ue)},Yt.parseSubscript=function(z,ge,Fe,Ue,Qe,ut,pt){var Vt=this.options.ecmaVersion>=11,Ft=Vt&&this.eat(V.questionDot);Ue&&Ft&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var nn=this.eat(V.bracketL);if(nn||Ft&&this.type!==V.parenL&&this.type!==V.backQuote||this.eat(V.dot)){var Zt=this.startNodeAt(ge,Fe);Zt.object=z,nn?(Zt.property=this.parseExpression(),this.expect(V.bracketR)):this.type===V.privateId&&z.type!=="Super"?Zt.property=this.parsePrivateIdent():Zt.property=this.parseIdent(this.options.allowReserved!=="never"),Zt.computed=!!nn,Vt&&(Zt.optional=Ft),z=this.finishNode(Zt,"MemberExpression")}else if(!Ue&&this.eat(V.parenL)){var _n=new hn,Gn=this.yieldPos,rr=this.awaitPos,Yn=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var gr=this.parseExprList(V.parenR,this.options.ecmaVersion>=8,!1,_n);if(Qe&&!Ft&&this.shouldParseAsyncArrow())return this.checkPatternErrors(_n,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=Gn,this.awaitPos=rr,this.awaitIdentPos=Yn,this.parseSubscriptAsyncArrow(ge,Fe,gr,pt);this.checkExpressionErrors(_n,!0),this.yieldPos=Gn||this.yieldPos,this.awaitPos=rr||this.awaitPos,this.awaitIdentPos=Yn||this.awaitIdentPos;var Jn=this.startNodeAt(ge,Fe);Jn.callee=z,Jn.arguments=gr,Vt&&(Jn.optional=Ft),z=this.finishNode(Jn,"CallExpression")}else if(this.type===V.backQuote){(Ft||ut)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var Xn=this.startNodeAt(ge,Fe);Xn.tag=z,Xn.quasi=this.parseTemplate({isTagged:!0}),z=this.finishNode(Xn,"TaggedTemplateExpression")}return z},Yt.parseExprAtom=function(z,ge,Fe){this.type===V.slash&&this.readRegexp();var Ue,Qe=this.potentialArrowAt===this.start;switch(this.type){case V._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),Ue=this.startNode(),this.next(),this.type===V.parenL&&!this.allowDirectSuper&&this.raise(Ue.start,"super() call outside constructor of a subclass"),this.type!==V.dot&&this.type!==V.bracketL&&this.type!==V.parenL&&this.unexpected(),this.finishNode(Ue,"Super");case V._this:return Ue=this.startNode(),this.next(),this.finishNode(Ue,"ThisExpression");case V.name:var ut=this.start,pt=this.startLoc,Vt=this.containsEsc,Ft=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!Vt&&Ft.name==="async"&&!this.canInsertSemicolon()&&this.eat(V._function))return this.overrideContext(Ut.f_expr),this.parseFunction(this.startNodeAt(ut,pt),0,!1,!0,ge);if(Qe&&!this.canInsertSemicolon()){if(this.eat(V.arrow))return this.parseArrowExpression(this.startNodeAt(ut,pt),[Ft],!1,ge);if(this.options.ecmaVersion>=8&&Ft.name==="async"&&this.type===V.name&&!Vt&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc))return Ft=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(V.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(ut,pt),[Ft],!0,ge)}return Ft;case V.regexp:var nn=this.value;return Ue=this.parseLiteral(nn.value),Ue.regex={pattern:nn.pattern,flags:nn.flags},Ue;case V.num:case V.string:return this.parseLiteral(this.value);case V._null:case V._true:case V._false:return Ue=this.startNode(),Ue.value=this.type===V._null?null:this.type===V._true,Ue.raw=this.type.keyword,this.next(),this.finishNode(Ue,"Literal");case V.parenL:var Zt=this.start,_n=this.parseParenAndDistinguishExpression(Qe,ge);return z&&(z.parenthesizedAssign<0&&!this.isSimpleAssignTarget(_n)&&(z.parenthesizedAssign=Zt),z.parenthesizedBind<0&&(z.parenthesizedBind=Zt)),_n;case V.bracketL:return Ue=this.startNode(),this.next(),Ue.elements=this.parseExprList(V.bracketR,!0,!0,z),this.finishNode(Ue,"ArrayExpression");case V.braceL:return this.overrideContext(Ut.b_expr),this.parseObj(!1,z);case V._function:return Ue=this.startNode(),this.next(),this.parseFunction(Ue,0);case V._class:return this.parseClass(this.startNode(),!1);case V._new:return this.parseNew();case V.backQuote:return this.parseTemplate();case V._import:return this.options.ecmaVersion>=11?this.parseExprImport(Fe):this.unexpected();default:return this.parseExprAtomDefault()}},Yt.parseExprAtomDefault=function(){this.unexpected()},Yt.parseExprImport=function(z){var ge=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===V.parenL&&!z)return this.parseDynamicImport(ge);if(this.type===V.dot){var Fe=this.startNodeAt(ge.start,ge.loc&&ge.loc.start);return Fe.name="import",ge.meta=this.finishNode(Fe,"Identifier"),this.parseImportMeta(ge)}else this.unexpected()},Yt.parseDynamicImport=function(z){if(this.next(),z.source=this.parseMaybeAssign(),!this.eat(V.parenR)){var ge=this.start;this.eat(V.comma)&&this.eat(V.parenR)?this.raiseRecoverable(ge,"Trailing comma is not allowed in import()"):this.unexpected(ge)}return this.finishNode(z,"ImportExpression")},Yt.parseImportMeta=function(z){this.next();var ge=this.containsEsc;return z.property=this.parseIdent(!0),z.property.name!=="meta"&&this.raiseRecoverable(z.property.start,"The only valid meta property for import is 'import.meta'"),ge&&this.raiseRecoverable(z.start,"'import.meta' must not contain escaped characters"),this.options.sourceType!=="module"&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(z.start,"Cannot use 'import.meta' outside a module"),this.finishNode(z,"MetaProperty")},Yt.parseLiteral=function(z){var ge=this.startNode();return ge.value=z,ge.raw=this.input.slice(this.start,this.end),ge.raw.charCodeAt(ge.raw.length-1)===110&&(ge.bigint=ge.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(ge,"Literal")},Yt.parseParenExpression=function(){this.expect(V.parenL);var z=this.parseExpression();return this.expect(V.parenR),z},Yt.shouldParseArrow=function(z){return!this.canInsertSemicolon()},Yt.parseParenAndDistinguishExpression=function(z,ge){var Fe=this.start,Ue=this.startLoc,Qe,ut=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var pt=this.start,Vt=this.startLoc,Ft=[],nn=!0,Zt=!1,_n=new hn,Gn=this.yieldPos,rr=this.awaitPos,Yn;for(this.yieldPos=0,this.awaitPos=0;this.type!==V.parenR;)if(nn?nn=!1:this.expect(V.comma),ut&&this.afterTrailingComma(V.parenR,!0)){Zt=!0;break}else if(this.type===V.ellipsis){Yn=this.start,Ft.push(this.parseParenItem(this.parseRestBinding())),this.type===V.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else Ft.push(this.parseMaybeAssign(!1,_n,this.parseParenItem));var gr=this.lastTokEnd,Jn=this.lastTokEndLoc;if(this.expect(V.parenR),z&&this.shouldParseArrow(Ft)&&this.eat(V.arrow))return this.checkPatternErrors(_n,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=Gn,this.awaitPos=rr,this.parseParenArrowList(Fe,Ue,Ft,ge);(!Ft.length||Zt)&&this.unexpected(this.lastTokStart),Yn&&this.unexpected(Yn),this.checkExpressionErrors(_n,!0),this.yieldPos=Gn||this.yieldPos,this.awaitPos=rr||this.awaitPos,Ft.length>1?(Qe=this.startNodeAt(pt,Vt),Qe.expressions=Ft,this.finishNodeAt(Qe,"SequenceExpression",gr,Jn)):Qe=Ft[0]}else Qe=this.parseParenExpression();if(this.options.preserveParens){var Xn=this.startNodeAt(Fe,Ue);return Xn.expression=Qe,this.finishNode(Xn,"ParenthesizedExpression")}else return Qe},Yt.parseParenItem=function(z){return z},Yt.parseParenArrowList=function(z,ge,Fe,Ue){return this.parseArrowExpression(this.startNodeAt(z,ge),Fe,!1,Ue)};var On=[];Yt.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var z=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===V.dot){var ge=this.startNodeAt(z.start,z.loc&&z.loc.start);ge.name="new",z.meta=this.finishNode(ge,"Identifier"),this.next();var Fe=this.containsEsc;return z.property=this.parseIdent(!0),z.property.name!=="target"&&this.raiseRecoverable(z.property.start,"The only valid meta property for new is 'new.target'"),Fe&&this.raiseRecoverable(z.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(z.start,"'new.target' can only be used in functions and class static block"),this.finishNode(z,"MetaProperty")}var Ue=this.start,Qe=this.startLoc;return z.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),Ue,Qe,!0,!1),this.eat(V.parenL)?z.arguments=this.parseExprList(V.parenR,this.options.ecmaVersion>=8,!1):z.arguments=On,this.finishNode(z,"NewExpression")},Yt.parseTemplateElement=function(z){var ge=z.isTagged,Fe=this.startNode();return this.type===V.invalidTemplate?(ge||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),Fe.value={raw:this.value.replace(/\r\n?/g,`
1225
1225
  `),cooked:null}):Fe.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,`
1226
- `),cooked:this.value},this.next(),Fe.tail=this.type===V.backQuote,this.finishNode(Fe,"TemplateElement")},Yt.parseTemplate=function(z){z===void 0&&(z={});var ge=z.isTagged;ge===void 0&&(ge=!1);var Fe=this.startNode();this.next(),Fe.expressions=[];var Ue=this.parseTemplateElement({isTagged:ge});for(Fe.quasis=[Ue];!Ue.tail;)this.type===V.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(V.dollarBraceL),Fe.expressions.push(this.parseExpression()),this.expect(V.braceR),Fe.quasis.push(Ue=this.parseTemplateElement({isTagged:ge}));return this.next(),this.finishNode(Fe,"TemplateLiteral")},Yt.isAsyncProp=function(z){return!z.computed&&z.key.type==="Identifier"&&z.key.name==="async"&&(this.type===V.name||this.type===V.num||this.type===V.string||this.type===V.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===V.star)&&!ne.test(this.input.slice(this.lastTokEnd,this.start))},Yt.parseObj=function(z,ge){var Fe=this.startNode(),Ue=!0,Qe={};for(Fe.properties=[],this.next();!this.eat(V.braceR);){if(Ue)Ue=!1;else if(this.expect(V.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(V.braceR))break;var ut=this.parseProperty(z,ge);z||this.checkPropClash(ut,Qe,ge),Fe.properties.push(ut)}return this.finishNode(Fe,z?"ObjectPattern":"ObjectExpression")},Yt.parseProperty=function(z,ge){var Fe=this.startNode(),Ue,Qe,ut,pt;if(this.options.ecmaVersion>=9&&this.eat(V.ellipsis))return z?(Fe.argument=this.parseIdent(!1),this.type===V.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.finishNode(Fe,"RestElement")):(Fe.argument=this.parseMaybeAssign(!1,ge),this.type===V.comma&&ge&&ge.trailingComma<0&&(ge.trailingComma=this.start),this.finishNode(Fe,"SpreadElement"));this.options.ecmaVersion>=6&&(Fe.method=!1,Fe.shorthand=!1,(z||ge)&&(ut=this.start,pt=this.startLoc),z||(Ue=this.eat(V.star)));var Vt=this.containsEsc;return this.parsePropertyName(Fe),!z&&!Vt&&this.options.ecmaVersion>=8&&!Ue&&this.isAsyncProp(Fe)?(Qe=!0,Ue=this.options.ecmaVersion>=9&&this.eat(V.star),this.parsePropertyName(Fe)):Qe=!1,this.parsePropertyValue(Fe,z,Ue,Qe,ut,pt,ge,Vt),this.finishNode(Fe,"Property")},Yt.parseGetterSetter=function(z){z.kind=z.key.name,this.parsePropertyName(z),z.value=this.parseMethod(!1);var ge=z.kind==="get"?0:1;if(z.value.params.length!==ge){var Fe=z.value.start;z.kind==="get"?this.raiseRecoverable(Fe,"getter should have no params"):this.raiseRecoverable(Fe,"setter should have exactly one param")}else z.kind==="set"&&z.value.params[0].type==="RestElement"&&this.raiseRecoverable(z.value.params[0].start,"Setter cannot use rest params")},Yt.parsePropertyValue=function(z,ge,Fe,Ue,Qe,ut,pt,Vt){(Fe||Ue)&&this.type===V.colon&&this.unexpected(),this.eat(V.colon)?(z.value=ge?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,pt),z.kind="init"):this.options.ecmaVersion>=6&&this.type===V.parenL?(ge&&this.unexpected(),z.kind="init",z.method=!0,z.value=this.parseMethod(Fe,Ue)):!ge&&!Vt&&this.options.ecmaVersion>=5&&!z.computed&&z.key.type==="Identifier"&&(z.key.name==="get"||z.key.name==="set")&&this.type!==V.comma&&this.type!==V.braceR&&this.type!==V.eq?((Fe||Ue)&&this.unexpected(),this.parseGetterSetter(z)):this.options.ecmaVersion>=6&&!z.computed&&z.key.type==="Identifier"?((Fe||Ue)&&this.unexpected(),this.checkUnreserved(z.key),z.key.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=Qe),z.kind="init",ge?z.value=this.parseMaybeDefault(Qe,ut,this.copyNode(z.key)):this.type===V.eq&&pt?(pt.shorthandAssign<0&&(pt.shorthandAssign=this.start),z.value=this.parseMaybeDefault(Qe,ut,this.copyNode(z.key))):z.value=this.copyNode(z.key),z.shorthand=!0):this.unexpected()},Yt.parsePropertyName=function(z){if(this.options.ecmaVersion>=6){if(this.eat(V.bracketL))return z.computed=!0,z.key=this.parseMaybeAssign(),this.expect(V.bracketR),z.key;z.computed=!1}return z.key=this.type===V.num||this.type===V.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never")},Yt.initFunction=function(z){z.id=null,this.options.ecmaVersion>=6&&(z.generator=z.expression=!1),this.options.ecmaVersion>=8&&(z.async=!1)},Yt.parseMethod=function(z,ge,Fe){var Ue=this.startNode(),Qe=this.yieldPos,ut=this.awaitPos,pt=this.awaitIdentPos;return this.initFunction(Ue),this.options.ecmaVersion>=6&&(Ue.generator=z),this.options.ecmaVersion>=8&&(Ue.async=!!ge),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Ct(ge,Ue.generator)|Rt|(Fe?dt:0)),this.expect(V.parenL),Ue.params=this.parseBindingList(V.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(Ue,!1,!0,!1),this.yieldPos=Qe,this.awaitPos=ut,this.awaitIdentPos=pt,this.finishNode(Ue,"FunctionExpression")},Yt.parseArrowExpression=function(z,ge,Fe,Ue){var Qe=this.yieldPos,ut=this.awaitPos,pt=this.awaitIdentPos;return this.enterScope(Ct(Fe,!1)|$t),this.initFunction(z),this.options.ecmaVersion>=8&&(z.async=!!Fe),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,z.params=this.toAssignableList(ge,!0),this.parseFunctionBody(z,!0,!1,Ue),this.yieldPos=Qe,this.awaitPos=ut,this.awaitIdentPos=pt,this.finishNode(z,"ArrowFunctionExpression")},Yt.parseFunctionBody=function(z,ge,Fe,Ue){var Qe=ge&&this.type!==V.braceL,ut=this.strict,pt=!1;if(Qe)z.body=this.parseMaybeAssign(Ue),z.expression=!0,this.checkParams(z,!1);else{var Vt=this.options.ecmaVersion>=7&&!this.isSimpleParamList(z.params);(!ut||Vt)&&(pt=this.strictDirective(this.end),pt&&Vt&&this.raiseRecoverable(z.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var Ft=this.labels;this.labels=[],pt&&(this.strict=!0),this.checkParams(z,!ut&&!pt&&!ge&&!Fe&&this.isSimpleParamList(z.params)),this.strict&&z.id&&this.checkLValSimple(z.id,ft),z.body=this.parseBlock(!1,void 0,pt&&!ut),z.expression=!1,this.adaptDirectivePrologue(z.body.body),this.labels=Ft}this.exitScope()},Yt.isSimpleParamList=function(z){for(var ge=0,Fe=z;ge<Fe.length;ge+=1){var Ue=Fe[ge];if(Ue.type!=="Identifier")return!1}return!0},Yt.checkParams=function(z,ge){for(var Fe=Object.create(null),Ue=0,Qe=z.params;Ue<Qe.length;Ue+=1){var ut=Qe[Ue];this.checkLValInnerPattern(ut,Ye,ge?null:Fe)}},Yt.parseExprList=function(z,ge,Fe,Ue){for(var Qe=[],ut=!0;!this.eat(z);){if(ut)ut=!1;else if(this.expect(V.comma),ge&&this.afterTrailingComma(z))break;var pt=void 0;Fe&&this.type===V.comma?pt=null:this.type===V.ellipsis?(pt=this.parseSpread(Ue),Ue&&this.type===V.comma&&Ue.trailingComma<0&&(Ue.trailingComma=this.start)):pt=this.parseMaybeAssign(!1,Ue),Qe.push(pt)}return Qe},Yt.checkUnreserved=function(z){var ge=z.start,Fe=z.end,Ue=z.name;if(this.inGenerator&&Ue==="yield"&&this.raiseRecoverable(ge,"Cannot use 'yield' as identifier inside a generator"),this.inAsync&&Ue==="await"&&this.raiseRecoverable(ge,"Cannot use 'await' as identifier inside an async function"),this.currentThisScope().inClassFieldInit&&Ue==="arguments"&&this.raiseRecoverable(ge,"Cannot use 'arguments' in class field initializer"),this.inClassStaticBlock&&(Ue==="arguments"||Ue==="await")&&this.raise(ge,"Cannot use "+Ue+" in class static initialization block"),this.keywords.test(Ue)&&this.raise(ge,"Unexpected keyword '"+Ue+"'"),!(this.options.ecmaVersion<6&&this.input.slice(ge,Fe).indexOf("\\")!==-1)){var Qe=this.strict?this.reservedWordsStrict:this.reservedWords;Qe.test(Ue)&&(!this.inAsync&&Ue==="await"&&this.raiseRecoverable(ge,"Cannot use keyword 'await' outside an async function"),this.raiseRecoverable(ge,"The keyword '"+Ue+"' is reserved"))}},Yt.parseIdent=function(z){var ge=this.parseIdentNode();return this.next(!!z),this.finishNode(ge,"Identifier"),z||(this.checkUnreserved(ge),ge.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=ge.start)),ge},Yt.parseIdentNode=function(){var z=this.startNode();return this.type===V.name?z.name=this.value:this.type.keyword?(z.name=this.type.keyword,(z.name==="class"||z.name==="function")&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=V.name):this.unexpected(),z},Yt.parsePrivateIdent=function(){var z=this.startNode();return this.type===V.privateId?z.name=this.value:this.unexpected(),this.next(),this.finishNode(z,"PrivateIdentifier"),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(z.start,"Private field '#"+z.name+"' must be declared in an enclosing class"):this.privateNameStack[this.privateNameStack.length-1].used.push(z)),z},Yt.parseYield=function(z){this.yieldPos||(this.yieldPos=this.start);var ge=this.startNode();return this.next(),this.type===V.semi||this.canInsertSemicolon()||this.type!==V.star&&!this.type.startsExpr?(ge.delegate=!1,ge.argument=null):(ge.delegate=this.eat(V.star),ge.argument=this.parseMaybeAssign(z)),this.finishNode(ge,"YieldExpression")},Yt.parseAwait=function(z){this.awaitPos||(this.awaitPos=this.start);var ge=this.startNode();return this.next(),ge.argument=this.parseMaybeUnary(null,!0,!1,z),this.finishNode(ge,"AwaitExpression")};var Fn=yt.prototype;Fn.raise=function(z,ge){var Fe=nt(this.input,z);ge+=" ("+Fe.line+":"+Fe.column+")";var Ue=new SyntaxError(ge);throw Ue.pos=z,Ue.loc=Fe,Ue.raisedAt=this.pos,Ue},Fn.raiseRecoverable=Fn.raise,Fn.curPosition=function(){if(this.options.locations)return new ze(this.curLine,this.pos-this.lineStart)};var Cn=yt.prototype,Bn=function(ge){this.flags=ge,this.var=[],this.lexical=[],this.functions=[],this.inClassFieldInit=!1};Cn.enterScope=function(z){this.scopeStack.push(new Bn(z))},Cn.exitScope=function(){this.scopeStack.pop()},Cn.treatFunctionsAsVarInScope=function(z){return z.flags&ot||!this.inModule&&z.flags&tt},Cn.declareName=function(z,ge,Fe){var Ue=!1;if(ge===Ze){var Qe=this.currentScope();Ue=Qe.lexical.indexOf(z)>-1||Qe.functions.indexOf(z)>-1||Qe.var.indexOf(z)>-1,Qe.lexical.push(z),this.inModule&&Qe.flags&tt&&delete this.undefinedExports[z]}else if(ge===mt){var ut=this.currentScope();ut.lexical.push(z)}else if(ge===ct){var pt=this.currentScope();this.treatFunctionsAsVar?Ue=pt.lexical.indexOf(z)>-1:Ue=pt.lexical.indexOf(z)>-1||pt.var.indexOf(z)>-1,pt.functions.push(z)}else for(var Vt=this.scopeStack.length-1;Vt>=0;--Vt){var Ft=this.scopeStack[Vt];if(Ft.lexical.indexOf(z)>-1&&!(Ft.flags&rt&&Ft.lexical[0]===z)||!this.treatFunctionsAsVarInScope(Ft)&&Ft.functions.indexOf(z)>-1){Ue=!0;break}if(Ft.var.push(z),this.inModule&&Ft.flags&tt&&delete this.undefinedExports[z],Ft.flags&Mt)break}Ue&&this.raiseRecoverable(Fe,"Identifier '"+z+"' has already been declared")},Cn.checkLocalExport=function(z){this.scopeStack[0].lexical.indexOf(z.name)===-1&&this.scopeStack[0].var.indexOf(z.name)===-1&&(this.undefinedExports[z.name]=z)},Cn.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]},Cn.currentVarScope=function(){for(var z=this.scopeStack.length-1;;z--){var ge=this.scopeStack[z];if(ge.flags&Mt)return ge}},Cn.currentThisScope=function(){for(var z=this.scopeStack.length-1;;z--){var ge=this.scopeStack[z];if(ge.flags&Mt&&!(ge.flags&$t))return ge}};var qn=function(ge,Fe,Ue){this.type="",this.start=Fe,this.end=0,ge.options.locations&&(this.loc=new Xe(ge,Ue)),ge.options.directSourceFile&&(this.sourceFile=ge.options.directSourceFile),ge.options.ranges&&(this.range=[Fe,0])},Un=yt.prototype;Un.startNode=function(){return new qn(this,this.start,this.startLoc)},Un.startNodeAt=function(z,ge){return new qn(this,z,ge)};function sr(z,ge,Fe,Ue){return z.type=ge,z.end=Fe,this.options.locations&&(z.loc.end=Ue),this.options.ranges&&(z.range[1]=Fe),z}Un.finishNode=function(z,ge){return sr.call(this,z,ge,this.lastTokEnd,this.lastTokEndLoc)},Un.finishNodeAt=function(z,ge,Fe,Ue){return sr.call(this,z,ge,Fe,Ue)},Un.copyNode=function(z){var ge=new qn(this,z.start,this.startLoc);for(var Fe in z)ge[Fe]=z[Fe];return ge};var wn="ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS",Dn=wn+" Extended_Pictographic",Zn=Dn,er=Zn+" EBase EComp EMod EPres ExtPict",Kn=er,or=Kn,kn={9:wn,10:Dn,11:Zn,12:er,13:Kn,14:or},lr="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",cr={9:"",10:"",11:"",12:"",13:"",14:lr},tr="Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu",nr="Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb",ur=nr+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",Xt=ur+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",it=Xt+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",Dt=it+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",Wt=Dt+" Hrkt Katakana_Or_Hiragana Kawi Nag_Mundari Nagm Unknown Zzzz",pn={9:nr,10:ur,11:Xt,12:it,13:Dt,14:Wt},bn={};function gn(z){var ge=bn[z]={binary:Le(kn[z]+" "+tr),binaryOfStrings:Le(cr[z]),nonBinary:{General_Category:Le(tr),Script:Le(pn[z])}};ge.nonBinary.Script_Extensions=ge.nonBinary.Script,ge.nonBinary.gc=ge.nonBinary.General_Category,ge.nonBinary.sc=ge.nonBinary.Script,ge.nonBinary.scx=ge.nonBinary.Script_Extensions}for(var Sn=0,In=[9,10,11,12,13,14];Sn<In.length;Sn+=1){var Hn=In[Sn];gn(Hn)}var zt=yt.prototype,yn=function(ge,Fe){this.parent=ge,this.base=Fe||this};yn.prototype.separatedFrom=function(ge){for(var Fe=this;Fe;Fe=Fe.parent)for(var Ue=ge;Ue;Ue=Ue.parent)if(Fe.base===Ue.base&&Fe!==Ue)return!0;return!1},yn.prototype.sibling=function(){return new yn(this.parent,this.base)};var En=function(ge){this.parser=ge,this.validFlags="gim"+(ge.options.ecmaVersion>=6?"uy":"")+(ge.options.ecmaVersion>=9?"s":"")+(ge.options.ecmaVersion>=13?"d":"")+(ge.options.ecmaVersion>=15?"v":""),this.unicodeProperties=bn[ge.options.ecmaVersion>=14?14:ge.options.ecmaVersion],this.source="",this.flags="",this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue="",this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null};En.prototype.reset=function(ge,Fe,Ue){var Qe=Ue.indexOf("v")!==-1,ut=Ue.indexOf("u")!==-1;this.start=ge|0,this.source=Fe+"",this.flags=Ue,Qe&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=ut&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=ut&&this.parser.options.ecmaVersion>=9)},En.prototype.raise=function(ge){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+ge)},En.prototype.at=function(ge,Fe){Fe===void 0&&(Fe=!1);var Ue=this.source,Qe=Ue.length;if(ge>=Qe)return-1;var ut=Ue.charCodeAt(ge);if(!(Fe||this.switchU)||ut<=55295||ut>=57344||ge+1>=Qe)return ut;var pt=Ue.charCodeAt(ge+1);return pt>=56320&&pt<=57343?(ut<<10)+pt-56613888:ut},En.prototype.nextIndex=function(ge,Fe){Fe===void 0&&(Fe=!1);var Ue=this.source,Qe=Ue.length;if(ge>=Qe)return Qe;var ut=Ue.charCodeAt(ge),pt;return!(Fe||this.switchU)||ut<=55295||ut>=57344||ge+1>=Qe||(pt=Ue.charCodeAt(ge+1))<56320||pt>57343?ge+1:ge+2},En.prototype.current=function(ge){return ge===void 0&&(ge=!1),this.at(this.pos,ge)},En.prototype.lookahead=function(ge){return ge===void 0&&(ge=!1),this.at(this.nextIndex(this.pos,ge),ge)},En.prototype.advance=function(ge){ge===void 0&&(ge=!1),this.pos=this.nextIndex(this.pos,ge)},En.prototype.eat=function(ge,Fe){return Fe===void 0&&(Fe=!1),this.current(Fe)===ge?(this.advance(Fe),!0):!1},En.prototype.eatChars=function(ge,Fe){Fe===void 0&&(Fe=!1);for(var Ue=this.pos,Qe=0,ut=ge;Qe<ut.length;Qe+=1){var pt=ut[Qe],Vt=this.at(Ue,Fe);if(Vt===-1||Vt!==pt)return!1;Ue=this.nextIndex(Ue,Fe)}return this.pos=Ue,!0},zt.validateRegExpFlags=function(z){for(var ge=z.validFlags,Fe=z.flags,Ue=!1,Qe=!1,ut=0;ut<Fe.length;ut++){var pt=Fe.charAt(ut);ge.indexOf(pt)===-1&&this.raise(z.start,"Invalid regular expression flag"),Fe.indexOf(pt,ut+1)>-1&&this.raise(z.start,"Duplicate regular expression flag"),pt==="u"&&(Ue=!0),pt==="v"&&(Qe=!0)}this.options.ecmaVersion>=15&&Ue&&Qe&&this.raise(z.start,"Invalid regular expression flag")};function dr(z){for(var ge in z)return!0;return!1}zt.validateRegExpPattern=function(z){this.regexp_pattern(z),!z.switchN&&this.options.ecmaVersion>=9&&dr(z.groupNames)&&(z.switchN=!0,this.regexp_pattern(z))},zt.regexp_pattern=function(z){z.pos=0,z.lastIntValue=0,z.lastStringValue="",z.lastAssertionIsQuantifiable=!1,z.numCapturingParens=0,z.maxBackReference=0,z.groupNames=Object.create(null),z.backReferenceNames.length=0,z.branchID=null,this.regexp_disjunction(z),z.pos!==z.source.length&&(z.eat(41)&&z.raise("Unmatched ')'"),(z.eat(93)||z.eat(125))&&z.raise("Lone quantifier brackets")),z.maxBackReference>z.numCapturingParens&&z.raise("Invalid escape");for(var ge=0,Fe=z.backReferenceNames;ge<Fe.length;ge+=1){var Ue=Fe[ge];z.groupNames[Ue]||z.raise("Invalid named capture referenced")}},zt.regexp_disjunction=function(z){var ge=this.options.ecmaVersion>=16;for(ge&&(z.branchID=new yn(z.branchID,null)),this.regexp_alternative(z);z.eat(124);)ge&&(z.branchID=z.branchID.sibling()),this.regexp_alternative(z);ge&&(z.branchID=z.branchID.parent),this.regexp_eatQuantifier(z,!0)&&z.raise("Nothing to repeat"),z.eat(123)&&z.raise("Lone quantifier brackets")},zt.regexp_alternative=function(z){for(;z.pos<z.source.length&&this.regexp_eatTerm(z););},zt.regexp_eatTerm=function(z){return this.regexp_eatAssertion(z)?(z.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(z)&&z.switchU&&z.raise("Invalid quantifier"),!0):(z.switchU?this.regexp_eatAtom(z):this.regexp_eatExtendedAtom(z))?(this.regexp_eatQuantifier(z),!0):!1},zt.regexp_eatAssertion=function(z){var ge=z.pos;if(z.lastAssertionIsQuantifiable=!1,z.eat(94)||z.eat(36))return!0;if(z.eat(92)){if(z.eat(66)||z.eat(98))return!0;z.pos=ge}if(z.eat(40)&&z.eat(63)){var Fe=!1;if(this.options.ecmaVersion>=9&&(Fe=z.eat(60)),z.eat(61)||z.eat(33))return this.regexp_disjunction(z),z.eat(41)||z.raise("Unterminated group"),z.lastAssertionIsQuantifiable=!Fe,!0}return z.pos=ge,!1},zt.regexp_eatQuantifier=function(z,ge){return ge===void 0&&(ge=!1),this.regexp_eatQuantifierPrefix(z,ge)?(z.eat(63),!0):!1},zt.regexp_eatQuantifierPrefix=function(z,ge){return z.eat(42)||z.eat(43)||z.eat(63)||this.regexp_eatBracedQuantifier(z,ge)},zt.regexp_eatBracedQuantifier=function(z,ge){var Fe=z.pos;if(z.eat(123)){var Ue=0,Qe=-1;if(this.regexp_eatDecimalDigits(z)&&(Ue=z.lastIntValue,z.eat(44)&&this.regexp_eatDecimalDigits(z)&&(Qe=z.lastIntValue),z.eat(125)))return Qe!==-1&&Qe<Ue&&!ge&&z.raise("numbers out of order in {} quantifier"),!0;z.switchU&&!ge&&z.raise("Incomplete quantifier"),z.pos=Fe}return!1},zt.regexp_eatAtom=function(z){return this.regexp_eatPatternCharacters(z)||z.eat(46)||this.regexp_eatReverseSolidusAtomEscape(z)||this.regexp_eatCharacterClass(z)||this.regexp_eatUncapturingGroup(z)||this.regexp_eatCapturingGroup(z)},zt.regexp_eatReverseSolidusAtomEscape=function(z){var ge=z.pos;if(z.eat(92)){if(this.regexp_eatAtomEscape(z))return!0;z.pos=ge}return!1},zt.regexp_eatUncapturingGroup=function(z){var ge=z.pos;if(z.eat(40)){if(z.eat(63)&&z.eat(58)){if(this.regexp_disjunction(z),z.eat(41))return!0;z.raise("Unterminated group")}z.pos=ge}return!1},zt.regexp_eatCapturingGroup=function(z){if(z.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(z):z.current()===63&&z.raise("Invalid group"),this.regexp_disjunction(z),z.eat(41))return z.numCapturingParens+=1,!0;z.raise("Unterminated group")}return!1},zt.regexp_eatExtendedAtom=function(z){return z.eat(46)||this.regexp_eatReverseSolidusAtomEscape(z)||this.regexp_eatCharacterClass(z)||this.regexp_eatUncapturingGroup(z)||this.regexp_eatCapturingGroup(z)||this.regexp_eatInvalidBracedQuantifier(z)||this.regexp_eatExtendedPatternCharacter(z)},zt.regexp_eatInvalidBracedQuantifier=function(z){return this.regexp_eatBracedQuantifier(z,!0)&&z.raise("Nothing to repeat"),!1},zt.regexp_eatSyntaxCharacter=function(z){var ge=z.current();return Rr(ge)?(z.lastIntValue=ge,z.advance(),!0):!1};function Rr(z){return z===36||z>=40&&z<=43||z===46||z===63||z>=91&&z<=94||z>=123&&z<=125}zt.regexp_eatPatternCharacters=function(z){for(var ge=z.pos,Fe=0;(Fe=z.current())!==-1&&!Rr(Fe);)z.advance();return z.pos!==ge},zt.regexp_eatExtendedPatternCharacter=function(z){var ge=z.current();return ge!==-1&&ge!==36&&!(ge>=40&&ge<=43)&&ge!==46&&ge!==63&&ge!==91&&ge!==94&&ge!==124?(z.advance(),!0):!1},zt.regexp_groupSpecifier=function(z){if(z.eat(63)){this.regexp_eatGroupName(z)||z.raise("Invalid group");var ge=this.options.ecmaVersion>=16,Fe=z.groupNames[z.lastStringValue];if(Fe)if(ge)for(var Ue=0,Qe=Fe;Ue<Qe.length;Ue+=1){var ut=Qe[Ue];ut.separatedFrom(z.branchID)||z.raise("Duplicate capture group name")}else z.raise("Duplicate capture group name");ge?(Fe||(z.groupNames[z.lastStringValue]=[])).push(z.branchID):z.groupNames[z.lastStringValue]=!0}},zt.regexp_eatGroupName=function(z){if(z.lastStringValue="",z.eat(60)){if(this.regexp_eatRegExpIdentifierName(z)&&z.eat(62))return!0;z.raise("Invalid capture group name")}return!1},zt.regexp_eatRegExpIdentifierName=function(z){if(z.lastStringValue="",this.regexp_eatRegExpIdentifierStart(z)){for(z.lastStringValue+=He(z.lastIntValue);this.regexp_eatRegExpIdentifierPart(z);)z.lastStringValue+=He(z.lastIntValue);return!0}return!1},zt.regexp_eatRegExpIdentifierStart=function(z){var ge=z.pos,Fe=this.options.ecmaVersion>=11,Ue=z.current(Fe);return z.advance(Fe),Ue===92&&this.regexp_eatRegExpUnicodeEscapeSequence(z,Fe)&&(Ue=z.lastIntValue),Dr(Ue)?(z.lastIntValue=Ue,!0):(z.pos=ge,!1)};function Dr(z){return A(z,!0)||z===36||z===95}zt.regexp_eatRegExpIdentifierPart=function(z){var ge=z.pos,Fe=this.options.ecmaVersion>=11,Ue=z.current(Fe);return z.advance(Fe),Ue===92&&this.regexp_eatRegExpUnicodeEscapeSequence(z,Fe)&&(Ue=z.lastIntValue),Vr(Ue)?(z.lastIntValue=Ue,!0):(z.pos=ge,!1)};function Vr(z){return M(z,!0)||z===36||z===95||z===8204||z===8205}zt.regexp_eatAtomEscape=function(z){return this.regexp_eatBackReference(z)||this.regexp_eatCharacterClassEscape(z)||this.regexp_eatCharacterEscape(z)||z.switchN&&this.regexp_eatKGroupName(z)?!0:(z.switchU&&(z.current()===99&&z.raise("Invalid unicode escape"),z.raise("Invalid escape")),!1)},zt.regexp_eatBackReference=function(z){var ge=z.pos;if(this.regexp_eatDecimalEscape(z)){var Fe=z.lastIntValue;if(z.switchU)return Fe>z.maxBackReference&&(z.maxBackReference=Fe),!0;if(Fe<=z.numCapturingParens)return!0;z.pos=ge}return!1},zt.regexp_eatKGroupName=function(z){if(z.eat(107)){if(this.regexp_eatGroupName(z))return z.backReferenceNames.push(z.lastStringValue),!0;z.raise("Invalid named reference")}return!1},zt.regexp_eatCharacterEscape=function(z){return this.regexp_eatControlEscape(z)||this.regexp_eatCControlLetter(z)||this.regexp_eatZero(z)||this.regexp_eatHexEscapeSequence(z)||this.regexp_eatRegExpUnicodeEscapeSequence(z,!1)||!z.switchU&&this.regexp_eatLegacyOctalEscapeSequence(z)||this.regexp_eatIdentityEscape(z)},zt.regexp_eatCControlLetter=function(z){var ge=z.pos;if(z.eat(99)){if(this.regexp_eatControlLetter(z))return!0;z.pos=ge}return!1},zt.regexp_eatZero=function(z){return z.current()===48&&!pr(z.lookahead())?(z.lastIntValue=0,z.advance(),!0):!1},zt.regexp_eatControlEscape=function(z){var ge=z.current();return ge===116?(z.lastIntValue=9,z.advance(),!0):ge===110?(z.lastIntValue=10,z.advance(),!0):ge===118?(z.lastIntValue=11,z.advance(),!0):ge===102?(z.lastIntValue=12,z.advance(),!0):ge===114?(z.lastIntValue=13,z.advance(),!0):!1},zt.regexp_eatControlLetter=function(z){var ge=z.current();return Pr(ge)?(z.lastIntValue=ge%32,z.advance(),!0):!1};function Pr(z){return z>=65&&z<=90||z>=97&&z<=122}zt.regexp_eatRegExpUnicodeEscapeSequence=function(z,ge){ge===void 0&&(ge=!1);var Fe=z.pos,Ue=ge||z.switchU;if(z.eat(117)){if(this.regexp_eatFixedHexDigits(z,4)){var Qe=z.lastIntValue;if(Ue&&Qe>=55296&&Qe<=56319){var ut=z.pos;if(z.eat(92)&&z.eat(117)&&this.regexp_eatFixedHexDigits(z,4)){var pt=z.lastIntValue;if(pt>=56320&&pt<=57343)return z.lastIntValue=(Qe-55296)*1024+(pt-56320)+65536,!0}z.pos=ut,z.lastIntValue=Qe}return!0}if(Ue&&z.eat(123)&&this.regexp_eatHexDigits(z)&&z.eat(125)&&Br(z.lastIntValue))return!0;Ue&&z.raise("Invalid unicode escape"),z.pos=Fe}return!1};function Br(z){return z>=0&&z<=1114111}zt.regexp_eatIdentityEscape=function(z){if(z.switchU)return this.regexp_eatSyntaxCharacter(z)?!0:z.eat(47)?(z.lastIntValue=47,!0):!1;var ge=z.current();return ge!==99&&(!z.switchN||ge!==107)?(z.lastIntValue=ge,z.advance(),!0):!1},zt.regexp_eatDecimalEscape=function(z){z.lastIntValue=0;var ge=z.current();if(ge>=49&&ge<=57){do z.lastIntValue=10*z.lastIntValue+(ge-48),z.advance();while((ge=z.current())>=48&&ge<=57);return!0}return!1};var Cr=0,Ln=1,Nn=2;zt.regexp_eatCharacterClassEscape=function(z){var ge=z.current();if(Lr(ge))return z.lastIntValue=-1,z.advance(),Ln;var Fe=!1;if(z.switchU&&this.options.ecmaVersion>=9&&((Fe=ge===80)||ge===112)){z.lastIntValue=-1,z.advance();var Ue;if(z.eat(123)&&(Ue=this.regexp_eatUnicodePropertyValueExpression(z))&&z.eat(125))return Fe&&Ue===Nn&&z.raise("Invalid property name"),Ue;z.raise("Invalid property name")}return Cr};function Lr(z){return z===100||z===68||z===115||z===83||z===119||z===87}zt.regexp_eatUnicodePropertyValueExpression=function(z){var ge=z.pos;if(this.regexp_eatUnicodePropertyName(z)&&z.eat(61)){var Fe=z.lastStringValue;if(this.regexp_eatUnicodePropertyValue(z)){var Ue=z.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(z,Fe,Ue),Ln}}if(z.pos=ge,this.regexp_eatLoneUnicodePropertyNameOrValue(z)){var Qe=z.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(z,Qe)}return Cr},zt.regexp_validateUnicodePropertyNameAndValue=function(z,ge,Fe){Be(z.unicodeProperties.nonBinary,ge)||z.raise("Invalid property name"),z.unicodeProperties.nonBinary[ge].test(Fe)||z.raise("Invalid property value")},zt.regexp_validateUnicodePropertyNameOrValue=function(z,ge){if(z.unicodeProperties.binary.test(ge))return Ln;if(z.switchV&&z.unicodeProperties.binaryOfStrings.test(ge))return Nn;z.raise("Invalid property name")},zt.regexp_eatUnicodePropertyName=function(z){var ge=0;for(z.lastStringValue="";wr(ge=z.current());)z.lastStringValue+=He(ge),z.advance();return z.lastStringValue!==""};function wr(z){return Pr(z)||z===95}zt.regexp_eatUnicodePropertyValue=function(z){var ge=0;for(z.lastStringValue="";Fr(ge=z.current());)z.lastStringValue+=He(ge),z.advance();return z.lastStringValue!==""};function Fr(z){return wr(z)||pr(z)}zt.regexp_eatLoneUnicodePropertyNameOrValue=function(z){return this.regexp_eatUnicodePropertyValue(z)},zt.regexp_eatCharacterClass=function(z){if(z.eat(91)){var ge=z.eat(94),Fe=this.regexp_classContents(z);return z.eat(93)||z.raise("Unterminated character class"),ge&&Fe===Nn&&z.raise("Negated character class may contain strings"),!0}return!1},zt.regexp_classContents=function(z){return z.current()===93?Ln:z.switchV?this.regexp_classSetExpression(z):(this.regexp_nonEmptyClassRanges(z),Ln)},zt.regexp_nonEmptyClassRanges=function(z){for(;this.regexp_eatClassAtom(z);){var ge=z.lastIntValue;if(z.eat(45)&&this.regexp_eatClassAtom(z)){var Fe=z.lastIntValue;z.switchU&&(ge===-1||Fe===-1)&&z.raise("Invalid character class"),ge!==-1&&Fe!==-1&&ge>Fe&&z.raise("Range out of order in character class")}}},zt.regexp_eatClassAtom=function(z){var ge=z.pos;if(z.eat(92)){if(this.regexp_eatClassEscape(z))return!0;if(z.switchU){var Fe=z.current();(Fe===99||Ar(Fe))&&z.raise("Invalid class escape"),z.raise("Invalid escape")}z.pos=ge}var Ue=z.current();return Ue!==93?(z.lastIntValue=Ue,z.advance(),!0):!1},zt.regexp_eatClassEscape=function(z){var ge=z.pos;if(z.eat(98))return z.lastIntValue=8,!0;if(z.switchU&&z.eat(45))return z.lastIntValue=45,!0;if(!z.switchU&&z.eat(99)){if(this.regexp_eatClassControlLetter(z))return!0;z.pos=ge}return this.regexp_eatCharacterClassEscape(z)||this.regexp_eatCharacterEscape(z)},zt.regexp_classSetExpression=function(z){var ge=Ln,Fe;if(!this.regexp_eatClassSetRange(z))if(Fe=this.regexp_eatClassSetOperand(z)){Fe===Nn&&(ge=Nn);for(var Ue=z.pos;z.eatChars([38,38]);){if(z.current()!==38&&(Fe=this.regexp_eatClassSetOperand(z))){Fe!==Nn&&(ge=Ln);continue}z.raise("Invalid character in character class")}if(Ue!==z.pos)return ge;for(;z.eatChars([45,45]);)this.regexp_eatClassSetOperand(z)||z.raise("Invalid character in character class");if(Ue!==z.pos)return ge}else z.raise("Invalid character in character class");for(;;)if(!this.regexp_eatClassSetRange(z)){if(Fe=this.regexp_eatClassSetOperand(z),!Fe)return ge;Fe===Nn&&(ge=Nn)}},zt.regexp_eatClassSetRange=function(z){var ge=z.pos;if(this.regexp_eatClassSetCharacter(z)){var Fe=z.lastIntValue;if(z.eat(45)&&this.regexp_eatClassSetCharacter(z)){var Ue=z.lastIntValue;return Fe!==-1&&Ue!==-1&&Fe>Ue&&z.raise("Range out of order in character class"),!0}z.pos=ge}return!1},zt.regexp_eatClassSetOperand=function(z){return this.regexp_eatClassSetCharacter(z)?Ln:this.regexp_eatClassStringDisjunction(z)||this.regexp_eatNestedClass(z)},zt.regexp_eatNestedClass=function(z){var ge=z.pos;if(z.eat(91)){var Fe=z.eat(94),Ue=this.regexp_classContents(z);if(z.eat(93))return Fe&&Ue===Nn&&z.raise("Negated character class may contain strings"),Ue;z.pos=ge}if(z.eat(92)){var Qe=this.regexp_eatCharacterClassEscape(z);if(Qe)return Qe;z.pos=ge}return null},zt.regexp_eatClassStringDisjunction=function(z){var ge=z.pos;if(z.eatChars([92,113])){if(z.eat(123)){var Fe=this.regexp_classStringDisjunctionContents(z);if(z.eat(125))return Fe}else z.raise("Invalid escape");z.pos=ge}return null},zt.regexp_classStringDisjunctionContents=function(z){for(var ge=this.regexp_classString(z);z.eat(124);)this.regexp_classString(z)===Nn&&(ge=Nn);return ge},zt.regexp_classString=function(z){for(var ge=0;this.regexp_eatClassSetCharacter(z);)ge++;return ge===1?Ln:Nn},zt.regexp_eatClassSetCharacter=function(z){var ge=z.pos;if(z.eat(92))return this.regexp_eatCharacterEscape(z)||this.regexp_eatClassSetReservedPunctuator(z)?!0:z.eat(98)?(z.lastIntValue=8,!0):(z.pos=ge,!1);var Fe=z.current();return Fe<0||Fe===z.lookahead()&&qr(Fe)||Ur(Fe)?!1:(z.advance(),z.lastIntValue=Fe,!0)};function qr(z){return z===33||z>=35&&z<=38||z>=42&&z<=44||z===46||z>=58&&z<=64||z===94||z===96||z===126}function Ur(z){return z===40||z===41||z===45||z===47||z>=91&&z<=93||z>=123&&z<=125}zt.regexp_eatClassSetReservedPunctuator=function(z){var ge=z.current();return Hr(ge)?(z.lastIntValue=ge,z.advance(),!0):!1};function Hr(z){return z===33||z===35||z===37||z===38||z===44||z===45||z>=58&&z<=62||z===64||z===96||z===126}zt.regexp_eatClassControlLetter=function(z){var ge=z.current();return pr(ge)||ge===95?(z.lastIntValue=ge%32,z.advance(),!0):!1},zt.regexp_eatHexEscapeSequence=function(z){var ge=z.pos;if(z.eat(120)){if(this.regexp_eatFixedHexDigits(z,2))return!0;z.switchU&&z.raise("Invalid escape"),z.pos=ge}return!1},zt.regexp_eatDecimalDigits=function(z){var ge=z.pos,Fe=0;for(z.lastIntValue=0;pr(Fe=z.current());)z.lastIntValue=10*z.lastIntValue+(Fe-48),z.advance();return z.pos!==ge};function pr(z){return z>=48&&z<=57}zt.regexp_eatHexDigits=function(z){var ge=z.pos,Fe=0;for(z.lastIntValue=0;Er(Fe=z.current());)z.lastIntValue=16*z.lastIntValue+Tr(Fe),z.advance();return z.pos!==ge};function Er(z){return z>=48&&z<=57||z>=65&&z<=70||z>=97&&z<=102}function Tr(z){return z>=65&&z<=70?10+(z-65):z>=97&&z<=102?10+(z-97):z-48}zt.regexp_eatLegacyOctalEscapeSequence=function(z){if(this.regexp_eatOctalDigit(z)){var ge=z.lastIntValue;if(this.regexp_eatOctalDigit(z)){var Fe=z.lastIntValue;ge<=3&&this.regexp_eatOctalDigit(z)?z.lastIntValue=ge*64+Fe*8+z.lastIntValue:z.lastIntValue=ge*8+Fe}else z.lastIntValue=ge;return!0}return!1},zt.regexp_eatOctalDigit=function(z){var ge=z.current();return Ar(ge)?(z.lastIntValue=ge-48,z.advance(),!0):(z.lastIntValue=0,!1)};function Ar(z){return z>=48&&z<=55}zt.regexp_eatFixedHexDigits=function(z,ge){var Fe=z.pos;z.lastIntValue=0;for(var Ue=0;Ue<ge;++Ue){var Qe=z.current();if(!Er(Qe))return z.pos=Fe,!1;z.lastIntValue=16*z.lastIntValue+Tr(Qe),z.advance()}return!0};var mr=function(ge){this.type=ge.type,this.value=ge.value,this.start=ge.start,this.end=ge.end,ge.options.locations&&(this.loc=new Xe(ge,ge.startLoc,ge.endLoc)),ge.options.ranges&&(this.range=[ge.start,ge.end])},sn=yt.prototype;sn.next=function(z){!z&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword),this.options.onToken&&this.options.onToken(new mr(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()},sn.getToken=function(){return this.next(),new mr(this)},typeof Symbol<"u"&&(sn[Symbol.iterator]=function(){var z=this;return{next:function(){var ge=z.getToken();return{done:ge.type===V.eof,value:ge}}}}),sn.nextToken=function(){var z=this.curContext();if((!z||!z.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(V.eof);if(z.override)return z.override(this);this.readToken(this.fullCharCodeAtPos())},sn.readToken=function(z){return A(z,this.options.ecmaVersion>=6)||z===92?this.readWord():this.getTokenFromCode(z)},sn.fullCharCodeAtPos=function(){var z=this.input.charCodeAt(this.pos);if(z<=55295||z>=56320)return z;var ge=this.input.charCodeAt(this.pos+1);return ge<=56319||ge>=57344?z:(z<<10)+ge-56613888},sn.skipBlockComment=function(){var z=this.options.onComment&&this.curPosition(),ge=this.pos,Fe=this.input.indexOf("*/",this.pos+=2);if(Fe===-1&&this.raise(this.pos-2,"Unterminated comment"),this.pos=Fe+2,this.options.locations)for(var Ue=void 0,Qe=ge;(Ue=Oe(this.input,Qe,this.pos))>-1;)++this.curLine,Qe=this.lineStart=Ue;this.options.onComment&&this.options.onComment(!0,this.input.slice(ge+2,Fe),ge,this.pos,z,this.curPosition())},sn.skipLineComment=function(z){for(var ge=this.pos,Fe=this.options.onComment&&this.curPosition(),Ue=this.input.charCodeAt(this.pos+=z);this.pos<this.input.length&&!se(Ue);)Ue=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(ge+z,this.pos),ge,this.pos,Fe,this.curPosition())},sn.skipSpace=function(){e:for(;this.pos<this.input.length;){var z=this.input.charCodeAt(this.pos);switch(z){case 32:case 160:++this.pos;break;case 13:this.input.charCodeAt(this.pos+1)===10&&++this.pos;case 10:case 8232:case 8233:++this.pos,this.options.locations&&(++this.curLine,this.lineStart=this.pos);break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break e}break;default:if(z>8&&z<14||z>=5760&&Ne.test(String.fromCharCode(z)))++this.pos;else break e}}},sn.finishToken=function(z,ge){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var Fe=this.type;this.type=z,this.value=ge,this.updateContext(Fe)},sn.readToken_dot=function(){var z=this.input.charCodeAt(this.pos+1);if(z>=48&&z<=57)return this.readNumber(!0);var ge=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&z===46&&ge===46?(this.pos+=3,this.finishToken(V.ellipsis)):(++this.pos,this.finishToken(V.dot))},sn.readToken_slash=function(){var z=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):z===61?this.finishOp(V.assign,2):this.finishOp(V.slash,1)},sn.readToken_mult_modulo_exp=function(z){var ge=this.input.charCodeAt(this.pos+1),Fe=1,Ue=z===42?V.star:V.modulo;return this.options.ecmaVersion>=7&&z===42&&ge===42&&(++Fe,Ue=V.starstar,ge=this.input.charCodeAt(this.pos+2)),ge===61?this.finishOp(V.assign,Fe+1):this.finishOp(Ue,Fe)},sn.readToken_pipe_amp=function(z){var ge=this.input.charCodeAt(this.pos+1);if(ge===z){if(this.options.ecmaVersion>=12){var Fe=this.input.charCodeAt(this.pos+2);if(Fe===61)return this.finishOp(V.assign,3)}return this.finishOp(z===124?V.logicalOR:V.logicalAND,2)}return ge===61?this.finishOp(V.assign,2):this.finishOp(z===124?V.bitwiseOR:V.bitwiseAND,1)},sn.readToken_caret=function(){var z=this.input.charCodeAt(this.pos+1);return z===61?this.finishOp(V.assign,2):this.finishOp(V.bitwiseXOR,1)},sn.readToken_plus_min=function(z){var ge=this.input.charCodeAt(this.pos+1);return ge===z?ge===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||ne.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(V.incDec,2):ge===61?this.finishOp(V.assign,2):this.finishOp(V.plusMin,1)},sn.readToken_lt_gt=function(z){var ge=this.input.charCodeAt(this.pos+1),Fe=1;return ge===z?(Fe=z===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+Fe)===61?this.finishOp(V.assign,Fe+1):this.finishOp(V.bitShift,Fe)):ge===33&&z===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(ge===61&&(Fe=2),this.finishOp(V.relational,Fe))},sn.readToken_eq_excl=function(z){var ge=this.input.charCodeAt(this.pos+1);return ge===61?this.finishOp(V.equality,this.input.charCodeAt(this.pos+2)===61?3:2):z===61&&ge===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(V.arrow)):this.finishOp(z===61?V.eq:V.prefix,1)},sn.readToken_question=function(){var z=this.options.ecmaVersion;if(z>=11){var ge=this.input.charCodeAt(this.pos+1);if(ge===46){var Fe=this.input.charCodeAt(this.pos+2);if(Fe<48||Fe>57)return this.finishOp(V.questionDot,2)}if(ge===63){if(z>=12){var Ue=this.input.charCodeAt(this.pos+2);if(Ue===61)return this.finishOp(V.assign,3)}return this.finishOp(V.coalesce,2)}}return this.finishOp(V.question,1)},sn.readToken_numberSign=function(){var z=this.options.ecmaVersion,ge=35;if(z>=13&&(++this.pos,ge=this.fullCharCodeAtPos(),A(ge,!0)||ge===92))return this.finishToken(V.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+He(ge)+"'")},sn.getTokenFromCode=function(z){switch(z){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(V.parenL);case 41:return++this.pos,this.finishToken(V.parenR);case 59:return++this.pos,this.finishToken(V.semi);case 44:return++this.pos,this.finishToken(V.comma);case 91:return++this.pos,this.finishToken(V.bracketL);case 93:return++this.pos,this.finishToken(V.bracketR);case 123:return++this.pos,this.finishToken(V.braceL);case 125:return++this.pos,this.finishToken(V.braceR);case 58:return++this.pos,this.finishToken(V.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(V.backQuote);case 48:var ge=this.input.charCodeAt(this.pos+1);if(ge===120||ge===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(ge===111||ge===79)return this.readRadixNumber(8);if(ge===98||ge===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(z);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(z);case 124:case 38:return this.readToken_pipe_amp(z);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(z);case 60:case 62:return this.readToken_lt_gt(z);case 61:case 33:return this.readToken_eq_excl(z);case 63:return this.readToken_question();case 126:return this.finishOp(V.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+He(z)+"'")},sn.finishOp=function(z,ge){var Fe=this.input.slice(this.pos,this.pos+ge);return this.pos+=ge,this.finishToken(z,Fe)},sn.readRegexp=function(){for(var z,ge,Fe=this.pos;;){this.pos>=this.input.length&&this.raise(Fe,"Unterminated regular expression");var Ue=this.input.charAt(this.pos);if(ne.test(Ue)&&this.raise(Fe,"Unterminated regular expression"),z)z=!1;else{if(Ue==="[")ge=!0;else if(Ue==="]"&&ge)ge=!1;else if(Ue==="/"&&!ge)break;z=Ue==="\\"}++this.pos}var Qe=this.input.slice(Fe,this.pos);++this.pos;var ut=this.pos,pt=this.readWord1();this.containsEsc&&this.unexpected(ut);var Vt=this.regexpState||(this.regexpState=new En(this));Vt.reset(Fe,Qe,pt),this.validateRegExpFlags(Vt),this.validateRegExpPattern(Vt);var Ft=null;try{Ft=new RegExp(Qe,pt)}catch{}return this.finishToken(V.regexp,{pattern:Qe,flags:pt,value:Ft})},sn.readInt=function(z,ge,Fe){for(var Ue=this.options.ecmaVersion>=12&&ge===void 0,Qe=Fe&&this.input.charCodeAt(this.pos)===48,ut=this.pos,pt=0,Vt=0,Ft=0,nn=ge??1/0;Ft<nn;++Ft,++this.pos){var Qt=this.input.charCodeAt(this.pos),_n=void 0;if(Ue&&Qt===95){Qe&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed in legacy octal numeric literals"),Vt===95&&this.raiseRecoverable(this.pos,"Numeric separator must be exactly one underscore"),Ft===0&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits"),Vt=Qt;continue}if(Qt>=97?_n=Qt-97+10:Qt>=65?_n=Qt-65+10:Qt>=48&&Qt<=57?_n=Qt-48:_n=1/0,_n>=z)break;Vt=Qt,pt=pt*z+_n}return Ue&&Vt===95&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===ut||ge!=null&&this.pos-ut!==ge?null:pt};function Gr(z,ge){return ge?parseInt(z,8):parseFloat(z.replace(/_/g,""))}function Ir(z){return typeof BigInt!="function"?null:BigInt(z.replace(/_/g,""))}sn.readRadixNumber=function(z){var ge=this.pos;this.pos+=2;var Fe=this.readInt(z);return Fe==null&&this.raise(this.start+2,"Expected number in radix "+z),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(Fe=Ir(this.input.slice(ge,this.pos)),++this.pos):A(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(V.num,Fe)},sn.readNumber=function(z){var ge=this.pos;!z&&this.readInt(10,void 0,!0)===null&&this.raise(ge,"Invalid number");var Fe=this.pos-ge>=2&&this.input.charCodeAt(ge)===48;Fe&&this.strict&&this.raise(ge,"Invalid number");var Ue=this.input.charCodeAt(this.pos);if(!Fe&&!z&&this.options.ecmaVersion>=11&&Ue===110){var Qe=Ir(this.input.slice(ge,this.pos));return++this.pos,A(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(V.num,Qe)}Fe&&/[89]/.test(this.input.slice(ge,this.pos))&&(Fe=!1),Ue===46&&!Fe&&(++this.pos,this.readInt(10),Ue=this.input.charCodeAt(this.pos)),(Ue===69||Ue===101)&&!Fe&&(Ue=this.input.charCodeAt(++this.pos),(Ue===43||Ue===45)&&++this.pos,this.readInt(10)===null&&this.raise(ge,"Invalid number")),A(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var ut=Gr(this.input.slice(ge,this.pos),Fe);return this.finishToken(V.num,ut)},sn.readCodePoint=function(){var z=this.input.charCodeAt(this.pos),ge;if(z===123){this.options.ecmaVersion<6&&this.unexpected();var Fe=++this.pos;ge=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,ge>1114111&&this.invalidStringToken(Fe,"Code point out of bounds")}else ge=this.readHexChar(4);return ge},sn.readString=function(z){for(var ge="",Fe=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var Ue=this.input.charCodeAt(this.pos);if(Ue===z)break;Ue===92?(ge+=this.input.slice(Fe,this.pos),ge+=this.readEscapedChar(!1),Fe=this.pos):Ue===8232||Ue===8233?(this.options.ecmaVersion<10&&this.raise(this.start,"Unterminated string constant"),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(se(Ue)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return ge+=this.input.slice(Fe,this.pos++),this.finishToken(V.string,ge)};var Nr={};sn.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(z){if(z===Nr)this.readInvalidTemplateToken();else throw z}this.inTemplateElement=!1},sn.invalidStringToken=function(z,ge){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Nr;this.raise(z,ge)},sn.readTmplToken=function(){for(var z="",ge=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var Fe=this.input.charCodeAt(this.pos);if(Fe===96||Fe===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos===this.start&&(this.type===V.template||this.type===V.invalidTemplate)?Fe===36?(this.pos+=2,this.finishToken(V.dollarBraceL)):(++this.pos,this.finishToken(V.backQuote)):(z+=this.input.slice(ge,this.pos),this.finishToken(V.template,z));if(Fe===92)z+=this.input.slice(ge,this.pos),z+=this.readEscapedChar(!0),ge=this.pos;else if(se(Fe)){switch(z+=this.input.slice(ge,this.pos),++this.pos,Fe){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:z+=`
1226
+ `),cooked:this.value},this.next(),Fe.tail=this.type===V.backQuote,this.finishNode(Fe,"TemplateElement")},Yt.parseTemplate=function(z){z===void 0&&(z={});var ge=z.isTagged;ge===void 0&&(ge=!1);var Fe=this.startNode();this.next(),Fe.expressions=[];var Ue=this.parseTemplateElement({isTagged:ge});for(Fe.quasis=[Ue];!Ue.tail;)this.type===V.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(V.dollarBraceL),Fe.expressions.push(this.parseExpression()),this.expect(V.braceR),Fe.quasis.push(Ue=this.parseTemplateElement({isTagged:ge}));return this.next(),this.finishNode(Fe,"TemplateLiteral")},Yt.isAsyncProp=function(z){return!z.computed&&z.key.type==="Identifier"&&z.key.name==="async"&&(this.type===V.name||this.type===V.num||this.type===V.string||this.type===V.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===V.star)&&!ne.test(this.input.slice(this.lastTokEnd,this.start))},Yt.parseObj=function(z,ge){var Fe=this.startNode(),Ue=!0,Qe={};for(Fe.properties=[],this.next();!this.eat(V.braceR);){if(Ue)Ue=!1;else if(this.expect(V.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(V.braceR))break;var ut=this.parseProperty(z,ge);z||this.checkPropClash(ut,Qe,ge),Fe.properties.push(ut)}return this.finishNode(Fe,z?"ObjectPattern":"ObjectExpression")},Yt.parseProperty=function(z,ge){var Fe=this.startNode(),Ue,Qe,ut,pt;if(this.options.ecmaVersion>=9&&this.eat(V.ellipsis))return z?(Fe.argument=this.parseIdent(!1),this.type===V.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.finishNode(Fe,"RestElement")):(Fe.argument=this.parseMaybeAssign(!1,ge),this.type===V.comma&&ge&&ge.trailingComma<0&&(ge.trailingComma=this.start),this.finishNode(Fe,"SpreadElement"));this.options.ecmaVersion>=6&&(Fe.method=!1,Fe.shorthand=!1,(z||ge)&&(ut=this.start,pt=this.startLoc),z||(Ue=this.eat(V.star)));var Vt=this.containsEsc;return this.parsePropertyName(Fe),!z&&!Vt&&this.options.ecmaVersion>=8&&!Ue&&this.isAsyncProp(Fe)?(Qe=!0,Ue=this.options.ecmaVersion>=9&&this.eat(V.star),this.parsePropertyName(Fe)):Qe=!1,this.parsePropertyValue(Fe,z,Ue,Qe,ut,pt,ge,Vt),this.finishNode(Fe,"Property")},Yt.parseGetterSetter=function(z){z.kind=z.key.name,this.parsePropertyName(z),z.value=this.parseMethod(!1);var ge=z.kind==="get"?0:1;if(z.value.params.length!==ge){var Fe=z.value.start;z.kind==="get"?this.raiseRecoverable(Fe,"getter should have no params"):this.raiseRecoverable(Fe,"setter should have exactly one param")}else z.kind==="set"&&z.value.params[0].type==="RestElement"&&this.raiseRecoverable(z.value.params[0].start,"Setter cannot use rest params")},Yt.parsePropertyValue=function(z,ge,Fe,Ue,Qe,ut,pt,Vt){(Fe||Ue)&&this.type===V.colon&&this.unexpected(),this.eat(V.colon)?(z.value=ge?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,pt),z.kind="init"):this.options.ecmaVersion>=6&&this.type===V.parenL?(ge&&this.unexpected(),z.kind="init",z.method=!0,z.value=this.parseMethod(Fe,Ue)):!ge&&!Vt&&this.options.ecmaVersion>=5&&!z.computed&&z.key.type==="Identifier"&&(z.key.name==="get"||z.key.name==="set")&&this.type!==V.comma&&this.type!==V.braceR&&this.type!==V.eq?((Fe||Ue)&&this.unexpected(),this.parseGetterSetter(z)):this.options.ecmaVersion>=6&&!z.computed&&z.key.type==="Identifier"?((Fe||Ue)&&this.unexpected(),this.checkUnreserved(z.key),z.key.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=Qe),z.kind="init",ge?z.value=this.parseMaybeDefault(Qe,ut,this.copyNode(z.key)):this.type===V.eq&&pt?(pt.shorthandAssign<0&&(pt.shorthandAssign=this.start),z.value=this.parseMaybeDefault(Qe,ut,this.copyNode(z.key))):z.value=this.copyNode(z.key),z.shorthand=!0):this.unexpected()},Yt.parsePropertyName=function(z){if(this.options.ecmaVersion>=6){if(this.eat(V.bracketL))return z.computed=!0,z.key=this.parseMaybeAssign(),this.expect(V.bracketR),z.key;z.computed=!1}return z.key=this.type===V.num||this.type===V.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never")},Yt.initFunction=function(z){z.id=null,this.options.ecmaVersion>=6&&(z.generator=z.expression=!1),this.options.ecmaVersion>=8&&(z.async=!1)},Yt.parseMethod=function(z,ge,Fe){var Ue=this.startNode(),Qe=this.yieldPos,ut=this.awaitPos,pt=this.awaitIdentPos;return this.initFunction(Ue),this.options.ecmaVersion>=6&&(Ue.generator=z),this.options.ecmaVersion>=8&&(Ue.async=!!ge),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Ct(ge,Ue.generator)|Rt|(Fe?dt:0)),this.expect(V.parenL),Ue.params=this.parseBindingList(V.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(Ue,!1,!0,!1),this.yieldPos=Qe,this.awaitPos=ut,this.awaitIdentPos=pt,this.finishNode(Ue,"FunctionExpression")},Yt.parseArrowExpression=function(z,ge,Fe,Ue){var Qe=this.yieldPos,ut=this.awaitPos,pt=this.awaitIdentPos;return this.enterScope(Ct(Fe,!1)|$t),this.initFunction(z),this.options.ecmaVersion>=8&&(z.async=!!Fe),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,z.params=this.toAssignableList(ge,!0),this.parseFunctionBody(z,!0,!1,Ue),this.yieldPos=Qe,this.awaitPos=ut,this.awaitIdentPos=pt,this.finishNode(z,"ArrowFunctionExpression")},Yt.parseFunctionBody=function(z,ge,Fe,Ue){var Qe=ge&&this.type!==V.braceL,ut=this.strict,pt=!1;if(Qe)z.body=this.parseMaybeAssign(Ue),z.expression=!0,this.checkParams(z,!1);else{var Vt=this.options.ecmaVersion>=7&&!this.isSimpleParamList(z.params);(!ut||Vt)&&(pt=this.strictDirective(this.end),pt&&Vt&&this.raiseRecoverable(z.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var Ft=this.labels;this.labels=[],pt&&(this.strict=!0),this.checkParams(z,!ut&&!pt&&!ge&&!Fe&&this.isSimpleParamList(z.params)),this.strict&&z.id&&this.checkLValSimple(z.id,ft),z.body=this.parseBlock(!1,void 0,pt&&!ut),z.expression=!1,this.adaptDirectivePrologue(z.body.body),this.labels=Ft}this.exitScope()},Yt.isSimpleParamList=function(z){for(var ge=0,Fe=z;ge<Fe.length;ge+=1){var Ue=Fe[ge];if(Ue.type!=="Identifier")return!1}return!0},Yt.checkParams=function(z,ge){for(var Fe=Object.create(null),Ue=0,Qe=z.params;Ue<Qe.length;Ue+=1){var ut=Qe[Ue];this.checkLValInnerPattern(ut,Ye,ge?null:Fe)}},Yt.parseExprList=function(z,ge,Fe,Ue){for(var Qe=[],ut=!0;!this.eat(z);){if(ut)ut=!1;else if(this.expect(V.comma),ge&&this.afterTrailingComma(z))break;var pt=void 0;Fe&&this.type===V.comma?pt=null:this.type===V.ellipsis?(pt=this.parseSpread(Ue),Ue&&this.type===V.comma&&Ue.trailingComma<0&&(Ue.trailingComma=this.start)):pt=this.parseMaybeAssign(!1,Ue),Qe.push(pt)}return Qe},Yt.checkUnreserved=function(z){var ge=z.start,Fe=z.end,Ue=z.name;if(this.inGenerator&&Ue==="yield"&&this.raiseRecoverable(ge,"Cannot use 'yield' as identifier inside a generator"),this.inAsync&&Ue==="await"&&this.raiseRecoverable(ge,"Cannot use 'await' as identifier inside an async function"),this.currentThisScope().inClassFieldInit&&Ue==="arguments"&&this.raiseRecoverable(ge,"Cannot use 'arguments' in class field initializer"),this.inClassStaticBlock&&(Ue==="arguments"||Ue==="await")&&this.raise(ge,"Cannot use "+Ue+" in class static initialization block"),this.keywords.test(Ue)&&this.raise(ge,"Unexpected keyword '"+Ue+"'"),!(this.options.ecmaVersion<6&&this.input.slice(ge,Fe).indexOf("\\")!==-1)){var Qe=this.strict?this.reservedWordsStrict:this.reservedWords;Qe.test(Ue)&&(!this.inAsync&&Ue==="await"&&this.raiseRecoverable(ge,"Cannot use keyword 'await' outside an async function"),this.raiseRecoverable(ge,"The keyword '"+Ue+"' is reserved"))}},Yt.parseIdent=function(z){var ge=this.parseIdentNode();return this.next(!!z),this.finishNode(ge,"Identifier"),z||(this.checkUnreserved(ge),ge.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=ge.start)),ge},Yt.parseIdentNode=function(){var z=this.startNode();return this.type===V.name?z.name=this.value:this.type.keyword?(z.name=this.type.keyword,(z.name==="class"||z.name==="function")&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=V.name):this.unexpected(),z},Yt.parsePrivateIdent=function(){var z=this.startNode();return this.type===V.privateId?z.name=this.value:this.unexpected(),this.next(),this.finishNode(z,"PrivateIdentifier"),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(z.start,"Private field '#"+z.name+"' must be declared in an enclosing class"):this.privateNameStack[this.privateNameStack.length-1].used.push(z)),z},Yt.parseYield=function(z){this.yieldPos||(this.yieldPos=this.start);var ge=this.startNode();return this.next(),this.type===V.semi||this.canInsertSemicolon()||this.type!==V.star&&!this.type.startsExpr?(ge.delegate=!1,ge.argument=null):(ge.delegate=this.eat(V.star),ge.argument=this.parseMaybeAssign(z)),this.finishNode(ge,"YieldExpression")},Yt.parseAwait=function(z){this.awaitPos||(this.awaitPos=this.start);var ge=this.startNode();return this.next(),ge.argument=this.parseMaybeUnary(null,!0,!1,z),this.finishNode(ge,"AwaitExpression")};var Fn=yt.prototype;Fn.raise=function(z,ge){var Fe=nt(this.input,z);ge+=" ("+Fe.line+":"+Fe.column+")";var Ue=new SyntaxError(ge);throw Ue.pos=z,Ue.loc=Fe,Ue.raisedAt=this.pos,Ue},Fn.raiseRecoverable=Fn.raise,Fn.curPosition=function(){if(this.options.locations)return new ze(this.curLine,this.pos-this.lineStart)};var Cn=yt.prototype,Bn=function(ge){this.flags=ge,this.var=[],this.lexical=[],this.functions=[],this.inClassFieldInit=!1};Cn.enterScope=function(z){this.scopeStack.push(new Bn(z))},Cn.exitScope=function(){this.scopeStack.pop()},Cn.treatFunctionsAsVarInScope=function(z){return z.flags&ot||!this.inModule&&z.flags&tt},Cn.declareName=function(z,ge,Fe){var Ue=!1;if(ge===Ze){var Qe=this.currentScope();Ue=Qe.lexical.indexOf(z)>-1||Qe.functions.indexOf(z)>-1||Qe.var.indexOf(z)>-1,Qe.lexical.push(z),this.inModule&&Qe.flags&tt&&delete this.undefinedExports[z]}else if(ge===mt){var ut=this.currentScope();ut.lexical.push(z)}else if(ge===ct){var pt=this.currentScope();this.treatFunctionsAsVar?Ue=pt.lexical.indexOf(z)>-1:Ue=pt.lexical.indexOf(z)>-1||pt.var.indexOf(z)>-1,pt.functions.push(z)}else for(var Vt=this.scopeStack.length-1;Vt>=0;--Vt){var Ft=this.scopeStack[Vt];if(Ft.lexical.indexOf(z)>-1&&!(Ft.flags&rt&&Ft.lexical[0]===z)||!this.treatFunctionsAsVarInScope(Ft)&&Ft.functions.indexOf(z)>-1){Ue=!0;break}if(Ft.var.push(z),this.inModule&&Ft.flags&tt&&delete this.undefinedExports[z],Ft.flags&Mt)break}Ue&&this.raiseRecoverable(Fe,"Identifier '"+z+"' has already been declared")},Cn.checkLocalExport=function(z){this.scopeStack[0].lexical.indexOf(z.name)===-1&&this.scopeStack[0].var.indexOf(z.name)===-1&&(this.undefinedExports[z.name]=z)},Cn.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]},Cn.currentVarScope=function(){for(var z=this.scopeStack.length-1;;z--){var ge=this.scopeStack[z];if(ge.flags&Mt)return ge}},Cn.currentThisScope=function(){for(var z=this.scopeStack.length-1;;z--){var ge=this.scopeStack[z];if(ge.flags&Mt&&!(ge.flags&$t))return ge}};var qn=function(ge,Fe,Ue){this.type="",this.start=Fe,this.end=0,ge.options.locations&&(this.loc=new Xe(ge,Ue)),ge.options.directSourceFile&&(this.sourceFile=ge.options.directSourceFile),ge.options.ranges&&(this.range=[Fe,0])},Un=yt.prototype;Un.startNode=function(){return new qn(this,this.start,this.startLoc)},Un.startNodeAt=function(z,ge){return new qn(this,z,ge)};function sr(z,ge,Fe,Ue){return z.type=ge,z.end=Fe,this.options.locations&&(z.loc.end=Ue),this.options.ranges&&(z.range[1]=Fe),z}Un.finishNode=function(z,ge){return sr.call(this,z,ge,this.lastTokEnd,this.lastTokEndLoc)},Un.finishNodeAt=function(z,ge,Fe,Ue){return sr.call(this,z,ge,Fe,Ue)},Un.copyNode=function(z){var ge=new qn(this,z.start,this.startLoc);for(var Fe in z)ge[Fe]=z[Fe];return ge};var wn="ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS",Dn=wn+" Extended_Pictographic",Zn=Dn,er=Zn+" EBase EComp EMod EPres ExtPict",Kn=er,or=Kn,kn={9:wn,10:Dn,11:Zn,12:er,13:Kn,14:or},lr="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",cr={9:"",10:"",11:"",12:"",13:"",14:lr},tr="Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu",nr="Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb",ur=nr+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",Xt=ur+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",it=Xt+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",Dt=it+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",Wt=Dt+" Hrkt Katakana_Or_Hiragana Kawi Nag_Mundari Nagm Unknown Zzzz",pn={9:nr,10:ur,11:Xt,12:it,13:Dt,14:Wt},bn={};function gn(z){var ge=bn[z]={binary:Le(kn[z]+" "+tr),binaryOfStrings:Le(cr[z]),nonBinary:{General_Category:Le(tr),Script:Le(pn[z])}};ge.nonBinary.Script_Extensions=ge.nonBinary.Script,ge.nonBinary.gc=ge.nonBinary.General_Category,ge.nonBinary.sc=ge.nonBinary.Script,ge.nonBinary.scx=ge.nonBinary.Script_Extensions}for(var Sn=0,In=[9,10,11,12,13,14];Sn<In.length;Sn+=1){var Hn=In[Sn];gn(Hn)}var zt=yt.prototype,yn=function(ge,Fe){this.parent=ge,this.base=Fe||this};yn.prototype.separatedFrom=function(ge){for(var Fe=this;Fe;Fe=Fe.parent)for(var Ue=ge;Ue;Ue=Ue.parent)if(Fe.base===Ue.base&&Fe!==Ue)return!0;return!1},yn.prototype.sibling=function(){return new yn(this.parent,this.base)};var En=function(ge){this.parser=ge,this.validFlags="gim"+(ge.options.ecmaVersion>=6?"uy":"")+(ge.options.ecmaVersion>=9?"s":"")+(ge.options.ecmaVersion>=13?"d":"")+(ge.options.ecmaVersion>=15?"v":""),this.unicodeProperties=bn[ge.options.ecmaVersion>=14?14:ge.options.ecmaVersion],this.source="",this.flags="",this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue="",this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null};En.prototype.reset=function(ge,Fe,Ue){var Qe=Ue.indexOf("v")!==-1,ut=Ue.indexOf("u")!==-1;this.start=ge|0,this.source=Fe+"",this.flags=Ue,Qe&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=ut&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=ut&&this.parser.options.ecmaVersion>=9)},En.prototype.raise=function(ge){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+ge)},En.prototype.at=function(ge,Fe){Fe===void 0&&(Fe=!1);var Ue=this.source,Qe=Ue.length;if(ge>=Qe)return-1;var ut=Ue.charCodeAt(ge);if(!(Fe||this.switchU)||ut<=55295||ut>=57344||ge+1>=Qe)return ut;var pt=Ue.charCodeAt(ge+1);return pt>=56320&&pt<=57343?(ut<<10)+pt-56613888:ut},En.prototype.nextIndex=function(ge,Fe){Fe===void 0&&(Fe=!1);var Ue=this.source,Qe=Ue.length;if(ge>=Qe)return Qe;var ut=Ue.charCodeAt(ge),pt;return!(Fe||this.switchU)||ut<=55295||ut>=57344||ge+1>=Qe||(pt=Ue.charCodeAt(ge+1))<56320||pt>57343?ge+1:ge+2},En.prototype.current=function(ge){return ge===void 0&&(ge=!1),this.at(this.pos,ge)},En.prototype.lookahead=function(ge){return ge===void 0&&(ge=!1),this.at(this.nextIndex(this.pos,ge),ge)},En.prototype.advance=function(ge){ge===void 0&&(ge=!1),this.pos=this.nextIndex(this.pos,ge)},En.prototype.eat=function(ge,Fe){return Fe===void 0&&(Fe=!1),this.current(Fe)===ge?(this.advance(Fe),!0):!1},En.prototype.eatChars=function(ge,Fe){Fe===void 0&&(Fe=!1);for(var Ue=this.pos,Qe=0,ut=ge;Qe<ut.length;Qe+=1){var pt=ut[Qe],Vt=this.at(Ue,Fe);if(Vt===-1||Vt!==pt)return!1;Ue=this.nextIndex(Ue,Fe)}return this.pos=Ue,!0},zt.validateRegExpFlags=function(z){for(var ge=z.validFlags,Fe=z.flags,Ue=!1,Qe=!1,ut=0;ut<Fe.length;ut++){var pt=Fe.charAt(ut);ge.indexOf(pt)===-1&&this.raise(z.start,"Invalid regular expression flag"),Fe.indexOf(pt,ut+1)>-1&&this.raise(z.start,"Duplicate regular expression flag"),pt==="u"&&(Ue=!0),pt==="v"&&(Qe=!0)}this.options.ecmaVersion>=15&&Ue&&Qe&&this.raise(z.start,"Invalid regular expression flag")};function dr(z){for(var ge in z)return!0;return!1}zt.validateRegExpPattern=function(z){this.regexp_pattern(z),!z.switchN&&this.options.ecmaVersion>=9&&dr(z.groupNames)&&(z.switchN=!0,this.regexp_pattern(z))},zt.regexp_pattern=function(z){z.pos=0,z.lastIntValue=0,z.lastStringValue="",z.lastAssertionIsQuantifiable=!1,z.numCapturingParens=0,z.maxBackReference=0,z.groupNames=Object.create(null),z.backReferenceNames.length=0,z.branchID=null,this.regexp_disjunction(z),z.pos!==z.source.length&&(z.eat(41)&&z.raise("Unmatched ')'"),(z.eat(93)||z.eat(125))&&z.raise("Lone quantifier brackets")),z.maxBackReference>z.numCapturingParens&&z.raise("Invalid escape");for(var ge=0,Fe=z.backReferenceNames;ge<Fe.length;ge+=1){var Ue=Fe[ge];z.groupNames[Ue]||z.raise("Invalid named capture referenced")}},zt.regexp_disjunction=function(z){var ge=this.options.ecmaVersion>=16;for(ge&&(z.branchID=new yn(z.branchID,null)),this.regexp_alternative(z);z.eat(124);)ge&&(z.branchID=z.branchID.sibling()),this.regexp_alternative(z);ge&&(z.branchID=z.branchID.parent),this.regexp_eatQuantifier(z,!0)&&z.raise("Nothing to repeat"),z.eat(123)&&z.raise("Lone quantifier brackets")},zt.regexp_alternative=function(z){for(;z.pos<z.source.length&&this.regexp_eatTerm(z););},zt.regexp_eatTerm=function(z){return this.regexp_eatAssertion(z)?(z.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(z)&&z.switchU&&z.raise("Invalid quantifier"),!0):(z.switchU?this.regexp_eatAtom(z):this.regexp_eatExtendedAtom(z))?(this.regexp_eatQuantifier(z),!0):!1},zt.regexp_eatAssertion=function(z){var ge=z.pos;if(z.lastAssertionIsQuantifiable=!1,z.eat(94)||z.eat(36))return!0;if(z.eat(92)){if(z.eat(66)||z.eat(98))return!0;z.pos=ge}if(z.eat(40)&&z.eat(63)){var Fe=!1;if(this.options.ecmaVersion>=9&&(Fe=z.eat(60)),z.eat(61)||z.eat(33))return this.regexp_disjunction(z),z.eat(41)||z.raise("Unterminated group"),z.lastAssertionIsQuantifiable=!Fe,!0}return z.pos=ge,!1},zt.regexp_eatQuantifier=function(z,ge){return ge===void 0&&(ge=!1),this.regexp_eatQuantifierPrefix(z,ge)?(z.eat(63),!0):!1},zt.regexp_eatQuantifierPrefix=function(z,ge){return z.eat(42)||z.eat(43)||z.eat(63)||this.regexp_eatBracedQuantifier(z,ge)},zt.regexp_eatBracedQuantifier=function(z,ge){var Fe=z.pos;if(z.eat(123)){var Ue=0,Qe=-1;if(this.regexp_eatDecimalDigits(z)&&(Ue=z.lastIntValue,z.eat(44)&&this.regexp_eatDecimalDigits(z)&&(Qe=z.lastIntValue),z.eat(125)))return Qe!==-1&&Qe<Ue&&!ge&&z.raise("numbers out of order in {} quantifier"),!0;z.switchU&&!ge&&z.raise("Incomplete quantifier"),z.pos=Fe}return!1},zt.regexp_eatAtom=function(z){return this.regexp_eatPatternCharacters(z)||z.eat(46)||this.regexp_eatReverseSolidusAtomEscape(z)||this.regexp_eatCharacterClass(z)||this.regexp_eatUncapturingGroup(z)||this.regexp_eatCapturingGroup(z)},zt.regexp_eatReverseSolidusAtomEscape=function(z){var ge=z.pos;if(z.eat(92)){if(this.regexp_eatAtomEscape(z))return!0;z.pos=ge}return!1},zt.regexp_eatUncapturingGroup=function(z){var ge=z.pos;if(z.eat(40)){if(z.eat(63)&&z.eat(58)){if(this.regexp_disjunction(z),z.eat(41))return!0;z.raise("Unterminated group")}z.pos=ge}return!1},zt.regexp_eatCapturingGroup=function(z){if(z.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(z):z.current()===63&&z.raise("Invalid group"),this.regexp_disjunction(z),z.eat(41))return z.numCapturingParens+=1,!0;z.raise("Unterminated group")}return!1},zt.regexp_eatExtendedAtom=function(z){return z.eat(46)||this.regexp_eatReverseSolidusAtomEscape(z)||this.regexp_eatCharacterClass(z)||this.regexp_eatUncapturingGroup(z)||this.regexp_eatCapturingGroup(z)||this.regexp_eatInvalidBracedQuantifier(z)||this.regexp_eatExtendedPatternCharacter(z)},zt.regexp_eatInvalidBracedQuantifier=function(z){return this.regexp_eatBracedQuantifier(z,!0)&&z.raise("Nothing to repeat"),!1},zt.regexp_eatSyntaxCharacter=function(z){var ge=z.current();return Rr(ge)?(z.lastIntValue=ge,z.advance(),!0):!1};function Rr(z){return z===36||z>=40&&z<=43||z===46||z===63||z>=91&&z<=94||z>=123&&z<=125}zt.regexp_eatPatternCharacters=function(z){for(var ge=z.pos,Fe=0;(Fe=z.current())!==-1&&!Rr(Fe);)z.advance();return z.pos!==ge},zt.regexp_eatExtendedPatternCharacter=function(z){var ge=z.current();return ge!==-1&&ge!==36&&!(ge>=40&&ge<=43)&&ge!==46&&ge!==63&&ge!==91&&ge!==94&&ge!==124?(z.advance(),!0):!1},zt.regexp_groupSpecifier=function(z){if(z.eat(63)){this.regexp_eatGroupName(z)||z.raise("Invalid group");var ge=this.options.ecmaVersion>=16,Fe=z.groupNames[z.lastStringValue];if(Fe)if(ge)for(var Ue=0,Qe=Fe;Ue<Qe.length;Ue+=1){var ut=Qe[Ue];ut.separatedFrom(z.branchID)||z.raise("Duplicate capture group name")}else z.raise("Duplicate capture group name");ge?(Fe||(z.groupNames[z.lastStringValue]=[])).push(z.branchID):z.groupNames[z.lastStringValue]=!0}},zt.regexp_eatGroupName=function(z){if(z.lastStringValue="",z.eat(60)){if(this.regexp_eatRegExpIdentifierName(z)&&z.eat(62))return!0;z.raise("Invalid capture group name")}return!1},zt.regexp_eatRegExpIdentifierName=function(z){if(z.lastStringValue="",this.regexp_eatRegExpIdentifierStart(z)){for(z.lastStringValue+=He(z.lastIntValue);this.regexp_eatRegExpIdentifierPart(z);)z.lastStringValue+=He(z.lastIntValue);return!0}return!1},zt.regexp_eatRegExpIdentifierStart=function(z){var ge=z.pos,Fe=this.options.ecmaVersion>=11,Ue=z.current(Fe);return z.advance(Fe),Ue===92&&this.regexp_eatRegExpUnicodeEscapeSequence(z,Fe)&&(Ue=z.lastIntValue),Dr(Ue)?(z.lastIntValue=Ue,!0):(z.pos=ge,!1)};function Dr(z){return A(z,!0)||z===36||z===95}zt.regexp_eatRegExpIdentifierPart=function(z){var ge=z.pos,Fe=this.options.ecmaVersion>=11,Ue=z.current(Fe);return z.advance(Fe),Ue===92&&this.regexp_eatRegExpUnicodeEscapeSequence(z,Fe)&&(Ue=z.lastIntValue),Vr(Ue)?(z.lastIntValue=Ue,!0):(z.pos=ge,!1)};function Vr(z){return M(z,!0)||z===36||z===95||z===8204||z===8205}zt.regexp_eatAtomEscape=function(z){return this.regexp_eatBackReference(z)||this.regexp_eatCharacterClassEscape(z)||this.regexp_eatCharacterEscape(z)||z.switchN&&this.regexp_eatKGroupName(z)?!0:(z.switchU&&(z.current()===99&&z.raise("Invalid unicode escape"),z.raise("Invalid escape")),!1)},zt.regexp_eatBackReference=function(z){var ge=z.pos;if(this.regexp_eatDecimalEscape(z)){var Fe=z.lastIntValue;if(z.switchU)return Fe>z.maxBackReference&&(z.maxBackReference=Fe),!0;if(Fe<=z.numCapturingParens)return!0;z.pos=ge}return!1},zt.regexp_eatKGroupName=function(z){if(z.eat(107)){if(this.regexp_eatGroupName(z))return z.backReferenceNames.push(z.lastStringValue),!0;z.raise("Invalid named reference")}return!1},zt.regexp_eatCharacterEscape=function(z){return this.regexp_eatControlEscape(z)||this.regexp_eatCControlLetter(z)||this.regexp_eatZero(z)||this.regexp_eatHexEscapeSequence(z)||this.regexp_eatRegExpUnicodeEscapeSequence(z,!1)||!z.switchU&&this.regexp_eatLegacyOctalEscapeSequence(z)||this.regexp_eatIdentityEscape(z)},zt.regexp_eatCControlLetter=function(z){var ge=z.pos;if(z.eat(99)){if(this.regexp_eatControlLetter(z))return!0;z.pos=ge}return!1},zt.regexp_eatZero=function(z){return z.current()===48&&!pr(z.lookahead())?(z.lastIntValue=0,z.advance(),!0):!1},zt.regexp_eatControlEscape=function(z){var ge=z.current();return ge===116?(z.lastIntValue=9,z.advance(),!0):ge===110?(z.lastIntValue=10,z.advance(),!0):ge===118?(z.lastIntValue=11,z.advance(),!0):ge===102?(z.lastIntValue=12,z.advance(),!0):ge===114?(z.lastIntValue=13,z.advance(),!0):!1},zt.regexp_eatControlLetter=function(z){var ge=z.current();return Pr(ge)?(z.lastIntValue=ge%32,z.advance(),!0):!1};function Pr(z){return z>=65&&z<=90||z>=97&&z<=122}zt.regexp_eatRegExpUnicodeEscapeSequence=function(z,ge){ge===void 0&&(ge=!1);var Fe=z.pos,Ue=ge||z.switchU;if(z.eat(117)){if(this.regexp_eatFixedHexDigits(z,4)){var Qe=z.lastIntValue;if(Ue&&Qe>=55296&&Qe<=56319){var ut=z.pos;if(z.eat(92)&&z.eat(117)&&this.regexp_eatFixedHexDigits(z,4)){var pt=z.lastIntValue;if(pt>=56320&&pt<=57343)return z.lastIntValue=(Qe-55296)*1024+(pt-56320)+65536,!0}z.pos=ut,z.lastIntValue=Qe}return!0}if(Ue&&z.eat(123)&&this.regexp_eatHexDigits(z)&&z.eat(125)&&Br(z.lastIntValue))return!0;Ue&&z.raise("Invalid unicode escape"),z.pos=Fe}return!1};function Br(z){return z>=0&&z<=1114111}zt.regexp_eatIdentityEscape=function(z){if(z.switchU)return this.regexp_eatSyntaxCharacter(z)?!0:z.eat(47)?(z.lastIntValue=47,!0):!1;var ge=z.current();return ge!==99&&(!z.switchN||ge!==107)?(z.lastIntValue=ge,z.advance(),!0):!1},zt.regexp_eatDecimalEscape=function(z){z.lastIntValue=0;var ge=z.current();if(ge>=49&&ge<=57){do z.lastIntValue=10*z.lastIntValue+(ge-48),z.advance();while((ge=z.current())>=48&&ge<=57);return!0}return!1};var Cr=0,Ln=1,Nn=2;zt.regexp_eatCharacterClassEscape=function(z){var ge=z.current();if(Lr(ge))return z.lastIntValue=-1,z.advance(),Ln;var Fe=!1;if(z.switchU&&this.options.ecmaVersion>=9&&((Fe=ge===80)||ge===112)){z.lastIntValue=-1,z.advance();var Ue;if(z.eat(123)&&(Ue=this.regexp_eatUnicodePropertyValueExpression(z))&&z.eat(125))return Fe&&Ue===Nn&&z.raise("Invalid property name"),Ue;z.raise("Invalid property name")}return Cr};function Lr(z){return z===100||z===68||z===115||z===83||z===119||z===87}zt.regexp_eatUnicodePropertyValueExpression=function(z){var ge=z.pos;if(this.regexp_eatUnicodePropertyName(z)&&z.eat(61)){var Fe=z.lastStringValue;if(this.regexp_eatUnicodePropertyValue(z)){var Ue=z.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(z,Fe,Ue),Ln}}if(z.pos=ge,this.regexp_eatLoneUnicodePropertyNameOrValue(z)){var Qe=z.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(z,Qe)}return Cr},zt.regexp_validateUnicodePropertyNameAndValue=function(z,ge,Fe){Be(z.unicodeProperties.nonBinary,ge)||z.raise("Invalid property name"),z.unicodeProperties.nonBinary[ge].test(Fe)||z.raise("Invalid property value")},zt.regexp_validateUnicodePropertyNameOrValue=function(z,ge){if(z.unicodeProperties.binary.test(ge))return Ln;if(z.switchV&&z.unicodeProperties.binaryOfStrings.test(ge))return Nn;z.raise("Invalid property name")},zt.regexp_eatUnicodePropertyName=function(z){var ge=0;for(z.lastStringValue="";wr(ge=z.current());)z.lastStringValue+=He(ge),z.advance();return z.lastStringValue!==""};function wr(z){return Pr(z)||z===95}zt.regexp_eatUnicodePropertyValue=function(z){var ge=0;for(z.lastStringValue="";Fr(ge=z.current());)z.lastStringValue+=He(ge),z.advance();return z.lastStringValue!==""};function Fr(z){return wr(z)||pr(z)}zt.regexp_eatLoneUnicodePropertyNameOrValue=function(z){return this.regexp_eatUnicodePropertyValue(z)},zt.regexp_eatCharacterClass=function(z){if(z.eat(91)){var ge=z.eat(94),Fe=this.regexp_classContents(z);return z.eat(93)||z.raise("Unterminated character class"),ge&&Fe===Nn&&z.raise("Negated character class may contain strings"),!0}return!1},zt.regexp_classContents=function(z){return z.current()===93?Ln:z.switchV?this.regexp_classSetExpression(z):(this.regexp_nonEmptyClassRanges(z),Ln)},zt.regexp_nonEmptyClassRanges=function(z){for(;this.regexp_eatClassAtom(z);){var ge=z.lastIntValue;if(z.eat(45)&&this.regexp_eatClassAtom(z)){var Fe=z.lastIntValue;z.switchU&&(ge===-1||Fe===-1)&&z.raise("Invalid character class"),ge!==-1&&Fe!==-1&&ge>Fe&&z.raise("Range out of order in character class")}}},zt.regexp_eatClassAtom=function(z){var ge=z.pos;if(z.eat(92)){if(this.regexp_eatClassEscape(z))return!0;if(z.switchU){var Fe=z.current();(Fe===99||Ar(Fe))&&z.raise("Invalid class escape"),z.raise("Invalid escape")}z.pos=ge}var Ue=z.current();return Ue!==93?(z.lastIntValue=Ue,z.advance(),!0):!1},zt.regexp_eatClassEscape=function(z){var ge=z.pos;if(z.eat(98))return z.lastIntValue=8,!0;if(z.switchU&&z.eat(45))return z.lastIntValue=45,!0;if(!z.switchU&&z.eat(99)){if(this.regexp_eatClassControlLetter(z))return!0;z.pos=ge}return this.regexp_eatCharacterClassEscape(z)||this.regexp_eatCharacterEscape(z)},zt.regexp_classSetExpression=function(z){var ge=Ln,Fe;if(!this.regexp_eatClassSetRange(z))if(Fe=this.regexp_eatClassSetOperand(z)){Fe===Nn&&(ge=Nn);for(var Ue=z.pos;z.eatChars([38,38]);){if(z.current()!==38&&(Fe=this.regexp_eatClassSetOperand(z))){Fe!==Nn&&(ge=Ln);continue}z.raise("Invalid character in character class")}if(Ue!==z.pos)return ge;for(;z.eatChars([45,45]);)this.regexp_eatClassSetOperand(z)||z.raise("Invalid character in character class");if(Ue!==z.pos)return ge}else z.raise("Invalid character in character class");for(;;)if(!this.regexp_eatClassSetRange(z)){if(Fe=this.regexp_eatClassSetOperand(z),!Fe)return ge;Fe===Nn&&(ge=Nn)}},zt.regexp_eatClassSetRange=function(z){var ge=z.pos;if(this.regexp_eatClassSetCharacter(z)){var Fe=z.lastIntValue;if(z.eat(45)&&this.regexp_eatClassSetCharacter(z)){var Ue=z.lastIntValue;return Fe!==-1&&Ue!==-1&&Fe>Ue&&z.raise("Range out of order in character class"),!0}z.pos=ge}return!1},zt.regexp_eatClassSetOperand=function(z){return this.regexp_eatClassSetCharacter(z)?Ln:this.regexp_eatClassStringDisjunction(z)||this.regexp_eatNestedClass(z)},zt.regexp_eatNestedClass=function(z){var ge=z.pos;if(z.eat(91)){var Fe=z.eat(94),Ue=this.regexp_classContents(z);if(z.eat(93))return Fe&&Ue===Nn&&z.raise("Negated character class may contain strings"),Ue;z.pos=ge}if(z.eat(92)){var Qe=this.regexp_eatCharacterClassEscape(z);if(Qe)return Qe;z.pos=ge}return null},zt.regexp_eatClassStringDisjunction=function(z){var ge=z.pos;if(z.eatChars([92,113])){if(z.eat(123)){var Fe=this.regexp_classStringDisjunctionContents(z);if(z.eat(125))return Fe}else z.raise("Invalid escape");z.pos=ge}return null},zt.regexp_classStringDisjunctionContents=function(z){for(var ge=this.regexp_classString(z);z.eat(124);)this.regexp_classString(z)===Nn&&(ge=Nn);return ge},zt.regexp_classString=function(z){for(var ge=0;this.regexp_eatClassSetCharacter(z);)ge++;return ge===1?Ln:Nn},zt.regexp_eatClassSetCharacter=function(z){var ge=z.pos;if(z.eat(92))return this.regexp_eatCharacterEscape(z)||this.regexp_eatClassSetReservedPunctuator(z)?!0:z.eat(98)?(z.lastIntValue=8,!0):(z.pos=ge,!1);var Fe=z.current();return Fe<0||Fe===z.lookahead()&&qr(Fe)||Ur(Fe)?!1:(z.advance(),z.lastIntValue=Fe,!0)};function qr(z){return z===33||z>=35&&z<=38||z>=42&&z<=44||z===46||z>=58&&z<=64||z===94||z===96||z===126}function Ur(z){return z===40||z===41||z===45||z===47||z>=91&&z<=93||z>=123&&z<=125}zt.regexp_eatClassSetReservedPunctuator=function(z){var ge=z.current();return Hr(ge)?(z.lastIntValue=ge,z.advance(),!0):!1};function Hr(z){return z===33||z===35||z===37||z===38||z===44||z===45||z>=58&&z<=62||z===64||z===96||z===126}zt.regexp_eatClassControlLetter=function(z){var ge=z.current();return pr(ge)||ge===95?(z.lastIntValue=ge%32,z.advance(),!0):!1},zt.regexp_eatHexEscapeSequence=function(z){var ge=z.pos;if(z.eat(120)){if(this.regexp_eatFixedHexDigits(z,2))return!0;z.switchU&&z.raise("Invalid escape"),z.pos=ge}return!1},zt.regexp_eatDecimalDigits=function(z){var ge=z.pos,Fe=0;for(z.lastIntValue=0;pr(Fe=z.current());)z.lastIntValue=10*z.lastIntValue+(Fe-48),z.advance();return z.pos!==ge};function pr(z){return z>=48&&z<=57}zt.regexp_eatHexDigits=function(z){var ge=z.pos,Fe=0;for(z.lastIntValue=0;Er(Fe=z.current());)z.lastIntValue=16*z.lastIntValue+Tr(Fe),z.advance();return z.pos!==ge};function Er(z){return z>=48&&z<=57||z>=65&&z<=70||z>=97&&z<=102}function Tr(z){return z>=65&&z<=70?10+(z-65):z>=97&&z<=102?10+(z-97):z-48}zt.regexp_eatLegacyOctalEscapeSequence=function(z){if(this.regexp_eatOctalDigit(z)){var ge=z.lastIntValue;if(this.regexp_eatOctalDigit(z)){var Fe=z.lastIntValue;ge<=3&&this.regexp_eatOctalDigit(z)?z.lastIntValue=ge*64+Fe*8+z.lastIntValue:z.lastIntValue=ge*8+Fe}else z.lastIntValue=ge;return!0}return!1},zt.regexp_eatOctalDigit=function(z){var ge=z.current();return Ar(ge)?(z.lastIntValue=ge-48,z.advance(),!0):(z.lastIntValue=0,!1)};function Ar(z){return z>=48&&z<=55}zt.regexp_eatFixedHexDigits=function(z,ge){var Fe=z.pos;z.lastIntValue=0;for(var Ue=0;Ue<ge;++Ue){var Qe=z.current();if(!Er(Qe))return z.pos=Fe,!1;z.lastIntValue=16*z.lastIntValue+Tr(Qe),z.advance()}return!0};var mr=function(ge){this.type=ge.type,this.value=ge.value,this.start=ge.start,this.end=ge.end,ge.options.locations&&(this.loc=new Xe(ge,ge.startLoc,ge.endLoc)),ge.options.ranges&&(this.range=[ge.start,ge.end])},sn=yt.prototype;sn.next=function(z){!z&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword),this.options.onToken&&this.options.onToken(new mr(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()},sn.getToken=function(){return this.next(),new mr(this)},typeof Symbol<"u"&&(sn[Symbol.iterator]=function(){var z=this;return{next:function(){var ge=z.getToken();return{done:ge.type===V.eof,value:ge}}}}),sn.nextToken=function(){var z=this.curContext();if((!z||!z.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(V.eof);if(z.override)return z.override(this);this.readToken(this.fullCharCodeAtPos())},sn.readToken=function(z){return A(z,this.options.ecmaVersion>=6)||z===92?this.readWord():this.getTokenFromCode(z)},sn.fullCharCodeAtPos=function(){var z=this.input.charCodeAt(this.pos);if(z<=55295||z>=56320)return z;var ge=this.input.charCodeAt(this.pos+1);return ge<=56319||ge>=57344?z:(z<<10)+ge-56613888},sn.skipBlockComment=function(){var z=this.options.onComment&&this.curPosition(),ge=this.pos,Fe=this.input.indexOf("*/",this.pos+=2);if(Fe===-1&&this.raise(this.pos-2,"Unterminated comment"),this.pos=Fe+2,this.options.locations)for(var Ue=void 0,Qe=ge;(Ue=Oe(this.input,Qe,this.pos))>-1;)++this.curLine,Qe=this.lineStart=Ue;this.options.onComment&&this.options.onComment(!0,this.input.slice(ge+2,Fe),ge,this.pos,z,this.curPosition())},sn.skipLineComment=function(z){for(var ge=this.pos,Fe=this.options.onComment&&this.curPosition(),Ue=this.input.charCodeAt(this.pos+=z);this.pos<this.input.length&&!se(Ue);)Ue=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(ge+z,this.pos),ge,this.pos,Fe,this.curPosition())},sn.skipSpace=function(){e:for(;this.pos<this.input.length;){var z=this.input.charCodeAt(this.pos);switch(z){case 32:case 160:++this.pos;break;case 13:this.input.charCodeAt(this.pos+1)===10&&++this.pos;case 10:case 8232:case 8233:++this.pos,this.options.locations&&(++this.curLine,this.lineStart=this.pos);break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break e}break;default:if(z>8&&z<14||z>=5760&&Ne.test(String.fromCharCode(z)))++this.pos;else break e}}},sn.finishToken=function(z,ge){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var Fe=this.type;this.type=z,this.value=ge,this.updateContext(Fe)},sn.readToken_dot=function(){var z=this.input.charCodeAt(this.pos+1);if(z>=48&&z<=57)return this.readNumber(!0);var ge=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&z===46&&ge===46?(this.pos+=3,this.finishToken(V.ellipsis)):(++this.pos,this.finishToken(V.dot))},sn.readToken_slash=function(){var z=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):z===61?this.finishOp(V.assign,2):this.finishOp(V.slash,1)},sn.readToken_mult_modulo_exp=function(z){var ge=this.input.charCodeAt(this.pos+1),Fe=1,Ue=z===42?V.star:V.modulo;return this.options.ecmaVersion>=7&&z===42&&ge===42&&(++Fe,Ue=V.starstar,ge=this.input.charCodeAt(this.pos+2)),ge===61?this.finishOp(V.assign,Fe+1):this.finishOp(Ue,Fe)},sn.readToken_pipe_amp=function(z){var ge=this.input.charCodeAt(this.pos+1);if(ge===z){if(this.options.ecmaVersion>=12){var Fe=this.input.charCodeAt(this.pos+2);if(Fe===61)return this.finishOp(V.assign,3)}return this.finishOp(z===124?V.logicalOR:V.logicalAND,2)}return ge===61?this.finishOp(V.assign,2):this.finishOp(z===124?V.bitwiseOR:V.bitwiseAND,1)},sn.readToken_caret=function(){var z=this.input.charCodeAt(this.pos+1);return z===61?this.finishOp(V.assign,2):this.finishOp(V.bitwiseXOR,1)},sn.readToken_plus_min=function(z){var ge=this.input.charCodeAt(this.pos+1);return ge===z?ge===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||ne.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(V.incDec,2):ge===61?this.finishOp(V.assign,2):this.finishOp(V.plusMin,1)},sn.readToken_lt_gt=function(z){var ge=this.input.charCodeAt(this.pos+1),Fe=1;return ge===z?(Fe=z===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+Fe)===61?this.finishOp(V.assign,Fe+1):this.finishOp(V.bitShift,Fe)):ge===33&&z===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(ge===61&&(Fe=2),this.finishOp(V.relational,Fe))},sn.readToken_eq_excl=function(z){var ge=this.input.charCodeAt(this.pos+1);return ge===61?this.finishOp(V.equality,this.input.charCodeAt(this.pos+2)===61?3:2):z===61&&ge===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(V.arrow)):this.finishOp(z===61?V.eq:V.prefix,1)},sn.readToken_question=function(){var z=this.options.ecmaVersion;if(z>=11){var ge=this.input.charCodeAt(this.pos+1);if(ge===46){var Fe=this.input.charCodeAt(this.pos+2);if(Fe<48||Fe>57)return this.finishOp(V.questionDot,2)}if(ge===63){if(z>=12){var Ue=this.input.charCodeAt(this.pos+2);if(Ue===61)return this.finishOp(V.assign,3)}return this.finishOp(V.coalesce,2)}}return this.finishOp(V.question,1)},sn.readToken_numberSign=function(){var z=this.options.ecmaVersion,ge=35;if(z>=13&&(++this.pos,ge=this.fullCharCodeAtPos(),A(ge,!0)||ge===92))return this.finishToken(V.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+He(ge)+"'")},sn.getTokenFromCode=function(z){switch(z){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(V.parenL);case 41:return++this.pos,this.finishToken(V.parenR);case 59:return++this.pos,this.finishToken(V.semi);case 44:return++this.pos,this.finishToken(V.comma);case 91:return++this.pos,this.finishToken(V.bracketL);case 93:return++this.pos,this.finishToken(V.bracketR);case 123:return++this.pos,this.finishToken(V.braceL);case 125:return++this.pos,this.finishToken(V.braceR);case 58:return++this.pos,this.finishToken(V.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(V.backQuote);case 48:var ge=this.input.charCodeAt(this.pos+1);if(ge===120||ge===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(ge===111||ge===79)return this.readRadixNumber(8);if(ge===98||ge===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(z);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(z);case 124:case 38:return this.readToken_pipe_amp(z);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(z);case 60:case 62:return this.readToken_lt_gt(z);case 61:case 33:return this.readToken_eq_excl(z);case 63:return this.readToken_question();case 126:return this.finishOp(V.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+He(z)+"'")},sn.finishOp=function(z,ge){var Fe=this.input.slice(this.pos,this.pos+ge);return this.pos+=ge,this.finishToken(z,Fe)},sn.readRegexp=function(){for(var z,ge,Fe=this.pos;;){this.pos>=this.input.length&&this.raise(Fe,"Unterminated regular expression");var Ue=this.input.charAt(this.pos);if(ne.test(Ue)&&this.raise(Fe,"Unterminated regular expression"),z)z=!1;else{if(Ue==="[")ge=!0;else if(Ue==="]"&&ge)ge=!1;else if(Ue==="/"&&!ge)break;z=Ue==="\\"}++this.pos}var Qe=this.input.slice(Fe,this.pos);++this.pos;var ut=this.pos,pt=this.readWord1();this.containsEsc&&this.unexpected(ut);var Vt=this.regexpState||(this.regexpState=new En(this));Vt.reset(Fe,Qe,pt),this.validateRegExpFlags(Vt),this.validateRegExpPattern(Vt);var Ft=null;try{Ft=new RegExp(Qe,pt)}catch{}return this.finishToken(V.regexp,{pattern:Qe,flags:pt,value:Ft})},sn.readInt=function(z,ge,Fe){for(var Ue=this.options.ecmaVersion>=12&&ge===void 0,Qe=Fe&&this.input.charCodeAt(this.pos)===48,ut=this.pos,pt=0,Vt=0,Ft=0,nn=ge??1/0;Ft<nn;++Ft,++this.pos){var Zt=this.input.charCodeAt(this.pos),_n=void 0;if(Ue&&Zt===95){Qe&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed in legacy octal numeric literals"),Vt===95&&this.raiseRecoverable(this.pos,"Numeric separator must be exactly one underscore"),Ft===0&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits"),Vt=Zt;continue}if(Zt>=97?_n=Zt-97+10:Zt>=65?_n=Zt-65+10:Zt>=48&&Zt<=57?_n=Zt-48:_n=1/0,_n>=z)break;Vt=Zt,pt=pt*z+_n}return Ue&&Vt===95&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===ut||ge!=null&&this.pos-ut!==ge?null:pt};function Gr(z,ge){return ge?parseInt(z,8):parseFloat(z.replace(/_/g,""))}function Ir(z){return typeof BigInt!="function"?null:BigInt(z.replace(/_/g,""))}sn.readRadixNumber=function(z){var ge=this.pos;this.pos+=2;var Fe=this.readInt(z);return Fe==null&&this.raise(this.start+2,"Expected number in radix "+z),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(Fe=Ir(this.input.slice(ge,this.pos)),++this.pos):A(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(V.num,Fe)},sn.readNumber=function(z){var ge=this.pos;!z&&this.readInt(10,void 0,!0)===null&&this.raise(ge,"Invalid number");var Fe=this.pos-ge>=2&&this.input.charCodeAt(ge)===48;Fe&&this.strict&&this.raise(ge,"Invalid number");var Ue=this.input.charCodeAt(this.pos);if(!Fe&&!z&&this.options.ecmaVersion>=11&&Ue===110){var Qe=Ir(this.input.slice(ge,this.pos));return++this.pos,A(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(V.num,Qe)}Fe&&/[89]/.test(this.input.slice(ge,this.pos))&&(Fe=!1),Ue===46&&!Fe&&(++this.pos,this.readInt(10),Ue=this.input.charCodeAt(this.pos)),(Ue===69||Ue===101)&&!Fe&&(Ue=this.input.charCodeAt(++this.pos),(Ue===43||Ue===45)&&++this.pos,this.readInt(10)===null&&this.raise(ge,"Invalid number")),A(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var ut=Gr(this.input.slice(ge,this.pos),Fe);return this.finishToken(V.num,ut)},sn.readCodePoint=function(){var z=this.input.charCodeAt(this.pos),ge;if(z===123){this.options.ecmaVersion<6&&this.unexpected();var Fe=++this.pos;ge=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,ge>1114111&&this.invalidStringToken(Fe,"Code point out of bounds")}else ge=this.readHexChar(4);return ge},sn.readString=function(z){for(var ge="",Fe=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var Ue=this.input.charCodeAt(this.pos);if(Ue===z)break;Ue===92?(ge+=this.input.slice(Fe,this.pos),ge+=this.readEscapedChar(!1),Fe=this.pos):Ue===8232||Ue===8233?(this.options.ecmaVersion<10&&this.raise(this.start,"Unterminated string constant"),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(se(Ue)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return ge+=this.input.slice(Fe,this.pos++),this.finishToken(V.string,ge)};var Nr={};sn.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(z){if(z===Nr)this.readInvalidTemplateToken();else throw z}this.inTemplateElement=!1},sn.invalidStringToken=function(z,ge){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Nr;this.raise(z,ge)},sn.readTmplToken=function(){for(var z="",ge=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var Fe=this.input.charCodeAt(this.pos);if(Fe===96||Fe===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos===this.start&&(this.type===V.template||this.type===V.invalidTemplate)?Fe===36?(this.pos+=2,this.finishToken(V.dollarBraceL)):(++this.pos,this.finishToken(V.backQuote)):(z+=this.input.slice(ge,this.pos),this.finishToken(V.template,z));if(Fe===92)z+=this.input.slice(ge,this.pos),z+=this.readEscapedChar(!0),ge=this.pos;else if(se(Fe)){switch(z+=this.input.slice(ge,this.pos),++this.pos,Fe){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:z+=`
1227
1227
  `;break;default:z+=String.fromCharCode(Fe);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),ge=this.pos}else++this.pos}},sn.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case"\\":++this.pos;break;case"$":if(this.input[this.pos+1]!=="{")break;case"`":return this.finishToken(V.invalidTemplate,this.input.slice(this.start,this.pos));case"\r":this.input[this.pos+1]===`
1228
1228
  `&&++this.pos;case`
1229
1229
  `:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")},sn.readEscapedChar=function(z){var ge=this.input.charCodeAt(++this.pos);switch(++this.pos,ge){case 110:return`
1230
- `;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return He(this.readCodePoint());case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),z){var Fe=this.pos-1;this.invalidStringToken(Fe,"Invalid escape sequence in template string")}default:if(ge>=48&&ge<=55){var Ue=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],Qe=parseInt(Ue,8);return Qe>255&&(Ue=Ue.slice(0,-1),Qe=parseInt(Ue,8)),this.pos+=Ue.length-1,ge=this.input.charCodeAt(this.pos),(Ue!=="0"||ge===56||ge===57)&&(this.strict||z)&&this.invalidStringToken(this.pos-1-Ue.length,z?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(Qe)}return se(ge)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(ge)}},sn.readHexChar=function(z){var ge=this.pos,Fe=this.readInt(16,z);return Fe===null&&this.invalidStringToken(ge,"Bad character escape sequence"),Fe},sn.readWord1=function(){this.containsEsc=!1;for(var z="",ge=!0,Fe=this.pos,Ue=this.options.ecmaVersion>=6;this.pos<this.input.length;){var Qe=this.fullCharCodeAtPos();if(M(Qe,Ue))this.pos+=Qe<=65535?1:2;else if(Qe===92){this.containsEsc=!0,z+=this.input.slice(Fe,this.pos);var ut=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var pt=this.readCodePoint();(ge?A:M)(pt,Ue)||this.invalidStringToken(ut,"Invalid Unicode escape"),z+=He(pt),Fe=this.pos}else break;ge=!1}return z+this.input.slice(Fe,this.pos)},sn.readWord=function(){var z=this.readWord1(),ge=V.name;return this.keywords.test(z)&&(ge=te[z]),this.finishToken(ge,z)};var Mr="8.12.1";yt.acorn={Parser:yt,version:Mr,defaultOptions:Je,Position:ze,SourceLocation:Xe,getLineInfo:nt,Node:qn,TokenType:I,tokTypes:V,keywordTypes:te,TokContext:Zt,tokContexts:Ut,isIdentifierChar:M,isIdentifierStart:A,Token:mr,isNewLine:se,lineBreak:ne,lineBreakG:ae,nonASCIIwhitespace:Ne};function zr(z,ge){return yt.parse(z,ge)}function Wr(z,ge,Fe){return yt.parseExpressionAt(z,ge,Fe)}function Kr(z,ge){return yt.tokenizer(z,ge)}n.Node=qn,n.Parser=yt,n.Position=ze,n.SourceLocation=Xe,n.TokContext=Zt,n.Token=mr,n.TokenType=I,n.defaultOptions=Je,n.getLineInfo=nt,n.isIdentifierChar=M,n.isIdentifierStart=A,n.isNewLine=se,n.keywordTypes=te,n.lineBreak=ne,n.lineBreakG=ae,n.nonASCIIwhitespace=Ne,n.parse=zr,n.parseExpressionAt=Wr,n.tokContexts=Ut,n.tokTypes=V,n.tokenizer=Kr,n.version=Mr})}),require_acorn_jsx=__commonJS((e,t)=>{var n=require_xhtml(),o=/^[\da-fA-F]+$/,l=/^\d+$/,d=new WeakMap;function f(_){_=_.Parser.acorn||_;let S=d.get(_);if(!S){const R=_.tokTypes,C=_.TokContext,E=_.TokenType,A=new C("<tag",!1),M=new C("</tag",!1),I=new C("<tag>...</tag>",!0,!0),j={tc_oTag:A,tc_cTag:M,tc_expr:I},q={jsxName:new E("jsxName"),jsxText:new E("jsxText",{beforeExpr:!0}),jsxTagStart:new E("jsxTagStart",{startsExpr:!0}),jsxTagEnd:new E("jsxTagEnd")};q.jsxTagStart.updateContext=function(){this.context.push(I),this.context.push(A),this.exprAllowed=!1},q.jsxTagEnd.updateContext=function(Q){let te=this.context.pop();te===A&&Q===R.slash||te===M?(this.context.pop(),this.exprAllowed=this.curContext()===I):this.exprAllowed=!0},S={tokContexts:j,tokTypes:q},d.set(_,S)}return S}function g(_){if(!_)return _;if(_.type==="JSXIdentifier")return _.name;if(_.type==="JSXNamespacedName")return _.namespace.name+":"+_.name.name;if(_.type==="JSXMemberExpression")return g(_.object)+"."+g(_.property)}t.exports=function(_){return _=_||{},function(S){return b({allowNamespaces:_.allowNamespaces!==!1,allowNamespacedObjects:!!_.allowNamespacedObjects,autoCloseVoidElements:!!_.autoCloseVoidElements},S)}},Object.defineProperty(t.exports,"tokTypes",{get:function(){return f(require_acorn()).tokTypes},configurable:!0,enumerable:!0});function b(_,S){const R=S.acorn||require_acorn(),C=f(R),E=R.tokTypes,A=C.tokTypes,M=R.tokContexts,I=C.tokContexts.tc_oTag,j=C.tokContexts.tc_cTag,q=C.tokContexts.tc_expr,Q=R.isNewLine,te=R.isIdentifierStart,F=R.isIdentifierChar;return class extends S{static get acornJsx(){return C}jsx_readToken(){let V="",ne=this.pos;for(;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated JSX contents");let ae=this.input.charCodeAt(this.pos);switch(ae){case 60:case 123:return this.pos===this.start?ae===60&&this.exprAllowed?(++this.pos,this.finishToken(A.jsxTagStart)):this.getTokenFromCode(ae):(V+=this.input.slice(ne,this.pos),this.finishToken(A.jsxText,V));case 38:V+=this.input.slice(ne,this.pos),V+=this.jsx_readEntity(),ne=this.pos;break;case 62:case 125:this.raise(this.pos,"Unexpected token `"+this.input[this.pos]+"`. Did you mean `"+(ae===62?"&gt;":"&rbrace;")+'` or `{"'+this.input[this.pos]+'"}`?');default:Q(ae)?(V+=this.input.slice(ne,this.pos),V+=this.jsx_readNewLine(!0),ne=this.pos):++this.pos}}}jsx_readNewLine(V){let ne=this.input.charCodeAt(this.pos),ae;return++this.pos,ne===13&&this.input.charCodeAt(this.pos)===10?(++this.pos,ae=V?`
1230
+ `;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return He(this.readCodePoint());case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),z){var Fe=this.pos-1;this.invalidStringToken(Fe,"Invalid escape sequence in template string")}default:if(ge>=48&&ge<=55){var Ue=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],Qe=parseInt(Ue,8);return Qe>255&&(Ue=Ue.slice(0,-1),Qe=parseInt(Ue,8)),this.pos+=Ue.length-1,ge=this.input.charCodeAt(this.pos),(Ue!=="0"||ge===56||ge===57)&&(this.strict||z)&&this.invalidStringToken(this.pos-1-Ue.length,z?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(Qe)}return se(ge)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(ge)}},sn.readHexChar=function(z){var ge=this.pos,Fe=this.readInt(16,z);return Fe===null&&this.invalidStringToken(ge,"Bad character escape sequence"),Fe},sn.readWord1=function(){this.containsEsc=!1;for(var z="",ge=!0,Fe=this.pos,Ue=this.options.ecmaVersion>=6;this.pos<this.input.length;){var Qe=this.fullCharCodeAtPos();if(M(Qe,Ue))this.pos+=Qe<=65535?1:2;else if(Qe===92){this.containsEsc=!0,z+=this.input.slice(Fe,this.pos);var ut=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var pt=this.readCodePoint();(ge?A:M)(pt,Ue)||this.invalidStringToken(ut,"Invalid Unicode escape"),z+=He(pt),Fe=this.pos}else break;ge=!1}return z+this.input.slice(Fe,this.pos)},sn.readWord=function(){var z=this.readWord1(),ge=V.name;return this.keywords.test(z)&&(ge=te[z]),this.finishToken(ge,z)};var Mr="8.12.1";yt.acorn={Parser:yt,version:Mr,defaultOptions:Je,Position:ze,SourceLocation:Xe,getLineInfo:nt,Node:qn,TokenType:I,tokTypes:V,keywordTypes:te,TokContext:Qt,tokContexts:Ut,isIdentifierChar:M,isIdentifierStart:A,Token:mr,isNewLine:se,lineBreak:ne,lineBreakG:ae,nonASCIIwhitespace:Ne};function zr(z,ge){return yt.parse(z,ge)}function Wr(z,ge,Fe){return yt.parseExpressionAt(z,ge,Fe)}function Kr(z,ge){return yt.tokenizer(z,ge)}n.Node=qn,n.Parser=yt,n.Position=ze,n.SourceLocation=Xe,n.TokContext=Qt,n.Token=mr,n.TokenType=I,n.defaultOptions=Je,n.getLineInfo=nt,n.isIdentifierChar=M,n.isIdentifierStart=A,n.isNewLine=se,n.keywordTypes=te,n.lineBreak=ne,n.lineBreakG=ae,n.nonASCIIwhitespace=Ne,n.parse=zr,n.parseExpressionAt=Wr,n.tokContexts=Ut,n.tokTypes=V,n.tokenizer=Kr,n.version=Mr})}),require_acorn_jsx=__commonJS((e,t)=>{var n=require_xhtml(),o=/^[\da-fA-F]+$/,l=/^\d+$/,d=new WeakMap;function f(_){_=_.Parser.acorn||_;let S=d.get(_);if(!S){const R=_.tokTypes,C=_.TokContext,E=_.TokenType,A=new C("<tag",!1),M=new C("</tag",!1),I=new C("<tag>...</tag>",!0,!0),j={tc_oTag:A,tc_cTag:M,tc_expr:I},q={jsxName:new E("jsxName"),jsxText:new E("jsxText",{beforeExpr:!0}),jsxTagStart:new E("jsxTagStart",{startsExpr:!0}),jsxTagEnd:new E("jsxTagEnd")};q.jsxTagStart.updateContext=function(){this.context.push(I),this.context.push(A),this.exprAllowed=!1},q.jsxTagEnd.updateContext=function(Q){let te=this.context.pop();te===A&&Q===R.slash||te===M?(this.context.pop(),this.exprAllowed=this.curContext()===I):this.exprAllowed=!0},S={tokContexts:j,tokTypes:q},d.set(_,S)}return S}function g(_){if(!_)return _;if(_.type==="JSXIdentifier")return _.name;if(_.type==="JSXNamespacedName")return _.namespace.name+":"+_.name.name;if(_.type==="JSXMemberExpression")return g(_.object)+"."+g(_.property)}t.exports=function(_){return _=_||{},function(S){return b({allowNamespaces:_.allowNamespaces!==!1,allowNamespacedObjects:!!_.allowNamespacedObjects,autoCloseVoidElements:!!_.autoCloseVoidElements},S)}},Object.defineProperty(t.exports,"tokTypes",{get:function(){return f(require_acorn()).tokTypes},configurable:!0,enumerable:!0});function b(_,S){const R=S.acorn||require_acorn(),C=f(R),E=R.tokTypes,A=C.tokTypes,M=R.tokContexts,I=C.tokContexts.tc_oTag,j=C.tokContexts.tc_cTag,q=C.tokContexts.tc_expr,Q=R.isNewLine,te=R.isIdentifierStart,F=R.isIdentifierChar;return class extends S{static get acornJsx(){return C}jsx_readToken(){let V="",ne=this.pos;for(;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated JSX contents");let ae=this.input.charCodeAt(this.pos);switch(ae){case 60:case 123:return this.pos===this.start?ae===60&&this.exprAllowed?(++this.pos,this.finishToken(A.jsxTagStart)):this.getTokenFromCode(ae):(V+=this.input.slice(ne,this.pos),this.finishToken(A.jsxText,V));case 38:V+=this.input.slice(ne,this.pos),V+=this.jsx_readEntity(),ne=this.pos;break;case 62:case 125:this.raise(this.pos,"Unexpected token `"+this.input[this.pos]+"`. Did you mean `"+(ae===62?"&gt;":"&rbrace;")+'` or `{"'+this.input[this.pos]+'"}`?');default:Q(ae)?(V+=this.input.slice(ne,this.pos),V+=this.jsx_readNewLine(!0),ne=this.pos):++this.pos}}}jsx_readNewLine(V){let ne=this.input.charCodeAt(this.pos),ae;return++this.pos,ne===13&&this.input.charCodeAt(this.pos)===10?(++this.pos,ae=V?`
1231
1231
  `:`\r
1232
1232
  `):ae=String.fromCharCode(ne),this.options.locations&&(++this.curLine,this.lineStart=this.pos),ae}jsx_readString(V){let ne="",ae=++this.pos;for(;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");let se=this.input.charCodeAt(this.pos);if(se===V)break;se===38?(ne+=this.input.slice(ae,this.pos),ne+=this.jsx_readEntity(),ae=this.pos):Q(se)?(ne+=this.input.slice(ae,this.pos),ne+=this.jsx_readNewLine(!1),ae=this.pos):++this.pos}return ne+=this.input.slice(ae,this.pos++),this.finishToken(E.string,ne)}jsx_readEntity(){let V="",ne=0,ae,se=this.input[this.pos];se!=="&"&&this.raise(this.pos,"Entity must start with an ampersand");let Oe=++this.pos;for(;this.pos<this.input.length&&ne++<10;){if(se=this.input[this.pos++],se===";"){V[0]==="#"?V[1]==="x"?(V=V.substr(2),o.test(V)&&(ae=String.fromCharCode(parseInt(V,16)))):(V=V.substr(1),l.test(V)&&(ae=String.fromCharCode(parseInt(V,10)))):ae=n[V];break}V+=se}return ae||(this.pos=Oe,"&")}jsx_readWord(){let V,ne=this.pos;do V=this.input.charCodeAt(++this.pos);while(F(V)||V===45);return this.finishToken(A.jsxName,this.input.slice(ne,this.pos))}jsx_parseIdentifier(){let V=this.startNode();return this.type===A.jsxName?V.name=this.value:this.type.keyword?V.name=this.type.keyword:this.unexpected(),this.next(),this.finishNode(V,"JSXIdentifier")}jsx_parseNamespacedName(){let V=this.start,ne=this.startLoc,ae=this.jsx_parseIdentifier();if(!_.allowNamespaces||!this.eat(E.colon))return ae;var se=this.startNodeAt(V,ne);return se.namespace=ae,se.name=this.jsx_parseIdentifier(),this.finishNode(se,"JSXNamespacedName")}jsx_parseElementName(){if(this.type===A.jsxTagEnd)return"";let V=this.start,ne=this.startLoc,ae=this.jsx_parseNamespacedName();for(this.type===E.dot&&ae.type==="JSXNamespacedName"&&!_.allowNamespacedObjects&&this.unexpected();this.eat(E.dot);){let se=this.startNodeAt(V,ne);se.object=ae,se.property=this.jsx_parseIdentifier(),ae=this.finishNode(se,"JSXMemberExpression")}return ae}jsx_parseAttributeValue(){switch(this.type){case E.braceL:let V=this.jsx_parseExpressionContainer();return V.expression.type==="JSXEmptyExpression"&&this.raise(V.start,"JSX attributes must only be assigned a non-empty expression"),V;case A.jsxTagStart:case E.string:return this.parseExprAtom();default:this.raise(this.start,"JSX value should be either an expression or a quoted JSX text")}}jsx_parseEmptyExpression(){let V=this.startNodeAt(this.lastTokEnd,this.lastTokEndLoc);return this.finishNodeAt(V,"JSXEmptyExpression",this.start,this.startLoc)}jsx_parseExpressionContainer(){let V=this.startNode();return this.next(),V.expression=this.type===E.braceR?this.jsx_parseEmptyExpression():this.parseExpression(),this.expect(E.braceR),this.finishNode(V,"JSXExpressionContainer")}jsx_parseAttribute(){let V=this.startNode();return this.eat(E.braceL)?(this.expect(E.ellipsis),V.argument=this.parseMaybeAssign(),this.expect(E.braceR),this.finishNode(V,"JSXSpreadAttribute")):(V.name=this.jsx_parseNamespacedName(),V.value=this.eat(E.eq)?this.jsx_parseAttributeValue():null,this.finishNode(V,"JSXAttribute"))}jsx_parseOpeningElementAt(V,ne){let ae=this.startNodeAt(V,ne);ae.attributes=[];let se=this.jsx_parseElementName();for(se&&(ae.name=se);this.type!==E.slash&&this.type!==A.jsxTagEnd;)ae.attributes.push(this.jsx_parseAttribute());ae.selfClosing=this.eat(E.slash),this.expect(A.jsxTagEnd);const Oe=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"];return _.autoCloseVoidElements&&se&&Oe.includes(se.name)&&(ae.selfClosing=!0),this.finishNode(ae,se?"JSXOpeningElement":"JSXOpeningFragment")}jsx_parseClosingElementAt(V,ne){let ae=this.startNodeAt(V,ne),se=this.jsx_parseElementName();return se&&(ae.name=se),this.expect(A.jsxTagEnd),this.finishNode(ae,se?"JSXClosingElement":"JSXClosingFragment")}jsx_parseElementAt(V,ne){let ae=this.startNodeAt(V,ne),se=[],Oe=this.jsx_parseOpeningElementAt(V,ne),Ne=null;if(!Oe.selfClosing){e:for(;;)switch(this.type){case A.jsxTagStart:if(V=this.start,ne=this.startLoc,this.next(),this.eat(E.slash)){Ne=this.jsx_parseClosingElementAt(V,ne);break e}se.push(this.jsx_parseElementAt(V,ne));break;case A.jsxText:se.push(this.parseExprAtom());break;case E.braceL:se.push(this.jsx_parseExpressionContainer());break;default:this.unexpected()}g(Ne.name)!==g(Oe.name)&&this.raise(Ne.start,"Expected corresponding JSX closing tag for <"+g(Oe.name)+">")}let oe=Oe.name?"Element":"Fragment";return ae["opening"+oe]=Oe,ae["closing"+oe]=Ne,ae.children=se,this.type===E.relational&&this.value==="<"&&this.raise(this.start,"Adjacent JSX elements must be wrapped in an enclosing tag"),this.finishNode(ae,"JSX"+oe)}jsx_parseText(){let V=this.parseLiteral(this.value);return V.type="JSXText",V}jsx_parseElement(){let V=this.start,ne=this.startLoc;return this.next(),this.jsx_parseElementAt(V,ne)}parseExprAtom(V){return this.type===A.jsxText?this.jsx_parseText():this.type===A.jsxTagStart?this.jsx_parseElement():super.parseExprAtom(V)}readToken(V){let ne=this.curContext();if(ne===q)return this.jsx_readToken();if(ne===I||ne===j){if(te(V))return this.jsx_readWord();if(V==62)return++this.pos,this.finishToken(A.jsxTagEnd);if((V===34||V===39)&&ne==I)return this.jsx_readString(V)}return V===60&&this.exprAllowed&&this.input.charCodeAt(this.pos+1)!==33?(++this.pos,this.finishToken(A.jsxTagStart)):super.readToken(V)}updateContext(V){if(this.type==E.braceL){var ne=this.curContext();ne==I?this.context.push(M.b_expr):ne==q?this.context.push(M.b_tmpl):super.updateContext(V),this.exprAllowed=!0}else if(this.type===E.slash&&V===A.jsxTagStart)this.context.length-=2,this.context.push(j),this.exprAllowed=!1;else return super.updateContext(V)}}}}),astralIdentifierCodes=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,370,1,81,2,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,10,1,2,0,49,6,4,4,14,9,5351,0,7,14,13835,9,87,9,39,4,60,6,26,9,1014,0,2,54,8,3,82,0,12,1,19628,1,4706,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,983,6,110,6,6,9,4759,9,787719,239],astralIdentifierStartCodes=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,68,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,349,41,7,1,79,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,4026,582,8634,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,689,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,43,8,8936,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,757,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4153,7,221,3,5761,15,7472,16,621,2467,541,1507,4938,6,4191],nonASCIIidentifierChars="‌‍·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛࢘-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᫎᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‌‍‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・",nonASCIIidentifierStartChars="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢎࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೝೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲈᲐ-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꟊꟐꟑꟓꟕ-ꟙꟲ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",reservedWords={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},ecma5AndLessKeywords="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",keywords$1={5:ecma5AndLessKeywords,"5module":ecma5AndLessKeywords+" export import",6:ecma5AndLessKeywords+" const class extends export import super"},keywordRelationalOperator=/^in(stanceof)?$/,nonASCIIidentifierStart=new RegExp("["+nonASCIIidentifierStartChars+"]"),nonASCIIidentifier=new RegExp("["+nonASCIIidentifierStartChars+nonASCIIidentifierChars+"]");function isInAstralSet(e,t){for(var n=65536,o=0;o<t.length;o+=2){if(n+=t[o],n>e)return!1;if(n+=t[o+1],n>=e)return!0}return!1}function isIdentifierStart(e,t){return e<65?e===36:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&nonASCIIidentifierStart.test(String.fromCharCode(e)):t===!1?!1:isInAstralSet(e,astralIdentifierStartCodes)}function isIdentifierChar(e,t){return e<48?e===36:e<58?!0:e<65?!1:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&nonASCIIidentifier.test(String.fromCharCode(e)):t===!1?!1:isInAstralSet(e,astralIdentifierStartCodes)||isInAstralSet(e,astralIdentifierCodes)}var TokenType=function e(t,n){n===void 0&&(n={}),this.label=t,this.keyword=n.keyword,this.beforeExpr=!!n.beforeExpr,this.startsExpr=!!n.startsExpr,this.isLoop=!!n.isLoop,this.isAssign=!!n.isAssign,this.prefix=!!n.prefix,this.postfix=!!n.postfix,this.binop=n.binop||null,this.updateContext=null};function binop(e,t){return new TokenType(e,{beforeExpr:!0,binop:t})}var beforeExpr={beforeExpr:!0},startsExpr={startsExpr:!0},keywords={};function kw(e,t){return t===void 0&&(t={}),t.keyword=e,keywords[e]=new TokenType(e,t)}var types$1={num:new TokenType("num",startsExpr),regexp:new TokenType("regexp",startsExpr),string:new TokenType("string",startsExpr),name:new TokenType("name",startsExpr),privateId:new TokenType("privateId",startsExpr),eof:new TokenType("eof"),bracketL:new TokenType("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new TokenType("]"),braceL:new TokenType("{",{beforeExpr:!0,startsExpr:!0}),braceR:new TokenType("}"),parenL:new TokenType("(",{beforeExpr:!0,startsExpr:!0}),parenR:new TokenType(")"),comma:new TokenType(",",beforeExpr),semi:new TokenType(";",beforeExpr),colon:new TokenType(":",beforeExpr),dot:new TokenType("."),question:new TokenType("?",beforeExpr),questionDot:new TokenType("?."),arrow:new TokenType("=>",beforeExpr),template:new TokenType("template"),invalidTemplate:new TokenType("invalidTemplate"),ellipsis:new TokenType("...",beforeExpr),backQuote:new TokenType("`",startsExpr),dollarBraceL:new TokenType("${",{beforeExpr:!0,startsExpr:!0}),eq:new TokenType("=",{beforeExpr:!0,isAssign:!0}),assign:new TokenType("_=",{beforeExpr:!0,isAssign:!0}),incDec:new TokenType("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new TokenType("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:binop("||",1),logicalAND:binop("&&",2),bitwiseOR:binop("|",3),bitwiseXOR:binop("^",4),bitwiseAND:binop("&",5),equality:binop("==/!=/===/!==",6),relational:binop("</>/<=/>=",7),bitShift:binop("<</>>/>>>",8),plusMin:new TokenType("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:binop("%",10),star:binop("*",10),slash:binop("/",10),starstar:new TokenType("**",{beforeExpr:!0}),coalesce:binop("??",1),_break:kw("break"),_case:kw("case",beforeExpr),_catch:kw("catch"),_continue:kw("continue"),_debugger:kw("debugger"),_default:kw("default",beforeExpr),_do:kw("do",{isLoop:!0,beforeExpr:!0}),_else:kw("else",beforeExpr),_finally:kw("finally"),_for:kw("for",{isLoop:!0}),_function:kw("function",startsExpr),_if:kw("if"),_return:kw("return",beforeExpr),_switch:kw("switch"),_throw:kw("throw",beforeExpr),_try:kw("try"),_var:kw("var"),_const:kw("const"),_while:kw("while",{isLoop:!0}),_with:kw("with"),_new:kw("new",{beforeExpr:!0,startsExpr:!0}),_this:kw("this",startsExpr),_super:kw("super",startsExpr),_class:kw("class",startsExpr),_extends:kw("extends",beforeExpr),_export:kw("export"),_import:kw("import",startsExpr),_null:kw("null",startsExpr),_true:kw("true",startsExpr),_false:kw("false",startsExpr),_in:kw("in",{beforeExpr:!0,binop:7}),_instanceof:kw("instanceof",{beforeExpr:!0,binop:7}),_typeof:kw("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:kw("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:kw("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},lineBreak=/\r\n?|\n|\u2028|\u2029/,lineBreakG=new RegExp(lineBreak.source,"g");function isNewLine(e){return e===10||e===13||e===8232||e===8233}function nextLineBreak(e,t,n){n===void 0&&(n=e.length);for(var o=t;o<n;o++){var l=e.charCodeAt(o);if(isNewLine(l))return o<n-1&&l===13&&e.charCodeAt(o+1)===10?o+2:o+1}return-1}var nonASCIIwhitespace=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,skipWhiteSpace=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,ref=Object.prototype,hasOwnProperty=ref.hasOwnProperty,toString=ref.toString,hasOwn=Object.hasOwn||function(e,t){return hasOwnProperty.call(e,t)},isArray=Array.isArray||function(e){return toString.call(e)==="[object Array]"},regexpCache=Object.create(null);function wordsRegexp(e){return regexpCache[e]||(regexpCache[e]=new RegExp("^(?:"+e.replace(/ /g,"|")+")$"))}function codePointToString(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}var loneSurrogate=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,Position=function e(t,n){this.line=t,this.column=n};Position.prototype.offset=function e(t){return new Position(this.line,this.column+t)};var SourceLocation=function e(t,n,o){this.start=n,this.end=o,t.sourceFile!==null&&(this.source=t.sourceFile)};function getLineInfo(e,t){for(var n=1,o=0;;){var l=nextLineBreak(e,o,t);if(l<0)return new Position(n,t-o);++n,o=l}}var defaultOptions={ecmaVersion:null,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},warnedAboutEcmaVersion=!1;function getOptions(e){var t={};for(var n in defaultOptions)t[n]=e&&hasOwn(e,n)?e[n]:defaultOptions[n];if(t.ecmaVersion==="latest"?t.ecmaVersion=1e8:t.ecmaVersion==null?(!warnedAboutEcmaVersion&&typeof console=="object"&&console.warn&&(warnedAboutEcmaVersion=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
1233
1233
  Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=11):t.ecmaVersion>=2015&&(t.ecmaVersion-=2009),t.allowReserved==null&&(t.allowReserved=t.ecmaVersion<5),(!e||e.allowHashBang==null)&&(t.allowHashBang=t.ecmaVersion>=14),isArray(t.onToken)){var o=t.onToken;t.onToken=function(l){return o.push(l)}}return isArray(t.onComment)&&(t.onComment=pushComment(t,t.onComment)),t}function pushComment(e,t){return function(n,o,l,d,f,g){var b={type:n?"Block":"Line",value:o,start:l,end:d};e.locations&&(b.loc=new SourceLocation(this,f,g)),e.ranges&&(b.range=[l,d]),t.push(b)}}var SCOPE_TOP=1,SCOPE_FUNCTION=2,SCOPE_ASYNC=4,SCOPE_GENERATOR=8,SCOPE_ARROW=16,SCOPE_SIMPLE_CATCH=32,SCOPE_SUPER=64,SCOPE_DIRECT_SUPER=128,SCOPE_CLASS_STATIC_BLOCK=256,SCOPE_VAR=SCOPE_TOP|SCOPE_FUNCTION|SCOPE_CLASS_STATIC_BLOCK;function functionFlags(e,t){return SCOPE_FUNCTION|(e?SCOPE_ASYNC:0)|(t?SCOPE_GENERATOR:0)}var BIND_NONE=0,BIND_VAR=1,BIND_LEXICAL=2,BIND_FUNCTION=3,BIND_SIMPLE_CATCH=4,BIND_OUTSIDE=5,Parser=function e(t,n,o){this.options=t=getOptions(t),this.sourceFile=t.sourceFile,this.keywords=wordsRegexp(keywords$1[t.ecmaVersion>=6?6:t.sourceType==="module"?"5module":5]);var l="";t.allowReserved!==!0&&(l=reservedWords[t.ecmaVersion>=6?6:t.ecmaVersion===5?5:3],t.sourceType==="module"&&(l+=" await")),this.reservedWords=wordsRegexp(l);var d=(l?l+" ":"")+reservedWords.strict;this.reservedWordsStrict=wordsRegexp(d),this.reservedWordsStrictBind=wordsRegexp(d+" "+reservedWords.strictBind),this.input=String(n),this.containsEsc=!1,o?(this.pos=o,this.lineStart=this.input.lastIndexOf(`
@@ -1237,7 +1237,7 @@ Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=1
1237
1237
  `;break;default:e+=String.fromCharCode(n);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else++this.pos}},pp.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case"\\":++this.pos;break;case"$":if(this.input[this.pos+1]!=="{")break;case"`":return this.finishToken(types$1.invalidTemplate,this.input.slice(this.start,this.pos));case"\r":this.input[this.pos+1]===`
1238
1238
  `&&++this.pos;case`
1239
1239
  `:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")},pp.readEscapedChar=function(e){var t=this.input.charCodeAt(++this.pos);switch(++this.pos,t){case 110:return`
1240
- `;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return codePointToString(this.readCodePoint());case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),e){var n=this.pos-1;this.invalidStringToken(n,"Invalid escape sequence in template string")}default:if(t>=48&&t<=55){var o=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],l=parseInt(o,8);return l>255&&(o=o.slice(0,-1),l=parseInt(o,8)),this.pos+=o.length-1,t=this.input.charCodeAt(this.pos),(o!=="0"||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-o.length,e?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(l)}return isNewLine(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}},pp.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,"Bad character escape sequence"),n},pp.readWord1=function(){this.containsEsc=!1;for(var e="",t=!0,n=this.pos,o=this.options.ecmaVersion>=6;this.pos<this.input.length;){var l=this.fullCharCodeAtPos();if(isIdentifierChar(l,o))this.pos+=l<=65535?1:2;else if(l===92){this.containsEsc=!0,e+=this.input.slice(n,this.pos);var d=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var f=this.readCodePoint();(t?isIdentifierStart:isIdentifierChar)(f,o)||this.invalidStringToken(d,"Invalid Unicode escape"),e+=codePointToString(f),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)},pp.readWord=function(){var e=this.readWord1(),t=types$1.name;return this.keywords.test(e)&&(t=keywords[e]),this.finishToken(t,e)};var version="8.12.1";Parser.acorn={Parser,version,defaultOptions,Position,SourceLocation,getLineInfo,Node:Node$3,TokenType,tokTypes:types$1,keywordTypes:keywords,TokContext,tokContexts:types,isIdentifierChar,isIdentifierStart,Token,isNewLine,lineBreak,lineBreakG,nonASCIIwhitespace};var AcornJSX=__toESM(require_acorn_jsx()),attributeNames_default={acceptcharset:"acceptCharset",accesskey:"accessKey",allowfullscreen:"allowFullScreen",autocapitalize:"autoCapitalize",autocomplete:"autoComplete",autofocus:"autoFocus",autoplay:"autoPlay",cellpadding:"cellPadding",cellspacing:"cellSpacing",charset:"charSet",class:"className",colspan:"colSpan",contenteditable:"contentEditable",crossorigin:"crossOrigin",datetime:"dateTime",enctype:"encType",for:"htmlFor",formaction:"formAction",formenctype:"formEncType",formmethod:"formMethod",formnovalidate:"formNoValidate",formtarget:"formTarget",frameborder:"frameBorder",hreflang:"hrefLang",httpequiv:"httpEquiv",inputmode:"inputMode",keyparams:"keyParams",keytype:"keyType",marginheight:"marginHeight",marginwidth:"marginWidth",maxlength:"maxLength",mediagroup:"mediaGroup",minlength:"minLength",novalidate:"noValidate",radiogroup:"radioGroup",readonly:"readOnly",referrerpolicy:"referrerPolicy",rowspan:"rowSpan",spellcheck:"spellCheck",srcdoc:"srcDoc",srclang:"srcLang",srcset:"srcSet",tabindex:"tabIndex",usemap:"useMap"},VOID_ELEMENTS=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"],NO_WHITESPACE=["table","tbody","tfoot","thead","tr"];function canHaveChildren(e){return VOID_ELEMENTS.indexOf(e.toLowerCase())===-1}function canHaveWhitespace(e){return NO_WHITESPACE.indexOf(e.toLowerCase())!==-1}class NullishShortCircuit extends Error{constructor(t="Nullish value encountered"){super(t),this.name="NullishShortCircuit"}}var hash=(e="",t=16)=>{const n=String(e);let o=0;return n.split("").forEach(l=>{o=(o<<5)-o+l.charCodeAt(0),o&=o}),Math.abs(o).toString(t)},randomHash=()=>hash(Math.random().toString()),camelCase=e=>e.replace(/([A-Z])([A-Z])/g,"$1 $2").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[^a-zA-Z\u00C0-\u00ff]/g," ").toLowerCase().split(" ").filter(t=>t).map((t,n)=>n>0?t[0].toUpperCase()+t.slice(1):t).join(""),parseStyle=e=>{switch(typeof e){case"string":return e.split(";").filter(t=>t).reduce((t,n)=>{const o=n.slice(0,n.indexOf(":")).trim(),l=n.slice(n.indexOf(":")+1).trim();return{...t,[camelCase(o)]:l}},{});case"object":return e;default:return}},pathToArrayPath=e=>e==null||e===""?[]:e.split("."),resolveArrayPath=(e,t)=>{const[n,...o]=t;if(!(e==null||n==null))return o.length===0?e[n]:resolveArrayPath(e[n],o)},resolvePath=(e,t)=>resolveArrayPath(e,pathToArrayPath(t));function handleNaN(e){return Number.isNaN(e)?"NaN":e}class JsxParser extends React.Component{constructor(){super(...arguments);en(this,"ParsedChildren",null);zn(this,fn,n=>{const o=Parser.extend(AcornJSX.default({autoCloseVoidElements:this.props.autoCloseVoidElements})),l=`<root>${n}</root>`;let d=[];try{return d=o.parse(l,{ecmaVersion:"latest"}),d=d.body[0].expression.children||[],d.map(f=>on(this,rn).call(this,f)).filter(Boolean)}catch(f){return this.props.showWarnings&&console.warn(f),this.props.onError&&this.props.onError(f),this.props.renderError?this.props.renderError({error:String(f)}):null}});zn(this,rn,(n,o)=>{var l,d;switch(n.type){case"JSXAttribute":return n.value===null?!0:on(this,rn).call(this,n.value,o);case"JSXElement":case"JSXFragment":return on(this,Qn).call(this,n,o);case"JSXExpressionContainer":return on(this,rn).call(this,n.expression,o);case"JSXText":const f=this.props.disableKeyGeneration?void 0:randomHash();return this.props.disableFragments?n.value:React.createElement(React.Fragment,{key:f},n.value);case"ArrayExpression":return n.elements.map(A=>on(this,rn).call(this,A,o));case"BinaryExpression":const g=on(this,rn).call(this,n.left,o),b=on(this,rn).call(this,n.right,o);let _;switch(n.operator){case"-":_=g-b;break;case"!=":_=g!=b;break;case"!==":_=g!==b;break;case"*":_=g*b;break;case"**":_=g**b;break;case"/":_=g/b;break;case"%":_=g%b;break;case"+":_=g+b;break;case"<":_=g<b;break;case"<=":_=g<=b;break;case"==":_=g==b;break;case"===":_=g===b;break;case">":_=g>b;break;case">=":_=g>=b;break;default:this.props.onError(new Error(`Unsupported binary operator: ${n.operator}`));return}return handleNaN(_);case"CallExpression":const S=on(this,rn).call(this,n.callee,o);if(S===void 0){if(n.optional)throw new NullishShortCircuit;this.props.onError(new Error(`The expression '${n.callee}' could not be resolved, resulting in an undefined return value.`));return}return S(...n.arguments.map(A=>on(this,rn).call(this,A,o)));case"ConditionalExpression":return on(this,rn).call(this,n.test,o)?on(this,rn).call(this,n.consequent,o):on(this,rn).call(this,n.alternate,o);case"ExpressionStatement":return on(this,rn).call(this,n.expression,o);case"Identifier":return n.name==="Infinity"?1/0:n.name==="-Infinity"?-1/0:n.name==="NaN"?NaN:o&&n.name in o?handleNaN(o[n.name]):handleNaN((this.props.bindings||{})[n.name]);case"Literal":return n.value;case"LogicalExpression":const R=on(this,rn).call(this,n.left,o);return n.operator==="||"&&R?R:n.operator==="&&"&&R||n.operator==="||"&&!R?on(this,rn).call(this,n.right,o):!1;case"MemberExpression":return on(this,ar).call(this,n,o);case"ChainExpression":return on(this,ir).call(this,n,o);case"ObjectExpression":const C={};return n.properties.forEach(A=>{C[A.key.name||A.key.value]=on(this,rn).call(this,A.value,o)}),C;case"TemplateElement":return n.value.cooked;case"TemplateLiteral":return[...n.expressions,...n.quasis].sort((A,M)=>A.start<M.start?-1:1).map(A=>on(this,rn).call(this,A,o)).join("");case"UnaryExpression":const E=on(this,rn).call(this,n.argument,o);switch(n.operator){case"+":return+E;case"-":return-E;case"!":return!E;case"~":return~E;case"typeof":return typeof E}return;case"ArrowFunctionExpression":return(n.async||n.generator)&&((d=(l=this.props).onError)==null||d.call(l,new Error("Async and generator arrow functions are not supported."))),(...A)=>{const M={...o};return n.params.forEach((I,j)=>{M[I.name]=A[j]}),on(this,rn).call(this,n.body,M)};default:this.props.onError(new Error(`The expression type '${n.type}' is not supported.`));return}});zn(this,ir,(n,o)=>{try{return on(this,rn).call(this,n.expression,o)}catch(l){if(l instanceof NullishShortCircuit)return;throw l}});zn(this,ar,(n,o)=>{const l=on(this,rn).call(this,n.object,o);let d;if(n.computed)d=on(this,rn).call(this,n.property,o);else if(n.property.type==="Identifier")d=n.property.name;else{this.props.onError(new Error("Only simple MemberExpressions are supported."));return}if(l==null&&n.optional)throw new NullishShortCircuit;let f;try{f=l[d]}catch{this.props.onError(new Error(`The property '${d}' could not be resolved on the object '${l}'.`));return}return typeof f=="function"?f.bind(l):f});zn(this,Wn,n=>n.type==="JSXIdentifier"?n.name:`${on(this,Wn).call(this,n.object)}.${on(this,Wn).call(this,n.property)}`);zn(this,Qn,(n,o)=>{const{allowUnknownElements:l,components:d,componentsOnly:f,onError:g}=this.props,{children:b=[]}=n,_=n.type==="JSXElement"?n.openingElement:n.openingFragment,{attributes:S=[]}=_,R=n.type==="JSXElement"?on(this,Wn).call(this,_.name):"",C=(this.props.blacklistedAttrs||[]).map(Q=>Q instanceof RegExp?Q:new RegExp(Q,"i")),E=(this.props.blacklistedTags||[]).map(Q=>Q.trim().toLowerCase()).filter(Boolean);if(/^(html|head|body)$/i.test(R))return b.map(Q=>on(this,Qn).call(this,Q,o));const A=R.trim().toLowerCase();if(E.indexOf(A)!==-1)return g(new Error(`The tag <${R}> is blacklisted, and will not be rendered.`)),null;if(R!==""&&!resolvePath(d,R)){if(f)return g(new Error(`The component <${R}> is unrecognized, and will not be rendered.`)),this.props.renderUnrecognized(R);if(!l&&document.createElement(R)instanceof HTMLUnknownElement)return g(new Error(`The tag <${R}> is unrecognized in this browser, and will not be rendered.`)),this.props.renderUnrecognized(R)}let M,I=n.type==="JSXElement"?resolvePath(d,R):React.Fragment;if(I||canHaveChildren(R)){if(M=b.map(te=>on(this,rn).call(this,te,o)),R.includes(".")){const F=R.split(".").reduce((V,ne)=>V?V[ne]:d==null?void 0:d[ne],null);F&&(I=F)}!I&&!canHaveWhitespace(R)&&(M=M.filter(te=>typeof te!="string"||!/^\s*$/.test(te)));const Q=M.find(te=>typeof te=="function");M.length===0?M=void 0:Q?M=Q:M.length===1?[M]=M:M.length>1&&!this.props.disableKeyGeneration&&(M=M.map((te,F)=>te!=null&&te.type&&!(te!=null&&te.key)?{...te,key:te.key||F}:te))}const j={key:this.props.disableKeyGeneration?void 0:randomHash()};S.forEach(Q=>{if(Q.type==="JSXAttribute"){const te=Q.name.name,F=attributeNames_default[te]||te,V=on(this,rn).call(this,Q,o);C.filter(ae=>ae.test(F)).length===0&&(j[F]=V)}else if(Q.type==="JSXSpreadAttribute"&&Q.argument.type==="Identifier"||Q.argument.type==="MemberExpression"){const te=on(this,rn).call(this,Q.argument,o);typeof te=="object"&&Object.keys(te).forEach(F=>{const V=attributeNames_default[F]||F;C.filter(ae=>ae.test(V)).length===0&&(j[V]=te[F])})}}),typeof j.style=="string"&&(j.style=parseStyle(j.style));const q=R.toLowerCase();return q==="option"&&(M=M.props.children),React.createElement(I||q,j,M)})}render(){const n=(this.props.jsx||"").trim().replace(/<!DOCTYPE([^>]*)>/g,"");this.ParsedChildren=on(this,fn).call(this,n);const o=[...new Set(["jsx-parser",...String(this.props.className).split(" ")])].filter(Boolean).join(" ");return this.props.renderInWrapper?React.createElement("div",{className:o},this.ParsedChildren):this.ParsedChildren}}fn=new WeakMap,rn=new WeakMap,ir=new WeakMap,ar=new WeakMap,Wn=new WeakMap,Qn=new WeakMap,en(JsxParser,"displayName","JsxParser"),en(JsxParser,"defaultProps",{allowUnknownElements:!0,autoCloseVoidElements:!1,bindings:{},blacklistedAttrs:[/^on.+/i],blacklistedTags:["script"],className:"",components:{},componentsOnly:!1,disableFragments:!1,disableKeyGeneration:!1,jsx:"",onError:()=>{},showWarnings:!1,renderError:void 0,renderInWrapper:!0,renderUnrecognized:()=>null});var source_default=JsxParser;const CountryFlag=({countryCode:e,className:t=""})=>{const[n,o]=React.useState(null),[l,d]=React.useState(!1);return React.useEffect(()=>{if(!e)return;const g=`https://purecatamphetamine.github.io/country-flag-icons/3x2/${e.toUpperCase()}.svg`;fetch(g,{method:"HEAD"}).then(b=>{b.ok?(o(g),d(!1)):d(!0)}).catch(()=>{d(!0)})},[e]),l||!n?jsxRuntime.jsx("span",{className:t,children:e}):jsxRuntime.jsx("img",{src:n,alt:`${e} flag`,className:`inline-block ${t}`,style:{width:"24px",height:"auto"}})};function ProductCard({applicationId:e,product:t,viewProductLink:n,defaultOpportunityNumber:o="",onAddToCart:l,addingToCart:d=!1,shopifyHostname:f,customAction:g=jsxRuntime.jsx(jsxRuntime.Fragment,{})}){var $t,rt,Rt,dt,It,Mt,Ct,Ke,Ye;const b=reactRouterDom.useNavigate(),{toast:_}=useToast(),[S,R]=React.useState(1),[C,E]=React.useState(null),[A,M]=React.useState(0),[I,j]=React.useState(!1),[q]=usePostV4ResellerByRouteResellerIdProductAndRandmarSkuShopifyMutation(),[Q,te]=React.useState(!1),[F,V]=React.useState(null),[ne,ae]=React.useState("idle"),[se,Oe]=React.useState(null),[Ne]=useLazyGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery(),oe=(($t=t==null?void 0:t.Distribution)==null?void 0:$t.Cost)||0,$e=((rt=t==null?void 0:t.Distribution)==null?void 0:rt.RegularPrice)||0,Ae=((Rt=t==null?void 0:t.Distribution)==null?void 0:Rt.Price)||0,je=!!(e&&(t!=null&&t.RandmarSKU));React.useEffect(()=>{R(1),E(null),M(0)},[t==null?void 0:t.RandmarSKU]),React.useEffect(()=>{var Ze;if(t&&o){const ct=(Ze=t.Opportunities)==null?void 0:Ze.find(mt=>mt.BidNumber==o);ct&&Be(ct)&&E(ct)}},[t,o]),React.useEffect(()=>{if(!t)return;const Ze=C!=null&&C.Price?C.Price:Ae;M($e>0?Math.round(($e-Ze)/$e*100):0)},[t,C,Ae,$e]),React.useEffect(()=>{d||R(1)},[d]),React.useEffect(()=>{if(!Q){V(null),ae("idle"),Oe(null);return}if(!e||!(t!=null&&t.RandmarSKU)){ae("error"),Oe("Missing identifiers to load performance data.");return}let Ze=!1;const ct=t.RandmarSKU;return(async()=>{ae("summary"),Oe(null);try{const ft=await Ne({routeApplicationId:e,randmarSku:ct,withSpecification:!1});if(Ze)return;if("error"in ft&&ft.error)throw ft.error;V(ft.data??null),ae("detailed");const yt=await Ne({routeApplicationId:e,randmarSku:ct,withSpecification:!0});if(Ze)return;if("error"in yt&&yt.error)throw yt.error;V(yt.data??ft.data??null),ae("complete")}catch(ft){if(Ze)return;console.error("Failed to load performance data for product modal",ft),ae("error"),Oe("We couldn't load the performance details. Please try again.")}})(),()=>{Ze=!0}},[e,Ne,Q,t==null?void 0:t.RandmarSKU]);const Be=Ze=>{if(Ze.Active!==!0)return!1;const ct=new Date().toISOString().split("T")[0];return!(Ze.EndDate&&Ze.EndDate.split("T")[0]<ct||Ze.StartDate&&Ze.StartDate.split("T")[0]>ct)},qe=Ze=>Ze>=90?{label:"Top 10% Bestseller",color:"text-purple-950",bgColor:"bg-purple-200"}:Ze>=75?{label:"Bestseller",color:"text-blue-700",bgColor:"bg-blue-50"}:Ze>=33?{label:"Popular",color:"text-green-700",bgColor:"bg-green-50"}:{label:"Rising",color:"text-gray-700",bgColor:"bg-white"},Ve=ne!=="complete"&&ne!=="error",Le=ne==="summary"?40:ne==="detailed"?80:10,He=(F==null?void 0:F.SalesStatistics)??[],We=Ve?[]:He,ze=(F==null?void 0:F.RandmarTitle)??(t==null?void 0:t.RandmarTitle)??(t==null?void 0:t.RandmarSKU)??"this product",Xe=(F==null?void 0:F.RandmarSKU)??(t==null?void 0:t.RandmarSKU);if(!t)return jsxRuntime.jsx(Card,{children:jsxRuntime.jsxs(CardContent,{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start mb-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx("div",{className:"h-10 w-24 flex items-center justify-end ml-4",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"})})]}),jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-24 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-28 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"flex gap-6",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-6 flex-1",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:jsxRuntime.jsx("div",{className:"w-60 h-40",children:jsxRuntime.jsx(Skeleton,{className:"w-full h-full rounded-lg"})})})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsx("div",{className:"flex flex-1",children:jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-24 mb-3"}),jsxRuntime.jsx(Skeleton,{className:"h-16 w-full rounded-md"})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-32 rounded-md"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24 mt-4"})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-start gap-1 mb-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"}),jsxRuntime.jsx(Skeleton,{className:"h-10 flex-1 rounded-md"})]})]})]})});const nt=(t==null?void 0:t.Opportunities)||[],Je=nt.length>0,st=()=>{if(S==null){R(1);return}S>1&&R(S-1)},et=()=>{if(S==null){R(1);return}R(S+1)},at=Ze=>{const ct=Number.parseInt(Ze.target.value,10);if(!isNaN(ct)&&ct>0){R(ct);return}R(void 0)},tt=()=>{(S==null||S<1)&&R(1)},ot=Ze=>{try{return new Date(Ze).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch(ct){return console.error(ct),Ze.split("T")[0]||"N/A"}},lt=()=>{typeof l<"u"&&l({quantity:S??1,bidNumber:(C==null?void 0:C.BidNumber)??null})},Ge=()=>{I||!f||(j(!0),q({routeResellerId:e??"",randmarSku:t.RandmarSKU??"",shopifyHostName:f}).then(Ze=>{if(Ze.error){console.error("Error syncing to Shopify:",Ze.error),_({title:"Product synced failed.",description:"Error syncing to Shopify:",variant:"destructive"});return}_({title:"Product synced",description:"Product synced to Shopify successfully",variant:"success"})}).catch(Ze=>{console.error("Error syncing to Shopify:",Ze),_({title:"Product synced failed.",description:"Error syncing to Shopify:",variant:"destructive"})}).finally(()=>{j(!1)}))};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Card,{className:"w-full hover:shadow-lg transition-shadow @container",children:jsxRuntime.jsxs(CardContent,{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start mb-3",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-xl",children:t.Title||t.RandmarTitle}),jsxRuntime.jsx("div",{className:"w-24 h-10 flex items-center justify-end ml-4 flex-shrink-0",children:jsxRuntime.jsx(PartnerLogo,{id:t.ManufacturerId,name:t.ManufacturerName,width:96,height:40},`partner_logo_${t.ManufacturerId}`)})]}),jsxRuntime.jsxs("div",{className:"flex flex-col @[36rem]:flex-row gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-1 @[36rem]:order-1 order-2 flex flex-col gap-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 items-center justify-center @[36rem]:items-start @[36rem]:justify-start",children:[t.State&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${t.State==="Active"?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(Check,{size:"12",className:"mr-1.5"})," ",t.State]}),jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${t.SerialNumber?"bg-green-50 text-green-700 hover:bg-green-50":"bg-yellow-50 text-yellow-700 hover:bg-yellow-50"}`,children:[jsxRuntime.jsx(QrCode,{size:"12",className:"mr-1.5"})," ",t.SerialNumber?"Serialized":"Unserialized"]}),t.TransparencyCode&&jsxRuntime.jsxs(Badge,{variant:"outline",className:"rounded-full px-3 bg-green-50 text-green-700 hover:bg-green-50",children:[jsxRuntime.jsx(CircleDashed,{size:"12",className:"mr-1.5"})," Transparency Code"]}),t.AvailableToBuy!==void 0&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${t.AvailableToBuy?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(ShoppingCart,{size:"12",className:"mr-1.5"})," ",t.AvailableToBuy?"Available":"Unavailable"]}),t.ManufacturerCategory!==void 0&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${(dt=t.ManufacturerCategory)!=null&&dt.QualificationRequired?"bg-blue-50 text-blue-700 hover:bg-blue-50":"bg-neutral-50 text-neutral-700 hover:bg-neutral-50"}`,children:[jsxRuntime.jsx(ShieldCheck,{size:"12",className:"mr-1.5"})," ",(It=t.ManufacturerCategory)!=null&&It.QualificationRequired?"Qualified Only":"Available to all"]}),t.ManufacturerId&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${t.AutoUpdate?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(RefreshCw,{size:"12",className:"mr-1.5"})," ",t.AutoUpdate?`Automatic Reorder (${t.MasterCarton})`:"Manually Reorders"]}),jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${t.BodyHTML&&t.Title&&t.MAP?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(Store,{size:"12",className:"mr-1.5"})," ",t.BodyHTML&&t.Title&&t.MAP?"Shopify Ready":"Not Shopify Ready"]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-4 flex-1",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"MPN"}),jsxRuntime.jsx("div",{className:"font-medium",children:t.MPN||"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"UPC"}),jsxRuntime.jsx("div",{className:"font-medium",children:t.UPC||"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Unit Weight"}),jsxRuntime.jsx("div",{className:"font-medium",children:t.UnitWeight?`${formatNumber(t.UnitWeight)} lbs`:"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"text-sm text-muted-foreground",children:["MAP",jsxRuntime.jsx("span",{className:"text-primary",children:" / "}),"MSRP"]}),jsxRuntime.jsxs("div",{className:"font-medium",children:[t.MAP?formatMoney(t.MAP):"N/A",jsxRuntime.jsx("span",{className:"text-primary",children:" / "}),t.MSRP?formatMoney(t.MSRP):"N/A"]})]}),!!t.OverallPercentileRank&&!!t.ManufacturerPercentileRank&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground mb-2",children:"Bestseller Status"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{children:"Global: "}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Badge,{variant:"outline",className:`rounded-full px-3 w-fit ${qe(t.OverallPercentileRank).bgColor} ${qe(t.OverallPercentileRank).color} hover:${qe(t.OverallPercentileRank).bgColor}`,children:qe(t.OverallPercentileRank).label})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["Percentile Rank: ",t.OverallPercentileRank]})})]})})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("span",{children:[t.ManufacturerName,": "]}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Badge,{variant:"outline",className:`rounded-full px-3 w-fit ${qe(t.ManufacturerPercentileRank).bgColor} ${qe(t.ManufacturerPercentileRank).color} hover:${qe(t.ManufacturerPercentileRank).bgColor}`,children:qe(t.ManufacturerPercentileRank).label})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["Percentile Rank: ",t.ManufacturerPercentileRank]})})]})})]})]})]}),t.CountryCodeOfOrigin&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Origin"}),jsxRuntime.jsxs("div",{className:"font-medium flex items-center",children:[jsxRuntime.jsx(CountryFlag,{countryCode:t.CountryCodeOfOrigin,className:"mr-2"}),t.CountryCodeOfOrigin]})]})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col @[36rem]:order-2 order-1 items-center",children:jsxRuntime.jsx(ProductImage,{randmarSKU:t.RandmarSKU||"",alt:t.RandmarTitle||""},`product_image_${t.RandmarSKU}`)})]}),jsxRuntime.jsx("div",{className:"flex flex-col @[36rem]:flex-row gap-6 mt-4",children:jsxRuntime.jsx("div",{className:"flex flex-1 @[36rem]:order-1 order-2",children:Je&&t.Distribution&&jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx("div",{className:"flex items-center",children:"You have "+nt.length+(nt.length>1?" opportunities":" opportunity")+" for this product:"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsx("div",{className:"space-y-2 max-h-[200px] overflow-y-auto p-2 mt-1",children:nt.map((Ze,ct)=>Be(Ze)?jsxRuntime.jsxs("div",{className:`flex justify-between items-center rounded-lg transition-colors py-2 px-4 border border-muted cursor-pointer ${Ze.BidNumber==(C==null?void 0:C.BidNumber)?"bg-purple-100 border-2 border-purple-900":"bg-white border-1 border-purple-600 hover:bg-purple-200"}`,onClick:()=>{E(Ze.BidNumber!==(C==null?void 0:C.BidNumber)?Ze:null)},children:[jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"font-medium text-sm",children:Ze.Opportunity}),jsxRuntime.jsx("span",{className:"text-xs text-neutral-900",children:Ze.BidNumber})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end",children:[jsxRuntime.jsx("span",{className:"font-semibold",children:formatMoney(Ze.Price??0)}),Ze.Rebate&&Ze.Rebate>0&&jsxRuntime.jsxs("span",{className:"text-xs text-green-600",children:["Rebate: ",formatMoney(Ze.Rebate)]}),Ze.EndDate&&jsxRuntime.jsxs("span",{className:"text-xs text-neutral-600",children:["Ends: ",ot(Ze.EndDate)]})]})]},ct):jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex justify-between items-center rounded-lg transition-colors py-2 px-4 bg-purple-100 border border-muted cursor-pointer !bg-neutral-50 hover:bg-neutral-100",onClick:()=>{Ze.BidNumber&&b(`/${e}/Opportunity/${Ze.ManufacturerId}/${Ze.BidNumber}`)},children:[jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"font-medium text-sm",children:Ze.Opportunity}),jsxRuntime.jsxs("span",{className:"text-xs text-neutral-900",children:[Ze.BidNumber," ",jsxRuntime.jsx(Badge,{variant:"outline",className:"text-xs mx-1 h-5 bg-gray-100",children:"Currently unavailable"})]})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end",children:[jsxRuntime.jsx("span",{className:"font-semibold",children:formatMoney(Ze.Price??0)}),Ze.Rebate&&Ze.Rebate>0&&jsxRuntime.jsxs("span",{className:"text-xs text-green-600",children:["Rebate: ",formatMoney(Ze.Rebate)]}),Ze.EndDate&&jsxRuntime.jsxs("span",{className:"text-xs text-neutral-600",children:["Ends: ",ot(Ze.EndDate)]})]})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"View Opportunity"})})]},ct))})})]})})}),jsxRuntime.jsxs("div",{className:"mt-4 flex flex-col gap-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-row flex-wrap justify-between items-end gap-4",children:[jsxRuntime.jsx("div",{className:"flex flex-col gap-3 flex-1",children:t.Distribution&&jsxRuntime.jsx("div",{className:"flex flex-col gap-1",children:oe>0?jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("span",{className:"text-2xl font-bold whitespace-nowrap",children:["Cost: ",formatMoney(oe)]})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap",children:[$e>0&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("span",{className:"text-2xl font-bold whitespace-nowrap",children:formatMoney((C?(Ct=(Mt=t.Opportunities)==null?void 0:Mt.find(Ze=>Ze.BidNumber==C.BidNumber))==null?void 0:Ct.Price:Ae)??0)})}),A>0&&jsxRuntime.jsx("span",{className:"text-muted-foreground line-through ml-2 whitespace-nowrap",children:formatMoney($e)})]}),A>0&&jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs(Badge,{variant:"outline",className:"bg-red-50 text-red-700 rounded-full px-3 whitespace-nowrap",children:[jsxRuntime.jsxs("span",{children:[A,"% OFF"]}),((Ke=t.InstantRebate)==null?void 0:Ke.EndDate)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"mx-1.5",children:"●"})," Ends ",t.InstantRebate.EndDate.split("T")[0]]}),(C==null?void 0:C.EndDate)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"mx-1.5",children:"●"})," Ends ",C.EndDate.split("T")[0]]})]})})]})})}),jsxRuntime.jsxs("div",{className:"flex flex-col justify-center @[36rem]:justify-end items-end gap-2 w-full @[36rem]:w-auto",children:[f&&jsxRuntime.jsx(Button$1,{className:"gap-2 whitespace-nowrap bg-green-600 hover:bg-green-700",onClick:Ge,disabled:I,children:I?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}),"Syncing..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2"}),"Sync to Shopify"]})}),g,typeof l<"u"&&jsxRuntime.jsxs("div",{className:"flex gap-2 whitespace-nowrap",children:[jsxRuntime.jsxs("div",{className:"flex items-center border rounded-md",children:[jsxRuntime.jsx(Button$1,{variant:"ghost",size:"icon",className:"rounded-r-none",onClick:st,disabled:typeof S<"u"&&(S<=1||!t.AvailableToBuy||d),children:"-"}),jsxRuntime.jsx("input",{value:S,onChange:at,onBlur:tt,onClick:Ze=>Ze.currentTarget.select(),className:`w-6 @[36rem]:w-12 text-center border-0 focus:ring-0 focus:outline-none ${!t.AvailableToBuy||d?"text-gray-400":""}`,disabled:!t.AvailableToBuy||d}),jsxRuntime.jsx(Button$1,{variant:"ghost",size:"icon",className:"rounded-l-none",onClick:et,disabled:!t.AvailableToBuy||d,children:"+"})]}),jsxRuntime.jsx(Button$1,{className:"gap-2 whitespace-nowrap",onClick:lt,disabled:!t.AvailableToBuy||d,children:d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}),"Adding..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2"}),"Add to Cart"]})})]})]})]}),jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-2 @[36rem]:flex-row",children:[jsxRuntime.jsx("div",{className:"flex-1 min-w-[10rem]",children:jsxRuntime.jsxs(Button$1,{variant:"outline",type:"button",className:"h-11 px-4 text-sm font-medium justify-start w-full",onClick:()=>te(!0),disabled:!je,children:[jsxRuntime.jsx(ChartLine,{className:"mr-2"}),"View statistics"]})}),jsxRuntime.jsx("div",{className:"flex-1 min-w-[10rem]",children:jsxRuntime.jsx(ProductInventoryButton,{applicationId:e??"",randmarSku:t.RandmarSKU??"",inventory:(Ye=t.Distribution)==null?void 0:Ye.Inventory,buttonSize:"lg",buttonClassName:"w-full h-11 justify-start"})}),n&&jsxRuntime.jsx(reactRouterDom.Link,{to:n,className:"flex-1 min-w-[10rem]",children:jsxRuntime.jsxs(Button$1,{variant:"outline",className:"h-11 px-4 text-sm font-medium justify-start w-full",children:[jsxRuntime.jsx(Eye,{className:"mr-2"}),"View Product"]})})]})]})]})}),jsxRuntime.jsx(Dialog,{open:Q,onOpenChange:te,children:jsxRuntime.jsxs(DialogContent,{className:"w-[min(95vw,1100px)] max-w-5xl space-y-6",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Monthly Sales Performance"}),jsxRuntime.jsxs(DialogDescription,{children:["Expanded product insights for ",ze,Xe?` (SKU ${Xe})`:""]})]}),jsxRuntime.jsx("div",{className:"space-y-6",children:se?jsxRuntime.jsxs(Alert,{variant:"destructive",children:[jsxRuntime.jsx(AlertTitle,{children:"Unable to load details"}),jsxRuntime.jsx(AlertDescription,{children:se})]}):jsxRuntime.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[jsxRuntime.jsxs("div",{className:"mb-4 space-y-2",children:[jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"Rolling 12-month sales dollars and units sold pulled from the detailed endpoint."}),Ve&&jsxRuntime.jsx("div",{"aria-live":"polite","aria-busy":"true",children:jsxRuntime.jsx(Progress,{value:Le,className:"h-2 w-full animate-pulse","aria-label":"Loading performance data"})})]}),jsxRuntime.jsx(SalesChart,{statistics:We,mode:"month",chartHeight:320}),Ve&&jsxRuntime.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"Gathering product summary and sales statistics..."})]})})]})})]})}const complexComponents=[`----
1240
+ `;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return codePointToString(this.readCodePoint());case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),e){var n=this.pos-1;this.invalidStringToken(n,"Invalid escape sequence in template string")}default:if(t>=48&&t<=55){var o=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],l=parseInt(o,8);return l>255&&(o=o.slice(0,-1),l=parseInt(o,8)),this.pos+=o.length-1,t=this.input.charCodeAt(this.pos),(o!=="0"||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-o.length,e?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(l)}return isNewLine(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}},pp.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,"Bad character escape sequence"),n},pp.readWord1=function(){this.containsEsc=!1;for(var e="",t=!0,n=this.pos,o=this.options.ecmaVersion>=6;this.pos<this.input.length;){var l=this.fullCharCodeAtPos();if(isIdentifierChar(l,o))this.pos+=l<=65535?1:2;else if(l===92){this.containsEsc=!0,e+=this.input.slice(n,this.pos);var d=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var f=this.readCodePoint();(t?isIdentifierStart:isIdentifierChar)(f,o)||this.invalidStringToken(d,"Invalid Unicode escape"),e+=codePointToString(f),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)},pp.readWord=function(){var e=this.readWord1(),t=types$1.name;return this.keywords.test(e)&&(t=keywords[e]),this.finishToken(t,e)};var version="8.12.1";Parser.acorn={Parser,version,defaultOptions,Position,SourceLocation,getLineInfo,Node:Node$3,TokenType,tokTypes:types$1,keywordTypes:keywords,TokContext,tokContexts:types,isIdentifierChar,isIdentifierStart,Token,isNewLine,lineBreak,lineBreakG,nonASCIIwhitespace};var AcornJSX=__toESM(require_acorn_jsx()),attributeNames_default={acceptcharset:"acceptCharset",accesskey:"accessKey",allowfullscreen:"allowFullScreen",autocapitalize:"autoCapitalize",autocomplete:"autoComplete",autofocus:"autoFocus",autoplay:"autoPlay",cellpadding:"cellPadding",cellspacing:"cellSpacing",charset:"charSet",class:"className",colspan:"colSpan",contenteditable:"contentEditable",crossorigin:"crossOrigin",datetime:"dateTime",enctype:"encType",for:"htmlFor",formaction:"formAction",formenctype:"formEncType",formmethod:"formMethod",formnovalidate:"formNoValidate",formtarget:"formTarget",frameborder:"frameBorder",hreflang:"hrefLang",httpequiv:"httpEquiv",inputmode:"inputMode",keyparams:"keyParams",keytype:"keyType",marginheight:"marginHeight",marginwidth:"marginWidth",maxlength:"maxLength",mediagroup:"mediaGroup",minlength:"minLength",novalidate:"noValidate",radiogroup:"radioGroup",readonly:"readOnly",referrerpolicy:"referrerPolicy",rowspan:"rowSpan",spellcheck:"spellCheck",srcdoc:"srcDoc",srclang:"srcLang",srcset:"srcSet",tabindex:"tabIndex",usemap:"useMap"},VOID_ELEMENTS=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"],NO_WHITESPACE=["table","tbody","tfoot","thead","tr"];function canHaveChildren(e){return VOID_ELEMENTS.indexOf(e.toLowerCase())===-1}function canHaveWhitespace(e){return NO_WHITESPACE.indexOf(e.toLowerCase())!==-1}class NullishShortCircuit extends Error{constructor(t="Nullish value encountered"){super(t),this.name="NullishShortCircuit"}}var hash=(e="",t=16)=>{const n=String(e);let o=0;return n.split("").forEach(l=>{o=(o<<5)-o+l.charCodeAt(0),o&=o}),Math.abs(o).toString(t)},randomHash=()=>hash(Math.random().toString()),camelCase=e=>e.replace(/([A-Z])([A-Z])/g,"$1 $2").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[^a-zA-Z\u00C0-\u00ff]/g," ").toLowerCase().split(" ").filter(t=>t).map((t,n)=>n>0?t[0].toUpperCase()+t.slice(1):t).join(""),parseStyle=e=>{switch(typeof e){case"string":return e.split(";").filter(t=>t).reduce((t,n)=>{const o=n.slice(0,n.indexOf(":")).trim(),l=n.slice(n.indexOf(":")+1).trim();return{...t,[camelCase(o)]:l}},{});case"object":return e;default:return}},pathToArrayPath=e=>e==null||e===""?[]:e.split("."),resolveArrayPath=(e,t)=>{const[n,...o]=t;if(!(e==null||n==null))return o.length===0?e[n]:resolveArrayPath(e[n],o)},resolvePath=(e,t)=>resolveArrayPath(e,pathToArrayPath(t));function handleNaN(e){return Number.isNaN(e)?"NaN":e}class JsxParser extends React.Component{constructor(){super(...arguments);en(this,"ParsedChildren",null);zn(this,fn,n=>{const o=Parser.extend(AcornJSX.default({autoCloseVoidElements:this.props.autoCloseVoidElements})),l=`<root>${n}</root>`;let d=[];try{return d=o.parse(l,{ecmaVersion:"latest"}),d=d.body[0].expression.children||[],d.map(f=>on(this,rn).call(this,f)).filter(Boolean)}catch(f){return this.props.showWarnings&&console.warn(f),this.props.onError&&this.props.onError(f),this.props.renderError?this.props.renderError({error:String(f)}):null}});zn(this,rn,(n,o)=>{var l,d;switch(n.type){case"JSXAttribute":return n.value===null?!0:on(this,rn).call(this,n.value,o);case"JSXElement":case"JSXFragment":return on(this,Qn).call(this,n,o);case"JSXExpressionContainer":return on(this,rn).call(this,n.expression,o);case"JSXText":const f=this.props.disableKeyGeneration?void 0:randomHash();return this.props.disableFragments?n.value:React.createElement(React.Fragment,{key:f},n.value);case"ArrayExpression":return n.elements.map(A=>on(this,rn).call(this,A,o));case"BinaryExpression":const g=on(this,rn).call(this,n.left,o),b=on(this,rn).call(this,n.right,o);let _;switch(n.operator){case"-":_=g-b;break;case"!=":_=g!=b;break;case"!==":_=g!==b;break;case"*":_=g*b;break;case"**":_=g**b;break;case"/":_=g/b;break;case"%":_=g%b;break;case"+":_=g+b;break;case"<":_=g<b;break;case"<=":_=g<=b;break;case"==":_=g==b;break;case"===":_=g===b;break;case">":_=g>b;break;case">=":_=g>=b;break;default:this.props.onError(new Error(`Unsupported binary operator: ${n.operator}`));return}return handleNaN(_);case"CallExpression":const S=on(this,rn).call(this,n.callee,o);if(S===void 0){if(n.optional)throw new NullishShortCircuit;this.props.onError(new Error(`The expression '${n.callee}' could not be resolved, resulting in an undefined return value.`));return}return S(...n.arguments.map(A=>on(this,rn).call(this,A,o)));case"ConditionalExpression":return on(this,rn).call(this,n.test,o)?on(this,rn).call(this,n.consequent,o):on(this,rn).call(this,n.alternate,o);case"ExpressionStatement":return on(this,rn).call(this,n.expression,o);case"Identifier":return n.name==="Infinity"?1/0:n.name==="-Infinity"?-1/0:n.name==="NaN"?NaN:o&&n.name in o?handleNaN(o[n.name]):handleNaN((this.props.bindings||{})[n.name]);case"Literal":return n.value;case"LogicalExpression":const R=on(this,rn).call(this,n.left,o);return n.operator==="||"&&R?R:n.operator==="&&"&&R||n.operator==="||"&&!R?on(this,rn).call(this,n.right,o):!1;case"MemberExpression":return on(this,ar).call(this,n,o);case"ChainExpression":return on(this,ir).call(this,n,o);case"ObjectExpression":const C={};return n.properties.forEach(A=>{C[A.key.name||A.key.value]=on(this,rn).call(this,A.value,o)}),C;case"TemplateElement":return n.value.cooked;case"TemplateLiteral":return[...n.expressions,...n.quasis].sort((A,M)=>A.start<M.start?-1:1).map(A=>on(this,rn).call(this,A,o)).join("");case"UnaryExpression":const E=on(this,rn).call(this,n.argument,o);switch(n.operator){case"+":return+E;case"-":return-E;case"!":return!E;case"~":return~E;case"typeof":return typeof E}return;case"ArrowFunctionExpression":return(n.async||n.generator)&&((d=(l=this.props).onError)==null||d.call(l,new Error("Async and generator arrow functions are not supported."))),(...A)=>{const M={...o};return n.params.forEach((I,j)=>{M[I.name]=A[j]}),on(this,rn).call(this,n.body,M)};default:this.props.onError(new Error(`The expression type '${n.type}' is not supported.`));return}});zn(this,ir,(n,o)=>{try{return on(this,rn).call(this,n.expression,o)}catch(l){if(l instanceof NullishShortCircuit)return;throw l}});zn(this,ar,(n,o)=>{const l=on(this,rn).call(this,n.object,o);let d;if(n.computed)d=on(this,rn).call(this,n.property,o);else if(n.property.type==="Identifier")d=n.property.name;else{this.props.onError(new Error("Only simple MemberExpressions are supported."));return}if(l==null&&n.optional)throw new NullishShortCircuit;let f;try{f=l[d]}catch{this.props.onError(new Error(`The property '${d}' could not be resolved on the object '${l}'.`));return}return typeof f=="function"?f.bind(l):f});zn(this,Wn,n=>n.type==="JSXIdentifier"?n.name:`${on(this,Wn).call(this,n.object)}.${on(this,Wn).call(this,n.property)}`);zn(this,Qn,(n,o)=>{const{allowUnknownElements:l,components:d,componentsOnly:f,onError:g}=this.props,{children:b=[]}=n,_=n.type==="JSXElement"?n.openingElement:n.openingFragment,{attributes:S=[]}=_,R=n.type==="JSXElement"?on(this,Wn).call(this,_.name):"",C=(this.props.blacklistedAttrs||[]).map(Q=>Q instanceof RegExp?Q:new RegExp(Q,"i")),E=(this.props.blacklistedTags||[]).map(Q=>Q.trim().toLowerCase()).filter(Boolean);if(/^(html|head|body)$/i.test(R))return b.map(Q=>on(this,Qn).call(this,Q,o));const A=R.trim().toLowerCase();if(E.indexOf(A)!==-1)return g(new Error(`The tag <${R}> is blacklisted, and will not be rendered.`)),null;if(R!==""&&!resolvePath(d,R)){if(f)return g(new Error(`The component <${R}> is unrecognized, and will not be rendered.`)),this.props.renderUnrecognized(R);if(!l&&document.createElement(R)instanceof HTMLUnknownElement)return g(new Error(`The tag <${R}> is unrecognized in this browser, and will not be rendered.`)),this.props.renderUnrecognized(R)}let M,I=n.type==="JSXElement"?resolvePath(d,R):React.Fragment;if(I||canHaveChildren(R)){if(M=b.map(te=>on(this,rn).call(this,te,o)),R.includes(".")){const F=R.split(".").reduce((V,ne)=>V?V[ne]:d==null?void 0:d[ne],null);F&&(I=F)}!I&&!canHaveWhitespace(R)&&(M=M.filter(te=>typeof te!="string"||!/^\s*$/.test(te)));const Q=M.find(te=>typeof te=="function");M.length===0?M=void 0:Q?M=Q:M.length===1?[M]=M:M.length>1&&!this.props.disableKeyGeneration&&(M=M.map((te,F)=>te!=null&&te.type&&!(te!=null&&te.key)?{...te,key:te.key||F}:te))}const j={key:this.props.disableKeyGeneration?void 0:randomHash()};S.forEach(Q=>{if(Q.type==="JSXAttribute"){const te=Q.name.name,F=attributeNames_default[te]||te,V=on(this,rn).call(this,Q,o);C.filter(ae=>ae.test(F)).length===0&&(j[F]=V)}else if(Q.type==="JSXSpreadAttribute"&&Q.argument.type==="Identifier"||Q.argument.type==="MemberExpression"){const te=on(this,rn).call(this,Q.argument,o);typeof te=="object"&&Object.keys(te).forEach(F=>{const V=attributeNames_default[F]||F;C.filter(ae=>ae.test(V)).length===0&&(j[V]=te[F])})}}),typeof j.style=="string"&&(j.style=parseStyle(j.style));const q=R.toLowerCase();return q==="option"&&(M=M.props.children),React.createElement(I||q,j,M)})}render(){const n=(this.props.jsx||"").trim().replace(/<!DOCTYPE([^>]*)>/g,"");this.ParsedChildren=on(this,fn).call(this,n);const o=[...new Set(["jsx-parser",...String(this.props.className).split(" ")])].filter(Boolean).join(" ");return this.props.renderInWrapper?React.createElement("div",{className:o},this.ParsedChildren):this.ParsedChildren}}fn=new WeakMap,rn=new WeakMap,ir=new WeakMap,ar=new WeakMap,Wn=new WeakMap,Qn=new WeakMap,en(JsxParser,"displayName","JsxParser"),en(JsxParser,"defaultProps",{allowUnknownElements:!0,autoCloseVoidElements:!1,bindings:{},blacklistedAttrs:[/^on.+/i],blacklistedTags:["script"],className:"",components:{},componentsOnly:!1,disableFragments:!1,disableKeyGeneration:!1,jsx:"",onError:()=>{},showWarnings:!1,renderError:void 0,renderInWrapper:!0,renderUnrecognized:()=>null});var source_default=JsxParser;const CountryFlag=({countryCode:e,className:t=""})=>{const[n,o]=React.useState(null),[l,d]=React.useState(!1);return React.useEffect(()=>{if(!e)return;const g=`https://purecatamphetamine.github.io/country-flag-icons/3x2/${e.toUpperCase()}.svg`;fetch(g,{method:"HEAD"}).then(b=>{b.ok?(o(g),d(!1)):d(!0)}).catch(()=>{d(!0)})},[e]),l||!n?jsxRuntime.jsx("span",{className:t,children:e}):jsxRuntime.jsx("img",{src:n,alt:`${e} flag`,className:`inline-block ${t}`,style:{width:"24px",height:"auto"}})};function ProductCard({applicationId:e,product:t,viewProductLink:n,defaultOpportunityNumber:o="",onAddToCart:l,addingToCart:d=!1,shopifyHostname:f,customAction:g=jsxRuntime.jsx(jsxRuntime.Fragment,{})}){var $t,rt,Rt,dt,It,Mt,Ct,Ke,Ye;const b=reactRouterDom.useNavigate(),{toast:_}=useToast(),[S,R]=React.useState(1),[C,E]=React.useState(null),[A,M]=React.useState(0),[I,j]=React.useState(!1),[q]=usePostV4ResellerByRouteResellerIdProductAndRandmarSkuShopifyMutation(),[Q,te]=React.useState(!1),[F,V]=React.useState(null),[ne,ae]=React.useState("idle"),[se,Oe]=React.useState(null),[Ne]=useLazyGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery(),oe=(($t=t==null?void 0:t.Distribution)==null?void 0:$t.Cost)||0,$e=((rt=t==null?void 0:t.Distribution)==null?void 0:rt.RegularPrice)||0,Ae=((Rt=t==null?void 0:t.Distribution)==null?void 0:Rt.Price)||0,je=!!(e&&(t!=null&&t.RandmarSKU));React.useEffect(()=>{R(1),E(null),M(0)},[t==null?void 0:t.RandmarSKU]),React.useEffect(()=>{var Ze;if(t&&o){const ct=(Ze=t.Opportunities)==null?void 0:Ze.find(mt=>mt.BidNumber==o);ct&&Be(ct)&&E(ct)}},[t,o]),React.useEffect(()=>{if(!t)return;const Ze=C!=null&&C.Price?C.Price:Ae;M($e>0?Math.round(($e-Ze)/$e*100):0)},[t,C,Ae,$e]),React.useEffect(()=>{d||R(1)},[d]),React.useEffect(()=>{if(!Q){V(null),ae("idle"),Oe(null);return}if(!e||!(t!=null&&t.RandmarSKU)){ae("error"),Oe("Missing identifiers to load performance data.");return}let Ze=!1;const ct=t.RandmarSKU;return(async()=>{ae("summary"),Oe(null);try{const ft=await Ne({routeApplicationId:e,randmarSku:ct,withSpecification:!1});if(Ze)return;if("error"in ft&&ft.error)throw ft.error;V(ft.data??null),ae("detailed");const yt=await Ne({routeApplicationId:e,randmarSku:ct,withSpecification:!0});if(Ze)return;if("error"in yt&&yt.error)throw yt.error;V(yt.data??ft.data??null),ae("complete")}catch(ft){if(Ze)return;console.error("Failed to load performance data for product modal",ft),ae("error"),Oe("We couldn't load the performance details. Please try again.")}})(),()=>{Ze=!0}},[e,Ne,Q,t==null?void 0:t.RandmarSKU]);const Be=Ze=>{if(Ze.Active!==!0)return!1;const ct=new Date().toISOString().split("T")[0];return!(Ze.EndDate&&Ze.EndDate.split("T")[0]<ct||Ze.StartDate&&Ze.StartDate.split("T")[0]>ct)},qe=Ze=>Ze>=90?{label:"Top 10% Bestseller",color:"text-purple-950",bgColor:"bg-purple-200"}:Ze>=75?{label:"Bestseller",color:"text-blue-700",bgColor:"bg-blue-50"}:Ze>=33?{label:"Popular",color:"text-green-700",bgColor:"bg-green-50"}:{label:"Rising",color:"text-gray-700",bgColor:"bg-white"},Ve=ne!=="complete"&&ne!=="error",Le=ne==="summary"?40:ne==="detailed"?80:10,He=(F==null?void 0:F.SalesStatistics)??[],We=Ve?[]:He,ze=(F==null?void 0:F.RandmarTitle)??(t==null?void 0:t.RandmarTitle)??(t==null?void 0:t.RandmarSKU)??"this product",Xe=(F==null?void 0:F.RandmarSKU)??(t==null?void 0:t.RandmarSKU);if(!t)return jsxRuntime.jsx(Card,{className:"flex h-full w-full flex-col",children:jsxRuntime.jsxs(CardContent,{className:"flex h-full flex-col p-6",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start mb-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx("div",{className:"h-10 w-24 flex items-center justify-end ml-4",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"})})]}),jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-24 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-28 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"flex gap-6",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-6 flex-1",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:jsxRuntime.jsx("div",{className:"w-60 h-40",children:jsxRuntime.jsx(Skeleton,{className:"w-full h-full rounded-lg"})})})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsx("div",{className:"flex flex-1",children:jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-24 mb-3"}),jsxRuntime.jsx(Skeleton,{className:"h-16 w-full rounded-md"})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-32 rounded-md"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24 mt-4"})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-start gap-1 mb-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"}),jsxRuntime.jsx(Skeleton,{className:"h-10 flex-1 rounded-md"})]})]})]})});const nt=(t==null?void 0:t.Opportunities)||[],Je=nt.length>0,st=()=>{if(S==null){R(1);return}S>1&&R(S-1)},et=()=>{if(S==null){R(1);return}R(S+1)},at=Ze=>{const ct=Number.parseInt(Ze.target.value,10);if(!isNaN(ct)&&ct>0){R(ct);return}R(void 0)},tt=()=>{(S==null||S<1)&&R(1)},ot=Ze=>{try{return new Date(Ze).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch(ct){return console.error(ct),Ze.split("T")[0]||"N/A"}},lt=()=>{typeof l<"u"&&l({quantity:S??1,bidNumber:(C==null?void 0:C.BidNumber)??null})},Ge=()=>{I||!f||(j(!0),q({routeResellerId:e??"",randmarSku:t.RandmarSKU??"",shopifyHostName:f}).then(Ze=>{if(Ze.error){console.error("Error syncing to Shopify:",Ze.error),_({title:"Product synced failed.",description:"Error syncing to Shopify:",variant:"destructive"});return}_({title:"Product synced",description:"Product synced to Shopify successfully",variant:"success"})}).catch(Ze=>{console.error("Error syncing to Shopify:",Ze),_({title:"Product synced failed.",description:"Error syncing to Shopify:",variant:"destructive"})}).finally(()=>{j(!1)}))};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Card,{className:"flex h-full w-full flex-col hover:shadow-lg transition-shadow @container",children:jsxRuntime.jsxs(CardContent,{className:"flex h-full flex-col p-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col gap-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start mb-3",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-xl",children:t.Title||t.RandmarTitle}),jsxRuntime.jsx("div",{className:"w-24 h-10 flex items-center justify-end ml-4 flex-shrink-0",children:jsxRuntime.jsx(PartnerLogo,{id:t.ManufacturerId,name:t.ManufacturerName,width:96,height:40},`partner_logo_${t.ManufacturerId}`)})]}),jsxRuntime.jsxs("div",{className:"flex flex-col @[36rem]:flex-row gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-1 @[36rem]:order-1 order-2 flex flex-col gap-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 items-center justify-center @[36rem]:items-start @[36rem]:justify-start",children:[t.State&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${t.State==="Active"?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(Check,{size:"12",className:"mr-1.5"})," ",t.State]}),jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${t.SerialNumber?"bg-green-50 text-green-700 hover:bg-green-50":"bg-yellow-50 text-yellow-700 hover:bg-yellow-50"}`,children:[jsxRuntime.jsx(QrCode,{size:"12",className:"mr-1.5"})," ",t.SerialNumber?"Serialized":"Unserialized"]}),t.TransparencyCode&&jsxRuntime.jsxs(Badge,{variant:"outline",className:"rounded-full px-3 bg-green-50 text-green-700 hover:bg-green-50",children:[jsxRuntime.jsx(CircleDashed,{size:"12",className:"mr-1.5"})," Transparency Code"]}),t.AvailableToBuy!==void 0&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${t.AvailableToBuy?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(ShoppingCart,{size:"12",className:"mr-1.5"})," ",t.AvailableToBuy?"Available":"Unavailable"]}),t.ManufacturerCategory!==void 0&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${(dt=t.ManufacturerCategory)!=null&&dt.QualificationRequired?"bg-blue-50 text-blue-700 hover:bg-blue-50":"bg-neutral-50 text-neutral-700 hover:bg-neutral-50"}`,children:[jsxRuntime.jsx(ShieldCheck,{size:"12",className:"mr-1.5"})," ",(It=t.ManufacturerCategory)!=null&&It.QualificationRequired?"Qualified Only":"Available to all"]}),t.ManufacturerId&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${t.AutoUpdate?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(RefreshCw,{size:"12",className:"mr-1.5"})," ",t.AutoUpdate?`Automatic Reorder (${t.MasterCarton})`:"Manually Reorders"]}),jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${t.BodyHTML&&t.Title&&t.MAP?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(Store,{size:"12",className:"mr-1.5"})," ",t.BodyHTML&&t.Title&&t.MAP?"Shopify Ready":"Not Shopify Ready"]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-4 flex-1",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"MPN"}),jsxRuntime.jsx("div",{className:"font-medium",children:t.MPN||"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"UPC"}),jsxRuntime.jsx("div",{className:"font-medium",children:t.UPC||"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Unit Weight"}),jsxRuntime.jsx("div",{className:"font-medium",children:t.UnitWeight?`${formatNumber(t.UnitWeight)} lbs`:"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"text-sm text-muted-foreground",children:["MAP",jsxRuntime.jsx("span",{className:"text-primary",children:" / "}),"MSRP"]}),jsxRuntime.jsxs("div",{className:"font-medium",children:[t.MAP?formatMoney(t.MAP):"N/A",jsxRuntime.jsx("span",{className:"text-primary",children:" / "}),t.MSRP?formatMoney(t.MSRP):"N/A"]})]}),!!t.OverallPercentileRank&&!!t.ManufacturerPercentileRank&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground mb-2",children:"Bestseller Status"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{children:"Global: "}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Badge,{variant:"outline",className:`rounded-full px-3 w-fit ${qe(t.OverallPercentileRank).bgColor} ${qe(t.OverallPercentileRank).color} hover:${qe(t.OverallPercentileRank).bgColor}`,children:qe(t.OverallPercentileRank).label})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["Percentile Rank: ",t.OverallPercentileRank]})})]})})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("span",{children:[t.ManufacturerName,": "]}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Badge,{variant:"outline",className:`rounded-full px-3 w-fit ${qe(t.ManufacturerPercentileRank).bgColor} ${qe(t.ManufacturerPercentileRank).color} hover:${qe(t.ManufacturerPercentileRank).bgColor}`,children:qe(t.ManufacturerPercentileRank).label})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["Percentile Rank: ",t.ManufacturerPercentileRank]})})]})})]})]})]}),t.CountryCodeOfOrigin&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Origin"}),jsxRuntime.jsxs("div",{className:"font-medium flex items-center",children:[jsxRuntime.jsx(CountryFlag,{countryCode:t.CountryCodeOfOrigin,className:"mr-2"}),t.CountryCodeOfOrigin]})]})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col @[36rem]:order-2 order-1 items-center",children:jsxRuntime.jsx(ProductImage,{randmarSKU:t.RandmarSKU||"",alt:t.RandmarTitle||""},`product_image_${t.RandmarSKU}`)})]}),jsxRuntime.jsx("div",{className:"flex flex-col @[36rem]:flex-row gap-6 mt-4",children:jsxRuntime.jsx("div",{className:"flex flex-1 @[36rem]:order-1 order-2",children:Je&&t.Distribution&&jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx("div",{className:"flex items-center",children:"You have "+nt.length+(nt.length>1?" opportunities":" opportunity")+" for this product:"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsx("div",{className:"space-y-2 max-h-[200px] overflow-y-auto p-2 mt-1",children:nt.map((Ze,ct)=>Be(Ze)?jsxRuntime.jsxs("div",{className:`flex justify-between items-center rounded-lg transition-colors py-2 px-4 border border-muted cursor-pointer ${Ze.BidNumber==(C==null?void 0:C.BidNumber)?"bg-purple-100 border-2 border-purple-900":"bg-white border-1 border-purple-600 hover:bg-purple-200"}`,onClick:()=>{E(Ze.BidNumber!==(C==null?void 0:C.BidNumber)?Ze:null)},children:[jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"font-medium text-sm",children:Ze.Opportunity}),jsxRuntime.jsx("span",{className:"text-xs text-neutral-900",children:Ze.BidNumber})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end",children:[jsxRuntime.jsx("span",{className:"font-semibold",children:formatMoney(Ze.Price??0)}),Ze.Rebate&&Ze.Rebate>0&&jsxRuntime.jsxs("span",{className:"text-xs text-green-600",children:["Rebate: ",formatMoney(Ze.Rebate)]}),Ze.EndDate&&jsxRuntime.jsxs("span",{className:"text-xs text-neutral-600",children:["Ends: ",ot(Ze.EndDate)]})]})]},ct):jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex justify-between items-center rounded-lg transition-colors py-2 px-4 bg-purple-100 border border-muted cursor-pointer !bg-neutral-50 hover:bg-neutral-100",onClick:()=>{Ze.BidNumber&&b(`/${e}/Opportunity/${Ze.ManufacturerId}/${Ze.BidNumber}`)},children:[jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"font-medium text-sm",children:Ze.Opportunity}),jsxRuntime.jsxs("span",{className:"text-xs text-neutral-900",children:[Ze.BidNumber," ",jsxRuntime.jsx(Badge,{variant:"outline",className:"text-xs mx-1 h-5 bg-gray-100",children:"Currently unavailable"})]})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end",children:[jsxRuntime.jsx("span",{className:"font-semibold",children:formatMoney(Ze.Price??0)}),Ze.Rebate&&Ze.Rebate>0&&jsxRuntime.jsxs("span",{className:"text-xs text-green-600",children:["Rebate: ",formatMoney(Ze.Rebate)]}),Ze.EndDate&&jsxRuntime.jsxs("span",{className:"text-xs text-neutral-600",children:["Ends: ",ot(Ze.EndDate)]})]})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"View Opportunity"})})]},ct))})})]})})})]}),jsxRuntime.jsxs("div",{className:"mt-4 flex flex-col gap-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-row flex-wrap justify-between items-end gap-4",children:[jsxRuntime.jsx("div",{className:"flex flex-col gap-3 flex-1",children:t.Distribution&&jsxRuntime.jsx("div",{className:"flex flex-col gap-1",children:oe>0?jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("span",{className:"text-2xl font-bold whitespace-nowrap",children:["Cost: ",formatMoney(oe)]})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap",children:[$e>0&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("span",{className:"text-2xl font-bold whitespace-nowrap",children:formatMoney((C?(Ct=(Mt=t.Opportunities)==null?void 0:Mt.find(Ze=>Ze.BidNumber==C.BidNumber))==null?void 0:Ct.Price:Ae)??0)})}),A>0&&jsxRuntime.jsx("span",{className:"text-muted-foreground line-through ml-2 whitespace-nowrap",children:formatMoney($e)})]}),A>0&&jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs(Badge,{variant:"outline",className:"bg-red-50 text-red-700 rounded-full px-3 whitespace-nowrap",children:[jsxRuntime.jsxs("span",{children:[A,"% OFF"]}),((Ke=t.InstantRebate)==null?void 0:Ke.EndDate)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"mx-1.5",children:"●"})," Ends ",t.InstantRebate.EndDate.split("T")[0]]}),(C==null?void 0:C.EndDate)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"mx-1.5",children:"●"})," Ends ",C.EndDate.split("T")[0]]})]})})]})})}),jsxRuntime.jsxs("div",{className:"flex flex-col justify-center @[36rem]:justify-end items-end gap-2 w-full @[36rem]:w-auto",children:[f&&jsxRuntime.jsx(Button$1,{className:"gap-2 whitespace-nowrap bg-green-600 hover:bg-green-700",onClick:Ge,disabled:I,children:I?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}),"Syncing..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2"}),"Sync to Shopify"]})}),g,typeof l<"u"&&jsxRuntime.jsxs("div",{className:"flex gap-2 whitespace-nowrap",children:[jsxRuntime.jsxs("div",{className:"flex items-center border rounded-md",children:[jsxRuntime.jsx(Button$1,{variant:"ghost",size:"icon",className:"rounded-r-none",onClick:st,disabled:typeof S<"u"&&(S<=1||!t.AvailableToBuy||d),children:"-"}),jsxRuntime.jsx("input",{value:S,onChange:at,onBlur:tt,onClick:Ze=>Ze.currentTarget.select(),className:`w-6 @[36rem]:w-12 text-center border-0 focus:ring-0 focus:outline-none ${!t.AvailableToBuy||d?"text-gray-400":""}`,disabled:!t.AvailableToBuy||d}),jsxRuntime.jsx(Button$1,{variant:"ghost",size:"icon",className:"rounded-l-none",onClick:et,disabled:!t.AvailableToBuy||d,children:"+"})]}),jsxRuntime.jsx(Button$1,{className:"gap-2 whitespace-nowrap",onClick:lt,disabled:!t.AvailableToBuy||d,children:d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}),"Adding..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2"}),"Add to Cart"]})})]})]})]}),jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-2 @[36rem]:flex-row",children:[jsxRuntime.jsx("div",{className:"flex-1 min-w-[10rem]",children:jsxRuntime.jsxs(Button$1,{variant:"outline",type:"button",className:"h-11 px-4 text-sm font-medium justify-start w-full",onClick:()=>te(!0),disabled:!je,children:[jsxRuntime.jsx(ChartLine,{className:"mr-2"}),"View statistics"]})}),jsxRuntime.jsx("div",{className:"flex-1 min-w-[10rem]",children:jsxRuntime.jsx(ProductInventoryButton,{applicationId:e??"",randmarSku:t.RandmarSKU??"",inventory:(Ye=t.Distribution)==null?void 0:Ye.Inventory,buttonSize:"lg",buttonClassName:"w-full h-11 justify-start"})}),n&&jsxRuntime.jsx(reactRouterDom.Link,{to:n,className:"flex-1 min-w-[10rem]",children:jsxRuntime.jsxs(Button$1,{variant:"outline",className:"h-11 px-4 text-sm font-medium justify-start w-full",children:[jsxRuntime.jsx(Eye,{className:"mr-2"}),"View Product"]})})]})]})]})}),jsxRuntime.jsx(Dialog,{open:Q,onOpenChange:te,children:jsxRuntime.jsxs(DialogContent,{className:"w-[min(95vw,1100px)] max-w-5xl space-y-6",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Monthly Sales Performance"}),jsxRuntime.jsxs(DialogDescription,{children:["Expanded product insights for ",ze,Xe?` (SKU ${Xe})`:""]})]}),jsxRuntime.jsx("div",{className:"space-y-6",children:se?jsxRuntime.jsxs(Alert,{variant:"destructive",children:[jsxRuntime.jsx(AlertTitle,{children:"Unable to load details"}),jsxRuntime.jsx(AlertDescription,{children:se})]}):jsxRuntime.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[jsxRuntime.jsxs("div",{className:"mb-4 space-y-2",children:[jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"Rolling 12-month sales dollars and units sold pulled from the detailed endpoint."}),Ve&&jsxRuntime.jsx("div",{"aria-live":"polite","aria-busy":"true",children:jsxRuntime.jsx(Progress,{value:Le,className:"h-2 w-full animate-pulse","aria-label":"Loading performance data"})})]}),jsxRuntime.jsx(SalesChart,{statistics:We,mode:"month",chartHeight:320}),Ve&&jsxRuntime.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"Gathering product summary and sales statistics..."})]})})]})})]})}const complexComponents=[`----
1241
1241
  PartnerCard: For data that fits this shape:
1242
1242
  { "ApplicationId": "19022", "PublicName": "BiOSS", "VoiceName": null, "VoiceStyle": null, "About": "example", "SceneName": "Kitchen Counter", "IsReseller": true, "IsManufacturer": true, "IsSalesAgency": false, "Socials": [ { "ApplicationId": "19022", "SocialNetwork": "Facebook", "Tag": "@bioss.ca" }, { "ApplicationId": "19022", "SocialNetwork": "Instagram", "Tag": "@bioss.ca" }, { "ApplicationId": "19022", "SocialNetwork": "LinkedIn", "Tag": "@biossinc" }, { "ApplicationId": "19022", "SocialNetwork": "Youtube", "Tag": "@biosssolutionssanitairessa4095" } ], "Manufacturer": null, "Reseller": null }
1243
1243
  Use <PartnerCard account={data} action={<></>}>`,`----
@@ -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
 
@@ -1452,6 +1452,6 @@ img.ProseMirror-separator {
1452
1452
  .ProseMirror p {
1453
1453
  margin-bottom: 0.5em;
1454
1454
  }
1455
- `;function RichTextEditor({id:e,name:t,value:n,onChange:o,placeholder:l,className:d,...f}){const[g,b]=React.useState(!1),_=React.useRef(null),S=React.useRef(null),R=useEditor({extensions:[StarterKit,Underline],content:n,editorProps:{attributes:{class:"prose prose-sm sm:prose dark:prose-invert focus:outline-none",id:e??"",name:t??""}},onUpdate:({editor:j})=>{const q=j.getHTML();o({target:{id:e,name:t,value:q}})}});React.useEffect(()=>{R&&n!==R.getHTML()&&R.commands.setContent(n)},[n,R]);const C=React.useCallback(j=>{if(R)if(R.chain().focus(),j==="paragraph")R.chain().setParagraph().run();else{const q=Number.parseInt(j.slice(1));R.chain().setHeading({level:q}).run()}},[R]),E=React.useCallback(j=>{if(R)switch(R.chain().focus(),j){case"bold":R.chain().toggleBold().run();break;case"italic":R.chain().toggleItalic().run();break;case"underline":R.chain().toggleUnderline().run();break;case"strike":R.chain().toggleStrike().run();break;case"bulletList":R.chain().toggleBulletList().run();break;case"orderedList":R.chain().toggleOrderedList().run();break}},[R]),A=React.useCallback(()=>{b(j=>!j)},[]),M=React.useCallback(j=>{const q=j.target.value;R&&R.commands.setContent(q),o({target:{id:e,name:t,value:q}})},[o,R,e,t]),I=React.useCallback(()=>{!g&&R&&R.commands.focus()},[g,R]);return R?jsxRuntime.jsxs("div",{ref:S,className:cn("border border-input rounded-md overflow-hidden focus-within:outline-hidden focus-within:ring-1 focus-within:ring-ring",d),onClick:I,...f,children:[jsxRuntime.jsx("style",{children:editorStyles}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center p-2 border-b border-input gap-2 bg-background",children:[jsxRuntime.jsxs(Select$1,{onValueChange:C,disabled:g,children:[jsxRuntime.jsx(SelectTrigger,{className:"w-[160px]",children:jsxRuntime.jsx(SelectValue,{placeholder:"Format"})}),jsxRuntime.jsx(SelectContent,{children:formatOptions.map(j=>jsxRuntime.jsx(SelectItem,{value:j.value,children:j.label},j.value))})]}),["bold","italic","underline","strike","bulletList","orderedList"].map(j=>jsxRuntime.jsxs(Button$1,{type:"button",variant:"ghost",size:"sm",onClick:()=>E(j),className:R.isActive(j)?"bg-muted":"",disabled:g,children:[j==="bold"&&jsxRuntime.jsx(Bold$1,{className:"h-4 w-4"}),j==="italic"&&jsxRuntime.jsx(Italic$1,{className:"h-4 w-4"}),j==="underline"&&jsxRuntime.jsx(Underline$1,{className:"h-4 w-4"}),j==="strike"&&jsxRuntime.jsx(Strikethrough,{className:"h-4 w-4"}),j==="bulletList"&&jsxRuntime.jsx(List$1,{className:"h-4 w-4"}),j==="orderedList"&&jsxRuntime.jsx(ListOrdered,{className:"h-4 w-4"})]},j)),jsxRuntime.jsx(Button$1,{type:"button",variant:"ghost",size:"sm",onClick:A,className:g?"bg-muted":"",children:jsxRuntime.jsx(Code$1,{className:"h-4 w-4"})})]}),jsxRuntime.jsx("div",{className:"p-3",children:g?jsxRuntime.jsx(Textarea,{ref:_,id:e,name:t,value:R.getHTML(),onChange:M,className:cn("min-h-[150px] font-mono text-sm resize-none border-0 focus-visible:ring-0 focus-visible:ring-offset-0",d),placeholder:l}):jsxRuntime.jsx(EditorContent,{editor:R})})]}):null}function ReceiptsTable({applicationId:e,receipts:t=null,loading:n=!1}){const o=React.useMemo(()=>[{accessorKey:"Location",header:"Location",cell:({row:f})=>f.original.Location??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"ReceiptDate",header:"Date",cell:({row:f})=>formatYYYYMMDDIntToDateString(f.original.ReceiptDate),enableSorting:!0,enableFiltering:!0},{accessorKey:"ReceiptNumber",header:"Number",cell:({row:f})=>f.original.ReceiptNumber?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/Document/${f.original.ReceiptNumber}`,className:"font-medium text-primary hover:underline",children:f.original.ReceiptNumber})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for Receipt ",f.original.ReceiptNumber]})})]})}):"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:f})=>f.original.Quantity??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"UnitPrice",header:"Unit Price",cell:({row:f})=>f.original.UnitPrice?formatMoney(f.original.UnitPrice):"—",enableSorting:!0,enableFiltering:!0}],[]),l=React.useMemo(()=>{const f={};if(t){const g=Array.from(new Set(t.map(_=>_.Location).filter(_=>_!=null)));f.Location=g;const b=Array.from(new Set(t.map(_=>formatYYYYMMDDIntToDateString(_.ReceiptDate)).filter(_=>_!=="—"&&_!=="Invalid Date"))).sort((_,S)=>new Date(S).getTime()-new Date(_).getTime());f.ReceiptDate=b}return f},[t]),d=t||[];return jsxRuntime.jsx(DataTable,{columns:o,data:d,uniqueValues:l,loading:n,tableClass:"bg-card text-card-foreground",initialSort:[{id:"ReceiptDate",desc:!0}]})}const formatDate$1=e=>{if(!e)return"N/A";try{const t=new Date(e);return isNaN(t.getTime())?"Invalid Date":t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return"Invalid Date"}},getStatusVariant=e=>{const t=(e==null?void 0:e.toLowerCase())||"";return t.includes("accepted")?"success":t.includes("error")||t.includes("rejected")?"destructive":"neutral"};function ReturnsTable({applicationId:e,returns:t=null,loading:n=!1}){const o=React.useMemo(()=>[{accessorKey:"ReturnNumber1",header:"RMA Number",cell:({row:f})=>{const g=f.original.ReturnNumber1||f.original.ReturnNumber;return g?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/Return/${g}`,className:"font-medium text-primary hover:underline",children:g})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for return ",g]})})]})}):"N/A"},enableSorting:!0,enableFiltering:!0},{accessorKey:"RequestDate",header:"Request Date",cell:({row:f})=>formatDate$1(f.original.RequestDate),enableSorting:!0},{accessorKey:"InvoiceNumber",header:"Invoice Number",cell:({row:f})=>{const g=f.original.InvoiceNumber;return g?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/Document/${g}`,className:"text-blue-600 hover:underline dark:text-blue-400",children:g})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for invoice ",g]})})]})}):"N/A"},enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:f})=>f.original.Quantity??"0",enableSorting:!0},{accessorKey:"ReasonForReturn",header:"Return Reason",cell:({row:f})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:f.original.ReasonForReturn??"—"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"Status",header:"Status",cell:({row:f})=>{const g=f.original.Status,b=getStatusVariant(g);let _="border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400";return b==="success"?_="border-green-500 bg-green-100 text-green-700 dark:border-green-600 dark:bg-green-900/50 dark:text-green-400":b==="destructive"&&(_="border-red-500 bg-red-100 text-red-700 dark:border-red-600 dark:bg-red-900/50 dark:text-red-400"),g?jsxRuntime.jsx(Badge,{variant:"outline",className:`${_} font-medium`,children:g}):"—"},enableSorting:!0,enableFiltering:!0},{accessorKey:"WarehouseLocation",header:"Warehouse",cell:({row:f})=>f.original.WarehouseLocation??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"LastUpdatedDate",header:"Last Update",cell:({row:f})=>formatDate$1(f.original.LastUpdatedDate)!=="N/A"?formatDate$1(f.original.LastUpdatedDate):"—",enableSorting:!0}],[e]),l=React.useMemo(()=>{const f={};if(t){const g=Array.from(new Set(t.map(S=>S.Status).filter(Boolean)));f.Status=g;const b=Array.from(new Set(t.map(S=>S.ReasonForReturn).filter(Boolean)));f.ReasonForReturn=b;const _=Array.from(new Set(t.map(S=>S.WarehouseLocation).filter(Boolean)));f.WarehouseLocation=_}return f},[t]),d=React.useMemo(()=>t?[...t].sort((g,b)=>(b.ReturnNumber1||b.ReturnNumber||"").localeCompare(g.ReturnNumber1||g.ReturnNumber||"")):[],[t]);return n?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(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-48 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:"Returns"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:o,data:d,uniqueValues:l})})]})}function PurchaseOrdersTable({applicationId:e,purchaseOrders:t=null,loading:n=!1}){const[o,l]=React.useState([]),[d]=usePostV4ManufacturerByRouteManufacturerIdPurchaseOrderAndPurchaseOrderNumberEditItemRandmarSkuMutation(),{toast:f}=useToast();React.useEffect(()=>{l(t||[])},[t]);const g=React.useMemo(()=>[{accessorKey:"PurchaseOrderNumber",header:"Number",cell:({row:_})=>_.original.PurchaseOrderNumber?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/Document/${_.original.PurchaseOrderNumber}`,className:"font-medium text-primary hover:underline",children:_.original.PurchaseOrderNumber})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for Purchase Order ",_.original.PurchaseOrderNumber]})})]})}):"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"PurchaseOrderDate",header:"Date",cell:({row:_})=>formatYYYYMMDDIntToDateString(_.original.PurchaseOrderDate),enableSorting:!0,enableFiltering:!0},{accessorKey:"Location",header:"Location",cell:({row:_})=>_.original.Location??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"PartNumber",header:"Part Number",cell:({row:_})=>_.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/${_.original.RandmarSKU}`,className:"font-medium text-primary hover:underline",children:_.original.MPN})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for Product ",_.original.RandmarSKU]})})]})}):"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"QuantityOrdered",header:"Quantity Ordered",cell:({row:_})=>_.original.QuantityOrdered??0,enableSorting:!0,enableFiltering:!0},{accessorKey:"UnitPrice",header:"Unit Price",cell:({row:_})=>_.original.UnitPrice?formatMoney(_.original.UnitPrice):"—",enableSorting:!0,enableFiltering:!0},{id:"actions",header:()=>jsxRuntime.jsx("div",{className:"text-right",children:"Action"}),cell:function({row:S}){const[R,C]=React.useState(!1),E=S.original,A=()=>{C(!0),d({routeManufacturerId:e,purchaseOrderNumber:E.PurchaseOrderNumber??"",randmarSku:E.RandmarSKU??"",quantity:0}).then(()=>{l(M=>M.filter(I=>!(I.PurchaseOrderNumber===I.PurchaseOrderNumber&&I.MPN===I.MPN))),f({variant:"success",title:"Success",description:`Part ${E.MPN} has been successfully deleted from Purchase Order ${E.PurchaseOrderNumber}.`})}).catch(M=>{console.error(M),C(!0),f({variant:"destructive",title:"Error",description:"Something went wrong!"})})};return jsxRuntime.jsx("div",{className:"text-right",children:jsxRuntime.jsxs(AlertDialog,{children:[jsxRuntime.jsx(AlertDialogTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"red",size:"sm",disabled:R,children:R?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Deleting"]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})})}),jsxRuntime.jsxs(AlertDialogContent,{children:[jsxRuntime.jsxs(AlertDialogHeader,{children:[jsxRuntime.jsx(AlertDialogTitle,{children:"Confirmation"}),jsxRuntime.jsxs(AlertDialogDescription,{children:["Are you sure you want to delete part ",jsxRuntime.jsx("strong",{children:E.MPN})," from Purchase Order ",jsxRuntime.jsx("strong",{children:E.PurchaseOrderNumber}),"?."]})]}),jsxRuntime.jsxs(AlertDialogFooter,{children:[jsxRuntime.jsx(AlertDialogCancel,{disabled:R,children:"Cancel"}),jsxRuntime.jsxs(AlertDialogAction,{onClick:A,disabled:R,children:[R&&jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Confirm"]})]})]})]})})}}],[e]),b=React.useMemo(()=>{const _={};return o&&(_.PurchaseOrderNumber=Array.from(new Set(o.map(S=>S.PurchaseOrderNumber).filter(S=>S!=null))),_.PurchaseOrderDate=Array.from(new Set(o.map(S=>S.PurchaseOrderDate).filter(S=>S!=null).map(String))),_.Location=Array.from(new Set(o.map(S=>S.Location).filter(S=>S!=null))),_.PartNumber=Array.from(new Set(o.map(S=>S.MPN).filter(S=>S!=null))),_.QuantityOrdered=Array.from(new Set(o.map(S=>S.QuantityOrdered).filter(S=>S!=null).map(String))),_.UnitPrice=Array.from(new Set(o.map(S=>S.UnitPrice).filter(S=>S!=null).map(String)))),_},[o]);return jsxRuntime.jsx(DataTable,{columns:g,data:o,uniqueValues:b,loading:n,tableClass:"bg-card text-card-foreground"})}function RequisitionsTable({applicationId:e,requisitions:t=null,loading:n=!1}){const[o,l]=React.useState([]),[d]=useDeleteV4ManufacturerByRouteManufacturerIdRequisitionAndRequisitionNumberMutation(),{toast:f}=useToast();React.useEffect(()=>{l(t||[])},[t]);const g=React.useMemo(()=>[{accessorKey:"RequisitionNumber",header:"Number",cell:({row:_})=>_.original.RequisitionNumber?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/Document/${_.original.RequisitionNumber}`,className:"font-medium text-primary hover:underline",children:_.original.RequisitionNumber})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for Draft Purchase ",_.original.RequisitionNumber]})})]})}):"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"RequisitionDate",header:"Date",cell:({row:_})=>formatYYYYMMDDIntToDateString(_.original.RequisitionDate),enableSorting:!0,enableFiltering:!0},{accessorKey:"Location",header:"Location",cell:({row:_})=>_.original.Location??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"QuantityOrdered",header:"Quantity Ordered",cell:({row:_})=>_.original.QuantityOrdered??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"QuantityOutstanding",header:"Quantity Outstanding",cell:({row:_})=>_.original.QuantityOutstanding??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"QuantityReceived",header:"Quantity Received",cell:({row:_})=>_.original.QuantityReceived??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"SubTotal",header:"Sub Total",cell:({row:_})=>_.original.SubTotal?formatMoney(_.original.SubTotal):"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"RequestedBy",header:"Requestor",cell:({row:_})=>_.original.RequestedBy??"—",enableSorting:!0,enableFiltering:!0},{id:"actions",header:()=>jsxRuntime.jsx("div",{className:"text-right",children:"Action"}),cell:function({row:S}){const[R,C]=React.useState(!1),E=S.original,A=()=>{C(!0),d({routeManufacturerId:e,requisitionNumber:E.RequisitionNumber??""}).then(()=>{l(M=>M.filter(I=>I.RequisitionNumber!==I.RequisitionNumber)),f({variant:"success",title:"Success",description:`Draft Purchase ${E.RequisitionNumber} has been successfully cancelled.`})}).catch(M=>{console.error(M),C(!0),f({variant:"destructive",title:"Error",description:"Something went wrong!"})})};return jsxRuntime.jsx("div",{className:"text-right",children:jsxRuntime.jsxs(AlertDialog,{children:[jsxRuntime.jsx(AlertDialogTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"red",size:"sm",disabled:R,children:R?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Cancelling"]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Trash2,{className:"mr-2 h-4 w-4"}),"Cancel"]})})}),jsxRuntime.jsxs(AlertDialogContent,{children:[jsxRuntime.jsxs(AlertDialogHeader,{children:[jsxRuntime.jsx(AlertDialogTitle,{children:"Confirmation"}),jsxRuntime.jsxs(AlertDialogDescription,{children:["Are you sure you want to cancel Draft Purchase ",jsxRuntime.jsx("strong",{children:E.RequisitionNumber}),"?."]})]}),jsxRuntime.jsxs(AlertDialogFooter,{children:[jsxRuntime.jsx(AlertDialogCancel,{disabled:R,children:"Cancel"}),jsxRuntime.jsxs(AlertDialogAction,{onClick:A,disabled:R,children:[R&&jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Confirm"]})]})]})]})})}}],[e]),b=React.useMemo(()=>{const _={};return o&&(_.RequisitionNumber=Array.from(new Set(o.map(S=>S.RequisitionNumber).filter(S=>S!=null))),_.RequisitionDate=Array.from(new Set(o.map(S=>S.RequisitionDate).filter(S=>S!=null).map(String))),_.QuantityOrdered=Array.from(new Set(o.map(S=>S.QuantityOrdered).filter(S=>S!=null).map(String))),_.QuantityOutstanding=Array.from(new Set(o.map(S=>S.QuantityOutstanding).filter(S=>S!=null).map(String))),_.QuantityReceived=Array.from(new Set(o.map(S=>S.QuantityReceived).filter(S=>S!=null).map(String))),_.Location=Array.from(new Set(o.map(S=>S.Location).filter(S=>S!=null))),_.RequestedBy=Array.from(new Set(o.map(S=>S.RequestedBy).filter(S=>S!=null))),_.SubTotal=Array.from(new Set(o.map(S=>S.SubTotal).filter(S=>S!=null).map(String)))),_},[o]);return jsxRuntime.jsx(DataTable,{columns:g,data:o,uniqueValues:b,loading:n,tableClass:"bg-card text-card-foreground"})}function ProductOverviewPage({applicationId:e,sku:t,product:n,productDefaultOpportunityNumber:o="",productOnAddToCart:l,productAddingToCart:d=!1,productShopifyHostname:f,productCustomAction:g=jsxRuntime.jsx(jsxRuntime.Fragment,{})}){var Q,te,F,V,ne,ae,se,Oe,Ne,oe,$e,Ae,je,Be,qe,Ve;const{data:b,isLoading:_}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:e,randmarSku:t??"",withSpecification:!1},{skip:!!n||!e||!t}),{data:S,isLoading:R}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:e,randmarSku:t??"",withSpecification:!0},{skip:!!n||!e||!t}),C=n??S??b,{data:E}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:e}),[A,M]=React.useState("stats-tab"),[I,j]=React.useState(!1);React.useEffect(()=>{var We,ze,Xe,nt,Je,st,et,at;if(!n&&R){j(!1);return}const Le={stats:(((We=C==null?void 0:C.SalesStatistics)==null?void 0:We.length)??0)<=0,inventory:(((Xe=(ze=C==null?void 0:C.Distribution)==null?void 0:ze.Inventory)==null?void 0:Xe.length)??0)<=0,opportunities:(((nt=C==null?void 0:C.Opportunities)==null?void 0:nt.length)??0)<=0,orders:(((Je=C==null?void 0:C.ActiveOrderDetails)==null?void 0:Je.length)??0)<=0&&(((st=C==null?void 0:C.Returns)==null?void 0:st.length)??0)<=0,invoices:(((et=C==null?void 0:C.CompletedOrderDetails)==null?void 0:et.length)??0)<=0,warehouse:(((at=C==null?void 0:C.Receipts)==null?void 0:at.length)??0)<=0},He=Object.values(Le).some(tt=>!tt);if(j(He),He&&Le[A]){const tt=Object.keys(Le).find(ot=>!Le[ot]);tt&&M(tt)}},[R,C,n,A]);const q=(C==null?void 0:C.ManufacturerId)!==e;return console.log("readonly",q),jsxRuntime.jsxs("div",{className:"@container",children:[jsxRuntime.jsxs("div",{className:"grid gap-4 grid-cols-1 @sm:grid-cols-2 @md:grid-cols-3",children:[jsxRuntime.jsx("div",{className:"@md:col-span-2",children:jsxRuntime.jsx(ProductCard,{applicationId:e,product:C??C,defaultOpportunityNumber:o,onAddToCart:l,addingToCart:d,shopifyHostname:f,customAction:g})}),jsxRuntime.jsxs(Card,{className:"flex flex-col",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsxs(CardTitle,{children:[jsxRuntime.jsx(Info,{className:"h-5 w-5 inline mr-2"})," Additionnal information"]})}),jsxRuntime.jsx(CardContent,{className:"basis-0 mb-6 grow overflow-y-auto",children:_?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsx(Skeleton,{className:"h-1 w-full my-6"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full mt-2"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full mt-1"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex justify-between",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Category Name"}),jsxRuntime.jsx("span",{className:"font-medium",children:(C==null?void 0:C.ProductType)||"N/A"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Master Carton"}),jsxRuntime.jsx("span",{className:"font-medium",children:(C==null?void 0:C.MasterCarton)||"N/A"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Skid Quantity"}),jsxRuntime.jsx("span",{className:"font-medium",children:(C==null?void 0:C.SkidQuantity)||"N/A"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Automatic Reorder"}),jsxRuntime.jsx("span",{className:"font-medium",children:C!=null&&C.AutoUpdate?"Yes":"No"})]}),((C==null?void 0:C.VoiceoverCaption)||(C==null?void 0:C.BodyHTML))&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("hr",{className:"my-6"}),jsxRuntime.jsx("div",{className:"text-muted-foreground mb-2",children:"Description"}),(C==null?void 0:C.VoiceoverCaption)&&jsxRuntime.jsx("div",{children:C==null?void 0:C.VoiceoverCaption}),(C==null?void 0:C.BodyHTML)&&jsxRuntime.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:(C==null?void 0:C.BodyHTML)??""}})]})]})})]})]}),jsxRuntime.jsx("div",{className:"my-4",children:_||R?jsxRuntime.jsx("div",{className:"mx-auto flex justify-center items-center h-32",children:jsxRuntime.jsx(LoaderCircle,{className:"h-8 w-8 animate-spin text-primary"})}):I&&jsxRuntime.jsxs(Tabs,{value:A,onValueChange:M,children:[jsxRuntime.jsxs(TabsList,{className:"inline-flex h-auto items-center justify-center rounded-none border-b bg-transparent p-0",children:[jsxRuntime.jsx(TabsTrigger,{value:"stats-tab",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",disabled:(((Q=C==null?void 0:C.SalesStatistics)==null?void 0:Q.length)??0)<=0,children:"Statistics"}),jsxRuntime.jsx(TabsTrigger,{value:"inventory-tab",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",disabled:(((F=(te=C==null?void 0:C.Distribution)==null?void 0:te.Inventory)==null?void 0:F.length)??0)<=0,children:"Inventory"}),jsxRuntime.jsx(TabsTrigger,{value:"opportunities-tab",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",disabled:(((V=C==null?void 0:C.Opportunities)==null?void 0:V.length)??0)<=0,children:"Opportunities"}),jsxRuntime.jsx(TabsTrigger,{value:"active-orders-tab",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",disabled:(((ne=C==null?void 0:C.ActiveOrderDetails)==null?void 0:ne.length)??0)<=0,children:"Active Orders"}),jsxRuntime.jsx(TabsTrigger,{value:"completed-orders-tab",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",disabled:(((ae=C==null?void 0:C.CompletedOrderDetails)==null?void 0:ae.length)??0)<=0,children:"Completed Orders"}),jsxRuntime.jsx(TabsTrigger,{value:"returns-tab",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",disabled:(((se=C==null?void 0:C.Returns)==null?void 0:se.length)??0)<=0,children:"Returns"}),jsxRuntime.jsx(TabsTrigger,{value:"purchase-orders-tab",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",disabled:!(E!=null&&E.IsManufacturer)||(((Oe=C==null?void 0:C.PurchaseOrders)==null?void 0:Oe.length)??0)<=0&&(((Ne=C==null?void 0:C.Requisitions)==null?void 0:Ne.length)??0)<=0,children:"Purchase Orders"}),jsxRuntime.jsx(TabsTrigger,{value:"warehouse-tab",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",disabled:(((oe=C==null?void 0:C.Receipts)==null?void 0:oe.length)??0)<=0,children:"Latest Warehouse Receiving"})]}),jsxRuntime.jsx(TabsContent,{value:"stats-tab",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(SalesChartCard,{statistics:(C==null?void 0:C.SalesStatistics)??[],loading:R})})}),jsxRuntime.jsx(TabsContent,{value:"inventory-tab",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ProductInventoryGrid,{inventory:(($e=C==null?void 0:C.Distribution)==null?void 0:$e.Inventory)??[],className:"bg-card text-card-foreground"})})}),jsxRuntime.jsx(TabsContent,{value:"opportunities-tab",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OpportunitiesTable,{applicationId:e,opportunities:C==null?void 0:C.Opportunities,loading:R})})}),jsxRuntime.jsx(TabsContent,{value:"active-orders-tab",children:(((Ae=C==null?void 0:C.ActiveOrderDetails)==null?void 0:Ae.length)??0)>0&&jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OrdersCard,{applicationId:e,title:"Active Orders",orders:C==null?void 0:C.ActiveOrderDetails,loading:R})})}),jsxRuntime.jsx(TabsContent,{value:"completed-orders-tab",children:(((je=C==null?void 0:C.CompletedOrderDetails)==null?void 0:je.length)??0)>0&&jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OrdersCard,{applicationId:e,title:"Completed Orders",orders:C==null?void 0:C.CompletedOrderDetails,loading:R})})}),jsxRuntime.jsx(TabsContent,{value:"returns-tab",children:(((Be=C==null?void 0:C.Returns)==null?void 0:Be.length)??0)>0&&jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ReturnsTable,{applicationId:e,returns:C==null?void 0:C.Returns,loading:R})})}),jsxRuntime.jsxs(TabsContent,{value:"purchase-orders-tab",children:[(((qe=C==null?void 0:C.PurchaseOrders)==null?void 0:qe.length)??0)>0&&jsxRuntime.jsxs(Card,{className:"mt-4 w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Purchase Orders"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(PurchaseOrdersTable,{applicationId:e,purchaseOrders:C==null?void 0:C.PurchaseOrders,loading:R})})]}),(((Ve=C==null?void 0:C.Requisitions)==null?void 0:Ve.length)??0)>0&&jsxRuntime.jsxs(Card,{className:"mt-4 w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Draft Purchases"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(RequisitionsTable,{applicationId:e,requisitions:C==null?void 0:C.Requisitions,loading:R})})]})]}),jsxRuntime.jsx(TabsContent,{value:"warehouse-tab",children:jsxRuntime.jsxs(Card,{className:"mt-4 w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Receipts"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(ReceiptsTable,{applicationId:e,receipts:C==null?void 0:C.Receipts,loading:R})})]})})]})})]})}const colClasses={base:{1:"grid-cols-1",2:"grid-cols-2",3:"grid-cols-3",4:"grid-cols-4",5:"grid-cols-5",6:"grid-cols-6"},sm:{1:"sm:grid-cols-1",2:"sm:grid-cols-2",3:"sm:grid-cols-3",4:"sm:grid-cols-4",5:"sm:grid-cols-5",6:"sm:grid-cols-6"},md:{1:"md:grid-cols-1",2:"md:grid-cols-2",3:"md:grid-cols-3",4:"md:grid-cols-4",5:"md:grid-cols-5",6:"md:grid-cols-6"},lg:{1:"lg:grid-cols-1",2:"lg:grid-cols-2",3:"lg:grid-cols-3",4:"lg:grid-cols-4",5:"lg:grid-cols-5",6:"lg:grid-cols-6"},xl:{1:"xl:grid-cols-1",2:"xl:grid-cols-2",3:"xl:grid-cols-3",4:"xl:grid-cols-4",5:"xl:grid-cols-5",6:"xl:grid-cols-6"}},buildGridClassName=e=>{const t={base:1,md:2,...e};return["grid","gap-4",t.base?colClasses.base[t.base]:"",t.sm?colClasses.sm[t.sm]:"",t.md?colClasses.md[t.md]:"",t.lg?colClasses.lg[t.lg]:"",t.xl?colClasses.xl[t.xl]:""].filter(Boolean).join(" ")},SearchPageGrid=({results:e,groupBy:t,renderItem:n})=>{const o=t(e);return jsxRuntime.jsx(jsxRuntime.Fragment,{children:Object.entries(o).map(([l,d])=>{const{items:f,gridCols:g}=d;if(f.length===0)return null;const b=buildGridClassName(g);return jsxRuntime.jsxs("div",{className:"mb-4",children:[jsxRuntime.jsx("h2",{className:"text-xl font-semibold tracking-tight mb-4",children:l}),jsxRuntime.jsx("div",{className:b,children:f.map((_,S)=>n(_,S))})]},l)})})},SearchPage=({query:e,results:t,isLoading:n,children:o})=>n?jsxRuntime.jsx("div",{className:"flex w-full justify-center items-center py-24",children:jsxRuntime.jsx(LoaderCircle,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e&&t.length===0?jsxRuntime.jsx("div",{className:"flex w-full justify-center items-start pt-16",children:jsxRuntime.jsx(Card,{className:"w-full max-w-lg",children:jsxRuntime.jsxs(CardHeader,{className:"text-center items-center",children:[jsxRuntime.jsx("div",{className:"rounded-full border bg-muted p-3 mb-4",children:jsxRuntime.jsx(SearchX,{className:"h-8 w-8 text-muted-foreground"})}),jsxRuntime.jsx(CardTitle,{children:"No Results Found"}),jsxRuntime.jsxs(CardDescription,{children:['Your search for "',e,'" did not return any results. Please try a different search term.']})]})})}):t.length>0?jsxRuntime.jsx("div",{className:"grid grid-cols-3 gap-8",children:jsxRuntime.jsx("div",{className:"col-span-3",children:o})}):null;var COLLAPSIBLE_NAME="Collapsible",[createCollapsibleContext,createCollapsibleScope]=createContextScope$2(COLLAPSIBLE_NAME),[CollapsibleProvider,useCollapsibleContext]=createCollapsibleContext(COLLAPSIBLE_NAME),Collapsible=React__namespace.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:o,defaultOpen:l,disabled:d,onOpenChange:f,...g}=e,[b,_]=useControllableState({prop:o,defaultProp:l??!1,onChange:f,caller:COLLAPSIBLE_NAME});return jsxRuntime.jsx(CollapsibleProvider,{scope:n,disabled:d,contentId:useId(),open:b,onOpenToggle:React__namespace.useCallback(()=>_(S=>!S),[_]),children:jsxRuntime.jsx(Primitive$4.div,{"data-state":getState$1(b),"data-disabled":d?"":void 0,...g,ref:t})})});Collapsible.displayName=COLLAPSIBLE_NAME;var TRIGGER_NAME$1="CollapsibleTrigger",CollapsibleTrigger=React__namespace.forwardRef((e,t)=>{const{__scopeCollapsible:n,...o}=e,l=useCollapsibleContext(TRIGGER_NAME$1,n);return jsxRuntime.jsx(Primitive$4.button,{type:"button","aria-controls":l.contentId,"aria-expanded":l.open||!1,"data-state":getState$1(l.open),"data-disabled":l.disabled?"":void 0,disabled:l.disabled,...o,ref:t,onClick:composeEventHandlers(e.onClick,l.onOpenToggle)})});CollapsibleTrigger.displayName=TRIGGER_NAME$1;var CONTENT_NAME$1="CollapsibleContent",CollapsibleContent=React__namespace.forwardRef((e,t)=>{const{forceMount:n,...o}=e,l=useCollapsibleContext(CONTENT_NAME$1,e.__scopeCollapsible);return jsxRuntime.jsx(Presence,{present:n||l.open,children:({present:d})=>jsxRuntime.jsx(CollapsibleContentImpl,{...o,ref:t,present:d})})});CollapsibleContent.displayName=CONTENT_NAME$1;var CollapsibleContentImpl=React__namespace.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:o,children:l,...d}=e,f=useCollapsibleContext(CONTENT_NAME$1,n),[g,b]=React__namespace.useState(o),_=React__namespace.useRef(null),S=useComposedRefs(t,_),R=React__namespace.useRef(0),C=R.current,E=React__namespace.useRef(0),A=E.current,M=f.open||g,I=React__namespace.useRef(M),j=React__namespace.useRef(void 0);return React__namespace.useEffect(()=>{const q=requestAnimationFrame(()=>I.current=!1);return()=>cancelAnimationFrame(q)},[]),useLayoutEffect2(()=>{const q=_.current;if(q){j.current=j.current||{transitionDuration:q.style.transitionDuration,animationName:q.style.animationName},q.style.transitionDuration="0s",q.style.animationName="none";const Q=q.getBoundingClientRect();R.current=Q.height,E.current=Q.width,I.current||(q.style.transitionDuration=j.current.transitionDuration,q.style.animationName=j.current.animationName),b(o)}},[f.open,o]),jsxRuntime.jsx(Primitive$4.div,{"data-state":getState$1(f.open),"data-disabled":f.disabled?"":void 0,id:f.contentId,hidden:!M,...d,ref:S,style:{"--radix-collapsible-content-height":C?`${C}px`:void 0,"--radix-collapsible-content-width":A?`${A}px`:void 0,...e.style},children:M&&l})});function getState$1(e){return e?"open":"closed"}var Root$1=Collapsible,Trigger=CollapsibleTrigger,Content=CollapsibleContent,ACCORDION_NAME="Accordion",ACCORDION_KEYS=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[Collection,useCollection,createCollectionScope]=createCollection(ACCORDION_NAME),[createAccordionContext]=createContextScope$2(ACCORDION_NAME,[createCollectionScope,createCollapsibleScope]),useCollapsibleScope=createCollapsibleScope(),Accordion$1=React.forwardRef((e,t)=>{const{type:n,...o}=e,l=o,d=o;return jsxRuntime.jsx(Collection.Provider,{scope:e.__scopeAccordion,children:n==="multiple"?jsxRuntime.jsx(AccordionImplMultiple,{...d,ref:t}):jsxRuntime.jsx(AccordionImplSingle,{...l,ref:t})})});Accordion$1.displayName=ACCORDION_NAME;var[AccordionValueProvider,useAccordionValueContext]=createAccordionContext(ACCORDION_NAME),[AccordionCollapsibleProvider,useAccordionCollapsibleContext]=createAccordionContext(ACCORDION_NAME,{collapsible:!1}),AccordionImplSingle=React.forwardRef((e,t)=>{const{value:n,defaultValue:o,onValueChange:l=()=>{},collapsible:d=!1,...f}=e,[g,b]=useControllableState({prop:n,defaultProp:o??"",onChange:l,caller:ACCORDION_NAME});return jsxRuntime.jsx(AccordionValueProvider,{scope:e.__scopeAccordion,value:React.useMemo(()=>g?[g]:[],[g]),onItemOpen:b,onItemClose:React.useCallback(()=>d&&b(""),[d,b]),children:jsxRuntime.jsx(AccordionCollapsibleProvider,{scope:e.__scopeAccordion,collapsible:d,children:jsxRuntime.jsx(AccordionImpl,{...f,ref:t})})})}),AccordionImplMultiple=React.forwardRef((e,t)=>{const{value:n,defaultValue:o,onValueChange:l=()=>{},...d}=e,[f,g]=useControllableState({prop:n,defaultProp:o??[],onChange:l,caller:ACCORDION_NAME}),b=React.useCallback(S=>g((R=[])=>[...R,S]),[g]),_=React.useCallback(S=>g((R=[])=>R.filter(C=>C!==S)),[g]);return jsxRuntime.jsx(AccordionValueProvider,{scope:e.__scopeAccordion,value:f,onItemOpen:b,onItemClose:_,children:jsxRuntime.jsx(AccordionCollapsibleProvider,{scope:e.__scopeAccordion,collapsible:!0,children:jsxRuntime.jsx(AccordionImpl,{...d,ref:t})})})}),[AccordionImplProvider,useAccordionContext]=createAccordionContext(ACCORDION_NAME),AccordionImpl=React.forwardRef((e,t)=>{const{__scopeAccordion:n,disabled:o,dir:l,orientation:d="vertical",...f}=e,g=React.useRef(null),b=useComposedRefs(g,t),_=useCollection(n),R=useDirection(l)==="ltr",C=composeEventHandlers(e.onKeyDown,E=>{var ae;if(!ACCORDION_KEYS.includes(E.key))return;const A=E.target,M=_().filter(se=>{var Oe;return!((Oe=se.ref.current)!=null&&Oe.disabled)}),I=M.findIndex(se=>se.ref.current===A),j=M.length;if(I===-1)return;E.preventDefault();let q=I;const Q=0,te=j-1,F=()=>{q=I+1,q>te&&(q=Q)},V=()=>{q=I-1,q<Q&&(q=te)};switch(E.key){case"Home":q=Q;break;case"End":q=te;break;case"ArrowRight":d==="horizontal"&&(R?F():V());break;case"ArrowDown":d==="vertical"&&F();break;case"ArrowLeft":d==="horizontal"&&(R?V():F());break;case"ArrowUp":d==="vertical"&&V();break}const ne=q%j;(ae=M[ne].ref.current)==null||ae.focus()});return jsxRuntime.jsx(AccordionImplProvider,{scope:n,disabled:o,direction:l,orientation:d,children:jsxRuntime.jsx(Collection.Slot,{scope:n,children:jsxRuntime.jsx(Primitive$4.div,{...f,"data-orientation":d,ref:b,onKeyDown:o?void 0:C})})})}),ITEM_NAME="AccordionItem",[AccordionItemProvider,useAccordionItemContext]=createAccordionContext(ITEM_NAME),AccordionItem$1=React.forwardRef((e,t)=>{const{__scopeAccordion:n,value:o,...l}=e,d=useAccordionContext(ITEM_NAME,n),f=useAccordionValueContext(ITEM_NAME,n),g=useCollapsibleScope(n),b=useId(),_=o&&f.value.includes(o)||!1,S=d.disabled||e.disabled;return jsxRuntime.jsx(AccordionItemProvider,{scope:n,open:_,disabled:S,triggerId:b,children:jsxRuntime.jsx(Root$1,{"data-orientation":d.orientation,"data-state":getState(_),...g,...l,ref:t,disabled:S,open:_,onOpenChange:R=>{R?f.onItemOpen(o):f.onItemClose(o)}})})});AccordionItem$1.displayName=ITEM_NAME;var HEADER_NAME="AccordionHeader",AccordionHeader=React.forwardRef((e,t)=>{const{__scopeAccordion:n,...o}=e,l=useAccordionContext(ACCORDION_NAME,n),d=useAccordionItemContext(HEADER_NAME,n);return jsxRuntime.jsx(Primitive$4.h3,{"data-orientation":l.orientation,"data-state":getState(d.open),"data-disabled":d.disabled?"":void 0,...o,ref:t})});AccordionHeader.displayName=HEADER_NAME;var TRIGGER_NAME="AccordionTrigger",AccordionTrigger$1=React.forwardRef((e,t)=>{const{__scopeAccordion:n,...o}=e,l=useAccordionContext(ACCORDION_NAME,n),d=useAccordionItemContext(TRIGGER_NAME,n),f=useAccordionCollapsibleContext(TRIGGER_NAME,n),g=useCollapsibleScope(n);return jsxRuntime.jsx(Collection.ItemSlot,{scope:n,children:jsxRuntime.jsx(Trigger,{"aria-disabled":d.open&&!f.collapsible||void 0,"data-orientation":l.orientation,id:d.triggerId,...g,...o,ref:t})})});AccordionTrigger$1.displayName=TRIGGER_NAME;var CONTENT_NAME="AccordionContent",AccordionContent$1=React.forwardRef((e,t)=>{const{__scopeAccordion:n,...o}=e,l=useAccordionContext(ACCORDION_NAME,n),d=useAccordionItemContext(CONTENT_NAME,n),f=useCollapsibleScope(n);return jsxRuntime.jsx(Content,{role:"region","aria-labelledby":d.triggerId,"data-orientation":l.orientation,...f,...o,ref:t,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}})});AccordionContent$1.displayName=CONTENT_NAME;function getState(e){return e?"open":"closed"}var Root2=Accordion$1,Item=AccordionItem$1,Header=AccordionHeader,Trigger2=AccordionTrigger$1,Content2=AccordionContent$1;const Accordion=Root2,AccordionItem=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Item,{ref:n,className:cn("border-b",e),...t}));AccordionItem.displayName="AccordionItem";const AccordionTrigger=React__namespace.forwardRef(({className:e,children:t,...n},o)=>jsxRuntime.jsx(Header,{className:"flex",children:jsxRuntime.jsxs(Trigger2,{ref:o,className:cn("flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline text-left [&[data-state=open]>svg]:rotate-180",e),...n,children:[t,jsxRuntime.jsx(ChevronDown,{className:"h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200"})]})}));AccordionTrigger.displayName=Trigger2.displayName;const AccordionContent=React__namespace.forwardRef(({className:e,children:t,...n},o)=>jsxRuntime.jsx(Content2,{ref:o,className:"overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:jsxRuntime.jsx("div",{className:cn("pb-4 pt-0",e),children:t})}));AccordionContent.displayName=Content2.displayName;function AssistantInsight({prompt:e,smartAndSlow:t=!1,thinkingPlaceholderText:n="Thinking...",withCard:o=!0}){const{response:l,isLoading:d,error:f,sendPrompt:g}=useGemini({useProModel:t,outputFormat:"html"});React.useEffect(()=>{e&&g(e)},[e,g]);const b=`flex items-start gap-4 ${o?"p-4 border rounded-lg bg-background":""}`;return jsxRuntime.jsxs("div",{className:b,children:[jsxRuntime.jsx(Bot,{className:`mt-1 h-6 w-6 flex-shrink-0 ${d?"animate-pulse text-primary":"text-primary"}`}),jsxRuntime.jsxs("div",{className:"w-full min-h-[4rem]",children:[d&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("p",{className:"font-medium text-muted-foreground",children:n}),jsxRuntime.jsxs("div",{className:"space-y-2 mt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-5/6"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-3/4"})]})]}),f&&jsxRuntime.jsx("p",{className:"text-sm text-red-600",children:f}),!d&&!f&&l&&jsxRuntime.jsx("div",{className:"chat-bubble-in-animation text-sm text-foreground space-y-4",dangerouslySetInnerHTML:{__html:l}})]})]})}function tzName(e,t,n="long"){return new Intl.DateTimeFormat("en-US",{hour:"numeric",timeZone:e,timeZoneName:n}).format(t).split(/\s/g).slice(2).join(" ")}const offsetFormatCache={},offsetCache={};function tzOffset(e,t){try{const o=(offsetFormatCache[e]||(offsetFormatCache[e]=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"longOffset"}).format))(t).split("GMT")[1];return o in offsetCache?offsetCache[o]:calcOffset(o,o.split(":"))}catch{if(e in offsetCache)return offsetCache[e];const n=e==null?void 0:e.match(offsetRe);return n?calcOffset(e,n.slice(1)):NaN}}const offsetRe=/([+-]\d\d):?(\d\d)?/;function calcOffset(e,t){const n=+(t[0]||0),o=+(t[1]||0),l=+(t[2]||0)/60;return offsetCache[e]=n*60+o>0?n*60+o+l:n*60-o-l}class TZDateMini extends Date{constructor(...t){super(),t.length>1&&typeof t[t.length-1]=="string"&&(this.timeZone=t.pop()),this.internal=new Date,isNaN(tzOffset(this.timeZone,this))?this.setTime(NaN):t.length?typeof t[0]=="number"&&(t.length===1||t.length===2&&typeof t[1]!="number")?this.setTime(t[0]):typeof t[0]=="string"?this.setTime(+new Date(t[0])):t[0]instanceof Date?this.setTime(+t[0]):(this.setTime(+new Date(...t)),adjustToSystemTZ(this),syncToInternal(this)):this.setTime(Date.now())}static tz(t,...n){return n.length?new TZDateMini(...n,t):new TZDateMini(Date.now(),t)}withTimeZone(t){return new TZDateMini(+this,t)}getTimezoneOffset(){const t=-tzOffset(this.timeZone,this);return t>0?Math.floor(t):Math.ceil(t)}setTime(t){return Date.prototype.setTime.apply(this,arguments),syncToInternal(this),+this}[Symbol.for("constructDateFrom")](t){return new TZDateMini(+new Date(t),this.timeZone)}}const re=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(e=>{if(!re.test(e))return;const t=e.replace(re,"$1UTC");TZDateMini.prototype[t]&&(e.startsWith("get")?TZDateMini.prototype[e]=function(){return this.internal[t]()}:(TZDateMini.prototype[e]=function(){return Date.prototype[t].apply(this.internal,arguments),syncFromInternal(this),+this},TZDateMini.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),syncToInternal(this),+this}))});function syncToInternal(e){e.internal.setTime(+e),e.internal.setUTCSeconds(e.internal.getUTCSeconds()-Math.round(-tzOffset(e.timeZone,e)*60))}function syncFromInternal(e){Date.prototype.setFullYear.call(e,e.internal.getUTCFullYear(),e.internal.getUTCMonth(),e.internal.getUTCDate()),Date.prototype.setHours.call(e,e.internal.getUTCHours(),e.internal.getUTCMinutes(),e.internal.getUTCSeconds(),e.internal.getUTCMilliseconds()),adjustToSystemTZ(e)}function adjustToSystemTZ(e){const t=tzOffset(e.timeZone,e),n=t>0?Math.floor(t):Math.ceil(t),o=new Date(+e);o.setUTCHours(o.getUTCHours()-1);const l=-new Date(+e).getTimezoneOffset(),d=-new Date(+o).getTimezoneOffset(),f=l-d,g=Date.prototype.getHours.apply(e)!==e.internal.getUTCHours();f&&g&&e.internal.setUTCMinutes(e.internal.getUTCMinutes()+f);const b=l-n;b&&Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+b);const _=new Date(+e);_.setUTCSeconds(0);const S=l>0?_.getSeconds():(_.getSeconds()-60)%60,R=Math.round(-(tzOffset(e.timeZone,e)*60))%60;(R||S)&&(e.internal.setUTCSeconds(e.internal.getUTCSeconds()+R),Date.prototype.setUTCSeconds.call(e,Date.prototype.getUTCSeconds.call(e)+R+S));const C=tzOffset(e.timeZone,e),E=C>0?Math.floor(C):Math.ceil(C),M=-new Date(+e).getTimezoneOffset()-E,I=E!==n,j=M-b;if(I&&j){Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+j);const q=tzOffset(e.timeZone,e),Q=q>0?Math.floor(q):Math.ceil(q),te=E-Q;te&&(e.internal.setUTCMinutes(e.internal.getUTCMinutes()+te),Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+te))}}class TZDate extends TZDateMini{static tz(t,...n){return n.length?new TZDate(...n,t):new TZDate(Date.now(),t)}toISOString(){const[t,n,o]=this.tzComponents(),l=`${t}${n}:${o}`;return this.internal.toISOString().slice(0,-1)+l}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){const[t,n,o,l]=this.internal.toUTCString().split(" ");return`${t==null?void 0:t.slice(0,-1)} ${o} ${n} ${l}`}toTimeString(){const t=this.internal.toUTCString().split(" ")[4],[n,o,l]=this.tzComponents();return`${t} GMT${n}${o}${l} (${tzName(this.timeZone,this)})`}toLocaleString(t,n){return Date.prototype.toLocaleString.call(this,t,{...n,timeZone:(n==null?void 0:n.timeZone)||this.timeZone})}toLocaleDateString(t,n){return Date.prototype.toLocaleDateString.call(this,t,{...n,timeZone:(n==null?void 0:n.timeZone)||this.timeZone})}toLocaleTimeString(t,n){return Date.prototype.toLocaleTimeString.call(this,t,{...n,timeZone:(n==null?void 0:n.timeZone)||this.timeZone})}tzComponents(){const t=this.getTimezoneOffset(),n=t>0?"-":"+",o=String(Math.floor(Math.abs(t)/60)).padStart(2,"0"),l=String(Math.abs(t)%60).padStart(2,"0");return[n,o,l]}withTimeZone(t){return new TZDate(+this,t)}[Symbol.for("constructDateFrom")](t){return new TZDate(+new Date(t),this.timeZone)}}const FIVE_WEEKS=5,FOUR_WEEKS=4;function getBroadcastWeeksInMonth(e,t){const n=t.startOfMonth(e),o=n.getDay()>0?n.getDay():7,l=t.addDays(e,-o+1),d=t.addDays(l,FIVE_WEEKS*7-1);return t.getMonth(e)===t.getMonth(d)?FIVE_WEEKS:FOUR_WEEKS}function startOfBroadcastWeek(e,t){const n=t.startOfMonth(e),o=n.getDay();return o===1?n:o===0?t.addDays(n,-6):t.addDays(n,-1*(o-1))}function endOfBroadcastWeek(e,t){const n=startOfBroadcastWeek(e,t),o=getBroadcastWeeksInMonth(e,t);return t.addDays(n,o*7-1)}class DateLib{constructor(t,n){this.Date=Date,this.today=()=>{var o;return(o=this.overrides)!=null&&o.today?this.overrides.today():this.options.timeZone?TZDate.tz(this.options.timeZone):new this.Date},this.newDate=(o,l,d)=>{var f;return(f=this.overrides)!=null&&f.newDate?this.overrides.newDate(o,l,d):this.options.timeZone?new TZDate(o,l,d,this.options.timeZone):new Date(o,l,d)},this.addDays=(o,l)=>{var d;return(d=this.overrides)!=null&&d.addDays?this.overrides.addDays(o,l):addDays(o,l)},this.addMonths=(o,l)=>{var d;return(d=this.overrides)!=null&&d.addMonths?this.overrides.addMonths(o,l):addMonths(o,l)},this.addWeeks=(o,l)=>{var d;return(d=this.overrides)!=null&&d.addWeeks?this.overrides.addWeeks(o,l):addWeeks(o,l)},this.addYears=(o,l)=>{var d;return(d=this.overrides)!=null&&d.addYears?this.overrides.addYears(o,l):addYears(o,l)},this.differenceInCalendarDays=(o,l)=>{var d;return(d=this.overrides)!=null&&d.differenceInCalendarDays?this.overrides.differenceInCalendarDays(o,l):differenceInCalendarDays(o,l)},this.differenceInCalendarMonths=(o,l)=>{var d;return(d=this.overrides)!=null&&d.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(o,l):differenceInCalendarMonths(o,l)},this.eachMonthOfInterval=o=>{var l;return(l=this.overrides)!=null&&l.eachMonthOfInterval?this.overrides.eachMonthOfInterval(o):eachMonthOfInterval(o)},this.eachYearOfInterval=o=>{var g;const l=(g=this.overrides)!=null&&g.eachYearOfInterval?this.overrides.eachYearOfInterval(o):eachYearOfInterval(o),d=new Set(l.map(b=>this.getYear(b)));if(d.size===l.length)return l;const f=[];return d.forEach(b=>{f.push(new Date(b,0,1))}),f},this.endOfBroadcastWeek=o=>{var l;return(l=this.overrides)!=null&&l.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(o):endOfBroadcastWeek(o,this)},this.endOfISOWeek=o=>{var l;return(l=this.overrides)!=null&&l.endOfISOWeek?this.overrides.endOfISOWeek(o):endOfISOWeek(o)},this.endOfMonth=o=>{var l;return(l=this.overrides)!=null&&l.endOfMonth?this.overrides.endOfMonth(o):endOfMonth(o)},this.endOfWeek=(o,l)=>{var d;return(d=this.overrides)!=null&&d.endOfWeek?this.overrides.endOfWeek(o,l):endOfWeek(o,this.options)},this.endOfYear=o=>{var l;return(l=this.overrides)!=null&&l.endOfYear?this.overrides.endOfYear(o):endOfYear(o)},this.format=(o,l,d)=>{var g;const f=(g=this.overrides)!=null&&g.format?this.overrides.format(o,l,this.options):format(o,l,this.options);return this.options.numerals&&this.options.numerals!=="latn"?this.replaceDigits(f):f},this.getISOWeek=o=>{var l;return(l=this.overrides)!=null&&l.getISOWeek?this.overrides.getISOWeek(o):getISOWeek(o)},this.getMonth=(o,l)=>{var d;return(d=this.overrides)!=null&&d.getMonth?this.overrides.getMonth(o,this.options):getMonth(o,this.options)},this.getYear=(o,l)=>{var d;return(d=this.overrides)!=null&&d.getYear?this.overrides.getYear(o,this.options):getYear(o,this.options)},this.getWeek=(o,l)=>{var d;return(d=this.overrides)!=null&&d.getWeek?this.overrides.getWeek(o,this.options):getWeek(o,this.options)},this.isAfter=(o,l)=>{var d;return(d=this.overrides)!=null&&d.isAfter?this.overrides.isAfter(o,l):isAfter(o,l)},this.isBefore=(o,l)=>{var d;return(d=this.overrides)!=null&&d.isBefore?this.overrides.isBefore(o,l):isBefore(o,l)},this.isDate=o=>{var l;return(l=this.overrides)!=null&&l.isDate?this.overrides.isDate(o):isDate(o)},this.isSameDay=(o,l)=>{var d;return(d=this.overrides)!=null&&d.isSameDay?this.overrides.isSameDay(o,l):isSameDay(o,l)},this.isSameMonth=(o,l)=>{var d;return(d=this.overrides)!=null&&d.isSameMonth?this.overrides.isSameMonth(o,l):isSameMonth(o,l)},this.isSameYear=(o,l)=>{var d;return(d=this.overrides)!=null&&d.isSameYear?this.overrides.isSameYear(o,l):isSameYear(o,l)},this.max=o=>{var l;return(l=this.overrides)!=null&&l.max?this.overrides.max(o):max$1(o)},this.min=o=>{var l;return(l=this.overrides)!=null&&l.min?this.overrides.min(o):min$1(o)},this.setMonth=(o,l)=>{var d;return(d=this.overrides)!=null&&d.setMonth?this.overrides.setMonth(o,l):setMonth(o,l)},this.setYear=(o,l)=>{var d;return(d=this.overrides)!=null&&d.setYear?this.overrides.setYear(o,l):setYear(o,l)},this.startOfBroadcastWeek=(o,l)=>{var d;return(d=this.overrides)!=null&&d.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(o,this):startOfBroadcastWeek(o,this)},this.startOfDay=o=>{var l;return(l=this.overrides)!=null&&l.startOfDay?this.overrides.startOfDay(o):startOfDay(o)},this.startOfISOWeek=o=>{var l;return(l=this.overrides)!=null&&l.startOfISOWeek?this.overrides.startOfISOWeek(o):startOfISOWeek(o)},this.startOfMonth=o=>{var l;return(l=this.overrides)!=null&&l.startOfMonth?this.overrides.startOfMonth(o):startOfMonth(o)},this.startOfWeek=(o,l)=>{var d;return(d=this.overrides)!=null&&d.startOfWeek?this.overrides.startOfWeek(o,this.options):startOfWeek(o,this.options)},this.startOfYear=o=>{var l;return(l=this.overrides)!=null&&l.startOfYear?this.overrides.startOfYear(o):startOfYear(o)},this.options={locale:enUS,...t},this.overrides=n}getDigitMap(){const{numerals:t="latn"}=this.options,n=new Intl.NumberFormat("en-US",{numberingSystem:t}),o={};for(let l=0;l<10;l++)o[l.toString()]=n.format(l);return o}replaceDigits(t){const n=this.getDigitMap();return t.replace(/\d/g,o=>n[o]||o)}formatNumber(t){return this.replaceDigits(t.toString())}getMonthYearOrder(){var n;const t=(n=this.options.locale)==null?void 0:n.code;return t&&DateLib.yearFirstLocales.has(t)?"year-first":"month-first"}formatMonthYear(t){const{locale:n,timeZone:o,numerals:l}=this.options,d=n==null?void 0:n.code;if(d&&DateLib.yearFirstLocales.has(d))try{return new Intl.DateTimeFormat(d,{month:"long",year:"numeric",timeZone:o,numberingSystem:l}).format(t)}catch{}const f=this.getMonthYearOrder()==="year-first"?"y LLLL":"LLLL y";return this.format(t,f)}}DateLib.yearFirstLocales=new Set(["eu","hu","ja","ja-Hira","ja-JP","ko","ko-KR","lt","lt-LT","lv","lv-LV","mn","mn-MN","zh","zh-CN","zh-HK","zh-TW"]);const defaultDateLib=new DateLib;class CalendarDay{constructor(t,n,o=defaultDateLib){this.date=t,this.displayMonth=n,this.outside=!!(n&&!o.isSameMonth(t,n)),this.dateLib=o,this.isoDate=o.format(t,"yyyy-MM-dd"),this.displayMonthId=o.format(n,"yyyy-MM"),this.dateMonthId=o.format(t,"yyyy-MM")}isEqualTo(t){return this.dateLib.isSameDay(t.date,this.date)&&this.dateLib.isSameMonth(t.displayMonth,this.displayMonth)}}class CalendarMonth{constructor(t,n){this.date=t,this.weeks=n}}class CalendarWeek{constructor(t,n){this.days=n,this.weekNumber=t}}function Button(e){return React.createElement("button",{...e})}function CaptionLabel(e){return React.createElement("span",{...e})}function Chevron(e){const{size:t=24,orientation:n="left",className:o}=e;return React.createElement("svg",{className:o,width:t,height:t,viewBox:"0 0 24 24"},n==="up"&&React.createElement("polygon",{points:"6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28"}),n==="down"&&React.createElement("polygon",{points:"6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72"}),n==="left"&&React.createElement("polygon",{points:"16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20"}),n==="right"&&React.createElement("polygon",{points:"8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20"}))}function Day(e){const{day:t,modifiers:n,...o}=e;return React.createElement("td",{...o})}function DayButton(e){const{day:t,modifiers:n,...o}=e,l=React.useRef(null);return React.useEffect(()=>{var d;n.focused&&((d=l.current)==null||d.focus())},[n.focused]),React.createElement("button",{ref:l,...o})}var UI;(function(e){e.Root="root",e.Chevron="chevron",e.Day="day",e.DayButton="day_button",e.CaptionLabel="caption_label",e.Dropdowns="dropdowns",e.Dropdown="dropdown",e.DropdownRoot="dropdown_root",e.Footer="footer",e.MonthGrid="month_grid",e.MonthCaption="month_caption",e.MonthsDropdown="months_dropdown",e.Month="month",e.Months="months",e.Nav="nav",e.NextMonthButton="button_next",e.PreviousMonthButton="button_previous",e.Week="week",e.Weeks="weeks",e.Weekday="weekday",e.Weekdays="weekdays",e.WeekNumber="week_number",e.WeekNumberHeader="week_number_header",e.YearsDropdown="years_dropdown"})(UI||(UI={}));var DayFlag;(function(e){e.disabled="disabled",e.hidden="hidden",e.outside="outside",e.focused="focused",e.today="today"})(DayFlag||(DayFlag={}));var SelectionState;(function(e){e.range_end="range_end",e.range_middle="range_middle",e.range_start="range_start",e.selected="selected"})(SelectionState||(SelectionState={}));var Animation;(function(e){e.weeks_before_enter="weeks_before_enter",e.weeks_before_exit="weeks_before_exit",e.weeks_after_enter="weeks_after_enter",e.weeks_after_exit="weeks_after_exit",e.caption_after_enter="caption_after_enter",e.caption_after_exit="caption_after_exit",e.caption_before_enter="caption_before_enter",e.caption_before_exit="caption_before_exit"})(Animation||(Animation={}));function Dropdown(e){const{options:t,className:n,components:o,classNames:l,...d}=e,f=[l[UI.Dropdown],n].join(" "),g=t==null?void 0:t.find(({value:b})=>b===d.value);return React.createElement("span",{"data-disabled":d.disabled,className:l[UI.DropdownRoot]},React.createElement(o.Select,{className:f,...d},t==null?void 0:t.map(({value:b,label:_,disabled:S})=>React.createElement(o.Option,{key:b,value:b,disabled:S},_))),React.createElement("span",{className:l[UI.CaptionLabel],"aria-hidden":!0},g==null?void 0:g.label,React.createElement(o.Chevron,{orientation:"down",size:18,className:l[UI.Chevron]})))}function DropdownNav(e){return React.createElement("div",{...e})}function Footer(e){return React.createElement("div",{...e})}function Month(e){const{calendarMonth:t,displayIndex:n,...o}=e;return React.createElement("div",{...o},e.children)}function MonthCaption(e){const{calendarMonth:t,displayIndex:n,...o}=e;return React.createElement("div",{...o})}function MonthGrid(e){return React.createElement("table",{...e})}function Months(e){return React.createElement("div",{...e})}const dayPickerContext=React.createContext(void 0);function useDayPicker(){const e=React.useContext(dayPickerContext);if(e===void 0)throw new Error("useDayPicker() must be used within a custom component.");return e}function MonthsDropdown(e){const{components:t}=useDayPicker();return React.createElement(t.Dropdown,{...e})}function Nav(e){const{onPreviousClick:t,onNextClick:n,previousMonth:o,nextMonth:l,...d}=e,{components:f,classNames:g,labels:{labelPrevious:b,labelNext:_}}=useDayPicker(),S=React.useCallback(C=>{l&&(n==null||n(C))},[l,n]),R=React.useCallback(C=>{o&&(t==null||t(C))},[o,t]);return React.createElement("nav",{...d},React.createElement(f.PreviousMonthButton,{type:"button",className:g[UI.PreviousMonthButton],tabIndex:o?void 0:-1,"aria-disabled":o?void 0:!0,"aria-label":b(o),onClick:R},React.createElement(f.Chevron,{disabled:o?void 0:!0,className:g[UI.Chevron],orientation:"left"})),React.createElement(f.NextMonthButton,{type:"button",className:g[UI.NextMonthButton],tabIndex:l?void 0:-1,"aria-disabled":l?void 0:!0,"aria-label":_(l),onClick:S},React.createElement(f.Chevron,{disabled:l?void 0:!0,orientation:"right",className:g[UI.Chevron]})))}function NextMonthButton(e){const{components:t}=useDayPicker();return React.createElement(t.Button,{...e})}function Option(e){return React.createElement("option",{...e})}function PreviousMonthButton(e){const{components:t}=useDayPicker();return React.createElement(t.Button,{...e})}function Root(e){const{rootRef:t,...n}=e;return React.createElement("div",{...n,ref:t})}function Select(e){return React.createElement("select",{...e})}function Week(e){const{week:t,...n}=e;return React.createElement("tr",{...n})}function Weekday(e){return React.createElement("th",{...e})}function Weekdays(e){return React.createElement("thead",{"aria-hidden":!0},React.createElement("tr",{...e}))}function WeekNumber(e){const{week:t,...n}=e;return React.createElement("th",{...n})}function WeekNumberHeader(e){return React.createElement("th",{...e})}function Weeks(e){return React.createElement("tbody",{...e})}function YearsDropdown(e){const{components:t}=useDayPicker();return React.createElement(t.Dropdown,{...e})}const components=Object.freeze(Object.defineProperty({__proto__:null,Button,CaptionLabel,Chevron,Day,DayButton,Dropdown,DropdownNav,Footer,Month,MonthCaption,MonthGrid,Months,MonthsDropdown,Nav,NextMonthButton,Option,PreviousMonthButton,Root,Select,Week,WeekNumber,WeekNumberHeader,Weekday,Weekdays,Weeks,YearsDropdown},Symbol.toStringTag,{value:"Module"}));function rangeIncludesDate(e,t,n=!1,o=defaultDateLib){let{from:l,to:d}=e;const{differenceInCalendarDays:f,isSameDay:g}=o;return l&&d?(f(d,l)<0&&([l,d]=[d,l]),f(t,l)>=(n?1:0)&&f(d,t)>=(n?1:0)):!n&&d?g(d,t):!n&&l?g(l,t):!1}function isDateInterval(e){return!!(e&&typeof e=="object"&&"before"in e&&"after"in e)}function isDateRange(e){return!!(e&&typeof e=="object"&&"from"in e)}function isDateAfterType(e){return!!(e&&typeof e=="object"&&"after"in e)}function isDateBeforeType(e){return!!(e&&typeof e=="object"&&"before"in e)}function isDayOfWeekType(e){return!!(e&&typeof e=="object"&&"dayOfWeek"in e)}function isDatesArray(e,t){return Array.isArray(e)&&e.every(t.isDate)}function dateMatchModifiers(e,t,n=defaultDateLib){const o=Array.isArray(t)?t:[t],{isSameDay:l,differenceInCalendarDays:d,isAfter:f}=n;return o.some(g=>{if(typeof g=="boolean")return g;if(n.isDate(g))return l(e,g);if(isDatesArray(g,n))return g.includes(e);if(isDateRange(g))return rangeIncludesDate(g,e,!1,n);if(isDayOfWeekType(g))return Array.isArray(g.dayOfWeek)?g.dayOfWeek.includes(e.getDay()):g.dayOfWeek===e.getDay();if(isDateInterval(g)){const b=d(g.before,e),_=d(g.after,e),S=b>0,R=_<0;return f(g.before,g.after)?R&&S:S||R}return isDateAfterType(g)?d(e,g.after)>0:isDateBeforeType(g)?d(g.before,e)>0:typeof g=="function"?g(e):!1})}function createGetModifiers(e,t,n,o,l){const{disabled:d,hidden:f,modifiers:g,showOutsideDays:b,broadcastCalendar:_,today:S=l.today()}=t,{isSameDay:R,isSameMonth:C,startOfMonth:E,isBefore:A,endOfMonth:M,isAfter:I}=l,j=n&&E(n),q=o&&M(o),Q={[DayFlag.focused]:[],[DayFlag.outside]:[],[DayFlag.disabled]:[],[DayFlag.hidden]:[],[DayFlag.today]:[]},te={};for(const F of e){const{date:V,displayMonth:ne}=F,ae=!!(ne&&!C(V,ne)),se=!!(j&&A(V,j)),Oe=!!(q&&I(V,q)),Ne=!!(d&&dateMatchModifiers(V,d,l)),oe=!!(f&&dateMatchModifiers(V,f,l))||se||Oe||!_&&!b&&ae||_&&b===!1&&ae,$e=R(V,S);ae&&Q.outside.push(F),Ne&&Q.disabled.push(F),oe&&Q.hidden.push(F),$e&&Q.today.push(F),g&&Object.keys(g).forEach(Ae=>{const je=g==null?void 0:g[Ae];je&&dateMatchModifiers(V,je,l)&&(te[Ae]?te[Ae].push(F):te[Ae]=[F])})}return F=>{const V={[DayFlag.focused]:!1,[DayFlag.disabled]:!1,[DayFlag.hidden]:!1,[DayFlag.outside]:!1,[DayFlag.today]:!1},ne={};for(const ae in Q){const se=Q[ae];V[ae]=se.some(Oe=>Oe===F)}for(const ae in te)ne[ae]=te[ae].some(se=>se===F);return{...V,...ne}}}function getClassNamesForModifiers(e,t,n={}){return Object.entries(e).filter(([,l])=>l===!0).reduce((l,[d])=>(n[d]?l.push(n[d]):t[DayFlag[d]]?l.push(t[DayFlag[d]]):t[SelectionState[d]]&&l.push(t[SelectionState[d]]),l),[t[UI.Day]])}function getComponents(e){return{...components,...e}}function getDataAttributes(e){const t={"data-mode":e.mode??void 0,"data-required":"required"in e?e.required:void 0,"data-multiple-months":e.numberOfMonths&&e.numberOfMonths>1||void 0,"data-week-numbers":e.showWeekNumber||void 0,"data-broadcast-calendar":e.broadcastCalendar||void 0,"data-nav-layout":e.navLayout||void 0};return Object.entries(e).forEach(([n,o])=>{n.startsWith("data-")&&(t[n]=o)}),t}function getDefaultClassNames(){const e={};for(const t in UI)e[UI[t]]=`rdp-${UI[t]}`;for(const t in DayFlag)e[DayFlag[t]]=`rdp-${DayFlag[t]}`;for(const t in SelectionState)e[SelectionState[t]]=`rdp-${SelectionState[t]}`;for(const t in Animation)e[Animation[t]]=`rdp-${Animation[t]}`;return e}function formatCaption(e,t,n){return(n??new DateLib(t)).formatMonthYear(e)}const formatMonthCaption=formatCaption;function formatDay(e,t,n){return(n??new DateLib(t)).format(e,"d")}function formatMonthDropdown(e,t=defaultDateLib){return t.format(e,"LLLL")}function formatWeekdayName(e,t,n){return(n??new DateLib(t)).format(e,"cccccc")}function formatWeekNumber(e,t=defaultDateLib){return e<10?t.formatNumber(`0${e.toLocaleString()}`):t.formatNumber(`${e.toLocaleString()}`)}function formatWeekNumberHeader(){return""}function formatYearDropdown(e,t=defaultDateLib){return t.format(e,"yyyy")}const formatYearCaption=formatYearDropdown,defaultFormatters=Object.freeze(Object.defineProperty({__proto__:null,formatCaption,formatDay,formatMonthCaption,formatMonthDropdown,formatWeekNumber,formatWeekNumberHeader,formatWeekdayName,formatYearCaption,formatYearDropdown},Symbol.toStringTag,{value:"Module"}));function getFormatters(e){return e!=null&&e.formatMonthCaption&&!e.formatCaption&&(e.formatCaption=e.formatMonthCaption),e!=null&&e.formatYearCaption&&!e.formatYearDropdown&&(e.formatYearDropdown=e.formatYearCaption),{...defaultFormatters,...e}}function getMonthOptions(e,t,n,o,l){const{startOfMonth:d,startOfYear:f,endOfYear:g,eachMonthOfInterval:b,getMonth:_}=l;return b({start:f(e),end:g(e)}).map(C=>{const E=o.formatMonthDropdown(C,l),A=_(C),M=t&&C<d(t)||n&&C>d(n)||!1;return{value:A,label:E,disabled:M}})}function getStyleForModifiers(e,t={},n={}){let o={...t==null?void 0:t[UI.Day]};return Object.entries(e).filter(([,l])=>l===!0).forEach(([l])=>{o={...o,...n==null?void 0:n[l]}}),o}function getWeekdays(e,t,n,o){const l=o??e.today(),d=n?e.startOfBroadcastWeek(l,e):t?e.startOfISOWeek(l):e.startOfWeek(l),f=[];for(let g=0;g<7;g++){const b=e.addDays(d,g);f.push(b)}return f}function getYearOptions(e,t,n,o,l=!1){if(!e||!t)return;const{startOfYear:d,endOfYear:f,eachYearOfInterval:g,getYear:b}=o,_=d(e),S=f(t),R=g({start:_,end:S});return l&&R.reverse(),R.map(C=>{const E=n.formatYearDropdown(C,o);return{value:b(C),label:E,disabled:!1}})}function labelDayButton(e,t,n,o){let l=(o??new DateLib(n)).format(e,"PPPP");return t.today&&(l=`Today, ${l}`),t.selected&&(l=`${l}, selected`),l}const labelDay=labelDayButton;function labelGrid(e,t,n){return(n??new DateLib(t)).formatMonthYear(e)}const labelCaption=labelGrid;function labelGridcell(e,t,n,o){let l=(o??new DateLib(n)).format(e,"PPPP");return t!=null&&t.today&&(l=`Today, ${l}`),l}function labelMonthDropdown(e){return"Choose the Month"}function labelNav(){return""}function labelNext(e){return"Go to the Next Month"}function labelPrevious(e){return"Go to the Previous Month"}function labelWeekday(e,t,n){return(n??new DateLib(t)).format(e,"cccc")}function labelWeekNumber(e,t){return`Week ${e}`}function labelWeekNumberHeader(e){return"Week Number"}function labelYearDropdown(e){return"Choose the Year"}const defaultLabels=Object.freeze(Object.defineProperty({__proto__:null,labelCaption,labelDay,labelDayButton,labelGrid,labelGridcell,labelMonthDropdown,labelNav,labelNext,labelPrevious,labelWeekNumber,labelWeekNumberHeader,labelWeekday,labelYearDropdown},Symbol.toStringTag,{value:"Module"})),asHtmlElement=e=>e instanceof HTMLElement?e:null,queryMonthEls=e=>[...e.querySelectorAll("[data-animated-month]")??[]],queryMonthEl=e=>asHtmlElement(e.querySelector("[data-animated-month]")),queryCaptionEl=e=>asHtmlElement(e.querySelector("[data-animated-caption]")),queryWeeksEl=e=>asHtmlElement(e.querySelector("[data-animated-weeks]")),queryNavEl=e=>asHtmlElement(e.querySelector("[data-animated-nav]")),queryWeekdaysEl=e=>asHtmlElement(e.querySelector("[data-animated-weekdays]"));function useAnimation(e,t,{classNames:n,months:o,focused:l,dateLib:d}){const f=React.useRef(null),g=React.useRef(o),b=React.useRef(!1);React.useLayoutEffect(()=>{const _=g.current;if(g.current=o,!t||!e.current||!(e.current instanceof HTMLElement)||o.length===0||_.length===0||o.length!==_.length)return;const S=d.isSameMonth(o[0].date,_[0].date),R=d.isAfter(o[0].date,_[0].date),C=R?n[Animation.caption_after_enter]:n[Animation.caption_before_enter],E=R?n[Animation.weeks_after_enter]:n[Animation.weeks_before_enter],A=f.current,M=e.current.cloneNode(!0);if(M instanceof HTMLElement?(queryMonthEls(M).forEach(Q=>{if(!(Q instanceof HTMLElement))return;const te=queryMonthEl(Q);te&&Q.contains(te)&&Q.removeChild(te);const F=queryCaptionEl(Q);F&&F.classList.remove(C);const V=queryWeeksEl(Q);V&&V.classList.remove(E)}),f.current=M):f.current=null,b.current||S||l)return;const I=A instanceof HTMLElement?queryMonthEls(A):[],j=queryMonthEls(e.current);if(j!=null&&j.every(q=>q instanceof HTMLElement)&&I&&I.every(q=>q instanceof HTMLElement)){b.current=!0,e.current.style.isolation="isolate";const q=queryNavEl(e.current);q&&(q.style.zIndex="1"),j.forEach((Q,te)=>{const F=I[te];if(!F)return;Q.style.position="relative",Q.style.overflow="hidden";const V=queryCaptionEl(Q);V&&V.classList.add(C);const ne=queryWeeksEl(Q);ne&&ne.classList.add(E);const ae=()=>{b.current=!1,e.current&&(e.current.style.isolation=""),q&&(q.style.zIndex=""),V&&V.classList.remove(C),ne&&ne.classList.remove(E),Q.style.position="",Q.style.overflow="",Q.contains(F)&&Q.removeChild(F)};F.style.pointerEvents="none",F.style.position="absolute",F.style.overflow="hidden",F.setAttribute("aria-hidden","true");const se=queryWeekdaysEl(F);se&&(se.style.opacity="0");const Oe=queryCaptionEl(F);Oe&&(Oe.classList.add(R?n[Animation.caption_before_exit]:n[Animation.caption_after_exit]),Oe.addEventListener("animationend",ae));const Ne=queryWeeksEl(F);Ne&&Ne.classList.add(R?n[Animation.weeks_before_exit]:n[Animation.weeks_after_exit]),Q.insertBefore(F,Q.firstChild)})}})}function getDates(e,t,n,o){const l=e[0],d=e[e.length-1],{ISOWeek:f,fixedWeeks:g,broadcastCalendar:b}=n??{},{addDays:_,differenceInCalendarDays:S,differenceInCalendarMonths:R,endOfBroadcastWeek:C,endOfISOWeek:E,endOfMonth:A,endOfWeek:M,isAfter:I,startOfBroadcastWeek:j,startOfISOWeek:q,startOfWeek:Q}=o,te=b?j(l,o):f?q(l):Q(l),F=b?C(d):f?E(A(d)):M(A(d)),V=S(F,te),ne=R(d,l)+1,ae=[];for(let Ne=0;Ne<=V;Ne++){const oe=_(te,Ne);if(t&&I(oe,t))break;ae.push(oe)}const Oe=(b?35:42)*ne;if(g&&ae.length<Oe){const Ne=Oe-ae.length;for(let oe=0;oe<Ne;oe++){const $e=_(ae[ae.length-1],1);ae.push($e)}}return ae}function getDays(e){const t=[];return e.reduce((n,o)=>{const l=o.weeks.reduce((d,f)=>d.concat(f.days.slice()),t.slice());return n.concat(l.slice())},t.slice())}function getDisplayMonths(e,t,n,o){const{numberOfMonths:l=1}=n,d=[];for(let f=0;f<l;f++){const g=o.addMonths(e,f);if(t&&g>t)break;d.push(g)}return d}function getInitialMonth(e,t,n,o){const{month:l,defaultMonth:d,today:f=o.today(),numberOfMonths:g=1}=e;let b=l||d||f;const{differenceInCalendarMonths:_,addMonths:S,startOfMonth:R}=o;if(n&&_(n,b)<g-1){const C=-1*(g-1);b=S(n,C)}return t&&_(b,t)<0&&(b=t),R(b)}function getMonths(e,t,n,o){const{addDays:l,endOfBroadcastWeek:d,endOfISOWeek:f,endOfMonth:g,endOfWeek:b,getISOWeek:_,getWeek:S,startOfBroadcastWeek:R,startOfISOWeek:C,startOfWeek:E}=o,A=e.reduce((M,I)=>{const j=n.broadcastCalendar?R(I,o):n.ISOWeek?C(I):E(I),q=n.broadcastCalendar?d(I):n.ISOWeek?f(g(I)):b(g(I)),Q=t.filter(ne=>ne>=j&&ne<=q),te=n.broadcastCalendar?35:42;if(n.fixedWeeks&&Q.length<te){const ne=t.filter(ae=>{const se=te-Q.length;return ae>q&&ae<=l(q,se)});Q.push(...ne)}const F=Q.reduce((ne,ae)=>{const se=n.ISOWeek?_(ae):S(ae),Oe=ne.find(oe=>oe.weekNumber===se),Ne=new CalendarDay(ae,I,o);return Oe?Oe.days.push(Ne):ne.push(new CalendarWeek(se,[Ne])),ne},[]),V=new CalendarMonth(I,F);return M.push(V),M},[]);return n.reverseMonths?A.reverse():A}function getNavMonths(e,t){let{startMonth:n,endMonth:o}=e;const{startOfYear:l,startOfDay:d,startOfMonth:f,endOfMonth:g,addYears:b,endOfYear:_,newDate:S,today:R}=t,{fromYear:C,toYear:E,fromMonth:A,toMonth:M}=e;!n&&A&&(n=A),!n&&C&&(n=t.newDate(C,0,1)),!o&&M&&(o=M),!o&&E&&(o=S(E,11,31));const I=e.captionLayout==="dropdown"||e.captionLayout==="dropdown-years";return n?n=f(n):C?n=S(C,0,1):!n&&I&&(n=l(b(e.today??R(),-100))),o?o=g(o):E?o=S(E,11,31):!o&&I&&(o=_(e.today??R())),[n&&d(n),o&&d(o)]}function getNextMonth(e,t,n,o){if(n.disableNavigation)return;const{pagedNavigation:l,numberOfMonths:d=1}=n,{startOfMonth:f,addMonths:g,differenceInCalendarMonths:b}=o,_=l?d:1,S=f(e);if(!t)return g(S,_);if(!(b(t,e)<d))return g(S,_)}function getPreviousMonth(e,t,n,o){if(n.disableNavigation)return;const{pagedNavigation:l,numberOfMonths:d}=n,{startOfMonth:f,addMonths:g,differenceInCalendarMonths:b}=o,_=l?d??1:1,S=f(e);if(!t)return g(S,-_);if(!(b(S,t)<=0))return g(S,-_)}function getWeeks(e){const t=[];return e.reduce((n,o)=>n.concat(o.weeks.slice()),t.slice())}function useControlledValue(e,t){const[n,o]=React.useState(e);return[t===void 0?n:t,o]}function useCalendar(e,t){var te;const[n,o]=getNavMonths(e,t),{startOfMonth:l,endOfMonth:d}=t,f=getInitialMonth(e,n,o,t),[g,b]=useControlledValue(f,e.month?f:void 0);React.useEffect(()=>{const F=getInitialMonth(e,n,o,t);b(F)},[e.timeZone]);const{months:_,weeks:S,days:R,previousMonth:C,nextMonth:E}=React.useMemo(()=>{const F=getDisplayMonths(g,o,{numberOfMonths:e.numberOfMonths},t),V=getDates(F,e.endMonth?d(e.endMonth):void 0,{ISOWeek:e.ISOWeek,fixedWeeks:e.fixedWeeks,broadcastCalendar:e.broadcastCalendar},t),ne=getMonths(F,V,{broadcastCalendar:e.broadcastCalendar,fixedWeeks:e.fixedWeeks,ISOWeek:e.ISOWeek,reverseMonths:e.reverseMonths},t),ae=getWeeks(ne),se=getDays(ne),Oe=getPreviousMonth(g,n,e,t),Ne=getNextMonth(g,o,e,t);return{months:ne,weeks:ae,days:se,previousMonth:Oe,nextMonth:Ne}},[t,g.getTime(),o==null?void 0:o.getTime(),n==null?void 0:n.getTime(),e.disableNavigation,e.broadcastCalendar,(te=e.endMonth)==null?void 0:te.getTime(),e.fixedWeeks,e.ISOWeek,e.numberOfMonths,e.pagedNavigation,e.reverseMonths]),{disableNavigation:A,onMonthChange:M}=e,I=F=>S.some(V=>V.days.some(ne=>ne.isEqualTo(F))),j=F=>{if(A)return;let V=l(F);n&&V<l(n)&&(V=l(n)),o&&V>l(o)&&(V=l(o)),b(V),M==null||M(V)};return{months:_,weeks:S,days:R,navStart:n,navEnd:o,previousMonth:C,nextMonth:E,goToMonth:j,goToDay:F=>{I(F)||j(F.date)}}}var FocusTargetPriority;(function(e){e[e.Today=0]="Today",e[e.Selected=1]="Selected",e[e.LastFocused=2]="LastFocused",e[e.FocusedModifier=3]="FocusedModifier"})(FocusTargetPriority||(FocusTargetPriority={}));function isFocusableDay(e){return!e[DayFlag.disabled]&&!e[DayFlag.hidden]&&!e[DayFlag.outside]}function calculateFocusTarget(e,t,n,o){let l,d=-1;for(const f of e){const g=t(f);isFocusableDay(g)&&(g[DayFlag.focused]&&d<FocusTargetPriority.FocusedModifier?(l=f,d=FocusTargetPriority.FocusedModifier):o!=null&&o.isEqualTo(f)&&d<FocusTargetPriority.LastFocused?(l=f,d=FocusTargetPriority.LastFocused):n(f.date)&&d<FocusTargetPriority.Selected?(l=f,d=FocusTargetPriority.Selected):g[DayFlag.today]&&d<FocusTargetPriority.Today&&(l=f,d=FocusTargetPriority.Today))}return l||(l=e.find(f=>isFocusableDay(t(f)))),l}function getFocusableDate(e,t,n,o,l,d,f){const{ISOWeek:g,broadcastCalendar:b}=d,{addDays:_,addMonths:S,addWeeks:R,addYears:C,endOfBroadcastWeek:E,endOfISOWeek:A,endOfWeek:M,max:I,min:j,startOfBroadcastWeek:q,startOfISOWeek:Q,startOfWeek:te}=f;let V={day:_,week:R,month:S,year:C,startOfWeek:ne=>b?q(ne,f):g?Q(ne):te(ne),endOfWeek:ne=>b?E(ne):g?A(ne):M(ne)}[e](n,t==="after"?1:-1);return t==="before"&&o?V=I([o,V]):t==="after"&&l&&(V=j([l,V])),V}function getNextFocus(e,t,n,o,l,d,f,g=0){if(g>365)return;const b=getFocusableDate(e,t,n.date,o,l,d,f),_=!!(d.disabled&&dateMatchModifiers(b,d.disabled,f)),S=!!(d.hidden&&dateMatchModifiers(b,d.hidden,f)),R=b,C=new CalendarDay(b,R,f);return!_&&!S?C:getNextFocus(e,t,C,o,l,d,f,g+1)}function useFocus(e,t,n,o,l){const{autoFocus:d}=e,[f,g]=React.useState(),b=calculateFocusTarget(t.days,n,o||(()=>!1),f),[_,S]=React.useState(d?b:void 0);return{isFocusTarget:M=>!!(b!=null&&b.isEqualTo(M)),setFocused:S,focused:_,blur:()=>{g(_),S(void 0)},moveFocus:(M,I)=>{if(!_)return;const j=getNextFocus(M,I,_,t.navStart,t.navEnd,e,l);j&&(e.disableNavigation&&!t.days.some(Q=>Q.isEqualTo(j))||(t.goToDay(j),S(j)))}}}function useMulti(e,t){const{selected:n,required:o,onSelect:l}=e,[d,f]=useControlledValue(n,l?n:void 0),g=l?n:d,{isSameDay:b}=t,_=E=>(g==null?void 0:g.some(A=>b(A,E)))??!1,{min:S,max:R}=e;return{selected:g,select:(E,A,M)=>{let I=[...g??[]];if(_(E)){if((g==null?void 0:g.length)===S||o&&(g==null?void 0:g.length)===1)return;I=g==null?void 0:g.filter(j=>!b(j,E))}else(g==null?void 0:g.length)===R?I=[E]:I=[...I,E];return l||f(I),l==null||l(I,E,A,M),I},isSelected:_}}function addToRange(e,t,n=0,o=0,l=!1,d=defaultDateLib){const{from:f,to:g}=t||{},{isSameDay:b,isAfter:_,isBefore:S}=d;let R;if(!f&&!g)R={from:e,to:n>0?void 0:e};else if(f&&!g)b(f,e)?n===0?R={from:f,to:e}:l?R={from:f,to:void 0}:R=void 0:S(e,f)?R={from:e,to:f}:R={from:f,to:e};else if(f&&g)if(b(f,e)&&b(g,e))l?R={from:f,to:g}:R=void 0;else if(b(f,e))R={from:f,to:n>0?void 0:e};else if(b(g,e))R={from:e,to:n>0?void 0:e};else if(S(e,f))R={from:e,to:g};else if(_(e,f))R={from:f,to:e};else if(_(e,g))R={from:f,to:e};else throw new Error("Invalid range");if(R!=null&&R.from&&(R!=null&&R.to)){const C=d.differenceInCalendarDays(R.to,R.from);o>0&&C>o?R={from:e,to:void 0}:n>1&&C<n&&(R={from:e,to:void 0})}return R}function rangeContainsDayOfWeek(e,t,n=defaultDateLib){const o=Array.isArray(t)?t:[t];let l=e.from;const d=n.differenceInCalendarDays(e.to,e.from),f=Math.min(d,6);for(let g=0;g<=f;g++){if(o.includes(l.getDay()))return!0;l=n.addDays(l,1)}return!1}function rangeOverlaps(e,t,n=defaultDateLib){return rangeIncludesDate(e,t.from,!1,n)||rangeIncludesDate(e,t.to,!1,n)||rangeIncludesDate(t,e.from,!1,n)||rangeIncludesDate(t,e.to,!1,n)}function rangeContainsModifiers(e,t,n=defaultDateLib){const o=Array.isArray(t)?t:[t];if(o.filter(g=>typeof g!="function").some(g=>typeof g=="boolean"?g:n.isDate(g)?rangeIncludesDate(e,g,!1,n):isDatesArray(g,n)?g.some(b=>rangeIncludesDate(e,b,!1,n)):isDateRange(g)?g.from&&g.to?rangeOverlaps(e,{from:g.from,to:g.to},n):!1:isDayOfWeekType(g)?rangeContainsDayOfWeek(e,g.dayOfWeek,n):isDateInterval(g)?n.isAfter(g.before,g.after)?rangeOverlaps(e,{from:n.addDays(g.after,1),to:n.addDays(g.before,-1)},n):dateMatchModifiers(e.from,g,n)||dateMatchModifiers(e.to,g,n):isDateAfterType(g)||isDateBeforeType(g)?dateMatchModifiers(e.from,g,n)||dateMatchModifiers(e.to,g,n):!1))return!0;const f=o.filter(g=>typeof g=="function");if(f.length){let g=e.from;const b=n.differenceInCalendarDays(e.to,e.from);for(let _=0;_<=b;_++){if(f.some(S=>S(g)))return!0;g=n.addDays(g,1)}}return!1}function useRange(e,t){const{disabled:n,excludeDisabled:o,selected:l,required:d,onSelect:f}=e,[g,b]=useControlledValue(l,f?l:void 0),_=f?l:g;return{selected:_,select:(C,E,A)=>{const{min:M,max:I}=e,j=C?addToRange(C,_,M,I,d,t):void 0;return o&&n&&(j!=null&&j.from)&&j.to&&rangeContainsModifiers({from:j.from,to:j.to},n,t)&&(j.from=C,j.to=void 0),f||b(j),f==null||f(j,C,E,A),j},isSelected:C=>_&&rangeIncludesDate(_,C,!1,t)}}function useSingle(e,t){const{selected:n,required:o,onSelect:l}=e,[d,f]=useControlledValue(n,l?n:void 0),g=l?n:d,{isSameDay:b}=t;return{selected:g,select:(R,C,E)=>{let A=R;return!o&&g&&g&&b(R,g)&&(A=void 0),l||f(A),l==null||l(A,R,C,E),A},isSelected:R=>g?b(g,R):!1}}function useSelection(e,t){const n=useSingle(e,t),o=useMulti(e,t),l=useRange(e,t);switch(e.mode){case"single":return n;case"multiple":return o;case"range":return l;default:return}}function toTimeZone(e,t){return e instanceof TZDate&&e.timeZone===t?e:new TZDate(e,t)}function convertMatcher(e,t){return typeof e=="boolean"||typeof e=="function"?e:e instanceof Date?toTimeZone(e,t):Array.isArray(e)?e.map(n=>n instanceof Date?toTimeZone(n,t):n):isDateRange(e)?{...e,from:e.from?toTimeZone(e.from,t):e.from,to:e.to?toTimeZone(e.to,t):e.to}:isDateInterval(e)?{before:toTimeZone(e.before,t),after:toTimeZone(e.after,t)}:isDateAfterType(e)?{after:toTimeZone(e.after,t)}:isDateBeforeType(e)?{before:toTimeZone(e.before,t)}:e}function convertMatchersToTimeZone(e,t){return e&&(Array.isArray(e)?e.map(n=>convertMatcher(n,t)):convertMatcher(e,t))}function DayPicker(e){var Vn;let t=e;const n=t.timeZone;if(n&&(t={...e,timeZone:n},t.today&&(t.today=toTimeZone(t.today,n)),t.month&&(t.month=toTimeZone(t.month,n)),t.defaultMonth&&(t.defaultMonth=toTimeZone(t.defaultMonth,n)),t.startMonth&&(t.startMonth=toTimeZone(t.startMonth,n)),t.endMonth&&(t.endMonth=toTimeZone(t.endMonth,n)),t.mode==="single"&&t.selected?t.selected=toTimeZone(t.selected,n):t.mode==="multiple"&&t.selected?t.selected=(Vn=t.selected)==null?void 0:Vn.map(Jt=>toTimeZone(Jt,n)):t.mode==="range"&&t.selected&&(t.selected={from:t.selected.from?toTimeZone(t.selected.from,n):t.selected.from,to:t.selected.to?toTimeZone(t.selected.to,n):t.selected.to}),t.disabled!==void 0&&(t.disabled=convertMatchersToTimeZone(t.disabled,n)),t.hidden!==void 0&&(t.hidden=convertMatchersToTimeZone(t.hidden,n)),t.modifiers)){const Jt={};Object.keys(t.modifiers).forEach(Zt=>{var Ut;Jt[Zt]=convertMatchersToTimeZone((Ut=t.modifiers)==null?void 0:Ut[Zt],n)}),t.modifiers=Jt}const{components:o,formatters:l,labels:d,dateLib:f,locale:g,classNames:b}=React.useMemo(()=>{const Jt={...enUS,...t.locale};return{dateLib:new DateLib({locale:Jt,weekStartsOn:t.broadcastCalendar?1:t.weekStartsOn,firstWeekContainsDate:t.firstWeekContainsDate,useAdditionalWeekYearTokens:t.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:t.useAdditionalDayOfYearTokens,timeZone:t.timeZone,numerals:t.numerals},t.dateLib),components:getComponents(t.components),formatters:getFormatters(t.formatters),labels:{...defaultLabels,...t.labels},locale:Jt,classNames:{...getDefaultClassNames(),...t.classNames}}},[t.locale,t.broadcastCalendar,t.weekStartsOn,t.firstWeekContainsDate,t.useAdditionalWeekYearTokens,t.useAdditionalDayOfYearTokens,t.timeZone,t.numerals,t.dateLib,t.components,t.formatters,t.labels,t.classNames]);t.today||(t={...t,today:f.today()});const{captionLayout:_,mode:S,navLayout:R,numberOfMonths:C=1,onDayBlur:E,onDayClick:A,onDayFocus:M,onDayKeyDown:I,onDayMouseEnter:j,onDayMouseLeave:q,onNextClick:Q,onPrevClick:te,showWeekNumber:F,styles:V}=t,{formatCaption:ne,formatDay:ae,formatMonthDropdown:se,formatWeekNumber:Oe,formatWeekNumberHeader:Ne,formatWeekdayName:oe,formatYearDropdown:$e}=l,Ae=useCalendar(t,f),{days:je,months:Be,navStart:qe,navEnd:Ve,previousMonth:Le,nextMonth:He,goToMonth:We}=Ae,ze=createGetModifiers(je,t,qe,Ve,f),{isSelected:Xe,select:nt,selected:Je}=useSelection(t,f)??{},{blur:st,focused:et,isFocusTarget:at,moveFocus:tt,setFocused:ot}=useFocus(t,Ae,ze,Xe??(()=>!1),f),{labelDayButton:lt,labelGridcell:Ge,labelGrid:$t,labelMonthDropdown:rt,labelNav:Rt,labelPrevious:dt,labelNext:It,labelWeekday:Mt,labelWeekNumber:Ct,labelWeekNumberHeader:Ke,labelYearDropdown:Ye}=d,Ze=React.useMemo(()=>getWeekdays(f,t.ISOWeek,t.broadcastCalendar,t.today),[f,t.ISOWeek,t.broadcastCalendar,t.today]),ct=S!==void 0||A!==void 0,mt=React.useCallback(()=>{Le&&(We(Le),te==null||te(Le))},[Le,We,te]),ft=React.useCallback(()=>{He&&(We(He),Q==null||Q(He))},[We,He,Q]),yt=React.useCallback((Jt,Zt)=>Ut=>{Ut.preventDefault(),Ut.stopPropagation(),ot(Jt),nt==null||nt(Jt.date,Zt,Ut),A==null||A(Jt.date,Zt,Ut)},[nt,A,ot]),Ht=React.useCallback((Jt,Zt)=>Ut=>{ot(Jt),M==null||M(Jt.date,Zt,Ut)},[M,ot]),Kt=React.useCallback((Jt,Zt)=>Ut=>{st(),E==null||E(Jt.date,Zt,Ut)},[st,E]),un=React.useCallback((Jt,Zt)=>Ut=>{const tn={ArrowLeft:[Ut.shiftKey?"month":"day",t.dir==="rtl"?"after":"before"],ArrowRight:[Ut.shiftKey?"month":"day",t.dir==="rtl"?"before":"after"],ArrowDown:[Ut.shiftKey?"year":"week","after"],ArrowUp:[Ut.shiftKey?"year":"week","before"],PageUp:[Ut.shiftKey?"year":"month","before"],PageDown:[Ut.shiftKey?"year":"month","after"],Home:["startOfWeek","before"],End:["endOfWeek","after"]};if(tn[Ut.key]){Ut.preventDefault(),Ut.stopPropagation();const[Yt,an]=tn[Ut.key];tt(Yt,an)}I==null||I(Jt.date,Zt,Ut)},[tt,I,t.dir]),hn=React.useCallback((Jt,Zt)=>Ut=>{j==null||j(Jt.date,Zt,Ut)},[j]),qt=React.useCallback((Jt,Zt)=>Ut=>{q==null||q(Jt.date,Zt,Ut)},[q]),An=React.useCallback(Jt=>Zt=>{const Ut=Number(Zt.target.value),tn=f.setMonth(f.startOfMonth(Jt),Ut);We(tn)},[f,We]),xn=React.useCallback(Jt=>Zt=>{const Ut=Number(Zt.target.value),tn=f.setYear(f.startOfMonth(Jt),Ut);We(tn)},[f,We]),{className:Rn,style:vn}=React.useMemo(()=>({className:[b[UI.Root],t.className].filter(Boolean).join(" "),style:{...V==null?void 0:V[UI.Root],...t.style}}),[b,t.className,t.style,V]),Pn=getDataAttributes(t),Mn=React.useRef(null);useAnimation(Mn,!!t.animate,{classNames:b,months:Be,focused:et,dateLib:f});const $n={dayPickerProps:t,selected:Je,select:nt,isSelected:Xe,months:Be,nextMonth:He,previousMonth:Le,goToMonth:We,getModifiers:ze,components:o,classNames:b,styles:V,labels:d,formatters:l};return React.createElement(dayPickerContext.Provider,{value:$n},React.createElement(o.Root,{rootRef:t.animate?Mn:void 0,className:Rn,style:vn,dir:t.dir,id:t.id,lang:t.lang,nonce:t.nonce,title:t.title,role:t.role,"aria-label":t["aria-label"],"aria-labelledby":t["aria-labelledby"],...Pn},React.createElement(o.Months,{className:b[UI.Months],style:V==null?void 0:V[UI.Months]},!t.hideNavigation&&!R&&React.createElement(o.Nav,{"data-animated-nav":t.animate?"true":void 0,className:b[UI.Nav],style:V==null?void 0:V[UI.Nav],"aria-label":Rt(),onPreviousClick:mt,onNextClick:ft,previousMonth:Le,nextMonth:He}),Be.map((Jt,Zt)=>React.createElement(o.Month,{"data-animated-month":t.animate?"true":void 0,className:b[UI.Month],style:V==null?void 0:V[UI.Month],key:Zt,displayIndex:Zt,calendarMonth:Jt},R==="around"&&!t.hideNavigation&&Zt===0&&React.createElement(o.PreviousMonthButton,{type:"button",className:b[UI.PreviousMonthButton],tabIndex:Le?void 0:-1,"aria-disabled":Le?void 0:!0,"aria-label":dt(Le),onClick:mt,"data-animated-button":t.animate?"true":void 0},React.createElement(o.Chevron,{disabled:Le?void 0:!0,className:b[UI.Chevron],orientation:t.dir==="rtl"?"right":"left"})),React.createElement(o.MonthCaption,{"data-animated-caption":t.animate?"true":void 0,className:b[UI.MonthCaption],style:V==null?void 0:V[UI.MonthCaption],calendarMonth:Jt,displayIndex:Zt},_!=null&&_.startsWith("dropdown")?React.createElement(o.DropdownNav,{className:b[UI.Dropdowns],style:V==null?void 0:V[UI.Dropdowns]},(()=>{const Ut=_==="dropdown"||_==="dropdown-months"?React.createElement(o.MonthsDropdown,{key:"month",className:b[UI.MonthsDropdown],"aria-label":rt(),classNames:b,components:o,disabled:!!t.disableNavigation,onChange:An(Jt.date),options:getMonthOptions(Jt.date,qe,Ve,l,f),style:V==null?void 0:V[UI.Dropdown],value:f.getMonth(Jt.date)}):React.createElement("span",{key:"month"},se(Jt.date,f)),tn=_==="dropdown"||_==="dropdown-years"?React.createElement(o.YearsDropdown,{key:"year",className:b[UI.YearsDropdown],"aria-label":Ye(f.options),classNames:b,components:o,disabled:!!t.disableNavigation,onChange:xn(Jt.date),options:getYearOptions(qe,Ve,l,f,!!t.reverseYears),style:V==null?void 0:V[UI.Dropdown],value:f.getYear(Jt.date)}):React.createElement("span",{key:"year"},$e(Jt.date,f));return f.getMonthYearOrder()==="year-first"?[tn,Ut]:[Ut,tn]})(),React.createElement("span",{role:"status","aria-live":"polite",style:{border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"}},ne(Jt.date,f.options,f))):React.createElement(o.CaptionLabel,{className:b[UI.CaptionLabel],role:"status","aria-live":"polite"},ne(Jt.date,f.options,f))),R==="around"&&!t.hideNavigation&&Zt===C-1&&React.createElement(o.NextMonthButton,{type:"button",className:b[UI.NextMonthButton],tabIndex:He?void 0:-1,"aria-disabled":He?void 0:!0,"aria-label":It(He),onClick:ft,"data-animated-button":t.animate?"true":void 0},React.createElement(o.Chevron,{disabled:He?void 0:!0,className:b[UI.Chevron],orientation:t.dir==="rtl"?"left":"right"})),Zt===C-1&&R==="after"&&!t.hideNavigation&&React.createElement(o.Nav,{"data-animated-nav":t.animate?"true":void 0,className:b[UI.Nav],style:V==null?void 0:V[UI.Nav],"aria-label":Rt(),onPreviousClick:mt,onNextClick:ft,previousMonth:Le,nextMonth:He}),React.createElement(o.MonthGrid,{role:"grid","aria-multiselectable":S==="multiple"||S==="range","aria-label":$t(Jt.date,f.options,f)||void 0,className:b[UI.MonthGrid],style:V==null?void 0:V[UI.MonthGrid]},!t.hideWeekdays&&React.createElement(o.Weekdays,{"data-animated-weekdays":t.animate?"true":void 0,className:b[UI.Weekdays],style:V==null?void 0:V[UI.Weekdays]},F&&React.createElement(o.WeekNumberHeader,{"aria-label":Ke(f.options),className:b[UI.WeekNumberHeader],style:V==null?void 0:V[UI.WeekNumberHeader],scope:"col"},Ne()),Ze.map(Ut=>React.createElement(o.Weekday,{"aria-label":Mt(Ut,f.options,f),className:b[UI.Weekday],key:String(Ut),style:V==null?void 0:V[UI.Weekday],scope:"col"},oe(Ut,f.options,f)))),React.createElement(o.Weeks,{"data-animated-weeks":t.animate?"true":void 0,className:b[UI.Weeks],style:V==null?void 0:V[UI.Weeks]},Jt.weeks.map(Ut=>React.createElement(o.Week,{className:b[UI.Week],key:Ut.weekNumber,style:V==null?void 0:V[UI.Week],week:Ut},F&&React.createElement(o.WeekNumber,{week:Ut,style:V==null?void 0:V[UI.WeekNumber],"aria-label":Ct(Ut.weekNumber,{locale:g}),className:b[UI.WeekNumber],scope:"row",role:"rowheader"},Oe(Ut.weekNumber,f)),Ut.days.map(tn=>{const{date:Yt}=tn,an=ze(tn);if(an[DayFlag.focused]=!an.hidden&&!!(et!=null&&et.isEqualTo(tn)),an[SelectionState.selected]=(Xe==null?void 0:Xe(Yt))||an.selected,isDateRange(Je)){const{from:Cn,to:Bn}=Je;an[SelectionState.range_start]=!!(Cn&&Bn&&f.isSameDay(Yt,Cn)),an[SelectionState.range_end]=!!(Cn&&Bn&&f.isSameDay(Yt,Bn)),an[SelectionState.range_middle]=rangeIncludesDate(Je,Yt,!0,f)}const mn=getStyleForModifiers(an,V,t.modifiersStyles),On=getClassNamesForModifiers(an,b,t.modifiersClassNames),Fn=!ct&&!an.hidden?Ge(Yt,an,f.options,f):void 0;return React.createElement(o.Day,{key:`${tn.isoDate}_${tn.displayMonthId}`,day:tn,modifiers:an,className:On.join(" "),style:mn,role:"gridcell","aria-selected":an.selected||void 0,"aria-label":Fn,"data-day":tn.isoDate,"data-month":tn.outside?tn.dateMonthId:void 0,"data-selected":an.selected||void 0,"data-disabled":an.disabled||void 0,"data-hidden":an.hidden||void 0,"data-outside":tn.outside||void 0,"data-focused":an.focused||void 0,"data-today":an.today||void 0},!an.hidden&&ct?React.createElement(o.DayButton,{className:b[UI.DayButton],style:V==null?void 0:V[UI.DayButton],type:"button",day:tn,modifiers:an,disabled:!an.focused&&an.disabled||void 0,"aria-disabled":an.focused&&an.disabled||void 0,tabIndex:at(tn)?0:-1,"aria-label":lt(Yt,an,f.options,f),onClick:yt(tn,an),onBlur:Kt(tn,an),onFocus:Ht(tn,an),onKeyDown:un(tn,an),onMouseEnter:hn(tn,an),onMouseLeave:qt(tn,an)},ae(Yt,f.options,f)):!an.hidden&&ae(tn.date,f.options,f))})))))))),t.footer&&React.createElement(o.Footer,{className:b[UI.Footer],style:V==null?void 0:V[UI.Footer],role:"status","aria-live":"polite"},t.footer)))}function Calendar({className:e,classNames:t,showOutsideDays:n=!0,captionLayout:o="label",buttonVariant:l="ghost",formatters:d,components:f,...g}){const b=getDefaultClassNames();return jsxRuntime.jsx(DayPicker,{showOutsideDays:n,className:cn("bg-background group/calendar p-3 [--cell-size:2rem] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,e),captionLayout:o,formatters:{formatMonthDropdown:_=>_.toLocaleString("default",{month:"short"}),...d},classNames:{root:cn("w-fit",b.root),months:cn("relative flex flex-col gap-4 md:flex-row",b.months),month:cn("flex w-full flex-col gap-4",b.month),nav:cn("absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",b.nav),button_previous:cn(buttonVariants({variant:l}),"h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50",b.button_previous),button_next:cn(buttonVariants({variant:l}),"h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50",b.button_next),month_caption:cn("flex h-[--cell-size] w-full items-center justify-center px-[--cell-size]",b.month_caption),dropdowns:cn("flex h-[--cell-size] w-full items-center justify-center gap-1.5 text-sm font-medium",b.dropdowns),dropdown_root:cn("has-focus:border-ring border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] relative rounded-md border",b.dropdown_root),dropdown:cn("bg-popover absolute inset-0 opacity-0",b.dropdown),caption_label:cn("select-none font-medium",o==="label"?"text-sm":"[&>svg]:text-muted-foreground flex h-8 items-center gap-1 rounded-md pl-2 pr-1 text-sm [&>svg]:size-3.5",b.caption_label),table:"w-full border-collapse",weekdays:cn("flex",b.weekdays),weekday:cn("text-muted-foreground flex-1 select-none rounded-md text-[0.8rem] font-normal",b.weekday),week:cn("mt-2 flex w-full",b.week),week_number_header:cn("w-[--cell-size] select-none",b.week_number_header),week_number:cn("text-muted-foreground select-none text-[0.8rem]",b.week_number),day:cn("group/day relative aspect-square h-full w-full select-none p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md",b.day),range_start:cn("bg-accent rounded-l-md",b.range_start),range_middle:cn("rounded-none",b.range_middle),range_end:cn("bg-accent rounded-r-md",b.range_end),today:cn("bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",b.today),outside:cn("text-muted-foreground aria-selected:text-muted-foreground",b.outside),disabled:cn("text-muted-foreground opacity-50",b.disabled),hidden:cn("invisible",b.hidden),...t},components:{Root:({className:_,rootRef:S,...R})=>jsxRuntime.jsx("div",{"data-slot":"calendar",ref:S,className:cn(_),...R}),Chevron:({className:_,orientation:S,...R})=>S==="left"?jsxRuntime.jsx(ChevronLeft,{className:cn("size-4",_),...R}):S==="right"?jsxRuntime.jsx(ChevronRight,{className:cn("size-4",_),...R}):jsxRuntime.jsx(ChevronDown,{className:cn("size-4",_),...R}),DayButton:CalendarDayButton,WeekNumber:({children:_,...S})=>jsxRuntime.jsx("td",{...S,children:jsxRuntime.jsx("div",{className:"flex size-[--cell-size] items-center justify-center text-center",children:_})}),...f},...g})}function CalendarDayButton({className:e,day:t,modifiers:n,...o}){const l=getDefaultClassNames(),d=React__namespace.useRef(null);return React__namespace.useEffect(()=>{var f;n.focused&&((f=d.current)==null||f.focus())},[n.focused]),jsxRuntime.jsx(Button$1,{ref:d,variant:"ghost",size:"icon","data-day":t.date.toLocaleDateString(),"data-selected-single":n.selected&&!n.range_start&&!n.range_end&&!n.range_middle,"data-range-start":n.range_start,"data-range-end":n.range_end,"data-range-middle":n.range_middle,className:cn("data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 flex aspect-square h-auto w-full min-w-[--cell-size] flex-col gap-1 font-normal leading-none data-[range-end=true]:rounded-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] [&>span]:text-xs [&>span]:opacity-70",l.day,e),...o})}function AssistantChat(e){return jsxRuntime.jsx(Card,{className:"max-w-6xl",children:jsxRuntime.jsx(AIChatLayout,{className:"h-[40em]",userId:e.userId,userName:e.userName,initialPrompt:e.initialPrompt})})}function formatDateToISO(e){if(!e||!isValidDate(e))return"";const t=e.getTimezoneOffset()*6e4;return new Date(e.getTime()-t).toISOString().split("T")[0]}function isValidDate(e){return e instanceof Date&&!isNaN(e.getTime())}function DatePicker({date:e,onDateChange:t,label:n,id:o,className:l}){const[d,f]=React__namespace.useState(!1),[g,b]=React__namespace.useState(e),[_,S]=React__namespace.useState(formatDateToISO(e));React__namespace.useEffect(()=>{S(formatDateToISO(e)),isValidDate(e)&&b(e)},[e]);const R=E=>{const M=E.target.value.replace(/\D/g,"").slice(0,8);let I=M;if(M.length>4&&(I=`${M.slice(0,4)}-${M.slice(4)}`),M.length>6&&(I=`${M.slice(0,4)}-${M.slice(4,6)}-${M.slice(6)}`),S(I),M.length===8){const j=new Date(I),q=new Date(j.getUTCFullYear(),j.getUTCMonth(),j.getUTCDate());isValidDate(q)?(t(q),b(q)):t(void 0)}else t(void 0)},C=E=>{E&&(t(E),S(formatDateToISO(E))),f(!1)};return jsxRuntime.jsxs("div",{className:cn("flex flex-col gap-2",l),children:[n&&jsxRuntime.jsx(Label$2,{htmlFor:o,children:n}),jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(Input,{id:o,value:_,placeholder:"YYYY-MM-DD",className:"bg-background pr-10",onChange:R,onKeyDown:E=>{E.key==="ArrowDown"&&(E.preventDefault(),f(!0))}}),jsxRuntime.jsxs(Popover,{open:d,onOpenChange:f,children:[jsxRuntime.jsx(PopoverTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"ghost",size:"icon",className:"absolute right-1 top-1/2 h-7 w-7 -translate-y-1/2","aria-label":"Select date",children:jsxRuntime.jsx(Calendar$1,{className:"h-4 w-4"})})}),jsxRuntime.jsx(PopoverContent,{className:"w-auto min-w-[280px] p-0",align:"end",sideOffset:8,children:jsxRuntime.jsx(Calendar,{mode:"single",selected:e,onSelect:C,month:g,onMonthChange:b,initialFocus:!0,className:"w-full"})})]})]})]})}function ExternalProductCard({product:e,viewProductLink:t}){return e?jsxRuntime.jsx(Card,{className:"@container border-dashed border-2 hover:shadow-md transition-shadow h-full",children:jsxRuntime.jsxs(CardContent,{className:"p-6 flex flex-col h-full",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start mb-4 @[36rem]:hidden",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-lg pr-4 text-center w-full",children:e.Title||e.RandmarTitle}),jsxRuntime.jsx("div",{className:"w-24 h-10 flex-shrink-0",children:jsxRuntime.jsx(PartnerLogo,{id:e.ManufacturerId,name:e.ManufacturerName,width:96,height:40})})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-x-6 gap-y-4 flex-grow @[36rem]:flex-row",children:[jsxRuntime.jsx("div",{className:"mx-auto flex-shrink-0 @[36rem]:mx-0 @[36rem]:w-48",children:jsxRuntime.jsx(ProductImage,{randmarSKU:e.RandmarSKU||"",alt:e.RandmarTitle||""})}),jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col text-center @[36rem]:text-left",children:[jsxRuntime.jsxs("div",{className:"hidden @[36rem]:flex justify-between items-start mb-4",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-lg pr-4",children:e.Title||e.RandmarTitle}),jsxRuntime.jsx("div",{className:"w-24 h-10 flex-shrink-0",children:jsxRuntime.jsx(PartnerLogo,{id:e.ManufacturerId,name:e.ManufacturerName,width:96,height:40})})]}),jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 justify-center @[36rem]:hidden",children:[jsxRuntime.jsxs(Badge,{variant:"outline",className:"border-orange-300 bg-orange-50 text-orange-800",children:[jsxRuntime.jsx(Telescope,{className:"mr-2 h-3 w-3"}),jsxRuntime.jsx("span",{children:"External Product"})]}),jsxRuntime.jsxs(Badge,{variant:"outline",className:"border-randmar-red bg-red-50 text-randmar-red",children:[jsxRuntime.jsx(Warehouse,{className:"mr-2 h-3 w-3"}),jsxRuntime.jsxs("span",{children:["Held by ",jsxRuntime.jsx("b",{children:"Randmar"})]})]})]}),jsxRuntime.jsxs("div",{className:"hidden @[36rem]:grid grid-cols-2 gap-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center rounded-md bg-orange-50 px-4 py-2 text-orange-800 border-1 border-orange-800 text-sm",children:[jsxRuntime.jsx(Telescope,{className:"mr-2 h-5 w-5 flex-shrink-0"}),jsxRuntime.jsx("span",{children:"External Product"})]}),jsxRuntime.jsxs("div",{className:"flex items-center rounded-md bg-red-50 px-4 py-2 text-randmar-red border-1 border-randmar-red text-sm",children:[jsxRuntime.jsx(Warehouse,{className:"mr-2 h-5 w-5 flex-shrink-0"}),jsxRuntime.jsxs("span",{children:["Held by ",jsxRuntime.jsx("b",{children:"Randmar"})]})]})]}),t&&jsxRuntime.jsx("div",{className:"mt-auto pt-4 flex justify-center @[36rem]:justify-end",children:jsxRuntime.jsx(reactRouterDom.Link,{to:t,children:jsxRuntime.jsxs(Button$1,{variant:"secondary",className:"w-full @[36rem]:w-auto",children:[jsxRuntime.jsx(Eye,{className:"mr-2 h-4 w-4"}),"View Product"]})})})]})]})]})}):jsxRuntime.jsx(Card,{className:"@container border-dashed border-2 h-full",children:jsxRuntime.jsx(CardContent,{className:"p-6 flex flex-col h-full",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-6 flex-grow @[36rem]:flex-row",children:[jsxRuntime.jsx("div",{className:"flex-shrink-0 @[36rem]:w-48",children:jsxRuntime.jsx(Skeleton,{className:"aspect-square w-full h-auto"})}),jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col gap-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-1/2"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 justify-center @[36rem]:hidden",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-36 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-36 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"hidden @[36rem]:grid grid-cols-2 gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md"})]})]}),jsxRuntime.jsx("div",{className:"mt-auto pt-4 flex justify-center @[36rem]:justify-end",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-full @[36rem]:w-40"})})]})]})})})}function getEndDateStatus(e){if(!e)return{text:"No End Date",variant:"neutral",daysRemaining:null};const t=new Date(e);if(isNaN(t.getTime()))return{text:"Invalid Date",variant:"neutral",daysRemaining:null};const n=new Date,o=new Date(t.getFullYear(),t.getMonth(),t.getDate()),l=new Date(n.getFullYear(),n.getMonth(),n.getDate()),d=o.getTime()-l.getTime(),f=Math.ceil(d/(1e3*60*60*24));return f<0?{text:`Ended ${Math.abs(f)}d ago`,variant:"destructive",daysRemaining:f}:f===0?{text:"Ends today",variant:"destructive",daysRemaining:f}:f<=7?{text:`Ends in ${f}d`,variant:"destructive",daysRemaining:f}:f<=30?{text:`Ends in ${f}d`,variant:"warning",daysRemaining:f}:{text:`Ends in ${f}d`,variant:"neutral",daysRemaining:f}}const formatDate=e=>{if(!e)return"N/A";try{const t=new Date(e);return isNaN(t.getTime())?"Invalid Date":t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return"Invalid Date"}};function OpportunitiesTable({applicationId:e,opportunities:t=null,loading:n=!1}){var ne;const{toast:o}=useToast(),[l,d]=React.useState({}),[f,g]=React.useState(!1),[b,_]=React.useState(""),[S,R]=React.useState(null),{data:C}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:e},{skip:!e}),E=React.useCallback((ae,se,Oe)=>{d(Ne=>({...Ne,[ae]:{...Ne[ae],[se]:Oe}}))},[]),[A]=usePutV4ResellerByRouteResellerIdOpportunityAndManufacturerIdDefaultMutation(),M=React.useCallback(async ae=>{if(!(C!=null&&C.IsReseller))return;if(!ae.BidNumber){o({title:"Error",description:"Bid Number is missing, cannot set default.",variant:"destructive"});return}const se=ae.BidNumber;E(se,"isSettingDefault",!0),A({routeResellerId:e,manufacturerId:ae.ManufacturerId??"",opportunityNumber:se}).unwrap().then(()=>{o({title:"Success",description:`Opportunity "${ae.OpportunityName||ae.Opportunity||se}" was successfully set as default.`,variant:"success"})}).catch(Oe=>{var Ne;console.error("Set as default error:",Oe),o({title:"Error",description:((Ne=Oe.data)==null?void 0:Ne.message)||Oe.message||"An error occurred while setting this opportunity as default.",variant:"destructive"})}).finally(()=>{E(se,"isSettingDefault",!1)})},[e,A,o,E,C==null?void 0:C.IsReseller]),[I]=usePostV4ResellerByRouteResellerIdOpportunityAndManufacturerIdBidNumberEmailMutation(),j=React.useCallback(ae=>{if(C!=null&&C.IsReseller){if(!ae.BidNumber){o({title:"Error",description:"Bid Number is missing, cannot prepare report.",variant:"destructive"});return}R(ae),_(""),g(!0)}},[o,C==null?void 0:C.IsReseller]),q=React.useCallback(async()=>{if(!(C!=null&&C.IsReseller))return;if(!S||!S.BidNumber){o({title:"Error",description:"No opportunity selected or Bid Number is missing.",variant:"destructive"});return}if(!b.trim()||!/\S+@\S+\.\S+/.test(b)){o({title:"Validation Error",description:"Please enter a valid email address.",variant:"destructive"});return}const ae=S.BidNumber;E(ae,"isSendingReport",!0),I({routeResellerId:e,manufacturerId:S.ManufacturerId??"",bidNumber:ae,emailAddress:b}).unwrap().then(()=>{o({title:"Success",description:`A report for "${S.OpportunityName||S.Opportunity||ae}" was successfully sent to ${b}.`,variant:"success"}),g(!1)}).catch(se=>{var Oe;console.error("Send report by email error:",se),o({title:"Error",description:((Oe=se.data)==null?void 0:Oe.message)||se.message||"An error occurred while sending the report by email.",variant:"destructive"})}).finally(()=>{E(ae,"isSendingReport",!1),f||(R(null),_(""))})},[S,b,e,I,o,E,g]),Q=React.useMemo(()=>[{accessorKey:"ManufacturerId",header:"Manuf.",cell:({row:ae})=>jsxRuntime.jsx("div",{className:"w-20 h-8",children:jsxRuntime.jsx(PartnerLogo,{id:ae.original.ManufacturerId,width:80,height:32})}),enableSorting:!0,enableFiltering:!0},{id:"opportunityDisplay",accessorFn:ae=>ae.OpportunityName||ae.Opportunity,header:"Opportunity",cell:({getValue:ae})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:ae()??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"BidNumber",header:"Bid Number",cell:({row:ae})=>ae.original.BidNumber??"N/A",enableSorting:!0,enableFiltering:!0},{id:"statusInfo",header:"Status",cell:({row:ae})=>{const se=ae.original,Oe=se.Active===!0,Ne=getEndDateStatus(se.EndDate);let oe="border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400";return Ne.variant==="destructive"?oe="border-red-500 bg-red-100 text-red-700 dark:border-red-600 dark:bg-red-900/50 dark:text-red-400":Ne.variant==="warning"&&(oe="border-yellow-500 bg-yellow-100 text-yellow-700 dark:border-yellow-600 dark:bg-yellow-900/50 dark:text-yellow-400"),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 min-w-[200px]",children:[jsxRuntime.jsx(Badge,{variant:"outline",className:Oe?"border-green-500 bg-green-100 text-green-700 dark:border-green-600 dark:bg-green-900/50 dark:text-green-400 font-medium":"border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400 font-medium",children:Oe?"Active":"Inactive"}),se.EndDate&&jsxRuntime.jsx(Badge,{variant:"outline",className:`${oe} font-medium`,children:Ne.text}),jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"ghost",size:"icon",className:"h-6 w-6 p-0 data-[state=delayed-open]:bg-accent data-[state=instant-open]:bg-accent",children:jsxRuntime.jsx(Info,{className:"h-4 w-4 text-muted-foreground"})})}),jsxRuntime.jsx(TooltipContent,{side:"top",align:"center",className:"bg-popover text-popover-foreground p-2 rounded shadow-lg",children:jsxRuntime.jsxs("div",{className:"text-sm space-y-1",children:[jsxRuntime.jsxs("p",{children:[jsxRuntime.jsx("strong",{children:"Start:"})," ",formatDate(se.StartDate)]}),jsxRuntime.jsxs("p",{children:[jsxRuntime.jsx("strong",{children:"End:"})," ",formatDate(se.EndDate)]}),jsxRuntime.jsxs("p",{children:[jsxRuntime.jsx("strong",{children:"Updated:"})," ",formatDate(se.LastUpdate)]})]})})]})})]})},enableFiltering:!1},{id:"actions",header:"Actions",cell:({row:ae})=>{var Be,qe;const se=ae.original;if(!se.BidNumber)return jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"Actions unavailable"});const Oe=se.BidNumber,Ne=(Be=l[Oe])==null?void 0:Be.isSettingDefault,oe=(S==null?void 0:S.BidNumber)===Oe&&((qe=l[Oe])==null?void 0:qe.isSendingReport),$e=Ne||oe,Ae=se.CanBeSetAsDefault===!0,je=C!=null&&C.IsManufacturer?`/${e}/Opportunity/${se.BidNumber}`:`/${e}/Opportunity/${se.ManufacturerId}/${se.BidNumber}`;return jsxRuntime.jsxs("div",{className:"flex space-x-2",children:[jsxRuntime.jsx(reactRouterDom.Link,{to:je,children:jsxRuntime.jsxs(Button$1,{variant:"outline",size:"sm",className:"flex items-center",children:[jsxRuntime.jsx(Star,{className:"mr-2 h-4 w-4"})," View"]})}),(C==null?void 0:C.IsReseller)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Button$1,{variant:"outline",size:"sm",onClick:()=>M(se),disabled:$e||!Ae,title:Ae?"Set as default":"This opportunity cannot be set as default",className:"flex items-center",children:[Ne?jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}):jsxRuntime.jsx(Star,{className:"mr-2 h-4 w-4"})," Set Default"]}),jsxRuntime.jsxs(Button$1,{variant:"outline",size:"sm",onClick:()=>j(se),disabled:$e,title:"Send report by email",className:"flex items-center",children:[oe?jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}):jsxRuntime.jsx(Send,{className:"mr-2 h-4 w-4"})," Send Report"]})]})]})}}],[l,M,j,S,C==null?void 0:C.IsReseller,e]),te=React.useMemo(()=>{const ae={};if(t){const se=Array.from(new Set(t.map(Ne=>Ne.ManufacturerId).filter(Ne=>Ne!=null)));ae.ManufacturerId=se;const Oe=Array.from(new Set(t.map(Ne=>Ne.OpportunityName||Ne.Opportunity).filter(Ne=>Ne!=null)));ae.opportunityDisplay=Oe}return ae},[t]),F=t||[],V=S!=null&&S.BidNumber?(ne=l[S.BidNumber])==null?void 0:ne.isSendingReport:!1;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-48 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(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Opportunities"})," "]}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:Q,data:F,uniqueValues:te})})]}),jsxRuntime.jsx(Dialog,{open:f,onOpenChange:ae=>{g(ae),ae||(R(null),_(""))},children:jsxRuntime.jsxs(DialogContent,{className:"@sm:max-w-[425px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Send Opportunity Report"}),jsxRuntime.jsxs(DialogDescription,{children:["Enter the email address to send the report for opportunity: ",jsxRuntime.jsx("br",{}),jsxRuntime.jsx("span",{className:"font-semibold",children:(S==null?void 0:S.OpportunityName)||(S==null?void 0:S.Opportunity)||"N/A"}),(S==null?void 0:S.BidNumber)&&jsxRuntime.jsxs("span",{className:"block text-sm text-muted-foreground",children:["Bid Number: ",S.BidNumber]})]})]}),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:b,onChange:ae=>_(ae.target.value),placeholder:"recipient@example.com",className:"col-span-3",disabled:V})]})}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>g(!1),disabled:V,children:"Cancel"}),jsxRuntime.jsxs(Button$1,{type:"submit",onClick:q,disabled:V,children:[V&&jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"})," Send Report"]})]})]})})]})}function useLoadScript(e){const[t,n]=React.useState(!0),[o,l]=React.useState(null),[d,f]=React.useState(!1),g=()=>{n(!1),f(!0)};return React.useEffect(()=>{if(!document){const R=new Error(`[ScriptLoadingError] document not defined when attempting to load ${e}`);l(R);return}const b=document.querySelector(`script[src="${e}"]`);if(b!=null&&b.dataset.loaded){g();return}const _=b||document.createElement("script");b||(_.src=e);const S=()=>{_.dataset.loaded="1",g()};_.addEventListener("load",S),_.addEventListener("error",R=>{console.error("Failed to load script:",e,R);const C=new Error(`[ScriptLoadingError] Failed to load script: ${e}`);l(C)}),b||document.head.append(_)},[]),{isLoading:t,error:o,isSuccess:d}}const isGoogleReady=e=>e&&e.charts,isGoogleChartsReady=(e,t)=>{const{controls:n,toolbarItems:o,getChartEditor:l}=e;return t&&t.charts&&t.visualization&&t.visualization.ChartWrapper&&t.visualization.Dashboard&&(!n||t.visualization.ChartWrapper)&&(!l||t.visualization.ChartEditor)&&(!o||t.visualization.drawToolbar)},getGoogleInstanceFromWindow=e=>window.google;function useLoadGoogleCharts(e){const{chartVersion:t="current",chartPackages:n=["corechart","controls"],chartLanguage:o="en",mapsApiKey:l}=e,[d,f]=React.useState(null),[g,b]=React.useState(null),[_,S]=React.useState(null),{isLoading:R,error:C,isSuccess:E}=useLoadScript(e.chartLoaderScriptUrl||"https://www.gstatic.com/charts/loader.js");return React.useEffect(()=>{if(!E)return;const A=getGoogleInstanceFromWindow();if(!isGoogleReady(A)){const M=new Error("[ScriptInitializationError] Script loaded but Google not attached to window.");b(M);return}if(isGoogleChartsReady(e,A)){f(A);return}A.charts.load(t,{packages:n,language:o,mapsApiKey:l}),A.charts.setOnLoadCallback(()=>{if(!isGoogleChartsReady(e,A)){const M=new Error("[GoogleChartsInitializationError] Google Charts not ready after load callback.");console.error(M),S(M);return}f(A)})},[E]),{error:C||g||_,isLoading:R,google:d}}const chartDefaultProps={legend_toggle:!1,options:{},legendToggle:!1,getChartWrapper:()=>{},spreadSheetQueryParameters:{headers:1,gid:1},rootProps:{},chartWrapperParams:{},chartLoaderScriptUrl:"https://www.gstatic.com/charts/loader.js"},GoogleChartControls=e=>{const{isReady:t,chartControls:n,filter:o}=e;return!t||!n||!(n!=null&&n.length)?null:React.createElement(React.Fragment,null,n.filter(l=>{let{controlProp:d,control:f}=l;return o?o({control:f,controlProp:d}):!0}).map(l=>{let{control:d}=l;return React.createElement("div",{key:d.getContainerId(),id:d.getContainerId()})}))};let uniqueID=0;const generateUniqueID=()=>(uniqueID+=1,`reactgooglegraph-${uniqueID}`),jn=class jn{};en(jn,"initializeControls",t=>{for(let n=0;n<t.length;n+=1){const{controlType:o,options:l,controlWrapperParams:d}=t[n].controlProp;d&&"state"in d&&t[n].control.setState(d.state),t[n].control.setOptions(l),t[n].control.setControlType(o)}}),en(jn,"listenToControlEvents",(t,n)=>{const{google:o}=n;return t.flatMap(l=>{const{control:d,controlProp:f}=l,{controlEvents:g=[]}=f;return g.map(b=>{const{callback:_,eventName:S}=b;return o.visualization.events.addListener(d,S,function(){for(var R=arguments.length,C=new Array(R),E=0;E<R;E++)C[E]=arguments[E];_({chartWrapper:null,controlWrapper:d,props:n,google:o,eventArgs:C})})})})}),en(jn,"createControlId",t=>{let n;return typeof t>"u"?n=`googlechart-control-${generateUniqueID()}`:n=t,n}),en(jn,"createChartControls",t=>{const{controls:n,google:o}=t;return n?n.map((l,d)=>{const{controlID:f,controlType:g,options:b,controlWrapperParams:_}=l,S=jn.createControlId(f);return{controlProp:l,control:new o.visualization.ControlWrapper({containerId:S,controlType:g,options:b,..._})}}):null}),en(jn,"addControls",t=>{const{chartWrapper:n,chartDashboard:o}=t,l=jn.createChartControls(t);return!l||!o||!n?null:(o.bind(l.map(d=>{let{control:f}=d;return f}),n),jn.initializeControls(l),l)});let GoogleChartControlsInternal=jn;const useCreateChartControls=e=>{const[t,n]=React__namespace.useState(null);return[React__namespace.useMemo(()=>!t||!e?null:e.map((l,d)=>{const f=t[d];return f?{controlProp:l,control:f}:void 0}).flatMap(l=>l?[l]:[]),[t,e]),n]},useListenToControlEvents=(e,t)=>{React__namespace.useEffect(()=>{const n=GoogleChartControlsInternal.listenToControlEvents(e??[],t);return()=>{n.forEach(o=>{t.google.visualization.events.removeListener(o)})}},[e,t])},useChartControls=e=>{const[t,n]=useCreateChartControls(e.controls);return useListenToControlEvents(t??[],e),{addControls:l=>{const d=GoogleChartControlsInternal.addControls(l);n((d==null?void 0:d.map(f=>f.control))??null)},renderControl:l=>{const{chartWrapper:d,chartDashboard:f}=e;return React__namespace.createElement(GoogleChartControls,{...e,isReady:!!(d&&f),chartControls:t,filter:l})}}},useChartId=e=>{const t=React__namespace.useRef(null);return{chartId:(()=>{const{graphID:l,graph_id:d}=e,f=l||d;let g;return f?g=f:g=t.current||generateUniqueID(),t.current=g,t.current})()}},DEFAULT_CHART_COLORS=["#3366CC","#DC3912","#FF9900","#109618","#990099","#3B3EAC","#0099C6","#DD4477","#66AA00","#B82E2E","#316395","#994499","#22AA99","#AAAA11","#6633CC","#E67300","#8B0707","#329262","#5574A6","#3B3EAC"],loadDataTableFromSpreadSheet=async function(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return new Promise((o,l)=>{const d=`${n.headers?`headers=${n.headers}`:"headers=0"}`,f=`${n.query?`&tq=${encodeURIComponent(n.query)}`:""}`,g=`${n.gid?`&gid=${n.gid}`:""}`,b=`${n.sheet?`&sheet=${n.sheet}`:""}`,_=`${n.access_token?`&access_token=${n.access_token}`:""}`,S=`${d}${g}${b}${f}${_}`,R=`${t}/gviz/tq?${S}`;new e.visualization.Query(R).send(E=>{E.isError()?l(`Error in query: ${E.getMessage()} ${E.getDetailedMessage()}`):o(E.getDataTable())})})},GRAY_COLOR="#CCCCCC",Tn=class Tn{};en(Tn,"grayOutHiddenColumnsLabel",(t,n)=>{const{googleChartWrapper:o,options:l}=t;if(!o){console.error("googleChartWrapper is not defined");return}const d=o.getDataTable();if(!d)return;const f=d.getNumberOfColumns();if(n.length>0===!1)return;const b=Array.from({length:f-1}).map((_,S)=>{const R=Tn.getColumnId(d,S+1);return n.includes(R)?GRAY_COLOR:l&&l.colors?l.colors[S]:DEFAULT_CHART_COLORS[S]});o.setOptions({...l,colors:b}),o.draw()}),en(Tn,"listenToLegendToggle",(t,n)=>{const[o,l]=n,{google:d,googleChartWrapper:f}=t;if(!f){console.error("googleChartWrapper is not defined");return}return d.visualization.events.addListener(f,"select",()=>{const b=f.getChart().getSelection(),_=f.getDataTable();if(b.length===0||b[0].row!==null||!_)return;const S=b[0].column,R=Tn.getColumnId(_,S);o!=null&&o.includes(R)?l(C=>[...C.filter(E=>E!==R)]):l(C=>[...C,R])})}),en(Tn,"draw",async t=>{const{data:n,diffdata:o,rows:l,columns:d,options:f,chartType:g,formatters:b,spreadSheetUrl:_,spreadSheetQueryParameters:S,googleChartDashboard:R,googleChartWrapper:C,google:E,hiddenColumns:A,legendToggle:M,legend_toggle:I}=t;if(!C){console.error("draw was called with googleChartWrapper = null");return}let j,q=null;if(o){const ne=E.visualization.arrayToDataTable(o.old),ae=E.visualization.arrayToDataTable(o.new);q=E.visualization[g].prototype.computeDiff(ne,ae)}n?n instanceof E.visualization.DataTable?j=n:Array.isArray(n)?j=E.visualization.arrayToDataTable(n):j=new E.visualization.DataTable(n):l&&d?j=E.visualization.arrayToDataTable([d,...l]):_?j=await loadDataTableFromSpreadSheet(E,_,S):j=E.visualization.arrayToDataTable([]);const Q=j.getNumberOfColumns(),te=Array(Q).fill(0).map((ne,ae)=>{const se=Tn.getColumnId(j,ae);return A.includes(se)?{label:j.getColumnLabel(ae),type:j.getColumnType(ae),calc:()=>null}:ae}),F=C.getChart();C.getChartType()==="Timeline"&&F&&F.clearChart(),C.setChartType(g),C.setOptions(f||{});const V=new E.visualization.DataView(j);V.setColumns(te),C.setDataTable(V),C.draw(),R&&R.draw(j),q&&(C.setDataTable(q),C.draw()),b&&(Tn.applyFormatters({dataTable:j,formatters:b,google:E}),C.setDataTable(j),C.draw()),(M===!0||I===!0)&&Tn.grayOutHiddenColumnsLabel(t,A)}),en(Tn,"getColumnId",(t,n)=>t.getColumnId(n)||t.getColumnLabel(n)),en(Tn,"applyFormatters",t=>{let{dataTable:n,formatters:o,google:l}=t;for(let d of o)switch(d.type){case"ArrowFormat":{new l.visualization.ArrowFormat(d.options).format(n,d.column);return}case"BarFormat":{new l.visualization.BarFormat(d.options).format(n,d.column);return}case"ColorFormat":{const f=new l.visualization.ColorFormat(d.options),{ranges:g}=d;if(g)for(let b of g)f.addRange(...b);f.format(n,d.column);return}case"DateFormat":{new l.visualization.DateFormat(d.options).format(n,d.column);return}case"NumberFormat":{new l.visualization.NumberFormat(d.options).format(n,d.column);return}case"PatternFormat":{new l.visualization.PatternFormat(d.options).format(n,d.column);return}default:{console.warn(`Unknown formatter type: ${d.type}`);return}}});let GoogleChartInternal=Tn;const useGoogleChartDataTable=e=>{const{google:t,googleChartWrapper:n,googleChartDashboard:o}=e,[l,d]=React__namespace.useState([]);React__namespace.useEffect(()=>{n&&GoogleChartInternal.draw({...e,hiddenColumns:l,googleChartWrapper:n,googleChartDashboard:o,google:t})},[l,e.data,e.rows,e.columns,e.options,e.chartLoaderScriptUrl,e.chartType,e.formatters,e.spreadSheetUrl,e.spreadSheetQueryParameters,e.legendToggle,e.legend_toggle]);const f=()=>{const{googleChartWrapper:_}=e;_&&_.draw()},g=_=>{const S=[],{legendToggle:R,legend_toggle:C}=e;if(GoogleChartInternal.draw({...e,hiddenColumns:l,googleChartWrapper:_,googleChartDashboard:o,google:t}),window.addEventListener("resize",f),C||R){const E=GoogleChartInternal.listenToLegendToggle(e,[l,d]);E&&S.push(E)}return S},b=(_,S)=>{window.removeEventListener("resize",f),S.forEach(R=>{t.visualization.events.removeListener(R)}),_.getChartType()==="Timeline"&&_.getChart()&&_.getChart().clearChart()};React__namespace.useEffect(()=>{if(!n)return;const _=g(n);return()=>{b(n,_)}},[n,g,b])},listenToEvents=e=>{const{chartEvents:t,google:n,googleChartWrapper:o}=e;if(t){if(!o){console.warn("listenToEvents was called before chart wrapper ready.");return}return t.map(l=>{let{eventName:d,callback:f}=l;return n.visualization.events.addListener(o,d,function(){for(var g=arguments.length,b=new Array(g),_=0;_<g;_++)b[_]=arguments[_];f({chartWrapper:o,props:e,google:n,eventArgs:b})})})}},useGoogleChartEvents=e=>{React.useEffect(()=>{if(!e.googleChartWrapper)return;const t=listenToEvents(e);return()=>{t==null||t.forEach(n=>{e.google.visualization.events.removeListener(n)})}},[e])},GoogleChart=e=>{const[t,n]=React__namespace.useState(null),[o,l]=React__namespace.useState(null),{addControls:d,renderControl:f}=useChartControls({...e,chartDashboard:o,chartWrapper:t});useGoogleChartEvents({...e,googleChartWrapper:t});const{chartId:g}=useChartId(e),b=React__namespace.useRef(null),_=React__namespace.useRef(null);React__namespace.useEffect(()=>{const{options:j,google:q,chartType:Q,chartWrapperParams:te,toolbarItems:F,getChartEditor:V,getChartWrapper:ne,onLoad:ae}=e,se={chartType:Q,options:j,containerId:g,...te},Oe=new q.visualization.ChartWrapper(se);Oe.setOptions(j||{}),ne==null||ne(Oe,q);const Ne=new q.visualization.Dashboard(b.current);F&&q.visualization.drawToolbar(_.current,F);let oe=null;V&&(oe=new q.visualization.ChartEditor,V({chartEditor:oe,chartWrapper:Oe,google:q})),d({...e,chartDashboard:Ne,chartWrapper:Oe}),n(Oe),l(Ne),ae==null||ae(q,{google:q,chartWrapper:Oe,chartEditor:oe,chartDashboard:Ne})},[]),useGoogleChartDataTable({...e,googleChartWrapper:t,googleChartDashboard:o});const S=()=>{const{width:j,height:q,options:Q,style:te,className:F,rootProps:V,google:ne}=e,ae={height:q||Q&&Q.height,width:j||Q&&Q.width,...te};return React__namespace.createElement("div",{id:g,style:ae,className:F,...V})},R=()=>e.toolbarItems?React__namespace.createElement("div",{ref:_}):null,{width:C,height:E,options:A,style:M}=e,I={height:E||A&&A.height,width:C||A&&A.width,...M};return e.render?React__namespace.createElement("div",{ref:b,style:I},React__namespace.createElement("div",{ref:_,id:"toolbar"}),e.render({renderChart:S,renderControl:f,renderToolbar:R})):React__namespace.createElement("div",{ref:b,style:I},f(j=>{let{controlProp:q}=j;return q.controlPosition!=="bottom"}),S(),f(j=>{let{controlProp:q}=j;return q.controlPosition==="bottom"}),R())},ChartContext=React__namespace.createContext(chartDefaultProps),ContextProvider=e=>{let{children:t,value:n}=e;return React__namespace.createElement(ChartContext.Provider,{value:n},t)},ChartView=e=>{const{google:t,isLoading:n,error:o}=useLoadGoogleCharts(e);return n?e.loader??null:o?e.errorElement??null:t?React.createElement(GoogleChart,{google:t,...e}):null},Chart=e=>{const t={...chartDefaultProps,...e};return React.createElement(ContextProvider,{value:t},React.createElement(ChartView,t))};var GoogleDataTableColumnRoleType;(function(e){e.annotation="annotation",e.annotationText="annotationText",e.certainty="certainty",e.emphasis="emphasis",e.interval="interval",e.scope="scope",e.style="style",e.tooltip="tooltip",e.domain="domain"})(GoogleDataTableColumnRoleType||(GoogleDataTableColumnRoleType={}));function parseHsl(e){const t=e.match(/(\d+\.?\d*)\s*(\d+\.?\d*)%\s*(\d+\.?\d*)%/);return t?{h:parseFloat(t[1]),s:parseFloat(t[2]),l:parseFloat(t[3])}:null}function hslToHex(e,t,n){n/=100;const o=t*Math.min(n,1-n)/100,l=d=>{const f=(d+e/30)%12,g=n-o*Math.max(Math.min(f-3,9-f,1),-1);return Math.round(255*g).toString(16).padStart(2,"0")};return`#${l(0)}${l(8)}${l(4)}`}const Treemap=React__namespace.forwardRef(({data:e,options:t,height:n="500px",className:o,loading:l,disableClick:d=!0,...f},g)=>{const b=React__namespace.useRef(null),[_,S]=React__namespace.useState(null);React__namespace.useEffect(()=>{if(!b.current)return;const E=b.current,A=()=>{const q=getComputedStyle(E).getPropertyValue("--primary").trim();if(q){const Q=parseHsl(q);if(Q){const{h:te,s:F,l:V}=Q;S({minColor:hslToHex(te,F,Math.min(100,V+50)),midColor:hslToHex(te,F,Math.min(100,V+35)),maxColor:hslToHex(te,F,Math.min(100,V+20))})}return!0}return!1};if(A())return;let M=0;const I=20,j=setInterval(()=>{(A()||M>=I)&&clearInterval(j),M++},100);return()=>{j&&clearInterval(j)}},[]);const R=React__namespace.useMemo(()=>{const E={headerHeight:0,fontSize:14,showScale:!1,isHtml:!0,backgroundColor:"hsl(var(--background))",generateTooltip:(A,M)=>{var q;const I=(q=e[A+1])==null?void 0:q[0];if(!I)return"";const j=formatMoney(M);return`<div class="p-2 bg-background text-foreground border rounded-md shadow-lg">
1455
+ `;function RichTextEditor({id:e,name:t,value:n,onChange:o,placeholder:l,className:d,...f}){const[g,b]=React.useState(!1),_=React.useRef(null),S=React.useRef(null),R=useEditor({extensions:[StarterKit,Underline],content:n,editorProps:{attributes:{class:"prose prose-sm sm:prose dark:prose-invert focus:outline-none",id:e??"",name:t??""}},onUpdate:({editor:j})=>{const q=j.getHTML();o({target:{id:e,name:t,value:q}})}});React.useEffect(()=>{R&&n!==R.getHTML()&&R.commands.setContent(n)},[n,R]);const C=React.useCallback(j=>{if(R)if(R.chain().focus(),j==="paragraph")R.chain().setParagraph().run();else{const q=Number.parseInt(j.slice(1));R.chain().setHeading({level:q}).run()}},[R]),E=React.useCallback(j=>{if(R)switch(R.chain().focus(),j){case"bold":R.chain().toggleBold().run();break;case"italic":R.chain().toggleItalic().run();break;case"underline":R.chain().toggleUnderline().run();break;case"strike":R.chain().toggleStrike().run();break;case"bulletList":R.chain().toggleBulletList().run();break;case"orderedList":R.chain().toggleOrderedList().run();break}},[R]),A=React.useCallback(()=>{b(j=>!j)},[]),M=React.useCallback(j=>{const q=j.target.value;R&&R.commands.setContent(q),o({target:{id:e,name:t,value:q}})},[o,R,e,t]),I=React.useCallback(()=>{!g&&R&&R.commands.focus()},[g,R]);return R?jsxRuntime.jsxs("div",{ref:S,className:cn("border border-input rounded-md overflow-hidden focus-within:outline-hidden focus-within:ring-1 focus-within:ring-ring",d),onClick:I,...f,children:[jsxRuntime.jsx("style",{children:editorStyles}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center p-2 border-b border-input gap-2 bg-background",children:[jsxRuntime.jsxs(Select$1,{onValueChange:C,disabled:g,children:[jsxRuntime.jsx(SelectTrigger,{className:"w-[160px]",children:jsxRuntime.jsx(SelectValue,{placeholder:"Format"})}),jsxRuntime.jsx(SelectContent,{children:formatOptions.map(j=>jsxRuntime.jsx(SelectItem,{value:j.value,children:j.label},j.value))})]}),["bold","italic","underline","strike","bulletList","orderedList"].map(j=>jsxRuntime.jsxs(Button$1,{type:"button",variant:"ghost",size:"sm",onClick:()=>E(j),className:R.isActive(j)?"bg-muted":"",disabled:g,children:[j==="bold"&&jsxRuntime.jsx(Bold$1,{className:"h-4 w-4"}),j==="italic"&&jsxRuntime.jsx(Italic$1,{className:"h-4 w-4"}),j==="underline"&&jsxRuntime.jsx(Underline$1,{className:"h-4 w-4"}),j==="strike"&&jsxRuntime.jsx(Strikethrough,{className:"h-4 w-4"}),j==="bulletList"&&jsxRuntime.jsx(List$1,{className:"h-4 w-4"}),j==="orderedList"&&jsxRuntime.jsx(ListOrdered,{className:"h-4 w-4"})]},j)),jsxRuntime.jsx(Button$1,{type:"button",variant:"ghost",size:"sm",onClick:A,className:g?"bg-muted":"",children:jsxRuntime.jsx(Code$1,{className:"h-4 w-4"})})]}),jsxRuntime.jsx("div",{className:"p-3",children:g?jsxRuntime.jsx(Textarea,{ref:_,id:e,name:t,value:R.getHTML(),onChange:M,className:cn("min-h-[150px] font-mono text-sm resize-none border-0 focus-visible:ring-0 focus-visible:ring-offset-0",d),placeholder:l}):jsxRuntime.jsx(EditorContent,{editor:R})})]}):null}function ReceiptsTable({applicationId:e,receipts:t=null,loading:n=!1}){const o=React.useMemo(()=>[{accessorKey:"Location",header:"Location",cell:({row:f})=>f.original.Location??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"ReceiptDate",header:"Date",cell:({row:f})=>formatYYYYMMDDIntToDateString(f.original.ReceiptDate),enableSorting:!0,enableFiltering:!0},{accessorKey:"ReceiptNumber",header:"Number",cell:({row:f})=>f.original.ReceiptNumber?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/Document/${f.original.ReceiptNumber}`,className:"font-medium text-primary hover:underline",children:f.original.ReceiptNumber})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for Receipt ",f.original.ReceiptNumber]})})]})}):"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:f})=>f.original.Quantity??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"UnitPrice",header:"Unit Price",cell:({row:f})=>f.original.UnitPrice?formatMoney(f.original.UnitPrice):"—",enableSorting:!0,enableFiltering:!0}],[]),l=React.useMemo(()=>{const f={};if(t){const g=Array.from(new Set(t.map(_=>_.Location).filter(_=>_!=null)));f.Location=g;const b=Array.from(new Set(t.map(_=>formatYYYYMMDDIntToDateString(_.ReceiptDate)).filter(_=>_!=="—"&&_!=="Invalid Date"))).sort((_,S)=>new Date(S).getTime()-new Date(_).getTime());f.ReceiptDate=b}return f},[t]),d=t||[];return jsxRuntime.jsx(DataTable,{columns:o,data:d,uniqueValues:l,loading:n,tableClass:"bg-card text-card-foreground",initialSort:[{id:"ReceiptDate",desc:!0}]})}const formatDate$1=e=>{if(!e)return"N/A";try{const t=new Date(e);return isNaN(t.getTime())?"Invalid Date":t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return"Invalid Date"}},getStatusVariant=e=>{const t=(e==null?void 0:e.toLowerCase())||"";return t.includes("accepted")?"success":t.includes("error")||t.includes("rejected")?"destructive":"neutral"};function ReturnsTable({applicationId:e,returns:t=null,loading:n=!1}){const o=React.useMemo(()=>[{accessorKey:"ReturnNumber1",header:"RMA Number",cell:({row:f})=>{const g=f.original.ReturnNumber1||f.original.ReturnNumber;return g?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/Return/${g}`,className:"font-medium text-primary hover:underline",children:g})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for return ",g]})})]})}):"N/A"},enableSorting:!0,enableFiltering:!0},{accessorKey:"RequestDate",header:"Request Date",cell:({row:f})=>formatDate$1(f.original.RequestDate),enableSorting:!0},{accessorKey:"InvoiceNumber",header:"Invoice Number",cell:({row:f})=>{const g=f.original.InvoiceNumber;return g?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/Document/${g}`,className:"text-blue-600 hover:underline dark:text-blue-400",children:g})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for invoice ",g]})})]})}):"N/A"},enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:f})=>f.original.Quantity??"0",enableSorting:!0},{accessorKey:"ReasonForReturn",header:"Return Reason",cell:({row:f})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:f.original.ReasonForReturn??"—"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"Status",header:"Status",cell:({row:f})=>{const g=f.original.Status,b=getStatusVariant(g);let _="border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400";return b==="success"?_="border-green-500 bg-green-100 text-green-700 dark:border-green-600 dark:bg-green-900/50 dark:text-green-400":b==="destructive"&&(_="border-red-500 bg-red-100 text-red-700 dark:border-red-600 dark:bg-red-900/50 dark:text-red-400"),g?jsxRuntime.jsx(Badge,{variant:"outline",className:`${_} font-medium`,children:g}):"—"},enableSorting:!0,enableFiltering:!0},{accessorKey:"WarehouseLocation",header:"Warehouse",cell:({row:f})=>f.original.WarehouseLocation??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"LastUpdatedDate",header:"Last Update",cell:({row:f})=>formatDate$1(f.original.LastUpdatedDate)!=="N/A"?formatDate$1(f.original.LastUpdatedDate):"—",enableSorting:!0}],[e]),l=React.useMemo(()=>{const f={};if(t){const g=Array.from(new Set(t.map(S=>S.Status).filter(Boolean)));f.Status=g;const b=Array.from(new Set(t.map(S=>S.ReasonForReturn).filter(Boolean)));f.ReasonForReturn=b;const _=Array.from(new Set(t.map(S=>S.WarehouseLocation).filter(Boolean)));f.WarehouseLocation=_}return f},[t]),d=React.useMemo(()=>t?[...t].sort((g,b)=>(b.ReturnNumber1||b.ReturnNumber||"").localeCompare(g.ReturnNumber1||g.ReturnNumber||"")):[],[t]);return n?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(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-48 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:"Returns"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:o,data:d,uniqueValues:l})})]})}function PurchaseOrdersTable({applicationId:e,purchaseOrders:t=null,loading:n=!1}){const[o,l]=React.useState([]),[d]=usePostV4ManufacturerByRouteManufacturerIdPurchaseOrderAndPurchaseOrderNumberEditItemRandmarSkuMutation(),{toast:f}=useToast();React.useEffect(()=>{l(t||[])},[t]);const g=React.useMemo(()=>[{accessorKey:"PurchaseOrderNumber",header:"Number",cell:({row:_})=>_.original.PurchaseOrderNumber?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/Document/${_.original.PurchaseOrderNumber}`,className:"font-medium text-primary hover:underline",children:_.original.PurchaseOrderNumber})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for Purchase Order ",_.original.PurchaseOrderNumber]})})]})}):"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"PurchaseOrderDate",header:"Date",cell:({row:_})=>formatYYYYMMDDIntToDateString(_.original.PurchaseOrderDate),enableSorting:!0,enableFiltering:!0},{accessorKey:"Location",header:"Location",cell:({row:_})=>_.original.Location??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"PartNumber",header:"Part Number",cell:({row:_})=>_.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/${_.original.RandmarSKU}`,className:"font-medium text-primary hover:underline",children:_.original.MPN})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for Product ",_.original.RandmarSKU]})})]})}):"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"QuantityOrdered",header:"Quantity Ordered",cell:({row:_})=>_.original.QuantityOrdered??0,enableSorting:!0,enableFiltering:!0},{accessorKey:"UnitPrice",header:"Unit Price",cell:({row:_})=>_.original.UnitPrice?formatMoney(_.original.UnitPrice):"—",enableSorting:!0,enableFiltering:!0},{id:"actions",header:()=>jsxRuntime.jsx("div",{className:"text-right",children:"Action"}),cell:function({row:S}){const[R,C]=React.useState(!1),E=S.original,A=()=>{C(!0),d({routeManufacturerId:e,purchaseOrderNumber:E.PurchaseOrderNumber??"",randmarSku:E.RandmarSKU??"",quantity:0}).then(()=>{l(M=>M.filter(I=>!(I.PurchaseOrderNumber===I.PurchaseOrderNumber&&I.MPN===I.MPN))),f({variant:"success",title:"Success",description:`Part ${E.MPN} has been successfully deleted from Purchase Order ${E.PurchaseOrderNumber}.`})}).catch(M=>{console.error(M),C(!0),f({variant:"destructive",title:"Error",description:"Something went wrong!"})})};return jsxRuntime.jsx("div",{className:"text-right",children:jsxRuntime.jsxs(AlertDialog,{children:[jsxRuntime.jsx(AlertDialogTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"red",size:"sm",disabled:R,children:R?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Deleting"]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})})}),jsxRuntime.jsxs(AlertDialogContent,{children:[jsxRuntime.jsxs(AlertDialogHeader,{children:[jsxRuntime.jsx(AlertDialogTitle,{children:"Confirmation"}),jsxRuntime.jsxs(AlertDialogDescription,{children:["Are you sure you want to delete part ",jsxRuntime.jsx("strong",{children:E.MPN})," from Purchase Order ",jsxRuntime.jsx("strong",{children:E.PurchaseOrderNumber}),"?."]})]}),jsxRuntime.jsxs(AlertDialogFooter,{children:[jsxRuntime.jsx(AlertDialogCancel,{disabled:R,children:"Cancel"}),jsxRuntime.jsxs(AlertDialogAction,{onClick:A,disabled:R,children:[R&&jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Confirm"]})]})]})]})})}}],[e]),b=React.useMemo(()=>{const _={};return o&&(_.PurchaseOrderNumber=Array.from(new Set(o.map(S=>S.PurchaseOrderNumber).filter(S=>S!=null))),_.PurchaseOrderDate=Array.from(new Set(o.map(S=>S.PurchaseOrderDate).filter(S=>S!=null).map(String))),_.Location=Array.from(new Set(o.map(S=>S.Location).filter(S=>S!=null))),_.PartNumber=Array.from(new Set(o.map(S=>S.MPN).filter(S=>S!=null))),_.QuantityOrdered=Array.from(new Set(o.map(S=>S.QuantityOrdered).filter(S=>S!=null).map(String))),_.UnitPrice=Array.from(new Set(o.map(S=>S.UnitPrice).filter(S=>S!=null).map(String)))),_},[o]);return jsxRuntime.jsx(DataTable,{columns:g,data:o,uniqueValues:b,loading:n,tableClass:"bg-card text-card-foreground"})}function RequisitionsTable({applicationId:e,requisitions:t=null,loading:n=!1}){const[o,l]=React.useState([]),[d]=useDeleteV4ManufacturerByRouteManufacturerIdRequisitionAndRequisitionNumberMutation(),{toast:f}=useToast();React.useEffect(()=>{l(t||[])},[t]);const g=React.useMemo(()=>[{accessorKey:"RequisitionNumber",header:"Number",cell:({row:_})=>_.original.RequisitionNumber?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/Document/${_.original.RequisitionNumber}`,className:"font-medium text-primary hover:underline",children:_.original.RequisitionNumber})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for Draft Purchase ",_.original.RequisitionNumber]})})]})}):"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"RequisitionDate",header:"Date",cell:({row:_})=>formatYYYYMMDDIntToDateString(_.original.RequisitionDate),enableSorting:!0,enableFiltering:!0},{accessorKey:"Location",header:"Location",cell:({row:_})=>_.original.Location??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"QuantityOrdered",header:"Quantity Ordered",cell:({row:_})=>_.original.QuantityOrdered??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"QuantityOutstanding",header:"Quantity Outstanding",cell:({row:_})=>_.original.QuantityOutstanding??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"QuantityReceived",header:"Quantity Received",cell:({row:_})=>_.original.QuantityReceived??"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"SubTotal",header:"Sub Total",cell:({row:_})=>_.original.SubTotal?formatMoney(_.original.SubTotal):"—",enableSorting:!0,enableFiltering:!0},{accessorKey:"RequestedBy",header:"Requestor",cell:({row:_})=>_.original.RequestedBy??"—",enableSorting:!0,enableFiltering:!0},{id:"actions",header:()=>jsxRuntime.jsx("div",{className:"text-right",children:"Action"}),cell:function({row:S}){const[R,C]=React.useState(!1),E=S.original,A=()=>{C(!0),d({routeManufacturerId:e,requisitionNumber:E.RequisitionNumber??""}).then(()=>{l(M=>M.filter(I=>I.RequisitionNumber!==I.RequisitionNumber)),f({variant:"success",title:"Success",description:`Draft Purchase ${E.RequisitionNumber} has been successfully cancelled.`})}).catch(M=>{console.error(M),C(!0),f({variant:"destructive",title:"Error",description:"Something went wrong!"})})};return jsxRuntime.jsx("div",{className:"text-right",children:jsxRuntime.jsxs(AlertDialog,{children:[jsxRuntime.jsx(AlertDialogTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"red",size:"sm",disabled:R,children:R?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Cancelling"]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Trash2,{className:"mr-2 h-4 w-4"}),"Cancel"]})})}),jsxRuntime.jsxs(AlertDialogContent,{children:[jsxRuntime.jsxs(AlertDialogHeader,{children:[jsxRuntime.jsx(AlertDialogTitle,{children:"Confirmation"}),jsxRuntime.jsxs(AlertDialogDescription,{children:["Are you sure you want to cancel Draft Purchase ",jsxRuntime.jsx("strong",{children:E.RequisitionNumber}),"?."]})]}),jsxRuntime.jsxs(AlertDialogFooter,{children:[jsxRuntime.jsx(AlertDialogCancel,{disabled:R,children:"Cancel"}),jsxRuntime.jsxs(AlertDialogAction,{onClick:A,disabled:R,children:[R&&jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Confirm"]})]})]})]})})}}],[e]),b=React.useMemo(()=>{const _={};return o&&(_.RequisitionNumber=Array.from(new Set(o.map(S=>S.RequisitionNumber).filter(S=>S!=null))),_.RequisitionDate=Array.from(new Set(o.map(S=>S.RequisitionDate).filter(S=>S!=null).map(String))),_.QuantityOrdered=Array.from(new Set(o.map(S=>S.QuantityOrdered).filter(S=>S!=null).map(String))),_.QuantityOutstanding=Array.from(new Set(o.map(S=>S.QuantityOutstanding).filter(S=>S!=null).map(String))),_.QuantityReceived=Array.from(new Set(o.map(S=>S.QuantityReceived).filter(S=>S!=null).map(String))),_.Location=Array.from(new Set(o.map(S=>S.Location).filter(S=>S!=null))),_.RequestedBy=Array.from(new Set(o.map(S=>S.RequestedBy).filter(S=>S!=null))),_.SubTotal=Array.from(new Set(o.map(S=>S.SubTotal).filter(S=>S!=null).map(String)))),_},[o]);return jsxRuntime.jsx(DataTable,{columns:g,data:o,uniqueValues:b,loading:n,tableClass:"bg-card text-card-foreground"})}function ProductOverviewPage({applicationId:e,sku:t,product:n,productDefaultOpportunityNumber:o="",productOnAddToCart:l,productAddingToCart:d=!1,productShopifyHostname:f,productCustomAction:g=jsxRuntime.jsx(jsxRuntime.Fragment,{})}){var Q,te,F,V,ne,ae,se,Oe,Ne,oe,$e,Ae,je,Be,qe,Ve;const{data:b,isLoading:_}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:e,randmarSku:t??"",withSpecification:!1},{skip:!!n||!e||!t}),{data:S,isLoading:R}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:e,randmarSku:t??"",withSpecification:!0},{skip:!!n||!e||!t}),C=n??S??b,{data:E}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:e}),[A,M]=React.useState("stats-tab"),[I,j]=React.useState(!1);React.useEffect(()=>{var We,ze,Xe,nt,Je,st,et,at;if(!n&&R){j(!1);return}const Le={stats:(((We=C==null?void 0:C.SalesStatistics)==null?void 0:We.length)??0)<=0,inventory:(((Xe=(ze=C==null?void 0:C.Distribution)==null?void 0:ze.Inventory)==null?void 0:Xe.length)??0)<=0,opportunities:(((nt=C==null?void 0:C.Opportunities)==null?void 0:nt.length)??0)<=0,orders:(((Je=C==null?void 0:C.ActiveOrderDetails)==null?void 0:Je.length)??0)<=0&&(((st=C==null?void 0:C.Returns)==null?void 0:st.length)??0)<=0,invoices:(((et=C==null?void 0:C.CompletedOrderDetails)==null?void 0:et.length)??0)<=0,warehouse:(((at=C==null?void 0:C.Receipts)==null?void 0:at.length)??0)<=0},He=Object.values(Le).some(tt=>!tt);if(j(He),He&&Le[A]){const tt=Object.keys(Le).find(ot=>!Le[ot]);tt&&M(tt)}},[R,C,n,A]);const q=(C==null?void 0:C.ManufacturerId)!==e;return console.log("readonly",q),jsxRuntime.jsxs("div",{className:"@container",children:[jsxRuntime.jsxs("div",{className:"grid gap-4 grid-cols-1 @sm:grid-cols-2 @md:grid-cols-3",children:[jsxRuntime.jsx("div",{className:"@md:col-span-2",children:jsxRuntime.jsx(ProductCard,{applicationId:e,product:C??C,defaultOpportunityNumber:o,onAddToCart:l,addingToCart:d,shopifyHostname:f,customAction:g})}),jsxRuntime.jsxs(Card,{className:"flex flex-col",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsxs(CardTitle,{children:[jsxRuntime.jsx(Info,{className:"h-5 w-5 inline mr-2"})," Additionnal information"]})}),jsxRuntime.jsx(CardContent,{className:"basis-0 mb-6 grow overflow-y-auto",children:_?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsx(Skeleton,{className:"h-1 w-full my-6"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full mt-2"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full mt-1"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex justify-between",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Category Name"}),jsxRuntime.jsx("span",{className:"font-medium",children:(C==null?void 0:C.ProductType)||"N/A"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Master Carton"}),jsxRuntime.jsx("span",{className:"font-medium",children:(C==null?void 0:C.MasterCarton)||"N/A"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Skid Quantity"}),jsxRuntime.jsx("span",{className:"font-medium",children:(C==null?void 0:C.SkidQuantity)||"N/A"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Automatic Reorder"}),jsxRuntime.jsx("span",{className:"font-medium",children:C!=null&&C.AutoUpdate?"Yes":"No"})]}),((C==null?void 0:C.VoiceoverCaption)||(C==null?void 0:C.BodyHTML))&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("hr",{className:"my-6"}),jsxRuntime.jsx("div",{className:"text-muted-foreground mb-2",children:"Description"}),(C==null?void 0:C.VoiceoverCaption)&&jsxRuntime.jsx("div",{children:C==null?void 0:C.VoiceoverCaption}),(C==null?void 0:C.BodyHTML)&&jsxRuntime.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:(C==null?void 0:C.BodyHTML)??""}})]})]})})]})]}),jsxRuntime.jsx("div",{className:"my-4",children:_||R?jsxRuntime.jsx("div",{className:"mx-auto flex justify-center items-center h-32",children:jsxRuntime.jsx(LoaderCircle,{className:"h-8 w-8 animate-spin text-primary"})}):I&&jsxRuntime.jsxs(Tabs,{value:A,onValueChange:M,children:[jsxRuntime.jsxs(TabsList,{className:"inline-flex h-auto items-center justify-center rounded-none border-b bg-transparent p-0",children:[jsxRuntime.jsx(TabsTrigger,{value:"stats-tab",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",disabled:(((Q=C==null?void 0:C.SalesStatistics)==null?void 0:Q.length)??0)<=0,children:"Statistics"}),jsxRuntime.jsx(TabsTrigger,{value:"inventory-tab",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",disabled:(((F=(te=C==null?void 0:C.Distribution)==null?void 0:te.Inventory)==null?void 0:F.length)??0)<=0,children:"Inventory"}),jsxRuntime.jsx(TabsTrigger,{value:"opportunities-tab",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",disabled:(((V=C==null?void 0:C.Opportunities)==null?void 0:V.length)??0)<=0,children:"Opportunities"}),jsxRuntime.jsx(TabsTrigger,{value:"active-orders-tab",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",disabled:(((ne=C==null?void 0:C.ActiveOrderDetails)==null?void 0:ne.length)??0)<=0,children:"Active Orders"}),jsxRuntime.jsx(TabsTrigger,{value:"completed-orders-tab",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",disabled:(((ae=C==null?void 0:C.CompletedOrderDetails)==null?void 0:ae.length)??0)<=0,children:"Completed Orders"}),jsxRuntime.jsx(TabsTrigger,{value:"returns-tab",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",disabled:(((se=C==null?void 0:C.Returns)==null?void 0:se.length)??0)<=0,children:"Returns"}),jsxRuntime.jsx(TabsTrigger,{value:"purchase-orders-tab",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",disabled:!(E!=null&&E.IsManufacturer)||(((Oe=C==null?void 0:C.PurchaseOrders)==null?void 0:Oe.length)??0)<=0&&(((Ne=C==null?void 0:C.Requisitions)==null?void 0:Ne.length)??0)<=0,children:"Purchase Orders"}),jsxRuntime.jsx(TabsTrigger,{value:"warehouse-tab",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",disabled:(((oe=C==null?void 0:C.Receipts)==null?void 0:oe.length)??0)<=0,children:"Latest Warehouse Receiving"})]}),jsxRuntime.jsx(TabsContent,{value:"stats-tab",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(SalesChartCard,{statistics:(C==null?void 0:C.SalesStatistics)??[],loading:R})})}),jsxRuntime.jsx(TabsContent,{value:"inventory-tab",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ProductInventoryGrid,{inventory:(($e=C==null?void 0:C.Distribution)==null?void 0:$e.Inventory)??[],className:"bg-card text-card-foreground"})})}),jsxRuntime.jsx(TabsContent,{value:"opportunities-tab",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OpportunitiesTable,{applicationId:e,opportunities:C==null?void 0:C.Opportunities,loading:R})})}),jsxRuntime.jsx(TabsContent,{value:"active-orders-tab",children:(((Ae=C==null?void 0:C.ActiveOrderDetails)==null?void 0:Ae.length)??0)>0&&jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OrdersCard,{applicationId:e,title:"Active Orders",orders:C==null?void 0:C.ActiveOrderDetails,loading:R})})}),jsxRuntime.jsx(TabsContent,{value:"completed-orders-tab",children:(((je=C==null?void 0:C.CompletedOrderDetails)==null?void 0:je.length)??0)>0&&jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OrdersCard,{applicationId:e,title:"Completed Orders",orders:C==null?void 0:C.CompletedOrderDetails,loading:R})})}),jsxRuntime.jsx(TabsContent,{value:"returns-tab",children:(((Be=C==null?void 0:C.Returns)==null?void 0:Be.length)??0)>0&&jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ReturnsTable,{applicationId:e,returns:C==null?void 0:C.Returns,loading:R})})}),jsxRuntime.jsxs(TabsContent,{value:"purchase-orders-tab",children:[(((qe=C==null?void 0:C.PurchaseOrders)==null?void 0:qe.length)??0)>0&&jsxRuntime.jsxs(Card,{className:"mt-4 w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Purchase Orders"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(PurchaseOrdersTable,{applicationId:e,purchaseOrders:C==null?void 0:C.PurchaseOrders,loading:R})})]}),(((Ve=C==null?void 0:C.Requisitions)==null?void 0:Ve.length)??0)>0&&jsxRuntime.jsxs(Card,{className:"mt-4 w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Draft Purchases"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(RequisitionsTable,{applicationId:e,requisitions:C==null?void 0:C.Requisitions,loading:R})})]})]}),jsxRuntime.jsx(TabsContent,{value:"warehouse-tab",children:jsxRuntime.jsxs(Card,{className:"mt-4 w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Receipts"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(ReceiptsTable,{applicationId:e,receipts:C==null?void 0:C.Receipts,loading:R})})]})})]})})]})}const colClasses={base:{1:"grid-cols-1",2:"grid-cols-2",3:"grid-cols-3",4:"grid-cols-4",5:"grid-cols-5",6:"grid-cols-6"},sm:{1:"sm:grid-cols-1",2:"sm:grid-cols-2",3:"sm:grid-cols-3",4:"sm:grid-cols-4",5:"sm:grid-cols-5",6:"sm:grid-cols-6"},md:{1:"md:grid-cols-1",2:"md:grid-cols-2",3:"md:grid-cols-3",4:"md:grid-cols-4",5:"md:grid-cols-5",6:"md:grid-cols-6"},lg:{1:"lg:grid-cols-1",2:"lg:grid-cols-2",3:"lg:grid-cols-3",4:"lg:grid-cols-4",5:"lg:grid-cols-5",6:"lg:grid-cols-6"},xl:{1:"xl:grid-cols-1",2:"xl:grid-cols-2",3:"xl:grid-cols-3",4:"xl:grid-cols-4",5:"xl:grid-cols-5",6:"xl:grid-cols-6"}},buildGridClassName=e=>{const t={base:1,md:2,...e};return["grid","gap-4",t.base?colClasses.base[t.base]:"",t.sm?colClasses.sm[t.sm]:"",t.md?colClasses.md[t.md]:"",t.lg?colClasses.lg[t.lg]:"",t.xl?colClasses.xl[t.xl]:""].filter(Boolean).join(" ")},SearchPageGrid=({results:e,groupBy:t,renderItem:n})=>{const o=t(e);return jsxRuntime.jsx(jsxRuntime.Fragment,{children:Object.entries(o).map(([l,d])=>{const{items:f,gridCols:g}=d;if(f.length===0)return null;const b=buildGridClassName(g);return jsxRuntime.jsxs("div",{className:"mb-4",children:[jsxRuntime.jsx("h2",{className:"text-xl font-semibold tracking-tight mb-4",children:l}),jsxRuntime.jsx("div",{className:b,children:f.map((_,S)=>n(_,S))})]},l)})})},SearchPage=({query:e,results:t,isLoading:n,children:o})=>n?jsxRuntime.jsx("div",{className:"flex w-full justify-center items-center py-24",children:jsxRuntime.jsx(LoaderCircle,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e&&t.length===0?jsxRuntime.jsx("div",{className:"flex w-full justify-center items-start pt-16",children:jsxRuntime.jsx(Card,{className:"w-full max-w-lg",children:jsxRuntime.jsxs(CardHeader,{className:"text-center items-center",children:[jsxRuntime.jsx("div",{className:"rounded-full border bg-muted p-3 mb-4",children:jsxRuntime.jsx(SearchX,{className:"h-8 w-8 text-muted-foreground"})}),jsxRuntime.jsx(CardTitle,{children:"No Results Found"}),jsxRuntime.jsxs(CardDescription,{children:['Your search for "',e,'" did not return any results. Please try a different search term.']})]})})}):t.length>0?jsxRuntime.jsx("div",{className:"grid grid-cols-3 gap-8",children:jsxRuntime.jsx("div",{className:"col-span-3",children:o})}):null;var COLLAPSIBLE_NAME="Collapsible",[createCollapsibleContext,createCollapsibleScope]=createContextScope$2(COLLAPSIBLE_NAME),[CollapsibleProvider,useCollapsibleContext]=createCollapsibleContext(COLLAPSIBLE_NAME),Collapsible=React__namespace.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:o,defaultOpen:l,disabled:d,onOpenChange:f,...g}=e,[b,_]=useControllableState({prop:o,defaultProp:l??!1,onChange:f,caller:COLLAPSIBLE_NAME});return jsxRuntime.jsx(CollapsibleProvider,{scope:n,disabled:d,contentId:useId(),open:b,onOpenToggle:React__namespace.useCallback(()=>_(S=>!S),[_]),children:jsxRuntime.jsx(Primitive$4.div,{"data-state":getState$1(b),"data-disabled":d?"":void 0,...g,ref:t})})});Collapsible.displayName=COLLAPSIBLE_NAME;var TRIGGER_NAME$1="CollapsibleTrigger",CollapsibleTrigger=React__namespace.forwardRef((e,t)=>{const{__scopeCollapsible:n,...o}=e,l=useCollapsibleContext(TRIGGER_NAME$1,n);return jsxRuntime.jsx(Primitive$4.button,{type:"button","aria-controls":l.contentId,"aria-expanded":l.open||!1,"data-state":getState$1(l.open),"data-disabled":l.disabled?"":void 0,disabled:l.disabled,...o,ref:t,onClick:composeEventHandlers(e.onClick,l.onOpenToggle)})});CollapsibleTrigger.displayName=TRIGGER_NAME$1;var CONTENT_NAME$1="CollapsibleContent",CollapsibleContent=React__namespace.forwardRef((e,t)=>{const{forceMount:n,...o}=e,l=useCollapsibleContext(CONTENT_NAME$1,e.__scopeCollapsible);return jsxRuntime.jsx(Presence,{present:n||l.open,children:({present:d})=>jsxRuntime.jsx(CollapsibleContentImpl,{...o,ref:t,present:d})})});CollapsibleContent.displayName=CONTENT_NAME$1;var CollapsibleContentImpl=React__namespace.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:o,children:l,...d}=e,f=useCollapsibleContext(CONTENT_NAME$1,n),[g,b]=React__namespace.useState(o),_=React__namespace.useRef(null),S=useComposedRefs(t,_),R=React__namespace.useRef(0),C=R.current,E=React__namespace.useRef(0),A=E.current,M=f.open||g,I=React__namespace.useRef(M),j=React__namespace.useRef(void 0);return React__namespace.useEffect(()=>{const q=requestAnimationFrame(()=>I.current=!1);return()=>cancelAnimationFrame(q)},[]),useLayoutEffect2(()=>{const q=_.current;if(q){j.current=j.current||{transitionDuration:q.style.transitionDuration,animationName:q.style.animationName},q.style.transitionDuration="0s",q.style.animationName="none";const Q=q.getBoundingClientRect();R.current=Q.height,E.current=Q.width,I.current||(q.style.transitionDuration=j.current.transitionDuration,q.style.animationName=j.current.animationName),b(o)}},[f.open,o]),jsxRuntime.jsx(Primitive$4.div,{"data-state":getState$1(f.open),"data-disabled":f.disabled?"":void 0,id:f.contentId,hidden:!M,...d,ref:S,style:{"--radix-collapsible-content-height":C?`${C}px`:void 0,"--radix-collapsible-content-width":A?`${A}px`:void 0,...e.style},children:M&&l})});function getState$1(e){return e?"open":"closed"}var Root$1=Collapsible,Trigger=CollapsibleTrigger,Content=CollapsibleContent,ACCORDION_NAME="Accordion",ACCORDION_KEYS=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[Collection,useCollection,createCollectionScope]=createCollection(ACCORDION_NAME),[createAccordionContext]=createContextScope$2(ACCORDION_NAME,[createCollectionScope,createCollapsibleScope]),useCollapsibleScope=createCollapsibleScope(),Accordion$1=React.forwardRef((e,t)=>{const{type:n,...o}=e,l=o,d=o;return jsxRuntime.jsx(Collection.Provider,{scope:e.__scopeAccordion,children:n==="multiple"?jsxRuntime.jsx(AccordionImplMultiple,{...d,ref:t}):jsxRuntime.jsx(AccordionImplSingle,{...l,ref:t})})});Accordion$1.displayName=ACCORDION_NAME;var[AccordionValueProvider,useAccordionValueContext]=createAccordionContext(ACCORDION_NAME),[AccordionCollapsibleProvider,useAccordionCollapsibleContext]=createAccordionContext(ACCORDION_NAME,{collapsible:!1}),AccordionImplSingle=React.forwardRef((e,t)=>{const{value:n,defaultValue:o,onValueChange:l=()=>{},collapsible:d=!1,...f}=e,[g,b]=useControllableState({prop:n,defaultProp:o??"",onChange:l,caller:ACCORDION_NAME});return jsxRuntime.jsx(AccordionValueProvider,{scope:e.__scopeAccordion,value:React.useMemo(()=>g?[g]:[],[g]),onItemOpen:b,onItemClose:React.useCallback(()=>d&&b(""),[d,b]),children:jsxRuntime.jsx(AccordionCollapsibleProvider,{scope:e.__scopeAccordion,collapsible:d,children:jsxRuntime.jsx(AccordionImpl,{...f,ref:t})})})}),AccordionImplMultiple=React.forwardRef((e,t)=>{const{value:n,defaultValue:o,onValueChange:l=()=>{},...d}=e,[f,g]=useControllableState({prop:n,defaultProp:o??[],onChange:l,caller:ACCORDION_NAME}),b=React.useCallback(S=>g((R=[])=>[...R,S]),[g]),_=React.useCallback(S=>g((R=[])=>R.filter(C=>C!==S)),[g]);return jsxRuntime.jsx(AccordionValueProvider,{scope:e.__scopeAccordion,value:f,onItemOpen:b,onItemClose:_,children:jsxRuntime.jsx(AccordionCollapsibleProvider,{scope:e.__scopeAccordion,collapsible:!0,children:jsxRuntime.jsx(AccordionImpl,{...d,ref:t})})})}),[AccordionImplProvider,useAccordionContext]=createAccordionContext(ACCORDION_NAME),AccordionImpl=React.forwardRef((e,t)=>{const{__scopeAccordion:n,disabled:o,dir:l,orientation:d="vertical",...f}=e,g=React.useRef(null),b=useComposedRefs(g,t),_=useCollection(n),R=useDirection(l)==="ltr",C=composeEventHandlers(e.onKeyDown,E=>{var ae;if(!ACCORDION_KEYS.includes(E.key))return;const A=E.target,M=_().filter(se=>{var Oe;return!((Oe=se.ref.current)!=null&&Oe.disabled)}),I=M.findIndex(se=>se.ref.current===A),j=M.length;if(I===-1)return;E.preventDefault();let q=I;const Q=0,te=j-1,F=()=>{q=I+1,q>te&&(q=Q)},V=()=>{q=I-1,q<Q&&(q=te)};switch(E.key){case"Home":q=Q;break;case"End":q=te;break;case"ArrowRight":d==="horizontal"&&(R?F():V());break;case"ArrowDown":d==="vertical"&&F();break;case"ArrowLeft":d==="horizontal"&&(R?V():F());break;case"ArrowUp":d==="vertical"&&V();break}const ne=q%j;(ae=M[ne].ref.current)==null||ae.focus()});return jsxRuntime.jsx(AccordionImplProvider,{scope:n,disabled:o,direction:l,orientation:d,children:jsxRuntime.jsx(Collection.Slot,{scope:n,children:jsxRuntime.jsx(Primitive$4.div,{...f,"data-orientation":d,ref:b,onKeyDown:o?void 0:C})})})}),ITEM_NAME="AccordionItem",[AccordionItemProvider,useAccordionItemContext]=createAccordionContext(ITEM_NAME),AccordionItem$1=React.forwardRef((e,t)=>{const{__scopeAccordion:n,value:o,...l}=e,d=useAccordionContext(ITEM_NAME,n),f=useAccordionValueContext(ITEM_NAME,n),g=useCollapsibleScope(n),b=useId(),_=o&&f.value.includes(o)||!1,S=d.disabled||e.disabled;return jsxRuntime.jsx(AccordionItemProvider,{scope:n,open:_,disabled:S,triggerId:b,children:jsxRuntime.jsx(Root$1,{"data-orientation":d.orientation,"data-state":getState(_),...g,...l,ref:t,disabled:S,open:_,onOpenChange:R=>{R?f.onItemOpen(o):f.onItemClose(o)}})})});AccordionItem$1.displayName=ITEM_NAME;var HEADER_NAME="AccordionHeader",AccordionHeader=React.forwardRef((e,t)=>{const{__scopeAccordion:n,...o}=e,l=useAccordionContext(ACCORDION_NAME,n),d=useAccordionItemContext(HEADER_NAME,n);return jsxRuntime.jsx(Primitive$4.h3,{"data-orientation":l.orientation,"data-state":getState(d.open),"data-disabled":d.disabled?"":void 0,...o,ref:t})});AccordionHeader.displayName=HEADER_NAME;var TRIGGER_NAME="AccordionTrigger",AccordionTrigger$1=React.forwardRef((e,t)=>{const{__scopeAccordion:n,...o}=e,l=useAccordionContext(ACCORDION_NAME,n),d=useAccordionItemContext(TRIGGER_NAME,n),f=useAccordionCollapsibleContext(TRIGGER_NAME,n),g=useCollapsibleScope(n);return jsxRuntime.jsx(Collection.ItemSlot,{scope:n,children:jsxRuntime.jsx(Trigger,{"aria-disabled":d.open&&!f.collapsible||void 0,"data-orientation":l.orientation,id:d.triggerId,...g,...o,ref:t})})});AccordionTrigger$1.displayName=TRIGGER_NAME;var CONTENT_NAME="AccordionContent",AccordionContent$1=React.forwardRef((e,t)=>{const{__scopeAccordion:n,...o}=e,l=useAccordionContext(ACCORDION_NAME,n),d=useAccordionItemContext(CONTENT_NAME,n),f=useCollapsibleScope(n);return jsxRuntime.jsx(Content,{role:"region","aria-labelledby":d.triggerId,"data-orientation":l.orientation,...f,...o,ref:t,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}})});AccordionContent$1.displayName=CONTENT_NAME;function getState(e){return e?"open":"closed"}var Root2=Accordion$1,Item=AccordionItem$1,Header=AccordionHeader,Trigger2=AccordionTrigger$1,Content2=AccordionContent$1;const Accordion=Root2,AccordionItem=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Item,{ref:n,className:cn("border-b",e),...t}));AccordionItem.displayName="AccordionItem";const AccordionTrigger=React__namespace.forwardRef(({className:e,children:t,...n},o)=>jsxRuntime.jsx(Header,{className:"flex",children:jsxRuntime.jsxs(Trigger2,{ref:o,className:cn("flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline text-left [&[data-state=open]>svg]:rotate-180",e),...n,children:[t,jsxRuntime.jsx(ChevronDown,{className:"h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200"})]})}));AccordionTrigger.displayName=Trigger2.displayName;const AccordionContent=React__namespace.forwardRef(({className:e,children:t,...n},o)=>jsxRuntime.jsx(Content2,{ref:o,className:"overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:jsxRuntime.jsx("div",{className:cn("pb-4 pt-0",e),children:t})}));AccordionContent.displayName=Content2.displayName;function AssistantInsight({prompt:e,smartAndSlow:t=!1,thinkingPlaceholderText:n="Thinking...",withCard:o=!0}){const{response:l,isLoading:d,error:f,sendPrompt:g}=useGemini({useProModel:t,outputFormat:"html"});React.useEffect(()=>{e&&g(e)},[e,g]);const b=`flex items-start gap-4 ${o?"p-4 border rounded-lg bg-background":""}`;return jsxRuntime.jsxs("div",{className:b,children:[jsxRuntime.jsx(Bot,{className:`mt-1 h-6 w-6 flex-shrink-0 ${d?"animate-pulse text-primary":"text-primary"}`}),jsxRuntime.jsxs("div",{className:"w-full min-h-[4rem]",children:[d&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("p",{className:"font-medium text-muted-foreground",children:n}),jsxRuntime.jsxs("div",{className:"space-y-2 mt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-5/6"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-3/4"})]})]}),f&&jsxRuntime.jsx("p",{className:"text-sm text-red-600",children:f}),!d&&!f&&l&&jsxRuntime.jsx("div",{className:"chat-bubble-in-animation text-sm text-foreground space-y-4",dangerouslySetInnerHTML:{__html:l}})]})]})}function tzName(e,t,n="long"){return new Intl.DateTimeFormat("en-US",{hour:"numeric",timeZone:e,timeZoneName:n}).format(t).split(/\s/g).slice(2).join(" ")}const offsetFormatCache={},offsetCache={};function tzOffset(e,t){try{const o=(offsetFormatCache[e]||(offsetFormatCache[e]=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"longOffset"}).format))(t).split("GMT")[1];return o in offsetCache?offsetCache[o]:calcOffset(o,o.split(":"))}catch{if(e in offsetCache)return offsetCache[e];const n=e==null?void 0:e.match(offsetRe);return n?calcOffset(e,n.slice(1)):NaN}}const offsetRe=/([+-]\d\d):?(\d\d)?/;function calcOffset(e,t){const n=+(t[0]||0),o=+(t[1]||0),l=+(t[2]||0)/60;return offsetCache[e]=n*60+o>0?n*60+o+l:n*60-o-l}class TZDateMini extends Date{constructor(...t){super(),t.length>1&&typeof t[t.length-1]=="string"&&(this.timeZone=t.pop()),this.internal=new Date,isNaN(tzOffset(this.timeZone,this))?this.setTime(NaN):t.length?typeof t[0]=="number"&&(t.length===1||t.length===2&&typeof t[1]!="number")?this.setTime(t[0]):typeof t[0]=="string"?this.setTime(+new Date(t[0])):t[0]instanceof Date?this.setTime(+t[0]):(this.setTime(+new Date(...t)),adjustToSystemTZ(this),syncToInternal(this)):this.setTime(Date.now())}static tz(t,...n){return n.length?new TZDateMini(...n,t):new TZDateMini(Date.now(),t)}withTimeZone(t){return new TZDateMini(+this,t)}getTimezoneOffset(){const t=-tzOffset(this.timeZone,this);return t>0?Math.floor(t):Math.ceil(t)}setTime(t){return Date.prototype.setTime.apply(this,arguments),syncToInternal(this),+this}[Symbol.for("constructDateFrom")](t){return new TZDateMini(+new Date(t),this.timeZone)}}const re=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(e=>{if(!re.test(e))return;const t=e.replace(re,"$1UTC");TZDateMini.prototype[t]&&(e.startsWith("get")?TZDateMini.prototype[e]=function(){return this.internal[t]()}:(TZDateMini.prototype[e]=function(){return Date.prototype[t].apply(this.internal,arguments),syncFromInternal(this),+this},TZDateMini.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),syncToInternal(this),+this}))});function syncToInternal(e){e.internal.setTime(+e),e.internal.setUTCSeconds(e.internal.getUTCSeconds()-Math.round(-tzOffset(e.timeZone,e)*60))}function syncFromInternal(e){Date.prototype.setFullYear.call(e,e.internal.getUTCFullYear(),e.internal.getUTCMonth(),e.internal.getUTCDate()),Date.prototype.setHours.call(e,e.internal.getUTCHours(),e.internal.getUTCMinutes(),e.internal.getUTCSeconds(),e.internal.getUTCMilliseconds()),adjustToSystemTZ(e)}function adjustToSystemTZ(e){const t=tzOffset(e.timeZone,e),n=t>0?Math.floor(t):Math.ceil(t),o=new Date(+e);o.setUTCHours(o.getUTCHours()-1);const l=-new Date(+e).getTimezoneOffset(),d=-new Date(+o).getTimezoneOffset(),f=l-d,g=Date.prototype.getHours.apply(e)!==e.internal.getUTCHours();f&&g&&e.internal.setUTCMinutes(e.internal.getUTCMinutes()+f);const b=l-n;b&&Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+b);const _=new Date(+e);_.setUTCSeconds(0);const S=l>0?_.getSeconds():(_.getSeconds()-60)%60,R=Math.round(-(tzOffset(e.timeZone,e)*60))%60;(R||S)&&(e.internal.setUTCSeconds(e.internal.getUTCSeconds()+R),Date.prototype.setUTCSeconds.call(e,Date.prototype.getUTCSeconds.call(e)+R+S));const C=tzOffset(e.timeZone,e),E=C>0?Math.floor(C):Math.ceil(C),M=-new Date(+e).getTimezoneOffset()-E,I=E!==n,j=M-b;if(I&&j){Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+j);const q=tzOffset(e.timeZone,e),Q=q>0?Math.floor(q):Math.ceil(q),te=E-Q;te&&(e.internal.setUTCMinutes(e.internal.getUTCMinutes()+te),Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+te))}}class TZDate extends TZDateMini{static tz(t,...n){return n.length?new TZDate(...n,t):new TZDate(Date.now(),t)}toISOString(){const[t,n,o]=this.tzComponents(),l=`${t}${n}:${o}`;return this.internal.toISOString().slice(0,-1)+l}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){const[t,n,o,l]=this.internal.toUTCString().split(" ");return`${t==null?void 0:t.slice(0,-1)} ${o} ${n} ${l}`}toTimeString(){const t=this.internal.toUTCString().split(" ")[4],[n,o,l]=this.tzComponents();return`${t} GMT${n}${o}${l} (${tzName(this.timeZone,this)})`}toLocaleString(t,n){return Date.prototype.toLocaleString.call(this,t,{...n,timeZone:(n==null?void 0:n.timeZone)||this.timeZone})}toLocaleDateString(t,n){return Date.prototype.toLocaleDateString.call(this,t,{...n,timeZone:(n==null?void 0:n.timeZone)||this.timeZone})}toLocaleTimeString(t,n){return Date.prototype.toLocaleTimeString.call(this,t,{...n,timeZone:(n==null?void 0:n.timeZone)||this.timeZone})}tzComponents(){const t=this.getTimezoneOffset(),n=t>0?"-":"+",o=String(Math.floor(Math.abs(t)/60)).padStart(2,"0"),l=String(Math.abs(t)%60).padStart(2,"0");return[n,o,l]}withTimeZone(t){return new TZDate(+this,t)}[Symbol.for("constructDateFrom")](t){return new TZDate(+new Date(t),this.timeZone)}}const FIVE_WEEKS=5,FOUR_WEEKS=4;function getBroadcastWeeksInMonth(e,t){const n=t.startOfMonth(e),o=n.getDay()>0?n.getDay():7,l=t.addDays(e,-o+1),d=t.addDays(l,FIVE_WEEKS*7-1);return t.getMonth(e)===t.getMonth(d)?FIVE_WEEKS:FOUR_WEEKS}function startOfBroadcastWeek(e,t){const n=t.startOfMonth(e),o=n.getDay();return o===1?n:o===0?t.addDays(n,-6):t.addDays(n,-1*(o-1))}function endOfBroadcastWeek(e,t){const n=startOfBroadcastWeek(e,t),o=getBroadcastWeeksInMonth(e,t);return t.addDays(n,o*7-1)}class DateLib{constructor(t,n){this.Date=Date,this.today=()=>{var o;return(o=this.overrides)!=null&&o.today?this.overrides.today():this.options.timeZone?TZDate.tz(this.options.timeZone):new this.Date},this.newDate=(o,l,d)=>{var f;return(f=this.overrides)!=null&&f.newDate?this.overrides.newDate(o,l,d):this.options.timeZone?new TZDate(o,l,d,this.options.timeZone):new Date(o,l,d)},this.addDays=(o,l)=>{var d;return(d=this.overrides)!=null&&d.addDays?this.overrides.addDays(o,l):addDays(o,l)},this.addMonths=(o,l)=>{var d;return(d=this.overrides)!=null&&d.addMonths?this.overrides.addMonths(o,l):addMonths(o,l)},this.addWeeks=(o,l)=>{var d;return(d=this.overrides)!=null&&d.addWeeks?this.overrides.addWeeks(o,l):addWeeks(o,l)},this.addYears=(o,l)=>{var d;return(d=this.overrides)!=null&&d.addYears?this.overrides.addYears(o,l):addYears(o,l)},this.differenceInCalendarDays=(o,l)=>{var d;return(d=this.overrides)!=null&&d.differenceInCalendarDays?this.overrides.differenceInCalendarDays(o,l):differenceInCalendarDays(o,l)},this.differenceInCalendarMonths=(o,l)=>{var d;return(d=this.overrides)!=null&&d.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(o,l):differenceInCalendarMonths(o,l)},this.eachMonthOfInterval=o=>{var l;return(l=this.overrides)!=null&&l.eachMonthOfInterval?this.overrides.eachMonthOfInterval(o):eachMonthOfInterval(o)},this.eachYearOfInterval=o=>{var g;const l=(g=this.overrides)!=null&&g.eachYearOfInterval?this.overrides.eachYearOfInterval(o):eachYearOfInterval(o),d=new Set(l.map(b=>this.getYear(b)));if(d.size===l.length)return l;const f=[];return d.forEach(b=>{f.push(new Date(b,0,1))}),f},this.endOfBroadcastWeek=o=>{var l;return(l=this.overrides)!=null&&l.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(o):endOfBroadcastWeek(o,this)},this.endOfISOWeek=o=>{var l;return(l=this.overrides)!=null&&l.endOfISOWeek?this.overrides.endOfISOWeek(o):endOfISOWeek(o)},this.endOfMonth=o=>{var l;return(l=this.overrides)!=null&&l.endOfMonth?this.overrides.endOfMonth(o):endOfMonth(o)},this.endOfWeek=(o,l)=>{var d;return(d=this.overrides)!=null&&d.endOfWeek?this.overrides.endOfWeek(o,l):endOfWeek(o,this.options)},this.endOfYear=o=>{var l;return(l=this.overrides)!=null&&l.endOfYear?this.overrides.endOfYear(o):endOfYear(o)},this.format=(o,l,d)=>{var g;const f=(g=this.overrides)!=null&&g.format?this.overrides.format(o,l,this.options):format(o,l,this.options);return this.options.numerals&&this.options.numerals!=="latn"?this.replaceDigits(f):f},this.getISOWeek=o=>{var l;return(l=this.overrides)!=null&&l.getISOWeek?this.overrides.getISOWeek(o):getISOWeek(o)},this.getMonth=(o,l)=>{var d;return(d=this.overrides)!=null&&d.getMonth?this.overrides.getMonth(o,this.options):getMonth(o,this.options)},this.getYear=(o,l)=>{var d;return(d=this.overrides)!=null&&d.getYear?this.overrides.getYear(o,this.options):getYear(o,this.options)},this.getWeek=(o,l)=>{var d;return(d=this.overrides)!=null&&d.getWeek?this.overrides.getWeek(o,this.options):getWeek(o,this.options)},this.isAfter=(o,l)=>{var d;return(d=this.overrides)!=null&&d.isAfter?this.overrides.isAfter(o,l):isAfter(o,l)},this.isBefore=(o,l)=>{var d;return(d=this.overrides)!=null&&d.isBefore?this.overrides.isBefore(o,l):isBefore(o,l)},this.isDate=o=>{var l;return(l=this.overrides)!=null&&l.isDate?this.overrides.isDate(o):isDate(o)},this.isSameDay=(o,l)=>{var d;return(d=this.overrides)!=null&&d.isSameDay?this.overrides.isSameDay(o,l):isSameDay(o,l)},this.isSameMonth=(o,l)=>{var d;return(d=this.overrides)!=null&&d.isSameMonth?this.overrides.isSameMonth(o,l):isSameMonth(o,l)},this.isSameYear=(o,l)=>{var d;return(d=this.overrides)!=null&&d.isSameYear?this.overrides.isSameYear(o,l):isSameYear(o,l)},this.max=o=>{var l;return(l=this.overrides)!=null&&l.max?this.overrides.max(o):max$1(o)},this.min=o=>{var l;return(l=this.overrides)!=null&&l.min?this.overrides.min(o):min$1(o)},this.setMonth=(o,l)=>{var d;return(d=this.overrides)!=null&&d.setMonth?this.overrides.setMonth(o,l):setMonth(o,l)},this.setYear=(o,l)=>{var d;return(d=this.overrides)!=null&&d.setYear?this.overrides.setYear(o,l):setYear(o,l)},this.startOfBroadcastWeek=(o,l)=>{var d;return(d=this.overrides)!=null&&d.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(o,this):startOfBroadcastWeek(o,this)},this.startOfDay=o=>{var l;return(l=this.overrides)!=null&&l.startOfDay?this.overrides.startOfDay(o):startOfDay(o)},this.startOfISOWeek=o=>{var l;return(l=this.overrides)!=null&&l.startOfISOWeek?this.overrides.startOfISOWeek(o):startOfISOWeek(o)},this.startOfMonth=o=>{var l;return(l=this.overrides)!=null&&l.startOfMonth?this.overrides.startOfMonth(o):startOfMonth(o)},this.startOfWeek=(o,l)=>{var d;return(d=this.overrides)!=null&&d.startOfWeek?this.overrides.startOfWeek(o,this.options):startOfWeek(o,this.options)},this.startOfYear=o=>{var l;return(l=this.overrides)!=null&&l.startOfYear?this.overrides.startOfYear(o):startOfYear(o)},this.options={locale:enUS,...t},this.overrides=n}getDigitMap(){const{numerals:t="latn"}=this.options,n=new Intl.NumberFormat("en-US",{numberingSystem:t}),o={};for(let l=0;l<10;l++)o[l.toString()]=n.format(l);return o}replaceDigits(t){const n=this.getDigitMap();return t.replace(/\d/g,o=>n[o]||o)}formatNumber(t){return this.replaceDigits(t.toString())}getMonthYearOrder(){var n;const t=(n=this.options.locale)==null?void 0:n.code;return t&&DateLib.yearFirstLocales.has(t)?"year-first":"month-first"}formatMonthYear(t){const{locale:n,timeZone:o,numerals:l}=this.options,d=n==null?void 0:n.code;if(d&&DateLib.yearFirstLocales.has(d))try{return new Intl.DateTimeFormat(d,{month:"long",year:"numeric",timeZone:o,numberingSystem:l}).format(t)}catch{}const f=this.getMonthYearOrder()==="year-first"?"y LLLL":"LLLL y";return this.format(t,f)}}DateLib.yearFirstLocales=new Set(["eu","hu","ja","ja-Hira","ja-JP","ko","ko-KR","lt","lt-LT","lv","lv-LV","mn","mn-MN","zh","zh-CN","zh-HK","zh-TW"]);const defaultDateLib=new DateLib;class CalendarDay{constructor(t,n,o=defaultDateLib){this.date=t,this.displayMonth=n,this.outside=!!(n&&!o.isSameMonth(t,n)),this.dateLib=o,this.isoDate=o.format(t,"yyyy-MM-dd"),this.displayMonthId=o.format(n,"yyyy-MM"),this.dateMonthId=o.format(t,"yyyy-MM")}isEqualTo(t){return this.dateLib.isSameDay(t.date,this.date)&&this.dateLib.isSameMonth(t.displayMonth,this.displayMonth)}}class CalendarMonth{constructor(t,n){this.date=t,this.weeks=n}}class CalendarWeek{constructor(t,n){this.days=n,this.weekNumber=t}}function Button(e){return React.createElement("button",{...e})}function CaptionLabel(e){return React.createElement("span",{...e})}function Chevron(e){const{size:t=24,orientation:n="left",className:o}=e;return React.createElement("svg",{className:o,width:t,height:t,viewBox:"0 0 24 24"},n==="up"&&React.createElement("polygon",{points:"6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28"}),n==="down"&&React.createElement("polygon",{points:"6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72"}),n==="left"&&React.createElement("polygon",{points:"16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20"}),n==="right"&&React.createElement("polygon",{points:"8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20"}))}function Day(e){const{day:t,modifiers:n,...o}=e;return React.createElement("td",{...o})}function DayButton(e){const{day:t,modifiers:n,...o}=e,l=React.useRef(null);return React.useEffect(()=>{var d;n.focused&&((d=l.current)==null||d.focus())},[n.focused]),React.createElement("button",{ref:l,...o})}var UI;(function(e){e.Root="root",e.Chevron="chevron",e.Day="day",e.DayButton="day_button",e.CaptionLabel="caption_label",e.Dropdowns="dropdowns",e.Dropdown="dropdown",e.DropdownRoot="dropdown_root",e.Footer="footer",e.MonthGrid="month_grid",e.MonthCaption="month_caption",e.MonthsDropdown="months_dropdown",e.Month="month",e.Months="months",e.Nav="nav",e.NextMonthButton="button_next",e.PreviousMonthButton="button_previous",e.Week="week",e.Weeks="weeks",e.Weekday="weekday",e.Weekdays="weekdays",e.WeekNumber="week_number",e.WeekNumberHeader="week_number_header",e.YearsDropdown="years_dropdown"})(UI||(UI={}));var DayFlag;(function(e){e.disabled="disabled",e.hidden="hidden",e.outside="outside",e.focused="focused",e.today="today"})(DayFlag||(DayFlag={}));var SelectionState;(function(e){e.range_end="range_end",e.range_middle="range_middle",e.range_start="range_start",e.selected="selected"})(SelectionState||(SelectionState={}));var Animation;(function(e){e.weeks_before_enter="weeks_before_enter",e.weeks_before_exit="weeks_before_exit",e.weeks_after_enter="weeks_after_enter",e.weeks_after_exit="weeks_after_exit",e.caption_after_enter="caption_after_enter",e.caption_after_exit="caption_after_exit",e.caption_before_enter="caption_before_enter",e.caption_before_exit="caption_before_exit"})(Animation||(Animation={}));function Dropdown(e){const{options:t,className:n,components:o,classNames:l,...d}=e,f=[l[UI.Dropdown],n].join(" "),g=t==null?void 0:t.find(({value:b})=>b===d.value);return React.createElement("span",{"data-disabled":d.disabled,className:l[UI.DropdownRoot]},React.createElement(o.Select,{className:f,...d},t==null?void 0:t.map(({value:b,label:_,disabled:S})=>React.createElement(o.Option,{key:b,value:b,disabled:S},_))),React.createElement("span",{className:l[UI.CaptionLabel],"aria-hidden":!0},g==null?void 0:g.label,React.createElement(o.Chevron,{orientation:"down",size:18,className:l[UI.Chevron]})))}function DropdownNav(e){return React.createElement("div",{...e})}function Footer(e){return React.createElement("div",{...e})}function Month(e){const{calendarMonth:t,displayIndex:n,...o}=e;return React.createElement("div",{...o},e.children)}function MonthCaption(e){const{calendarMonth:t,displayIndex:n,...o}=e;return React.createElement("div",{...o})}function MonthGrid(e){return React.createElement("table",{...e})}function Months(e){return React.createElement("div",{...e})}const dayPickerContext=React.createContext(void 0);function useDayPicker(){const e=React.useContext(dayPickerContext);if(e===void 0)throw new Error("useDayPicker() must be used within a custom component.");return e}function MonthsDropdown(e){const{components:t}=useDayPicker();return React.createElement(t.Dropdown,{...e})}function Nav(e){const{onPreviousClick:t,onNextClick:n,previousMonth:o,nextMonth:l,...d}=e,{components:f,classNames:g,labels:{labelPrevious:b,labelNext:_}}=useDayPicker(),S=React.useCallback(C=>{l&&(n==null||n(C))},[l,n]),R=React.useCallback(C=>{o&&(t==null||t(C))},[o,t]);return React.createElement("nav",{...d},React.createElement(f.PreviousMonthButton,{type:"button",className:g[UI.PreviousMonthButton],tabIndex:o?void 0:-1,"aria-disabled":o?void 0:!0,"aria-label":b(o),onClick:R},React.createElement(f.Chevron,{disabled:o?void 0:!0,className:g[UI.Chevron],orientation:"left"})),React.createElement(f.NextMonthButton,{type:"button",className:g[UI.NextMonthButton],tabIndex:l?void 0:-1,"aria-disabled":l?void 0:!0,"aria-label":_(l),onClick:S},React.createElement(f.Chevron,{disabled:l?void 0:!0,orientation:"right",className:g[UI.Chevron]})))}function NextMonthButton(e){const{components:t}=useDayPicker();return React.createElement(t.Button,{...e})}function Option(e){return React.createElement("option",{...e})}function PreviousMonthButton(e){const{components:t}=useDayPicker();return React.createElement(t.Button,{...e})}function Root(e){const{rootRef:t,...n}=e;return React.createElement("div",{...n,ref:t})}function Select(e){return React.createElement("select",{...e})}function Week(e){const{week:t,...n}=e;return React.createElement("tr",{...n})}function Weekday(e){return React.createElement("th",{...e})}function Weekdays(e){return React.createElement("thead",{"aria-hidden":!0},React.createElement("tr",{...e}))}function WeekNumber(e){const{week:t,...n}=e;return React.createElement("th",{...n})}function WeekNumberHeader(e){return React.createElement("th",{...e})}function Weeks(e){return React.createElement("tbody",{...e})}function YearsDropdown(e){const{components:t}=useDayPicker();return React.createElement(t.Dropdown,{...e})}const components=Object.freeze(Object.defineProperty({__proto__:null,Button,CaptionLabel,Chevron,Day,DayButton,Dropdown,DropdownNav,Footer,Month,MonthCaption,MonthGrid,Months,MonthsDropdown,Nav,NextMonthButton,Option,PreviousMonthButton,Root,Select,Week,WeekNumber,WeekNumberHeader,Weekday,Weekdays,Weeks,YearsDropdown},Symbol.toStringTag,{value:"Module"}));function rangeIncludesDate(e,t,n=!1,o=defaultDateLib){let{from:l,to:d}=e;const{differenceInCalendarDays:f,isSameDay:g}=o;return l&&d?(f(d,l)<0&&([l,d]=[d,l]),f(t,l)>=(n?1:0)&&f(d,t)>=(n?1:0)):!n&&d?g(d,t):!n&&l?g(l,t):!1}function isDateInterval(e){return!!(e&&typeof e=="object"&&"before"in e&&"after"in e)}function isDateRange(e){return!!(e&&typeof e=="object"&&"from"in e)}function isDateAfterType(e){return!!(e&&typeof e=="object"&&"after"in e)}function isDateBeforeType(e){return!!(e&&typeof e=="object"&&"before"in e)}function isDayOfWeekType(e){return!!(e&&typeof e=="object"&&"dayOfWeek"in e)}function isDatesArray(e,t){return Array.isArray(e)&&e.every(t.isDate)}function dateMatchModifiers(e,t,n=defaultDateLib){const o=Array.isArray(t)?t:[t],{isSameDay:l,differenceInCalendarDays:d,isAfter:f}=n;return o.some(g=>{if(typeof g=="boolean")return g;if(n.isDate(g))return l(e,g);if(isDatesArray(g,n))return g.includes(e);if(isDateRange(g))return rangeIncludesDate(g,e,!1,n);if(isDayOfWeekType(g))return Array.isArray(g.dayOfWeek)?g.dayOfWeek.includes(e.getDay()):g.dayOfWeek===e.getDay();if(isDateInterval(g)){const b=d(g.before,e),_=d(g.after,e),S=b>0,R=_<0;return f(g.before,g.after)?R&&S:S||R}return isDateAfterType(g)?d(e,g.after)>0:isDateBeforeType(g)?d(g.before,e)>0:typeof g=="function"?g(e):!1})}function createGetModifiers(e,t,n,o,l){const{disabled:d,hidden:f,modifiers:g,showOutsideDays:b,broadcastCalendar:_,today:S=l.today()}=t,{isSameDay:R,isSameMonth:C,startOfMonth:E,isBefore:A,endOfMonth:M,isAfter:I}=l,j=n&&E(n),q=o&&M(o),Q={[DayFlag.focused]:[],[DayFlag.outside]:[],[DayFlag.disabled]:[],[DayFlag.hidden]:[],[DayFlag.today]:[]},te={};for(const F of e){const{date:V,displayMonth:ne}=F,ae=!!(ne&&!C(V,ne)),se=!!(j&&A(V,j)),Oe=!!(q&&I(V,q)),Ne=!!(d&&dateMatchModifiers(V,d,l)),oe=!!(f&&dateMatchModifiers(V,f,l))||se||Oe||!_&&!b&&ae||_&&b===!1&&ae,$e=R(V,S);ae&&Q.outside.push(F),Ne&&Q.disabled.push(F),oe&&Q.hidden.push(F),$e&&Q.today.push(F),g&&Object.keys(g).forEach(Ae=>{const je=g==null?void 0:g[Ae];je&&dateMatchModifiers(V,je,l)&&(te[Ae]?te[Ae].push(F):te[Ae]=[F])})}return F=>{const V={[DayFlag.focused]:!1,[DayFlag.disabled]:!1,[DayFlag.hidden]:!1,[DayFlag.outside]:!1,[DayFlag.today]:!1},ne={};for(const ae in Q){const se=Q[ae];V[ae]=se.some(Oe=>Oe===F)}for(const ae in te)ne[ae]=te[ae].some(se=>se===F);return{...V,...ne}}}function getClassNamesForModifiers(e,t,n={}){return Object.entries(e).filter(([,l])=>l===!0).reduce((l,[d])=>(n[d]?l.push(n[d]):t[DayFlag[d]]?l.push(t[DayFlag[d]]):t[SelectionState[d]]&&l.push(t[SelectionState[d]]),l),[t[UI.Day]])}function getComponents(e){return{...components,...e}}function getDataAttributes(e){const t={"data-mode":e.mode??void 0,"data-required":"required"in e?e.required:void 0,"data-multiple-months":e.numberOfMonths&&e.numberOfMonths>1||void 0,"data-week-numbers":e.showWeekNumber||void 0,"data-broadcast-calendar":e.broadcastCalendar||void 0,"data-nav-layout":e.navLayout||void 0};return Object.entries(e).forEach(([n,o])=>{n.startsWith("data-")&&(t[n]=o)}),t}function getDefaultClassNames(){const e={};for(const t in UI)e[UI[t]]=`rdp-${UI[t]}`;for(const t in DayFlag)e[DayFlag[t]]=`rdp-${DayFlag[t]}`;for(const t in SelectionState)e[SelectionState[t]]=`rdp-${SelectionState[t]}`;for(const t in Animation)e[Animation[t]]=`rdp-${Animation[t]}`;return e}function formatCaption(e,t,n){return(n??new DateLib(t)).formatMonthYear(e)}const formatMonthCaption=formatCaption;function formatDay(e,t,n){return(n??new DateLib(t)).format(e,"d")}function formatMonthDropdown(e,t=defaultDateLib){return t.format(e,"LLLL")}function formatWeekdayName(e,t,n){return(n??new DateLib(t)).format(e,"cccccc")}function formatWeekNumber(e,t=defaultDateLib){return e<10?t.formatNumber(`0${e.toLocaleString()}`):t.formatNumber(`${e.toLocaleString()}`)}function formatWeekNumberHeader(){return""}function formatYearDropdown(e,t=defaultDateLib){return t.format(e,"yyyy")}const formatYearCaption=formatYearDropdown,defaultFormatters=Object.freeze(Object.defineProperty({__proto__:null,formatCaption,formatDay,formatMonthCaption,formatMonthDropdown,formatWeekNumber,formatWeekNumberHeader,formatWeekdayName,formatYearCaption,formatYearDropdown},Symbol.toStringTag,{value:"Module"}));function getFormatters(e){return e!=null&&e.formatMonthCaption&&!e.formatCaption&&(e.formatCaption=e.formatMonthCaption),e!=null&&e.formatYearCaption&&!e.formatYearDropdown&&(e.formatYearDropdown=e.formatYearCaption),{...defaultFormatters,...e}}function getMonthOptions(e,t,n,o,l){const{startOfMonth:d,startOfYear:f,endOfYear:g,eachMonthOfInterval:b,getMonth:_}=l;return b({start:f(e),end:g(e)}).map(C=>{const E=o.formatMonthDropdown(C,l),A=_(C),M=t&&C<d(t)||n&&C>d(n)||!1;return{value:A,label:E,disabled:M}})}function getStyleForModifiers(e,t={},n={}){let o={...t==null?void 0:t[UI.Day]};return Object.entries(e).filter(([,l])=>l===!0).forEach(([l])=>{o={...o,...n==null?void 0:n[l]}}),o}function getWeekdays(e,t,n,o){const l=o??e.today(),d=n?e.startOfBroadcastWeek(l,e):t?e.startOfISOWeek(l):e.startOfWeek(l),f=[];for(let g=0;g<7;g++){const b=e.addDays(d,g);f.push(b)}return f}function getYearOptions(e,t,n,o,l=!1){if(!e||!t)return;const{startOfYear:d,endOfYear:f,eachYearOfInterval:g,getYear:b}=o,_=d(e),S=f(t),R=g({start:_,end:S});return l&&R.reverse(),R.map(C=>{const E=n.formatYearDropdown(C,o);return{value:b(C),label:E,disabled:!1}})}function labelDayButton(e,t,n,o){let l=(o??new DateLib(n)).format(e,"PPPP");return t.today&&(l=`Today, ${l}`),t.selected&&(l=`${l}, selected`),l}const labelDay=labelDayButton;function labelGrid(e,t,n){return(n??new DateLib(t)).formatMonthYear(e)}const labelCaption=labelGrid;function labelGridcell(e,t,n,o){let l=(o??new DateLib(n)).format(e,"PPPP");return t!=null&&t.today&&(l=`Today, ${l}`),l}function labelMonthDropdown(e){return"Choose the Month"}function labelNav(){return""}function labelNext(e){return"Go to the Next Month"}function labelPrevious(e){return"Go to the Previous Month"}function labelWeekday(e,t,n){return(n??new DateLib(t)).format(e,"cccc")}function labelWeekNumber(e,t){return`Week ${e}`}function labelWeekNumberHeader(e){return"Week Number"}function labelYearDropdown(e){return"Choose the Year"}const defaultLabels=Object.freeze(Object.defineProperty({__proto__:null,labelCaption,labelDay,labelDayButton,labelGrid,labelGridcell,labelMonthDropdown,labelNav,labelNext,labelPrevious,labelWeekNumber,labelWeekNumberHeader,labelWeekday,labelYearDropdown},Symbol.toStringTag,{value:"Module"})),asHtmlElement=e=>e instanceof HTMLElement?e:null,queryMonthEls=e=>[...e.querySelectorAll("[data-animated-month]")??[]],queryMonthEl=e=>asHtmlElement(e.querySelector("[data-animated-month]")),queryCaptionEl=e=>asHtmlElement(e.querySelector("[data-animated-caption]")),queryWeeksEl=e=>asHtmlElement(e.querySelector("[data-animated-weeks]")),queryNavEl=e=>asHtmlElement(e.querySelector("[data-animated-nav]")),queryWeekdaysEl=e=>asHtmlElement(e.querySelector("[data-animated-weekdays]"));function useAnimation(e,t,{classNames:n,months:o,focused:l,dateLib:d}){const f=React.useRef(null),g=React.useRef(o),b=React.useRef(!1);React.useLayoutEffect(()=>{const _=g.current;if(g.current=o,!t||!e.current||!(e.current instanceof HTMLElement)||o.length===0||_.length===0||o.length!==_.length)return;const S=d.isSameMonth(o[0].date,_[0].date),R=d.isAfter(o[0].date,_[0].date),C=R?n[Animation.caption_after_enter]:n[Animation.caption_before_enter],E=R?n[Animation.weeks_after_enter]:n[Animation.weeks_before_enter],A=f.current,M=e.current.cloneNode(!0);if(M instanceof HTMLElement?(queryMonthEls(M).forEach(Q=>{if(!(Q instanceof HTMLElement))return;const te=queryMonthEl(Q);te&&Q.contains(te)&&Q.removeChild(te);const F=queryCaptionEl(Q);F&&F.classList.remove(C);const V=queryWeeksEl(Q);V&&V.classList.remove(E)}),f.current=M):f.current=null,b.current||S||l)return;const I=A instanceof HTMLElement?queryMonthEls(A):[],j=queryMonthEls(e.current);if(j!=null&&j.every(q=>q instanceof HTMLElement)&&I&&I.every(q=>q instanceof HTMLElement)){b.current=!0,e.current.style.isolation="isolate";const q=queryNavEl(e.current);q&&(q.style.zIndex="1"),j.forEach((Q,te)=>{const F=I[te];if(!F)return;Q.style.position="relative",Q.style.overflow="hidden";const V=queryCaptionEl(Q);V&&V.classList.add(C);const ne=queryWeeksEl(Q);ne&&ne.classList.add(E);const ae=()=>{b.current=!1,e.current&&(e.current.style.isolation=""),q&&(q.style.zIndex=""),V&&V.classList.remove(C),ne&&ne.classList.remove(E),Q.style.position="",Q.style.overflow="",Q.contains(F)&&Q.removeChild(F)};F.style.pointerEvents="none",F.style.position="absolute",F.style.overflow="hidden",F.setAttribute("aria-hidden","true");const se=queryWeekdaysEl(F);se&&(se.style.opacity="0");const Oe=queryCaptionEl(F);Oe&&(Oe.classList.add(R?n[Animation.caption_before_exit]:n[Animation.caption_after_exit]),Oe.addEventListener("animationend",ae));const Ne=queryWeeksEl(F);Ne&&Ne.classList.add(R?n[Animation.weeks_before_exit]:n[Animation.weeks_after_exit]),Q.insertBefore(F,Q.firstChild)})}})}function getDates(e,t,n,o){const l=e[0],d=e[e.length-1],{ISOWeek:f,fixedWeeks:g,broadcastCalendar:b}=n??{},{addDays:_,differenceInCalendarDays:S,differenceInCalendarMonths:R,endOfBroadcastWeek:C,endOfISOWeek:E,endOfMonth:A,endOfWeek:M,isAfter:I,startOfBroadcastWeek:j,startOfISOWeek:q,startOfWeek:Q}=o,te=b?j(l,o):f?q(l):Q(l),F=b?C(d):f?E(A(d)):M(A(d)),V=t&&(b?C(t):f?E(t):M(t)),ne=V&&I(F,V)?V:F,ae=S(ne,te),se=R(d,l)+1,Oe=[];for(let $e=0;$e<=ae;$e++){const Ae=_(te,$e);Oe.push(Ae)}const oe=(b?35:42)*se;if(g&&Oe.length<oe){const $e=oe-Oe.length;for(let Ae=0;Ae<$e;Ae++){const je=_(Oe[Oe.length-1],1);Oe.push(je)}}return Oe}function getDays(e){const t=[];return e.reduce((n,o)=>{const l=o.weeks.reduce((d,f)=>d.concat(f.days.slice()),t.slice());return n.concat(l.slice())},t.slice())}function getDisplayMonths(e,t,n,o){const{numberOfMonths:l=1}=n,d=[];for(let f=0;f<l;f++){const g=o.addMonths(e,f);if(t&&g>t)break;d.push(g)}return d}function getInitialMonth(e,t,n,o){const{month:l,defaultMonth:d,today:f=o.today(),numberOfMonths:g=1}=e;let b=l||d||f;const{differenceInCalendarMonths:_,addMonths:S,startOfMonth:R}=o;if(n&&_(n,b)<g-1){const C=-1*(g-1);b=S(n,C)}return t&&_(b,t)<0&&(b=t),R(b)}function getMonths(e,t,n,o){const{addDays:l,endOfBroadcastWeek:d,endOfISOWeek:f,endOfMonth:g,endOfWeek:b,getISOWeek:_,getWeek:S,startOfBroadcastWeek:R,startOfISOWeek:C,startOfWeek:E}=o,A=e.reduce((M,I)=>{const j=n.broadcastCalendar?R(I,o):n.ISOWeek?C(I):E(I),q=n.broadcastCalendar?d(I):n.ISOWeek?f(g(I)):b(g(I)),Q=t.filter(ne=>ne>=j&&ne<=q),te=n.broadcastCalendar?35:42;if(n.fixedWeeks&&Q.length<te){const ne=t.filter(ae=>{const se=te-Q.length;return ae>q&&ae<=l(q,se)});Q.push(...ne)}const F=Q.reduce((ne,ae)=>{const se=n.ISOWeek?_(ae):S(ae),Oe=ne.find(oe=>oe.weekNumber===se),Ne=new CalendarDay(ae,I,o);return Oe?Oe.days.push(Ne):ne.push(new CalendarWeek(se,[Ne])),ne},[]),V=new CalendarMonth(I,F);return M.push(V),M},[]);return n.reverseMonths?A.reverse():A}function getNavMonths(e,t){let{startMonth:n,endMonth:o}=e;const{startOfYear:l,startOfDay:d,startOfMonth:f,endOfMonth:g,addYears:b,endOfYear:_,newDate:S,today:R}=t,{fromYear:C,toYear:E,fromMonth:A,toMonth:M}=e;!n&&A&&(n=A),!n&&C&&(n=t.newDate(C,0,1)),!o&&M&&(o=M),!o&&E&&(o=S(E,11,31));const I=e.captionLayout==="dropdown"||e.captionLayout==="dropdown-years";return n?n=f(n):C?n=S(C,0,1):!n&&I&&(n=l(b(e.today??R(),-100))),o?o=g(o):E?o=S(E,11,31):!o&&I&&(o=_(e.today??R())),[n&&d(n),o&&d(o)]}function getNextMonth(e,t,n,o){if(n.disableNavigation)return;const{pagedNavigation:l,numberOfMonths:d=1}=n,{startOfMonth:f,addMonths:g,differenceInCalendarMonths:b}=o,_=l?d:1,S=f(e);if(!t)return g(S,_);if(!(b(t,e)<d))return g(S,_)}function getPreviousMonth(e,t,n,o){if(n.disableNavigation)return;const{pagedNavigation:l,numberOfMonths:d}=n,{startOfMonth:f,addMonths:g,differenceInCalendarMonths:b}=o,_=l?d??1:1,S=f(e);if(!t)return g(S,-_);if(!(b(S,t)<=0))return g(S,-_)}function getWeeks(e){const t=[];return e.reduce((n,o)=>n.concat(o.weeks.slice()),t.slice())}function useControlledValue(e,t){const[n,o]=React.useState(e);return[t===void 0?n:t,o]}function useCalendar(e,t){var te;const[n,o]=getNavMonths(e,t),{startOfMonth:l,endOfMonth:d}=t,f=getInitialMonth(e,n,o,t),[g,b]=useControlledValue(f,e.month?f:void 0);React.useEffect(()=>{const F=getInitialMonth(e,n,o,t);b(F)},[e.timeZone]);const{months:_,weeks:S,days:R,previousMonth:C,nextMonth:E}=React.useMemo(()=>{const F=getDisplayMonths(g,o,{numberOfMonths:e.numberOfMonths},t),V=getDates(F,e.endMonth?d(e.endMonth):void 0,{ISOWeek:e.ISOWeek,fixedWeeks:e.fixedWeeks,broadcastCalendar:e.broadcastCalendar},t),ne=getMonths(F,V,{broadcastCalendar:e.broadcastCalendar,fixedWeeks:e.fixedWeeks,ISOWeek:e.ISOWeek,reverseMonths:e.reverseMonths},t),ae=getWeeks(ne),se=getDays(ne),Oe=getPreviousMonth(g,n,e,t),Ne=getNextMonth(g,o,e,t);return{months:ne,weeks:ae,days:se,previousMonth:Oe,nextMonth:Ne}},[t,g.getTime(),o==null?void 0:o.getTime(),n==null?void 0:n.getTime(),e.disableNavigation,e.broadcastCalendar,(te=e.endMonth)==null?void 0:te.getTime(),e.fixedWeeks,e.ISOWeek,e.numberOfMonths,e.pagedNavigation,e.reverseMonths]),{disableNavigation:A,onMonthChange:M}=e,I=F=>S.some(V=>V.days.some(ne=>ne.isEqualTo(F))),j=F=>{if(A)return;let V=l(F);n&&V<l(n)&&(V=l(n)),o&&V>l(o)&&(V=l(o)),b(V),M==null||M(V)};return{months:_,weeks:S,days:R,navStart:n,navEnd:o,previousMonth:C,nextMonth:E,goToMonth:j,goToDay:F=>{I(F)||j(F.date)}}}var FocusTargetPriority;(function(e){e[e.Today=0]="Today",e[e.Selected=1]="Selected",e[e.LastFocused=2]="LastFocused",e[e.FocusedModifier=3]="FocusedModifier"})(FocusTargetPriority||(FocusTargetPriority={}));function isFocusableDay(e){return!e[DayFlag.disabled]&&!e[DayFlag.hidden]&&!e[DayFlag.outside]}function calculateFocusTarget(e,t,n,o){let l,d=-1;for(const f of e){const g=t(f);isFocusableDay(g)&&(g[DayFlag.focused]&&d<FocusTargetPriority.FocusedModifier?(l=f,d=FocusTargetPriority.FocusedModifier):o!=null&&o.isEqualTo(f)&&d<FocusTargetPriority.LastFocused?(l=f,d=FocusTargetPriority.LastFocused):n(f.date)&&d<FocusTargetPriority.Selected?(l=f,d=FocusTargetPriority.Selected):g[DayFlag.today]&&d<FocusTargetPriority.Today&&(l=f,d=FocusTargetPriority.Today))}return l||(l=e.find(f=>isFocusableDay(t(f)))),l}function getFocusableDate(e,t,n,o,l,d,f){const{ISOWeek:g,broadcastCalendar:b}=d,{addDays:_,addMonths:S,addWeeks:R,addYears:C,endOfBroadcastWeek:E,endOfISOWeek:A,endOfWeek:M,max:I,min:j,startOfBroadcastWeek:q,startOfISOWeek:Q,startOfWeek:te}=f;let V={day:_,week:R,month:S,year:C,startOfWeek:ne=>b?q(ne,f):g?Q(ne):te(ne),endOfWeek:ne=>b?E(ne):g?A(ne):M(ne)}[e](n,t==="after"?1:-1);return t==="before"&&o?V=I([o,V]):t==="after"&&l&&(V=j([l,V])),V}function getNextFocus(e,t,n,o,l,d,f,g=0){if(g>365)return;const b=getFocusableDate(e,t,n.date,o,l,d,f),_=!!(d.disabled&&dateMatchModifiers(b,d.disabled,f)),S=!!(d.hidden&&dateMatchModifiers(b,d.hidden,f)),R=b,C=new CalendarDay(b,R,f);return!_&&!S?C:getNextFocus(e,t,C,o,l,d,f,g+1)}function useFocus(e,t,n,o,l){const{autoFocus:d}=e,[f,g]=React.useState(),b=calculateFocusTarget(t.days,n,o||(()=>!1),f),[_,S]=React.useState(d?b:void 0);return{isFocusTarget:M=>!!(b!=null&&b.isEqualTo(M)),setFocused:S,focused:_,blur:()=>{g(_),S(void 0)},moveFocus:(M,I)=>{if(!_)return;const j=getNextFocus(M,I,_,t.navStart,t.navEnd,e,l);j&&(e.disableNavigation&&!t.days.some(Q=>Q.isEqualTo(j))||(t.goToDay(j),S(j)))}}}function useMulti(e,t){const{selected:n,required:o,onSelect:l}=e,[d,f]=useControlledValue(n,l?n:void 0),g=l?n:d,{isSameDay:b}=t,_=E=>(g==null?void 0:g.some(A=>b(A,E)))??!1,{min:S,max:R}=e;return{selected:g,select:(E,A,M)=>{let I=[...g??[]];if(_(E)){if((g==null?void 0:g.length)===S||o&&(g==null?void 0:g.length)===1)return;I=g==null?void 0:g.filter(j=>!b(j,E))}else(g==null?void 0:g.length)===R?I=[E]:I=[...I,E];return l||f(I),l==null||l(I,E,A,M),I},isSelected:_}}function addToRange(e,t,n=0,o=0,l=!1,d=defaultDateLib){const{from:f,to:g}=t||{},{isSameDay:b,isAfter:_,isBefore:S}=d;let R;if(!f&&!g)R={from:e,to:n>0?void 0:e};else if(f&&!g)b(f,e)?n===0?R={from:f,to:e}:l?R={from:f,to:void 0}:R=void 0:S(e,f)?R={from:e,to:f}:R={from:f,to:e};else if(f&&g)if(b(f,e)&&b(g,e))l?R={from:f,to:g}:R=void 0;else if(b(f,e))R={from:f,to:n>0?void 0:e};else if(b(g,e))R={from:e,to:n>0?void 0:e};else if(S(e,f))R={from:e,to:g};else if(_(e,f))R={from:f,to:e};else if(_(e,g))R={from:f,to:e};else throw new Error("Invalid range");if(R!=null&&R.from&&(R!=null&&R.to)){const C=d.differenceInCalendarDays(R.to,R.from);o>0&&C>o?R={from:e,to:void 0}:n>1&&C<n&&(R={from:e,to:void 0})}return R}function rangeContainsDayOfWeek(e,t,n=defaultDateLib){const o=Array.isArray(t)?t:[t];let l=e.from;const d=n.differenceInCalendarDays(e.to,e.from),f=Math.min(d,6);for(let g=0;g<=f;g++){if(o.includes(l.getDay()))return!0;l=n.addDays(l,1)}return!1}function rangeOverlaps(e,t,n=defaultDateLib){return rangeIncludesDate(e,t.from,!1,n)||rangeIncludesDate(e,t.to,!1,n)||rangeIncludesDate(t,e.from,!1,n)||rangeIncludesDate(t,e.to,!1,n)}function rangeContainsModifiers(e,t,n=defaultDateLib){const o=Array.isArray(t)?t:[t];if(o.filter(g=>typeof g!="function").some(g=>typeof g=="boolean"?g:n.isDate(g)?rangeIncludesDate(e,g,!1,n):isDatesArray(g,n)?g.some(b=>rangeIncludesDate(e,b,!1,n)):isDateRange(g)?g.from&&g.to?rangeOverlaps(e,{from:g.from,to:g.to},n):!1:isDayOfWeekType(g)?rangeContainsDayOfWeek(e,g.dayOfWeek,n):isDateInterval(g)?n.isAfter(g.before,g.after)?rangeOverlaps(e,{from:n.addDays(g.after,1),to:n.addDays(g.before,-1)},n):dateMatchModifiers(e.from,g,n)||dateMatchModifiers(e.to,g,n):isDateAfterType(g)||isDateBeforeType(g)?dateMatchModifiers(e.from,g,n)||dateMatchModifiers(e.to,g,n):!1))return!0;const f=o.filter(g=>typeof g=="function");if(f.length){let g=e.from;const b=n.differenceInCalendarDays(e.to,e.from);for(let _=0;_<=b;_++){if(f.some(S=>S(g)))return!0;g=n.addDays(g,1)}}return!1}function useRange(e,t){const{disabled:n,excludeDisabled:o,selected:l,required:d,onSelect:f}=e,[g,b]=useControlledValue(l,f?l:void 0),_=f?l:g;return{selected:_,select:(C,E,A)=>{const{min:M,max:I}=e,j=C?addToRange(C,_,M,I,d,t):void 0;return o&&n&&(j!=null&&j.from)&&j.to&&rangeContainsModifiers({from:j.from,to:j.to},n,t)&&(j.from=C,j.to=void 0),f||b(j),f==null||f(j,C,E,A),j},isSelected:C=>_&&rangeIncludesDate(_,C,!1,t)}}function useSingle(e,t){const{selected:n,required:o,onSelect:l}=e,[d,f]=useControlledValue(n,l?n:void 0),g=l?n:d,{isSameDay:b}=t;return{selected:g,select:(R,C,E)=>{let A=R;return!o&&g&&g&&b(R,g)&&(A=void 0),l||f(A),l==null||l(A,R,C,E),A},isSelected:R=>g?b(g,R):!1}}function useSelection(e,t){const n=useSingle(e,t),o=useMulti(e,t),l=useRange(e,t);switch(e.mode){case"single":return n;case"multiple":return o;case"range":return l;default:return}}function toTimeZone(e,t){return e instanceof TZDate&&e.timeZone===t?e:new TZDate(e,t)}function convertMatcher(e,t){return typeof e=="boolean"||typeof e=="function"?e:e instanceof Date?toTimeZone(e,t):Array.isArray(e)?e.map(n=>n instanceof Date?toTimeZone(n,t):n):isDateRange(e)?{...e,from:e.from?toTimeZone(e.from,t):e.from,to:e.to?toTimeZone(e.to,t):e.to}:isDateInterval(e)?{before:toTimeZone(e.before,t),after:toTimeZone(e.after,t)}:isDateAfterType(e)?{after:toTimeZone(e.after,t)}:isDateBeforeType(e)?{before:toTimeZone(e.before,t)}:e}function convertMatchersToTimeZone(e,t){return e&&(Array.isArray(e)?e.map(n=>convertMatcher(n,t)):convertMatcher(e,t))}function DayPicker(e){var Vn;let t=e;const n=t.timeZone;if(n&&(t={...e,timeZone:n},t.today&&(t.today=toTimeZone(t.today,n)),t.month&&(t.month=toTimeZone(t.month,n)),t.defaultMonth&&(t.defaultMonth=toTimeZone(t.defaultMonth,n)),t.startMonth&&(t.startMonth=toTimeZone(t.startMonth,n)),t.endMonth&&(t.endMonth=toTimeZone(t.endMonth,n)),t.mode==="single"&&t.selected?t.selected=toTimeZone(t.selected,n):t.mode==="multiple"&&t.selected?t.selected=(Vn=t.selected)==null?void 0:Vn.map(Jt=>toTimeZone(Jt,n)):t.mode==="range"&&t.selected&&(t.selected={from:t.selected.from?toTimeZone(t.selected.from,n):t.selected.from,to:t.selected.to?toTimeZone(t.selected.to,n):t.selected.to}),t.disabled!==void 0&&(t.disabled=convertMatchersToTimeZone(t.disabled,n)),t.hidden!==void 0&&(t.hidden=convertMatchersToTimeZone(t.hidden,n)),t.modifiers)){const Jt={};Object.keys(t.modifiers).forEach(Qt=>{var Ut;Jt[Qt]=convertMatchersToTimeZone((Ut=t.modifiers)==null?void 0:Ut[Qt],n)}),t.modifiers=Jt}const{components:o,formatters:l,labels:d,dateLib:f,locale:g,classNames:b}=React.useMemo(()=>{const Jt={...enUS,...t.locale};return{dateLib:new DateLib({locale:Jt,weekStartsOn:t.broadcastCalendar?1:t.weekStartsOn,firstWeekContainsDate:t.firstWeekContainsDate,useAdditionalWeekYearTokens:t.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:t.useAdditionalDayOfYearTokens,timeZone:t.timeZone,numerals:t.numerals},t.dateLib),components:getComponents(t.components),formatters:getFormatters(t.formatters),labels:{...defaultLabels,...t.labels},locale:Jt,classNames:{...getDefaultClassNames(),...t.classNames}}},[t.locale,t.broadcastCalendar,t.weekStartsOn,t.firstWeekContainsDate,t.useAdditionalWeekYearTokens,t.useAdditionalDayOfYearTokens,t.timeZone,t.numerals,t.dateLib,t.components,t.formatters,t.labels,t.classNames]);t.today||(t={...t,today:f.today()});const{captionLayout:_,mode:S,navLayout:R,numberOfMonths:C=1,onDayBlur:E,onDayClick:A,onDayFocus:M,onDayKeyDown:I,onDayMouseEnter:j,onDayMouseLeave:q,onNextClick:Q,onPrevClick:te,showWeekNumber:F,styles:V}=t,{formatCaption:ne,formatDay:ae,formatMonthDropdown:se,formatWeekNumber:Oe,formatWeekNumberHeader:Ne,formatWeekdayName:oe,formatYearDropdown:$e}=l,Ae=useCalendar(t,f),{days:je,months:Be,navStart:qe,navEnd:Ve,previousMonth:Le,nextMonth:He,goToMonth:We}=Ae,ze=createGetModifiers(je,t,qe,Ve,f),{isSelected:Xe,select:nt,selected:Je}=useSelection(t,f)??{},{blur:st,focused:et,isFocusTarget:at,moveFocus:tt,setFocused:ot}=useFocus(t,Ae,ze,Xe??(()=>!1),f),{labelDayButton:lt,labelGridcell:Ge,labelGrid:$t,labelMonthDropdown:rt,labelNav:Rt,labelPrevious:dt,labelNext:It,labelWeekday:Mt,labelWeekNumber:Ct,labelWeekNumberHeader:Ke,labelYearDropdown:Ye}=d,Ze=React.useMemo(()=>getWeekdays(f,t.ISOWeek,t.broadcastCalendar,t.today),[f,t.ISOWeek,t.broadcastCalendar,t.today]),ct=S!==void 0||A!==void 0,mt=React.useCallback(()=>{Le&&(We(Le),te==null||te(Le))},[Le,We,te]),ft=React.useCallback(()=>{He&&(We(He),Q==null||Q(He))},[We,He,Q]),yt=React.useCallback((Jt,Qt)=>Ut=>{Ut.preventDefault(),Ut.stopPropagation(),ot(Jt),!Qt.disabled&&(nt==null||nt(Jt.date,Qt,Ut),A==null||A(Jt.date,Qt,Ut))},[nt,A,ot]),Ht=React.useCallback((Jt,Qt)=>Ut=>{ot(Jt),M==null||M(Jt.date,Qt,Ut)},[M,ot]),Kt=React.useCallback((Jt,Qt)=>Ut=>{st(),E==null||E(Jt.date,Qt,Ut)},[st,E]),un=React.useCallback((Jt,Qt)=>Ut=>{const tn={ArrowLeft:[Ut.shiftKey?"month":"day",t.dir==="rtl"?"after":"before"],ArrowRight:[Ut.shiftKey?"month":"day",t.dir==="rtl"?"before":"after"],ArrowDown:[Ut.shiftKey?"year":"week","after"],ArrowUp:[Ut.shiftKey?"year":"week","before"],PageUp:[Ut.shiftKey?"year":"month","before"],PageDown:[Ut.shiftKey?"year":"month","after"],Home:["startOfWeek","before"],End:["endOfWeek","after"]};if(tn[Ut.key]){Ut.preventDefault(),Ut.stopPropagation();const[Yt,an]=tn[Ut.key];tt(Yt,an)}I==null||I(Jt.date,Qt,Ut)},[tt,I,t.dir]),hn=React.useCallback((Jt,Qt)=>Ut=>{j==null||j(Jt.date,Qt,Ut)},[j]),qt=React.useCallback((Jt,Qt)=>Ut=>{q==null||q(Jt.date,Qt,Ut)},[q]),An=React.useCallback(Jt=>Qt=>{const Ut=Number(Qt.target.value),tn=f.setMonth(f.startOfMonth(Jt),Ut);We(tn)},[f,We]),xn=React.useCallback(Jt=>Qt=>{const Ut=Number(Qt.target.value),tn=f.setYear(f.startOfMonth(Jt),Ut);We(tn)},[f,We]),{className:Rn,style:vn}=React.useMemo(()=>({className:[b[UI.Root],t.className].filter(Boolean).join(" "),style:{...V==null?void 0:V[UI.Root],...t.style}}),[b,t.className,t.style,V]),Pn=getDataAttributes(t),Mn=React.useRef(null);useAnimation(Mn,!!t.animate,{classNames:b,months:Be,focused:et,dateLib:f});const $n={dayPickerProps:t,selected:Je,select:nt,isSelected:Xe,months:Be,nextMonth:He,previousMonth:Le,goToMonth:We,getModifiers:ze,components:o,classNames:b,styles:V,labels:d,formatters:l};return React.createElement(dayPickerContext.Provider,{value:$n},React.createElement(o.Root,{rootRef:t.animate?Mn:void 0,className:Rn,style:vn,dir:t.dir,id:t.id,lang:t.lang,nonce:t.nonce,title:t.title,role:t.role,"aria-label":t["aria-label"],"aria-labelledby":t["aria-labelledby"],...Pn},React.createElement(o.Months,{className:b[UI.Months],style:V==null?void 0:V[UI.Months]},!t.hideNavigation&&!R&&React.createElement(o.Nav,{"data-animated-nav":t.animate?"true":void 0,className:b[UI.Nav],style:V==null?void 0:V[UI.Nav],"aria-label":Rt(),onPreviousClick:mt,onNextClick:ft,previousMonth:Le,nextMonth:He}),Be.map((Jt,Qt)=>React.createElement(o.Month,{"data-animated-month":t.animate?"true":void 0,className:b[UI.Month],style:V==null?void 0:V[UI.Month],key:Qt,displayIndex:Qt,calendarMonth:Jt},R==="around"&&!t.hideNavigation&&Qt===0&&React.createElement(o.PreviousMonthButton,{type:"button",className:b[UI.PreviousMonthButton],tabIndex:Le?void 0:-1,"aria-disabled":Le?void 0:!0,"aria-label":dt(Le),onClick:mt,"data-animated-button":t.animate?"true":void 0},React.createElement(o.Chevron,{disabled:Le?void 0:!0,className:b[UI.Chevron],orientation:t.dir==="rtl"?"right":"left"})),React.createElement(o.MonthCaption,{"data-animated-caption":t.animate?"true":void 0,className:b[UI.MonthCaption],style:V==null?void 0:V[UI.MonthCaption],calendarMonth:Jt,displayIndex:Qt},_!=null&&_.startsWith("dropdown")?React.createElement(o.DropdownNav,{className:b[UI.Dropdowns],style:V==null?void 0:V[UI.Dropdowns]},(()=>{const Ut=_==="dropdown"||_==="dropdown-months"?React.createElement(o.MonthsDropdown,{key:"month",className:b[UI.MonthsDropdown],"aria-label":rt(),classNames:b,components:o,disabled:!!t.disableNavigation,onChange:An(Jt.date),options:getMonthOptions(Jt.date,qe,Ve,l,f),style:V==null?void 0:V[UI.Dropdown],value:f.getMonth(Jt.date)}):React.createElement("span",{key:"month"},se(Jt.date,f)),tn=_==="dropdown"||_==="dropdown-years"?React.createElement(o.YearsDropdown,{key:"year",className:b[UI.YearsDropdown],"aria-label":Ye(f.options),classNames:b,components:o,disabled:!!t.disableNavigation,onChange:xn(Jt.date),options:getYearOptions(qe,Ve,l,f,!!t.reverseYears),style:V==null?void 0:V[UI.Dropdown],value:f.getYear(Jt.date)}):React.createElement("span",{key:"year"},$e(Jt.date,f));return f.getMonthYearOrder()==="year-first"?[tn,Ut]:[Ut,tn]})(),React.createElement("span",{role:"status","aria-live":"polite",style:{border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"}},ne(Jt.date,f.options,f))):React.createElement(o.CaptionLabel,{className:b[UI.CaptionLabel],role:"status","aria-live":"polite"},ne(Jt.date,f.options,f))),R==="around"&&!t.hideNavigation&&Qt===C-1&&React.createElement(o.NextMonthButton,{type:"button",className:b[UI.NextMonthButton],tabIndex:He?void 0:-1,"aria-disabled":He?void 0:!0,"aria-label":It(He),onClick:ft,"data-animated-button":t.animate?"true":void 0},React.createElement(o.Chevron,{disabled:He?void 0:!0,className:b[UI.Chevron],orientation:t.dir==="rtl"?"left":"right"})),Qt===C-1&&R==="after"&&!t.hideNavigation&&React.createElement(o.Nav,{"data-animated-nav":t.animate?"true":void 0,className:b[UI.Nav],style:V==null?void 0:V[UI.Nav],"aria-label":Rt(),onPreviousClick:mt,onNextClick:ft,previousMonth:Le,nextMonth:He}),React.createElement(o.MonthGrid,{role:"grid","aria-multiselectable":S==="multiple"||S==="range","aria-label":$t(Jt.date,f.options,f)||void 0,className:b[UI.MonthGrid],style:V==null?void 0:V[UI.MonthGrid]},!t.hideWeekdays&&React.createElement(o.Weekdays,{"data-animated-weekdays":t.animate?"true":void 0,className:b[UI.Weekdays],style:V==null?void 0:V[UI.Weekdays]},F&&React.createElement(o.WeekNumberHeader,{"aria-label":Ke(f.options),className:b[UI.WeekNumberHeader],style:V==null?void 0:V[UI.WeekNumberHeader],scope:"col"},Ne()),Ze.map(Ut=>React.createElement(o.Weekday,{"aria-label":Mt(Ut,f.options,f),className:b[UI.Weekday],key:String(Ut),style:V==null?void 0:V[UI.Weekday],scope:"col"},oe(Ut,f.options,f)))),React.createElement(o.Weeks,{"data-animated-weeks":t.animate?"true":void 0,className:b[UI.Weeks],style:V==null?void 0:V[UI.Weeks]},Jt.weeks.map(Ut=>React.createElement(o.Week,{className:b[UI.Week],key:Ut.weekNumber,style:V==null?void 0:V[UI.Week],week:Ut},F&&React.createElement(o.WeekNumber,{week:Ut,style:V==null?void 0:V[UI.WeekNumber],"aria-label":Ct(Ut.weekNumber,{locale:g}),className:b[UI.WeekNumber],scope:"row",role:"rowheader"},Oe(Ut.weekNumber,f)),Ut.days.map(tn=>{const{date:Yt}=tn,an=ze(tn);if(an[DayFlag.focused]=!an.hidden&&!!(et!=null&&et.isEqualTo(tn)),an[SelectionState.selected]=(Xe==null?void 0:Xe(Yt))||an.selected,isDateRange(Je)){const{from:Cn,to:Bn}=Je;an[SelectionState.range_start]=!!(Cn&&Bn&&f.isSameDay(Yt,Cn)),an[SelectionState.range_end]=!!(Cn&&Bn&&f.isSameDay(Yt,Bn)),an[SelectionState.range_middle]=rangeIncludesDate(Je,Yt,!0,f)}const mn=getStyleForModifiers(an,V,t.modifiersStyles),On=getClassNamesForModifiers(an,b,t.modifiersClassNames),Fn=!ct&&!an.hidden?Ge(Yt,an,f.options,f):void 0;return React.createElement(o.Day,{key:`${tn.isoDate}_${tn.displayMonthId}`,day:tn,modifiers:an,className:On.join(" "),style:mn,role:"gridcell","aria-selected":an.selected||void 0,"aria-label":Fn,"data-day":tn.isoDate,"data-month":tn.outside?tn.dateMonthId:void 0,"data-selected":an.selected||void 0,"data-disabled":an.disabled||void 0,"data-hidden":an.hidden||void 0,"data-outside":tn.outside||void 0,"data-focused":an.focused||void 0,"data-today":an.today||void 0},!an.hidden&&ct?React.createElement(o.DayButton,{className:b[UI.DayButton],style:V==null?void 0:V[UI.DayButton],type:"button",day:tn,modifiers:an,disabled:!an.focused&&an.disabled||void 0,"aria-disabled":an.focused&&an.disabled||void 0,tabIndex:at(tn)?0:-1,"aria-label":lt(Yt,an,f.options,f),onClick:yt(tn,an),onBlur:Kt(tn,an),onFocus:Ht(tn,an),onKeyDown:un(tn,an),onMouseEnter:hn(tn,an),onMouseLeave:qt(tn,an)},ae(Yt,f.options,f)):!an.hidden&&ae(tn.date,f.options,f))})))))))),t.footer&&React.createElement(o.Footer,{className:b[UI.Footer],style:V==null?void 0:V[UI.Footer],role:"status","aria-live":"polite"},t.footer)))}function Calendar({className:e,classNames:t,showOutsideDays:n=!0,captionLayout:o="label",buttonVariant:l="ghost",formatters:d,components:f,...g}){const b=getDefaultClassNames();return jsxRuntime.jsx(DayPicker,{showOutsideDays:n,className:cn("bg-background group/calendar p-3 [--cell-size:2rem] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,e),captionLayout:o,formatters:{formatMonthDropdown:_=>_.toLocaleString("default",{month:"short"}),...d},classNames:{root:cn("w-fit",b.root),months:cn("relative flex flex-col gap-4 md:flex-row",b.months),month:cn("flex w-full flex-col gap-4",b.month),nav:cn("absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",b.nav),button_previous:cn(buttonVariants({variant:l}),"h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50",b.button_previous),button_next:cn(buttonVariants({variant:l}),"h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50",b.button_next),month_caption:cn("flex h-[--cell-size] w-full items-center justify-center px-[--cell-size]",b.month_caption),dropdowns:cn("flex h-[--cell-size] w-full items-center justify-center gap-1.5 text-sm font-medium",b.dropdowns),dropdown_root:cn("has-focus:border-ring border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] relative rounded-md border",b.dropdown_root),dropdown:cn("bg-popover absolute inset-0 opacity-0",b.dropdown),caption_label:cn("select-none font-medium",o==="label"?"text-sm":"[&>svg]:text-muted-foreground flex h-8 items-center gap-1 rounded-md pl-2 pr-1 text-sm [&>svg]:size-3.5",b.caption_label),table:"w-full border-collapse",weekdays:cn("flex",b.weekdays),weekday:cn("text-muted-foreground flex-1 select-none rounded-md text-[0.8rem] font-normal",b.weekday),week:cn("mt-2 flex w-full",b.week),week_number_header:cn("w-[--cell-size] select-none",b.week_number_header),week_number:cn("text-muted-foreground select-none text-[0.8rem]",b.week_number),day:cn("group/day relative aspect-square h-full w-full select-none p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md",b.day),range_start:cn("bg-accent rounded-l-md",b.range_start),range_middle:cn("rounded-none",b.range_middle),range_end:cn("bg-accent rounded-r-md",b.range_end),today:cn("bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",b.today),outside:cn("text-muted-foreground aria-selected:text-muted-foreground",b.outside),disabled:cn("text-muted-foreground opacity-50",b.disabled),hidden:cn("invisible",b.hidden),...t},components:{Root:({className:_,rootRef:S,...R})=>jsxRuntime.jsx("div",{"data-slot":"calendar",ref:S,className:cn(_),...R}),Chevron:({className:_,orientation:S,...R})=>S==="left"?jsxRuntime.jsx(ChevronLeft,{className:cn("size-4",_),...R}):S==="right"?jsxRuntime.jsx(ChevronRight,{className:cn("size-4",_),...R}):jsxRuntime.jsx(ChevronDown,{className:cn("size-4",_),...R}),DayButton:CalendarDayButton,WeekNumber:({children:_,...S})=>jsxRuntime.jsx("td",{...S,children:jsxRuntime.jsx("div",{className:"flex size-[--cell-size] items-center justify-center text-center",children:_})}),...f},...g})}function CalendarDayButton({className:e,day:t,modifiers:n,...o}){const l=getDefaultClassNames(),d=React__namespace.useRef(null);return React__namespace.useEffect(()=>{var f;n.focused&&((f=d.current)==null||f.focus())},[n.focused]),jsxRuntime.jsx(Button$1,{ref:d,variant:"ghost",size:"icon","data-day":t.date.toLocaleDateString(),"data-selected-single":n.selected&&!n.range_start&&!n.range_end&&!n.range_middle,"data-range-start":n.range_start,"data-range-end":n.range_end,"data-range-middle":n.range_middle,className:cn("data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 flex aspect-square h-auto w-full min-w-[--cell-size] flex-col gap-1 font-normal leading-none data-[range-end=true]:rounded-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] [&>span]:text-xs [&>span]:opacity-70",l.day,e),...o})}function AssistantChat(e){return jsxRuntime.jsx(Card,{className:"max-w-6xl",children:jsxRuntime.jsx(AIChatLayout,{className:"h-[40em]",userId:e.userId,userName:e.userName,initialPrompt:e.initialPrompt})})}function formatDateToISO(e){if(!e||!isValidDate(e))return"";const t=e.getTimezoneOffset()*6e4;return new Date(e.getTime()-t).toISOString().split("T")[0]}function isValidDate(e){return e instanceof Date&&!isNaN(e.getTime())}function DatePicker({date:e,onDateChange:t,label:n,id:o,className:l}){const[d,f]=React__namespace.useState(!1),[g,b]=React__namespace.useState(e),[_,S]=React__namespace.useState(formatDateToISO(e));React__namespace.useEffect(()=>{S(formatDateToISO(e)),isValidDate(e)&&b(e)},[e]);const R=E=>{const M=E.target.value.replace(/\D/g,"").slice(0,8);let I=M;if(M.length>4&&(I=`${M.slice(0,4)}-${M.slice(4)}`),M.length>6&&(I=`${M.slice(0,4)}-${M.slice(4,6)}-${M.slice(6)}`),S(I),M.length===8){const j=new Date(I),q=new Date(j.getUTCFullYear(),j.getUTCMonth(),j.getUTCDate());isValidDate(q)?(t(q),b(q)):t(void 0)}else t(void 0)},C=E=>{E&&(t(E),S(formatDateToISO(E))),f(!1)};return jsxRuntime.jsxs("div",{className:cn("flex flex-col gap-2",l),children:[n&&jsxRuntime.jsx(Label$2,{htmlFor:o,children:n}),jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(Input,{id:o,value:_,placeholder:"YYYY-MM-DD",className:"bg-background pr-10",onChange:R,onKeyDown:E=>{E.key==="ArrowDown"&&(E.preventDefault(),f(!0))}}),jsxRuntime.jsxs(Popover,{open:d,onOpenChange:f,children:[jsxRuntime.jsx(PopoverTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"ghost",size:"icon",className:"absolute right-1 top-1/2 h-7 w-7 -translate-y-1/2","aria-label":"Select date",children:jsxRuntime.jsx(Calendar$1,{className:"h-4 w-4"})})}),jsxRuntime.jsx(PopoverContent,{className:"w-auto min-w-[280px] p-0",align:"end",sideOffset:8,children:jsxRuntime.jsx(Calendar,{mode:"single",selected:e,onSelect:C,month:g,onMonthChange:b,initialFocus:!0,className:"w-full"})})]})]})]})}function ExternalProductCard({product:e,viewProductLink:t}){return e?jsxRuntime.jsx(Card,{className:"@container border-dashed border-2 hover:shadow-md transition-shadow h-full",children:jsxRuntime.jsxs(CardContent,{className:"p-6 flex flex-col h-full",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start mb-4 @[36rem]:hidden",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-lg pr-4 text-center w-full",children:e.Title||e.RandmarTitle}),jsxRuntime.jsx("div",{className:"w-24 h-10 flex-shrink-0",children:jsxRuntime.jsx(PartnerLogo,{id:e.ManufacturerId,name:e.ManufacturerName,width:96,height:40})})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-x-6 gap-y-4 flex-grow @[36rem]:flex-row",children:[jsxRuntime.jsx("div",{className:"mx-auto flex-shrink-0 @[36rem]:mx-0 @[36rem]:w-48",children:jsxRuntime.jsx(ProductImage,{randmarSKU:e.RandmarSKU||"",alt:e.RandmarTitle||""})}),jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col text-center @[36rem]:text-left",children:[jsxRuntime.jsxs("div",{className:"hidden @[36rem]:flex justify-between items-start mb-4",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-lg pr-4",children:e.Title||e.RandmarTitle}),jsxRuntime.jsx("div",{className:"w-24 h-10 flex-shrink-0",children:jsxRuntime.jsx(PartnerLogo,{id:e.ManufacturerId,name:e.ManufacturerName,width:96,height:40})})]}),jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 justify-center @[36rem]:hidden",children:[jsxRuntime.jsxs(Badge,{variant:"outline",className:"border-orange-300 bg-orange-50 text-orange-800",children:[jsxRuntime.jsx(Telescope,{className:"mr-2 h-3 w-3"}),jsxRuntime.jsx("span",{children:"External Product"})]}),jsxRuntime.jsxs(Badge,{variant:"outline",className:"border-randmar-red bg-red-50 text-randmar-red",children:[jsxRuntime.jsx(Warehouse,{className:"mr-2 h-3 w-3"}),jsxRuntime.jsxs("span",{children:["Held by ",jsxRuntime.jsx("b",{children:"Randmar"})]})]})]}),jsxRuntime.jsxs("div",{className:"hidden @[36rem]:grid grid-cols-2 gap-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center rounded-md bg-orange-50 px-4 py-2 text-orange-800 border-1 border-orange-800 text-sm",children:[jsxRuntime.jsx(Telescope,{className:"mr-2 h-5 w-5 flex-shrink-0"}),jsxRuntime.jsx("span",{children:"External Product"})]}),jsxRuntime.jsxs("div",{className:"flex items-center rounded-md bg-red-50 px-4 py-2 text-randmar-red border-1 border-randmar-red text-sm",children:[jsxRuntime.jsx(Warehouse,{className:"mr-2 h-5 w-5 flex-shrink-0"}),jsxRuntime.jsxs("span",{children:["Held by ",jsxRuntime.jsx("b",{children:"Randmar"})]})]})]}),t&&jsxRuntime.jsx("div",{className:"mt-auto pt-4 flex justify-center @[36rem]:justify-end",children:jsxRuntime.jsx(reactRouterDom.Link,{to:t,children:jsxRuntime.jsxs(Button$1,{variant:"secondary",className:"w-full @[36rem]:w-auto",children:[jsxRuntime.jsx(Eye,{className:"mr-2 h-4 w-4"}),"View Product"]})})})]})]})]})}):jsxRuntime.jsx(Card,{className:"@container border-dashed border-2 h-full",children:jsxRuntime.jsx(CardContent,{className:"p-6 flex flex-col h-full",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-6 flex-grow @[36rem]:flex-row",children:[jsxRuntime.jsx("div",{className:"flex-shrink-0 @[36rem]:w-48",children:jsxRuntime.jsx(Skeleton,{className:"aspect-square w-full h-auto"})}),jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col gap-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-1/2"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 justify-center @[36rem]:hidden",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-36 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-36 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"hidden @[36rem]:grid grid-cols-2 gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md"})]})]}),jsxRuntime.jsx("div",{className:"mt-auto pt-4 flex justify-center @[36rem]:justify-end",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-full @[36rem]:w-40"})})]})]})})})}function getEndDateStatus(e){if(!e)return{text:"No End Date",variant:"neutral",daysRemaining:null};const t=new Date(e);if(isNaN(t.getTime()))return{text:"Invalid Date",variant:"neutral",daysRemaining:null};const n=new Date,o=new Date(t.getFullYear(),t.getMonth(),t.getDate()),l=new Date(n.getFullYear(),n.getMonth(),n.getDate()),d=o.getTime()-l.getTime(),f=Math.ceil(d/(1e3*60*60*24));return f<0?{text:`Ended ${Math.abs(f)}d ago`,variant:"destructive",daysRemaining:f}:f===0?{text:"Ends today",variant:"destructive",daysRemaining:f}:f<=7?{text:`Ends in ${f}d`,variant:"destructive",daysRemaining:f}:f<=30?{text:`Ends in ${f}d`,variant:"warning",daysRemaining:f}:{text:`Ends in ${f}d`,variant:"neutral",daysRemaining:f}}const formatDate=e=>{if(!e)return"N/A";try{const t=new Date(e);return isNaN(t.getTime())?"Invalid Date":t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return"Invalid Date"}};function OpportunitiesTable({applicationId:e,opportunities:t=null,loading:n=!1}){var ne;const{toast:o}=useToast(),[l,d]=React.useState({}),[f,g]=React.useState(!1),[b,_]=React.useState(""),[S,R]=React.useState(null),{data:C}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:e},{skip:!e}),E=React.useCallback((ae,se,Oe)=>{d(Ne=>({...Ne,[ae]:{...Ne[ae],[se]:Oe}}))},[]),[A]=usePutV4ResellerByRouteResellerIdOpportunityAndManufacturerIdDefaultMutation(),M=React.useCallback(async ae=>{if(!(C!=null&&C.IsReseller))return;if(!ae.BidNumber){o({title:"Error",description:"Bid Number is missing, cannot set default.",variant:"destructive"});return}const se=ae.BidNumber;E(se,"isSettingDefault",!0),A({routeResellerId:e,manufacturerId:ae.ManufacturerId??"",opportunityNumber:se}).unwrap().then(()=>{o({title:"Success",description:`Opportunity "${ae.OpportunityName||ae.Opportunity||se}" was successfully set as default.`,variant:"success"})}).catch(Oe=>{var Ne;console.error("Set as default error:",Oe),o({title:"Error",description:((Ne=Oe.data)==null?void 0:Ne.message)||Oe.message||"An error occurred while setting this opportunity as default.",variant:"destructive"})}).finally(()=>{E(se,"isSettingDefault",!1)})},[e,A,o,E,C==null?void 0:C.IsReseller]),[I]=usePostV4ResellerByRouteResellerIdOpportunityAndManufacturerIdBidNumberEmailMutation(),j=React.useCallback(ae=>{if(C!=null&&C.IsReseller){if(!ae.BidNumber){o({title:"Error",description:"Bid Number is missing, cannot prepare report.",variant:"destructive"});return}R(ae),_(""),g(!0)}},[o,C==null?void 0:C.IsReseller]),q=React.useCallback(async()=>{if(!(C!=null&&C.IsReseller))return;if(!S||!S.BidNumber){o({title:"Error",description:"No opportunity selected or Bid Number is missing.",variant:"destructive"});return}if(!b.trim()||!/\S+@\S+\.\S+/.test(b)){o({title:"Validation Error",description:"Please enter a valid email address.",variant:"destructive"});return}const ae=S.BidNumber;E(ae,"isSendingReport",!0),I({routeResellerId:e,manufacturerId:S.ManufacturerId??"",bidNumber:ae,emailAddress:b}).unwrap().then(()=>{o({title:"Success",description:`A report for "${S.OpportunityName||S.Opportunity||ae}" was successfully sent to ${b}.`,variant:"success"}),g(!1)}).catch(se=>{var Oe;console.error("Send report by email error:",se),o({title:"Error",description:((Oe=se.data)==null?void 0:Oe.message)||se.message||"An error occurred while sending the report by email.",variant:"destructive"})}).finally(()=>{E(ae,"isSendingReport",!1),f||(R(null),_(""))})},[S,b,e,I,o,E,g]),Q=React.useMemo(()=>[{accessorKey:"ManufacturerId",header:"Manuf.",cell:({row:ae})=>jsxRuntime.jsx("div",{className:"w-20 h-8",children:jsxRuntime.jsx(PartnerLogo,{id:ae.original.ManufacturerId,width:80,height:32})}),enableSorting:!0,enableFiltering:!0},{id:"opportunityDisplay",accessorFn:ae=>ae.OpportunityName||ae.Opportunity,header:"Opportunity",cell:({getValue:ae})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:ae()??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"BidNumber",header:"Bid Number",cell:({row:ae})=>ae.original.BidNumber??"N/A",enableSorting:!0,enableFiltering:!0},{id:"statusInfo",header:"Status",cell:({row:ae})=>{const se=ae.original,Oe=se.Active===!0,Ne=getEndDateStatus(se.EndDate);let oe="border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400";return Ne.variant==="destructive"?oe="border-red-500 bg-red-100 text-red-700 dark:border-red-600 dark:bg-red-900/50 dark:text-red-400":Ne.variant==="warning"&&(oe="border-yellow-500 bg-yellow-100 text-yellow-700 dark:border-yellow-600 dark:bg-yellow-900/50 dark:text-yellow-400"),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 min-w-[200px]",children:[jsxRuntime.jsx(Badge,{variant:"outline",className:Oe?"border-green-500 bg-green-100 text-green-700 dark:border-green-600 dark:bg-green-900/50 dark:text-green-400 font-medium":"border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400 font-medium",children:Oe?"Active":"Inactive"}),se.EndDate&&jsxRuntime.jsx(Badge,{variant:"outline",className:`${oe} font-medium`,children:Ne.text}),jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"ghost",size:"icon",className:"h-6 w-6 p-0 data-[state=delayed-open]:bg-accent data-[state=instant-open]:bg-accent",children:jsxRuntime.jsx(Info,{className:"h-4 w-4 text-muted-foreground"})})}),jsxRuntime.jsx(TooltipContent,{side:"top",align:"center",className:"bg-popover text-popover-foreground p-2 rounded shadow-lg",children:jsxRuntime.jsxs("div",{className:"text-sm space-y-1",children:[jsxRuntime.jsxs("p",{children:[jsxRuntime.jsx("strong",{children:"Start:"})," ",formatDate(se.StartDate)]}),jsxRuntime.jsxs("p",{children:[jsxRuntime.jsx("strong",{children:"End:"})," ",formatDate(se.EndDate)]}),jsxRuntime.jsxs("p",{children:[jsxRuntime.jsx("strong",{children:"Updated:"})," ",formatDate(se.LastUpdate)]})]})})]})})]})},enableFiltering:!1},{id:"actions",header:"Actions",cell:({row:ae})=>{var Be,qe;const se=ae.original;if(!se.BidNumber)return jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"Actions unavailable"});const Oe=se.BidNumber,Ne=(Be=l[Oe])==null?void 0:Be.isSettingDefault,oe=(S==null?void 0:S.BidNumber)===Oe&&((qe=l[Oe])==null?void 0:qe.isSendingReport),$e=Ne||oe,Ae=se.CanBeSetAsDefault===!0,je=C!=null&&C.IsManufacturer?`/${e}/Opportunity/${se.BidNumber}`:`/${e}/Opportunity/${se.ManufacturerId}/${se.BidNumber}`;return jsxRuntime.jsxs("div",{className:"flex space-x-2",children:[jsxRuntime.jsx(reactRouterDom.Link,{to:je,children:jsxRuntime.jsxs(Button$1,{variant:"outline",size:"sm",className:"flex items-center",children:[jsxRuntime.jsx(Star,{className:"mr-2 h-4 w-4"})," View"]})}),(C==null?void 0:C.IsReseller)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Button$1,{variant:"outline",size:"sm",onClick:()=>M(se),disabled:$e||!Ae,title:Ae?"Set as default":"This opportunity cannot be set as default",className:"flex items-center",children:[Ne?jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}):jsxRuntime.jsx(Star,{className:"mr-2 h-4 w-4"})," Set Default"]}),jsxRuntime.jsxs(Button$1,{variant:"outline",size:"sm",onClick:()=>j(se),disabled:$e,title:"Send report by email",className:"flex items-center",children:[oe?jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}):jsxRuntime.jsx(Send,{className:"mr-2 h-4 w-4"})," Send Report"]})]})]})}}],[l,M,j,S,C==null?void 0:C.IsReseller,e]),te=React.useMemo(()=>{const ae={};if(t){const se=Array.from(new Set(t.map(Ne=>Ne.ManufacturerId).filter(Ne=>Ne!=null)));ae.ManufacturerId=se;const Oe=Array.from(new Set(t.map(Ne=>Ne.OpportunityName||Ne.Opportunity).filter(Ne=>Ne!=null)));ae.opportunityDisplay=Oe}return ae},[t]),F=t||[],V=S!=null&&S.BidNumber?(ne=l[S.BidNumber])==null?void 0:ne.isSendingReport:!1;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-48 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(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Opportunities"})," "]}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:Q,data:F,uniqueValues:te})})]}),jsxRuntime.jsx(Dialog,{open:f,onOpenChange:ae=>{g(ae),ae||(R(null),_(""))},children:jsxRuntime.jsxs(DialogContent,{className:"@sm:max-w-[425px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Send Opportunity Report"}),jsxRuntime.jsxs(DialogDescription,{children:["Enter the email address to send the report for opportunity: ",jsxRuntime.jsx("br",{}),jsxRuntime.jsx("span",{className:"font-semibold",children:(S==null?void 0:S.OpportunityName)||(S==null?void 0:S.Opportunity)||"N/A"}),(S==null?void 0:S.BidNumber)&&jsxRuntime.jsxs("span",{className:"block text-sm text-muted-foreground",children:["Bid Number: ",S.BidNumber]})]})]}),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:b,onChange:ae=>_(ae.target.value),placeholder:"recipient@example.com",className:"col-span-3",disabled:V})]})}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>g(!1),disabled:V,children:"Cancel"}),jsxRuntime.jsxs(Button$1,{type:"submit",onClick:q,disabled:V,children:[V&&jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"})," Send Report"]})]})]})})]})}function useLoadScript(e){const[t,n]=React.useState(!0),[o,l]=React.useState(null),[d,f]=React.useState(!1),g=()=>{n(!1),f(!0)};return React.useEffect(()=>{if(!document){const R=new Error(`[ScriptLoadingError] document not defined when attempting to load ${e}`);l(R);return}const b=document.querySelector(`script[src="${e}"]`);if(b!=null&&b.dataset.loaded){g();return}const _=b||document.createElement("script");b||(_.src=e);const S=()=>{_.dataset.loaded="1",g()};_.addEventListener("load",S),_.addEventListener("error",R=>{console.error("Failed to load script:",e,R);const C=new Error(`[ScriptLoadingError] Failed to load script: ${e}`);l(C)}),b||document.head.append(_)},[]),{isLoading:t,error:o,isSuccess:d}}const isGoogleReady=e=>e&&e.charts,isGoogleChartsReady=(e,t)=>{const{controls:n,toolbarItems:o,getChartEditor:l}=e;return t&&t.charts&&t.visualization&&t.visualization.ChartWrapper&&t.visualization.Dashboard&&(!n||t.visualization.ChartWrapper)&&(!l||t.visualization.ChartEditor)&&(!o||t.visualization.drawToolbar)},getGoogleInstanceFromWindow=e=>window.google;function useLoadGoogleCharts(e){const{chartVersion:t="current",chartPackages:n=["corechart","controls"],chartLanguage:o="en",mapsApiKey:l}=e,[d,f]=React.useState(null),[g,b]=React.useState(null),[_,S]=React.useState(null),{isLoading:R,error:C,isSuccess:E}=useLoadScript(e.chartLoaderScriptUrl||"https://www.gstatic.com/charts/loader.js");return React.useEffect(()=>{if(!E)return;const A=getGoogleInstanceFromWindow();if(!isGoogleReady(A)){const M=new Error("[ScriptInitializationError] Script loaded but Google not attached to window.");b(M);return}if(isGoogleChartsReady(e,A)){f(A);return}A.charts.load(t,{packages:n,language:o,mapsApiKey:l}),A.charts.setOnLoadCallback(()=>{if(!isGoogleChartsReady(e,A)){const M=new Error("[GoogleChartsInitializationError] Google Charts not ready after load callback.");console.error(M),S(M);return}f(A)})},[E]),{error:C||g||_,isLoading:R,google:d}}const chartDefaultProps={legend_toggle:!1,options:{},legendToggle:!1,getChartWrapper:()=>{},spreadSheetQueryParameters:{headers:1,gid:1},rootProps:{},chartWrapperParams:{},chartLoaderScriptUrl:"https://www.gstatic.com/charts/loader.js"},GoogleChartControls=e=>{const{isReady:t,chartControls:n,filter:o}=e;return!t||!n||!(n!=null&&n.length)?null:React.createElement(React.Fragment,null,n.filter(l=>{let{controlProp:d,control:f}=l;return o?o({control:f,controlProp:d}):!0}).map(l=>{let{control:d}=l;return React.createElement("div",{key:d.getContainerId(),id:d.getContainerId()})}))};let uniqueID=0;const generateUniqueID=()=>(uniqueID+=1,`reactgooglegraph-${uniqueID}`),jn=class jn{};en(jn,"initializeControls",t=>{for(let n=0;n<t.length;n+=1){const{controlType:o,options:l,controlWrapperParams:d}=t[n].controlProp;d&&"state"in d&&t[n].control.setState(d.state),t[n].control.setOptions(l),t[n].control.setControlType(o)}}),en(jn,"listenToControlEvents",(t,n)=>{const{google:o}=n;return t.flatMap(l=>{const{control:d,controlProp:f}=l,{controlEvents:g=[]}=f;return g.map(b=>{const{callback:_,eventName:S}=b;return o.visualization.events.addListener(d,S,function(){for(var R=arguments.length,C=new Array(R),E=0;E<R;E++)C[E]=arguments[E];_({chartWrapper:null,controlWrapper:d,props:n,google:o,eventArgs:C})})})})}),en(jn,"createControlId",t=>{let n;return typeof t>"u"?n=`googlechart-control-${generateUniqueID()}`:n=t,n}),en(jn,"createChartControls",t=>{const{controls:n,google:o}=t;return n?n.map((l,d)=>{const{controlID:f,controlType:g,options:b,controlWrapperParams:_}=l,S=jn.createControlId(f);return{controlProp:l,control:new o.visualization.ControlWrapper({containerId:S,controlType:g,options:b,..._})}}):null}),en(jn,"addControls",t=>{const{chartWrapper:n,chartDashboard:o}=t,l=jn.createChartControls(t);return!l||!o||!n?null:(o.bind(l.map(d=>{let{control:f}=d;return f}),n),jn.initializeControls(l),l)});let GoogleChartControlsInternal=jn;const useCreateChartControls=e=>{const[t,n]=React__namespace.useState(null);return[React__namespace.useMemo(()=>!t||!e?null:e.map((l,d)=>{const f=t[d];return f?{controlProp:l,control:f}:void 0}).flatMap(l=>l?[l]:[]),[t,e]),n]},useListenToControlEvents=(e,t)=>{React__namespace.useEffect(()=>{const n=GoogleChartControlsInternal.listenToControlEvents(e??[],t);return()=>{n.forEach(o=>{t.google.visualization.events.removeListener(o)})}},[e,t])},useChartControls=e=>{const[t,n]=useCreateChartControls(e.controls);return useListenToControlEvents(t??[],e),{addControls:l=>{const d=GoogleChartControlsInternal.addControls(l);n((d==null?void 0:d.map(f=>f.control))??null)},renderControl:l=>{const{chartWrapper:d,chartDashboard:f}=e;return React__namespace.createElement(GoogleChartControls,{...e,isReady:!!(d&&f),chartControls:t,filter:l})}}},useChartId=e=>{const t=React__namespace.useRef(null);return{chartId:(()=>{const{graphID:l,graph_id:d}=e,f=l||d;let g;return f?g=f:g=t.current||generateUniqueID(),t.current=g,t.current})()}},DEFAULT_CHART_COLORS=["#3366CC","#DC3912","#FF9900","#109618","#990099","#3B3EAC","#0099C6","#DD4477","#66AA00","#B82E2E","#316395","#994499","#22AA99","#AAAA11","#6633CC","#E67300","#8B0707","#329262","#5574A6","#3B3EAC"],loadDataTableFromSpreadSheet=async function(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return new Promise((o,l)=>{const d=`${n.headers?`headers=${n.headers}`:"headers=0"}`,f=`${n.query?`&tq=${encodeURIComponent(n.query)}`:""}`,g=`${n.gid?`&gid=${n.gid}`:""}`,b=`${n.sheet?`&sheet=${n.sheet}`:""}`,_=`${n.access_token?`&access_token=${n.access_token}`:""}`,S=`${d}${g}${b}${f}${_}`,R=`${t}/gviz/tq?${S}`;new e.visualization.Query(R).send(E=>{E.isError()?l(`Error in query: ${E.getMessage()} ${E.getDetailedMessage()}`):o(E.getDataTable())})})},GRAY_COLOR="#CCCCCC",Tn=class Tn{};en(Tn,"grayOutHiddenColumnsLabel",(t,n)=>{const{googleChartWrapper:o,options:l}=t;if(!o){console.error("googleChartWrapper is not defined");return}const d=o.getDataTable();if(!d)return;const f=d.getNumberOfColumns();if(n.length>0===!1)return;const b=Array.from({length:f-1}).map((_,S)=>{const R=Tn.getColumnId(d,S+1);return n.includes(R)?GRAY_COLOR:l&&l.colors?l.colors[S]:DEFAULT_CHART_COLORS[S]});o.setOptions({...l,colors:b}),o.draw()}),en(Tn,"listenToLegendToggle",(t,n)=>{const[o,l]=n,{google:d,googleChartWrapper:f}=t;if(!f){console.error("googleChartWrapper is not defined");return}return d.visualization.events.addListener(f,"select",()=>{const b=f.getChart().getSelection(),_=f.getDataTable();if(b.length===0||b[0].row!==null||!_)return;const S=b[0].column,R=Tn.getColumnId(_,S);o!=null&&o.includes(R)?l(C=>[...C.filter(E=>E!==R)]):l(C=>[...C,R])})}),en(Tn,"draw",async t=>{const{data:n,diffdata:o,rows:l,columns:d,options:f,chartType:g,formatters:b,spreadSheetUrl:_,spreadSheetQueryParameters:S,googleChartDashboard:R,googleChartWrapper:C,google:E,hiddenColumns:A,legendToggle:M,legend_toggle:I}=t;if(!C){console.error("draw was called with googleChartWrapper = null");return}let j,q=null;if(o){const ne=E.visualization.arrayToDataTable(o.old),ae=E.visualization.arrayToDataTable(o.new);q=E.visualization[g].prototype.computeDiff(ne,ae)}n?n instanceof E.visualization.DataTable?j=n:Array.isArray(n)?j=E.visualization.arrayToDataTable(n):j=new E.visualization.DataTable(n):l&&d?j=E.visualization.arrayToDataTable([d,...l]):_?j=await loadDataTableFromSpreadSheet(E,_,S):j=E.visualization.arrayToDataTable([]);const Q=j.getNumberOfColumns(),te=Array(Q).fill(0).map((ne,ae)=>{const se=Tn.getColumnId(j,ae);return A.includes(se)?{label:j.getColumnLabel(ae),type:j.getColumnType(ae),calc:()=>null}:ae}),F=C.getChart();C.getChartType()==="Timeline"&&F&&F.clearChart(),C.setChartType(g),C.setOptions(f||{});const V=new E.visualization.DataView(j);V.setColumns(te),C.setDataTable(V),C.draw(),R&&R.draw(j),q&&(C.setDataTable(q),C.draw()),b&&(Tn.applyFormatters({dataTable:j,formatters:b,google:E}),C.setDataTable(j),C.draw()),(M===!0||I===!0)&&Tn.grayOutHiddenColumnsLabel(t,A)}),en(Tn,"getColumnId",(t,n)=>t.getColumnId(n)||t.getColumnLabel(n)),en(Tn,"applyFormatters",t=>{let{dataTable:n,formatters:o,google:l}=t;for(let d of o)switch(d.type){case"ArrowFormat":{new l.visualization.ArrowFormat(d.options).format(n,d.column);return}case"BarFormat":{new l.visualization.BarFormat(d.options).format(n,d.column);return}case"ColorFormat":{const f=new l.visualization.ColorFormat(d.options),{ranges:g}=d;if(g)for(let b of g)f.addRange(...b);f.format(n,d.column);return}case"DateFormat":{new l.visualization.DateFormat(d.options).format(n,d.column);return}case"NumberFormat":{new l.visualization.NumberFormat(d.options).format(n,d.column);return}case"PatternFormat":{new l.visualization.PatternFormat(d.options).format(n,d.column);return}default:{console.warn(`Unknown formatter type: ${d.type}`);return}}});let GoogleChartInternal=Tn;const useGoogleChartDataTable=e=>{const{google:t,googleChartWrapper:n,googleChartDashboard:o}=e,[l,d]=React__namespace.useState([]);React__namespace.useEffect(()=>{n&&GoogleChartInternal.draw({...e,hiddenColumns:l,googleChartWrapper:n,googleChartDashboard:o,google:t})},[l,e.data,e.rows,e.columns,e.options,e.chartLoaderScriptUrl,e.chartType,e.formatters,e.spreadSheetUrl,e.spreadSheetQueryParameters,e.legendToggle,e.legend_toggle]);const f=()=>{const{googleChartWrapper:_}=e;_&&_.draw()},g=_=>{const S=[],{legendToggle:R,legend_toggle:C}=e;if(GoogleChartInternal.draw({...e,hiddenColumns:l,googleChartWrapper:_,googleChartDashboard:o,google:t}),window.addEventListener("resize",f),C||R){const E=GoogleChartInternal.listenToLegendToggle(e,[l,d]);E&&S.push(E)}return S},b=(_,S)=>{window.removeEventListener("resize",f),S.forEach(R=>{t.visualization.events.removeListener(R)}),_.getChartType()==="Timeline"&&_.getChart()&&_.getChart().clearChart()};React__namespace.useEffect(()=>{if(!n)return;const _=g(n);return()=>{b(n,_)}},[n,g,b])},listenToEvents=e=>{const{chartEvents:t,google:n,googleChartWrapper:o}=e;if(t){if(!o){console.warn("listenToEvents was called before chart wrapper ready.");return}return t.map(l=>{let{eventName:d,callback:f}=l;return n.visualization.events.addListener(o,d,function(){for(var g=arguments.length,b=new Array(g),_=0;_<g;_++)b[_]=arguments[_];f({chartWrapper:o,props:e,google:n,eventArgs:b})})})}},useGoogleChartEvents=e=>{React.useEffect(()=>{if(!e.googleChartWrapper)return;const t=listenToEvents(e);return()=>{t==null||t.forEach(n=>{e.google.visualization.events.removeListener(n)})}},[e])},GoogleChart=e=>{const[t,n]=React__namespace.useState(null),[o,l]=React__namespace.useState(null),{addControls:d,renderControl:f}=useChartControls({...e,chartDashboard:o,chartWrapper:t});useGoogleChartEvents({...e,googleChartWrapper:t});const{chartId:g}=useChartId(e),b=React__namespace.useRef(null),_=React__namespace.useRef(null);React__namespace.useEffect(()=>{const{options:j,google:q,chartType:Q,chartWrapperParams:te,toolbarItems:F,getChartEditor:V,getChartWrapper:ne,onLoad:ae}=e,se={chartType:Q,options:j,containerId:g,...te},Oe=new q.visualization.ChartWrapper(se);Oe.setOptions(j||{}),ne==null||ne(Oe,q);const Ne=new q.visualization.Dashboard(b.current);F&&q.visualization.drawToolbar(_.current,F);let oe=null;V&&(oe=new q.visualization.ChartEditor,V({chartEditor:oe,chartWrapper:Oe,google:q})),d({...e,chartDashboard:Ne,chartWrapper:Oe}),n(Oe),l(Ne),ae==null||ae(q,{google:q,chartWrapper:Oe,chartEditor:oe,chartDashboard:Ne})},[]),useGoogleChartDataTable({...e,googleChartWrapper:t,googleChartDashboard:o});const S=()=>{const{width:j,height:q,options:Q,style:te,className:F,rootProps:V,google:ne}=e,ae={height:q||Q&&Q.height,width:j||Q&&Q.width,...te};return React__namespace.createElement("div",{id:g,style:ae,className:F,...V})},R=()=>e.toolbarItems?React__namespace.createElement("div",{ref:_}):null,{width:C,height:E,options:A,style:M}=e,I={height:E||A&&A.height,width:C||A&&A.width,...M};return e.render?React__namespace.createElement("div",{ref:b,style:I},React__namespace.createElement("div",{ref:_,id:"toolbar"}),e.render({renderChart:S,renderControl:f,renderToolbar:R})):React__namespace.createElement("div",{ref:b,style:I},f(j=>{let{controlProp:q}=j;return q.controlPosition!=="bottom"}),S(),f(j=>{let{controlProp:q}=j;return q.controlPosition==="bottom"}),R())},ChartContext=React__namespace.createContext(chartDefaultProps),ContextProvider=e=>{let{children:t,value:n}=e;return React__namespace.createElement(ChartContext.Provider,{value:n},t)},ChartView=e=>{const{google:t,isLoading:n,error:o}=useLoadGoogleCharts(e);return n?e.loader??null:o?e.errorElement??null:t?React.createElement(GoogleChart,{google:t,...e}):null},Chart=e=>{const t={...chartDefaultProps,...e};return React.createElement(ContextProvider,{value:t},React.createElement(ChartView,t))};var GoogleDataTableColumnRoleType;(function(e){e.annotation="annotation",e.annotationText="annotationText",e.certainty="certainty",e.emphasis="emphasis",e.interval="interval",e.scope="scope",e.style="style",e.tooltip="tooltip",e.domain="domain"})(GoogleDataTableColumnRoleType||(GoogleDataTableColumnRoleType={}));function parseHsl(e){const t=e.match(/(\d+\.?\d*)\s*(\d+\.?\d*)%\s*(\d+\.?\d*)%/);return t?{h:parseFloat(t[1]),s:parseFloat(t[2]),l:parseFloat(t[3])}:null}function hslToHex(e,t,n){n/=100;const o=t*Math.min(n,1-n)/100,l=d=>{const f=(d+e/30)%12,g=n-o*Math.max(Math.min(f-3,9-f,1),-1);return Math.round(255*g).toString(16).padStart(2,"0")};return`#${l(0)}${l(8)}${l(4)}`}const Treemap=React__namespace.forwardRef(({data:e,options:t,height:n="500px",className:o,loading:l,disableClick:d=!0,...f},g)=>{const b=React__namespace.useRef(null),[_,S]=React__namespace.useState(null);React__namespace.useEffect(()=>{if(!b.current)return;const E=b.current,A=()=>{const q=getComputedStyle(E).getPropertyValue("--primary").trim();if(q){const Q=parseHsl(q);if(Q){const{h:te,s:F,l:V}=Q;S({minColor:hslToHex(te,F,Math.min(100,V+50)),midColor:hslToHex(te,F,Math.min(100,V+35)),maxColor:hslToHex(te,F,Math.min(100,V+20))})}return!0}return!1};if(A())return;let M=0;const I=20,j=setInterval(()=>{(A()||M>=I)&&clearInterval(j),M++},100);return()=>{j&&clearInterval(j)}},[]);const R=React__namespace.useMemo(()=>{const E={headerHeight:0,fontSize:14,showScale:!1,isHtml:!0,backgroundColor:"hsl(var(--background))",generateTooltip:(A,M)=>{var q;const I=(q=e[A+1])==null?void 0:q[0];if(!I)return"";const j=formatMoney(M);return`<div class="p-2 bg-background text-foreground border rounded-md shadow-lg">
1456
1456
  <strong>${I}</strong><br>Value: ${j}
1457
1457
  </div>`}};return _&&(!t||!t.colorAxis)&&(E.minColor=_.minColor,E.midColor=_.midColor,E.maxColor=_.maxColor),{...E,...t}},[e,t,_]),C=React__namespace.useMemo(()=>d?[{eventName:"select",callback:({chartWrapper:A})=>{A.getChart().setSelection(null)}}]:void 0,[d]);return React__namespace.useImperativeHandle(g,()=>b.current,[]),l?jsxRuntime.jsx("div",{ref:b,className:cn("w-full",o),style:{height:n},...f,children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full"})}):!e||e.length<=2?jsxRuntime.jsx("div",{ref:b,className:cn("w-full flex items-center justify-center text-muted-foreground",o),style:{height:n},...f,children:"No data available"}):jsxRuntime.jsx("div",{ref:b,className:cn("w-full",o),style:{height:n},...f,children:jsxRuntime.jsx(Chart,{chartType:"TreeMap",width:"100%",height:"100%",data:e,options:R,chartEvents:C,loader:jsxRuntime.jsx(Skeleton,{className:"h-full w-full"})})})});Treemap.displayName="Treemap";const TopPercentTreemap=({data:e,topPercent:t=80,title:n,loading:o,...l})=>{const d=React__namespace.useMemo(()=>{if(!e||e.length===0)return[["ID","Parent","Value"],["Root",null,0]];const g=[...e].sort((A,M)=>M.value-A.value),_=g.reduce((A,M)=>A+M.value,0)*(t/100),S=[["ID","Parent","Value"],["Root",null,0]],R=[],C=[];let E=0;for(const A of g)E<_?(R.push(A),E+=A.value):C.push(A);if(R.forEach(A=>{S.push([A.name,"Root",A.value])}),C.length>0){const A=`More... (${C.length} items)`;S.push([A,"Root",0]),C.forEach(M=>{S.push([M.name,A,M.value])})}return S},[e,t]),f=React__namespace.useMemo(()=>({title:n,maxDepth:1,backgroundColor:"hsl(var(--background))"}),[n]);return jsxRuntime.jsx(Treemap,{data:d,options:f,className:cn("h-full",l.className),loading:o,disableClick:!1,...l})};exports.AIChatLayout=AIChatLayout,exports.Accordion=Accordion,exports.AccordionContent=AccordionContent,exports.AccordionItem=AccordionItem,exports.AccordionTrigger=AccordionTrigger,exports.ActiveOrdersCard=ActiveOrdersCard,exports.AiGeneratedContent=AiGeneratedContent,exports.Alert=Alert,exports.AlertDescription=AlertDescription,exports.AlertDialog=AlertDialog,exports.AlertDialogAction=AlertDialogAction,exports.AlertDialogCancel=AlertDialogCancel,exports.AlertDialogContent=AlertDialogContent,exports.AlertDialogDescription=AlertDialogDescription,exports.AlertDialogFooter=AlertDialogFooter,exports.AlertDialogHeader=AlertDialogHeader,exports.AlertDialogTitle=AlertDialogTitle,exports.AlertDialogTrigger=AlertDialogTrigger,exports.AlertTitle=AlertTitle,exports.AreaChart=AreaChart,exports.AssistantChat=AssistantChat,exports.AssistantInsight=AssistantInsight,exports.Avatar=Avatar,exports.AvatarFallback=AvatarFallback,exports.AvatarFooter=AvatarFooter,exports.AvatarImage=AvatarImage,exports.Badge=Badge,exports.Button=Button$1,exports.Calendar=Calendar,exports.Card=Card,exports.CardContent=CardContent,exports.CardDescription=CardDescription,exports.CardFooter=CardFooter,exports.CardHeader=CardHeader,exports.CardTitle=CardTitle,exports.ChatLayout=ChatLayout,exports.ChatProvider=ChatProvider,exports.Checkbox=Checkbox,exports.Command=Command,exports.CommandDialog=CommandDialog,exports.CommandEmpty=CommandEmpty,exports.CommandGroup=CommandGroup,exports.CommandInput=CommandInput,exports.CommandItem=CommandItem,exports.CommandList=CommandList,exports.CommandSeparator=CommandSeparator,exports.CommandShortcut=CommandShortcut,exports.CountryFlag=CountryFlag,exports.DataTable=DataTable,exports.DatePicker=DatePicker,exports.Dialog=Dialog,exports.DialogClose=DialogClose,exports.DialogContent=DialogContent,exports.DialogDescription=DialogDescription,exports.DialogFooter=DialogFooter,exports.DialogHeader=DialogHeader,exports.DialogOverlay=DialogOverlay,exports.DialogPortal=DialogPortal,exports.DialogTitle=DialogTitle,exports.DialogTrigger=DialogTrigger,exports.DropdownMenu=DropdownMenu,exports.DropdownMenuCheckboxItem=DropdownMenuCheckboxItem,exports.DropdownMenuContent=DropdownMenuContent,exports.DropdownMenuGroup=DropdownMenuGroup,exports.DropdownMenuItem=DropdownMenuItem,exports.DropdownMenuLabel=DropdownMenuLabel,exports.DropdownMenuPortal=DropdownMenuPortal,exports.DropdownMenuRadioGroup=DropdownMenuRadioGroup,exports.DropdownMenuRadioItem=DropdownMenuRadioItem,exports.DropdownMenuSeparator=DropdownMenuSeparator,exports.DropdownMenuShortcut=DropdownMenuShortcut,exports.DropdownMenuSub=DropdownMenuSub,exports.DropdownMenuSubContent=DropdownMenuSubContent,exports.DropdownMenuSubTrigger=DropdownMenuSubTrigger,exports.DropdownMenuTrigger=DropdownMenuTrigger,exports.ExploreManufacturers=ExploreManufacturers,exports.ExternalProductCard=ExternalProductCard,exports.GeminiApiKeyProvider=GeminiApiKeyProvider,exports.GeneralDocumentCard=GeneralDocumentCard,exports.Input=Input,exports.InputOTP=InputOTP,exports.InputOTPGroup=InputOTPGroup,exports.InputOTPSeparator=InputOTPSeparator,exports.InputOTPSlot=InputOTPSlot,exports.Label=Label$2,exports.Layout=Layout,exports.ManufacturerCard=ManufacturerCard,exports.ManufacturerGetStartedButton=ManufacturerGetStartedButton,exports.ManufacturerOverviewPage=ManufacturerOverviewPage,exports.ManufacturerReorderingCard=ManufacturerReorderingCard,exports.MultiSelect=MultiSelect,exports.Navbar=Navbar,exports.OpportunitiesTable=OpportunitiesTable,exports.OrdersCard=OrdersCard,exports.PageHeader=PageHeader,exports.PartnerActions=PartnerActions,exports.PartnerCard=PartnerCard,exports.PartnerRelationshipPage=PartnerRelationshipPage,exports.Popover=Popover,exports.PopoverAnchor=PopoverAnchor,exports.PopoverContent=PopoverContent,exports.PopoverTrigger=PopoverTrigger,exports.Preloader=Preloader,exports.ProductCard=ProductCard,exports.ProductImage=ProductImage,exports.ProductInventoryGrid=ProductInventoryGrid,exports.ProductOverviewPage=ProductOverviewPage,exports.Progress=Progress,exports.RadioGroup=RadioGroup$1,exports.RadioGroupItem=RadioGroupItem,exports.ResellerBillingOverviewCard=ResellerBillingOverviewCard,exports.ResellerCard=ResellerCard,exports.ResellerOverview=ResellerOverview,exports.ResellerQualificationsCard=ResellerQualificationsCard,exports.ReturnsTable=ReturnsTable,exports.RichTextEditor=RichTextEditor,exports.SalesChart=SalesChart,exports.SalesOverviewCard=SalesOverviewCard,exports.ScrollArea=ScrollArea,exports.ScrollBar=ScrollBar,exports.SearchPage=SearchPage,exports.SearchPageGrid=SearchPageGrid,exports.Select=Select$1,exports.SelectContent=SelectContent,exports.SelectGroup=SelectGroup,exports.SelectItem=SelectItem,exports.SelectLabel=SelectLabel,exports.SelectScrollDownButton=SelectScrollDownButton,exports.SelectScrollUpButton=SelectScrollUpButton,exports.SelectTrigger=SelectTrigger,exports.SelectValue=SelectValue,exports.Separator=Separator$1,exports.Sheet=Sheet,exports.SheetClose=SheetClose,exports.SheetContent=SheetContent,exports.SheetDescription=SheetDescription,exports.SheetFooter=SheetFooter,exports.SheetHeader=SheetHeader,exports.SheetOverlay=SheetOverlay,exports.SheetPortal=SheetPortal,exports.SheetTitle=SheetTitle,exports.SheetTrigger=SheetTrigger,exports.Sidebar=Sidebar,exports.SidebarContent=SidebarContent,exports.SidebarFooter=SidebarFooter,exports.SidebarGroup=SidebarGroup,exports.SidebarGroupAction=SidebarGroupAction,exports.SidebarGroupContent=SidebarGroupContent,exports.SidebarGroupLabel=SidebarGroupLabel,exports.SidebarHeader=SidebarHeader,exports.SidebarInput=SidebarInput,exports.SidebarInset=SidebarInset,exports.SidebarMenu=SidebarMenu,exports.SidebarMenuAction=SidebarMenuAction,exports.SidebarMenuBadge=SidebarMenuBadge,exports.SidebarMenuButton=SidebarMenuButton,exports.SidebarMenuItem=SidebarMenuItem,exports.SidebarMenuSkeleton=SidebarMenuSkeleton,exports.SidebarMenuSub=SidebarMenuSub,exports.SidebarMenuSubButton=SidebarMenuSubButton,exports.SidebarMenuSubItem=SidebarMenuSubItem,exports.SidebarProvider=SidebarProvider,exports.SidebarRail=SidebarRail,exports.SidebarSeparator=SidebarSeparator,exports.SidebarTrigger=SidebarTrigger,exports.Skeleton=Skeleton,exports.Switch=Switch,exports.Table=Table,exports.TableBody=TableBody,exports.TableCaption=TableCaption,exports.TableCell=TableCell,exports.TableFooter=TableFooter,exports.TableHead=TableHead,exports.TableHeader=TableHeader,exports.TableRow=TableRow,exports.Tabs=Tabs,exports.TabsContent=TabsContent,exports.TabsList=TabsList,exports.TabsTrigger=TabsTrigger,exports.Textarea=Textarea,exports.Toast=Toast,exports.ToastAction=ToastAction,exports.ToastClose=ToastClose,exports.ToastDescription=ToastDescription,exports.ToastProvider=ToastProvider,exports.ToastTitle=ToastTitle,exports.ToastViewport=ToastViewport,exports.Toaster=Toaster,exports.Tooltip=Tooltip$1,exports.TooltipContent=TooltipContent,exports.TooltipProvider=TooltipProvider,exports.TooltipTrigger=TooltipTrigger,exports.TopPercentTreemap=TopPercentTreemap,exports.Topbar=Topbar,exports.Treemap=Treemap,exports.badgeVariants=badgeVariants,exports.buttonVariants=buttonVariants,exports.formatMoney=formatMoney,exports.formatNumber=formatNumber,exports.formatYYYYMMDDIntToDateString=formatYYYYMMDDIntToDateString,exports.toast=toast,exports.useChat=useChat,exports.useGeminiApiKey=useGeminiApiKey,exports.useIsMobile=useIsMobile,exports.useSidebar=useSidebar,exports.useToast=useToast,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})}));