(()=>{"use strict";var e={n:t=>{var l=t&&t.__esModule?()=>t.default:()=>t;return e.d(l,{a:l}),l},d:(t,l)=>{for(var r in l)e.o(l,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:l[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.wp.element,l=window.wp.blocks,r=window.wp.components,s=window.wp.blockEditor,o=window.wp.i18n,n=window.wp.serverSideRender;var i=e.n(n);const a=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"name":"llms/course-author","title":"Course Author","category":"llms-blocks","description":"Display the Course Author’s name, avatar, and (optionally) biography for a specific course.","textdomain":"lifterlms","attributes":{"avatar_size":{"type":"integer","default":48},"bio":{"type":"string","default":"yes"},"course_id":{"type":"integer"},"llms_visibility":{"type":"string"},"llms_visibility_in":{"type":"string"},"llms_visibility_posts":{"type":"string"}},"supports":{"align":["wide","full"]},"editorScript":"file:./index.js"}'),c=window.wp.primitives,u=window.wp.data,p=["course","lesson","llms_quiz"],d=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"name";const l=null==e?void 0:e.replace("llms_",""),r=l.charAt(0).toUpperCase()+l.slice(1);return"name"===t?l:r},m=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"course";const{posts:t,currentPostType:l}=(0,u.useSelect)((t=>{var l;return{posts:t("core").getEntityRecords("postType",e),currentPostType:null===(l=t("core/editor"))||void 0===l?void 0:l.getCurrentPostType()}}),[]),r=(d(e),[]);return p.includes(l)||r.push({label:(0,o.__)("Select course","lifterlms"),value:0}),null!=t&&t.length&&t.forEach((e=>{r.push({label:e.title.rendered+" (ID: "+e.id+")",value:e.id})})),p.includes(l)&&r.unshift({label:(0,o.sprintf)(
// Translators: %s = Post type name.
(0,o.__)("Inherit from current %s","lifterlms"),d(l)),value:0}),null!=r&&r.length||r.push({label:(0,o.__)("Loading","lifterlms"),value:0}),r},h=e=>{var l,s;let{attributes:n,setAttributes:i,postType:a="course",attribute:c="course_id"}=e;const u=m(a),p=d(a),h=d(a,"title"),b=(0,o.sprintf)(
// Translators: %s = Post type name.
(0,o.__)("Select the %s to associate with this block.","lifterlms"),p);return(0,t.createElement)(r.PanelRow,null,(0,t.createElement)(r.SelectControl,{label:h,help:b,value:null!==(l=null==n?void 0:n[c])&&void 0!==l?l:null==u||null===(s=u[0])||void 0===s?void 0:s.value,options:u,onChange:e=>{i({[c]:parseInt(e,10)})}}))};(0,l.registerBlockType)(a,{icon:()=>(0,t.createElement)(c.SVG,{className:"llms-block-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512"},(0,t.createElement)(c.Path,{d:"M224 256A128 128 0 1 0 224 0a128 128 0 1 0 0 256zm-45.7 48C79.8 304 0 383.8 0 482.3C0 498.7 13.3 512 29.7 512H418.3c16.4 0 29.7-13.3 29.7-29.7C448 383.8 368.2 304 269.7 304H178.3z"})),edit:e=>{const{attributes:l,setAttributes:n}=e,c=(0,s.useBlockProps)(),u=m(),p=(0,t.useMemo)((()=>{let e=(0,o.__)("Author not found. This block will not be displayed.","lifterlms");return!l.course_id&&u.length>0&&(e=(0,o.__)("No course selected. Please choose a Course from the block sidebar panel.","lifterlms")),(0,t.createElement)(i(),{block:a.name,attributes:l,LoadingResponsePlaceholder:()=>(0,t.createElement)(r.Spinner,null),ErrorResponsePlaceholder:()=>(0,t.createElement)("p",{className:"llms-block-error"},(0,o.__)("Error loading content. Please check block settings are valid. This block will not be displayed.","lifterlms")),EmptyResponsePlaceholder:()=>(0,t.createElement)("p",{className:"llms-block-empty"},e)})}),[l]);return(0,t.createElement)(t.Fragment,null,(0,t.createElement)(s.InspectorControls,null,(0,t.createElement)(r.PanelBody,{title:(0,o.__)("Course Author Settings","lifterlms")},(0,t.createElement)(r.PanelRow,null,(0,t.createElement)(r.RangeControl,{label:(0,o.__)("Avatar Size","lifterlms"),help:(0,o.__)("The size of the avatar in pixels.","lifterlms"),value:l.avatar_size,onChange:e=>n({avatar_size:parseInt(e)}),min:0,max:300,allowReset:!0,resetFallbackValue:a.attributes.avatar_size.default,default:a.attributes.avatar_size.default})),(0,t.createElement)(r.PanelRow,null,(0,t.createElement)(r.ToggleControl,{label:(0,o.__)("Display Bio","lifterlms"),help:null!=l&&l.bio?(0,o.__)("Author bio is displayed.","lifterlms"):(0,o.__)("Author bio is hidden.","lifterlms"),checked:"yes"===l.bio,onChange:e=>n({bio:e?"yes":"no"})})),(0,t.createElement)(h,e))),(0,t.createElement)("div",c,(0,t.createElement)(r.Disabled,null,p)))}})})();