@marvalt/wadapter 1.1.10

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.
Files changed (45) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +190 -0
  3. package/dist/client/wordpress-client.d.ts +43 -0
  4. package/dist/client/wordpress-client.d.ts.map +1 -0
  5. package/dist/generators/form-protection/form-protection-generator.d.ts +46 -0
  6. package/dist/generators/form-protection/form-protection-generator.d.ts.map +1 -0
  7. package/dist/generators/gravity-forms/gravity-forms-generator.d.ts +36 -0
  8. package/dist/generators/gravity-forms/gravity-forms-generator.d.ts.map +1 -0
  9. package/dist/generators/wordpress/wordpress-generator.d.ts +53 -0
  10. package/dist/generators/wordpress/wordpress-generator.d.ts.map +1 -0
  11. package/dist/gravity-forms/gravity-forms-client.d.ts +33 -0
  12. package/dist/gravity-forms/gravity-forms-client.d.ts.map +1 -0
  13. package/dist/index.d.ts +1015 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.esm.js +2479 -0
  16. package/dist/index.esm.js.map +1 -0
  17. package/dist/index.js +2524 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/react/components/GravityForm.d.ts +28 -0
  20. package/dist/react/components/GravityForm.d.ts.map +1 -0
  21. package/dist/react/components/WordPressContent.d.ts +28 -0
  22. package/dist/react/components/WordPressContent.d.ts.map +1 -0
  23. package/dist/react/hooks/useGravityForms.d.ts +34 -0
  24. package/dist/react/hooks/useGravityForms.d.ts.map +1 -0
  25. package/dist/react/hooks/useWordPress.d.ts +32 -0
  26. package/dist/react/hooks/useWordPress.d.ts.map +1 -0
  27. package/dist/react/providers/GravityFormsProvider.d.ts +29 -0
  28. package/dist/react/providers/GravityFormsProvider.d.ts.map +1 -0
  29. package/dist/react/providers/WordPressProvider.d.ts +29 -0
  30. package/dist/react/providers/WordPressProvider.d.ts.map +1 -0
  31. package/dist/setupTests.d.ts +18 -0
  32. package/dist/setupTests.d.ts.map +1 -0
  33. package/dist/transformers/wordpress-transformers.d.ts +69 -0
  34. package/dist/transformers/wordpress-transformers.d.ts.map +1 -0
  35. package/dist/types/form-protection.d.ts +47 -0
  36. package/dist/types/form-protection.d.ts.map +1 -0
  37. package/dist/types/gravity-forms.d.ts +110 -0
  38. package/dist/types/gravity-forms.d.ts.map +1 -0
  39. package/dist/types/wordpress.d.ts +350 -0
  40. package/dist/types/wordpress.d.ts.map +1 -0
  41. package/dist/utils/config.d.ts +26 -0
  42. package/dist/utils/config.d.ts.map +1 -0
  43. package/dist/utils/validation.d.ts +28 -0
  44. package/dist/utils/validation.d.ts.map +1 -0
  45. package/package.json +84 -0
package/dist/index.js ADDED
@@ -0,0 +1,2524 @@
1
+ 'use strict';
2
+
3
+ var require$$0 = require('react');
4
+ var fs = require('fs');
5
+ var path = require('path');
6
+
7
+ /**
8
+ * @license GPL-3.0-or-later
9
+ *
10
+ * This file is part of the MarVAlt Open SDK.
11
+ * Copyright (c) 2025 Vibune Pty Ltd.
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21
+ * See the GNU General Public License for more details.
22
+ */
23
+ class WordPressClient {
24
+ constructor(config) {
25
+ this.config = config;
26
+ }
27
+ async makeRequest(endpoint, params = {}, options = {}) {
28
+ const baseUrl = this.getBaseUrl();
29
+ const queryString = new URLSearchParams();
30
+ Object.entries(params).forEach(([key, value]) => {
31
+ if (value !== undefined && value !== null) {
32
+ if (Array.isArray(value)) {
33
+ value.forEach(v => queryString.append(key, v.toString()));
34
+ }
35
+ else {
36
+ queryString.append(key, value.toString());
37
+ }
38
+ }
39
+ });
40
+ // Construct URL based on auth mode
41
+ let url;
42
+ if (this.config.authMode === 'cloudflare_proxy' || this.config.authMode === 'supabase_proxy') {
43
+ // For proxy modes, pass the endpoint as query parameter (worker expects /wp/v2/ format)
44
+ const fullEndpoint = `${endpoint}?${queryString.toString()}`;
45
+ url = `${baseUrl}?endpoint=${encodeURIComponent(fullEndpoint)}`;
46
+ }
47
+ else {
48
+ // For direct mode, construct the full WordPress API URL
49
+ url = `${baseUrl}/wp-json${endpoint}?${queryString.toString()}`;
50
+ }
51
+ const headers = {
52
+ 'Content-Type': 'application/json',
53
+ };
54
+ // Add authentication based on mode
55
+ if (this.config.authMode === 'cloudflare_proxy') {
56
+ // Add Cloudflare proxy authentication headers
57
+ if (this.config.appId) {
58
+ headers['x-app-id'] = this.config.appId;
59
+ }
60
+ if (this.config.workerSecret) {
61
+ headers['x-app-secret'] = this.config.workerSecret;
62
+ }
63
+ if (this.config.cfAccessClientId && this.config.cfAccessClientSecret) {
64
+ headers['CF-Access-Client-Id'] = this.config.cfAccessClientId;
65
+ headers['CF-Access-Client-Secret'] = this.config.cfAccessClientSecret;
66
+ }
67
+ }
68
+ else if (this.config.authMode === 'supabase_proxy') {
69
+ // Add Supabase proxy authentication headers
70
+ if (this.config.supabaseAnonKey) {
71
+ headers['apikey'] = this.config.supabaseAnonKey;
72
+ }
73
+ }
74
+ else {
75
+ // Direct mode - use basic auth
76
+ if (this.config.username && this.config.password) {
77
+ const credentials = btoa(`${this.config.username}:${this.config.password}`);
78
+ headers.Authorization = `Basic ${credentials}`;
79
+ }
80
+ }
81
+ console.log('🔍 WordPress API Request Debug:', {
82
+ url,
83
+ method: options.method || 'GET',
84
+ authMode: this.config.authMode,
85
+ headers: Object.keys(headers),
86
+ });
87
+ const response = await fetch(url, {
88
+ method: options.method || 'GET',
89
+ headers,
90
+ body: options.body,
91
+ signal: AbortSignal.timeout(this.config.timeout || 30000),
92
+ ...options,
93
+ });
94
+ if (!response.ok) {
95
+ console.error('❌ WordPress API Error:', {
96
+ status: response.status,
97
+ statusText: response.statusText,
98
+ url,
99
+ headers: Object.fromEntries(response.headers.entries()),
100
+ });
101
+ throw new Error(`WordPress API request failed: ${response.status} ${response.statusText}`);
102
+ }
103
+ const responseText = await response.text();
104
+ console.log('🔍 WordPress API Response:', {
105
+ status: response.status,
106
+ responseLength: responseText.length,
107
+ responsePreview: responseText.substring(0, 200),
108
+ });
109
+ if (!responseText) {
110
+ // Return empty array for empty responses (common for endpoints with no data)
111
+ return [];
112
+ }
113
+ try {
114
+ return JSON.parse(responseText);
115
+ }
116
+ catch (error) {
117
+ const message = error instanceof Error ? error.message : String(error);
118
+ console.error('❌ JSON Parse Error:', {
119
+ error: message,
120
+ responseText: responseText.substring(0, 500),
121
+ });
122
+ throw new Error(`Failed to parse JSON response: ${message}`);
123
+ }
124
+ }
125
+ getBaseUrl() {
126
+ switch (this.config.authMode) {
127
+ case 'cloudflare_proxy':
128
+ return this.config.cloudflareWorkerUrl || '';
129
+ case 'supabase_proxy':
130
+ return `${this.config.supabaseUrl}/functions/v1/wp-proxy`;
131
+ default:
132
+ return this.config.apiUrl || '';
133
+ }
134
+ }
135
+ async getPosts(params = {}) {
136
+ return this.makeRequest('/wp/v2/posts', params);
137
+ }
138
+ async getPost(id) {
139
+ return this.makeRequest(`/wp/v2/posts/${id}`);
140
+ }
141
+ async getPages(params = {}) {
142
+ return this.makeRequest('/wp/v2/pages', params);
143
+ }
144
+ async getPage(id) {
145
+ return this.makeRequest(`/wp/v2/pages/${id}`);
146
+ }
147
+ async getMedia(params = {}) {
148
+ return this.makeRequest('/wp/v2/media', params);
149
+ }
150
+ async getMediaItem(id) {
151
+ return this.makeRequest(`/wp/v2/media/${id}`);
152
+ }
153
+ async getCategories(params = {}) {
154
+ return this.makeRequest('/wp/v2/categories', params);
155
+ }
156
+ async getTags(params = {}) {
157
+ return this.makeRequest('/wp/v2/tags', params);
158
+ }
159
+ // Gravity Forms endpoints
160
+ async getGravityForms() {
161
+ return this.makeRequest('/gf-api/v1/forms');
162
+ }
163
+ async getGravityForm(formId) {
164
+ return this.makeRequest(`/gf-api/v1/forms/${formId}/config`);
165
+ }
166
+ async submitGravityForm(formId, entry) {
167
+ return this.makeRequest(`/gf-api/v1/forms/${formId}/submit`, {}, {
168
+ method: 'POST',
169
+ body: JSON.stringify(entry),
170
+ });
171
+ }
172
+ // Static data endpoints
173
+ async getStaticDataNonce() {
174
+ return this.makeRequest('/static-data/v1/nonce');
175
+ }
176
+ async getAllData(params = {}) {
177
+ const [posts, pages, media, categories, tags] = await Promise.all([
178
+ this.getPosts(params),
179
+ this.getPages(params),
180
+ this.getMedia(params),
181
+ this.getCategories(params),
182
+ this.getTags(params),
183
+ ]);
184
+ return { posts, pages, media, categories, tags };
185
+ }
186
+ }
187
+
188
+ /**
189
+ * @license GPL-3.0-or-later
190
+ *
191
+ * This file is part of the MarVAlt Open SDK.
192
+ * Copyright (c) 2025 Vibune Pty Ltd.
193
+ *
194
+ * This program is free software: you can redistribute it and/or modify
195
+ * it under the terms of the GNU General Public License as published by
196
+ * the Free Software Foundation, either version 3 of the License, or
197
+ * (at your option) any later version.
198
+ *
199
+ * This program is distributed in the hope that it will be useful,
200
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
201
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
202
+ * See the GNU General Public License for more details.
203
+ */
204
+ function transformWordPressPost(post) {
205
+ return {
206
+ id: post.id,
207
+ title: post.title.rendered,
208
+ content: post.content.rendered,
209
+ excerpt: post.excerpt.rendered,
210
+ slug: post.slug,
211
+ date: post.date,
212
+ modified: post.modified,
213
+ author: post.author,
214
+ featuredMedia: post.featured_media || null,
215
+ categories: post.categories || [],
216
+ tags: post.tags || [],
217
+ link: post.link,
218
+ };
219
+ }
220
+ function transformWordPressPage(page) {
221
+ return {
222
+ id: page.id,
223
+ title: page.title.rendered,
224
+ content: page.content.rendered,
225
+ excerpt: page.excerpt.rendered,
226
+ slug: page.slug,
227
+ date: page.date,
228
+ modified: page.modified,
229
+ author: page.author,
230
+ featuredMedia: page.featured_media || null,
231
+ parent: page.parent,
232
+ menuOrder: page.menu_order,
233
+ link: page.link,
234
+ };
235
+ }
236
+ function transformWordPressMedia(media) {
237
+ const transformedSizes = {};
238
+ if (media.media_details?.sizes) {
239
+ Object.entries(media.media_details.sizes).forEach(([key, size]) => {
240
+ transformedSizes[key] = {
241
+ file: size.file,
242
+ width: size.width,
243
+ height: size.height,
244
+ mimeType: size.mime_type,
245
+ sourceUrl: size.source_url,
246
+ };
247
+ });
248
+ }
249
+ return {
250
+ id: media.id,
251
+ title: media.title.rendered,
252
+ description: media.description.rendered,
253
+ caption: media.caption.rendered,
254
+ altText: media.alt_text,
255
+ sourceUrl: media.source_url,
256
+ mimeType: media.mime_type,
257
+ mediaType: media.media_type,
258
+ sizes: transformedSizes,
259
+ };
260
+ }
261
+ function transformWordPressPosts(posts) {
262
+ return posts.map(transformWordPressPost);
263
+ }
264
+ function transformWordPressPages(pages) {
265
+ return pages.map(transformWordPressPage);
266
+ }
267
+ function transformWordPressMediaItems(media) {
268
+ return media.map(transformWordPressMedia);
269
+ }
270
+
271
+ /**
272
+ * @license GPL-3.0-or-later
273
+ *
274
+ * This file is part of the MarVAlt Open SDK.
275
+ * Copyright (c) 2025 Vibune Pty Ltd.
276
+ *
277
+ * This program is free software: you can redistribute it and/or modify
278
+ * it under the terms of the GNU General Public License as published by
279
+ * the Free Software Foundation, either version 3 of the License, or
280
+ * (at your option) any later version.
281
+ *
282
+ * This program is distributed in the hope that it will be useful,
283
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
284
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
285
+ * See the GNU General Public License for more details.
286
+ */
287
+ class GravityFormsClient {
288
+ constructor(config) {
289
+ this.config = config;
290
+ }
291
+ async makeRequest(endpoint, options = {}) {
292
+ // Construct URL based on auth mode
293
+ let url;
294
+ if (this.config.authMode === 'cloudflare_proxy' || this.config.authMode === 'supabase_proxy') {
295
+ // For proxy modes, pass the endpoint as query parameter
296
+ const baseUrl = this.getBaseUrl();
297
+ url = `${baseUrl}?endpoint=${encodeURIComponent(endpoint)}`;
298
+ }
299
+ else {
300
+ // For direct mode, construct the full API URL
301
+ url = `${this.config.apiUrl}${endpoint}`;
302
+ }
303
+ const headers = {
304
+ 'Content-Type': 'application/json',
305
+ ...options.headers,
306
+ };
307
+ // Add authentication based on mode
308
+ if (this.config.authMode === 'cloudflare_proxy') {
309
+ // Add Cloudflare proxy authentication headers
310
+ if (this.config.appId) {
311
+ headers['x-app-id'] = this.config.appId;
312
+ }
313
+ if (this.config.workerSecret) {
314
+ headers['x-app-secret'] = this.config.workerSecret;
315
+ headers['x-worker-secret'] = this.config.workerSecret; // legacy/alt header supported by Worker
316
+ }
317
+ if (this.config.cfAccessClientId && this.config.cfAccessClientSecret) {
318
+ headers['CF-Access-Client-Id'] = this.config.cfAccessClientId;
319
+ headers['CF-Access-Client-Secret'] = this.config.cfAccessClientSecret;
320
+ }
321
+ }
322
+ else if (this.config.authMode === 'supabase_proxy') {
323
+ // Add Supabase proxy authentication headers
324
+ if (this.config.supabaseAnonKey) {
325
+ headers['apikey'] = this.config.supabaseAnonKey;
326
+ }
327
+ }
328
+ else {
329
+ // Direct mode - use basic auth
330
+ if (this.config.username && this.config.password) {
331
+ const credentials = btoa(`${this.config.username}:${this.config.password}`);
332
+ headers.Authorization = `Basic ${credentials}`;
333
+ }
334
+ }
335
+ const response = await fetch(url, {
336
+ ...options,
337
+ headers,
338
+ signal: AbortSignal.timeout(this.config.timeout || 30000),
339
+ });
340
+ if (!response.ok) {
341
+ throw new Error(`Gravity Forms API request failed: ${response.status} ${response.statusText}`);
342
+ }
343
+ const responseText = await response.text();
344
+ if (!responseText) {
345
+ return [];
346
+ }
347
+ try {
348
+ return JSON.parse(responseText);
349
+ }
350
+ catch (error) {
351
+ console.error('❌ Gravity Forms JSON Parse Error:', {
352
+ error: error.message,
353
+ responseText: responseText.substring(0, 500),
354
+ });
355
+ throw new Error(`Failed to parse JSON response: ${error.message}`);
356
+ }
357
+ }
358
+ getBaseUrl() {
359
+ switch (this.config.authMode) {
360
+ case 'cloudflare_proxy':
361
+ return this.config.cloudflareWorkerUrl || '';
362
+ case 'supabase_proxy':
363
+ return `${this.config.supabaseUrl}/functions/v1/wp-proxy`;
364
+ default:
365
+ return this.config.apiUrl || '';
366
+ }
367
+ }
368
+ async getForm(id) {
369
+ return this.makeRequest(`/gf-api/v1/forms/${id}`);
370
+ }
371
+ async getForms() {
372
+ return this.makeRequest('/gf-api/v1/forms');
373
+ }
374
+ async getFormConfig(id) {
375
+ return this.makeRequest(`/gf-api/v1/forms/${id}/config`);
376
+ }
377
+ async submitForm(formId, submission) {
378
+ return this.makeRequest(`/gf-api/v1/forms/${formId}/submit`, {
379
+ method: 'POST',
380
+ body: JSON.stringify(submission),
381
+ });
382
+ }
383
+ async getHealth() {
384
+ return this.makeRequest('/gf-api/v1/health');
385
+ }
386
+ }
387
+
388
+ /**
389
+ * @license GPL-3.0-or-later
390
+ *
391
+ * This file is part of the MarVAlt Open SDK.
392
+ * Copyright (c) 2025 Vibune Pty Ltd.
393
+ *
394
+ * This program is free software: you can redistribute it and/or modify
395
+ * it under the terms of the GNU General Public License as published by
396
+ * the Free Software Foundation, either version 3 of the License, or
397
+ * (at your option) any later version.
398
+ *
399
+ * This program is distributed in the hope that it will be useful,
400
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
401
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
402
+ * See the GNU General Public License for more details.
403
+ */
404
+ // React Hook for WordPress Data
405
+ function useWordPress(endpoint, id, config) {
406
+ const [data, setData] = require$$0.useState(null);
407
+ const [loading, setLoading] = require$$0.useState(true);
408
+ const [error, setError] = require$$0.useState(null);
409
+ const fetchData = async () => {
410
+ if (!config) {
411
+ setError(new Error('WordPress configuration is required'));
412
+ setLoading(false);
413
+ return;
414
+ }
415
+ try {
416
+ setLoading(true);
417
+ setError(null);
418
+ const client = new WordPressClient(config);
419
+ let result;
420
+ switch (endpoint) {
421
+ case 'posts':
422
+ result = id
423
+ ? await client.getPost(id)
424
+ : await client.getPosts();
425
+ break;
426
+ case 'pages':
427
+ result = id
428
+ ? await client.getPage(id)
429
+ : await client.getPages();
430
+ break;
431
+ case 'media':
432
+ result = id
433
+ ? await client.getMediaItem(id)
434
+ : await client.getMedia();
435
+ break;
436
+ case 'categories':
437
+ result = await client.getCategories();
438
+ break;
439
+ case 'tags':
440
+ result = await client.getTags();
441
+ break;
442
+ default:
443
+ throw new Error(`Unknown endpoint: ${endpoint}`);
444
+ }
445
+ setData(result);
446
+ }
447
+ catch (err) {
448
+ setError(err instanceof Error ? err : new Error('Unknown error'));
449
+ }
450
+ finally {
451
+ setLoading(false);
452
+ }
453
+ };
454
+ require$$0.useEffect(() => {
455
+ fetchData();
456
+ }, [endpoint, id, config?.apiUrl]);
457
+ return {
458
+ data,
459
+ loading,
460
+ error,
461
+ refetch: fetchData,
462
+ };
463
+ }
464
+ // Specific hooks for common use cases
465
+ function useWordPressPosts(config) {
466
+ return useWordPress('posts', undefined, config);
467
+ }
468
+ function useWordPressPost(id, config) {
469
+ return useWordPress('posts', id, config);
470
+ }
471
+ function useWordPressPages(config) {
472
+ return useWordPress('pages', undefined, config);
473
+ }
474
+ function useWordPressPage(id, config) {
475
+ return useWordPress('pages', id, config);
476
+ }
477
+ function useWordPressMedia(config) {
478
+ return useWordPress('media', undefined, config);
479
+ }
480
+ function useWordPressCategories(config) {
481
+ return useWordPress('categories', undefined, config);
482
+ }
483
+ function useWordPressTags(config) {
484
+ return useWordPress('tags', undefined, config);
485
+ }
486
+
487
+ /**
488
+ * @license GPL-3.0-or-later
489
+ *
490
+ * This file is part of the MarVAlt Open SDK.
491
+ * Copyright (c) 2025 Vibune Pty Ltd.
492
+ *
493
+ * This program is free software: you can redistribute it and/or modify
494
+ * it under the terms of the GNU General Public License as published by
495
+ * the Free Software Foundation, either version 3 of the License, or
496
+ * (at your option) any later version.
497
+ *
498
+ * This program is distributed in the hope that it will be useful,
499
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
500
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
501
+ * See the GNU General Public License for more details.
502
+ */
503
+ // React Hook for Gravity Forms
504
+ function useGravityForms(formId, config) {
505
+ const [form, setForm] = require$$0.useState(null);
506
+ const [loading, setLoading] = require$$0.useState(true);
507
+ const [error, setError] = require$$0.useState(null);
508
+ const [submitting, setSubmitting] = require$$0.useState(false);
509
+ const [result, setResult] = require$$0.useState(null);
510
+ const fetchForm = require$$0.useCallback(async () => {
511
+ if (!config) {
512
+ setError(new Error('Gravity Forms configuration is required'));
513
+ setLoading(false);
514
+ return;
515
+ }
516
+ try {
517
+ setLoading(true);
518
+ setError(null);
519
+ const client = new GravityFormsClient(config);
520
+ const formData = await client.getForm(formId);
521
+ setForm(formData);
522
+ }
523
+ catch (err) {
524
+ setError(err instanceof Error ? err : new Error('Unknown error'));
525
+ }
526
+ finally {
527
+ setLoading(false);
528
+ }
529
+ }, [formId, config?.apiUrl]);
530
+ const submitForm = require$$0.useCallback(async (submission) => {
531
+ if (!config) {
532
+ setError(new Error('Gravity Forms configuration is required'));
533
+ return;
534
+ }
535
+ try {
536
+ setSubmitting(true);
537
+ setError(null);
538
+ setResult(null);
539
+ const client = new GravityFormsClient(config);
540
+ const submissionResult = await client.submitForm(formId, submission);
541
+ setResult(submissionResult);
542
+ }
543
+ catch (err) {
544
+ setError(err instanceof Error ? err : new Error('Unknown error'));
545
+ }
546
+ finally {
547
+ setSubmitting(false);
548
+ }
549
+ }, [formId, config?.apiUrl]);
550
+ return {
551
+ form,
552
+ loading,
553
+ error,
554
+ submitting,
555
+ result,
556
+ submitForm,
557
+ refetch: fetchForm,
558
+ };
559
+ }
560
+ function useGravityFormsConfig(formId, config) {
561
+ const [formConfig, setFormConfig] = require$$0.useState(null);
562
+ const [loading, setLoading] = require$$0.useState(true);
563
+ const [error, setError] = require$$0.useState(null);
564
+ const fetchConfig = require$$0.useCallback(async () => {
565
+ if (!config) {
566
+ setError(new Error('Gravity Forms configuration is required'));
567
+ setLoading(false);
568
+ return;
569
+ }
570
+ try {
571
+ setLoading(true);
572
+ setError(null);
573
+ const client = new GravityFormsClient(config);
574
+ const configData = await client.getFormConfig(formId);
575
+ setFormConfig(configData);
576
+ }
577
+ catch (err) {
578
+ setError(err instanceof Error ? err : new Error('Unknown error'));
579
+ }
580
+ finally {
581
+ setLoading(false);
582
+ }
583
+ }, [formId, config?.apiUrl]);
584
+ return {
585
+ formConfig,
586
+ loading,
587
+ error,
588
+ refetch: fetchConfig,
589
+ };
590
+ }
591
+
592
+ var jsxRuntime = {exports: {}};
593
+
594
+ var reactJsxRuntime_production_min = {};
595
+
596
+ /**
597
+ * @license React
598
+ * react-jsx-runtime.production.min.js
599
+ *
600
+ * Copyright (c) Facebook, Inc. and its affiliates.
601
+ *
602
+ * This source code is licensed under the MIT license found in the
603
+ * LICENSE file in the root directory of this source tree.
604
+ */
605
+
606
+ var hasRequiredReactJsxRuntime_production_min;
607
+
608
+ function requireReactJsxRuntime_production_min () {
609
+ if (hasRequiredReactJsxRuntime_production_min) return reactJsxRuntime_production_min;
610
+ hasRequiredReactJsxRuntime_production_min = 1;
611
+ var f=require$$0,k=Symbol.for("react.element"),l=Symbol.for("react.fragment"),m=Object.prototype.hasOwnProperty,n=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:true,ref:true,__self:true,__source:true};
612
+ function q(c,a,g){var b,d={},e=null,h=null;void 0!==g&&(e=""+g);void 0!==a.key&&(e=""+a.key);void 0!==a.ref&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a) void 0===d[b]&&(d[b]=a[b]);return {$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}reactJsxRuntime_production_min.Fragment=l;reactJsxRuntime_production_min.jsx=q;reactJsxRuntime_production_min.jsxs=q;
613
+ return reactJsxRuntime_production_min;
614
+ }
615
+
616
+ var reactJsxRuntime_development = {};
617
+
618
+ /**
619
+ * @license React
620
+ * react-jsx-runtime.development.js
621
+ *
622
+ * Copyright (c) Facebook, Inc. and its affiliates.
623
+ *
624
+ * This source code is licensed under the MIT license found in the
625
+ * LICENSE file in the root directory of this source tree.
626
+ */
627
+
628
+ var hasRequiredReactJsxRuntime_development;
629
+
630
+ function requireReactJsxRuntime_development () {
631
+ if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
632
+ hasRequiredReactJsxRuntime_development = 1;
633
+
634
+ if (process.env.NODE_ENV !== "production") {
635
+ (function() {
636
+
637
+ var React = require$$0;
638
+
639
+ // ATTENTION
640
+ // When adding new symbols to this file,
641
+ // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
642
+ // The Symbol used to tag the ReactElement-like types.
643
+ var REACT_ELEMENT_TYPE = Symbol.for('react.element');
644
+ var REACT_PORTAL_TYPE = Symbol.for('react.portal');
645
+ var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
646
+ var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');
647
+ var REACT_PROFILER_TYPE = Symbol.for('react.profiler');
648
+ var REACT_PROVIDER_TYPE = Symbol.for('react.provider');
649
+ var REACT_CONTEXT_TYPE = Symbol.for('react.context');
650
+ var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
651
+ var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
652
+ var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
653
+ var REACT_MEMO_TYPE = Symbol.for('react.memo');
654
+ var REACT_LAZY_TYPE = Symbol.for('react.lazy');
655
+ var REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen');
656
+ var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
657
+ var FAUX_ITERATOR_SYMBOL = '@@iterator';
658
+ function getIteratorFn(maybeIterable) {
659
+ if (maybeIterable === null || typeof maybeIterable !== 'object') {
660
+ return null;
661
+ }
662
+
663
+ var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
664
+
665
+ if (typeof maybeIterator === 'function') {
666
+ return maybeIterator;
667
+ }
668
+
669
+ return null;
670
+ }
671
+
672
+ var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
673
+
674
+ function error(format) {
675
+ {
676
+ {
677
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
678
+ args[_key2 - 1] = arguments[_key2];
679
+ }
680
+
681
+ printWarning('error', format, args);
682
+ }
683
+ }
684
+ }
685
+
686
+ function printWarning(level, format, args) {
687
+ // When changing this logic, you might want to also
688
+ // update consoleWithStackDev.www.js as well.
689
+ {
690
+ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
691
+ var stack = ReactDebugCurrentFrame.getStackAddendum();
692
+
693
+ if (stack !== '') {
694
+ format += '%s';
695
+ args = args.concat([stack]);
696
+ } // eslint-disable-next-line react-internal/safe-string-coercion
697
+
698
+
699
+ var argsWithFormat = args.map(function (item) {
700
+ return String(item);
701
+ }); // Careful: RN currently depends on this prefix
702
+
703
+ argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
704
+ // breaks IE9: https://github.com/facebook/react/issues/13610
705
+ // eslint-disable-next-line react-internal/no-production-logging
706
+
707
+ Function.prototype.apply.call(console[level], console, argsWithFormat);
708
+ }
709
+ }
710
+
711
+ // -----------------------------------------------------------------------------
712
+
713
+ var enableScopeAPI = false; // Experimental Create Event Handle API.
714
+ var enableCacheElement = false;
715
+ var enableTransitionTracing = false; // No known bugs, but needs performance testing
716
+
717
+ var enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber
718
+ // stuff. Intended to enable React core members to more easily debug scheduling
719
+ // issues in DEV builds.
720
+
721
+ var enableDebugTracing = false; // Track which Fiber(s) schedule render work.
722
+
723
+ var REACT_MODULE_REFERENCE;
724
+
725
+ {
726
+ REACT_MODULE_REFERENCE = Symbol.for('react.module.reference');
727
+ }
728
+
729
+ function isValidElementType(type) {
730
+ if (typeof type === 'string' || typeof type === 'function') {
731
+ return true;
732
+ } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
733
+
734
+
735
+ if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing ) {
736
+ return true;
737
+ }
738
+
739
+ if (typeof type === 'object' && type !== null) {
740
+ if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
741
+ // types supported by any Flight configuration anywhere since
742
+ // we don't know which Flight build this will end up being used
743
+ // with.
744
+ type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) {
745
+ return true;
746
+ }
747
+ }
748
+
749
+ return false;
750
+ }
751
+
752
+ function getWrappedName(outerType, innerType, wrapperName) {
753
+ var displayName = outerType.displayName;
754
+
755
+ if (displayName) {
756
+ return displayName;
757
+ }
758
+
759
+ var functionName = innerType.displayName || innerType.name || '';
760
+ return functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName;
761
+ } // Keep in sync with react-reconciler/getComponentNameFromFiber
762
+
763
+
764
+ function getContextName(type) {
765
+ return type.displayName || 'Context';
766
+ } // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.
767
+
768
+
769
+ function getComponentNameFromType(type) {
770
+ if (type == null) {
771
+ // Host root, text node or just invalid type.
772
+ return null;
773
+ }
774
+
775
+ {
776
+ if (typeof type.tag === 'number') {
777
+ error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.');
778
+ }
779
+ }
780
+
781
+ if (typeof type === 'function') {
782
+ return type.displayName || type.name || null;
783
+ }
784
+
785
+ if (typeof type === 'string') {
786
+ return type;
787
+ }
788
+
789
+ switch (type) {
790
+ case REACT_FRAGMENT_TYPE:
791
+ return 'Fragment';
792
+
793
+ case REACT_PORTAL_TYPE:
794
+ return 'Portal';
795
+
796
+ case REACT_PROFILER_TYPE:
797
+ return 'Profiler';
798
+
799
+ case REACT_STRICT_MODE_TYPE:
800
+ return 'StrictMode';
801
+
802
+ case REACT_SUSPENSE_TYPE:
803
+ return 'Suspense';
804
+
805
+ case REACT_SUSPENSE_LIST_TYPE:
806
+ return 'SuspenseList';
807
+
808
+ }
809
+
810
+ if (typeof type === 'object') {
811
+ switch (type.$$typeof) {
812
+ case REACT_CONTEXT_TYPE:
813
+ var context = type;
814
+ return getContextName(context) + '.Consumer';
815
+
816
+ case REACT_PROVIDER_TYPE:
817
+ var provider = type;
818
+ return getContextName(provider._context) + '.Provider';
819
+
820
+ case REACT_FORWARD_REF_TYPE:
821
+ return getWrappedName(type, type.render, 'ForwardRef');
822
+
823
+ case REACT_MEMO_TYPE:
824
+ var outerName = type.displayName || null;
825
+
826
+ if (outerName !== null) {
827
+ return outerName;
828
+ }
829
+
830
+ return getComponentNameFromType(type.type) || 'Memo';
831
+
832
+ case REACT_LAZY_TYPE:
833
+ {
834
+ var lazyComponent = type;
835
+ var payload = lazyComponent._payload;
836
+ var init = lazyComponent._init;
837
+
838
+ try {
839
+ return getComponentNameFromType(init(payload));
840
+ } catch (x) {
841
+ return null;
842
+ }
843
+ }
844
+
845
+ // eslint-disable-next-line no-fallthrough
846
+ }
847
+ }
848
+
849
+ return null;
850
+ }
851
+
852
+ var assign = Object.assign;
853
+
854
+ // Helpers to patch console.logs to avoid logging during side-effect free
855
+ // replaying on render function. This currently only patches the object
856
+ // lazily which won't cover if the log function was extracted eagerly.
857
+ // We could also eagerly patch the method.
858
+ var disabledDepth = 0;
859
+ var prevLog;
860
+ var prevInfo;
861
+ var prevWarn;
862
+ var prevError;
863
+ var prevGroup;
864
+ var prevGroupCollapsed;
865
+ var prevGroupEnd;
866
+
867
+ function disabledLog() {}
868
+
869
+ disabledLog.__reactDisabledLog = true;
870
+ function disableLogs() {
871
+ {
872
+ if (disabledDepth === 0) {
873
+ /* eslint-disable react-internal/no-production-logging */
874
+ prevLog = console.log;
875
+ prevInfo = console.info;
876
+ prevWarn = console.warn;
877
+ prevError = console.error;
878
+ prevGroup = console.group;
879
+ prevGroupCollapsed = console.groupCollapsed;
880
+ prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099
881
+
882
+ var props = {
883
+ configurable: true,
884
+ enumerable: true,
885
+ value: disabledLog,
886
+ writable: true
887
+ }; // $FlowFixMe Flow thinks console is immutable.
888
+
889
+ Object.defineProperties(console, {
890
+ info: props,
891
+ log: props,
892
+ warn: props,
893
+ error: props,
894
+ group: props,
895
+ groupCollapsed: props,
896
+ groupEnd: props
897
+ });
898
+ /* eslint-enable react-internal/no-production-logging */
899
+ }
900
+
901
+ disabledDepth++;
902
+ }
903
+ }
904
+ function reenableLogs() {
905
+ {
906
+ disabledDepth--;
907
+
908
+ if (disabledDepth === 0) {
909
+ /* eslint-disable react-internal/no-production-logging */
910
+ var props = {
911
+ configurable: true,
912
+ enumerable: true,
913
+ writable: true
914
+ }; // $FlowFixMe Flow thinks console is immutable.
915
+
916
+ Object.defineProperties(console, {
917
+ log: assign({}, props, {
918
+ value: prevLog
919
+ }),
920
+ info: assign({}, props, {
921
+ value: prevInfo
922
+ }),
923
+ warn: assign({}, props, {
924
+ value: prevWarn
925
+ }),
926
+ error: assign({}, props, {
927
+ value: prevError
928
+ }),
929
+ group: assign({}, props, {
930
+ value: prevGroup
931
+ }),
932
+ groupCollapsed: assign({}, props, {
933
+ value: prevGroupCollapsed
934
+ }),
935
+ groupEnd: assign({}, props, {
936
+ value: prevGroupEnd
937
+ })
938
+ });
939
+ /* eslint-enable react-internal/no-production-logging */
940
+ }
941
+
942
+ if (disabledDepth < 0) {
943
+ error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.');
944
+ }
945
+ }
946
+ }
947
+
948
+ var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
949
+ var prefix;
950
+ function describeBuiltInComponentFrame(name, source, ownerFn) {
951
+ {
952
+ if (prefix === undefined) {
953
+ // Extract the VM specific prefix used by each line.
954
+ try {
955
+ throw Error();
956
+ } catch (x) {
957
+ var match = x.stack.trim().match(/\n( *(at )?)/);
958
+ prefix = match && match[1] || '';
959
+ }
960
+ } // We use the prefix to ensure our stacks line up with native stack frames.
961
+
962
+
963
+ return '\n' + prefix + name;
964
+ }
965
+ }
966
+ var reentry = false;
967
+ var componentFrameCache;
968
+
969
+ {
970
+ var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
971
+ componentFrameCache = new PossiblyWeakMap();
972
+ }
973
+
974
+ function describeNativeComponentFrame(fn, construct) {
975
+ // If something asked for a stack inside a fake render, it should get ignored.
976
+ if ( !fn || reentry) {
977
+ return '';
978
+ }
979
+
980
+ {
981
+ var frame = componentFrameCache.get(fn);
982
+
983
+ if (frame !== undefined) {
984
+ return frame;
985
+ }
986
+ }
987
+
988
+ var control;
989
+ reentry = true;
990
+ var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.
991
+
992
+ Error.prepareStackTrace = undefined;
993
+ var previousDispatcher;
994
+
995
+ {
996
+ previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function
997
+ // for warnings.
998
+
999
+ ReactCurrentDispatcher.current = null;
1000
+ disableLogs();
1001
+ }
1002
+
1003
+ try {
1004
+ // This should throw.
1005
+ if (construct) {
1006
+ // Something should be setting the props in the constructor.
1007
+ var Fake = function () {
1008
+ throw Error();
1009
+ }; // $FlowFixMe
1010
+
1011
+
1012
+ Object.defineProperty(Fake.prototype, 'props', {
1013
+ set: function () {
1014
+ // We use a throwing setter instead of frozen or non-writable props
1015
+ // because that won't throw in a non-strict mode function.
1016
+ throw Error();
1017
+ }
1018
+ });
1019
+
1020
+ if (typeof Reflect === 'object' && Reflect.construct) {
1021
+ // We construct a different control for this case to include any extra
1022
+ // frames added by the construct call.
1023
+ try {
1024
+ Reflect.construct(Fake, []);
1025
+ } catch (x) {
1026
+ control = x;
1027
+ }
1028
+
1029
+ Reflect.construct(fn, [], Fake);
1030
+ } else {
1031
+ try {
1032
+ Fake.call();
1033
+ } catch (x) {
1034
+ control = x;
1035
+ }
1036
+
1037
+ fn.call(Fake.prototype);
1038
+ }
1039
+ } else {
1040
+ try {
1041
+ throw Error();
1042
+ } catch (x) {
1043
+ control = x;
1044
+ }
1045
+
1046
+ fn();
1047
+ }
1048
+ } catch (sample) {
1049
+ // This is inlined manually because closure doesn't do it for us.
1050
+ if (sample && control && typeof sample.stack === 'string') {
1051
+ // This extracts the first frame from the sample that isn't also in the control.
1052
+ // Skipping one frame that we assume is the frame that calls the two.
1053
+ var sampleLines = sample.stack.split('\n');
1054
+ var controlLines = control.stack.split('\n');
1055
+ var s = sampleLines.length - 1;
1056
+ var c = controlLines.length - 1;
1057
+
1058
+ while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
1059
+ // We expect at least one stack frame to be shared.
1060
+ // Typically this will be the root most one. However, stack frames may be
1061
+ // cut off due to maximum stack limits. In this case, one maybe cut off
1062
+ // earlier than the other. We assume that the sample is longer or the same
1063
+ // and there for cut off earlier. So we should find the root most frame in
1064
+ // the sample somewhere in the control.
1065
+ c--;
1066
+ }
1067
+
1068
+ for (; s >= 1 && c >= 0; s--, c--) {
1069
+ // Next we find the first one that isn't the same which should be the
1070
+ // frame that called our sample function and the control.
1071
+ if (sampleLines[s] !== controlLines[c]) {
1072
+ // In V8, the first line is describing the message but other VMs don't.
1073
+ // If we're about to return the first line, and the control is also on the same
1074
+ // line, that's a pretty good indicator that our sample threw at same line as
1075
+ // the control. I.e. before we entered the sample frame. So we ignore this result.
1076
+ // This can happen if you passed a class to function component, or non-function.
1077
+ if (s !== 1 || c !== 1) {
1078
+ do {
1079
+ s--;
1080
+ c--; // We may still have similar intermediate frames from the construct call.
1081
+ // The next one that isn't the same should be our match though.
1082
+
1083
+ if (c < 0 || sampleLines[s] !== controlLines[c]) {
1084
+ // V8 adds a "new" prefix for native classes. Let's remove it to make it prettier.
1085
+ var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled "<anonymous>"
1086
+ // but we have a user-provided "displayName"
1087
+ // splice it in to make the stack more readable.
1088
+
1089
+
1090
+ if (fn.displayName && _frame.includes('<anonymous>')) {
1091
+ _frame = _frame.replace('<anonymous>', fn.displayName);
1092
+ }
1093
+
1094
+ {
1095
+ if (typeof fn === 'function') {
1096
+ componentFrameCache.set(fn, _frame);
1097
+ }
1098
+ } // Return the line we found.
1099
+
1100
+
1101
+ return _frame;
1102
+ }
1103
+ } while (s >= 1 && c >= 0);
1104
+ }
1105
+
1106
+ break;
1107
+ }
1108
+ }
1109
+ }
1110
+ } finally {
1111
+ reentry = false;
1112
+
1113
+ {
1114
+ ReactCurrentDispatcher.current = previousDispatcher;
1115
+ reenableLogs();
1116
+ }
1117
+
1118
+ Error.prepareStackTrace = previousPrepareStackTrace;
1119
+ } // Fallback to just using the name if we couldn't make it throw.
1120
+
1121
+
1122
+ var name = fn ? fn.displayName || fn.name : '';
1123
+ var syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';
1124
+
1125
+ {
1126
+ if (typeof fn === 'function') {
1127
+ componentFrameCache.set(fn, syntheticFrame);
1128
+ }
1129
+ }
1130
+
1131
+ return syntheticFrame;
1132
+ }
1133
+ function describeFunctionComponentFrame(fn, source, ownerFn) {
1134
+ {
1135
+ return describeNativeComponentFrame(fn, false);
1136
+ }
1137
+ }
1138
+
1139
+ function shouldConstruct(Component) {
1140
+ var prototype = Component.prototype;
1141
+ return !!(prototype && prototype.isReactComponent);
1142
+ }
1143
+
1144
+ function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
1145
+
1146
+ if (type == null) {
1147
+ return '';
1148
+ }
1149
+
1150
+ if (typeof type === 'function') {
1151
+ {
1152
+ return describeNativeComponentFrame(type, shouldConstruct(type));
1153
+ }
1154
+ }
1155
+
1156
+ if (typeof type === 'string') {
1157
+ return describeBuiltInComponentFrame(type);
1158
+ }
1159
+
1160
+ switch (type) {
1161
+ case REACT_SUSPENSE_TYPE:
1162
+ return describeBuiltInComponentFrame('Suspense');
1163
+
1164
+ case REACT_SUSPENSE_LIST_TYPE:
1165
+ return describeBuiltInComponentFrame('SuspenseList');
1166
+ }
1167
+
1168
+ if (typeof type === 'object') {
1169
+ switch (type.$$typeof) {
1170
+ case REACT_FORWARD_REF_TYPE:
1171
+ return describeFunctionComponentFrame(type.render);
1172
+
1173
+ case REACT_MEMO_TYPE:
1174
+ // Memo may contain any component type so we recursively resolve it.
1175
+ return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
1176
+
1177
+ case REACT_LAZY_TYPE:
1178
+ {
1179
+ var lazyComponent = type;
1180
+ var payload = lazyComponent._payload;
1181
+ var init = lazyComponent._init;
1182
+
1183
+ try {
1184
+ // Lazy may contain any component type so we recursively resolve it.
1185
+ return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
1186
+ } catch (x) {}
1187
+ }
1188
+ }
1189
+ }
1190
+
1191
+ return '';
1192
+ }
1193
+
1194
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
1195
+
1196
+ var loggedTypeFailures = {};
1197
+ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
1198
+
1199
+ function setCurrentlyValidatingElement(element) {
1200
+ {
1201
+ if (element) {
1202
+ var owner = element._owner;
1203
+ var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
1204
+ ReactDebugCurrentFrame.setExtraStackFrame(stack);
1205
+ } else {
1206
+ ReactDebugCurrentFrame.setExtraStackFrame(null);
1207
+ }
1208
+ }
1209
+ }
1210
+
1211
+ function checkPropTypes(typeSpecs, values, location, componentName, element) {
1212
+ {
1213
+ // $FlowFixMe This is okay but Flow doesn't know it.
1214
+ var has = Function.call.bind(hasOwnProperty);
1215
+
1216
+ for (var typeSpecName in typeSpecs) {
1217
+ if (has(typeSpecs, typeSpecName)) {
1218
+ var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
1219
+ // fail the render phase where it didn't fail before. So we log it.
1220
+ // After these have been cleaned up, we'll let them throw.
1221
+
1222
+ try {
1223
+ // This is intentionally an invariant that gets caught. It's the same
1224
+ // behavior as without this statement except with a better message.
1225
+ if (typeof typeSpecs[typeSpecName] !== 'function') {
1226
+ // eslint-disable-next-line react-internal/prod-error-codes
1227
+ var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');
1228
+ err.name = 'Invariant Violation';
1229
+ throw err;
1230
+ }
1231
+
1232
+ error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
1233
+ } catch (ex) {
1234
+ error$1 = ex;
1235
+ }
1236
+
1237
+ if (error$1 && !(error$1 instanceof Error)) {
1238
+ setCurrentlyValidatingElement(element);
1239
+
1240
+ error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);
1241
+
1242
+ setCurrentlyValidatingElement(null);
1243
+ }
1244
+
1245
+ if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
1246
+ // Only monitor this failure once because there tends to be a lot of the
1247
+ // same error.
1248
+ loggedTypeFailures[error$1.message] = true;
1249
+ setCurrentlyValidatingElement(element);
1250
+
1251
+ error('Failed %s type: %s', location, error$1.message);
1252
+
1253
+ setCurrentlyValidatingElement(null);
1254
+ }
1255
+ }
1256
+ }
1257
+ }
1258
+ }
1259
+
1260
+ var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
1261
+
1262
+ function isArray(a) {
1263
+ return isArrayImpl(a);
1264
+ }
1265
+
1266
+ /*
1267
+ * The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol
1268
+ * and Temporal.* types. See https://github.com/facebook/react/pull/22064.
1269
+ *
1270
+ * The functions in this module will throw an easier-to-understand,
1271
+ * easier-to-debug exception with a clear errors message message explaining the
1272
+ * problem. (Instead of a confusing exception thrown inside the implementation
1273
+ * of the `value` object).
1274
+ */
1275
+ // $FlowFixMe only called in DEV, so void return is not possible.
1276
+ function typeName(value) {
1277
+ {
1278
+ // toStringTag is needed for namespaced types like Temporal.Instant
1279
+ var hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag;
1280
+ var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object';
1281
+ return type;
1282
+ }
1283
+ } // $FlowFixMe only called in DEV, so void return is not possible.
1284
+
1285
+
1286
+ function willCoercionThrow(value) {
1287
+ {
1288
+ try {
1289
+ testStringCoercion(value);
1290
+ return false;
1291
+ } catch (e) {
1292
+ return true;
1293
+ }
1294
+ }
1295
+ }
1296
+
1297
+ function testStringCoercion(value) {
1298
+ // If you ended up here by following an exception call stack, here's what's
1299
+ // happened: you supplied an object or symbol value to React (as a prop, key,
1300
+ // DOM attribute, CSS property, string ref, etc.) and when React tried to
1301
+ // coerce it to a string using `'' + value`, an exception was thrown.
1302
+ //
1303
+ // The most common types that will cause this exception are `Symbol` instances
1304
+ // and Temporal objects like `Temporal.Instant`. But any object that has a
1305
+ // `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this
1306
+ // exception. (Library authors do this to prevent users from using built-in
1307
+ // numeric operators like `+` or comparison operators like `>=` because custom
1308
+ // methods are needed to perform accurate arithmetic or comparison.)
1309
+ //
1310
+ // To fix the problem, coerce this object or symbol value to a string before
1311
+ // passing it to React. The most reliable way is usually `String(value)`.
1312
+ //
1313
+ // To find which value is throwing, check the browser or debugger console.
1314
+ // Before this exception was thrown, there should be `console.error` output
1315
+ // that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the
1316
+ // problem and how that type was used: key, atrribute, input value prop, etc.
1317
+ // In most cases, this console output also shows the component and its
1318
+ // ancestor components where the exception happened.
1319
+ //
1320
+ // eslint-disable-next-line react-internal/safe-string-coercion
1321
+ return '' + value;
1322
+ }
1323
+ function checkKeyStringCoercion(value) {
1324
+ {
1325
+ if (willCoercionThrow(value)) {
1326
+ error('The provided key is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', typeName(value));
1327
+
1328
+ return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
1329
+ }
1330
+ }
1331
+ }
1332
+
1333
+ var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
1334
+ var RESERVED_PROPS = {
1335
+ key: true,
1336
+ ref: true,
1337
+ __self: true,
1338
+ __source: true
1339
+ };
1340
+ var specialPropKeyWarningShown;
1341
+ var specialPropRefWarningShown;
1342
+
1343
+ function hasValidRef(config) {
1344
+ {
1345
+ if (hasOwnProperty.call(config, 'ref')) {
1346
+ var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
1347
+
1348
+ if (getter && getter.isReactWarning) {
1349
+ return false;
1350
+ }
1351
+ }
1352
+ }
1353
+
1354
+ return config.ref !== undefined;
1355
+ }
1356
+
1357
+ function hasValidKey(config) {
1358
+ {
1359
+ if (hasOwnProperty.call(config, 'key')) {
1360
+ var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
1361
+
1362
+ if (getter && getter.isReactWarning) {
1363
+ return false;
1364
+ }
1365
+ }
1366
+ }
1367
+
1368
+ return config.key !== undefined;
1369
+ }
1370
+
1371
+ function warnIfStringRefCannotBeAutoConverted(config, self) {
1372
+ {
1373
+ if (typeof config.ref === 'string' && ReactCurrentOwner.current && self) ;
1374
+ }
1375
+ }
1376
+
1377
+ function defineKeyPropWarningGetter(props, displayName) {
1378
+ {
1379
+ var warnAboutAccessingKey = function () {
1380
+ if (!specialPropKeyWarningShown) {
1381
+ specialPropKeyWarningShown = true;
1382
+
1383
+ error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
1384
+ }
1385
+ };
1386
+
1387
+ warnAboutAccessingKey.isReactWarning = true;
1388
+ Object.defineProperty(props, 'key', {
1389
+ get: warnAboutAccessingKey,
1390
+ configurable: true
1391
+ });
1392
+ }
1393
+ }
1394
+
1395
+ function defineRefPropWarningGetter(props, displayName) {
1396
+ {
1397
+ var warnAboutAccessingRef = function () {
1398
+ if (!specialPropRefWarningShown) {
1399
+ specialPropRefWarningShown = true;
1400
+
1401
+ error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
1402
+ }
1403
+ };
1404
+
1405
+ warnAboutAccessingRef.isReactWarning = true;
1406
+ Object.defineProperty(props, 'ref', {
1407
+ get: warnAboutAccessingRef,
1408
+ configurable: true
1409
+ });
1410
+ }
1411
+ }
1412
+ /**
1413
+ * Factory method to create a new React element. This no longer adheres to
1414
+ * the class pattern, so do not use new to call it. Also, instanceof check
1415
+ * will not work. Instead test $$typeof field against Symbol.for('react.element') to check
1416
+ * if something is a React Element.
1417
+ *
1418
+ * @param {*} type
1419
+ * @param {*} props
1420
+ * @param {*} key
1421
+ * @param {string|object} ref
1422
+ * @param {*} owner
1423
+ * @param {*} self A *temporary* helper to detect places where `this` is
1424
+ * different from the `owner` when React.createElement is called, so that we
1425
+ * can warn. We want to get rid of owner and replace string `ref`s with arrow
1426
+ * functions, and as long as `this` and owner are the same, there will be no
1427
+ * change in behavior.
1428
+ * @param {*} source An annotation object (added by a transpiler or otherwise)
1429
+ * indicating filename, line number, and/or other information.
1430
+ * @internal
1431
+ */
1432
+
1433
+
1434
+ var ReactElement = function (type, key, ref, self, source, owner, props) {
1435
+ var element = {
1436
+ // This tag allows us to uniquely identify this as a React Element
1437
+ $$typeof: REACT_ELEMENT_TYPE,
1438
+ // Built-in properties that belong on the element
1439
+ type: type,
1440
+ key: key,
1441
+ ref: ref,
1442
+ props: props,
1443
+ // Record the component responsible for creating this element.
1444
+ _owner: owner
1445
+ };
1446
+
1447
+ {
1448
+ // The validation flag is currently mutative. We put it on
1449
+ // an external backing store so that we can freeze the whole object.
1450
+ // This can be replaced with a WeakMap once they are implemented in
1451
+ // commonly used development environments.
1452
+ element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
1453
+ // the validation flag non-enumerable (where possible, which should
1454
+ // include every environment we run tests in), so the test framework
1455
+ // ignores it.
1456
+
1457
+ Object.defineProperty(element._store, 'validated', {
1458
+ configurable: false,
1459
+ enumerable: false,
1460
+ writable: true,
1461
+ value: false
1462
+ }); // self and source are DEV only properties.
1463
+
1464
+ Object.defineProperty(element, '_self', {
1465
+ configurable: false,
1466
+ enumerable: false,
1467
+ writable: false,
1468
+ value: self
1469
+ }); // Two elements created in two different places should be considered
1470
+ // equal for testing purposes and therefore we hide it from enumeration.
1471
+
1472
+ Object.defineProperty(element, '_source', {
1473
+ configurable: false,
1474
+ enumerable: false,
1475
+ writable: false,
1476
+ value: source
1477
+ });
1478
+
1479
+ if (Object.freeze) {
1480
+ Object.freeze(element.props);
1481
+ Object.freeze(element);
1482
+ }
1483
+ }
1484
+
1485
+ return element;
1486
+ };
1487
+ /**
1488
+ * https://github.com/reactjs/rfcs/pull/107
1489
+ * @param {*} type
1490
+ * @param {object} props
1491
+ * @param {string} key
1492
+ */
1493
+
1494
+ function jsxDEV(type, config, maybeKey, source, self) {
1495
+ {
1496
+ var propName; // Reserved names are extracted
1497
+
1498
+ var props = {};
1499
+ var key = null;
1500
+ var ref = null; // Currently, key can be spread in as a prop. This causes a potential
1501
+ // issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
1502
+ // or <div key="Hi" {...props} /> ). We want to deprecate key spread,
1503
+ // but as an intermediary step, we will use jsxDEV for everything except
1504
+ // <div {...props} key="Hi" />, because we aren't currently able to tell if
1505
+ // key is explicitly declared to be undefined or not.
1506
+
1507
+ if (maybeKey !== undefined) {
1508
+ {
1509
+ checkKeyStringCoercion(maybeKey);
1510
+ }
1511
+
1512
+ key = '' + maybeKey;
1513
+ }
1514
+
1515
+ if (hasValidKey(config)) {
1516
+ {
1517
+ checkKeyStringCoercion(config.key);
1518
+ }
1519
+
1520
+ key = '' + config.key;
1521
+ }
1522
+
1523
+ if (hasValidRef(config)) {
1524
+ ref = config.ref;
1525
+ warnIfStringRefCannotBeAutoConverted(config, self);
1526
+ } // Remaining properties are added to a new props object
1527
+
1528
+
1529
+ for (propName in config) {
1530
+ if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
1531
+ props[propName] = config[propName];
1532
+ }
1533
+ } // Resolve default props
1534
+
1535
+
1536
+ if (type && type.defaultProps) {
1537
+ var defaultProps = type.defaultProps;
1538
+
1539
+ for (propName in defaultProps) {
1540
+ if (props[propName] === undefined) {
1541
+ props[propName] = defaultProps[propName];
1542
+ }
1543
+ }
1544
+ }
1545
+
1546
+ if (key || ref) {
1547
+ var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
1548
+
1549
+ if (key) {
1550
+ defineKeyPropWarningGetter(props, displayName);
1551
+ }
1552
+
1553
+ if (ref) {
1554
+ defineRefPropWarningGetter(props, displayName);
1555
+ }
1556
+ }
1557
+
1558
+ return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
1559
+ }
1560
+ }
1561
+
1562
+ var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
1563
+ var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
1564
+
1565
+ function setCurrentlyValidatingElement$1(element) {
1566
+ {
1567
+ if (element) {
1568
+ var owner = element._owner;
1569
+ var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
1570
+ ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
1571
+ } else {
1572
+ ReactDebugCurrentFrame$1.setExtraStackFrame(null);
1573
+ }
1574
+ }
1575
+ }
1576
+
1577
+ var propTypesMisspellWarningShown;
1578
+
1579
+ {
1580
+ propTypesMisspellWarningShown = false;
1581
+ }
1582
+ /**
1583
+ * Verifies the object is a ReactElement.
1584
+ * See https://reactjs.org/docs/react-api.html#isvalidelement
1585
+ * @param {?object} object
1586
+ * @return {boolean} True if `object` is a ReactElement.
1587
+ * @final
1588
+ */
1589
+
1590
+
1591
+ function isValidElement(object) {
1592
+ {
1593
+ return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
1594
+ }
1595
+ }
1596
+
1597
+ function getDeclarationErrorAddendum() {
1598
+ {
1599
+ if (ReactCurrentOwner$1.current) {
1600
+ var name = getComponentNameFromType(ReactCurrentOwner$1.current.type);
1601
+
1602
+ if (name) {
1603
+ return '\n\nCheck the render method of `' + name + '`.';
1604
+ }
1605
+ }
1606
+
1607
+ return '';
1608
+ }
1609
+ }
1610
+
1611
+ function getSourceInfoErrorAddendum(source) {
1612
+ {
1613
+
1614
+ return '';
1615
+ }
1616
+ }
1617
+ /**
1618
+ * Warn if there's no key explicitly set on dynamic arrays of children or
1619
+ * object keys are not valid. This allows us to keep track of children between
1620
+ * updates.
1621
+ */
1622
+
1623
+
1624
+ var ownerHasKeyUseWarning = {};
1625
+
1626
+ function getCurrentComponentErrorInfo(parentType) {
1627
+ {
1628
+ var info = getDeclarationErrorAddendum();
1629
+
1630
+ if (!info) {
1631
+ var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
1632
+
1633
+ if (parentName) {
1634
+ info = "\n\nCheck the top-level render call using <" + parentName + ">.";
1635
+ }
1636
+ }
1637
+
1638
+ return info;
1639
+ }
1640
+ }
1641
+ /**
1642
+ * Warn if the element doesn't have an explicit key assigned to it.
1643
+ * This element is in an array. The array could grow and shrink or be
1644
+ * reordered. All children that haven't already been validated are required to
1645
+ * have a "key" property assigned to it. Error statuses are cached so a warning
1646
+ * will only be shown once.
1647
+ *
1648
+ * @internal
1649
+ * @param {ReactElement} element Element that requires a key.
1650
+ * @param {*} parentType element's parent's type.
1651
+ */
1652
+
1653
+
1654
+ function validateExplicitKey(element, parentType) {
1655
+ {
1656
+ if (!element._store || element._store.validated || element.key != null) {
1657
+ return;
1658
+ }
1659
+
1660
+ element._store.validated = true;
1661
+ var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
1662
+
1663
+ if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
1664
+ return;
1665
+ }
1666
+
1667
+ ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
1668
+ // property, it may be the creator of the child that's responsible for
1669
+ // assigning it a key.
1670
+
1671
+ var childOwner = '';
1672
+
1673
+ if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
1674
+ // Give the component that originally created this child.
1675
+ childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + ".";
1676
+ }
1677
+
1678
+ setCurrentlyValidatingElement$1(element);
1679
+
1680
+ error('Each child in a list should have a unique "key" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
1681
+
1682
+ setCurrentlyValidatingElement$1(null);
1683
+ }
1684
+ }
1685
+ /**
1686
+ * Ensure that every element either is passed in a static location, in an
1687
+ * array with an explicit keys property defined, or in an object literal
1688
+ * with valid key property.
1689
+ *
1690
+ * @internal
1691
+ * @param {ReactNode} node Statically passed child of any type.
1692
+ * @param {*} parentType node's parent's type.
1693
+ */
1694
+
1695
+
1696
+ function validateChildKeys(node, parentType) {
1697
+ {
1698
+ if (typeof node !== 'object') {
1699
+ return;
1700
+ }
1701
+
1702
+ if (isArray(node)) {
1703
+ for (var i = 0; i < node.length; i++) {
1704
+ var child = node[i];
1705
+
1706
+ if (isValidElement(child)) {
1707
+ validateExplicitKey(child, parentType);
1708
+ }
1709
+ }
1710
+ } else if (isValidElement(node)) {
1711
+ // This element was passed in a valid location.
1712
+ if (node._store) {
1713
+ node._store.validated = true;
1714
+ }
1715
+ } else if (node) {
1716
+ var iteratorFn = getIteratorFn(node);
1717
+
1718
+ if (typeof iteratorFn === 'function') {
1719
+ // Entry iterators used to provide implicit keys,
1720
+ // but now we print a separate warning for them later.
1721
+ if (iteratorFn !== node.entries) {
1722
+ var iterator = iteratorFn.call(node);
1723
+ var step;
1724
+
1725
+ while (!(step = iterator.next()).done) {
1726
+ if (isValidElement(step.value)) {
1727
+ validateExplicitKey(step.value, parentType);
1728
+ }
1729
+ }
1730
+ }
1731
+ }
1732
+ }
1733
+ }
1734
+ }
1735
+ /**
1736
+ * Given an element, validate that its props follow the propTypes definition,
1737
+ * provided by the type.
1738
+ *
1739
+ * @param {ReactElement} element
1740
+ */
1741
+
1742
+
1743
+ function validatePropTypes(element) {
1744
+ {
1745
+ var type = element.type;
1746
+
1747
+ if (type === null || type === undefined || typeof type === 'string') {
1748
+ return;
1749
+ }
1750
+
1751
+ var propTypes;
1752
+
1753
+ if (typeof type === 'function') {
1754
+ propTypes = type.propTypes;
1755
+ } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
1756
+ // Inner props are checked in the reconciler.
1757
+ type.$$typeof === REACT_MEMO_TYPE)) {
1758
+ propTypes = type.propTypes;
1759
+ } else {
1760
+ return;
1761
+ }
1762
+
1763
+ if (propTypes) {
1764
+ // Intentionally inside to avoid triggering lazy initializers:
1765
+ var name = getComponentNameFromType(type);
1766
+ checkPropTypes(propTypes, element.props, 'prop', name, element);
1767
+ } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
1768
+ propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
1769
+
1770
+ var _name = getComponentNameFromType(type);
1771
+
1772
+ error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
1773
+ }
1774
+
1775
+ if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
1776
+ error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
1777
+ }
1778
+ }
1779
+ }
1780
+ /**
1781
+ * Given a fragment, validate that it can only be provided with fragment props
1782
+ * @param {ReactElement} fragment
1783
+ */
1784
+
1785
+
1786
+ function validateFragmentProps(fragment) {
1787
+ {
1788
+ var keys = Object.keys(fragment.props);
1789
+
1790
+ for (var i = 0; i < keys.length; i++) {
1791
+ var key = keys[i];
1792
+
1793
+ if (key !== 'children' && key !== 'key') {
1794
+ setCurrentlyValidatingElement$1(fragment);
1795
+
1796
+ error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
1797
+
1798
+ setCurrentlyValidatingElement$1(null);
1799
+ break;
1800
+ }
1801
+ }
1802
+
1803
+ if (fragment.ref !== null) {
1804
+ setCurrentlyValidatingElement$1(fragment);
1805
+
1806
+ error('Invalid attribute `ref` supplied to `React.Fragment`.');
1807
+
1808
+ setCurrentlyValidatingElement$1(null);
1809
+ }
1810
+ }
1811
+ }
1812
+
1813
+ var didWarnAboutKeySpread = {};
1814
+ function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
1815
+ {
1816
+ var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
1817
+ // succeed and there will likely be errors in render.
1818
+
1819
+ if (!validType) {
1820
+ var info = '';
1821
+
1822
+ if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
1823
+ info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
1824
+ }
1825
+
1826
+ var sourceInfo = getSourceInfoErrorAddendum();
1827
+
1828
+ if (sourceInfo) {
1829
+ info += sourceInfo;
1830
+ } else {
1831
+ info += getDeclarationErrorAddendum();
1832
+ }
1833
+
1834
+ var typeString;
1835
+
1836
+ if (type === null) {
1837
+ typeString = 'null';
1838
+ } else if (isArray(type)) {
1839
+ typeString = 'array';
1840
+ } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
1841
+ typeString = "<" + (getComponentNameFromType(type.type) || 'Unknown') + " />";
1842
+ info = ' Did you accidentally export a JSX literal instead of a component?';
1843
+ } else {
1844
+ typeString = typeof type;
1845
+ }
1846
+
1847
+ error('React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
1848
+ }
1849
+
1850
+ var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.
1851
+ // TODO: Drop this when these are no longer allowed as the type argument.
1852
+
1853
+ if (element == null) {
1854
+ return element;
1855
+ } // Skip key warning if the type isn't valid since our key validation logic
1856
+ // doesn't expect a non-string/function type and can throw confusing errors.
1857
+ // We don't want exception behavior to differ between dev and prod.
1858
+ // (Rendering will throw with a helpful message and as soon as the type is
1859
+ // fixed, the key warnings will appear.)
1860
+
1861
+
1862
+ if (validType) {
1863
+ var children = props.children;
1864
+
1865
+ if (children !== undefined) {
1866
+ if (isStaticChildren) {
1867
+ if (isArray(children)) {
1868
+ for (var i = 0; i < children.length; i++) {
1869
+ validateChildKeys(children[i], type);
1870
+ }
1871
+
1872
+ if (Object.freeze) {
1873
+ Object.freeze(children);
1874
+ }
1875
+ } else {
1876
+ error('React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.');
1877
+ }
1878
+ } else {
1879
+ validateChildKeys(children, type);
1880
+ }
1881
+ }
1882
+ }
1883
+
1884
+ {
1885
+ if (hasOwnProperty.call(props, 'key')) {
1886
+ var componentName = getComponentNameFromType(type);
1887
+ var keys = Object.keys(props).filter(function (k) {
1888
+ return k !== 'key';
1889
+ });
1890
+ var beforeExample = keys.length > 0 ? '{key: someKey, ' + keys.join(': ..., ') + ': ...}' : '{key: someKey}';
1891
+
1892
+ if (!didWarnAboutKeySpread[componentName + beforeExample]) {
1893
+ var afterExample = keys.length > 0 ? '{' + keys.join(': ..., ') + ': ...}' : '{}';
1894
+
1895
+ error('A props object containing a "key" prop is being spread into JSX:\n' + ' let props = %s;\n' + ' <%s {...props} />\n' + 'React keys must be passed directly to JSX without using spread:\n' + ' let props = %s;\n' + ' <%s key={someKey} {...props} />', beforeExample, componentName, afterExample, componentName);
1896
+
1897
+ didWarnAboutKeySpread[componentName + beforeExample] = true;
1898
+ }
1899
+ }
1900
+ }
1901
+
1902
+ if (type === REACT_FRAGMENT_TYPE) {
1903
+ validateFragmentProps(element);
1904
+ } else {
1905
+ validatePropTypes(element);
1906
+ }
1907
+
1908
+ return element;
1909
+ }
1910
+ } // These two functions exist to still get child warnings in dev
1911
+ // even with the prod transform. This means that jsxDEV is purely
1912
+ // opt-in behavior for better messages but that we won't stop
1913
+ // giving you warnings if you use production apis.
1914
+
1915
+ function jsxWithValidationStatic(type, props, key) {
1916
+ {
1917
+ return jsxWithValidation(type, props, key, true);
1918
+ }
1919
+ }
1920
+ function jsxWithValidationDynamic(type, props, key) {
1921
+ {
1922
+ return jsxWithValidation(type, props, key, false);
1923
+ }
1924
+ }
1925
+
1926
+ var jsx = jsxWithValidationDynamic ; // we may want to special case jsxs internally to take advantage of static children.
1927
+ // for now we can ship identical prod functions
1928
+
1929
+ var jsxs = jsxWithValidationStatic ;
1930
+
1931
+ reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
1932
+ reactJsxRuntime_development.jsx = jsx;
1933
+ reactJsxRuntime_development.jsxs = jsxs;
1934
+ })();
1935
+ }
1936
+ return reactJsxRuntime_development;
1937
+ }
1938
+
1939
+ if (process.env.NODE_ENV === 'production') {
1940
+ jsxRuntime.exports = requireReactJsxRuntime_production_min();
1941
+ } else {
1942
+ jsxRuntime.exports = requireReactJsxRuntime_development();
1943
+ }
1944
+
1945
+ var jsxRuntimeExports = jsxRuntime.exports;
1946
+
1947
+ const WordPressContent = ({ content, className = '', showExcerpt = false, showDate = true, showAuthor = true, }) => {
1948
+ return (jsxRuntimeExports.jsxs("article", { className: `wordpress-content ${className}`, children: [jsxRuntimeExports.jsxs("header", { className: "content-header", children: [jsxRuntimeExports.jsx("h1", { className: "content-title", dangerouslySetInnerHTML: { __html: content.title.rendered } }), showDate && (jsxRuntimeExports.jsx("time", { className: "content-date", dateTime: content.date, children: new Date(content.date).toLocaleDateString() })), showAuthor && 'author' in content && (jsxRuntimeExports.jsxs("span", { className: "content-author", children: ["Author ID: ", content.author] }))] }), showExcerpt && content.excerpt && (jsxRuntimeExports.jsx("div", { className: "content-excerpt", dangerouslySetInnerHTML: { __html: content.excerpt.rendered } })), jsxRuntimeExports.jsx("div", { className: "content-body", dangerouslySetInnerHTML: { __html: content.content.rendered } })] }));
1949
+ };
1950
+
1951
+ const GravityForm = ({ formId, config, className = '', onSubmit, onError, }) => {
1952
+ const { form, loading, error, submitting, result, submitForm } = useGravityForms(formId, config);
1953
+ const [formData, setFormData] = require$$0.useState({});
1954
+ const handleSubmit = async (e) => {
1955
+ e.preventDefault();
1956
+ try {
1957
+ const submission = {
1958
+ form_id: formId,
1959
+ field_values: formData,
1960
+ };
1961
+ await submitForm(submission);
1962
+ if (onSubmit && result) {
1963
+ onSubmit(result);
1964
+ }
1965
+ }
1966
+ catch (err) {
1967
+ if (onError) {
1968
+ onError(err instanceof Error ? err : new Error('Unknown error'));
1969
+ }
1970
+ }
1971
+ };
1972
+ const handleFieldChange = (fieldId, value) => {
1973
+ setFormData(prev => ({
1974
+ ...prev,
1975
+ [fieldId]: value,
1976
+ }));
1977
+ };
1978
+ if (loading) {
1979
+ return jsxRuntimeExports.jsx("div", { className: `gravity-form loading ${className}`, children: "Loading form..." });
1980
+ }
1981
+ if (error) {
1982
+ return jsxRuntimeExports.jsxs("div", { className: `gravity-form error ${className}`, children: ["Error: ", error.message] });
1983
+ }
1984
+ if (!form) {
1985
+ return jsxRuntimeExports.jsx("div", { className: `gravity-form not-found ${className}`, children: "Form not found" });
1986
+ }
1987
+ return (jsxRuntimeExports.jsx("div", { className: `gravity-form ${className}`, children: jsxRuntimeExports.jsxs("form", { onSubmit: handleSubmit, children: [jsxRuntimeExports.jsx("h2", { children: form.title }), form.description && jsxRuntimeExports.jsx("p", { children: form.description }), form.fields.map(field => (jsxRuntimeExports.jsxs("div", { className: `field field-${field.type}`, children: [jsxRuntimeExports.jsxs("label", { htmlFor: `field_${field.id}`, children: [field.label, field.required && jsxRuntimeExports.jsx("span", { className: "required", children: "*" })] }), field.description && (jsxRuntimeExports.jsx("p", { className: "field-description", children: field.description })), field.type === 'text' && (jsxRuntimeExports.jsx("input", { type: "text", id: `field_${field.id}`, name: field.label, required: field.required, placeholder: field.placeholder, onChange: (e) => handleFieldChange(field.id.toString(), e.target.value) })), field.type === 'email' && (jsxRuntimeExports.jsx("input", { type: "email", id: `field_${field.id}`, name: field.label, required: field.required, placeholder: field.placeholder, onChange: (e) => handleFieldChange(field.id.toString(), e.target.value) })), field.type === 'textarea' && (jsxRuntimeExports.jsx("textarea", { id: `field_${field.id}`, name: field.label, required: field.required, placeholder: field.placeholder, onChange: (e) => handleFieldChange(field.id.toString(), e.target.value) })), field.type === 'select' && field.choices && (jsxRuntimeExports.jsxs("select", { id: `field_${field.id}`, name: field.label, required: field.required, onChange: (e) => handleFieldChange(field.id.toString(), e.target.value), children: [jsxRuntimeExports.jsx("option", { value: "", children: "Select an option" }), field.choices.map((choice, index) => (jsxRuntimeExports.jsx("option", { value: choice.value, children: choice.text }, index)))] }))] }, field.id))), jsxRuntimeExports.jsx("button", { type: "submit", disabled: submitting, children: submitting ? 'Submitting...' : 'Submit' }), result && (jsxRuntimeExports.jsx("div", { className: `result ${result.success ? 'success' : 'error'}`, children: result.message }))] }) }));
1988
+ };
1989
+
1990
+ const WordPressContext = require$$0.createContext(undefined);
1991
+ const WordPressProvider = ({ config, children }) => {
1992
+ return (jsxRuntimeExports.jsx(WordPressContext.Provider, { value: { config }, children: children }));
1993
+ };
1994
+ function useWordPressContext() {
1995
+ const context = require$$0.useContext(WordPressContext);
1996
+ if (context === undefined) {
1997
+ throw new Error('useWordPressContext must be used within a WordPressProvider');
1998
+ }
1999
+ return context;
2000
+ }
2001
+
2002
+ const GravityFormsContext = require$$0.createContext(undefined);
2003
+ const GravityFormsProvider = ({ config, children }) => {
2004
+ return (jsxRuntimeExports.jsx(GravityFormsContext.Provider, { value: { config }, children: children }));
2005
+ };
2006
+ function useGravityFormsContext() {
2007
+ const context = require$$0.useContext(GravityFormsContext);
2008
+ if (context === undefined) {
2009
+ throw new Error('useGravityFormsContext must be used within a GravityFormsProvider');
2010
+ }
2011
+ return context;
2012
+ }
2013
+
2014
+ /**
2015
+ * @license GPL-3.0-or-later
2016
+ *
2017
+ * This file is part of the MarVAlt Open SDK.
2018
+ * Copyright (c) 2025 Vibune Pty Ltd.
2019
+ *
2020
+ * This program is free software: you can redistribute it and/or modify
2021
+ * it under the terms of the GNU General Public License as published by
2022
+ * the Free Software Foundation, either version 3 of the License, or
2023
+ * (at your option) any later version.
2024
+ *
2025
+ * This program is distributed in the hope that it will be useful,
2026
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2027
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2028
+ * See the GNU General Public License for more details.
2029
+ */
2030
+ // WordPress Static Data Generator
2031
+ class WordPressGenerator {
2032
+ constructor(config) {
2033
+ this.config = config;
2034
+ }
2035
+ async generateStaticData() {
2036
+ const client = new WordPressClient(this.config);
2037
+ console.log('🚀 Starting WordPress static data generation...');
2038
+ const frontendId = this.config.frontendId || 'default-frontend';
2039
+ const frontendName = this.config.frontendName || 'Default Frontend';
2040
+ const postTypes = this.config.postTypes || ['posts', 'pages', 'case_studies', 'projects', 'members', 'testimonial', 'faqs', 'products', 'services', 'events'];
2041
+ const data = await client.getAllData({
2042
+ per_page: this.config.maxItems || 100,
2043
+ _embed: this.config.includeEmbedded || false,
2044
+ });
2045
+ // Create the static data structure matching the existing format
2046
+ const staticData = {
2047
+ generated_at: new Date().toISOString(),
2048
+ frontend_id: frontendId,
2049
+ frontend_name: frontendName,
2050
+ config: {
2051
+ frontend_id: frontendId,
2052
+ frontend_name: frontendName,
2053
+ post_types: postTypes.reduce((acc, postType) => {
2054
+ acc[postType] = {
2055
+ max_items: this.config.maxItems || 100,
2056
+ include_embedded: this.config.includeEmbedded || true,
2057
+ orderby: 'date',
2058
+ order: 'desc',
2059
+ };
2060
+ return acc;
2061
+ }, {}),
2062
+ },
2063
+ // Map the data to the expected structure
2064
+ posts: data.posts,
2065
+ pages: data.pages,
2066
+ media: data.media,
2067
+ categories: data.categories,
2068
+ tags: data.tags,
2069
+ };
2070
+ // Write to file
2071
+ this.writeStaticData(staticData);
2072
+ console.log('✅ WordPress static data generation completed');
2073
+ console.log(`📊 Generated data: ${data.posts.length} posts, ${data.pages.length} pages, ${data.media.length} media items`);
2074
+ return staticData;
2075
+ }
2076
+ writeStaticData(data) {
2077
+ try {
2078
+ const outputPath = path.join(process.cwd(), this.config.outputPath);
2079
+ fs.writeFileSync(outputPath, JSON.stringify(data, null, 2));
2080
+ console.log(`📁 Static data written to: ${outputPath}`);
2081
+ }
2082
+ catch (error) {
2083
+ console.error('❌ Error writing static data:', error);
2084
+ throw error;
2085
+ }
2086
+ }
2087
+ async generatePostsOnly() {
2088
+ const client = new WordPressClient(this.config);
2089
+ return client.getPosts({ per_page: 100 });
2090
+ }
2091
+ async generatePagesOnly() {
2092
+ const client = new WordPressClient(this.config);
2093
+ return client.getPages({ per_page: 100 });
2094
+ }
2095
+ async generateMediaOnly() {
2096
+ const client = new WordPressClient(this.config);
2097
+ return client.getMedia({ per_page: 100 });
2098
+ }
2099
+ }
2100
+ // Convenience function for easy usage
2101
+ async function generateWordPressData(config) {
2102
+ const generator = new WordPressGenerator(config);
2103
+ return generator.generateStaticData();
2104
+ }
2105
+
2106
+ /**
2107
+ * @license GPL-3.0-or-later
2108
+ *
2109
+ * This file is part of the MarVAlt Open SDK.
2110
+ * Copyright (c) 2025 Vibune Pty Ltd.
2111
+ *
2112
+ * This program is free software: you can redistribute it and/or modify
2113
+ * it under the terms of the GNU General Public License as published by
2114
+ * the Free Software Foundation, either version 3 of the License, or
2115
+ * (at your option) any later version.
2116
+ *
2117
+ * This program is distributed in the hope that it will be useful,
2118
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2119
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2120
+ * See the GNU General Public License for more details.
2121
+ */
2122
+ // Gravity Forms Static Data Generator
2123
+ class GravityFormsGenerator {
2124
+ constructor(config) {
2125
+ this.config = config;
2126
+ }
2127
+ async generateStaticData() {
2128
+ const client = new GravityFormsClient(this.config);
2129
+ console.log('🚀 Starting Gravity Forms static data generation...');
2130
+ let forms = [];
2131
+ if (this.config.formIds && this.config.formIds.length > 0) {
2132
+ // Generate specific forms
2133
+ for (const formId of this.config.formIds) {
2134
+ try {
2135
+ const form = await client.getFormConfig(formId);
2136
+ if (this.config.includeInactive || form.is_active) {
2137
+ forms.push(form);
2138
+ }
2139
+ }
2140
+ catch (error) {
2141
+ console.warn(`⚠️ Could not fetch form ${formId}:`, error);
2142
+ }
2143
+ }
2144
+ }
2145
+ else {
2146
+ // Generate all forms
2147
+ const formsList = await client.getForms();
2148
+ console.log('🔍 Gravity Forms Response:', {
2149
+ formsType: typeof formsList,
2150
+ isArray: Array.isArray(formsList),
2151
+ formsLength: formsList?.length,
2152
+ formsPreview: formsList ? JSON.stringify(formsList).substring(0, 200) : 'null',
2153
+ });
2154
+ let formsMetadata = [];
2155
+ if (Array.isArray(formsList)) {
2156
+ formsMetadata = formsList;
2157
+ }
2158
+ else if (formsList && typeof formsList === 'object' && Array.isArray(formsList.forms)) {
2159
+ formsMetadata = formsList.forms;
2160
+ }
2161
+ else if (formsList) {
2162
+ formsMetadata = [formsList];
2163
+ }
2164
+ if (!this.config.includeInactive) {
2165
+ formsMetadata = formsMetadata.filter(form => form.is_active === '1' || form.is_active === true);
2166
+ }
2167
+ // Fetch full form configuration for each form (schema lives under /config)
2168
+ console.log(`🔄 Fetching full data for ${formsMetadata.length} forms...`);
2169
+ forms = [];
2170
+ for (const formMetadata of formsMetadata) {
2171
+ try {
2172
+ const formId = Number(formMetadata.id);
2173
+ const fullForm = await client.getFormConfig(formId);
2174
+ forms.push(fullForm);
2175
+ console.log(`✅ Fetched form: ${fullForm.title} (${fullForm.fields?.length || 0} fields)`);
2176
+ }
2177
+ catch (error) {
2178
+ console.error(`❌ Failed to fetch form ${formMetadata.id} config:`, error);
2179
+ throw error;
2180
+ }
2181
+ }
2182
+ }
2183
+ const staticData = {
2184
+ generated_at: new Date().toISOString(),
2185
+ total_forms: forms.length,
2186
+ forms,
2187
+ };
2188
+ // Write to file
2189
+ this.writeStaticData(staticData);
2190
+ console.log('✅ Gravity Forms static data generation completed');
2191
+ console.log(`📊 Generated data: ${forms.length} forms`);
2192
+ return staticData;
2193
+ }
2194
+ writeStaticData(data) {
2195
+ try {
2196
+ const outputPath = path.join(process.cwd(), this.config.outputPath);
2197
+ fs.writeFileSync(outputPath, JSON.stringify(data, null, 2));
2198
+ console.log(`📁 Static data written to: ${outputPath}`);
2199
+ }
2200
+ catch (error) {
2201
+ console.error('❌ Error writing static data:', error);
2202
+ throw error;
2203
+ }
2204
+ }
2205
+ async generateFormConfig(formId) {
2206
+ const client = new GravityFormsClient(this.config);
2207
+ return client.getFormConfig(formId);
2208
+ }
2209
+ }
2210
+ // Convenience function for easy usage
2211
+ async function generateGravityFormsData(config) {
2212
+ const generator = new GravityFormsGenerator(config);
2213
+ return generator.generateStaticData();
2214
+ }
2215
+
2216
+ /**
2217
+ * @license GPL-3.0-or-later
2218
+ *
2219
+ * This file is part of the MarVAlt Open SDK.
2220
+ * Copyright (c) 2025 Vibune Pty Ltd.
2221
+ *
2222
+ * This program is free software: you can redistribute it and/or modify
2223
+ * it under the terms of the GNU General Public License as published by
2224
+ * the Free Software Foundation, either version 3 of the License, or
2225
+ * (at your option) any later version.
2226
+ *
2227
+ * This program is distributed in the hope that it will be useful,
2228
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2229
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2230
+ * See the GNU General Public License for more details.
2231
+ */
2232
+ class FormProtectionGenerator {
2233
+ constructor(config) {
2234
+ this.config = config;
2235
+ }
2236
+ async generateStaticData() {
2237
+ console.log('🚀 Starting Form Protection static data generation...');
2238
+ const forms = this.config.forms.map(form => ({
2239
+ id: form.id,
2240
+ name: form.name,
2241
+ protectionLevel: form.protectionLevel,
2242
+ emailVerification: this.config.emailVerification,
2243
+ spamProtection: this.config.spamProtection,
2244
+ rateLimiting: this.config.rateLimiting,
2245
+ }));
2246
+ const staticData = {
2247
+ config: {
2248
+ enabled: this.config.enabled,
2249
+ secret: this.config.secret,
2250
+ emailVerification: this.config.emailVerification,
2251
+ spamProtection: this.config.spamProtection,
2252
+ rateLimiting: this.config.rateLimiting,
2253
+ maxSubmissionsPerHour: this.config.maxSubmissionsPerHour,
2254
+ maxSubmissionsPerDay: this.config.maxSubmissionsPerDay,
2255
+ },
2256
+ forms,
2257
+ generatedAt: new Date().toISOString(),
2258
+ };
2259
+ // Write to file
2260
+ this.writeStaticData(staticData);
2261
+ console.log('✅ Form Protection static data generation completed');
2262
+ console.log(`📊 Generated data: ${forms.length} protected forms`);
2263
+ return staticData;
2264
+ }
2265
+ writeStaticData(data) {
2266
+ try {
2267
+ const outputPath = path.join(process.cwd(), this.config.outputPath);
2268
+ fs.writeFileSync(outputPath, JSON.stringify(data, null, 2));
2269
+ console.log(`📁 Static data written to: ${outputPath}`);
2270
+ }
2271
+ catch (error) {
2272
+ console.error('❌ Error writing static data:', error);
2273
+ throw error;
2274
+ }
2275
+ }
2276
+ validateFormProtection(formData) {
2277
+ // Basic validation logic for form protection
2278
+ const errors = [];
2279
+ if (this.config.emailVerification && !formData.email) {
2280
+ errors.push('Email verification is required');
2281
+ }
2282
+ if (this.config.spamProtection) {
2283
+ // Basic spam detection logic
2284
+ if (formData.message && formData.message.length < 10) {
2285
+ errors.push('Message too short');
2286
+ }
2287
+ }
2288
+ return {
2289
+ success: errors.length === 0,
2290
+ protected: this.config.enabled,
2291
+ message: errors.length > 0 ? errors.join(', ') : 'Form is protected',
2292
+ verificationRequired: this.config.emailVerification,
2293
+ spamDetected: errors.length > 0,
2294
+ };
2295
+ }
2296
+ }
2297
+ // Convenience function for easy usage
2298
+ async function generateFormProtectionData(config) {
2299
+ const generator = new FormProtectionGenerator(config);
2300
+ return generator.generateStaticData();
2301
+ }
2302
+
2303
+ /**
2304
+ * @license GPL-3.0-or-later
2305
+ *
2306
+ * This file is part of the MarVAlt Open SDK.
2307
+ * Copyright (c) 2025 Vibune Pty Ltd.
2308
+ *
2309
+ * This program is free software: you can redistribute it and/or modify
2310
+ * it under the terms of the GNU General Public License as published by
2311
+ * the Free Software Foundation, either version 3 of the License, or
2312
+ * (at your option) any later version.
2313
+ *
2314
+ * This program is distributed in the hope that it will be useful,
2315
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2316
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2317
+ * See the GNU General Public License for more details.
2318
+ */
2319
+ function createWordPressConfig(overrides = {}) {
2320
+ return {
2321
+ apiUrl: process.env.VITE_WORDPRESS_API_URL || '',
2322
+ authMode: process.env.VITE_WP_AUTH_MODE || 'cloudflare_proxy',
2323
+ cloudflareWorkerUrl: process.env.VITE_CLOUDFLARE_WORKER_URL,
2324
+ supabaseUrl: process.env.VITE_SUPABASE_URL,
2325
+ username: process.env.VITE_WP_API_USERNAME,
2326
+ password: process.env.VITE_WP_APP_PASSWORD,
2327
+ timeout: 30000,
2328
+ retries: 3,
2329
+ ...overrides,
2330
+ };
2331
+ }
2332
+ function createGravityFormsConfig(overrides = {}) {
2333
+ return {
2334
+ apiUrl: process.env.VITE_GRAVITY_FORMS_API_URL || '',
2335
+ authMode: process.env.VITE_WP_AUTH_MODE || 'cloudflare_proxy',
2336
+ cloudflareWorkerUrl: process.env.VITE_CLOUDFLARE_WORKER_URL,
2337
+ supabaseUrl: process.env.VITE_SUPABASE_URL,
2338
+ username: process.env.VITE_GRAVITY_FORMS_USERNAME || '',
2339
+ password: process.env.VITE_GRAVITY_FORMS_PASSWORD || '',
2340
+ timeout: 30000,
2341
+ retries: 3,
2342
+ ...overrides,
2343
+ };
2344
+ }
2345
+ function createFormProtectionConfig(overrides = {}) {
2346
+ return {
2347
+ enabled: process.env.VITE_FORM_PROTECTION_ENABLED === 'true',
2348
+ secret: process.env.VITE_FORM_PROTECTION_SECRET || '',
2349
+ emailVerification: process.env.VITE_FORM_PROTECTION_EMAIL_VERIFICATION === 'true',
2350
+ spamProtection: process.env.VITE_FORM_PROTECTION_SPAM_PROTECTION === 'true',
2351
+ rateLimiting: process.env.VITE_FORM_PROTECTION_RATE_LIMITING === 'true',
2352
+ maxSubmissionsPerHour: parseInt(process.env.VITE_FORM_PROTECTION_MAX_HOURLY || '10'),
2353
+ maxSubmissionsPerDay: parseInt(process.env.VITE_FORM_PROTECTION_MAX_DAILY || '50'),
2354
+ ...overrides,
2355
+ };
2356
+ }
2357
+ function validateWordPressConfig(config) {
2358
+ const errors = [];
2359
+ if (!config.apiUrl) {
2360
+ errors.push('WordPress API URL is required');
2361
+ }
2362
+ if (config.authMode === 'cloudflare_proxy' && !config.cloudflareWorkerUrl) {
2363
+ errors.push('Cloudflare Worker URL is required for cloudflare_proxy mode');
2364
+ }
2365
+ if (config.authMode === 'supabase_proxy' && !config.supabaseUrl) {
2366
+ errors.push('Supabase URL is required for supabase_proxy mode');
2367
+ }
2368
+ return errors;
2369
+ }
2370
+ function validateGravityFormsConfig(config) {
2371
+ const errors = [];
2372
+ if (!config.apiUrl) {
2373
+ errors.push('Gravity Forms API URL is required');
2374
+ }
2375
+ if (!config.username) {
2376
+ errors.push('Gravity Forms username is required');
2377
+ }
2378
+ if (!config.password) {
2379
+ errors.push('Gravity Forms password is required');
2380
+ }
2381
+ return errors;
2382
+ }
2383
+ function validateFormProtectionConfig(config) {
2384
+ const errors = [];
2385
+ if (config.enabled && !config.secret) {
2386
+ errors.push('Form protection secret is required when protection is enabled');
2387
+ }
2388
+ if (config.maxSubmissionsPerHour && config.maxSubmissionsPerHour < 1) {
2389
+ errors.push('Max submissions per hour must be at least 1');
2390
+ }
2391
+ if (config.maxSubmissionsPerDay && config.maxSubmissionsPerDay < 1) {
2392
+ errors.push('Max submissions per day must be at least 1');
2393
+ }
2394
+ return errors;
2395
+ }
2396
+
2397
+ /**
2398
+ * @license GPL-3.0-or-later
2399
+ *
2400
+ * This file is part of the MarVAlt Open SDK.
2401
+ * Copyright (c) 2025 Vibune Pty Ltd.
2402
+ *
2403
+ * This program is free software: you can redistribute it and/or modify
2404
+ * it under the terms of the GNU General Public License as published by
2405
+ * the Free Software Foundation, either version 3 of the License, or
2406
+ * (at your option) any later version.
2407
+ *
2408
+ * This program is distributed in the hope that it will be useful,
2409
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2410
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2411
+ * See the GNU General Public License for more details.
2412
+ */
2413
+ // Validation utilities
2414
+ function validateEmail(email) {
2415
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
2416
+ return emailRegex.test(email);
2417
+ }
2418
+ function validateRequired(value) {
2419
+ return value !== null && value !== undefined && value !== '';
2420
+ }
2421
+ function validateMinLength(value, minLength) {
2422
+ return value.length >= minLength;
2423
+ }
2424
+ function validateMaxLength(value, maxLength) {
2425
+ return value.length <= maxLength;
2426
+ }
2427
+ function validatePhoneNumber(phone) {
2428
+ const phoneRegex = /^[\+]?[1-9][\d]{0,15}$/;
2429
+ return phoneRegex.test(phone.replace(/\s/g, ''));
2430
+ }
2431
+ function validateUrl(url) {
2432
+ try {
2433
+ new URL(url);
2434
+ return true;
2435
+ }
2436
+ catch {
2437
+ return false;
2438
+ }
2439
+ }
2440
+ function sanitizeHtml(html) {
2441
+ // Basic HTML sanitization - in production, use a proper library like DOMPurify
2442
+ return html
2443
+ .replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, '')
2444
+ .replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi, '')
2445
+ .replace(/javascript:/gi, '')
2446
+ .replace(/on\w+\s*=/gi, '');
2447
+ }
2448
+ function validateFormData(formData, rules) {
2449
+ const errors = {};
2450
+ let isValid = true;
2451
+ for (const [fieldName, fieldRules] of Object.entries(rules)) {
2452
+ const value = formData[fieldName];
2453
+ const fieldErrors = [];
2454
+ if (fieldRules.required && !validateRequired(value)) {
2455
+ fieldErrors.push(`${fieldName} is required`);
2456
+ }
2457
+ if (value && fieldRules.type === 'email' && !validateEmail(value)) {
2458
+ fieldErrors.push(`${fieldName} must be a valid email address`);
2459
+ }
2460
+ if (value && fieldRules.type === 'url' && !validateUrl(value)) {
2461
+ fieldErrors.push(`${fieldName} must be a valid URL`);
2462
+ }
2463
+ if (value && fieldRules.type === 'phone' && !validatePhoneNumber(value)) {
2464
+ fieldErrors.push(`${fieldName} must be a valid phone number`);
2465
+ }
2466
+ if (value && fieldRules.minLength && !validateMinLength(value, fieldRules.minLength)) {
2467
+ fieldErrors.push(`${fieldName} must be at least ${fieldRules.minLength} characters long`);
2468
+ }
2469
+ if (value && fieldRules.maxLength && !validateMaxLength(value, fieldRules.maxLength)) {
2470
+ fieldErrors.push(`${fieldName} must be no more than ${fieldRules.maxLength} characters long`);
2471
+ }
2472
+ if (fieldErrors.length > 0) {
2473
+ errors[fieldName] = fieldErrors;
2474
+ isValid = false;
2475
+ }
2476
+ }
2477
+ return { isValid, errors };
2478
+ }
2479
+
2480
+ exports.FormProtectionGenerator = FormProtectionGenerator;
2481
+ exports.GravityForm = GravityForm;
2482
+ exports.GravityFormsClient = GravityFormsClient;
2483
+ exports.GravityFormsGenerator = GravityFormsGenerator;
2484
+ exports.GravityFormsProvider = GravityFormsProvider;
2485
+ exports.WordPressClient = WordPressClient;
2486
+ exports.WordPressContent = WordPressContent;
2487
+ exports.WordPressGenerator = WordPressGenerator;
2488
+ exports.WordPressProvider = WordPressProvider;
2489
+ exports.createFormProtectionConfig = createFormProtectionConfig;
2490
+ exports.createGravityFormsConfig = createGravityFormsConfig;
2491
+ exports.createWordPressConfig = createWordPressConfig;
2492
+ exports.generateFormProtectionData = generateFormProtectionData;
2493
+ exports.generateGravityFormsData = generateGravityFormsData;
2494
+ exports.generateWordPressData = generateWordPressData;
2495
+ exports.sanitizeHtml = sanitizeHtml;
2496
+ exports.transformWordPressMedia = transformWordPressMedia;
2497
+ exports.transformWordPressMediaItems = transformWordPressMediaItems;
2498
+ exports.transformWordPressPage = transformWordPressPage;
2499
+ exports.transformWordPressPages = transformWordPressPages;
2500
+ exports.transformWordPressPost = transformWordPressPost;
2501
+ exports.transformWordPressPosts = transformWordPressPosts;
2502
+ exports.useGravityForms = useGravityForms;
2503
+ exports.useGravityFormsConfig = useGravityFormsConfig;
2504
+ exports.useGravityFormsContext = useGravityFormsContext;
2505
+ exports.useWordPress = useWordPress;
2506
+ exports.useWordPressCategories = useWordPressCategories;
2507
+ exports.useWordPressContext = useWordPressContext;
2508
+ exports.useWordPressMedia = useWordPressMedia;
2509
+ exports.useWordPressPage = useWordPressPage;
2510
+ exports.useWordPressPages = useWordPressPages;
2511
+ exports.useWordPressPost = useWordPressPost;
2512
+ exports.useWordPressPosts = useWordPressPosts;
2513
+ exports.useWordPressTags = useWordPressTags;
2514
+ exports.validateEmail = validateEmail;
2515
+ exports.validateFormData = validateFormData;
2516
+ exports.validateFormProtectionConfig = validateFormProtectionConfig;
2517
+ exports.validateGravityFormsConfig = validateGravityFormsConfig;
2518
+ exports.validateMaxLength = validateMaxLength;
2519
+ exports.validateMinLength = validateMinLength;
2520
+ exports.validatePhoneNumber = validatePhoneNumber;
2521
+ exports.validateRequired = validateRequired;
2522
+ exports.validateUrl = validateUrl;
2523
+ exports.validateWordPressConfig = validateWordPressConfig;
2524
+ //# sourceMappingURL=index.js.map