(()=>{"use strict";var e={};function t(){return t=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var l=arguments[t];for(var r in l)({}).hasOwnProperty.call(l,r)&&(e[r]=l[r])}return e},t.apply(null,arguments)}e.n=t=>{var l=t&&t.__esModule?()=>t.default:()=>t;return e.d(l,{a:l}),l},e.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]})},e.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);const l=window.wp.element,r=window.wp.blocks,s=window.wp.components,o=window.wp.blockEditor,n=window.wp.i18n,i=window.wp.serverSideRender;var c=e.n(i);const a=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"name":"llms/pricing-table","title":"Pricing Table","category":"llms-blocks","description":"Outputs a LifterLMS Pricing table (like those found on a course or membership page) for a course or membership outside of a course or membership. Useful if you want to create custom sales pages.","textdomain":"lifterlms","attributes":{"product":{"type":"integer"},"postType":{"type":"string","default":"course"},"llms_visibility":{"type":"string"},"llms_visibility_in":{"type":"string"},"llms_visibility_posts":{"type":"string"}},"supports":{"align":["wide","full"]},"editorScript":"file:./index.js"}'),u=window.wp.primitives,p=(0,l.createElement)(u.SVG,{className:"llms-block-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 576 512"},(0,l.createElement)(u.Path,{d:"M64 64C28.7 64 0 92.7 0 128V384c0 35.3 28.7 64 64 64H512c35.3 0 64-28.7 64-64V128c0-35.3-28.7-64-64-64H64zM272 192H496c8.8 0 16 7.2 16 16s-7.2 16-16 16H272c-8.8 0-16-7.2-16-16s7.2-16 16-16zM256 304c0-8.8 7.2-16 16-16H496c8.8 0 16 7.2 16 16s-7.2 16-16 16H272c-8.8 0-16-7.2-16-16zM164 152v13.9c7.5 1.2 14.6 2.9 21.1 4.7c10.7 2.8 17 13.8 14.2 24.5s-13.8 17-24.5 14.2c-11-2.9-21.6-5-31.2-5.2c-7.9-.1-16 1.8-21.5 5c-4.8 2.8-6.2 5.6-6.2 9.3c0 1.8 .1 3.5 5.3 6.7c6.3 3.8 15.5 6.7 28.3 10.5l.7 .2c11.2 3.4 25.6 7.7 37.1 15c12.9 8.1 24.3 21.3 24.6 41.6c.3 20.9-10.5 36.1-24.8 45c-7.2 4.5-15.2 7.3-23.2 9V360c0 11-9 20-20 20s-20-9-20-20V345.4c-10.3-2.2-20-5.5-28.2-8.4l0 0 0 0c-2.1-.7-4.1-1.4-6.1-2.1c-10.5-3.5-16.1-14.8-12.6-25.3s14.8-16.1 25.3-12.6c2.5 .8 4.9 1.7 7.2 2.4c13.6 4.6 24 8.1 35.1 8.5c8.6 .3 16.5-1.6 21.4-4.7c4.1-2.5 6-5.5 5.9-10.5c0-2.9-.8-5-5.9-8.2c-6.3-4-15.4-6.9-28-10.7l-1.7-.5c-10.9-3.3-24.6-7.4-35.6-14c-12.7-7.7-24.6-20.5-24.7-40.7c-.1-21.1 11.8-35.7 25.8-43.9c6.9-4.1 14.5-6.8 22.2-8.5V152c0-11 9-20 20-20s20 9 20 20z"})),m=window.wp.data,d=["course","lesson","llms_quiz"],b=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},h=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"course";const{posts:t,currentPostType:l}=(0,m.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=(b(e),[]);return d.includes(l)||r.push({label:(0,n.__)("Select course","lifterlms"),value:0}),null!=t&&t.length&&t.forEach((e=>{r.push({label:e.title.rendered+" (ID: "+e.id+")",value:e.id})})),d.includes(l)&&r.unshift({label:(0,n.sprintf)(
// Translators: %s = Post type name.
(0,n.__)("Inherit from current %s","lifterlms"),b(l)),value:0}),null!=r&&r.length||r.push({label:(0,n.__)("Loading","lifterlms"),value:0}),r},v=e=>{var t,r;let{attributes:o,setAttributes:i,postType:c="course",attribute:a="course_id"}=e;const u=h(c),p=b(c),m=b(c,"title"),d=(0,n.sprintf)(
// Translators: %s = Post type name.
(0,n.__)("Select the %s to associate with this block.","lifterlms"),p);return(0,l.createElement)(s.PanelRow,null,(0,l.createElement)(s.SelectControl,{label:m,help:d,value:null!==(t=null==o?void 0:o[a])&&void 0!==t?t:null==u||null===(r=u[0])||void 0===r?void 0:r.value,options:u,onChange:e=>{i({[a]:parseInt(e,10)})}}))},w=[{label:(0,n.__)("Course","lifterlms"),value:"course"},{label:(0,n.__)("Membership","lifterlms"),value:"llms_membership"}];(0,r.registerBlockType)(a,{icon:p,edit:e=>{var r;const{attributes:i,setAttributes:u}=e,p=(0,o.useBlockProps)(),m=h(),d=(0,l.useMemo)((()=>{let e=(0,n.__)("Author not found. This block will not be displayed.","lifterlms");return!i.product&&m.length>0&&(e=(0,n.__)("No course selected. Please choose a Course from the block sidebar panel.","lifterlms")),(0,l.createElement)(c(),{block:a.name,attributes:i,LoadingResponsePlaceholder:()=>(0,l.createElement)(s.Spinner,null),ErrorResponsePlaceholder:()=>(0,l.createElement)("p",{className:"llms-block-error"},(0,n.__)("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"},e)})}),[i]);return(0,l.createElement)(l.Fragment,null,(0,l.createElement)(o.InspectorControls,null,(0,l.createElement)(s.PanelBody,{title:(0,n.__)("Pricing Table Settings","lifterlms")},(0,l.createElement)(s.PanelRow,null,(0,l.createElement)(s.SelectControl,{label:(0,n.__)("Post Type","lifterlms"),value:i.postType,options:w,onChange:e=>u({postType:e,product:""})})),(0,l.createElement)(v,t({},e,{postType:null!==(r=null==i?void 0:i.postType)&&void 0!==r?r:"course",attribute:"product"})))),(0,l.createElement)("div",p,(0,l.createElement)(s.Disabled,null,d)))}})})();