(()=>{"use strict";var o,e={16248:(o,e,l)=>{const r=window.wp.element,t=window.React,n=window.wp.i18n;var a=l(68030);const d=window.ReactJSXRuntime,s=()=>{const[o,e]=(0,t.useState)([]),[l,r]=(0,t.useState)(0),[s,i]=(0,t.useState)(1),[c]=(0,t.useState)(5),[m,h]=(0,t.useState)(!1),[_,u]=(0,t.useState)(""),w=Math.ceil(l/c),b=(0,t.useCallback)(()=>{h(!0),u(""),(0,a.A)({method:"GET",url:`${courseMyAcc.apiUrl}/moowoodle/v1/my-courses`,headers:{"X-WP-Nonce":window.courseMyAcc.nonce},params:{page:s,row:c}}).then(o=>{e(o.data.data||[]),r(o.data.count||0)}).catch(()=>{u((0,n.__)("Failed to fetch courses.","moowoodle"))}).finally(()=>h(!1))},[s,c]);return(0,t.useEffect)(()=>{b()},[b]),(0,d.jsxs)("div",{className:"moowoodle-my-courses",children:[(0,d.jsxs)("table",{className:"moowoodle-table shop_table shop_table_responsive my_account_orders",children:[(0,d.jsx)("thead",{children:(0,d.jsxs)("tr",{children:[(0,d.jsx)("th",{children:(0,n.__)("Username","moowoodle")}),(0,d.jsx)("th",{children:(0,n.__)("Course Name","moowoodle")}),(0,d.jsx)("th",{children:(0,n.__)("Enrolment Date","moowoodle")}),(0,d.jsx)("th",{children:(0,n.__)("Password (First Time Login only)","moowoodle")}),(0,d.jsx)("th",{children:(0,n.__)("Action","moowoodle")})]})}),(0,d.jsx)("tbody",{children:m?(0,d.jsx)("tr",{children:(0,d.jsx)("td",{colSpan:5,children:(0,n.__)("Loading…","moowoodle")})}):_?(0,d.jsx)("tr",{children:(0,d.jsx)("td",{colSpan:5,className:"error-row",children:_})}):o.length?o.map((o,e)=>(0,d.jsxs)("tr",{children:[(0,d.jsx)("td",{"data-label":(0,n.__)("Username","moowoodle"),children:o.user_name||(0,n.__)("N/A","moowoodle")}),(0,d.jsx)("td",{"data-label":(0,n.__)("Course Name","moowoodle"),children:o.course_name||(0,n.__)("Unknown Course","moowoodle")}),(0,d.jsx)("td",{"data-label":(0,n.__)("Enrolment Date","moowoodle"),children:o.enrollment_date||(0,n.__)("No Date Available","moowoodle")}),(0,d.jsx)("td",{"data-label":(0,n.__)("Password (First Time Login only)","moowoodle"),children:o.password||(0,n.__)("Password not Available","moowoodle")}),(0,d.jsx)("td",{"data-label":(0,n.__)("Action","moowoodle"),children:o.moodle_url?(0,d.jsx)("a",{href:o.moodle_url,target:"_blank",rel:"noopener noreferrer",className:"woocommerce-button wp-element-button moowoodle",children:(0,n.__)("View","moowoodle")}):(0,d.jsx)("span",{className:"disabled",children:(0,n.__)("No Link","moowoodle")})})]},e)):(0,d.jsx)("tr",{children:(0,d.jsx)("td",{colSpan:5,className:"no-data-row",children:(0,n.__)("You haven't purchased any courses yet.","moowoodle")})})})]}),w<=1?null:(0,d.jsxs)("div",{className:"pagination",children:[(0,d.jsx)("button",{disabled:1===s||m,onClick:()=>i(o=>Math.max(o-1,1)),children:(0,n.__)("Previous","moowoodle")}),(0,d.jsx)("span",{children:(0,n.sprintf)(
// translators: %1$d is the current page number, %2$d is the total number of pages.
// translators: %1$d is the current page number, %2$d is the total number of pages.
(0,n.__)("Page %1$d of %2$d","moowoodle"),s,w)}),(0,d.jsx)("button",{disabled:s===w||m,onClick:()=>i(o=>Math.min(o+1,w)),children:(0,n.__)("Next","moowoodle")})]})]})};document.addEventListener("DOMContentLoaded",()=>{const o=document.getElementById("moowoodle-my-course");o&&(0,r.render)((0,d.jsx)(s,{}),o)})}},l={};function r(o){var t=l[o];if(void 0!==t)return t.exports;var n=l[o]={exports:{}};return e[o](n,n.exports,r),n.exports}r.m=e,o=[],r.O=(e,l,t,n)=>{if(!l){var a=1/0;for(c=0;c<o.length;c++){for(var[l,t,n]=o[c],d=!0,s=0;s<l.length;s++)(!1&n||a>=n)&&Object.keys(r.O).every(o=>r.O[o](l[s]))?l.splice(s--,1):(d=!1,n<a&&(a=n));if(d){o.splice(c--,1);var i=t();void 0!==i&&(e=i)}}return e}n=n||0;for(var c=o.length;c>0&&o[c-1][2]>n;c--)o[c]=o[c-1];o[c]=[l,t,n]},r.d=(o,e)=>{for(var l in e)r.o(e,l)&&!r.o(o,l)&&Object.defineProperty(o,l,{enumerable:!0,get:e[l]})},r.o=(o,e)=>Object.prototype.hasOwnProperty.call(o,e),r.r=o=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})},(()=>{var o={503:0};r.O.j=e=>0===o[e];var e=(e,l)=>{var t,n,[a,d,s]=l,i=0;if(a.some(e=>0!==o[e])){for(t in d)r.o(d,t)&&(r.m[t]=d[t]);if(s)var c=s(r)}for(e&&e(l);i<a.length;i++)n=a[i],r.o(o,n)&&o[n]&&o[n][0](),o[n]=0;return r.O(c)},l=globalThis.webpackChunkmoowoodle=globalThis.webpackChunkmoowoodle||[];l.forEach(e.bind(null,0)),l.push=e.bind(null,l.push.bind(l))})();var t=r.O(void 0,[268],()=>r(16248));t=r.O(t)})();