{"ast":null,"code":"import _slicedToArray from \"C:/Users/user/Desktop/03portreact/node_modules/@babel/runtime/helpers/esm/slicedToArray.js\";\nimport { Children as $iqq3r$Children, cloneElement as $iqq3r$cloneElement, useState as $iqq3r$useState, useRef as $iqq3r$useRef, useEffect as $iqq3r$useEffect, useCallback as $iqq3r$useCallback, useReducer as $iqq3r$useReducer } from \"react\";\nimport { flushSync as $iqq3r$flushSync } from \"react-dom\";\nimport { useComposedRefs as $iqq3r$useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { useLayoutEffect as $iqq3r$useLayoutEffect } from \"@radix-ui/react-use-layout-effect\";\nfunction $fe963b355347cc68$export$3e6543de14f8614f(initialState, machine) {\n  return $iqq3r$useReducer(function (state, event) {\n    var nextState = machine[state][event];\n    return nextState !== null && nextState !== void 0 ? nextState : state;\n  }, initialState);\n}\nvar $921a889cee6df7e8$export$99c2b779aa4e8b8b = function $921a889cee6df7e8$export$99c2b779aa4e8b8b(props) {\n  var present = props.present,\n    children = props.children;\n  var presence = $921a889cee6df7e8$var$usePresence(present);\n  var child = typeof children === 'function' ? children({\n    present: presence.isPresent\n  }) : $iqq3r$Children.only(children);\n  var ref = $iqq3r$useComposedRefs(presence.ref, child.ref);\n  var forceMount = typeof children === 'function';\n  return forceMount || presence.isPresent ? /*#__PURE__*/$iqq3r$cloneElement(child, {\n    ref: ref\n  }) : null;\n};\n$921a889cee6df7e8$export$99c2b779aa4e8b8b.displayName = 'Presence';\n/* -------------------------------------------------------------------------------------------------\n * usePresence\n * -----------------------------------------------------------------------------------------------*/\nfunction $921a889cee6df7e8$var$usePresence(present) {\n  var _$iqq3r$useState = $iqq3r$useState(),\n    _$iqq3r$useState2 = _slicedToArray(_$iqq3r$useState, 2),\n    node1 = _$iqq3r$useState2[0],\n    setNode = _$iqq3r$useState2[1];\n  var stylesRef = $iqq3r$useRef({});\n  var prevPresentRef = $iqq3r$useRef(present);\n  var prevAnimationNameRef = $iqq3r$useRef('none');\n  var initialState = present ? 'mounted' : 'unmounted';\n  var _$fe963b355347cc68$ex = $fe963b355347cc68$export$3e6543de14f8614f(initialState, {\n      mounted: {\n        UNMOUNT: 'unmounted',\n        ANIMATION_OUT: 'unmountSuspended'\n      },\n      unmountSuspended: {\n        MOUNT: 'mounted',\n        ANIMATION_END: 'unmounted'\n      },\n      unmounted: {\n        MOUNT: 'mounted'\n      }\n    }),\n    _$fe963b355347cc68$ex2 = _slicedToArray(_$fe963b355347cc68$ex, 2),\n    state = _$fe963b355347cc68$ex2[0],\n    send = _$fe963b355347cc68$ex2[1];\n  $iqq3r$useEffect(function () {\n    var currentAnimationName = $921a889cee6df7e8$var$getAnimationName(stylesRef.current);\n    prevAnimationNameRef.current = state === 'mounted' ? currentAnimationName : 'none';\n  }, [state]);\n  $iqq3r$useLayoutEffect(function () {\n    var styles = stylesRef.current;\n    var wasPresent = prevPresentRef.current;\n    var hasPresentChanged = wasPresent !== present;\n    if (hasPresentChanged) {\n      var prevAnimationName = prevAnimationNameRef.current;\n      var currentAnimationName = $921a889cee6df7e8$var$getAnimationName(styles);\n      if (present) send('MOUNT');else if (currentAnimationName === 'none' || (styles === null || styles === void 0 ? void 0 : styles.display) === 'none')\n        // If there is no exit animation or the element is hidden, animations won't run\n        // so we unmount instantly\n        send('UNMOUNT');else {\n        /**\n        * When `present` changes to `false`, we check changes to animation-name to\n        * determine whether an animation has started. We chose this approach (reading\n        * computed styles) because there is no `animationrun` event and `animationstart`\n        * fires after `animation-delay` has expired which would be too late.\n        */\n        var isAnimating = prevAnimationName !== currentAnimationName;\n        if (wasPresent && isAnimating) send('ANIMATION_OUT');else send('UNMOUNT');\n      }\n      prevPresentRef.current = present;\n    }\n  }, [present, send]);\n  $iqq3r$useLayoutEffect(function () {\n    if (node1) {\n      /**\n      * Triggering an ANIMATION_OUT during an ANIMATION_IN will fire an `animationcancel`\n      * event for ANIMATION_IN after we have entered `unmountSuspended` state. So, we\n      * make sure we only trigger ANIMATION_END for the currently active animation.\n      */\n      var handleAnimationEnd = function handleAnimationEnd(event) {\n        var currentAnimationName = $921a889cee6df7e8$var$getAnimationName(stylesRef.current);\n        var isCurrentAnimation = currentAnimationName.includes(event.animationName);\n        if (event.target === node1 && isCurrentAnimation)\n          // With React 18 concurrency this update is applied\n          // a frame after the animation ends, creating a flash of visible content.\n          // By manually flushing we ensure they sync within a frame, removing the flash.\n          $iqq3r$flushSync(function () {\n            return send('ANIMATION_END');\n          });\n      };\n      var handleAnimationStart = function handleAnimationStart(event) {\n        if (event.target === node1)\n          // if animation occurred, store its name as the previous animation.\n          prevAnimationNameRef.current = $921a889cee6df7e8$var$getAnimationName(stylesRef.current);\n      };\n      node1.addEventListener('animationstart', handleAnimationStart);\n      node1.addEventListener('animationcancel', handleAnimationEnd);\n      node1.addEventListener('animationend', handleAnimationEnd);\n      return function () {\n        node1.removeEventListener('animationstart', handleAnimationStart);\n        node1.removeEventListener('animationcancel', handleAnimationEnd);\n        node1.removeEventListener('animationend', handleAnimationEnd);\n      };\n    } else\n      // Transition to the unmounted state if the node is removed prematurely.\n      // We avoid doing so during cleanup as the node may change but still exist.\n      send('ANIMATION_END');\n  }, [node1, send]);\n  return {\n    isPresent: ['mounted', 'unmountSuspended'].includes(state),\n    ref: $iqq3r$useCallback(function (node) {\n      if (node) stylesRef.current = getComputedStyle(node);\n      setNode(node);\n    }, [])\n  };\n}\n/* -----------------------------------------------------------------------------------------------*/\nfunction $921a889cee6df7e8$var$getAnimationName(styles) {\n  return (styles === null || styles === void 0 ? void 0 : styles.animationName) || 'none';\n}\nexport { $921a889cee6df7e8$export$99c2b779aa4e8b8b as Presence };","map":{"version":3,"names":["$fe963b355347cc68$export$3e6543de14f8614f","useStateMachine","initialState","machine","$iqq3r$useReducer","state","event","nextState","$921a889cee6df7e8$export$99c2b779aa4e8b8b","Presence","props","present","children","presence","$921a889cee6df7e8$var$usePresence","child","isPresent","$iqq3r$Children","only","ref","$iqq3r$useComposedRefs","forceMount","$iqq3r$cloneElement","displayName","usePresence","_$iqq3r$useState","$iqq3r$useState","_$iqq3r$useState2","_slicedToArray","node1","setNode","stylesRef","$iqq3r$useRef","prevPresentRef","prevAnimationNameRef","_$fe963b355347cc68$ex","mounted","UNMOUNT","ANIMATION_OUT","unmountSuspended","MOUNT","ANIMATION_END","unmounted","_$fe963b355347cc68$ex2","send","$iqq3r$useEffect","currentAnimationName","$921a889cee6df7e8$var$getAnimationName","current","$iqq3r$useLayoutEffect","styles","wasPresent","hasPresentChanged","prevAnimationName","display","isAnimating","handleAnimationEnd","isCurrentAnimation","includes","animationName","target","$iqq3r$flushSync","handleAnimationStart","addEventListener","removeEventListener","$iqq3r$useCallback","node","getComputedStyle","getAnimationName"],"sources":["C:\\Users\\user\\Desktop\\03portreact\\node_modules\\@radix-ui\\react-presence\\dist\\packages\\react\\presence\\src\\index.ts","C:\\Users\\user\\Desktop\\03portreact\\node_modules\\@radix-ui\\react-presence\\dist\\packages\\react\\presence\\src\\Presence.tsx","C:\\Users\\user\\Desktop\\03portreact\\node_modules\\@radix-ui\\react-presence\\dist\\packages\\react\\presence\\src\\useStateMachine.tsx"],"sourcesContent":["export { Presence } from './Presence';\nexport type { PresenceProps } from './Presence';\n","import * as React from 'react';\nimport * as ReactDOM from 'react-dom';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { useLayoutEffect } from '@radix-ui/react-use-layout-effect';\nimport { useStateMachine } from './useStateMachine';\n\ninterface PresenceProps {\n  children: React.ReactElement | ((props: { present: boolean }) => React.ReactElement);\n  present: boolean;\n}\n\nconst Presence: React.FC<PresenceProps> = (props) => {\n  const { present, children } = props;\n  const presence = usePresence(present);\n\n  const child = (\n    typeof children === 'function'\n      ? children({ present: presence.isPresent })\n      : React.Children.only(children)\n  ) as React.ReactElement;\n\n  const ref = useComposedRefs(presence.ref, (child as any).ref);\n  const forceMount = typeof children === 'function';\n  return forceMount || presence.isPresent ? React.cloneElement(child, { ref }) : null;\n};\n\nPresence.displayName = 'Presence';\n\n/* -------------------------------------------------------------------------------------------------\n * usePresence\n * -----------------------------------------------------------------------------------------------*/\n\nfunction usePresence(present: boolean) {\n  const [node, setNode] = React.useState<HTMLElement>();\n  const stylesRef = React.useRef<CSSStyleDeclaration>({} as any);\n  const prevPresentRef = React.useRef(present);\n  const prevAnimationNameRef = React.useRef<string>('none');\n  const initialState = present ? 'mounted' : 'unmounted';\n  const [state, send] = useStateMachine(initialState, {\n    mounted: {\n      UNMOUNT: 'unmounted',\n      ANIMATION_OUT: 'unmountSuspended',\n    },\n    unmountSuspended: {\n      MOUNT: 'mounted',\n      ANIMATION_END: 'unmounted',\n    },\n    unmounted: {\n      MOUNT: 'mounted',\n    },\n  });\n\n  React.useEffect(() => {\n    const currentAnimationName = getAnimationName(stylesRef.current);\n    prevAnimationNameRef.current = state === 'mounted' ? currentAnimationName : 'none';\n  }, [state]);\n\n  useLayoutEffect(() => {\n    const styles = stylesRef.current;\n    const wasPresent = prevPresentRef.current;\n    const hasPresentChanged = wasPresent !== present;\n\n    if (hasPresentChanged) {\n      const prevAnimationName = prevAnimationNameRef.current;\n      const currentAnimationName = getAnimationName(styles);\n\n      if (present) {\n        send('MOUNT');\n      } else if (currentAnimationName === 'none' || styles?.display === 'none') {\n        // If there is no exit animation or the element is hidden, animations won't run\n        // so we unmount instantly\n        send('UNMOUNT');\n      } else {\n        /**\n         * When `present` changes to `false`, we check changes to animation-name to\n         * determine whether an animation has started. We chose this approach (reading\n         * computed styles) because there is no `animationrun` event and `animationstart`\n         * fires after `animation-delay` has expired which would be too late.\n         */\n        const isAnimating = prevAnimationName !== currentAnimationName;\n\n        if (wasPresent && isAnimating) {\n          send('ANIMATION_OUT');\n        } else {\n          send('UNMOUNT');\n        }\n      }\n\n      prevPresentRef.current = present;\n    }\n  }, [present, send]);\n\n  useLayoutEffect(() => {\n    if (node) {\n      /**\n       * Triggering an ANIMATION_OUT during an ANIMATION_IN will fire an `animationcancel`\n       * event for ANIMATION_IN after we have entered `unmountSuspended` state. So, we\n       * make sure we only trigger ANIMATION_END for the currently active animation.\n       */\n      const handleAnimationEnd = (event: AnimationEvent) => {\n        const currentAnimationName = getAnimationName(stylesRef.current);\n        const isCurrentAnimation = currentAnimationName.includes(event.animationName);\n        if (event.target === node && isCurrentAnimation) {\n          // With React 18 concurrency this update is applied\n          // a frame after the animation ends, creating a flash of visible content.\n          // By manually flushing we ensure they sync within a frame, removing the flash.\n          ReactDOM.flushSync(() => send('ANIMATION_END'));\n        }\n      };\n      const handleAnimationStart = (event: AnimationEvent) => {\n        if (event.target === node) {\n          // if animation occurred, store its name as the previous animation.\n          prevAnimationNameRef.current = getAnimationName(stylesRef.current);\n        }\n      };\n      node.addEventListener('animationstart', handleAnimationStart);\n      node.addEventListener('animationcancel', handleAnimationEnd);\n      node.addEventListener('animationend', handleAnimationEnd);\n      return () => {\n        node.removeEventListener('animationstart', handleAnimationStart);\n        node.removeEventListener('animationcancel', handleAnimationEnd);\n        node.removeEventListener('animationend', handleAnimationEnd);\n      };\n    } else {\n      // Transition to the unmounted state if the node is removed prematurely.\n      // We avoid doing so during cleanup as the node may change but still exist.\n      send('ANIMATION_END');\n    }\n  }, [node, send]);\n\n  return {\n    isPresent: ['mounted', 'unmountSuspended'].includes(state),\n    ref: React.useCallback((node: HTMLElement) => {\n      if (node) stylesRef.current = getComputedStyle(node);\n      setNode(node);\n    }, []),\n  };\n}\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction getAnimationName(styles?: CSSStyleDeclaration) {\n  return styles?.animationName || 'none';\n}\n\nexport { Presence };\nexport type { PresenceProps };\n","import * as React from 'react';\n\ntype Machine<S> = { [k: string]: { [k: string]: S } };\ntype MachineState<T> = keyof T;\ntype MachineEvent<T> = keyof UnionToIntersection<T[keyof T]>;\n\n// 🤯 https://fettblog.eu/typescript-union-to-intersection/\ntype UnionToIntersection<T> = (T extends any ? (x: T) => any : never) extends (x: infer R) => any\n  ? R\n  : never;\n\nexport function useStateMachine<M>(\n  initialState: MachineState<M>,\n  machine: M & Machine<MachineState<M>>\n) {\n  return React.useReducer((state: MachineState<M>, event: MachineEvent<M>): MachineState<M> => {\n    const nextState = (machine[state] as any)[event];\n    return nextState ?? state;\n  }, initialState);\n}\n"],"mappings":";;;;;AEWO,SAASA,yCAATC,CACLC,YADK,EAELC,OAFK,EAGL;EACA,OAAOC,iBAAA,CAAiB,UAACC,KAAD,EAAyBC,KAAzB,EAAqE;IAC3F,IAAMC,SAAS,GAAIJ,OAAO,CAACE,KAAD,CAAR,CAAwBC,KAAxB,CAAlB;IACA,OAAOC,SAAP,aAAOA,SAAP,cAAOA,SAAP,GAAoBF,KAApB;GAFK,EAGJH,YAHI,CAAP;;ADJF,IAAMM,yCAAiC,GAAI,SAArCA,yCAAiCC,CAAIC,KAAD,EAAW;EACnD,IAAQC,OAAF,GAAwBD,KAA9B,CAZFC,OAAA;IAYmBC,QAAA,GAAaF,KAA9B,CAZFE,QAAA;EAaE,IAAMC,QAAQ,GAAGC,iCAAW,CAACH,OAAD,CAA5B;EAEA,IAAMI,KAAK,GACT,OAAOH,QAAP,KAAoB,UAApB,GACIA,QAAQ,CAAC;IAAED,OAAO,EAAEE,QAAQ,CAACG;GAArB,CADZ,GAEIC,eAAA,CAAeC,IAAf,CAAoBN,QAApB,CAHN;EAMA,IAAMO,GAAG,GAAGC,sBAAe,CAACP,QAAQ,CAACM,GAAV,EAAgBJ,KAAD,CAAeI,GAA9B,CAA3B;EACA,IAAME,UAAU,GAAG,OAAOT,QAAP,KAAoB,UAAvC;EACA,OAAOS,UAAU,IAAIR,QAAQ,CAACG,SAAvB,gBAAmCM,mBAAA,CAAmBP,KAAnB,EAA0B;IAvBtEI,GAAA,EAuBwEA;GAA5B,CAAnC,GAAwE,IAA/E;CAZF;AAeAX,yCAAQ,CAACe,WAAT,GAAuB,UAAvB;AAEA;;;AAIA,SAAST,iCAATU,CAAqBb,OAArB,EAAuC;EACrC,IAAAc,gBAAA,GAAwBC,eAAA,EAAxB;IAAAC,iBAAA,GAAAC,cAAA,CAAAH,gBAAA;I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