(()=>{"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 n in l)e.o(l,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:l[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.wp.element,l=window.wp.blocks,n=window.wp.components,s=window.wp.blockEditor,r=window.wp.i18n,o=window.wp.apiFetch;var i=e.n(o);const a=window.wp.serverSideRender;var c=e.n(a);const m=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"name":"llms/my-achievements","title":"My Achievements","category":"llms-blocks","description":"Outputs achievements using the achievement loop templates.","textdomain":"lifterlms","attributes":{"count":{"type":"integer"},"columns":{"type":"integer","default":5},"user_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"}'),p=window.wp.primitives;(0,l.registerBlockType)(m,{icon:()=>(0,t.createElement)(p.SVG,{className:"llms-block-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 576 512"},(0,t.createElement)(p.Path,{d:"M400 0H176c-26.5 0-48.1 21.8-47.1 48.2c.2 5.3 .4 10.6 .7 15.8H24C10.7 64 0 74.7 0 88c0 92.6 33.5 157 78.5 200.7c44.3 43.1 98.3 64.8 138.1 75.8c23.4 6.5 39.4 26 39.4 45.6c0 20.9-17 37.9-37.9 37.9H192c-17.7 0-32 14.3-32 32s14.3 32 32 32H384c17.7 0 32-14.3 32-32s-14.3-32-32-32H357.9C337 448 320 431 320 410.1c0-19.6 15.9-39.2 39.4-45.6c39.9-11 93.9-32.7 138.2-75.8C542.5 245 576 180.6 576 88c0-13.3-10.7-24-24-24H446.4c.3-5.2 .5-10.4 .7-15.8C448.1 21.8 426.5 0 400 0zM48.9 112h84.4c9.1 90.1 29.2 150.3 51.9 190.6c-24.9-11-50.8-26.5-73.2-48.3c-32-31.1-58-76-63-142.3zM464.1 254.3c-22.4 21.8-48.3 37.3-73.2 48.3c22.7-40.3 42.8-100.5 51.9-190.6h84.4c-5.1 66.3-31.1 111.2-63 142.3z"})),edit:e=>{const{attributes:l,setAttributes:o}=e,a=(0,s.useBlockProps)(),[p,u]=(0,t.useState)([]),d=[{label:(0,r.__)("Current user","lifterlms"),value:0}],w=(0,t.useMemo)((()=>(0,t.createElement)(c(),{block:m.name,attributes:l,LoadingResponsePlaceholder:()=>(0,t.createElement)(n.Spinner,null),ErrorResponsePlaceholder:()=>(0,t.createElement)("p",{className:"llms-block-error"},(0,r.__)("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"},(0,r.__)("No achievements found matching your selection. This block will not be displayed.","lifterlms"))})),[l]);return i()({path:"/wp/v2/users"}).then((e=>{u(e)})),p.forEach((e=>{d.push({label:e.name,value:e.id})})),(0,t.createElement)(t.Fragment,null,(0,t.createElement)(s.InspectorControls,null,(0,t.createElement)(n.PanelBody,{title:(0,r.__)("My Account Settings","lifterlms")},(0,t.createElement)(n.PanelRow,null,(0,t.createElement)(n.__experimentalNumberControl,{label:(0,r.__)("Count","lifterlms"),help:(0,r.__)("Number of achievements to display. Leave empty to display all achievements for user.","lifterlms"),value:l.count,onChange:e=>o({count:e})})),(0,t.createElement)(n.PanelRow,null,(0,t.createElement)(n.RangeControl,{label:(0,r.__)("Columns","lifterlms"),help:(0,r.__)("Number of columns to display.","lifterlms"),value:l.columns,onChange:e=>o({columns:e}),min:1,max:12})),(0,t.createElement)(n.PanelRow,null,(0,t.createElement)(n.SelectControl,{label:(0,r.__)("User","lifterlms"),help:(0,r.__)("Select a user to display achievements for. Leave empty to display achievements for the current user.","lifterlms"),value:l.user_id,options:d,onChange:e=>o({user_id:e})})))),(0,t.createElement)("div",a,(0,t.createElement)(n.Disabled,null,w)))}})})();