{"version":3,"file":"AppHeader.js","sources":["../../node_modules/usehooks-ts/dist/esm/useReadLocalStorage/useReadLocalStorage.js","../../node_modules/framer-motion/dist/es/utils/use-is-mounted.mjs","../../node_modules/framer-motion/dist/es/utils/use-force-update.mjs","../../node_modules/framer-motion/dist/es/components/AnimatePresence/PopChild.mjs","../../node_modules/framer-motion/dist/es/components/AnimatePresence/PresenceChild.mjs","../../node_modules/framer-motion/dist/es/utils/use-unmount-effect.mjs","../../node_modules/framer-motion/dist/es/components/AnimatePresence/index.mjs","../../node_modules/@headlessui/react/dist/utils/env.js","../../node_modules/@headlessui/react/dist/hooks/use-iso-morphic-effect.js","../../node_modules/@headlessui/react/dist/hooks/use-latest-value.js","../../node_modules/@headlessui/react/dist/utils/micro-task.js","../../node_modules/@headlessui/react/dist/hooks/use-event.js","../../node_modules/@headlessui/react/dist/hooks/use-server-handoff-complete.js","../../node_modules/@headlessui/react/dist/hooks/use-id.js","../../node_modules/@headlessui/react/dist/utils/match.js","../../node_modules/@headlessui/react/dist/utils/owner.js","../../node_modules/@headlessui/react/dist/utils/focus-management.js","../../node_modules/@headlessui/react/dist/hooks/use-document-event.js","../../node_modules/@headlessui/react/dist/hooks/use-window-event.js","../../node_modules/@headlessui/react/dist/hooks/use-outside-click.js","../../node_modules/@headlessui/react/dist/hooks/use-resolve-button-type.js","../../node_modules/@headlessui/react/dist/hooks/use-sync-refs.js","../../node_modules/@headlessui/react/dist/utils/class-names.js","../../node_modules/@headlessui/react/dist/utils/render.js","../../node_modules/@headlessui/react/dist/utils/bugs.js","../../node_modules/@headlessui/react/dist/internal/hidden.js","../../node_modules/@headlessui/react/dist/internal/open-closed.js","../../node_modules/@headlessui/react/dist/components/keyboard.js","../../node_modules/@headlessui/react/dist/hooks/use-tab-direction.js","../../node_modules/@headlessui/react/dist/hooks/use-owner.js","../../node_modules/@headlessui/react/dist/hooks/use-event-listener.js","../../node_modules/@headlessui/react/dist/hooks/use-on-unmount.js","../../node_modules/@headlessui/react/dist/internal/portal-force-root.js","../../node_modules/@headlessui/react/dist/components/portal/portal.js","../../node_modules/@headlessui/react/dist/hooks/use-root-containers.js","../../node_modules/@headlessui/react/dist/components/popover/popover.js","../../node_modules/@headlessui/react/dist/internal/focus-sentinel.js","../../node_modules/@headlessui/react/dist/utils/stable-collection.js","../../node_modules/@headlessui/react/dist/components/tabs/tabs.js","../../node_modules/swr/_internal/dist/index.mjs","../../node_modules/swr/core/dist/index.mjs","../../src/hooks/useFetcher.tsx","../../src/hooks/useWindowResize.tsx","../../src/assets/logo-trans.png","../../src/assets/logo-icon.png","../../src/components/ExploreLogo.tsx","../../src/features/Account/Profile/FormModal.tsx","../../src/features/Account/Profile/ProfileUpdate.tsx","../../src/features/Account/Profile/ChangePassword.tsx","../../src/features/Account/Bookmarks/types.ts","../../src/utils/bookmarkUtils.ts","../../src/ui/Icon/CloseIcon.tsx","../../src/components/Bookmark.tsx","../../src/features/Account/Bookmarks/ImageBookmarks.tsx","../../src/features/Account/Bookmarks/PageBookmarks.tsx","../../src/features/Account/Bookmarks/TextBookmarks.tsx","../../src/features/Account/Bookmarks/Bookmarks.tsx","../../src/services/api/BugReportApi.ts","../../src/schemas/BugReportSchema.ts","../../src/features/Dashboard/BugReportForm.tsx","../../src/components/DashboardLink.tsx","../../src/features/Dashboard/index.tsx","../../src/components/LanguageSwitcher.tsx","../../src/components/AppHeader.tsx"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react';\nimport { useEventListener } from '..';\nfunction useReadLocalStorage(key) {\n const readValue = useCallback(() => {\n if (typeof window === 'undefined') {\n return null;\n }\n try {\n const item = window.localStorage.getItem(key);\n return item ? JSON.parse(item) : null;\n }\n catch (error) {\n console.warn(`Error reading localStorage key “${key}”:`, error);\n return null;\n }\n }, [key]);\n const [storedValue, setStoredValue] = useState(readValue);\n useEffect(() => {\n setStoredValue(readValue());\n }, []);\n const handleStorageChange = useCallback((event) => {\n if ((event === null || event === void 0 ? void 0 : event.key) && event.key !== key) {\n return;\n }\n setStoredValue(readValue());\n }, [key, readValue]);\n useEventListener('storage', handleStorageChange);\n useEventListener('local-storage', handleStorageChange);\n return storedValue;\n}\nexport default useReadLocalStorage;\n","import { useRef } from 'react';\nimport { useIsomorphicLayoutEffect } from './use-isomorphic-effect.mjs';\n\nfunction useIsMounted() {\n const isMounted = useRef(false);\n useIsomorphicLayoutEffect(() => {\n isMounted.current = true;\n return () => {\n isMounted.current = false;\n };\n }, []);\n return isMounted;\n}\n\nexport { useIsMounted };\n","import { useState, useCallback } from 'react';\nimport { useIsMounted } from './use-is-mounted.mjs';\nimport { frame } from '../frameloop/frame.mjs';\n\nfunction useForceUpdate() {\n const isMounted = useIsMounted();\n const [forcedRenderCount, setForcedRenderCount] = useState(0);\n const forceRender = useCallback(() => {\n isMounted.current && setForcedRenderCount(forcedRenderCount + 1);\n }, [forcedRenderCount]);\n /**\n * Defer this to the end of the next animation frame in case there are multiple\n * synchronous calls.\n */\n const deferredForceRender = useCallback(() => frame.postRender(forceRender), [forceRender]);\n return [deferredForceRender, forcedRenderCount];\n}\n\nexport { useForceUpdate };\n","import * as React from 'react';\nimport { useId, useRef, useInsertionEffect } from 'react';\n\n/**\n * Measurement functionality has to be within a separate component\n * to leverage snapshot lifecycle.\n */\nclass PopChildMeasure extends React.Component {\n getSnapshotBeforeUpdate(prevProps) {\n const element = this.props.childRef.current;\n if (element && prevProps.isPresent && !this.props.isPresent) {\n const size = this.props.sizeRef.current;\n size.height = element.offsetHeight || 0;\n size.width = element.offsetWidth || 0;\n size.top = element.offsetTop;\n size.left = element.offsetLeft;\n }\n return null;\n }\n /**\n * Required with getSnapshotBeforeUpdate to stop React complaining.\n */\n componentDidUpdate() { }\n render() {\n return this.props.children;\n }\n}\nfunction PopChild({ children, isPresent }) {\n const id = useId();\n const ref = useRef(null);\n const size = useRef({\n width: 0,\n height: 0,\n top: 0,\n left: 0,\n });\n /**\n * We create and inject a style block so we can apply this explicit\n * sizing in a non-destructive manner by just deleting the style block.\n *\n * We can't apply size via render as the measurement happens\n * in getSnapshotBeforeUpdate (post-render), likewise if we apply the\n * styles directly on the DOM node, we might be overwriting\n * styles set via the style prop.\n */\n useInsertionEffect(() => {\n const { width, height, top, left } = size.current;\n if (isPresent || !ref.current || !width || !height)\n return;\n ref.current.dataset.motionPopId = id;\n const style = document.createElement(\"style\");\n document.head.appendChild(style);\n if (style.sheet) {\n style.sheet.insertRule(`\n [data-motion-pop-id=\"${id}\"] {\n position: absolute !important;\n width: ${width}px !important;\n height: ${height}px !important;\n top: ${top}px !important;\n left: ${left}px !important;\n }\n `);\n }\n return () => {\n document.head.removeChild(style);\n };\n }, [isPresent]);\n return (React.createElement(PopChildMeasure, { isPresent: isPresent, childRef: ref, sizeRef: size }, React.cloneElement(children, { ref })));\n}\n\nexport { PopChild };\n","import * as React from 'react';\nimport { useId, useMemo } from 'react';\nimport { PresenceContext } from '../../context/PresenceContext.mjs';\nimport { useConstant } from '../../utils/use-constant.mjs';\nimport { PopChild } from './PopChild.mjs';\n\nconst PresenceChild = ({ children, initial, isPresent, onExitComplete, custom, presenceAffectsLayout, mode, }) => {\n const presenceChildren = useConstant(newChildrenMap);\n const id = useId();\n const context = useMemo(() => ({\n id,\n initial,\n isPresent,\n custom,\n onExitComplete: (childId) => {\n presenceChildren.set(childId, true);\n for (const isComplete of presenceChildren.values()) {\n if (!isComplete)\n return; // can stop searching when any is incomplete\n }\n onExitComplete && onExitComplete();\n },\n register: (childId) => {\n presenceChildren.set(childId, false);\n return () => presenceChildren.delete(childId);\n },\n }), \n /**\n * If the presence of a child affects the layout of the components around it,\n * we want to make a new context value to ensure they get re-rendered\n * so they can detect that layout change.\n */\n presenceAffectsLayout ? undefined : [isPresent]);\n useMemo(() => {\n presenceChildren.forEach((_, key) => presenceChildren.set(key, false));\n }, [isPresent]);\n /**\n * If there's no `motion` components to fire exit animations, we want to remove this\n * component immediately.\n */\n React.useEffect(() => {\n !isPresent &&\n !presenceChildren.size &&\n onExitComplete &&\n onExitComplete();\n }, [isPresent]);\n if (mode === \"popLayout\") {\n children = React.createElement(PopChild, { isPresent: isPresent }, children);\n }\n return (React.createElement(PresenceContext.Provider, { value: context }, children));\n};\nfunction newChildrenMap() {\n return new Map();\n}\n\nexport { PresenceChild };\n","import { useEffect } from 'react';\n\nfunction useUnmountEffect(callback) {\n return useEffect(() => () => callback(), []);\n}\n\nexport { useUnmountEffect };\n","import * as React from 'react';\nimport { useContext, useRef, cloneElement, Children, isValidElement } from 'react';\nimport { useForceUpdate } from '../../utils/use-force-update.mjs';\nimport { useIsMounted } from '../../utils/use-is-mounted.mjs';\nimport { PresenceChild } from './PresenceChild.mjs';\nimport { LayoutGroupContext } from '../../context/LayoutGroupContext.mjs';\nimport { useIsomorphicLayoutEffect } from '../../utils/use-isomorphic-effect.mjs';\nimport { useUnmountEffect } from '../../utils/use-unmount-effect.mjs';\nimport { invariant } from '../../utils/errors.mjs';\n\nconst getChildKey = (child) => child.key || \"\";\nfunction updateChildLookup(children, allChildren) {\n children.forEach((child) => {\n const key = getChildKey(child);\n allChildren.set(key, child);\n });\n}\nfunction onlyElements(children) {\n const filtered = [];\n // We use forEach here instead of map as map mutates the component key by preprending `.$`\n Children.forEach(children, (child) => {\n if (isValidElement(child))\n filtered.push(child);\n });\n return filtered;\n}\n/**\n * `AnimatePresence` enables the animation of components that have been removed from the tree.\n *\n * When adding/removing more than a single child, every child **must** be given a unique `key` prop.\n *\n * Any `motion` components that have an `exit` property defined will animate out when removed from\n * the tree.\n *\n * ```jsx\n * import { motion, AnimatePresence } from 'framer-motion'\n *\n * export const Items = ({ items }) => (\n * \n * {items.map(item => (\n * \n * ))}\n * \n * )\n * ```\n *\n * You can sequence exit animations throughout a tree using variants.\n *\n * If a child contains multiple `motion` components with `exit` props, it will only unmount the child\n * once all `motion` components have finished animating out. Likewise, any components using\n * `usePresence` all need to call `safeToRemove`.\n *\n * @public\n */\nconst AnimatePresence = ({ children, custom, initial = true, onExitComplete, exitBeforeEnter, presenceAffectsLayout = true, mode = \"sync\", }) => {\n invariant(!exitBeforeEnter, \"Replace exitBeforeEnter with mode='wait'\");\n // We want to force a re-render once all exiting animations have finished. We\n // either use a local forceRender function, or one from a parent context if it exists.\n const forceRender = useContext(LayoutGroupContext).forceRender || useForceUpdate()[0];\n const isMounted = useIsMounted();\n // Filter out any children that aren't ReactElements. We can only track ReactElements with a props.key\n const filteredChildren = onlyElements(children);\n let childrenToRender = filteredChildren;\n const exitingChildren = useRef(new Map()).current;\n // Keep a living record of the children we're actually rendering so we\n // can diff to figure out which are entering and exiting\n const presentChildren = useRef(childrenToRender);\n // A lookup table to quickly reference components by key\n const allChildren = useRef(new Map()).current;\n // If this is the initial component render, just deal with logic surrounding whether\n // we play onMount animations or not.\n const isInitialRender = useRef(true);\n useIsomorphicLayoutEffect(() => {\n isInitialRender.current = false;\n updateChildLookup(filteredChildren, allChildren);\n presentChildren.current = childrenToRender;\n });\n useUnmountEffect(() => {\n isInitialRender.current = true;\n allChildren.clear();\n exitingChildren.clear();\n });\n if (isInitialRender.current) {\n return (React.createElement(React.Fragment, null, childrenToRender.map((child) => (React.createElement(PresenceChild, { key: getChildKey(child), isPresent: true, initial: initial ? undefined : false, presenceAffectsLayout: presenceAffectsLayout, mode: mode }, child)))));\n }\n // If this is a subsequent render, deal with entering and exiting children\n childrenToRender = [...childrenToRender];\n // Diff the keys of the currently-present and target children to update our\n // exiting list.\n const presentKeys = presentChildren.current.map(getChildKey);\n const targetKeys = filteredChildren.map(getChildKey);\n // Diff the present children with our target children and mark those that are exiting\n const numPresent = presentKeys.length;\n for (let i = 0; i < numPresent; i++) {\n const key = presentKeys[i];\n if (targetKeys.indexOf(key) === -1 && !exitingChildren.has(key)) {\n exitingChildren.set(key, undefined);\n }\n }\n // If we currently have exiting children, and we're deferring rendering incoming children\n // until after all current children have exiting, empty the childrenToRender array\n if (mode === \"wait\" && exitingChildren.size) {\n childrenToRender = [];\n }\n // Loop through all currently exiting components and clone them to overwrite `animate`\n // with any `exit` prop they might have defined.\n exitingChildren.forEach((component, key) => {\n // If this component is actually entering again, early return\n if (targetKeys.indexOf(key) !== -1)\n return;\n const child = allChildren.get(key);\n if (!child)\n return;\n const insertionIndex = presentKeys.indexOf(key);\n let exitingComponent = component;\n if (!exitingComponent) {\n const onExit = () => {\n allChildren.delete(key);\n exitingChildren.delete(key);\n // Remove this child from the present children\n const removeIndex = presentChildren.current.findIndex((presentChild) => presentChild.key === key);\n presentChildren.current.splice(removeIndex, 1);\n // Defer re-rendering until all exiting children have indeed left\n if (!exitingChildren.size) {\n presentChildren.current = filteredChildren;\n if (isMounted.current === false)\n return;\n forceRender();\n onExitComplete && onExitComplete();\n }\n };\n exitingComponent = (React.createElement(PresenceChild, { key: getChildKey(child), isPresent: false, onExitComplete: onExit, custom: custom, presenceAffectsLayout: presenceAffectsLayout, mode: mode }, child));\n exitingChildren.set(key, exitingComponent);\n }\n childrenToRender.splice(insertionIndex, 0, exitingComponent);\n });\n // Add `MotionContext` even to children that don't need it to ensure we're rendering\n // the same tree between renders\n childrenToRender = childrenToRender.map((child) => {\n const key = child.key;\n return exitingChildren.has(key) ? (child) : (React.createElement(PresenceChild, { key: getChildKey(child), isPresent: true, presenceAffectsLayout: presenceAffectsLayout, mode: mode }, child));\n });\n if (process.env.NODE_ENV !== \"production\" &&\n mode === \"wait\" &&\n childrenToRender.length > 1) {\n console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to \"wait\". This will lead to odd visual behaviour.`);\n }\n return (React.createElement(React.Fragment, null, exitingChildren.size\n ? childrenToRender\n : childrenToRender.map((child) => cloneElement(child))));\n};\n\nexport { AnimatePresence };\n","var i=Object.defineProperty;var d=(t,e,n)=>e in t?i(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var r=(t,e,n)=>(d(t,typeof e!=\"symbol\"?e+\"\":e,n),n);class o{constructor(){r(this,\"current\",this.detect());r(this,\"handoffState\",\"pending\");r(this,\"currentId\",0)}set(e){this.current!==e&&(this.handoffState=\"pending\",this.currentId=0,this.current=e)}reset(){this.set(this.detect())}nextId(){return++this.currentId}get isServer(){return this.current===\"server\"}get isClient(){return this.current===\"client\"}detect(){return typeof window==\"undefined\"||typeof document==\"undefined\"?\"server\":\"client\"}handoff(){this.handoffState===\"pending\"&&(this.handoffState=\"complete\")}get isHandoffComplete(){return this.handoffState===\"complete\"}}let s=new o;export{s as env};\n","import{useLayoutEffect as t,useEffect as c}from\"react\";import{env as i}from'../utils/env.js';let l=(e,f)=>{i.isServer?c(e,f):t(e,f)};export{l as useIsoMorphicEffect};\n","import{useRef as t}from\"react\";import{useIsoMorphicEffect as o}from'./use-iso-morphic-effect.js';function s(e){let r=t(e);return o(()=>{r.current=e},[e]),r}export{s as useLatestValue};\n","function t(e){typeof queueMicrotask==\"function\"?queueMicrotask(e):Promise.resolve().then(e).catch(o=>setTimeout(()=>{throw o}))}export{t as microTask};\n","import a from\"react\";import{useLatestValue as n}from'./use-latest-value.js';let o=function(t){let e=n(t);return a.useCallback((...r)=>e.current(...r),[e])};export{o as useEvent};\n","import{useState as r,useEffect as o}from\"react\";import{env as t}from'../utils/env.js';function l(){let[e,f]=r(t.isHandoffComplete);return e&&t.isHandoffComplete===!1&&f(!1),o(()=>{e!==!0&&f(!0)},[e]),o(()=>t.handoff(),[]),e}export{l as useServerHandoffComplete};\n","var o;import t from\"react\";import{useIsoMorphicEffect as d}from'./use-iso-morphic-effect.js';import{useServerHandoffComplete as f}from'./use-server-handoff-complete.js';import{env as r}from'../utils/env.js';let I=(o=t.useId)!=null?o:function(){let n=f(),[e,u]=t.useState(n?()=>r.nextId():null);return d(()=>{e===null&&u(r.nextId())},[e]),e!=null?\"\"+e:void 0};export{I as useId};\n","function u(r,n,...a){if(r in n){let e=n[r];return typeof e==\"function\"?e(...a):e}let t=new Error(`Tried to handle \"${r}\" but there is no handler defined. Only defined handlers are: ${Object.keys(n).map(e=>`\"${e}\"`).join(\", \")}.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,u),t}export{u as match};\n","import{env as n}from'./env.js';function e(r){return n.isServer?null:r instanceof Node?r.ownerDocument:r!=null&&r.hasOwnProperty(\"current\")&&r.current instanceof Node?r.current.ownerDocument:document}export{e as getOwnerDocument};\n","import{disposables as b}from'./disposables.js';import{match as L}from'./match.js';import{getOwnerDocument as m}from'./owner.js';let c=[\"[contentEditable=true]\",\"[tabindex]\",\"a[href]\",\"area[href]\",\"button:not([disabled])\",\"iframe\",\"input:not([disabled])\",\"select:not([disabled])\",\"textarea:not([disabled])\"].map(e=>`${e}:not([tabindex='-1'])`).join(\",\");var M=(n=>(n[n.First=1]=\"First\",n[n.Previous=2]=\"Previous\",n[n.Next=4]=\"Next\",n[n.Last=8]=\"Last\",n[n.WrapAround=16]=\"WrapAround\",n[n.NoScroll=32]=\"NoScroll\",n))(M||{}),N=(o=>(o[o.Error=0]=\"Error\",o[o.Overflow=1]=\"Overflow\",o[o.Success=2]=\"Success\",o[o.Underflow=3]=\"Underflow\",o))(N||{}),F=(t=>(t[t.Previous=-1]=\"Previous\",t[t.Next=1]=\"Next\",t))(F||{});function f(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(c)).sort((r,t)=>Math.sign((r.tabIndex||Number.MAX_SAFE_INTEGER)-(t.tabIndex||Number.MAX_SAFE_INTEGER)))}var T=(t=>(t[t.Strict=0]=\"Strict\",t[t.Loose=1]=\"Loose\",t))(T||{});function h(e,r=0){var t;return e===((t=m(e))==null?void 0:t.body)?!1:L(r,{[0](){return e.matches(c)},[1](){let l=e;for(;l!==null;){if(l.matches(c))return!0;l=l.parentElement}return!1}})}function D(e){let r=m(e);b().nextFrame(()=>{r&&!h(r.activeElement,0)&&y(e)})}var w=(t=>(t[t.Keyboard=0]=\"Keyboard\",t[t.Mouse=1]=\"Mouse\",t))(w||{});typeof window!=\"undefined\"&&typeof document!=\"undefined\"&&(document.addEventListener(\"keydown\",e=>{e.metaKey||e.altKey||e.ctrlKey||(document.documentElement.dataset.headlessuiFocusVisible=\"\")},!0),document.addEventListener(\"click\",e=>{e.detail===1?delete document.documentElement.dataset.headlessuiFocusVisible:e.detail===0&&(document.documentElement.dataset.headlessuiFocusVisible=\"\")},!0));function y(e){e==null||e.focus({preventScroll:!0})}let S=[\"textarea\",\"input\"].join(\",\");function H(e){var r,t;return(t=(r=e==null?void 0:e.matches)==null?void 0:r.call(e,S))!=null?t:!1}function I(e,r=t=>t){return e.slice().sort((t,l)=>{let o=r(t),i=r(l);if(o===null||i===null)return 0;let n=o.compareDocumentPosition(i);return n&Node.DOCUMENT_POSITION_FOLLOWING?-1:n&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function _(e,r){return O(f(),r,{relativeTo:e})}function O(e,r,{sorted:t=!0,relativeTo:l=null,skipElements:o=[]}={}){let i=Array.isArray(e)?e.length>0?e[0].ownerDocument:document:e.ownerDocument,n=Array.isArray(e)?t?I(e):e:f(e);o.length>0&&n.length>1&&(n=n.filter(s=>!o.includes(s))),l=l!=null?l:i.activeElement;let E=(()=>{if(r&5)return 1;if(r&10)return-1;throw new Error(\"Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last\")})(),x=(()=>{if(r&1)return 0;if(r&2)return Math.max(0,n.indexOf(l))-1;if(r&4)return Math.max(0,n.indexOf(l))+1;if(r&8)return n.length-1;throw new Error(\"Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last\")})(),p=r&32?{preventScroll:!0}:{},d=0,a=n.length,u;do{if(d>=a||d+a<=0)return 0;let s=x+d;if(r&16)s=(s+a)%a;else{if(s<0)return 3;if(s>=a)return 1}u=n[s],u==null||u.focus(p),d+=E}while(u!==i.activeElement);return r&6&&H(u)&&u.select(),2}export{M as Focus,N as FocusResult,T as FocusableMode,y as focusElement,_ as focusFrom,O as focusIn,f as getFocusableElements,h as isFocusableElement,D as restoreFocusIfNecessary,I as sortByDomNode};\n","import{useEffect as m}from\"react\";import{useLatestValue as c}from'./use-latest-value.js';function d(e,r,n){let o=c(r);m(()=>{function t(u){o.current(u)}return document.addEventListener(e,t,n),()=>document.removeEventListener(e,t,n)},[e,n])}export{d as useDocumentEvent};\n","import{useEffect as d}from\"react\";import{useLatestValue as a}from'./use-latest-value.js';function s(e,r,n){let o=a(r);d(()=>{function t(i){o.current(i)}return window.addEventListener(e,t,n),()=>window.removeEventListener(e,t,n)},[e,n])}export{s as useWindowEvent};\n","import{useEffect as d,useRef as c}from\"react\";import{FocusableMode as p,isFocusableElement as C}from'../utils/focus-management.js';import{useDocumentEvent as f}from'./use-document-event.js';import{useWindowEvent as M}from'./use-window-event.js';function H(s,m,i=!0){let l=c(!1);d(()=>{requestAnimationFrame(()=>{l.current=i})},[i]);function a(e,o){if(!l.current||e.defaultPrevented)return;let n=o(e);if(n===null||!n.getRootNode().contains(n))return;let E=function r(t){return typeof t==\"function\"?r(t()):Array.isArray(t)||t instanceof Set?t:[t]}(s);for(let r of E){if(r===null)continue;let t=r instanceof HTMLElement?r:r.current;if(t!=null&&t.contains(n)||e.composed&&e.composedPath().includes(t))return}return!C(n,p.Loose)&&n.tabIndex!==-1&&e.preventDefault(),m(e,n)}let u=c(null);f(\"mousedown\",e=>{var o,n;l.current&&(u.current=((n=(o=e.composedPath)==null?void 0:o.call(e))==null?void 0:n[0])||e.target)},!0),f(\"click\",e=>{u.current&&(a(e,()=>u.current),u.current=null)},!0),M(\"blur\",e=>a(e,()=>window.document.activeElement instanceof HTMLIFrameElement?window.document.activeElement:null),!0)}export{H as useOutsideClick};\n","import{useState as o}from\"react\";import{useIsoMorphicEffect as r}from'./use-iso-morphic-effect.js';function i(t){var n;if(t.type)return t.type;let e=(n=t.as)!=null?n:\"button\";if(typeof e==\"string\"&&e.toLowerCase()===\"button\")return\"button\"}function s(t,e){let[n,u]=o(()=>i(t));return r(()=>{u(i(t))},[t.type,t.as]),r(()=>{n||e.current&&e.current instanceof HTMLButtonElement&&!e.current.hasAttribute(\"type\")&&u(\"button\")},[n,e]),n}export{s as useResolveButtonType};\n","import{useRef as l,useEffect as i}from\"react\";import{useEvent as r}from'./use-event.js';let u=Symbol();function T(t,n=!0){return Object.assign(t,{[u]:n})}function y(...t){let n=l(t);i(()=>{n.current=t},[t]);let c=r(e=>{for(let o of n.current)o!=null&&(typeof o==\"function\"?o(e):o.current=e)});return t.every(e=>e==null||(e==null?void 0:e[u]))?void 0:c}export{T as optionalRef,y as useSyncRefs};\n","function e(...n){return n.filter(Boolean).join(\" \")}export{e as classNames};\n","import{Fragment as T,cloneElement as x,createElement as E,forwardRef as b,isValidElement as h}from\"react\";import{classNames as F}from'./class-names.js';import{match as P}from'./match.js';var S=(a=>(a[a.None=0]=\"None\",a[a.RenderStrategy=1]=\"RenderStrategy\",a[a.Static=2]=\"Static\",a))(S||{}),j=(e=>(e[e.Unmount=0]=\"Unmount\",e[e.Hidden=1]=\"Hidden\",e))(j||{});function X({ourProps:r,theirProps:t,slot:e,defaultTag:a,features:s,visible:n=!0,name:f}){let o=N(t,r);if(n)return c(o,e,a,f);let u=s!=null?s:0;if(u&2){let{static:l=!1,...p}=o;if(l)return c(p,e,a,f)}if(u&1){let{unmount:l=!0,...p}=o;return P(l?0:1,{[0](){return null},[1](){return c({...p,hidden:!0,style:{display:\"none\"}},e,a,f)}})}return c(o,e,a,f)}function c(r,t={},e,a){let{as:s=e,children:n,refName:f=\"ref\",...o}=g(r,[\"unmount\",\"static\"]),u=r.ref!==void 0?{[f]:r.ref}:{},l=typeof n==\"function\"?n(t):n;\"className\"in o&&o.className&&typeof o.className==\"function\"&&(o.className=o.className(t));let p={};if(t){let i=!1,m=[];for(let[y,d]of Object.entries(t))typeof d==\"boolean\"&&(i=!0),d===!0&&m.push(y);i&&(p[\"data-headlessui-state\"]=m.join(\" \"))}if(s===T&&Object.keys(R(o)).length>0){if(!h(l)||Array.isArray(l)&&l.length>1)throw new Error(['Passing props on \"Fragment\"!',\"\",`The current component <${a} /> is rendering a \"Fragment\".`,\"However we need to passthrough the following props:\",Object.keys(o).map(d=>` - ${d}`).join(`\n`),\"\",\"You can apply a few solutions:\",['Add an `as=\"...\"` prop, to ensure that we render an actual element instead of a \"Fragment\".',\"Render a single element as the child so that we can forward the props onto that element.\"].map(d=>` - ${d}`).join(`\n`)].join(`\n`));let i=l.props,m=typeof(i==null?void 0:i.className)==\"function\"?(...d)=>F(i==null?void 0:i.className(...d),o.className):F(i==null?void 0:i.className,o.className),y=m?{className:m}:{};return x(l,Object.assign({},N(l.props,R(g(o,[\"ref\"]))),p,u,w(l.ref,u.ref),y))}return E(s,Object.assign({},g(o,[\"ref\"]),s!==T&&u,s!==T&&p),l)}function w(...r){return{ref:r.every(t=>t==null)?void 0:t=>{for(let e of r)e!=null&&(typeof e==\"function\"?e(t):e.current=t)}}}function N(...r){var a;if(r.length===0)return{};if(r.length===1)return r[0];let t={},e={};for(let s of r)for(let n in s)n.startsWith(\"on\")&&typeof s[n]==\"function\"?((a=e[n])!=null||(e[n]=[]),e[n].push(s[n])):t[n]=s[n];if(t.disabled||t[\"aria-disabled\"])return Object.assign(t,Object.fromEntries(Object.keys(e).map(s=>[s,void 0])));for(let s in e)Object.assign(t,{[s](n,...f){let o=e[s];for(let u of o){if((n instanceof Event||(n==null?void 0:n.nativeEvent)instanceof Event)&&n.defaultPrevented)return;u(n,...f)}}});return t}function D(r){var t;return Object.assign(b(r),{displayName:(t=r.displayName)!=null?t:r.name})}function R(r){let t=Object.assign({},r);for(let e in t)t[e]===void 0&&delete t[e];return t}function g(r,t=[]){let e=Object.assign({},r);for(let a of t)a in e&&delete e[a];return e}export{S as Features,j as RenderStrategy,R as compact,D as forwardRefWithAs,X as render};\n","function r(n){let e=n.parentElement,l=null;for(;e&&!(e instanceof HTMLFieldSetElement);)e instanceof HTMLLegendElement&&(l=e),e=e.parentElement;let t=(e==null?void 0:e.getAttribute(\"disabled\"))===\"\";return t&&i(l)?!1:t}function i(n){if(!n)return!1;let e=n.previousElementSibling;for(;e!==null;){if(e instanceof HTMLLegendElement)return!1;e=e.previousElementSibling}return!0}export{r as isDisabledReactIssue7711};\n","import{forwardRefWithAs as r,render as i}from'../utils/render.js';let a=\"div\";var p=(e=>(e[e.None=1]=\"None\",e[e.Focusable=2]=\"Focusable\",e[e.Hidden=4]=\"Hidden\",e))(p||{});function s(t,o){let{features:n=1,...e}=t,d={ref:o,\"aria-hidden\":(n&2)===2?!0:void 0,style:{position:\"fixed\",top:1,left:1,width:1,height:0,padding:0,margin:-1,overflow:\"hidden\",clip:\"rect(0, 0, 0, 0)\",whiteSpace:\"nowrap\",borderWidth:\"0\",...(n&4)===4&&(n&2)!==2&&{display:\"none\"}}};return i({ourProps:d,theirProps:e,slot:{},defaultTag:a,name:\"Hidden\"})}let c=r(s);export{p as Features,c as Hidden};\n","import l,{createContext as t,useContext as p}from\"react\";let n=t(null);n.displayName=\"OpenClosedContext\";var d=(e=>(e[e.Open=1]=\"Open\",e[e.Closed=2]=\"Closed\",e[e.Closing=4]=\"Closing\",e[e.Opening=8]=\"Opening\",e))(d||{});function C(){return p(n)}function c({value:o,children:r}){return l.createElement(n.Provider,{value:o},r)}export{c as OpenClosedProvider,d as State,C as useOpenClosed};\n","var o=(r=>(r.Space=\" \",r.Enter=\"Enter\",r.Escape=\"Escape\",r.Backspace=\"Backspace\",r.Delete=\"Delete\",r.ArrowLeft=\"ArrowLeft\",r.ArrowUp=\"ArrowUp\",r.ArrowRight=\"ArrowRight\",r.ArrowDown=\"ArrowDown\",r.Home=\"Home\",r.End=\"End\",r.PageUp=\"PageUp\",r.PageDown=\"PageDown\",r.Tab=\"Tab\",r))(o||{});export{o as Keys};\n","import{useRef as t}from\"react\";import{useWindowEvent as a}from'./use-window-event.js';var s=(r=>(r[r.Forwards=0]=\"Forwards\",r[r.Backwards=1]=\"Backwards\",r))(s||{});function n(){let e=t(0);return a(\"keydown\",o=>{o.key===\"Tab\"&&(e.current=o.shiftKey?1:0)},!0),e}export{s as Direction,n as useTabDirection};\n","import{useMemo as t}from\"react\";import{getOwnerDocument as o}from'../utils/owner.js';function n(...e){return t(()=>o(...e),[...e])}export{n as useOwnerDocument};\n","import{useEffect as d}from\"react\";import{useLatestValue as s}from'./use-latest-value.js';function E(n,e,a,t){let i=s(a);d(()=>{n=n!=null?n:window;function r(o){i.current(o)}return n.addEventListener(e,r,t),()=>n.removeEventListener(e,r,t)},[n,e,t])}export{E as useEventListener};\n","import{useRef as u,useEffect as n}from\"react\";import{microTask as o}from'../utils/micro-task.js';import{useEvent as f}from'./use-event.js';function c(t){let r=f(t),e=u(!1);n(()=>(e.current=!1,()=>{e.current=!0,o(()=>{e.current&&r()})}),[r])}export{c as useOnUnmount};\n","import t,{createContext as r,useContext as c}from\"react\";let e=r(!1);function l(){return c(e)}function P(o){return t.createElement(e.Provider,{value:o.force},o.children)}export{P as ForcePortalRoot,l as usePortalRoot};\n","import T,{Fragment as P,createContext as m,useContext as s,useEffect as d,useRef as g,useState as R,useMemo as E}from\"react\";import{createPortal as H}from\"react-dom\";import{forwardRefWithAs as c,render as y}from'../../utils/render.js';import{useIsoMorphicEffect as x}from'../../hooks/use-iso-morphic-effect.js';import{usePortalRoot as b}from'../../internal/portal-force-root.js';import{useServerHandoffComplete as h}from'../../hooks/use-server-handoff-complete.js';import{optionalRef as O,useSyncRefs as L}from'../../hooks/use-sync-refs.js';import{useOnUnmount as _}from'../../hooks/use-on-unmount.js';import{useOwnerDocument as A}from'../../hooks/use-owner.js';import{env as G}from'../../utils/env.js';import{useEvent as M}from'../../hooks/use-event.js';function F(p){let l=b(),n=s(v),e=A(p),[a,o]=R(()=>{if(!l&&n!==null||G.isServer)return null;let t=e==null?void 0:e.getElementById(\"headlessui-portal-root\");if(t)return t;if(e===null)return null;let r=e.createElement(\"div\");return r.setAttribute(\"id\",\"headlessui-portal-root\"),e.body.appendChild(r)});return d(()=>{a!==null&&(e!=null&&e.body.contains(a)||e==null||e.body.appendChild(a))},[a,e]),d(()=>{l||n!==null&&o(n.current)},[n,o,l]),a}let U=P;function N(p,l){let n=p,e=g(null),a=L(O(u=>{e.current=u}),l),o=A(e),t=F(e),[r]=R(()=>{var u;return G.isServer?null:(u=o==null?void 0:o.createElement(\"div\"))!=null?u:null}),i=s(f),C=h();return x(()=>{!t||!r||t.contains(r)||(r.setAttribute(\"data-headlessui-portal\",\"\"),t.appendChild(r))},[t,r]),x(()=>{if(r&&i)return i.register(r)},[i,r]),_(()=>{var u;!t||!r||(r instanceof Node&&t.contains(r)&&t.removeChild(r),t.childNodes.length<=0&&((u=t.parentElement)==null||u.removeChild(t)))}),C?!t||!r?null:H(y({ourProps:{ref:a},theirProps:n,defaultTag:U,name:\"Portal\"}),r):null}let S=P,v=m(null);function j(p,l){let{target:n,...e}=p,o={ref:L(l)};return T.createElement(v.Provider,{value:n},y({ourProps:o,theirProps:e,defaultTag:S,name:\"Popover.Group\"}))}let f=m(null);function ae(){let p=s(f),l=g([]),n=M(o=>(l.current.push(o),p&&p.register(o),()=>e(o))),e=M(o=>{let t=l.current.indexOf(o);t!==-1&&l.current.splice(t,1),p&&p.unregister(o)}),a=E(()=>({register:n,unregister:e,portals:l}),[n,e,l]);return[l,E(()=>function({children:t}){return T.createElement(f.Provider,{value:a},t)},[a])]}let D=c(N),I=c(j),pe=Object.assign(D,{Group:I});export{pe as Portal,ae as useNestedPortals};\n","import s,{useRef as a,useMemo as m}from\"react\";import{Hidden as d,Features as M}from'../internal/hidden.js';import{useEvent as l}from'./use-event.js';import{useOwnerDocument as H}from'./use-owner.js';function p({defaultContainers:f=[],portals:o}={}){let t=a(null),i=H(t),u=l(()=>{var r;let n=[];for(let e of f)e!==null&&(e instanceof HTMLElement?n.push(e):\"current\"in e&&e.current instanceof HTMLElement&&n.push(e.current));if(o!=null&&o.current)for(let e of o.current)n.push(e);for(let e of(r=i==null?void 0:i.querySelectorAll(\"html > *, body > *\"))!=null?r:[])e!==document.body&&e!==document.head&&e instanceof HTMLElement&&e.id!==\"headlessui-portal-root\"&&(e.contains(t.current)||n.some(c=>e.contains(c))||n.push(e));return n});return{resolveContainers:u,contains:l(n=>u().some(r=>r.contains(n))),mainTreeNodeRef:t,MainTreeNode:m(()=>function(){return s.createElement(d,{features:M.Hidden,ref:t})},[t])}}export{p as useRootContainers};\n","import C,{createContext as Q,createRef as de,useContext as Z,useEffect as ee,useMemo as H,useReducer as be,useRef as J,useState as ce}from\"react\";import{match as w}from'../../utils/match.js';import{forwardRefWithAs as X,render as Y,Features as te}from'../../utils/render.js';import{optionalRef as Se,useSyncRefs as j}from'../../hooks/use-sync-refs.js';import{useId as V}from'../../hooks/use-id.js';import{Keys as N}from'../keyboard.js';import{isDisabledReactIssue7711 as ve}from'../../utils/bugs.js';import{getFocusableElements as ne,Focus as G,focusIn as U,isFocusableElement as Ae,FocusableMode as Oe,FocusResult as le}from'../../utils/focus-management.js';import{OpenClosedProvider as Re,State as $,useOpenClosed as Te}from'../../internal/open-closed.js';import{useResolveButtonType as Ce}from'../../hooks/use-resolve-button-type.js';import{useOutsideClick as Fe}from'../../hooks/use-outside-click.js';import{getOwnerDocument as Me}from'../../utils/owner.js';import{useOwnerDocument as ae}from'../../hooks/use-owner.js';import{useEventListener as xe}from'../../hooks/use-event-listener.js';import{Hidden as pe,Features as se}from'../../internal/hidden.js';import{useEvent as S}from'../../hooks/use-event.js';import{useTabDirection as me,Direction as k}from'../../hooks/use-tab-direction.js';import'../../utils/micro-task.js';import{useLatestValue as ye}from'../../hooks/use-latest-value.js';import{useIsoMorphicEffect as Ie}from'../../hooks/use-iso-morphic-effect.js';import{useRootContainers as Le}from'../../hooks/use-root-containers.js';import{useNestedPortals as Be}from'../../components/portal/portal.js';var De=(u=>(u[u.Open=0]=\"Open\",u[u.Closed=1]=\"Closed\",u))(De||{}),he=(e=>(e[e.TogglePopover=0]=\"TogglePopover\",e[e.ClosePopover=1]=\"ClosePopover\",e[e.SetButton=2]=\"SetButton\",e[e.SetButtonId=3]=\"SetButtonId\",e[e.SetPanel=4]=\"SetPanel\",e[e.SetPanelId=5]=\"SetPanelId\",e))(he||{});let He={[0]:t=>{let o={...t,popoverState:w(t.popoverState,{[0]:1,[1]:0})};return o.popoverState===0&&(o.__demoMode=!1),o},[1](t){return t.popoverState===1?t:{...t,popoverState:1}},[2](t,o){return t.button===o.button?t:{...t,button:o.button}},[3](t,o){return t.buttonId===o.buttonId?t:{...t,buttonId:o.buttonId}},[4](t,o){return t.panel===o.panel?t:{...t,panel:o.panel}},[5](t,o){return t.panelId===o.panelId?t:{...t,panelId:o.panelId}}},ue=Q(null);ue.displayName=\"PopoverContext\";function oe(t){let o=Z(ue);if(o===null){let u=new Error(`<${t} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(u,oe),u}return o}let ie=Q(null);ie.displayName=\"PopoverAPIContext\";function fe(t){let o=Z(ie);if(o===null){let u=new Error(`<${t} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(u,fe),u}return o}let Pe=Q(null);Pe.displayName=\"PopoverGroupContext\";function Ee(){return Z(Pe)}let re=Q(null);re.displayName=\"PopoverPanelContext\";function _e(){return Z(re)}function Ge(t,o){return w(o.type,He,t,o)}let ke=\"div\";function we(t,o){var I;let{__demoMode:u=!1,...A}=t,O=J(null),n=j(o,Se(l=>{O.current=l})),e=J([]),T=be(Ge,{__demoMode:u,popoverState:u?0:1,buttons:e,button:null,buttonId:null,panel:null,panelId:null,beforePanelSentinel:de(),afterPanelSentinel:de()}),[{popoverState:P,button:p,buttonId:F,panel:a,panelId:m,beforePanelSentinel:y,afterPanelSentinel:s},i]=T,d=ae((I=O.current)!=null?I:p),g=H(()=>{if(!p||!a)return!1;for(let K of document.querySelectorAll(\"body > *\"))if(Number(K==null?void 0:K.contains(p))^Number(K==null?void 0:K.contains(a)))return!0;let l=ne(),R=l.indexOf(p),q=(R+l.length-1)%l.length,W=(R+1)%l.length,z=l[q],ge=l[W];return!a.contains(z)&&!a.contains(ge)},[p,a]),L=ye(F),h=ye(m),_=H(()=>({buttonId:L,panelId:h,close:()=>i({type:1})}),[L,h,i]),B=Ee(),D=B==null?void 0:B.registerPopover,f=S(()=>{var l;return(l=B==null?void 0:B.isFocusWithinPopoverGroup())!=null?l:(d==null?void 0:d.activeElement)&&((p==null?void 0:p.contains(d.activeElement))||(a==null?void 0:a.contains(d.activeElement)))});ee(()=>D==null?void 0:D(_),[D,_]);let[E,b]=Be(),c=Le({portals:E,defaultContainers:[p,a]});xe(d==null?void 0:d.defaultView,\"focus\",l=>{var R,q,W,z;l.target!==window&&l.target instanceof HTMLElement&&P===0&&(f()||p&&a&&(c.contains(l.target)||(q=(R=y.current)==null?void 0:R.contains)!=null&&q.call(R,l.target)||(z=(W=s.current)==null?void 0:W.contains)!=null&&z.call(W,l.target)||i({type:1})))},!0),Fe(c.resolveContainers,(l,R)=>{i({type:1}),Ae(R,Oe.Loose)||(l.preventDefault(),p==null||p.focus())},P===0);let M=S(l=>{i({type:1});let R=(()=>l?l instanceof HTMLElement?l:\"current\"in l&&l.current instanceof HTMLElement?l.current:p:p)();R==null||R.focus()}),r=H(()=>({close:M,isPortalled:g}),[M,g]),v=H(()=>({open:P===0,close:M}),[P,M]),x={ref:n};return C.createElement(re.Provider,{value:null},C.createElement(ue.Provider,{value:T},C.createElement(ie.Provider,{value:r},C.createElement(Re,{value:w(P,{[0]:$.Open,[1]:$.Closed})},C.createElement(b,null,Y({ourProps:x,theirProps:A,slot:v,defaultTag:ke,name:\"Popover\"}),C.createElement(c.MainTreeNode,null))))))}let Ne=\"button\";function Ue(t,o){let u=V(),{id:A=`headlessui-popover-button-${u}`,...O}=t,[n,e]=oe(\"Popover.Button\"),{isPortalled:T}=fe(\"Popover.Button\"),P=J(null),p=`headlessui-focus-sentinel-${V()}`,F=Ee(),a=F==null?void 0:F.closeOthers,y=_e()!==null;ee(()=>{if(!y)return e({type:3,buttonId:A}),()=>{e({type:3,buttonId:null})}},[y,A,e]);let[s]=ce(()=>Symbol()),i=j(P,o,y?null:r=>{if(r)n.buttons.current.push(s);else{let v=n.buttons.current.indexOf(s);v!==-1&&n.buttons.current.splice(v,1)}n.buttons.current.length>1&&console.warn(\"You are already using a but only 1 is supported.\"),r&&e({type:2,button:r})}),d=j(P,o),g=ae(P),L=S(r=>{var v,x,I;if(y){if(n.popoverState===1)return;switch(r.key){case N.Space:case N.Enter:r.preventDefault(),(x=(v=r.target).click)==null||x.call(v),e({type:1}),(I=n.button)==null||I.focus();break}}else switch(r.key){case N.Space:case N.Enter:r.preventDefault(),r.stopPropagation(),n.popoverState===1&&(a==null||a(n.buttonId)),e({type:0});break;case N.Escape:if(n.popoverState!==0)return a==null?void 0:a(n.buttonId);if(!P.current||g!=null&&g.activeElement&&!P.current.contains(g.activeElement))return;r.preventDefault(),r.stopPropagation(),e({type:1});break}}),h=S(r=>{y||r.key===N.Space&&r.preventDefault()}),_=S(r=>{var v,x;ve(r.currentTarget)||t.disabled||(y?(e({type:1}),(v=n.button)==null||v.focus()):(r.preventDefault(),r.stopPropagation(),n.popoverState===1&&(a==null||a(n.buttonId)),e({type:0}),(x=n.button)==null||x.focus()))}),B=S(r=>{r.preventDefault(),r.stopPropagation()}),D=n.popoverState===0,f=H(()=>({open:D}),[D]),E=Ce(t,P),b=y?{ref:d,type:E,onKeyDown:L,onClick:_}:{ref:i,id:n.buttonId,type:E,\"aria-expanded\":t.disabled?void 0:n.popoverState===0,\"aria-controls\":n.panel?n.panelId:void 0,onKeyDown:L,onKeyUp:h,onClick:_,onMouseDown:B},c=me(),M=S(()=>{let r=n.panel;if(!r)return;function v(){w(c.current,{[k.Forwards]:()=>U(r,G.First),[k.Backwards]:()=>U(r,G.Last)})===le.Error&&U(ne().filter(I=>I.dataset.headlessuiFocusGuard!==\"true\"),w(c.current,{[k.Forwards]:G.Next,[k.Backwards]:G.Previous}),{relativeTo:n.button})}v()});return C.createElement(C.Fragment,null,Y({ourProps:b,theirProps:O,slot:f,defaultTag:Ne,name:\"Popover.Button\"}),D&&!y&&T&&C.createElement(pe,{id:p,features:se.Focusable,\"data-headlessui-focus-guard\":!0,as:\"button\",type:\"button\",onFocus:M}))}let We=\"div\",Ke=te.RenderStrategy|te.Static;function je(t,o){let u=V(),{id:A=`headlessui-popover-overlay-${u}`,...O}=t,[{popoverState:n},e]=oe(\"Popover.Overlay\"),T=j(o),P=Te(),p=(()=>P!==null?(P&$.Open)===$.Open:n===0)(),F=S(y=>{if(ve(y.currentTarget))return y.preventDefault();e({type:1})}),a=H(()=>({open:n===0}),[n]);return Y({ourProps:{ref:T,id:A,\"aria-hidden\":!0,onClick:F},theirProps:O,slot:a,defaultTag:We,features:Ke,visible:p,name:\"Popover.Overlay\"})}let Ve=\"div\",$e=te.RenderStrategy|te.Static;function Je(t,o){let u=V(),{id:A=`headlessui-popover-panel-${u}`,focus:O=!1,...n}=t,[e,T]=oe(\"Popover.Panel\"),{close:P,isPortalled:p}=fe(\"Popover.Panel\"),F=`headlessui-focus-sentinel-before-${V()}`,a=`headlessui-focus-sentinel-after-${V()}`,m=J(null),y=j(m,o,f=>{T({type:4,panel:f})}),s=ae(m);Ie(()=>(T({type:5,panelId:A}),()=>{T({type:5,panelId:null})}),[A,T]);let i=Te(),d=(()=>i!==null?(i&$.Open)===$.Open:e.popoverState===0)(),g=S(f=>{var E;switch(f.key){case N.Escape:if(e.popoverState!==0||!m.current||s!=null&&s.activeElement&&!m.current.contains(s.activeElement))return;f.preventDefault(),f.stopPropagation(),T({type:1}),(E=e.button)==null||E.focus();break}});ee(()=>{var f;t.static||e.popoverState===1&&((f=t.unmount)==null||f)&&T({type:4,panel:null})},[e.popoverState,t.unmount,t.static,T]),ee(()=>{if(e.__demoMode||!O||e.popoverState!==0||!m.current)return;let f=s==null?void 0:s.activeElement;m.current.contains(f)||U(m.current,G.First)},[e.__demoMode,O,m,e.popoverState]);let L=H(()=>({open:e.popoverState===0,close:P}),[e,P]),h={ref:y,id:A,onKeyDown:g,onBlur:O&&e.popoverState===0?f=>{var b,c,M,r,v;let E=f.relatedTarget;E&&m.current&&((b=m.current)!=null&&b.contains(E)||(T({type:1}),((M=(c=e.beforePanelSentinel.current)==null?void 0:c.contains)!=null&&M.call(c,E)||(v=(r=e.afterPanelSentinel.current)==null?void 0:r.contains)!=null&&v.call(r,E))&&E.focus({preventScroll:!0})))}:void 0,tabIndex:-1},_=me(),B=S(()=>{let f=m.current;if(!f)return;function E(){w(_.current,{[k.Forwards]:()=>{var c;U(f,G.First)===le.Error&&((c=e.afterPanelSentinel.current)==null||c.focus())},[k.Backwards]:()=>{var b;(b=e.button)==null||b.focus({preventScroll:!0})}})}E()}),D=S(()=>{let f=m.current;if(!f)return;function E(){w(_.current,{[k.Forwards]:()=>{var x;if(!e.button)return;let b=ne(),c=b.indexOf(e.button),M=b.slice(0,c+1),v=[...b.slice(c+1),...M];for(let I of v.slice())if(I.dataset.headlessuiFocusGuard===\"true\"||(x=e.panel)!=null&&x.contains(I)){let l=v.indexOf(I);l!==-1&&v.splice(l,1)}U(v,G.First,{sorted:!1})},[k.Backwards]:()=>{var c;U(f,G.Previous)===le.Error&&((c=e.button)==null||c.focus())}})}E()});return C.createElement(re.Provider,{value:A},d&&p&&C.createElement(pe,{id:F,ref:e.beforePanelSentinel,features:se.Focusable,\"data-headlessui-focus-guard\":!0,as:\"button\",type:\"button\",onFocus:B}),Y({ourProps:h,theirProps:n,slot:L,defaultTag:Ve,features:$e,visible:d,name:\"Popover.Panel\"}),d&&p&&C.createElement(pe,{id:a,ref:e.afterPanelSentinel,features:se.Focusable,\"data-headlessui-focus-guard\":!0,as:\"button\",type:\"button\",onFocus:D}))}let Xe=\"div\";function Ye(t,o){let u=J(null),A=j(u,o),[O,n]=ce([]),e=S(s=>{n(i=>{let d=i.indexOf(s);if(d!==-1){let g=i.slice();return g.splice(d,1),g}return i})}),T=S(s=>(n(i=>[...i,s]),()=>e(s))),P=S(()=>{var d;let s=Me(u);if(!s)return!1;let i=s.activeElement;return(d=u.current)!=null&&d.contains(i)?!0:O.some(g=>{var L,h;return((L=s.getElementById(g.buttonId.current))==null?void 0:L.contains(i))||((h=s.getElementById(g.panelId.current))==null?void 0:h.contains(i))})}),p=S(s=>{for(let i of O)i.buttonId.current!==s&&i.close()}),F=H(()=>({registerPopover:T,unregisterPopover:e,isFocusWithinPopoverGroup:P,closeOthers:p}),[T,e,P,p]),a=H(()=>({}),[]),m=t,y={ref:A};return C.createElement(Pe.Provider,{value:F},Y({ourProps:y,theirProps:m,slot:a,defaultTag:Xe,name:\"Popover.Group\"}))}let qe=X(we),ze=X(Ue),Qe=X(je),Ze=X(Je),et=X(Ye),kt=Object.assign(qe,{Button:ze,Overlay:Qe,Panel:Ze,Group:et});export{kt as Popover};\n","import i,{useState as s}from\"react\";import{Hidden as c,Features as l}from'./hidden.js';function p({onFocus:n}){let[r,o]=s(!0);return r?i.createElement(c,{as:\"button\",type:\"button\",features:l.Focusable,onFocus:a=>{a.preventDefault();let e,u=50;function t(){if(u--<=0){e&&cancelAnimationFrame(e);return}if(n()){o(!1),cancelAnimationFrame(e);return}e=requestAnimationFrame(t)}e=requestAnimationFrame(t)}}):null}export{p as FocusSentinel};\n","import*as r from\"react\";const s=r.createContext(null);function a(){return{groups:new Map,get(n,t){var c;let e=this.groups.get(n);e||(e=new Map,this.groups.set(n,e));let l=(c=e.get(t))!=null?c:0;e.set(t,l+1);let o=Array.from(e.keys()).indexOf(t);function i(){let u=e.get(t);u>1?e.set(t,u-1):e.delete(t)}return[o,i]}}}function C({children:n}){let t=r.useRef(a());return r.createElement(s.Provider,{value:t},n)}function d(n){let t=r.useContext(s);if(!t)throw new Error(\"You must wrap your component in a \");let e=f(),[l,o]=t.current.get(n,e);return r.useEffect(()=>o,[]),l}function f(){var l,o,i;let n=(i=(o=(l=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED)==null?void 0:l.ReactCurrentOwner)==null?void 0:o.current)!=null?i:null;if(!n)return Symbol();let t=[],e=n;for(;e;)t.push(e.index),e=e.return;return\"$.\"+t.join(\".\")}export{C as StableCollection,d as useStableCollectionIndex};\n","import _,{Fragment as ne,createContext as V,useContext as Q,useMemo as F,useReducer as re,useRef as K}from\"react\";import{render as w,Features as Y,forwardRefWithAs as v}from'../../utils/render.js';import{useId as Z}from'../../hooks/use-id.js';import{match as G}from'../../utils/match.js';import{Keys as P}from'../../components/keyboard.js';import{focusIn as h,Focus as g,sortByDomNode as H,FocusResult as k}from'../../utils/focus-management.js';import{useIsoMorphicEffect as O}from'../../hooks/use-iso-morphic-effect.js';import{useSyncRefs as U}from'../../hooks/use-sync-refs.js';import{useResolveButtonType as ae}from'../../hooks/use-resolve-button-type.js';import{useLatestValue as J}from'../../hooks/use-latest-value.js';import{FocusSentinel as le}from'../../internal/focus-sentinel.js';import{useEvent as D}from'../../hooks/use-event.js';import{microTask as oe}from'../../utils/micro-task.js';import{Hidden as se}from'../../internal/hidden.js';import{getOwnerDocument as ie}from'../../utils/owner.js';import{StableCollection as pe,useStableCollectionIndex as ee}from'../../utils/stable-collection.js';var ue=(t=>(t[t.Forwards=0]=\"Forwards\",t[t.Backwards=1]=\"Backwards\",t))(ue||{}),Te=(o=>(o[o.Less=-1]=\"Less\",o[o.Equal=0]=\"Equal\",o[o.Greater=1]=\"Greater\",o))(Te||{}),de=(r=>(r[r.SetSelectedIndex=0]=\"SetSelectedIndex\",r[r.RegisterTab=1]=\"RegisterTab\",r[r.UnregisterTab=2]=\"UnregisterTab\",r[r.RegisterPanel=3]=\"RegisterPanel\",r[r.UnregisterPanel=4]=\"UnregisterPanel\",r))(de||{});let ce={[0](e,n){var u;let t=H(e.tabs,T=>T.current),o=H(e.panels,T=>T.current),s=t.filter(T=>{var l;return!((l=T.current)!=null&&l.hasAttribute(\"disabled\"))}),r={...e,tabs:t,panels:o};if(n.index<0||n.index>t.length-1){let T=G(Math.sign(n.index-e.selectedIndex),{[-1]:()=>1,[0]:()=>G(Math.sign(n.index),{[-1]:()=>0,[0]:()=>0,[1]:()=>1}),[1]:()=>0});return s.length===0?r:{...r,selectedIndex:G(T,{[0]:()=>t.indexOf(s[0]),[1]:()=>t.indexOf(s[s.length-1])})}}let i=t.slice(0,n.index),b=[...t.slice(n.index),...i].find(T=>s.includes(T));if(!b)return r;let c=(u=t.indexOf(b))!=null?u:e.selectedIndex;return c===-1&&(c=e.selectedIndex),{...r,selectedIndex:c}},[1](e,n){var r;if(e.tabs.includes(n.tab))return e;let t=e.tabs[e.selectedIndex],o=H([...e.tabs,n.tab],i=>i.current),s=(r=o.indexOf(t))!=null?r:e.selectedIndex;return s===-1&&(s=e.selectedIndex),{...e,tabs:o,selectedIndex:s}},[2](e,n){return{...e,tabs:e.tabs.filter(t=>t!==n.tab)}},[3](e,n){return e.panels.includes(n.panel)?e:{...e,panels:H([...e.panels,n.panel],t=>t.current)}},[4](e,n){return{...e,panels:e.panels.filter(t=>t!==n.panel)}}},X=V(null);X.displayName=\"TabsDataContext\";function M(e){let n=Q(X);if(n===null){let t=new Error(`<${e} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,M),t}return n}let $=V(null);$.displayName=\"TabsActionsContext\";function q(e){let n=Q($);if(n===null){let t=new Error(`<${e} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,q),t}return n}function fe(e,n){return G(n.type,ce,e,n)}let be=ne;function me(e,n){let{defaultIndex:t=0,vertical:o=!1,manual:s=!1,onChange:r,selectedIndex:i=null,...R}=e;const b=o?\"vertical\":\"horizontal\",c=s?\"manual\":\"auto\";let u=i!==null,T=U(n),[l,d]=re(fe,{selectedIndex:i!=null?i:t,tabs:[],panels:[]}),y=F(()=>({selectedIndex:l.selectedIndex}),[l.selectedIndex]),m=J(r||(()=>{})),x=J(l.tabs),E=F(()=>({orientation:b,activation:c,...l}),[b,c,l]),S=D(p=>(d({type:1,tab:p}),()=>d({type:2,tab:p}))),A=D(p=>(d({type:3,panel:p}),()=>d({type:4,panel:p}))),L=D(p=>{C.current!==p&&m.current(p),u||d({type:0,index:p})}),C=J(u?e.selectedIndex:l.selectedIndex),N=F(()=>({registerTab:S,registerPanel:A,change:L}),[]);O(()=>{d({type:0,index:i!=null?i:t})},[i]),O(()=>{if(C.current===void 0||l.tabs.length<=0)return;let p=H(l.tabs,a=>a.current);p.some((a,f)=>l.tabs[f]!==a)&&L(p.indexOf(l.tabs[C.current]))});let B={ref:T};return _.createElement(pe,null,_.createElement($.Provider,{value:N},_.createElement(X.Provider,{value:E},E.tabs.length<=0&&_.createElement(le,{onFocus:()=>{var p,I;for(let a of x.current)if(((p=a.current)==null?void 0:p.tabIndex)===0)return(I=a.current)==null||I.focus(),!0;return!1}}),w({ourProps:B,theirProps:R,slot:y,defaultTag:be,name:\"Tabs\"}))))}let Pe=\"div\";function ge(e,n){let{orientation:t,selectedIndex:o}=M(\"Tab.List\"),s=U(n);return w({ourProps:{ref:s,role:\"tablist\",\"aria-orientation\":t},theirProps:e,slot:{selectedIndex:o},defaultTag:Pe,name:\"Tabs.List\"})}let ye=\"button\";function xe(e,n){var p,I;let t=Z(),{id:o=`headlessui-tabs-tab-${t}`,...s}=e,{orientation:r,activation:i,selectedIndex:R,tabs:b,panels:c}=M(\"Tab\"),u=q(\"Tab\"),T=M(\"Tab\"),l=K(null),d=U(l,n);O(()=>u.registerTab(l),[u,l]);let y=ee(\"tabs\"),m=b.indexOf(l);m===-1&&(m=y);let x=m===R,E=D(a=>{var j;let f=a();if(f===k.Success&&i===\"auto\"){let W=(j=ie(l))==null?void 0:j.activeElement,z=T.tabs.findIndex(te=>te.current===W);z!==-1&&u.change(z)}return f}),S=D(a=>{let f=b.map(W=>W.current).filter(Boolean);if(a.key===P.Space||a.key===P.Enter){a.preventDefault(),a.stopPropagation(),u.change(m);return}switch(a.key){case P.Home:case P.PageUp:return a.preventDefault(),a.stopPropagation(),E(()=>h(f,g.First));case P.End:case P.PageDown:return a.preventDefault(),a.stopPropagation(),E(()=>h(f,g.Last))}if(E(()=>G(r,{vertical(){return a.key===P.ArrowUp?h(f,g.Previous|g.WrapAround):a.key===P.ArrowDown?h(f,g.Next|g.WrapAround):k.Error},horizontal(){return a.key===P.ArrowLeft?h(f,g.Previous|g.WrapAround):a.key===P.ArrowRight?h(f,g.Next|g.WrapAround):k.Error}}))===k.Success)return a.preventDefault()}),A=K(!1),L=D(()=>{var a;A.current||(A.current=!0,(a=l.current)==null||a.focus(),u.change(m),oe(()=>{A.current=!1}))}),C=D(a=>{a.preventDefault()}),N=F(()=>({selected:x}),[x]),B={ref:d,onKeyDown:S,onMouseDown:C,onClick:L,id:o,role:\"tab\",type:ae(e,l),\"aria-controls\":(I=(p=c[m])==null?void 0:p.current)==null?void 0:I.id,\"aria-selected\":x,tabIndex:x?0:-1};return w({ourProps:B,theirProps:s,slot:N,defaultTag:ye,name:\"Tabs.Tab\"})}let Ee=\"div\";function Ae(e,n){let{selectedIndex:t}=M(\"Tab.Panels\"),o=U(n),s=F(()=>({selectedIndex:t}),[t]);return w({ourProps:{ref:o},theirProps:e,slot:s,defaultTag:Ee,name:\"Tabs.Panels\"})}let Re=\"div\",Le=Y.RenderStrategy|Y.Static;function De(e,n){var E,S,A,L;let t=Z(),{id:o=`headlessui-tabs-panel-${t}`,tabIndex:s=0,...r}=e,{selectedIndex:i,tabs:R,panels:b}=M(\"Tab.Panel\"),c=q(\"Tab.Panel\"),u=K(null),T=U(u,n);O(()=>c.registerPanel(u),[c,u]);let l=ee(\"panels\"),d=b.indexOf(u);d===-1&&(d=l);let y=d===i,m=F(()=>({selected:y}),[y]),x={ref:T,id:o,role:\"tabpanel\",\"aria-labelledby\":(S=(E=R[d])==null?void 0:E.current)==null?void 0:S.id,tabIndex:y?s:-1};return!y&&((A=r.unmount)==null||A)&&!((L=r.static)!=null&&L)?_.createElement(se,{as:\"span\",...x}):w({ourProps:x,theirProps:r,slot:m,defaultTag:Re,features:Le,visible:y,name:\"Tabs.Panel\"})}let Se=v(xe),Ie=v(me),Fe=v(ge),he=v(Ae),Me=v(De),rt=Object.assign(Se,{Group:Ie,List:Fe,Panels:he,Panel:Me});export{rt as Tab};\n","import React, { useEffect, useLayoutEffect, createContext, useContext, useMemo, useRef, createElement, useState, useCallback } from 'react';\n\n// Shared state between server components and client components\nconst noop = ()=>{};\n// Using noop() as the undefined value as undefined can be replaced\n// by something else. Prettier ignore and extra parentheses are necessary here\n// to ensure that tsc doesn't remove the __NOINLINE__ comment.\n// prettier-ignore\nconst UNDEFINED = /*#__NOINLINE__*/ noop();\nconst OBJECT = Object;\nconst isUndefined = (v)=>v === UNDEFINED;\nconst isFunction = (v)=>typeof v == 'function';\nconst mergeObjects = (a, b)=>({\n ...a,\n ...b\n });\nconst isPromiseLike = (x)=>isFunction(x.then);\n\n// use WeakMap to store the object->key mapping\n// so the objects can be garbage collected.\n// WeakMap uses a hashtable under the hood, so the lookup\n// complexity is almost O(1).\nconst table = new WeakMap();\n// counter of the key\nlet counter = 0;\n// A stable hash implementation that supports:\n// - Fast and ensures unique hash properties\n// - Handles unserializable values\n// - Handles object key ordering\n// - Generates short results\n//\n// This is not a serialization function, and the result is not guaranteed to be\n// parsable.\nconst stableHash = (arg)=>{\n const type = typeof arg;\n const constructor = arg && arg.constructor;\n const isDate = constructor == Date;\n let result;\n let index;\n if (OBJECT(arg) === arg && !isDate && constructor != RegExp) {\n // Object/function, not null/date/regexp. Use WeakMap to store the id first.\n // If it's already hashed, directly return the result.\n result = table.get(arg);\n if (result) return result;\n // Store the hash first for circular reference detection before entering the\n // recursive `stableHash` calls.\n // For other objects like set and map, we use this id directly as the hash.\n result = ++counter + '~';\n table.set(arg, result);\n if (constructor == Array) {\n // Array.\n result = '@';\n for(index = 0; index < arg.length; index++){\n result += stableHash(arg[index]) + ',';\n }\n table.set(arg, result);\n }\n if (constructor == OBJECT) {\n // Object, sort keys.\n result = '#';\n const keys = OBJECT.keys(arg).sort();\n while(!isUndefined(index = keys.pop())){\n if (!isUndefined(arg[index])) {\n result += index + ':' + stableHash(arg[index]) + ',';\n }\n }\n table.set(arg, result);\n }\n } else {\n result = isDate ? arg.toJSON() : type == 'symbol' ? arg.toString() : type == 'string' ? JSON.stringify(arg) : '' + arg;\n }\n return result;\n};\n\n// Global state used to deduplicate requests and store listeners\nconst SWRGlobalState = new WeakMap();\n\nconst EMPTY_CACHE = {};\nconst INITIAL_CACHE = {};\nconst STR_UNDEFINED = 'undefined';\n// NOTE: Use the function to guarantee it's re-evaluated between jsdom and node runtime for tests.\nconst isWindowDefined = typeof window != STR_UNDEFINED;\nconst isDocumentDefined = typeof document != STR_UNDEFINED;\nconst hasRequestAnimationFrame = ()=>isWindowDefined && typeof window['requestAnimationFrame'] != STR_UNDEFINED;\nconst createCacheHelper = (cache, key)=>{\n const state = SWRGlobalState.get(cache);\n return [\n // Getter\n ()=>!isUndefined(key) && cache.get(key) || EMPTY_CACHE,\n // Setter\n (info)=>{\n if (!isUndefined(key)) {\n const prev = cache.get(key);\n // Before writing to the store, we keep the value in the initial cache\n // if it's not there yet.\n if (!(key in INITIAL_CACHE)) {\n INITIAL_CACHE[key] = prev;\n }\n state[5](key, mergeObjects(prev, info), prev || EMPTY_CACHE);\n }\n },\n // Subscriber\n state[6],\n // Get server cache snapshot\n ()=>{\n if (!isUndefined(key)) {\n // If the cache was updated on the client, we return the stored initial value.\n if (key in INITIAL_CACHE) return INITIAL_CACHE[key];\n }\n // If we haven't done any client-side updates, we return the current value.\n return !isUndefined(key) && cache.get(key) || EMPTY_CACHE;\n }\n ];\n} // export { UNDEFINED, OBJECT, isUndefined, isFunction, mergeObjects, isPromiseLike }\n;\n\n/**\n * Due to the bug https://bugs.chromium.org/p/chromium/issues/detail?id=678075,\n * it's not reliable to detect if the browser is currently online or offline\n * based on `navigator.onLine`.\n * As a workaround, we always assume it's online on the first load, and change\n * the status upon `online` or `offline` events.\n */ let online = true;\nconst isOnline = ()=>online;\n// For node and React Native, `add/removeEventListener` doesn't exist on window.\nconst [onWindowEvent, offWindowEvent] = isWindowDefined && window.addEventListener ? [\n window.addEventListener.bind(window),\n window.removeEventListener.bind(window)\n] : [\n noop,\n noop\n];\nconst isVisible = ()=>{\n const visibilityState = isDocumentDefined && document.visibilityState;\n return isUndefined(visibilityState) || visibilityState !== 'hidden';\n};\nconst initFocus = (callback)=>{\n // focus revalidate\n if (isDocumentDefined) {\n document.addEventListener('visibilitychange', callback);\n }\n onWindowEvent('focus', callback);\n return ()=>{\n if (isDocumentDefined) {\n document.removeEventListener('visibilitychange', callback);\n }\n offWindowEvent('focus', callback);\n };\n};\nconst initReconnect = (callback)=>{\n // revalidate on reconnected\n const onOnline = ()=>{\n online = true;\n callback();\n };\n // nothing to revalidate, just update the status\n const onOffline = ()=>{\n online = false;\n };\n onWindowEvent('online', onOnline);\n onWindowEvent('offline', onOffline);\n return ()=>{\n offWindowEvent('online', onOnline);\n offWindowEvent('offline', onOffline);\n };\n};\nconst preset = {\n isOnline,\n isVisible\n};\nconst defaultConfigOptions = {\n initFocus,\n initReconnect\n};\n\nconst IS_REACT_LEGACY = !React.useId;\nconst IS_SERVER = !isWindowDefined || 'Deno' in window;\n// Polyfill requestAnimationFrame\nconst rAF = (f)=>hasRequestAnimationFrame() ? window['requestAnimationFrame'](f) : setTimeout(f, 1);\n// React currently throws a warning when using useLayoutEffect on the server.\n// To get around it, we can conditionally useEffect on the server (no-op) and\n// useLayoutEffect in the browser.\nconst useIsomorphicLayoutEffect = IS_SERVER ? useEffect : useLayoutEffect;\n// This assignment is to extend the Navigator type to use effectiveType.\nconst navigatorConnection = typeof navigator !== 'undefined' && navigator.connection;\n// Adjust the config based on slow connection status (<= 70Kbps).\nconst slowConnection = !IS_SERVER && navigatorConnection && ([\n 'slow-2g',\n '2g'\n].includes(navigatorConnection.effectiveType) || navigatorConnection.saveData);\n\nconst serialize = (key)=>{\n if (isFunction(key)) {\n try {\n key = key();\n } catch (err) {\n // dependencies not ready\n key = '';\n }\n }\n // Use the original key as the argument of fetcher. This can be a string or an\n // array of values.\n const args = key;\n // If key is not falsy, or not an empty array, hash it.\n key = typeof key == 'string' ? key : (Array.isArray(key) ? key.length : key) ? stableHash(key) : '';\n return [\n key,\n args\n ];\n};\n\n// Global timestamp.\nlet __timestamp = 0;\nconst getTimestamp = ()=>++__timestamp;\n\nconst FOCUS_EVENT = 0;\nconst RECONNECT_EVENT = 1;\nconst MUTATE_EVENT = 2;\nconst ERROR_REVALIDATE_EVENT = 3;\n\nvar constants = {\n __proto__: null,\n ERROR_REVALIDATE_EVENT: ERROR_REVALIDATE_EVENT,\n FOCUS_EVENT: FOCUS_EVENT,\n MUTATE_EVENT: MUTATE_EVENT,\n RECONNECT_EVENT: RECONNECT_EVENT\n};\n\nasync function internalMutate(...args) {\n const [cache, _key, _data, _opts] = args;\n // When passing as a boolean, it's explicitly used to disable/enable\n // revalidation.\n const options = mergeObjects({\n populateCache: true,\n throwOnError: true\n }, typeof _opts === 'boolean' ? {\n revalidate: _opts\n } : _opts || {});\n let populateCache = options.populateCache;\n const rollbackOnErrorOption = options.rollbackOnError;\n let optimisticData = options.optimisticData;\n const revalidate = options.revalidate !== false;\n const rollbackOnError = (error)=>{\n return typeof rollbackOnErrorOption === 'function' ? rollbackOnErrorOption(error) : rollbackOnErrorOption !== false;\n };\n const throwOnError = options.throwOnError;\n // If the second argument is a key filter, return the mutation results for all\n // filtered keys.\n if (isFunction(_key)) {\n const keyFilter = _key;\n const matchedKeys = [];\n const it = cache.keys();\n for (const key of it){\n if (// Skip the special useSWRInfinite and useSWRSubscription keys.\n !/^\\$(inf|sub)\\$/.test(key) && keyFilter(cache.get(key)._k)) {\n matchedKeys.push(key);\n }\n }\n return Promise.all(matchedKeys.map(mutateByKey));\n }\n return mutateByKey(_key);\n async function mutateByKey(_k) {\n // Serialize key\n const [key] = serialize(_k);\n if (!key) return;\n const [get, set] = createCacheHelper(cache, key);\n const [EVENT_REVALIDATORS, MUTATION, FETCH, PRELOAD] = SWRGlobalState.get(cache);\n const revalidators = EVENT_REVALIDATORS[key];\n const startRevalidate = ()=>{\n if (revalidate) {\n // Invalidate the key by deleting the concurrent request markers so new\n // requests will not be deduped.\n delete FETCH[key];\n delete PRELOAD[key];\n if (revalidators && revalidators[0]) {\n return revalidators[0](MUTATE_EVENT).then(()=>get().data);\n }\n }\n return get().data;\n };\n // If there is no new data provided, revalidate the key with current state.\n if (args.length < 3) {\n // Revalidate and broadcast state.\n return startRevalidate();\n }\n let data = _data;\n let error;\n // Update global timestamps.\n const beforeMutationTs = getTimestamp();\n MUTATION[key] = [\n beforeMutationTs,\n 0\n ];\n const hasOptimisticData = !isUndefined(optimisticData);\n const state = get();\n // `displayedData` is the current value on screen. It could be the optimistic value\n // that is going to be overridden by a `committedData`, or get reverted back.\n // `committedData` is the validated value that comes from a fetch or mutation.\n const displayedData = state.data;\n const currentData = state._c;\n const committedData = isUndefined(currentData) ? displayedData : currentData;\n // Do optimistic data update.\n if (hasOptimisticData) {\n optimisticData = isFunction(optimisticData) ? optimisticData(committedData, displayedData) : optimisticData;\n // When we set optimistic data, backup the current committedData data in `_c`.\n set({\n data: optimisticData,\n _c: committedData\n });\n }\n if (isFunction(data)) {\n // `data` is a function, call it passing current cache value.\n try {\n data = data(committedData);\n } catch (err) {\n // If it throws an error synchronously, we shouldn't update the cache.\n error = err;\n }\n }\n // `data` is a promise/thenable, resolve the final data first.\n if (data && isPromiseLike(data)) {\n // This means that the mutation is async, we need to check timestamps to\n // avoid race conditions.\n data = await data.catch((err)=>{\n error = err;\n });\n // Check if other mutations have occurred since we've started this mutation.\n // If there's a race we don't update cache or broadcast the change,\n // just return the data.\n if (beforeMutationTs !== MUTATION[key][0]) {\n if (error) throw error;\n return data;\n } else if (error && hasOptimisticData && rollbackOnError(error)) {\n // Rollback. Always populate the cache in this case but without\n // transforming the data.\n populateCache = true;\n data = committedData;\n // Reset data to be the latest committed data, and clear the `_c` value.\n set({\n data,\n _c: UNDEFINED\n });\n }\n }\n // If we should write back the cache after request.\n if (populateCache) {\n if (!error) {\n // Transform the result into data.\n if (isFunction(populateCache)) {\n data = populateCache(data, committedData);\n }\n // Only update cached data and reset the error if there's no error. Data can be `undefined` here.\n set({\n data,\n error: UNDEFINED,\n _c: UNDEFINED\n });\n }\n }\n // Reset the timestamp to mark the mutation has ended.\n MUTATION[key][1] = getTimestamp();\n // Update existing SWR Hooks' internal states:\n const res = await startRevalidate();\n // The mutation and revalidation are ended, we can clear it since the data is\n // not an optimistic value anymore.\n set({\n _c: UNDEFINED\n });\n // Throw error or return data\n if (error) {\n if (throwOnError) throw error;\n return;\n }\n return populateCache ? res : data;\n }\n}\n\nconst revalidateAllKeys = (revalidators, type)=>{\n for(const key in revalidators){\n if (revalidators[key][0]) revalidators[key][0](type);\n }\n};\nconst initCache = (provider, options)=>{\n // The global state for a specific provider will be used to deduplicate\n // requests and store listeners. As well as a mutate function that is bound to\n // the cache.\n // The provider's global state might be already initialized. Let's try to get the\n // global state associated with the provider first.\n if (!SWRGlobalState.has(provider)) {\n const opts = mergeObjects(defaultConfigOptions, options);\n // If there's no global state bound to the provider, create a new one with the\n // new mutate function.\n const EVENT_REVALIDATORS = {};\n const mutate = internalMutate.bind(UNDEFINED, provider);\n let unmount = noop;\n const subscriptions = {};\n const subscribe = (key, callback)=>{\n const subs = subscriptions[key] || [];\n subscriptions[key] = subs;\n subs.push(callback);\n return ()=>subs.splice(subs.indexOf(callback), 1);\n };\n const setter = (key, value, prev)=>{\n provider.set(key, value);\n const subs = subscriptions[key];\n if (subs) {\n for (const fn of subs){\n fn(value, prev);\n }\n }\n };\n const initProvider = ()=>{\n if (!SWRGlobalState.has(provider)) {\n // Update the state if it's new, or if the provider has been extended.\n SWRGlobalState.set(provider, [\n EVENT_REVALIDATORS,\n {},\n {},\n {},\n mutate,\n setter,\n subscribe\n ]);\n if (!IS_SERVER) {\n // When listening to the native events for auto revalidations,\n // we intentionally put a delay (setTimeout) here to make sure they are\n // fired after immediate JavaScript executions, which can be\n // React's state updates.\n // This avoids some unnecessary revalidations such as\n // https://github.com/vercel/swr/issues/1680.\n const releaseFocus = opts.initFocus(setTimeout.bind(UNDEFINED, revalidateAllKeys.bind(UNDEFINED, EVENT_REVALIDATORS, FOCUS_EVENT)));\n const releaseReconnect = opts.initReconnect(setTimeout.bind(UNDEFINED, revalidateAllKeys.bind(UNDEFINED, EVENT_REVALIDATORS, RECONNECT_EVENT)));\n unmount = ()=>{\n releaseFocus && releaseFocus();\n releaseReconnect && releaseReconnect();\n // When un-mounting, we need to remove the cache provider from the state\n // storage too because it's a side-effect. Otherwise, when re-mounting we\n // will not re-register those event listeners.\n SWRGlobalState.delete(provider);\n };\n }\n }\n };\n initProvider();\n // This is a new provider, we need to initialize it and setup DOM events\n // listeners for `focus` and `reconnect` actions.\n // We might want to inject an extra layer on top of `provider` in the future,\n // such as key serialization, auto GC, etc.\n // For now, it's just a `Map` interface without any modifications.\n return [\n provider,\n mutate,\n initProvider,\n unmount\n ];\n }\n return [\n provider,\n SWRGlobalState.get(provider)[4]\n ];\n};\n\n// error retry\nconst onErrorRetry = (_, __, config, revalidate, opts)=>{\n const maxRetryCount = config.errorRetryCount;\n const currentRetryCount = opts.retryCount;\n // Exponential backoff\n const timeout = ~~((Math.random() + 0.5) * (1 << (currentRetryCount < 8 ? currentRetryCount : 8))) * config.errorRetryInterval;\n if (!isUndefined(maxRetryCount) && currentRetryCount > maxRetryCount) {\n return;\n }\n setTimeout(revalidate, timeout, opts);\n};\nconst compare = (currentData, newData)=>stableHash(currentData) == stableHash(newData);\n// Default cache provider\nconst [cache, mutate] = initCache(new Map());\n// Default config\nconst defaultConfig = mergeObjects({\n // events\n onLoadingSlow: noop,\n onSuccess: noop,\n onError: noop,\n onErrorRetry,\n onDiscarded: noop,\n // switches\n revalidateOnFocus: true,\n revalidateOnReconnect: true,\n revalidateIfStale: true,\n shouldRetryOnError: true,\n // timeouts\n errorRetryInterval: slowConnection ? 10000 : 5000,\n focusThrottleInterval: 5 * 1000,\n dedupingInterval: 2 * 1000,\n loadingTimeout: slowConnection ? 5000 : 3000,\n // providers\n compare,\n isPaused: ()=>false,\n cache,\n mutate,\n fallback: {}\n}, // use web preset by default\npreset);\n\nconst mergeConfigs = (a, b)=>{\n // Need to create a new object to avoid mutating the original here.\n const v = mergeObjects(a, b);\n // If two configs are provided, merge their `use` and `fallback` options.\n if (b) {\n const { use: u1 , fallback: f1 } = a;\n const { use: u2 , fallback: f2 } = b;\n if (u1 && u2) {\n v.use = u1.concat(u2);\n }\n if (f1 && f2) {\n v.fallback = mergeObjects(f1, f2);\n }\n }\n return v;\n};\n\nconst SWRConfigContext = createContext({});\nconst SWRConfig = (props)=>{\n const { value } = props;\n const parentConfig = useContext(SWRConfigContext);\n const isFunctionalConfig = isFunction(value);\n const config = useMemo(()=>isFunctionalConfig ? value(parentConfig) : value, [\n isFunctionalConfig,\n parentConfig,\n value\n ]);\n // Extend parent context values and middleware.\n const extendedConfig = useMemo(()=>isFunctionalConfig ? config : mergeConfigs(parentConfig, config), [\n isFunctionalConfig,\n parentConfig,\n config\n ]);\n // Should not use the inherited provider.\n const provider = config && config.provider;\n // initialize the cache only on first access.\n const cacheContextRef = useRef(UNDEFINED);\n if (provider && !cacheContextRef.current) {\n cacheContextRef.current = initCache(provider(extendedConfig.cache || cache), config);\n }\n const cacheContext = cacheContextRef.current;\n // Override the cache if a new provider is given.\n if (cacheContext) {\n extendedConfig.cache = cacheContext[0];\n extendedConfig.mutate = cacheContext[1];\n }\n // Unsubscribe events.\n useIsomorphicLayoutEffect(()=>{\n if (cacheContext) {\n cacheContext[2] && cacheContext[2]();\n return cacheContext[3];\n }\n }, []);\n return createElement(SWRConfigContext.Provider, mergeObjects(props, {\n value: extendedConfig\n }));\n};\n\n// @ts-expect-error\nconst enableDevtools = isWindowDefined && window.__SWR_DEVTOOLS_USE__;\nconst use = enableDevtools ? window.__SWR_DEVTOOLS_USE__ : [];\nconst setupDevTools = ()=>{\n if (enableDevtools) {\n // @ts-expect-error\n window.__SWR_DEVTOOLS_REACT__ = React;\n }\n};\n\nconst normalize = (args)=>{\n return isFunction(args[1]) ? [\n args[0],\n args[1],\n args[2] || {}\n ] : [\n args[0],\n null,\n (args[1] === null ? args[2] : args[1]) || {}\n ];\n};\n\nconst useSWRConfig = ()=>{\n return mergeObjects(defaultConfig, useContext(SWRConfigContext));\n};\n\nconst preload = (key_, fetcher)=>{\n const [key, fnArg] = serialize(key_);\n const [, , , PRELOAD] = SWRGlobalState.get(cache);\n // Prevent preload to be called multiple times before used.\n if (PRELOAD[key]) return PRELOAD[key];\n const req = fetcher(fnArg);\n PRELOAD[key] = req;\n return req;\n};\nconst middleware = (useSWRNext)=>(key_, fetcher_, config)=>{\n // fetcher might be a sync function, so this should not be an async function\n const fetcher = fetcher_ && ((...args)=>{\n const [key] = serialize(key_);\n const [, , , PRELOAD] = SWRGlobalState.get(cache);\n const req = PRELOAD[key];\n if (isUndefined(req)) return fetcher_(...args);\n delete PRELOAD[key];\n return req;\n });\n return useSWRNext(key_, fetcher, config);\n };\n\nconst BUILT_IN_MIDDLEWARE = use.concat(middleware);\n\n// It's tricky to pass generic types as parameters, so we just directly override\n// the types here.\nconst withArgs = (hook)=>{\n return function useSWRArgs(...args) {\n // Get the default and inherited configuration.\n const fallbackConfig = useSWRConfig();\n // Normalize arguments.\n const [key, fn, _config] = normalize(args);\n // Merge configurations.\n const config = mergeConfigs(fallbackConfig, _config);\n // Apply middleware\n let next = hook;\n const { use } = config;\n const middleware = (use || []).concat(BUILT_IN_MIDDLEWARE);\n for(let i = middleware.length; i--;){\n next = middleware[i](next);\n }\n return next(key, fn || config.fetcher || null, config);\n };\n};\n\n/**\n * An implementation of state with dependency-tracking.\n */ const useStateWithDeps = (state)=>{\n const rerender = useState({})[1];\n const unmountedRef = useRef(false);\n const stateRef = useRef(state);\n // If a state property (data, error, or isValidating) is accessed by the render\n // function, we mark the property as a dependency so if it is updated again\n // in the future, we trigger a rerender.\n // This is also known as dependency-tracking.\n const stateDependenciesRef = useRef({\n data: false,\n error: false,\n isValidating: false\n });\n /**\n * @param payload To change stateRef, pass the values explicitly to setState:\n * @example\n * ```js\n * setState({\n * isValidating: false\n * data: newData // set data to newData\n * error: undefined // set error to undefined\n * })\n *\n * setState({\n * isValidating: false\n * data: undefined // set data to undefined\n * error: err // set error to err\n * })\n * ```\n */ const setState = useCallback((payload)=>{\n let shouldRerender = false;\n const currentState = stateRef.current;\n for(const _ in payload){\n const k = _;\n // If the property has changed, update the state and mark rerender as\n // needed.\n if (currentState[k] !== payload[k]) {\n currentState[k] = payload[k];\n // If the property is accessed by the component, a rerender should be\n // triggered.\n if (stateDependenciesRef.current[k]) {\n shouldRerender = true;\n }\n }\n }\n if (shouldRerender && !unmountedRef.current) {\n if (IS_REACT_LEGACY) {\n rerender({});\n } else {\n React.startTransition(()=>rerender({}));\n }\n }\n }, [\n rerender\n ]);\n useIsomorphicLayoutEffect(()=>{\n unmountedRef.current = false;\n return ()=>{\n unmountedRef.current = true;\n };\n });\n return [\n stateRef,\n stateDependenciesRef.current,\n setState\n ];\n};\n\n// Add a callback function to a list of keyed callback functions and return\n// the unsubscribe function.\nconst subscribeCallback = (key, callbacks, callback)=>{\n const keyedRevalidators = callbacks[key] || (callbacks[key] = []);\n keyedRevalidators.push(callback);\n return ()=>{\n const index = keyedRevalidators.indexOf(callback);\n if (index >= 0) {\n // O(1): faster than splice\n keyedRevalidators[index] = keyedRevalidators[keyedRevalidators.length - 1];\n keyedRevalidators.pop();\n }\n };\n};\n\n// Create a custom hook with a middleware\nconst withMiddleware = (useSWR, middleware)=>{\n return (...args)=>{\n const [key, fn, config] = normalize(args);\n const uses = (config.use || []).concat(middleware);\n return useSWR(key, fn, {\n ...config,\n use: uses\n });\n };\n};\n\nsetupDevTools();\n\nexport { IS_REACT_LEGACY, IS_SERVER, OBJECT, SWRConfig, SWRGlobalState, UNDEFINED, cache, compare, createCacheHelper, defaultConfig, defaultConfigOptions, getTimestamp, hasRequestAnimationFrame, initCache, internalMutate, isDocumentDefined, isFunction, isPromiseLike, isUndefined, isWindowDefined, mergeConfigs, mergeObjects, mutate, noop, normalize, preload, preset, rAF, constants as revalidateEvents, serialize, slowConnection, stableHash, subscribeCallback, useIsomorphicLayoutEffect, useSWRConfig, useStateWithDeps, withArgs, withMiddleware };\n","import ReactExports, { useRef, useMemo, useCallback, useDebugValue } from 'react';\nimport { useSyncExternalStore } from 'use-sync-external-store/shim/index.js';\nimport { serialize, OBJECT, SWRConfig as SWRConfig$1, defaultConfig, withArgs, SWRGlobalState, createCacheHelper, isUndefined, getTimestamp, UNDEFINED, isFunction, revalidateEvents, internalMutate, useIsomorphicLayoutEffect, subscribeCallback, IS_SERVER, rAF, IS_REACT_LEGACY, mergeObjects } from 'swr/_internal';\nexport { mutate, preload, useSWRConfig } from 'swr/_internal';\n\nconst unstable_serialize = (key)=>serialize(key)[0];\n\n/// \nconst use = ReactExports.use || ((promise)=>{\n if (promise.status === 'pending') {\n throw promise;\n } else if (promise.status === 'fulfilled') {\n return promise.value;\n } else if (promise.status === 'rejected') {\n throw promise.reason;\n } else {\n promise.status = 'pending';\n promise.then((v)=>{\n promise.status = 'fulfilled';\n promise.value = v;\n }, (e)=>{\n promise.status = 'rejected';\n promise.reason = e;\n });\n throw promise;\n }\n});\nconst WITH_DEDUPE = {\n dedupe: true\n};\nconst useSWRHandler = (_key, fetcher, config)=>{\n const { cache , compare , suspense , fallbackData , revalidateOnMount , revalidateIfStale , refreshInterval , refreshWhenHidden , refreshWhenOffline , keepPreviousData } = config;\n const [EVENT_REVALIDATORS, MUTATION, FETCH, PRELOAD] = SWRGlobalState.get(cache);\n // `key` is the identifier of the SWR internal state,\n // `fnArg` is the argument/arguments parsed from the key, which will be passed\n // to the fetcher.\n // All of them are derived from `_key`.\n const [key, fnArg] = serialize(_key);\n // If it's the initial render of this hook.\n const initialMountedRef = useRef(false);\n // If the hook is unmounted already. This will be used to prevent some effects\n // to be called after unmounting.\n const unmountedRef = useRef(false);\n // Refs to keep the key and config.\n const keyRef = useRef(key);\n const fetcherRef = useRef(fetcher);\n const configRef = useRef(config);\n const getConfig = ()=>configRef.current;\n const isActive = ()=>getConfig().isVisible() && getConfig().isOnline();\n const [getCache, setCache, subscribeCache, getInitialCache] = createCacheHelper(cache, key);\n const stateDependencies = useRef({}).current;\n const fallback = isUndefined(fallbackData) ? config.fallback[key] : fallbackData;\n const isEqual = (prev, current)=>{\n for(const _ in stateDependencies){\n const t = _;\n if (t === 'data') {\n if (!compare(prev[t], current[t])) {\n if (!isUndefined(prev[t])) {\n return false;\n }\n if (!compare(returnedData, current[t])) {\n return false;\n }\n }\n } else {\n if (current[t] !== prev[t]) {\n return false;\n }\n }\n }\n return true;\n };\n const getSnapshot = useMemo(()=>{\n const shouldStartRequest = (()=>{\n if (!key) return false;\n if (!fetcher) return false;\n // If `revalidateOnMount` is set, we take the value directly.\n if (!isUndefined(revalidateOnMount)) return revalidateOnMount;\n // If it's paused, we skip revalidation.\n if (getConfig().isPaused()) return false;\n if (suspense) return false;\n if (!isUndefined(revalidateIfStale)) return revalidateIfStale;\n return true;\n })();\n // Get the cache and merge it with expected states.\n const getSelectedCache = (state)=>{\n // We only select the needed fields from the state.\n const snapshot = mergeObjects(state);\n delete snapshot._k;\n if (!shouldStartRequest) {\n return snapshot;\n }\n return {\n isValidating: true,\n isLoading: true,\n ...snapshot\n };\n };\n const cachedData = getCache();\n const initialData = getInitialCache();\n const clientSnapshot = getSelectedCache(cachedData);\n const serverSnapshot = cachedData === initialData ? clientSnapshot : getSelectedCache(initialData);\n // To make sure that we are returning the same object reference to avoid\n // unnecessary re-renders, we keep the previous snapshot and use deep\n // comparison to check if we need to return a new one.\n let memorizedSnapshot = clientSnapshot;\n return [\n ()=>{\n const newSnapshot = getSelectedCache(getCache());\n const compareResult = isEqual(newSnapshot, memorizedSnapshot);\n if (compareResult) {\n // Mentally, we should always return the `memorizedSnapshot` here\n // as there's no change between the new and old snapshots.\n // However, since the `isEqual` function only compares selected fields,\n // the values of the unselected fields might be changed. That's\n // simply because we didn't track them.\n // To support the case in https://github.com/vercel/swr/pull/2576,\n // we need to update these fields in the `memorizedSnapshot` too\n // with direct mutations to ensure the snapshot is always up-to-date\n // even for the unselected fields, but only trigger re-renders when\n // the selected fields are changed.\n memorizedSnapshot.data = newSnapshot.data;\n memorizedSnapshot.isLoading = newSnapshot.isLoading;\n memorizedSnapshot.isValidating = newSnapshot.isValidating;\n memorizedSnapshot.error = newSnapshot.error;\n return memorizedSnapshot;\n } else {\n memorizedSnapshot = newSnapshot;\n return newSnapshot;\n }\n },\n ()=>serverSnapshot\n ];\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n cache,\n key\n ]);\n // Get the current state that SWR should return.\n const cached = useSyncExternalStore(useCallback((callback)=>subscribeCache(key, (current, prev)=>{\n if (!isEqual(prev, current)) callback();\n }), // eslint-disable-next-line react-hooks/exhaustive-deps\n [\n cache,\n key\n ]), getSnapshot[0], getSnapshot[1]);\n const isInitialMount = !initialMountedRef.current;\n const hasRevalidator = EVENT_REVALIDATORS[key] && EVENT_REVALIDATORS[key].length > 0;\n const cachedData = cached.data;\n const data = isUndefined(cachedData) ? fallback : cachedData;\n const error = cached.error;\n // Use a ref to store previously returned data. Use the initial data as its initial value.\n const laggyDataRef = useRef(data);\n const returnedData = keepPreviousData ? isUndefined(cachedData) ? laggyDataRef.current : cachedData : data;\n // - Suspense mode and there's stale data for the initial render.\n // - Not suspense mode and there is no fallback data and `revalidateIfStale` is enabled.\n // - `revalidateIfStale` is enabled but `data` is not defined.\n const shouldDoInitialRevalidation = (()=>{\n // if a key already has revalidators and also has error, we should not trigger revalidation\n if (hasRevalidator && !isUndefined(error)) return false;\n // If `revalidateOnMount` is set, we take the value directly.\n if (isInitialMount && !isUndefined(revalidateOnMount)) return revalidateOnMount;\n // If it's paused, we skip revalidation.\n if (getConfig().isPaused()) return false;\n // Under suspense mode, it will always fetch on render if there is no\n // stale data so no need to revalidate immediately mount it again.\n // If data exists, only revalidate if `revalidateIfStale` is true.\n if (suspense) return isUndefined(data) ? false : revalidateIfStale;\n // If there is no stale data, we need to revalidate when mount;\n // If `revalidateIfStale` is set to true, we will always revalidate.\n return isUndefined(data) || revalidateIfStale;\n })();\n // Resolve the default validating state:\n // If it's able to validate, and it should revalidate when mount, this will be true.\n const defaultValidatingState = !!(key && fetcher && isInitialMount && shouldDoInitialRevalidation);\n const isValidating = isUndefined(cached.isValidating) ? defaultValidatingState : cached.isValidating;\n const isLoading = isUndefined(cached.isLoading) ? defaultValidatingState : cached.isLoading;\n // The revalidation function is a carefully crafted wrapper of the original\n // `fetcher`, to correctly handle the many edge cases.\n const revalidate = useCallback(async (revalidateOpts)=>{\n const currentFetcher = fetcherRef.current;\n if (!key || !currentFetcher || unmountedRef.current || getConfig().isPaused()) {\n return false;\n }\n let newData;\n let startAt;\n let loading = true;\n const opts = revalidateOpts || {};\n // If there is no ongoing concurrent request, or `dedupe` is not set, a\n // new request should be initiated.\n const shouldStartNewRequest = !FETCH[key] || !opts.dedupe;\n /*\n For React 17\n Do unmount check for calls:\n If key has changed during the revalidation, or the component has been\n unmounted, old dispatch and old event callbacks should not take any\n effect\n\n For React 18\n only check if key has changed\n https://github.com/reactwg/react-18/discussions/82\n */ const callbackSafeguard = ()=>{\n if (IS_REACT_LEGACY) {\n return !unmountedRef.current && key === keyRef.current && initialMountedRef.current;\n }\n return key === keyRef.current;\n };\n // The final state object when the request finishes.\n const finalState = {\n isValidating: false,\n isLoading: false\n };\n const finishRequestAndUpdateState = ()=>{\n setCache(finalState);\n };\n const cleanupState = ()=>{\n // Check if it's still the same request before deleting it.\n const requestInfo = FETCH[key];\n if (requestInfo && requestInfo[1] === startAt) {\n delete FETCH[key];\n }\n };\n // Start fetching. Change the `isValidating` state, update the cache.\n const initialState = {\n isValidating: true\n };\n // It is in the `isLoading` state, if and only if there is no cached data.\n // This bypasses fallback data and laggy data.\n if (isUndefined(getCache().data)) {\n initialState.isLoading = true;\n }\n try {\n if (shouldStartNewRequest) {\n setCache(initialState);\n // If no cache is being rendered currently (it shows a blank page),\n // we trigger the loading slow event.\n if (config.loadingTimeout && isUndefined(getCache().data)) {\n setTimeout(()=>{\n if (loading && callbackSafeguard()) {\n getConfig().onLoadingSlow(key, config);\n }\n }, config.loadingTimeout);\n }\n // Start the request and save the timestamp.\n // Key must be truthy if entering here.\n FETCH[key] = [\n currentFetcher(fnArg),\n getTimestamp()\n ];\n }\n [newData, startAt] = FETCH[key];\n newData = await newData;\n if (shouldStartNewRequest) {\n // If the request isn't interrupted, clean it up after the\n // deduplication interval.\n setTimeout(cleanupState, config.dedupingInterval);\n }\n // If there're other ongoing request(s), started after the current one,\n // we need to ignore the current one to avoid possible race conditions:\n // req1------------------>res1 (current one)\n // req2---------------->res2\n // the request that fired later will always be kept.\n // The timestamp maybe be `undefined` or a number\n if (!FETCH[key] || FETCH[key][1] !== startAt) {\n if (shouldStartNewRequest) {\n if (callbackSafeguard()) {\n getConfig().onDiscarded(key);\n }\n }\n return false;\n }\n // Clear error.\n finalState.error = UNDEFINED;\n // If there're other mutations(s), that overlapped with the current revalidation:\n // case 1:\n // req------------------>res\n // mutate------>end\n // case 2:\n // req------------>res\n // mutate------>end\n // case 3:\n // req------------------>res\n // mutate-------...---------->\n // we have to ignore the revalidation result (res) because it's no longer fresh.\n // meanwhile, a new revalidation should be triggered when the mutation ends.\n const mutationInfo = MUTATION[key];\n if (!isUndefined(mutationInfo) && // case 1\n (startAt <= mutationInfo[0] || // case 2\n startAt <= mutationInfo[1] || // case 3\n mutationInfo[1] === 0)) {\n finishRequestAndUpdateState();\n if (shouldStartNewRequest) {\n if (callbackSafeguard()) {\n getConfig().onDiscarded(key);\n }\n }\n return false;\n }\n // Deep compare with the latest state to avoid extra re-renders.\n // For local state, compare and assign.\n const cacheData = getCache().data;\n // Since the compare fn could be custom fn\n // cacheData might be different from newData even when compare fn returns True\n finalState.data = compare(cacheData, newData) ? cacheData : newData;\n // Trigger the successful callback if it's the original request.\n if (shouldStartNewRequest) {\n if (callbackSafeguard()) {\n getConfig().onSuccess(newData, key, config);\n }\n }\n } catch (err) {\n cleanupState();\n const currentConfig = getConfig();\n const { shouldRetryOnError } = currentConfig;\n // Not paused, we continue handling the error. Otherwise, discard it.\n if (!currentConfig.isPaused()) {\n // Get a new error, don't use deep comparison for errors.\n finalState.error = err;\n // Error event and retry logic. Only for the actual request, not\n // deduped ones.\n if (shouldStartNewRequest && callbackSafeguard()) {\n currentConfig.onError(err, key, currentConfig);\n if (shouldRetryOnError === true || isFunction(shouldRetryOnError) && shouldRetryOnError(err)) {\n if (isActive()) {\n // If it's inactive, stop. It will auto-revalidate when\n // refocusing or reconnecting.\n // When retrying, deduplication is always enabled.\n currentConfig.onErrorRetry(err, key, currentConfig, (_opts)=>{\n const revalidators = EVENT_REVALIDATORS[key];\n if (revalidators && revalidators[0]) {\n revalidators[0](revalidateEvents.ERROR_REVALIDATE_EVENT, _opts);\n }\n }, {\n retryCount: (opts.retryCount || 0) + 1,\n dedupe: true\n });\n }\n }\n }\n }\n }\n // Mark loading as stopped.\n loading = false;\n // Update the current hook's state.\n finishRequestAndUpdateState();\n return true;\n }, // `setState` is immutable, and `eventsCallback`, `fnArg`, and\n // `keyValidating` are depending on `key`, so we can exclude them from\n // the deps array.\n //\n // FIXME:\n // `fn` and `config` might be changed during the lifecycle,\n // but they might be changed every render like this.\n // `useSWR('key', () => fetch('/api/'), { suspense: true })`\n // So we omit the values from the deps array\n // even though it might cause unexpected behaviors.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [\n key,\n cache\n ]);\n // Similar to the global mutate but bound to the current cache and key.\n // `cache` isn't allowed to change during the lifecycle.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const boundMutate = useCallback(// Use callback to make sure `keyRef.current` returns latest result every time\n (...args)=>{\n return internalMutate(cache, keyRef.current, ...args);\n }, // eslint-disable-next-line react-hooks/exhaustive-deps\n []);\n // The logic for updating refs.\n useIsomorphicLayoutEffect(()=>{\n fetcherRef.current = fetcher;\n configRef.current = config;\n // Handle laggy data updates. If there's cached data of the current key,\n // it'll be the correct reference.\n if (!isUndefined(cachedData)) {\n laggyDataRef.current = cachedData;\n }\n });\n // After mounted or key changed.\n useIsomorphicLayoutEffect(()=>{\n if (!key) return;\n const softRevalidate = revalidate.bind(UNDEFINED, WITH_DEDUPE);\n // Expose revalidators to global event listeners. So we can trigger\n // revalidation from the outside.\n let nextFocusRevalidatedAt = 0;\n const onRevalidate = (type, opts = {})=>{\n if (type == revalidateEvents.FOCUS_EVENT) {\n const now = Date.now();\n if (getConfig().revalidateOnFocus && now > nextFocusRevalidatedAt && isActive()) {\n nextFocusRevalidatedAt = now + getConfig().focusThrottleInterval;\n softRevalidate();\n }\n } else if (type == revalidateEvents.RECONNECT_EVENT) {\n if (getConfig().revalidateOnReconnect && isActive()) {\n softRevalidate();\n }\n } else if (type == revalidateEvents.MUTATE_EVENT) {\n return revalidate();\n } else if (type == revalidateEvents.ERROR_REVALIDATE_EVENT) {\n return revalidate(opts);\n }\n return;\n };\n const unsubEvents = subscribeCallback(key, EVENT_REVALIDATORS, onRevalidate);\n // Mark the component as mounted and update corresponding refs.\n unmountedRef.current = false;\n keyRef.current = key;\n initialMountedRef.current = true;\n // Keep the original key in the cache.\n setCache({\n _k: fnArg\n });\n // Trigger a revalidation\n if (shouldDoInitialRevalidation) {\n if (isUndefined(data) || IS_SERVER) {\n // Revalidate immediately.\n softRevalidate();\n } else {\n // Delay the revalidate if we have data to return so we won't block\n // rendering.\n rAF(softRevalidate);\n }\n }\n return ()=>{\n // Mark it as unmounted.\n unmountedRef.current = true;\n unsubEvents();\n };\n }, [\n key\n ]);\n // Polling\n useIsomorphicLayoutEffect(()=>{\n let timer;\n function next() {\n // Use the passed interval\n // ...or invoke the function with the updated data to get the interval\n const interval = isFunction(refreshInterval) ? refreshInterval(getCache().data) : refreshInterval;\n // We only start the next interval if `refreshInterval` is not 0, and:\n // - `force` is true, which is the start of polling\n // - or `timer` is not 0, which means the effect wasn't canceled\n if (interval && timer !== -1) {\n timer = setTimeout(execute, interval);\n }\n }\n function execute() {\n // Check if it's OK to execute:\n // Only revalidate when the page is visible, online, and not errored.\n if (!getCache().error && (refreshWhenHidden || getConfig().isVisible()) && (refreshWhenOffline || getConfig().isOnline())) {\n revalidate(WITH_DEDUPE).then(next);\n } else {\n // Schedule the next interval to check again.\n next();\n }\n }\n next();\n return ()=>{\n if (timer) {\n clearTimeout(timer);\n timer = -1;\n }\n };\n }, [\n refreshInterval,\n refreshWhenHidden,\n refreshWhenOffline,\n key\n ]);\n // Display debug info in React DevTools.\n useDebugValue(returnedData);\n // In Suspense mode, we can't return the empty `data` state.\n // If there is an `error`, the `error` needs to be thrown to the error boundary.\n // If there is no `error`, the `revalidation` promise needs to be thrown to\n // the suspense boundary.\n if (suspense && isUndefined(data) && key) {\n // SWR should throw when trying to use Suspense on the server with React 18,\n // without providing any initial data. See:\n // https://github.com/vercel/swr/issues/1832\n if (!IS_REACT_LEGACY && IS_SERVER) {\n throw new Error('Fallback data is required when using suspense in SSR.');\n }\n // Always update fetcher and config refs even with the Suspense mode.\n fetcherRef.current = fetcher;\n configRef.current = config;\n unmountedRef.current = false;\n const req = PRELOAD[key];\n if (!isUndefined(req)) {\n const promise = boundMutate(req);\n use(promise);\n }\n if (isUndefined(error)) {\n const promise = revalidate(WITH_DEDUPE);\n if (!isUndefined(returnedData)) {\n promise.status = 'fulfilled';\n promise.value = true;\n }\n use(promise);\n } else {\n throw error;\n }\n }\n return {\n mutate: boundMutate,\n get data () {\n stateDependencies.data = true;\n return returnedData;\n },\n get error () {\n stateDependencies.error = true;\n return error;\n },\n get isValidating () {\n stateDependencies.isValidating = true;\n return isValidating;\n },\n get isLoading () {\n stateDependencies.isLoading = true;\n return isLoading;\n }\n };\n};\nconst SWRConfig = OBJECT.defineProperty(SWRConfig$1, 'defaultValue', {\n value: defaultConfig\n});\n/**\n * A hook to fetch data.\n *\n * @link https://swr.vercel.app\n * @example\n * ```jsx\n * import useSWR from 'swr'\n * function Profile() {\n * const { data, error } = useSWR('/api/user', fetcher)\n * if (error) return