(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[57415],{1292:(t,e,r)=>{Promise.resolve().then(r.bind(r,26184))},10133:(t,e,r)=>{"use strict";r.d(e,{C_:()=>c,D9:()=>d,J4:()=>g,OM:()=>o,PG:()=>s,RD:()=>u,Wp:()=>f,YG:()=>p,kw:()=>l,tR:()=>h,zs:()=>m});var a=r(59185),i=r(76541),n=r(16099);let o=async t=>{try{let e=(await i.uE.get(n.Sn.COURSES.LIST,{params:t})).data;if(e.success&&e.data)return{data:e.data,pagination:e.pagination||{page:t?.page||1,limit:t?.limit||10,total:e.data.length,pages:1}};throw Error("Failed to fetch courses")}catch(t){throw Error((0,i.hS)(t))}},s=async t=>{try{let e=(await i.uE.get(n.Sn.COURSES.FILTER,{params:t})).data;if(e.success&&e.data)return{data:e.data,pagination:e.pagination||{page:t?.page||1,limit:t?.limit||10,total:e.data.length,pages:1}};throw Error("Failed to filter courses")}catch(t){throw Error((0,i.hS)(t))}},d=async()=>{try{let t=(await i.uE.get(n.Sn.COURSES.FEATURED_LIST)).data;if(t?.success&&Array.isArray(t.data)||Array.isArray(t?.data))return t.data;return[]}catch(t){return console.error("getFeaturedCourses error:",t),[]}},l=async()=>{try{let t=await i.uE.get(n.Sn.COURSES.ONGOING);return(0,i.yH)(t)}catch(t){throw Error((0,i.hS)(t))}},u=async()=>{try{return(await o({status:"UPCOMING_EVENTS",limit:20})).data||[]}catch{return[]}},p=async t=>{try{let e=await i.uE.get(n.Sn.COURSES.BY_ID(t)),r=e.data;if(r.success&&r.data)return r.data;return(0,i.yH)(e)}catch(t){throw Error((0,i.hS)(t))}},c=async t=>{try{if(t.onProgress?.(0),!t.title||!t.title.trim())throw Error("Title is required");let e=new FormData;e.append("title",t.title.trim()),t.instructorIds?.length&&e.append("instructorIds",JSON.stringify(t.instructorIds)),t.instructorId?.trim()&&e.append("instructorId",t.instructorId.trim()),t.slug&&e.append("slug",t.slug.trim()),t.description&&e.append("description",t.description),t.shortDescription&&e.append("shortDescription",t.shortDescription),t.thumbnail&&!t.thumbnailFile&&e.append("thumbnail",t.thumbnail),void 0!==t.price&&e.append("price",t.price.toString()),void 0!==t.originalPrice&&e.append("originalPrice",t.originalPrice.toString()),void 0!==t.isFree&&e.append("isFree",t.isFree.toString()),e.append("status",t.status||"PUBLISHED"),t.audienceType&&e.append("audienceType",t.audienceType),t.level&&e.append("level",t.level),void 0!==t.duration&&e.append("duration",t.duration.toString()),t.language&&e.append("language",t.language),void 0!==t.featured&&e.append("featured",t.featured.toString()),void 0!==t.isOngoing&&e.append("isOngoing",t.isOngoing.toString()),void 0!==t.startDate&&t.startDate&&e.append("startDate",t.startDate),void 0!==t.endDate&&t.endDate&&e.append("endDate",t.endDate),t.tags&&e.append("tags",t.tags),t.learningOutcomes&&Array.isArray(t.learningOutcomes)&&e.append("learningOutcomes",JSON.stringify(t.learningOutcomes)),t.skills&&Array.isArray(t.skills)&&e.append("skills",JSON.stringify(t.skills)),t.promoVideoSlots&&t.promoVideoSlots.length>0?(e.append("promoVideoSlots",JSON.stringify(t.promoVideoSlots)),t.videoFiles?.forEach(t=>e.append("video",t))):t.videoUrl&&t.videoUrl.trim()&&e.append("videoUrl",t.videoUrl.trim()),t.categoryId&&t.categoryId.trim()&&e.append("categoryId",t.categoryId.trim()),t.thumbnailFile&&e.append("thumbnail",t.thumbnailFile),!t.promoVideoSlots?.length&&t.videoFile&&e.append("video",t.videoFile),t.onProgress?.(0);let r=t.videoFile||t.thumbnailFile||t.videoFiles&&t.videoFiles.length>0,a=await i.uE.post(n.Sn.COURSES.LIST,e,{headers:{"Content-Type":"multipart/form-data"},timeout:r?72e5:12e4,onUploadProgress:e=>{if(t.onProgress){if(null!=e.total&&e.total>0){let r=Math.round(e.loaded/e.total*100);t.onProgress(Math.min(r,99))}else if(null!=e.loaded){let r=e.loaded/1048576,a=5+90*Math.min(1,r/200);t.onProgress(Math.min(Math.round(a),99))}}}});return t.onProgress?.(100),(0,i.yH)(a)}catch(e){if(a.A.isAxiosError(e)){if(console.error("Course creation error details:",{status:e.response?.status,statusText:e.response?.statusText,data:e.response?.data,message:e.message,requestData:{title:t.title,instructorId:t.instructorId,hasThumbnail:!!t.thumbnailFile}}),"ECONNABORTED"===e.code||e.message?.includes("timeout"))throw Error("Upload took too long. For 300MB+ videos use a fast connection or try a smaller file. You can also add the video later from the course edit page.");if(e.response?.status===408)throw Error("Request timed out during file upload. Please try again.");if(e.response?.status===400){let t=e.response.data;if(t?.errors&&Array.isArray(t.errors)&&t.errors.length>0){let e=t.errors.map(t=>{let e=t.param||t.path||t.field||"field",r=t.msg||t.message||"Invalid value";return`${e}: ${r}`}).join("\n");throw Error(`Validation failed:
${e}`)}throw Error((0,i.hS)(e))}if(e.response?.status===503)throw Error((0,i.hS)(e));if(!e.response)throw Error("Network error. Please check your internet connection and try again.")}throw Error((0,i.hS)(e))}},g=async(t,e)=>{try{let r=new FormData;e.title&&r.append("title",e.title.trim()),e.slug&&r.append("slug",e.slug),void 0!==e.description&&r.append("description",e.description),void 0!==e.shortDescription&&r.append("shortDescription",e.shortDescription),e.thumbnail&&!e.thumbnailFile&&r.append("thumbnail",e.thumbnail),void 0!==e.price&&r.append("price",e.price.toString()),void 0!==e.originalPrice&&r.append("originalPrice",e.originalPrice.toString()),void 0!==e.isFree&&r.append("isFree",e.isFree.toString()),void 0!==e.status&&r.append("status",e.status),void 0!==e.audienceType&&r.append("audienceType",e.audienceType||""),e.level&&r.append("level",e.level),void 0!==e.duration&&r.append("duration",e.duration.toString()),e.language&&r.append("language",e.language),void 0!==e.featured&&r.append("featured",e.featured.toString()),void 0!==e.isOngoing&&r.append("isOngoing",e.isOngoing.toString()),void 0!==e.startDate&&r.append("startDate",e.startDate||""),void 0!==e.endDate&&r.append("endDate",e.endDate||""),void 0!==e.tags&&r.append("tags",e.tags),e.promoVideoSlots&&e.promoVideoSlots.length>0?(r.append("promoVideoSlots",JSON.stringify(e.promoVideoSlots)),e.videoFiles?.forEach(t=>r.append("video",t))):e.promoVideoSlots&&0===e.promoVideoSlots.length?r.append("promoVideoSlots","[]"):void 0!==e.videoUrl&&r.append("videoUrl",null!==e.videoUrl?String(e.videoUrl).trim():""),void 0!==e.learningOutcomes&&(Array.isArray(e.learningOutcomes)&&e.learningOutcomes.length>0?r.append("learningOutcomes",JSON.stringify(e.learningOutcomes)):r.append("learningOutcomes","")),void 0!==e.skills&&(Array.isArray(e.skills)&&e.skills.length>0?r.append("skills",JSON.stringify(e.skills)):r.append("skills","")),e.instructorIds?.length&&r.append("instructorIds",JSON.stringify(e.instructorIds)),e.instructorId&&r.append("instructorId",e.instructorId.trim()),void 0!==e.categoryId&&r.append("categoryId",e.categoryId||""),e.thumbnailFile&&r.append("thumbnail",e.thumbnailFile),!e.promoVideoSlots?.length&&e.videoFile&&r.append("video",e.videoFile);let a=e.onProgress;a?.(0);let o=e.thumbnailFile||e.videoFile||e.videoFiles&&e.videoFiles.length>0,s=await i.uE.put(n.Sn.COURSES.BY_ID(t),r,{headers:{"Content-Type":"multipart/form-data"},timeout:o?72e5:6e4,onUploadProgress:t=>{if(a){if(null!=t.total&&t.total>0){let e=Math.round(t.loaded/t.total*100);a(Math.min(e,99))}else if(null!=t.loaded){let e=t.loaded/1048576,r=5+90*Math.min(1,e/200);a(Math.min(Math.round(r),99))}}}});return a?.(100),(0,i.yH)(s)}catch(t){if(a.A.isAxiosError(t)&&t.response?.status===400){let e=t.response.data;if(e?.errors&&Array.isArray(e.errors)&&e.errors.length>0){let t=e.errors.map(t=>{let e=t.param||t.path||t.field||"field",r=t.msg||t.message||"Invalid value";return`${e}: ${r}`}).join("\n");throw Error(`Validation failed:
${t}`)}}throw a.A.isAxiosError(t)&&t.response?.status,Error((0,i.hS)(t))}},h=async(t,e)=>{try{let r=(await i.uE.patch(n.Sn.COURSES.FEATURED(t),{featured:e})).data;if(r.success&&r.data)return r.data;throw Error(r.message||"Failed to update popular")}catch(t){throw Error((0,i.hS)(t))}},m=async t=>{try{await i.uE.delete(n.Sn.COURSES.BY_ID(t))}catch(t){throw Error((0,i.hS)(t))}},f=async(t,e)=>{try{let r=(await i.uE.post(n.Sn.COURSES.CERTIFICATE_TEMPLATE(t),e,{headers:{"Content-Type":"multipart/form-data"}})).data;if(r.success&&r.data)return r.data;throw Error(r.message||"Failed to upload certificate template")}catch(t){throw Error((0,i.hS)(t))}}},20112:(t,e,r)=>{"use strict";r.d(e,{s:()=>i});var a=r(76541);async function i(){let t=null;try{for(let e of["/affiliate/me","/affiliates/me"])try{let t=await a.uE.get(e);if(t.data.success&&t.data.data)return t.data.data}catch(e){if(t=e,e?.response?.status===404)continue;throw e}return null}catch(e){throw Error((0,a.hS)(t||e))}}},26184:(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>n});var a=r(95155),i=r(5420);function n(){return(0,a.jsx)(i.A,{})}},90927:(t,e,r)=>{"use strict";r.d(e,{B7:()=>c,Bw:()=>p,I9:()=>s,X8:()=>u,ae:()=>g,oG:()=>d}),r(86559);var a=r(76541);let i=["res.cloudinary.com"];function n(t){let e=t.toLowerCase();return"supabase.co"===e||e.endsWith(".supabase.co")||e.includes("datahub.com.np")||e.includes("s3-np1")}function o(t,e,r){let a=t.trim(),i=`url=${encodeURIComponent(a)}`;return`/api/media/image?${i}`}function s(t){return`/api/media/file?url=${encodeURIComponent(t.trim())}`}function d(t,e){if(!t||"string"!=typeof t)return"";let r=t.trim();if(!r)return"";if(r.startsWith("blob:")||r.startsWith("data:"))return r;let i=e??(0,a.getApiBaseUrl)();if(u(r)){let t=p(r,i);return t.includes("/media/image")?t:o(r,i)}return p(r,i)||r}function l(t){if(!t||"string"!=typeof t)return!1;let e=t.trim();return e.startsWith("/")&&!e.startsWith("//")}function u(t){if(!t||"string"!=typeof t)return!1;let e=t.trim();return!(!e||l(e)||e.startsWith("blob:")||e.startsWith("data:")||e.includes("/media/image")||e.includes("/storage/v1/object/sign/"))&&(!/^https?:\/\//i.test(e)||function(t){if(!t||!/^https?:\/\//i.test(t))return!1;try{let e=new URL(t);return n(e.hostname)||e.pathname.includes("/dplms-saas-bucket/")}catch{return!1}}(e)||function(t){try{let e=new URL(t);return"drive.google.com"===e.hostname||e.hostname.endsWith(".drive.google.com")||"docs.google.com"===e.hostname||e.hostname.endsWith(".googleusercontent.com")||"googleusercontent.com"===e.hostname}catch{return!1}}(e))}function p(t,e){if(!t||"string"!=typeof t)return"";let r=t.trim();return r?r.includes("/media/image")||r.includes("/storage/v1/object/sign/")||l(r)?r:!/^https?:\/\//i.test(r)||u(r)?o(r,e):r:""}function c(t,e){return d(t,e)}function g(t){if(!t||"string"!=typeof t)return!1;let e=t.trim();if(e.startsWith("blob:")||e.startsWith("data:"))return!1;try{if(e.startsWith("https://")||e.startsWith("http://"))return!0;let r=new URL(t).hostname.toLowerCase();return n(r)||i.some(t=>r===t||r.endsWith("."+t))}catch{return!1}}},99462:(t,e,r)=>{"use strict";r.d(e,{Fb:()=>g,b:()=>o,sK:()=>h});var a=r(73321),i=r(12115);let n="academy-route-change";function o(){window.dispatchEvent(new Event(n))}let s=new Set,d=!1;function l(){d||(d=!0,setTimeout(()=>{d=!1,s.forEach(t=>{try{t()}catch{}})},0))}function u(t){s.add(t);let e=()=>l();return window.addEventListener("popstate",e),window.addEventListener(n,e),()=>{s.delete(t),window.removeEventListener("popstate",e),window.removeEventListener(n,e)}}function p(){return window.location.pathname||"/"}function c(){return window.location.search||""}function g(){return(0,i.useSyncExternalStore)(u,c,()=>"")}function h(){let t=(0,a.usePathname)()||"/",e=(0,i.useSyncExternalStore)(u,p,()=>t);return((0,i.useEffect)(()=>{l()},[]),e&&e!==t)?e:t}}},t=>{t.O(0,[24777,66711,92619,59185,98500,5772,67530,76541,92106,33206,96329,5420,28441,93794,77358],()=>t(t.s=1292)),_N_E=t.O()}]);