{"version":3,"file":"draft.cjs","sources":["../../../../packages/components-wc/src/subject/draft.ts"],"sourcesContent":["import { uid } from '../base/uid'\nimport { type AnswerType, type SubjectItemType, SubjectType } from './types'\n\nexport interface CreateSubjectDraftOptions {\n  examAnswerRelationType?: number | null\n}\n\nfunction createChoiceAnswers(count: number) {\n  return Array.from({ length: count }, () => ({ title: '', isCorrect: false }))\n}\n\nfunction createScaleAnswers(count: number) {\n  return Array.from({ length: count }, (_, index) => ({ title: '', orderIndex: index + 1 }))\n}\n\nexport function createSubjectDraft(type: SubjectItemType, options: CreateSubjectDraftOptions = {}) {\n  if (type === SubjectType.PAGE_END) {\n    return {\n      customId: uid(),\n      answerType: SubjectType.PAGE_END,\n    }\n  }\n\n  const base = {\n    customId: uid(),\n    answerType: type as AnswerType,\n    title: '',\n    analysis: '',\n    isEdit: true,\n    examRichTextContent: '',\n  }\n\n  if (type === SubjectType.SINGLE || type === SubjectType.MULTIPLE || type === SubjectType.SORT) {\n    return {\n      ...base,\n      answers: createChoiceAnswers(4),\n      ...(type === SubjectType.SORT ? { leastAnswerCount: null, examExpand: '' } : {}),\n      ...(options.examAnswerRelationType != null ? { examAnswerRelationType: options.examAnswerRelationType } : {}),\n    }\n  }\n\n  if (type === SubjectType.BLANK_FILL) {\n    return {\n      ...base,\n      answers: [],\n      examAnswerSettingBO: { isInOrder: false, isIgnoreCase: true },\n    }\n  }\n\n  if (type === SubjectType.TEXT_FILL) {\n    return {\n      ...base,\n      answers: [{ title: '', tag: '', showInput: false }],\n      examAnswerSettingBO: { isInOrder: false, isIgnoreCase: true },\n      examExpand: '',\n    }\n  }\n\n  if (type === SubjectType.SCALE) {\n    return {\n      ...base,\n      answers: createScaleAnswers(5),\n      scaleQuestionList: [],\n    }\n  }\n\n  return {\n    ...base,\n    answers: [],\n  }\n}\n"],"names":["createScaleAnswers","count","Array","from","length","_","index","title","orderIndex","type","options","arguments","undefined","SubjectType","PAGE_END","customId","uid","answerType","base","analysis","isEdit","examRichTextContent","SINGLE","MULTIPLE","SORT","answers","isCorrect","leastAnswerCount","examExpand","examAnswerRelationType","BLANK_FILL","examAnswerSettingBO","isInOrder","isIgnoreCase","TEXT_FILL","tag","showInput","SCALE","scaleQuestionList"],"mappings":"uEAWA,SAASA,EAAmBC,GAC1B,OAAOC,MAAMC,KAAK,CAAEC,OAAQH,GAAS,CAACI,EAAGC,KAAA,CAAaC,MAAO,GAAIC,WAAYF,EAAQ,IACvF,4BAEO,SAA4BG,GAAgE,IAAzCC,EAAAC,UAAAP,OAAA,QAAAQ,IAAAD,UAAA,GAAAA,UAAA,GAAqC,CAAA,EAC7F,GAAIF,IAASI,EAAAA,YAAYC,SACvB,MAAO,CACLC,SAAUC,EAAAA,MACVC,WAAYJ,EAAAA,YAAYC,UAI5B,MAAMI,EAAO,CACXH,SAAUC,EAAAA,MACVC,WAAYR,EACZF,MAAO,GACPY,SAAU,GACVC,QAAQ,EACRC,oBAAqB,IAGvB,OAAIZ,IAASI,cAAYS,QAAUb,IAASI,EAAAA,YAAYU,UAAYd,IAASI,EAAAA,YAAYW,KAChF,IACFN,EACHO,SA5BuBxB,EA4BM,EA3B1BC,MAAMC,KAAK,CAAEC,OAAQH,GAAS,KAAA,CAASM,MAAO,GAAImB,WAAW,SA4B5DjB,IAASI,EAAAA,YAAYW,KAAO,CAAEG,iBAAkB,KAAMC,WAAY,IAAO,MACvC,MAAlClB,EAAQmB,uBAAiC,CAAEA,uBAAwBnB,EAAQmB,wBAA2B,CAAA,GAI1GpB,IAASI,EAAAA,YAAYiB,WAChB,IACFZ,EACHO,QAAS,GACTM,oBAAqB,CAAEC,WAAW,EAAOC,cAAc,IAIvDxB,IAASI,EAAAA,YAAYqB,UAChB,IACFhB,EACHO,QAAS,CAAC,CAAElB,MAAO,GAAI4B,IAAK,GAAIC,WAAW,IAC3CL,oBAAqB,CAAEC,WAAW,EAAOC,cAAc,GACvDL,WAAY,IAIZnB,IAASI,EAAAA,YAAYwB,MAChB,IACFnB,EACHO,QAASzB,EAAmB,GAC5BsC,kBAAmB,IAIhB,IACFpB,EACHO,QAAS,IA7Db,IAA6BxB,CA+D7B"}