(()=>{"use strict";const e=window.ReactJSXRuntime,{__}=wp.i18n,{Component:t,Fragment:s}=wp.element,{InspectorControls:i}=wp.blockEditor,{SelectControl:n,Button:o,PanelBody:l,PanelRow:a}=wp.components;class r extends t{render(){const{attributes:t,setAttributes:a,onIdChange:r,selectOptions:c}=this.props,{id:d,views:w,testimonials:p}=t;return(0,e.jsx)(s,{children:(0,e.jsx)(i,{children:(0,e.jsxs)(l,{title:__("View Settings"),initialOpen:!0,children:[0===stViews.views.length&&(0,e.jsxs)(s,{children:[(0,e.jsx)("p",{children:__("You don't seem to have any views.")}),(0,e.jsx)(o,{href:stViews.adminURL+"edit.php?post_type=wpm-testimonial&page=testimonial-views&action=add",target:"_blank",isDefault:!0,children:__("Add New View")})]}),stViews.views.length>0&&(0,e.jsxs)(s,{children:[(0,e.jsx)(n,{label:__("Select View"),value:d,options:c,onChange:e=>r(parseInt(e))},d),0!==d&&(0,e.jsx)(o,{target:"_blank",href:stViews.adminURL+"edit.php?post_type=wpm-testimonial&page=testimonial-views&action=edit&id="+d,isSecondary:!0,children:__("Edit View")})]})]})})})}}const{__:c}=wp.i18n,{Component:d,Fragment:w,useEffect:p}=wp.element,{withSelect:h}=wp.data,{SelectControl:m,Spinner:v,Toolbar:u,Button:g}=wp.components,{BlockControls:b}=wp.blockEditor,x=t=>{const{attributes:s,setAttributes:i}=t,{id:n,views:o,status:l,testimonials:a,mode:d}=s;p((()=>{i({status:"ready",views:stViews.views}),0!==n&&h(n)}),[]);const h=e=>{t.setAttributes({status:"ready",id:e})},u=()=>{const e=[{value:0,label:c("None")}];return stViews.views.forEach((function(t){e.push({value:t.id,label:t.name})})),e};return stViews.views.length>0&&c("Edit View"),"loading"===l?[(0,e.jsx)(w,{children:(0,e.jsx)("div",{className:"st-block-preview",children:(0,e.jsxs)("div",{className:"st-block-preview__content",children:[(0,e.jsx)("div",{className:"st-block-preview__logo",children:" "}),(0,e.jsx)(v,{})]})})},"logo")]:[(0,e.jsxs)(w,{children:[(0,e.jsx)(r,{onIdChange:e=>h(e),selectOptions:u(),...t}),(0,e.jsx)("div",{className:"st-block-preview",children:(0,e.jsxs)("div",{className:"st-block-preview__content",children:[(0,e.jsx)("div",{className:"st-block-preview__logo"}),0===stViews.views.length&&(0,e.jsxs)(w,{children:[(0,e.jsx)("h6",{children:c("You don't seem to have any views.")}),(0,e.jsx)(g,{href:stViews.adminURL+"edit.php?post_type=wpm-testimonial&page=testimonial-views&action=add",target:"_blank",isDefault:!0,children:c("Add New View")})]}),stViews.views.length>0&&(0,e.jsxs)(w,{children:[(0,e.jsx)(m,{label:"Select a view:",className:"st-view-select",value:n,options:u(),onChange:e=>h(parseInt(e))},n),0!==n&&(0,e.jsx)(g,{target:"_blank",href:stViews.adminURL+"edit.php?post_type=wpm-testimonial&page=testimonial-views&action=edit&id="+n,isSecondary:!0,children:c("Edit Settings")})]})]})})]},"viewSelect")]},{__:j}=wp.i18n,{registerBlockType:_}=wp.blocks;new class{constructor(){this.registerBlock()}registerBlock(){this.blockName="strongtestimonials/view",this.blockAttributes={id:{type:"number",default:0},mode:{type:"string",default:"display"}},_(this.blockName,{title:"Strong Testimonial View",description:j("Render ST View","strong-testimonials"),icon:"editor-quote",category:"common",supports:{html:!1,customClassName:!1},attributes:this.blockAttributes,edit:x,save:()=>null})}}})();