UNPKG

13.2 kBJavaScriptView Raw
1/**
2 * @license React
3 * react.react-server.production.js
4 *
5 * Copyright (c) Meta Platforms, Inc. and affiliates.
6 *
7 * This source code is licensed under the MIT license found in the
8 * LICENSE file in the root directory of this source tree.
9 */
10
11"use strict";
12var ReactSharedInternals = { H: null, A: null };
13function formatProdErrorMessage(code) {
14 var url = "https://react.dev/errors/" + code;
15 if (1 < arguments.length) {
16 url += "?args[]=" + encodeURIComponent(arguments[1]);
17 for (var i = 2; i < arguments.length; i++)
18 url += "&args[]=" + encodeURIComponent(arguments[i]);
19 }
20 return (
21 "Minified React error #" +
22 code +
23 "; visit " +
24 url +
25 " for the full message or use the non-minified dev environment for full errors and additional helpful warnings."
26 );
27}
28var isArrayImpl = Array.isArray,
29 REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
30 REACT_PORTAL_TYPE = Symbol.for("react.portal"),
31 REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
32 REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
33 REACT_PROFILER_TYPE = Symbol.for("react.profiler"),
34 REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
35 REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
36 REACT_MEMO_TYPE = Symbol.for("react.memo"),
37 REACT_LAZY_TYPE = Symbol.for("react.lazy"),
38 MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
39function getIteratorFn(maybeIterable) {
40 if (null === maybeIterable || "object" !== typeof maybeIterable) return null;
41 maybeIterable =
42 (MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL]) ||
43 maybeIterable["@@iterator"];
44 return "function" === typeof maybeIterable ? maybeIterable : null;
45}
46var hasOwnProperty = Object.prototype.hasOwnProperty,
47 assign = Object.assign;
48function ReactElement(type, key, self, source, owner, props) {
49 self = props.ref;
50 return {
51 $$typeof: REACT_ELEMENT_TYPE,
52 type: type,
53 key: key,
54 ref: void 0 !== self ? self : null,
55 props: props
56 };
57}
58function cloneAndReplaceKey(oldElement, newKey) {
59 return ReactElement(
60 oldElement.type,
61 newKey,
62 void 0,
63 void 0,
64 void 0,
65 oldElement.props
66 );
67}
68function isValidElement(object) {
69 return (
70 "object" === typeof object &&
71 null !== object &&
72 object.$$typeof === REACT_ELEMENT_TYPE
73 );
74}
75function escape(key) {
76 var escaperLookup = { "=": "=0", ":": "=2" };
77 return (
78 "$" +
79 key.replace(/[=:]/g, function (match) {
80 return escaperLookup[match];
81 })
82 );
83}
84var userProvidedKeyEscapeRegex = /\/+/g;
85function getElementKey(element, index) {
86 return "object" === typeof element && null !== element && null != element.key
87 ? escape("" + element.key)
88 : index.toString(36);
89}
90function noop() {}
91function resolveThenable(thenable) {
92 switch (thenable.status) {
93 case "fulfilled":
94 return thenable.value;
95 case "rejected":
96 throw thenable.reason;
97 default:
98 switch (
99 ("string" === typeof thenable.status
100 ? thenable.then(noop, noop)
101 : ((thenable.status = "pending"),
102 thenable.then(
103 function (fulfilledValue) {
104 "pending" === thenable.status &&
105 ((thenable.status = "fulfilled"),
106 (thenable.value = fulfilledValue));
107 },
108 function (error) {
109 "pending" === thenable.status &&
110 ((thenable.status = "rejected"), (thenable.reason = error));
111 }
112 )),
113 thenable.status)
114 ) {
115 case "fulfilled":
116 return thenable.value;
117 case "rejected":
118 throw thenable.reason;
119 }
120 }
121 throw thenable;
122}
123function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
124 var type = typeof children;
125 if ("undefined" === type || "boolean" === type) children = null;
126 var invokeCallback = !1;
127 if (null === children) invokeCallback = !0;
128 else
129 switch (type) {
130 case "bigint":
131 case "string":
132 case "number":
133 invokeCallback = !0;
134 break;
135 case "object":
136 switch (children.$$typeof) {
137 case REACT_ELEMENT_TYPE:
138 case REACT_PORTAL_TYPE:
139 invokeCallback = !0;
140 break;
141 case REACT_LAZY_TYPE:
142 return (
143 (invokeCallback = children._init),
144 mapIntoArray(
145 invokeCallback(children._payload),
146 array,
147 escapedPrefix,
148 nameSoFar,
149 callback
150 )
151 );
152 }
153 }
154 if (invokeCallback)
155 return (
156 (callback = callback(children)),
157 (invokeCallback =
158 "" === nameSoFar ? "." + getElementKey(children, 0) : nameSoFar),
159 isArrayImpl(callback)
160 ? ((escapedPrefix = ""),
161 null != invokeCallback &&
162 (escapedPrefix =
163 invokeCallback.replace(userProvidedKeyEscapeRegex, "$&/") + "/"),
164 mapIntoArray(callback, array, escapedPrefix, "", function (c) {
165 return c;
166 }))
167 : null != callback &&
168 (isValidElement(callback) &&
169 (callback = cloneAndReplaceKey(
170 callback,
171 escapedPrefix +
172 (null == callback.key ||
173 (children && children.key === callback.key)
174 ? ""
175 : ("" + callback.key).replace(
176 userProvidedKeyEscapeRegex,
177 "$&/"
178 ) + "/") +
179 invokeCallback
180 )),
181 array.push(callback)),
182 1
183 );
184 invokeCallback = 0;
185 var nextNamePrefix = "" === nameSoFar ? "." : nameSoFar + ":";
186 if (isArrayImpl(children))
187 for (var i = 0; i < children.length; i++)
188 (nameSoFar = children[i]),
189 (type = nextNamePrefix + getElementKey(nameSoFar, i)),
190 (invokeCallback += mapIntoArray(
191 nameSoFar,
192 array,
193 escapedPrefix,
194 type,
195 callback
196 ));
197 else if (((i = getIteratorFn(children)), "function" === typeof i))
198 for (
199 children = i.call(children), i = 0;
200 !(nameSoFar = children.next()).done;
201
202 )
203 (nameSoFar = nameSoFar.value),
204 (type = nextNamePrefix + getElementKey(nameSoFar, i++)),
205 (invokeCallback += mapIntoArray(
206 nameSoFar,
207 array,
208 escapedPrefix,
209 type,
210 callback
211 ));
212 else if ("object" === type) {
213 if ("function" === typeof children.then)
214 return mapIntoArray(
215 resolveThenable(children),
216 array,
217 escapedPrefix,
218 nameSoFar,
219 callback
220 );
221 array = String(children);
222 throw Error(
223 formatProdErrorMessage(
224 31,
225 "[object Object]" === array
226 ? "object with keys {" + Object.keys(children).join(", ") + "}"
227 : array
228 )
229 );
230 }
231 return invokeCallback;
232}
233function mapChildren(children, func, context) {
234 if (null == children) return children;
235 var result = [],
236 count = 0;
237 mapIntoArray(children, result, "", "", function (child) {
238 return func.call(context, child, count++);
239 });
240 return result;
241}
242function lazyInitializer(payload) {
243 if (-1 === payload._status) {
244 var ctor = payload._result;
245 ctor = ctor();
246 ctor.then(
247 function (moduleObject) {
248 if (0 === payload._status || -1 === payload._status)
249 (payload._status = 1), (payload._result = moduleObject);
250 },
251 function (error) {
252 if (0 === payload._status || -1 === payload._status)
253 (payload._status = 2), (payload._result = error);
254 }
255 );
256 -1 === payload._status && ((payload._status = 0), (payload._result = ctor));
257 }
258 if (1 === payload._status) return payload._result.default;
259 throw payload._result;
260}
261function createCacheRoot() {
262 return new WeakMap();
263}
264function createCacheNode() {
265 return { s: 0, v: void 0, o: null, p: null };
266}
267exports.Children = {
268 map: mapChildren,
269 forEach: function (children, forEachFunc, forEachContext) {
270 mapChildren(
271 children,
272 function () {
273 forEachFunc.apply(this, arguments);
274 },
275 forEachContext
276 );
277 },
278 count: function (children) {
279 var n = 0;
280 mapChildren(children, function () {
281 n++;
282 });
283 return n;
284 },
285 toArray: function (children) {
286 return (
287 mapChildren(children, function (child) {
288 return child;
289 }) || []
290 );
291 },
292 only: function (children) {
293 if (!isValidElement(children)) throw Error(formatProdErrorMessage(143));
294 return children;
295 }
296};
297exports.Fragment = REACT_FRAGMENT_TYPE;
298exports.Profiler = REACT_PROFILER_TYPE;
299exports.StrictMode = REACT_STRICT_MODE_TYPE;
300exports.Suspense = REACT_SUSPENSE_TYPE;
301exports.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE =
302 ReactSharedInternals;
303exports.cache = function (fn) {
304 return function () {
305 var dispatcher = ReactSharedInternals.A;
306 if (!dispatcher) return fn.apply(null, arguments);
307 var fnMap = dispatcher.getCacheForType(createCacheRoot);
308 dispatcher = fnMap.get(fn);
309 void 0 === dispatcher &&
310 ((dispatcher = createCacheNode()), fnMap.set(fn, dispatcher));
311 fnMap = 0;
312 for (var l = arguments.length; fnMap < l; fnMap++) {
313 var arg = arguments[fnMap];
314 if (
315 "function" === typeof arg ||
316 ("object" === typeof arg && null !== arg)
317 ) {
318 var objectCache = dispatcher.o;
319 null === objectCache && (dispatcher.o = objectCache = new WeakMap());
320 dispatcher = objectCache.get(arg);
321 void 0 === dispatcher &&
322 ((dispatcher = createCacheNode()), objectCache.set(arg, dispatcher));
323 } else
324 (objectCache = dispatcher.p),
325 null === objectCache && (dispatcher.p = objectCache = new Map()),
326 (dispatcher = objectCache.get(arg)),
327 void 0 === dispatcher &&
328 ((dispatcher = createCacheNode()),
329 objectCache.set(arg, dispatcher));
330 }
331 if (1 === dispatcher.s) return dispatcher.v;
332 if (2 === dispatcher.s) throw dispatcher.v;
333 try {
334 var result = fn.apply(null, arguments);
335 fnMap = dispatcher;
336 fnMap.s = 1;
337 return (fnMap.v = result);
338 } catch (error) {
339 throw ((result = dispatcher), (result.s = 2), (result.v = error), error);
340 }
341 };
342};
343exports.cloneElement = function (element, config, children) {
344 if (null === element || void 0 === element)
345 throw Error(formatProdErrorMessage(267, element));
346 var props = assign({}, element.props),
347 key = element.key,
348 owner = void 0;
349 if (null != config)
350 for (propName in (void 0 !== config.ref && (owner = void 0),
351 void 0 !== config.key && (key = "" + config.key),
352 config))
353 !hasOwnProperty.call(config, propName) ||
354 "key" === propName ||
355 "__self" === propName ||
356 "__source" === propName ||
357 ("ref" === propName && void 0 === config.ref) ||
358 (props[propName] = config[propName]);
359 var propName = arguments.length - 2;
360 if (1 === propName) props.children = children;
361 else if (1 < propName) {
362 for (var childArray = Array(propName), i = 0; i < propName; i++)
363 childArray[i] = arguments[i + 2];
364 props.children = childArray;
365 }
366 return ReactElement(element.type, key, void 0, void 0, owner, props);
367};
368exports.createElement = function (type, config, children) {
369 var propName,
370 props = {},
371 key = null;
372 if (null != config)
373 for (propName in (void 0 !== config.key && (key = "" + config.key), config))
374 hasOwnProperty.call(config, propName) &&
375 "key" !== propName &&
376 "__self" !== propName &&
377 "__source" !== propName &&
378 (props[propName] = config[propName]);
379 var childrenLength = arguments.length - 2;
380 if (1 === childrenLength) props.children = children;
381 else if (1 < childrenLength) {
382 for (var childArray = Array(childrenLength), i = 0; i < childrenLength; i++)
383 childArray[i] = arguments[i + 2];
384 props.children = childArray;
385 }
386 if (type && type.defaultProps)
387 for (propName in ((childrenLength = type.defaultProps), childrenLength))
388 void 0 === props[propName] &&
389 (props[propName] = childrenLength[propName]);
390 return ReactElement(type, key, void 0, void 0, null, props);
391};
392exports.createRef = function () {
393 return { current: null };
394};
395exports.forwardRef = function (render) {
396 return { $$typeof: REACT_FORWARD_REF_TYPE, render: render };
397};
398exports.isValidElement = isValidElement;
399exports.lazy = function (ctor) {
400 return {
401 $$typeof: REACT_LAZY_TYPE,
402 _payload: { _status: -1, _result: ctor },
403 _init: lazyInitializer
404 };
405};
406exports.memo = function (type, compare) {
407 return {
408 $$typeof: REACT_MEMO_TYPE,
409 type: type,
410 compare: void 0 === compare ? null : compare
411 };
412};
413exports.use = function (usable) {
414 return ReactSharedInternals.H.use(usable);
415};
416exports.useCallback = function (callback, deps) {
417 return ReactSharedInternals.H.useCallback(callback, deps);
418};
419exports.useDebugValue = function () {};
420exports.useId = function () {
421 return ReactSharedInternals.H.useId();
422};
423exports.useMemo = function (create, deps) {
424 return ReactSharedInternals.H.useMemo(create, deps);
425};
426exports.version = "19.0.0";