{
  "version": 3,
  "sources": ["../../../src/components/post-discussion/panel.js"],
  "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tDropdown,\n\tButton,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { useState, useMemo } from '@wordpress/element';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport PostTypeSupportCheck from '../post-type-support-check';\nimport PostComments from '../post-comments';\nimport PostPingbacks from '../post-pingbacks';\nimport PostPanelRow from '../post-panel-row';\n\nconst PANEL_NAME = 'discussion-panel';\n\nfunction ModalContents( { onClose } ) {\n\treturn (\n\t\t<div className=\"editor-post-discussion\">\n\t\t\t<InspectorPopoverHeader\n\t\t\t\ttitle={ __( 'Discussion' ) }\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t\t<VStack spacing={ 4 }>\n\t\t\t\t<PostTypeSupportCheck supportKeys=\"comments\">\n\t\t\t\t\t<PostComments />\n\t\t\t\t</PostTypeSupportCheck>\n\t\t\t\t<PostTypeSupportCheck supportKeys=\"trackbacks\">\n\t\t\t\t\t<PostPingbacks />\n\t\t\t\t</PostTypeSupportCheck>\n\t\t\t</VStack>\n\t\t</div>\n\t);\n}\n\nfunction PostDiscussionToggle( { isOpen, onClick } ) {\n\tconst {\n\t\tcommentStatus,\n\t\tpingStatus,\n\t\tcommentsSupported,\n\t\ttrackbacksSupported,\n\t} = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\tconst { getPostType } = select( coreStore );\n\t\tconst postType = getPostType( getEditedPostAttribute( 'type' ) );\n\t\treturn {\n\t\t\tcommentStatus: getEditedPostAttribute( 'comment_status' ) ?? 'open',\n\t\t\tpingStatus: getEditedPostAttribute( 'ping_status' ) ?? 'open',\n\t\t\tcommentsSupported: !! postType.supports.comments,\n\t\t\ttrackbacksSupported: !! postType.supports.trackbacks,\n\t\t};\n\t}, [] );\n\tlet label;\n\tif ( commentStatus === 'open' ) {\n\t\tif ( pingStatus === 'open' ) {\n\t\t\tlabel = _x( 'Open', 'Adjective: e.g. \"Comments are open\"' );\n\t\t} else {\n\t\t\tlabel = trackbacksSupported\n\t\t\t\t? __( 'Comments only' )\n\t\t\t\t: _x( 'Open', 'Adjective: e.g. \"Comments are open\"' );\n\t\t}\n\t} else if ( pingStatus === 'open' ) {\n\t\tlabel = commentsSupported ? __( 'Pings only' ) : __( 'Pings enabled' );\n\t} else {\n\t\tlabel = __( 'Closed' );\n\t}\n\treturn (\n\t\t<Button\n\t\t\tsize=\"compact\"\n\t\t\tclassName=\"editor-post-discussion__panel-toggle\"\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-label={ __( 'Change discussion options' ) }\n\t\t\taria-expanded={ isOpen }\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ label }\n\t\t</Button>\n\t);\n}\n\n/**\n * This component allows to update comment and pingback\n * settings for the current post. Internally there are\n * checks whether the current post has support for the\n * above and if the `discussion-panel` panel is enabled.\n *\n * @return {React.ReactNode} The rendered PostDiscussionPanel component.\n */\nexport default function PostDiscussionPanel() {\n\tconst { isEnabled } = useSelect( ( select ) => {\n\t\tconst { isEditorPanelEnabled } = select( editorStore );\n\t\treturn {\n\t\t\tisEnabled: isEditorPanelEnabled( PANEL_NAME ),\n\t\t};\n\t}, [] );\n\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( {\n\t\t\t// Anchor the popover to the middle of the entire row so that it doesn't\n\t\t\t// move around when the label changes.\n\t\t\tanchor: popoverAnchor,\n\t\t\tplacement: 'left-start',\n\t\t\toffset: 36,\n\t\t\tshift: true,\n\t\t} ),\n\t\t[ popoverAnchor ]\n\t);\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PostTypeSupportCheck supportKeys={ [ 'comments', 'trackbacks' ] }>\n\t\t\t<PostPanelRow label={ __( 'Discussion' ) } ref={ setPopoverAnchor }>\n\t\t\t\t<Dropdown\n\t\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\t\tclassName=\"editor-post-discussion__panel-dropdown\"\n\t\t\t\t\tcontentClassName=\"editor-post-discussion__panel-dialog\"\n\t\t\t\t\tfocusOnMount\n\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t\t<PostDiscussionToggle\n\t\t\t\t\t\t\tisOpen={ isOpen }\n\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t\t<ModalContents onClose={ onClose } />\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</PostPanelRow>\n\t\t</PostTypeSupportCheck>\n\t);\n}\n"],
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAuB;AACvB,wBAIO;AACP,kBAA0B;AAC1B,qBAAkC;AAClC,0BAA+E;AAC/E,uBAAmC;AAKnC,mBAAqC;AACrC,qCAAiC;AACjC,2BAAyB;AACzB,4BAA0B;AAC1B,4BAAyB;AAOtB;AALH,IAAM,aAAa;AAEnB,SAAS,cAAe,EAAE,QAAQ,GAAI;AACrC,SACC,6CAAC,SAAI,WAAU,0BACd;AAAA;AAAA,MAAC,oBAAAA;AAAA,MAAA;AAAA,QACA,WAAQ,gBAAI,YAAa;AAAA,QACzB;AAAA;AAAA,IACD;AAAA,IACA,6CAAC,kBAAAC,sBAAA,EAAO,SAAU,GACjB;AAAA,kDAAC,+BAAAC,SAAA,EAAqB,aAAY,YACjC,sD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CAAE,WAAY;AAC9C,UAAM,EAAE,qBAAqB,IAAI,OAAQ,aAAAD,KAAY;AACrD,WAAO;AAAA,MACN,WAAW,qBAAsB,UAAW;AAAA,IAC7C;AAAA,EACD,GAAG,CAAC,CAAE;AAIN,QAAM,CAAE,eAAe,gBAAiB,QAAI,yBAAU,IAAK;AAE3D,QAAM,mBAAe;AAAA,IACpB,OAAQ;AAAA;AAAA;AAAA,MAGP,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,QAAQ;AAAA,MACR,OAAO;AAAA,IACR;AAAA,IACA,CAAE,aAAc;AAAA,EACjB;AAEA,MAAK,CAAE,WAAY;AAClB,WAAO;AAAA,EACR;AAEA,SACC,4CAAC,+BAAAH,SAAA,EAAqB,aAAc,CAAE,YAAY,YAAa,GAC9D,sDAAC,sBAAAK,SAAA,EAAa,WAAQ,gBAAI,YAAa,GAAI,KAAM,kBAChD;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA,WAAU;AAAA,MACV,kBAAiB;AAAA,MACjB,cAAY;AAAA,MACZ,cAAe,CAAE,EAAE,QAAQ,SAAS,MACnC;AAAA,QAAC;AAAA;AAAA,UACA;AAAA,UACA,SAAU;AAAA;AAAA,MACX;AAAA,MAED,eAAgB,CAAE,EAAE,QAAQ,MAC3B,4CAAC,iBAAc,SAAoB;AAAA;AAAA,EAErC,GACD,GACD;AAEF;",
  "names": ["InspectorPopoverHeader", "VStack", "PostTypeSupportCheck", "PostComments", "PostPingbacks", "editorStore", "coreStore", "PostPanelRow"]
}
