(()=>{"use strict";var e={n:l=>{var t=l&&l.__esModule?()=>l.default:()=>l;return e.d(t,{a:t}),t},d:(l,t)=>{for(var n in t)e.o(t,n)&&!e.o(l,n)&&Object.defineProperty(l,n,{enumerable:!0,get:t[n]})},o:(e,l)=>Object.prototype.hasOwnProperty.call(e,l)};const l=window.wp.element,t=window.wp.blocks,n=window.wp.components,o=window.wp.blockEditor,s=window.wp.i18n,r=window.wp.serverSideRender;var i=e.n(r);const a=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"name":"llms/course-outline","title":"Course Outline","category":"llms-blocks","description":"Outputs the course outline as displayed by the widget of the same name. Can show full course outline or just the current section outline. Setting the Outline Type to Current Sections refers to the section that contains the next uncompleted lesson for current student. If the student is not enrolled then the first section in the course will be displayed.","textdomain":"lifterlms","attributes":{"collapse":{"type":"boolean","default":false},"course_id":{"type":"integer"},"outline_type":{"type":"string","default":"full"},"toggles":{"type":"boolean","default":false},"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 l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"name";const t=null==e?void 0:e.replace("llms_",""),n=t.charAt(0).toUpperCase()+t.slice(1);return"name"===l?t:n},m=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"course";const{posts:l,currentPostType:t}=(0,u.useSelect)((l=>{var t;return{posts:l("core").getEntityRecords("postType",e),currentPostType:null===(t=l("core/editor"))||void 0===t?void 0:t.getCurrentPostType()}}),[]),n=(d(e),[]);return p.includes(t)||n.push({label:(0,s.__)("Select course","lifterlms"),value:0}),null!=l&&l.length&&l.forEach((e=>{n.push({label:e.title.rendered+" (ID: "+e.id+")",value:e.id})})),p.includes(t)&&n.unshift({label:(0,s.sprintf)(
// Translators: %s = Post type name.
(0,s.__)("Inherit from current %s","lifterlms"),d(t)),value:0}),null!=n&&n.length||n.push({label:(0,s.__)("Loading","lifterlms"),value:0}),n},h=e=>{var t,o;let{attributes:r,setAttributes:i,postType:a="course",attribute:c="course_id"}=e;const u=m(a),p=d(a),h=d(a,"title"),f=(0,s.sprintf)(
// Translators: %s = Post type name.
(0,s.__)("Select the %s to associate with this block.","lifterlms"),p);return(0,l.createElement)(n.PanelRow,null,(0,l.createElement)(n.SelectControl,{label:h,help:f,value:null!==(t=null==r?void 0:r[c])&&void 0!==t?t:null==u||null===(o=u[0])||void 0===o?void 0:o.value,options:u,onChange:e=>{i({[c]:parseInt(e,10)})}}))};(0,t.registerBlockType)(a,{icon:()=>(0,l.createElement)(c.SVG,{className:"llms-block-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 576 512"},(0,l.createElement)(c.Path,{d:"M64 32C64 14.3 49.7 0 32 0S0 14.3 0 32v96V384c0 35.3 28.7 64 64 64H256V384H64V160H256V96H64V32zM288 192c0 17.7 14.3 32 32 32H544c17.7 0 32-14.3 32-32V64c0-17.7-14.3-32-32-32H445.3c-8.5 0-16.6-3.4-22.6-9.4L409.4 9.4c-6-6-14.1-9.4-22.6-9.4H320c-17.7 0-32 14.3-32 32V192zm0 288c0 17.7 14.3 32 32 32H544c17.7 0 32-14.3 32-32V352c0-17.7-14.3-32-32-32H445.3c-8.5 0-16.6-3.4-22.6-9.4l-13.3-13.3c-6-6-14.1-9.4-22.6-9.4H320c-17.7 0-32 14.3-32 32V480z"})),edit:e=>{const{attributes:t,setAttributes:r}=e,c=(0,o.useBlockProps)(),d=(()=>{const e=(0,u.useSelect)((e=>{var l;return null===(l=e("core/editor"))||void 0===l?void 0:l.getCurrentPostType()}),[]);return p.includes(e)})(),f=m(),_=(0,l.useMemo)((()=>(0,l.createElement)(i(),{block:a.name,attributes:t,LoadingResponsePlaceholder:()=>(0,l.createElement)(n.Spinner,null),ErrorResponsePlaceholder:()=>(0,l.createElement)("p",{className:"llms-block-error"},(0,s.__)("Error loading content. Please check block settings are valid. This block will not be displayed.","lifterlms")),EmptyResponsePlaceholder:()=>(0,l.createElement)("p",{className:"llms-block-empty"},(0,s.__)("No outline information available for this course. This block will not be displayed.","lifterlms"))})),[t]);var b;return t.course_id||d||r({course_id:null==f||null===(b=f[0])||void 0===b?void 0:b.value}),(0,l.createElement)(l.Fragment,null,(0,l.createElement)(o.InspectorControls,null,(0,l.createElement)(n.PanelBody,{title:(0,s.__)("Course Outline Settings","lifterlms")},(0,l.createElement)(n.PanelRow,null,(0,l.createElement)(n.ToggleControl,{label:(0,s.__)("Collapse","lifterlms"),help:(0,s.__)("If true, will make the outline sections collapsible via click events.","lifterlms"),checked:t.collapse,onChange:e=>r({collapse:e})})),t.collapse&&(0,l.createElement)(n.PanelRow,null,(0,l.createElement)(n.ToggleControl,{label:(0,s.__)("Toggles","lifterlms"),help:(0,s.__)('If true, will display "Collapse All" and "Expand All" toggles at the bottom of the outline. Only functions if "collapse" is true.',"lifterlms"),checked:t.toggles,onChange:e=>r({toggles:e})})),(0,l.createElement)(h,e),(0,l.createElement)(n.PanelRow,null,(0,l.createElement)(n.SelectControl,{label:(0,s.__)("Outline Type","lifterlms"),help:(0,s.__)("Select the type of outline to display.","lifterlms"),value:t.outline_type,options:[{label:(0,s.__)("Full","lifterlms"),value:"full",isDefault:!0},{label:(0,s.__)("Current Section","lifterlms"),value:"current_section"}],onChange:e=>r({outline_type:e})})))),(0,l.createElement)("div",c,(0,l.createElement)(n.Disabled,null,_)))}})})();