1import{t as w,I as _,e as d,q as E,y as p,r as m,v as A,m as B,x as y,N as $,u as C,F as u}from"./vendor-firebase-NOrVjYbK.js";import{av as g,b7 as T,k as c}from"./index-C0esqoXR.js";import{c as k}from"./groupsApi-CtFxURg_.js";const h=99,{getUserGroups:G,createGroup:L,renameGroup:R,deleteGroup:S,setItemGroup:b}=k({parent:"head_tilt_lessons",items:"lessons"});async function M(r,t){if(g(),!t.questions||t.questions.length===0)throw new Error("Bà i há»c phải có Ãt nhất 1 câu há»i");if(t.questions.length>h)throw new Error(`Bà i há»c chá» ÄÆ°á»£c tá»i Äa ${h} câu há»i`);t.questions.forEach((s,i)=>{if((!s.questionText||!s.questionText.trim())&&!s.questionImage)throw new Error(`Câu há»i ${i+1} không ÄÆ°á»£c Äá» trá»ng`);if((!s.answerA||!s.answerA.trim())&&!s.imageA)throw new Error(`Câu há»i ${i+1}: Äáp án A không ÄÆ°á»£c Äá» trá»ng`);if((!s.answerB||!s.answerB.trim())&&!s.imageB)throw new Error(`Câu há»i ${i+1}: Äáp án B không ÄÆ°á»£c Äá» trá»ng`);if(s.correctAnswer!=="A"&&s.correctAnswer!=="B")throw new Error(`Câu há»i ${i+1}: Phải chá»n Äáp án Äúng là A hoặc B`)});const o=w(c,"head_tilt_lessons",r,"lessons"),n={...t,createdAt:u(),updatedAt:u()},e=await _(o,n);return await T(r,"headTiltQuiz",1),{id:e.id,...n}}const l=8;async function v(r,t=null){const o=w(c,"head_tilt_lessons",r,"lessons"),n=[A("createdAt","desc"),y(l+1)];t&&n.splice(1,0,$(t));const s=(await p(m(o,...n))).docs,i=s.length>l,a=i?s.slice(0,l):s;return{lessons:a.map(f=>({id:f.id,...f.data()})),lastDoc:a.length>0?a[a.length-1]:null,hasMore:i}}async function I(r){const t=w(c,"head_tilt_lessons",r,"lessons");return(await p(m(t,A("createdAt","desc")))).docs.map(n=>{var i,a;const e=n.data(),s=(i=e.createdAt)!=null&&i.toMillis?e.createdAt.toMillis():(a=e.createdAt)!=null&&a.seconds?e.createdAt.seconds*1e3:null;return{id:n.id,...e,createdAtMillis:s}})}async function P(r,t){const o=d(c,"head_tilt_lessons",r,"lessons",t),n=await B(o);if(!n.exists())throw new Error("Không tìm thấy bà i há»c");return{id:n.id,...n.data()}}async function j(r,t,o){if(g(),o.questions){if(o.questions.length>h)throw new Error(`Bà i há»c chá» ÄÆ°á»£c tá»i Äa ${h} câu há»i`);o.questions.forEach((e,s)=>{if((!e.questionText||!e.questionText.trim())&&!e.questionImage)throw new Error(`Câu há»i ${s+1} không ÄÆ°á»£c Äá» trá»ng`);if((!e.answerA||!e.answerA.trim())&&!e.imageA)throw new Error(`Câu há»i ${s+1}: Äáp án A không ÄÆ°á»£c Äá» trá»ng`);if((!e.answerB||!e.answerB.trim())&&!e.imageB)throw new Error(`Câu há»i ${s+1}: Äáp án B không ÄÆ°á»£c Äá» trá»ng`);if(e.correctAnswer!=="A"&&e.correctAnswer!=="B")throw new Error(`Câu há»i ${s+1}: Phải chá»n Äáp án Äúng là A hoặc B`)})}const n=d(c,"head_tilt_lessons",r,"lessons",t);await C(n,{...o,updatedAt:u()})}async function D(r,t){g();const o=d(c,"head_tilt_lessons",r,"lessons",t);await E(o)}const N=Object.freeze(Object.defineProperty({__proto__:null,createGroup:L,createLesson:M,deleteGroup:S,deleteLesson:D,getAllLessons:I,getLesson:P,getLessons:v,getUserGroups:G,renameGroup:R,setItemGroup:b,updateLesson:j},Symbol.toStringTag,{value:"Module"}));export{P as a,M as c,D as d,I as g,N as h,j as u};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.