directus-extension-synque-ai 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,674 @@
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+ Preamble
9
+
10
+ The GNU General Public License is a free, copyleft license for
11
+ software and other kinds of works.
12
+
13
+ The licenses for most software and other practical works are designed
14
+ to take away your freedom to share and change the works. By contrast,
15
+ the GNU General Public License is intended to guarantee your freedom to
16
+ share and change all versions of a program--to make sure it remains free
17
+ software for all its users. We, the Free Software Foundation, use the
18
+ GNU General Public License for most of our software; it applies also to
19
+ any other work released this way by its authors. You can apply it to
20
+ your programs, too.
21
+
22
+ When we speak of free software, we are referring to freedom, not
23
+ price. Our General Public Licenses are designed to make sure that you
24
+ have the freedom to distribute copies of free software (and charge for
25
+ them if you wish), that you receive source code or can get it if you
26
+ want it, that you can change the software or use pieces of it in new
27
+ free programs, and that you know you can do these things.
28
+
29
+ To protect your rights, we need to prevent others from denying you
30
+ these rights or asking you to surrender the rights. Therefore, you have
31
+ certain responsibilities if you distribute copies of the software, or if
32
+ you modify it: responsibilities to respect the freedom of others.
33
+
34
+ For example, if you distribute copies of such a program, whether
35
+ gratis or for a fee, you must pass on to the recipients the same
36
+ freedoms that you received. You must make sure that they, too, receive
37
+ or can get the source code. And you must show them these terms so they
38
+ know their rights.
39
+
40
+ Developers that use the GNU GPL protect your rights with two steps:
41
+ (1) assert copyright on the software, and (2) offer you this License
42
+ giving you legal permission to copy, distribute and/or modify it.
43
+
44
+ For the developers' and authors' protection, the GPL clearly explains
45
+ that there is no warranty for this free software. For both users' and
46
+ authors' sake, the GPL requires that modified versions be marked as
47
+ changed, so that their problems will not be attributed erroneously to
48
+ authors of previous versions.
49
+
50
+ Some devices are designed to deny users access to install or run
51
+ modified versions of the software inside them, although the manufacturer
52
+ can do so. This is fundamentally incompatible with the aim of
53
+ protecting users' freedom to change the software. The systematic
54
+ pattern of such abuse occurs in the area of products for individuals to
55
+ use, which is precisely where it is most unacceptable. Therefore, we
56
+ have designed this version of the GPL to prohibit the practice for those
57
+ products. If such problems arise substantially in other domains, we
58
+ stand ready to extend this provision to those domains in future versions
59
+ of the GPL, as needed to protect the freedom of users.
60
+
61
+ Finally, every program is threatened constantly by software patents.
62
+ States should not allow patents to restrict development and use of
63
+ software on general-purpose computers, but in those that do, we wish to
64
+ avoid the special danger that patents applied to a free program could
65
+ make it effectively proprietary. To prevent this, the GPL assures that
66
+ patents cannot be used to render the program non-free.
67
+
68
+ The precise terms and conditions for copying, distribution and
69
+ modification follow.
70
+
71
+ TERMS AND CONDITIONS
72
+
73
+ 0. Definitions.
74
+
75
+ "This License" refers to version 3 of the GNU General Public License.
76
+
77
+ "Copyright" also means copyright-like laws that apply to other kinds of
78
+ works, such as semiconductor masks.
79
+
80
+ "The Program" refers to any copyrightable work licensed under this
81
+ License. Each licensee is addressed as "you". "Licensees" and
82
+ "recipients" may be individuals or organizations.
83
+
84
+ To "modify" a work means to copy from or adapt all or part of the work
85
+ in a fashion requiring copyright permission, other than the making of an
86
+ exact copy. The resulting work is called a "modified version" of the
87
+ earlier work or a work "based on" the earlier work.
88
+
89
+ A "covered work" means either the unmodified Program or a work based
90
+ on the Program.
91
+
92
+ To "propagate" a work means to do anything with it that, without
93
+ permission, would make you directly or secondarily liable for
94
+ infringement under applicable copyright law, except executing it on a
95
+ computer or modifying a private copy. Propagation includes copying,
96
+ distribution (with or without modification), making available to the
97
+ public, and in some countries other activities as well.
98
+
99
+ To "convey" a work means any kind of propagation that enables other
100
+ parties to make or receive copies. Mere interaction with a user through
101
+ a computer network, with no transfer of a copy, is not conveying.
102
+
103
+ An interactive user interface displays "Appropriate Legal Notices"
104
+ to the extent that it includes a convenient and prominently visible
105
+ feature that (1) displays an appropriate copyright notice, and (2)
106
+ tells the user that there is no warranty for the work (except to the
107
+ extent that warranties are provided), that licensees may convey the
108
+ work under this License, and how to view a copy of this License. If
109
+ the interface presents a list of user commands or options, such as a
110
+ menu, a prominent item in the list meets this criterion.
111
+
112
+ 1. Source Code.
113
+
114
+ The "source code" for a work means the preferred form of the work
115
+ for making modifications to it. "Object code" means any non-source
116
+ form of a work.
117
+
118
+ A "Standard Interface" means an interface that either is an official
119
+ standard defined by a recognized standards body, or, in the case of
120
+ interfaces specified for a particular programming language, one that
121
+ is widely used among developers working in that language.
122
+
123
+ The "System Libraries" of an executable work include anything, other
124
+ than the work as a whole, that (a) is included in the normal form of
125
+ packaging a Major Component, but which is not part of that Major
126
+ Component, and (b) serves only to enable use of the work with that
127
+ Major Component, or to implement a Standard Interface for which an
128
+ implementation is available to the public in source code form. A
129
+ "Major Component", in this context, means a major essential component
130
+ (kernel, window system, and so on) of the specific operating system
131
+ (if any) on which the executable work runs, or a compiler used to
132
+ produce the work, or an object code interpreter used to run it.
133
+
134
+ The "Corresponding Source" for a work in object code form means all
135
+ the source code needed to generate, install, and (for an executable
136
+ work) run the object code and to modify the work, including scripts to
137
+ control those activities. However, it does not include the work's
138
+ System Libraries, or general-purpose tools or generally available free
139
+ programs which are used unmodified in performing those activities but
140
+ which are not part of the work. For example, Corresponding Source
141
+ includes interface definition files associated with source files for
142
+ the work, and the source code for shared libraries and dynamically
143
+ linked subprograms that the work is specifically designed to require,
144
+ such as by intimate data communication or control flow between those
145
+ subprograms and other parts of the work.
146
+
147
+ The Corresponding Source need not include anything that users
148
+ can regenerate automatically from other parts of the Corresponding
149
+ Source.
150
+
151
+ The Corresponding Source for a work in source code form is that
152
+ same work.
153
+
154
+ 2. Basic Permissions.
155
+
156
+ All rights granted under this License are granted for the term of
157
+ copyright on the Program, and are irrevocable provided the stated
158
+ conditions are met. This License explicitly affirms your unlimited
159
+ permission to run the unmodified Program. The output from running a
160
+ covered work is covered by this License only if the output, given its
161
+ content, constitutes a covered work. This License acknowledges your
162
+ rights of fair use or other equivalent, as provided by copyright law.
163
+
164
+ You may make, run and propagate covered works that you do not
165
+ convey, without conditions so long as your license otherwise remains
166
+ in force. You may convey covered works to others for the sole purpose
167
+ of having them make modifications exclusively for you, or provide you
168
+ with facilities for running those works, provided that you comply with
169
+ the terms of this License in conveying all material for which you do
170
+ not control copyright. Those thus making or running the covered works
171
+ for you must do so exclusively on your behalf, under your direction
172
+ and control, on terms that prohibit them from making any copies of
173
+ your copyrighted material outside their relationship with you.
174
+
175
+ Conveying under any other circumstances is permitted solely under
176
+ the conditions stated below. Sublicensing is not allowed; section 10
177
+ makes it unnecessary.
178
+
179
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
+
181
+ No covered work shall be deemed part of an effective technological
182
+ measure under any applicable law fulfilling obligations under article
183
+ 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184
+ similar laws prohibiting or restricting circumvention of such
185
+ measures.
186
+
187
+ When you convey a covered work, you waive any legal power to forbid
188
+ circumvention of technological measures to the extent such circumvention
189
+ is effected by exercising rights under this License with respect to
190
+ the covered work, and you disclaim any intention to limit operation or
191
+ modification of the work as a means of enforcing, against the work's
192
+ users, your or third parties' legal rights to forbid circumvention of
193
+ technological measures.
194
+
195
+ 4. Conveying Verbatim Copies.
196
+
197
+ You may convey verbatim copies of the Program's source code as you
198
+ receive it, in any medium, provided that you conspicuously and
199
+ appropriately publish on each copy an appropriate copyright notice;
200
+ keep intact all notices stating that this License and any
201
+ non-permissive terms added in accord with section 7 apply to the code;
202
+ keep intact all notices of the absence of any warranty; and give all
203
+ recipients a copy of this License along with the Program.
204
+
205
+ You may charge any price or no price for each copy that you convey,
206
+ and you may offer support or warranty protection for a fee.
207
+
208
+ 5. Conveying Modified Source Versions.
209
+
210
+ You may convey a work based on the Program, or the modifications to
211
+ produce it from the Program, in the form of source code under the
212
+ terms of section 4, provided that you also meet all of these conditions:
213
+
214
+ a) The work must carry prominent notices stating that you modified
215
+ it, and giving a relevant date.
216
+
217
+ b) The work must carry prominent notices stating that it is
218
+ released under this License and any conditions added under section
219
+ 7. This requirement modifies the requirement in section 4 to
220
+ "keep intact all notices".
221
+
222
+ c) You must license the entire work, as a whole, under this
223
+ License to anyone who comes into possession of a copy. This
224
+ License will therefore apply, along with any applicable section 7
225
+ additional terms, to the whole of the work, and all its parts,
226
+ regardless of how they are packaged. This License gives no
227
+ permission to license the work in any other way, but it does not
228
+ invalidate such permission if you have separately received it.
229
+
230
+ d) If the work has interactive user interfaces, each must display
231
+ Appropriate Legal Notices; however, if the Program has interactive
232
+ interfaces that do not display Appropriate Legal Notices, your
233
+ work need not make them do so.
234
+
235
+ A compilation of a covered work with other separate and independent
236
+ works, which are not by their nature extensions of the covered work,
237
+ and which are not combined with it such as to form a larger program,
238
+ in or on a volume of a storage or distribution medium, is called an
239
+ "aggregate" if the compilation and its resulting copyright are not
240
+ used to limit the access or legal rights of the compilation's users
241
+ beyond what the individual works permit. Inclusion of a covered work
242
+ in an aggregate does not cause this License to apply to the other
243
+ parts of the aggregate.
244
+
245
+ 6. Conveying Non-Source Forms.
246
+
247
+ You may convey a covered work in object code form under the terms
248
+ of sections 4 and 5, provided that you also convey the
249
+ machine-readable Corresponding Source under the terms of this License,
250
+ in one of these ways:
251
+
252
+ a) Convey the object code in, or embodied in, a physical product
253
+ (including a physical distribution medium), accompanied by the
254
+ Corresponding Source fixed on a durable physical medium
255
+ customarily used for software interchange.
256
+
257
+ b) Convey the object code in, or embodied in, a physical product
258
+ (including a physical distribution medium), accompanied by a
259
+ written offer, valid for at least three years and valid for as
260
+ long as you offer spare parts or customer support for that product
261
+ model, to give anyone who possesses the object code either (1) a
262
+ copy of the Corresponding Source for all the software in the
263
+ product that is covered by this License, on a durable physical
264
+ medium customarily used for software interchange, for a price no
265
+ more than your reasonable cost of physically performing this
266
+ conveying of source, or (2) access to copy the
267
+ Corresponding Source from a network server at no charge.
268
+
269
+ c) Convey individual copies of the object code with a copy of the
270
+ written offer to provide the Corresponding Source. This
271
+ alternative is allowed only occasionally and noncommercially, and
272
+ only if you received the object code with such an offer, in accord
273
+ with subsection 6b.
274
+
275
+ d) Convey the object code by offering access from a designated
276
+ place (gratis or for a charge), and offer equivalent access to the
277
+ Corresponding Source in the same way through the same place at no
278
+ further charge. You need not require recipients to copy the
279
+ Corresponding Source along with the object code. If the place to
280
+ copy the object code is a network server, the Corresponding Source
281
+ may be on a different server (operated by you or a third party)
282
+ that supports equivalent copying facilities, provided you maintain
283
+ clear directions next to the object code saying where to find the
284
+ Corresponding Source. Regardless of what server hosts the
285
+ Corresponding Source, you remain obligated to ensure that it is
286
+ available for as long as needed to satisfy these requirements.
287
+
288
+ e) Convey the object code using peer-to-peer transmission, provided
289
+ you inform other peers where the object code and Corresponding
290
+ Source of the work are being offered to the general public at no
291
+ charge under subsection 6d.
292
+
293
+ A separable portion of the object code, whose source code is excluded
294
+ from the Corresponding Source as a System Library, need not be
295
+ included in conveying the object code work.
296
+
297
+ A "User Product" is either (1) a "consumer product", which means any
298
+ tangible personal property which is normally used for personal, family,
299
+ or household purposes, or (2) anything designed or sold for incorporation
300
+ into a dwelling. In determining whether a product is a consumer product,
301
+ doubtful cases shall be resolved in favor of coverage. For a particular
302
+ product received by a particular user, "normally used" refers to a
303
+ typical or common use of that class of product, regardless of the status
304
+ of the particular user or of the way in which the particular user
305
+ actually uses, or expects or is expected to use, the product. A product
306
+ is a consumer product regardless of whether the product has substantial
307
+ commercial, industrial or non-consumer uses, unless such uses represent
308
+ the only significant mode of use of the product.
309
+
310
+ "Installation Information" for a User Product means any methods,
311
+ procedures, authorization keys, or other information required to install
312
+ and execute modified versions of a covered work in that User Product from
313
+ a modified version of its Corresponding Source. The information must
314
+ suffice to ensure that the continued functioning of the modified object
315
+ code is in no case prevented or interfered with solely because
316
+ modification has been made.
317
+
318
+ If you convey an object code work under this section in, or with, or
319
+ specifically for use in, a User Product, and the conveying occurs as
320
+ part of a transaction in which the right of possession and use of the
321
+ User Product is transferred to the recipient in perpetuity or for a
322
+ fixed term (regardless of how the transaction is characterized), the
323
+ Corresponding Source conveyed under this section must be accompanied
324
+ by the Installation Information. But this requirement does not apply
325
+ if neither you nor any third party retains the ability to install
326
+ modified object code on the User Product (for example, the work has
327
+ been installed in ROM).
328
+
329
+ The requirement to provide Installation Information does not include a
330
+ requirement to continue to provide support service, warranty, or updates
331
+ for a work that has been modified or installed by the recipient, or for
332
+ the User Product in which it has been modified or installed. Access to a
333
+ network may be denied when the modification itself materially and
334
+ adversely affects the operation of the network or violates the rules and
335
+ protocols for communication across the network.
336
+
337
+ Corresponding Source conveyed, and Installation Information provided,
338
+ in accord with this section must be in a format that is publicly
339
+ documented (and with an implementation available to the public in
340
+ source code form), and must require no special password or key for
341
+ unpacking, reading or copying.
342
+
343
+ 7. Additional Terms.
344
+
345
+ "Additional permissions" are terms that supplement the terms of this
346
+ License by making exceptions from one or more of its conditions.
347
+ Additional permissions that are applicable to the entire Program shall
348
+ be treated as though they were included in this License, to the extent
349
+ that they are valid under applicable law. If additional permissions
350
+ apply only to part of the Program, that part may be used separately
351
+ under those permissions, but the entire Program remains governed by
352
+ this License without regard to the additional permissions.
353
+
354
+ When you convey a copy of a covered work, you may at your option
355
+ remove any additional permissions from that copy, or from any part of
356
+ it. (Additional permissions may be written to require their own
357
+ removal in certain cases when you modify the work.) You may place
358
+ additional permissions on material, added by you to a covered work,
359
+ for which you have or can give appropriate copyright permission.
360
+
361
+ Notwithstanding any other provision of this License, for material you
362
+ add to a covered work, you may (if authorized by the copyright holders of
363
+ that material) supplement the terms of this License with terms:
364
+
365
+ a) Disclaiming warranty or limiting liability differently from the
366
+ terms of sections 15 and 16 of this License; or
367
+
368
+ b) Requiring preservation of specified reasonable legal notices or
369
+ author attributions in that material or in the Appropriate Legal
370
+ Notices displayed by works containing it; or
371
+
372
+ c) Prohibiting misrepresentation of the origin of that material, or
373
+ requiring that modified versions of such material be marked in
374
+ reasonable ways as different from the original version; or
375
+
376
+ d) Limiting the use for publicity purposes of names of licensors or
377
+ authors of the material; or
378
+
379
+ e) Declining to grant rights under trademark law for use of some
380
+ trade names, trademarks, or service marks; or
381
+
382
+ f) Requiring indemnification of licensors and authors of that
383
+ material by anyone who conveys the material (or modified versions of
384
+ it) with contractual assumptions of liability to the recipient, for
385
+ any liability that these contractual assumptions directly impose on
386
+ those licensors and authors.
387
+
388
+ All other non-permissive additional terms are considered "further
389
+ restrictions" within the meaning of section 10. If the Program as you
390
+ received it, or any part of it, contains a notice stating that it is
391
+ governed by this License along with a term that is a further
392
+ restriction, you may remove that term. If a license document contains
393
+ a further restriction but permits relicensing or conveying under this
394
+ License, you may add to a covered work material governed by the terms
395
+ of that license document, provided that the further restriction does
396
+ not survive such relicensing or conveying.
397
+
398
+ If you add terms to a covered work in accord with this section, you
399
+ must place, in the relevant source files, a statement of the
400
+ additional terms that apply to those files, or a notice indicating
401
+ where to find the applicable terms.
402
+
403
+ Additional terms, permissive or non-permissive, may be stated in the
404
+ form of a separately written license, or stated as exceptions;
405
+ the above requirements apply either way.
406
+
407
+ 8. Termination.
408
+
409
+ You may not propagate or modify a covered work except as expressly
410
+ provided under this License. Any attempt otherwise to propagate or
411
+ modify it is void, and will automatically terminate your rights under
412
+ this License (including any patent licenses granted under the third
413
+ paragraph of section 11).
414
+
415
+ However, if you cease all violation of this License, then your
416
+ license from a particular copyright holder is reinstated (a)
417
+ provisionally, unless and until the copyright holder explicitly and
418
+ finally terminates your license, and (b) permanently, if the copyright
419
+ holder fails to notify you of the violation by some reasonable means
420
+ prior to 60 days after the cessation.
421
+
422
+ Moreover, your license from a particular copyright holder is
423
+ reinstated permanently if the copyright holder notifies you of the
424
+ violation by some reasonable means, this is the first time you have
425
+ received notice of violation of this License (for any work) from that
426
+ copyright holder, and you cure the violation prior to 30 days after
427
+ your receipt of the notice.
428
+
429
+ Termination of your rights under this section does not terminate the
430
+ licenses of parties who have received copies or rights from you under
431
+ this License. If your rights have been terminated and not permanently
432
+ reinstated, you do not qualify to receive new licenses for the same
433
+ material under section 10.
434
+
435
+ 9. Acceptance Not Required for Having Copies.
436
+
437
+ You are not required to accept this License in order to receive or
438
+ run a copy of the Program. Ancillary propagation of a covered work
439
+ occurring solely as a consequence of using peer-to-peer transmission
440
+ to receive a copy likewise does not require acceptance. However,
441
+ nothing other than this License grants you permission to propagate or
442
+ modify any covered work. These actions infringe copyright if you do
443
+ not accept this License. Therefore, by modifying or propagating a
444
+ covered work, you indicate your acceptance of this License to do so.
445
+
446
+ 10. Automatic Licensing of Downstream Recipients.
447
+
448
+ Each time you convey a covered work, the recipient automatically
449
+ receives a license from the original licensors, to run, modify and
450
+ propagate that work, subject to this License. You are not responsible
451
+ for enforcing compliance by third parties with this License.
452
+
453
+ An "entity transaction" is a transaction transferring control of an
454
+ organization, or substantially all assets of one, or subdividing an
455
+ organization, or merging organizations. If propagation of a covered
456
+ work results from an entity transaction, each party to that
457
+ transaction who receives a copy of the work also receives whatever
458
+ licenses to the work the party's predecessor in interest had or could
459
+ give under the previous paragraph, plus a right to possession of the
460
+ Corresponding Source of the work from the predecessor in interest, if
461
+ the predecessor has it or can get it with reasonable efforts.
462
+
463
+ You may not impose any further restrictions on the exercise of the
464
+ rights granted or affirmed under this License. For example, you may
465
+ not impose a license fee, royalty, or other charge for exercise of
466
+ rights granted under this License, and you may not initiate litigation
467
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
468
+ any patent claim is infringed by making, using, selling, offering for
469
+ sale, or importing the Program or any portion of it.
470
+
471
+ 11. Patents.
472
+
473
+ A "contributor" is a copyright holder who authorizes use under this
474
+ License of the Program or a work on which the Program is based. The
475
+ work thus licensed is called the contributor's "contributor version".
476
+
477
+ A contributor's "essential patent claims" are all patent claims
478
+ owned or controlled by the contributor, whether already acquired or
479
+ hereafter acquired, that would be infringed by some manner, permitted
480
+ by this License, of making, using, or selling its contributor version,
481
+ but do not include claims that would be infringed only as a
482
+ consequence of further modification of the contributor version. For
483
+ purposes of this definition, "control" includes the right to grant
484
+ patent sublicenses in a manner consistent with the requirements of
485
+ this License.
486
+
487
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
488
+ patent license under the contributor's essential patent claims, to
489
+ make, use, sell, offer for sale, import and otherwise run, modify and
490
+ propagate the contents of its contributor version.
491
+
492
+ In the following three paragraphs, a "patent license" is any express
493
+ agreement or commitment, however denominated, not to enforce a patent
494
+ (such as an express permission to practice a patent or covenant not to
495
+ sue for patent infringement). To "grant" such a patent license to a
496
+ party means to make such an agreement or commitment not to enforce a
497
+ patent against the party.
498
+
499
+ If you convey a covered work, knowingly relying on a patent license,
500
+ and the Corresponding Source of the work is not available for anyone
501
+ to copy, free of charge and under the terms of this License, through a
502
+ publicly available network server or other readily accessible means,
503
+ then you must either (1) cause the Corresponding Source to be so
504
+ available, or (2) arrange to deprive yourself of the benefit of the
505
+ patent license for this particular work, or (3) arrange, in a manner
506
+ consistent with the requirements of this License, to extend the patent
507
+ license to downstream recipients. "Knowingly relying" means you have
508
+ actual knowledge that, but for the patent license, your conveying the
509
+ covered work in a country, or your recipient's use of the covered work
510
+ in a country, would infringe one or more identifiable patents in that
511
+ country that you have reason to believe are valid.
512
+
513
+ If, pursuant to or in connection with a single transaction or
514
+ arrangement, you convey, or propagate by procuring conveyance of, a
515
+ covered work, and grant a patent license to some of the parties
516
+ receiving the covered work authorizing them to use, propagate, modify
517
+ or convey a specific copy of the covered work, then the patent license
518
+ you grant is automatically extended to all recipients of the covered
519
+ work and works based on it.
520
+
521
+ A patent license is "discriminatory" if it does not include within
522
+ the scope of its coverage, prohibits the exercise of, or is
523
+ conditioned on the non-exercise of one or more of the rights that are
524
+ specifically granted under this License. You may not convey a covered
525
+ work if you are a party to an arrangement with a third party that is
526
+ in the business of distributing software, under which you make payment
527
+ to the third party based on the extent of your activity of conveying
528
+ the work, and under which the third party grants, to any of the
529
+ parties who would receive the covered work from you, a discriminatory
530
+ patent license (a) in connection with copies of the covered work
531
+ conveyed by you (or copies made from those copies), or (b) primarily
532
+ for and in connection with specific products or compilations that
533
+ contain the covered work, unless you entered into that arrangement,
534
+ or that patent license was granted, prior to 28 March 2007.
535
+
536
+ Nothing in this License shall be construed as excluding or limiting
537
+ any implied license or other defenses to infringement that may
538
+ otherwise be available to you under applicable patent law.
539
+
540
+ 12. No Surrender of Others' Freedom.
541
+
542
+ If conditions are imposed on you (whether by court order, agreement or
543
+ otherwise) that contradict the conditions of this License, they do not
544
+ excuse you from the conditions of this License. If you cannot convey a
545
+ covered work so as to satisfy simultaneously your obligations under this
546
+ License and any other pertinent obligations, then as a consequence you may
547
+ not convey it at all. For example, if you agree to terms that obligate you
548
+ to collect a royalty for further conveying from those to whom you convey
549
+ the Program, the only way you could satisfy both those terms and this
550
+ License would be to refrain entirely from conveying the Program.
551
+
552
+ 13. Use with the GNU Affero General Public License.
553
+
554
+ Notwithstanding any other provision of this License, you have
555
+ permission to link or combine any covered work with a work licensed
556
+ under version 3 of the GNU Affero General Public License into a single
557
+ combined work, and to convey the resulting work. The terms of this
558
+ License will continue to apply to the part which is the covered work,
559
+ but the special requirements of the GNU Affero General Public License,
560
+ section 13, concerning interaction through a network will apply to the
561
+ combination as such.
562
+
563
+ 14. Revised Versions of this License.
564
+
565
+ The Free Software Foundation may publish revised and/or new versions of
566
+ the GNU General Public License from time to time. Such new versions will
567
+ be similar in spirit to the present version, but may differ in detail to
568
+ address new problems or concerns.
569
+
570
+ Each version is given a distinguishing version number. If the
571
+ Program specifies that a certain numbered version of the GNU General
572
+ Public License "or any later version" applies to it, you have the
573
+ option of following the terms and conditions either of that numbered
574
+ version or of any later version published by the Free Software
575
+ Foundation. If the Program does not specify a version number of the
576
+ GNU General Public License, you may choose any version ever published
577
+ by the Free Software Foundation.
578
+
579
+ If the Program specifies that a proxy can decide which future
580
+ versions of the GNU General Public License can be used, that proxy's
581
+ public statement of acceptance of a version permanently authorizes you
582
+ to choose that version for the Program.
583
+
584
+ Later license versions may give you additional or different
585
+ permissions. However, no additional obligations are imposed on any
586
+ author or copyright holder as a result of your choosing to follow a
587
+ later version.
588
+
589
+ 15. Disclaimer of Warranty.
590
+
591
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592
+ APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593
+ HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594
+ OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597
+ IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599
+
600
+ 16. Limitation of Liability.
601
+
602
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604
+ THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607
+ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608
+ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609
+ EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610
+ SUCH DAMAGES.
611
+
612
+ 17. Interpretation of Sections 15 and 16.
613
+
614
+ If the disclaimer of warranty and limitation of liability provided
615
+ above cannot be given local legal effect according to their terms,
616
+ reviewing courts shall apply local law that most closely approximates
617
+ an absolute waiver of all civil liability in connection with the
618
+ Program, unless a warranty or assumption of liability accompanies a
619
+ copy of the Program in return for a fee.
620
+
621
+ END OF TERMS AND CONDITIONS
622
+
623
+ How to Apply These Terms to Your New Programs
624
+
625
+ If you develop a new program, and you want it to be of the greatest
626
+ possible use to the public, the best way to achieve this is to make it
627
+ free software which everyone can redistribute and change under these terms.
628
+
629
+ To do so, attach the following notices to the program. It is safest
630
+ to attach them to the start of each source file to most effectively
631
+ state the exclusion of warranty; and each file should have at least
632
+ the "copyright" line and a pointer to where the full notice is found.
633
+
634
+ <one line to give the program's name and a brief idea of what it does.>
635
+ Copyright (C) <year> <name of author>
636
+
637
+ This program is free software: you can redistribute it and/or modify
638
+ it under the terms of the GNU General Public License as published by
639
+ the Free Software Foundation, either version 3 of the License, or
640
+ (at your option) any later version.
641
+
642
+ This program is distributed in the hope that it will be useful,
643
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
644
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645
+ GNU General Public License for more details.
646
+
647
+ You should have received a copy of the GNU General Public License
648
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
649
+
650
+ Also add information on how to contact you by electronic and paper mail.
651
+
652
+ If the program does terminal interaction, make it output a short
653
+ notice like this when it starts in an interactive mode:
654
+
655
+ <program> Copyright (C) <year> <name of author>
656
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657
+ This is free software, and you are welcome to redistribute it
658
+ under certain conditions; type `show c' for details.
659
+
660
+ The hypothetical commands `show w' and `show c' should show the appropriate
661
+ parts of the General Public License. Of course, your program's commands
662
+ might be different; for a GUI interface, you would use an "about box".
663
+
664
+ You should also get your employer (if you work as a programmer) or school,
665
+ if any, to sign a "copyright disclaimer" for the program, if necessary.
666
+ For more information on this, and how to apply and follow the GNU GPL, see
667
+ <https://www.gnu.org/licenses/>.
668
+
669
+ The GNU General Public License does not permit incorporating your program
670
+ into proprietary programs. If your program is a subroutine library, you
671
+ may consider it more useful to permit linking proprietary applications with
672
+ the library. If this is what you want to do, use the GNU Lesser General
673
+ Public License instead of this License. But first, please read
674
+ <https://www.gnu.org/licenses/why-not-lgpl.html>.
package/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # synqueD11Gpt
2
+
3
+ Directus 11 AI Agent Extension - Transform your Directus CMS with intelligent automation and natural language processing.
4
+
5
+ ## Features
6
+
7
+ - Natural language commands for Directus CMS
8
+ - Smart automation with AI-powered decision making
9
+ - Real-time processing with MCP integration
10
+ - Context-aware data operations
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ npm install synqued11gpt
16
+ ```
17
+
18
+ Or add to your Directus extensions folder manually.
19
+
20
+ ## Configuration
21
+
22
+ 1. Go to **Settings** > **Project Settings** > **Module Bar**
23
+ 2. Enable **AI Agent** module
24
+ 3. Navigate to AI Agent > Settings
25
+ 4. Configure:
26
+ - **Directus URL**: Your Directus instance URL
27
+ - **Admin Token**: Your Directus admin access token
28
+ - **AI API Key**: Your OpenAI API key
29
+ - **AI Model**: Model to use (e.g., `gpt-4o`, `gpt-4-turbo`)
30
+ - **AI Base URL**: API endpoint (default: `https://api.openai.com/v1`)
31
+
32
+ ## Usage
33
+
34
+ 1. Open AI Agent > Chat
35
+ 2. Type natural language commands like:
36
+ - "Show me all collections"
37
+ - "Create a new blog post titled 'Hello World'"
38
+ - "List all users"
39
+ - "Update the status of article 5 to published"
40
+
41
+ ## Supported AI Providers
42
+
43
+ - OpenAI (GPT-4, GPT-4 Turbo, GPT-4o)
44
+ - Any OpenAI-compatible API (DeepSeek, etc.)
45
+
46
+ ## Requirements
47
+
48
+ - Directus 10.x or 11.x
49
+ - Node.js 18+
50
+
51
+ ## License
52
+
53
+ MIT
package/dist/api.js ADDED
@@ -0,0 +1,5 @@
1
+ import{spawn as e}from"child_process";import t from"node:http";import r from"node:https";import o from"node:zlib";import n,{PassThrough as i,pipeline as s}from"node:stream";import{Buffer as a}from"node:buffer";import{types as l,promisify as c,deprecate as u}from"node:util";import{format as d}from"node:url";import{isIP as f}from"node:net";import"node:fs";import"node:path";const h=[{type:"function",function:{name:"system-prompt",description:"Get system information and role. This should be the first call.",parameters:{type:"object",properties:{},additionalProperties:!1}}},{type:"function",function:{name:"users-me",description:"Get current user information.",parameters:{type:"object",properties:{},additionalProperties:!1}}},{type:"function",function:{name:"read-users",description:"List users. Use for searching by name.",parameters:{type:"object",properties:{query:{type:"object",properties:{filter:{type:"object",description:"User filtering"},fields:{type:"array",items:{type:"string"}},limit:{type:"number"},search:{type:"string",description:"Name search"}}}}}}},{type:"function",function:{name:"read-collections",description:"Dynamically get all available collections and their structures.",parameters:{type:"object",properties:{},additionalProperties:!1}}},{type:"function",function:{name:"read-items",description:"Get data from any collection. Dynamically determine collection name.",parameters:{type:"object",properties:{collection:{type:"string",description:"Dynamic collection name"},query:{type:"object",properties:{filter:{type:"object"},limit:{type:"number"},offset:{type:"number"},fields:{type:"array",items:{type:"string"}},sort:{type:"array",items:{type:"string"}},search:{type:"string"}}}},required:["collection"]}}},{type:"function",function:{name:"create-item",description:"Add dynamic data to any collection.",parameters:{type:"object",properties:{collection:{type:"string",description:"Collection name"},item:{type:"object",description:"Record data to create",additionalProperties:!0}},required:["collection","item"]}}},{type:"function",function:{name:"update-item",description:"Update existing record.",parameters:{type:"object",properties:{collection:{type:"string",description:"Collection name"},id:{type:"string",description:"Record ID"},data:{type:"object",description:"Data to update",additionalProperties:!0}},required:["collection","id","data"]}}},{type:"function",function:{name:"read-flows",description:"List automated workflows.",parameters:{type:"object",properties:{query:{type:"object"}}}}},{type:"function",function:{name:"trigger-flow",description:"Trigger workflow.",parameters:{type:"object",properties:{id:{type:"string",description:"Flow ID"},data:{type:"object",additionalProperties:!0},keys:{type:"array",items:{type:"string"}}},required:["id"]}}},{type:"function",function:{name:"read-folders",description:"List file folders.",parameters:{type:"object",properties:{query:{type:"object"}}}}},{type:"function",function:{name:"read-files",description:"List files or get single file information.",parameters:{type:"object",properties:{query:{type:"object"},id:{type:"string",description:"File ID"},raw:{type:"boolean",description:"Get raw content"}}}}},{type:"function",function:{name:"import-file",description:"Upload file from URL.",parameters:{type:"object",properties:{url:{type:"string",description:"File URL"},data:{type:"object",additionalProperties:!0}},required:["url"]}}},{type:"function",function:{name:"update-files",description:"Update file information.",parameters:{type:"object",properties:{ids:{type:"array",items:{type:"string"}},data:{type:"object",additionalProperties:!0}},required:["ids","data"]}}},{type:"function",function:{name:"read-fields",description:"Get field definitions.",parameters:{type:"object",properties:{collection:{type:"string",description:"Collection name (optional)"}}}}},{type:"function",function:{name:"read-field",description:"Get specific field definition.",parameters:{type:"object",properties:{collection:{type:"string",description:"Collection name"},field:{type:"string",description:"Field name"}},required:["collection","field"]}}},{type:"function",function:{name:"create-field",description:"Create new field.",parameters:{type:"object",properties:{collection:{type:"string",description:"Collection name"},field:{type:"object",additionalProperties:!0}},required:["collection","field"]}}},{type:"function",function:{name:"update-field",description:"Update field definition.",parameters:{type:"object",properties:{collection:{type:"string",description:"Collection name"},field:{type:"string",description:"Field name"},data:{type:"object",additionalProperties:!0}},required:["collection","field","data"]}}},{type:"function",function:{name:"read-comments",description:"Get record comments.",parameters:{type:"object",properties:{collection:{type:"string",description:"Collection name"},item:{type:"string",description:"Record ID"}},required:["collection","item"]}}},{type:"function",function:{name:"upsert-comment",description:"Add or update comment.",parameters:{type:"object",properties:{collection:{type:"string",description:"Collection name"},item:{type:"string",description:"Record ID"},comment:{type:"string",description:"Comment text"},id:{type:"string",description:"Comment ID (for update)"}},required:["collection","item","comment"]}}},{type:"function",function:{name:"markdown-tool",description:"HTML-Markdown conversion.",parameters:{type:"object",properties:{content:{type:"string",description:"Content to convert"},to:{type:"string",enum:["html","markdown"],description:"Target format"}},required:["content","to"]}}}];class p{constructor(){this.nextId=1,this.pendingRequests=new Map,this.child=null,this.initialized=!1,this.connectPromise=null,this.timeout=6e4}async connect(e,t){if(this.connectPromise)return console.log("🔄 Using existing connection promise..."),this.connectPromise;if(this.initialized)console.log("✅ Already connected");else{this.connectPromise=this._doConnect(e,t);try{return await this.connectPromise,void(this.connectPromise=null)}catch(e){throw this.connectPromise=null,this.initialized=!1,e}}}async _doConnect(t,r){return new Promise((o,n)=>{if(!r||""===r.trim())return console.error("❌ Admin token is empty! MCP won't work."),void n(new Error("Admin token is required"));const i={...process.env,DIRECTUS_URL:t,DIRECTUS_TOKEN:r};console.log(`🔧 MCP connecting with URL: ${t}, Token: ${r?"SET ("+r.substring(0,10)+"...)":"NOT SET"}`),this.child=e("npx",["@directus/content-mcp@latest"],{stdio:["pipe","pipe","pipe"],env:i,shell:!0,cwd:process.cwd()});let s,a="",l=!1;this.child.stdout.on("data",e=>{a+=e.toString();const t=a.split("\n");a=t.pop(),t.forEach(e=>{if(e.trim())try{const t=JSON.parse(e);console.log("MCP Response:",t),1===t.id&&t.result&&!l?(clearTimeout(s),this.initialized=!0,l=!0,console.log("✅ MCP initialized successfully"),o()):this.handleMessage(t)}catch(t){console.log("MCP stdout:",e)}})}),this.child.stderr.on("data",e=>{const t=e.toString();console.error("MCP stderr:",t),!t.includes("Fatal error")&&!t.includes("ZodError")||l||(clearTimeout(s),l=!0,n(new Error("MCP Fatal Error: "+t)))}),this.child.on("error",e=>{console.error("MCP process error:",e),l||(clearTimeout(s),l=!0,n(e))}),this.child.on("close",e=>{console.log(`MCP process closed with code ${e}`),0===e||this.initialized||l||(clearTimeout(s),l=!0,n(new Error(`MCP process exited with code ${e}`)))}),s=setTimeout(async()=>{if(!l)try{console.log("🚀 Initializing MCP..."),await this._sendInitRequest()}catch(e){l||(l=!0,console.error("❌ MCP initialization error:",e),n(e))}},3e3),setTimeout(()=>{l||(clearTimeout(s),l=!0,n(new Error(`MCP connection timeout after ${this.timeout}ms`)))},this.timeout)})}async _sendInitRequest(){if(!this.child||!this.child.stdin)throw new Error("MCP child process not ready");const e={jsonrpc:"2.0",id:1,method:"initialize",params:{protocolVersion:"2024-11-05",capabilities:{},clientInfo:{name:"directus-extension-ai-agent",version:"1.0.0"}}};console.log("MCP Request:",e);try{this.child.stdin.write(JSON.stringify(e)+"\n")}catch(e){throw new Error(`Failed to send init request: ${e.message}`)}}async sendRequest(e,t={}){if(!this.child||!this.child.stdin)throw new Error("MCP client not connected");const r=this.nextId++,o={jsonrpc:"2.0",id:r,method:e,params:t};return console.log("MCP Request:",o),new Promise((t,n)=>{const i=setTimeout(()=>{this.pendingRequests.delete(r),console.error(`❌ MCP Request timeout for ${e}`),n(new Error(`Request timeout for ${e}`))},3e4);this.pendingRequests.set(r,{resolve:t,reject:n,timeout:i});try{this.child.stdin.write(JSON.stringify(o)+"\n")}catch(e){clearTimeout(i),this.pendingRequests.delete(r),n(e)}})}handleMessage(e){if(e.id&&this.pendingRequests.has(e.id)){const{resolve:t,reject:r,timeout:o}=this.pendingRequests.get(e.id);clearTimeout(o),this.pendingRequests.delete(e.id),e.error?(console.error("❌ MCP Error Response:",e.error),r(new Error(e.error.message||JSON.stringify(e.error)))):t(e.result)}}async callTool(e,t){if(!this.initialized)throw new Error("MCP client not initialized");console.log(`🔧 Calling tool: ${e} with args:`,t);try{const r=await this.sendRequest("tools/call",{name:e,arguments:t});return console.log(`✅ Tool ${e} result:`,JSON.stringify(r).substring(0,200)),r}catch(t){throw console.error(`❌ Tool ${e} error:`,t.message),t}}disconnect(){this.child&&(console.log("🔌 Disconnecting MCP"),this.child.kill(),this.child=null,this.initialized=!1,this.connectPromise=null,this.pendingRequests.clear())}}class m{constructor({apiKey:e,baseURL:t="https://api.openai.com/v1"}){this.apiKey=e,this.baseURL=t}async chat(e){const t=(await Promise.resolve().then(function(){return pe})).default,r=await t(`${this.baseURL}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify(e)});if(!r.ok){const e=await r.text();throw new Error(`OpenAI API error: ${r.status} - ${e}`)}return await r.json()}}async function y(e){try{console.log("🔍 Loading settings with raw SQL...");if(0===(await e.raw("\n SELECT COUNT(*) as count \n FROM information_schema.tables \n WHERE table_schema = DATABASE() \n AND table_name = 'ai_agent_settings'\n "))[0][0].count)return console.log("❌ Table doesn't exist"),{directus_url:"http://localhost:8055",admin_token:"",ai_model:"gpt-3.5-turbo",ai_base_url:"https://api.openai.com/v1",ai_api_key:""};const t=await e.raw("SELECT * FROM ai_agent_settings LIMIT 1");return t[0].length>0?(console.log("✅ Settings loaded from database"),t[0][0]):(console.log("⚠️ Table exists but no data"),{directus_url:"http://localhost:8055",admin_token:"",ai_model:"gpt-3.5-turbo",ai_base_url:"https://api.openai.com/v1",ai_api_key:""})}catch(e){return console.error("❌ Settings load error:",e.message),{directus_url:"http://localhost:8055",admin_token:"",ai_model:"gpt-3.5-turbo",ai_base_url:"https://api.openai.com/v1",ai_api_key:""}}}async function b(e){try{const t=e.match(/read-items.*collection[:\s]*["'](\w+)["']/i),r=e.match(/create-item.*collection[:\s]*["'](\w+)["']/i);if(t){const e=t[1];console.log(`🔧 Manual read-items: ${e}`);return g(await mcpClient.callTool("read-items",{collection:e,query:{sort:["-id"],limit:1}}))}return r?(console.log("🔧 Manual create-item detected but needs more params"),{message:"create-item parameters missing"}):null}catch(e){return console.error("Manual execution error:",e),null}}function _(e,t){if("read-items"===e&&!t.query){const{collection:e,...r}=t;return{collection:e,query:r}}return t}function g(e){try{if(e.isError)return{success:!1,error:"Tool failed",details:e.content};if(e.content&&Array.isArray(e.content)){const t=e.content.find(e=>"text"===e.type);if(t){const e=t.text.match(/<data>(.*?)<\/data>/s);if(e)try{const t=JSON.parse(e[1]);if(Array.isArray(t)&&t.length>0){const e=t[0],r=e.id||e.ID;return{success:!0,data:t,extracted_id:r,message:r?`ID: ${r} extracted`:"Data retrieved"}}return{success:!0,data:t}}catch(e){return{success:!0,data:t.text}}}}return{success:!0,data:e}}catch(e){return{success:!1,error:e.message}}}const w=[],S=[{name:"mcp-server",config:(e,t)=>{const{services:r,getSchema:o,database:n}=t,{ItemsService:i,UtilsService:s}=r;let a=null,l=null,c=null,u=null;const d=async()=>{new i("ai_agent_settings",{schema:await o()}),l=new s({schema:await o(),accountability:{role:"admin",admin:!0}}),await async function(e,t,r){if(!e){console.log("🔧 Creating settings table with raw SQL...");try{(await t.raw("\n SELECT COUNT(*) as count \n FROM information_schema.tables \n WHERE table_schema = DATABASE() \n AND table_name = 'ai_agent_settings'\n "))[0][0].count>0?console.log("✅ Settings table already exists"):(await t.raw("\n CREATE TABLE IF NOT EXISTS ai_agent_settings (\n id INT AUTO_INCREMENT PRIMARY KEY,\n directus_url VARCHAR(255),\n admin_token TEXT,\n ai_model VARCHAR(100),\n ai_api_key VARCHAR(255),\n ai_base_url VARCHAR(255)\n )\n "),console.log("✅ Table created")),await t.raw("\n INSERT IGNORE INTO directus_collections (collection, icon, note, singleton)\n VALUES ('ai_agent_settings', 'settings', 'AI Agent settings', true)\n ");const o=[["id","primary","input",1],["directus_url",null,"input",2],["admin_token",null,"input",3],["ai_model",null,"input",4],["ai_api_key",null,"input",5],["ai_base_url",null,"input",6]];for(const[e,r,n,i]of o)await t.raw("\n INSERT IGNORE INTO directus_fields (\n collection,\n field,\n special,\n interface,\n options,\n display,\n display_options,\n readonly,\n hidden,\n sort,\n width,\n translations,\n note,\n conditions,\n required,\n `group`,\n validation,\n validation_message\n )\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\n ",["ai_agent_settings",e,r,n,null,null,null,!1,!1,i,"full",null,null,null,!1,null,null,null]);0===(await t.raw("SELECT COUNT(*) as count FROM ai_agent_settings"))[0][0].count&&(await t.raw("\n INSERT INTO ai_agent_settings (directus_url, ai_model, ai_base_url)\n VALUES (?, ?, ?)\n ",["http://localhost:8055","gpt-3.5-turbo","https://api.openai.com/v1"]),console.log("✅ Default settings inserted")),console.log("🎉 Table and Directus metadata setup complete"),e=!0;const n=await r.clearCache({system:!0});console.log(n)}catch(e){console.error("❌ Table setup failed:",e)}}}(false,n,l)};d().catch(console.error),e.get("/settings",async(e,t)=>{try{if(!0!==e.accountability.admin)return t.status(403).json({success:!1,error:"Admin access required to view settings"});const r=await y(n);t.json({success:!0,data:r})}catch(e){console.error("Settings error:",e),t.status(500).json({success:!1,error:e.message})}}),e.post("/settings",async(e,t)=>{try{const r=new i("ai_agent_settings",{schema:await o(),accountability:e.accountability}),n=await r.readByQuery({limit:1});n.length>0?await r.updateOne(n[0].id,e.body):await r.createOne(e.body),u?.initialized&&(u.disconnect(),a=null),t.json({success:!0,message:"Settings saved"})}catch(e){console.error("Save error:",e),t.status(500).json({success:!1,error:e.message})}}),e.post("/prompt",async(e,t)=>{if(!0!==e.accountability.admin)return t.status(403).json({success:!1,error:"Admin access required to use AI Agent"});try{const{prompt:r}=e.body;if(!r)return t.status(400).json({success:!1,error:"Prompt is required"});console.log("User Prompt:",r);let o=await async function(e,t){e&&t||await d();let r=await y(e);if(console.log("🔍 Current settings check:",{has_settings:!!r,has_token:!!r?.admin_token,token_length:r?.admin_token?.length||0}),!r?.admin_token||""===r.admin_token.trim())throw new Error("Admin token not set! Please go to settings.");if(u||(u=new p),u.initialized||a||(console.log("🔄 Starting MCP connection..."),a=u.connect(r.directus_url,r.admin_token)),a)try{await a,a=null,console.log("✅ MCP connection ready")}catch(e){throw a=null,u=null,e}return r}(n,l);if(!o)return t.status(500).json({success:!1,error:"Failed to load settings"});if(!o.ai_api_key)return t.status(400).json({success:!1,error:"AI API Key is required in settings"});c=new m({apiKey:o.ai_api_key,baseURL:o.ai_base_url||"https://api.openai.com/v1"});let i=[{role:"system",content:'You are a Directus CMS expert. MANDATORY OPERATION ORDER:\n\n 1️⃣ read-collections → What collections exist?\n 2️⃣ read-fields collection="X" → What fields does collection X have?\n 3️⃣ Perform operation based on fields\n\n 🔧 CREATE/UPDATE RULES:\n - NEVER guess fields!\n - First learn real fields with read-fields\n - Only use existing fields\n - Always fill mandatory fields\n\n 🎯 TOOL ORDER:\n ❌ WRONG: create-item → error\n ✅ CORRECT: read-collections → read-fields → create-item\n\n 💡 SMART LOGIC:\n - "Add new X" → read-fields collection="X" → create-item with real fields\n - "Link to latest Y" → read-items collection="Y" → get ID → use in create-item\n - "Update Z" → read-fields collection="Z" → update-item\n\n 📋 FORMAT:\n read-items: {"collection": "X", "query": {"sort": ["-id"], "limit": 1}}\n read-fields: {"collection": "X"}\n\n START WITH: read-collections!'},{role:"user",content:r}],s=0;const f=10,w=20;for(;s<f;){console.log(`\n--- AI Iteration ${s+1} ---`);try{let e={model:o.ai_model,messages:i,temperature:.3,max_tokens:2e3};try{e.tools=h,e.tool_choice="auto"}catch(t){console.log("⚠️ Tools not supported, using text-only mode"),e.messages.push({role:"system",content:"Tools not supported. Please directly explain what operation you want to perform."})}const r=(await c.chat(e)).choices[0].message;if(console.log("Assistant message:",JSON.stringify(r,null,2)),i.push(r),!(r.tool_calls&&r.tool_calls.length>0)){if(r.content){if(console.log("🎯 Final response:",r.content),r.content.includes("read-items")||r.content.includes("create-item")||r.content.includes("read-collections")){console.log("🔍 AI tool request detected, trying manual execution...");const e=await b(r.content);if(e){i.push({role:"system",content:`Tool result: ${JSON.stringify(e)}`}),s++;continue}}return t.status(200).json({success:!0,response:r.content,iterations:s+1})}return t.status(200).json({success:!0,response:"Operation completed but result is empty.",iterations:s+1})}console.log(`🔧 Tool calls: ${r.tool_calls.length}`);for(const e of r.tool_calls)try{let t={};e.function.arguments&&(t=JSON.parse(e.function.arguments)),console.log(`🚀 Calling: ${e.function.name}`,t),t=_(e.function.name,t);let r=g(await u.callTool(e.function.name,t));console.log("✅ Result:",JSON.stringify(r).substring(0,300)),r.extracted_id&&i.push({role:"system",content:`🎯 ID extracted: ${r.extracted_id} - You can use this in relational fields!`});let o=JSON.stringify(r);const n=8e3;o.length>n&&(console.log(`⚠️ Truncating large result (${o.length} chars)`),o=o.substring(0,n)+"... [truncated]"),i.push({role:"tool",tool_call_id:e.id,content:o})}catch(t){console.error("❌ Tool error:",t.message),i.push({role:"tool",tool_call_id:e.id,content:JSON.stringify({error:t.message})})}i.length>w&&(console.log(`⚠️ Trimming conversation from ${i.length} to ${w} messages`),i=[i[0],i[1],...i.slice(2-w)]),s++}catch(e){if(console.error("🔥 Error:",e),e.message.includes("tools")||e.message.includes("unmarshal")){console.log("🔄 Tools error, retrying without tools...");const e=await c.chat({model:o.ai_model,messages:i,temperature:.3,max_tokens:2e3});return t.status(200).json({success:!0,response:e.choices[0].message.content,iterations:s+1,note:"Tools not supported, text-only response"})}return t.status(500).json({success:!1,error:e.message,iterations:s+1})}}return t.status(200).json({success:!0,response:"Operation completed.",iterations:f})}catch(e){return console.error("💥 Error:",e),t.status(500).json({success:!1,error:e.message})}})}}],v=[];var T,R="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},E={exports:{}};if(!globalThis.ReadableStream)try{const e=require("node:process"),{emitWarning:t}=e;try{e.emitWarning=()=>{},Object.assign(globalThis,require("node:stream/web")),e.emitWarning=t}catch(r){throw e.emitWarning=t,r}}catch(e){Object.assign(globalThis,(T||(T=1,function(e){function t(){}function r(e){return"object"==typeof e&&null!==e||"function"==typeof e}const o=t;function n(e,t){try{Object.defineProperty(e,"name",{value:t,configurable:!0})}catch(e){}}const i=Promise,s=Promise.prototype.then,a=Promise.reject.bind(i);function l(e){return new i(e)}function c(e){return l(t=>t(e))}function u(e){return a(e)}function d(e,t,r){return s.call(e,t,r)}function f(e,t,r){d(d(e,t,r),void 0,o)}function h(e,t){f(e,t)}function p(e,t){f(e,void 0,t)}function m(e,t,r){return d(e,t,r)}function y(e){d(e,void 0,o)}let b=e=>{if("function"==typeof queueMicrotask)b=queueMicrotask;else{const e=c(void 0);b=t=>d(e,t)}return b(e)};function _(e,t,r){if("function"!=typeof e)throw new TypeError("Argument is not a function");return Function.prototype.apply.call(e,t,r)}function g(e,t,r){try{return c(_(e,t,r))}catch(e){return u(e)}}const w=16384;class S{constructor(){this._cursor=0,this._size=0,this._front={_elements:[],_next:void 0},this._back=this._front,this._cursor=0,this._size=0}get length(){return this._size}push(e){const t=this._back;let r=t;t._elements.length===w-1&&(r={_elements:[],_next:void 0}),t._elements.push(e),r!==t&&(this._back=r,t._next=r),++this._size}shift(){const e=this._front;let t=e;const r=this._cursor;let o=r+1;const n=e._elements,i=n[r];return o===w&&(t=e._next,o=0),--this._size,this._cursor=o,e!==t&&(this._front=t),n[r]=void 0,i}forEach(e){let t=this._cursor,r=this._front,o=r._elements;for(;!(t===o.length&&void 0===r._next||t===o.length&&(r=r._next,o=r._elements,t=0,0===o.length));)e(o[t]),++t}peek(){const e=this._front,t=this._cursor;return e._elements[t]}}const v=Symbol("[[AbortSteps]]"),T=Symbol("[[ErrorSteps]]"),E=Symbol("[[CancelSteps]]"),P=Symbol("[[PullSteps]]"),A=Symbol("[[ReleaseSteps]]");function C(e,t){e._ownerReadableStream=t,t._reader=e,"readable"===t._state?j(e):"closed"===t._state?$(e):L(e,t._storedError)}function q(e,t){return Ko(e._ownerReadableStream,t)}function O(e){const t=e._ownerReadableStream;"readable"===t._state?I(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")):D(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")),t._readableStreamController[A](),t._reader=void 0,e._ownerReadableStream=void 0}function k(e){return new TypeError("Cannot "+e+" a stream using a released reader")}function j(e){e._closedPromise=l((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r})}function L(e,t){j(e),I(e,t)}function $(e){j(e),M(e)}function I(e,t){void 0!==e._closedPromise_reject&&(y(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}function D(e,t){L(e,t)}function M(e){void 0!==e._closedPromise_resolve&&(e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}const z=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},B=Math.trunc||function(e){return e<0?Math.ceil(e):Math.floor(e)};function F(e){return"object"==typeof e||"function"==typeof e}function W(e,t){if(void 0!==e&&!F(e))throw new TypeError(`${t} is not an object.`)}function x(e,t){if("function"!=typeof e)throw new TypeError(`${t} is not a function.`)}function U(e){return"object"==typeof e&&null!==e||"function"==typeof e}function N(e,t){if(!U(e))throw new TypeError(`${t} is not an object.`)}function H(e,t,r){if(void 0===e)throw new TypeError(`Parameter ${t} is required in '${r}'.`)}function V(e,t,r){if(void 0===e)throw new TypeError(`${t} is required in '${r}'.`)}function Y(e){return Number(e)}function Q(e){return 0===e?0:e}function G(e){return Q(B(e))}function J(e,t){const r=0,o=Number.MAX_SAFE_INTEGER;let n=Number(e);if(n=Q(n),!z(n))throw new TypeError(`${t} is not a finite number`);if(n=G(n),n<r||n>o)throw new TypeError(`${t} is outside the accepted range of ${r} to ${o}, inclusive`);return z(n)&&0!==n?n:0}function K(e,t){if(!Go(e))throw new TypeError(`${t} is not a ReadableStream.`)}function X(e){return new oe(e)}function Z(e,t){e._reader._readRequests.push(t)}function ee(e,t,r){const o=e._reader._readRequests.shift();r?o._closeSteps():o._chunkSteps(t)}function te(e){return e._reader._readRequests.length}function re(e){const t=e._reader;return void 0!==t&&!!ne(t)}class oe{constructor(e){if(H(e,1,"ReadableStreamDefaultReader"),K(e,"First parameter"),Jo(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");C(this,e),this._readRequests=new S}get closed(){return ne(this)?this._closedPromise:u(le("closed"))}cancel(e=void 0){return ne(this)?void 0===this._ownerReadableStream?u(k("cancel")):q(this,e):u(le("cancel"))}read(){if(!ne(this))return u(le("read"));if(void 0===this._ownerReadableStream)return u(k("read from"));let e,t;const r=l((r,o)=>{e=r,t=o}),o={_chunkSteps:t=>e({value:t,done:!1}),_closeSteps:()=>e({value:void 0,done:!0}),_errorSteps:e=>t(e)};return ie(this,o),r}releaseLock(){if(!ne(this))throw le("releaseLock");void 0!==this._ownerReadableStream&&se(this)}}function ne(e){return!!r(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readRequests")&&e instanceof oe}function ie(e,t){const r=e._ownerReadableStream;r._disturbed=!0,"closed"===r._state?t._closeSteps():"errored"===r._state?t._errorSteps(r._storedError):r._readableStreamController[P](t)}function se(e){O(e),ae(e,new TypeError("Reader was released"))}function ae(e,t){const r=e._readRequests;e._readRequests=new S,r.forEach(e=>{e._errorSteps(t)})}function le(e){return new TypeError(`ReadableStreamDefaultReader.prototype.${e} can only be used on a ReadableStreamDefaultReader`)}Object.defineProperties(oe.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),n(oe.prototype.cancel,"cancel"),n(oe.prototype.read,"read"),n(oe.prototype.releaseLock,"releaseLock"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(oe.prototype,Symbol.toStringTag,{value:"ReadableStreamDefaultReader",configurable:!0});const ce=Object.getPrototypeOf(Object.getPrototypeOf(async function*(){}).prototype);class ue{constructor(e,t){this._ongoingPromise=void 0,this._isFinished=!1,this._reader=e,this._preventCancel=t}next(){const e=()=>this._nextSteps();return this._ongoingPromise=this._ongoingPromise?m(this._ongoingPromise,e,e):e(),this._ongoingPromise}return(e){const t=()=>this._returnSteps(e);return this._ongoingPromise?m(this._ongoingPromise,t,t):t()}_nextSteps(){if(this._isFinished)return Promise.resolve({value:void 0,done:!0});const e=this._reader;let t,r;const o=l((e,o)=>{t=e,r=o});return ie(e,{_chunkSteps:e=>{this._ongoingPromise=void 0,b(()=>t({value:e,done:!1}))},_closeSteps:()=>{this._ongoingPromise=void 0,this._isFinished=!0,O(e),t({value:void 0,done:!0})},_errorSteps:t=>{this._ongoingPromise=void 0,this._isFinished=!0,O(e),r(t)}}),o}_returnSteps(e){if(this._isFinished)return Promise.resolve({value:e,done:!0});this._isFinished=!0;const t=this._reader;if(!this._preventCancel){const r=q(t,e);return O(t),m(r,()=>({value:e,done:!0}))}return O(t),c({value:e,done:!0})}}const de={next(){return he(this)?this._asyncIteratorImpl.next():u(pe("next"))},return(e){return he(this)?this._asyncIteratorImpl.return(e):u(pe("return"))}};function fe(e,t){const r=X(e),o=new ue(r,t),n=Object.create(de);return n._asyncIteratorImpl=o,n}function he(e){if(!r(e))return!1;if(!Object.prototype.hasOwnProperty.call(e,"_asyncIteratorImpl"))return!1;try{return e._asyncIteratorImpl instanceof ue}catch(e){return!1}}function pe(e){return new TypeError(`ReadableStreamAsyncIterator.${e} can only be used on a ReadableSteamAsyncIterator`)}Object.setPrototypeOf(de,ce);const me=Number.isNaN||function(e){return e!=e};var ye,be,_e;function ge(e){return e.slice()}function we(e,t,r,o,n){new Uint8Array(e).set(new Uint8Array(r,o,n),t)}let Se=e=>(Se="function"==typeof e.transfer?e=>e.transfer():"function"==typeof structuredClone?e=>structuredClone(e,{transfer:[e]}):e=>e,Se(e)),ve=e=>(ve="boolean"==typeof e.detached?e=>e.detached:e=>0===e.byteLength,ve(e));function Te(e,t,r){if(e.slice)return e.slice(t,r);const o=r-t,n=new ArrayBuffer(o);return we(n,0,e,t,o),n}function Re(e,t){const r=e[t];if(null!=r){if("function"!=typeof r)throw new TypeError(`${String(t)} is not a function`);return r}}function Ee(e){const t={[Symbol.iterator]:()=>e.iterator},r=async function*(){return yield*t}();return{iterator:r,nextMethod:r.next,done:!1}}const Pe=null!==(_e=null!==(ye=Symbol.asyncIterator)&&void 0!==ye?ye:null===(be=Symbol.for)||void 0===be?void 0:be.call(Symbol,"Symbol.asyncIterator"))&&void 0!==_e?_e:"@@asyncIterator";function Ae(e,t="sync",o){if(void 0===o)if("async"===t){if(void 0===(o=Re(e,Pe)))return Ee(Ae(e,"sync",Re(e,Symbol.iterator)))}else o=Re(e,Symbol.iterator);if(void 0===o)throw new TypeError("The object is not iterable");const n=_(o,e,[]);if(!r(n))throw new TypeError("The iterator method must return an object");return{iterator:n,nextMethod:n.next,done:!1}}function Ce(e){const t=_(e.nextMethod,e.iterator,[]);if(!r(t))throw new TypeError("The iterator.next() method must return an object");return t}function qe(e){return Boolean(e.done)}function Oe(e){return e.value}function ke(e){return!("number"!=typeof e||me(e)||e<0)}function je(e){const t=Te(e.buffer,e.byteOffset,e.byteOffset+e.byteLength);return new Uint8Array(t)}function Le(e){const t=e._queue.shift();return e._queueTotalSize-=t.size,e._queueTotalSize<0&&(e._queueTotalSize=0),t.value}function $e(e,t,r){if(!ke(r)||r===1/0)throw new RangeError("Size must be a finite, non-NaN, non-negative number.");e._queue.push({value:t,size:r}),e._queueTotalSize+=r}function Ie(e){return e._queue.peek().value}function De(e){e._queue=new S,e._queueTotalSize=0}function Me(e){return e===DataView}function ze(e){return Me(e.constructor)}function Be(e){return Me(e)?1:e.BYTES_PER_ELEMENT}class Fe{constructor(){throw new TypeError("Illegal constructor")}get view(){if(!Ue(this))throw St("view");return this._view}respond(e){if(!Ue(this))throw St("respond");if(H(e,1,"respond"),e=J(e,"First parameter"),void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");if(ve(this._view.buffer))throw new TypeError("The BYOB request's buffer has been detached and so cannot be used as a response");yt(this._associatedReadableByteStreamController,e)}respondWithNewView(e){if(!Ue(this))throw St("respondWithNewView");if(H(e,1,"respondWithNewView"),!ArrayBuffer.isView(e))throw new TypeError("You can only respond with array buffer views");if(void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");if(ve(e.buffer))throw new TypeError("The given view's buffer has been detached and so cannot be used as a response");bt(this._associatedReadableByteStreamController,e)}}Object.defineProperties(Fe.prototype,{respond:{enumerable:!0},respondWithNewView:{enumerable:!0},view:{enumerable:!0}}),n(Fe.prototype.respond,"respond"),n(Fe.prototype.respondWithNewView,"respondWithNewView"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Fe.prototype,Symbol.toStringTag,{value:"ReadableStreamBYOBRequest",configurable:!0});class We{constructor(){throw new TypeError("Illegal constructor")}get byobRequest(){if(!xe(this))throw vt("byobRequest");return pt(this)}get desiredSize(){if(!xe(this))throw vt("desiredSize");return mt(this)}close(){if(!xe(this))throw vt("close");if(this._closeRequested)throw new TypeError("The stream has already been closed; do not close it again!");const e=this._controlledReadableByteStream._state;if("readable"!==e)throw new TypeError(`The stream (in ${e} state) is not in the readable state and cannot be closed`);ut(this)}enqueue(e){if(!xe(this))throw vt("enqueue");if(H(e,1,"enqueue"),!ArrayBuffer.isView(e))throw new TypeError("chunk must be an array buffer view");if(0===e.byteLength)throw new TypeError("chunk must have non-zero byteLength");if(0===e.buffer.byteLength)throw new TypeError("chunk's buffer must have non-zero byteLength");if(this._closeRequested)throw new TypeError("stream is closed or draining");const t=this._controlledReadableByteStream._state;if("readable"!==t)throw new TypeError(`The stream (in ${t} state) is not in the readable state and cannot be enqueued to`);dt(this,e)}error(e=void 0){if(!xe(this))throw vt("error");ft(this,e)}[E](e){He(this),De(this);const t=this._cancelAlgorithm(e);return ct(this),t}[P](e){const t=this._controlledReadableByteStream;if(this._queueTotalSize>0)return void ht(this,e);const r=this._autoAllocateChunkSize;if(void 0!==r){let t;try{t=new ArrayBuffer(r)}catch(t){return void e._errorSteps(t)}const o={buffer:t,bufferByteLength:r,byteOffset:0,byteLength:r,bytesFilled:0,minimumFill:1,elementSize:1,viewConstructor:Uint8Array,readerType:"default"};this._pendingPullIntos.push(o)}Z(t,e),Ne(this)}[A](){if(this._pendingPullIntos.length>0){const e=this._pendingPullIntos.peek();e.readerType="none",this._pendingPullIntos=new S,this._pendingPullIntos.push(e)}}}function xe(e){return!!r(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableByteStream")&&e instanceof We}function Ue(e){return!!r(e)&&!!Object.prototype.hasOwnProperty.call(e,"_associatedReadableByteStreamController")&&e instanceof Fe}function Ne(e){lt(e)&&(e._pulling?e._pullAgain=!0:(e._pulling=!0,f(e._pullAlgorithm(),()=>(e._pulling=!1,e._pullAgain&&(e._pullAgain=!1,Ne(e)),null),t=>(ft(e,t),null))))}function He(e){et(e),e._pendingPullIntos=new S}function Ve(e,t){let r=!1;"closed"===e._state&&(r=!0);const o=Ye(t);"default"===t.readerType?ee(e,o,r):Ct(e,o,r)}function Ye(e){const t=e.bytesFilled,r=e.elementSize;return new e.viewConstructor(e.buffer,e.byteOffset,t/r)}function Qe(e,t,r,o){e._queue.push({buffer:t,byteOffset:r,byteLength:o}),e._queueTotalSize+=o}function Ge(e,t,r,o){let n;try{n=Te(t,r,r+o)}catch(t){throw ft(e,t),t}Qe(e,n,0,o)}function Je(e,t){t.bytesFilled>0&&Ge(e,t.buffer,t.byteOffset,t.bytesFilled),at(e)}function Ke(e,t){const r=Math.min(e._queueTotalSize,t.byteLength-t.bytesFilled),o=t.bytesFilled+r;let n=r,i=!1;const s=o-o%t.elementSize;s>=t.minimumFill&&(n=s-t.bytesFilled,i=!0);const a=e._queue;for(;n>0;){const r=a.peek(),o=Math.min(n,r.byteLength),i=t.byteOffset+t.bytesFilled;we(t.buffer,i,r.buffer,r.byteOffset,o),r.byteLength===o?a.shift():(r.byteOffset+=o,r.byteLength-=o),e._queueTotalSize-=o,Xe(e,o,t),n-=o}return i}function Xe(e,t,r){r.bytesFilled+=t}function Ze(e){0===e._queueTotalSize&&e._closeRequested?(ct(e),Xo(e._controlledReadableByteStream)):Ne(e)}function et(e){null!==e._byobRequest&&(e._byobRequest._associatedReadableByteStreamController=void 0,e._byobRequest._view=null,e._byobRequest=null)}function tt(e){for(;e._pendingPullIntos.length>0;){if(0===e._queueTotalSize)return;const t=e._pendingPullIntos.peek();Ke(e,t)&&(at(e),Ve(e._controlledReadableByteStream,t))}}function rt(e){const t=e._controlledReadableByteStream._reader;for(;t._readRequests.length>0;){if(0===e._queueTotalSize)return;ht(e,t._readRequests.shift())}}function ot(e,t,r,o){const n=e._controlledReadableByteStream,i=t.constructor,s=Be(i),{byteOffset:a,byteLength:l}=t,c=r*s;let u;try{u=Se(t.buffer)}catch(e){return void o._errorSteps(e)}const d={buffer:u,bufferByteLength:u.byteLength,byteOffset:a,byteLength:l,bytesFilled:0,minimumFill:c,elementSize:s,viewConstructor:i,readerType:"byob"};if(e._pendingPullIntos.length>0)return e._pendingPullIntos.push(d),void At(n,o);if("closed"===n._state){const e=new i(d.buffer,d.byteOffset,0);return void o._closeSteps(e)}if(e._queueTotalSize>0){if(Ke(e,d)){const t=Ye(d);return Ze(e),void o._chunkSteps(t)}if(e._closeRequested){const t=new TypeError("Insufficient bytes to fill elements in the given buffer");return ft(e,t),void o._errorSteps(t)}}e._pendingPullIntos.push(d),At(n,o),Ne(e)}function nt(e,t){"none"===t.readerType&&at(e);const r=e._controlledReadableByteStream;if(Ot(r))for(;qt(r)>0;)Ve(r,at(e))}function it(e,t,r){if(Xe(e,t,r),"none"===r.readerType)return Je(e,r),void tt(e);if(r.bytesFilled<r.minimumFill)return;at(e);const o=r.bytesFilled%r.elementSize;if(o>0){const t=r.byteOffset+r.bytesFilled;Ge(e,r.buffer,t-o,o)}r.bytesFilled-=o,Ve(e._controlledReadableByteStream,r),tt(e)}function st(e,t){const r=e._pendingPullIntos.peek();et(e),"closed"===e._controlledReadableByteStream._state?nt(e,r):it(e,t,r),Ne(e)}function at(e){return e._pendingPullIntos.shift()}function lt(e){const t=e._controlledReadableByteStream;return"readable"===t._state&&!e._closeRequested&&!!e._started&&(!!(re(t)&&te(t)>0)||!!(Ot(t)&&qt(t)>0)||mt(e)>0)}function ct(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0}function ut(e){const t=e._controlledReadableByteStream;if(!e._closeRequested&&"readable"===t._state)if(e._queueTotalSize>0)e._closeRequested=!0;else{if(e._pendingPullIntos.length>0){const t=e._pendingPullIntos.peek();if(t.bytesFilled%t.elementSize!==0){const t=new TypeError("Insufficient bytes to fill elements in the given buffer");throw ft(e,t),t}}ct(e),Xo(t)}}function dt(e,t){const r=e._controlledReadableByteStream;if(e._closeRequested||"readable"!==r._state)return;const{buffer:o,byteOffset:n,byteLength:i}=t;if(ve(o))throw new TypeError("chunk's buffer is detached and so cannot be enqueued");const s=Se(o);if(e._pendingPullIntos.length>0){const t=e._pendingPullIntos.peek();if(ve(t.buffer))throw new TypeError("The BYOB request's buffer has been detached and so cannot be filled with an enqueued chunk");et(e),t.buffer=Se(t.buffer),"none"===t.readerType&&Je(e,t)}re(r)?(rt(e),0===te(r)?Qe(e,s,n,i):(e._pendingPullIntos.length>0&&at(e),ee(r,new Uint8Array(s,n,i),!1))):Ot(r)?(Qe(e,s,n,i),tt(e)):Qe(e,s,n,i),Ne(e)}function ft(e,t){const r=e._controlledReadableByteStream;"readable"===r._state&&(He(e),De(e),ct(e),Zo(r,t))}function ht(e,t){const r=e._queue.shift();e._queueTotalSize-=r.byteLength,Ze(e);const o=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);t._chunkSteps(o)}function pt(e){if(null===e._byobRequest&&e._pendingPullIntos.length>0){const t=e._pendingPullIntos.peek(),r=new Uint8Array(t.buffer,t.byteOffset+t.bytesFilled,t.byteLength-t.bytesFilled),o=Object.create(Fe.prototype);wt(o,e,r),e._byobRequest=o}return e._byobRequest}function mt(e){const t=e._controlledReadableByteStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function yt(e,t){const r=e._pendingPullIntos.peek();if("closed"===e._controlledReadableByteStream._state){if(0!==t)throw new TypeError("bytesWritten must be 0 when calling respond() on a closed stream")}else{if(0===t)throw new TypeError("bytesWritten must be greater than 0 when calling respond() on a readable stream");if(r.bytesFilled+t>r.byteLength)throw new RangeError("bytesWritten out of range")}r.buffer=Se(r.buffer),st(e,t)}function bt(e,t){const r=e._pendingPullIntos.peek();if("closed"===e._controlledReadableByteStream._state){if(0!==t.byteLength)throw new TypeError("The view's length must be 0 when calling respondWithNewView() on a closed stream")}else if(0===t.byteLength)throw new TypeError("The view's length must be greater than 0 when calling respondWithNewView() on a readable stream");if(r.byteOffset+r.bytesFilled!==t.byteOffset)throw new RangeError("The region specified by view does not match byobRequest");if(r.bufferByteLength!==t.buffer.byteLength)throw new RangeError("The buffer of view has different capacity than byobRequest");if(r.bytesFilled+t.byteLength>r.byteLength)throw new RangeError("The region specified by view is larger than byobRequest");const o=t.byteLength;r.buffer=Se(t.buffer),st(e,o)}function _t(e,t,r,o,n,i,s){t._controlledReadableByteStream=e,t._pullAgain=!1,t._pulling=!1,t._byobRequest=null,t._queue=t._queueTotalSize=void 0,De(t),t._closeRequested=!1,t._started=!1,t._strategyHWM=i,t._pullAlgorithm=o,t._cancelAlgorithm=n,t._autoAllocateChunkSize=s,t._pendingPullIntos=new S,e._readableStreamController=t,f(c(r()),()=>(t._started=!0,Ne(t),null),e=>(ft(t,e),null))}function gt(e,t,r){const o=Object.create(We.prototype);let n,i,s;n=void 0!==t.start?()=>t.start(o):()=>{},i=void 0!==t.pull?()=>t.pull(o):()=>c(void 0),s=void 0!==t.cancel?e=>t.cancel(e):()=>c(void 0);const a=t.autoAllocateChunkSize;if(0===a)throw new TypeError("autoAllocateChunkSize must be greater than 0");_t(e,o,n,i,s,r,a)}function wt(e,t,r){e._associatedReadableByteStreamController=t,e._view=r}function St(e){return new TypeError(`ReadableStreamBYOBRequest.prototype.${e} can only be used on a ReadableStreamBYOBRequest`)}function vt(e){return new TypeError(`ReadableByteStreamController.prototype.${e} can only be used on a ReadableByteStreamController`)}function Tt(e,t){W(e,t);const r=null==e?void 0:e.mode;return{mode:void 0===r?void 0:Rt(r,`${t} has member 'mode' that`)}}function Rt(e,t){if("byob"!=(e=`${e}`))throw new TypeError(`${t} '${e}' is not a valid enumeration value for ReadableStreamReaderMode`);return e}function Et(e,t){var r;return W(e,t),{min:J(null!==(r=null==e?void 0:e.min)&&void 0!==r?r:1,`${t} has member 'min' that`)}}function Pt(e){return new kt(e)}function At(e,t){e._reader._readIntoRequests.push(t)}function Ct(e,t,r){const o=e._reader._readIntoRequests.shift();r?o._closeSteps(t):o._chunkSteps(t)}function qt(e){return e._reader._readIntoRequests.length}function Ot(e){const t=e._reader;return void 0!==t&&!!jt(t)}Object.defineProperties(We.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},byobRequest:{enumerable:!0},desiredSize:{enumerable:!0}}),n(We.prototype.close,"close"),n(We.prototype.enqueue,"enqueue"),n(We.prototype.error,"error"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(We.prototype,Symbol.toStringTag,{value:"ReadableByteStreamController",configurable:!0});class kt{constructor(e){if(H(e,1,"ReadableStreamBYOBReader"),K(e,"First parameter"),Jo(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");if(!xe(e._readableStreamController))throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");C(this,e),this._readIntoRequests=new S}get closed(){return jt(this)?this._closedPromise:u(Dt("closed"))}cancel(e=void 0){return jt(this)?void 0===this._ownerReadableStream?u(k("cancel")):q(this,e):u(Dt("cancel"))}read(e,t={}){if(!jt(this))return u(Dt("read"));if(!ArrayBuffer.isView(e))return u(new TypeError("view must be an array buffer view"));if(0===e.byteLength)return u(new TypeError("view must have non-zero byteLength"));if(0===e.buffer.byteLength)return u(new TypeError("view's buffer must have non-zero byteLength"));if(ve(e.buffer))return u(new TypeError("view's buffer has been detached"));let r;try{r=Et(t,"options")}catch(e){return u(e)}const o=r.min;if(0===o)return u(new TypeError("options.min must be greater than 0"));if(ze(e)){if(o>e.byteLength)return u(new RangeError("options.min must be less than or equal to view's byteLength"))}else if(o>e.length)return u(new RangeError("options.min must be less than or equal to view's length"));if(void 0===this._ownerReadableStream)return u(k("read from"));let n,i;const s=l((e,t)=>{n=e,i=t}),a={_chunkSteps:e=>n({value:e,done:!1}),_closeSteps:e=>n({value:e,done:!0}),_errorSteps:e=>i(e)};return Lt(this,e,o,a),s}releaseLock(){if(!jt(this))throw Dt("releaseLock");void 0!==this._ownerReadableStream&&$t(this)}}function jt(e){return!!r(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readIntoRequests")&&e instanceof kt}function Lt(e,t,r,o){const n=e._ownerReadableStream;n._disturbed=!0,"errored"===n._state?o._errorSteps(n._storedError):ot(n._readableStreamController,t,r,o)}function $t(e){O(e),It(e,new TypeError("Reader was released"))}function It(e,t){const r=e._readIntoRequests;e._readIntoRequests=new S,r.forEach(e=>{e._errorSteps(t)})}function Dt(e){return new TypeError(`ReadableStreamBYOBReader.prototype.${e} can only be used on a ReadableStreamBYOBReader`)}function Mt(e,t){const{highWaterMark:r}=e;if(void 0===r)return t;if(me(r)||r<0)throw new RangeError("Invalid highWaterMark");return r}function zt(e){const{size:t}=e;return t||(()=>1)}function Bt(e,t){W(e,t);const r=null==e?void 0:e.highWaterMark,o=null==e?void 0:e.size;return{highWaterMark:void 0===r?void 0:Y(r),size:void 0===o?void 0:Ft(o,`${t} has member 'size' that`)}}function Ft(e,t){return x(e,t),t=>Y(e(t))}function Wt(e,t){W(e,t);const r=null==e?void 0:e.abort,o=null==e?void 0:e.close,n=null==e?void 0:e.start,i=null==e?void 0:e.type,s=null==e?void 0:e.write;return{abort:void 0===r?void 0:xt(r,e,`${t} has member 'abort' that`),close:void 0===o?void 0:Ut(o,e,`${t} has member 'close' that`),start:void 0===n?void 0:Nt(n,e,`${t} has member 'start' that`),write:void 0===s?void 0:Ht(s,e,`${t} has member 'write' that`),type:i}}function xt(e,t,r){return x(e,r),r=>g(e,t,[r])}function Ut(e,t,r){return x(e,r),()=>g(e,t,[])}function Nt(e,t,r){return x(e,r),r=>_(e,t,[r])}function Ht(e,t,r){return x(e,r),(r,o)=>g(e,t,[r,o])}function Vt(e,t){if(!er(e))throw new TypeError(`${t} is not a WritableStream.`)}function Yt(e){if("object"!=typeof e||null===e)return!1;try{return"boolean"==typeof e.aborted}catch(e){return!1}}Object.defineProperties(kt.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),n(kt.prototype.cancel,"cancel"),n(kt.prototype.read,"read"),n(kt.prototype.releaseLock,"releaseLock"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(kt.prototype,Symbol.toStringTag,{value:"ReadableStreamBYOBReader",configurable:!0});const Qt="function"==typeof AbortController;function Gt(){if(Qt)return new AbortController}class Jt{constructor(e={},t={}){void 0===e?e=null:N(e,"First parameter");const r=Bt(t,"Second parameter"),o=Wt(e,"First parameter");if(Zt(this),void 0!==o.type)throw new RangeError("Invalid type is specified");const n=zt(r);jr(this,o,Mt(r,1),n)}get locked(){if(!er(this))throw Nr("locked");return tr(this)}abort(e=void 0){return er(this)?tr(this)?u(new TypeError("Cannot abort a stream that already has a writer")):rr(this,e):u(Nr("abort"))}close(){return er(this)?tr(this)?u(new TypeError("Cannot close a stream that already has a writer")):fr(this)?u(new TypeError("Cannot close an already-closing stream")):or(this):u(Nr("close"))}getWriter(){if(!er(this))throw Nr("getWriter");return Kt(this)}}function Kt(e){return new _r(e)}function Xt(e,t,r,o,n=1,i=()=>1){const s=Object.create(Jt.prototype);return Zt(s),kr(s,Object.create(qr.prototype),e,t,r,o,n,i),s}function Zt(e){e._state="writable",e._storedError=void 0,e._writer=void 0,e._writableStreamController=void 0,e._writeRequests=new S,e._inFlightWriteRequest=void 0,e._closeRequest=void 0,e._inFlightCloseRequest=void 0,e._pendingAbortRequest=void 0,e._backpressure=!1}function er(e){return!!r(e)&&!!Object.prototype.hasOwnProperty.call(e,"_writableStreamController")&&e instanceof Jt}function tr(e){return void 0!==e._writer}function rr(e,t){var r;if("closed"===e._state||"errored"===e._state)return c(void 0);e._writableStreamController._abortReason=t,null===(r=e._writableStreamController._abortController)||void 0===r||r.abort(t);const o=e._state;if("closed"===o||"errored"===o)return c(void 0);if(void 0!==e._pendingAbortRequest)return e._pendingAbortRequest._promise;let n=!1;"erroring"===o&&(n=!0,t=void 0);const i=l((r,o)=>{e._pendingAbortRequest={_promise:void 0,_resolve:r,_reject:o,_reason:t,_wasAlreadyErroring:n}});return e._pendingAbortRequest._promise=i,n||sr(e,t),i}function or(e){const t=e._state;if("closed"===t||"errored"===t)return u(new TypeError(`The stream (in ${t} state) is not in the writable state and cannot be closed`));const r=l((t,r)=>{const o={_resolve:t,_reject:r};e._closeRequest=o}),o=e._writer;return void 0!==o&&e._backpressure&&"writable"===t&&so(o),$r(e._writableStreamController),r}function nr(e){return l((t,r)=>{const o={_resolve:t,_reject:r};e._writeRequests.push(o)})}function ir(e,t){"writable"!==e._state?ar(e):sr(e,t)}function sr(e,t){const r=e._writableStreamController;e._state="erroring",e._storedError=t;const o=e._writer;void 0!==o&&Rr(o,t),!hr(e)&&r._started&&ar(e)}function ar(e){e._state="errored",e._writableStreamController[T]();const t=e._storedError;if(e._writeRequests.forEach(e=>{e._reject(t)}),e._writeRequests=new S,void 0===e._pendingAbortRequest)return void yr(e);const r=e._pendingAbortRequest;if(e._pendingAbortRequest=void 0,r._wasAlreadyErroring)return r._reject(t),void yr(e);f(e._writableStreamController[v](r._reason),()=>(r._resolve(),yr(e),null),t=>(r._reject(t),yr(e),null))}function lr(e){e._inFlightWriteRequest._resolve(void 0),e._inFlightWriteRequest=void 0}function cr(e,t){e._inFlightWriteRequest._reject(t),e._inFlightWriteRequest=void 0,ir(e,t)}function ur(e){e._inFlightCloseRequest._resolve(void 0),e._inFlightCloseRequest=void 0,"erroring"===e._state&&(e._storedError=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._resolve(),e._pendingAbortRequest=void 0)),e._state="closed";const t=e._writer;void 0!==t&&Zr(t)}function dr(e,t){e._inFlightCloseRequest._reject(t),e._inFlightCloseRequest=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._reject(t),e._pendingAbortRequest=void 0),ir(e,t)}function fr(e){return void 0!==e._closeRequest||void 0!==e._inFlightCloseRequest}function hr(e){return void 0!==e._inFlightWriteRequest||void 0!==e._inFlightCloseRequest}function pr(e){e._inFlightCloseRequest=e._closeRequest,e._closeRequest=void 0}function mr(e){e._inFlightWriteRequest=e._writeRequests.shift()}function yr(e){void 0!==e._closeRequest&&(e._closeRequest._reject(e._storedError),e._closeRequest=void 0);const t=e._writer;void 0!==t&&Kr(t,e._storedError)}function br(e,t){const r=e._writer;void 0!==r&&t!==e._backpressure&&(t?no(r):so(r)),e._backpressure=t}Object.defineProperties(Jt.prototype,{abort:{enumerable:!0},close:{enumerable:!0},getWriter:{enumerable:!0},locked:{enumerable:!0}}),n(Jt.prototype.abort,"abort"),n(Jt.prototype.close,"close"),n(Jt.prototype.getWriter,"getWriter"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Jt.prototype,Symbol.toStringTag,{value:"WritableStream",configurable:!0});class _r{constructor(e){if(H(e,1,"WritableStreamDefaultWriter"),Vt(e,"First parameter"),tr(e))throw new TypeError("This stream has already been locked for exclusive writing by another writer");this._ownerWritableStream=e,e._writer=this;const t=e._state;if("writable"===t)!fr(e)&&e._backpressure?eo(this):ro(this),Qr(this);else if("erroring"===t)to(this,e._storedError),Qr(this);else if("closed"===t)ro(this),Jr(this);else{const t=e._storedError;to(this,t),Gr(this,t)}}get closed(){return gr(this)?this._closedPromise:u(Vr("closed"))}get desiredSize(){if(!gr(this))throw Vr("desiredSize");if(void 0===this._ownerWritableStream)throw Yr("desiredSize");return Er(this)}get ready(){return gr(this)?this._readyPromise:u(Vr("ready"))}abort(e=void 0){return gr(this)?void 0===this._ownerWritableStream?u(Yr("abort")):wr(this,e):u(Vr("abort"))}close(){if(!gr(this))return u(Vr("close"));const e=this._ownerWritableStream;return void 0===e?u(Yr("close")):fr(e)?u(new TypeError("Cannot close an already-closing stream")):Sr(this)}releaseLock(){if(!gr(this))throw Vr("releaseLock");void 0!==this._ownerWritableStream&&Pr(this)}write(e=void 0){return gr(this)?void 0===this._ownerWritableStream?u(Yr("write to")):Ar(this,e):u(Vr("write"))}}function gr(e){return!!r(e)&&!!Object.prototype.hasOwnProperty.call(e,"_ownerWritableStream")&&e instanceof _r}function wr(e,t){return rr(e._ownerWritableStream,t)}function Sr(e){return or(e._ownerWritableStream)}function vr(e){const t=e._ownerWritableStream,r=t._state;return fr(t)||"closed"===r?c(void 0):"errored"===r?u(t._storedError):Sr(e)}function Tr(e,t){"pending"===e._closedPromiseState?Kr(e,t):Xr(e,t)}function Rr(e,t){"pending"===e._readyPromiseState?oo(e,t):io(e,t)}function Er(e){const t=e._ownerWritableStream,r=t._state;return"errored"===r||"erroring"===r?null:"closed"===r?0:Dr(t._writableStreamController)}function Pr(e){const t=e._ownerWritableStream,r=new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");Rr(e,r),Tr(e,r),t._writer=void 0,e._ownerWritableStream=void 0}function Ar(e,t){const r=e._ownerWritableStream,o=r._writableStreamController,n=Ir(o,t);if(r!==e._ownerWritableStream)return u(Yr("write to"));const i=r._state;if("errored"===i)return u(r._storedError);if(fr(r)||"closed"===i)return u(new TypeError("The stream is closing or closed and cannot be written to"));if("erroring"===i)return u(r._storedError);const s=nr(r);return Mr(o,t,n),s}Object.defineProperties(_r.prototype,{abort:{enumerable:!0},close:{enumerable:!0},releaseLock:{enumerable:!0},write:{enumerable:!0},closed:{enumerable:!0},desiredSize:{enumerable:!0},ready:{enumerable:!0}}),n(_r.prototype.abort,"abort"),n(_r.prototype.close,"close"),n(_r.prototype.releaseLock,"releaseLock"),n(_r.prototype.write,"write"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(_r.prototype,Symbol.toStringTag,{value:"WritableStreamDefaultWriter",configurable:!0});const Cr={};class qr{constructor(){throw new TypeError("Illegal constructor")}get abortReason(){if(!Or(this))throw Hr("abortReason");return this._abortReason}get signal(){if(!Or(this))throw Hr("signal");if(void 0===this._abortController)throw new TypeError("WritableStreamDefaultController.prototype.signal is not supported");return this._abortController.signal}error(e=void 0){if(!Or(this))throw Hr("error");"writable"===this._controlledWritableStream._state&&Ur(this,e)}[v](e){const t=this._abortAlgorithm(e);return Lr(this),t}[T](){De(this)}}function Or(e){return!!r(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledWritableStream")&&e instanceof qr}function kr(e,t,r,o,n,i,s,a){t._controlledWritableStream=e,e._writableStreamController=t,t._queue=void 0,t._queueTotalSize=void 0,De(t),t._abortReason=void 0,t._abortController=Gt(),t._started=!1,t._strategySizeAlgorithm=a,t._strategyHWM=s,t._writeAlgorithm=o,t._closeAlgorithm=n,t._abortAlgorithm=i;const l=xr(t);br(e,l),f(c(r()),()=>(t._started=!0,zr(t),null),r=>(t._started=!0,ir(e,r),null))}function jr(e,t,r,o){const n=Object.create(qr.prototype);let i,s,a,l;i=void 0!==t.start?()=>t.start(n):()=>{},s=void 0!==t.write?e=>t.write(e,n):()=>c(void 0),a=void 0!==t.close?()=>t.close():()=>c(void 0),l=void 0!==t.abort?e=>t.abort(e):()=>c(void 0),kr(e,n,i,s,a,l,r,o)}function Lr(e){e._writeAlgorithm=void 0,e._closeAlgorithm=void 0,e._abortAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function $r(e){$e(e,Cr,0),zr(e)}function Ir(e,t){try{return e._strategySizeAlgorithm(t)}catch(t){return Br(e,t),1}}function Dr(e){return e._strategyHWM-e._queueTotalSize}function Mr(e,t,r){try{$e(e,t,r)}catch(t){return void Br(e,t)}const o=e._controlledWritableStream;fr(o)||"writable"!==o._state||br(o,xr(e)),zr(e)}function zr(e){const t=e._controlledWritableStream;if(!e._started)return;if(void 0!==t._inFlightWriteRequest)return;if("erroring"===t._state)return void ar(t);if(0===e._queue.length)return;const r=Ie(e);r===Cr?Fr(e):Wr(e,r)}function Br(e,t){"writable"===e._controlledWritableStream._state&&Ur(e,t)}function Fr(e){const t=e._controlledWritableStream;pr(t),Le(e);const r=e._closeAlgorithm();Lr(e),f(r,()=>(ur(t),null),e=>(dr(t,e),null))}function Wr(e,t){const r=e._controlledWritableStream;mr(r),f(e._writeAlgorithm(t),()=>{lr(r);const t=r._state;if(Le(e),!fr(r)&&"writable"===t){const t=xr(e);br(r,t)}return zr(e),null},t=>("writable"===r._state&&Lr(e),cr(r,t),null))}function xr(e){return Dr(e)<=0}function Ur(e,t){const r=e._controlledWritableStream;Lr(e),sr(r,t)}function Nr(e){return new TypeError(`WritableStream.prototype.${e} can only be used on a WritableStream`)}function Hr(e){return new TypeError(`WritableStreamDefaultController.prototype.${e} can only be used on a WritableStreamDefaultController`)}function Vr(e){return new TypeError(`WritableStreamDefaultWriter.prototype.${e} can only be used on a WritableStreamDefaultWriter`)}function Yr(e){return new TypeError("Cannot "+e+" a stream using a released writer")}function Qr(e){e._closedPromise=l((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r,e._closedPromiseState="pending"})}function Gr(e,t){Qr(e),Kr(e,t)}function Jr(e){Qr(e),Zr(e)}function Kr(e,t){void 0!==e._closedPromise_reject&&(y(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="rejected")}function Xr(e,t){Gr(e,t)}function Zr(e){void 0!==e._closedPromise_resolve&&(e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="resolved")}function eo(e){e._readyPromise=l((t,r)=>{e._readyPromise_resolve=t,e._readyPromise_reject=r}),e._readyPromiseState="pending"}function to(e,t){eo(e),oo(e,t)}function ro(e){eo(e),so(e)}function oo(e,t){void 0!==e._readyPromise_reject&&(y(e._readyPromise),e._readyPromise_reject(t),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="rejected")}function no(e){eo(e)}function io(e,t){to(e,t)}function so(e){void 0!==e._readyPromise_resolve&&(e._readyPromise_resolve(void 0),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="fulfilled")}function ao(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:void 0!==R?R:void 0}Object.defineProperties(qr.prototype,{abortReason:{enumerable:!0},signal:{enumerable:!0},error:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(qr.prototype,Symbol.toStringTag,{value:"WritableStreamDefaultController",configurable:!0});const lo=ao();function co(e){if("function"!=typeof e&&"object"!=typeof e)return!1;if("DOMException"!==e.name)return!1;try{return new e,!0}catch(e){return!1}}function uo(){const e=null==lo?void 0:lo.DOMException;return co(e)?e:void 0}function fo(){const e=function(e,t){this.message=e||"",this.name=t||"Error",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)};return n(e,"DOMException"),e.prototype=Object.create(Error.prototype),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,configurable:!0}),e}const ho=uo()||fo();function po(e,r,o,n,i,s){const a=X(e),u=Kt(r);e._disturbed=!0;let m=!1,b=c(void 0);return l((_,g)=>{let w;if(void 0!==s){if(w=()=>{const t=void 0!==s.reason?s.reason:new ho("Aborted","AbortError"),o=[];n||o.push(()=>"writable"===r._state?rr(r,t):c(void 0)),i||o.push(()=>"readable"===e._state?Ko(e,t):c(void 0)),P(()=>Promise.all(o.map(e=>e())),!0,t)},s.aborted)return void w();s.addEventListener("abort",w)}function S(){return l((e,t)=>{function r(o){o?e():d(v(),r,t)}r(!1)})}function v(){return m?c(!0):d(u._readyPromise,()=>l((e,r)=>{ie(a,{_chunkSteps:r=>{b=d(Ar(u,r),void 0,t),e(!1)},_closeSteps:()=>e(!0),_errorSteps:r})}))}if(R(e,a._closedPromise,e=>(n?A(!0,e):P(()=>rr(r,e),!0,e),null)),R(r,u._closedPromise,t=>(i?A(!0,t):P(()=>Ko(e,t),!0,t),null)),E(e,a._closedPromise,()=>(o?A():P(()=>vr(u)),null)),fr(r)||"closed"===r._state){const t=new TypeError("the destination writable stream closed before all data could be piped to it");i?A(!0,t):P(()=>Ko(e,t),!0,t)}function T(){const e=b;return d(b,()=>e!==b?T():void 0)}function R(e,t,r){"errored"===e._state?r(e._storedError):p(t,r)}function E(e,t,r){"closed"===e._state?r():h(t,r)}function P(e,t,o){function n(){return f(e(),()=>C(t,o),e=>C(!0,e)),null}m||(m=!0,"writable"!==r._state||fr(r)?n():h(T(),n))}function A(e,t){m||(m=!0,"writable"!==r._state||fr(r)?C(e,t):h(T(),()=>C(e,t)))}function C(e,t){return Pr(u),O(a),void 0!==s&&s.removeEventListener("abort",w),e?g(t):_(void 0),null}y(S())})}class mo{constructor(){throw new TypeError("Illegal constructor")}get desiredSize(){if(!yo(this))throw Co("desiredSize");return To(this)}close(){if(!yo(this))throw Co("close");if(!Eo(this))throw new TypeError("The stream is not in a state that permits close");wo(this)}enqueue(e=void 0){if(!yo(this))throw Co("enqueue");if(!Eo(this))throw new TypeError("The stream is not in a state that permits enqueue");return So(this,e)}error(e=void 0){if(!yo(this))throw Co("error");vo(this,e)}[E](e){De(this);const t=this._cancelAlgorithm(e);return go(this),t}[P](e){const t=this._controlledReadableStream;if(this._queue.length>0){const r=Le(this);this._closeRequested&&0===this._queue.length?(go(this),Xo(t)):bo(this),e._chunkSteps(r)}else Z(t,e),bo(this)}[A](){}}function yo(e){return!!r(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableStream")&&e instanceof mo}function bo(e){_o(e)&&(e._pulling?e._pullAgain=!0:(e._pulling=!0,f(e._pullAlgorithm(),()=>(e._pulling=!1,e._pullAgain&&(e._pullAgain=!1,bo(e)),null),t=>(vo(e,t),null))))}function _o(e){const t=e._controlledReadableStream;return!!Eo(e)&&!!e._started&&(!!(Jo(t)&&te(t)>0)||To(e)>0)}function go(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function wo(e){if(!Eo(e))return;const t=e._controlledReadableStream;e._closeRequested=!0,0===e._queue.length&&(go(e),Xo(t))}function So(e,t){if(!Eo(e))return;const r=e._controlledReadableStream;if(Jo(r)&&te(r)>0)ee(r,t,!1);else{let r;try{r=e._strategySizeAlgorithm(t)}catch(t){throw vo(e,t),t}try{$e(e,t,r)}catch(t){throw vo(e,t),t}}bo(e)}function vo(e,t){const r=e._controlledReadableStream;"readable"===r._state&&(De(e),go(e),Zo(r,t))}function To(e){const t=e._controlledReadableStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function Ro(e){return!_o(e)}function Eo(e){const t=e._controlledReadableStream._state;return!e._closeRequested&&"readable"===t}function Po(e,t,r,o,n,i,s){t._controlledReadableStream=e,t._queue=void 0,t._queueTotalSize=void 0,De(t),t._started=!1,t._closeRequested=!1,t._pullAgain=!1,t._pulling=!1,t._strategySizeAlgorithm=s,t._strategyHWM=i,t._pullAlgorithm=o,t._cancelAlgorithm=n,e._readableStreamController=t,f(c(r()),()=>(t._started=!0,bo(t),null),e=>(vo(t,e),null))}function Ao(e,t,r,o){const n=Object.create(mo.prototype);let i,s,a;i=void 0!==t.start?()=>t.start(n):()=>{},s=void 0!==t.pull?()=>t.pull(n):()=>c(void 0),a=void 0!==t.cancel?e=>t.cancel(e):()=>c(void 0),Po(e,n,i,s,a,r,o)}function Co(e){return new TypeError(`ReadableStreamDefaultController.prototype.${e} can only be used on a ReadableStreamDefaultController`)}function qo(e,t){return xe(e._readableStreamController)?ko(e):Oo(e)}function Oo(e,t){const r=X(e);let o,n,i,s,a,u=!1,d=!1,f=!1,h=!1;const m=l(e=>{a=e});function y(){return u?(d=!0,c(void 0)):(u=!0,ie(r,{_chunkSteps:e=>{b(()=>{d=!1;const t=e,r=e;f||So(i._readableStreamController,t),h||So(s._readableStreamController,r),u=!1,d&&y()})},_closeSteps:()=>{u=!1,f||wo(i._readableStreamController),h||wo(s._readableStreamController),f&&h||a(void 0)},_errorSteps:()=>{u=!1}}),c(void 0))}function _(t){if(f=!0,o=t,h){const t=ge([o,n]),r=Ko(e,t);a(r)}return m}function g(t){if(h=!0,n=t,f){const t=ge([o,n]),r=Ko(e,t);a(r)}return m}function w(){}return i=Vo(w,y,_),s=Vo(w,y,g),p(r._closedPromise,e=>(vo(i._readableStreamController,e),vo(s._readableStreamController,e),f&&h||a(void 0),null)),[i,s]}function ko(e){let t,r,o,n,i,s=X(e),a=!1,u=!1,d=!1,f=!1,h=!1;const m=l(e=>{i=e});function y(e){p(e._closedPromise,t=>(e!==s||(ft(o._readableStreamController,t),ft(n._readableStreamController,t),f&&h||i(void 0)),null))}function _(){jt(s)&&(O(s),s=X(e),y(s)),ie(s,{_chunkSteps:t=>{b(()=>{u=!1,d=!1;const r=t;let s=t;if(!f&&!h)try{s=je(t)}catch(t){return ft(o._readableStreamController,t),ft(n._readableStreamController,t),void i(Ko(e,t))}f||dt(o._readableStreamController,r),h||dt(n._readableStreamController,s),a=!1,u?w():d&&S()})},_closeSteps:()=>{a=!1,f||ut(o._readableStreamController),h||ut(n._readableStreamController),o._readableStreamController._pendingPullIntos.length>0&&yt(o._readableStreamController,0),n._readableStreamController._pendingPullIntos.length>0&&yt(n._readableStreamController,0),f&&h||i(void 0)},_errorSteps:()=>{a=!1}})}function g(t,r){ne(s)&&(O(s),s=Pt(e),y(s));const l=r?n:o,c=r?o:n;Lt(s,t,1,{_chunkSteps:t=>{b(()=>{u=!1,d=!1;const o=r?h:f;if(r?f:h)o||bt(l._readableStreamController,t);else{let r;try{r=je(t)}catch(t){return ft(l._readableStreamController,t),ft(c._readableStreamController,t),void i(Ko(e,t))}o||bt(l._readableStreamController,t),dt(c._readableStreamController,r)}a=!1,u?w():d&&S()})},_closeSteps:e=>{a=!1;const t=r?h:f,o=r?f:h;t||ut(l._readableStreamController),o||ut(c._readableStreamController),void 0!==e&&(t||bt(l._readableStreamController,e),!o&&c._readableStreamController._pendingPullIntos.length>0&&yt(c._readableStreamController,0)),t&&o||i(void 0)},_errorSteps:()=>{a=!1}})}function w(){if(a)return u=!0,c(void 0);a=!0;const e=pt(o._readableStreamController);return null===e?_():g(e._view,!1),c(void 0)}function S(){if(a)return d=!0,c(void 0);a=!0;const e=pt(n._readableStreamController);return null===e?_():g(e._view,!0),c(void 0)}function v(o){if(f=!0,t=o,h){const o=ge([t,r]),n=Ko(e,o);i(n)}return m}function T(o){if(h=!0,r=o,f){const o=ge([t,r]),n=Ko(e,o);i(n)}return m}function R(){}return o=Yo(R,w,v),n=Yo(R,S,T),y(s),[o,n]}function jo(e){return r(e)&&void 0!==e.getReader}function Lo(e){return jo(e)?Io(e.getReader()):$o(e)}function $o(e){let o;const n=Ae(e,"async");function i(){let e;try{e=Ce(n)}catch(e){return u(e)}return m(c(e),e=>{if(!r(e))throw new TypeError("The promise returned by the iterator.next() method must fulfill with an object");if(qe(e))wo(o._readableStreamController);else{const t=Oe(e);So(o._readableStreamController,t)}})}function s(e){const t=n.iterator;let o,i;try{o=Re(t,"return")}catch(e){return u(e)}if(void 0===o)return c(void 0);try{i=_(o,t,[e])}catch(e){return u(e)}return m(c(i),e=>{if(!r(e))throw new TypeError("The promise returned by the iterator.return() method must fulfill with an object")})}return o=Vo(t,i,s,0),o}function Io(e){let o;function n(){let t;try{t=e.read()}catch(e){return u(e)}return m(t,e=>{if(!r(e))throw new TypeError("The promise returned by the reader.read() method must fulfill with an object");if(e.done)wo(o._readableStreamController);else{const t=e.value;So(o._readableStreamController,t)}})}function i(t){try{return c(e.cancel(t))}catch(e){return u(e)}}return o=Vo(t,n,i,0),o}function Do(e,t){W(e,t);const r=e,o=null==r?void 0:r.autoAllocateChunkSize,n=null==r?void 0:r.cancel,i=null==r?void 0:r.pull,s=null==r?void 0:r.start,a=null==r?void 0:r.type;return{autoAllocateChunkSize:void 0===o?void 0:J(o,`${t} has member 'autoAllocateChunkSize' that`),cancel:void 0===n?void 0:Mo(n,r,`${t} has member 'cancel' that`),pull:void 0===i?void 0:zo(i,r,`${t} has member 'pull' that`),start:void 0===s?void 0:Bo(s,r,`${t} has member 'start' that`),type:void 0===a?void 0:Fo(a,`${t} has member 'type' that`)}}function Mo(e,t,r){return x(e,r),r=>g(e,t,[r])}function zo(e,t,r){return x(e,r),r=>g(e,t,[r])}function Bo(e,t,r){return x(e,r),r=>_(e,t,[r])}function Fo(e,t){if("bytes"!=(e=`${e}`))throw new TypeError(`${t} '${e}' is not a valid enumeration value for ReadableStreamType`);return e}function Wo(e,t){W(e,t);const r=null==e?void 0:e.preventCancel;return{preventCancel:Boolean(r)}}function xo(e,t){W(e,t);const r=null==e?void 0:e.preventAbort,o=null==e?void 0:e.preventCancel,n=null==e?void 0:e.preventClose,i=null==e?void 0:e.signal;return void 0!==i&&Uo(i,`${t} has member 'signal' that`),{preventAbort:Boolean(r),preventCancel:Boolean(o),preventClose:Boolean(n),signal:i}}function Uo(e,t){if(!Yt(e))throw new TypeError(`${t} is not an AbortSignal.`)}function No(e,t){W(e,t);const r=null==e?void 0:e.readable;V(r,"readable","ReadableWritablePair"),K(r,`${t} has member 'readable' that`);const o=null==e?void 0:e.writable;return V(o,"writable","ReadableWritablePair"),Vt(o,`${t} has member 'writable' that`),{readable:r,writable:o}}Object.defineProperties(mo.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},desiredSize:{enumerable:!0}}),n(mo.prototype.close,"close"),n(mo.prototype.enqueue,"enqueue"),n(mo.prototype.error,"error"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(mo.prototype,Symbol.toStringTag,{value:"ReadableStreamDefaultController",configurable:!0});class Ho{constructor(e={},t={}){void 0===e?e=null:N(e,"First parameter");const r=Bt(t,"Second parameter"),o=Do(e,"First parameter");if(Qo(this),"bytes"===o.type){if(void 0!==r.size)throw new RangeError("The strategy for a byte stream cannot have a size function");gt(this,o,Mt(r,0))}else{const e=zt(r);Ao(this,o,Mt(r,1),e)}}get locked(){if(!Go(this))throw en("locked");return Jo(this)}cancel(e=void 0){return Go(this)?Jo(this)?u(new TypeError("Cannot cancel a stream that already has a reader")):Ko(this,e):u(en("cancel"))}getReader(e=void 0){if(!Go(this))throw en("getReader");return void 0===Tt(e,"First parameter").mode?X(this):Pt(this)}pipeThrough(e,t={}){if(!Go(this))throw en("pipeThrough");H(e,1,"pipeThrough");const r=No(e,"First parameter"),o=xo(t,"Second parameter");if(Jo(this))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream");if(tr(r.writable))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream");return y(po(this,r.writable,o.preventClose,o.preventAbort,o.preventCancel,o.signal)),r.readable}pipeTo(e,t={}){if(!Go(this))return u(en("pipeTo"));if(void 0===e)return u("Parameter 1 is required in 'pipeTo'.");if(!er(e))return u(new TypeError("ReadableStream.prototype.pipeTo's first argument must be a WritableStream"));let r;try{r=xo(t,"Second parameter")}catch(e){return u(e)}return Jo(this)?u(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream")):tr(e)?u(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream")):po(this,e,r.preventClose,r.preventAbort,r.preventCancel,r.signal)}tee(){if(!Go(this))throw en("tee");return ge(qo(this))}values(e=void 0){if(!Go(this))throw en("values");return fe(this,Wo(e,"First parameter").preventCancel)}[Pe](e){return this.values(e)}static from(e){return Lo(e)}}function Vo(e,t,r,o=1,n=()=>1){const i=Object.create(Ho.prototype);return Qo(i),Po(i,Object.create(mo.prototype),e,t,r,o,n),i}function Yo(e,t,r){const o=Object.create(Ho.prototype);return Qo(o),_t(o,Object.create(We.prototype),e,t,r,0,void 0),o}function Qo(e){e._state="readable",e._reader=void 0,e._storedError=void 0,e._disturbed=!1}function Go(e){return!!r(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readableStreamController")&&e instanceof Ho}function Jo(e){return void 0!==e._reader}function Ko(e,r){if(e._disturbed=!0,"closed"===e._state)return c(void 0);if("errored"===e._state)return u(e._storedError);Xo(e);const o=e._reader;if(void 0!==o&&jt(o)){const e=o._readIntoRequests;o._readIntoRequests=new S,e.forEach(e=>{e._closeSteps(void 0)})}return m(e._readableStreamController[E](r),t)}function Xo(e){e._state="closed";const t=e._reader;if(void 0!==t&&(M(t),ne(t))){const e=t._readRequests;t._readRequests=new S,e.forEach(e=>{e._closeSteps()})}}function Zo(e,t){e._state="errored",e._storedError=t;const r=e._reader;void 0!==r&&(I(r,t),ne(r)?ae(r,t):It(r,t))}function en(e){return new TypeError(`ReadableStream.prototype.${e} can only be used on a ReadableStream`)}function tn(e,t){W(e,t);const r=null==e?void 0:e.highWaterMark;return V(r,"highWaterMark","QueuingStrategyInit"),{highWaterMark:Y(r)}}Object.defineProperties(Ho,{from:{enumerable:!0}}),Object.defineProperties(Ho.prototype,{cancel:{enumerable:!0},getReader:{enumerable:!0},pipeThrough:{enumerable:!0},pipeTo:{enumerable:!0},tee:{enumerable:!0},values:{enumerable:!0},locked:{enumerable:!0}}),n(Ho.from,"from"),n(Ho.prototype.cancel,"cancel"),n(Ho.prototype.getReader,"getReader"),n(Ho.prototype.pipeThrough,"pipeThrough"),n(Ho.prototype.pipeTo,"pipeTo"),n(Ho.prototype.tee,"tee"),n(Ho.prototype.values,"values"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Ho.prototype,Symbol.toStringTag,{value:"ReadableStream",configurable:!0}),Object.defineProperty(Ho.prototype,Pe,{value:Ho.prototype.values,writable:!0,configurable:!0});const rn=e=>e.byteLength;n(rn,"size");class on{constructor(e){H(e,1,"ByteLengthQueuingStrategy"),e=tn(e,"First parameter"),this._byteLengthQueuingStrategyHighWaterMark=e.highWaterMark}get highWaterMark(){if(!sn(this))throw nn("highWaterMark");return this._byteLengthQueuingStrategyHighWaterMark}get size(){if(!sn(this))throw nn("size");return rn}}function nn(e){return new TypeError(`ByteLengthQueuingStrategy.prototype.${e} can only be used on a ByteLengthQueuingStrategy`)}function sn(e){return!!r(e)&&!!Object.prototype.hasOwnProperty.call(e,"_byteLengthQueuingStrategyHighWaterMark")&&e instanceof on}Object.defineProperties(on.prototype,{highWaterMark:{enumerable:!0},size:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(on.prototype,Symbol.toStringTag,{value:"ByteLengthQueuingStrategy",configurable:!0});const an=()=>1;n(an,"size");class ln{constructor(e){H(e,1,"CountQueuingStrategy"),e=tn(e,"First parameter"),this._countQueuingStrategyHighWaterMark=e.highWaterMark}get highWaterMark(){if(!un(this))throw cn("highWaterMark");return this._countQueuingStrategyHighWaterMark}get size(){if(!un(this))throw cn("size");return an}}function cn(e){return new TypeError(`CountQueuingStrategy.prototype.${e} can only be used on a CountQueuingStrategy`)}function un(e){return!!r(e)&&!!Object.prototype.hasOwnProperty.call(e,"_countQueuingStrategyHighWaterMark")&&e instanceof ln}function dn(e,t){W(e,t);const r=null==e?void 0:e.cancel,o=null==e?void 0:e.flush,n=null==e?void 0:e.readableType,i=null==e?void 0:e.start,s=null==e?void 0:e.transform,a=null==e?void 0:e.writableType;return{cancel:void 0===r?void 0:mn(r,e,`${t} has member 'cancel' that`),flush:void 0===o?void 0:fn(o,e,`${t} has member 'flush' that`),readableType:n,start:void 0===i?void 0:hn(i,e,`${t} has member 'start' that`),transform:void 0===s?void 0:pn(s,e,`${t} has member 'transform' that`),writableType:a}}function fn(e,t,r){return x(e,r),r=>g(e,t,[r])}function hn(e,t,r){return x(e,r),r=>_(e,t,[r])}function pn(e,t,r){return x(e,r),(r,o)=>g(e,t,[r,o])}function mn(e,t,r){return x(e,r),r=>g(e,t,[r])}Object.defineProperties(ln.prototype,{highWaterMark:{enumerable:!0},size:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(ln.prototype,Symbol.toStringTag,{value:"CountQueuingStrategy",configurable:!0});class yn{constructor(e={},t={},r={}){void 0===e&&(e=null);const o=Bt(t,"Second parameter"),n=Bt(r,"Third parameter"),i=dn(e,"First parameter");if(void 0!==i.readableType)throw new RangeError("Invalid readableType specified");if(void 0!==i.writableType)throw new RangeError("Invalid writableType specified");const s=Mt(n,0),a=zt(n),c=Mt(o,1),u=zt(o);let d;bn(this,l(e=>{d=e}),c,u,s,a),Pn(this,i),void 0!==i.start?d(i.start(this._transformStreamController)):d(void 0)}get readable(){if(!_n(this))throw Fn("readable");return this._readable}get writable(){if(!_n(this))throw Fn("writable");return this._writable}}function bn(e,t,r,o,n,i){function s(){return t}function a(t){return jn(e,t)}function l(t){return Ln(e,t)}function c(){return $n(e)}function u(){return In(e)}function d(t){return Dn(e,t)}e._writable=Xt(s,a,c,l,r,o),e._readable=Vo(s,u,d,n,i),e._backpressure=void 0,e._backpressureChangePromise=void 0,e._backpressureChangePromise_resolve=void 0,vn(e,!0),e._transformStreamController=void 0}function _n(e){return!!r(e)&&!!Object.prototype.hasOwnProperty.call(e,"_transformStreamController")&&e instanceof yn}function gn(e,t){vo(e._readable._readableStreamController,t),wn(e,t)}function wn(e,t){An(e._transformStreamController),Br(e._writable._writableStreamController,t),Sn(e)}function Sn(e){e._backpressure&&vn(e,!1)}function vn(e,t){void 0!==e._backpressureChangePromise&&e._backpressureChangePromise_resolve(),e._backpressureChangePromise=l(t=>{e._backpressureChangePromise_resolve=t}),e._backpressure=t}Object.defineProperties(yn.prototype,{readable:{enumerable:!0},writable:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(yn.prototype,Symbol.toStringTag,{value:"TransformStream",configurable:!0});class Tn{constructor(){throw new TypeError("Illegal constructor")}get desiredSize(){if(!Rn(this))throw Mn("desiredSize");return To(this._controlledTransformStream._readable._readableStreamController)}enqueue(e=void 0){if(!Rn(this))throw Mn("enqueue");Cn(this,e)}error(e=void 0){if(!Rn(this))throw Mn("error");qn(this,e)}terminate(){if(!Rn(this))throw Mn("terminate");kn(this)}}function Rn(e){return!!r(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledTransformStream")&&e instanceof Tn}function En(e,t,r,o,n){t._controlledTransformStream=e,e._transformStreamController=t,t._transformAlgorithm=r,t._flushAlgorithm=o,t._cancelAlgorithm=n,t._finishPromise=void 0,t._finishPromise_resolve=void 0,t._finishPromise_reject=void 0}function Pn(e,t){const r=Object.create(Tn.prototype);let o,n,i;o=void 0!==t.transform?e=>t.transform(e,r):e=>{try{return Cn(r,e),c(void 0)}catch(e){return u(e)}},n=void 0!==t.flush?()=>t.flush(r):()=>c(void 0),i=void 0!==t.cancel?e=>t.cancel(e):()=>c(void 0),En(e,r,o,n,i)}function An(e){e._transformAlgorithm=void 0,e._flushAlgorithm=void 0,e._cancelAlgorithm=void 0}function Cn(e,t){const r=e._controlledTransformStream,o=r._readable._readableStreamController;if(!Eo(o))throw new TypeError("Readable side is not in a state that permits enqueue");try{So(o,t)}catch(e){throw wn(r,e),r._readable._storedError}Ro(o)!==r._backpressure&&vn(r,!0)}function qn(e,t){gn(e._controlledTransformStream,t)}function On(e,t){return m(e._transformAlgorithm(t),void 0,t=>{throw gn(e._controlledTransformStream,t),t})}function kn(e){const t=e._controlledTransformStream;wo(t._readable._readableStreamController),wn(t,new TypeError("TransformStream terminated"))}function jn(e,t){const r=e._transformStreamController;return e._backpressure?m(e._backpressureChangePromise,()=>{const o=e._writable;if("erroring"===o._state)throw o._storedError;return On(r,t)}):On(r,t)}function Ln(e,t){const r=e._transformStreamController;if(void 0!==r._finishPromise)return r._finishPromise;const o=e._readable;r._finishPromise=l((e,t)=>{r._finishPromise_resolve=e,r._finishPromise_reject=t});const n=r._cancelAlgorithm(t);return An(r),f(n,()=>("errored"===o._state?Bn(r,o._storedError):(vo(o._readableStreamController,t),zn(r)),null),e=>(vo(o._readableStreamController,e),Bn(r,e),null)),r._finishPromise}function $n(e){const t=e._transformStreamController;if(void 0!==t._finishPromise)return t._finishPromise;const r=e._readable;t._finishPromise=l((e,r)=>{t._finishPromise_resolve=e,t._finishPromise_reject=r});const o=t._flushAlgorithm();return An(t),f(o,()=>("errored"===r._state?Bn(t,r._storedError):(wo(r._readableStreamController),zn(t)),null),e=>(vo(r._readableStreamController,e),Bn(t,e),null)),t._finishPromise}function In(e){return vn(e,!1),e._backpressureChangePromise}function Dn(e,t){const r=e._transformStreamController;if(void 0!==r._finishPromise)return r._finishPromise;const o=e._writable;r._finishPromise=l((e,t)=>{r._finishPromise_resolve=e,r._finishPromise_reject=t});const n=r._cancelAlgorithm(t);return An(r),f(n,()=>("errored"===o._state?Bn(r,o._storedError):(Br(o._writableStreamController,t),Sn(e),zn(r)),null),t=>(Br(o._writableStreamController,t),Sn(e),Bn(r,t),null)),r._finishPromise}function Mn(e){return new TypeError(`TransformStreamDefaultController.prototype.${e} can only be used on a TransformStreamDefaultController`)}function zn(e){void 0!==e._finishPromise_resolve&&(e._finishPromise_resolve(),e._finishPromise_resolve=void 0,e._finishPromise_reject=void 0)}function Bn(e,t){void 0!==e._finishPromise_reject&&(y(e._finishPromise),e._finishPromise_reject(t),e._finishPromise_resolve=void 0,e._finishPromise_reject=void 0)}function Fn(e){return new TypeError(`TransformStream.prototype.${e} can only be used on a TransformStream`)}Object.defineProperties(Tn.prototype,{enqueue:{enumerable:!0},error:{enumerable:!0},terminate:{enumerable:!0},desiredSize:{enumerable:!0}}),n(Tn.prototype.enqueue,"enqueue"),n(Tn.prototype.error,"error"),n(Tn.prototype.terminate,"terminate"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Tn.prototype,Symbol.toStringTag,{value:"TransformStreamDefaultController",configurable:!0}),e.ByteLengthQueuingStrategy=on,e.CountQueuingStrategy=ln,e.ReadableByteStreamController=We,e.ReadableStream=Ho,e.ReadableStreamBYOBReader=kt,e.ReadableStreamBYOBRequest=Fe,e.ReadableStreamDefaultController=mo,e.ReadableStreamDefaultReader=oe,e.TransformStream=yn,e.TransformStreamDefaultController=Tn,e.WritableStream=Jt,e.WritableStreamDefaultController=qr,e.WritableStreamDefaultWriter=_r}(E.exports)),E.exports))}try{const{Blob:e}=require("buffer");e&&!e.prototype.stream&&(e.prototype.stream=function(e){let t=0;const r=this;return new ReadableStream({type:"bytes",async pull(e){const o=r.slice(t,Math.min(r.size,t+65536)),n=await o.arrayBuffer();t+=n.byteLength,e.enqueue(new Uint8Array(n)),t===r.size&&e.close()}})})}catch(e){}
2
+ /*! fetch-blob. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */async function*P(e,t=!0){for(const r of e)if("stream"in r)yield*r.stream();else if(ArrayBuffer.isView(r))if(t){let e=r.byteOffset;const t=r.byteOffset+r.byteLength;for(;e!==t;){const o=Math.min(t-e,65536),n=r.buffer.slice(e,e+o);e+=n.byteLength,yield new Uint8Array(n)}}else yield r;else{let e=0,t=r;for(;e!==t.size;){const r=t.slice(e,Math.min(t.size,e+65536)),o=await r.arrayBuffer();e+=o.byteLength,yield new Uint8Array(o)}}}const A=class e{#e=[];#t="";#r=0;#o="transparent";constructor(t=[],r={}){if("object"!=typeof t||null===t)throw new TypeError("Failed to construct 'Blob': The provided value cannot be converted to a sequence.");if("function"!=typeof t[Symbol.iterator])throw new TypeError("Failed to construct 'Blob': The object must have a callable @@iterator property.");if("object"!=typeof r&&"function"!=typeof r)throw new TypeError("Failed to construct 'Blob': parameter 2 cannot convert to dictionary.");null===r&&(r={});const o=new TextEncoder;for(const r of t){let t;t=ArrayBuffer.isView(r)?new Uint8Array(r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength)):r instanceof ArrayBuffer?new Uint8Array(r.slice(0)):r instanceof e?r:o.encode(`${r}`),this.#r+=ArrayBuffer.isView(t)?t.byteLength:t.size,this.#e.push(t)}this.#o=`${void 0===r.endings?"transparent":r.endings}`;const n=void 0===r.type?"":String(r.type);this.#t=/^[\x20-\x7E]*$/.test(n)?n:""}get size(){return this.#r}get type(){return this.#t}async text(){const e=new TextDecoder;let t="";for await(const r of P(this.#e,!1))t+=e.decode(r,{stream:!0});return t+=e.decode(),t}async arrayBuffer(){const e=new Uint8Array(this.size);let t=0;for await(const r of P(this.#e,!1))e.set(r,t),t+=r.length;return e.buffer}stream(){const e=P(this.#e,!0);return new globalThis.ReadableStream({type:"bytes",async pull(t){const r=await e.next();r.done?t.close():t.enqueue(r.value)},async cancel(){await e.return()}})}slice(t=0,r=this.size,o=""){const{size:n}=this;let i=t<0?Math.max(n+t,0):Math.min(t,n),s=r<0?Math.max(n+r,0):Math.min(r,n);const a=Math.max(s-i,0),l=this.#e,c=[];let u=0;for(const e of l){if(u>=a)break;const t=ArrayBuffer.isView(e)?e.byteLength:e.size;if(i&&t<=i)i-=t,s-=t;else{let r;ArrayBuffer.isView(e)?(r=e.subarray(i,Math.min(t,s)),u+=r.byteLength):(r=e.slice(i,Math.min(t,s)),u+=r.size),s-=t,c.push(r),i=0}}const d=new e([],{type:String(o).toLowerCase()});return d.#r=a,d.#e=c,d}get[Symbol.toStringTag](){return"Blob"}static[Symbol.hasInstance](e){return e&&"object"==typeof e&&"function"==typeof e.constructor&&("function"==typeof e.stream||"function"==typeof e.arrayBuffer)&&/^(Blob|File)$/.test(e[Symbol.toStringTag])}};Object.defineProperties(A.prototype,{size:{enumerable:!0},type:{enumerable:!0},slice:{enumerable:!0}});var C=A;const q=class extends C{#n=0;#i="";constructor(e,t,r={}){if(arguments.length<2)throw new TypeError(`Failed to construct 'File': 2 arguments required, but only ${arguments.length} present.`);super(e,r),null===r&&(r={});const o=void 0===r.lastModified?Date.now():Number(r.lastModified);Number.isNaN(o)||(this.#n=o),this.#i=String(t)}get name(){return this.#i}get lastModified(){return this.#n}get[Symbol.toStringTag](){return"File"}static[Symbol.hasInstance](e){return!!e&&e instanceof C&&/^(File)$/.test(e[Symbol.toStringTag])}};
3
+ /*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
4
+ var{toStringTag:O,iterator:k,hasInstance:j}=Symbol,L=Math.random,$="append,set,get,getAll,delete,keys,values,entries,forEach,constructor".split(","),I=(e,t,r)=>(e+="",/^(Blob|File)$/.test(t&&t[O])?[(r=void 0!==r?r+"":"File"==t[O]?t.name:"blob",e),t.name!==r||"blob"==t[O]?new q([t],r,t):t]:[e,t+""]),D=(e,t)=>(t?e:e.replace(/\r?\n|\r/g,"\r\n")).replace(/\n/g,"%0A").replace(/\r/g,"%0D").replace(/"/g,"%22"),M=(e,t,r)=>{if(t.length<r)throw new TypeError(`Failed to execute '${e}' on 'FormData': ${r} arguments required, but only ${t.length} present.`)};const z=class{#s=[];constructor(...e){if(e.length)throw new TypeError("Failed to construct 'FormData': parameter 1 is not of type 'HTMLFormElement'.")}get[O](){return"FormData"}[k](){return this.entries()}static[j](e){return e&&"object"==typeof e&&"FormData"===e[O]&&!$.some(t=>"function"!=typeof e[t])}append(...e){M("append",arguments,2),this.#s.push(I(...e))}delete(e){M("delete",arguments,1),e+="",this.#s=this.#s.filter(([t])=>t!==e)}get(e){M("get",arguments,1),e+="";for(var t=this.#s,r=t.length,o=0;o<r;o++)if(t[o][0]===e)return t[o][1];return null}getAll(e,t){return M("getAll",arguments,1),t=[],e+="",this.#s.forEach(r=>r[0]===e&&t.push(r[1])),t}has(e){return M("has",arguments,1),e+="",this.#s.some(t=>t[0]===e)}forEach(e,t){for(var[r,o]of(M("forEach",arguments,1),this))e.call(t,o,r,this)}set(...e){M("set",arguments,2);var t=[],r=!0;e=I(...e),this.#s.forEach(o=>{o[0]===e[0]?r&&(r=!t.push(e)):t.push(o)}),r&&t.push(e),this.#s=t}*entries(){yield*this.#s}*keys(){for(var[e]of this)yield e}*values(){for(var[,e]of this)yield e}};class B extends Error{constructor(e,t){super(e),Error.captureStackTrace(this,this.constructor),this.type=t}get name(){return this.constructor.name}get[Symbol.toStringTag](){return this.constructor.name}}class F extends B{constructor(e,t,r){super(e,t),r&&(this.code=this.errno=r.code,this.erroredSysCall=r.syscall)}}const W=Symbol.toStringTag,x=e=>"object"==typeof e&&"function"==typeof e.append&&"function"==typeof e.delete&&"function"==typeof e.get&&"function"==typeof e.getAll&&"function"==typeof e.has&&"function"==typeof e.set&&"function"==typeof e.sort&&"URLSearchParams"===e[W],U=e=>e&&"object"==typeof e&&"function"==typeof e.arrayBuffer&&"string"==typeof e.type&&"function"==typeof e.stream&&"function"==typeof e.constructor&&/^(Blob|File)$/.test(e[W]),N=c(n.pipeline),H=Symbol("Body internals");class V{constructor(e,{size:t=0}={}){let r=null;null===e?e=null:x(e)?e=a.from(e.toString()):U(e)||a.isBuffer(e)||(l.isAnyArrayBuffer(e)?e=a.from(e):ArrayBuffer.isView(e)?e=a.from(e.buffer,e.byteOffset,e.byteLength):e instanceof n||(e instanceof z?(e=function(e,t=C){var r=`${L()}${L()}`.replace(/\./g,"").slice(-28).padStart(32,"-"),o=[],n=`--${r}\r\nContent-Disposition: form-data; name="`;return e.forEach((e,t)=>"string"==typeof e?o.push(n+D(t)+`"\r\n\r\n${e.replace(/\r(?!\n)|(?<!\r)\n/g,"\r\n")}\r\n`):o.push(n+D(t)+`"; filename="${D(e.name,1)}"\r\nContent-Type: ${e.type||"application/octet-stream"}\r\n\r\n`,e,"\r\n")),o.push(`--${r}--`),new t(o,{type:"multipart/form-data; boundary="+r})}(e),r=e.type.split("=")[1]):e=a.from(String(e))));let o=e;a.isBuffer(e)?o=n.Readable.from(e):U(e)&&(o=n.Readable.from(e.stream())),this[H]={body:e,stream:o,boundary:r,disturbed:!1,error:null},this.size=t,e instanceof n&&e.on("error",e=>{const t=e instanceof B?e:new F(`Invalid response body while trying to fetch ${this.url}: ${e.message}`,"system",e);this[H].error=t})}get body(){return this[H].stream}get bodyUsed(){return this[H].disturbed}async arrayBuffer(){const{buffer:e,byteOffset:t,byteLength:r}=await Y(this);return e.slice(t,t+r)}async formData(){const e=this.headers.get("content-type");if(e.startsWith("application/x-www-form-urlencoded")){const e=new z,t=new URLSearchParams(await this.text());for(const[r,o]of t)e.append(r,o);return e}const{toFormData:t}=await Promise.resolve().then(function(){return Te});return t(this.body,e)}async blob(){const e=this.headers&&this.headers.get("content-type")||this[H].body&&this[H].body.type||"",t=await this.arrayBuffer();return new C([t],{type:e})}async json(){const e=await this.text();return JSON.parse(e)}async text(){const e=await Y(this);return(new TextDecoder).decode(e)}buffer(){return Y(this)}}async function Y(e){if(e[H].disturbed)throw new TypeError(`body used already for: ${e.url}`);if(e[H].disturbed=!0,e[H].error)throw e[H].error;const{body:t}=e;if(null===t)return a.alloc(0);if(!(t instanceof n))return a.alloc(0);const r=[];let o=0;try{for await(const n of t){if(e.size>0&&o+n.length>e.size){const r=new F(`content size at ${e.url} over limit: ${e.size}`,"max-size");throw t.destroy(r),r}o+=n.length,r.push(n)}}catch(t){throw t instanceof B?t:new F(`Invalid response body while trying to fetch ${e.url}: ${t.message}`,"system",t)}if(!0!==t.readableEnded&&!0!==t._readableState.ended)throw new F(`Premature close of server response while trying to fetch ${e.url}`);try{return r.every(e=>"string"==typeof e)?a.from(r.join("")):a.concat(r,o)}catch(t){throw new F(`Could not create Buffer from response body for ${e.url}: ${t.message}`,"system",t)}}V.prototype.buffer=u(V.prototype.buffer,"Please use 'response.arrayBuffer()' instead of 'response.buffer()'","node-fetch#buffer"),Object.defineProperties(V.prototype,{body:{enumerable:!0},bodyUsed:{enumerable:!0},arrayBuffer:{enumerable:!0},blob:{enumerable:!0},json:{enumerable:!0},text:{enumerable:!0},data:{get:u(()=>{},"data doesn't exist, use json(), text(), arrayBuffer(), or body instead","https://github.com/node-fetch/node-fetch/issues/1000 (response)")}});const Q=(e,t)=>{let r,o,{body:s}=e[H];if(e.bodyUsed)throw new Error("cannot clone body after it is used");return s instanceof n&&"function"!=typeof s.getBoundary&&(r=new i({highWaterMark:t}),o=new i({highWaterMark:t}),s.pipe(r),s.pipe(o),e[H].stream=r,s=o),s},G=u(e=>e.getBoundary(),"form-data doesn't follow the spec and requires special treatment. Use alternative package","https://github.com/node-fetch/node-fetch/issues/1167"),J=(e,t)=>null===e?null:"string"==typeof e?"text/plain;charset=UTF-8":x(e)?"application/x-www-form-urlencoded;charset=UTF-8":U(e)?e.type||null:a.isBuffer(e)||l.isAnyArrayBuffer(e)||ArrayBuffer.isView(e)?null:e instanceof z?`multipart/form-data; boundary=${t[H].boundary}`:e&&"function"==typeof e.getBoundary?`multipart/form-data;boundary=${G(e)}`:e instanceof n?null:"text/plain;charset=UTF-8",K="function"==typeof t.validateHeaderName?t.validateHeaderName:e=>{if(!/^[\^`\-\w!#$%&'*+.|~]+$/.test(e)){const t=new TypeError(`Header name must be a valid HTTP token [${e}]`);throw Object.defineProperty(t,"code",{value:"ERR_INVALID_HTTP_TOKEN"}),t}},X="function"==typeof t.validateHeaderValue?t.validateHeaderValue:(e,t)=>{if(/[^\t\u0020-\u007E\u0080-\u00FF]/.test(t)){const t=new TypeError(`Invalid character in header content ["${e}"]`);throw Object.defineProperty(t,"code",{value:"ERR_INVALID_CHAR"}),t}};class Z extends URLSearchParams{constructor(e){let t=[];if(e instanceof Z){const r=e.raw();for(const[e,o]of Object.entries(r))t.push(...o.map(t=>[e,t]))}else if(null==e);else{if("object"!=typeof e||l.isBoxedPrimitive(e))throw new TypeError("Failed to construct 'Headers': The provided value is not of type '(sequence<sequence<ByteString>> or record<ByteString, ByteString>)");{const r=e[Symbol.iterator];if(null==r)t.push(...Object.entries(e));else{if("function"!=typeof r)throw new TypeError("Header pairs must be iterable");t=[...e].map(e=>{if("object"!=typeof e||l.isBoxedPrimitive(e))throw new TypeError("Each header pair must be an iterable object");return[...e]}).map(e=>{if(2!==e.length)throw new TypeError("Each header pair must be a name/value tuple");return[...e]})}}}return t=t.length>0?t.map(([e,t])=>(K(e),X(e,String(t)),[String(e).toLowerCase(),String(t)])):void 0,super(t),new Proxy(this,{get(e,t,r){switch(t){case"append":case"set":return(r,o)=>(K(r),X(r,String(o)),URLSearchParams.prototype[t].call(e,String(r).toLowerCase(),String(o)));case"delete":case"has":case"getAll":return r=>(K(r),URLSearchParams.prototype[t].call(e,String(r).toLowerCase()));case"keys":return()=>(e.sort(),new Set(URLSearchParams.prototype.keys.call(e)).keys());default:return Reflect.get(e,t,r)}}})}get[Symbol.toStringTag](){return this.constructor.name}toString(){return Object.prototype.toString.call(this)}get(e){const t=this.getAll(e);if(0===t.length)return null;let r=t.join(", ");return/^content-encoding$/i.test(e)&&(r=r.toLowerCase()),r}forEach(e,t=void 0){for(const r of this.keys())Reflect.apply(e,t,[this.get(r),r,this])}*values(){for(const e of this.keys())yield this.get(e)}*entries(){for(const e of this.keys())yield[e,this.get(e)]}[Symbol.iterator](){return this.entries()}raw(){return[...this.keys()].reduce((e,t)=>(e[t]=this.getAll(t),e),{})}[Symbol.for("nodejs.util.inspect.custom")](){return[...this.keys()].reduce((e,t)=>{const r=this.getAll(t);return e[t]="host"===t?r[0]:r.length>1?r:r[0],e},{})}}Object.defineProperties(Z.prototype,["get","entries","forEach","values"].reduce((e,t)=>(e[t]={enumerable:!0},e),{}));const ee=new Set([301,302,303,307,308]),te=e=>ee.has(e),re=Symbol("Response internals");class oe extends V{constructor(e=null,t={}){super(e,t);const r=null!=t.status?t.status:200,o=new Z(t.headers);if(null!==e&&!o.has("Content-Type")){const t=J(e,this);t&&o.append("Content-Type",t)}this[re]={type:"default",url:t.url,status:r,statusText:t.statusText||"",headers:o,counter:t.counter,highWaterMark:t.highWaterMark}}get type(){return this[re].type}get url(){return this[re].url||""}get status(){return this[re].status}get ok(){return this[re].status>=200&&this[re].status<300}get redirected(){return this[re].counter>0}get statusText(){return this[re].statusText}get headers(){return this[re].headers}get highWaterMark(){return this[re].highWaterMark}clone(){return new oe(Q(this,this.highWaterMark),{type:this.type,url:this.url,status:this.status,statusText:this.statusText,headers:this.headers,ok:this.ok,redirected:this.redirected,size:this.size,highWaterMark:this.highWaterMark})}static redirect(e,t=302){if(!te(t))throw new RangeError('Failed to execute "redirect" on "response": Invalid status code');return new oe(null,{headers:{location:new URL(e).toString()},status:t})}static error(){const e=new oe(null,{status:0,statusText:""});return e[re].type="error",e}static json(e=void 0,t={}){const r=JSON.stringify(e);if(void 0===r)throw new TypeError("data is not JSON serializable");const o=new Z(t&&t.headers);return o.has("content-type")||o.set("content-type","application/json"),new oe(r,{...t,headers:o})}get[Symbol.toStringTag](){return"Response"}}Object.defineProperties(oe.prototype,{type:{enumerable:!0},url:{enumerable:!0},status:{enumerable:!0},ok:{enumerable:!0},redirected:{enumerable:!0},statusText:{enumerable:!0},headers:{enumerable:!0},clone:{enumerable:!0}});function ne(e,t=!1){return null==e?"no-referrer":(e=new URL(e),/^(about|blob|data):$/.test(e.protocol)?"no-referrer":(e.username="",e.password="",e.hash="",t&&(e.pathname="",e.search=""),e))}const ie=new Set(["","no-referrer","no-referrer-when-downgrade","same-origin","origin","strict-origin","origin-when-cross-origin","strict-origin-when-cross-origin","unsafe-url"]);function se(e){return!!/^about:(blank|srcdoc)$/.test(e)||("data:"===e.protocol||(!!/^(blob|filesystem):$/.test(e.protocol)||function(e){if(/^(http|ws)s:$/.test(e.protocol))return!0;const t=e.host.replace(/(^\[)|(]$)/g,""),r=f(t);return!(4!==r||!/^127\./.test(t))||!(6!==r||!/^(((0+:){7})|(::(0+:){0,6}))0*1$/.test(t))||"localhost"!==e.host&&!e.host.endsWith(".localhost")&&"file:"===e.protocol}(e)))}const ae=Symbol("Request internals"),le=e=>"object"==typeof e&&"object"==typeof e[ae],ce=u(()=>{},".data is not a valid RequestInit property, use .body instead","https://github.com/node-fetch/node-fetch/issues/1000 (request)");class ue extends V{constructor(e,t={}){let r;if(le(e)?r=new URL(e.url):(r=new URL(e),e={}),""!==r.username||""!==r.password)throw new TypeError(`${r} is an url with embedded credentials.`);let o=t.method||e.method||"GET";if(/^(delete|get|head|options|post|put)$/i.test(o)&&(o=o.toUpperCase()),!le(t)&&"data"in t&&ce(),(null!=t.body||le(e)&&null!==e.body)&&("GET"===o||"HEAD"===o))throw new TypeError("Request with GET/HEAD method cannot have body");const n=t.body?t.body:le(e)&&null!==e.body?Q(e):null;super(n,{size:t.size||e.size||0});const i=new Z(t.headers||e.headers||{});if(null!==n&&!i.has("Content-Type")){const e=J(n,this);e&&i.set("Content-Type",e)}let s=le(e)?e.signal:null;if("signal"in t&&(s=t.signal),null!=s&&("object"!=typeof(a=s)||"AbortSignal"!==a[W]&&"EventTarget"!==a[W]))throw new TypeError("Expected signal to be an instanceof AbortSignal or EventTarget");var a;let l=null==t.referrer?e.referrer:t.referrer;if(""===l)l="no-referrer";else if(l){const e=new URL(l);l=/^about:(\/\/)?client$/.test(e)?"client":e}else l=void 0;this[ae]={method:o,redirect:t.redirect||e.redirect||"follow",headers:i,parsedURL:r,signal:s,referrer:l},this.follow=void 0===t.follow?void 0===e.follow?20:e.follow:t.follow,this.compress=void 0===t.compress?void 0===e.compress||e.compress:t.compress,this.counter=t.counter||e.counter||0,this.agent=t.agent||e.agent,this.highWaterMark=t.highWaterMark||e.highWaterMark||16384,this.insecureHTTPParser=t.insecureHTTPParser||e.insecureHTTPParser||!1,this.referrerPolicy=t.referrerPolicy||e.referrerPolicy||""}get method(){return this[ae].method}get url(){return d(this[ae].parsedURL)}get headers(){return this[ae].headers}get redirect(){return this[ae].redirect}get signal(){return this[ae].signal}get referrer(){return"no-referrer"===this[ae].referrer?"":"client"===this[ae].referrer?"about:client":this[ae].referrer?this[ae].referrer.toString():void 0}get referrerPolicy(){return this[ae].referrerPolicy}set referrerPolicy(e){this[ae].referrerPolicy=function(e){if(!ie.has(e))throw new TypeError(`Invalid referrerPolicy: ${e}`);return e}(e)}clone(){return new ue(this)}get[Symbol.toStringTag](){return"Request"}}Object.defineProperties(ue.prototype,{method:{enumerable:!0},url:{enumerable:!0},headers:{enumerable:!0},redirect:{enumerable:!0},clone:{enumerable:!0},signal:{enumerable:!0},referrer:{enumerable:!0},referrerPolicy:{enumerable:!0}});const de=e=>{const{parsedURL:t}=e[ae],r=new Z(e[ae].headers);r.has("Accept")||r.set("Accept","*/*");let o=null;if(null===e.body&&/^(post|put)$/i.test(e.method)&&(o="0"),null!==e.body){const t=(e=>{const{body:t}=e[H];return null===t?0:U(t)?t.size:a.isBuffer(t)?t.length:t&&"function"==typeof t.getLengthSync&&t.hasKnownLength&&t.hasKnownLength()?t.getLengthSync():null})(e);"number"!=typeof t||Number.isNaN(t)||(o=String(t))}o&&r.set("Content-Length",o),""===e.referrerPolicy&&(e.referrerPolicy="strict-origin-when-cross-origin"),e.referrer&&"no-referrer"!==e.referrer?e[ae].referrer=function(e,{referrerURLCallback:t,referrerOriginCallback:r}={}){if("no-referrer"===e.referrer||""===e.referrerPolicy)return null;const o=e.referrerPolicy;if("about:client"===e.referrer)return"no-referrer";const n=e.referrer;let i=ne(n),s=ne(n,!0);i.toString().length>4096&&(i=s),t&&(i=t(i)),r&&(s=r(s));const a=new URL(e.url);switch(o){case"no-referrer":return"no-referrer";case"origin":return s;case"unsafe-url":return i;case"strict-origin":return se(i)&&!se(a)?"no-referrer":s.toString();case"strict-origin-when-cross-origin":return i.origin===a.origin?i:se(i)&&!se(a)?"no-referrer":s;case"same-origin":return i.origin===a.origin?i:"no-referrer";case"origin-when-cross-origin":return i.origin===a.origin?i:s;case"no-referrer-when-downgrade":return se(i)&&!se(a)?"no-referrer":i;default:throw new TypeError(`Invalid referrerPolicy: ${o}`)}}(e):e[ae].referrer="no-referrer",e[ae].referrer instanceof URL&&r.set("Referer",e.referrer),r.has("User-Agent")||r.set("User-Agent","node-fetch"),e.compress&&!r.has("Accept-Encoding")&&r.set("Accept-Encoding","gzip, deflate, br");let{agent:n}=e;"function"==typeof n&&(n=n(t));const i=(e=>{if(e.search)return e.search;const t=e.href.length-1,r=e.hash||("#"===e.href[t]?"#":"");return"?"===e.href[t-r.length]?"?":""})(t);return{parsedURL:t,options:{path:t.pathname+i,method:e.method,headers:r[Symbol.for("nodejs.util.inspect.custom")](),insecureHTTPParser:e.insecureHTTPParser,agent:n}}};class fe extends B{constructor(e,t="aborted"){super(e,t)}}
5
+ /*! node-domexception. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */if(!globalThis.DOMException)try{const{MessageChannel:e}=require("worker_threads"),t=(new e).port1,r=new ArrayBuffer;t.postMessage(r,[r,r])}catch(e){"DOMException"===e.constructor.name&&(globalThis.DOMException=e.constructor)}const he=new Set(["data:","http:","https:"]);var pe=Object.freeze({__proto__:null,AbortError:fe,Blob:C,FetchError:F,File:q,FormData:z,Headers:Z,Request:ue,Response:oe,default:async function e(l,c){return new Promise((u,d)=>{const f=new ue(l,c),{parsedURL:h,options:p}=de(f);if(!he.has(h.protocol))throw new TypeError(`node-fetch cannot load ${l}. URL scheme "${h.protocol.replace(/:$/,"")}" is not supported.`);if("data:"===h.protocol){const e=function(e){if(!/^data:/i.test(e))throw new TypeError('`uri` does not appear to be a Data URI (must begin with "data:")');const t=(e=e.replace(/\r?\n/g,"")).indexOf(",");if(-1===t||t<=4)throw new TypeError("malformed data: URI");const r=e.substring(5,t).split(";");let o="",n=!1;const i=r[0]||"text/plain";let s=i;for(let e=1;e<r.length;e++)"base64"===r[e]?n=!0:r[e]&&(s+=`;${r[e]}`,0===r[e].indexOf("charset=")&&(o=r[e].substring(8)));r[0]||o.length||(s+=";charset=US-ASCII",o="US-ASCII");const a=n?"base64":"ascii",l=unescape(e.substring(t+1)),c=Buffer.from(l,a);return c.type=i,c.typeFull=s,c.charset=o,c}(f.url),t=new oe(e,{headers:{"Content-Type":e.typeFull}});return void u(t)}const m=("https:"===h.protocol?r:t).request,{signal:y}=f;let b=null;const _=()=>{const e=new fe("The operation was aborted.");d(e),f.body&&f.body instanceof n.Readable&&f.body.destroy(e),b&&b.body&&b.body.emit("error",e)};if(y&&y.aborted)return void _();const g=()=>{_(),S()},w=m(h.toString(),p);y&&y.addEventListener("abort",g);const S=()=>{w.abort(),y&&y.removeEventListener("abort",g)};w.on("error",e=>{d(new F(`request to ${f.url} failed, reason: ${e.message}`,"system",e)),S()}),function(e,t){const r=a.from("0\r\n\r\n");let o,n=!1,i=!1;e.on("response",e=>{const{headers:t}=e;n="chunked"===t["transfer-encoding"]&&!t["content-length"]}),e.on("socket",s=>{const l=()=>{if(n&&!i){const e=new Error("Premature close");e.code="ERR_STREAM_PREMATURE_CLOSE",t(e)}},c=e=>{i=0===a.compare(e.slice(-5),r),!i&&o&&(i=0===a.compare(o.slice(-3),r.slice(0,3))&&0===a.compare(e.slice(-2),r.slice(3))),o=e};s.prependListener("close",l),s.on("data",c),e.on("close",()=>{s.removeListener("close",l),s.removeListener("data",c)})})}(w,e=>{b&&b.body&&b.body.destroy(e)}),process.version<"v14"&&w.on("socket",e=>{let t;e.prependListener("end",()=>{t=e._eventsCount}),e.prependListener("close",r=>{if(b&&t<e._eventsCount&&!r){const e=new Error("Premature close");e.code="ERR_STREAM_PREMATURE_CLOSE",b.body.emit("error",e)}})}),w.on("response",t=>{w.setTimeout(0);const r=function(e=[]){return new Z(e.reduce((e,t,r,o)=>(r%2==0&&e.push(o.slice(r,r+2)),e),[]).filter(([e,t])=>{try{return K(e),X(e,String(t)),!0}catch{return!1}}))}(t.rawHeaders);if(te(t.statusCode)){const o=r.get("Location");let i=null;try{i=null===o?null:new URL(o,f.url)}catch{if("manual"!==f.redirect)return d(new F(`uri requested responds with an invalid redirect URL: ${o}`,"invalid-redirect")),void S()}switch(f.redirect){case"error":return d(new F(`uri requested responds with a redirect, redirect mode is set to error: ${f.url}`,"no-redirect")),void S();case"manual":break;case"follow":{if(null===i)break;if(f.counter>=f.follow)return d(new F(`maximum redirect reached at: ${f.url}`,"max-redirect")),void S();const o={headers:new Z(f.headers),follow:f.follow,counter:f.counter+1,agent:f.agent,compress:f.compress,method:f.method,body:Q(f),signal:f.signal,size:f.size,referrer:f.referrer,referrerPolicy:f.referrerPolicy};if(!((e,t)=>{const r=new URL(t).hostname,o=new URL(e).hostname;return r===o||r.endsWith(`.${o}`)})(f.url,i)||(a=f.url,new URL(i).protocol!==new URL(a).protocol))for(const e of["authorization","www-authenticate","cookie","cookie2"])o.headers.delete(e);if(303!==t.statusCode&&f.body&&c.body instanceof n.Readable)return d(new F("Cannot follow redirect with body being a readable stream","unsupported-redirect")),void S();303!==t.statusCode&&(301!==t.statusCode&&302!==t.statusCode||"POST"!==f.method)||(o.method="GET",o.body=void 0,o.headers.delete("content-length"));const s=function(e){const t=(e.get("referrer-policy")||"").split(/[,\s]+/);let r="";for(const e of t)e&&ie.has(e)&&(r=e);return r}(r);return s&&(o.referrerPolicy=s),u(e(new ue(i,o))),void S()}default:return d(new TypeError(`Redirect option '${f.redirect}' is not a valid value of RequestRedirect`))}}var a;y&&t.once("end",()=>{y.removeEventListener("abort",g)});let l=s(t,new i,e=>{e&&d(e)});process.version<"v12.10"&&t.on("aborted",g);const h={url:f.url,status:t.statusCode,statusText:t.statusMessage,headers:r,size:f.size,counter:f.counter,highWaterMark:f.highWaterMark},p=r.get("Content-Encoding");if(!f.compress||"HEAD"===f.method||null===p||204===t.statusCode||304===t.statusCode)return b=new oe(l,h),void u(b);const m={flush:o.Z_SYNC_FLUSH,finishFlush:o.Z_SYNC_FLUSH};if("gzip"===p||"x-gzip"===p)return l=s(l,o.createGunzip(m),e=>{e&&d(e)}),b=new oe(l,h),void u(b);if("deflate"===p||"x-deflate"===p){const e=s(t,new i,e=>{e&&d(e)});return e.once("data",e=>{l=8==(15&e[0])?s(l,o.createInflate(),e=>{e&&d(e)}):s(l,o.createInflateRaw(),e=>{e&&d(e)}),b=new oe(l,h),u(b)}),void e.once("end",()=>{b||(b=new oe(l,h),u(b))})}if("br"===p)return l=s(l,o.createBrotliDecompress(),e=>{e&&d(e)}),b=new oe(l,h),void u(b);b=new oe(l,h),u(b)}),(async(e,{body:t})=>{null===t?e.end():await N(t,e)})(w,f).catch(d)})},isRedirect:te});let me=0;const ye={START_BOUNDARY:me++,HEADER_FIELD_START:me++,HEADER_FIELD:me++,HEADER_VALUE_START:me++,HEADER_VALUE:me++,HEADER_VALUE_ALMOST_DONE:me++,HEADERS_ALMOST_DONE:me++,PART_DATA_START:me++,PART_DATA:me++,END:me++};let be=1;const _e=be,ge=be*=2,we=e=>32|e,Se=()=>{};class ve{constructor(e){this.index=0,this.flags=0,this.onHeaderEnd=Se,this.onHeaderField=Se,this.onHeadersEnd=Se,this.onHeaderValue=Se,this.onPartBegin=Se,this.onPartData=Se,this.onPartEnd=Se,this.boundaryChars={},e="\r\n--"+e;const t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r),this.boundaryChars[t[r]]=!0;this.boundary=t,this.lookbehind=new Uint8Array(this.boundary.length+8),this.state=ye.START_BOUNDARY}write(e){let t=0;const r=e.length;let o=this.index,{lookbehind:n,boundary:i,boundaryChars:s,index:a,state:l,flags:c}=this;const u=this.boundary.length,d=u-1,f=e.length;let h,p;const m=e=>{this[e+"Mark"]=t},y=e=>{delete this[e+"Mark"]},b=(e,t,r,o)=>{void 0!==t&&t===r||this[e](o&&o.subarray(t,r))},_=(r,o)=>{const n=r+"Mark";n in this&&(o?(b(r,this[n],t,e),delete this[n]):(b(r,this[n],e.length,e),this[n]=0))};for(t=0;t<r;t++)switch(h=e[t],l){case ye.START_BOUNDARY:if(a===i.length-2){if(45===h)c|=ge;else if(13!==h)return;a++;break}if(a-1==i.length-2){if(c&ge&&45===h)l=ye.END,c=0;else{if(c&ge||10!==h)return;a=0,b("onPartBegin"),l=ye.HEADER_FIELD_START}break}h!==i[a+2]&&(a=-2),h===i[a+2]&&a++;break;case ye.HEADER_FIELD_START:l=ye.HEADER_FIELD,m("onHeaderField"),a=0;case ye.HEADER_FIELD:if(13===h){y("onHeaderField"),l=ye.HEADERS_ALMOST_DONE;break}if(a++,45===h)break;if(58===h){if(1===a)return;_("onHeaderField",!0),l=ye.HEADER_VALUE_START;break}if(p=we(h),p<97||p>122)return;break;case ye.HEADER_VALUE_START:if(32===h)break;m("onHeaderValue"),l=ye.HEADER_VALUE;case ye.HEADER_VALUE:13===h&&(_("onHeaderValue",!0),b("onHeaderEnd"),l=ye.HEADER_VALUE_ALMOST_DONE);break;case ye.HEADER_VALUE_ALMOST_DONE:if(10!==h)return;l=ye.HEADER_FIELD_START;break;case ye.HEADERS_ALMOST_DONE:if(10!==h)return;b("onHeadersEnd"),l=ye.PART_DATA_START;break;case ye.PART_DATA_START:l=ye.PART_DATA,m("onPartData");case ye.PART_DATA:if(o=a,0===a){for(t+=d;t<f&&!(e[t]in s);)t+=u;t-=d,h=e[t]}if(a<i.length)i[a]===h?(0===a&&_("onPartData",!0),a++):a=0;else if(a===i.length)a++,13===h?c|=_e:45===h?c|=ge:a=0;else if(a-1===i.length)if(c&_e){if(a=0,10===h){c&=~_e,b("onPartEnd"),b("onPartBegin"),l=ye.HEADER_FIELD_START;break}}else c&ge&&45===h?(b("onPartEnd"),l=ye.END,c=0):a=0;if(a>0)n[a-1]=h;else if(o>0){const e=new Uint8Array(n.buffer,n.byteOffset,n.byteLength);b("onPartData",0,o,e),o=0,m("onPartData"),t--}break;case ye.END:break;default:throw new Error(`Unexpected state entered: ${l}`)}_("onHeaderField"),_("onHeaderValue"),_("onPartData"),this.index=a,this.state=l,this.flags=c}end(){if(this.state===ye.HEADER_FIELD_START&&0===this.index||this.state===ye.PART_DATA&&this.index===this.boundary.length)this.onPartEnd();else if(this.state!==ye.END)throw new Error("MultipartParser.end(): stream ended unexpectedly")}}var Te=Object.freeze({__proto__:null,toFormData:async function(e,t){if(!/multipart/i.test(t))throw new TypeError("Failed to fetch");const r=t.match(/boundary=(?:"([^"]+)"|([^;]+))/i);if(!r)throw new TypeError("no or bad content-type header, no multipart boundary");const o=new ve(r[1]||r[2]);let n,i,s,a,l,c;const u=[],d=new z,f=e=>{s+=y.decode(e,{stream:!0})},h=e=>{u.push(e)},p=()=>{const e=new q(u,c,{type:l});d.append(a,e)},m=()=>{d.append(a,s)},y=new TextDecoder("utf-8");y.decode(),o.onPartBegin=function(){o.onPartData=f,o.onPartEnd=m,n="",i="",s="",a="",l="",c=null,u.length=0},o.onHeaderField=function(e){n+=y.decode(e,{stream:!0})},o.onHeaderValue=function(e){i+=y.decode(e,{stream:!0})},o.onHeaderEnd=function(){if(i+=y.decode(),n=n.toLowerCase(),"content-disposition"===n){const e=i.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);e&&(a=e[2]||e[3]||""),c=function(e){const t=e.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);if(!t)return;const r=t[2]||t[3]||"";let o=r.slice(r.lastIndexOf("\\")+1);return o=o.replace(/%22/g,'"'),o=o.replace(/&#(\d{4});/g,(e,t)=>String.fromCharCode(t)),o}(i),c&&(o.onPartData=h,o.onPartEnd=p)}else"content-type"===n&&(l=i);i="",n=""};for await(const t of e)o.write(t);return o.end(),d}});export{S as endpoints,w as hooks,v as operations};
package/dist/app.js ADDED
@@ -0,0 +1 @@
1
+ import{useApi as e,defineModule as n}from"@directus/extensions-sdk";import{resolveComponent as t,openBlock as a,createElementBlock as o,createCommentVNode as r,createElementVNode as i,createVNode as s,Transition as d,withCtx as l,createBlock as c,createTextVNode as g,toDisplayString as m,Fragment as p,renderList as u,normalizeClass as v,createStaticVNode as b,resolveDynamicComponent as f}from"vue";function h(e){return{addQueryToPath:n,getToken:t,addTokenToURL:function(e){const a=t();return a?n(e,{access_token:a}):e}};function n(e,n){const t=[];for(const[e,a]of Object.entries(n))t.push(`${e}=${a}`);return e.includes("?")?`${e}&${t.join("&")}`:`${e}?${t.join("&")}`}function t(){return e.defaults?.headers?.Authorization?.split(" ")[1]||e.defaults?.headers?.common?.Authorization?.split(" ")[1]||null}}var x=[],y=[];function w(e,n){if(e&&"undefined"!=typeof document){var t,a=!0===n.prepend?"prepend":"append",o=!0===n.singleTag,r="string"==typeof n.container?document.querySelector(n.container):document.getElementsByTagName("head")[0];if(o){var i=x.indexOf(r);-1===i&&(i=x.push(r)-1,y[i]={}),t=y[i]&&y[i][a]?y[i][a]:y[i][a]=s()}else t=s();65279===e.charCodeAt(0)&&(e=e.substring(1)),t.styleSheet?t.styleSheet.cssText+=e:t.appendChild(document.createTextNode(e))}function s(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),n.attributes)for(var t=Object.keys(n.attributes),o=0;o<t.length;o++)e.setAttribute(t[o],n.attributes[t[o]]);var i="prepend"===a?"afterbegin":"beforeend";return r.insertAdjacentElement(i,e),e}}w("\n.settings-container[data-v-ec88d0fd] {\n max-width: 800px;\n margin: 0 auto;\n padding: var(--content-padding);\n}\n\n/* Alert container */\n.alert-container[data-v-ec88d0fd] {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n z-index: 10;\n pointer-events: none;\n}\n.fixed-alert[data-v-ec88d0fd] {\n margin: 0 1rem;\n pointer-events: all;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n border-radius: var(--border-radius);\n}\n.settings-sections[data-v-ec88d0fd] {\n display: flex;\n flex-direction: column;\n gap: 2rem;\n margin-bottom: 2rem;\n}\n.settings-section[data-v-ec88d0fd] {\n background: var(--background-page);\n border: var(--border-width) solid var(--border-color);\n border-radius: var(--border-radius);\n padding: 1.5rem;\n}\n.section-title[data-v-ec88d0fd] {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n font-size: var(--font-size-large);\n font-weight: 600;\n color: var(--foreground-normal);\n margin: 0 0 1rem 0;\n}\n.section-grid[data-v-ec88d0fd] {\n display: grid;\n gap: 1rem;\n grid-template-columns: 1fr;\n}\n.section-grid[data-v-ec88d0fd] .v-input {\n margin-bottom: 0;\n}\n.settings-actions[data-v-ec88d0fd] {\n display: flex;\n gap: 1rem;\n justify-content: flex-start;\n margin-bottom: 2rem;\n padding: 1rem 0;\n border-top: var(--border-width) solid var(--border-color);\n border-bottom: var(--border-width) solid var(--border-color);\n}\n\n/* Transition for messages */\n.fade-enter-active[data-v-ec88d0fd],\n.fade-leave-active[data-v-ec88d0fd] {\n transition: opacity 0.4s ease, transform 0.4s ease;\n}\n.fade-enter-from[data-v-ec88d0fd] {\n opacity: 0;\n transform: translateY(-20px);\n}\n.fade-leave-to[data-v-ec88d0fd] {\n opacity: 0;\n transform: translateY(-20px);\n}\n\n/* Responsive design */\n@media (min-width: 600px) {\n.section-grid[data-v-ec88d0fd] {\n grid-template-columns: 1fr 1fr;\n}\n.settings-actions[data-v-ec88d0fd] {\n justify-content: flex-end;\n}\n}\n@media (min-width: 768px) {\n.settings-container[data-v-ec88d0fd] {\n padding: calc(var(--content-padding) * 2);\n}\n}\n\n/* Custom styling for better Directus integration */\n.settings-section[data-v-ec88d0fd]:hover {\n border-color: var(--border-color-alt);\n transition: border-color 0.2s ease;\n}\n[data-v-ec88d0fd] .v-input .input {\n transition: border-color 0.2s ease, box-shadow 0.2s ease;\n}\n[data-v-ec88d0fd] .v-input .input:focus {\n box-shadow: 0 0 0 2px var(--primary-25);\n}\n",{});var k=(e,n)=>{const t=e.__vccOpts||e;for(const[e,a]of n)t[e]=a;return t};const _={class:"settings-container"},T={class:"alert-container"},A={class:"settings-sections"},S={class:"settings-section"},C={class:"section-title"},I={class:"section-grid"},z={class:"settings-section"},j={class:"section-title"},R={class:"section-grid"},U={class:"settings-actions"};var D=k({setup(){const n=e(),{addTokenToURL:t}=h(n);return{api:n,addTokenToURL:t}},data:()=>({loading:!1,message:"",messageType:"success",settings:{directus_url:"",admin_token:"",ai_api_key:"",ai_model:"gpt-3.5-turbo",ai_base_url:"https://api.openai.com/v1"}}),methods:{async saveSettings(){this.loading=!0,this.message="";try{const e=await fetch(this.addTokenToURL("/mcp-server/settings"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(this.settings)}),n=await e.json();n.success?(this.message="Settings saved successfully!",this.messageType="success"):(this.message="Error: "+n.error,this.messageType="danger")}catch(e){this.message="Save error: "+e.message,this.messageType="danger"}finally{this.loading=!1,setTimeout(()=>{this.message=""},5e3)}},async loadSettings(e=!1){this.loading=!0;try{const n=await fetch(this.addTokenToURL("/mcp-server/settings")),t=await n.json();t.success&&t.data&&(this.settings={directus_url:t.data.directus_url||"http://localhost:8055",admin_token:t.data.admin_token||"",ai_api_key:t.data.ai_api_key||"",ai_model:t.data.ai_model||"gpt-3.5-turbo",ai_base_url:t.data.ai_base_url||"https://api.openai.com/v1"},e&&(this.message="Settings loaded successfully!",this.messageType="success"))}catch(e){console.error("Failed to load settings:",e),this.message="Error loading settings",this.messageType="danger"}finally{this.loading=!1,this.message&&setTimeout(()=>{this.message=""},3e3)}}},async mounted(){await this.loadSettings(!1)}},[["render",function(e,n,p,u,v,b){const f=t("v-notice"),h=t("v-icon"),x=t("v-input"),y=t("v-button");return a(),o("div",_,[r(" Status Messages - EN ÜSTTE SABİT "),i("div",T,[s(d,{name:"fade"},{default:l(()=>[v.message?(a(),c(f,{key:0,type:v.messageType,icon:"success"===v.messageType?"check_circle":"error",class:"fixed-alert"},{default:l(()=>[g(m(v.message),1)]),_:1},8,["type","icon"])):r("v-if",!0)]),_:1})]),i("div",A,[r(" Directus Configuration "),i("div",S,[i("h2",C,[s(h,{name:"dns"}),n[6]||(n[6]=g(" Directus Configuration "))]),i("div",I,[s(x,{modelValue:v.settings.directus_url,"onUpdate:modelValue":n[0]||(n[0]=e=>v.settings.directus_url=e),label:"Directus URL",placeholder:"http://localhost:8055",disabled:v.loading},null,8,["modelValue","disabled"]),s(x,{modelValue:v.settings.admin_token,"onUpdate:modelValue":n[1]||(n[1]=e=>v.settings.admin_token=e),label:"Admin Token",placeholder:"Enter your admin token",type:"password",disabled:v.loading},null,8,["modelValue","disabled"])])]),r(" AI Configuration "),i("div",z,[i("h2",j,[s(h,{name:"smart_toy"}),n[7]||(n[7]=g(" AI Configuration "))]),i("div",R,[s(x,{modelValue:v.settings.ai_api_key,"onUpdate:modelValue":n[2]||(n[2]=e=>v.settings.ai_api_key=e),label:"AI API Key",placeholder:"Enter your OpenAI API key",type:"password",disabled:v.loading},null,8,["modelValue","disabled"]),s(x,{modelValue:v.settings.ai_model,"onUpdate:modelValue":n[3]||(n[3]=e=>v.settings.ai_model=e),label:"AI Model",placeholder:"gpt-3.5-turbo, gpt-4, gpt-4-turbo, gpt-4o",disabled:v.loading},null,8,["modelValue","disabled"]),s(x,{modelValue:v.settings.ai_base_url,"onUpdate:modelValue":n[4]||(n[4]=e=>v.settings.ai_base_url=e),label:"AI Base URL",placeholder:"https://api.openai.com/v1",disabled:v.loading},null,8,["modelValue","disabled"])])])]),r(" Actions "),i("div",U,[s(y,{onClick:b.saveSettings,disabled:v.loading,loading:v.loading,kind:"primary",large:""},{default:l(()=>[g(m(v.loading?"Saving...":"Save Settings"),1)]),_:1},8,["onClick","disabled","loading"]),s(y,{onClick:n[5]||(n[5]=e=>b.loadSettings(!0)),disabled:v.loading,kind:"secondary",large:""},{default:l(()=>[s(h,{name:"refresh"}),n[8]||(n[8]=g(" Reload "))]),_:1,__:[8]},8,["disabled"])])])}],["__scopeId","data-v-ec88d0fd"],["__file","SettingsForm.vue"]]);w("\n.chat-container[data-v-ec9761bd] {\n display: flex;\n flex-direction: column;\n height: calc(100vh - 200px);\n max-height: 800px;\n border: var(--border-width) solid var(--border-color);\n border-radius: var(--border-radius);\n background-color: var(--background-page);\n overflow: hidden;\n}\n.chat-header[data-v-ec9761bd] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: var(--content-padding);\n border-bottom: var(--border-width) solid var(--border-color);\n background-color: var(--background-normal);\n}\n.chat-messages[data-v-ec9761bd] {\n flex: 1;\n overflow-y: auto;\n padding: var(--content-padding);\n display: flex;\n flex-direction: column;\n gap: 16px;\n}\n.empty-state[data-v-ec9761bd] {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n height: 100%;\n text-align: center;\n color: var(--foreground-subdued);\n gap: 12px;\n}\n.empty-title[data-v-ec9761bd] {\n font-size: 18px;\n font-weight: 600;\n color: var(--foreground-normal);\n}\n.empty-text[data-v-ec9761bd] {\n max-width: 400px;\n line-height: 1.5;\n}\n.message-wrapper[data-v-ec9761bd] {\n display: flex;\n max-width: 80%;\n}\n.message-wrapper.user[data-v-ec9761bd] {\n align-self: flex-end;\n justify-content: flex-end;\n}\n.message-wrapper.ai[data-v-ec9761bd] {\n align-self: flex-start;\n justify-content: flex-start;\n}\n.message-bubble[data-v-ec9761bd] {\n border-radius: 16px;\n padding: 14px 18px;\n position: relative;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);\n max-width: 100%;\n}\n\n/* 用户消息 - 蓝色背景 */\n.message-wrapper.user .message-bubble[data-v-ec9761bd] {\n background-color: #2563eb;\n color: #ffffff;\n border: 1px solid #1d4ed8;\n border-radius: 16px 16px 4px 16px;\n}\n\n/* AI 消息 - 浅灰背景,深色文字 */\n.message-wrapper.ai .message-bubble[data-v-ec9761bd] {\n background-color: #f3f4f6;\n color: #1f2937;\n border: 1px solid #e5e7eb;\n border-radius: 16px 16px 16px 4px;\n}\n.message-content[data-v-ec9761bd] {\n word-wrap: break-word;\n line-height: 1.5;\n}\n.message-wrapper.user .message-content[data-v-ec9761bd] code {\n background-color: rgba(255, 255, 255, 0.2);\n color: #ffffff;\n padding: 3px 8px;\n border-radius: 6px;\n font-family: var(--family-monospace);\n font-size: 0.9em;\n}\n.message-wrapper.ai .message-content[data-v-ec9761bd] code {\n background-color: #e5e7eb;\n color: #111827;\n padding: 3px 8px;\n border-radius: 6px;\n font-family: var(--family-monospace);\n font-size: 0.9em;\n}\n.message-content[data-v-ec9761bd] strong {\n font-weight: 600;\n}\n.message-time[data-v-ec9761bd] {\n font-size: 11px;\n opacity: 0.7;\n margin-top: 6px;\n text-align: right;\n}\n.message-wrapper.user .message-time[data-v-ec9761bd] {\n color: rgba(255, 255, 255, 0.8);\n}\n.message-wrapper.ai .message-time[data-v-ec9761bd] {\n color: #6b7280;\n}\n.typing-indicator[data-v-ec9761bd] {\n display: flex;\n gap: 4px;\n margin-bottom: 8px;\n}\n.typing-indicator span[data-v-ec9761bd] {\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background-color: #6b7280;\n animation: typing-ec9761bd 1.4s infinite ease-in-out;\n}\n.typing-indicator span[data-v-ec9761bd]:nth-child(1) {\n animation-delay: -0.32s;\n}\n.typing-indicator span[data-v-ec9761bd]:nth-child(2) {\n animation-delay: -0.16s;\n}\n@keyframes typing-ec9761bd {\n0%,\n 80%,\n 100% {\n transform: scale(0);\n opacity: 0.3;\n}\n40% {\n transform: scale(1);\n opacity: 0.8;\n}\n}\n.chat-input[data-v-ec9761bd] {\n display: flex;\n gap: 12px;\n padding: var(--content-padding);\n border-top: var(--border-width) solid var(--border-color);\n background-color: var(--background-normal);\n align-items: flex-end;\n}\n.chat-input[data-v-ec9761bd] .v-textarea {\n flex: 1;\n}\n\n/* Scrollbar styling */\n.chat-messages[data-v-ec9761bd]::-webkit-scrollbar {\n width: 6px;\n}\n.chat-messages[data-v-ec9761bd]::-webkit-scrollbar-track {\n background: var(--background-normal);\n}\n.chat-messages[data-v-ec9761bd]::-webkit-scrollbar-thumb {\n background: var(--border-color);\n border-radius: 3px;\n}\n.chat-messages[data-v-ec9761bd]::-webkit-scrollbar-thumb:hover {\n background: var(--foreground-subdued);\n}\n",{});const V={class:"chat-container"},E={class:"chat-messages",ref:"messagesContainer"},M={key:0,class:"empty-state"},P={class:"message-bubble"},$=["innerHTML"],L={class:"message-time"},H={key:1,class:"message-wrapper ai typing"},O={class:"chat-input"};var F=k({setup(){const n=e(),{addTokenToURL:t}=h(n);return{api:n,addTokenToURL:t}},data:()=>({messages:[],inputText:"",loading:!1}),computed:{inputTextTrimmed(){return this.inputText?this.inputText.trim():""}},methods:{async sendMessage(){if(!this.inputTextTrimmed||this.loading)return;const e={id:Date.now(),text:this.inputTextTrimmed,sender:"user",timestamp:new Date};this.messages.push(e);const n=this.inputTextTrimmed;this.inputText="",this.loading=!0;try{const e=await fetch(this.addTokenToURL("/mcp-server/prompt"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:n})}),t=await e.json(),a={id:Date.now()+1,text:t.success?t.response:`Error: ${t.error||"Unknown error"}`,sender:"ai",timestamp:new Date};this.messages.push(a)}catch(e){const n={id:Date.now()+1,text:`Connection error: ${e.message}`,sender:"ai",timestamp:new Date};this.messages.push(n)}finally{this.loading=!1,this.scrollToBottom()}},handleKeyDown(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),this.sendMessage())},clearChat(){this.messages=[]},formatMessage:e=>e?e.replace(/\*\*(.*?)\*\*/g,"<strong>$1</strong>").replace(/\*(.*?)\*/g,"<em>$1</em>").replace(/`(.*?)`/g,"<code>$1</code>").replace(/\n/g,"<br>"):"",formatTime:e=>e?new Intl.DateTimeFormat("en-US",{hour:"2-digit",minute:"2-digit"}).format(e):"",scrollToBottom(){this.$nextTick(()=>{const e=this.$refs.messagesContainer;e&&(e.scrollTop=e.scrollHeight)})}},updated(){this.scrollToBottom()}},[["render",function(e,n,d,c,g,b){const f=t("v-icon"),h=t("v-textarea"),x=t("v-button");return a(),o("div",V,[i("div",E,[0===g.messages.length?(a(),o("div",M,[s(f,{name:"smart_toy",large:""}),n[1]||(n[1]=i("div",{class:"empty-title"},"Welcome to AI Assistant",-1)),n[2]||(n[2]=i("div",{class:"empty-text"}," Ask questions about your Directus database. The AI Assistant will help you manage collections and data. ",-1))])):r("v-if",!0),(a(!0),o(p,null,u(g.messages,e=>(a(),o("div",{key:e.id,class:v(["message-wrapper",e.sender])},[i("div",P,[i("div",{class:"message-content",innerHTML:b.formatMessage(e.text)},null,8,$),i("div",L,m(b.formatTime(e.timestamp)),1)])],2))),128)),g.loading?(a(),o("div",H,n[3]||(n[3]=[i("div",{class:"message-bubble"},[i("div",{class:"typing-indicator"},[i("span"),i("span"),i("span")]),i("div",{class:"message-content"},"AI is thinking...")],-1)]))):r("v-if",!0)],512),i("div",O,[s(h,{modelValue:g.inputText,"onUpdate:modelValue":n[0]||(n[0]=e=>g.inputText=e),placeholder:"Type your message... (Enter to send, Shift+Enter for new line)",disabled:g.loading,onKeydown:b.handleKeyDown,rows:"1","auto-expand":""},null,8,["modelValue","disabled","onKeydown"]),s(x,{onClick:b.sendMessage,disabled:g.loading||!b.inputTextTrimmed,loading:g.loading,icon:""},{default:l(()=>[s(f,{name:"send"})]),_:1},8,["onClick","disabled","loading"])])])}],["__scopeId","data-v-ec9761bd"],["__file","ChatWindow.vue"]]);w('\n.home-container[data-v-90eb5e85] {\n max-width: 1200px;\n margin: 0 auto;\n padding: 2rem;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;\n}\n\n/* Hero Section */\n.hero-section[data-v-90eb5e85] {\n display: flex;\n align-items: center;\n justify-content: space-between;\n margin-bottom: 4rem;\n padding: 3rem 0;\n background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n border-radius: 20px;\n color: white;\n padding: 3rem;\n}\n.hero-content[data-v-90eb5e85] {\n flex: 1;\n}\n.hero-title[data-v-90eb5e85] {\n font-size: 3rem;\n font-weight: 700;\n margin-bottom: 1rem;\n line-height: 1.2;\n}\n.hero-subtitle[data-v-90eb5e85] {\n font-size: 1.25rem;\n margin-bottom: 2rem;\n opacity: 0.9;\n line-height: 1.6;\n}\n.hero-badge[data-v-90eb5e85] {\n margin-top: 1rem;\n}\n.badge[data-v-90eb5e85] {\n background: rgba(255, 255, 255, 0.2);\n padding: 0.5rem 1rem;\n border-radius: 25px;\n font-size: 0.9rem;\n font-weight: 500;\n}\n.hero-visual[data-v-90eb5e85] {\n flex: 0 0 auto;\n margin-left: 2rem;\n}\n.ai-icon[data-v-90eb5e85] {\n font-size: 6rem;\n animation: float-90eb5e85 3s ease-in-out infinite;\n}\n@keyframes float-90eb5e85 {\n0%,\n 100% {\n transform: translateY(0px);\n}\n50% {\n transform: translateY(-20px);\n}\n}\n\n/* Features Section */\n.features-section[data-v-90eb5e85] {\n margin-bottom: 4rem;\n}\n.section-title[data-v-90eb5e85] {\n font-size: 2.5rem;\n font-weight: 600;\n text-align: center;\n margin-bottom: 3rem;\n color: var(--foreground-normal);\n}\n.features-grid[data-v-90eb5e85] {\n display: grid;\n grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));\n gap: 2rem;\n}\n.feature-card[data-v-90eb5e85] {\n background: var(--background-page);\n padding: 2rem;\n border-radius: 12px;\n text-align: center;\n border: 1px solid var(--border-color);\n transition: transform 0.3s ease, box-shadow 0.3s ease;\n}\n.feature-card[data-v-90eb5e85]:hover {\n transform: translateY(-5px);\n box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);\n}\n.feature-icon[data-v-90eb5e85] {\n font-size: 3rem;\n margin-bottom: 1rem;\n}\n.feature-card h3[data-v-90eb5e85] {\n font-size: 1.25rem;\n font-weight: 600;\n margin-bottom: 1rem;\n color: var(--foreground-normal);\n}\n.feature-card p[data-v-90eb5e85] {\n color: var(--foreground-subdued);\n line-height: 1.6;\n}\n\n/* Advanced Solutions Section */\n.advanced-section[data-v-90eb5e85] {\n margin-bottom: 4rem;\n background: var(--background-page);\n padding: 3rem;\n border-radius: 16px;\n border: 1px solid var(--border-color);\n}\n.advanced-content[data-v-90eb5e85] {\n display: grid;\n grid-template-columns: 2fr 1fr;\n gap: 3rem;\n align-items: start;\n}\n.advanced-text h3[data-v-90eb5e85] {\n font-size: 1.5rem;\n font-weight: 600;\n margin-bottom: 1rem;\n color: var(--foreground-normal);\n}\n.advanced-text p[data-v-90eb5e85] {\n color: var(--foreground-subdued);\n line-height: 1.6;\n margin-bottom: 1.5rem;\n}\n.advanced-list[data-v-90eb5e85] {\n list-style: none;\n padding: 0;\n}\n.advanced-list li[data-v-90eb5e85] {\n padding: 0.75rem 0;\n border-bottom: 1px solid var(--border-color);\n color: var(--foreground-subdued);\n line-height: 1.5;\n}\n.advanced-list li[data-v-90eb5e85]:last-child {\n border-bottom: none;\n}\n.contact-card[data-v-90eb5e85] {\n background: linear-gradient(135deg, #6c5ce7 0%, #74b9ff 100%);\n padding: 2rem;\n border-radius: 12px;\n color: white;\n text-align: center;\n}\n.contact-card h4[data-v-90eb5e85] {\n font-size: 1.25rem;\n font-weight: 600;\n margin-bottom: 0.5rem;\n}\n.contact-card p[data-v-90eb5e85] {\n margin-bottom: 1.5rem;\n opacity: 0.9;\n}\n.contact-info[data-v-90eb5e85] {\n display: flex;\n flex-direction: column;\n gap: 0.75rem;\n}\n.contact-item[data-v-90eb5e85] {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 0.5rem;\n font-size: 0.9rem;\n}\n.contact-icon[data-v-90eb5e85] {\n font-size: 1.1rem;\n}\n\n/* Getting Started Section */\n.getting-started[data-v-90eb5e85] {\n margin-bottom: 4rem;\n}\n.steps-grid[data-v-90eb5e85] {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 1rem;\n flex-wrap: wrap;\n}\n.step-card[data-v-90eb5e85] {\n background: var(--background-page);\n padding: 2rem;\n border-radius: 12px;\n text-align: center;\n border: 1px solid var(--border-color);\n min-width: 200px;\n flex: 1;\n max-width: 300px;\n}\n.step-number[data-v-90eb5e85] {\n width: 40px;\n height: 40px;\n background: var(--primary);\n color: white;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n font-weight: 600;\n font-size: 1.25rem;\n margin: 0 auto 1rem;\n}\n.step-card h4[data-v-90eb5e85] {\n font-size: 1.1rem;\n font-weight: 600;\n margin-bottom: 0.5rem;\n color: var(--foreground-normal);\n}\n.step-card p[data-v-90eb5e85] {\n color: var(--foreground-subdued);\n font-size: 0.9rem;\n line-height: 1.5;\n}\n.step-arrow[data-v-90eb5e85] {\n font-size: 2rem;\n color: var(--foreground-subdued);\n font-weight: bold;\n}\n\n/* Footer */\n.footer[data-v-90eb5e85] {\n border-top: 1px solid var(--border-color);\n padding-top: 2rem;\n margin-top: 2rem;\n}\n.footer-content[data-v-90eb5e85] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n flex-wrap: wrap;\n gap: 1rem;\n}\n.footer-brand[data-v-90eb5e85] {\n display: flex;\n flex-direction: column;\n gap: 0.25rem;\n}\n.footer-brand strong[data-v-90eb5e85] {\n color: var(--foreground-normal);\n font-size: 1.1rem;\n}\n.footer-brand span[data-v-90eb5e85] {\n color: var(--foreground-subdued);\n font-size: 0.9rem;\n}\n.footer-disclaimer[data-v-90eb5e85] {\n max-width: 400px;\n text-align: right;\n}\n.footer-disclaimer small[data-v-90eb5e85] {\n color: var(--foreground-subdued);\n font-size: 0.8rem;\n line-height: 1.4;\n}\n\n/* Responsive Design */\n@media (max-width: 768px) {\n.hero-section[data-v-90eb5e85] {\n flex-direction: column;\n text-align: center;\n}\n.hero-visual[data-v-90eb5e85] {\n margin-left: 0;\n margin-top: 2rem;\n}\n.hero-title[data-v-90eb5e85] {\n font-size: 2rem;\n}\n.advanced-content[data-v-90eb5e85] {\n grid-template-columns: 1fr;\n}\n.steps-grid[data-v-90eb5e85] {\n flex-direction: column;\n}\n.step-arrow[data-v-90eb5e85] {\n transform: rotate(90deg);\n}\n.footer-content[data-v-90eb5e85] {\n flex-direction: column;\n text-align: center;\n}\n.footer-disclaimer[data-v-90eb5e85] {\n text-align: center;\n}\n}\n',{});const B={class:"home-container"};var K=k({name:"Home"},[["render",function(e,n,t,s,d,l){return a(),o("div",B,[r(" Hero Section "),n[0]||(n[0]=b('<div class="hero-section" data-v-90eb5e85><div class="hero-content" data-v-90eb5e85><h1 class="hero-title" data-v-90eb5e85>AI Agent for Directus</h1><p class="hero-subtitle" data-v-90eb5e85> Transform your Directus CMS with intelligent automation and natural language processing </p><div class="hero-badge" data-v-90eb5e85><span class="badge" data-v-90eb5e85>Powered by Uncw3b Software</span></div></div><div class="hero-visual" data-v-90eb5e85><div class="ai-icon" data-v-90eb5e85>🤖</div></div></div>',1)),r(" Features Section "),n[1]||(n[1]=b('<div class="features-section" data-v-90eb5e85><h2 class="section-title" data-v-90eb5e85>Key Features</h2><div class="features-grid" data-v-90eb5e85><div class="feature-card" data-v-90eb5e85><div class="feature-icon" data-v-90eb5e85>💬</div><h3 data-v-90eb5e85>Natural Language Commands</h3><p data-v-90eb5e85> Interact with your Directus CMS using plain English. Create, update, and query data effortlessly. </p></div><div class="feature-card" data-v-90eb5e85><div class="feature-icon" data-v-90eb5e85>🔄</div><h3 data-v-90eb5e85>Smart Automation</h3><p data-v-90eb5e85> Automate complex workflows and data operations with intelligent AI-powered decision making. </p></div><div class="feature-card" data-v-90eb5e85><div class="feature-icon" data-v-90eb5e85>⚡</div><h3 data-v-90eb5e85>Real-time Processing</h3><p data-v-90eb5e85> Get instant responses and execute operations in real-time with advanced MCP integration. </p></div><div class="feature-card" data-v-90eb5e85><div class="feature-icon" data-v-90eb5e85>🎯</div><h3 data-v-90eb5e85>Context-Aware</h3><p data-v-90eb5e85> AI understands your data structure and relationships for more accurate operations. </p></div></div></div>',1)),r(" Getting Started Section "),n[2]||(n[2]=b('<div class="getting-started" data-v-90eb5e85><h2 class="section-title" data-v-90eb5e85>Getting Started</h2><div class="steps-grid" data-v-90eb5e85><div class="step-card" data-v-90eb5e85><div class="step-number" data-v-90eb5e85>1</div><h4 data-v-90eb5e85>Configure Settings</h4><p data-v-90eb5e85> Set up your AI API key and Directus connection in the Settings tab </p></div><div class="step-arrow" data-v-90eb5e85>→</div><div class="step-card" data-v-90eb5e85><div class="step-number" data-v-90eb5e85>2</div><h4 data-v-90eb5e85>Start Chatting</h4><p data-v-90eb5e85> Use natural language to interact with your data and automate tasks </p></div><div class="step-arrow" data-v-90eb5e85>→</div><div class="step-card" data-v-90eb5e85><div class="step-number" data-v-90eb5e85>3</div><h4 data-v-90eb5e85>Explore &amp; Automate</h4><p data-v-90eb5e85> Discover powerful automation possibilities and streamline your workflow </p></div></div></div>',1)),r(" About Section "),n[3]||(n[3]=i("div",{class:"footer"},[i("div",{class:"footer-content"},[i("div",{class:"footer-brand"},[i("strong",null,"Uncw3b Software"),i("span",null,"AI-powered tools for modern Directus projects")]),i("div",{class:"footer-disclaimer"},[i("small",null," This extension is created and maintained by Uncw3b. Visit our website for open-source contributions, support, and updates. ")])])],-1))])}],["__scopeId","data-v-90eb5e85"],["__file","Home.vue"]]);w("\n.module-content[data-v-7ced0a23] {\n padding: 0;\n}\n.default-content[data-v-7ced0a23] {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n height: 200px;\n text-align: center;\n color: var(--foreground-subdued);\n}\n.default-content .type-title[data-v-7ced0a23] {\n margin-bottom: 12px;\n color: var(--foreground-normal);\n}\n",{});const N={class:"module-content"},Y={key:1,class:"default-content"};var G=k({props:{page:{type:String,default:"home"}},computed:{pageTitle(){switch(this.getCurrentRoute()){case"home":return"AI Agent - Home";case"agent-settings":return"AI Agent - Settings";case"chat":return"AI Agent - Chat";default:return"AI Agent"}},currentPageComponent(){const e=this.getCurrentRoute();switch(console.log("Current route determined as:",e),e){case"agent-settings":return D;case"chat":return F;default:return K}}},methods:{getCurrentRoute(){const e=this.$route.path;return console.log("Current path:",e),console.log("Page prop:",this.page),e.includes("/agent-settings")?"agent-settings":e.includes("/chat")?"chat":"/ai-agent/"===e||"/ai-agent"===e||"home"===this.page||""===this.page?"home":this.page||"home"},isActiveRoute(e){return this.getCurrentRoute()===e}}},[["render",function(e,n,d,g,m,p){const u=t("v-icon"),v=t("v-list-item-icon"),b=t("v-text-overflow"),h=t("v-list-item-content"),x=t("v-list-item"),y=t("v-list"),w=t("private-view");return a(),c(w,{title:p.pageTitle},{navigation:l(()=>[r(" Yan Menü "),s(y,{nav:""},{default:l(()=>[s(x,{to:"/ai-agent/",active:p.isActiveRoute("home")},{default:l(()=>[s(v,null,{default:l(()=>[s(u,{name:"home"})]),_:1}),s(h,null,{default:l(()=>[s(b,{text:"Home"})]),_:1})]),_:1},8,["active"]),s(x,{to:"/ai-agent/agent-settings",active:p.isActiveRoute("agent-settings")},{default:l(()=>[s(v,null,{default:l(()=>[s(u,{name:"settings"})]),_:1}),s(h,null,{default:l(()=>[s(b,{text:"Settings"})]),_:1})]),_:1},8,["active"]),s(x,{to:"/ai-agent/chat",active:p.isActiveRoute("chat")},{default:l(()=>[s(v,null,{default:l(()=>[s(u,{name:"chat"})]),_:1}),s(h,null,{default:l(()=>[s(b,{text:"Chat"})]),_:1})]),_:1},8,["active"])]),_:1})]),default:l(()=>[i("div",N,[p.currentPageComponent?(a(),c(f(p.currentPageComponent),{key:0})):(a(),o("div",Y,n[0]||(n[0]=[i("div",{class:"type-title"},"AI Agent",-1),i("p",null,"Please select a page from the side menu.",-1)])))])]),_:1},8,["title"])}],["__scopeId","data-v-7ced0a23"],["__file","module.vue"]]);const q=[],J=[],W=[],Q=[n({id:"ai-agent",name:"AI Agent",icon:"smart_toy",routes:[{path:"",component:G},{path:"agent-settings",component:G},{path:"chat",component:G}]})],X=[],Z=[],ee=[];export{J as displays,q as interfaces,W as layouts,Q as modules,ee as operations,X as panels,Z as themes};
package/package.json ADDED
@@ -0,0 +1,79 @@
1
+ {
2
+ "name": "directus-extension-synque-ai",
3
+ "description": "Directus 11 AI Agent Extension - Transform your Directus CMS with intelligent automation and natural language processing.",
4
+ "icon": "extension",
5
+ "version": "1.0.0",
6
+ "license": "MIT",
7
+ "keywords": [
8
+ "directus",
9
+ "directus-extension",
10
+ "directus-extension-bundle",
11
+ "directus-11",
12
+ "openai",
13
+ "ai-agent",
14
+ "gpt",
15
+ "synque"
16
+ ],
17
+ "type": "module",
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "author": "Synque",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/synque/directus-extension-synque-ai"
25
+ },
26
+ "directus:extension": {
27
+ "type": "bundle",
28
+ "path": {
29
+ "app": "dist/app.js",
30
+ "api": "dist/api.js"
31
+ },
32
+ "entries": [
33
+ {
34
+ "type": "endpoint",
35
+ "name": "mcp-server",
36
+ "source": "src/mcp-server/index.js"
37
+ },
38
+ {
39
+ "type": "module",
40
+ "name": "agent-frontend",
41
+ "source": "src/agent-frontend/index.js"
42
+ }
43
+ ],
44
+ "host": "^10.0.0 || ^11.0.0",
45
+ "sandbox": {
46
+ "enabled": true,
47
+ "requestedScopes": {
48
+ "log": {},
49
+ "sleep": {},
50
+ "request": {
51
+ "methods": [
52
+ "GET",
53
+ "POST"
54
+ ],
55
+ "urls": [
56
+ "https://api.openai.com/*",
57
+ "https://*.openrouter.ai/*",
58
+ "https://codex.ekt.me/*"
59
+ ]
60
+ }
61
+ }
62
+ }
63
+ },
64
+ "scripts": {
65
+ "build": "directus-extension build",
66
+ "dev": "directus-extension build -w --no-minify",
67
+ "link": "directus-extension link",
68
+ "validate": "directus-extension validate",
69
+ "add": "directus-extension add"
70
+ },
71
+ "devDependencies": {
72
+ "@directus/extensions-sdk": "13.1.1",
73
+ "vue": "^3.5.17"
74
+ },
75
+ "dependencies": {
76
+ "node-fetch": "^3.3.2",
77
+ "openai": "^5.6.0"
78
+ }
79
+ }