@dotcms/react 0.0.1-alpha.9 → 0.0.1-beta.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 (81) hide show
  1. package/README.md +45 -4
  2. package/es.regexp.to-string.esm.js +1878 -0
  3. package/index.esm.d.ts +1 -0
  4. package/index.esm.js +3464 -0
  5. package/next.esm.d.ts +1 -0
  6. package/next.esm.js +738 -0
  7. package/package.json +54 -27
  8. package/src/index.d.ts +1 -0
  9. package/src/lib/deprecated/components/BlockEditorRenderer/BlockEditorRenderer.d.ts +37 -0
  10. package/src/lib/deprecated/components/BlockEditorRenderer/blocks/Code.d.ts +17 -0
  11. package/src/lib/deprecated/components/BlockEditorRenderer/blocks/Contentlet.d.ts +41 -0
  12. package/src/lib/deprecated/components/BlockEditorRenderer/blocks/Image.d.ts +8 -0
  13. package/src/lib/deprecated/components/BlockEditorRenderer/blocks/Lists.d.ts +22 -0
  14. package/src/lib/deprecated/components/BlockEditorRenderer/blocks/Table.d.ts +16 -0
  15. package/src/lib/deprecated/components/BlockEditorRenderer/blocks/Texts.d.ts +71 -0
  16. package/src/lib/deprecated/components/BlockEditorRenderer/blocks/Video.d.ts +8 -0
  17. package/src/lib/deprecated/components/BlockEditorRenderer/item/BlockEditorBlock.d.ts +12 -0
  18. package/src/lib/deprecated/components/Column/Column.d.ts +19 -0
  19. package/src/lib/deprecated/components/Container/Container.d.ts +19 -0
  20. package/src/lib/deprecated/components/DotEditableText/DotEditableText.d.ts +30 -0
  21. package/src/lib/deprecated/components/DotEditableText/utils.d.ts +36 -0
  22. package/src/lib/{components/DotcmsLayout/DotcmsLayout.tsx → deprecated/components/DotcmsLayout/DotcmsLayout.d.ts} +9 -23
  23. package/src/lib/deprecated/components/PageProvider/PageProvider.d.ts +14 -0
  24. package/src/lib/deprecated/components/Row/Row.d.ts +26 -0
  25. package/src/lib/deprecated/contexts/PageContext.d.ts +8 -0
  26. package/src/lib/deprecated/deprecated_api.d.ts +7 -0
  27. package/src/lib/deprecated/hooks/useCheckHaveContent.d.ts +5 -0
  28. package/src/lib/deprecated/hooks/useDotcmsEditor.d.ts +13 -0
  29. package/src/lib/deprecated/hooks/useDotcmsPageContext.d.ts +9 -0
  30. package/src/lib/deprecated/mocks/mockPageContext.d.ts +7 -0
  31. package/src/lib/deprecated/models/blocks.interface.d.ts +89 -0
  32. package/src/lib/deprecated/models/content-node.interface.d.ts +82 -0
  33. package/src/lib/deprecated/models/index.d.ts +127 -0
  34. package/src/lib/deprecated/utils/utils.d.ts +58 -0
  35. package/src/lib/next/__test__/mock.d.ts +11 -0
  36. package/src/lib/next/components/Column/Column.d.ts +37 -0
  37. package/src/lib/next/components/Container/Container.d.ts +32 -0
  38. package/src/lib/next/components/Container/ContainerFallbakcs.d.ts +24 -0
  39. package/src/lib/next/components/Contentlet/Contentlet.d.ts +32 -0
  40. package/src/lib/next/components/DotCMSLayoutBody/DotCMSLayoutBody.d.ts +26 -0
  41. package/src/lib/next/components/DotCMSLayoutBody/components/ErrorMessage.d.ts +9 -0
  42. package/src/lib/next/components/DotCMSShow/DotCMSShow.d.ts +49 -0
  43. package/src/lib/next/components/FallbackComponent/FallbackComponent.d.ts +41 -0
  44. package/src/lib/next/components/Row/Row.d.ts +21 -0
  45. package/src/lib/next/contexts/DotCMSPageContext.d.ts +23 -0
  46. package/src/lib/next/hooks/useCheckVisibleContent.d.ts +24 -0
  47. package/src/lib/next/hooks/useDotCMSShowWhen.d.ts +31 -0
  48. package/src/lib/next/hooks/useIsDevMode.d.ts +13 -0
  49. package/src/lib/next/types.d.ts +421 -0
  50. package/src/lib/next/utils/index.d.ts +136 -0
  51. package/src/next.d.ts +3 -0
  52. package/.babelrc +0 -12
  53. package/.eslintrc.json +0 -18
  54. package/jest.config.ts +0 -11
  55. package/project.json +0 -51
  56. package/src/index.ts +0 -4
  57. package/src/lib/components/Column/Column.module.css +0 -99
  58. package/src/lib/components/Column/Column.spec.tsx +0 -78
  59. package/src/lib/components/Column/Column.tsx +0 -45
  60. package/src/lib/components/Container/Container.module.css +0 -7
  61. package/src/lib/components/Container/Container.spec.tsx +0 -82
  62. package/src/lib/components/Container/Container.tsx +0 -105
  63. package/src/lib/components/DotcmsLayout/DotcmsLayout.module.css +0 -7
  64. package/src/lib/components/DotcmsLayout/DotcmsLayout.spec.tsx +0 -41
  65. package/src/lib/components/PageProvider/PageProvider.module.css +0 -7
  66. package/src/lib/components/PageProvider/PageProvider.spec.tsx +0 -54
  67. package/src/lib/components/PageProvider/PageProvider.tsx +0 -95
  68. package/src/lib/components/Row/Row.module.css +0 -5
  69. package/src/lib/components/Row/Row.spec.tsx +0 -92
  70. package/src/lib/components/Row/Row.tsx +0 -51
  71. package/src/lib/contexts/PageContext.tsx +0 -5
  72. package/src/lib/hooks/useDotcmsEditor.spec.ts +0 -56
  73. package/src/lib/hooks/useDotcmsEditor.ts +0 -29
  74. package/src/lib/hooks/useDotcmsPageContext.spec.tsx +0 -43
  75. package/src/lib/hooks/useDotcmsPageContext.tsx +0 -15
  76. package/src/lib/mocks/mockPageContext.tsx +0 -84
  77. package/src/lib/utils/utils.ts +0 -69
  78. package/tsconfig.json +0 -20
  79. package/tsconfig.lib.json +0 -23
  80. package/tsconfig.spec.json +0 -20
  81. /package/src/lib/{mocks/index.ts → deprecated/mocks/index.d.ts} +0 -0
package/index.esm.js ADDED
@@ -0,0 +1,3464 @@
1
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
+ import { s as styleInject, f as functionUncurryThis, t as toString$4, r as requireObjectCoercible$1, a as toIntegerOrInfinity$1, i as iteratorDefine, b as internalState, c as createIterResultObject$2, d as fails$2, w as wellKnownSymbol$4, e as descriptors, g as classofRaw$1, h as aCallable$2, j as functionBindNative, m as makeBuiltInExports, o as objectDefineProperty, k as objectIsPrototypeOf, l as functionCall, n as anObject$4, p as getMethod$2, q as iterators, u as getBuiltIn$1, v as isCallable$2, x as classof$3, y as inspectSource$1, z as createPropertyDescriptor$2, A as isNullOrUndefined$1, B as tryToString$1, C as toObject$1, D as lengthOfArrayLike$1, E as global$3, F as defineBuiltIn$5, G as arraySlice$2, _ as _export, H as setToStringTag$2, I as iteratorCreateConstructor, J as isObject$1, K as objectCreate, L as hasOwnProperty_1, M as objectAssign } from './es.regexp.to-string.esm.js';
3
+ import { useState, useEffect, createContext, useRef, useContext, createElement, forwardRef } from 'react';
4
+ import { isInsideEditor, initEditor, updateNavigation, destroyEditor, postMessageToEditor, CLIENT_ACTIONS, DotCmsClient, NOTIFY_CLIENT, initInlineEditing } from '@dotcms/client';
5
+ import { createUVESubscription } from '@dotcms/uve';
6
+ import { Editor } from '@tinymce/tinymce-react';
7
+
8
+ var isPure = false;
9
+
10
+ /**
11
+ * Custom Hook to handle the DotCMS editor interaction with the page.
12
+ *
13
+ * @category Hooks
14
+ * @param {DotcmsPageProps} props {
15
+ * pageContext,
16
+ * config,
17
+ * }
18
+ * @returns {DotCMSPageContext} The context for a DotCMS page provided by the editor.
19
+ */
20
+ const useDotcmsEditor = ({
21
+ pageContext,
22
+ config
23
+ }) => {
24
+ const {
25
+ pathname,
26
+ onReload,
27
+ editor
28
+ } = config;
29
+ const [state, setState] = useState(Object.assign({}, pageContext, {
30
+ isInsideEditor: false
31
+ }));
32
+ /**
33
+ * Initializes the DotCMS editor.
34
+ */
35
+ useEffect(() => {
36
+ if (!isInsideEditor()) {
37
+ return;
38
+ }
39
+ initEditor({
40
+ pathname
41
+ });
42
+ updateNavigation(pathname || '/');
43
+ setState(prevState => Object.assign({}, prevState, {
44
+ isInsideEditor: true
45
+ }));
46
+ return () => destroyEditor();
47
+ }, [pathname]);
48
+ /**
49
+ * Reloads the page when changes are made in the editor.
50
+ */
51
+ useEffect(() => {
52
+ const insideEditor = isInsideEditor();
53
+ if (!insideEditor || !onReload) {
54
+ return;
55
+ }
56
+ const {
57
+ unsubscribe
58
+ } = createUVESubscription('changes', () => onReload());
59
+ return () => unsubscribe();
60
+ }, [onReload]);
61
+ /**
62
+ * Sends a message to the editor when the client is ready.
63
+ */
64
+ useEffect(() => {
65
+ if (!isInsideEditor()) {
66
+ return;
67
+ }
68
+ postMessageToEditor({
69
+ action: CLIENT_ACTIONS.CLIENT_READY,
70
+ payload: editor
71
+ });
72
+ }, [pathname, editor]);
73
+ /**
74
+ * Old
75
+ */
76
+ useEffect(() => {
77
+ if (!isInsideEditor()) {
78
+ return;
79
+ }
80
+ const {
81
+ unsubscribe
82
+ } = createUVESubscription('changes', data => {
83
+ const pageAsset = data;
84
+ setState(state => Object.assign({}, state, {
85
+ pageAsset
86
+ }));
87
+ });
88
+ return () => unsubscribe();
89
+ }, []);
90
+ return state;
91
+ };
92
+
93
+ /**
94
+ * The `PageContext` is a React context that provides access to the DotCMS page context.
95
+ *
96
+ * @category Contexts
97
+ */
98
+ const PageContext = /*#__PURE__*/createContext(null);
99
+
100
+ /**
101
+ * `PageProvider` is a functional component that provides a context for a DotCMS page.
102
+ * It takes a `PageProviderProps` object as a parameter and returns a JSX element.
103
+ *
104
+ * @category Components
105
+ * @param {PageProviderProps} props - The properties for the PageProvider. Includes an `entity` and `children`.
106
+ * @returns {JSX.Element} - A JSX element that provides a context for a DotCMS page.
107
+ */
108
+ function PageProvider(props) {
109
+ const {
110
+ pageContext,
111
+ children
112
+ } = props;
113
+ return jsx(PageContext.Provider, {
114
+ value: pageContext,
115
+ children: children
116
+ });
117
+ }
118
+
119
+ var css_248z$1 = ".Row-module_row__1QEdR {\n display: grid;\n grid-template-columns: repeat(12, 1fr);\n gap: 1rem;\n}\n";
120
+ var styles$1 = {"row":"Row-module_row__1QEdR"};
121
+ styleInject(css_248z$1);
122
+
123
+ var css_248z = ".Column-module_col-start-1__pAqyF {\n grid-column-start: 1;\n}\n\n.Column-module_col-start-2__WwVhl {\n grid-column-start: 2;\n}\n\n.Column-module_col-start-3__DAtqM {\n grid-column-start: 3;\n}\n\n.Column-module_col-start-4__KAXJl {\n grid-column-start: 4;\n}\n\n.Column-module_col-start-5__9yg8H {\n grid-column-start: 5;\n}\n\n.Column-module_col-start-6__L9Fl1 {\n grid-column-start: 6;\n}\n\n.Column-module_col-start-7__7GWMg {\n grid-column-start: 7;\n}\n\n.Column-module_col-start-8__VPNje {\n grid-column-start: 8;\n}\n\n.Column-module_col-start-9__TQinR {\n grid-column-start: 9;\n}\n\n.Column-module_col-start-10__WuD2n {\n grid-column-start: 10;\n}\n\n.Column-module_col-start-11__ZYzHu {\n grid-column-start: 11;\n}\n\n.Column-module_col-start-12__XupQX {\n grid-column-start: 12;\n}\n\n.Column-module_col-end-1__thNVg {\n grid-column-end: 1;\n}\n\n.Column-module_col-end-2__7vCsE {\n grid-column-end: 2;\n}\n\n.Column-module_col-end-3__TiQJe {\n grid-column-end: 3;\n}\n\n.Column-module_col-end-4__66z6K {\n grid-column-end: 4;\n}\n\n.Column-module_col-end-5__MLwPh {\n grid-column-end: 5;\n}\n\n.Column-module_col-end-6__dz6-q {\n grid-column-end: 6;\n}\n\n.Column-module_col-end-7__Loe0Q {\n grid-column-end: 7;\n}\n\n.Column-module_col-end-8__NePGi {\n grid-column-end: 8;\n}\n\n.Column-module_col-end-9__V0-is {\n grid-column-end: 9;\n}\n\n.Column-module_col-end-10__b-1ia {\n grid-column-end: 10;\n}\n\n.Column-module_col-end-11__QroWM {\n grid-column-end: 11;\n}\n\n.Column-module_col-end-12__j-YYw {\n grid-column-end: 12;\n}\n\n.Column-module_col-end-13__khBAA {\n grid-column-end: 13;\n}\n";
124
+ var styles = {"col-start-1":"Column-module_col-start-1__pAqyF","col-start-2":"Column-module_col-start-2__WwVhl","col-start-3":"Column-module_col-start-3__DAtqM","col-start-4":"Column-module_col-start-4__KAXJl","col-start-5":"Column-module_col-start-5__9yg8H","col-start-6":"Column-module_col-start-6__L9Fl1","col-start-7":"Column-module_col-start-7__7GWMg","col-start-8":"Column-module_col-start-8__VPNje","col-start-9":"Column-module_col-start-9__TQinR","col-start-10":"Column-module_col-start-10__WuD2n","col-start-11":"Column-module_col-start-11__ZYzHu","col-start-12":"Column-module_col-start-12__XupQX","col-end-1":"Column-module_col-end-1__thNVg","col-end-2":"Column-module_col-end-2__7vCsE","col-end-3":"Column-module_col-end-3__TiQJe","col-end-4":"Column-module_col-end-4__66z6K","col-end-5":"Column-module_col-end-5__MLwPh","col-end-6":"Column-module_col-end-6__dz6-q","col-end-7":"Column-module_col-end-7__Loe0Q","col-end-8":"Column-module_col-end-8__NePGi","col-end-9":"Column-module_col-end-9__V0-is","col-end-10":"Column-module_col-end-10__b-1ia","col-end-11":"Column-module_col-end-11__QroWM","col-end-12":"Column-module_col-end-12__j-YYw","col-end-13":"Column-module_col-end-13__khBAA"};
125
+ styleInject(css_248z);
126
+
127
+ const endClassMap = {
128
+ 1: 'col-end-1',
129
+ 2: 'col-end-2',
130
+ 3: 'col-end-3',
131
+ 4: 'col-end-4',
132
+ 5: 'col-end-5',
133
+ 6: 'col-end-6',
134
+ 7: 'col-end-7',
135
+ 8: 'col-end-8',
136
+ 9: 'col-end-9',
137
+ 10: 'col-end-10',
138
+ 11: 'col-end-11',
139
+ 12: 'col-end-12',
140
+ 13: 'col-end-13'
141
+ };
142
+ const startClassMap = {
143
+ 1: 'col-start-1',
144
+ 2: 'col-start-2',
145
+ 3: 'col-start-3',
146
+ 4: 'col-start-4',
147
+ 5: 'col-start-5',
148
+ 6: 'col-start-6',
149
+ 7: 'col-start-7',
150
+ 8: 'col-start-8',
151
+ 9: 'col-start-9',
152
+ 10: 'col-start-10',
153
+ 11: 'col-start-11',
154
+ 12: 'col-start-12'
155
+ };
156
+ /**
157
+ * Get the container data from the containers object using the current container reference obtained from the layout.
158
+ *
159
+ * @param {ContainerData} containers
160
+ * @param {DotCMSPageContext['pageAsset']['layout']['body']['rows'][0]['columns'][0]['containers'][0]} containerRef
161
+ * @returns {Object} Container with all the data it has.
162
+ */
163
+ const getContainersData = (containers, containerRef) => {
164
+ var _containers$identifie;
165
+ const {
166
+ identifier,
167
+ uuid
168
+ } = containerRef;
169
+ const {
170
+ containerStructures,
171
+ container
172
+ } = containers[identifier];
173
+ // Get the variant id
174
+ const {
175
+ variantId
176
+ } = (container == null ? void 0 : container.parentPermissionable) || {};
177
+ // Get accepts types of content types for this container
178
+ const acceptTypes = containerStructures.map(structure => structure.contentTypeVar).join(',');
179
+ // Get the contentlets for "this" container
180
+ const contentlets = (_containers$identifie = containers[identifier].contentlets[`uuid-${uuid}`]) != null ? _containers$identifie : containers[identifier].contentlets[`uuid-dotParser_${uuid}`];
181
+ if (!contentlets) {
182
+ console.warn(`We couldn't find the contentlets for the container with the identifier ${identifier} and the uuid ${uuid} becareful by adding content to this container.\nWe recommend to change the container in the layout and add the content again.`);
183
+ }
184
+ return Object.assign({}, containers[identifier].container, {
185
+ acceptTypes,
186
+ contentlets: contentlets != null ? contentlets : [],
187
+ variantId
188
+ });
189
+ };
190
+ /**
191
+ * Combine classes into a single string.
192
+ *
193
+ * @param {string[]} classes
194
+ * @returns {string} Combined classes
195
+ */
196
+ const combineClasses = classes => classes.filter(Boolean).join(' ');
197
+ /**
198
+ * Get the start and end classes for the column based on the left offset and width.
199
+ *
200
+ * @param {number} start
201
+ * @param {number} end
202
+ * @returns {Object} Start and end classes
203
+ */
204
+ const getPositionStyleClasses = (start, end) => {
205
+ const startClass = startClassMap[start];
206
+ const endClass = endClassMap[end];
207
+ return {
208
+ startClass,
209
+ endClass
210
+ };
211
+ };
212
+ /**
213
+ * Validates the structure of a Block Editor block.
214
+ *
215
+ * This function checks that:
216
+ * 1. The blocks parameter is a valid object
217
+ * 2. The block has a 'doc' type
218
+ * 3. The block has a valid content array that is not empty
219
+ *
220
+ * @param {Block} blocks - The blocks structure to validate
221
+ * @returns {BlockEditorState} Object containing validation state and any error message
222
+ * @property {boolean} BlockEditorState.isValid - Whether the blocks structure is valid
223
+ * @property {string | null} BlockEditorState.error - Error message if invalid, null if valid
224
+ */
225
+ const isValidBlocks = blocks => {
226
+ if (!blocks) {
227
+ return {
228
+ error: `Error: Blocks object is not defined`
229
+ };
230
+ }
231
+ if (typeof blocks !== 'object') {
232
+ return {
233
+ error: `Error: Blocks must be an object, but received: ${typeof blocks}`
234
+ };
235
+ }
236
+ if (blocks.type !== 'doc') {
237
+ return {
238
+ error: 'Error: Blocks must have a doc type'
239
+ };
240
+ }
241
+ if (!blocks.content || !Array.isArray(blocks.content)) {
242
+ return {
243
+ error: 'Error: Blocks must have a valid content array'
244
+ };
245
+ }
246
+ if (blocks.content.length === 0) {
247
+ return {
248
+ error: 'Error: Blocks content is empty'
249
+ };
250
+ }
251
+ return {
252
+ error: null
253
+ };
254
+ };
255
+
256
+ const useCheckHaveContent = () => {
257
+ const contentletDivRef = useRef(null);
258
+ const [haveContent, setHaveContent] = useState(false);
259
+ useEffect(() => {
260
+ if (!contentletDivRef.current) {
261
+ return;
262
+ }
263
+ const childElement = contentletDivRef.current.firstElementChild;
264
+ if (!childElement) {
265
+ return;
266
+ }
267
+ const height = childElement.getBoundingClientRect().height;
268
+ if (height > 0) {
269
+ setHaveContent(true);
270
+ return;
271
+ }
272
+ setHaveContent(false);
273
+ }, [contentletDivRef]);
274
+ return {
275
+ contentletDivRef,
276
+ haveContent
277
+ };
278
+ };
279
+
280
+ /**
281
+ * Component to render when there is no component for the content type.
282
+ *
283
+ * @param {{ readonly contentType: string }} { contentType }
284
+ * @return {*}
285
+ */
286
+ function NoComponent({
287
+ contentType
288
+ }) {
289
+ return jsxs("div", {
290
+ "data-testid": "no-component",
291
+ children: ["No Component for ", contentType]
292
+ });
293
+ }
294
+ /**
295
+ * Component to render when there is no content in the container.
296
+ *
297
+ * @return {*}
298
+ */
299
+ function EmptyContent() {
300
+ return null;
301
+ }
302
+ /**
303
+ * Renders a Container with its content using information provided by dotCMS Page API.
304
+ *
305
+ * @see {@link https://www.dotcms.com/docs/latest/page-rest-api-layout-as-a-service-laas}
306
+ * @export
307
+ * @param {ContainerProps} { containerRef }
308
+ * @return {JSX.Element} Rendered container with content
309
+ */
310
+ function Container({
311
+ containerRef
312
+ }) {
313
+ const {
314
+ isInsideEditor
315
+ } = useContext(PageContext);
316
+ const {
317
+ identifier,
318
+ uuid
319
+ } = containerRef;
320
+ const {
321
+ haveContent,
322
+ contentletDivRef
323
+ } = useCheckHaveContent();
324
+ // Get the containers from the global context
325
+ const {
326
+ pageAsset: {
327
+ containers
328
+ },
329
+ components
330
+ } = useContext(PageContext);
331
+ const {
332
+ acceptTypes,
333
+ contentlets,
334
+ maxContentlets,
335
+ variantId,
336
+ path
337
+ } = getContainersData(containers, containerRef);
338
+ const container = {
339
+ acceptTypes,
340
+ identifier: path != null ? path : identifier,
341
+ maxContentlets,
342
+ variantId,
343
+ uuid
344
+ };
345
+ const containerStyles = contentlets.length ? undefined : {
346
+ width: '100%',
347
+ backgroundColor: '#ECF0FD',
348
+ display: 'flex',
349
+ justifyContent: 'center',
350
+ alignItems: 'center',
351
+ color: '#030E32',
352
+ height: '10rem'
353
+ };
354
+ const ContainerChildren = contentlets.map(contentlet => {
355
+ const ContentTypeComponent = components[contentlet.contentType];
356
+ const DefaultComponent = components['CustomNoComponent'] || NoComponent;
357
+ const Component = isInsideEditor ? ContentTypeComponent || DefaultComponent : ContentTypeComponent || EmptyContent;
358
+ return isInsideEditor ? jsx("div", {
359
+ "data-testid": "dot-contentlet",
360
+ "data-dot-object": "contentlet",
361
+ "data-dot-identifier": contentlet.identifier,
362
+ "data-dot-basetype": contentlet.baseType,
363
+ "data-dot-title": contentlet.widgetTitle || contentlet.title,
364
+ "data-dot-inode": contentlet.inode,
365
+ "data-dot-type": contentlet.contentType,
366
+ "data-dot-container": JSON.stringify(container),
367
+ "data-dot-on-number-of-pages": contentlet.onNumberOfPages,
368
+ ref: contentletDivRef,
369
+ style: {
370
+ minHeight: haveContent ? undefined : '4rem'
371
+ },
372
+ children: jsx(Component, Object.assign({}, contentlet))
373
+ }, contentlet.identifier) : (/*#__PURE__*/createElement(Component, Object.assign({}, contentlet, {
374
+ key: contentlet.identifier
375
+ })));
376
+ });
377
+ return isInsideEditor ? jsx("div", {
378
+ "data-testid": "dot-container",
379
+ "data-dot-object": "container",
380
+ "data-dot-accept-types": acceptTypes,
381
+ "data-dot-identifier": path != null ? path : identifier,
382
+ "data-max-contentlets": maxContentlets,
383
+ "data-dot-uuid": uuid,
384
+ style: containerStyles,
385
+ children: ContainerChildren.length ? ContainerChildren : 'This container is empty.'
386
+ }) :
387
+ // eslint-disable-next-line react/jsx-no-useless-fragment
388
+ jsx(Fragment, {
389
+ children: ContainerChildren
390
+ });
391
+ }
392
+
393
+ /**
394
+ * Renders a Column with its containers using information provided by dotCMS Page API.
395
+ *
396
+ * @see {@link https://www.dotcms.com/docs/latest/page-rest-api-layout-as-a-service-laas}
397
+ * @export
398
+ * @param {ColumnProps} { column }
399
+ * @return {JSX.Element} Rendered column with containers
400
+ */
401
+ function Column({
402
+ column
403
+ }) {
404
+ const {
405
+ isInsideEditor
406
+ } = useContext(PageContext);
407
+ const {
408
+ startClass,
409
+ endClass
410
+ } = getPositionStyleClasses(column.leftOffset, column.width + column.leftOffset);
411
+ const combinedClasses = combineClasses([styles[endClass], styles[startClass]]);
412
+ const columnProps = isInsideEditor ? {
413
+ 'data-dot': 'column',
414
+ 'data-testid': 'column'
415
+ } : {};
416
+ return jsx("div", Object.assign({}, columnProps, {
417
+ className: combinedClasses,
418
+ children: jsx("div", {
419
+ className: column.styleClass,
420
+ children: column.containers.map(container => jsx(Container, {
421
+ containerRef: container
422
+ }, `${container.identifier}-${container.uuid}`))
423
+ })
424
+ }));
425
+ }
426
+
427
+ /**
428
+ * This component renders a row with all it's content using the layout provided by dotCMS Page API.
429
+ *
430
+ * @see {@link https://www.dotcms.com/docs/latest/page-rest-api-layout-as-a-service-laas}
431
+ * @category Components
432
+ * @param {React.ForwardedRef<HTMLDivElement, RowProps>} ref
433
+ * @return {JSX.Element} Rendered rows with columns
434
+ */
435
+ const Row = /*#__PURE__*/forwardRef((props, ref) => {
436
+ const {
437
+ isInsideEditor
438
+ } = useContext(PageContext);
439
+ const {
440
+ row
441
+ } = props;
442
+ const rowProps = isInsideEditor ? {
443
+ 'data-dot': 'row',
444
+ 'data-testid': 'row',
445
+ ref
446
+ } : {};
447
+ return jsx("div", {
448
+ className: row.styleClass,
449
+ children: jsx("div", {
450
+ className: "container",
451
+ children: jsx("div", Object.assign({}, rowProps, {
452
+ className: styles$1.row,
453
+ children: row.columns.map((column, index) => jsx(Column, {
454
+ column: column
455
+ }, index))
456
+ }))
457
+ })
458
+ });
459
+ });
460
+
461
+ /**
462
+ * `DotcmsLayout` is a functional component that renders a layout for a DotCMS page.
463
+ * It takes a `DotcmsPageProps` object as a parameter and returns a JSX element.
464
+ *
465
+ * @category Components
466
+ * @param {DotcmsPageProps} props - The properties for the DotCMS page.
467
+ * @returns {JSX.Element} - A JSX element that represents the layout for a DotCMS page.
468
+ * @deprecated Use {@link https://github.com/dotCMS/core/blob/main/core-web/libs/sdk/react/src/lib/next/components/DotCMSLayoutBody/DotCMSLayoutBody.tsx DotCMSLayoutBody} instead.
469
+ */
470
+ function DotcmsLayout(dotPageProps) {
471
+ var _pageContext$pageAsse;
472
+ const pageContext = useDotcmsEditor(dotPageProps);
473
+ return jsx(PageProvider, {
474
+ pageContext: pageContext,
475
+ children: (_pageContext$pageAsse = pageContext.pageAsset) == null || (_pageContext$pageAsse = _pageContext$pageAsse.layout) == null ? void 0 : _pageContext$pageAsse.body.rows.map((row, index) => jsx(Row, {
476
+ row: row
477
+ }, index))
478
+ });
479
+ }
480
+
481
+ var uncurryThis$9 = functionUncurryThis;
482
+ var toIntegerOrInfinity = toIntegerOrInfinity$1;
483
+ var toString$3 = toString$4;
484
+ var requireObjectCoercible = requireObjectCoercible$1;
485
+
486
+ var charAt$3 = uncurryThis$9(''.charAt);
487
+ var charCodeAt$1 = uncurryThis$9(''.charCodeAt);
488
+ var stringSlice$2 = uncurryThis$9(''.slice);
489
+
490
+ var createMethod = function (CONVERT_TO_STRING) {
491
+ return function ($this, pos) {
492
+ var S = toString$3(requireObjectCoercible($this));
493
+ var position = toIntegerOrInfinity(pos);
494
+ var size = S.length;
495
+ var first, second;
496
+ if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
497
+ first = charCodeAt$1(S, position);
498
+ return first < 0xD800 || first > 0xDBFF || position + 1 === size
499
+ || (second = charCodeAt$1(S, position + 1)) < 0xDC00 || second > 0xDFFF
500
+ ? CONVERT_TO_STRING
501
+ ? charAt$3(S, position)
502
+ : first
503
+ : CONVERT_TO_STRING
504
+ ? stringSlice$2(S, position, position + 2)
505
+ : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
506
+ };
507
+ };
508
+
509
+ var stringMultibyte = {
510
+ // `String.prototype.codePointAt` method
511
+ // https://tc39.es/ecma262/#sec-string.prototype.codepointat
512
+ codeAt: createMethod(false),
513
+ // `String.prototype.at` method
514
+ // https://github.com/mathiasbynens/String.prototype.at
515
+ charAt: createMethod(true)
516
+ };
517
+
518
+ var charAt$2 = stringMultibyte.charAt;
519
+ var toString$2 = toString$4;
520
+ var InternalStateModule$2 = internalState;
521
+ var defineIterator = iteratorDefine;
522
+ var createIterResultObject$1 = createIterResultObject$2;
523
+
524
+ var STRING_ITERATOR = 'String Iterator';
525
+ var setInternalState$2 = InternalStateModule$2.set;
526
+ var getInternalState = InternalStateModule$2.getterFor(STRING_ITERATOR);
527
+
528
+ // `String.prototype[@@iterator]` method
529
+ // https://tc39.es/ecma262/#sec-string.prototype-@@iterator
530
+ defineIterator(String, 'String', function (iterated) {
531
+ setInternalState$2(this, {
532
+ type: STRING_ITERATOR,
533
+ string: toString$2(iterated),
534
+ index: 0
535
+ });
536
+ // `%StringIteratorPrototype%.next` method
537
+ // https://tc39.es/ecma262/#sec-%stringiteratorprototype%.next
538
+ }, function next() {
539
+ var state = getInternalState(this);
540
+ var string = state.string;
541
+ var index = state.index;
542
+ var point;
543
+ if (index >= string.length) return createIterResultObject$1(undefined, true);
544
+ point = charAt$2(string, index);
545
+ state.index += point.length;
546
+ return createIterResultObject$1(point, false);
547
+ });
548
+
549
+ var fails$1 = fails$2;
550
+ var wellKnownSymbol$3 = wellKnownSymbol$4;
551
+ var DESCRIPTORS$5 = descriptors;
552
+ var IS_PURE = isPure;
553
+
554
+ var ITERATOR$3 = wellKnownSymbol$3('iterator');
555
+
556
+ var urlConstructorDetection = !fails$1(function () {
557
+ // eslint-disable-next-line unicorn/relative-url-style -- required for testing
558
+ var url = new URL('b?a=1&b=2&c=3', 'http://a');
559
+ var params = url.searchParams;
560
+ var params2 = new URLSearchParams('a=1&a=2&b=3');
561
+ var result = '';
562
+ url.pathname = 'c%20d';
563
+ params.forEach(function (value, key) {
564
+ params['delete']('b');
565
+ result += key + value;
566
+ });
567
+ params2['delete']('a', 2);
568
+ // `undefined` case is a Chromium 117 bug
569
+ // https://bugs.chromium.org/p/v8/issues/detail?id=14222
570
+ params2['delete']('b', undefined);
571
+ return (IS_PURE && (!url.toJSON || !params2.has('a', 1) || params2.has('a', 2) || !params2.has('a', undefined) || params2.has('b')))
572
+ || (!params.size && (IS_PURE || !DESCRIPTORS$5))
573
+ || !params.sort
574
+ || url.href !== 'http://a/c%20d?a=1&c=3'
575
+ || params.get('c') !== '3'
576
+ || String(new URLSearchParams('?a=1')) !== 'a=1'
577
+ || !params[ITERATOR$3]
578
+ // throws in Edge
579
+ || new URL('https://a@b').username !== 'a'
580
+ || new URLSearchParams(new URLSearchParams('a=b')).get('a') !== 'b'
581
+ // not punycoded in Edge
582
+ || new URL('http://тест').host !== 'xn--e1aybc'
583
+ // not escaped in Chrome 62-
584
+ || new URL('http://a#б').hash !== '#%D0%B1'
585
+ // fails in Chrome 66-
586
+ || result !== 'a1c3'
587
+ // throws in Safari
588
+ || new URL('http://x', undefined).host !== 'x';
589
+ });
590
+
591
+ var classofRaw = classofRaw$1;
592
+ var uncurryThis$8 = functionUncurryThis;
593
+
594
+ var functionUncurryThisClause = function (fn) {
595
+ // Nashorn bug:
596
+ // https://github.com/zloirock/core-js/issues/1128
597
+ // https://github.com/zloirock/core-js/issues/1130
598
+ if (classofRaw(fn) === 'Function') return uncurryThis$8(fn);
599
+ };
600
+
601
+ var uncurryThis$7 = functionUncurryThisClause;
602
+ var aCallable$1 = aCallable$2;
603
+ var NATIVE_BIND = functionBindNative;
604
+
605
+ var bind$3 = uncurryThis$7(uncurryThis$7.bind);
606
+
607
+ // optional / simple context binding
608
+ var functionBindContext = function (fn, that) {
609
+ aCallable$1(fn);
610
+ return that === undefined ? fn : NATIVE_BIND ? bind$3(fn, that) : function (/* ...args */) {
611
+ return fn.apply(that, arguments);
612
+ };
613
+ };
614
+
615
+ var makeBuiltIn = makeBuiltInExports;
616
+ var defineProperty = objectDefineProperty;
617
+
618
+ var defineBuiltInAccessor$3 = function (target, name, descriptor) {
619
+ if (descriptor.get) makeBuiltIn(descriptor.get, name, { getter: true });
620
+ if (descriptor.set) makeBuiltIn(descriptor.set, name, { setter: true });
621
+ return defineProperty.f(target, name, descriptor);
622
+ };
623
+
624
+ var isPrototypeOf = objectIsPrototypeOf;
625
+
626
+ var $TypeError$2 = TypeError;
627
+
628
+ var anInstance$2 = function (it, Prototype) {
629
+ if (isPrototypeOf(Prototype, it)) return it;
630
+ throw new $TypeError$2('Incorrect invocation');
631
+ };
632
+
633
+ var call$4 = functionCall;
634
+ var anObject$3 = anObject$4;
635
+ var getMethod$1 = getMethod$2;
636
+
637
+ var iteratorClose$1 = function (iterator, kind, value) {
638
+ var innerResult, innerError;
639
+ anObject$3(iterator);
640
+ try {
641
+ innerResult = getMethod$1(iterator, 'return');
642
+ if (!innerResult) {
643
+ if (kind === 'throw') throw value;
644
+ return value;
645
+ }
646
+ innerResult = call$4(innerResult, iterator);
647
+ } catch (error) {
648
+ innerError = true;
649
+ innerResult = error;
650
+ }
651
+ if (kind === 'throw') throw value;
652
+ if (innerError) throw innerResult;
653
+ anObject$3(innerResult);
654
+ return value;
655
+ };
656
+
657
+ var anObject$2 = anObject$4;
658
+ var iteratorClose = iteratorClose$1;
659
+
660
+ // call something on iterator step with safe closing on error
661
+ var callWithSafeIterationClosing$1 = function (iterator, fn, value, ENTRIES) {
662
+ try {
663
+ return ENTRIES ? fn(anObject$2(value)[0], value[1]) : fn(value);
664
+ } catch (error) {
665
+ iteratorClose(iterator, 'throw', error);
666
+ }
667
+ };
668
+
669
+ var wellKnownSymbol$2 = wellKnownSymbol$4;
670
+ var Iterators$1 = iterators;
671
+
672
+ var ITERATOR$2 = wellKnownSymbol$2('iterator');
673
+ var ArrayPrototype = Array.prototype;
674
+
675
+ // check on default Array iterator
676
+ var isArrayIteratorMethod$1 = function (it) {
677
+ return it !== undefined && (Iterators$1.Array === it || ArrayPrototype[ITERATOR$2] === it);
678
+ };
679
+
680
+ var uncurryThis$6 = functionUncurryThis;
681
+ var fails = fails$2;
682
+ var isCallable$1 = isCallable$2;
683
+ var classof$2 = classof$3;
684
+ var getBuiltIn = getBuiltIn$1;
685
+ var inspectSource = inspectSource$1;
686
+
687
+ var noop = function () { /* empty */ };
688
+ var construct = getBuiltIn('Reflect', 'construct');
689
+ var constructorRegExp = /^\s*(?:class|function)\b/;
690
+ var exec$2 = uncurryThis$6(constructorRegExp.exec);
691
+ var INCORRECT_TO_STRING = !constructorRegExp.test(noop);
692
+
693
+ var isConstructorModern = function isConstructor(argument) {
694
+ if (!isCallable$1(argument)) return false;
695
+ try {
696
+ construct(noop, [], argument);
697
+ return true;
698
+ } catch (error) {
699
+ return false;
700
+ }
701
+ };
702
+
703
+ var isConstructorLegacy = function isConstructor(argument) {
704
+ if (!isCallable$1(argument)) return false;
705
+ switch (classof$2(argument)) {
706
+ case 'AsyncFunction':
707
+ case 'GeneratorFunction':
708
+ case 'AsyncGeneratorFunction': return false;
709
+ }
710
+ try {
711
+ // we can't check .prototype since constructors produced by .bind haven't it
712
+ // `Function#toString` throws on some built-it function in some legacy engines
713
+ // (for example, `DOMQuad` and similar in FF41-)
714
+ return INCORRECT_TO_STRING || !!exec$2(constructorRegExp, inspectSource(argument));
715
+ } catch (error) {
716
+ return true;
717
+ }
718
+ };
719
+
720
+ isConstructorLegacy.sham = true;
721
+
722
+ // `IsConstructor` abstract operation
723
+ // https://tc39.es/ecma262/#sec-isconstructor
724
+ var isConstructor$1 = !construct || fails(function () {
725
+ var called;
726
+ return isConstructorModern(isConstructorModern.call)
727
+ || !isConstructorModern(Object)
728
+ || !isConstructorModern(function () { called = true; })
729
+ || called;
730
+ }) ? isConstructorLegacy : isConstructorModern;
731
+
732
+ var DESCRIPTORS$4 = descriptors;
733
+ var definePropertyModule = objectDefineProperty;
734
+ var createPropertyDescriptor$1 = createPropertyDescriptor$2;
735
+
736
+ var createProperty$1 = function (object, key, value) {
737
+ if (DESCRIPTORS$4) definePropertyModule.f(object, key, createPropertyDescriptor$1(0, value));
738
+ else object[key] = value;
739
+ };
740
+
741
+ var classof$1 = classof$3;
742
+ var getMethod = getMethod$2;
743
+ var isNullOrUndefined = isNullOrUndefined$1;
744
+ var Iterators = iterators;
745
+ var wellKnownSymbol$1 = wellKnownSymbol$4;
746
+
747
+ var ITERATOR$1 = wellKnownSymbol$1('iterator');
748
+
749
+ var getIteratorMethod$3 = function (it) {
750
+ if (!isNullOrUndefined(it)) return getMethod(it, ITERATOR$1)
751
+ || getMethod(it, '@@iterator')
752
+ || Iterators[classof$1(it)];
753
+ };
754
+
755
+ var call$3 = functionCall;
756
+ var aCallable = aCallable$2;
757
+ var anObject$1 = anObject$4;
758
+ var tryToString = tryToString$1;
759
+ var getIteratorMethod$2 = getIteratorMethod$3;
760
+
761
+ var $TypeError$1 = TypeError;
762
+
763
+ var getIterator$2 = function (argument, usingIterator) {
764
+ var iteratorMethod = arguments.length < 2 ? getIteratorMethod$2(argument) : usingIterator;
765
+ if (aCallable(iteratorMethod)) return anObject$1(call$3(iteratorMethod, argument));
766
+ throw new $TypeError$1(tryToString(argument) + ' is not iterable');
767
+ };
768
+
769
+ var bind$2 = functionBindContext;
770
+ var call$2 = functionCall;
771
+ var toObject = toObject$1;
772
+ var callWithSafeIterationClosing = callWithSafeIterationClosing$1;
773
+ var isArrayIteratorMethod = isArrayIteratorMethod$1;
774
+ var isConstructor = isConstructor$1;
775
+ var lengthOfArrayLike = lengthOfArrayLike$1;
776
+ var createProperty = createProperty$1;
777
+ var getIterator$1 = getIterator$2;
778
+ var getIteratorMethod$1 = getIteratorMethod$3;
779
+
780
+ var $Array = Array;
781
+
782
+ // `Array.from` method implementation
783
+ // https://tc39.es/ecma262/#sec-array.from
784
+ var arrayFrom$1 = function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
785
+ var O = toObject(arrayLike);
786
+ var IS_CONSTRUCTOR = isConstructor(this);
787
+ var argumentsLength = arguments.length;
788
+ var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
789
+ var mapping = mapfn !== undefined;
790
+ if (mapping) mapfn = bind$2(mapfn, argumentsLength > 2 ? arguments[2] : undefined);
791
+ var iteratorMethod = getIteratorMethod$1(O);
792
+ var index = 0;
793
+ var length, result, step, iterator, next, value;
794
+ // if the target is not iterable or it's an array with the default iterator - use a simple case
795
+ if (iteratorMethod && !(this === $Array && isArrayIteratorMethod(iteratorMethod))) {
796
+ result = IS_CONSTRUCTOR ? new this() : [];
797
+ iterator = getIterator$1(O, iteratorMethod);
798
+ next = iterator.next;
799
+ for (;!(step = call$2(next, iterator)).done; index++) {
800
+ value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [step.value, index], true) : step.value;
801
+ createProperty(result, index, value);
802
+ }
803
+ } else {
804
+ length = lengthOfArrayLike(O);
805
+ result = IS_CONSTRUCTOR ? new this(length) : $Array(length);
806
+ for (;length > index; index++) {
807
+ value = mapping ? mapfn(O[index], index) : O[index];
808
+ createProperty(result, index, value);
809
+ }
810
+ }
811
+ result.length = index;
812
+ return result;
813
+ };
814
+
815
+ // based on https://github.com/bestiejs/punycode.js/blob/master/punycode.js
816
+ var uncurryThis$5 = functionUncurryThis;
817
+
818
+ var maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
819
+ var base = 36;
820
+ var tMin = 1;
821
+ var tMax = 26;
822
+ var skew = 38;
823
+ var damp = 700;
824
+ var initialBias = 72;
825
+ var initialN = 128; // 0x80
826
+ var delimiter = '-'; // '\x2D'
827
+ var regexNonASCII = /[^\0-\u007E]/; // non-ASCII chars
828
+ var regexSeparators = /[.\u3002\uFF0E\uFF61]/g; // RFC 3490 separators
829
+ var OVERFLOW_ERROR = 'Overflow: input needs wider integers to process';
830
+ var baseMinusTMin = base - tMin;
831
+
832
+ var $RangeError = RangeError;
833
+ var exec$1 = uncurryThis$5(regexSeparators.exec);
834
+ var floor$2 = Math.floor;
835
+ var fromCharCode = String.fromCharCode;
836
+ var charCodeAt = uncurryThis$5(''.charCodeAt);
837
+ var join$2 = uncurryThis$5([].join);
838
+ var push$3 = uncurryThis$5([].push);
839
+ var replace$2 = uncurryThis$5(''.replace);
840
+ var split$2 = uncurryThis$5(''.split);
841
+ var toLowerCase$1 = uncurryThis$5(''.toLowerCase);
842
+
843
+ /**
844
+ * Creates an array containing the numeric code points of each Unicode
845
+ * character in the string. While JavaScript uses UCS-2 internally,
846
+ * this function will convert a pair of surrogate halves (each of which
847
+ * UCS-2 exposes as separate characters) into a single code point,
848
+ * matching UTF-16.
849
+ */
850
+ var ucs2decode = function (string) {
851
+ var output = [];
852
+ var counter = 0;
853
+ var length = string.length;
854
+ while (counter < length) {
855
+ var value = charCodeAt(string, counter++);
856
+ if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
857
+ // It's a high surrogate, and there is a next character.
858
+ var extra = charCodeAt(string, counter++);
859
+ if ((extra & 0xFC00) === 0xDC00) { // Low surrogate.
860
+ push$3(output, ((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
861
+ } else {
862
+ // It's an unmatched surrogate; only append this code unit, in case the
863
+ // next code unit is the high surrogate of a surrogate pair.
864
+ push$3(output, value);
865
+ counter--;
866
+ }
867
+ } else {
868
+ push$3(output, value);
869
+ }
870
+ }
871
+ return output;
872
+ };
873
+
874
+ /**
875
+ * Converts a digit/integer into a basic code point.
876
+ */
877
+ var digitToBasic = function (digit) {
878
+ // 0..25 map to ASCII a..z or A..Z
879
+ // 26..35 map to ASCII 0..9
880
+ return digit + 22 + 75 * (digit < 26);
881
+ };
882
+
883
+ /**
884
+ * Bias adaptation function as per section 3.4 of RFC 3492.
885
+ * https://tools.ietf.org/html/rfc3492#section-3.4
886
+ */
887
+ var adapt = function (delta, numPoints, firstTime) {
888
+ var k = 0;
889
+ delta = firstTime ? floor$2(delta / damp) : delta >> 1;
890
+ delta += floor$2(delta / numPoints);
891
+ while (delta > baseMinusTMin * tMax >> 1) {
892
+ delta = floor$2(delta / baseMinusTMin);
893
+ k += base;
894
+ }
895
+ return floor$2(k + (baseMinusTMin + 1) * delta / (delta + skew));
896
+ };
897
+
898
+ /**
899
+ * Converts a string of Unicode symbols (e.g. a domain name label) to a
900
+ * Punycode string of ASCII-only symbols.
901
+ */
902
+ var encode = function (input) {
903
+ var output = [];
904
+
905
+ // Convert the input in UCS-2 to an array of Unicode code points.
906
+ input = ucs2decode(input);
907
+
908
+ // Cache the length.
909
+ var inputLength = input.length;
910
+
911
+ // Initialize the state.
912
+ var n = initialN;
913
+ var delta = 0;
914
+ var bias = initialBias;
915
+ var i, currentValue;
916
+
917
+ // Handle the basic code points.
918
+ for (i = 0; i < input.length; i++) {
919
+ currentValue = input[i];
920
+ if (currentValue < 0x80) {
921
+ push$3(output, fromCharCode(currentValue));
922
+ }
923
+ }
924
+
925
+ var basicLength = output.length; // number of basic code points.
926
+ var handledCPCount = basicLength; // number of code points that have been handled;
927
+
928
+ // Finish the basic string with a delimiter unless it's empty.
929
+ if (basicLength) {
930
+ push$3(output, delimiter);
931
+ }
932
+
933
+ // Main encoding loop:
934
+ while (handledCPCount < inputLength) {
935
+ // All non-basic code points < n have been handled already. Find the next larger one:
936
+ var m = maxInt;
937
+ for (i = 0; i < input.length; i++) {
938
+ currentValue = input[i];
939
+ if (currentValue >= n && currentValue < m) {
940
+ m = currentValue;
941
+ }
942
+ }
943
+
944
+ // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>, but guard against overflow.
945
+ var handledCPCountPlusOne = handledCPCount + 1;
946
+ if (m - n > floor$2((maxInt - delta) / handledCPCountPlusOne)) {
947
+ throw new $RangeError(OVERFLOW_ERROR);
948
+ }
949
+
950
+ delta += (m - n) * handledCPCountPlusOne;
951
+ n = m;
952
+
953
+ for (i = 0; i < input.length; i++) {
954
+ currentValue = input[i];
955
+ if (currentValue < n && ++delta > maxInt) {
956
+ throw new $RangeError(OVERFLOW_ERROR);
957
+ }
958
+ if (currentValue === n) {
959
+ // Represent delta as a generalized variable-length integer.
960
+ var q = delta;
961
+ var k = base;
962
+ while (true) {
963
+ var t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
964
+ if (q < t) break;
965
+ var qMinusT = q - t;
966
+ var baseMinusT = base - t;
967
+ push$3(output, fromCharCode(digitToBasic(t + qMinusT % baseMinusT)));
968
+ q = floor$2(qMinusT / baseMinusT);
969
+ k += base;
970
+ }
971
+
972
+ push$3(output, fromCharCode(digitToBasic(q)));
973
+ bias = adapt(delta, handledCPCountPlusOne, handledCPCount === basicLength);
974
+ delta = 0;
975
+ handledCPCount++;
976
+ }
977
+ }
978
+
979
+ delta++;
980
+ n++;
981
+ }
982
+ return join$2(output, '');
983
+ };
984
+
985
+ var stringPunycodeToAscii = function (input) {
986
+ var encoded = [];
987
+ var labels = split$2(replace$2(toLowerCase$1(input), regexSeparators, '\u002E'), '.');
988
+ var i, label;
989
+ for (i = 0; i < labels.length; i++) {
990
+ label = labels[i];
991
+ push$3(encoded, exec$1(regexNonASCII, label) ? 'xn--' + encode(label) : label);
992
+ }
993
+ return join$2(encoded, '.');
994
+ };
995
+
996
+ var $TypeError = TypeError;
997
+
998
+ var validateArgumentsLength$4 = function (passed, required) {
999
+ if (passed < required) throw new $TypeError('Not enough arguments');
1000
+ return passed;
1001
+ };
1002
+
1003
+ var global$2 = global$3;
1004
+ var DESCRIPTORS$3 = descriptors;
1005
+
1006
+ // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
1007
+ var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
1008
+
1009
+ // Avoid NodeJS experimental warning
1010
+ var safeGetBuiltIn$1 = function (name) {
1011
+ if (!DESCRIPTORS$3) return global$2[name];
1012
+ var descriptor = getOwnPropertyDescriptor(global$2, name);
1013
+ return descriptor && descriptor.value;
1014
+ };
1015
+
1016
+ var defineBuiltIn$4 = defineBuiltIn$5;
1017
+
1018
+ var defineBuiltIns$1 = function (target, src, options) {
1019
+ for (var key in src) defineBuiltIn$4(target, key, src[key], options);
1020
+ return target;
1021
+ };
1022
+
1023
+ var arraySlice$1 = arraySlice$2;
1024
+
1025
+ var floor$1 = Math.floor;
1026
+
1027
+ var sort = function (array, comparefn) {
1028
+ var length = array.length;
1029
+
1030
+ if (length < 8) {
1031
+ // insertion sort
1032
+ var i = 1;
1033
+ var element, j;
1034
+
1035
+ while (i < length) {
1036
+ j = i;
1037
+ element = array[i];
1038
+ while (j && comparefn(array[j - 1], element) > 0) {
1039
+ array[j] = array[--j];
1040
+ }
1041
+ if (j !== i++) array[j] = element;
1042
+ }
1043
+ } else {
1044
+ // merge sort
1045
+ var middle = floor$1(length / 2);
1046
+ var left = sort(arraySlice$1(array, 0, middle), comparefn);
1047
+ var right = sort(arraySlice$1(array, middle), comparefn);
1048
+ var llength = left.length;
1049
+ var rlength = right.length;
1050
+ var lindex = 0;
1051
+ var rindex = 0;
1052
+
1053
+ while (lindex < llength || rindex < rlength) {
1054
+ array[lindex + rindex] = (lindex < llength && rindex < rlength)
1055
+ ? comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++]
1056
+ : lindex < llength ? left[lindex++] : right[rindex++];
1057
+ }
1058
+ }
1059
+
1060
+ return array;
1061
+ };
1062
+
1063
+ var arraySort$1 = sort;
1064
+
1065
+ // TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env`
1066
+
1067
+ var $$2 = _export;
1068
+ var global$1 = global$3;
1069
+ var safeGetBuiltIn = safeGetBuiltIn$1;
1070
+ var call$1 = functionCall;
1071
+ var uncurryThis$4 = functionUncurryThis;
1072
+ var DESCRIPTORS$2 = descriptors;
1073
+ var USE_NATIVE_URL$1 = urlConstructorDetection;
1074
+ var defineBuiltIn$3 = defineBuiltIn$5;
1075
+ var defineBuiltInAccessor$2 = defineBuiltInAccessor$3;
1076
+ var defineBuiltIns = defineBuiltIns$1;
1077
+ var setToStringTag$1 = setToStringTag$2;
1078
+ var createIteratorConstructor = iteratorCreateConstructor;
1079
+ var InternalStateModule$1 = internalState;
1080
+ var anInstance$1 = anInstance$2;
1081
+ var isCallable = isCallable$2;
1082
+ var hasOwn$1 = hasOwnProperty_1;
1083
+ var bind$1 = functionBindContext;
1084
+ var classof = classof$3;
1085
+ var anObject = anObject$4;
1086
+ var isObject = isObject$1;
1087
+ var $toString$1 = toString$4;
1088
+ var create = objectCreate;
1089
+ var createPropertyDescriptor = createPropertyDescriptor$2;
1090
+ var getIterator = getIterator$2;
1091
+ var getIteratorMethod = getIteratorMethod$3;
1092
+ var createIterResultObject = createIterResultObject$2;
1093
+ var validateArgumentsLength$3 = validateArgumentsLength$4;
1094
+ var wellKnownSymbol = wellKnownSymbol$4;
1095
+ var arraySort = arraySort$1;
1096
+
1097
+ var ITERATOR = wellKnownSymbol('iterator');
1098
+ var URL_SEARCH_PARAMS = 'URLSearchParams';
1099
+ var URL_SEARCH_PARAMS_ITERATOR = URL_SEARCH_PARAMS + 'Iterator';
1100
+ var setInternalState$1 = InternalStateModule$1.set;
1101
+ var getInternalParamsState = InternalStateModule$1.getterFor(URL_SEARCH_PARAMS);
1102
+ var getInternalIteratorState = InternalStateModule$1.getterFor(URL_SEARCH_PARAMS_ITERATOR);
1103
+
1104
+ var nativeFetch = safeGetBuiltIn('fetch');
1105
+ var NativeRequest = safeGetBuiltIn('Request');
1106
+ var Headers = safeGetBuiltIn('Headers');
1107
+ var RequestPrototype = NativeRequest && NativeRequest.prototype;
1108
+ var HeadersPrototype = Headers && Headers.prototype;
1109
+ var RegExp$1 = global$1.RegExp;
1110
+ var TypeError$2 = global$1.TypeError;
1111
+ var decodeURIComponent = global$1.decodeURIComponent;
1112
+ var encodeURIComponent$1 = global$1.encodeURIComponent;
1113
+ var charAt$1 = uncurryThis$4(''.charAt);
1114
+ var join$1 = uncurryThis$4([].join);
1115
+ var push$2 = uncurryThis$4([].push);
1116
+ var replace$1 = uncurryThis$4(''.replace);
1117
+ var shift$1 = uncurryThis$4([].shift);
1118
+ var splice = uncurryThis$4([].splice);
1119
+ var split$1 = uncurryThis$4(''.split);
1120
+ var stringSlice$1 = uncurryThis$4(''.slice);
1121
+
1122
+ var plus = /\+/g;
1123
+ var sequences = Array(4);
1124
+
1125
+ var percentSequence = function (bytes) {
1126
+ return sequences[bytes - 1] || (sequences[bytes - 1] = RegExp$1('((?:%[\\da-f]{2}){' + bytes + '})', 'gi'));
1127
+ };
1128
+
1129
+ var percentDecode = function (sequence) {
1130
+ try {
1131
+ return decodeURIComponent(sequence);
1132
+ } catch (error) {
1133
+ return sequence;
1134
+ }
1135
+ };
1136
+
1137
+ var deserialize = function (it) {
1138
+ var result = replace$1(it, plus, ' ');
1139
+ var bytes = 4;
1140
+ try {
1141
+ return decodeURIComponent(result);
1142
+ } catch (error) {
1143
+ while (bytes) {
1144
+ result = replace$1(result, percentSequence(bytes--), percentDecode);
1145
+ }
1146
+ return result;
1147
+ }
1148
+ };
1149
+
1150
+ var find = /[!'()~]|%20/g;
1151
+
1152
+ var replacements = {
1153
+ '!': '%21',
1154
+ "'": '%27',
1155
+ '(': '%28',
1156
+ ')': '%29',
1157
+ '~': '%7E',
1158
+ '%20': '+'
1159
+ };
1160
+
1161
+ var replacer = function (match) {
1162
+ return replacements[match];
1163
+ };
1164
+
1165
+ var serialize = function (it) {
1166
+ return replace$1(encodeURIComponent$1(it), find, replacer);
1167
+ };
1168
+
1169
+ var URLSearchParamsIterator = createIteratorConstructor(function Iterator(params, kind) {
1170
+ setInternalState$1(this, {
1171
+ type: URL_SEARCH_PARAMS_ITERATOR,
1172
+ target: getInternalParamsState(params).entries,
1173
+ index: 0,
1174
+ kind: kind
1175
+ });
1176
+ }, URL_SEARCH_PARAMS, function next() {
1177
+ var state = getInternalIteratorState(this);
1178
+ var target = state.target;
1179
+ var index = state.index++;
1180
+ if (!target || index >= target.length) {
1181
+ state.target = undefined;
1182
+ return createIterResultObject(undefined, true);
1183
+ }
1184
+ var entry = target[index];
1185
+ switch (state.kind) {
1186
+ case 'keys': return createIterResultObject(entry.key, false);
1187
+ case 'values': return createIterResultObject(entry.value, false);
1188
+ } return createIterResultObject([entry.key, entry.value], false);
1189
+ }, true);
1190
+
1191
+ var URLSearchParamsState = function (init) {
1192
+ this.entries = [];
1193
+ this.url = null;
1194
+
1195
+ if (init !== undefined) {
1196
+ if (isObject(init)) this.parseObject(init);
1197
+ else this.parseQuery(typeof init == 'string' ? charAt$1(init, 0) === '?' ? stringSlice$1(init, 1) : init : $toString$1(init));
1198
+ }
1199
+ };
1200
+
1201
+ URLSearchParamsState.prototype = {
1202
+ type: URL_SEARCH_PARAMS,
1203
+ bindURL: function (url) {
1204
+ this.url = url;
1205
+ this.update();
1206
+ },
1207
+ parseObject: function (object) {
1208
+ var entries = this.entries;
1209
+ var iteratorMethod = getIteratorMethod(object);
1210
+ var iterator, next, step, entryIterator, entryNext, first, second;
1211
+
1212
+ if (iteratorMethod) {
1213
+ iterator = getIterator(object, iteratorMethod);
1214
+ next = iterator.next;
1215
+ while (!(step = call$1(next, iterator)).done) {
1216
+ entryIterator = getIterator(anObject(step.value));
1217
+ entryNext = entryIterator.next;
1218
+ if (
1219
+ (first = call$1(entryNext, entryIterator)).done ||
1220
+ (second = call$1(entryNext, entryIterator)).done ||
1221
+ !call$1(entryNext, entryIterator).done
1222
+ ) throw new TypeError$2('Expected sequence with length 2');
1223
+ push$2(entries, { key: $toString$1(first.value), value: $toString$1(second.value) });
1224
+ }
1225
+ } else for (var key in object) if (hasOwn$1(object, key)) {
1226
+ push$2(entries, { key: key, value: $toString$1(object[key]) });
1227
+ }
1228
+ },
1229
+ parseQuery: function (query) {
1230
+ if (query) {
1231
+ var entries = this.entries;
1232
+ var attributes = split$1(query, '&');
1233
+ var index = 0;
1234
+ var attribute, entry;
1235
+ while (index < attributes.length) {
1236
+ attribute = attributes[index++];
1237
+ if (attribute.length) {
1238
+ entry = split$1(attribute, '=');
1239
+ push$2(entries, {
1240
+ key: deserialize(shift$1(entry)),
1241
+ value: deserialize(join$1(entry, '='))
1242
+ });
1243
+ }
1244
+ }
1245
+ }
1246
+ },
1247
+ serialize: function () {
1248
+ var entries = this.entries;
1249
+ var result = [];
1250
+ var index = 0;
1251
+ var entry;
1252
+ while (index < entries.length) {
1253
+ entry = entries[index++];
1254
+ push$2(result, serialize(entry.key) + '=' + serialize(entry.value));
1255
+ } return join$1(result, '&');
1256
+ },
1257
+ update: function () {
1258
+ this.entries.length = 0;
1259
+ this.parseQuery(this.url.query);
1260
+ },
1261
+ updateURL: function () {
1262
+ if (this.url) this.url.update();
1263
+ }
1264
+ };
1265
+
1266
+ // `URLSearchParams` constructor
1267
+ // https://url.spec.whatwg.org/#interface-urlsearchparams
1268
+ var URLSearchParamsConstructor = function URLSearchParams(/* init */) {
1269
+ anInstance$1(this, URLSearchParamsPrototype$3);
1270
+ var init = arguments.length > 0 ? arguments[0] : undefined;
1271
+ var state = setInternalState$1(this, new URLSearchParamsState(init));
1272
+ if (!DESCRIPTORS$2) this.size = state.entries.length;
1273
+ };
1274
+
1275
+ var URLSearchParamsPrototype$3 = URLSearchParamsConstructor.prototype;
1276
+
1277
+ defineBuiltIns(URLSearchParamsPrototype$3, {
1278
+ // `URLSearchParams.prototype.append` method
1279
+ // https://url.spec.whatwg.org/#dom-urlsearchparams-append
1280
+ append: function append(name, value) {
1281
+ var state = getInternalParamsState(this);
1282
+ validateArgumentsLength$3(arguments.length, 2);
1283
+ push$2(state.entries, { key: $toString$1(name), value: $toString$1(value) });
1284
+ if (!DESCRIPTORS$2) this.length++;
1285
+ state.updateURL();
1286
+ },
1287
+ // `URLSearchParams.prototype.delete` method
1288
+ // https://url.spec.whatwg.org/#dom-urlsearchparams-delete
1289
+ 'delete': function (name /* , value */) {
1290
+ var state = getInternalParamsState(this);
1291
+ var length = validateArgumentsLength$3(arguments.length, 1);
1292
+ var entries = state.entries;
1293
+ var key = $toString$1(name);
1294
+ var $value = length < 2 ? undefined : arguments[1];
1295
+ var value = $value === undefined ? $value : $toString$1($value);
1296
+ var index = 0;
1297
+ while (index < entries.length) {
1298
+ var entry = entries[index];
1299
+ if (entry.key === key && (value === undefined || entry.value === value)) {
1300
+ splice(entries, index, 1);
1301
+ if (value !== undefined) break;
1302
+ } else index++;
1303
+ }
1304
+ if (!DESCRIPTORS$2) this.size = entries.length;
1305
+ state.updateURL();
1306
+ },
1307
+ // `URLSearchParams.prototype.get` method
1308
+ // https://url.spec.whatwg.org/#dom-urlsearchparams-get
1309
+ get: function get(name) {
1310
+ var entries = getInternalParamsState(this).entries;
1311
+ validateArgumentsLength$3(arguments.length, 1);
1312
+ var key = $toString$1(name);
1313
+ var index = 0;
1314
+ for (; index < entries.length; index++) {
1315
+ if (entries[index].key === key) return entries[index].value;
1316
+ }
1317
+ return null;
1318
+ },
1319
+ // `URLSearchParams.prototype.getAll` method
1320
+ // https://url.spec.whatwg.org/#dom-urlsearchparams-getall
1321
+ getAll: function getAll(name) {
1322
+ var entries = getInternalParamsState(this).entries;
1323
+ validateArgumentsLength$3(arguments.length, 1);
1324
+ var key = $toString$1(name);
1325
+ var result = [];
1326
+ var index = 0;
1327
+ for (; index < entries.length; index++) {
1328
+ if (entries[index].key === key) push$2(result, entries[index].value);
1329
+ }
1330
+ return result;
1331
+ },
1332
+ // `URLSearchParams.prototype.has` method
1333
+ // https://url.spec.whatwg.org/#dom-urlsearchparams-has
1334
+ has: function has(name /* , value */) {
1335
+ var entries = getInternalParamsState(this).entries;
1336
+ var length = validateArgumentsLength$3(arguments.length, 1);
1337
+ var key = $toString$1(name);
1338
+ var $value = length < 2 ? undefined : arguments[1];
1339
+ var value = $value === undefined ? $value : $toString$1($value);
1340
+ var index = 0;
1341
+ while (index < entries.length) {
1342
+ var entry = entries[index++];
1343
+ if (entry.key === key && (value === undefined || entry.value === value)) return true;
1344
+ }
1345
+ return false;
1346
+ },
1347
+ // `URLSearchParams.prototype.set` method
1348
+ // https://url.spec.whatwg.org/#dom-urlsearchparams-set
1349
+ set: function set(name, value) {
1350
+ var state = getInternalParamsState(this);
1351
+ validateArgumentsLength$3(arguments.length, 1);
1352
+ var entries = state.entries;
1353
+ var found = false;
1354
+ var key = $toString$1(name);
1355
+ var val = $toString$1(value);
1356
+ var index = 0;
1357
+ var entry;
1358
+ for (; index < entries.length; index++) {
1359
+ entry = entries[index];
1360
+ if (entry.key === key) {
1361
+ if (found) splice(entries, index--, 1);
1362
+ else {
1363
+ found = true;
1364
+ entry.value = val;
1365
+ }
1366
+ }
1367
+ }
1368
+ if (!found) push$2(entries, { key: key, value: val });
1369
+ if (!DESCRIPTORS$2) this.size = entries.length;
1370
+ state.updateURL();
1371
+ },
1372
+ // `URLSearchParams.prototype.sort` method
1373
+ // https://url.spec.whatwg.org/#dom-urlsearchparams-sort
1374
+ sort: function sort() {
1375
+ var state = getInternalParamsState(this);
1376
+ arraySort(state.entries, function (a, b) {
1377
+ return a.key > b.key ? 1 : -1;
1378
+ });
1379
+ state.updateURL();
1380
+ },
1381
+ // `URLSearchParams.prototype.forEach` method
1382
+ forEach: function forEach(callback /* , thisArg */) {
1383
+ var entries = getInternalParamsState(this).entries;
1384
+ var boundFunction = bind$1(callback, arguments.length > 1 ? arguments[1] : undefined);
1385
+ var index = 0;
1386
+ var entry;
1387
+ while (index < entries.length) {
1388
+ entry = entries[index++];
1389
+ boundFunction(entry.value, entry.key, this);
1390
+ }
1391
+ },
1392
+ // `URLSearchParams.prototype.keys` method
1393
+ keys: function keys() {
1394
+ return new URLSearchParamsIterator(this, 'keys');
1395
+ },
1396
+ // `URLSearchParams.prototype.values` method
1397
+ values: function values() {
1398
+ return new URLSearchParamsIterator(this, 'values');
1399
+ },
1400
+ // `URLSearchParams.prototype.entries` method
1401
+ entries: function entries() {
1402
+ return new URLSearchParamsIterator(this, 'entries');
1403
+ }
1404
+ }, { enumerable: true });
1405
+
1406
+ // `URLSearchParams.prototype[@@iterator]` method
1407
+ defineBuiltIn$3(URLSearchParamsPrototype$3, ITERATOR, URLSearchParamsPrototype$3.entries, { name: 'entries' });
1408
+
1409
+ // `URLSearchParams.prototype.toString` method
1410
+ // https://url.spec.whatwg.org/#urlsearchparams-stringification-behavior
1411
+ defineBuiltIn$3(URLSearchParamsPrototype$3, 'toString', function toString() {
1412
+ return getInternalParamsState(this).serialize();
1413
+ }, { enumerable: true });
1414
+
1415
+ // `URLSearchParams.prototype.size` getter
1416
+ // https://github.com/whatwg/url/pull/734
1417
+ if (DESCRIPTORS$2) defineBuiltInAccessor$2(URLSearchParamsPrototype$3, 'size', {
1418
+ get: function size() {
1419
+ return getInternalParamsState(this).entries.length;
1420
+ },
1421
+ configurable: true,
1422
+ enumerable: true
1423
+ });
1424
+
1425
+ setToStringTag$1(URLSearchParamsConstructor, URL_SEARCH_PARAMS);
1426
+
1427
+ $$2({ global: true, constructor: true, forced: !USE_NATIVE_URL$1 }, {
1428
+ URLSearchParams: URLSearchParamsConstructor
1429
+ });
1430
+
1431
+ // Wrap `fetch` and `Request` for correct work with polyfilled `URLSearchParams`
1432
+ if (!USE_NATIVE_URL$1 && isCallable(Headers)) {
1433
+ var headersHas = uncurryThis$4(HeadersPrototype.has);
1434
+ var headersSet = uncurryThis$4(HeadersPrototype.set);
1435
+
1436
+ var wrapRequestOptions = function (init) {
1437
+ if (isObject(init)) {
1438
+ var body = init.body;
1439
+ var headers;
1440
+ if (classof(body) === URL_SEARCH_PARAMS) {
1441
+ headers = init.headers ? new Headers(init.headers) : new Headers();
1442
+ if (!headersHas(headers, 'content-type')) {
1443
+ headersSet(headers, 'content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
1444
+ }
1445
+ return create(init, {
1446
+ body: createPropertyDescriptor(0, $toString$1(body)),
1447
+ headers: createPropertyDescriptor(0, headers)
1448
+ });
1449
+ }
1450
+ } return init;
1451
+ };
1452
+
1453
+ if (isCallable(nativeFetch)) {
1454
+ $$2({ global: true, enumerable: true, dontCallGetSet: true, forced: true }, {
1455
+ fetch: function fetch(input /* , init */) {
1456
+ return nativeFetch(input, arguments.length > 1 ? wrapRequestOptions(arguments[1]) : {});
1457
+ }
1458
+ });
1459
+ }
1460
+
1461
+ if (isCallable(NativeRequest)) {
1462
+ var RequestConstructor = function Request(input /* , init */) {
1463
+ anInstance$1(this, RequestPrototype);
1464
+ return new NativeRequest(input, arguments.length > 1 ? wrapRequestOptions(arguments[1]) : {});
1465
+ };
1466
+
1467
+ RequestPrototype.constructor = RequestConstructor;
1468
+ RequestConstructor.prototype = RequestPrototype;
1469
+
1470
+ $$2({ global: true, constructor: true, dontCallGetSet: true, forced: true }, {
1471
+ Request: RequestConstructor
1472
+ });
1473
+ }
1474
+ }
1475
+
1476
+ var web_urlSearchParams_constructor = {
1477
+ URLSearchParams: URLSearchParamsConstructor,
1478
+ getState: getInternalParamsState
1479
+ };
1480
+
1481
+ // TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env`
1482
+
1483
+ var $$1 = _export;
1484
+ var DESCRIPTORS$1 = descriptors;
1485
+ var USE_NATIVE_URL = urlConstructorDetection;
1486
+ var global = global$3;
1487
+ var bind = functionBindContext;
1488
+ var uncurryThis$3 = functionUncurryThis;
1489
+ var defineBuiltIn$2 = defineBuiltIn$5;
1490
+ var defineBuiltInAccessor$1 = defineBuiltInAccessor$3;
1491
+ var anInstance = anInstance$2;
1492
+ var hasOwn = hasOwnProperty_1;
1493
+ var assign = objectAssign;
1494
+ var arrayFrom = arrayFrom$1;
1495
+ var arraySlice = arraySlice$2;
1496
+ var codeAt = stringMultibyte.codeAt;
1497
+ var toASCII = stringPunycodeToAscii;
1498
+ var $toString = toString$4;
1499
+ var setToStringTag = setToStringTag$2;
1500
+ var validateArgumentsLength$2 = validateArgumentsLength$4;
1501
+ var URLSearchParamsModule = web_urlSearchParams_constructor;
1502
+ var InternalStateModule = internalState;
1503
+
1504
+ var setInternalState = InternalStateModule.set;
1505
+ var getInternalURLState = InternalStateModule.getterFor('URL');
1506
+ var URLSearchParams$1 = URLSearchParamsModule.URLSearchParams;
1507
+ var getInternalSearchParamsState = URLSearchParamsModule.getState;
1508
+
1509
+ var NativeURL = global.URL;
1510
+ var TypeError$1 = global.TypeError;
1511
+ var parseInt = global.parseInt;
1512
+ var floor = Math.floor;
1513
+ var pow = Math.pow;
1514
+ var charAt = uncurryThis$3(''.charAt);
1515
+ var exec = uncurryThis$3(/./.exec);
1516
+ var join = uncurryThis$3([].join);
1517
+ var numberToString = uncurryThis$3(1.0.toString);
1518
+ var pop = uncurryThis$3([].pop);
1519
+ var push$1 = uncurryThis$3([].push);
1520
+ var replace = uncurryThis$3(''.replace);
1521
+ var shift = uncurryThis$3([].shift);
1522
+ var split = uncurryThis$3(''.split);
1523
+ var stringSlice = uncurryThis$3(''.slice);
1524
+ var toLowerCase = uncurryThis$3(''.toLowerCase);
1525
+ var unshift = uncurryThis$3([].unshift);
1526
+
1527
+ var INVALID_AUTHORITY = 'Invalid authority';
1528
+ var INVALID_SCHEME = 'Invalid scheme';
1529
+ var INVALID_HOST = 'Invalid host';
1530
+ var INVALID_PORT = 'Invalid port';
1531
+
1532
+ var ALPHA = /[a-z]/i;
1533
+ // eslint-disable-next-line regexp/no-obscure-range -- safe
1534
+ var ALPHANUMERIC = /[\d+-.a-z]/i;
1535
+ var DIGIT = /\d/;
1536
+ var HEX_START = /^0x/i;
1537
+ var OCT = /^[0-7]+$/;
1538
+ var DEC = /^\d+$/;
1539
+ var HEX = /^[\da-f]+$/i;
1540
+ /* eslint-disable regexp/no-control-character -- safe */
1541
+ var FORBIDDEN_HOST_CODE_POINT = /[\0\t\n\r #%/:<>?@[\\\]^|]/;
1542
+ var FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT = /[\0\t\n\r #/:<>?@[\\\]^|]/;
1543
+ var LEADING_C0_CONTROL_OR_SPACE = /^[\u0000-\u0020]+/;
1544
+ var TRAILING_C0_CONTROL_OR_SPACE = /(^|[^\u0000-\u0020])[\u0000-\u0020]+$/;
1545
+ var TAB_AND_NEW_LINE = /[\t\n\r]/g;
1546
+ /* eslint-enable regexp/no-control-character -- safe */
1547
+ var EOF;
1548
+
1549
+ // https://url.spec.whatwg.org/#ipv4-number-parser
1550
+ var parseIPv4 = function (input) {
1551
+ var parts = split(input, '.');
1552
+ var partsLength, numbers, index, part, radix, number, ipv4;
1553
+ if (parts.length && parts[parts.length - 1] === '') {
1554
+ parts.length--;
1555
+ }
1556
+ partsLength = parts.length;
1557
+ if (partsLength > 4) return input;
1558
+ numbers = [];
1559
+ for (index = 0; index < partsLength; index++) {
1560
+ part = parts[index];
1561
+ if (part === '') return input;
1562
+ radix = 10;
1563
+ if (part.length > 1 && charAt(part, 0) === '0') {
1564
+ radix = exec(HEX_START, part) ? 16 : 8;
1565
+ part = stringSlice(part, radix === 8 ? 1 : 2);
1566
+ }
1567
+ if (part === '') {
1568
+ number = 0;
1569
+ } else {
1570
+ if (!exec(radix === 10 ? DEC : radix === 8 ? OCT : HEX, part)) return input;
1571
+ number = parseInt(part, radix);
1572
+ }
1573
+ push$1(numbers, number);
1574
+ }
1575
+ for (index = 0; index < partsLength; index++) {
1576
+ number = numbers[index];
1577
+ if (index === partsLength - 1) {
1578
+ if (number >= pow(256, 5 - partsLength)) return null;
1579
+ } else if (number > 255) return null;
1580
+ }
1581
+ ipv4 = pop(numbers);
1582
+ for (index = 0; index < numbers.length; index++) {
1583
+ ipv4 += numbers[index] * pow(256, 3 - index);
1584
+ }
1585
+ return ipv4;
1586
+ };
1587
+
1588
+ // https://url.spec.whatwg.org/#concept-ipv6-parser
1589
+ // eslint-disable-next-line max-statements -- TODO
1590
+ var parseIPv6 = function (input) {
1591
+ var address = [0, 0, 0, 0, 0, 0, 0, 0];
1592
+ var pieceIndex = 0;
1593
+ var compress = null;
1594
+ var pointer = 0;
1595
+ var value, length, numbersSeen, ipv4Piece, number, swaps, swap;
1596
+
1597
+ var chr = function () {
1598
+ return charAt(input, pointer);
1599
+ };
1600
+
1601
+ if (chr() === ':') {
1602
+ if (charAt(input, 1) !== ':') return;
1603
+ pointer += 2;
1604
+ pieceIndex++;
1605
+ compress = pieceIndex;
1606
+ }
1607
+ while (chr()) {
1608
+ if (pieceIndex === 8) return;
1609
+ if (chr() === ':') {
1610
+ if (compress !== null) return;
1611
+ pointer++;
1612
+ pieceIndex++;
1613
+ compress = pieceIndex;
1614
+ continue;
1615
+ }
1616
+ value = length = 0;
1617
+ while (length < 4 && exec(HEX, chr())) {
1618
+ value = value * 16 + parseInt(chr(), 16);
1619
+ pointer++;
1620
+ length++;
1621
+ }
1622
+ if (chr() === '.') {
1623
+ if (length === 0) return;
1624
+ pointer -= length;
1625
+ if (pieceIndex > 6) return;
1626
+ numbersSeen = 0;
1627
+ while (chr()) {
1628
+ ipv4Piece = null;
1629
+ if (numbersSeen > 0) {
1630
+ if (chr() === '.' && numbersSeen < 4) pointer++;
1631
+ else return;
1632
+ }
1633
+ if (!exec(DIGIT, chr())) return;
1634
+ while (exec(DIGIT, chr())) {
1635
+ number = parseInt(chr(), 10);
1636
+ if (ipv4Piece === null) ipv4Piece = number;
1637
+ else if (ipv4Piece === 0) return;
1638
+ else ipv4Piece = ipv4Piece * 10 + number;
1639
+ if (ipv4Piece > 255) return;
1640
+ pointer++;
1641
+ }
1642
+ address[pieceIndex] = address[pieceIndex] * 256 + ipv4Piece;
1643
+ numbersSeen++;
1644
+ if (numbersSeen === 2 || numbersSeen === 4) pieceIndex++;
1645
+ }
1646
+ if (numbersSeen !== 4) return;
1647
+ break;
1648
+ } else if (chr() === ':') {
1649
+ pointer++;
1650
+ if (!chr()) return;
1651
+ } else if (chr()) return;
1652
+ address[pieceIndex++] = value;
1653
+ }
1654
+ if (compress !== null) {
1655
+ swaps = pieceIndex - compress;
1656
+ pieceIndex = 7;
1657
+ while (pieceIndex !== 0 && swaps > 0) {
1658
+ swap = address[pieceIndex];
1659
+ address[pieceIndex--] = address[compress + swaps - 1];
1660
+ address[compress + --swaps] = swap;
1661
+ }
1662
+ } else if (pieceIndex !== 8) return;
1663
+ return address;
1664
+ };
1665
+
1666
+ var findLongestZeroSequence = function (ipv6) {
1667
+ var maxIndex = null;
1668
+ var maxLength = 1;
1669
+ var currStart = null;
1670
+ var currLength = 0;
1671
+ var index = 0;
1672
+ for (; index < 8; index++) {
1673
+ if (ipv6[index] !== 0) {
1674
+ if (currLength > maxLength) {
1675
+ maxIndex = currStart;
1676
+ maxLength = currLength;
1677
+ }
1678
+ currStart = null;
1679
+ currLength = 0;
1680
+ } else {
1681
+ if (currStart === null) currStart = index;
1682
+ ++currLength;
1683
+ }
1684
+ }
1685
+ if (currLength > maxLength) {
1686
+ maxIndex = currStart;
1687
+ maxLength = currLength;
1688
+ }
1689
+ return maxIndex;
1690
+ };
1691
+
1692
+ // https://url.spec.whatwg.org/#host-serializing
1693
+ var serializeHost = function (host) {
1694
+ var result, index, compress, ignore0;
1695
+ // ipv4
1696
+ if (typeof host == 'number') {
1697
+ result = [];
1698
+ for (index = 0; index < 4; index++) {
1699
+ unshift(result, host % 256);
1700
+ host = floor(host / 256);
1701
+ } return join(result, '.');
1702
+ // ipv6
1703
+ } else if (typeof host == 'object') {
1704
+ result = '';
1705
+ compress = findLongestZeroSequence(host);
1706
+ for (index = 0; index < 8; index++) {
1707
+ if (ignore0 && host[index] === 0) continue;
1708
+ if (ignore0) ignore0 = false;
1709
+ if (compress === index) {
1710
+ result += index ? ':' : '::';
1711
+ ignore0 = true;
1712
+ } else {
1713
+ result += numberToString(host[index], 16);
1714
+ if (index < 7) result += ':';
1715
+ }
1716
+ }
1717
+ return '[' + result + ']';
1718
+ } return host;
1719
+ };
1720
+
1721
+ var C0ControlPercentEncodeSet = {};
1722
+ var fragmentPercentEncodeSet = assign({}, C0ControlPercentEncodeSet, {
1723
+ ' ': 1, '"': 1, '<': 1, '>': 1, '`': 1
1724
+ });
1725
+ var pathPercentEncodeSet = assign({}, fragmentPercentEncodeSet, {
1726
+ '#': 1, '?': 1, '{': 1, '}': 1
1727
+ });
1728
+ var userinfoPercentEncodeSet = assign({}, pathPercentEncodeSet, {
1729
+ '/': 1, ':': 1, ';': 1, '=': 1, '@': 1, '[': 1, '\\': 1, ']': 1, '^': 1, '|': 1
1730
+ });
1731
+
1732
+ var percentEncode = function (chr, set) {
1733
+ var code = codeAt(chr, 0);
1734
+ return code > 0x20 && code < 0x7F && !hasOwn(set, chr) ? chr : encodeURIComponent(chr);
1735
+ };
1736
+
1737
+ // https://url.spec.whatwg.org/#special-scheme
1738
+ var specialSchemes = {
1739
+ ftp: 21,
1740
+ file: null,
1741
+ http: 80,
1742
+ https: 443,
1743
+ ws: 80,
1744
+ wss: 443
1745
+ };
1746
+
1747
+ // https://url.spec.whatwg.org/#windows-drive-letter
1748
+ var isWindowsDriveLetter = function (string, normalized) {
1749
+ var second;
1750
+ return string.length === 2 && exec(ALPHA, charAt(string, 0))
1751
+ && ((second = charAt(string, 1)) === ':' || (!normalized && second === '|'));
1752
+ };
1753
+
1754
+ // https://url.spec.whatwg.org/#start-with-a-windows-drive-letter
1755
+ var startsWithWindowsDriveLetter = function (string) {
1756
+ var third;
1757
+ return string.length > 1 && isWindowsDriveLetter(stringSlice(string, 0, 2)) && (
1758
+ string.length === 2 ||
1759
+ ((third = charAt(string, 2)) === '/' || third === '\\' || third === '?' || third === '#')
1760
+ );
1761
+ };
1762
+
1763
+ // https://url.spec.whatwg.org/#single-dot-path-segment
1764
+ var isSingleDot = function (segment) {
1765
+ return segment === '.' || toLowerCase(segment) === '%2e';
1766
+ };
1767
+
1768
+ // https://url.spec.whatwg.org/#double-dot-path-segment
1769
+ var isDoubleDot = function (segment) {
1770
+ segment = toLowerCase(segment);
1771
+ return segment === '..' || segment === '%2e.' || segment === '.%2e' || segment === '%2e%2e';
1772
+ };
1773
+
1774
+ // States:
1775
+ var SCHEME_START = {};
1776
+ var SCHEME = {};
1777
+ var NO_SCHEME = {};
1778
+ var SPECIAL_RELATIVE_OR_AUTHORITY = {};
1779
+ var PATH_OR_AUTHORITY = {};
1780
+ var RELATIVE = {};
1781
+ var RELATIVE_SLASH = {};
1782
+ var SPECIAL_AUTHORITY_SLASHES = {};
1783
+ var SPECIAL_AUTHORITY_IGNORE_SLASHES = {};
1784
+ var AUTHORITY = {};
1785
+ var HOST = {};
1786
+ var HOSTNAME = {};
1787
+ var PORT = {};
1788
+ var FILE = {};
1789
+ var FILE_SLASH = {};
1790
+ var FILE_HOST = {};
1791
+ var PATH_START = {};
1792
+ var PATH = {};
1793
+ var CANNOT_BE_A_BASE_URL_PATH = {};
1794
+ var QUERY = {};
1795
+ var FRAGMENT = {};
1796
+
1797
+ var URLState = function (url, isBase, base) {
1798
+ var urlString = $toString(url);
1799
+ var baseState, failure, searchParams;
1800
+ if (isBase) {
1801
+ failure = this.parse(urlString);
1802
+ if (failure) throw new TypeError$1(failure);
1803
+ this.searchParams = null;
1804
+ } else {
1805
+ if (base !== undefined) baseState = new URLState(base, true);
1806
+ failure = this.parse(urlString, null, baseState);
1807
+ if (failure) throw new TypeError$1(failure);
1808
+ searchParams = getInternalSearchParamsState(new URLSearchParams$1());
1809
+ searchParams.bindURL(this);
1810
+ this.searchParams = searchParams;
1811
+ }
1812
+ };
1813
+
1814
+ URLState.prototype = {
1815
+ type: 'URL',
1816
+ // https://url.spec.whatwg.org/#url-parsing
1817
+ // eslint-disable-next-line max-statements -- TODO
1818
+ parse: function (input, stateOverride, base) {
1819
+ var url = this;
1820
+ var state = stateOverride || SCHEME_START;
1821
+ var pointer = 0;
1822
+ var buffer = '';
1823
+ var seenAt = false;
1824
+ var seenBracket = false;
1825
+ var seenPasswordToken = false;
1826
+ var codePoints, chr, bufferCodePoints, failure;
1827
+
1828
+ input = $toString(input);
1829
+
1830
+ if (!stateOverride) {
1831
+ url.scheme = '';
1832
+ url.username = '';
1833
+ url.password = '';
1834
+ url.host = null;
1835
+ url.port = null;
1836
+ url.path = [];
1837
+ url.query = null;
1838
+ url.fragment = null;
1839
+ url.cannotBeABaseURL = false;
1840
+ input = replace(input, LEADING_C0_CONTROL_OR_SPACE, '');
1841
+ input = replace(input, TRAILING_C0_CONTROL_OR_SPACE, '$1');
1842
+ }
1843
+
1844
+ input = replace(input, TAB_AND_NEW_LINE, '');
1845
+
1846
+ codePoints = arrayFrom(input);
1847
+
1848
+ while (pointer <= codePoints.length) {
1849
+ chr = codePoints[pointer];
1850
+ switch (state) {
1851
+ case SCHEME_START:
1852
+ if (chr && exec(ALPHA, chr)) {
1853
+ buffer += toLowerCase(chr);
1854
+ state = SCHEME;
1855
+ } else if (!stateOverride) {
1856
+ state = NO_SCHEME;
1857
+ continue;
1858
+ } else return INVALID_SCHEME;
1859
+ break;
1860
+
1861
+ case SCHEME:
1862
+ if (chr && (exec(ALPHANUMERIC, chr) || chr === '+' || chr === '-' || chr === '.')) {
1863
+ buffer += toLowerCase(chr);
1864
+ } else if (chr === ':') {
1865
+ if (stateOverride && (
1866
+ (url.isSpecial() !== hasOwn(specialSchemes, buffer)) ||
1867
+ (buffer === 'file' && (url.includesCredentials() || url.port !== null)) ||
1868
+ (url.scheme === 'file' && !url.host)
1869
+ )) return;
1870
+ url.scheme = buffer;
1871
+ if (stateOverride) {
1872
+ if (url.isSpecial() && specialSchemes[url.scheme] === url.port) url.port = null;
1873
+ return;
1874
+ }
1875
+ buffer = '';
1876
+ if (url.scheme === 'file') {
1877
+ state = FILE;
1878
+ } else if (url.isSpecial() && base && base.scheme === url.scheme) {
1879
+ state = SPECIAL_RELATIVE_OR_AUTHORITY;
1880
+ } else if (url.isSpecial()) {
1881
+ state = SPECIAL_AUTHORITY_SLASHES;
1882
+ } else if (codePoints[pointer + 1] === '/') {
1883
+ state = PATH_OR_AUTHORITY;
1884
+ pointer++;
1885
+ } else {
1886
+ url.cannotBeABaseURL = true;
1887
+ push$1(url.path, '');
1888
+ state = CANNOT_BE_A_BASE_URL_PATH;
1889
+ }
1890
+ } else if (!stateOverride) {
1891
+ buffer = '';
1892
+ state = NO_SCHEME;
1893
+ pointer = 0;
1894
+ continue;
1895
+ } else return INVALID_SCHEME;
1896
+ break;
1897
+
1898
+ case NO_SCHEME:
1899
+ if (!base || (base.cannotBeABaseURL && chr !== '#')) return INVALID_SCHEME;
1900
+ if (base.cannotBeABaseURL && chr === '#') {
1901
+ url.scheme = base.scheme;
1902
+ url.path = arraySlice(base.path);
1903
+ url.query = base.query;
1904
+ url.fragment = '';
1905
+ url.cannotBeABaseURL = true;
1906
+ state = FRAGMENT;
1907
+ break;
1908
+ }
1909
+ state = base.scheme === 'file' ? FILE : RELATIVE;
1910
+ continue;
1911
+
1912
+ case SPECIAL_RELATIVE_OR_AUTHORITY:
1913
+ if (chr === '/' && codePoints[pointer + 1] === '/') {
1914
+ state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
1915
+ pointer++;
1916
+ } else {
1917
+ state = RELATIVE;
1918
+ continue;
1919
+ } break;
1920
+
1921
+ case PATH_OR_AUTHORITY:
1922
+ if (chr === '/') {
1923
+ state = AUTHORITY;
1924
+ break;
1925
+ } else {
1926
+ state = PATH;
1927
+ continue;
1928
+ }
1929
+
1930
+ case RELATIVE:
1931
+ url.scheme = base.scheme;
1932
+ if (chr === EOF) {
1933
+ url.username = base.username;
1934
+ url.password = base.password;
1935
+ url.host = base.host;
1936
+ url.port = base.port;
1937
+ url.path = arraySlice(base.path);
1938
+ url.query = base.query;
1939
+ } else if (chr === '/' || (chr === '\\' && url.isSpecial())) {
1940
+ state = RELATIVE_SLASH;
1941
+ } else if (chr === '?') {
1942
+ url.username = base.username;
1943
+ url.password = base.password;
1944
+ url.host = base.host;
1945
+ url.port = base.port;
1946
+ url.path = arraySlice(base.path);
1947
+ url.query = '';
1948
+ state = QUERY;
1949
+ } else if (chr === '#') {
1950
+ url.username = base.username;
1951
+ url.password = base.password;
1952
+ url.host = base.host;
1953
+ url.port = base.port;
1954
+ url.path = arraySlice(base.path);
1955
+ url.query = base.query;
1956
+ url.fragment = '';
1957
+ state = FRAGMENT;
1958
+ } else {
1959
+ url.username = base.username;
1960
+ url.password = base.password;
1961
+ url.host = base.host;
1962
+ url.port = base.port;
1963
+ url.path = arraySlice(base.path);
1964
+ url.path.length--;
1965
+ state = PATH;
1966
+ continue;
1967
+ } break;
1968
+
1969
+ case RELATIVE_SLASH:
1970
+ if (url.isSpecial() && (chr === '/' || chr === '\\')) {
1971
+ state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
1972
+ } else if (chr === '/') {
1973
+ state = AUTHORITY;
1974
+ } else {
1975
+ url.username = base.username;
1976
+ url.password = base.password;
1977
+ url.host = base.host;
1978
+ url.port = base.port;
1979
+ state = PATH;
1980
+ continue;
1981
+ } break;
1982
+
1983
+ case SPECIAL_AUTHORITY_SLASHES:
1984
+ state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
1985
+ if (chr !== '/' || charAt(buffer, pointer + 1) !== '/') continue;
1986
+ pointer++;
1987
+ break;
1988
+
1989
+ case SPECIAL_AUTHORITY_IGNORE_SLASHES:
1990
+ if (chr !== '/' && chr !== '\\') {
1991
+ state = AUTHORITY;
1992
+ continue;
1993
+ } break;
1994
+
1995
+ case AUTHORITY:
1996
+ if (chr === '@') {
1997
+ if (seenAt) buffer = '%40' + buffer;
1998
+ seenAt = true;
1999
+ bufferCodePoints = arrayFrom(buffer);
2000
+ for (var i = 0; i < bufferCodePoints.length; i++) {
2001
+ var codePoint = bufferCodePoints[i];
2002
+ if (codePoint === ':' && !seenPasswordToken) {
2003
+ seenPasswordToken = true;
2004
+ continue;
2005
+ }
2006
+ var encodedCodePoints = percentEncode(codePoint, userinfoPercentEncodeSet);
2007
+ if (seenPasswordToken) url.password += encodedCodePoints;
2008
+ else url.username += encodedCodePoints;
2009
+ }
2010
+ buffer = '';
2011
+ } else if (
2012
+ chr === EOF || chr === '/' || chr === '?' || chr === '#' ||
2013
+ (chr === '\\' && url.isSpecial())
2014
+ ) {
2015
+ if (seenAt && buffer === '') return INVALID_AUTHORITY;
2016
+ pointer -= arrayFrom(buffer).length + 1;
2017
+ buffer = '';
2018
+ state = HOST;
2019
+ } else buffer += chr;
2020
+ break;
2021
+
2022
+ case HOST:
2023
+ case HOSTNAME:
2024
+ if (stateOverride && url.scheme === 'file') {
2025
+ state = FILE_HOST;
2026
+ continue;
2027
+ } else if (chr === ':' && !seenBracket) {
2028
+ if (buffer === '') return INVALID_HOST;
2029
+ failure = url.parseHost(buffer);
2030
+ if (failure) return failure;
2031
+ buffer = '';
2032
+ state = PORT;
2033
+ if (stateOverride === HOSTNAME) return;
2034
+ } else if (
2035
+ chr === EOF || chr === '/' || chr === '?' || chr === '#' ||
2036
+ (chr === '\\' && url.isSpecial())
2037
+ ) {
2038
+ if (url.isSpecial() && buffer === '') return INVALID_HOST;
2039
+ if (stateOverride && buffer === '' && (url.includesCredentials() || url.port !== null)) return;
2040
+ failure = url.parseHost(buffer);
2041
+ if (failure) return failure;
2042
+ buffer = '';
2043
+ state = PATH_START;
2044
+ if (stateOverride) return;
2045
+ continue;
2046
+ } else {
2047
+ if (chr === '[') seenBracket = true;
2048
+ else if (chr === ']') seenBracket = false;
2049
+ buffer += chr;
2050
+ } break;
2051
+
2052
+ case PORT:
2053
+ if (exec(DIGIT, chr)) {
2054
+ buffer += chr;
2055
+ } else if (
2056
+ chr === EOF || chr === '/' || chr === '?' || chr === '#' ||
2057
+ (chr === '\\' && url.isSpecial()) ||
2058
+ stateOverride
2059
+ ) {
2060
+ if (buffer !== '') {
2061
+ var port = parseInt(buffer, 10);
2062
+ if (port > 0xFFFF) return INVALID_PORT;
2063
+ url.port = (url.isSpecial() && port === specialSchemes[url.scheme]) ? null : port;
2064
+ buffer = '';
2065
+ }
2066
+ if (stateOverride) return;
2067
+ state = PATH_START;
2068
+ continue;
2069
+ } else return INVALID_PORT;
2070
+ break;
2071
+
2072
+ case FILE:
2073
+ url.scheme = 'file';
2074
+ if (chr === '/' || chr === '\\') state = FILE_SLASH;
2075
+ else if (base && base.scheme === 'file') {
2076
+ switch (chr) {
2077
+ case EOF:
2078
+ url.host = base.host;
2079
+ url.path = arraySlice(base.path);
2080
+ url.query = base.query;
2081
+ break;
2082
+ case '?':
2083
+ url.host = base.host;
2084
+ url.path = arraySlice(base.path);
2085
+ url.query = '';
2086
+ state = QUERY;
2087
+ break;
2088
+ case '#':
2089
+ url.host = base.host;
2090
+ url.path = arraySlice(base.path);
2091
+ url.query = base.query;
2092
+ url.fragment = '';
2093
+ state = FRAGMENT;
2094
+ break;
2095
+ default:
2096
+ if (!startsWithWindowsDriveLetter(join(arraySlice(codePoints, pointer), ''))) {
2097
+ url.host = base.host;
2098
+ url.path = arraySlice(base.path);
2099
+ url.shortenPath();
2100
+ }
2101
+ state = PATH;
2102
+ continue;
2103
+ }
2104
+ } else {
2105
+ state = PATH;
2106
+ continue;
2107
+ } break;
2108
+
2109
+ case FILE_SLASH:
2110
+ if (chr === '/' || chr === '\\') {
2111
+ state = FILE_HOST;
2112
+ break;
2113
+ }
2114
+ if (base && base.scheme === 'file' && !startsWithWindowsDriveLetter(join(arraySlice(codePoints, pointer), ''))) {
2115
+ if (isWindowsDriveLetter(base.path[0], true)) push$1(url.path, base.path[0]);
2116
+ else url.host = base.host;
2117
+ }
2118
+ state = PATH;
2119
+ continue;
2120
+
2121
+ case FILE_HOST:
2122
+ if (chr === EOF || chr === '/' || chr === '\\' || chr === '?' || chr === '#') {
2123
+ if (!stateOverride && isWindowsDriveLetter(buffer)) {
2124
+ state = PATH;
2125
+ } else if (buffer === '') {
2126
+ url.host = '';
2127
+ if (stateOverride) return;
2128
+ state = PATH_START;
2129
+ } else {
2130
+ failure = url.parseHost(buffer);
2131
+ if (failure) return failure;
2132
+ if (url.host === 'localhost') url.host = '';
2133
+ if (stateOverride) return;
2134
+ buffer = '';
2135
+ state = PATH_START;
2136
+ } continue;
2137
+ } else buffer += chr;
2138
+ break;
2139
+
2140
+ case PATH_START:
2141
+ if (url.isSpecial()) {
2142
+ state = PATH;
2143
+ if (chr !== '/' && chr !== '\\') continue;
2144
+ } else if (!stateOverride && chr === '?') {
2145
+ url.query = '';
2146
+ state = QUERY;
2147
+ } else if (!stateOverride && chr === '#') {
2148
+ url.fragment = '';
2149
+ state = FRAGMENT;
2150
+ } else if (chr !== EOF) {
2151
+ state = PATH;
2152
+ if (chr !== '/') continue;
2153
+ } break;
2154
+
2155
+ case PATH:
2156
+ if (
2157
+ chr === EOF || chr === '/' ||
2158
+ (chr === '\\' && url.isSpecial()) ||
2159
+ (!stateOverride && (chr === '?' || chr === '#'))
2160
+ ) {
2161
+ if (isDoubleDot(buffer)) {
2162
+ url.shortenPath();
2163
+ if (chr !== '/' && !(chr === '\\' && url.isSpecial())) {
2164
+ push$1(url.path, '');
2165
+ }
2166
+ } else if (isSingleDot(buffer)) {
2167
+ if (chr !== '/' && !(chr === '\\' && url.isSpecial())) {
2168
+ push$1(url.path, '');
2169
+ }
2170
+ } else {
2171
+ if (url.scheme === 'file' && !url.path.length && isWindowsDriveLetter(buffer)) {
2172
+ if (url.host) url.host = '';
2173
+ buffer = charAt(buffer, 0) + ':'; // normalize windows drive letter
2174
+ }
2175
+ push$1(url.path, buffer);
2176
+ }
2177
+ buffer = '';
2178
+ if (url.scheme === 'file' && (chr === EOF || chr === '?' || chr === '#')) {
2179
+ while (url.path.length > 1 && url.path[0] === '') {
2180
+ shift(url.path);
2181
+ }
2182
+ }
2183
+ if (chr === '?') {
2184
+ url.query = '';
2185
+ state = QUERY;
2186
+ } else if (chr === '#') {
2187
+ url.fragment = '';
2188
+ state = FRAGMENT;
2189
+ }
2190
+ } else {
2191
+ buffer += percentEncode(chr, pathPercentEncodeSet);
2192
+ } break;
2193
+
2194
+ case CANNOT_BE_A_BASE_URL_PATH:
2195
+ if (chr === '?') {
2196
+ url.query = '';
2197
+ state = QUERY;
2198
+ } else if (chr === '#') {
2199
+ url.fragment = '';
2200
+ state = FRAGMENT;
2201
+ } else if (chr !== EOF) {
2202
+ url.path[0] += percentEncode(chr, C0ControlPercentEncodeSet);
2203
+ } break;
2204
+
2205
+ case QUERY:
2206
+ if (!stateOverride && chr === '#') {
2207
+ url.fragment = '';
2208
+ state = FRAGMENT;
2209
+ } else if (chr !== EOF) {
2210
+ if (chr === "'" && url.isSpecial()) url.query += '%27';
2211
+ else if (chr === '#') url.query += '%23';
2212
+ else url.query += percentEncode(chr, C0ControlPercentEncodeSet);
2213
+ } break;
2214
+
2215
+ case FRAGMENT:
2216
+ if (chr !== EOF) url.fragment += percentEncode(chr, fragmentPercentEncodeSet);
2217
+ break;
2218
+ }
2219
+
2220
+ pointer++;
2221
+ }
2222
+ },
2223
+ // https://url.spec.whatwg.org/#host-parsing
2224
+ parseHost: function (input) {
2225
+ var result, codePoints, index;
2226
+ if (charAt(input, 0) === '[') {
2227
+ if (charAt(input, input.length - 1) !== ']') return INVALID_HOST;
2228
+ result = parseIPv6(stringSlice(input, 1, -1));
2229
+ if (!result) return INVALID_HOST;
2230
+ this.host = result;
2231
+ // opaque host
2232
+ } else if (!this.isSpecial()) {
2233
+ if (exec(FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT, input)) return INVALID_HOST;
2234
+ result = '';
2235
+ codePoints = arrayFrom(input);
2236
+ for (index = 0; index < codePoints.length; index++) {
2237
+ result += percentEncode(codePoints[index], C0ControlPercentEncodeSet);
2238
+ }
2239
+ this.host = result;
2240
+ } else {
2241
+ input = toASCII(input);
2242
+ if (exec(FORBIDDEN_HOST_CODE_POINT, input)) return INVALID_HOST;
2243
+ result = parseIPv4(input);
2244
+ if (result === null) return INVALID_HOST;
2245
+ this.host = result;
2246
+ }
2247
+ },
2248
+ // https://url.spec.whatwg.org/#cannot-have-a-username-password-port
2249
+ cannotHaveUsernamePasswordPort: function () {
2250
+ return !this.host || this.cannotBeABaseURL || this.scheme === 'file';
2251
+ },
2252
+ // https://url.spec.whatwg.org/#include-credentials
2253
+ includesCredentials: function () {
2254
+ return this.username !== '' || this.password !== '';
2255
+ },
2256
+ // https://url.spec.whatwg.org/#is-special
2257
+ isSpecial: function () {
2258
+ return hasOwn(specialSchemes, this.scheme);
2259
+ },
2260
+ // https://url.spec.whatwg.org/#shorten-a-urls-path
2261
+ shortenPath: function () {
2262
+ var path = this.path;
2263
+ var pathSize = path.length;
2264
+ if (pathSize && (this.scheme !== 'file' || pathSize !== 1 || !isWindowsDriveLetter(path[0], true))) {
2265
+ path.length--;
2266
+ }
2267
+ },
2268
+ // https://url.spec.whatwg.org/#concept-url-serializer
2269
+ serialize: function () {
2270
+ var url = this;
2271
+ var scheme = url.scheme;
2272
+ var username = url.username;
2273
+ var password = url.password;
2274
+ var host = url.host;
2275
+ var port = url.port;
2276
+ var path = url.path;
2277
+ var query = url.query;
2278
+ var fragment = url.fragment;
2279
+ var output = scheme + ':';
2280
+ if (host !== null) {
2281
+ output += '//';
2282
+ if (url.includesCredentials()) {
2283
+ output += username + (password ? ':' + password : '') + '@';
2284
+ }
2285
+ output += serializeHost(host);
2286
+ if (port !== null) output += ':' + port;
2287
+ } else if (scheme === 'file') output += '//';
2288
+ output += url.cannotBeABaseURL ? path[0] : path.length ? '/' + join(path, '/') : '';
2289
+ if (query !== null) output += '?' + query;
2290
+ if (fragment !== null) output += '#' + fragment;
2291
+ return output;
2292
+ },
2293
+ // https://url.spec.whatwg.org/#dom-url-href
2294
+ setHref: function (href) {
2295
+ var failure = this.parse(href);
2296
+ if (failure) throw new TypeError$1(failure);
2297
+ this.searchParams.update();
2298
+ },
2299
+ // https://url.spec.whatwg.org/#dom-url-origin
2300
+ getOrigin: function () {
2301
+ var scheme = this.scheme;
2302
+ var port = this.port;
2303
+ if (scheme === 'blob') try {
2304
+ return new URLConstructor(scheme.path[0]).origin;
2305
+ } catch (error) {
2306
+ return 'null';
2307
+ }
2308
+ if (scheme === 'file' || !this.isSpecial()) return 'null';
2309
+ return scheme + '://' + serializeHost(this.host) + (port !== null ? ':' + port : '');
2310
+ },
2311
+ // https://url.spec.whatwg.org/#dom-url-protocol
2312
+ getProtocol: function () {
2313
+ return this.scheme + ':';
2314
+ },
2315
+ setProtocol: function (protocol) {
2316
+ this.parse($toString(protocol) + ':', SCHEME_START);
2317
+ },
2318
+ // https://url.spec.whatwg.org/#dom-url-username
2319
+ getUsername: function () {
2320
+ return this.username;
2321
+ },
2322
+ setUsername: function (username) {
2323
+ var codePoints = arrayFrom($toString(username));
2324
+ if (this.cannotHaveUsernamePasswordPort()) return;
2325
+ this.username = '';
2326
+ for (var i = 0; i < codePoints.length; i++) {
2327
+ this.username += percentEncode(codePoints[i], userinfoPercentEncodeSet);
2328
+ }
2329
+ },
2330
+ // https://url.spec.whatwg.org/#dom-url-password
2331
+ getPassword: function () {
2332
+ return this.password;
2333
+ },
2334
+ setPassword: function (password) {
2335
+ var codePoints = arrayFrom($toString(password));
2336
+ if (this.cannotHaveUsernamePasswordPort()) return;
2337
+ this.password = '';
2338
+ for (var i = 0; i < codePoints.length; i++) {
2339
+ this.password += percentEncode(codePoints[i], userinfoPercentEncodeSet);
2340
+ }
2341
+ },
2342
+ // https://url.spec.whatwg.org/#dom-url-host
2343
+ getHost: function () {
2344
+ var host = this.host;
2345
+ var port = this.port;
2346
+ return host === null ? ''
2347
+ : port === null ? serializeHost(host)
2348
+ : serializeHost(host) + ':' + port;
2349
+ },
2350
+ setHost: function (host) {
2351
+ if (this.cannotBeABaseURL) return;
2352
+ this.parse(host, HOST);
2353
+ },
2354
+ // https://url.spec.whatwg.org/#dom-url-hostname
2355
+ getHostname: function () {
2356
+ var host = this.host;
2357
+ return host === null ? '' : serializeHost(host);
2358
+ },
2359
+ setHostname: function (hostname) {
2360
+ if (this.cannotBeABaseURL) return;
2361
+ this.parse(hostname, HOSTNAME);
2362
+ },
2363
+ // https://url.spec.whatwg.org/#dom-url-port
2364
+ getPort: function () {
2365
+ var port = this.port;
2366
+ return port === null ? '' : $toString(port);
2367
+ },
2368
+ setPort: function (port) {
2369
+ if (this.cannotHaveUsernamePasswordPort()) return;
2370
+ port = $toString(port);
2371
+ if (port === '') this.port = null;
2372
+ else this.parse(port, PORT);
2373
+ },
2374
+ // https://url.spec.whatwg.org/#dom-url-pathname
2375
+ getPathname: function () {
2376
+ var path = this.path;
2377
+ return this.cannotBeABaseURL ? path[0] : path.length ? '/' + join(path, '/') : '';
2378
+ },
2379
+ setPathname: function (pathname) {
2380
+ if (this.cannotBeABaseURL) return;
2381
+ this.path = [];
2382
+ this.parse(pathname, PATH_START);
2383
+ },
2384
+ // https://url.spec.whatwg.org/#dom-url-search
2385
+ getSearch: function () {
2386
+ var query = this.query;
2387
+ return query ? '?' + query : '';
2388
+ },
2389
+ setSearch: function (search) {
2390
+ search = $toString(search);
2391
+ if (search === '') {
2392
+ this.query = null;
2393
+ } else {
2394
+ if (charAt(search, 0) === '?') search = stringSlice(search, 1);
2395
+ this.query = '';
2396
+ this.parse(search, QUERY);
2397
+ }
2398
+ this.searchParams.update();
2399
+ },
2400
+ // https://url.spec.whatwg.org/#dom-url-searchparams
2401
+ getSearchParams: function () {
2402
+ return this.searchParams.facade;
2403
+ },
2404
+ // https://url.spec.whatwg.org/#dom-url-hash
2405
+ getHash: function () {
2406
+ var fragment = this.fragment;
2407
+ return fragment ? '#' + fragment : '';
2408
+ },
2409
+ setHash: function (hash) {
2410
+ hash = $toString(hash);
2411
+ if (hash === '') {
2412
+ this.fragment = null;
2413
+ return;
2414
+ }
2415
+ if (charAt(hash, 0) === '#') hash = stringSlice(hash, 1);
2416
+ this.fragment = '';
2417
+ this.parse(hash, FRAGMENT);
2418
+ },
2419
+ update: function () {
2420
+ this.query = this.searchParams.serialize() || null;
2421
+ }
2422
+ };
2423
+
2424
+ // `URL` constructor
2425
+ // https://url.spec.whatwg.org/#url-class
2426
+ var URLConstructor = function URL(url /* , base */) {
2427
+ var that = anInstance(this, URLPrototype);
2428
+ var base = validateArgumentsLength$2(arguments.length, 1) > 1 ? arguments[1] : undefined;
2429
+ var state = setInternalState(that, new URLState(url, false, base));
2430
+ if (!DESCRIPTORS$1) {
2431
+ that.href = state.serialize();
2432
+ that.origin = state.getOrigin();
2433
+ that.protocol = state.getProtocol();
2434
+ that.username = state.getUsername();
2435
+ that.password = state.getPassword();
2436
+ that.host = state.getHost();
2437
+ that.hostname = state.getHostname();
2438
+ that.port = state.getPort();
2439
+ that.pathname = state.getPathname();
2440
+ that.search = state.getSearch();
2441
+ that.searchParams = state.getSearchParams();
2442
+ that.hash = state.getHash();
2443
+ }
2444
+ };
2445
+
2446
+ var URLPrototype = URLConstructor.prototype;
2447
+
2448
+ var accessorDescriptor = function (getter, setter) {
2449
+ return {
2450
+ get: function () {
2451
+ return getInternalURLState(this)[getter]();
2452
+ },
2453
+ set: setter && function (value) {
2454
+ return getInternalURLState(this)[setter](value);
2455
+ },
2456
+ configurable: true,
2457
+ enumerable: true
2458
+ };
2459
+ };
2460
+
2461
+ if (DESCRIPTORS$1) {
2462
+ // `URL.prototype.href` accessors pair
2463
+ // https://url.spec.whatwg.org/#dom-url-href
2464
+ defineBuiltInAccessor$1(URLPrototype, 'href', accessorDescriptor('serialize', 'setHref'));
2465
+ // `URL.prototype.origin` getter
2466
+ // https://url.spec.whatwg.org/#dom-url-origin
2467
+ defineBuiltInAccessor$1(URLPrototype, 'origin', accessorDescriptor('getOrigin'));
2468
+ // `URL.prototype.protocol` accessors pair
2469
+ // https://url.spec.whatwg.org/#dom-url-protocol
2470
+ defineBuiltInAccessor$1(URLPrototype, 'protocol', accessorDescriptor('getProtocol', 'setProtocol'));
2471
+ // `URL.prototype.username` accessors pair
2472
+ // https://url.spec.whatwg.org/#dom-url-username
2473
+ defineBuiltInAccessor$1(URLPrototype, 'username', accessorDescriptor('getUsername', 'setUsername'));
2474
+ // `URL.prototype.password` accessors pair
2475
+ // https://url.spec.whatwg.org/#dom-url-password
2476
+ defineBuiltInAccessor$1(URLPrototype, 'password', accessorDescriptor('getPassword', 'setPassword'));
2477
+ // `URL.prototype.host` accessors pair
2478
+ // https://url.spec.whatwg.org/#dom-url-host
2479
+ defineBuiltInAccessor$1(URLPrototype, 'host', accessorDescriptor('getHost', 'setHost'));
2480
+ // `URL.prototype.hostname` accessors pair
2481
+ // https://url.spec.whatwg.org/#dom-url-hostname
2482
+ defineBuiltInAccessor$1(URLPrototype, 'hostname', accessorDescriptor('getHostname', 'setHostname'));
2483
+ // `URL.prototype.port` accessors pair
2484
+ // https://url.spec.whatwg.org/#dom-url-port
2485
+ defineBuiltInAccessor$1(URLPrototype, 'port', accessorDescriptor('getPort', 'setPort'));
2486
+ // `URL.prototype.pathname` accessors pair
2487
+ // https://url.spec.whatwg.org/#dom-url-pathname
2488
+ defineBuiltInAccessor$1(URLPrototype, 'pathname', accessorDescriptor('getPathname', 'setPathname'));
2489
+ // `URL.prototype.search` accessors pair
2490
+ // https://url.spec.whatwg.org/#dom-url-search
2491
+ defineBuiltInAccessor$1(URLPrototype, 'search', accessorDescriptor('getSearch', 'setSearch'));
2492
+ // `URL.prototype.searchParams` getter
2493
+ // https://url.spec.whatwg.org/#dom-url-searchparams
2494
+ defineBuiltInAccessor$1(URLPrototype, 'searchParams', accessorDescriptor('getSearchParams'));
2495
+ // `URL.prototype.hash` accessors pair
2496
+ // https://url.spec.whatwg.org/#dom-url-hash
2497
+ defineBuiltInAccessor$1(URLPrototype, 'hash', accessorDescriptor('getHash', 'setHash'));
2498
+ }
2499
+
2500
+ // `URL.prototype.toJSON` method
2501
+ // https://url.spec.whatwg.org/#dom-url-tojson
2502
+ defineBuiltIn$2(URLPrototype, 'toJSON', function toJSON() {
2503
+ return getInternalURLState(this).serialize();
2504
+ }, { enumerable: true });
2505
+
2506
+ // `URL.prototype.toString` method
2507
+ // https://url.spec.whatwg.org/#URL-stringification-behavior
2508
+ defineBuiltIn$2(URLPrototype, 'toString', function toString() {
2509
+ return getInternalURLState(this).serialize();
2510
+ }, { enumerable: true });
2511
+
2512
+ if (NativeURL) {
2513
+ var nativeCreateObjectURL = NativeURL.createObjectURL;
2514
+ var nativeRevokeObjectURL = NativeURL.revokeObjectURL;
2515
+ // `URL.createObjectURL` method
2516
+ // https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL
2517
+ if (nativeCreateObjectURL) defineBuiltIn$2(URLConstructor, 'createObjectURL', bind(nativeCreateObjectURL, NativeURL));
2518
+ // `URL.revokeObjectURL` method
2519
+ // https://developer.mozilla.org/en-US/docs/Web/API/URL/revokeObjectURL
2520
+ if (nativeRevokeObjectURL) defineBuiltIn$2(URLConstructor, 'revokeObjectURL', bind(nativeRevokeObjectURL, NativeURL));
2521
+ }
2522
+
2523
+ setToStringTag(URLConstructor, 'URL');
2524
+
2525
+ $$1({ global: true, constructor: true, forced: !USE_NATIVE_URL, sham: !DESCRIPTORS$1 }, {
2526
+ URL: URLConstructor
2527
+ });
2528
+
2529
+ var $ = _export;
2530
+ var call = functionCall;
2531
+
2532
+ // `URL.prototype.toJSON` method
2533
+ // https://url.spec.whatwg.org/#dom-url-tojson
2534
+ $({ target: 'URL', proto: true, enumerable: true }, {
2535
+ toJSON: function toJSON() {
2536
+ return call(URL.prototype.toString, this);
2537
+ }
2538
+ });
2539
+
2540
+ var defineBuiltIn$1 = defineBuiltIn$5;
2541
+ var uncurryThis$2 = functionUncurryThis;
2542
+ var toString$1 = toString$4;
2543
+ var validateArgumentsLength$1 = validateArgumentsLength$4;
2544
+
2545
+ var $URLSearchParams$1 = URLSearchParams;
2546
+ var URLSearchParamsPrototype$2 = $URLSearchParams$1.prototype;
2547
+ var append = uncurryThis$2(URLSearchParamsPrototype$2.append);
2548
+ var $delete = uncurryThis$2(URLSearchParamsPrototype$2['delete']);
2549
+ var forEach$1 = uncurryThis$2(URLSearchParamsPrototype$2.forEach);
2550
+ var push = uncurryThis$2([].push);
2551
+ var params$1 = new $URLSearchParams$1('a=1&a=2&b=3');
2552
+
2553
+ params$1['delete']('a', 1);
2554
+ // `undefined` case is a Chromium 117 bug
2555
+ // https://bugs.chromium.org/p/v8/issues/detail?id=14222
2556
+ params$1['delete']('b', undefined);
2557
+
2558
+ if (params$1 + '' !== 'a=2') {
2559
+ defineBuiltIn$1(URLSearchParamsPrototype$2, 'delete', function (name /* , value */) {
2560
+ var length = arguments.length;
2561
+ var $value = length < 2 ? undefined : arguments[1];
2562
+ if (length && $value === undefined) return $delete(this, name);
2563
+ var entries = [];
2564
+ forEach$1(this, function (v, k) { // also validates `this`
2565
+ push(entries, { key: k, value: v });
2566
+ });
2567
+ validateArgumentsLength$1(length, 1);
2568
+ var key = toString$1(name);
2569
+ var value = toString$1($value);
2570
+ var index = 0;
2571
+ var dindex = 0;
2572
+ var found = false;
2573
+ var entriesLength = entries.length;
2574
+ var entry;
2575
+ while (index < entriesLength) {
2576
+ entry = entries[index++];
2577
+ if (found || entry.key === key) {
2578
+ found = true;
2579
+ $delete(this, entry.key);
2580
+ } else dindex++;
2581
+ }
2582
+ while (dindex < entriesLength) {
2583
+ entry = entries[dindex++];
2584
+ if (!(entry.key === key && entry.value === value)) append(this, entry.key, entry.value);
2585
+ }
2586
+ }, { enumerable: true, unsafe: true });
2587
+ }
2588
+
2589
+ var defineBuiltIn = defineBuiltIn$5;
2590
+ var uncurryThis$1 = functionUncurryThis;
2591
+ var toString = toString$4;
2592
+ var validateArgumentsLength = validateArgumentsLength$4;
2593
+
2594
+ var $URLSearchParams = URLSearchParams;
2595
+ var URLSearchParamsPrototype$1 = $URLSearchParams.prototype;
2596
+ var getAll = uncurryThis$1(URLSearchParamsPrototype$1.getAll);
2597
+ var $has = uncurryThis$1(URLSearchParamsPrototype$1.has);
2598
+ var params = new $URLSearchParams('a=1');
2599
+
2600
+ // `undefined` case is a Chromium 117 bug
2601
+ // https://bugs.chromium.org/p/v8/issues/detail?id=14222
2602
+ if (params.has('a', 2) || !params.has('a', undefined)) {
2603
+ defineBuiltIn(URLSearchParamsPrototype$1, 'has', function has(name /* , value */) {
2604
+ var length = arguments.length;
2605
+ var $value = length < 2 ? undefined : arguments[1];
2606
+ if (length && $value === undefined) return $has(this, name);
2607
+ var values = getAll(this, name); // also validates `this`
2608
+ validateArgumentsLength(length, 1);
2609
+ var value = toString($value);
2610
+ var index = 0;
2611
+ while (index < values.length) {
2612
+ if (values[index++] === value) return true;
2613
+ } return false;
2614
+ }, { enumerable: true, unsafe: true });
2615
+ }
2616
+
2617
+ var DESCRIPTORS = descriptors;
2618
+ var uncurryThis = functionUncurryThis;
2619
+ var defineBuiltInAccessor = defineBuiltInAccessor$3;
2620
+
2621
+ var URLSearchParamsPrototype = URLSearchParams.prototype;
2622
+ var forEach = uncurryThis(URLSearchParamsPrototype.forEach);
2623
+
2624
+ // `URLSearchParams.prototype.size` getter
2625
+ // https://github.com/whatwg/url/pull/734
2626
+ if (DESCRIPTORS && !('size' in URLSearchParamsPrototype)) {
2627
+ defineBuiltInAccessor(URLSearchParamsPrototype, 'size', {
2628
+ get: function size() {
2629
+ var count = 0;
2630
+ forEach(this, function () { count++; });
2631
+ return count;
2632
+ },
2633
+ configurable: true,
2634
+ enumerable: true
2635
+ });
2636
+ }
2637
+
2638
+ const DEFAULT_TINYMCE_CONFIG = {
2639
+ inline: true,
2640
+ menubar: false,
2641
+ powerpaste_html_import: 'clean',
2642
+ powerpaste_word_import: 'clean',
2643
+ suffix: '.min',
2644
+ valid_styles: {
2645
+ '*': 'font-size,font-family,color,text-decoration,text-align'
2646
+ }
2647
+ };
2648
+ const TINYMCE_CONFIG = {
2649
+ full: Object.assign({}, DEFAULT_TINYMCE_CONFIG, {
2650
+ plugins: 'link lists autolink charmap',
2651
+ toolbar: ['styleselect undo redo | bold italic underline | forecolor backcolor | alignleft aligncenter alignright alignfull | numlist bullist outdent indent | hr charmap removeformat | link'],
2652
+ style_formats: [{
2653
+ title: 'Paragraph',
2654
+ format: 'p'
2655
+ }, {
2656
+ title: 'Header 1',
2657
+ format: 'h1'
2658
+ }, {
2659
+ title: 'Header 2',
2660
+ format: 'h2'
2661
+ }, {
2662
+ title: 'Header 3',
2663
+ format: 'h3'
2664
+ }, {
2665
+ title: 'Header 4',
2666
+ format: 'h4'
2667
+ }, {
2668
+ title: 'Header 5',
2669
+ format: 'h5'
2670
+ }, {
2671
+ title: 'Header 6',
2672
+ format: 'h6'
2673
+ }, {
2674
+ title: 'Pre',
2675
+ format: 'pre'
2676
+ }, {
2677
+ title: 'Code',
2678
+ format: 'code'
2679
+ }]
2680
+ }),
2681
+ plain: Object.assign({}, DEFAULT_TINYMCE_CONFIG, {
2682
+ plugins: '',
2683
+ toolbar: ''
2684
+ }),
2685
+ minimal: Object.assign({}, DEFAULT_TINYMCE_CONFIG, {
2686
+ plugins: 'link autolink',
2687
+ toolbar: 'bold italic underline | link',
2688
+ valid_elements: 'strong,em,span[style],a[href]'
2689
+ })
2690
+ };
2691
+
2692
+ const MCE_URL = '/ext/tinymcev7/tinymce.min.js';
2693
+ /**
2694
+ * Allows inline edit content pulled from dotCMS API using TinyMCE editor
2695
+ *
2696
+ * @export
2697
+ * @component
2698
+ * @param {Readonly<DotEditableTextProps>} props {
2699
+ * mode = 'plain',
2700
+ * format = 'text',
2701
+ * contentlet,
2702
+ * fieldName = ''
2703
+ * }
2704
+ * @example
2705
+ * ```javascript
2706
+ * import { DotEditableText } from '@dotcms/react';
2707
+ *
2708
+ * const MyContentletWithTitle = ({ contentlet }) => (
2709
+ * <h2>
2710
+ * <DotEditableText
2711
+ * contentlet={contentlet}
2712
+ * fieldName="title"
2713
+ * mode='full'
2714
+ * format='text'/>
2715
+ * </h2>
2716
+ * );
2717
+ * ```
2718
+ * @returns {JSX.Element} A component to edit content inline
2719
+ */
2720
+ function DotEditableText({
2721
+ mode = 'plain',
2722
+ format = 'text',
2723
+ contentlet,
2724
+ fieldName = ''
2725
+ }) {
2726
+ const editorRef = useRef(null);
2727
+ const [scriptSrc, setScriptSrc] = useState('');
2728
+ const [isInsideEditor$1, setIsInsideEditor] = useState(false);
2729
+ const [content, setContent] = useState((contentlet == null ? void 0 : contentlet[fieldName]) || '');
2730
+ useEffect(() => {
2731
+ var _editorRef$current;
2732
+ setIsInsideEditor(isInsideEditor());
2733
+ if (!contentlet || !fieldName) {
2734
+ console.error('DotEditableText: contentlet or fieldName is missing');
2735
+ console.error('Ensure that all needed props are passed to view and edit the content');
2736
+ return;
2737
+ }
2738
+ if (!isInsideEditor()) {
2739
+ return;
2740
+ }
2741
+ const createURL = new URL(MCE_URL, DotCmsClient.dotcmsUrl);
2742
+ setScriptSrc(createURL.toString());
2743
+ const content = (contentlet == null ? void 0 : contentlet[fieldName]) || '';
2744
+ (_editorRef$current = editorRef.current) == null || _editorRef$current.setContent(content, {
2745
+ format
2746
+ });
2747
+ setContent(content);
2748
+ }, [format, fieldName, contentlet]);
2749
+ useEffect(() => {
2750
+ if (!isInsideEditor()) {
2751
+ return;
2752
+ }
2753
+ const onMessage = ({
2754
+ data
2755
+ }) => {
2756
+ const {
2757
+ name,
2758
+ payload
2759
+ } = data;
2760
+ if (name !== NOTIFY_CLIENT.UVE_COPY_CONTENTLET_INLINE_EDITING_SUCCESS) {
2761
+ return;
2762
+ }
2763
+ const {
2764
+ oldInode,
2765
+ inode
2766
+ } = payload;
2767
+ const currentInode = contentlet.inode;
2768
+ const shouldFocus = currentInode === oldInode || currentInode === inode;
2769
+ if (shouldFocus) {
2770
+ var _editorRef$current2;
2771
+ (_editorRef$current2 = editorRef.current) == null || _editorRef$current2.focus();
2772
+ }
2773
+ };
2774
+ window.addEventListener('message', onMessage);
2775
+ return () => {
2776
+ window.removeEventListener('message', onMessage);
2777
+ };
2778
+ }, [contentlet.inode]);
2779
+ const onMouseDown = event => {
2780
+ var _editorRef$current3;
2781
+ const {
2782
+ onNumberOfPages = 1
2783
+ } = contentlet;
2784
+ const {
2785
+ inode,
2786
+ languageId: language
2787
+ } = contentlet;
2788
+ if (onNumberOfPages <= 1 || (_editorRef$current3 = editorRef.current) != null && _editorRef$current3.hasFocus()) {
2789
+ return;
2790
+ }
2791
+ event.stopPropagation();
2792
+ event.preventDefault();
2793
+ postMessageToEditor({
2794
+ action: CLIENT_ACTIONS.COPY_CONTENTLET_INLINE_EDITING,
2795
+ payload: {
2796
+ dataset: {
2797
+ inode,
2798
+ language,
2799
+ fieldName
2800
+ }
2801
+ }
2802
+ });
2803
+ };
2804
+ const onFocusOut = () => {
2805
+ var _editorRef$current4, _editorRef$current5;
2806
+ const editedContent = ((_editorRef$current4 = editorRef.current) == null ? void 0 : _editorRef$current4.getContent({
2807
+ format: format
2808
+ })) || '';
2809
+ const {
2810
+ inode,
2811
+ languageId: langId
2812
+ } = contentlet;
2813
+ if (!((_editorRef$current5 = editorRef.current) != null && _editorRef$current5.isDirty()) || !didContentChange(editedContent)) {
2814
+ return;
2815
+ }
2816
+ postMessageToEditor({
2817
+ action: CLIENT_ACTIONS.UPDATE_CONTENTLET_INLINE_EDITING,
2818
+ payload: {
2819
+ content: editedContent,
2820
+ dataset: {
2821
+ inode,
2822
+ langId,
2823
+ fieldName
2824
+ }
2825
+ }
2826
+ });
2827
+ };
2828
+ const didContentChange = editedContent => {
2829
+ return content !== editedContent;
2830
+ };
2831
+ if (!isInsideEditor$1) {
2832
+ // We can let the user pass the Child Component and create a root to get the HTML for the editor
2833
+ return jsx("span", {
2834
+ dangerouslySetInnerHTML: {
2835
+ __html: content
2836
+ }
2837
+ });
2838
+ }
2839
+ return jsx(Editor, {
2840
+ tinymceScriptSrc: scriptSrc,
2841
+ inline: true,
2842
+ onInit: (_, editor) => editorRef.current = editor,
2843
+ init: TINYMCE_CONFIG[mode],
2844
+ initialValue: content,
2845
+ onMouseDown: onMouseDown,
2846
+ onFocusOut: onFocusOut
2847
+ });
2848
+ }
2849
+
2850
+ /**
2851
+ * `useDotcmsPageContext` is a custom React hook that provides access to the `PageProviderContext`.
2852
+ * It takes no parameters and returns the context value or `null` if it's not available.
2853
+ *
2854
+ * @category Hooks
2855
+ * @returns {DotCMSPageContext | null} - The context value or `null` if it's not available.
2856
+ */
2857
+ function useDotcmsPageContext() {
2858
+ return useContext(PageContext);
2859
+ }
2860
+
2861
+ /**
2862
+ * Represents the different types of Blocks that can be used in the Block Editor
2863
+ *
2864
+ * @export
2865
+ * @enum {number}
2866
+ */
2867
+ var Blocks;
2868
+ (function (Blocks) {
2869
+ Blocks["PARAGRAPH"] = "paragraph";
2870
+ Blocks["HEADING"] = "heading";
2871
+ Blocks["TEXT"] = "text";
2872
+ Blocks["BULLET_LIST"] = "bulletList";
2873
+ Blocks["ORDERED_LIST"] = "orderedList";
2874
+ Blocks["LIST_ITEM"] = "listItem";
2875
+ Blocks["BLOCK_QUOTE"] = "blockquote";
2876
+ Blocks["CODE_BLOCK"] = "codeBlock";
2877
+ Blocks["HARDBREAK"] = "hardBreak";
2878
+ Blocks["HORIZONTAL_RULE"] = "horizontalRule";
2879
+ Blocks["DOT_IMAGE"] = "dotImage";
2880
+ Blocks["DOT_VIDEO"] = "dotVideo";
2881
+ Blocks["TABLE"] = "table";
2882
+ Blocks["DOT_CONTENT"] = "dotContent";
2883
+ })(Blocks || (Blocks = {}));
2884
+
2885
+ /**
2886
+ * Renders a code block component.
2887
+ *
2888
+ * @param attrs - The attributes of the code block.
2889
+ * @param children - The content of the code block.
2890
+ * @returns The rendered code block component.
2891
+ */
2892
+ const CodeBlock = ({
2893
+ attrs,
2894
+ children
2895
+ }) => {
2896
+ const language = (attrs == null ? void 0 : attrs.language) || '';
2897
+ return jsx("pre", {
2898
+ "data-language": language,
2899
+ children: jsx("code", {
2900
+ children: children
2901
+ })
2902
+ });
2903
+ };
2904
+ /**
2905
+ * Renders a blockquote component.
2906
+ *
2907
+ * @param children - The content to be rendered inside the blockquote.
2908
+ * @returns The rendered blockquote component.
2909
+ */
2910
+ const BlockQuote = ({
2911
+ children
2912
+ }) => {
2913
+ return jsx("blockquote", {
2914
+ children: children
2915
+ });
2916
+ };
2917
+
2918
+ function _objectWithoutPropertiesLoose(r, e) {
2919
+ if (null == r) return {};
2920
+ var t = {};
2921
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
2922
+ if (e.includes(n)) continue;
2923
+ t[n] = r[n];
2924
+ }
2925
+ return t;
2926
+ }
2927
+
2928
+ const _excluded = ["customRenderers"];
2929
+ /**
2930
+ * Renders the default content for an unknown content type.
2931
+ */
2932
+ const DefaultContent = () => jsx("div", {
2933
+ children: "Unknown Content Type"
2934
+ });
2935
+ /**
2936
+ * Renders a DotContent component.
2937
+ *
2938
+ * @param {DotContentProps} props - The props for the DotContent component.
2939
+ * @returns {JSX.Element} The rendered DotContent component.
2940
+ */
2941
+ const DotContent = _ref => {
2942
+ var _customRenderers$data;
2943
+ let {
2944
+ customRenderers
2945
+ } = _ref,
2946
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
2947
+ const {
2948
+ attrs
2949
+ } = props;
2950
+ const data = attrs == null ? void 0 : attrs.data;
2951
+ const Component = (_customRenderers$data = customRenderers == null ? void 0 : customRenderers[data == null ? void 0 : data.contentType]) != null ? _customRenderers$data : DefaultContent;
2952
+ if (!data) {
2953
+ console.error('DotContent: No data provided');
2954
+ }
2955
+ return jsx(Component, Object.assign({}, props));
2956
+ };
2957
+
2958
+ /**
2959
+ * Renders an image component for dotCMS.
2960
+ *
2961
+ * @param props - The props for the DotCMSImage component.
2962
+ * @returns The rendered image component.
2963
+ */
2964
+ const DotCMSImage = props => {
2965
+ const {
2966
+ data,
2967
+ src,
2968
+ alt
2969
+ } = props.attrs;
2970
+ const client = DotCmsClient.instance;
2971
+ const srcUrl = data != null && data.identifier ? `${client.dotcmsUrl}${src}` : src;
2972
+ return jsx("img", {
2973
+ alt: alt,
2974
+ src: srcUrl
2975
+ });
2976
+ };
2977
+
2978
+ /**
2979
+ * ListItem component represents a list item in a block editor.
2980
+ *
2981
+ * @param children - The content of the list item.
2982
+ * @returns The rendered list item element.
2983
+ */
2984
+ const ListItem = ({
2985
+ children
2986
+ }) => {
2987
+ return jsx("li", {
2988
+ children: children
2989
+ });
2990
+ };
2991
+ /**
2992
+ * Renders an ordered list component.
2993
+ *
2994
+ * @param children - The content to be rendered inside the ordered list.
2995
+ * @returns The ordered list component.
2996
+ */
2997
+ const OrderedList = ({
2998
+ children
2999
+ }) => {
3000
+ return jsx("ol", {
3001
+ children: children
3002
+ });
3003
+ };
3004
+ /**
3005
+ * Renders a bullet list component.
3006
+ *
3007
+ * @param children - The content of the bullet list.
3008
+ * @returns The rendered bullet list component.
3009
+ */
3010
+ const BulletList = ({
3011
+ children
3012
+ }) => {
3013
+ return jsx("ul", {
3014
+ children: children
3015
+ });
3016
+ };
3017
+
3018
+ /**
3019
+ * Renders a table component for the Block Editor.
3020
+ *
3021
+ * @param content - The content of the table.
3022
+ * @param blockEditorItem - The Block Editor item component.
3023
+ */
3024
+ const TableRenderer = ({
3025
+ content,
3026
+ blockEditorItem
3027
+ }) => {
3028
+ const BlockEditorItemComponent = blockEditorItem;
3029
+ const renderTableContent = node => {
3030
+ return jsx(BlockEditorItemComponent, {
3031
+ content: node.content
3032
+ });
3033
+ };
3034
+ return jsxs("table", {
3035
+ children: [jsx("thead", {
3036
+ children: content.slice(0, 1).map((rowNode, rowIndex) => {
3037
+ var _rowNode$content;
3038
+ return jsx("tr", {
3039
+ children: (_rowNode$content = rowNode.content) == null ? void 0 : _rowNode$content.map((cellNode, cellIndex) => {
3040
+ var _cellNode$attrs, _cellNode$attrs2;
3041
+ return jsx("th", {
3042
+ colSpan: Number(((_cellNode$attrs = cellNode.attrs) == null ? void 0 : _cellNode$attrs.colspan) || 1),
3043
+ rowSpan: Number(((_cellNode$attrs2 = cellNode.attrs) == null ? void 0 : _cellNode$attrs2.rowspan) || 1),
3044
+ children: renderTableContent(cellNode)
3045
+ }, `${cellNode.type}-${cellIndex}`);
3046
+ })
3047
+ }, `${rowNode.type}-${rowIndex}`);
3048
+ })
3049
+ }), jsx("tbody", {
3050
+ children: content.slice(1).map((rowNode, rowIndex) => {
3051
+ var _rowNode$content2;
3052
+ return jsx("tr", {
3053
+ children: (_rowNode$content2 = rowNode.content) == null ? void 0 : _rowNode$content2.map((cellNode, cellIndex) => {
3054
+ var _cellNode$attrs3, _cellNode$attrs4;
3055
+ return jsx("td", {
3056
+ colSpan: Number(((_cellNode$attrs3 = cellNode.attrs) == null ? void 0 : _cellNode$attrs3.colspan) || 1),
3057
+ rowSpan: Number(((_cellNode$attrs4 = cellNode.attrs) == null ? void 0 : _cellNode$attrs4.rowspan) || 1),
3058
+ children: renderTableContent(cellNode)
3059
+ }, `${cellNode.type}-${cellIndex}`);
3060
+ })
3061
+ }, `${rowNode.type}-${rowIndex}`);
3062
+ })
3063
+ })]
3064
+ });
3065
+ };
3066
+
3067
+ /**
3068
+ * Renders the text in bold.
3069
+ *
3070
+ * @param children - The content to be rendered in bold.
3071
+ */
3072
+ const Bold = ({
3073
+ children
3074
+ }) => jsx("strong", {
3075
+ children: children
3076
+ });
3077
+ /**
3078
+ * Renders the text in italic format.
3079
+ *
3080
+ * @param children - The content to be rendered in italic.
3081
+ */
3082
+ const Italic = ({
3083
+ children
3084
+ }) => jsx("em", {
3085
+ children: children
3086
+ });
3087
+ /**
3088
+ * Renders a strike-through text.
3089
+ *
3090
+ * @param children - The content to be rendered within the strike-through element.
3091
+ */
3092
+ const Strike = ({
3093
+ children
3094
+ }) => jsx("s", {
3095
+ children: children
3096
+ });
3097
+ /**
3098
+ * Renders an underline element for the given children.
3099
+ *
3100
+ * @param children - The content to be underlined.
3101
+ */
3102
+ const Underline = ({
3103
+ children
3104
+ }) => jsx("u", {
3105
+ children: children
3106
+ });
3107
+ /**
3108
+ * Renders a paragraph element.
3109
+ *
3110
+ * @param children - The content of the paragraph.
3111
+ * @param attrs - The style attributes for the paragraph.
3112
+ * @returns The rendered paragraph element.
3113
+ */
3114
+ const Paragraph = ({
3115
+ children,
3116
+ attrs
3117
+ }) => {
3118
+ return jsx("p", {
3119
+ style: attrs,
3120
+ children: children
3121
+ });
3122
+ };
3123
+ /**
3124
+ * Renders a link component.
3125
+ *
3126
+ * @param children - The content of the link.
3127
+ * @param attrs - The attributes to be applied to the link.
3128
+ * @returns The rendered link component.
3129
+ */
3130
+ const Link = ({
3131
+ children,
3132
+ attrs
3133
+ }) => {
3134
+ return jsx("a", Object.assign({}, attrs, {
3135
+ children: children
3136
+ }));
3137
+ };
3138
+ /**
3139
+ * Renders a heading element with the specified level.
3140
+ *
3141
+ * @param children - The content of the heading.
3142
+ * @param attrs - The attributes for the heading.
3143
+ * @returns The rendered heading element.
3144
+ */
3145
+ const Heading = ({
3146
+ children,
3147
+ attrs
3148
+ }) => {
3149
+ const level = (attrs == null ? void 0 : attrs.level) || 1;
3150
+ const Tag = `h${level}`;
3151
+ return jsx(Tag, {
3152
+ children: children
3153
+ });
3154
+ };
3155
+ /**
3156
+ * Renders the superscript text.
3157
+ *
3158
+ * @param children - The content to be rendered as superscript.
3159
+ */
3160
+ const Superscript = ({
3161
+ children
3162
+ }) => jsx("sup", {
3163
+ children: children
3164
+ });
3165
+ /**
3166
+ * Renders a subscript element.
3167
+ *
3168
+ * @param children - The content to be rendered as subscript.
3169
+ */
3170
+ const Subscript = ({
3171
+ children
3172
+ }) => jsx("sub", {
3173
+ children: children
3174
+ });
3175
+ const nodeMarks = {
3176
+ link: Link,
3177
+ bold: Bold,
3178
+ underline: Underline,
3179
+ italic: Italic,
3180
+ strike: Strike,
3181
+ superscript: Superscript,
3182
+ subscript: Subscript
3183
+ };
3184
+ /**
3185
+ * Renders a text block with optional marks.
3186
+ *
3187
+ * @param props - The props for the TextBlock component.
3188
+ * @returns The rendered text block.
3189
+ */
3190
+ const TextBlock = props => {
3191
+ const {
3192
+ marks = [],
3193
+ text
3194
+ } = props;
3195
+ const mark = marks[0] || {
3196
+ type: '',
3197
+ attrs: {}
3198
+ };
3199
+ const newProps = Object.assign({}, props, {
3200
+ marks: marks.slice(1)
3201
+ });
3202
+ const Component = nodeMarks[mark == null ? void 0 : mark.type];
3203
+ // To avoid the warning: "Warning: Invalid DOM property `class`. Did you mean `className`?"
3204
+ if (mark.attrs) {
3205
+ mark.attrs.className = mark.attrs.class;
3206
+ delete mark.attrs.class;
3207
+ }
3208
+ if (!Component) {
3209
+ return text;
3210
+ }
3211
+ return jsx(Component, {
3212
+ attrs: mark.attrs,
3213
+ children: jsx(TextBlock, Object.assign({}, newProps))
3214
+ });
3215
+ };
3216
+
3217
+ /**
3218
+ * Renders a video component for displaying videos.
3219
+ *
3220
+ * @param props - The properties for the video component.
3221
+ * @returns The rendered video component.
3222
+ */
3223
+ const DotCMSVideo = props => {
3224
+ const {
3225
+ data,
3226
+ src,
3227
+ mimeType,
3228
+ width,
3229
+ height
3230
+ } = props.attrs;
3231
+ const client = DotCmsClient.instance;
3232
+ const srcUrl = data != null && data.identifier ? `${client.dotcmsUrl}${src}` : src;
3233
+ const poster = data != null && data.thumbnail ? `${client.dotcmsUrl}${data == null ? void 0 : data.thumbnail}` : 'poster-image.jpg';
3234
+ return jsxs("video", {
3235
+ controls: true,
3236
+ preload: "metadata",
3237
+ poster: poster,
3238
+ width: width,
3239
+ height: height,
3240
+ children: [jsx("track", {
3241
+ default: true,
3242
+ kind: "captions",
3243
+ srcLang: "en"
3244
+ }), jsx("source", {
3245
+ src: srcUrl,
3246
+ type: mimeType
3247
+ }), "Your browser does not support the ", jsx("code", {
3248
+ children: "video"
3249
+ }), " element."]
3250
+ });
3251
+ };
3252
+
3253
+ /**
3254
+ * Renders a block editor item based on the provided content and custom renderers.
3255
+ *
3256
+ * @param content - The content nodes to render.
3257
+ * @param customRenderers - Optional custom renderers for specific node types.
3258
+ * @returns The rendered block editor item.
3259
+ */
3260
+ const BlockEditorBlock = ({
3261
+ content,
3262
+ customRenderers
3263
+ }) => {
3264
+ return content == null ? void 0 : content.map((node, index) => {
3265
+ const CustomRendererComponent = customRenderers == null ? void 0 : customRenderers[node.type];
3266
+ if (CustomRendererComponent) {
3267
+ return jsx(CustomRendererComponent, Object.assign({}, node, {
3268
+ content: node.content,
3269
+ children: jsx(BlockEditorBlock, {
3270
+ content: node.content,
3271
+ customRenderers: customRenderers
3272
+ })
3273
+ }), `${node.type}-${index}`);
3274
+ }
3275
+ switch (node.type) {
3276
+ case Blocks.PARAGRAPH:
3277
+ return jsx(Paragraph, Object.assign({}, node, {
3278
+ children: jsx(BlockEditorBlock, {
3279
+ content: node.content,
3280
+ customRenderers: customRenderers
3281
+ })
3282
+ }), `${node.type}-${index}`);
3283
+ case Blocks.HEADING:
3284
+ return jsx(Heading, Object.assign({}, node, {
3285
+ children: jsx(BlockEditorBlock, {
3286
+ content: node.content,
3287
+ customRenderers: customRenderers
3288
+ })
3289
+ }), `${node.type}-${index}`);
3290
+ case Blocks.TEXT:
3291
+ return jsx(TextBlock, Object.assign({}, node), `${node.type}-${index}`);
3292
+ case Blocks.BULLET_LIST:
3293
+ return jsx(BulletList, {
3294
+ children: jsx(BlockEditorBlock, {
3295
+ content: node.content,
3296
+ customRenderers: customRenderers
3297
+ })
3298
+ }, `${node.type}-${index}`);
3299
+ case Blocks.ORDERED_LIST:
3300
+ return jsx(OrderedList, {
3301
+ children: jsx(BlockEditorBlock, {
3302
+ content: node.content,
3303
+ customRenderers: customRenderers
3304
+ })
3305
+ }, `${node.type}-${index}`);
3306
+ case Blocks.LIST_ITEM:
3307
+ return jsx(ListItem, {
3308
+ children: jsx(BlockEditorBlock, {
3309
+ content: node.content,
3310
+ customRenderers: customRenderers
3311
+ })
3312
+ }, `${node.type}-${index}`);
3313
+ case Blocks.BLOCK_QUOTE:
3314
+ return jsx(BlockQuote, {
3315
+ children: jsx(BlockEditorBlock, {
3316
+ content: node.content,
3317
+ customRenderers: customRenderers
3318
+ })
3319
+ }, `${node.type}-${index}`);
3320
+ case Blocks.CODE_BLOCK:
3321
+ return jsx(CodeBlock, Object.assign({}, node, {
3322
+ children: jsx(BlockEditorBlock, {
3323
+ content: node.content,
3324
+ customRenderers: customRenderers
3325
+ })
3326
+ }), `${node.type}-${index}`);
3327
+ case Blocks.HARDBREAK:
3328
+ return jsx("br", {}, `${node.type}-${index}`);
3329
+ case Blocks.HORIZONTAL_RULE:
3330
+ return jsx("hr", {}, `${node.type}-${index}`);
3331
+ case Blocks.DOT_IMAGE:
3332
+ return jsx(DotCMSImage, Object.assign({}, node), `${node.type}-${index}`);
3333
+ case Blocks.DOT_VIDEO:
3334
+ return jsx(DotCMSVideo, Object.assign({}, node), `${node.type}-${index}`);
3335
+ case Blocks.TABLE:
3336
+ return jsx(TableRenderer, {
3337
+ content: node.content,
3338
+ blockEditorItem: BlockEditorBlock
3339
+ }, `${node.type}-${index}`);
3340
+ case Blocks.DOT_CONTENT:
3341
+ return jsx(DotContent, Object.assign({}, node, {
3342
+ customRenderers: customRenderers
3343
+ }), `${node.type}-${index}`);
3344
+ default:
3345
+ return jsxs("div", {
3346
+ children: ["Unknown Block Type ", node.type]
3347
+ }, `${node.type}-${index}`);
3348
+ }
3349
+ });
3350
+ };
3351
+
3352
+ /**
3353
+ * BlockEditorRenderer component for rendering block editor field.
3354
+ *
3355
+ * @component
3356
+ * @param {Object} props - The component props.
3357
+ * @param {Block} props.blocks - The blocks of content to render.
3358
+ * @param {CustomRenderer} [props.customRenderers] - Optional custom renderers for specific block types.
3359
+ * @param {string} [props.className] - Optional CSS class name for the container div.
3360
+ * @param {React.CSSProperties} [props.style] - Optional inline styles for the container div.
3361
+ * @param {boolean} props.editable - Flag to enable inline editing. When true, `contentlet` and `fieldName` are required. Note: Enterprise only feature.
3362
+ * @param {DotCMSContentlet} [props.contentlet] - Contentlet object for inline editing. Required when `editable` is true.
3363
+ * @param {string} [props.fieldName] - Field name for inline editing. Required when `editable` is true.
3364
+ * @returns {JSX.Element} A div containing the rendered blocks of content.
3365
+ */
3366
+ const BlockEditorRenderer = ({
3367
+ style,
3368
+ blocks,
3369
+ editable,
3370
+ fieldName,
3371
+ className,
3372
+ contentlet,
3373
+ customRenderers
3374
+ }) => {
3375
+ const ref = useRef(null);
3376
+ const [blockEditorState, setBlockEditorState] = useState({
3377
+ error: null
3378
+ });
3379
+ /**
3380
+ * Sets up inline editing functionality when the component is editable and inside the editor.
3381
+ *
3382
+ * This effect:
3383
+ * 1. Checks if inline editing should be enabled based on props and editor context
3384
+ * 2. Validates required props for inline editing (contentlet and fieldName)
3385
+ * 3. Extracts necessary data from the contentlet
3386
+ * 4. Adds a click handler to initialize inline editing with the block editor
3387
+ * 5. Cleans up event listener on unmount
3388
+ *
3389
+ * @dependency {boolean} editable - Flag to enable/disable inline editing
3390
+ * @dependency {DotCMSContentlet} contentlet - Contentlet data required for editing
3391
+ * @dependency {Block} blocks - The content blocks to edit
3392
+ * @dependency {string} fieldName - Name of the field being edited
3393
+ */
3394
+ useEffect(() => {
3395
+ if (!editable || !ref.current || !isInsideEditor()) {
3396
+ return;
3397
+ }
3398
+ // TypeScript will throw an error if contentlet or fieldName are not provided when editable is true,
3399
+ // but we need to check them again to avoid runtime errors in Pure JavaScript
3400
+ if (!contentlet || !fieldName) {
3401
+ console.error('contentlet and fieldName are required to enable inline editing');
3402
+ return;
3403
+ }
3404
+ const {
3405
+ inode,
3406
+ languageId: language,
3407
+ contentType
3408
+ } = contentlet;
3409
+ // `ContentNode` lives on `@dotcms/react` that's why we can use it in `@dotcms/client`
3410
+ // We need to move interfaces to external lib
3411
+ const content = blocks;
3412
+ const element = ref.current;
3413
+ const handleClickEvent = () => {
3414
+ initInlineEditing('BLOCK_EDITOR', {
3415
+ inode,
3416
+ content,
3417
+ language,
3418
+ fieldName,
3419
+ contentType
3420
+ });
3421
+ };
3422
+ element.addEventListener('click', handleClickEvent);
3423
+ return () => element.removeEventListener('click', handleClickEvent);
3424
+ }, [editable, contentlet, blocks, fieldName]);
3425
+ /**
3426
+ * Validates the blocks structure and updates the block editor state.
3427
+ *
3428
+ * This effect:
3429
+ * 1. Validates that blocks have the correct structure (doc type, content array, etc)
3430
+ * 2. Updates the block editor state with validation result
3431
+ * 3. Logs any validation errors to console
3432
+ *
3433
+ * @dependency {Block} blocks - The content blocks to validate
3434
+ */
3435
+ useEffect(() => {
3436
+ const validationResult = isValidBlocks(blocks);
3437
+ setBlockEditorState(validationResult);
3438
+ if (validationResult.error) {
3439
+ console.error(validationResult.error);
3440
+ }
3441
+ }, [blocks]);
3442
+ if (blockEditorState.error) {
3443
+ console.error(blockEditorState.error);
3444
+ if (isInsideEditor()) {
3445
+ return jsx("div", {
3446
+ "data-testid": "invalid-blocks-message",
3447
+ children: blockEditorState.error
3448
+ });
3449
+ }
3450
+ return null;
3451
+ }
3452
+ return jsx("div", {
3453
+ className: className,
3454
+ style: style,
3455
+ ref: ref,
3456
+ "data-testid": "dot-block-editor-container",
3457
+ children: jsx(BlockEditorBlock, {
3458
+ content: blocks == null ? void 0 : blocks.content,
3459
+ customRenderers: customRenderers
3460
+ })
3461
+ });
3462
+ };
3463
+
3464
+ export { BlockEditorRenderer, DotEditableText, DotcmsLayout, PageProvider, Row, useDotcmsPageContext };