// Copyright (C) 2017-2023 Smart code 203358507 const React = require('react'); const PropTypes = require('prop-types'); const classnames = require('classnames'); const { useTranslation } = require('react-i18next'); const { default: Icon } = require('@stremio/stremio-icons/react'); const { Button, Image } = require('stremio/components'); const styles = require('./styles'); const Addon = ({ className, id, name, version, logo, description, types, behaviorHints, installed, onInstall, onUninstall, onConfigure, onOpen, onShare, dataset }) => { const { t } = useTranslation(); const onInstallClick = React.useCallback((event) => { event.stopPropagation(); if (typeof onInstall === 'function') { onInstall({ type: 'install', nativeEvent: event.nativeEvent, reactEvent: event, dataset: dataset }); } }, [onInstall, dataset]); const onUninstallClick = React.useCallback((event) => { event.stopPropagation(); if (typeof onUninstall === 'function') { onUninstall({ type: 'uninstall', nativeEvent: event.nativeEvent, reactEvent: event, dataset: dataset }); } }, [onUninstall, dataset]); const onOpenClick = React.useCallback((event) => { event.stopPropagation(); if (typeof onOpen === 'function') { onOpen({ type: 'open', nativeEvent: event.nativeEvent, reactEvent: event, dataset: dataset }); } }, [onOpen, dataset]); const configureButtonOnClick = React.useCallback((event) => { event.stopPropagation(); if (typeof onConfigure === 'function') { onConfigure({ type: 'configure', nativeEvent: event.nativeEvent, reactEvent: event, dataset: dataset }); } }, [onConfigure, dataset]); const shareButtonOnClick = React.useCallback((event) => { event.stopPropagation(); if (typeof onShare === 'function') { onShare({ type: 'share', nativeEvent: event.nativeEvent, reactEvent: event, dataset: dataset }); } }, [onShare, dataset]); const onKeyDown = React.useCallback((event) => { if (event.key === 'Enter') { onOpenClick(event); } }, [onOpenClick]); const renderLogoFallback = React.useCallback(() => ( ), []); return ( : null } ); }; Addon.propTypes = { className: PropTypes.string, id: PropTypes.string, name: PropTypes.string, version: PropTypes.string, logo: PropTypes.string, description: PropTypes.string, types: PropTypes.arrayOf(PropTypes.string), behaviorHints: PropTypes.shape({ adult: PropTypes.bool, configurable: PropTypes.bool, configurationRequired: PropTypes.bool, p2p: PropTypes.bool, }), installed: PropTypes.bool, onToggle: PropTypes.func, onInstall: PropTypes.func, onUninstall: PropTypes.func, onConfigure: PropTypes.func, onOpen: PropTypes.func, onShare: PropTypes.func, dataset: PropTypes.object }; module.exports = Addon;