{
  "version": 3,
  "sources": ["../../src/hooks/states.js"],
  "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { getBlockType } from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport StateControl from '../components/global-styles/state-control';\nimport StateControlBadges from '../components/global-styles/state-control-badges';\nimport { useToolsPanelDropdownMenuProps } from '../components/global-styles/utils';\n\nexport const PSEUDO_STATE_LABELS = {\n\t':hover': __( 'Hover' ),\n\t':focus': __( 'Focus' ),\n\t':focus-visible': __( 'Focus-visible' ),\n\t':active': __( 'Active' ),\n};\n\nexport const RESPONSIVE_STATE_LABELS = {\n\ttablet: __( 'Tablet' ),\n\tmobile: __( 'Mobile' ),\n};\n\n// Keep in sync with WP_Theme_JSON_Gutenberg::VALID_BLOCK_PSEUDO_SELECTORS\n// and packages/global-styles-engine/src/core/render.tsx.\nexport const VALID_BLOCK_PSEUDO_STATES = {\n\t'core/button': [ ':hover', ':focus', ':focus-visible', ':active' ],\n\t'core/navigation-link': [ ':hover', ':focus', ':focus-visible', ':active' ],\n};\n\nfunction getPseudoStateOptions( name ) {\n\tconst validStates = VALID_BLOCK_PSEUDO_STATES[ name ] ?? [];\n\n\treturn validStates\n\t\t.filter( ( state ) => PSEUDO_STATE_LABELS[ state ] )\n\t\t.map( ( state ) => ( {\n\t\t\tvalue: state,\n\t\t\tlabel: PSEUDO_STATE_LABELS[ state ],\n\t\t} ) );\n}\n\nconst DEFAULT_STATE_VALUE = 'default';\n\nfunction getViewportStateOptions( name ) {\n\tif ( ! getBlockType( name )?.attributes?.style ) {\n\t\treturn [];\n\t}\n\n\treturn Object.entries( RESPONSIVE_STATE_LABELS ).map(\n\t\t( [ value, label ] ) => ( {\n\t\t\tvalue,\n\t\t\tlabel,\n\t\t} )\n\t);\n}\n\n/**\n * Renders a style-state selector in the block card header.\n * Viewport states are shown for blocks with a style attribute, while\n * pseudo-states are shown for blocks with configured pseudo-state support.\n *\n * @param {Object}   props          Component props.\n * @param {string}   props.name     Block name.\n * @param {Object}   props.value    Currently selected style-state value.\n * @param {Function} props.onChange Callback when style-state selection changes.\n * @return {Element|null} State control component, or null if not applicable.\n */\nexport function BlockStatesControl( { name, value, onChange } ) {\n\tconst viewportStateOptions = getViewportStateOptions( name );\n\tconst pseudoStateOptions = getPseudoStateOptions( name );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\tif ( ! viewportStateOptions.length && ! pseudoStateOptions.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<StateControl\n\t\t\tviewportStates={ viewportStateOptions }\n\t\t\tpseudoStates={ pseudoStateOptions }\n\t\t\tviewportValue={ value?.viewport ?? DEFAULT_STATE_VALUE }\n\t\t\tpseudoStateValue={ value?.pseudo ?? DEFAULT_STATE_VALUE }\n\t\t\tonChangeViewport={ ( viewport ) => onChange( { viewport } ) }\n\t\t\tonChangePseudoState={ ( pseudo ) => onChange( { pseudo } ) }\n\t\t\tpopoverProps={ dropdownMenuProps.popoverProps }\n\t\t\tshowText={ false }\n\t\t/>\n\t);\n}\n\nexport function BlockStateBadges( { name, value } ) {\n\tconst viewportStateOptions = getViewportStateOptions( name );\n\tconst pseudoStateOptions = getPseudoStateOptions( name );\n\n\tif ( ! viewportStateOptions.length && ! pseudoStateOptions.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<StateControlBadges\n\t\t\tviewportStates={ viewportStateOptions }\n\t\t\tpseudoStates={ pseudoStateOptions }\n\t\t\tviewportValue={ value?.viewport ?? DEFAULT_STATE_VALUE }\n\t\t\tpseudoStateValue={ value?.pseudo ?? DEFAULT_STATE_VALUE }\n\t\t/>\n\t);\n}\n"],
  "mappings": ";AAGA,SAAS,oBAAoB;AAC7B,SAAS,UAAU;AAKnB,OAAO,kBAAkB;AACzB,OAAO,wBAAwB;AAC/B,SAAS,sCAAsC;AAoE7C;AAlEK,IAAM,sBAAsB;AAAA,EAClC,UAAU,GAAI,OAAQ;AAAA,EACtB,UAAU,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