sunpeak 0.5.35 → 0.5.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/commands/build.mjs +10 -0
- package/bin/commands/dev.mjs +13 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/style.css +8 -4
- package/package.json +1 -1
- package/template/dist/chatgpt/albums.js +14 -54
- package/template/dist/chatgpt/carousel.js +14 -54
- package/template/dist/chatgpt/counter.js +14 -54
- package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_Button.js +13 -858
- package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_Button.js.map +4 -4
- package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_Checkbox.js +33 -0
- package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_Checkbox.js.map +7 -0
- package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_Icon.js +4 -4
- package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_Input.js +13 -0
- package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_SegmentedControl.js +103 -0
- package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_SegmentedControl.js.map +7 -0
- package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_Select.js +1019 -0
- package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_Select.js.map +7 -0
- package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_Textarea.js +95 -0
- package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_Textarea.js.map +7 -0
- package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_theme.js +45 -0
- package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_theme.js.map +7 -0
- package/template/node_modules/.vite/deps/_metadata.json +82 -25
- package/template/node_modules/.vite/deps/{chunk-TNWQ7JGO.js → chunk-4TLBUCVB.js} +2 -2
- package/template/node_modules/.vite/deps/chunk-675LFNY2.js +628 -0
- package/template/node_modules/.vite/deps/chunk-675LFNY2.js.map +7 -0
- package/template/node_modules/.vite/deps/chunk-BAG6OO6S.js +115 -0
- package/template/node_modules/.vite/deps/chunk-BAG6OO6S.js.map +7 -0
- package/template/node_modules/.vite/deps/chunk-CQ3GYAYB.js +112 -0
- package/template/node_modules/.vite/deps/chunk-CQ3GYAYB.js.map +7 -0
- package/template/node_modules/.vite/deps/chunk-EGRHWZRV.js +1 -0
- package/template/node_modules/.vite/deps/chunk-EGRHWZRV.js.map +7 -0
- package/template/node_modules/.vite/deps/{chunk-5WRI5ZAA.js → chunk-ILHRZGIS.js} +17 -2
- package/template/node_modules/.vite/deps/chunk-ILHRZGIS.js.map +7 -0
- package/template/node_modules/.vite/deps/{chunk-DUV225XW.js → chunk-KFGKZMLK.js} +3 -3
- package/template/node_modules/.vite/deps/{chunk-7IRBE5E4.js → chunk-PTVT3RFX.js} +3 -3
- package/template/node_modules/.vite/deps/chunk-QPJAV452.js +13 -0
- package/template/node_modules/.vite/deps/chunk-QPJAV452.js.map +7 -0
- package/template/node_modules/.vite/deps/chunk-SGWD4VEU.js +15195 -0
- package/template/node_modules/.vite/deps/chunk-SGWD4VEU.js.map +7 -0
- package/template/node_modules/.vite/deps/{chunk-D3BYX6F4.js → chunk-XB525PXG.js} +3 -3
- package/template/node_modules/.vite/deps/chunk-YOJ6QPGS.js +231 -0
- package/template/node_modules/.vite/deps/chunk-YOJ6QPGS.js.map +7 -0
- package/template/node_modules/.vite/deps/clsx.js +1 -1
- package/template/node_modules/.vite/deps/embla-carousel-react.js +2 -2
- package/template/node_modules/.vite/deps/embla-carousel-wheel-gestures.js +1 -1
- package/template/node_modules/.vite/deps/react-dom.js +3 -3
- package/template/node_modules/.vite/deps/react-dom_client.js +3 -3
- package/template/node_modules/.vite/deps/react.js +2 -2
- package/template/node_modules/.vite/deps/react_jsx-dev-runtime.js +2 -2
- package/template/node_modules/.vite/deps/react_jsx-runtime.js +3 -3
- package/template/node_modules/.vite/deps/tailwind-merge.js +1 -1
- package/template/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -1
- package/template/src/components/resources/counter-resource.test.tsx +4 -4
- package/template/src/components/resources/counter-resource.tsx +5 -5
- /package/template/node_modules/.vite/deps/{chunk-5WRI5ZAA.js.map → @openai_apps-sdk-ui_components_Input.js.map} +0 -0
- /package/template/node_modules/.vite/deps/{chunk-TNWQ7JGO.js.map → chunk-4TLBUCVB.js.map} +0 -0
- /package/template/node_modules/.vite/deps/{chunk-DUV225XW.js.map → chunk-KFGKZMLK.js.map} +0 -0
- /package/template/node_modules/.vite/deps/{chunk-7IRBE5E4.js.map → chunk-PTVT3RFX.js.map} +0 -0
- /package/template/node_modules/.vite/deps/{chunk-D3BYX6F4.js.map → chunk-XB525PXG.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [
|
|
4
|
-
"sourcesContent": ["/**\n * lodash (Custom Build) <https://lodash.com/>\n * Build: `lodash modularize exports=\"npm\" -o ./`\n * Copyright jQuery Foundation and other contributors <https://jquery.org/>\n * Released under MIT license <https://lodash.com/license>\n * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>\n * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n */\n\n/** Used as the `TypeError` message for \"Functions\" methods. */\nvar FUNC_ERROR_TEXT = 'Expected a function';\n\n/** Used as references for various `Number` constants. */\nvar NAN = 0 / 0;\n\n/** `Object#toString` result references. */\nvar symbolTag = '[object Symbol]';\n\n/** Used to match leading and trailing whitespace. */\nvar reTrim = /^\\s+|\\s+$/g;\n\n/** Used to detect bad signed hexadecimal string values. */\nvar reIsBadHex = /^[-+]0x[0-9a-f]+$/i;\n\n/** Used to detect binary string values. */\nvar reIsBinary = /^0b[01]+$/i;\n\n/** Used to detect octal string values. */\nvar reIsOctal = /^0o[0-7]+$/i;\n\n/** Built-in method references without a dependency on `root`. */\nvar freeParseInt = parseInt;\n\n/** Detect free variable `global` from Node.js. */\nvar freeGlobal = typeof global == 'object' && global && global.Object === Object && global;\n\n/** Detect free variable `self`. */\nvar freeSelf = typeof self == 'object' && self && self.Object === Object && self;\n\n/** Used as a reference to the global object. */\nvar root = freeGlobal || freeSelf || Function('return this')();\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar objectToString = objectProto.toString;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeMax = Math.max,\n nativeMin = Math.min;\n\n/**\n * Gets the timestamp of the number of milliseconds that have elapsed since\n * the Unix epoch (1 January 1970 00:00:00 UTC).\n *\n * @static\n * @memberOf _\n * @since 2.4.0\n * @category Date\n * @returns {number} Returns the timestamp.\n * @example\n *\n * _.defer(function(stamp) {\n * console.log(_.now() - stamp);\n * }, _.now());\n * // => Logs the number of milliseconds it took for the deferred invocation.\n */\nvar now = function() {\n return root.Date.now();\n};\n\n/**\n * Creates a debounced function that delays invoking `func` until after `wait`\n * milliseconds have elapsed since the last time the debounced function was\n * invoked. The debounced function comes with a `cancel` method to cancel\n * delayed `func` invocations and a `flush` method to immediately invoke them.\n * Provide `options` to indicate whether `func` should be invoked on the\n * leading and/or trailing edge of the `wait` timeout. The `func` is invoked\n * with the last arguments provided to the debounced function. Subsequent\n * calls to the debounced function return the result of the last `func`\n * invocation.\n *\n * **Note:** If `leading` and `trailing` options are `true`, `func` is\n * invoked on the trailing edge of the timeout only if the debounced function\n * is invoked more than once during the `wait` timeout.\n *\n * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred\n * until to the next tick, similar to `setTimeout` with a timeout of `0`.\n *\n * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)\n * for details over the differences between `_.debounce` and `_.throttle`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to debounce.\n * @param {number} [wait=0] The number of milliseconds to delay.\n * @param {Object} [options={}] The options object.\n * @param {boolean} [options.leading=false]\n * Specify invoking on the leading edge of the timeout.\n * @param {number} [options.maxWait]\n * The maximum time `func` is allowed to be delayed before it's invoked.\n * @param {boolean} [options.trailing=true]\n * Specify invoking on the trailing edge of the timeout.\n * @returns {Function} Returns the new debounced function.\n * @example\n *\n * // Avoid costly calculations while the window size is in flux.\n * jQuery(window).on('resize', _.debounce(calculateLayout, 150));\n *\n * // Invoke `sendMail` when clicked, debouncing subsequent calls.\n * jQuery(element).on('click', _.debounce(sendMail, 300, {\n * 'leading': true,\n * 'trailing': false\n * }));\n *\n * // Ensure `batchLog` is invoked once after 1 second of debounced calls.\n * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });\n * var source = new EventSource('/stream');\n * jQuery(source).on('message', debounced);\n *\n * // Cancel the trailing debounced invocation.\n * jQuery(window).on('popstate', debounced.cancel);\n */\nfunction debounce(func, wait, options) {\n var lastArgs,\n lastThis,\n maxWait,\n result,\n timerId,\n lastCallTime,\n lastInvokeTime = 0,\n leading = false,\n maxing = false,\n trailing = true;\n\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n wait = toNumber(wait) || 0;\n if (isObject(options)) {\n leading = !!options.leading;\n maxing = 'maxWait' in options;\n maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;\n trailing = 'trailing' in options ? !!options.trailing : trailing;\n }\n\n function invokeFunc(time) {\n var args = lastArgs,\n thisArg = lastThis;\n\n lastArgs = lastThis = undefined;\n lastInvokeTime = time;\n result = func.apply(thisArg, args);\n return result;\n }\n\n function leadingEdge(time) {\n // Reset any `maxWait` timer.\n lastInvokeTime = time;\n // Start the timer for the trailing edge.\n timerId = setTimeout(timerExpired, wait);\n // Invoke the leading edge.\n return leading ? invokeFunc(time) : result;\n }\n\n function remainingWait(time) {\n var timeSinceLastCall = time - lastCallTime,\n timeSinceLastInvoke = time - lastInvokeTime,\n result = wait - timeSinceLastCall;\n\n return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;\n }\n\n function shouldInvoke(time) {\n var timeSinceLastCall = time - lastCallTime,\n timeSinceLastInvoke = time - lastInvokeTime;\n\n // Either this is the first call, activity has stopped and we're at the\n // trailing edge, the system time has gone backwards and we're treating\n // it as the trailing edge, or we've hit the `maxWait` limit.\n return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||\n (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));\n }\n\n function timerExpired() {\n var time = now();\n if (shouldInvoke(time)) {\n return trailingEdge(time);\n }\n // Restart the timer.\n timerId = setTimeout(timerExpired, remainingWait(time));\n }\n\n function trailingEdge(time) {\n timerId = undefined;\n\n // Only invoke if we have `lastArgs` which means `func` has been\n // debounced at least once.\n if (trailing && lastArgs) {\n return invokeFunc(time);\n }\n lastArgs = lastThis = undefined;\n return result;\n }\n\n function cancel() {\n if (timerId !== undefined) {\n clearTimeout(timerId);\n }\n lastInvokeTime = 0;\n lastArgs = lastCallTime = lastThis = timerId = undefined;\n }\n\n function flush() {\n return timerId === undefined ? result : trailingEdge(now());\n }\n\n function debounced() {\n var time = now(),\n isInvoking = shouldInvoke(time);\n\n lastArgs = arguments;\n lastThis = this;\n lastCallTime = time;\n\n if (isInvoking) {\n if (timerId === undefined) {\n return leadingEdge(lastCallTime);\n }\n if (maxing) {\n // Handle invocations in a tight loop.\n timerId = setTimeout(timerExpired, wait);\n return invokeFunc(lastCallTime);\n }\n }\n if (timerId === undefined) {\n timerId = setTimeout(timerExpired, wait);\n }\n return result;\n }\n debounced.cancel = cancel;\n debounced.flush = flush;\n return debounced;\n}\n\n/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return !!value && (type == 'object' || type == 'function');\n}\n\n/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n return !!value && typeof value == 'object';\n}\n\n/**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n *\n * _.isSymbol(Symbol.iterator);\n * // => true\n *\n * _.isSymbol('abc');\n * // => false\n */\nfunction isSymbol(value) {\n return typeof value == 'symbol' ||\n (isObjectLike(value) && objectToString.call(value) == symbolTag);\n}\n\n/**\n * Converts `value` to a number.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to process.\n * @returns {number} Returns the number.\n * @example\n *\n * _.toNumber(3.2);\n * // => 3.2\n *\n * _.toNumber(Number.MIN_VALUE);\n * // => 5e-324\n *\n * _.toNumber(Infinity);\n * // => Infinity\n *\n * _.toNumber('3.2');\n * // => 3.2\n */\nfunction toNumber(value) {\n if (typeof value == 'number') {\n return value;\n }\n if (isSymbol(value)) {\n return NAN;\n }\n if (isObject(value)) {\n var other = typeof value.valueOf == 'function' ? value.valueOf() : value;\n value = isObject(other) ? (other + '') : other;\n }\n if (typeof value != 'string') {\n return value === 0 ? value : +value;\n }\n value = value.replace(reTrim, '');\n var isBinary = reIsBinary.test(value);\n return (isBinary || reIsOctal.test(value))\n ? freeParseInt(value.slice(2), isBinary ? 2 : 8)\n : (reIsBadHex.test(value) ? NAN : +value);\n}\n\nmodule.exports = debounce;\n", "\"use client\"\n\nimport clsx from \"clsx\"\nimport {\n type ButtonHTMLAttributes,\n type ComponentProps,\n type ComponentType,\n type MouseEventHandler,\n type ReactNode,\n useCallback,\n} from \"react\"\nimport { handlePressableMouseEnter } from \"../../lib/helpers\"\nimport { wrapTextNodeSiblings } from \"../../lib/renderHelpers\"\nimport { type ControlSize, type SemanticColors, type Sizes, type Variants } from \"../../types\"\nimport { useLinkComponent } from \"../AppsSDKUIProvider/internal\"\nimport { LoadingIndicator } from \"../Indicator\"\nimport { TransitionGroup } from \"../Transition/TransitionGroup\"\nimport s from \"./Button.module.css\"\n\ntype CommonProps = {\n /**\n * Color for the button\n * @default secondary\n */\n color: SemanticColors<\n \"primary\" | \"secondary\" | \"danger\" | \"success\" | \"info\" | \"discovery\" | \"caution\" | \"warning\"\n >\n /**\n * Style variant for the Button\n * @default \"solid\"\n */\n variant?: Variants<\"solid\" | \"soft\" | \"outline\" | \"ghost\">\n /**\n * Determines if the button should be a fully rounded pill shape\n * @default false\n */\n pill?: boolean\n /**\n * Disables the button visually and from interactions\n * @default false\n */\n disabled?: boolean\n /**\n * Controls the visual tone when the button is disabled. \"relaxed\" will use a default cursor instead of not-allowed.\n */\n disabledTone?: \"relaxed\"\n /**\n * Determines if the button should take up 100% of available width\n * @default false\n */\n block?: boolean\n /**\n * Applies a negative margin using the current gutter to optically align the button\n * with surrounding content.\n */\n opticallyAlign?: \"start\" | \"end\"\n /**\n * Controls size of the button, specifically height, but also includes defaults for `gutterSize`, `iconSize`, `font-size`, etc.\n *\n * | 3xs | 2xs | xs | sm | md | lg | xl | 2xl | 3xl |\n * | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- |\n * | `22px` | `24px` | `26px` | `28px` | `32px` | `36px` | `40px` | `44px` | `48px` |\n * @default md\n */\n size?: ControlSize\n /**\n * Controls the size of icons within the button, defaults to value from `size`.\n *\n * | xs | sm | md | lg | xl | 2xl |\n * | ------ | ------ | ------ | ------ | ------ | ------ |\n * | `14px` | `16px` | `18px` | `20px` | `22px` | `24px` |\n */\n iconSize?: Sizes<\"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\">\n /**\n * Controls gutter on the edges of the button, defaults to value from `size`.\n *\n * | 3xs | 2xs | xs | sm | md | lg | xl |\n * | ------ | ------ | ------ | ------ | ------ | ------ | ------ |\n * | `4px` | `6px` | `8px` | `10px` | `12px` | `14px` | `16px` |\n */\n gutterSize?: Sizes<\"3xs\" | \"2xs\" | \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\">\n /** Custom class applied to the Button element */\n className?: string\n /** Content rendered inside of the Button */\n children: React.ReactNode\n}\n\nexport type ButtonProps = CommonProps & {\n /**\n * Determines if the button should have matching width and height, based on the `size`.\n * @default false\n */\n uniform?: boolean\n /**\n * Displays selected styles on the button, varying by `variant\n * @default false\n */\n selected?: boolean\n /**\n * Displays loading indicator on top of button contents\n * @default false\n */\n loading?: boolean\n /**\n * Determines whether the button should be made inert, without introducing visual change.\n * @default false\n */\n inert?: boolean\n /** Ref for the button */\n ref?: React.Ref<HTMLButtonElement | null>\n} & ButtonHTMLAttributes<HTMLButtonElement>\n\nexport const Button = (props: ButtonProps) => {\n const {\n type = \"button\",\n color = \"primary\",\n variant = \"solid\",\n pill = true,\n uniform = false,\n size = \"md\",\n iconSize,\n gutterSize,\n loading,\n selected,\n block,\n opticallyAlign,\n children,\n className,\n onClick,\n disabled,\n disabledTone,\n // Defaults to `loading` state\n inert = loading,\n ...restProps\n } = props\n\n const isInert = disabled || inert\n\n const handleClick: MouseEventHandler<HTMLButtonElement> = useCallback(\n (e) => {\n if (disabled) {\n return\n }\n onClick?.(e)\n },\n [onClick, disabled],\n )\n\n return (\n <button\n type={type}\n className={clsx(s.Button, className)}\n data-color={color}\n data-variant={variant}\n data-pill={pill ? \"\" : undefined}\n data-uniform={uniform ? \"\" : undefined}\n data-size={size}\n data-gutter-size={gutterSize}\n data-icon-size={iconSize}\n data-loading={loading ? \"\" : undefined}\n data-selected={selected ? \"\" : undefined}\n data-block={block ? \"\" : undefined}\n data-optically-align={opticallyAlign}\n onPointerEnter={handlePressableMouseEnter}\n // Non-visual, accessible disablement\n // NOTE: Do not use literal `inert` because that is incorrect semantically\n disabled={isInert}\n aria-disabled={isInert}\n tabIndex={isInert ? -1 : undefined}\n // Visual disablement\n data-disabled={disabled ? \"\" : undefined}\n data-disabled-tone={disabled ? disabledTone : undefined}\n onClick={handleClick}\n {...restProps}\n >\n <TransitionGroup className={s.ButtonLoader} enterDuration={250} exitDuration={150}>\n {loading && <LoadingIndicator key=\"loader\" />}\n </TransitionGroup>\n <span className={s.ButtonInner}>{wrapTextNodeSiblings(children)}</span>\n </button>\n )\n}\n\ntype ButtonLink = <\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends ComponentType<any> | \"a\" = AppsSDKUI.LinkComponent,\n>(\n props: Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, \"href\"> &\n CommonProps & {\n /**\n * Explicity specify that the link is an external link. This should be\n * automatically detected based on the URL, but in some cases (e.g.\n * my-app://foo) you may want to explicitly set this.\n */\n external?: boolean\n /**\n * Override the default component used for the link. This is useful for\n * using a routing library, or SSR rendering.\n * purposes.\n *\n * @default 'a'\n */\n as?: T\n } & ComponentProps<T>,\n) => ReactNode\n\nexport const ButtonLink = ((\n props: Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, \"href\"> &\n CommonProps & {\n href?: string\n to?: string\n external?: boolean\n as?: AppsSDKUI.LinkComponent\n },\n) => {\n const {\n color = \"primary\",\n variant = \"solid\",\n pill = true,\n size = \"md\",\n gutterSize,\n iconSize,\n external,\n block,\n opticallyAlign,\n children,\n className,\n disabled,\n disabledTone,\n onClick,\n onPointerEnter,\n as: OverrideComponent,\n href,\n to,\n ...restProps\n } = props\n\n const isExternal = external ?? /^https?:\\/\\//.test(href ?? to ?? \"\")\n const DefaultComponent = useLinkComponent()\n const LinkComponent = OverrideComponent || (isExternal ? \"a\" : DefaultComponent)\n\n const sharedProps = {\n \"className\": clsx(s.Button, className),\n disabled,\n \"aria-disabled\": disabled,\n \"tabIndex\": disabled ? -1 : undefined,\n // Visual disablement (inert not supported in links, always applied)\n \"data-disabled\": disabled ? \"\" : undefined,\n \"data-disabled-tone\": disabled ? disabledTone : undefined,\n \"data-color\": color,\n \"data-variant\": variant,\n \"data-pill\": pill ? \"\" : undefined,\n \"data-block\": block ? \"\" : undefined,\n \"data-optically-align\": opticallyAlign,\n \"data-size\": size,\n \"data-gutter-size\": gutterSize,\n \"data-icon-size\": iconSize,\n \"onClick\": disabled ? undefined : onClick,\n \"onPointerEnter\": (evt: React.PointerEvent<HTMLAnchorElement>) => {\n handlePressableMouseEnter(evt)\n onPointerEnter?.(evt)\n },\n }\n\n if (disabled) {\n // Don't thread down stuff that isn't valid for a span - just keep the event handlers\n const eventProps = Object.fromEntries(\n Object.entries(restProps).filter(\n ([key, value]) => key.startsWith(\"on\") && typeof value === \"function\",\n ),\n )\n return (\n <span role=\"link\" {...sharedProps} {...eventProps}>\n <span className={s.ButtonInner}>{wrapTextNodeSiblings(children)}</span>\n </span>\n )\n }\n\n const linkProps = {\n ...(isExternal\n ? { target: \"_blank\", rel: \"noopener noreferrer\", href: href ?? to }\n : { href, to }),\n ...sharedProps,\n ...restProps,\n }\n\n return (\n <LinkComponent {...linkProps}>\n <span className={s.ButtonInner}>{wrapTextNodeSiblings(children)}</span>\n </LinkComponent>\n )\n}) as ButtonLink\n", "import { type CSSProperties } from \"react\"\nimport { canUseDOM, hasDocument, hasWindow } from \"./environment\"\nimport type { Pretty } from \"./utilityTypes\"\n\nexport const prefersReducedMotion = () => {\n if (!hasWindow || typeof window.matchMedia !== \"function\") {\n return false\n }\n\n return window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches\n}\n\nexport const handlePressableMouseEnter = (evt: React.MouseEvent) => {\n const target = evt.currentTarget\n\n // Safely coerce type to HTMLElement so TS is peaceful with `evt.target`\n if (!(target instanceof HTMLElement)) {\n return\n }\n\n const elementWidth = target.offsetWidth\n\n let scale = 0.985\n\n if (elementWidth <= 80) {\n scale = 0.96\n } else if (elementWidth <= 150) {\n scale = 0.97\n } else if (elementWidth <= 220) {\n scale = 0.98\n } else if (elementWidth > 600) {\n scale = 0.995\n }\n\n target.style.setProperty(\"--scale\", scale.toString())\n}\n\ninterface CancelAnimationFrame {\n (): void\n}\n\nexport const waitForAnimationFrame = (\n cb: () => void,\n options?: { frames: number },\n): CancelAnimationFrame => {\n const runAfterTick = () => {\n const id = setTimeout(cb)\n return () => {\n clearTimeout(id)\n }\n }\n\n if (!canUseDOM || typeof window.requestAnimationFrame !== \"function\") {\n return runAfterTick()\n }\n\n const visibilityHidden = hasDocument && document.visibilityState === \"hidden\"\n if (visibilityHidden) {\n return runAfterTick()\n }\n\n let frames = options?.frames ?? 2\n let animationFrame = window.requestAnimationFrame(function recurse() {\n frames -= 1\n if (frames === 0) {\n cb()\n } else {\n animationFrame = window.requestAnimationFrame(recurse)\n }\n })\n\n return () => {\n if (typeof window.cancelAnimationFrame === \"function\") {\n window.cancelAnimationFrame(animationFrame)\n }\n }\n}\n\nexport const toCssVariables = (\n variables: Record<string, string | number | undefined>,\n): CSSProperties => {\n const formattedVariables = Object.keys(variables).reduce(\n (acc, variable) => {\n // Ensure value is truthy\n const value = variables[variable]\n // Accept 0 as a valid value\n if (value || value === 0) {\n // Add the prefix if it wasn't already provided\n const prefix = variable.startsWith(\"--\") ? \"\" : \"--\"\n const formattedValue = typeof value === \"number\" ? `${value}px` : value\n\n acc[`${prefix}${variable}`] = formattedValue\n }\n\n return acc\n },\n {} as Record<string, string>,\n )\n\n // Safe casting because we know we've formatted an object of CSS Variable strings\n return formattedVariables as CSSProperties\n}\n\nexport const toAngle = (value: number | string): string =>\n typeof value === \"number\" ? `${value}deg` : value\n\nexport const toOpacityProperty = (opacity: number): string => String(opacity)\n\nexport const toMsDurationProperty = (duration: number): string => `${duration}ms`\n\nexport const toTransformProperty = ({\n x,\n y,\n scale,\n rotate,\n skewX,\n skewY,\n}: {\n x?: number\n y?: number\n scale?: number\n rotate?: number | string\n skewX?: number | string\n skewY?: number | string\n} = {}): string => {\n const transforms = [\n x == null ? null : `translateX(${x}px)`,\n y == null ? null : `translateY(${y}px)`,\n scale == null ? null : `scale(${scale})`,\n rotate == null ? null : `rotate(${toAngle(rotate)})`,\n skewX == null ? null : `skewX(${toAngle(skewX)})`,\n skewY == null ? null : `skewY(${toAngle(skewY)})`,\n ].filter(Boolean)\n\n return transforms.length ? transforms.join(\" \") : \"none\"\n}\n\nexport const toFilterProperty = ({ blur }: { blur?: number | undefined } = {}) => {\n // Maybe add more support in the future\n const filters = [blur == null ? null : `blur(${blur}px)`].filter(Boolean)\n\n return filters.length ? filters.join(\" \") : \"none\"\n}\n\nexport const preventDefaultHandler = (evt: Event) => {\n evt.preventDefault()\n}\n\n/*\n * Intentionally simple selector string. Purposeful exclusions: (for now)\n * - select, because our selects are better recognized as button\n * - unused selectors like iframe, object, .etc.\n * - states like [inert]\n */\nexport const focusableElements = (element: HTMLElement) =>\n element.querySelectorAll<HTMLElement>(\n 'a[href], input:not([disabled]):not([type=\"hidden\"]), textarea:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex^=\"-\"]), [contenteditable]',\n )\n\nexport const sleep = (ms: number): Promise<void> =>\n new Promise((resolve) => setTimeout(resolve, ms))\n\n/**\n * Group an array of objects by a property, preserving the *first-seen* order\n * of each group.\n *\n * @example\n * groupByOrdered(people, \"team\")\n * // => [ { team: \"infra\", items:[...] }, { team:\"design\", items:[...] }, ... ]\n */\nexport function groupByProperty<T extends object, K extends keyof T, F = T[K]>(\n items: T[],\n key: K,\n format: (raw: T[K], item: T) => F = (raw) => raw as F,\n) {\n const groups: Pretty<{ [P in K]: F } & { items: T[] }>[] = []\n const indexMap = new Map<unknown, number>() // maps group value -> index in groups array\n\n for (const item of items) {\n const value = format(item[key], item)\n\n // Add to existing group\n const existing = indexMap.get(value)\n if (existing !== undefined) {\n groups[existing].items.push(item)\n continue\n }\n\n // Create new group\n const group = { [key]: value, items: [item] } as { [P in K]: F } & { items: T[] }\n indexMap.set(value, groups.length)\n groups.push(group)\n }\n\n return groups\n}\n", "const META_ENV = typeof import.meta !== \"undefined\" ? import.meta.env : undefined\n\nconst NODE_ENV =\n typeof process !== \"undefined\" && process.env?.NODE_ENV ? process.env?.NODE_ENV : \"production\"\n\nexport const isDev = NODE_ENV === \"development\" || !!META_ENV?.DEV\n\nexport const isJSDomLike =\n (typeof navigator !== \"undefined\" && /(jsdom|happy-dom)/i.test(navigator.userAgent)) ||\n typeof (globalThis as Record<string, unknown>).happyDOM === \"object\"\n\nexport const isTest = NODE_ENV === \"test\" || META_ENV?.MODE === \"test\" || isJSDomLike\n\nexport const hasWindow = typeof window !== \"undefined\"\nexport const hasDocument = typeof document !== \"undefined\"\nexport const canUseDOM = hasWindow && hasDocument\n", "import { Children, cloneElement, isValidElement, type ReactElement, type ReactNode } from \"react\"\n\nconst flattenTextNodes = (children: ReactNode): ReactNode[] => {\n const nodes = Children.toArray(children)\n const result: ReactNode[] = []\n let buffer = \"\"\n\n const flush = () => {\n if (buffer !== \"\") {\n result.push(buffer)\n buffer = \"\"\n }\n }\n\n for (const node of nodes) {\n if (node == null || typeof node === \"boolean\") {\n continue\n }\n\n if (typeof node === \"string\" || typeof node === \"number\") {\n buffer += String(node)\n continue\n }\n\n // Boundary encountered: output any accumulated text, then the node\n flush()\n result.push(node)\n }\n\n flush()\n return result\n}\n\n// Helper to wrap text node siblings of other elements in a tag,\n// which enables sibling selectors to behave as expected for certain conditions\nexport const wrapTextNodeSiblings = (children: ReactNode): ReactNode => {\n const flattenedChildren = flattenTextNodes(children)\n const childrenCount = Children.count(flattenedChildren)\n\n return Children.map(flattenedChildren, (child) => {\n if (typeof child === \"string\" && !!child.trim()) {\n // Children with no siblings can immediately return\n if (childrenCount <= 1) {\n return child\n }\n\n // Wrap text nodes that have siblings\n return <span>{child}</span>\n }\n\n // For valid elements, recursively render to capture wrapped children\n if (isValidElement(child)) {\n const element = child as ReactElement<{ children?: ReactNode }>\n const { children: innerChildren, ...restProps } = element.props\n\n if (innerChildren != null) {\n return cloneElement(element, restProps, wrapTextNodeSiblings(innerChildren))\n }\n\n return element\n }\n\n return child\n })\n}\n", "\"use client\"\n\nimport { useContext } from \"react\"\nimport { AppsSDKUIContext } from \"./AppsSDKUIContext\"\n\nexport function useLinkComponent() {\n const context = useContext(AppsSDKUIContext)\n return context?.linkComponent ?? \"a\"\n}\n", "\"use client\"\n\nimport { type ComponentType, createContext, type ForwardRefExoticComponent } from \"react\"\n\ntype AppsSDKUIContextValue = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n linkComponent: ComponentType<any> | ForwardRefExoticComponent<any> | \"a\"\n}\n\nexport const AppsSDKUIContext = createContext<AppsSDKUIContextValue | null>(null)\n", "\"use client\"\n\nimport clsx from \"clsx\"\nimport { useState, type ComponentProps } from \"react\"\nimport { useSimulatedProgress } from \"../../hooks/useSimulatedProgress\"\n\nimport { toCssVariables } from \"../../lib/helpers\"\nimport s from \"./CircularProgress.module.css\"\n\nexport type CircularProgressProps = Omit<ComponentProps<\"div\">, \"children\"> & {\n /**\n * Maximum duration to use for simulated upload progress in ms\n * @default 15000\n */\n maxDuration?: number\n /**\n * Sets the progress to full and resolves the simulated timer\n * @default false\n */\n done?: boolean\n /**\n * Sets the progress to full and resolves the simulated timer\n * @default false\n */\n progress?: number\n /** Size of the indicator, in pixels\n * @default 28px\n */\n size?: number | string\n /** Stroke width of the indicator, in pixels, between 1 and 4\n * @default 2\n */\n strokeWidth?: number\n /** Color of the active progress track (stroke) */\n trackActiveColor?: string\n /** Color of the base track (background stroke) */\n trackColor?: string\n}\n\nexport const CircularProgress = ({\n maxDuration = 15000, // 15 seconds\n done = false,\n className,\n progress: propProgress,\n size,\n strokeWidth,\n trackActiveColor,\n trackColor,\n style,\n ...restProps\n}: CircularProgressProps) => {\n const [currentTime] = useState(new Date())\n const simulatedProgressDone = propProgress !== undefined || done\n const simulatedProgress = useSimulatedProgress(+currentTime, maxDuration, simulatedProgressDone)\n const progress = propProgress ?? simulatedProgress\n\n return (\n <div\n {...restProps}\n className={clsx(s.Container, className)}\n style={\n style ||\n toCssVariables({\n \"circular-progress-size\": size,\n \"circular-progress-stroke\": strokeWidth ? Math.min(4, strokeWidth) : undefined,\n \"circular-progress-track-active-color\": trackActiveColor,\n \"circular-progress-track-color\": trackColor,\n })\n }\n >\n <svg viewBox=\"0 0 20 20\" className={s.Track} data-no-autosize>\n <circle cx=\"10\" cy=\"10\" r=\"8\" fill=\"none\" />\n </svg>\n <svg\n viewBox=\"0 0 20 20\"\n className={s.TrackProgress}\n style={{\n strokeDashoffset: 50 - 50 * (progress / 100),\n }}\n data-no-autosize\n >\n <circle cx=\"10\" cy=\"10\" r=\"8\" fill=\"none\" />\n </svg>\n </div>\n )\n}\n", "import { useState } from \"react\"\nimport { useInterval } from \"usehooks-ts\"\n\n/**\n * Deterministically returns a progress value between 0 and 100 that decays as it approaches 100,\n * based on a maximum duration and the elapsed time.\n *\n * @param maxTime - The maximum duration (in ms) after which the progress will be 100\n * @param elapsedTime - The elapsed time (in ms) since the start time\n * @returns The simulated progress percentage\n */\nexport function getSimulatedProgress(maxTime: number, elapsedTime: number) {\n // Parameters\n const P_max = 99.9 // Maximum percentage to approach (less than 100%)\n const P1 = 35 // Percentage at which the rate slows down\n const initialRate = (3 * 100) / maxTime // Initial rate (% per second)\n const t1 = P1 / initialRate // Time when progress reaches P1\n\n let percentage\n\n if (elapsedTime <= t1) {\n // **Phase 1:** Linear increase at the start to show consistency in progress\n percentage = initialRate * elapsedTime\n } else {\n // **Phase 2:** Progress slows down, approaching P_max\n const k = 4 // Controls how quickly progress approaches P_max\n const remainingTime = maxTime - t1\n const timeSinceT1 = elapsedTime - t1\n const exponent = -k * (timeSinceT1 / remainingTime)\n percentage = P1 + (P_max - P1) * (1 - Math.exp(exponent))\n }\n\n // Ensure the percentage does not exceed P_max\n return Math.min(percentage, P_max)\n}\n\n/**\n * Returns a number that will increase over time, decaying as it approaches 100,\n * withouth ever reaching the end.\n *\n * @param startAt - The time at which the progress started\n * @param maxDuration - The maximum duration (in ms) after which the progress will be 100\n * @param completed - Sets progress to 100% immediately\n */\nexport const useSimulatedProgress = (startAt: number, maxDuration: number, completed?: boolean) => {\n const elapsedStartTime = +new Date() - startAt\n const [progress, setProgress] = useState(getSimulatedProgress(maxDuration, elapsedStartTime))\n\n const incrementProgress = () => {\n const elapsedTime = +new Date() - startAt\n const newProgress =\n elapsedTime >= maxDuration ? 100 : getSimulatedProgress(maxDuration, elapsedTime)\n setProgress(newProgress)\n }\n\n useInterval(incrementProgress, completed ? null : 100)\n\n return completed ? 100 : progress\n}\n", "import { useState, useCallback, useLayoutEffect, useEffect, useRef, useMemo } from 'react';\nimport debounce from 'lodash.debounce';\n\n// src/useBoolean/useBoolean.ts\nfunction useBoolean(defaultValue = false) {\n if (typeof defaultValue !== \"boolean\") {\n throw new Error(\"defaultValue must be `true` or `false`\");\n }\n const [value, setValue] = useState(defaultValue);\n const setTrue = useCallback(() => {\n setValue(true);\n }, []);\n const setFalse = useCallback(() => {\n setValue(false);\n }, []);\n const toggle = useCallback(() => {\n setValue((x) => !x);\n }, []);\n return { value, setValue, setTrue, setFalse, toggle };\n}\nvar useIsomorphicLayoutEffect = typeof window !== \"undefined\" ? useLayoutEffect : useEffect;\n\n// src/useEventListener/useEventListener.ts\nfunction useEventListener(eventName, handler, element, options) {\n const savedHandler = useRef(handler);\n useIsomorphicLayoutEffect(() => {\n savedHandler.current = handler;\n }, [handler]);\n useEffect(() => {\n const targetElement = (element == null ? void 0 : element.current) ?? window;\n if (!(targetElement && targetElement.addEventListener))\n return;\n const listener = (event) => {\n savedHandler.current(event);\n };\n targetElement.addEventListener(eventName, listener, options);\n return () => {\n targetElement.removeEventListener(eventName, listener, options);\n };\n }, [eventName, element, options]);\n}\n\n// src/useClickAnyWhere/useClickAnyWhere.ts\nfunction useClickAnyWhere(handler) {\n useEventListener(\"click\", (event) => {\n handler(event);\n });\n}\nfunction useCopyToClipboard() {\n const [copiedText, setCopiedText] = useState(null);\n const copy = useCallback(async (text) => {\n if (!(navigator == null ? void 0 : navigator.clipboard)) {\n console.warn(\"Clipboard not supported\");\n return false;\n }\n try {\n await navigator.clipboard.writeText(text);\n setCopiedText(text);\n return true;\n } catch (error) {\n console.warn(\"Copy failed\", error);\n setCopiedText(null);\n return false;\n }\n }, []);\n return [copiedText, copy];\n}\nfunction useCounter(initialValue) {\n const [count, setCount] = useState(initialValue ?? 0);\n const increment = useCallback(() => {\n setCount((x) => x + 1);\n }, []);\n const decrement = useCallback(() => {\n setCount((x) => x - 1);\n }, []);\n const reset = useCallback(() => {\n setCount(initialValue ?? 0);\n }, [initialValue]);\n return {\n count,\n increment,\n decrement,\n reset,\n setCount\n };\n}\nfunction useInterval(callback, delay) {\n const savedCallback = useRef(callback);\n useIsomorphicLayoutEffect(() => {\n savedCallback.current = callback;\n }, [callback]);\n useEffect(() => {\n if (delay === null) {\n return;\n }\n const id = setInterval(() => {\n savedCallback.current();\n }, delay);\n return () => {\n clearInterval(id);\n };\n }, [delay]);\n}\n\n// src/useCountdown/useCountdown.ts\nfunction useCountdown({\n countStart,\n countStop = 0,\n intervalMs = 1e3,\n isIncrement = false\n}) {\n const {\n count,\n increment,\n decrement,\n reset: resetCounter\n } = useCounter(countStart);\n const {\n value: isCountdownRunning,\n setTrue: startCountdown,\n setFalse: stopCountdown\n } = useBoolean(false);\n const resetCountdown = useCallback(() => {\n stopCountdown();\n resetCounter();\n }, [stopCountdown, resetCounter]);\n const countdownCallback = useCallback(() => {\n if (count === countStop) {\n stopCountdown();\n return;\n }\n if (isIncrement) {\n increment();\n } else {\n decrement();\n }\n }, [count, countStop, decrement, increment, isIncrement, stopCountdown]);\n useInterval(countdownCallback, isCountdownRunning ? intervalMs : null);\n return [count, { startCountdown, stopCountdown, resetCountdown }];\n}\nfunction useEventCallback(fn) {\n const ref = useRef(() => {\n throw new Error(\"Cannot call an event handler while rendering.\");\n });\n useIsomorphicLayoutEffect(() => {\n ref.current = fn;\n }, [fn]);\n return useCallback((...args) => {\n var _a;\n return (_a = ref.current) == null ? void 0 : _a.call(ref, ...args);\n }, [ref]);\n}\n\n// src/useLocalStorage/useLocalStorage.ts\nvar IS_SERVER = typeof window === \"undefined\";\nfunction useLocalStorage(key, initialValue, options = {}) {\n const { initializeWithValue = true } = options;\n const serializer = useCallback(\n (value) => {\n if (options.serializer) {\n return options.serializer(value);\n }\n return JSON.stringify(value);\n },\n [options]\n );\n const deserializer = useCallback(\n (value) => {\n if (options.deserializer) {\n return options.deserializer(value);\n }\n if (value === \"undefined\") {\n return void 0;\n }\n const defaultValue = initialValue instanceof Function ? initialValue() : initialValue;\n let parsed;\n try {\n parsed = JSON.parse(value);\n } catch (error) {\n console.error(\"Error parsing JSON:\", error);\n return defaultValue;\n }\n return parsed;\n },\n [options, initialValue]\n );\n const readValue = useCallback(() => {\n const initialValueToUse = initialValue instanceof Function ? initialValue() : initialValue;\n if (IS_SERVER) {\n return initialValueToUse;\n }\n try {\n const raw = window.localStorage.getItem(key);\n return raw ? deserializer(raw) : initialValueToUse;\n } catch (error) {\n console.warn(`Error reading localStorage key \\u201C${key}\\u201D:`, error);\n return initialValueToUse;\n }\n }, [initialValue, key, deserializer]);\n const [storedValue, setStoredValue] = useState(() => {\n if (initializeWithValue) {\n return readValue();\n }\n return initialValue instanceof Function ? initialValue() : initialValue;\n });\n const setValue = useEventCallback((value) => {\n if (IS_SERVER) {\n console.warn(\n `Tried setting localStorage key \\u201C${key}\\u201D even though environment is not a client`\n );\n }\n try {\n const newValue = value instanceof Function ? value(readValue()) : value;\n window.localStorage.setItem(key, serializer(newValue));\n setStoredValue(newValue);\n window.dispatchEvent(new StorageEvent(\"local-storage\", { key }));\n } catch (error) {\n console.warn(`Error setting localStorage key \\u201C${key}\\u201D:`, error);\n }\n });\n const removeValue = useEventCallback(() => {\n if (IS_SERVER) {\n console.warn(\n `Tried removing localStorage key \\u201C${key}\\u201D even though environment is not a client`\n );\n }\n const defaultValue = initialValue instanceof Function ? initialValue() : initialValue;\n window.localStorage.removeItem(key);\n setStoredValue(defaultValue);\n window.dispatchEvent(new StorageEvent(\"local-storage\", { key }));\n });\n useEffect(() => {\n setStoredValue(readValue());\n }, [key]);\n const handleStorageChange = useCallback(\n (event) => {\n if (event.key && event.key !== key) {\n return;\n }\n setStoredValue(readValue());\n },\n [key, readValue]\n );\n useEventListener(\"storage\", handleStorageChange);\n useEventListener(\"local-storage\", handleStorageChange);\n return [storedValue, setValue, removeValue];\n}\nvar IS_SERVER2 = typeof window === \"undefined\";\nfunction useMediaQuery(query, {\n defaultValue = false,\n initializeWithValue = true\n} = {}) {\n const getMatches = (query2) => {\n if (IS_SERVER2) {\n return defaultValue;\n }\n return window.matchMedia(query2).matches;\n };\n const [matches, setMatches] = useState(() => {\n if (initializeWithValue) {\n return getMatches(query);\n }\n return defaultValue;\n });\n function handleChange() {\n setMatches(getMatches(query));\n }\n useIsomorphicLayoutEffect(() => {\n const matchMedia = window.matchMedia(query);\n handleChange();\n if (matchMedia.addListener) {\n matchMedia.addListener(handleChange);\n } else {\n matchMedia.addEventListener(\"change\", handleChange);\n }\n return () => {\n if (matchMedia.removeListener) {\n matchMedia.removeListener(handleChange);\n } else {\n matchMedia.removeEventListener(\"change\", handleChange);\n }\n };\n }, [query]);\n return matches;\n}\n\n// src/useDarkMode/useDarkMode.ts\nvar COLOR_SCHEME_QUERY = \"(prefers-color-scheme: dark)\";\nvar LOCAL_STORAGE_KEY = \"usehooks-ts-dark-mode\";\nfunction useDarkMode(options = {}) {\n const {\n defaultValue,\n localStorageKey = LOCAL_STORAGE_KEY,\n initializeWithValue = true\n } = options;\n const isDarkOS = useMediaQuery(COLOR_SCHEME_QUERY, {\n initializeWithValue,\n defaultValue\n });\n const [isDarkMode, setDarkMode] = useLocalStorage(\n localStorageKey,\n defaultValue ?? isDarkOS ?? false,\n { initializeWithValue }\n );\n useIsomorphicLayoutEffect(() => {\n if (isDarkOS !== isDarkMode) {\n setDarkMode(isDarkOS);\n }\n }, [isDarkOS]);\n return {\n isDarkMode,\n toggle: () => {\n setDarkMode((prev) => !prev);\n },\n enable: () => {\n setDarkMode(true);\n },\n disable: () => {\n setDarkMode(false);\n },\n set: (value) => {\n setDarkMode(value);\n }\n };\n}\nfunction useUnmount(func) {\n const funcRef = useRef(func);\n funcRef.current = func;\n useEffect(\n () => () => {\n funcRef.current();\n },\n []\n );\n}\n\n// src/useDebounceCallback/useDebounceCallback.ts\nfunction useDebounceCallback(func, delay = 500, options) {\n const debouncedFunc = useRef();\n useUnmount(() => {\n if (debouncedFunc.current) {\n debouncedFunc.current.cancel();\n }\n });\n const debounced = useMemo(() => {\n const debouncedFuncInstance = debounce(func, delay, options);\n const wrappedFunc = (...args) => {\n return debouncedFuncInstance(...args);\n };\n wrappedFunc.cancel = () => {\n debouncedFuncInstance.cancel();\n };\n wrappedFunc.isPending = () => {\n return !!debouncedFunc.current;\n };\n wrappedFunc.flush = () => {\n return debouncedFuncInstance.flush();\n };\n return wrappedFunc;\n }, [func, delay, options]);\n useEffect(() => {\n debouncedFunc.current = debounce(func, delay, options);\n }, [func, delay, options]);\n return debounced;\n}\nfunction useDebounceValue(initialValue, delay, options) {\n const eq = (options == null ? void 0 : options.equalityFn) ?? ((left, right) => left === right);\n const unwrappedInitialValue = initialValue instanceof Function ? initialValue() : initialValue;\n const [debouncedValue, setDebouncedValue] = useState(unwrappedInitialValue);\n const previousValueRef = useRef(unwrappedInitialValue);\n const updateDebouncedValue = useDebounceCallback(\n setDebouncedValue,\n delay,\n options\n );\n if (!eq(previousValueRef.current, unwrappedInitialValue)) {\n updateDebouncedValue(unwrappedInitialValue);\n previousValueRef.current = unwrappedInitialValue;\n }\n return [debouncedValue, updateDebouncedValue];\n}\nfunction useDocumentTitle(title, options = {}) {\n const { preserveTitleOnUnmount = true } = options;\n const defaultTitle = useRef(null);\n useIsomorphicLayoutEffect(() => {\n defaultTitle.current = window.document.title;\n }, []);\n useIsomorphicLayoutEffect(() => {\n window.document.title = title;\n }, [title]);\n useUnmount(() => {\n if (!preserveTitleOnUnmount && defaultTitle.current) {\n window.document.title = defaultTitle.current;\n }\n });\n}\nfunction useHover(elementRef) {\n const [value, setValue] = useState(false);\n const handleMouseEnter = () => {\n setValue(true);\n };\n const handleMouseLeave = () => {\n setValue(false);\n };\n useEventListener(\"mouseenter\", handleMouseEnter, elementRef);\n useEventListener(\"mouseleave\", handleMouseLeave, elementRef);\n return value;\n}\nfunction useIntersectionObserver({\n threshold = 0,\n root = null,\n rootMargin = \"0%\",\n freezeOnceVisible = false,\n initialIsIntersecting = false,\n onChange\n} = {}) {\n var _a;\n const [ref, setRef] = useState(null);\n const [state, setState] = useState(() => ({\n isIntersecting: initialIsIntersecting,\n entry: void 0\n }));\n const callbackRef = useRef();\n callbackRef.current = onChange;\n const frozen = ((_a = state.entry) == null ? void 0 : _a.isIntersecting) && freezeOnceVisible;\n useEffect(() => {\n if (!ref)\n return;\n if (!(\"IntersectionObserver\" in window))\n return;\n if (frozen)\n return;\n let unobserve;\n const observer = new IntersectionObserver(\n (entries) => {\n const thresholds = Array.isArray(observer.thresholds) ? observer.thresholds : [observer.thresholds];\n entries.forEach((entry) => {\n const isIntersecting = entry.isIntersecting && thresholds.some((threshold2) => entry.intersectionRatio >= threshold2);\n setState({ isIntersecting, entry });\n if (callbackRef.current) {\n callbackRef.current(isIntersecting, entry);\n }\n if (isIntersecting && freezeOnceVisible && unobserve) {\n unobserve();\n unobserve = void 0;\n }\n });\n },\n { threshold, root, rootMargin }\n );\n observer.observe(ref);\n return () => {\n observer.disconnect();\n };\n }, [\n ref,\n // eslint-disable-next-line react-hooks/exhaustive-deps\n JSON.stringify(threshold),\n root,\n rootMargin,\n frozen,\n freezeOnceVisible\n ]);\n const prevRef = useRef(null);\n useEffect(() => {\n var _a2;\n if (!ref && ((_a2 = state.entry) == null ? void 0 : _a2.target) && !freezeOnceVisible && !frozen && prevRef.current !== state.entry.target) {\n prevRef.current = state.entry.target;\n setState({ isIntersecting: initialIsIntersecting, entry: void 0 });\n }\n }, [ref, state.entry, freezeOnceVisible, frozen, initialIsIntersecting]);\n const result = [\n setRef,\n !!state.isIntersecting,\n state.entry\n ];\n result.ref = result[0];\n result.isIntersecting = result[1];\n result.entry = result[2];\n return result;\n}\nfunction useIsClient() {\n const [isClient, setClient] = useState(false);\n useEffect(() => {\n setClient(true);\n }, []);\n return isClient;\n}\nfunction useIsMounted() {\n const isMounted = useRef(false);\n useEffect(() => {\n isMounted.current = true;\n return () => {\n isMounted.current = false;\n };\n }, []);\n return useCallback(() => isMounted.current, []);\n}\nfunction useMap(initialState = /* @__PURE__ */ new Map()) {\n const [map, setMap] = useState(new Map(initialState));\n const actions = {\n set: useCallback((key, value) => {\n setMap((prev) => {\n const copy = new Map(prev);\n copy.set(key, value);\n return copy;\n });\n }, []),\n setAll: useCallback((entries) => {\n setMap(() => new Map(entries));\n }, []),\n remove: useCallback((key) => {\n setMap((prev) => {\n const copy = new Map(prev);\n copy.delete(key);\n return copy;\n });\n }, []),\n reset: useCallback(() => {\n setMap(() => /* @__PURE__ */ new Map());\n }, [])\n };\n return [map, actions];\n}\n\n// src/useOnClickOutside/useOnClickOutside.ts\nfunction useOnClickOutside(ref, handler, eventType = \"mousedown\", eventListenerOptions = {}) {\n useEventListener(\n eventType,\n (event) => {\n const target = event.target;\n if (!target || !target.isConnected) {\n return;\n }\n const isOutside = Array.isArray(ref) ? ref.filter((r) => Boolean(r.current)).every((r) => r.current && !r.current.contains(target)) : ref.current && !ref.current.contains(target);\n if (isOutside) {\n handler(event);\n }\n },\n void 0,\n eventListenerOptions\n );\n}\nvar IS_SERVER3 = typeof window === \"undefined\";\nfunction useReadLocalStorage(key, options = {}) {\n let { initializeWithValue = true } = options;\n if (IS_SERVER3) {\n initializeWithValue = false;\n }\n const deserializer = useCallback(\n (value) => {\n if (options.deserializer) {\n return options.deserializer(value);\n }\n if (value === \"undefined\") {\n return void 0;\n }\n let parsed;\n try {\n parsed = JSON.parse(value);\n } catch (error) {\n console.error(\"Error parsing JSON:\", error);\n return null;\n }\n return parsed;\n },\n [options]\n );\n const readValue = useCallback(() => {\n if (IS_SERVER3) {\n return null;\n }\n try {\n const raw = window.localStorage.getItem(key);\n return raw ? deserializer(raw) : null;\n } catch (error) {\n console.warn(`Error reading localStorage key \\u201C${key}\\u201D:`, error);\n return null;\n }\n }, [key, deserializer]);\n const [storedValue, setStoredValue] = useState(() => {\n if (initializeWithValue) {\n return readValue();\n }\n return void 0;\n });\n useEffect(() => {\n setStoredValue(readValue());\n }, [key]);\n const handleStorageChange = useCallback(\n (event) => {\n if (event.key && event.key !== key) {\n return;\n }\n setStoredValue(readValue());\n },\n [key, readValue]\n );\n useEventListener(\"storage\", handleStorageChange);\n useEventListener(\"local-storage\", handleStorageChange);\n return storedValue;\n}\nvar initialSize = {\n width: void 0,\n height: void 0\n};\nfunction useResizeObserver(options) {\n const { ref, box = \"content-box\" } = options;\n const [{ width, height }, setSize] = useState(initialSize);\n const isMounted = useIsMounted();\n const previousSize = useRef({ ...initialSize });\n const onResize = useRef(void 0);\n onResize.current = options.onResize;\n useEffect(() => {\n if (!ref.current)\n return;\n if (typeof window === \"undefined\" || !(\"ResizeObserver\" in window))\n return;\n const observer = new ResizeObserver(([entry]) => {\n const boxProp = box === \"border-box\" ? \"borderBoxSize\" : box === \"device-pixel-content-box\" ? \"devicePixelContentBoxSize\" : \"contentBoxSize\";\n const newWidth = extractSize(entry, boxProp, \"inlineSize\");\n const newHeight = extractSize(entry, boxProp, \"blockSize\");\n const hasChanged = previousSize.current.width !== newWidth || previousSize.current.height !== newHeight;\n if (hasChanged) {\n const newSize = { width: newWidth, height: newHeight };\n previousSize.current.width = newWidth;\n previousSize.current.height = newHeight;\n if (onResize.current) {\n onResize.current(newSize);\n } else {\n if (isMounted()) {\n setSize(newSize);\n }\n }\n }\n });\n observer.observe(ref.current, { box });\n return () => {\n observer.disconnect();\n };\n }, [box, ref, isMounted]);\n return { width, height };\n}\nfunction extractSize(entry, box, sizeType) {\n if (!entry[box]) {\n if (box === \"contentBoxSize\") {\n return entry.contentRect[sizeType === \"inlineSize\" ? \"width\" : \"height\"];\n }\n return void 0;\n }\n return Array.isArray(entry[box]) ? entry[box][0][sizeType] : (\n // @ts-ignore Support Firefox's non-standard behavior\n entry[box][sizeType]\n );\n}\nvar IS_SERVER4 = typeof window === \"undefined\";\nfunction useScreen(options = {}) {\n let { initializeWithValue = true } = options;\n if (IS_SERVER4) {\n initializeWithValue = false;\n }\n const readScreen = () => {\n if (IS_SERVER4) {\n return void 0;\n }\n return window.screen;\n };\n const [screen, setScreen] = useState(() => {\n if (initializeWithValue) {\n return readScreen();\n }\n return void 0;\n });\n const debouncedSetScreen = useDebounceCallback(\n setScreen,\n options.debounceDelay\n );\n function handleSize() {\n const newScreen = readScreen();\n const setSize = options.debounceDelay ? debouncedSetScreen : setScreen;\n if (newScreen) {\n const {\n width,\n height,\n availHeight,\n availWidth,\n colorDepth,\n orientation,\n pixelDepth\n } = newScreen;\n setSize({\n width,\n height,\n availHeight,\n availWidth,\n colorDepth,\n orientation,\n pixelDepth\n });\n }\n }\n useEventListener(\"resize\", handleSize);\n useIsomorphicLayoutEffect(() => {\n handleSize();\n }, []);\n return screen;\n}\nvar cachedScriptStatuses = /* @__PURE__ */ new Map();\nfunction getScriptNode(src) {\n const node = document.querySelector(\n `script[src=\"${src}\"]`\n );\n const status = node == null ? void 0 : node.getAttribute(\"data-status\");\n return {\n node,\n status\n };\n}\nfunction useScript(src, options) {\n const [status, setStatus] = useState(() => {\n if (!src || (options == null ? void 0 : options.shouldPreventLoad)) {\n return \"idle\";\n }\n if (typeof window === \"undefined\") {\n return \"loading\";\n }\n return cachedScriptStatuses.get(src) ?? \"loading\";\n });\n useEffect(() => {\n if (!src || (options == null ? void 0 : options.shouldPreventLoad)) {\n return;\n }\n const cachedScriptStatus = cachedScriptStatuses.get(src);\n if (cachedScriptStatus === \"ready\" || cachedScriptStatus === \"error\") {\n setStatus(cachedScriptStatus);\n return;\n }\n const script = getScriptNode(src);\n let scriptNode = script.node;\n if (!scriptNode) {\n scriptNode = document.createElement(\"script\");\n scriptNode.src = src;\n scriptNode.async = true;\n if (options == null ? void 0 : options.id) {\n scriptNode.id = options.id;\n }\n scriptNode.setAttribute(\"data-status\", \"loading\");\n document.body.appendChild(scriptNode);\n const setAttributeFromEvent = (event) => {\n const scriptStatus = event.type === \"load\" ? \"ready\" : \"error\";\n scriptNode == null ? void 0 : scriptNode.setAttribute(\"data-status\", scriptStatus);\n };\n scriptNode.addEventListener(\"load\", setAttributeFromEvent);\n scriptNode.addEventListener(\"error\", setAttributeFromEvent);\n } else {\n setStatus(script.status ?? cachedScriptStatus ?? \"loading\");\n }\n const setStateFromEvent = (event) => {\n const newStatus = event.type === \"load\" ? \"ready\" : \"error\";\n setStatus(newStatus);\n cachedScriptStatuses.set(src, newStatus);\n };\n scriptNode.addEventListener(\"load\", setStateFromEvent);\n scriptNode.addEventListener(\"error\", setStateFromEvent);\n return () => {\n if (scriptNode) {\n scriptNode.removeEventListener(\"load\", setStateFromEvent);\n scriptNode.removeEventListener(\"error\", setStateFromEvent);\n }\n if (scriptNode && (options == null ? void 0 : options.removeOnUnmount)) {\n scriptNode.remove();\n cachedScriptStatuses.delete(src);\n }\n };\n }, [src, options == null ? void 0 : options.shouldPreventLoad, options == null ? void 0 : options.removeOnUnmount, options == null ? void 0 : options.id]);\n return status;\n}\nvar IS_SERVER5 = typeof window === \"undefined\";\nfunction useScrollLock(options = {}) {\n const { autoLock = true, lockTarget, widthReflow = true } = options;\n const [isLocked, setIsLocked] = useState(false);\n const target = useRef(null);\n const originalStyle = useRef(null);\n const lock = () => {\n if (target.current) {\n const { overflow, paddingRight } = target.current.style;\n originalStyle.current = { overflow, paddingRight };\n if (widthReflow) {\n const offsetWidth = target.current === document.body ? window.innerWidth : target.current.offsetWidth;\n const currentPaddingRight = parseInt(window.getComputedStyle(target.current).paddingRight, 10) || 0;\n const scrollbarWidth = offsetWidth - target.current.scrollWidth;\n target.current.style.paddingRight = `${scrollbarWidth + currentPaddingRight}px`;\n }\n target.current.style.overflow = \"hidden\";\n setIsLocked(true);\n }\n };\n const unlock = () => {\n if (target.current && originalStyle.current) {\n target.current.style.overflow = originalStyle.current.overflow;\n if (widthReflow) {\n target.current.style.paddingRight = originalStyle.current.paddingRight;\n }\n }\n setIsLocked(false);\n };\n useIsomorphicLayoutEffect(() => {\n if (IS_SERVER5)\n return;\n if (lockTarget) {\n target.current = typeof lockTarget === \"string\" ? document.querySelector(lockTarget) : lockTarget;\n }\n if (!target.current) {\n target.current = document.body;\n }\n if (autoLock) {\n lock();\n }\n return () => {\n unlock();\n };\n }, [autoLock, lockTarget, widthReflow]);\n return { isLocked, lock, unlock };\n}\nvar IS_SERVER6 = typeof window === \"undefined\";\nfunction useSessionStorage(key, initialValue, options = {}) {\n const { initializeWithValue = true } = options;\n const serializer = useCallback(\n (value) => {\n if (options.serializer) {\n return options.serializer(value);\n }\n return JSON.stringify(value);\n },\n [options]\n );\n const deserializer = useCallback(\n (value) => {\n if (options.deserializer) {\n return options.deserializer(value);\n }\n if (value === \"undefined\") {\n return void 0;\n }\n const defaultValue = initialValue instanceof Function ? initialValue() : initialValue;\n let parsed;\n try {\n parsed = JSON.parse(value);\n } catch (error) {\n console.error(\"Error parsing JSON:\", error);\n return defaultValue;\n }\n return parsed;\n },\n [options, initialValue]\n );\n const readValue = useCallback(() => {\n const initialValueToUse = initialValue instanceof Function ? initialValue() : initialValue;\n if (IS_SERVER6) {\n return initialValueToUse;\n }\n try {\n const raw = window.sessionStorage.getItem(key);\n return raw ? deserializer(raw) : initialValueToUse;\n } catch (error) {\n console.warn(`Error reading sessionStorage key \\u201C${key}\\u201D:`, error);\n return initialValueToUse;\n }\n }, [initialValue, key, deserializer]);\n const [storedValue, setStoredValue] = useState(() => {\n if (initializeWithValue) {\n return readValue();\n }\n return initialValue instanceof Function ? initialValue() : initialValue;\n });\n const setValue = useEventCallback((value) => {\n if (IS_SERVER6) {\n console.warn(\n `Tried setting sessionStorage key \\u201C${key}\\u201D even though environment is not a client`\n );\n }\n try {\n const newValue = value instanceof Function ? value(readValue()) : value;\n window.sessionStorage.setItem(key, serializer(newValue));\n setStoredValue(newValue);\n window.dispatchEvent(new StorageEvent(\"session-storage\", { key }));\n } catch (error) {\n console.warn(`Error setting sessionStorage key \\u201C${key}\\u201D:`, error);\n }\n });\n const removeValue = useEventCallback(() => {\n if (IS_SERVER6) {\n console.warn(\n `Tried removing sessionStorage key \\u201C${key}\\u201D even though environment is not a client`\n );\n }\n const defaultValue = initialValue instanceof Function ? initialValue() : initialValue;\n window.sessionStorage.removeItem(key);\n setStoredValue(defaultValue);\n window.dispatchEvent(new StorageEvent(\"session-storage\", { key }));\n });\n useEffect(() => {\n setStoredValue(readValue());\n }, [key]);\n const handleStorageChange = useCallback(\n (event) => {\n if (event.key && event.key !== key) {\n return;\n }\n setStoredValue(readValue());\n },\n [key, readValue]\n );\n useEventListener(\"storage\", handleStorageChange);\n useEventListener(\"session-storage\", handleStorageChange);\n return [storedValue, setValue, removeValue];\n}\nfunction useStep(maxStep) {\n const [currentStep, setCurrentStep] = useState(1);\n const canGoToNextStep = currentStep + 1 <= maxStep;\n const canGoToPrevStep = currentStep - 1 > 0;\n const setStep = useCallback(\n (step) => {\n const newStep = step instanceof Function ? step(currentStep) : step;\n if (newStep >= 1 && newStep <= maxStep) {\n setCurrentStep(newStep);\n return;\n }\n throw new Error(\"Step not valid\");\n },\n [maxStep, currentStep]\n );\n const goToNextStep = useCallback(() => {\n if (canGoToNextStep) {\n setCurrentStep((step) => step + 1);\n }\n }, [canGoToNextStep]);\n const goToPrevStep = useCallback(() => {\n if (canGoToPrevStep) {\n setCurrentStep((step) => step - 1);\n }\n }, [canGoToPrevStep]);\n const reset = useCallback(() => {\n setCurrentStep(1);\n }, []);\n return [\n currentStep,\n {\n goToNextStep,\n goToPrevStep,\n canGoToNextStep,\n canGoToPrevStep,\n setStep,\n reset\n }\n ];\n}\n\n// src/useTernaryDarkMode/useTernaryDarkMode.ts\nvar COLOR_SCHEME_QUERY2 = \"(prefers-color-scheme: dark)\";\nvar LOCAL_STORAGE_KEY2 = \"usehooks-ts-ternary-dark-mode\";\nfunction useTernaryDarkMode({\n defaultValue = \"system\",\n localStorageKey = LOCAL_STORAGE_KEY2,\n initializeWithValue = true\n} = {}) {\n const isDarkOS = useMediaQuery(COLOR_SCHEME_QUERY2, { initializeWithValue });\n const [mode, setMode] = useLocalStorage(localStorageKey, defaultValue, {\n initializeWithValue\n });\n const isDarkMode = mode === \"dark\" || mode === \"system\" && isDarkOS;\n const toggleTernaryDarkMode = () => {\n const modes = [\"light\", \"system\", \"dark\"];\n setMode((prevMode) => {\n const nextIndex = (modes.indexOf(prevMode) + 1) % modes.length;\n return modes[nextIndex];\n });\n };\n return {\n isDarkMode,\n ternaryDarkMode: mode,\n setTernaryDarkMode: setMode,\n toggleTernaryDarkMode\n };\n}\nfunction useTimeout(callback, delay) {\n const savedCallback = useRef(callback);\n useIsomorphicLayoutEffect(() => {\n savedCallback.current = callback;\n }, [callback]);\n useEffect(() => {\n if (!delay && delay !== 0) {\n return;\n }\n const id = setTimeout(() => {\n savedCallback.current();\n }, delay);\n return () => {\n clearTimeout(id);\n };\n }, [delay]);\n}\nfunction useToggle(defaultValue) {\n const [value, setValue] = useState(!!defaultValue);\n const toggle = useCallback(() => {\n setValue((x) => !x);\n }, []);\n return [value, toggle, setValue];\n}\nvar IS_SERVER7 = typeof window === \"undefined\";\nfunction useWindowSize(options = {}) {\n let { initializeWithValue = true } = options;\n if (IS_SERVER7) {\n initializeWithValue = false;\n }\n const [windowSize, setWindowSize] = useState(() => {\n if (initializeWithValue) {\n return {\n width: window.innerWidth,\n height: window.innerHeight\n };\n }\n return {\n width: void 0,\n height: void 0\n };\n });\n const debouncedSetWindowSize = useDebounceCallback(\n setWindowSize,\n options.debounceDelay\n );\n function handleSize() {\n const setSize = options.debounceDelay ? debouncedSetWindowSize : setWindowSize;\n setSize({\n width: window.innerWidth,\n height: window.innerHeight\n });\n }\n useEventListener(\"resize\", handleSize);\n useIsomorphicLayoutEffect(() => {\n handleSize();\n }, []);\n return windowSize;\n}\n\nexport { useBoolean, useClickAnyWhere, useCopyToClipboard, useCountdown, useCounter, useDarkMode, useDebounceCallback, useDebounceValue, useDocumentTitle, useEventCallback, useEventListener, useHover, useIntersectionObserver, useInterval, useIsClient, useIsMounted, useIsomorphicLayoutEffect, useLocalStorage, useMap, useMediaQuery, useOnClickOutside, useReadLocalStorage, useResizeObserver, useScreen, useScript, useScrollLock, useSessionStorage, useStep, useTernaryDarkMode, useTimeout, useToggle, useUnmount, useWindowSize };\n", "import clsx from \"clsx\"\nimport type { ComponentProps } from \"react\"\nimport s from \"./LoadingDots.module.css\"\n\nexport type LoadingDotsProps = Omit<ComponentProps<\"div\">, \"children\">\n\nexport const LoadingDots = ({ className, ...restProps }: LoadingDotsProps) => {\n return (\n <div className={clsx(s.LoadingDots, className)} {...restProps}>\n <div className={s.Dot} />\n <div className={s.Dot} />\n <div className={s.Dot} />\n </div>\n )\n}\n", "import clsx from \"clsx\"\nimport type { ComponentProps } from \"react\"\nimport { toCssVariables } from \"../../lib/helpers\"\nimport s from \"./LoadingIndicator.module.css\"\n\nexport type LoadingIndicatorProps = {\n /** Classname applied to the indicator */\n className?: string\n /** Size of the indicator, in pixels\n * @default 1em\n */\n size?: number | string\n /** Stroke width of the indicator, in pixels\n * @default 2\n */\n strokeWidth?: number\n} & Omit<ComponentProps<\"div\">, \"children\">\n\nexport const LoadingIndicator = ({\n className,\n size,\n strokeWidth,\n style,\n ...restProps\n}: LoadingIndicatorProps) => {\n return (\n <div\n {...restProps}\n className={clsx(s.LoadingIndicator, className)}\n style={\n style ||\n toCssVariables({\n \"indicator-size\": size,\n \"indicator-stroke\": strokeWidth,\n })\n }\n />\n )\n}\n", "\"use client\"\n\nimport React, {\n Children,\n useCallback,\n useEffect,\n useLayoutEffect,\n useReducer,\n useRef,\n useState,\n type CSSProperties,\n} from \"react\"\nimport { mergeRefs } from \"react-merge-refs\"\n\nimport { waitForAnimationFrame } from \"../../lib/helpers\"\n\nimport clsx from \"clsx\"\nimport { useTimeout } from \"usehooks-ts\"\nimport getDisableAnimations from \"./getDisableAnimations\"\nimport {\n assertSingleChildWhenRef,\n ChildrenWithKeys,\n computeNextRenderChildren,\n noop,\n useChildCallback,\n type CallbackType,\n type ReactElementWithKey,\n type TransitionGroupChildCallbacks,\n} from \"./shared\"\nimport s from \"./TransitionGroup.module.css\"\nimport { getInitialTransitionState, transitionReducer } from \"./transitionReducer\"\n\ntype TransitionGroupChildProps = {\n as: \"div\" | \"span\"\n children: React.ReactNode\n className?: string\n transitionId?: string\n style?: CSSProperties\n preventMountTransition?: boolean\n shouldRender: boolean\n enterDuration: number\n exitDuration: number\n enterMountDelay?: number\n removeChild: () => void\n ref?: React.Ref<unknown>\n} & TransitionGroupChildCallbacks\n\nconst TransitionGroupChildInner = ({\n ref: forwardedRef,\n as: TagName,\n children,\n className,\n transitionId,\n style,\n preventMountTransition,\n shouldRender,\n enterDuration,\n exitDuration,\n removeChild,\n onEnter,\n onEnterActive,\n onEnterComplete,\n onExit,\n onExitActive,\n onExitComplete,\n}: TransitionGroupChildProps) => {\n const [state, dispatch] = useReducer(\n transitionReducer,\n getInitialTransitionState(preventMountTransition || false),\n )\n // Allow a child to prevent mount transition, but still experience\n // future enter transition events, when applicable.\n const preventedMountTransition = useRef<boolean>(false)\n const elementRef = useRef<HTMLDivElement | null>(null)\n // Duration values should not affect hook re-renders, so we create refs for them\n const enterDurationRef = useRef<number>(enterDuration)\n enterDurationRef.current = enterDuration\n const exitDurationRef = useRef<number>(exitDuration)\n exitDurationRef.current = exitDuration\n\n const lastCallbackRef = useRef<CallbackType>(null)\n const triggerCallback = useCallback(\n (callbackType: CallbackType) => {\n const element = elementRef.current\n\n if (!element || callbackType === lastCallbackRef.current) {\n return\n }\n\n lastCallbackRef.current = callbackType\n\n switch (callbackType) {\n case \"enter\":\n onEnter(element)\n break\n case \"enter-active\":\n onEnterActive(element)\n break\n case \"enter-complete\":\n onEnterComplete(element)\n break\n case \"exit\":\n onExit(element)\n break\n case \"exit-active\":\n onExitActive(element)\n break\n case \"exit-complete\":\n onExitComplete(element)\n break\n default:\n callbackType satisfies never\n break\n }\n },\n [onEnter, onEnterActive, onEnterComplete, onExit, onExitActive, onExitComplete],\n )\n\n React.useLayoutEffect(() => {\n // Exit transition\n if (!shouldRender) {\n let exitTimeout: number | undefined\n\n dispatch({ type: \"exit-before\" })\n triggerCallback(\"exit\")\n\n const cancelAnimationFrame = waitForAnimationFrame(() => {\n dispatch({ type: \"exit-active\" })\n triggerCallback(\"exit-active\")\n\n exitTimeout = window.setTimeout(() => {\n triggerCallback(\"exit-complete\")\n removeChild()\n }, exitDurationRef.current)\n })\n\n return () => {\n cancelAnimationFrame()\n if (exitTimeout !== undefined) clearTimeout(exitTimeout)\n }\n }\n\n // Enter transition\n\n // Check if we need to prevent this specific entering cycle\n if (preventMountTransition && !preventedMountTransition.current) {\n // Mark initial transition as prevented and short-circuit.\n preventedMountTransition.current = true\n return\n }\n\n let enterTimeout: number | undefined\n\n dispatch({ type: \"enter-before\" })\n triggerCallback(\"enter\")\n\n const cancelAnimationFrame = waitForAnimationFrame(() => {\n dispatch({ type: \"enter-active\" })\n triggerCallback(\"enter-active\")\n\n enterTimeout = window.setTimeout(() => {\n dispatch({ type: \"done\" })\n triggerCallback(\"enter-complete\")\n }, enterDurationRef.current)\n })\n\n return () => {\n cancelAnimationFrame()\n if (enterTimeout !== undefined) clearTimeout(enterTimeout)\n }\n }, [\n shouldRender,\n // This value is immutable after <TransitionGroup> is created, and does not change on re-renders.\n preventMountTransition,\n removeChild,\n triggerCallback,\n ])\n\n useEffect(() => {\n // Required for <StrictMode>, because we need to unset this token\n // when the hooks are re-run. It's an imperative effect that we need to manage.\n return () => {\n preventedMountTransition.current = false\n }\n }, [])\n\n return (\n <TagName\n ref={mergeRefs([elementRef, forwardedRef])}\n className={clsx(className, s.TransitionGroupChild)}\n data-transition-id={transitionId}\n style={style}\n data-entering={state.enter ? \"\" : undefined}\n data-entering-active={state.enterActive ? \"\" : undefined}\n data-exiting={state.exit ? \"\" : undefined}\n data-exiting-active={state.exitActive ? \"\" : undefined}\n data-interrupted={state.interrupted ? \"\" : undefined}\n >\n {children}\n </TagName>\n )\n}\n\nconst TransitionGroupChild = (props: TransitionGroupChildProps) => {\n // Don't spread these out of props - pass all props to inner child\n const { enterMountDelay, preventMountTransition } = props\n // Mount gating occurs when enterMountDelay exists, and isn't initial mount\n // Otherwise, this flag is a no-op and the TransitionChild mounts normally.\n const mountDelay = !preventMountTransition && enterMountDelay != null ? enterMountDelay : null\n const [mounted, setMounted] = useState(mountDelay == null)\n useTimeout(() => setMounted(true), mounted ? null : mountDelay)\n\n return mounted ? <TransitionGroupChildInner {...props} /> : null\n}\n\nexport type TransitionGroupProps = {\n /** Components controlled by TransitionGroup rendering */\n children: React.ReactNode\n /** Determines the tag used by wrapping elements */\n as?: \"div\" | \"span\"\n /** Class passed to wrapping elements */\n className?: string\n /** Identifier passed to wrapping elements as `[data-transition-id]` */\n transitionId?: string\n /** Determines the amount of time that the enter state is applied during mounting */\n enterDuration?: number\n /** Determines the amount of time that the exit state is applied before unmounting */\n exitDuration?: number\n /**\n * Determines if children should have an enter transition applied during mounting of the TransitionGroup.\n * @default true\n */\n preventInitialTransition?: boolean\n /** Delay in MS to wait before mounting a child. `null` for no delay (default). */\n enterMountDelay?: number\n /** Render children changes immediately, bypassing transition timings */\n disableAnimations?: boolean\n /** Determines how new children are added to the children array */\n insertMethod?: \"append\" | \"prepend\"\n /** Styles applied to wrapping elements */\n style?: CSSProperties\n /** Ref for the TransitionGroup */\n ref?: React.Ref<unknown>\n} & Partial<TransitionGroupChildCallbacks>\n\ntype RenderChild = {\n component: ReactElementWithKey\n shouldRender: boolean\n preventMountTransition?: boolean\n removeChild: () => void\n} & TransitionGroupChildCallbacks\n\nexport const TransitionGroup = (props: TransitionGroupProps) => {\n const {\n ref: forwardedRef,\n as: TagName = \"span\",\n children,\n className,\n transitionId,\n style,\n enterDuration = 0,\n exitDuration = 0,\n preventInitialTransition = true,\n enterMountDelay,\n insertMethod = \"append\",\n disableAnimations = getDisableAnimations(),\n } = props\n // Create stable, mutable references for all callbacks\n const onEnter = useChildCallback(props.onEnter ?? noop)\n const onEnterActive = useChildCallback(props.onEnterActive ?? noop)\n const onEnterComplete = useChildCallback(props.onEnterComplete ?? noop)\n const onExit = useChildCallback(props.onExit ?? noop)\n const onExitActive = useChildCallback(props.onExitActive ?? noop)\n const onExitComplete = useChildCallback(props.onExitComplete ?? noop)\n\n // Ensure all children are provided with keys.\n // Cannot reliably use Children.toArray() because `key` is processed: https://reactjs.org/docs/react-api.html#reactchildrentoarray\n Children.forEach(children, (child) => {\n // @ts-expect-error - We know `key` might not exist on certain types, that's why we're checking\n if (child && !child.key) {\n throw new Error(\"Child elements of <TransitionGroup /> must include a `key`\")\n }\n })\n\n const createDefaultRenderChildProps = useCallback(\n (child: ReactElementWithKey): RenderChild => ({\n component: child,\n shouldRender: true,\n removeChild: () => {\n setRenderChildren((currentRenderChildren) =>\n currentRenderChildren.filter((c) => child.key !== c.component.key),\n )\n },\n onEnter,\n onEnterActive,\n onEnterComplete,\n onExit,\n onExitActive,\n onExitComplete,\n }),\n [onEnter, onEnterActive, onEnterComplete, onExit, onExitActive, onExitComplete],\n )\n\n const [renderChildren, setRenderChildren] = useState<RenderChild[]>((): RenderChild[] => {\n return ChildrenWithKeys(children).map((child) => ({\n ...createDefaultRenderChildProps(child),\n // Lock this value to whatever the value was on initial render of the TransitionGroup.\n // It doesn't make sense to change this once it is mounted.\n preventMountTransition: preventInitialTransition,\n }))\n })\n\n useLayoutEffect(() => {\n setRenderChildren((currentRenderChildren): RenderChild[] => {\n const propChildrenArray = ChildrenWithKeys(children)\n return computeNextRenderChildren(\n propChildrenArray,\n currentRenderChildren,\n createDefaultRenderChildProps,\n insertMethod,\n )\n })\n }, [children, insertMethod, createDefaultRenderChildProps])\n\n // Prevent mistakes with forwardRef() by ensuring single child usage within the group.\n assertSingleChildWhenRef(\"TransitionGroup\", forwardedRef, Children.count(children))\n\n if (disableAnimations) {\n return (\n <>\n {Children.map(children, (child) => (\n <TagName\n // @ts-expect-error -- TS is not happy about this forwardedRef, but it's fine.\n ref={forwardedRef}\n className={className}\n style={style}\n data-transition-id={transitionId}\n >\n {child}\n </TagName>\n ))}\n </>\n )\n }\n\n return (\n <>\n {renderChildren.map(({ component, ...restProps }) => (\n <TransitionGroupChild\n key={component.key}\n {...restProps}\n as={TagName}\n className={className}\n transitionId={transitionId}\n enterDuration={enterDuration}\n exitDuration={exitDuration}\n enterMountDelay={enterMountDelay}\n style={style}\n ref={forwardedRef}\n >\n {component}\n </TransitionGroupChild>\n ))}\n </>\n )\n}\n", "import type * as React from \"react\";\n\nexport function mergeRefs<T = any>(\n refs: Array<React.MutableRefObject<T> | React.LegacyRef<T> | undefined | null>\n): React.RefCallback<T> {\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref != null) {\n (ref as React.MutableRefObject<T | null>).current = value;\n }\n });\n };\n}\n", "import { isTest } from \"../../lib/constants\"\n\n// By default, all tests will treat <TransitionGroup> as `disableAnimations={true}`,\n// removing the need to be aware of misc. async animations happening across tests.\n// We could add support for things like `prefers-reduced-motion` in the future here as well.\nexport default () => isTest\n", "import React, { Children, useCallback, useRef } from \"react\"\nimport { isDev, isTest } from \"../../lib/constants\"\n\nexport type TransitionDefinition = {\n opacity?: number\n /** The horizontal translation value in pixels */\n x?: number\n /** The horizontal vertical value in pixels */\n y?: number\n /** The opacity value ranging from 0 to 1. */\n scale?: number\n rotate?: number | string\n skewX?: number | string\n skewY?: number | string\n blur?: number\n duration?: number\n delay?: number\n timingFunction?: string\n}\n\nexport type InitialTransitionDefinition = Omit<\n TransitionDefinition,\n \"duration\" | \"delay\" | \"timingFunction\"\n>\n\nexport type LayoutTransitionDefinition = {\n duration?: number\n delay?: number\n timingFunction?: string\n}\n\nexport type CallbackType =\n | \"enter\"\n | \"enter-active\"\n | \"enter-complete\"\n | \"exit\"\n | \"exit-active\"\n | \"exit-complete\"\n\n// Transition callbacks and types shared across implementations\nexport type TransitionGroupChildCallback = (element: HTMLDivElement) => void\n\nexport type TransitionGroupChildCallbacks = {\n /** Callback fired when an enter animation is staged (e.g., component mounted to the DOM) */\n onEnter: TransitionGroupChildCallback\n /** Callback fired when an enter animation starts */\n onEnterActive: TransitionGroupChildCallback\n /** Callback fired when an enter animation completes */\n onEnterComplete: TransitionGroupChildCallback\n /** Callback fired when an exit animation is staged */\n onExit: TransitionGroupChildCallback\n /** Callback fired when an exit animation starts */\n onExitActive: TransitionGroupChildCallback\n /** Callback fired when an exit animation completes (e.g., component unmounted from the DOM) */\n onExitComplete: TransitionGroupChildCallback\n}\n\nexport const NonNullChildren = (children: React.ReactNode) =>\n Children.toArray(children).filter((child) => child !== null && child !== undefined)\n\n// Shared keyed-children and transition helpers\nexport interface ReactElementWithKey extends React.ReactElement {\n key: string\n}\n\nexport const ChildrenWithKeys = (\n children: React.ReactNode,\n shouldThrow: boolean = false,\n componentName: string = \"TransitionGroup\",\n): ReactElementWithKey[] => {\n const validChildren: ReactElementWithKey[] = []\n Children.forEach(children, (child) => {\n if (child && typeof child === \"object\" && \"key\" in child && !!child.key) {\n // @ts-expect-error -- The above conditional is enough coercion that the component is valid\n validChildren.push(child)\n } else if (shouldThrow) {\n throw new Error(`Child elements of <${componentName} /> must include a \\`key\\``)\n }\n })\n return validChildren\n}\n\nexport const noop = () => {}\n\nexport const useChildCallback = (cb: (el: HTMLDivElement) => void) => {\n const ref = useRef(cb)\n ref.current = cb\n return useCallback<(el: HTMLDivElement) => void>((element) => ref.current(element), [])\n}\n\nexport type InsertMethod = \"append\" | \"prepend\"\n\nexport function computeNextRenderChildren<\n RenderChild extends { component: ReactElementWithKey; shouldRender: boolean },\n>(\n propChildrenArray: ReactElementWithKey[],\n currentRenderChildren: RenderChild[],\n createDefaultRenderChildProps: (child: ReactElementWithKey) => RenderChild,\n insertMethod: InsertMethod,\n): RenderChild[] {\n const propChildKeyMap = propChildrenArray.reduce<Record<string, number>>(\n (acc, child) => ({ ...acc, [child.key]: 1 }),\n {},\n )\n const currentRenderChildKeyMap = currentRenderChildren.reduce<Record<string, number>>(\n (acc, child) => ({ ...acc, [child.component.key]: 1 }),\n {},\n )\n\n const newRenderChildren: RenderChild[] = propChildrenArray\n .filter((propChild) => !currentRenderChildKeyMap[propChild.key])\n .map(createDefaultRenderChildProps)\n\n const updatedCurrentChildren: RenderChild[] = currentRenderChildren.map((childProps) => ({\n ...childProps,\n component:\n propChildrenArray.find(({ key }) => key === childProps.component.key) || childProps.component,\n shouldRender: !!propChildKeyMap[childProps.component.key],\n }))\n\n return insertMethod === \"append\"\n ? updatedCurrentChildren.concat(newRenderChildren)\n : newRenderChildren.concat(updatedCurrentChildren)\n}\n\nexport function assertSingleChildWhenRef(\n componentName: string,\n ref: React.Ref<unknown> | undefined,\n childrenCount: number,\n): void {\n if ((isTest || isDev) && ref && childrenCount > 1) {\n throw new Error(`Cannot use forwardRef with multiple children in <${componentName} />`)\n }\n}\n", "export type TransitionState = {\n enter: boolean\n enterActive: boolean\n exit: boolean\n exitActive: boolean\n interrupted: boolean\n}\n\nexport type TransitionStateAction =\n | { type: \"enter-before\" }\n | { type: \"enter-active\" }\n | { type: \"exit-before\" }\n | { type: \"exit-active\" }\n | { type: \"done\" }\n\nexport const RESTING_TRANSITION_STATE: TransitionState = {\n enter: false,\n enterActive: false,\n exit: false,\n exitActive: false,\n interrupted: false,\n}\n\nexport const getInitialTransitionState = (preventMountTransition: boolean): TransitionState => ({\n ...RESTING_TRANSITION_STATE,\n enter: !preventMountTransition,\n})\n\nexport const transitionReducer = (\n state: TransitionState,\n action: TransitionStateAction,\n): TransitionState => {\n switch (action.type) {\n case \"enter-before\":\n return {\n enter: true,\n enterActive: false,\n exit: false,\n exitActive: false,\n interrupted: state.interrupted || state.exit,\n }\n case \"enter-active\":\n return {\n enter: true,\n enterActive: true,\n exit: false,\n exitActive: false,\n interrupted: false,\n }\n case \"exit-before\":\n return {\n enter: false,\n enterActive: false,\n exit: true,\n exitActive: false,\n interrupted: state.interrupted || state.enter,\n }\n case \"exit-active\":\n return {\n enter: false,\n enterActive: false,\n exit: true,\n exitActive: true,\n interrupted: false,\n }\n case \"done\":\n default:\n return RESTING_TRANSITION_STATE\n }\n}\n", "\"use client\"\n\nimport { useEffect, useRef, useState, type MouseEvent } from \"react\"\nimport { copyToClipboard, type ClipboardContent } from \"../../lib/copyToClipboard\"\nimport { Check, Copy } from \"../Icon\"\nimport { Animate } from \"../Transition\"\nimport { Button, type ButtonProps } from \"./Button\"\n\nexport type CopyButtonProps = {\n copyValue: string | ClipboardContent | (() => string) | (() => ClipboardContent)\n children?: React.ReactNode | ((props: { copied: boolean }) => React.ReactNode)\n} & Omit<ButtonProps, \"children\">\n\nexport const CopyButton = ({ children, copyValue, onClick, ...restProps }: CopyButtonProps) => {\n const [copied, setCopied] = useState<boolean>(false)\n const copiedTimeout = useRef<number | null>(null)\n\n const handleClick = (evt: MouseEvent<HTMLButtonElement>) => {\n // No-op when copied is true\n if (copied) {\n return\n }\n\n setCopied(true)\n onClick?.(evt)\n\n // Copy content to clipboard\n // NOTE: Failures are a silent no-op\n copyToClipboard(typeof copyValue === \"function\" ? copyValue() : copyValue)\n\n copiedTimeout.current = window.setTimeout(() => {\n setCopied(false)\n }, 1300)\n }\n\n useEffect(() => {\n return () => {\n if (copiedTimeout.current) clearTimeout(copiedTimeout.current)\n }\n }, [])\n\n return (\n <Button {...restProps} onClick={handleClick}>\n <Animate\n className=\"w-[var(--button-icon-size)] h-[var(--button-icon-size)]\"\n initial={{ scale: 0.6 }}\n enter={{ scale: 1, delay: 150, duration: 300 }}\n exit={{ scale: 0.6, duration: 150 }}\n forceCompositeLayer\n >\n {copied ? <Check key=\"copied-icon\" /> : <Copy key=\"copy-icon\" />}\n </Animate>\n {typeof children === \"function\" ? children({ copied }) : children}\n </Button>\n )\n}\n", "export type ClipboardContent = {\n \"text/plain\"?: string\n \"image/png\"?: Blob\n \"image/jpeg\"?: Blob\n \"image/webp\"?: Blob\n}\n\nconst supportsRichClipboard = (): boolean =>\n typeof ClipboardItem !== \"undefined\" && !!navigator.clipboard?.write\n\n// Convert ClipboardContent to { [mime]: Blob } for ClipboardItem\nexport function toClipboardItem(content: ClipboardContent): ClipboardItem {\n const { \"text/plain\": text, ...rest } = content\n return new ClipboardItem({\n ...rest,\n ...(text ? { \"text/plain\": new Blob([text], { type: \"text/plain\" }) } : null),\n })\n}\n\n/**\n * Utility for copying rich content in a cross-browser way\n *\n * @param {string | ClipboardContent} content\n * @param {HTMLElement} container - Fallback text copy method requires appending a textarea\n * to the DOM and focusing it. If you don't want to shift focus out of the currently\n * focused container (e.g. a popover) you can specify a custom container to append\n * the textarea to keep focus in that container. This need for this edge case is\n * exceedingly rare as navigator.clipboard.writeText support expands.\n * @returns - A promise that resolves to true if the copy was successful, false otherwise.\n */\nexport async function copyToClipboard(\n content: string | ClipboardContent,\n container: HTMLElement = document.body,\n): Promise<boolean> {\n if (typeof content === \"string\") {\n return copyText(content, container)\n }\n\n try {\n if (supportsRichClipboard()) {\n await navigator.clipboard.write([toClipboardItem(content)])\n return true\n }\n\n // Fallback: if we have plain text, at least copy that.\n if (content[\"text/plain\"]) {\n return copyText(content[\"text/plain\"], container)\n }\n\n return false\n } catch (error) {\n return false\n }\n}\n\n/**\n * Utility for copying plaintext in a cross-browser way\n *\n * @param {string} text\n * @param {HTMLElement} container - Fallback text copy method requires appending a textarea\n * to the DOM and focusing it. If you don't want to shift focus out of the currently\n * focused container (e.g. a popover) you can specify a custom container to append\n * the textarea to keep focus in that container. This need for this edge case is\n * exceedingly rare as navigator.clipboard.writeText support expands.\n * @returns - A promise that resolves to true if the copy was successful, false otherwise.\n */\nexport async function copyText(\n text: string,\n container: HTMLElement = document.body,\n): Promise<boolean> {\n if (navigator.clipboard) {\n try {\n // Try to use the navigator.clipboard method first\n await navigator.clipboard.writeText(text)\n return true\n } catch (error) {\n // If that doesn't work, we continue on to the fallback\n // method below\n }\n }\n\n // Fallback method\n const textArea = document.createElement(\"textarea\")\n textArea.value = text\n\n // Avoid visibility/interaction\n textArea.style.position = \"fixed\"\n textArea.style.top = \"0\"\n textArea.style.left = \"0\"\n textArea.style.opacity = \"0\"\n\n container.appendChild(textArea)\n textArea.focus()\n textArea.select()\n\n let succeeded = false\n try {\n succeeded = document.execCommand(\"copy\")\n } catch (error) {\n // Ignore\n }\n container.removeChild(textArea)\n return succeeded\n}\n", "\"use client\"\n\nimport clsx from \"clsx\"\nimport { TransitionGroup, type TransitionGroupProps } from \"./TransitionGroup\"\n\nimport { type CSSProperties } from \"react\"\nimport {\n toCssVariables,\n toFilterProperty,\n toMsDurationProperty,\n toOpacityProperty,\n toTransformProperty,\n} from \"../../lib/helpers\"\nimport s from \"./Animate.module.css\"\nimport { type InitialTransitionDefinition, type TransitionDefinition } from \"./shared\"\n\nexport type AnimateProps = Pick<\n TransitionGroupProps,\n \"as\" | \"children\" | \"className\" | \"insertMethod\" | \"preventInitialTransition\"\n> & {\n /** Class applied to the inner TransitionGroup */\n transitionClassName?: string\n /** Styles applied to the enter transition */\n enter?: TransitionDefinition\n /** Styles applied to the exit transition */\n exit?: TransitionDefinition\n /** Styles applied before the enter transition occurs */\n initial?: InitialTransitionDefinition\n /**\n * Determines how transition states are positioned\n * @default absolute\n */\n transitionPosition?: \"absolute\" | \"static\"\n /**\n * Applies `will-change` to force animating elements to composite layers. Use with caution!\n * @default false\n */\n forceCompositeLayer?: boolean\n}\n\nexport const Animate = (props: AnimateProps) => {\n const {\n as: TagName = \"span\",\n className,\n children,\n preventInitialTransition,\n insertMethod,\n transitionClassName,\n transitionPosition = \"absolute\",\n } = props\n const { enterTotalDuration, exitTotalDuration, variables } = getAnimationProperties(props)\n\n return (\n <TagName\n className={clsx(\"block\", transitionPosition === \"absolute\" && \"relative\", className)}\n data-transition-position={transitionPosition}\n style={variables}\n >\n <TransitionGroup\n as={TagName}\n className={clsx(s.TransitionItem, transitionClassName)}\n enterDuration={enterTotalDuration}\n exitDuration={exitTotalDuration}\n insertMethod={insertMethod}\n preventInitialTransition={preventInitialTransition}\n >\n {children}\n </TransitionGroup>\n </TagName>\n )\n}\n\n// Keep in sync with default values in Animate.module.css\nconst DEFAULT_ENTER_DURATION_MS_EASE = 400\nconst DEFAULT_ENTER_DURATION_MS_CUBIC = 500\nconst DEFAULT_EXIT_DURATION_MS_EASE = 200\nconst DEFAULT_EXIT_DURATION_MS_CUBIC = 300\n\nfunction getAnimationProperties({\n initial: initial,\n enter: enter,\n exit: exit,\n forceCompositeLayer,\n}: AnimateProps): {\n enterTotalDuration: number\n exitTotalDuration: number\n variables: CSSProperties\n} {\n // Dynamically inspect if we're transitioning transform properties, and apply cubic curves and timings as defaults\n const initialTransform = toTransformProperty(initial)\n const enterTransform = toTransformProperty(enter)\n const exitTransform = toTransformProperty(exit)\n const isCubicTransition = [initialTransform, exitTransform, enterTransform].some(\n (t) => t !== \"none\",\n )\n const enterDuration =\n enter?.duration ??\n (isCubicTransition ? DEFAULT_ENTER_DURATION_MS_CUBIC : DEFAULT_ENTER_DURATION_MS_EASE)\n const enterTimingFunction =\n enter?.timingFunction ?? (isCubicTransition ? \"var(--cubic-enter)\" : \"ease\")\n const exitDuration =\n exit?.duration ??\n (isCubicTransition ? DEFAULT_EXIT_DURATION_MS_CUBIC : DEFAULT_EXIT_DURATION_MS_EASE)\n const exitTimingFunction =\n exit?.timingFunction ?? (isCubicTransition ? \"var(--cubic-exit)\" : \"ease\")\n\n // Generate variable overrides from props\n const variables = toCssVariables({\n \"tg-will-change\": forceCompositeLayer ? \"transform, opacity\" : \"auto\",\n \"tg-enter-opacity\": toOpacityProperty(enter?.opacity ?? 1),\n \"tg-enter-transform\": enterTransform,\n \"tg-enter-filter\": toFilterProperty(enter),\n \"tg-enter-duration\": toMsDurationProperty(enterDuration),\n \"tg-enter-delay\": toMsDurationProperty(enter?.delay ?? 0),\n \"tg-enter-timing-function\": enterTimingFunction,\n \"tg-exit-opacity\": toOpacityProperty(exit?.opacity ?? 0),\n \"tg-exit-transform\": exitTransform,\n \"tg-exit-filter\": toFilterProperty(exit),\n \"tg-exit-duration\": toMsDurationProperty(exitDuration),\n \"tg-exit-delay\": toMsDurationProperty(exit?.delay ?? 0),\n \"tg-exit-timing-function\": exitTimingFunction,\n \"tg-initial-opacity\": toOpacityProperty(initial?.opacity ?? exit?.opacity ?? 0),\n \"tg-initial-transform\": initialTransform === \"none\" ? exitTransform : initialTransform,\n \"tg-initial-filter\": toFilterProperty(initial ?? exit ?? {}),\n } satisfies Record<string, string>)\n\n const enterTotalDuration = (enter?.delay ?? 0) + enterDuration\n const exitTotalDuration = (exit?.delay ?? 0) + exitDuration\n\n return { enterTotalDuration, exitTotalDuration, variables }\n}\n", "\"use client\"\n\nimport clsx from \"clsx\"\nimport { useRef, type CSSProperties } from \"react\"\nimport {\n toCssVariables,\n toFilterProperty,\n toMsDurationProperty,\n toOpacityProperty,\n toTransformProperty,\n waitForAnimationFrame,\n} from \"../../lib/helpers\"\nimport s from \"./AnimateLayout.module.css\"\nimport { TransitionGroup, type TransitionGroupProps } from \"./TransitionGroup\"\nimport {\n type InitialTransitionDefinition,\n type LayoutTransitionDefinition,\n type TransitionDefinition,\n} from \"./shared\"\n\nexport type AnimateLayoutProps = Pick<\n TransitionGroupProps,\n \"as\" | \"children\" | \"className\" | \"insertMethod\" | \"preventInitialTransition\"\n> & {\n /**\n * Determines if `overflow: hidden` is applied to the wrapper element\n * @default false\n */\n hideOverflow?: boolean\n /**\n * Determines which side of the container the items will pin to during enter/exit\n * @default \"start\"\n */\n itemAnchor?: \"start\" | \"end\"\n /**\n * Determines which property will be animated during transitions\n * @default \"height\"\n */\n dimension?: \"width\" | \"height\"\n layoutEnter?: LayoutTransitionDefinition\n layoutExit?: LayoutTransitionDefinition\n layoutMove?: LayoutTransitionDefinition\n\n enter?: TransitionDefinition\n exit?: TransitionDefinition\n initial?: InitialTransitionDefinition\n /** Class applied to the inner TransitionGroup */\n transitionClassName?: string\n /**\n * Applies `will-change` to force animating elements to composite layers. Use with caution!\n * @default false\n */\n forceCompositeLayer?: boolean\n}\n\nexport const AnimateLayout = (props: AnimateLayoutProps) => {\n const {\n as: TagName = \"span\",\n children,\n transitionClassName,\n insertMethod,\n className,\n hideOverflow = false,\n // An initial height animation will almost never be correct. Consider carefully when overriding.\n preventInitialTransition = true,\n itemAnchor = \"start\",\n dimension = \"height\",\n } = props\n const containerRef = useRef<HTMLDivElement | null>(null)\n const captainRef = useRef<HTMLDivElement | null>(null)\n const exitTimestampRef = useRef<number | null>(null)\n\n const { enterTotalDuration, exitTotalDuration, variables } = getAnimationProperties(props)\n\n const handleEnter = (element: HTMLDivElement) => {\n const container = containerRef.current\n\n if (!container) {\n return\n }\n\n // If handleExit() was called >50ms ago, consider this a \"move\" and don't touch \"interrupted\" state\n const justExited = exitTimestampRef.current && Date.now() - exitTimestampRef.current < 50\n\n const anotherCaptain = !!captainRef.current\n // Look at me, I'm the captain now\n captainRef.current = element\n\n // Recent exits are a near guarantee we are \"moving\" states\n container.dataset.direction = justExited || anotherCaptain ? \"move\" : \"in\"\n\n // If we just exited, don't touch the interrupted state. Exit just set it with the correct state of things\n if (!justExited) {\n container.dataset.interrupted = String(!!container.style[dimension])\n }\n\n const clientRect = container.getBoundingClientRect()\n container.style[dimension] = `${clientRect[dimension]}px`\n }\n\n const handleEnterActive = (element: HTMLDivElement) => {\n const container = containerRef.current\n\n if (!container) {\n return\n }\n\n // ~Impossible to not be the captain at this point, but check anyway.\n const amICaptain = captainRef.current === element\n if (!amICaptain) {\n return\n }\n\n // IMPORTANT: Use clientHeight/clientWidth to measure children, in case they have scale() applied\n const value = dimension === \"width\" ? element.clientWidth : element.clientHeight\n container.style[dimension] = `${value}px`\n }\n\n const handleEnterComplete = (element: HTMLDivElement) => {\n const container = containerRef.current\n\n // Wait for the next tick, to ensure React has cleared `[data-entering*]` state from the DOM\n // Without this, it's possible that we release the height from the container\n // before the children in the DOM are naturally positioned (non-absolute).\n waitForAnimationFrame(() => {\n const amICaptain = captainRef.current === element\n if (!container || !amICaptain) {\n return\n }\n\n // Restore natural height to the DOM node\n container.style[dimension] = \"\"\n })\n }\n\n const handleExit = (element: HTMLDivElement) => {\n const container = containerRef.current\n const amICaptain = !captainRef.current || captainRef.current === element\n\n if (!container || !amICaptain) {\n return\n }\n\n // o7\n captainRef.current = null\n exitTimestampRef.current = Date.now()\n\n container.dataset.direction = \"out\"\n container.dataset.interrupted = String(!!container.style[dimension])\n\n const clientRect = container.getBoundingClientRect()\n container.style[dimension] = `${clientRect[dimension]}px`\n }\n\n const handleExitActive = (_element: HTMLDivElement) => {\n const container = containerRef.current\n const newCaptainExists = !!captainRef.current\n\n // If another component has become the captain, exit early\n if (!container || newCaptainExists) {\n return\n }\n\n // Animate to zero layout\n container.style[dimension] = \"0\"\n }\n\n const handleExitComplete = (_element: HTMLDivElement) => {\n // Wait for the next tick, to ensure React has cleared `[data-exiting*]` state from the DOM\n waitForAnimationFrame(() => {\n const container = containerRef.current\n const newCaptainExists = !!captainRef.current\n\n // If another component has become the captain, exit early\n if (!container || newCaptainExists) {\n return\n }\n\n // Restore natural height to the DOM node\n container.style[dimension] = \"\"\n })\n }\n\n return (\n <TagName\n ref={containerRef}\n className={clsx(s.Layout, className)}\n style={variables}\n data-item-anchor={itemAnchor}\n data-clip={hideOverflow}\n data-dimension={dimension}\n >\n <TransitionGroup\n as={TagName}\n className={clsx(s.TransitionItem, transitionClassName)}\n insertMethod={insertMethod}\n enterDuration={enterTotalDuration}\n exitDuration={exitTotalDuration}\n preventInitialTransition={preventInitialTransition}\n onEnter={handleEnter}\n onEnterActive={handleEnterActive}\n onEnterComplete={handleEnterComplete}\n onExit={handleExit}\n onExitActive={handleExitActive}\n onExitComplete={handleExitComplete}\n >\n {children}\n </TransitionGroup>\n </TagName>\n )\n}\n\n// Keep in sync with default values in AnimateLayout.module.css\nconst DEFAULT_LAYOUT_ENTER_DURATION_MS = 300\nconst DEFAULT_LAYOUT_ENTER_DELAY_MS = 0\nconst DEFAULT_LAYOUT_EXIT_DURATION_MS = 300\nconst DEFAULT_LAYOUT_EXIT_DELAY_MS = 0\nconst DEFAULT_LAYOUT_MOVE_DURATION_MS = 300\nconst DEFAULT_LAYOUT_MOVE_DELAY_MS = 0\nconst DEFAULT_ENTER_DURATION_MS_EASE = 300\nconst DEFAULT_ENTER_DURATION_MS_CUBIC = 300\nconst DEFAULT_ENTER_DELAY_MS = 100\nconst DEFAULT_EXIT_DURATION_MS_EASE = 200\nconst DEFAULT_EXIT_DURATION_MS_CUBIC = 200\nconst DEFAULT_EXIT_DELAY_MS = 0\n\nfunction getAnimationProperties({\n initial,\n enter,\n exit,\n forceCompositeLayer,\n layoutEnter,\n layoutExit,\n layoutMove,\n}: AnimateLayoutProps): {\n enterTotalDuration: number\n exitTotalDuration: number\n variables: CSSProperties\n} {\n // Dynamically inspect if we're transitioning transform properties, and apply cubic curves and timings as defaults\n const initialTransform = toTransformProperty(initial)\n const enterTransform = toTransformProperty(enter)\n const exitTransform = toTransformProperty(exit)\n const isCubicTransition = [initialTransform, exitTransform, enterTransform].some(\n (t) => t !== \"none\",\n )\n const enterDuration =\n enter?.duration ??\n (isCubicTransition ? DEFAULT_ENTER_DURATION_MS_CUBIC : DEFAULT_ENTER_DURATION_MS_EASE)\n const enterTimingFunction =\n enter?.timingFunction ?? (isCubicTransition ? \"var(--cubic-enter)\" : \"ease\")\n const exitDuration =\n exit?.duration ??\n (isCubicTransition ? DEFAULT_EXIT_DURATION_MS_CUBIC : DEFAULT_EXIT_DURATION_MS_EASE)\n const exitTimingFunction =\n exit?.timingFunction ?? (isCubicTransition ? \"var(--cubic-exit)\" : \"ease\")\n\n // Generate variable overrides from props\n const variables = toCssVariables({\n \"tg-will-change\": forceCompositeLayer ? \"transform, opacity\" : \"auto\",\n \"tg-enter-opacity\": toOpacityProperty(enter?.opacity ?? 1),\n \"tg-enter-transform\": enterTransform,\n \"tg-enter-filter\": toFilterProperty(enter),\n \"tg-enter-duration\": toMsDurationProperty(enterDuration),\n \"tg-enter-delay\": toMsDurationProperty(enter?.delay ?? DEFAULT_ENTER_DELAY_MS),\n \"tg-enter-timing-function\": enterTimingFunction,\n \"tg-exit-opacity\": toOpacityProperty(exit?.opacity ?? 0),\n \"tg-exit-transform\": exitTransform,\n \"tg-exit-filter\": toFilterProperty(exit ?? {}),\n \"tg-exit-duration\": toMsDurationProperty(exitDuration),\n \"tg-exit-delay\": toMsDurationProperty(exit?.delay ?? DEFAULT_EXIT_DELAY_MS),\n \"tg-exit-timing-function\": exitTimingFunction,\n \"tg-initial-opacity\": toOpacityProperty(initial?.opacity ?? exit?.opacity ?? 0),\n \"tg-initial-transform\": initialTransform === \"none\" ? exitTransform : initialTransform,\n \"tg-initial-filter\": toFilterProperty(initial ?? exit ?? {}),\n \"tg-layout-enter-duration\": toMsDurationProperty(\n layoutEnter?.duration ?? DEFAULT_LAYOUT_ENTER_DURATION_MS,\n ),\n \"tg-layout-enter-delay\": toMsDurationProperty(\n layoutEnter?.delay ?? DEFAULT_LAYOUT_ENTER_DELAY_MS,\n ),\n \"tg-layout-enter-timing-function\": layoutEnter?.timingFunction ?? \"var(--cubic-move)\",\n \"tg-layout-exit-duration\": toMsDurationProperty(\n layoutExit?.duration ?? DEFAULT_LAYOUT_EXIT_DURATION_MS,\n ),\n \"tg-layout-exit-delay\": toMsDurationProperty(layoutExit?.delay ?? DEFAULT_LAYOUT_EXIT_DELAY_MS),\n \"tg-layout-exit-timing-function\": layoutExit?.timingFunction ?? \"var(--cubic-move)\",\n \"tg-layout-move-duration\": toMsDurationProperty(\n layoutMove?.duration ?? DEFAULT_LAYOUT_MOVE_DURATION_MS,\n ),\n \"tg-layout-move-delay\": toMsDurationProperty(layoutMove?.delay ?? DEFAULT_LAYOUT_MOVE_DELAY_MS),\n \"tg-layout-move-timing-function\": layoutMove?.timingFunction ?? \"var(--cubic-move)\",\n } satisfies Record<string, string>)\n\n const enterTotalDuration =\n (enter?.delay ?? DEFAULT_ENTER_DELAY_MS) + (enterDuration ?? DEFAULT_ENTER_DURATION_MS_EASE)\n const exitTotalDuration =\n (exit?.delay ?? DEFAULT_EXIT_DELAY_MS) + (exitDuration ?? DEFAULT_EXIT_DURATION_MS_EASE)\n const layoutEnterTotalDuration =\n (layoutEnter?.delay ?? DEFAULT_LAYOUT_ENTER_DELAY_MS) +\n (layoutEnter?.duration ?? DEFAULT_LAYOUT_ENTER_DURATION_MS)\n const layoutExitTotalDuration =\n (layoutExit?.delay ?? DEFAULT_LAYOUT_EXIT_DELAY_MS) +\n (layoutExit?.duration ?? DEFAULT_LAYOUT_EXIT_DURATION_MS)\n const layoutMoveTotalDuration =\n (layoutMove?.delay ?? DEFAULT_LAYOUT_MOVE_DELAY_MS) +\n (layoutMove?.duration ?? DEFAULT_LAYOUT_MOVE_DURATION_MS)\n\n return {\n // In order for us to release layout dimensions (e.g., height) to the natural DOM state,\n // we must ensure the behaviors from the TransitionGroup callbacks are synced with the outer layout `transitions`.\n // Setting TransitionGroup timing to the max of these durations is the simplest approach.\n // In practice, these should only vary by about 50-200ms at most; imperceivable to end-users.\n enterTotalDuration: Math.max(\n enterTotalDuration,\n layoutEnterTotalDuration,\n layoutMoveTotalDuration,\n ),\n exitTotalDuration: Math.max(\n exitTotalDuration,\n layoutExitTotalDuration,\n layoutMoveTotalDuration,\n ),\n variables,\n }\n}\n", "\"use client\"\n\nimport { TransitionGroup, type TransitionGroupProps } from \"./TransitionGroup\"\n\nimport clsx from \"clsx\"\nimport { type CSSProperties } from \"react\"\nimport {\n toCssVariables,\n toFilterProperty,\n toMsDurationProperty,\n toOpacityProperty,\n toTransformProperty,\n waitForAnimationFrame,\n} from \"../../lib/helpers\"\nimport s from \"./AnimateLayoutGroup.module.css\"\nimport {\n type InitialTransitionDefinition,\n type LayoutTransitionDefinition,\n NonNullChildren,\n type TransitionDefinition,\n} from \"./shared\"\n\nexport type AnimateLayoutGroupProps = Pick<\n TransitionGroupProps,\n \"as\" | \"children\" | \"className\" | \"insertMethod\" | \"preventInitialTransition\"\n> & {\n /**\n * Determines if `overflow: hidden` is applied to the wrapper element\n * @default false\n */\n hideOverflow?: boolean\n /**\n * Determines which side of the container the items will pin to during enter/exit\n * @default \"start\"\n */\n itemAnchor?: \"start\" | \"end\"\n /**\n * Determines which property will be animated during transitions\n * @default \"height\"\n */\n dimension?: \"width\" | \"height\"\n layoutEnter?: LayoutTransitionDefinition\n layoutExit?: LayoutTransitionDefinition\n layoutMove?: LayoutTransitionDefinition\n\n enter?: TransitionDefinition\n exit?: TransitionDefinition\n initial?: InitialTransitionDefinition\n /** Class applied to the inner TransitionGroup */\n transitionClassName?: string\n /**\n * Applies `will-change` to force animating elements to composite layers. Use with caution!\n * @default false\n */\n forceCompositeLayer?: boolean\n}\n\nexport const AnimateLayoutGroup = (props: AnimateLayoutGroupProps) => {\n const {\n as: TagName = \"span\",\n children,\n className,\n transitionClassName,\n dimension = \"height\",\n } = props\n const { enterTotalDuration, exitTotalDuration, variables } = getAnimationProperties(props)\n\n const handleEnter = (element: HTMLDivElement) => {\n // Stage zero layout\n element.style[dimension] = \"0\"\n }\n\n const handleEnterActive = (element: HTMLDivElement) => {\n waitForAnimationFrame(() => {\n // Animate to target height\n // IMPORTANT: Use clientHeight/clientWidth to measure children, in case they have scale() applied\n const value =\n dimension === \"width\"\n ? element.firstElementChild?.clientWidth\n : element.firstElementChild?.clientHeight\n\n element.style[dimension] = `${value ?? 0}px`\n })\n }\n\n const handleEnterComplete = (element: HTMLDivElement) => {\n waitForAnimationFrame(() => {\n // Restore natural layout to the DOM node\n element.style[dimension] = \"\"\n })\n }\n\n const handleExit = (element: HTMLDivElement) => {\n element.style[dimension] = `${element.getBoundingClientRect()[dimension]}px`\n }\n\n const handleExitActive = (element: HTMLDivElement) => {\n waitForAnimationFrame(() => {\n // Animate to zero layout\n element.style[dimension] = \"0\"\n })\n }\n\n return (\n <TransitionGroup\n as={TagName}\n className={clsx(s.LayoutItem, className)}\n style={variables}\n // Adding 32ms to timers because of the additional waitForAnimationFrame() calls\n enterDuration={enterTotalDuration + 32}\n exitDuration={exitTotalDuration + 32}\n onEnter={handleEnter}\n onEnterActive={handleEnterActive}\n onEnterComplete={handleEnterComplete}\n onExit={handleExit}\n onExitActive={handleExitActive}\n >\n {NonNullChildren(children).map((child) => (\n // Ensure any falsy child.key value is sent specifically as `undefined`.\n // This ensures that key is not misinterpreted as a string 'null', 'false', etc.\n <TagName\n className={clsx(s.TransitionItem, transitionClassName)}\n // @ts-expect-error Pass-through the validation of `key` to <TransitionGroup>\n key={child.key || undefined}\n data-dimension={dimension}\n >\n {child}\n </TagName>\n ))}\n </TransitionGroup>\n )\n}\n\n// Keep in sync with default values in AnimateLayout.module.css\nconst DEFAULT_LAYOUT_ENTER_DURATION_MS = 300\nconst DEFAULT_LAYOUT_ENTER_DELAY_MS = 0\nconst DEFAULT_LAYOUT_EXIT_DURATION_MS = 300\nconst DEFAULT_LAYOUT_EXIT_DELAY_MS = 50\nconst DEFAULT_LAYOUT_MOVE_DURATION_MS = 300\nconst DEFAULT_LAYOUT_MOVE_DELAY_MS = 0\nconst DEFAULT_ENTER_DURATION_MS_EASE = 400\nconst DEFAULT_ENTER_DURATION_MS_CUBIC = 400\nconst DEFAULT_ENTER_DELAY_MS = 150\nconst DEFAULT_EXIT_DURATION_MS_EASE = 200\nconst DEFAULT_EXIT_DURATION_MS_CUBIC = 300\nconst DEFAULT_EXIT_DELAY_MS = 0\n\nfunction getAnimationProperties({\n initial,\n enter,\n exit,\n forceCompositeLayer,\n layoutEnter,\n layoutExit,\n layoutMove,\n}: AnimateLayoutGroupProps): {\n enterTotalDuration: number\n exitTotalDuration: number\n variables: CSSProperties\n} {\n // Dynamically inspect if we're transitioning transform properties, and apply cubic curves and timings as defaults\n const initialTransform = toTransformProperty(initial)\n const enterTransform = toTransformProperty(enter)\n const exitTransform = toTransformProperty(exit)\n const isCubicTransition = [initialTransform, exitTransform, enterTransform].some(\n (t) => t !== \"none\",\n )\n const enterDuration =\n enter?.duration ??\n (isCubicTransition ? DEFAULT_ENTER_DURATION_MS_CUBIC : DEFAULT_ENTER_DURATION_MS_EASE)\n const enterTimingFunction =\n enter?.timingFunction ?? (isCubicTransition ? \"var(--cubic-enter)\" : \"ease\")\n const exitDuration =\n exit?.duration ??\n (isCubicTransition ? DEFAULT_EXIT_DURATION_MS_CUBIC : DEFAULT_EXIT_DURATION_MS_EASE)\n const exitTimingFunction =\n exit?.timingFunction ?? (isCubicTransition ? \"var(--cubic-exit)\" : \"ease\")\n\n // Generate variable overrides from props\n const variables = toCssVariables({\n \"tg-will-change\": forceCompositeLayer ? \"transform, opacity\" : \"auto\",\n \"tg-enter-opacity\": toOpacityProperty(enter?.opacity ?? 1),\n \"tg-enter-transform\": enterTransform,\n \"tg-enter-filter\": toFilterProperty(enter ?? {}),\n \"tg-enter-duration\": toMsDurationProperty(enterDuration),\n \"tg-enter-delay\": toMsDurationProperty(enter?.delay ?? DEFAULT_ENTER_DELAY_MS),\n \"tg-enter-timing-function\": enterTimingFunction,\n \"tg-exit-opacity\": toOpacityProperty(exit?.opacity ?? 0),\n \"tg-exit-transform\": exitTransform,\n \"tg-exit-filter\": toFilterProperty(exit ?? {}),\n \"tg-exit-duration\": toMsDurationProperty(exitDuration),\n \"tg-exit-delay\": toMsDurationProperty(exit?.delay ?? DEFAULT_EXIT_DELAY_MS),\n \"tg-exit-timing-function\": exitTimingFunction,\n \"tg-initial-opacity\": toOpacityProperty(initial?.opacity ?? exit?.opacity ?? 0),\n \"tg-initial-transform\": initialTransform === \"none\" ? exitTransform : initialTransform,\n \"tg-initial-filter\": toFilterProperty(initial ?? exit ?? {}),\n \"tg-layout-enter-duration\": toMsDurationProperty(\n layoutEnter?.duration ?? DEFAULT_LAYOUT_ENTER_DURATION_MS,\n ),\n \"tg-layout-enter-delay\": toMsDurationProperty(\n layoutEnter?.delay ?? DEFAULT_LAYOUT_ENTER_DELAY_MS,\n ),\n \"tg-layout-enter-timing-function\": layoutEnter?.timingFunction ?? \"var(--cubic-move)\",\n \"tg-layout-exit-duration\": toMsDurationProperty(\n layoutExit?.duration ?? DEFAULT_LAYOUT_EXIT_DURATION_MS,\n ),\n \"tg-layout-exit-delay\": toMsDurationProperty(layoutExit?.delay ?? DEFAULT_LAYOUT_EXIT_DELAY_MS),\n \"tg-layout-exit-timing-function\": layoutExit?.timingFunction ?? \"var(--cubic-move)\",\n \"tg-layout-move-duration\": toMsDurationProperty(\n layoutMove?.duration ?? DEFAULT_LAYOUT_MOVE_DURATION_MS,\n ),\n \"tg-layout-move-delay\": toMsDurationProperty(\n layoutMove?.delay ?? DEFAULT_LAYOUT_MOVE_DURATION_MS,\n ),\n \"tg-layout-move-timing-function\": layoutMove?.timingFunction ?? \"var(--cubic-move)\",\n } satisfies Record<string, string>)\n\n const enterTotalDuration =\n (enter?.delay ?? DEFAULT_ENTER_DELAY_MS) + (enterDuration ?? DEFAULT_ENTER_DURATION_MS_EASE)\n const exitTotalDuration =\n (exit?.delay ?? DEFAULT_EXIT_DELAY_MS) + (exitDuration ?? DEFAULT_EXIT_DURATION_MS_EASE)\n const layoutEnterTotalDuration =\n (layoutEnter?.delay ?? DEFAULT_LAYOUT_ENTER_DELAY_MS) +\n (layoutEnter?.duration ?? DEFAULT_LAYOUT_ENTER_DURATION_MS)\n const layoutExitTotalDuration =\n (layoutExit?.delay ?? DEFAULT_LAYOUT_EXIT_DELAY_MS) +\n (layoutExit?.duration ?? DEFAULT_LAYOUT_EXIT_DURATION_MS)\n const layoutMoveTotalDuration =\n (layoutMove?.delay ?? DEFAULT_LAYOUT_MOVE_DELAY_MS) +\n (layoutMove?.duration ?? DEFAULT_LAYOUT_MOVE_DURATION_MS)\n\n return {\n // In order for us to release layout dimensions (e.g., height) to the natural DOM state,\n // we must ensure the behaviors from the TransitionGroup callbacks are synced with the outer layout `transitions`.\n // Setting TransitionGroup timing to the max of these durations is the simplest approach.\n // In practice, these should only vary by about 50-200ms at most; imperceivable to end-users.\n enterTotalDuration: Math.max(\n enterTotalDuration,\n layoutEnterTotalDuration,\n layoutMoveTotalDuration,\n ),\n exitTotalDuration: Math.max(\n exitTotalDuration,\n layoutExitTotalDuration,\n layoutMoveTotalDuration,\n ),\n variables,\n }\n}\n", "\"use client\"\n\nimport React, {\n Children,\n useCallback,\n useEffect,\n useLayoutEffect,\n useReducer,\n useRef,\n useState,\n} from \"react\"\nimport { mergeRefs } from \"react-merge-refs\"\n\nimport { waitForAnimationFrame } from \"../../lib/helpers\"\n\n// (no-op) clsx removed: className is not managed at group-level for slotted children\nimport { useTimeout } from \"usehooks-ts\"\nimport getDisableAnimations from \"./getDisableAnimations\"\nimport {\n assertSingleChildWhenRef,\n ChildrenWithKeys,\n computeNextRenderChildren,\n noop,\n useChildCallback,\n type CallbackType,\n type ReactElementWithKey,\n type TransitionGroupChildCallbacks,\n} from \"./shared\"\nimport { getInitialTransitionState, transitionReducer } from \"./transitionReducer\"\n\ntype SlotTransitionGroupChildProps = {\n component: ReactElementWithKey\n preventMountTransition?: boolean\n shouldRender: boolean\n enterDuration: number\n exitDuration: number\n enterMountDelay?: number\n removeChild: () => void\n ref?: React.Ref<unknown>\n} & TransitionGroupChildCallbacks\n\nconst SlotTransitionGroupChildInner = ({\n ref,\n component,\n preventMountTransition,\n shouldRender,\n enterDuration,\n exitDuration,\n removeChild,\n onEnter,\n onEnterActive,\n onEnterComplete,\n onExit,\n onExitActive,\n onExitComplete,\n}: SlotTransitionGroupChildProps) => {\n const [state, dispatch] = useReducer(\n transitionReducer,\n getInitialTransitionState(preventMountTransition || false),\n )\n const preventedMountTransition = useRef<boolean>(false)\n const elementRef = useRef<HTMLDivElement | null>(null)\n const enterDurationRef = useRef<number>(enterDuration)\n enterDurationRef.current = enterDuration\n const exitDurationRef = useRef<number>(exitDuration)\n exitDurationRef.current = exitDuration\n\n const lastCallbackRef = useRef<CallbackType>(null as unknown as CallbackType)\n const triggerCallback = useCallback(\n (callbackType: CallbackType) => {\n const element = elementRef.current\n if (!element || callbackType === lastCallbackRef.current) {\n return\n }\n lastCallbackRef.current = callbackType\n switch (callbackType) {\n case \"enter\":\n onEnter(element)\n break\n case \"enter-active\":\n onEnterActive(element)\n break\n case \"enter-complete\":\n onEnterComplete(element)\n break\n case \"exit\":\n onExit(element)\n break\n case \"exit-active\":\n onExitActive(element)\n break\n case \"exit-complete\":\n onExitComplete(element)\n break\n default:\n callbackType satisfies never\n break\n }\n },\n [onEnter, onEnterActive, onEnterComplete, onExit, onExitActive, onExitComplete],\n )\n\n /**\n * IMPORTANT: `useLayoutEffect()` is used here to avoid race conditions between new SlotTransitionGroupChild components.\n */\n useLayoutEffect(() => {\n // Exit transition\n if (!shouldRender) {\n let exitTimeout: number | undefined\n\n dispatch({ type: \"exit-before\" })\n triggerCallback(\"exit\")\n\n const cancelAnimationFrame = waitForAnimationFrame(() => {\n dispatch({ type: \"exit-active\" })\n triggerCallback(\"exit-active\")\n\n exitTimeout = window.setTimeout(() => {\n triggerCallback(\"exit-complete\")\n removeChild()\n }, exitDurationRef.current)\n })\n\n return () => {\n cancelAnimationFrame()\n if (exitTimeout !== undefined) clearTimeout(exitTimeout)\n }\n }\n\n // Enter transition\n\n // Check if we need to prevent this specific entering cycle\n if (preventMountTransition && !preventedMountTransition.current) {\n // Mark initial transition as prevented and short-circuit.\n preventedMountTransition.current = true\n return\n }\n\n let enterTimeout: number | undefined\n\n dispatch({ type: \"enter-before\" })\n triggerCallback(\"enter\")\n\n const cancelAnimationFrame = waitForAnimationFrame(() => {\n dispatch({ type: \"enter-active\" })\n triggerCallback(\"enter-active\")\n\n enterTimeout = window.setTimeout(() => {\n dispatch({ type: \"done\" })\n triggerCallback(\"enter-complete\")\n }, enterDurationRef.current)\n })\n\n return () => {\n cancelAnimationFrame()\n if (enterTimeout !== undefined) clearTimeout(enterTimeout)\n }\n }, [\n shouldRender,\n // This value is immutable after <SlotTransitionGroup> is created, and does not change on re-renders.\n preventMountTransition,\n removeChild,\n triggerCallback,\n ])\n\n useEffect(() => {\n // Required for <StrictMode>\n return () => {\n preventedMountTransition.current = false\n }\n }, [])\n\n const original = component\n\n const mergedRef = mergeRefs<unknown>([\n elementRef as unknown as React.Ref<unknown>,\n ref as unknown as React.Ref<unknown>,\n ((original as unknown as { ref?: React.Ref<unknown> }).ref ?? null) as React.Ref<unknown>,\n ])\n\n const nextProps = {\n \"data-entering\": state.enter ? \"\" : undefined,\n \"data-entering-active\": state.enterActive ? \"\" : undefined,\n \"data-exiting\": state.exit ? \"\" : undefined,\n \"data-exiting-active\": state.exitActive ? \"\" : undefined,\n \"data-interrupted\": state.interrupted ? \"\" : undefined,\n \"ref\": mergedRef,\n }\n\n return React.isValidElement(original) ? React.cloneElement(original, nextProps) : null\n}\n\nconst SlotTransitionGroupChild = (props: SlotTransitionGroupChildProps) => {\n const { enterMountDelay, preventMountTransition } = props\n const mountDelay = !preventMountTransition && enterMountDelay != null ? enterMountDelay : null\n const [mounted, setMounted] = useState(mountDelay == null)\n useTimeout(() => setMounted(true), mounted ? null : mountDelay)\n\n return mounted ? <SlotTransitionGroupChildInner {...props} /> : null\n}\n\nexport type SlotTransitionGroupProps = {\n /** Components controlled by SlotTransitionGroup rendering */\n children: React.ReactNode\n /** Determines the amount of time that the enter state is applied during mounting */\n enterDuration?: number\n /** Determines the amount of time that the exit state is applied before unmounting */\n exitDuration?: number\n /**\n * Determines if children should have an enter transition applied during mounting of the group.\n * @default true\n */\n preventInitialTransition?: boolean\n /** Delay in MS to wait before mounting a child. `null` for no delay (default). */\n enterMountDelay?: number\n /** Render children changes immediately, bypassing transition timings */\n disableAnimations?: boolean\n /** Determines how new children are added to the children array */\n insertMethod?: \"append\" | \"prepend\"\n /** Ref for the SlotTransitionGroup (applied to the single child when possible) */\n ref?: React.Ref<unknown>\n} & Partial<TransitionGroupChildCallbacks>\n\ntype RenderChild = {\n component: ReactElementWithKey\n shouldRender: boolean\n preventMountTransition?: boolean\n removeChild: () => void\n} & TransitionGroupChildCallbacks\n\nexport const SlotTransitionGroup = (props: SlotTransitionGroupProps) => {\n const {\n ref,\n children,\n enterDuration = 0,\n exitDuration = 0,\n preventInitialTransition = true,\n enterMountDelay,\n insertMethod = \"append\",\n disableAnimations = getDisableAnimations(),\n } = props\n\n // Create stable, mutable references for all callbacks\n const onEnter = useChildCallback(props.onEnter ?? noop)\n const onEnterActive = useChildCallback(props.onEnterActive ?? noop)\n const onEnterComplete = useChildCallback(props.onEnterComplete ?? noop)\n const onExit = useChildCallback(props.onExit ?? noop)\n const onExitActive = useChildCallback(props.onExitActive ?? noop)\n const onExitComplete = useChildCallback(props.onExitComplete ?? noop)\n\n // Ensure all children are provided with keys.\n Children.forEach(children, (child) => {\n // @ts-expect-error - We know `key` might not exist on certain types, that's why we're checking\n if (child && !child.key) {\n throw new Error(\"Child elements of <SlotTransitionGroup /> must include a `key`\")\n }\n })\n\n const createDefaultRenderChildProps = useCallback(\n (child: ReactElementWithKey): RenderChild => ({\n component: child,\n shouldRender: true,\n removeChild: () => {\n setRenderChildren((currentRenderChildren) =>\n currentRenderChildren.filter((c) => child.key !== c.component.key),\n )\n },\n onEnter,\n onEnterActive,\n onEnterComplete,\n onExit,\n onExitActive,\n onExitComplete,\n }),\n [onEnter, onEnterActive, onEnterComplete, onExit, onExitActive, onExitComplete],\n )\n\n const [renderChildren, setRenderChildren] = useState<RenderChild[]>((): RenderChild[] => {\n return ChildrenWithKeys(children).map((child) => ({\n ...createDefaultRenderChildProps(child),\n // Lock this value to whatever the value was on initial render of the group.\n preventMountTransition: preventInitialTransition,\n }))\n })\n\n // IMPORTANT: useLayoutEffect is required to satisfy render timings for prop updates to input elements\n useLayoutEffect(() => {\n setRenderChildren((currentRenderChildren): RenderChild[] => {\n const propChildrenArray = ChildrenWithKeys(children, false, \"SlotTransitionGroup\")\n return computeNextRenderChildren(\n propChildrenArray,\n currentRenderChildren,\n createDefaultRenderChildProps,\n insertMethod,\n )\n })\n }, [children, insertMethod, createDefaultRenderChildProps])\n\n // Prevent mistakes with forwardRef() by ensuring single child usage within the group.\n assertSingleChildWhenRef(\"SlotTransitionGroup\", ref, Children.count(children))\n\n if (disableAnimations) {\n // Fast path: when animations are disabled and no ref is provided, render children as-is.\n if (!ref) {\n return <>{children}</>\n }\n\n // If a ref is provided, attach it to the (single) child by cloning.\n return (\n <>\n {Children.map(children, (child) => {\n if (!React.isValidElement(child)) return child\n const original = child as ReactElementWithKey\n const merged = mergeRefs<unknown>([\n ref as unknown as React.Ref<unknown>,\n ((original as unknown as { ref?: React.Ref<unknown> }).ref ??\n null) as React.Ref<unknown>,\n ])\n const nextProps = { ref: merged }\n return React.cloneElement(original, nextProps)\n })}\n </>\n )\n }\n\n return (\n <>\n {renderChildren.map(({ component, ...restProps }) => (\n <SlotTransitionGroupChild\n key={component.key}\n {...restProps}\n component={component}\n enterDuration={enterDuration}\n exitDuration={exitDuration}\n enterMountDelay={enterMountDelay}\n ref={ref}\n />\n ))}\n </>\n )\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAUA,QAAI,kBAAkB;AAGtB,QAAI,MAAM,IAAI;AAGd,QAAI,YAAY;AAGhB,QAAI,SAAS;AAGb,QAAI,aAAa;AAGjB,QAAI,aAAa;AAGjB,QAAI,YAAY;AAGhB,QAAI,eAAe;AAGnB,QAAI,aAAa,OAAO,UAAU,YAAY,UAAU,OAAO,WAAW,UAAU;AAGpF,QAAI,WAAW,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,yBAAkB,KAAK;AACnD,QAAM,oBAAgB,uBAAsB,IAAI;AAEhD,QAAM,cAAc,CAAC,QAAsC;AAEzD,QAAI,QAAQ;AACV;IACF;AAEA,cAAU,IAAI;AACd,uCAAU;AAIV,oBAAgB,OAAO,cAAc,aAAa,UAAS,IAAK,SAAS;AAEzE,kBAAc,UAAU,OAAO,WAAW,MAAK;AAC7C,gBAAU,KAAK;IACjB,GAAG,IAAI;EACT;AAEA,gCAAU,MAAK;AACb,WAAO,MAAK;AACV,UAAI,cAAc;AAAS,qBAAa,cAAc,OAAO;IAC/D;EACF,GAAG,CAAA,CAAE;AAEL,aACE,qBAAAC,MAAC,QAAM,EAAA,GAAK,WAAW,SAAS,aAAW,UAAA,KACzC,qBAAAC,KAAC,SAAO,EACN,WAAU,2DACV,SAAS,EAAE,OAAO,IAAG,GACrB,OAAO,EAAE,OAAO,GAAG,OAAO,KAAK,UAAU,IAAG,GAC5C,MAAM,EAAE,OAAO,KAAK,UAAU,IAAG,GACjC,qBAAmB,MAAA,UAElB,aAAS,qBAAAA,KAAC,eAAK,CAAA,GAAK,aAAa,QAAM,qBAAAA,KAAC,cAAI,CAAA,GAAK,WAAW,EAAG,CAAA,GAEjE,OAAO,aAAa,aAAa,SAAS,EAAE,OAAM,CAAE,IAAI,QAAQ,EAAA,CAAA;AAGvE;",
|
|
6
|
-
"names": [
|
|
3
|
+
"sources": [],
|
|
4
|
+
"sourcesContent": [],
|
|
5
|
+
"mappings": "",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
dist_exports2 as dist_exports
|
|
3
|
+
} from "./chunk-SGWD4VEU.js";
|
|
4
|
+
import "./chunk-KFGKZMLK.js";
|
|
5
|
+
import {
|
|
6
|
+
clsx_default
|
|
7
|
+
} from "./chunk-CNYJBM5F.js";
|
|
8
|
+
import {
|
|
9
|
+
require_jsx_runtime
|
|
10
|
+
} from "./chunk-PTVT3RFX.js";
|
|
11
|
+
import {
|
|
12
|
+
require_react
|
|
13
|
+
} from "./chunk-4TLBUCVB.js";
|
|
14
|
+
import {
|
|
15
|
+
__toESM
|
|
16
|
+
} from "./chunk-ILHRZGIS.js";
|
|
17
|
+
|
|
18
|
+
// ../node_modules/.pnpm/@openai+apps-sdk-ui@0.2.0_@types+react-dom@19.2.3_@types+react@19.2.7__@types+react@19._60630c8dcc43ec213b3e346c9e26579b/node_modules/@openai/apps-sdk-ui/dist/es/components/Checkbox/Checkbox.js
|
|
19
|
+
var import_jsx_runtime = __toESM(require_jsx_runtime());
|
|
20
|
+
var import_react = __toESM(require_react());
|
|
21
|
+
import s from "/home/runner/work/sunpeak/sunpeak/node_modules/.pnpm/@openai+apps-sdk-ui@0.2.0_@types+react-dom@19.2.3_@types+react@19.2.7__@types+react@19._60630c8dcc43ec213b3e346c9e26579b/node_modules/@openai/apps-sdk-ui/dist/es/components/Checkbox/Checkbox.module.css";
|
|
22
|
+
var Checkbox = ({ className, label, id: propsId, disabled, orientation = "left", ...restProps }) => {
|
|
23
|
+
const reactId = (0, import_react.useId)();
|
|
24
|
+
const id = propsId ?? reactId;
|
|
25
|
+
return (0, import_jsx_runtime.jsxs)("div", { "data-disabled": disabled ? "" : void 0, "data-has-label": label ? "" : void 0, "data-orientation": orientation, className: clsx_default(className, s.Container), children: [(0, import_jsx_runtime.jsx)(dist_exports.Root, { className: s.Checkbox, id, disabled, ...restProps, children: (0, import_jsx_runtime.jsx)(dist_exports.Indicator, { className: s.CheckMark }) }), label && (0, import_jsx_runtime.jsx)("label", { htmlFor: id, className: s.Label, onMouseDown: (event) => {
|
|
26
|
+
if (!event.defaultPrevented && event.detail > 1)
|
|
27
|
+
event.preventDefault();
|
|
28
|
+
}, children: label })] });
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
Checkbox
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=@openai_apps-sdk-ui_components_Checkbox.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../node_modules/.pnpm/@openai+apps-sdk-ui@0.2.0_@types+react-dom@19.2.3_@types+react@19.2.7__@types+react@19._60630c8dcc43ec213b3e346c9e26579b/node_modules/@openai/apps-sdk-ui/src/components/Checkbox/Checkbox.tsx"],
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport clsx from \"clsx\"\nimport { Checkbox as RadixCheckbox } from \"radix-ui\"\nimport { type FocusEventHandler, type ReactNode, useId } from \"react\"\nimport s from \"./Checkbox.module.css\"\n\nexport type CheckboxProps = {\n /** The `id` of the checkbox. */\n id?: string\n /** The state of the checkbox when it is initially rendered. Use when you do not need to control its state. */\n defaultChecked?: boolean | \"indeterminate\"\n /** The controlled state of the checkbox. Must be used in conjunction with `onCheckedChange`. */\n checked?: boolean | \"indeterminate\"\n /** Optional accessible label rendered to the right of the checkbox. */\n label?: ReactNode\n /** Event handler called when the state of the checkbox changes. */\n onCheckedChange?: (nextState: boolean) => void\n /** Event handler called when the checkbox looses focus. */\n onBlur?: FocusEventHandler<HTMLButtonElement>\n /** Event handler called when the checkbox gains focus. */\n onFocus?: FocusEventHandler<HTMLButtonElement>\n /** When `true`, prevents the user from interacting with the checkbox. */\n disabled?: boolean\n /** When `true`, indicates that the user must check the checkbox before the owning form can be submitted. */\n required?: boolean\n /** The name of the checkbox. Submitted with its owning form as part of a name/value pair. */\n name?: string\n /** The value given as data when submitted with a `name`. */\n value?: string\n /** CSS classes applied to wrapper node */\n className?: string\n /**\n * The orientation of the checkbox relative to the label.\n *\n * @default \"left\"\n */\n orientation?: \"left\" | \"right\"\n}\n\nexport const Checkbox = ({\n className,\n label,\n id: propsId,\n disabled,\n orientation = \"left\",\n ...restProps\n}: CheckboxProps) => {\n const reactId = useId()\n const id = propsId ?? reactId\n\n return (\n <div\n data-disabled={disabled ? \"\" : undefined}\n data-has-label={label ? \"\" : undefined}\n data-orientation={orientation}\n className={clsx(className, s.Container)}\n >\n <RadixCheckbox.Root className={s.Checkbox} id={id} disabled={disabled} {...restProps}>\n <RadixCheckbox.Indicator className={s.CheckMark} />\n </RadixCheckbox.Root>\n {label && (\n <label\n htmlFor={id}\n className={s.Label}\n onMouseDown={(event) => {\n if (!event.defaultPrevented && event.detail > 1) event.preventDefault()\n }}\n >\n {label}\n </label>\n )}\n </div>\n )\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAIA,mBAA8D;AAC9D,OAAO,OAAO;AAmCP,IAAM,WAAW,CAAC,EACvB,WACA,OACA,IAAI,SACJ,UACA,cAAc,QACd,GAAG,UAAS,MACM;AAClB,QAAM,cAAU,oBAAK;AACrB,QAAM,KAAK,WAAW;AAEtB,aACE,mBAAAA,MAAA,OAAA,EAAA,iBACiB,WAAW,KAAK,QAAS,kBACxB,QAAQ,KAAK,QAAS,oBACpB,aAClB,WAAW,aAAK,WAAW,EAAE,SAAS,GAAC,UAAA,KAEvC,mBAAAC,KAAC,aAAc,MAAI,EAAC,WAAW,EAAE,UAAU,IAAQ,UAAkB,GAAM,WAAS,cAClF,mBAAAA,KAAC,aAAc,WAAS,EAAC,WAAW,EAAE,UAAS,CAAA,EAAI,CAAA,GAEpD,aACC,mBAAAA,KAAA,SAAA,EACE,SAAS,IACT,WAAW,EAAE,OACb,aAAa,CAAC,UAAS;AACrB,QAAI,CAAC,MAAM,oBAAoB,MAAM,SAAS;AAAG,YAAM,eAAc;EACvE,GAAC,UAEA,MAAK,CAAA,CAET,EAAA,CAAA;AAGP;",
|
|
6
|
+
"names": ["_jsxs", "_jsx"]
|
|
7
|
+
}
|
|
@@ -744,10 +744,10 @@ import {
|
|
|
744
744
|
XXsCrossed_default,
|
|
745
745
|
XXs_default,
|
|
746
746
|
X_default
|
|
747
|
-
} from "./chunk-
|
|
748
|
-
import "./chunk-
|
|
749
|
-
import "./chunk-
|
|
750
|
-
import "./chunk-
|
|
747
|
+
} from "./chunk-XB525PXG.js";
|
|
748
|
+
import "./chunk-PTVT3RFX.js";
|
|
749
|
+
import "./chunk-4TLBUCVB.js";
|
|
750
|
+
import "./chunk-ILHRZGIS.js";
|
|
751
751
|
export {
|
|
752
752
|
AddMember_default as AddMember,
|
|
753
753
|
AddSources_default as AddSources,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Input
|
|
3
|
+
} from "./chunk-CQ3GYAYB.js";
|
|
4
|
+
import "./chunk-QPJAV452.js";
|
|
5
|
+
import "./chunk-EGRHWZRV.js";
|
|
6
|
+
import "./chunk-CNYJBM5F.js";
|
|
7
|
+
import "./chunk-PTVT3RFX.js";
|
|
8
|
+
import "./chunk-4TLBUCVB.js";
|
|
9
|
+
import "./chunk-ILHRZGIS.js";
|
|
10
|
+
export {
|
|
11
|
+
Input
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=@openai_apps-sdk-ui_components_Input.js.map
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import {
|
|
2
|
+
dist_exports4 as dist_exports
|
|
3
|
+
} from "./chunk-SGWD4VEU.js";
|
|
4
|
+
import "./chunk-KFGKZMLK.js";
|
|
5
|
+
import {
|
|
6
|
+
useResizeObserver
|
|
7
|
+
} from "./chunk-YOJ6QPGS.js";
|
|
8
|
+
import {
|
|
9
|
+
handlePressableMouseEnter,
|
|
10
|
+
waitForAnimationFrame
|
|
11
|
+
} from "./chunk-BAG6OO6S.js";
|
|
12
|
+
import "./chunk-EGRHWZRV.js";
|
|
13
|
+
import {
|
|
14
|
+
clsx_default
|
|
15
|
+
} from "./chunk-CNYJBM5F.js";
|
|
16
|
+
import {
|
|
17
|
+
require_jsx_runtime
|
|
18
|
+
} from "./chunk-PTVT3RFX.js";
|
|
19
|
+
import {
|
|
20
|
+
require_react
|
|
21
|
+
} from "./chunk-4TLBUCVB.js";
|
|
22
|
+
import {
|
|
23
|
+
__toESM
|
|
24
|
+
} from "./chunk-ILHRZGIS.js";
|
|
25
|
+
|
|
26
|
+
// ../node_modules/.pnpm/@openai+apps-sdk-ui@0.2.0_@types+react-dom@19.2.3_@types+react@19.2.7__@types+react@19._60630c8dcc43ec213b3e346c9e26579b/node_modules/@openai/apps-sdk-ui/dist/es/components/SegmentedControl/SegmentedControl.js
|
|
27
|
+
var import_jsx_runtime = __toESM(require_jsx_runtime());
|
|
28
|
+
var import_react = __toESM(require_react());
|
|
29
|
+
import s from "/home/runner/work/sunpeak/sunpeak/node_modules/.pnpm/@openai+apps-sdk-ui@0.2.0_@types+react-dom@19.2.3_@types+react@19.2.7__@types+react@19._60630c8dcc43ec213b3e346c9e26579b/node_modules/@openai/apps-sdk-ui/dist/es/components/SegmentedControl/SegmentedControl.module.css";
|
|
30
|
+
var SegmentedControl = ({ value, onChange, children, block, pill = true, size = "md", gutterSize, className, onClick, ...restProps }) => {
|
|
31
|
+
const rootRef = (0, import_react.useRef)(null);
|
|
32
|
+
const thumbRef = (0, import_react.useRef)(null);
|
|
33
|
+
const applyThumbSizing = (0, import_react.useCallback)((attemptScroll) => {
|
|
34
|
+
const root = rootRef.current;
|
|
35
|
+
const thumb = thumbRef.current;
|
|
36
|
+
if (!root || !thumb) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const activeNode = root == null ? void 0 : root.querySelector('[data-state="on"]');
|
|
40
|
+
if (!activeNode) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const rootWidth = root.clientWidth;
|
|
44
|
+
let targetWidth = Math.floor(activeNode.clientWidth);
|
|
45
|
+
const targetOffset = activeNode.offsetLeft;
|
|
46
|
+
if (rootWidth - (targetWidth + targetOffset) < 2) {
|
|
47
|
+
targetWidth = targetWidth - 1;
|
|
48
|
+
}
|
|
49
|
+
thumb.style.width = `${Math.floor(targetWidth)}px`;
|
|
50
|
+
thumb.style.transform = `translateX(${targetOffset}px)`;
|
|
51
|
+
if (root.scrollWidth > rootWidth) {
|
|
52
|
+
const buffer = rootWidth * 0.15;
|
|
53
|
+
const scrollLeft = root.scrollLeft;
|
|
54
|
+
const left = activeNode.offsetLeft;
|
|
55
|
+
const right = left + targetWidth;
|
|
56
|
+
if (left < scrollLeft + buffer || right > scrollLeft + rootWidth - buffer) {
|
|
57
|
+
if (attemptScroll) {
|
|
58
|
+
activeNode.scrollIntoView({ block: "nearest", inline: "center", behavior: "smooth" });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}, []);
|
|
63
|
+
useResizeObserver({
|
|
64
|
+
// @ts-expect-error(2322) -- bug in types: https://github.com/juliencrn/usehooks-ts/issues/663
|
|
65
|
+
ref: rootRef,
|
|
66
|
+
onResize: () => {
|
|
67
|
+
const thumb = thumbRef.current;
|
|
68
|
+
if (!thumb) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const currentTransition = thumb.style.transition;
|
|
72
|
+
thumb.style.transition = "";
|
|
73
|
+
applyThumbSizing(false);
|
|
74
|
+
thumb.style.transition = currentTransition;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
78
|
+
const root = rootRef.current;
|
|
79
|
+
const thumb = thumbRef.current;
|
|
80
|
+
if (!root || !thumb) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
applyThumbSizing(!!thumb.style.transition);
|
|
84
|
+
if (!thumb.style.transition) {
|
|
85
|
+
waitForAnimationFrame(() => {
|
|
86
|
+
thumb.style.transition = "width 300ms var(--cubic-enter), transform 300ms var(--cubic-enter)";
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}, [applyThumbSizing, value, size, gutterSize, pill]);
|
|
90
|
+
const handleValueChange = (nextValue) => {
|
|
91
|
+
if (nextValue && onChange)
|
|
92
|
+
onChange(nextValue);
|
|
93
|
+
};
|
|
94
|
+
return (0, import_jsx_runtime.jsxs)(dist_exports.Root, { ref: rootRef, className: clsx_default(s.SegmentedControl, className), type: "single", value, loop: false, onValueChange: handleValueChange, onClick, "data-block": block ? "" : void 0, "data-pill": pill ? "" : void 0, "data-size": size, "data-gutter-size": gutterSize, ...restProps, children: [(0, import_jsx_runtime.jsx)("div", { className: s.SegmentedControlThumb, ref: thumbRef }), children] });
|
|
95
|
+
};
|
|
96
|
+
var Segment = ({ children, ...restProps }) => {
|
|
97
|
+
return (0, import_jsx_runtime.jsx)(dist_exports.Item, { className: s.SegmentedControlOption, ...restProps, onPointerEnter: handlePressableMouseEnter, children: (0, import_jsx_runtime.jsx)("span", { className: "relative", children }) });
|
|
98
|
+
};
|
|
99
|
+
SegmentedControl.Option = Segment;
|
|
100
|
+
export {
|
|
101
|
+
SegmentedControl
|
|
102
|
+
};
|
|
103
|
+
//# sourceMappingURL=@openai_apps-sdk-ui_components_SegmentedControl.js.map
|
package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_SegmentedControl.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../node_modules/.pnpm/@openai+apps-sdk-ui@0.2.0_@types+react-dom@19.2.3_@types+react@19.2.7__@types+react@19._60630c8dcc43ec213b3e346c9e26579b/node_modules/@openai/apps-sdk-ui/src/components/SegmentedControl/SegmentedControl.tsx"],
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport clsx from \"clsx\"\nimport { ToggleGroup } from \"radix-ui\"\nimport { useCallback, useLayoutEffect, useRef } from \"react\"\nimport { useResizeObserver } from \"usehooks-ts\"\nimport { handlePressableMouseEnter, waitForAnimationFrame } from \"../../lib/helpers\"\nimport { type ControlSize, type Sizes } from \"../../types\"\nimport s from \"./SegmentedControl.module.css\"\n\nexport type SizeVariant = \"2xs\" | \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\"\n\nexport type SegmentedControlProps<T extends string> = {\n /**\n * Controlled value for the group\n */\n \"value\": T\n /** Callback for when a new value is selected */\n \"onChange\"?: (nextValue: T) => void\n /** Callback any time the control is clicked (even if a new value was not selected) */\n \"onClick\"?: () => void\n /**\n * Text read aloud to screen readers when the control is focused\n */\n \"aria-label\": string\n /**\n * Controls the size of the segmented control\n *\n * | 3xs | 2xs | xs | sm | md | lg | xl | 2xl | 3xl |\n * | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- |\n * | `22px` | `24px` | `26px` | `28px` | `32px` | `36px` | `40px` | `44px` | `48px` |\n *\n * @default md\n */\n \"size\"?: ControlSize\n /**\n * Controls gutter on the edges of the button, defaults to value from `size`.\n *\n * | 2xs | xs | sm | md | lg | xl |\n * | ------ | ------ | ------ | ------ | ------ | ------ |\n * | `6px` | `8px` | `10px` | `12px` | `14px` | `16px` |\n */\n \"gutterSize\"?: Sizes<\"2xs\" | \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\">\n /** Disable the entire group */\n \"disabled\"?: boolean\n /**\n * Display the control as a block element with equal width segments\n * @default false\n */\n \"block\"?: boolean\n /**\n * Determines if the segment control, and its options, should be a fully rounded pill shape.\n * @default false\n */\n \"pill\"?: boolean\n \"className\"?: string\n \"children\": React.ReactNode\n}\n\nexport const SegmentedControl = <T extends string>({\n value,\n onChange,\n children,\n block,\n pill = true,\n size = \"md\",\n gutterSize,\n className,\n onClick,\n ...restProps\n}: SegmentedControlProps<T>) => {\n const rootRef = useRef<HTMLDivElement>(null)\n const thumbRef = useRef<HTMLDivElement>(null)\n\n const applyThumbSizing = useCallback((attemptScroll: boolean) => {\n const root = rootRef.current\n const thumb = thumbRef.current\n\n if (!root || !thumb) {\n return\n }\n\n // Get selected node\n const activeNode = root?.querySelector<HTMLDivElement>('[data-state=\"on\"]')\n\n // Impossible\n if (!activeNode) {\n return\n }\n\n const rootWidth = root.clientWidth\n let targetWidth = Math.floor(activeNode.clientWidth)\n const targetOffset = activeNode.offsetLeft\n\n // Detect if the thumb is moving too far to the edge of the container.\n // This would most commonly be due to subpixel widths adding up to excessive distance.\n if (rootWidth - (targetWidth + targetOffset) < 2) {\n targetWidth = targetWidth - 1\n }\n\n thumb.style.width = `${Math.floor(targetWidth)}px`\n thumb.style.transform = `translateX(${targetOffset}px)`\n\n // If the control is scrollable, ensure the active option is visible\n if (root.scrollWidth > rootWidth) {\n // Only scroll items near the edge, but not the inner 2/3.\n const buffer = rootWidth * 0.15\n const scrollLeft = root.scrollLeft\n const left = activeNode.offsetLeft\n const right = left + targetWidth\n if (left < scrollLeft + buffer || right > scrollLeft + rootWidth - buffer) {\n // Cheap trick to avoid unintentional scroll on mount - transition is set after mounting\n if (attemptScroll) {\n activeNode.scrollIntoView({ block: \"nearest\", inline: \"center\", behavior: \"smooth\" })\n }\n }\n }\n }, [])\n\n useResizeObserver({\n // @ts-expect-error(2322) -- bug in types: https://github.com/juliencrn/usehooks-ts/issues/663\n ref: rootRef,\n onResize: () => {\n const thumb = thumbRef.current\n\n if (!thumb) {\n return\n }\n\n // Perform the size update instantly\n const currentTransition = thumb.style.transition\n thumb.style.transition = \"\"\n applyThumbSizing(false)\n thumb.style.transition = currentTransition\n },\n })\n\n useLayoutEffect(() => {\n const root = rootRef.current\n const thumb = thumbRef.current\n\n if (!root || !thumb) {\n return\n }\n\n // Cheap trick to avoid unintentional scroll on mount - transition is set after mounting\n applyThumbSizing(!!thumb.style.transition)\n\n // Apply transition after initial calculation is set\n if (!thumb.style.transition) {\n waitForAnimationFrame(() => {\n thumb.style.transition =\n \"width 300ms var(--cubic-enter), transform 300ms var(--cubic-enter)\"\n })\n }\n }, [applyThumbSizing, value, size, gutterSize, pill])\n\n const handleValueChange = (nextValue: T) => {\n // Only trigger onChange when a value exists\n // Disallow toggling off enabled items\n if (nextValue && onChange) onChange(nextValue)\n }\n\n return (\n <ToggleGroup.Root\n ref={rootRef}\n className={clsx(s.SegmentedControl, className)}\n type=\"single\"\n value={value}\n loop={false}\n onValueChange={handleValueChange}\n onClick={onClick}\n data-block={block ? \"\" : undefined}\n data-pill={pill ? \"\" : undefined}\n data-size={size}\n data-gutter-size={gutterSize}\n {...restProps}\n >\n <div className={s.SegmentedControlThumb} ref={thumbRef} />\n {children}\n </ToggleGroup.Root>\n )\n}\n\ntype SegmentedControlOptionProps = {\n /**\n * Option value\n */\n \"value\": string\n /**\n * Text read aloud to screen readers when the option is focused\n */\n \"aria-label\"?: string\n /**\n * Content to render in the option\n */\n \"children\": React.ReactNode\n /**\n * Disable the individual option\n */\n \"disabled\"?: boolean\n}\n\nconst Segment = ({ children, ...restProps }: SegmentedControlOptionProps) => {\n return (\n <ToggleGroup.Item\n className={s.SegmentedControlOption}\n {...restProps}\n onPointerEnter={handlePressableMouseEnter}\n >\n <span className=\"relative\">{children}</span>\n </ToggleGroup.Item>\n )\n}\n\nSegmentedControl.Option = Segment\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,mBAAqD;AAIrD,OAAO,OAAO;AAmDP,IAAM,mBAAmB,CAAmB,EACjD,OACA,UACA,UACA,OACA,OAAO,MACP,OAAO,MACP,YACA,WACA,SACA,GAAG,UAAS,MACiB;AAC7B,QAAM,cAAU,qBAAuB,IAAI;AAC3C,QAAM,eAAW,qBAAuB,IAAI;AAE5C,QAAM,uBAAmB,0BAAY,CAAC,kBAA0B;AAC9D,UAAM,OAAO,QAAQ;AACrB,UAAM,QAAQ,SAAS;AAEvB,QAAI,CAAC,QAAQ,CAAC,OAAO;AACnB;IACF;AAGA,UAAM,aAAa,6BAAM,cAA8B;AAGvD,QAAI,CAAC,YAAY;AACf;IACF;AAEA,UAAM,YAAY,KAAK;AACvB,QAAI,cAAc,KAAK,MAAM,WAAW,WAAW;AACnD,UAAM,eAAe,WAAW;AAIhC,QAAI,aAAa,cAAc,gBAAgB,GAAG;AAChD,oBAAc,cAAc;IAC9B;AAEA,UAAM,MAAM,QAAQ,GAAG,KAAK,MAAM,WAAW,CAAC;AAC9C,UAAM,MAAM,YAAY,cAAc,YAAY;AAGlD,QAAI,KAAK,cAAc,WAAW;AAEhC,YAAM,SAAS,YAAY;AAC3B,YAAM,aAAa,KAAK;AACxB,YAA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