(()=>{"use strict";const t=window.wp.plugins,e=window.ReactJSXRuntime,{Button:s,Dropdown:o,PanelRow:i}=wp.components,{PluginPostStatusInfo:r}=wp.editor,{Component:p}=wp.element,{sprintf:n,__}=wp.i18n;class a extends p{constructor(t){super(...arguments),this.state={currentPostType:window.ptsBlockEditor.currentPostType}}render(){return(0,e.jsxs)("fieldset",{className:"editor-post-type__dialog-fieldset",children:[(0,e.jsx)("legend",{className:"editor-post-type__dialog-legend",children:__("Post Type","post-type-switcher")}),window.ptsBlockEditor.availablePostTypes.map(({value:t,label:s})=>(0,e.jsxs)("div",{className:"editor-post-type__choice",children:[(0,e.jsx)("input",{type:"radio",className:"editor-post-type__dialog-radio",name:"editor-post-type__setting",value:t,onChange:()=>{const e=this.state.currentPostType;this.setState({currentPostType:t});const s=n(__("Are you sure you want to change this from a '%s' to a '%s'?","post-type-switcher"),e,t);window.confirm(s)?window.location.href=window.ptsBlockEditor.changeUrl+"&pts_post_type="+t:this.setState({currentPostType:e})},checked:t===this.state.currentPostType,id:`editor-post-type-switcher-${t}`}),(0,e.jsx)("label",{htmlFor:`editor-post-type-switcher-${t}`,className:"editor-post-type__dialog-label",children:s})]},t))]},"post-type-switcher-selector")}}(0,t.registerPlugin)("post-type-switcher",{render:()=>(0,e.jsx)(r,{children:(0,e.jsxs)("div",{className:"edit-post-post-type",children:[(0,e.jsx)("div",{className:"editor-post-panel__row-label",children:__("Post Type","post-type-switcher")}),(0,e.jsx)("div",{className:"editor-post-panel__row-control",children:(0,e.jsx)(o,{popoverProps:{placement:"left-start",offset:138,shift:!0},contentClassName:"edit-post-post-type__dialog",renderToggle:({isOpen:t,onToggle:o})=>(0,e.jsx)(s,{type:"button","aria-expanded":t,"aria-label":n(__("Change post type: %s","post-type-switcher"),window.ptsBlockEditor.currentPostType),className:"edit-post-post-type__toggle is-compact is-tertiary",onClick:o,children:window.ptsBlockEditor.currentPostTypeLabel}),renderContent:()=>(0,e.jsx)(a,{})})})]})})})})();