import{d as C,U,q as k,r as D,x as N,ae as R,D as c,y as O,a7 as P,a as n,S as M,A as l,C as T,V as Q,a1 as K,z as H,Z as F}from"./index-74aaacd7.js";import{e as d,Q as p,C as A,D as $,K as z,P as V,i as j,A as W,a as G,R as X}from"./index-236256eb.js";import{M as q}from"./index-d2dfee14.js";import{u as Y,a as Z}from"./index-cc31fe60.js";import{S as J,a as ee}from"./index-7d601596.js";import{I as te}from"./index-418977f3.js";import"./index-2176a893.js";import"./index-2205fe72.js";import"./index-baa1bd27.js";const ne="_unitDetail_13q27_1",se="_unitSwipe_13q27_9",ie="_questionTitle_13q27_12",oe="_questionNum_13q27_21",ae="_questionType_13q27_24",ue="_wapList_13q27_31",le="_btnSection_13q27_37",re="_prevBtn_13q27_42",ce="_nextBtn_13q27_43",de="_activePrevBtn_13q27_44",pe="_right_13q27_67",fe="_error_13q27_70",ve="_minutes_13q27_73",o={unitDetail:ne,unitSwipe:se,questionTitle:ie,questionNum:oe,questionType:ae,wapList:ue,btnSection:le,prevBtn:re,nextBtn:ce,activePrevBtn:de,right:pe,error:fe,minutes:ve};function we(r){return typeof r=="function"||Object.prototype.toString.call(r)==="[object Object]"&&!K(r)}const Ee=C({name:"unit-detail",setup(){const r=U(),I=k(),f=D(),e=N({type:r.query.type,knowledgePointIds:r.query.knowledgePointIds,lessonCoursewareId:r.query.lessonCoursewareId,studentUnitExaminationId:"",background:"transparent",color:"#fff",visiableAnswer:!1,examDetail:{},currentIndex:0,time:0,questionList:[],visiableInfo:{show:!1,operationType:"RESULT",type:"DEFAULT",content:"",showCancelButton:!1,confirmButtonText:"",cancelButtonText:"",title:""},nextStatus:!1,swipeHeight:"auto",countDownOver:!1}),u=R({time:e.time,onChange(s){if(3e5>=s.total&&!e.countDownOver){if(e.visiableInfo.show){e.countDownOver=!0;return}e.visiableInfo.show=!0,e.visiableInfo.title="倒计时5分钟",e.visiableInfo.showCancelButton=!1,e.visiableInfo.operationType="TIME",e.visiableInfo.type="COUNTDOWN",e.visiableInfo.confirmButtonText="确认",e.visiableInfo.content="距离交卷时间还剩五分钟哦,请尽快答题~",e.countDownOver=!0}},onFinish:async()=>{d.emit("unitAudioStop"),await y(),b()}}),E=async()=>{try{let s={};if(e.type==="ai"){const{data:t}=await c.post("/edu-app/studentUnitExamination/pointRandomSave",{data:{knowledgePointIds:e.knowledgePointIds}});s=t||{}}else{const{data:t}=await c.post("/edu-app/studentUnitExamination/mockExamination",{data:{lessonCoursewareId:e.lessonCoursewareId}});s=t||{}}s.examinationQuestionAdds.forEach(t=>{t.showAnalysis=!1,t.analysis={message:t.answerAnalysis,topic:!0,userResult:!1},t.userAnswer=[]}),e.questionList=s.examinationQuestionAdds||[],e.studentUnitExaminationId=s.unitExaminationId,e.examDetail=s||{},L()}catch(s){}},L=async()=>{const t=(e.examDetail||{}).timeMinutes||0;e.time=Math.ceil(t*60*1e3),setTimeout(()=>{u.reset(t*60*1e3),u.start()},10)},S=async()=>{var s;e.nextStatus=!0;try{const t=e.questionList||[],a=[];if(t.forEach((i,m)=>{i.userAnswer&&i.userAnswer.length>0&&a.push({questionId:i.id,details:i.userAnswer})}),e.questionList.length===e.currentIndex+1){d.emit("unitAudioStop"),e.visiableInfo.show=!0,e.visiableInfo.title="测验完成",e.visiableInfo.showCancelButton=!0,e.visiableInfo.operationType="CONTINUE",e.visiableInfo.type="DEFAULT",e.visiableInfo.cancelButtonText="再等等",e.visiableInfo.confirmButtonText="确认完成",e.visiableInfo.content="确认本次测验的题目都完成了吗?",e.nextStatus=!1,b();return}await c.post("/edu-app/studentUnitExamination/submitAnswer",{hideLoading:!0,data:{answers:a,studentUnitExaminationId:e.studentUnitExaminationId}}),(s=f.value)==null||s.next()}catch(t){}e.nextStatus=!1};let h=0;const v=(s=!0)=>{H(()=>{s&&window.scrollTo(0,0),setTimeout(()=>{var x;const t=(x=document.querySelectorAll(".van-swipe-item")[e.currentIndex])==null?void 0:x.querySelector(".swipe-item-question"),a=t==null?void 0:t.querySelectorAll(".answerTitleImg img");let i=!0;a==null||a.forEach(B=>{B.complete||(i=!1)}),!i&&h<3&&setTimeout(()=>{h+=1,v(s)},300),i&&(h=0);const m=F(t);e.swipeHeight=m.height},100)})},g=()=>{e.visiableInfo.operationType==="RESULT"?(e.visiableInfo.show=!1,I.back(),I.back()):e.visiableInfo.operationType==="BACK"||e.visiableInfo.operationType==="CONTINUE"?y():e.visiableInfo.operationType==="TIME"&&(e.visiableInfo.show=!1)},_=async s=>{if(e.visiableInfo.operationType==="BACK"){if(s){e.visiableInfo.show=!1,window.history.pushState(null,"",document.URL),window.addEventListener("popstate",w,!1);return}try{await c.get("/edu-app/studentUnitExamination/dropExamination",{params:{studentUnitExaminationId:e.studentUnitExaminationId}}),e.visiableInfo.show=!1,b()}catch(t){}}else e.visiableInfo.operationType==="CONTINUE"&&(e.visiableInfo.show=!1,window.history.pushState(null,"",document.URL),window.addEventListener("popstate",w,!1))},y=async()=>{try{const s=e.questionList||[],t=[];s.forEach(i=>{i.userAnswer&&i.userAnswer.length>0&&t.push({questionId:i.id,details:i.userAnswer})});const{data:a}=await c.post("/edu-app/studentUnitExamination/completionExamination",{hideLoading:!1,data:{answers:t,studentUnitExaminationId:e.studentUnitExaminationId}});e.visiableInfo.show=!0,e.visiableInfo.title=a.score+"分",e.visiableInfo.showCancelButton=!1,e.visiableInfo.operationType="RESULT",e.visiableInfo.confirmButtonText="确认",a.status==="A_EXCELLENT"?(e.visiableInfo.type="GOOD",e.visiableInfo.content="