1"use strict";(self.webpackChunklearning_go=self.webpackChunklearning_go||[]).push([[7241,9839],{7241:(e,t,n)=>{n.r(t),n.d(t,{default:()=>$a});var l=n(65043),s=n(91688),a=n(40812),i=n(48927),o=n(40790),r=n(45726),c=n(75200),d=n(74725),u=n(26321),w=n(89379),p=n(48304),m=n(27528),x=n(74904),b=n(89376),v=n(63248),h=n(28261),f=n(99723),g=n(47097),j=n(43550),y=n(80045),A=n(40854),E=n.n(A),I=n(45543);const N={certificates:{path:"/certificates/fullinfo",rowsKey:"certificates"},courses:{path:"/courses/fullinfo",rowsKey:"courses",parentField:"certificateId"},units:{path:"/units/fullinfo",rowsKey:"units",parentField:"courseId",ranked:!0},topics:{path:"/topics/fullinfo",rowsKey:"topics",parentField:"unitId",ranked:!0,contextFields:["courseName","unitName"]},sizes:{path:"/questions/sizes/fullinfo",rowsKey:"data"}},q=["nameEn","nameAr"],R=10;function C(){let{parentField:e,parentId:t,ranked:n,search:l}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const s=[];e&&t&&s.push([e,"=",t]);const a=String(null!==l&&void 0!==l?l:"").trim();if(a&&s.push((e=>e?[...q,"rank"]:q)(n).flatMap((e,t)=>t?["or",[e,"contains",a]]:[[e,"contains",a]])),s.length)return 1===s.length?s[0]:[s[0],"and",s[1]]}function k(e){return e.flatMap((e,t)=>t?["or",["id","=",e]]:[["id","=",e]])}function _(e,t,n){var l;const s=null!==(l=t?e.nameAr:e.nameEn)&&void 0!==l?l:"";return n&&s&&null!=e.rank&&""!==e.rank?"".concat(s," (").concat(e.rank,")"):s}function S(e,t){return(null!==t&&void 0!==t?t:[]).map(t=>e[t]).filter(Boolean).join(" / ")}
1const Y=(e,t,n)=>{const l=N[n];return{value:e.id,label:_(e,t,null===l||void 0===l?void 0:l.ranked),context:S(e,null===l||void 0===l?void 0:l.contextFields),certificateId:e.certificateId,courseId:e.courseId,unitId:e.unitId}},M={MCQ_SINGLE:"MCQ_SINGLE",MCQ_MULTI:"MCQ_MULTI",NUMERIC:"NUMERIC",CATEGORIZATION:"CATEGORIZATION",SEQUENCE:"SEQUENCE",CLOZE:"CLOZE"},T=[M.MCQ_SINGLE,M.MCQ_MULTI,M.NUMERIC,M.CATEGORIZATION,M.SEQUENCE,M.CLOZE],P={EASY:"EASY",MID:"MID",HARD:"HARD"},O={THEORY:"THEORY",PRACTICAL:"PRACTICAL"},G={KNOWLEDGE:"KNOWLEDGE",COMPREHENSION:"COMPREHENSION",APPLICATION:"APPLICATION",ANALYSIS:"ANALYSIS",SYNTHESIS:"SYNTHESIS",EVALUATION:"EVALUATION"},F={ACTIVE:"ACTIVE",INACTIVE:"INACTIVE"},z={BANK:"BANK",MOCK:"MOCK",FREQ:"FREQ"},D="CBQ",B="STANDARD",L="RANDOM",Q="__",U=e=>e!==M.MCQ_SINGLE&&e!==M.MCQ_MULTI,V=e=>"cbq.types.".concat(e,".label"),H=e=>"cbq.types.".concat(e,".hint"),K=/[\u200B-\u200F\u202A-\u202E\u2060\uFEFF]/g,W=e=>(e=>{var t;return e.includes("&")?"undefined"===typeof DOMParser?e.replace(/&(?:[a-z\d]+|#\d+|#x[\da-f]+);/gi," "):null!==(t=(new DOMParser).parseFromString("<!doctype html><body>".concat(e),"text/html").body.textContent)&&void 0!==t?t:"":e})(String(null!==e&&void 0!==e?e:"").replace(/<[^>]*>/g," ")).replace(K,"").replace(/\s+/g," ").trim(),Z=/<img\b/i,$=e=>0===W(e).length&&!Z.test(String(null!==e&&void 0!==e?e:"")),X=new RegExp("(<[^>]*>)|".concat(Q),"g"),J=(e,t)=>{let n=0;return String(null!==e&&void 0!==e?e:"").replace(X,(e,l)=>{if(l)return l;const s=t(n);return n+=1,s})},ee=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,te=/[A-Za-z\u00C0-\u024F\u0370-\u03FF\u0400-\u04FF\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,ne=e=>{const t=W(e).match(te);if(t)return ee.test(t[0])?"rtl":"ltr"},le=/<img\b[^>]*\ssrc\s*=\s*["']?(?:data|blob):/i,se=e=>"string"===typeof e?le.test(e):!(!e||"object"!==typeof e)&&Object.values(e).some(se),ae=function(){for(var e,t=arguments.length,n=new Array(t),l=0;l<t;l++)n[l]=arguments[l];return null!==(e=n.find(e=>!$(e)))&&void 0!==e?e:""},ie=(e,t,n)=>e?ae(t,n):ae(n,t),oe=e=>{const t=W(e);return t?t.split(Q).length-1:0};let re=0;const ce=function(){return re+=1,"".concat(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"row","-").concat(re,"-").concat(Math.random().toString(36).slice(2,8))},de="VIDEO",ue=1048576,we={[de]:{accept:"video/mp4,.mp4",extensions:["mp4"],maxBytes:512*ue}},pe=function(){const e=String(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").toLowerCase().split(".");return e.length>1?e.pop():""};function me(e){const t=Number(e);return t?t<ue?"".concat(Math.max(1,Math.round(t/1024))," KB"):"".concat((t/ue).toFixed(t<10*ue?1:0)," MB"):""}function xe(e){const t=Math.round(Number(e)||0);return t?"".concat(Math.floor(t/60),":").concat(String(t%60).padStart(2,"0")):""}const be=/^\d{10,}_/;function ve(e){var t,n;const l=String(null!==e&&void 0!==e?e:"").split(/[?#]/)[0].split("/").filter(Boolean);let s=null!==(t=l.pop())&&void 0!==t?t:"";return"m3u8"===pe(s)&&(s=null!==(n=l.pop())&&void 0!==n?n:""),(e=>{try{return decodeURIComponent(e)}catch(t){return e}})(s).replace(be,"")}const he=e=>(null===e||void 0===e?void 0:e.name)||ve(null===e||void 0===e?void 0:e.url),fe=e=>!["ENC_PEND","ENC_FAIL"].includes(null===e||void 0===e?void 0:e.status),ge=(e,t)=>(0,w.A)({key:ce("med"),kind:e,id:null,url:"",name:"",status:"",sizeInBytes:0,lengthSeconds:0,synced:!1},t),je=(e,t,n)=>{var l;return ge(e,(0,w.A)((0,w.A)({},t),{},{name:null!==(l=null===n||void 0===n?void 0:n.name)&&void 0!==l?l:""}))},ye=e=>{var t,n,l,s,a;return ge(de,{key:"video-".concat(null===e||void 0===e?void 0:e.id),id:null!==(t=null===e||void 0===e?void 0:e.id)&&void 0!==t?t:null,url:null!==(n=null===e||void 0===e?void 0:e.urlEn)&&void 0!==n?n:"",name:null!==(l=null!==(s=null===e||void 0===e?void 0:e.nameEn)&&void 0!==s?s:null===e||void 0===e?void 0:e.nameAr)&&void 0!==l?l:"",status:null!==(a=null===e||void 0===e?void 0:e.status)&&void 0!==a?a:"",sizeInBytes:Number(null===e||void 0===e?void 0:e.sizeInBytesEn)||0,lengthSeconds:Number(null===e||void 0===e?void 0:e.lengthSecondsEn)||0,synced:!0})};function Ae(e,t){return{toAttach:e.filter(e=>!e.id&&!e.synced),toDetach:t.filter(e=>e.id)}}const Ee=(e,t)=>{const{toAttach:n,toDetach:l}=Ae(e,t);return n.length>0||l.length>0},Ie=()=>({id:ce("cls"),certificateId:"",courseId:"",unitId:"",topicIds:[]}),Ne=()=>({id:ce("opt"),textAr:"",textEn:"",explanationAr:"",explanationEn:"",correct:!1}),qe=()=>({id:ce("nb"),correctAnswer:""}),Re=()=>({id:ce("cat"),nameAr:"",nameEn:""}),Ce=()=>({id:ce("cit"),textAr:"",textEn:"",categoryId:""}),ke=()=>({id:ce("seq"),textAr:"",textEn:""}),_e=()=>({id:ce("cop"),textAr:"",textEn:"",correct:!1}),Se=()=>({id:ce("cb"),options:[_e(),_e()]}),Ye=()=>({mcq:{shuffle:!0,options:[Ne(),Ne(),Ne(),Ne()]},numeric:{templateAr:"",templateEn:"",blanks:[]},categorization:{categories:[Re(),Re()],items:[Ce(),Ce()]},sequence:{shuffle:!0,items:[ke(),ke(),ke()]},cloze:{templateAr:"",templateEn:"",blanks:[]}}),Me=function(){return{id:null,type:arguments.length>0&&void 0!==arguments[0]?arguments[0]:M.MCQ_SINGLE,meta:{classifications:[Ie()],difficulty:P.MID,category:O.THEORY,conceptType:"",durationSeconds:60,usedIn:[z.BANK],questionSizeId:"",rank:"",status:F.INACTIVE},titleAr:"",titleEn:"",explanationAr:"",explanationEn:"",payload:Ye()}},Te=()=>({id:null,titleAr:"",titleEn:"",descriptionAr:"",descriptionEn:"",imageUrl:"",status:F.INACTIVE}),Pe=e=>!String(null!==e&&void 0!==e?e:"").trim(),Oe=function(e){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:$)(e)?"":e};var Ge=n(6070);const Fe=e=>String(null!==e&&void 0!==e?e:"").replace(/[^0-9.()-]/g,""),ze=e=>{const t=Fe(e),n=t.includes("(")||t.trimStart().startsWith("-"),l=t.replace(/[()-]/g,""),[s="",...a]=l.split(".");return{negative:n,digits:s,decimals:a.join("").slice(0,10),hasDecimalPoint:l.includes(".")}},De=e=>{const{negative:t,digits:n,decimals:l,hasDecimalPoint:s}=ze(e);if(!n&&!l)return"";const a=s&&l?"".concat(n||"0",".").concat(l):n||"0";return t?"-".concat(a):a},Be=e=>{const{negative:t,digits:n,decimals:l,hasDecimalPoint:s}=ze(e);if(!n&&!l&&!s)return"";let a=n?(0,Ge.A)(Number(n)).format({thousandSeparated:!0,mantissa:0}):"0";
1return s&&(a+=".".concat(l)),t?"-".concat(a):a},Le={[M.MCQ_SINGLE]:"mcq",[M.MCQ_MULTI]:"mcq",[M.NUMERIC]:"numeric",[M.CATEGORIZATION]:"categorization",[M.SEQUENCE]:"sequence",[M.CLOZE]:"cloze"},Qe=e=>{var t;return null!==(t=Le[e])&&void 0!==t?t:"mcq"},Ue=e=>Boolean(e&&Le[e]);function Ve(e,t){const n={};return $(e)||(n.ar=e),$(t)||(n.en=t),Object.keys(n).length?n:void 0}const He=e=>{var t,n;return{ar:null!==(t=null===e||void 0===e?void 0:e.ar)&&void 0!==t?t:"",en:null!==(n=null===e||void 0===e?void 0:e.en)&&void 0!==n?n:""}};function Ke(e,t){const n=Ve(e,t);return n?{text:n}:void 0}const We=e=>He(null===e||void 0===e?void 0:e.text),Ze=/\{\{slot:([^}]+)\}\}/g;function $e(e,t){if(!$(e))return J(e,e=>t[e]?"{{slot:".concat(t[e],"}}"):"__")}const Xe=e=>String(null!==e&&void 0!==e?e:"").replace(Ze,"__");function Je(e,t,n){const l=$e(e,n),s=$e(t,n);return(0,w.A)((0,w.A)({},l?{ar:l}:{}),s?{en:s}:{})}const et=e=>e?L:B,tt=e=>e!==B,nt=e=>{var t;return{id:String(e.id),text:null!==(t=Ve(e.textAr,e.textEn))&&void 0!==t?t:{en:""}}},lt=e=>(0,w.A)((0,w.A)({},nt(e)),{},{explanation:{text:{en:""}}}),st=e=>{var t;return(0,w.A)((0,w.A)({},nt(e)),{},{explanation:null!==(t=Ke(e.explanationAr,e.explanationEn))&&void 0!==t?t:{text:{en:""}}})},at=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=He(null===e||void 0===e?void 0:e.text);return(0,w.A)({id:null===e||void 0===e?void 0:e.id,textAr:n.ar,textEn:n.en},t)};function it(e){const{shuffle:t,options:n}=e.payload.mcq,l=n.filter(e=>e.correct).map(e=>String(e.id)),s={sort:et(t),options:n.map(st),correctIds:l};return e.type===M.MCQ_MULTI&&(s.requiredSelCnt=l.length),s}const ot={[M.MCQ_SINGLE]:it,[M.MCQ_MULTI]:it,[M.SEQUENCE]:function(e){const{shuffle:t,items:n}=e.payload.sequence;return{sort:et(t),options:n.map(lt),correctIds:n.map(e=>String(e.id))}},[M.CATEGORIZATION]:function(e){const{categories:t,items:n}=e.payload.categorization;return{slots:t.map(e=>{var t;return{id:String(e.id),text:null!==(t=Ve(e.nameAr,e.nameEn))&&void 0!==t?t:{en:""}}}),options:n.map(e=>{var t;return{id:String(e.id),text:null!==(t=Ve(e.textAr,e.textEn))&&void 0!==t?t:{en:""}}}),correctIds:n.reduce((e,t)=>(e[String(t.id)]=String(t.categoryId),e),{})}},[M.CLOZE]:function(e){const{templateAr:t,templateEn:n,blanks:l}=e.payload.cloze;return{text:Je(t,n,l.map(e=>String(e.id))),slots:l.map(e=>({id:String(e.id),options:e.options.map(lt)})),correctIds:l.reduce((e,t)=>{var n;const l=null!==(n=t.options.find(e=>e.correct))&&void 0!==n?n:t.options[0];return l&&(e[String(t.id)]=String(l.id)),e},{})}},[M.NUMERIC]:function(e){const{templateAr:t,templateEn:n,blanks:l}=e.payload.numeric;return{text:Je(t,n,l.map(e=>String(e.id))),slots:l.map(e=>({id:String(e.id),explanation:{text:{en:""}}}))}}};function rt(e){const t={version:1,type:e.type,body:ot[e.type](e)},n=Ke(e.titleAr,e.titleEn);n&&(t.head=n);const l=U(e.type)?Ke(e.explanationAr,e.explanationEn):void 0;return l&&(t.explanation=l),e.type===M.NUMERIC&&(t.correctIds=e.payload.numeric.blanks.reduce((e,t)=>(e[String(t.id)]={value:Number(De(t.correctAnswer))},e),{})),t}function ct(e){var t,n;const l=new Set((null!==(t=null===e||void 0===e?void 0:e.correctIds)&&void 0!==t?t:[]).map(String));return{shuffle:tt(null===e||void 0===e?void 0:e.sort),options:(null!==(n=null===e||void 0===e?void 0:e.options)&&void 0!==n?n:[]).map(e=>function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=We(null===e||void 0===e?void 0:e.explanation);return at(e,(0,w.A)({explanationAr:n.ar,explanationEn:n.en},t))}(e,{correct:l.has(String(null===e||void 0===e?void 0:e.id))}))}}function dt(e,t){const n=Ye();return(0,w.A)((0,w.A)({},n),{},{[e]:(0,w.A)((0,w.A)({},n[e]),t)})}function ut(e){var t;const n="string"===typeof e?wt(e):e,l=null===n||void 0===n?void 0:n.type;if(!l||!Le[l]){const e=Me();return{type:e.type,titleAr:"",titleEn:"",explanationAr:"",explanationEn:"",payload:e.payload}}const s=We(n.head),a=We(n.explanation),i=Qe(l),o=null!==(t=n.body)&&void 0!==t?t:{},r={mcq:()=>ct(o),sequence:()=>function(e){var t,n;const l=null!==(t=null===e||void 0===e?void 0:e.options)&&void 0!==t?t:[],s=new Map(l.map(e=>[String(null===e||void 0===e?void 0:e.id),e])),a=(null!==(n=null===e||void 0===e?void 0:e.correctIds)&&void 0!==n?n:[]).map(String),i=new Set(a
1),o=a.map(e=>s.get(e)).filter(Boolean),r=l.filter(e=>!i.has(String(null===e||void 0===e?void 0:e.id)));return{shuffle:tt(null===e||void 0===e?void 0:e.sort),items:[...o,...r].map(e=>at(e))}}(o),categorization:()=>function(e){var t,n,l;const s=null!==(t=null===e||void 0===e?void 0:e.correctIds)&&void 0!==t?t:{};return{categories:(null!==(n=null===e||void 0===e?void 0:e.slots)&&void 0!==n?n:[]).map(e=>{const t=He(null===e||void 0===e?void 0:e.text);return{id:null===e||void 0===e?void 0:e.id,nameAr:t.ar,nameEn:t.en}}),items:(null!==(l=null===e||void 0===e?void 0:e.options)&&void 0!==l?l:[]).map(e=>{var t;const n=He(null===e||void 0===e?void 0:e.text);return{id:null===e||void 0===e?void 0:e.id,textAr:n.ar,textEn:n.en,categoryId:null!==(t=s[String(null===e||void 0===e?void 0:e.id)])&&void 0!==t?t:""}})}}(o),cloze:()=>function(e){var t,n,l,s;const a=null!==(t=null===e||void 0===e?void 0:e.correctIds)&&void 0!==t?t:{};return{templateAr:Xe(null===e||void 0===e||null===(n=e.text)||void 0===n?void 0:n.ar),templateEn:Xe(null===e||void 0===e||null===(l=e.text)||void 0===l?void 0:l.en),blanks:(null!==(s=null===e||void 0===e?void 0:e.slots)&&void 0!==s?s:[]).map(e=>{var t;return{id:null===e||void 0===e?void 0:e.id,options:(null!==(t=null===e||void 0===e?void 0:e.options)&&void 0!==t?t:[]).map(t=>at(t,{correct:String(a[String(null===e||void 0===e?void 0:e.id)])===String(null===t||void 0===t?void 0:t.id)}))}})}}(o),numeric:()=>function(e){var t,n,l;let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return{templateAr:Xe(null===e||void 0===e||null===(t=e.text)||void 0===t?void 0:t.ar),templateEn:Xe(null===e||void 0===e||null===(n=e.text)||void 0===n?void 0:n.en),blanks:(null!==(l=null===e||void 0===e?void 0:e.slots)&&void 0!==l?l:[]).map(e=>{const t=s[String(null===e||void 0===e?void 0:e.id)];return{id:null===e||void 0===e?void 0:e.id,correctAnswer:null==(null===t||void 0===t?void 0:t.value)?"":String(t.value)}})}}(o,n.correctIds)}[i]();return{type:l,titleAr:s.ar,titleEn:s.en,explanationAr:a.ar,explanationEn:a.en,payload:dt(i,r)}}function wt(e){try{return JSON.parse(e)}catch(t){return null}}function pt(e){return e?"object"===typeof e?e:wt(e):null}const mt=(e,t)=>(Array.isArray(e)?e:String(null!==e&&void 0!==e?e:"").split(",")).map(e=>String(e).trim()).filter(e=>e in t),xt=e=>mt(e,z),bt=e=>{var t;return[...new Set((null!==(t=null===e||void 0===e?void 0:e.classifications)&&void 0!==t?t:[]).flatMap(e=>{var t;return null!==(t=e.topicIds)&&void 0!==t?t:[]}).map(Number).filter(Number.isFinite))]};function vt(e){var t;let{factId:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{meta:l}=e,s=String(null!==(t=l.rank)&&void 0!==t?t:"").trim();return{factId:null==n?void 0:Number(n),topicsIds:bt(l),questionSubType:e.type,questionCateg:l.category,questionDifficult:l.difficulty,questionSizeId:Number(l.questionSizeId),conceptType:l.conceptType,durationSeconds:Number(l.durationSeconds),rank:s||void 0,useForExam:l.usedIn,isActive:l.status===F.ACTIVE,textAr:Oe(e.titleAr),textEn:Oe(e.titleEn),contentJson:JSON.stringify(rt(e))}}function ht(e){var t,n,l,s,a;let{classifications:i}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const o=Me(),r=ut(null===e||void 0===e?void 0:e.contentJson);return(0,w.A)((0,w.A)({},r),{},{id:null!==(t=null===e||void 0===e?void 0:e.id)&&void 0!==t?t:null,titleAr:ae(r.titleAr,null===e||void 0===e?void 0:e.textAr),titleEn:ae(r.titleEn,null===e||void 0===e?void 0:e.textEn),meta:{classifications:null!==i&&void 0!==i&&i.length?i:o.meta.classifications,difficulty:null!==(n=null===e||void 0===e?void 0:e.questionDifficult)&&void 0!==n?n:o.meta.difficulty,category:null!==(l=null===e||void 0===e?void 0:e.questionCateg)&&void 0!==l?l:o.meta.category,conceptType:null!==(s=null===e||void 0===e?void 0:e.conceptType)&&void 0!==s?s:"",durationSeconds:Number(null===e||void 0===e?void 0:e.durationSeconds)||o.meta.durationSeconds,usedIn:xt(null===e||void 0===e?void 0:e.useForExam),questionSizeId:null!==(a=null===e||void 0===e?void 0:e.questionSizeId)&&void 0!==a?a:"",rank:null==(null===e||void 0===e?void 0:e.rank)?"":String(e.rank),status:null!==e&&void 0!==e&&e.isActive?F.ACTIVE:F.INACTIVE}})}const ft=e=>({factTitleAr:Oe(e.titleAr,Pe),factTitleEn:Oe(e.titleEn,Pe),factContentAr:Oe(e.descriptionAr),factContentEn:Oe(e.descriptionEn),imgUrl:e.imageUrl||null,isActive:e.status===F.ACTIVE,useFor:D}),gt=e=>{var t,n,l,s,a,i,o;return{id:null===e||void 0===e?void 0:e.id,titleAr:null!==(t=null===e||void 0===e?void 0:e.factTitleAr)&&void 0!==t?t:"",titleEn:null!==(n=null===e||void 0===e?void 0:e.factTitleEn)&&void 0!==n?n:"",descriptionAr:null!==(l=null===e||void 0===e?void 0:e.factContentAr)&&void 0!==l?l:"",descriptionEn:null!==(s=null===e||void 0===e?void 0:e.factContentEn)&&void 0!==s?s:"",imageUrl:null!==(a=null===e||void 0===e?void 0:e.imgUrl)&&void 0!==a?a:"",status:null!==e&&void 0!==e&&e.isActive?F.ACTIVE:F.INACTIVE,createdAt:(null!==(i=null!==(o=null===e||void 0===e?void 0:e.creatAt)&&void 0!==o?o:null===e||void 0===e?void 0:e.createdAt)&&void 0!==i?i:"").toString().slice(0,10),questionsCount:null==(null===e||void 0===e?void 0:e.questionsCount)?null:Number(e.questionsCount)||0}},jt=["topicsIds"],yt=3e4,At={all:["cbq"],facts:e=>[...At.all,"facts",null!==e&&void 0!==e?e:{}],fact:e=>[...At.all,"fact",e],factQuestions:(e,t)=>[...At.all,"fact",e,"questions",...t?[t]:[]],factQuestion:(e,t)=>[...At.all,"fact",e,"questions","one",t],questionTopics:e=>[...At.all,"question",e,"topics"],questionMedia:e=>[...At.all,"question",e,"media"],lookup:(e,t)=>[...At.all,"lookup",e,null!==t&&void 0!==t?t:{}],lookupAll:e=>[...At.all,"lookup",e,"all"],lookupLabels:(e,t)=>[...At.all,"lookup",e,"labels",t]};function Et(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=Object.entries(e).filter(e=>{let[,t]=e;return void 0!==t&&null!==t&&""!==t}).map(e=>{let[t,n]=e;return"".concat(t,"=").concat("string"===typeof n?n:JSON.stringify(n))});return t.length?"?".concat(t.join("&")):""}async function It(){var e,t;let{skip:n,take:l,search:s,courseId:a,unitId:i,topicId:o,sort:r}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const c="/questions/facts/fullinfo".concat(Et({skip:n,take:l,searchTxt:null===s||void 0===s?void 0:s.trim(),sort:r,courseId:a,unitId:i,topicId:o,useFor:D})),{data:d}=await I.Ay.get(c);return{rows:(null!==(e=null===d||void 0===d?void 0:d.data)&&void 0!==e?e:[]).map(gt),total:null!==(t=null===d||void 0===d?void 0:d.allCount)&&void 0!==t?t:0}}async function Nt(e){await I.Ay.delete("/questions/fact",{data:{factId:Number(e)}})}async function qt(e){var t;const n=new FormData;n.append("img",e);const{data:l}=await I.Ay.post("/img/upload",n,{headers:{"Content-Type":"multipart/form-data"}});return null!==(t=null===l||void 0===l?void 0:l.imgUrl)&&void 0!==t?t:""}async function Rt(e){var t,n;let{skip:l=0,take:s=10,filter:a,sort:i}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const o="/questions/cbq/fullinfo".concat(Et({factId:Number(e),skip:l,take:s,filter:a,sort:i})),{data:r}=await I.Ay.get(o);return{rows:null!==(t=null===r||void 0===r?void 0:r.data)&&void 0!==t?t:[],total:null!==(n=null===r||void 0===r?void 0:r.allCount)&&void 0!==n?n:0}}async function Ct(e){await I.Ay.delete("/questions/question",{data:{questionId:Number(e)}})}async function kt(e,t){const{videoUrl:n,sizeInBytes:l,lengthSec:s}=await async function(e,t,n,l){const s=new FormData;s.append(t,n);const{data:a}=await E().post("".concat(I._f).concat(e),s,{withCredentials:!0,headers:{"Content-Type":"multipart/form-data"},onUploadProgress:l?e=>{let{loaded:t,total:n}=e;return l(n?Math.round(100*t/n):null)}:void 0});return null!==a&&void 0!==a?a:{}}("/video/upload","video",e,t);return{url:null!==n&&void 0!==n?n:"",sizeInBytes:Number(l)||0,lengthSeconds:Number(s)||0}}async function _t(e,t){await I.Ay.post("/video/new",{questionId:Number(e),urlEn:t.url,sizeInBytesEn:t.sizeInBytes,lengthSecondsEn:t.lengthSeconds})}async function St(e,t){await I.Ay.delete("/video/question",{data:{videoId:t.id,questionId:Number(e)}})}async function Yt(e){var t;const{data:n}=await I.Ay.get("/admin/question/".concat(e,"/topics"));return null!==(t=null===n||void 0===n?void 0:n.data)&&void 0!==t?t:[]}async function Mt(e,t){await I.Ay.post("/admin/question/topics/resets",{questionId:Number(e),topicsIds:t})}const Tt=e=>Array.isArray(e)?e:Object.values(null!==e&&void 0!==e?e:{});async function Pt(e){var t;let{skip:n=0,take:l=R,parentId:s,search:a}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{path:i,rowsKey:o,parentField:r,ranked:c}
1=N[e],d="".concat(i).concat(Et({skip:n,take:l,filter:C({parentField:r,parentId:s,ranked:c,search:a})})),{data:u}=await I.Ay.get(d);return{rows:Tt(null===u||void 0===u?void 0:u[o]),total:null!==(t=null===u||void 0===u?void 0:u.allCount)&&void 0!==t?t:0}}var Ot=n(70579);const Gt=Object.freeze({certificateId:null,courseId:null,unitId:null,topicId:null}),Ft=Object.freeze({hidden:[],textFilters:{},selectFilters:{},sort:null,page:1,pageSearch:"",limit:10}),zt=(0,l.createContext)(null);function Dt(e){let{children:t}=e;const[n,s]=(0,l.useState)(""),[a,i]=(0,l.useState)(""),[o,r]=(0,l.useState)(1),[c,d]=(0,l.useState)(10),[u,w]=(0,l.useState)(Gt),[p,m]=(0,l.useState)(()=>new Set),x=(0,l.useCallback)(e=>{m(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),[b,v]=(0,l.useState)(()=>({search:"",ids:new Set})),h=(0,l.useCallback)((e,t)=>{v(n=>{const l=new Set(n.search===e?n.ids:[]);return l.has(t)?l.delete(t):l.add(t),{search:e,ids:l}})},[]),[f,g]=(0,l.useState)(()=>new Map),j=(0,l.useCallback)(e=>{var t;return null!==(t=f.get(String(e)))&&void 0!==t?t:Ft},[f]),y=(0,l.useCallback)((e,t)=>{g(n=>{var l;const s=String(e),a=null!==(l=n.get(s))&&void 0!==l?l:Ft,i=t(a);return i===a?n:new Map(n).set(s,i)})},[]),[A,E]=(0,l.useState)({}),[I,N]=(0,l.useState)(()=>new Map),q=(0,l.useCallback)(e=>{N(t=>{const n=(null!==e&&void 0!==e?e:[]).filter(e=>null!=(null===e||void 0===e?void 0:e.id)&&t.get(String(e.id))!==e);if(!n.length)return t;const l=new Map(t);return n.forEach(e=>l.set(String(e.id),e)),l})},[]),R=(0,l.useCallback)(e=>{var t;return null!==(t=I.get(String(e)))&&void 0!==t?t:null},[I]),C=(0,l.useMemo)(()=>({search:n,setSearch:s,appliedSearch:a,setAppliedSearch:i,page:o,setPage:r,limit:c,setLimit:d,factFilters:u,setFactFilters:w,expanded:p,toggleExpanded:x,collapsedInSearch:b,toggleCollapsedInSearch:h,tablePrefsFor:j,updateTablePrefs:y,columnWidths:A,setColumnWidths:E,rememberFacts:q,factById:R}),[n,a,o,c,u,p,x,b,h,j,y,A,q,R]);return(0,Ot.jsx)(zt.Provider,{value:C,children:t})}function Bt(){const e=(0,l.useContext)(zt);if(!e)throw new Error("useCbqScreenState must be used inside <CbqScreenStateProvider>");return e}const Lt=[{selector:"creatAt",desc:!0}];var Qt=n(5766),Ut=n.n(Qt),Vt=n(72450),Ht=n.n(Vt);function Kt(e){let{fields:t,data:n,filename:l}=e;const s=Ut().unparse({fields:t,data:n}),a=new Blob(["\ufeff".concat(s)],{type:"text/csv;charset=utf-8;"});Ht()(a,"".concat(String(l||"cbq").replace(/[\\/:*?"<>|]/g,"-"),".csv"))}const Wt=[{id:"id",labelKey:"cbq.columns.factId"},{id:"titleAr",labelKey:"ArabicTitle"},{id:"titleEn",labelKey:"EnglishTitle"},{id:"status",labelKey:"cbq.columns.factStatus"},{id:"createdAt",labelKey:"CreatedAt"}];function Zt(){const{expanded:e,toggleExpanded:t,collapsedInSearch:n,toggleCollapsedInSearch:s}=Bt(),a=function(){const{factFilters:e,setFactFilters:t,setPage:n}=Bt();return{value:e,set:(0,l.useCallback)((e,l)=>{t(t=>{switch(e){case"certificateId":return(0,w.A)((0,w.A)({},Gt),{},{certificateId:l});case"courseId":return(0,w.A)((0,w.A)({},t),{},{courseId:l,unitId:null,topicId:null});case"unitId":return(0,w.A)((0,w.A)({},t),{},{unitId:l,topicId:null});default:return(0,w.A)((0,w.A)({},t),{},{topicId:l})}}),n(1)},[t,n])}}(),i=function(){var e,t;let{filters:n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{t:s,i18n:a}=(0,d.B)(),i="ar"===a.language,o=(0,v.jE)(),{search:r,setSearch:c,appliedSearch:u,setAppliedSearch:p,page:m,setPage:x,limit:y,setLimit:A,rememberFacts:E}=Bt(),I=(0,b.o_)(r.trim(),2e3);(0,l.useEffect)(()=>{I!==u&&(p(I),x(1))},[I,u,p,x]);const N=(0,l.useMemo)(()=>{var e,t,l;return{skip:(m-1)*y,take:y,sort:Lt,search:u,courseId:null!==(e=null===n||void 0===n?void 0:n.courseId)&&void 0!==e?e:void 0,unitId:null!==(t=null===n||void 0===n?void 0:n.unitId)&&void 0!==t?t:void 0,topicId:null!==(l=null===n||void 0===n?void 0:n.topicId)&&void 0!==l?l:void 0}},[m,y,u,null===n||void 0===n?void 0:n.courseId,null===n||void 0===n?void 0:n.unitId,null===n||void 0===n?void 0:n.topicId]),{data:q,isLoading:R,isFetching:C,isError:k}=(0,h.I)({queryKey:At.facts(N),queryFn:async()=>(0,w.A)((0,w.A)({},await It(N)),{},{search:N.search}),placeholderData:f.rX,staleTime:yt}),_=(0,g.n)({mutationFn:Nt,onSuccess:()=>{o.invalidateQueries({queryKey:At.all}),j.oR.success(s("cbq.toast.deleted"))},onError:()=>j.oR.error(s("cbq.toast.deleteFailed"))}),S=(0,l.useMemo)(()=>{var e;return(null!==(e=null===q||void 0===q?void 0:q.rows)&&void 0!==e?e:[]).map(e=>(0,w.A)((0,w.A)({},e),{},{title:ie(i,e.titleAr,e.titleEn),excerpt:W(ie(i,e.descriptionAr,e.descriptionEn)).slice(0,180)}))},[q,i]);(0,l.useEffect)(()=>E(S),[S,E]);const Y=(0,l.useCallback)(e=>{A(e),x(1)},[A,x]),M=(0,l.useCallback)((e,t)=>_.mutate(e,t),[_]);return{rows:S,params:N,total:null!==(e=null===q||void 0===q?void 0:q.total)&&void 0!==e?e:0,page:m,setPage:x,limit:y,setLimit:Y,isLoading:R,isFetching:C,isError:k,search:r,setSearch:c,resultsSearch:null!==(t=null===q||void 0===q?void 0:q.search)&&void 0!==t?t:"",remove:M,isRemoving:_.isPending}}({filters:a.value}),{params:o,resultsSearch:r}=i,{exportCsv:c,isExporting:u}=function(e){const{t:t}=(0,d.B)(),[n,s]=(0,l.useState)(!1);return{exportCsv:(0,l.useCallback)(async()=>{s(!0);try{const{rows:n}=await It((0,w.A)((0,w.A)({},e),{},{skip:0,take:1e3}));if(!n.length)return void j.oR.info(t("cbq.toast.nothingToExport"));Kt({fields:Wt.map(e=>t(e.labelKey)),data:n.map(e=>Wt.map(n=>{var l;return"status"===n.id?t(e.status===F.ACTIVE?"cbq.status.ACTIVE":"cbq.status.INACTIVE"):null!==(l=e[n.id])&&void 0!==l?l:""})),filename:t("cbq.titles.bank")})}catch(n){j.oR.error(t("cbq.errors.listFailed"))}finally{s(!1)}},[e,t]),isExporting:n}}(o),p=(0,l.useCallback)(t=>r?!(n.search===r&&n.ids.has(t)):e.has(t),[r,n,e]),m=(0,l.useCallback)(e=>r?s(r,e):t(e),[r,s,t]),[x,y]=(0,l.useState)(null),[A,E]=(0,l.useState)(null),[I,N]=(0,l.useState)(null);return(0,w.A)((0,w.A)({filters:a},i),{},{exportCsv:c,isExporting:u,isExpanded:p,toggle:m,preview:x,setPreview:y,editing:A,setEditing:E,pendingDelete:I,setPendingDelete:N})}var $t=n(96685),Xt=n(56005),Jt=n(14746),en=n(26156),tn=n(40447),nn=n(76846),ln=n(89698),sn=n(47768),an=n(29839);const on=[{id:"id",labelKey:"cbq.columns.id",px:90,always:!0,start:!0,filter:"search",sortable:!0},{id:"title",labelKey:"cbq.columns.title",px:240,always:!0,start:!0,fill:!0,filter:"search",sortable:!0},{id:"format",labelKey:"cbq.columns.format",px:150,filter:"select",sortable:!0},{id:"difficulty",labelKey:"cbq.columns.difficulty",px:120,filter:"select"},{id:"category",labelKey:"cbq.columns.category",px:140,filter:"select",sortable:!0},{id:"concept",labelKey:"cbq.columns.concept",px:150,filter:"select"},{id:"size",labelKey:"cbq.columns.size",px:120,filter:"select",sortable:!0},{id:"usedIn",labelKey:"cbq.columns.usedIn",px:160,filter:"select",sortable:!0},{id:"rank",labelKey:"cbq.columns.rank",px:180,filter:"search",sortable:!0},{id:"video",labelKey:"cbq.columns.video",px:90,filter:"select",sortable:!0},{id:"created",labelKey:"cbq.columns.created",px:120,sortable:!0},{id:"active",labelKey:"cbq.columns.active",px:90,always:!0,filter:"select",sortable:!0},{id:"actions",labelKey:"cbq.columns.actions",px:120,always:!0}],rn="all",cn="HAS",dn="NONE",un={format:T,difficulty:[P.EASY,P.MID,P.HARD],category:[O.THEORY,O.PRACTICAL],concept:Object.values(G),usedIn:[z.BANK,z.MOCK,z.FREQ],video:[cn,dn],active:[F.ACTIVE,F.INACTIVE]};function wn(e,t,n){switch(e){case"format":return Ue(t)?n(V(t)):n("cbq.labels.unsupportedType");case"difficulty":return n("cbq.difficulty.".concat(t));case"category":return n("cbq.category.".concat(t));case"concept":return n("cbq.concept.".concat(t));case"usedIn":return n("cbq.usedIn.".concat(t));case"video":return n("cbq.video.".concat(t));case"active":return n("cbq.status.".concat(t));default:return t}}const pn=e=>{const t=Number(e);if(!Number.isFinite(t)||t<=0)return"";const n=Math.floor(t/60),l=t%60;return n?"".concat(n,":").concat(String(l).padStart(2,"0")):"0:".concat(String(l).padStart(2,"0"))},mn=/^\d{4}-\d{2}-\d{2}$/;function xn(e){if(!e)return"";const t=String(e);if(mn.test(t))return t;const n=new Date(t);if(Number.isNaN(n.getTime()))return"";const l=e=>String(e).padStart(2,"0");return"".concat(n.getFullYear(),"-").concat(l(n.getMonth()+1),"-").concat(l(n.getDate()))}const bn={id:e=>["id","contains",e],title:e=>[["textEn","contains",e],"or",["textAr","contains",e]],rank:e=>["rank","contains",e],format:e=>["questionSubType","=",e],difficulty:e=>["questionDifficult","=",e],category:e=>["questionCateg","=",e],concept:e=>["conceptType","contains",e],size:e=>["questionSizeId","=",Number(e)],usedIn:e=>["useForExam","contains",e],video:e=>e===cn?["videosCount",">",0]:["videosCount","=",0],active:e=>["isActive","=",e===F.ACTIVE]},vn={id:()=>"id",title:e=>e?"textAr":"textEn",format:()=>"questionSubType",category:()=>"questionCateg",created:()=>"creatAt",size:()=>"questionSizeId",usedIn:()=>"useForExam",rank:()=>"rank",video:()=>"videosCount",active:()=>"isActive"},hn=[{selector:"id",desc:!1}],fn=e=>Object.entries(null!==e&&void 0!==e?e:{}).map(e=>{let[t,n]=e;return[t,String(null!==n&&void 0!==n?n:"").trim()]}).filter(e=>{let[,t]=e;return""!==t}),gn=e=>Object.entries(null!==e&&void 0!==e?e:{}).filter(e=>{let[,t]=e;return t&&t!==rn});function jn(){var e;let{search:t,textFilters:n,selectFilters:l,sort:s,isArabic:a}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const i=String(null!==t&&void 0!==t?t:"").trim(),o=[...i?[(r=i,[["textEn","contains",r],"or",["textAr","contains",r],"or",["rank","contains",r]])]:[],...[...fn(n),...gn(l)].map(e=>{var t;let[n,l]=e;return null===(t=bn[n])||void 0===t?void 0:t.call(bn,l)}
1).filter(Boolean)];var r;const c=s?null===(e=vn[s.columnId])||void 0===e?void 0:e.call(vn,a):void 0;return{filter:o.length?o.flatMap((e,t)=>t?["and",e]:[e]):void 0,sort:c?[{selector:c,desc:Boolean(s.desc)}]:hn}}function yn(e,t,n){let{sizeName:l}=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return(null!==e&&void 0!==e?e:[]).map(e=>{var s,a,i,o,r,c,d;const u=t.get(e.id),w=null!==(s=null===u||void 0===u||null===(a=u.head)||void 0===a?void 0:a.text)&&void 0!==s?s:{},p=n?ae(w.ar,e.textAr,w.en,e.textEn):ae(w.en,e.textEn,w.ar,e.textAr);return{id:e.id,questionId:e.id,type:null!==(i=null===u||void 0===u?void 0:u.type)&&void 0!==i?i:"",title:W(p),difficulty:null!==(o=e.questionDifficult)&&void 0!==o?o:"",category:null!==(r=e.questionCateg)&&void 0!==r?r:"",concepts:(m=e.conceptType,mt(m,G)),size:null!==(c=null===l||void 0===l?void 0:l(e.questionSizeId))&&void 0!==c?c:"",videosCount:Number(e.videosCount)||0,usedIn:xt(e.useForExam),rank:null==e.rank?"":String(e.rank),isActive:Boolean(e.isActive),created:xn(null!==(d=e.creatAt)&&void 0!==d?d:e.createdAt)};var m})}var An=n(38957),En=n(3502);const In=[];function Nn(e,t){var n,s;let{enabled:a=!0}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{data:i,isLoading:o,isFetching:r,isError:c,isSuccess:d,isPlaceholderData:u}=(0,h.I)({queryKey:At.factQuestions(e,t),queryFn:()=>Rt(e,t),enabled:Boolean(e)&&a,placeholderData:f.rX,staleTime:yt}),w=(0,l.useMemo)(()=>{var e;const t=new Map;return(null!==(e=null===i||void 0===i?void 0:i.rows)&&void 0!==e?e:[]).forEac
1h(e=>{t.set(e.id,pt(e.contentJson))}),t},[i]);return{questions:null!==(n=null===i||void 0===i?void 0:i.rows)&&void 0!==n?n:In,total:null!==(s=null===i||void 0===i?void 0:i.total)&&void 0!==s?s:0,contents:w,isLoading:o,isFetching:r,isError:c,isSuccess:d,isPlaceholderData:u}}function qn(e){let{fact:t,params:n,visibleColumns:s,sizeLabel:a}=e;const{t:i,i18n:o}=(0,d.B)(),r="ar"===o.language,[c,u]=(0,l.useState)(!1);return{exportCsv:(0,l.useCallback)(async()=>{u(!0);try{const{rows:e}=await Rt(null===t||void 0===t?void 0:t.id,(0,w.A)((0,w.A)({},n),{},{skip:0,take:1e3}));if(!e.length)return void j.oR.info(i("cbq.toast.nothingToExport"));const l=new Map(e.map(e=>[e.id,pt(e.contentJson)])),o=s.filter(e=>"actions"!==e.id);Kt({fields:o.map(e=>e.label),data:yn(e,l,r,{sizeName:a}).map(e=>o.map(t=>function(e,t,n){var l;switch(t){case"format":return e.type?wn("format",e.type,n):"";case"difficulty":return e.difficulty?wn("difficulty",e.difficulty,n):"";case"category":return e.category?wn("category",e.category,n):"";case"concept":return e.concepts.map(e=>wn("concept",e,n)).join(" | ");case"usedIn":return e.usedIn.map(e=>wn("usedIn",e,n)).join(" | ");case"video":return String(e.videosCount);case"active":return wn("active",e.isActive?F.ACTIVE:F.INACTIVE,n);case"actions":return"";default:return null!==(l=e[t])&&void 0!==l?l:""}}(e,t.id,i))),filename:r?null===t||void 0===t?void 0:t.titleAr:null===t||void 0===t?void 0:t.titleEn})}catch(e){j.oR.error(i("cbq.errors.questionsFailed"))}finally{u(!1)}},[t,n,s,a,r,i]),isExporting:c}}const Rn={skip:0,take:100},Cn=[];const kn=e=>t=>{if(!(e in t))return t;const n=(0,w.A)({},t);return delete n[e],n};function _n(e){let{enabled:t=!0,search:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{t:s,i18n:a}=(0,d.B)(),i="ar"===a.language,o=(0,v.jE)(),r=null===e||void 0===e?void 0:e.id,c=String(null!==n&&void 0!==n?n:"").trim(),{tablePrefsFor:u,updateTablePrefs:p}=Bt(),{hidden:m,textFilters:x,selectFilters:b,sort:f,page:y,pageSearch:A,limit:E}=u(r),N=A===c?y:1,q=(0,l.useCallback)(e=>p(r,e),[p,r]),R=(0,l.useMemo)(()=>({skip:0,take:1,filter:jn({search:c}).filter}),[c]),C=Nn(r,R,{enabled:t&&Boolean(c)}),k=!c||C.isError||C.isSuccess&&!C.isPlaceholderData,_=Boolean(c)&&k&&C.total>0,S=(0,l.useMemo)(()=>{const{filter:e,sort:t}=jn({search:_?c:void 0,textFilters:x,selectFilters:b,sort:f,isArabic:i});return{skip:(N-1)*E,take:E,filter:e,sort:t}},[_,c,x,b,f,i,N,E]),M=Nn(r,S,{enabled:t&&k}),{questions:T,total:P,contents:O,isFetching:G,isError:F}=M,z=t&&!k||M.isLoading,{options:D,labelOf:B}=function(){const{i18n:e}=(0,d.B)(),t="ar"===e.language,{data:n}=(0,h.I)({queryKey:At.lookupAll("sizes"),queryFn:()=>Pt("sizes",Rn),staleTime:3e5}),s=(0,l.useMemo)(()=>{var e;return(null!==(e=null===n||void 0===n?void 0:n.rows)&&void 0!==e?e:Cn).map(e=>Y(e,t))},[n,t]),a=(0,l.useMemo)(()=>new Map(s.map(e=>[e.value,e.label])),[s]),i=(0,l.useCallback)(e=>{var t;return null!==(t=a.get(e))&&void 0!==t?t:""},[a]);return{options:s,labelOf:i}}(),L=(0,l.useMemo)(()=>yn(T,O,i,{sizeName:B}),[T,O,i,B]),Q=(0,l.useMemo)(()=>on.map(e=>(0,w.A)((0,w.A)({},e),{},{label:s(e.labelKey)})),[s]),U=(0,l.useCallback)(e=>function(e,t,n){var l;return[{value:rn,label:t("cbq.filters.all")},...null!==n&&void 0!==n?n:(null!==(l=un[e])&&void 0!==l?l:[]).map(n=>({value:n,label:wn(e,n,t)}))]}(e,s,"size"===e?D:void 0),[s,D]),{widthOf:V,resizingId:H,resizeHandleProps:K}=function(){var e;const{columnWidths:t,setColumnWidths:n}=Bt(),[s,a]=(0,l.useState)(null),i=(0,l.useRef)(null),o=(0,l.useCallback)(e=>{var n;return(null===s||void 0===s?void 0:s.id)===e.id?s.px:null!==(n=t[e.id])&&void 0!==n?n:e.px},[s,t]),r=(0,l.useCallback)(()=>{const e=i.current;e&&(i.current=null,e.moved&&n(t=>(0,w.A)((0,w.A)({},t),{},{[e.id]:e.px})),a(null))},[n]),c=(0,l.useCallback)(e=>({onPointerDown:t=>{if(0!==t.button)return;const n=t.currentTarget.closest("th");if(!n)return;t.preventDefault(),t.stopPropagation(),t.currentTarget.setPointerCapture(t.pointerId);const l=Math.round(n.getBoundingClientRect().width);i.current={id:e,startX:t.clientX,startPx:l,px:l,moved:!1,sign:"rtl"===window.getComputedStyle(n).direction?-1:1},a({id:e,px:l})},onPointerMove:t=>
1{const n=i.current;if(!n)return;const l=Math.max(60,Math.round(n.startPx+(t.clientX-n.startX)*n.sign));l!==n.px&&(n.px=l,n.moved=!0,a({id:e,px:l}))},onPointerUp:r,onLostPointerCapture:r,onClick:e=>e.stopPropagation(),onDoubleClick:t=>{t.stopPropagation(),n(t=>{if(!(e in t))return t;const n=(0,w.A)({},t);return delete n[e],n})}}),[r,n]);return{widthOf:o,resizingId:null!==(e=null===s||void 0===s?void 0:s.id)&&void 0!==e?e:null,resizeHandleProps:c}}(),W=(0,l.useMemo)(()=>Q.filter(e=>e.always||!m.includes(e.id)).map(e=>(0,w.A)((0,w.A)({},e),{},{px:V(e)})),[Q,m,V]),Z=_||function(){let{textFilters:e,selectFilters:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return fn(e).length>0||gn(t).length>0}({textFilters:x,selectFilters:b}),$=(0,l.useCallback)(e=>{q(t=>{var n;return(0,w.A)((0,w.A)({},t),{},{hidden:t.hidden.includes(e)?t.hidden.filter(t=>t!==e):[...t.hidden,e],textFilters:kn(e)(t.textFilters),selectFilters:kn(e)(t.selectFilters),sort:(null===(n=t.sort)||void 0===n?void 0:n.columnId)===e?null:t.sort,page:1})})},[q]),X=(0,l.useCallback)((e,t)=>{q(n=>(0,w.A)((0,w.A)({},n),{},{textFilters:(0,w.A)((0,w.A)({},n.textFilters),{},{[e]:t}),page:1}))},[q]),J=(0,l.useCallback)((e,t)=>{q(n=>(0,w.A)((0,w.A)({},n),{},{selectFilters:(0,w.A)((0,w.A)({},n.selectFilters),{},{[e]:t}),page:1}))},[q]),ee=(0,l.useCallback)((e,t)=>q(n=>(0,w.A)((0,w.A)({},n),{},{sort:{columnId:e,desc:t},page:1})),[q]),te=(0,l.useCallback)(e=>q(t=>(0,w.A)((0,w.A)({},t),{},{page:e,pageSearch:c})),[q,c]),ne=(0,l.useCallback)(e=>q(t=>(0,w.A)((0,w.A)({},t),{},{limit:e,page:1})),[q]),le=(0,l.useCallback)(()=>o.invalidateQueries({queryKey:At.factQuestions(r)}),[o,r]),se=(0,g.n)({mutationFn:e=>{let{questionId:t,isActive:n}=e;return async function(e,t){await I.Ay.post("/questions/question/update",{questionId:Number(e),isActive:t})}(t,n)},onSuccess:le,onError:()=>j.oR.error(s("cbq.toast.statusFailed"))}),ae=(0,g.n)({mutationFn:Ct,onSuccess:()=>{le(),j.oR.success(s("cbq.toast.questionDeleted"))},onError:()=>j.oR.error(s("cbq.toast.questionDeleteFailed"))}),ie=(0,l.useCallback)((e,t)=>se.mutate({questionId:e,isActive:t}),[se]),oe=(0,l.useCallback)((e,t)=>ae.mutate(e,t),[ae]),{exportCsv:re,isExporting:ce}=qn({fact:e,params:S,visibleColumns:W,sizeLabel:B}),[de,ue]=(0,l.useState)(null),we=Boolean((0,An.Y)([En.fV.ADMIN_RESOURCES.QUESTIONS,En.fV.PERMISSIONS.EDIT])&&(0,An.Y)([En.fV.ADMIN_RESOURCES.VIDEOS,En.fV.PERMISSIONS.READ])),[pe,me]=(0,l.useState)(null),xe=(0,l.useCallback)(()=>{pe&&o.invalidateQueries({queryKey:At.questionMedia(pe.questionId)}),me(null),le()},[pe,o,le]),be=Boolean((0,An.Y)([En.fV.ADMIN_RESOURCES.QUESTIONS,En.fV.PERMISSIONS.EDIT])&&(0,An.Y)([En.fV.ADMIN_RESOURCES.TOPICS,En.fV.PERMISSIONS.READ])),[ve,he]=(0,l.useState)(null),[fe,ge]=(0,l.useState)(!1),je=(0,l.useCallback)(e=>{he(e),ge(!0)},[]),ye=(0,l.useCallback)(()=>ge(!1),[]);return{pendingDelete:de,setPendingDelete:ue,canManageVideos:we,explanationsFor:pe,openExplanations:me,closeExplanations:xe,canLinkTopics:be,topicsFor:ve,topicsOpen:fe,openTopics:je,closeTopics:ye,rows:L,total:P,isFiltered:Z,isLoading:z,isFetching:G,isError:F,columns:Q,visibleColumns:W,hidden:m,toggleColumn:$,resizingId:H,resizeHandleProps:K,textFilters:x,selectFilters:b,selectOptionsFor:U,sort:f,setTextFilter:X,setSelectFilter:J,sortBy:ee,page:N,setPage:te,limit:E,setLimit:ne,setActive:ie,removeQuestion:oe,isMutating:se.isPending||ae.isPending,isRemoving:ae.isPending,exportCsv:re,isExporting:ce}}var Sn=n(12157);function Yn(e){let{open:t,title:n,description:l,confirmLabel:s,loading:a=!1,onConfirm:i,onClose:r}=e;const{t:u}=(0,d.B)();return(0,Ot.jsxs)(Sn.A,{open:t,onClose:a?void 0:r,size:"xs",backdrop:"static",className:"cbq-confirm-dialog",children:[(0,Ot.jsx)(Sn.A.Body,{className:"tw-pt-2",children:(0,Ot.jsxs)("div",{className:"tw-flex tw-items-start tw-gap-3",children:[(0,Ot.jsx)("span",{className:"tw-flex tw-h-10 tw-w-10 tw-shrink-0 tw-items-center tw-justify-center tw-rounded-full tw-bg-ERROR_25 tw-text-ERROR_100",children:(0,Ot.jsx)(c.eHT,{size:20})}),(0,Ot.jsxs)("div",{className:"tw-flex tw-min-w-0 tw-flex-col tw-gap-1.5",children:[(0,Ot.jsx)("h4",{className:"tw-m-0 tw-text-base tw-font-bold tw-text-GREY_90",children:n}),(0,Ot.jsx)("p",{className:"tw-m-0 tw-text-[13px] tw-leading-6 tw-text-GREY_70",children:l})]})]})}),(0,Ot.jsxs)(Sn.A.Footer,{children:[(0,Ot.jsx)(o.A,{appearance:"subtle",onClick:r,disabled:a,children:u("cbq.actions.cancel")}),(0,Ot.jsx)(o.A,{appearance:"primary",color:"red",loading:a,onClick:i,children:null!==s&&void 0!==s?s:u("cbq.actions.confirmDelete")})]})]})}var Mn=n(50053),Tn=n(75714);const Pn=[];function On(e){let{resource:t,parentId:n,value:s,multiple:a,selectedOptions:i,onChange:o}=e;const r=(0,l.useRef)(null),c=(0,l.useRef)(null),[u,p]=(0,l.useState)(),[m,x]=(0,l.useState)(!1),[v,h]=(0,l.useState)(()=>new Map),{options:f,search:g,setSearch:j,onScroll:y,hasMore:A,isLoading:E,isError:I}=function(e){let{resource:t,parentId:n,enabled:s=!1}=e;const{i18n:a}=(0,d.B)(),i="ar"===a.language,[o,r]=(0,l.useState)(""),c=(0,b.o_)(o.trim(),300),u=(0,l.useMemo)(()=>({parentId:n||void 0,search:c||void 0}),[n,c]),p=(0,Tn.q)({queryKey:At.lookup(t,u),queryFn:e=>{let{pageParam:n}=e;return Pt(t,(0,w.A)((0,w.A)({},u),{},{skip:n,take:R}))},initialPageParam:0,getNextPageParam:(e,t)=>{const n=t.reduce((e,t)=>
1e+t.rows.length,0);return n<e.total?n:void 0},enabled:s,staleTime:6e4}),{data:m,fetchNextPage:x,hasNextPage:v,isFetchingNextPage:h}=p;return{options:(0,l.useMemo)(()=>m?m.pages.flatMap(e=>e.rows.map(e=>Y(e,i,t))):Pn,[m,i,t]),search:o,setSearch:r,onScroll:(0,l.useCallback)(e=>{const{scrollTop:t,scrollHeight:n,clientHeight:l}=e.currentTarget;n-t-l>80||v&&!h&&x()},[x,v,h]),hasMore:Boolean(v),isLoading:p.isFetching&&!h,isFetchingMore:h,isError:p.isError}}({resource:t,parentId:n,enabled:m}),N=(0,l.useMemo)(()=>a?Array.isArray(s)?s:[]:null==s||""===s?[]:[s],[a,s]),q=(0,l.useMemo)(()=>{const e=new Map(i.map(e=>[e.value,e]));return v.forEach((t,n)=>e.set(n,t)),f.forEach(t=>e.set(t.value,t)),e},[f,i,v]),C=(0,l.useMemo)(()=>N.map(e=>{var t;return null===(t=q.get(e))||void 0===t?void 0:t.label}).filter(Boolean).join("\u060c "),[N,q]),k=(0,l.useCallback)(()=>{var e;p(null===(e=c.current)||void 0===e?void 0:e.offsetWidth),x(!0),j("")},[j]);return{shell:c,whisper:r,menuWidth:u,search:g,setSearch:j,onScroll:y,options:f,hasMore:A,isLoading:E,isError:I,selectedValues:N,summary:C,onOpen:k,choose:e=>{var t;if(h(t=>t.has(e.value)?t:new Map(t).set(e.value,e)),!a)return o(e.value,e),void(null===(t=r.current)||void 0===t||t.close());const n=N.includes(e.value)?N.filter(t=>t!==e.value):[...N,e.value];o(n,e)},clear:()=>o(a?[]:null,null)}}function Gn(e){let{resource:t,parentId:n,value:l,multiple:s=!1,selectedOptions:a=[],placeholder:o,disabled:r=!1,cleanable:u=!0,showSummary:w=!0,onChange:p}=e;const{t:x}=(0,d.B)(),{shell:b,whisper:v,menuWidth:h,search:f,setSearch:g,onScroll:j,options:y,hasMore:A,isLoading:E,isError:I,selectedValues:N,summary:q,onOpen:R,choose:C,clear:k}=On({resource:t,parentId:n,value:l,multiple:s,selectedOptions:a,onChange:p});return(0,Ot.jsxs)("div",{ref:b,className:"tw-relative tw-min-w-0",children:[(0,Ot.jsx)($t.A,{ref:v,trigger:"click",placement:"bottomStart",onOpen:R,disabled:r,speaker:(0,Ot.jsxs)(Mn.A,{arrow:!1,full:!0,style:{width:h},children:[(0,Ot.jsx)("div",{className:"tw-border-0 tw-border-b tw-border-solid tw-border-GREY_
110 tw-p-2",children:(0,Ot.jsx)(m.A,{size:"sm",value:f,onChange:g,autoFocus:!0,placeholder:x("cbq.placeholders.searchOptions")})}),(0,Ot.jsxs)("div",{className:"tw-max-h-64 tw-overflow-y-auto tw-p-1",onScroll:j,children:[I?(0,Ot.jsx)("p",{className:"tw-m-0 tw-px-3 tw-py-2 tw-text-xs tw-text-ERROR_100",children:x("cbq.errors.lookupFailed")}):E?(0,Ot.jsx)("div",{className:"tw-flex tw-justify-center tw-py-6",children:(0,Ot.jsx)(i.A,{})}):0===y.length?(0,Ot.jsx)("p",{className:"tw-m-0 tw-px-3 tw-py-2 tw-text-xs tw-text-GREY_50",children:x("cbq.labels.noOptions")}):y.map(e=>{const t=N.includes(e.value),n=e.context?"".concat(e.context," / ").concat(e.label):e.label;return(0,Ot.jsxs)("button",{type:"button",title:n,onClick:()=>C(e),className:"tw-flex tw-w-full tw-items-center tw-gap-2 tw-rounded tw-border-0 tw-px-3 tw-py-2 tw-text-start tw-text-sm ".concat(t?"tw-bg-PRIMARY_05 tw-font-semibold tw-text-PRIMARY_60":"tw-bg-transparent tw-text-GREY_90 hover:tw-bg-GREY_05"),children:[(0,Ot.jsx)(c.YrT,{className:"tw-shrink-0 ".concat(t?"tw-opacity-100":"tw-opacity-0")}),(0,Ot.jsxs)("span",{className:"tw-flex-1 tw-truncate",children:[e.context?(0,Ot.jsx)("span",{className:"tw-font-normal tw-text-GREY_50",children:"".concat(e.context," / ")}):null,e.label]})]},e.value)}),A?(0,Ot.jsx)("p",{className:"tw-m-0 tw-px-3 tw-py-2 tw-text-center tw-text-[11px] tw-text-GREY_50",children:x("cbq.labels.scrollForMore")}):null]})]}),children:(0,Ot.jsx)("button",{type:"button",disabled:r,className:"tw-flex tw-h-9 tw-w-full tw-items-center tw-gap-2 tw-rounded-md tw-border tw-border-solid tw-border-GREY_
110 tw-bg-WHITE tw-py-0 tw-pe-14 tw-ps-3 tw-text-sm disabled:tw-bg-GREY_05",children:(0,Ot.jsx)("span",{title:w?q:void 0,className:"tw-block tw-min-w-0 tw-flex-1 tw-truncate tw-text-start ".concat(w&&q?"tw-text-GREY_90":"tw-text-GREY_50"),children:w&&q||o})})}),(0,Ot.jsxs)("span",{className:"tw-pointer-events-none tw-absolute tw-inset-y-0 tw-end-2 tw-flex tw-items-center tw-gap-1",children:[u&&N.length>0&&!r?(0,Ot.jsx)("button",{type:"button","aria-label":x("cbq.actions.clear"),onClick:k,className:"tw-pointer-events-auto tw-rounded tw-border-0 tw-bg-transparent tw-p-1 tw-leading-none tw-text-GREY_50 hover:tw-bg-GREY_10 hover:tw-text-GREY_90",children:(0,Ot.jsx)(c.yGN,{})}):null,(0,Ot.jsx)(c.fK4,{className:"tw-text-GREY_50"})]})]})}const Fn={indigo:"tw-bg-PRIMARY_05 tw-text-PRIMARY_60",green:"tw-bg-SECONDARY_2 tw-text-SECONDARY_60",gold:"tw-bg-[#FFF6E3] tw-text-GOLD",red:"tw-bg-ERROR_25 tw-text-ERROR_100",grey:"tw-bg-GREY_05 tw-text-GREY_70",navy:"tw-bg-[#EAF4F8] tw-text-CPA_NAVY"};function zn(e){let{tone:t="grey",children:n,title:l,className:s=""}=e;return(0,Ot.jsx)("span",{title:l,className:"tw-inline-flex tw-max-w-full tw-items-center tw-truncate tw-rounded-md tw-px-2 tw-py-0.5 tw-text-[11px] tw-font-semibold ".concat(Fn[t]," ").concat(s),children:n})}const Dn={[M.MCQ_SINGLE]:"indigo",[M.MCQ_MULTI]:"navy",[M.NUMERIC]:"gold",[M.CATEGORIZATION]:"green",[M.SEQUENCE]:"gold",[M.CLOZE]:"red"},Bn=e=>{var t;return null!==(t=Dn[e])&&void 0!==t?t:"grey"},Ln={EASY:"tw-bg-SECONDARY_50",MID:"tw-bg-GOLD",HARD:"tw-bg-ERROR_75"};function Qn(e){var t;let{value:n,label:l}=e;return n?(0,Ot.jsxs)("span",{className:"tw-inline-flex tw-items-center tw-gap-2 tw-text-xs tw-text-GREY_90",children:[(0,Ot.jsx)("span",{className:"tw-h-2 tw-w-2 tw-shrink-0 tw-rounded-full ".concat(null!==(t=Ln[n])&&void 0!==t?t:"tw-bg-GREY_30")}),l]}):null}const Un=[];function Vn(e,t){const{i18n:n}=(0,d.B)(),s="ar"===n.language,a=(0,l.useMemo)(()=>[...new Set((null!==t&&void 0!==t?t:[]).filter(e=>""!==e&&null!=e))].sort(),[t]),{data:i}=(0,h.I)({queryKey:At.lookupLabels(e,a),queryFn:()=>async function(e,t){if(!t.length)return[];const{path:n,rowsKey:l}=N[e],s="".concat(n).concat(Et({skip:0,take:t.length,filter:k(t)})),{data:a}=await I.Ay.get(s);return Tt(null===a||void 0===a?void 0:a[l])}(e,a),enabled:a.length>0,staleTime:3e5}),o=(0,l.useMemo)(()=>(null!==i&&void 0!==i?i:Un).map(t=>Y(t,s,e)),[i,s,e]),r=(0,l.useMemo)(()=>new Map(o.map(e=>[e.value,e])),[o]),c=(0,l.useCallback)(e=>{var t,n;return null!==(t=null===(n=r.get(e))||void 0===n?void 0:n.label)&&void 0!==t?t:""},[r]);return{options:o,byId:r,labelOf:c}}const Hn=[];function Kn(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Hn;const[n,s]=(0,l.useState)(()=>new Map),a=(0,l.useMemo)(()=>t.filter(e=>""!==e&&null!=e),[t]),i=(0,l.useMemo)(()=>a.filter(e=>!n.has(e)),[a,n]),{options:o}=Vn(e,i);(0,l.useEffect)(()=>{o.length&&s(e=>{const t=new Map(e);return o.forEach(e=>t.set(e.value,e)),t})},[o]);const r=(0,l.useCallback)(e=>{e&&s(t=>t.has(e.value)?t:new Map(t).set(e.value,e))},[]);return{selected:(0,l.useMemo)(()=>a.map(e=>n.get(e)).filter(Boolean),[a,n]),byId:n,remember:r}}const Wn=[];function Zn(e){let{open:t,question:n,onClose:s}=e;const{t:a}=(0,d.B)(),{items:u,topicIds:w,selectedOptions:p,setTopics:m,removeTopic:x,isLoading:b,isError:f,isEmpty:y,canSave:A,save:E,isSaving:I,close:N}=function(e){let{open:t,question:n,onClose:s}=e;const{t:a}=(0,d.B)(),i=(0,v.jE)(),o=null===n||void 0===n?void 0:n.questionId,{data:r,isLoading:c,isError:u}=(0,h.I)({queryKey:At.questionTopics(o),queryFn:()=>Yt(o),enabled:t&&Boolean(o),staleTime:yt}),w=(0,l.useMemo)(()=>[...new Set((null!==r&&void 0!==r?r:Wn).map(e=>e.topicId).filter(e=>null!=e))],[r]),[p,m]=(0,l.useState)(null),x=null!==p&&void 0!==p?p:w,{selected:b,byId:f,remember:y}=Kn("topics",x),A=(0,l.useCallback)((e,t)=>{y(t),m(null!==e&&void 0!==e?e:[])},[y]),E=(0,l.useCallback)(e=>m(x.filter(t=>t!==e)),[x]),I=(0,l.useMemo)(()=>x.map(e=>{var t,n;const l=f.get(e);return{id:e,label:null!==(t=null===l||void 0===l?void 0:l.label)&&void 0!==t?t:"",context:null!==(n=null===l||void 0===l?void 0:l.context)&&void 0!==n?n:"",isNew:!w.includes(e)}}),[x,f,w]),N=null!==p&&(p.length!==w.length||p.some(e=>!w.includes(e))),q=(0,l.useCallback)(()=>{m(null),null===s||void 0===s||s()},[s]),R=(0,g.n)({mutationFn:e=>{let{id:t,ids:n}=e;return Mt(t,n)},onSuccess:(e,t)=>{let{id:n}=t;i.invalidateQueries({queryKey:At.questionTopics(n)}),j.oR.success(a("cbq.toast.topicsSaved")),q()},onError:()=>j.oR.error(a("cbq.toast.topicsSaveFailed"))}),C=(0,l.useCallback)(()=>R.mutate({id:o,ids:x.map(Number)}),[R,o,x]);return{items:I,topicIds:x,selectedOptions:b,setTopics:A,removeTopic:E,isLoading:t&&c,isError:u,isEmpty:0===x.length,canSave:N&&x.length>0&&!u,save:C,isSaving:R.isPending,close:q}}({open:t,question:n,onClose:s}),q=n?"".concat(n.id," \xb7 ").concat(n.title||a("cbq.labels.untitledQuestion")):"";return(0,Ot.jsxs)(Sn.A,{open:t,onClose:I?void 0:N,size:"md",overflow:!0,backdrop:"static",className:"cbq-question-topics-modal",children:[(0,Ot.jsx)(Sn.A.Header,{closeButton:!I,children:(0,Ot.jsx)(Sn.A.Title,{children:(0,Ot.jsxs)("span",{className:"tw-flex tw-items-center tw-gap-3",children:[(0,Ot.jsx)("span",{className:"tw-flex tw-h-9 tw-w-9 tw-shrink-0 tw-items-center tw-justify-center tw-rounded-lg tw-bg-PRIMARY_05 tw-text-PRIMARY_60",children:(0,Ot.jsx)(ln.AFi,{size:18})}),(0,Ot.jsxs)("span",{className:"tw-flex tw-min-w-0 tw-flex-col",children:[(0,Ot.jsx)("span",{className:"tw-text-base tw-font-bold tw-text-GREY_90",children:a("cbq.titles.questionTopics")}),(0,Ot.jsx)("span",{title:q,className:"tw-truncate tw-text-xs tw-font-normal tw-text-GREY_50",children:q})]})]})})}),(0,Ot.jsx)(Sn.A.Body,{children:(0,Ot.jsxs)("div",{className:"tw-flex tw-flex-col tw-gap-4",children:[(0,Ot.jsxs)("div",{className:"tw-flex tw-flex-col tw-gap-1.5",children:[(0,Ot.jsx)("span",{className:"tw-text-xs tw-font-semibold tw-text-GREY_70",children:a("cbq.labels.addTopics")}),(0,Ot.jsx)(Gn,{resource:"topics",multiple:!0,value:w,selectedOptions:p,placeholder:a("cbq.placeholders.searchTopics"),showSummary:!1,cleanable:!1,disabled:b||f||I,onChange:m}),(0,Ot.jsx)("p",{className:"tw-m-0 tw-text-[11px] tw-text-GREY_50",children:a("cbq.hints.linkTopics")})]}),(0,Ot.jsxs)("section",{className:"tw-overflow-hidden tw-rounded-lg tw-border tw-border-GREY_
110",children:[(0,Ot.jsxs)("header",{className:"tw-flex tw-items-center tw-justify-between tw-gap-2 tw-border-0 tw-border-b tw-border-solid tw-border-GREY_10 tw-bg-GREY_05 tw-px-3 tw-py-2",children:[(0,Ot.jsx)("span",{className:"tw-text-xs tw-font-bold tw-text-GREY_70",children:a("cbq.labels.linkedTopics")}),b||f?null:(0,Ot.jsx)(zn,{tone:"indigo",className:"tw-shrink-0",children:u.length})]}),b?(0,Ot.jsx)("div",{className:"tw-flex tw-h-28 tw-items-center tw-justify-center",children:(0,Ot.jsx)(i.A,{content:a("cbq.labels.loading")})}):f?(0,Ot.jsx)(r.A,{type:"error",showIcon:!0,className:"tw-m-3",children:a("cbq.errors.topicsFailed")}):y?(0,Ot.jsxs)("div",{className:"tw-flex tw-flex-col tw-items-center tw-gap-2 tw-px-4 tw-py-8 tw-text-center",children:[(0,Ot.jsx)("span",{className:"tw-flex tw-h-10 tw-w-10 tw-items-center tw-justify-center tw-rounded-full tw-bg-GREY_05 tw-text-GREY_50",children:(0,Ot.jsx)(ln.xp8,{size:20})}),(0,Ot.jsx)("p",{className:"tw-m-0 tw-text-sm tw-text-GREY_70",children:a("cbq.labels.noTopics")}),(0,Ot.jsx)("p",{className:"tw-m-0 tw-text-xs tw-text-ERROR_100",children:a("cbq.validation.minTopics")})]}):(0,Ot.jsx)("ul",{className:"tw-m-0 tw-max-h-80 tw-list-none tw-divide-y tw-divide-GREY_10 tw-overflow-y-auto tw-p-0",children:u.map((e,t)=>(0,Ot.jsxs)("li",{className:"tw-flex tw-items-center tw-gap-3 tw-px-3 tw-py-2.5 hover:tw-bg-PRIMARY_2",children:[(0,Ot.jsx)("span",{className:"tw-flex tw-h-7 tw-w-7 tw-shrink-0 tw-items-center tw-justify-center tw-rounded-full tw-bg-PRIMARY_05 tw-text-[11px] tw-font-bold tw-text-PRIMARY_60",children:t+1}),(0,Ot.jsx)("span",{className:"tw-flex tw-min-w-0 tw-flex-1 tw-flex-col tw-gap-0.5",children:e.label?(0,Ot.jsxs)(Ot.Fragment,{children:[(0,Ot.jsx)("span",{title:e.label,className:"tw-truncate tw-text-sm tw-font-semibold tw-text-GREY_90",children:e.label}),e.context?(0,Ot.jsx)("span",{title:e.context,className:"tw-truncate tw-text-[11px] tw-text-GREY_50",children:e.context}):null]}):(0,Ot.jsxs)(Ot.Fragment,{children:[(0,Ot.jsx)("span",{className:"tw-h-3 tw-w-40 tw-max-w-full tw-animate-pulse tw-rounded tw-bg-GREY_10"}),(0,Ot.jsx)("span",{className:"tw-h-2.5 tw-w-56 tw-max-w-full tw-animate-pulse tw-rounded tw-bg-GREY_05"})]})}),e.isNew?(0,Ot.jsx)(zn,{tone:"green",className:"tw-shrink-0",children:a("cbq.labels.newTopicLink")}):null,(0,Ot.jsx)($t.A,{placement:"top",trigger:"hover",speaker:(0,Ot.jsx)(Xt.A,{children:a("cbq.actions.unlinkTopic")}),children:(0,Ot.jsx)(Jt.A,{size:"xs",appearance:"subtle",icon:(0,Ot.jsx)(c.yGN,{}),className:"tw-shrink-0 tw-text-GREY_50 hover:tw-text-ERROR_100",disabled:I,onClick:()=>x(e.id),"aria-label":a("cbq.actions.unlinkTopic")})})]},e.id))})]})]})}),(0,Ot.jsxs)(Sn.A.Footer,{children:[(0,Ot.jsx)(o.A,{appearance:"subtle",onClick:N,disabled:I,children:a("cbq.actions.cancel")}),(0,Ot.jsx)(o.A,{appearance:"primary",startIcon:(0,Ot.jsx)(c.Bc_,{}),loading:I,disabled:!A,onClick:E,className:"tw-bg-PRIMARY_60",children:a("cbq.actions.saveChanges")})]})]})}var $n=n(6720);const Xn=e=>"tw-inline-flex tw-shrink-0 tw-items-center tw-justify-center tw-rounded tw-border-0 tw-p-0.5 tw-text-[13px] tw-leading-none tw-transition-colors ".concat(e?"tw-bg-PRIMARY_05 tw-text-PRIMARY_60":"tw-bg-transparent tw-text-GREY_50 hover:tw-bg-GREY_10 hover:tw-text-GREY_90");function Jn(){const{i18n:e}=(0,d.B)();return"ar"===e.language?"bottomEnd":"bottomStart"}function el(e){let{selected:t,icon:n,children:l,onClick:s}=e;return(0,Ot.jsxs)("button",{type:"button",onClick:s,className:"tw-flex tw-w-full tw-items-center tw-gap-2 tw-rounded tw-border-0 tw-px-2 tw-py-1.5 tw-text-start tw-text-xs ".concat(t?"tw-bg-PRIMARY_05 tw-font-semibold tw-text-PRIMARY_60":"tw-bg-transparent tw-font-medium tw-text-GREY_90 hover:tw-bg-GREY_05"),children:[(0,Ot.jsx)("span",{className:"tw-flex tw-h-3.5 tw-w-3.5 tw-shrink-0 tw-items-center tw-justify-center",children:null!==n&&void 0!==n?n:t?(0,Ot.jsx)(c.YrT,{}):null}),(0,Ot.jsx)("span",{className:"tw-flex-1 tw-truncate",children:l})]})}function tl(e){let{column:t,value:n="",onApply:s}=e;const{t:a}=(0,d.B)(),i=Jn(),r=(0,l.useRef)(null),[u,w]=(0,l.useState)(n),p=e=>{s(t.id,e),(()=>{var e;null===(e=r.current)||void 0===e||e.close()})()};return(0,Ot.jsx)($t.A,{ref:r,trigger:"click",placement:i,preventOverflow:!0,onOpen:()=>w(n),speaker:(0,Ot.jsx)(Mn.A,{arrow:!1,className:"tw-w-56",children:(0,Ot.jsxs)("div",{className:"tw-flex tw-flex-col tw-gap-2",children:[(0,Ot.jsx)(m.A,{size:"sm",value:u,autoFocus:!0,placeholder:a("cbq.placeholders.searchColumn",{column:t.label}),onChange:w,onPressEnter:()=>p(u.trim())}),(0,Ot.jsx)(o.A,{size:"xs",appearance:"primary",className:"tw-bg-PRIMARY_60",onClick:()=>p(u.trim()),children:a("cbq.actions.apply")}),(0,Ot.jsx)(o.A,{size:"xs",onClick:()=>p(""),children:a("cbq.actions.clear")})]})}),children:(0,Ot.jsx)("button",{type:"button","aria-label":a("cbq.actions.search"),className:Xn(Boolean(n)),children:(0,Ot.jsx)(c.CKj,{})})})}
1function nl(e){let{column:t,value:n=rn,options:s,onApply:a}=e;const{t:i}=(0,d.B)(),o=Jn(),r=(0,l.useRef)(null);return(0,Ot.jsx)($t.A,{ref:r,trigger:"click",placement:o,preventOverflow:!0,speaker:(0,Ot.jsx)(Mn.A,{arrow:!1,full:!0,className:"tw-w-52 tw-py-1",children:s.map(e=>(0,Ot.jsx)(el,{selected:e.value===n,onClick:()=>{var n;a(t.id,e.value),null===(n=r.current)||void 0===n||n.close()},children:e.label},e.value))}),children:(0,Ot.jsx)("button",{type:"button","aria-label":i("cbq.actions.filter"),className:Xn(Boolean(n)&&n!==rn),children:(0,Ot.jsx)(c.K7R,{})})})}function ll(e){let{column:t,sort:n,onSort:s}=e;const{t:a}=(0,d.B)(),i=Jn(),o=(0,l.useRef)(null),r=(null===n||void 0===n?void 0:n.columnId)===t.id,u=e=>{var n;s(t.id,e),null===(n=o.current)||void 0===n||n.close()};return(0,Ot.jsx)($t.A,{ref:o,trigger:"click",placement:i,preventOverflow:!0,speaker:(0,Ot.jsxs)(Mn.A,{arrow:!1,full:!0,className:"tw-w-40 tw-py-1",children:[(0,Ot.jsx)(el,{selected:r&&!n.desc,icon:(0,Ot.jsx)(c.ei4,{}),onClick:()=>u(!1),children:a("cbq.actions.sortAsc")}),(0,Ot.jsx)(el,{selected:r&&n.desc,icon:(0,Ot.jsx)(c.LPr,{}),onClick:()=>u(!0),children:a("cbq.actions.sortDesc")})]}),children:(0,Ot.jsx)("button",{type:"button","aria-label":a("cbq.actions.sort"),className:Xn(r),children:(0,Ot.jsx)($n.O24,{})})})}function sl(e){let{fact:t,search:n,onAddQuestion:l,onOpenQuestion:s,onViewQuestion:a}=e;const{t:u}=(0,d.B)(),{rows:p,total:m,isFiltered:x,isLoading:v,isFetching:h,isError:f,columns:g,visibleColumns:j,hidden:y,toggleColumn:A,resizingId:E,resizeHandleProps:I,textFilters:N,selectFilters:q,selectOptionsFor:R,sort:C,setTextFilter:k,setSelectFilter:_,sortBy:S,page:Y,setPage:M,limit:T,setLimit:P,setActive:O,removeQuestion:G,isMutating:F,isRemoving:z,exportCsv:D,isExporting:B,pendingDelete:L,setPendingDelete:Q,canManageVideos:U,explanationsFor:V,openExplanations:H,closeExplanations:K,canLinkTopics:W,topicsFor:Z,topicsOpen:$,openTopics:X,closeTopics:J}=_n(t,{search:n}),ee=j.reduce((e,t)=>e+t.px,0),te=(e,t)=>{switch(t){case"id":return(0,Ot.jsx)("button",{type:"button",title:e.id,onClick:t=>{t.stopPropagation(),null===a||void 0===a||a(e.questionId)},className:"tw-block tw-max-w-full tw-truncate tw-text-start tw-font-semibold tw-text-PRIMARY_50 hover:tw-underline",children:e.id});case"title":return(0,Ot.jsx)("span",{className:"tw-block tw-truncate tw-text-GREY_90",title:e.title,children:e.title||u("cbq.labels.untitledQuestion")});case"format":return(0,Ot.jsx)(zn,{tone:Bn(e.type),title:e.type,children:wn("format",e.type,u)});case"difficulty":return(0,Ot.jsx)(Qn,{value:e.difficulty,label:e.difficulty?u("cbq.difficulty.".concat(e.difficulty)):""});case"category":return e.category?(0,Ot.jsx)(zn,{tone:"navy",children:wn("category",e.category,u)}):null;case"concept":{const[t,...n]=e.concepts;if(!t)return null;const l=e.concepts.map(e=>wn("concept",e,u)).join(" \u2022 ");return(0,Ot.jsxs)("span",{className:"tw-flex tw-w-full tw-items-center tw-justify-center tw-gap-1",title:l,children:[(0,Ot.jsx)("span",{className:"tw-min-w-0 tw-truncate tw-text-xs tw-text-GREY_90",children:wn("concept",t,u)}),n.length?(0,Ot.jsx)(zn,{tone:"grey",className:"tw-shrink-0",children:"+".concat(n.length)}):null]})}case"size":return e.size?(0,Ot.jsx)(zn,{tone:"indigo",children:e.size}):null;case"video":{const t=e.videosCount>0,n=u("cbq.labels.videosCount",{n:e.videosCount}),l=(0,Ot.jsx)(ln.B0$,{size:18,"aria-label":n,title:n,className:"tw-mx-auto ".concat(t?"tw-text-SECONDARY_60":"tw-text-GREY_30")});return U?(0,Ot.jsx)("button",{type:"button",title:n,"aria-label":n,onClick:t=>{t.stopPropagation(),H(e)},className:"tw-mx-auto tw-block tw-rounded tw-p-1 hover:tw-bg-GREY_05",children:l}):l}case"usedIn":{const[t,...n]=e.usedIn;if(!t)return null;const l=e.usedIn.map(e=>u("cbq.usedIn.".concat(e))).join(" \u2022 ");return(0,Ot.jsxs)("span",{className:"tw-flex tw-w-full tw-items-center tw-justify-center tw-gap-1",title:l,children:[(0,Ot.jsx)(zn,{tone:"green",children:u("cbq.usedIn.".concat(t))}),n.length?(0,Ot.jsx)(zn,{tone:"grey",className:"tw-shrink-0",children:"+".concat(n.length)}):null]})}case"rank":return e.rank?(0,Ot.jsx)(zn,{tone:"grey",title:e.rank,children:e.rank}):null;case"created":return(0,Ot.jsx)("span",{className:"tw-text-xs tw-text-GREY_70",children:e.created});case"active":return(0,Ot.jsx)(en.A,{size:"sm",checked:e.isActive,disabled:F,onChange:t=>O(e.questionId,t)});case"actions":return(0,Ot.jsxs)("span",{className:"tw-flex tw-items-center tw-justify-center tw-gap-1",children:[(0,Ot.jsx)($t.A,{placement:"top",trigger:"hover",speaker:(0,Ot.jsx)(Xt.A,{children:u("cbq.actions.edit")}),children:(0,Ot.jsx)(Jt.A,{size:"xs",appearance:"subtle",icon:(0,Ot.jsx)(c.WXf,{}),className:"tw-text-GREY_50",onClick:()=>null===s||void 0===s?void 0:s(e.questionId),"aria-label":u("cbq.actions.edit")})}),W?(0,Ot.jsx)($t.A,{placement:"top",trigger:"hover",speaker:(0,Ot.jsx)(Xt.A,{children:u("cbq.actions.linkTopics")}),children:(0,Ot.jsx)(Jt.A,{size:"xs",appearance:"subtle",icon:(0,Ot.jsx)(ln.AFi,{}),className:"tw-text-PRIMARY_50",onClick:()=>X(e),"aria-label":u("cbq.actions.linkTopics")})}):null,(0,Ot.jsx)($t.A,{placement:"top",trigger:"hover",speaker:(0,Ot.jsx)(Xt.A,{children:u("cbq.actions.remove")}),children:(0,Ot.jsx)(Jt.A,{size:"xs",appearance:"subtle",icon:(0,Ot.jsx)(c.IXo,{}),className:"tw-text-ERROR_100",disabled:F,onClick:()=>Q(e),"aria-label":u("cbq.actions.remove")})})]});default:return null}};return(0,Ot.jsxs)("section",{className:"tw-min-w-0 tw-rounded-xl tw-border tw-border-GREY_
110 tw-bg-PRIMARY_2 tw-p-4",children:[(0,Ot.jsxs)("header",{className:"tw-mb-3 tw-flex tw-flex-wrap tw-items-center tw-gap-2",children:[(0,Ot.jsx)("h3",{className:"tw-m-0 tw-text-sm tw-font-bold tw-text-GREY_90",children:u("cbq.labels.questionsWithCount",{n:m})}),(0,Ot.jsx)("div",{className:"tw-flex-1"}),(0,Ot.jsx)(o.A,{appearance:"primary",size:"sm",startIcon:(0,Ot.jsx)(c.GGD,{}),onClick:()=>null===l||void 0===l?void 0:l(),className:"tw-bg-PRIMARY_60",children:u("cbq.actions.add")}),(0,Ot.jsx)(tn.A,{size:"sm",appearance:"default",placement:"bottomEnd",icon:(0,Ot.jsx)(c.Dw7,{}),title:u("cbq.actions.columns"),menuStyle:{maxHeight:288,overflowY:"auto"},children:g.map(e=>(0,Ot.jsx)(tn.A.Item,{panel:!0,className:"tw-px-3 tw-py-1",children:(0,Ot.jsx)(nn.A,{checked:e.always||!y.includes(e.id),disabled:e.always,onChange:()=>A(e.id),children:e.label})},e.id))}),(0,Ot.jsx)(o.A,{size:"sm",startIcon:(0,Ot.jsx)(c.a4x,{}),onClick:D,loading:B,children:u("cbq.actions.export")})]}),v?(0,Ot.jsx)("div",{className:"tw-flex tw-h-24 tw-items-center tw-justify-center",children:(0,Ot.jsx)(i.A,{content:u("cbq.labels.loading")})}):f?(0,Ot.jsx)(r.A,{type:"error",showIcon:!0,children:u("cbq.errors.questionsFailed")}):(0,Ot.jsx)("div",{className:"tw-w-full tw-min-w-0 tw-overflow-x-auto tw-rounded-lg tw-border tw-border-GREY_
110 tw-bg-WHITE tw-transition-opacity ".concat(h?"tw-opacity-60":""),children:(0,Ot.jsxs)("table",{className:"tw-w-full tw-table-fixed tw-border-separate tw-border-spacing-0 tw-text-sm",style:{minWidth:ee},children:[(0,Ot.jsx)("thead",{children:(0,Ot.jsx)("tr",{className:"tw-group/head tw-bg-GREY_05",children:j.map(e=>(0,Ot.jsxs)("th",{scope:"col",style:{width:e.fill?void 0:e.px},className:"tw-relative tw-border-b tw-border-GREY_10 tw-px-2 tw-py-2 tw-text-start tw-text-[11px] tw-font-bold tw-uppercase tw-tracking-wide tw-text-GREY_70",children:[(0,Ot.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-1 ".concat(e.start?"":"tw-justify-center"),children:[(0,Ot.jsx)("span",{className:"tw-truncate",children:e.label}),(0,Ot.jsxs)("span",{className:"tw-flex tw-shrink-0 tw-items-center",children:["search"===e.filter&&(0,Ot.jsx)(tl,{column:e,value:N[e.id],onApply:k}),"select"===e.filter&&(0,Ot.jsx)(nl,{column:e,value:q[e.id],options:R(e.id),onApply:_}),e.sortable&&(0,Ot.jsx)(ll,{column:e,sort:C,onSort:S})]})]}),(0,Ot.jsx)("span",(0,w.A)((0,w.A)({role:"separator","aria-orientation":"vertical","aria-label":u("cbq.actions.resizeColumn"),title:u("cbq.actions.resizeColumn")},I(e.id)),{},{className:"tw-group/edge tw-absolute tw-inset-y-0 tw-end-0 tw-z-10 tw-flex tw-w-2 tw-cursor-col-resize tw-touch-none tw-select-none tw-justify-end",children:(0,Ot.jsx)("span",{className:"tw-my-1.5 tw-w-0.5 tw-rounded-full tw-transition-colors ".concat(E===e.id?"tw-bg-PRIMARY_50":"tw-bg-transparent group-hover/head:tw-bg-GREY_30 group-hover/edge:tw-bg-PRIMARY_50")})}))]},e.id))})}),(0,Ot.jsxs)("tbody",{children:[0===p.length?(0,Ot.jsx)("tr",{children:(0,Ot.jsx)("td",{colSpan:j.length,className:"tw-px-2 tw-py-6 tw-text-center tw-text-xs tw-text-GREY_50",children:u(x?"cbq.labels.noMatchingQuestions":"cbq.labels.noQuestions")})}):null,p.map(e=>(0,Ot.jsx)("tr",{className:"tw-h-11 tw-cursor-pointer hover:tw-bg-PRIMARY_2",children:j.map(t=>{const n="active"!==t.id&&"actions"!==t.id;return(0,Ot.jsx)("td",{style:{width:t.fill?void 0:t.px},onClick:n?()=>null===a||void 0===a?void 0:a(e.questionId):void 0,className:"tw-border-b tw-border-GREY_
110 tw-px-2 tw-py-0 tw-align-middle ".concat(t.start?"":"tw-text-center"),children:te(e,t.id)},t.id)})},e.questionId))]})]})}),!v&&!f&&m>T?(0,Ot.jsx)(b.dK,{className:"tw-mt-3",page:Y,pageSize:T,total:m,onPageChange:M,onPageSizeChange:P,pageSizes:[10,20,50]}):null,(0,Ot.jsx)(Yn,{open:Boolean(L),title:u("cbq.dialogs.deleteQuestionTitle"),description:u("cbq.dialogs.deleteQuestionDescription"),loading:z,onClose:()=>Q(null),onConfirm:()=>G(L.questionId,{onSuccess:()=>Q(null)})}),(0,Ot.jsx)(Zn,{open:$,question:Z,onClose:J}),(0,Ot.jsx)(sn.A,{onClose:K,open:Boolean(V),content:V?(0,Ot.jsx)(an.default,{data:{id:V.questionId,rank:V.rank}}):null,closeIcon:!0,header:u("Explanations"),size:"large",centered:!0,closeOnDimmerClick:!1})]})}function al(e){let{fact:t,expanded:n,search:l,onToggle:s,onPreview:a,onEdit:i,onDelete:o,onAddQuestion:r,onOpenQuestion:u,onViewQuestion:w}=e;const{t:p}=(0,d.B)(),m=t.status===F.ACTIVE,x=(e,t,n,l)=>(0,Ot.jsx)($t.A,{placement:"top",trigger:"hover",speaker:(0,Ot.jsx)(Xt.A,{children:p(t)}),children:(0,Ot.jsx)(Jt.A,{size:"sm",appearance:"subtle",icon:e,onClick:n,className:l?"tw-text-ERROR_100":"tw-text-GREY_50","aria-label":p(t)})});return(0,Ot.jsxs)("article",{className:"tw-min-w-0 tw-rounded-xl tw-border tw-border-GREY_
110 tw-bg-WHITE tw-shadow-sm",children:[(0,Ot.jsxs)("div",{className:"tw-flex tw-items-start tw-gap-3 tw-p-4",children:[(0,Ot.jsx)(Jt.A,{size:"sm",appearance:"subtle",icon:n?(0,Ot.jsx)(c.wAb,{}):(0,Ot.jsx)(c.fK4,{}),onClick:s,"aria-expanded":n,"aria-label":p(n?"cbq.actions.collapse":"cbq.actions.expand"),className:"tw-mt-0.5 tw-shrink-0 tw-text-GREY_50"}),(0,Ot.jsxs)("div",{className:"tw-flex tw-min-w-0 tw-flex-1 tw-flex-col tw-gap-2",children:[(0,Ot.jsx)("button",{type:"button",onClick:s,className:"tw-text-start tw-text-base tw-font-bold tw-text-GREY_90 hover:tw-text-PRIMARY_60",children:t.title}),(0,Ot.jsx)("p",{className:"tw-m-0 tw-text-[13px] tw-leading-6 tw-text-GREY_70 ".concat(n?"":"tw-line-clamp-2"),children:t.excerpt}),(0,Ot.jsxs)("div",{className:"tw-flex tw-flex-wrap tw-items-center tw-gap-x-5 tw-gap-y-1 tw-text-[13px]",children:[(0,Ot.jsxs)("span",{className:"tw-inline-flex tw-items-center tw-gap-1.5",children:[(0,Ot.jsx)("span",{className:"tw-h-2 tw-w-2 tw-rounded-full ".concat(m?"tw-bg-SECONDARY_50":"tw-bg-GREY_30")}),(0,Ot.jsx)("span",{className:m?"tw-text-SECONDARY_60":"tw-text-GREY_50",children:p("cbq.status.".concat(t.status))})]}),null!=t.questionsCount?(0,Ot.jsx)($t.A,{placement:"top",trigger:"hover",speaker:(0,Ot.jsx)(Xt.A,{children:p("cbq.labels.factQuestionsCount",{n:t.questionsCount})}),children:(0,Ot.jsxs)("span",{"aria-label":p("cbq.labels.factQuestionsCount",{n:t.questionsCount}),className:"tw-inline-flex tw-h-6 tw-min-w-[1.5rem] tw-items-center tw-justify-center tw-gap-1 tw-rounded-full tw-px-2 tw-text-xs tw-font-bold tw-tabular-nums ".concat(t.questionsCount>0?"tw-bg-PRIMARY_05 tw-text-PRIMARY_60":"tw-bg-GREY_05 tw-text-GREY_50"),children:[(0,Ot.jsx)(c.Wm,{"aria-hidden":!0}),t.questionsCount]})}):null,t.createdAt?(0,Ot.jsx)("span",{className:"tw-text-GREY_50",children:p("cbq.labels.created",{date:t.createdAt})}):null]})]}),(0,Ot.jsxs)("div",{className:"tw-flex tw-shrink-0 tw-items-center tw-gap-1",children:[x((0,Ot.jsx)(c.Vap,{}),"cbq.actions.preview",a),x((0,Ot.jsx)(c.WXf,{}),"cbq.actions.edit",i),x((0,Ot.jsx)(c.IXo,{}),"cbq.actions.remove",o,!0)]})]}),n?(0,Ot.jsx)("div",{className:"tw-min-w-0 tw-px-4 tw-pb-4",children:(0,Ot.jsx)(sl,{fact:t,search:l,onAddQuestion:()=>r(t),onOpenQuestion:e=>u(t,e),onViewQuestion:e=>w(t,e)})}):null]})}function il(e){let{value:t,set:n}=e;const{t:l}=(0,d.B)(),s=(e,t,n,s,a)=>(0,Ot.jsxs)("div",{className:"tw-flex tw-min-w-0 tw-flex-col tw-gap-1",children:[(0,Ot.jsx)("span",{className:"tw-text-[11px] tw-font-semibold tw-uppercase tw-tracking-wide tw-text-GREY_50",children:e}),(0,Ot.jsx)(Gn,{resource:t,parentId:n,value:s,onChange:a,placeholder:l("cbq.filters.all")})]});return(0,Ot.jsxs)("div",{className:"tw-grid tw-min-w-0 tw-grid-cols-1 tw-gap-4 sm:tw-grid-cols-2 lg:tw-grid-cols-4",children:[s(l("Certification"),"certificates",null,t.certificateId,e=>n("certificateId",e)),s(l("Course"),"courses",t.certificateId,t.courseId,e=>n("courseId",e)),s(l("Unit"),"units",t.courseId,t.unitId,e=>n("unitId",e)),s(l("Topic"),"topics",t.unitId,t.topicId,e=>n("topicId",e))]})}var ol=n(87977);const rl={ADD_ATTR:["style","start","colspan","rowspan","target"]};function cl(e){var t;let{html:n,dir:l,className:s=""}=e;return(0,Ot.jsx)("div",{dir:null!==(t=ne(n))&&void 0!==t?t:l,className:"cbq-rich ".concat(s),dangerouslySetInnerHTML:{__html:ol.A.
1sanitize(String(null!==n&&void 0!==n?n:""),rl)}})}function dl(e){let{fact:t,open:n,onClose:l}=e;const{t:s}=(0,d.B)();if(!t)return null;const a=(e,t,n,l)=>(0,Ot.jsxs)("section",{className:"tw-flex tw-flex-col tw-gap-2",children:[(0,Ot.jsx)("span",{className:"tw-text-xs tw-font-bold tw-uppercase tw-tracking-wide tw-text-PRIMARY_60",children:e}),(0,Ot.jsxs)("div",{dir:l,style:{direction:l},className:"tw-rounded-lg tw-border tw-border-GREY_10 tw-bg-PRIMARY_2 tw-p-4",children:[(0,Ot.jsx)("h4",{className:"tw-mt-0 tw-mb-2 tw-text-sm tw-font-bold tw-text-GREY_90",children:t}),(0,Ot.jsx)(cl,{html:n,dir:l,className:"tw-text-[13px] tw-leading-7 tw-text-GREY_70"})]})]});return(0,Ot.jsxs)(Sn.A,{open:n,onClose:l,size:"lg",overflow:!0,children:[(0,Ot.jsx)(Sn.A.Header,{children:(0,Ot.jsx)(Sn.A.Title,{children:s("cbq.titles.preview")})}),(0,Ot.jsx)(Sn.A.Body,{children:(0,Ot.jsxs)("div",{className:"tw-flex tw-flex-col tw-gap-5",children:[a(s("cbq.lang.ar"),t.titleAr,t.descriptionAr,"rtl"),a(s("cbq.lang.en"),t.titleEn,t.descriptionEn,"ltr")]})}),(0,Ot.jsx)(Sn.A.Footer,{children:(0,Ot.jsx)(o.A,{onClick:l,appearance:"subtle",children:s("cbq.actions.close")})})]})}var ul=n(24858);const wl=(0,l.createContext)(null);function pl(e){let{children:t,initial:n="en"}=e;const[s,a]=(0,l.useState)(n),i=(0,l.useMemo)(()=>({lang:s,setLang:a,isArabic:"ar"===s,field:e=>"".concat(e).concat("ar"===s?"Ar":"En"),dir:"ar"===s?"rtl":"ltr"}),[s]);return(0,Ot.jsx)(wl.Provider,{value:i,children:t})}function ml(){const e=(0,l.useContext)(wl);if(!e)throw new Error("useEditorLanguage must be used inside <EditorLanguageProvider>");return e}function xl(){const{t:e,i18n:t}=(0,d.B)();return(0,l.useCallback)(n=>n?t.exists(n)?e(n):e("cbq.validation.invalid"):null,[e,t])}function bl(e){let{label:t,hint:n,error:l,required:s,children:a,className:i=""}=e;const o=xl()(null===l||void 0===l?void 0:l.message);return(0,Ot.jsxs)("div",{className:"cbq-field tw-flex tw-flex-col tw-gap-1.5 ".concat(i),children:[t?(0,Ot.jsxs)("label",{className:"tw-text-[13px] tw-font-semibold tw-text-GREY_90",children:[t,s?(0,Ot.jsx)("span",{className:"tw-text-ERROR_100 tw-mx-1",children:"*"}):null]}):null,a,o?(0,Ot.jsx)("span",{className:"tw-text-xs tw-text-ERROR_100",children:o}):n?(0,Ot.jsx)("span",{className:"tw-text-xs tw-text-GREY_50",children:n}):null]})}function vl(e){let{name:t,label:n,hint:l,error:s,placeholder:a,required:i,dir:o,rows:r,deps:c,disabled:d=!1,className:u}=e;return(0,Ot.jsx)(bl,{label:n,hint:l,error:s,required:i,className:u,children:(0,Ot.jsx)(ul.xI,{name:t,rules:c?{deps:c}:void 0,render:e=>{var t;let{field:n}=e;return(0,Ot.jsx)(m.A,{value:null!==(t=n.value)&&void 0!==t?t:"",onChange:n.onChange,onBlur:n.onBlur,placeholder:a,disabled:d,as:r?"textarea":"input",rows:r,style:o?{direction:o,textAlign:"rtl"===o?"right":"left"}:void 0})}})})}function hl(e){let{name:t,label:n,hint:l,disabled:s=!1,checkedValue:a=!0,uncheckedValue:i=!1,checkedLabel:o,uncheckedLabel:r,className:c=""}=e;const d=Boolean(o||r);return(0,Ot.jsxs)("div",{className:"tw-flex tw-items-center tw-justify-between tw-gap-4 ".concat(c),children:[(0,Ot.jsxs)("div",{className:"tw-flex tw-flex-col",children:[(0,Ot.jsx)("span",{className:"tw-text-[13px] tw-font-semibold tw-text-GREY_90",children:n}),l?(0,Ot.jsx)("span",{className:"tw-text-xs tw-text-GREY_50",children:l}):null]}),(0,Ot.jsx)(ul.xI,{name:t,render:e=>{let{field:t}=e;const n=t.value===a;return(0,Ot.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-2",children:[(0,Ot.jsx)(en.A,{checked:n,onChange:e=>t.onChange(e?a:i),disabled:s}),d?(0,Ot.jsx)("span",{className:"tw-whitespace-nowrap tw-text-[13px] tw-font-semibold tw-text-GREY_90",children:n?o:r}):null]})}})]})}var fl=n(6839);const gl={"*":"direction"},jl=e=>e.forEach(e=>e.attr("dir",null));const yl=/[\u0600-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/,Al=/[A-Za-z]/;function El(e){if(!/mso-bidi-font-(?:family|size)/i.test(e)||"undefined"===typeof DOMParser)return e;const t=(new DOMParser).parseFromString(e,"text/html");let n=!1;return t.body.querySelectorAll('[style*="mso-bidi-font"]').forEach(e=>{const t=e.textContent;if(!yl.test(t)||Al.test(t))return;const l=(s=e.getAttribute("style"),String(null!==s&&void 0!==s?s:"").split(";").map(e=>{const t=e.indexOf(":");return t<0?[]:[e.slice(0,t).trim(),e.slice(t+1).trim()]}).filter(e=>{let[t,n]=e;return t&&n}));var s;const a=e=>{var t;return null===(t=l.find(t=>{let[n]=t;return n.toLowerCase()===e}))||void 0===t?void 0:t[1]},i=a("mso-bidi-font-family"),o=a("mso-bidi-font-size");if(!i&&!o)return;const r=l.filter(e=>{let[t]=e;const n=t.toLowerCase();return!(i&&"font-family"===n)&&!(o&&"font-size"===n)});
1i&&r.push(["font-family",i]),o&&r.push(["font-size",o]),e.setAttribute("style",r.map(e=>{let[t,n]=e;return"".concat(t,": ").concat(n)}).join("; ")),n=!0}),n?t.body.innerHTML:e}const Il="cbq-cell",Nl=/^(bar-row|corner-)/,ql=(e,t)=>{const n=t.getBoundingClientRect().width;n&&(e=>{const t=e.querySelectorAll(":scope > colgroup > col");if(t.length)return Array.from(t);const n=Array.from(e.rows).find(e=>Array.from(e.cells).every(e=>1===e.colSpan));return n?Array.from(n.cells):[]})(t).forEach(t=>{const l=t.getBoundingClientRect().width/n*100;l>0&&e.dom.setStyle(t,"width","".concat(l.toFixed(2),"%"))})},Rl=(e,t)=>{Array.from(t.rows).forEach(t=>Array.from(t.cells).forEach(t=>{if((e=>{var t;return 1===e.childNodes.length&&(null===(t=e.firstElementChild)||void 0===t?void 0:t.classList.contains(Il))})(t))return;const n=e.dom.create("div",{class:Il});for(;t.firstChild;)n.appendChild(t.firstChild);t.appendChild(n)}))};function Cl(e){e.on("ObjectResizeStart",t=>{var n;const l=t.target;var s;"TABLE"===(null===(s=l)||void 0===s?void 0:s.nodeName)&&(((e,t)=>{"fixed"!==t.style.tableLayout&&(t.querySelector('col[style*="width"], col[width], td[style*="width"], td[width], th[style*="width"], th[width]')||ql(e,t),e.dom.setStyle(t,"table-layout","fixed"))})(e,l),Nl.test(null!==(n=t.origin)&&void 0!==n?n:"")&&Rl(e,l))})}const kl="cbqimageupload";function _l(){const{t:e}=(0,d.B)();return(0,l.useCallback)(t=>{const n=(e,n)=>{e.unblock(),e.setData({file:[]}),t.windowManager.alert(n)},l=l=>{const[s]=l.getData().file;s?(l.block(e("cbq.hints.uploadingImage")),qt(s).catch(()=>"").then(s=>{s?(l.close(),function(e,t){const{dom:n}
1=e,l="cbq-img-".concat(Date.now());e.undoManager.transact(()=>{e.insertContent(n.createHTML("img",{id:l,src:t,alt:""}));const s=n.get(l);if(!s)return;n.setAttrib(s,"id",null);const a=n.getParent(s,n.isBlock),i=n.create("p");s.parentNode.insertBefore(i,s),i.appendChild(s),a&&!e.schema.isValidChild(a.nodeName.toLowerCase(),"p")&&n.split(a,i),e.selection.setCursorLocation(i,1)})}(t,s)):n(l,e("cbq.toast.imageUploadFailed"))})):n(l,e("cbq.toast.mediaWrongType"))};t.ui.registry.addButton(kl,{icon:"image",tooltip:"Insert image",onAction:()=>t.windowManager.open({title:e("cbq.actions.addImage"),body:{type:"panel",items:[{type:"dropzone",name:"file"}]},initialData:{file:[]},buttons:[{type:"cancel",text:"Cancel"}],onChange:(e,t)=>{let{name:n}=t;"file"===n&&l(e)}})})},[e])}const Sl=["Cairo=cairo,sans-serif","Arial=arial,helvetica,sans-serif","Courier New=courier new,courier,monospace","Georgia=georgia,palatino,serif","Impact=impact,sans-serif","Lucida Console=lucida console,monaco,monospace","Tahoma=tahoma,arial,helvetica,sans-serif","Times New Roman=times new roman,times,serif","Verdana=verdana,geneva,sans-serif"].join("; "),Yl="undo redo | fontsize fontfamily blocks | bold italic strikethrough underline | alignleft aligncenter alignright al
1ignjustify | numlist bullist | "+"forecolor backcolor | removeformat | table | link ".concat(kl),Ml=["default","".concat("","/css/cairo.css")];function Tl(e){let{minHeight:t}=e;const{dir:n,isArabic:s}=ml(),a=_l(),i=function(){const{t:e}=(0,d.B)();return(0,l.useCallback)(t=>{const n=t.blob();return qt(new File([n],t.filename(),{type:n.type})).catch(()=>"").then(t=>t||Promise.reject({message:e("cbq.toast.imageUploadFailed"),remove:!0}))},[e])}();return(0,l.useMemo)(()=>({menubar:!1,statusbar:!1,resize:!1,branding:!1,promotion:!1,directionality:n,invalid_styles:gl,invalid_elements:"iframe,object,embed",language:"en",min_height:null!==t&&void 0!==t?t:220,autoresize_bottom_margin:12,plugins:"advlist autolink autoresize directionality link lists table",toolbar:Yl,toolbar_mode:"wrap",contextmenu:"table",font_family_formats:Sl,font_size_formats:"8pt 10pt 12pt 14pt 18pt 24pt 36pt",block_formats:"Paragraph=p; Heading 1=h1; Heading 2=h2; Heading 3=h3; Heading 4=h4; Heading 5=h5",setup:e=>{!function(e){e.on("input",t=>{"formatSetBlockTextDirection"===t.inputType&&e.dom.select('[style*="direction"]').forEach(t=>{e.dom.setStyle(t,"direction",null)})}),e.on("PreInit",()=>{e.parser.addAttributeFilter("dir",jl),e.serializer.addAttributeFilter("dir",jl)})}(e),function(e){e.on("PastePreProcess",e=>{e.internal||(e.content=El(e.content))}),e.on("PastePostProcess",t=>{t.node.querySelectorAll('img[src^="blob:"]').forEach(t=>{e.editorUpload.blobCache.getByUri(t.getAttribute("src"))||t.remove()})}),e.on("input",t=>{"insertFromPaste"===t.inputType&&function(e){const t=e.selection.getRng();if(!t.collapsed||1!==t.startContainer.nodeType)return;let n=t.startContainer.childNodes[t.startOffset-1];for(;n&&1===n.nodeType&&!e.dom.isBlock(n);)n=n.lastChild;n&&3===n.nodeType&&n.data.length&&(e.selection.setCursorLocation(n,n.data.length),e.nodeChanged())}(e)})}(e),Cl(e),a(e)},paste_webkit_styles:"font-family font-size color font-weight font-style text-decoration",paste_data_images:!0,images_upload_handler:i,images_file_types:"jpeg,jpg,png",convert_urls:!1,content_css:Ml,content_style:"body{font-family:cairo,sans-serif;font-size:14px;line-height:1.7;padding:8px 12px;"+"direction:".concat(n,";text-align:").concat(s?"right":"left",";}")+'img{max-width:100%;height:auto;}table{border-collapse:collapse;}table:has(col[style*="width"],col[width],td[style*="width"],td[width],th[style*="width"],th[width]){table-layout:fixed;}table td,table th{border:1px solid #d9d9d9;overflow-wrap:break-word;}table:not([cellpadding]) td,table:not([cellpadding]) th{padding:4px 8px;}table td p,table th p{margin:5px 0;}'+"table td>.".concat(Il,",table th>.").concat(Il)+"{padding:4px 8px;display:flex;flex-direction:column;justify-content:safe center;}"+"table td:has(>.".concat(Il,"),table th:has(>.").concat(Il,")")+"{padding:0;position:relative;}"+'table tr[style*="height"]>td>.'.concat(Il,",")+'table tr[style*="height"]>th>.'.concat(Il)+"{position:absolute;inset:0;overflow:hidden;}"}),[n,s,t,a,i])}function Pl(e){let{name:t,label:n,hint:l,error:s,minHeight:a,deps:i,disabled:o=!1}=e;const r=Tl({minHeight:a});return(0,Ot.jsx)(bl,{label:n,hint:l,error:s,children:(0,Ot.jsx)(ul.xI,{name:t,rules:i?{deps:i}:void 0,render:e=>{var n;let{field:l}=e;return(0,Ot.jsx)("div",{className:"tw-rounded-md tw-overflow-hidden tw-border ".concat(s?"tw-border-ERROR_75":"tw-border-GREY_
110"),children:(0,Ot.jsx)(fl.K,{tinymceScriptSrc:"/tinymce/tinymce.min.js",licenseKey:"gpl",disabled:o,value:null!==(n=l.value)&&void 0!==n?n:"",onEditorChange:l.onChange,onBlur:l.onBlur,init:r},t)})}})})}var Ol=n(91850),Gl=n(9139),Fl=n(5341);const zl={required:"cbq.validation.required",requiredEnglish:"cbq.validation.requiredEnglish",minOptions:"cbq.validation.minOptions",minItems:"cbq.validation.minItems",minCategories:"cbq.validation.minCategories",atLeastOneCorrect:"cbq.validation.atLeastOneCorrect",exactlyOneCorrect:"cbq.validation.exactlyOneCorrect",needsBlank:"cbq.validation.needsBlank",blanksMismatch:"cbq.validation.blanksMismatch",invalidNumber:"cbq.validation.invalidNumber",unknownCategory:"cbq.validation.unknownCategory",minClassifications:"cbq.validation.minClassifications",minTopics:"cbq.validation.minTopics",timeRange:"cbq.validation.timeRange"},Dl=()=>Gl.Yj().default(""),Bl=()=>Gl.Yj().default(""),Ll=()=>Gl.KC([Gl.Yj(),Gl.ai()]),Ql=()=>Gl.KC([Gl.Yj(),Gl.ai()]).default(""),Ul=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:zl.required;return Gl.Yj().refine(t=>e.includes(t),t)},Vl=function(e,t,n,l){let{isEmpty:s=$,message:a=zl.requiredEnglish}=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};s(null===t||void 0===t?void 0:t["".concat(n,"En")])&&e.addIssue({code:"custom",message:a,path:[...l,"".concat(n,"En")]})},Hl={isEmpty:Pe},Kl=Gl.Ik({id:Ll(),certificateId:Ql(),courseId:Ql(),unitId:Ql(),topicIds:Gl.YO(Gl.KC([Gl.Yj(),Gl.ai()])).default([])}),Wl=Gl.Ik({classifications:Gl.YO(Kl).min(1,zl.minClassifications),difficulty:Ul(Object.values(P)),category:Ul(Object.values(O)),conceptType:Ul(Object.values(G)),durationSeconds:Fl.ai().min(1,zl.timeRange).max(3600,zl.timeRange),usedIn:Gl.YO(Ul(Object.values(z))).min(1,zl.required),questionSizeId:Gl.KC([Gl.Yj(),Gl.ai()]).refine(e=>""!==e&&null!=e,zl.required),rank:Gl.Yj().trim().min(1,zl.required),status:Ul(Object.values(F))}).superRefine((e,t)=>{e.classifications.reduce((e,t)=>{var n,l;return e+(null!==(n=null===(l=t.topicIds)||void 0===l?void 0:l.length)&&void 0!==n?n:0)},0)||t.addIssue({code:"custom",message:zl.minTopics,path:["classifications"]})}),Zl=Gl.Ik({shuffle:Gl.zM().default(!0),options:Gl.YO(Gl.Ik({id:Ll(),textAr:Dl(),textEn:Dl(),explanationAr:Dl(),explanationEn:Dl(),correct:Gl.zM().default(!1)})).default([])}),$l=Gl.Ik({templateAr:Dl(),templateEn:Dl(),blanks:Gl.YO(Gl.Ik({id:Ll(),correctAnswer:Gl.Yj().default("")})).default([])}),Xl=Gl.Ik({categories:Gl.YO(Gl.Ik({id:Ll(),nameAr:Bl(),nameEn:Bl()})).default([]),items:Gl.YO(Gl.Ik({id:Ll(),textAr:Bl(),textEn:Bl(),categoryId:Gl.KC([Gl.Yj(),Gl.ai()]).default("")})).default([])}),Jl=Gl.Ik({shuffle:Gl.zM().default(!0),items:Gl.YO(Gl.Ik({id:Ll(),textAr:Bl(),textEn:Bl()})).default([])}),es=Gl.Ik({templateAr:Dl(),templateEn:Dl(),blanks:Gl.YO(Gl.Ik({id:Ll(),options:Gl.YO(Gl.Ik({id:Ll(),textAr:Bl(),textEn:Bl(),correct:Gl.zM().default(!1)})).default([])})).default([])}),ts=Gl.Ik({mcq:Zl,numeric:$l,categorization:Xl,sequence:Jl,cloze:es}),ns=(e,t)=>{const{options:n}=e.payload.mcq,l=["payload","mcq","options"];n.length<2&&t.addIssue({code:"custom",message:zl.minOptions,path:l}),n.forEach((e,n)=>{Vl(t,e,"text",[...l,n])});const s=n.filter(e=>e.correct).length;e.type===M.MCQ_SINGLE&&1!==s&&t.addIssue({code:"custom",message:zl.exactlyOneCorrect,path:l}),e.type===M.MCQ_MULTI&&s<1&&t.addIssue({code:"custom",message:zl.atLeastOneCorrect,path:l})},ls=(e,t,n,l,s)=>{if($(l))return void e.addIssue({code:"custom",message:zl.requiredEnglish,path:["payload",t,"templateEn"]});const a=oe(n),i=oe(l);!$(n)&&a<1&&e.addIssue({code:"custom",message:zl.needsBlank,path:["payload",t,"templateAr"]}),i<1&&e.addIssue({code:"custom",message:zl.needsBlank,path:["payload",t,"templateEn"]}),a>0&&i>0&&a!==i&&e.addIssue({code:"custom",message:zl.blanksMismatch,path:["payload",t,"templateEn"]});const o=Math.max(a,i);o>0&&s!==o&&e.addIssue({code:"custom",message:zl.blanksMismatch,path:["payload",t,"blanks"]})},ss={[M.MCQ_SINGLE]:ns,[M.MCQ_MULTI]:ns,[M.NUMERIC]:(e,t)=>{const n=e.payload.numeric;ls(t,"numeric",n.templateAr,n.templateEn,n.blanks.length),n.blanks.forEach((e,n)=>{const l=["payload","numeric","blanks",n];(e=>{const t=De(e);if(!t)return!1;if(!/^-?\d+(\.\d+)?$/.test(t))return!1;const[,n=""]=t.split(".");return n.length<=10})(e.correctAnswer)||t.addIssue({code:"custom",message:e.correctAnswer?zl.invali
1dNumber:zl.required,path:[...l,"correctAnswer"]})})},[M.CATEGORIZATION]:(e,t)=>{const n=e.payload.categorization,l=["payload","categorization","categories"],s=["payload","categorization","items"];n.categories.length<2&&t.addIssue({code:"custom",message:zl.minCategories,path:l}),n.categories.forEach((e,n)=>{Vl(t,e,"name",[...l,n],Hl)}),n.items.length<1&&t.addIssue({code:"custom",message:zl.minItems,path:s});const a=new Set(n.categories.map(e=>e.id));n.items.forEach((e,n)=>{Vl(t,e,"text",[...s,n],Hl),e.categoryId&&a.has(e.categoryId)||t.addIssue({code:"custom",message:zl.unknownCategory,path:[...s,n,"categoryId"]})})},[M.SEQUENCE]:(e,t)=>{const{items:n}=e.payload.sequence,l=["payload","sequence","items"];n.length<2&&t.addIssue({code:"custom",message:zl.minItems,path:l}),n.forEach((e,n)=>{Vl(t,e,"text",[...l,n],Hl)})},[M.CLOZE]:(e,t)=>{const n=e.payload.cloze;ls(t,"cloze",n.templateAr,n.templateEn,n.blanks.length),n.blanks.forEach((e,n)=>{const l=["payload","cloze","blanks",n,"options"];e.options.length<2&&t.addIssue({code:"custom",message:zl.minOptions,path:l}),e.options.forEach((e,n)=>{Vl(t,e,"text",[...l,n],Hl)}),1!==e.options.filter(e=>e.correct).length&&t.addIssue({code:"custom",message:zl.exactlyOneCorrect,path:l})})}},as=Gl.Ik({id:Ll().nullable().default(null),type:Ul(Object.values(M)),meta:Wl,titleAr:Dl(),titleEn:Dl(),explanationAr:Dl(),explanationEn:Dl(),payload:ts}).superRefine((e,t)=>{var n;Vl(t,e,"title",[]),null===(n=ss[e.type])||void 0===n||n.call(ss,e,t)}),is=Gl.Ik({id:Ll().nullable().default(null),titleAr:Gl.Yj().trim(),titleEn:Gl.Yj().trim(),descriptionAr:Dl(),descriptionEn:Dl(),imageUrl:Bl(),status:Ul(Object.values(F)).default(F.INACTIVE)}).superRefine((e,t)=>{Vl(t,e,"title",[],Hl),Vl(t,e,"description",[])});function os(e){let{open:t,fact:n,onClose:s}=e;const{t:a}=(0,d.B)(),i=(0,v.jE)(),o=Boolean(null===n||void 0===n?void 0:n.id),[r,c]=(0,l.useState)(!1),u=(0,ul.mN)({resolver:(0,Ol.u)(is),defaultValues:Te(),mode:"onSubmit",reValidateMode:"onChange"}),{handleSubmit:p,reset:m,formState:x,setValue:b,watch:h}=u;(0,l.useEffect)(()=>{t&&m(n?(0,w.A)((0,w.A)({},Te()),rs(n)):Te())},[t,n,m]);const f=(0,g.n)({mutationFn:e=>o?async function(e,t){await I.Ay.post("/questions/fact/update",(0,w.A)((0,w.A)({},ft(t)),{},{factId:Number(e)}))}(n.id,e):async function(e){await I.Ay.post("/questions/fact/new",ft(e))}(e),onSuccess:()=>{i.invalidateQueries({queryKey:At.all}),j.oR.success(a(o?"cbq.toast.updated":"cbq.toast.created")),null===s||void 0===s||s()},onError:()=>j.oR.error(a("cbq.toast.saveFailed"))}),y=p(e=>{se(e)?j.oR.error(a("cbq.toast.imageStillUploading")):f.mutate(e)},()=>j.oR.error(a("cbq.toast.validationFailed"))),A=(0,l.useCallback)(e=>b("imageUrl",null!==e&&void 0!==e?e:"",{shouldDirty:!0}),[b]),E=(0,l.useCallback)(async e=>{var t;const n=null===e||void 0===e||null===(t=e[e.length-1])||void 0===t?void 0:t.blobFile;if(n){c(!0);try{A(await qt(n))}catch(l){j.oR.error(a("cbq.toast.imageUploadFailed"))}finally{c(!1)}}},[A,a]),N=(0,l.useCallback)(e=>{var t,n;"Escape"===(null===e||void 0===e?void 0:e.key)&&null!==(t=e.target)&&void 0!==t&&null!==(n=t.closest)&&void 0!==n&&n.call(t,".tox")||null===s||void 0===s||s()},[s]);return{form:u,isEdit:o,errors:x.errors,submit:y,requestClose:N,isSaving:f.isPending,isUploading:r,imageUrl:h("imageUrl"),pickImage:E,clearImage:(0,l.useCallback)(()=>A(""),[A])}}const rs=e=>{var t,n,l,s,a;return{id:e.id,titleAr:null!==(t=e.titleAr)&&void 0!==t?t:"",titleEn:null!==(n=e.titleEn)&&void 0!==n?n:"",descriptionAr:null!==(l=e.descriptionAr)&&void 0!==l?l:"",descriptionEn:null!==(s=e.descriptionEn)&&void 0!==s?s:"",imageUrl:null!==(a=e.imageUrl)&&void 0!==a?a:"",status:e.status}};var cs=n(75899);function ds(e){let{value:t,onPick:n,onClear:l,uploading:s,className:a}=e;const{t:i}=(0,d.B)();return(0,Ot.jsx)(bl,{label:i("Photo"),hint:s?i("cbq.hints.uploadingImage"):t?void 0:i("cbq.hints.noImage"),className:a,children:(0,Ot.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-3",children:[(0,Ot.jsx)("span",{className:"tw-flex tw-h-16 tw-w-24 tw-shrink-0 tw-items-center tw-justify-center tw-overflow-hidden tw-rounded-md tw-border tw-border-GREY_
110 tw-bg-PRIMARY_2",children:t?(0,Ot.jsx)("img",{src:t,alt:i("Photo"),className:"tw-h-full tw-w-full tw-object-cover"}):(0,Ot.jsx)(c.fZZ,{size:20,className:"tw-text-GREY_30"})}),(0,Ot.jsx)(cs.A,{autoUpload:!1,fileList:[],action:"",accept:"image/png,image/jpeg,image/jpg",disabled:s,onChange:n,children:(0,Ot.jsx)(o.A,{appearance:"ghost",startIcon:(0,Ot.jsx)(c.B88,{}),loading:s,children:i(t?"ChangeImage":"cbq.actions.addImage")})}),t?(0,Ot.jsx)(Jt.A,{appearance:"subtle",icon:(0,Ot.jsx)(c.IXo,{}),className:"tw-text-ERROR_100",disabled:s,onClick:l,"aria-label":i("DeleteImage")}):null]})})}function us(e){let{lang:t,errors:n}=e;const{t:l}=(0,d.B)(),s="ar"===t,a=s?"Ar":"En";return(0,Ot.jsx)(pl,{initial:t,children:(0,Ot.jsxs)("section",{className:"tw-flex tw-min-w-0 tw-flex-col tw-gap-3",children:[(0,Ot.jsx)(vl,{name:"title".concat(a),label:l(s?"ArabicTitle":"EnglishTitle"),placeholder:l("cbq.placeholders.factTitle"),error:null===n||void 0===n?void 0:n["title".concat(a)],dir:s?"rtl":"ltr"}),(0,Ot.jsx)(Pl,{name:"description".concat(a),label:l(s?"ArabicDescription":"EnglishDescription"),error:null===n||void 0===n?void 0:n["description".concat(a)],minHeight:180})]})})}function ws(e){let{open:t,fact:n,onClose:l}=e;const{t:s}=(0,d.B)(),{form:a,isEdit:i,errors:r,submit:u,requestClose:p,isSaving:m,isUploading:x,imageUrl:b,pickImage:v,clearImage:h}=os({open:t,fact:n,onClose:l}),f=m||x;return(0,Ot.jsx)(ul.Op,(0,w.A)((0,w.A)({},a),{},{children:(0,Ot.jsxs)(Sn.A,{open:t,onClose:f?void 0:p,size:"lg",overflow:!0,backdrop:"static",enforceFocus:!1,children:[(0,Ot.jsx)(Sn.A.Header,{children:(0,Ot.jsx)(Sn.A.Title,{children:s(i?"cbq.titles.editFact":"cbq.titles.newFact")})}),(0,Ot.jsx)(Sn.A.Body,{children:(0,Ot.jsxs)("form",{id:"cbq-fact-form",onSubmit:u,className:"tw-flex tw-flex-col tw-gap-5",children:[(0,Ot.jsx)("p",{className:"tw-m-0 tw-text-xs tw-text-GREY_50",children:s("cbq.hints.factOnly")}),(0,Ot.jsxs)("div",{className:"tw-grid tw-min-w-0 tw-grid-cols-1 tw-gap-5 lg:tw-grid-cols-2",children:[(0,Ot.jsx)(us,{lang:"en",errors:r}),(0,Ot.jsx)(us,{lang:"ar",errors:r})]}),(0,Ot.jsxs)("div",{className:"tw-grid tw-min-w-0 tw-grid-cols-1 tw-gap-4 lg:tw-grid-cols-3",children:[(0,Ot.jsx)(hl,{name:"status",label:s("cbq.labels.factStatus"),checkedValue:F.ACTIVE,uncheckedValue:F.INACTIVE,checkedLabel:s("cbq.status.ACTIVE"),uncheckedLabel:s("cbq.status.INACTIVE"),className:"tw-h-fit tw-self-center tw-rounded-md tw-border tw-border-GREY_
110 tw-px-3 tw-py-2.5"}),(0,Ot.jsx)(ds,{value:b,onPick:v,onClear:h,uploading:x,className:"lg:tw-col-span-2"})]})]})}),(0,Ot.jsxs)(Sn.A.Footer,{children:[(0,Ot.jsx)(o.A,{appearance:"subtle",onClick:l,disabled:f,children:s("cbq.actions.cancel")}),(0,Ot.jsx)(o.A,{appearance:"primary",type:"submit",form:"cbq-fact-form",startIcon:(0,Ot.jsx)(c.Bc_,{}),loading:m,disabled:x,className:"tw-bg-PRIMARY_60",children:s(i?"cbq.actions.saveChanges":"cbq.actions.createFact")})]})]})}))}function ps(e){var t;let{onAddQuestion:n,onOpenQuestion:l,onViewQuestion:s}=e;const{t:a}=(0,d.B)(),{filters:u,rows:v,total:h,page:f,setPage:g,limit:j,setLimit:y,isLoading:A,isFetching:E,isError:I,search:N,setSearch:q,remove:R,isRemoving:C,exportCsv:k,isExporting:_,isExpanded:S,toggle:Y,resultsSearch:M,preview:T,setPreview:P,editing:O,setEditing:G,pendingDelete:F,setPendingDelete:z}=Zt();return(0,Ot.jsxs)("div",{className:"tw-flex tw-w-full tw-min-w-0 tw-flex-col tw-gap-5",children:[(0,Ot.jsxs)("header",{className:"tw-flex tw-min-w-0 tw-flex-wrap tw-items-center tw-gap-3",children:[(0,Ot.jsx)(x.io,{title:a("cbq.titles.cbq"),color:"blue"}),(0,Ot.jsx)("div",{className:"tw-flex-1"}),(0,Ot.jsxs)(p.A,{inside:!0,className:"tw-max-w-xs",children:[(0,Ot.jsx)(m.A,{value:N,onChange:q,placeholder:a("cbq.placeholders.searchFacts")}),(0,Ot.jsx)(p.A.Addon,{children:(0,Ot.jsx)(c.CKj,{})})]}),(0,Ot.jsx)(o.A,{appearance:"primary",startIcon:(0,Ot.jsx)(c.GGD,{}),onClick:()=>G({}),className:"tw-bg-PRIMARY_60",children:a("cbq.actions.add")}),(0,Ot.jsx)(o.A,{startIcon:(0,Ot.jsx)(c.a4x,{}),onClick:k,loading:_,children:a("cbq.actions.export")})]}),(0,Ot.jsx)(il,(0,w.A)({},u)),I?(0,Ot.jsx)(r.A,{type:"error",showIcon:!0,children:a("cbq.errors.listFailed")}):null,A?(0,Ot.jsx)("div",{className:"tw-flex tw-h-48 tw-items-center tw-justify-center",children:(0,Ot.jsx)(i.A,{size:"md",content:a("cbq.labels.loading")})}):null,A||I||v.length?null:(0,Ot.jsx)(r.A,{type:"info",showIcon:!0,children:a("cbq.labels.noFacts")}),(0,Ot.jsx)("div",{className:"tw-flex tw-min-w-0 tw-flex-col tw-gap-4 ".concat(E&&!A?"tw-opacity-60":""),children:v.map(e=>(0,Ot.jsx)(al,{fact:e,expanded:S(e.id),search:M,onToggle:()=>Y(e.id),onPreview:()=>P(e),onEdit:()=>G(e),onDelete:()=>z(e),onAddQuestion:n,onOpenQuestion:l,onViewQuestion:s},e.id))}),h?(0,Ot.jsx)(b.dK,{page:f,pageSize:j,total:h,onPageChange:g,onPageSizeChange:y}):null,(0,Ot.jsx)(ws,{open:Boolean(O),fact:null!==O&&void 0!==O&&O.id?O:null,onClose:()=>G(null)}),(0,Ot.jsx)(dl,{fact:T,open:Boolean(T),onClose:()=>P(null)}),(0,Ot.jsx)(Yn,{open:Boolean(F),title:a("cbq.dialogs.deleteFactTitle"),description:a("cbq.dialogs.deleteFactDescription",{name:null!==(t=null===F||void 0===F?void 0:F.title)&&void 0!==t?t:""}),loading:C,onClose:()=>z(null),onConfirm:()=>R(F.id,{onSuccess:()=>z(null)})})]})}const ms=new Set(["ref","type","types","message"]);function xs(e){var t,n,l;return null!==(t=null!==(n=null===e||void 0===e||null===(l=e.root)||void 0===l?void 0:l.message)&&void 0!==n?n:null===e||void 0===e?void 0:e.message)&&void 0!==t?t:null}function bs(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(!e||"object"!==typeof e)return[];const n=[];return"string"===typeof e.message&&e.message&&n.push({path:t,message:e.message}),e.root&&n.push(...bs(e.root,t)),Object.keys(e).forEach(l=>{if(ms.has(l)||"root"===l)return;const s=e[l];s&&"object"===typeof s&&n.push(...bs(s,t?"".concat(t,".").concat(l):l))}),n}const vs=(e,t)=>t?{key:e,params:t}:{key:e},hs=e=>{var t;return vs("cbq.labels.optionNumber",{letter:null!==(t="ABCDEFGHIJKLMNOPQRSTUVWXYZ"[Number(e)])&&void 0!==t?t:Number(e)+1})},fs=e=>vs("cbq.labels.blankNumber",{number:Number(e)+1}),gs={difficulty:"cbq.labels.difficulty",category:"cbq.labels.category",conceptType:"cbq.labels.concept",durationSeconds:"cbq.labels.estimatedTime",questionSizeId:"cbq.labels.size",usedIn:"cbq.labels.usedIn",rank:"cbq.labels.rank",status:"cbq.labels.status"},js={certificateId:"cbq.labels.certificate",courseId:"cbq.labels.course",unitId:"cbq.labels.unit",topicIds:"cbq.labels.topics"},ys=[[/^type$/,()=>[vs("cbq.titles.typeSection")]],[/^title(?:Ar|En)$/,()=>[vs("cbq.labels.questionText")]],[/^explanation(?:Ar|En)$/,()=>[vs("cbq.labels.questionExplanation")]],[/^meta\.classifications$/,()=>[vs("cbq.labels.academicClassification")]],[/^meta\.classifications\.\d+\.(\w+)$/,e=>js[e[1]]?[vs("cbq.labels.academicClassification"),vs(js[e[1]])]:null],[/^meta\.(\w+)$/,e=>gs[e[1]]?[vs(gs[e[1]])]:null],[/^payload\.mcq\.options$/,()=>[vs("cbq.labels.options")]],[/^payload\.mcq\.options\.(\d+)\.text(?:Ar|En)$/,e=>[hs(e[1]),vs("cbq.labels.optionText")]],[/^payload\.mcq\.options\.(\d+)\.explanation(?:Ar|En)$/,e=>[hs(e[1]),vs("cbq.labels.optionExplanation")]],[/^payload\.numeric\.template(?:Ar|En)$/,()=>[vs("cbq.labels.numericTemplate")]],[/^payload\.numeric\.blanks$/,()=>[vs("cbq.labels.blanks")]],[/^payload\.numeric\.blanks\.(\d+)\.correctAnswer$/,e=>[vs("cbq.labels.blankAnswer",{number:Number(e[1])+1})]],[/^payload\.categorization\.categories$/,()=>[vs("cbq.labels.categories")]],[/^payload\.categorization\.categories\.(\d+)\.name(?:Ar|En)$/,e=>[vs("cbq.labels.categoryName",{number:Number(e[1])+1})]],[/^payload\.categorization\.items$/,()=>[vs("cbq.labels.itemsToCategorize")]],[/^payload\.categorization\.items\.(\d+)\.categoryId$/,e=>[vs("cbq.labels.itemText",{number:Number(e[1])+1}),vs("cbq.labels.correctCategory")]],[/^payload\.categorization\.items\.(\d+)\.text(?:Ar|En)$/,e=>[vs("cbq.labels.itemText",{number:Number(e[1])+1})]],[/^payload\.sequence\.items$/,()=>[vs("cbq.labels.steps")]],[/^payload\.sequence\.items\.(\d+)\.text(?:Ar|En)$/,e=>[vs("cbq.labels.stepNumber",{number:Number(e[1])+1})]],[/^payload\.cloze\.template(?:Ar|En)$/,()=>[vs("cbq.labels.sentenceTemplate")]],[/^payload\.cloze\.blanks$/,()=>[vs("cbq.labels.blanks")]],[/^payload\.cloze\.blanks\.(\d+)\.options$/,e=>[fs(e[1]),vs("cbq.labels.options")]],[/^payload\.cloze\.blanks\.(\d+)\.options\.(\d+)\.text(?:Ar|En)$/,e=>[fs(e[1]),hs(e[2])]]];function As(e){var t;const n=null!==(t=String(e).split(".").pop())&&void 0!==t?t:"";return/[a-z]Ar$/.test(n)?"ar":/[a-z]En$/.test(n)?"en":null}function Es(e){const t=new Set;return bs(e).reduce((e,n)=>{let{path:l,message:s}=n;const a="".concat(l,"|").concat(s);return t.has(a)||(t.add(a),e.push((0,w.A)({path:l,message:s},function(e){const t=ys.find(t=>{let[n]=t;return n.test(e)}),n=t?t[1](e.match(t[0])):null;return{parts:null!==n&&void 0!==n?n:[],lang:As(e)}}(l)))),e},[])}function Is(e,t){let{enabled:n=!0}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{data:s,isLoading:a,isError:i}=(0,h.I)({queryKey:At.factQuestion(e,t),queryFn:()=>async function(e,t){var n,l;const s="/questions/cbq/fullinfo".concat(Et({factId:Number(e),skip:0,take:1,filter:[["id","=",Number(t)]]})),{data:a}=await I.Ay.get(s);return null!==(n=(null!==(l=null===a||void 0===a?void 0:a.data)&&void 0!==l?l:[])[0])&&void 0!==n?n:null}(e,t),enabled:Boolean(e)&&Boolean(t)&&n,staleTime:yt}),o=(0,l.useMemo)(()=>pt(null===s||void 0===s?void 0:s.contentJson),[s]);return{row:null!==s&&void 0!==s?s:null,content:o,isLoading:a,isError:i}}const Ns=[];function qs(e){const t=Boolean(e),{data:n,isLoading:l,isError:s,isFetched:a}=(0,h.I)({queryKey:At.questionMedia(e),queryFn:()=>async function(e){var t,n;const l=await I.Ay.get("/videos/fullinfo/question/".concat(Number(e),"?type=EXPLANATION"));return(null!==(t=null===l||void 0===l||null===(n=l.data)||void 0===n?void 0:n.data)&&void 0!==t?t:[]).map(ye)}(e),enabled:t,staleTime:yt});return{items:null!==n&&void 0!==n?n:Ns,isLoading:t&&l,isError:t&&s,isFetched:t&&a}}const Rs="cbq/media-sync-failed";function Cs(e){let{questionId:t}=e;const{t:n}=(0,d.B)(),s=(0,v.jE)(),[a,i]=(0,l.useState)([]),[o,r]=(0,l.useState)([]),[c,u]=(0,l.useState)(null),[p,m]=(0,l.useState)(null),x=(0,l.useRef)(!1),{items:b,isLoading:h,isError:f,isFetched:g}=qs(t);(0,l.useEffect)(()=>{g&&!x.current&&(i(b),x.current=!0)},[g,b]);const y=(0,l.useRef)(a),A=(0,l.useRef)(o);(0,l.useEffect)(()=>{y.current=a,A.current=o},[a,o]);const E=(0,l.useCallback)(async(e,t)=>{if(!t)return;const l=function(e,t){const n=we[e];return n&&t&&n.extensions.includes(pe(t.name))?t.size>n.maxBytes?"cbq.toast.mediaTooLarge":null:"cbq.toast.mediaWrongType"}(e,t);if(l)j.oR.error(n(l));else{u(e),m(0);try{const n=await kt(t,m);if(!n.url)throw new Error("upload returned no url");i(l=>[...l,je(e,n,t)])}catch(s){j.oR.error(n("cbq.toast.mediaUploadFailed"))}finally{u(null),m(null)}}},[n]),I=(0,l.useCallback)(e=>{i(t=>t.filter(t=>
1t.key!==e.key)),e.id&&r(t=>[...t,e])},[]),N=(0,l.useCallback)(async e=>{const{toAttach:t,toDetach:n}=Ae(y.current,A.current);if(!t.length&&!n.length)return;const l=[],a=[];let o=!1;try{for(const n of t)await _t(e,n),l.push(n.key);for(const t of n)await St(e,t),a.push(t.key)}catch(c){o=!0}if(l.length&&i(e=>e.map(e=>l.includes(e.key)?(0,w.A)((0,w.A)({},e),{},{synced:!0}):e)),a.length&&r(e=>e.filter(e=>!a.includes(e.key))),o||(x.current=!1),s.invalidateQueries({queryKey:At.questionMedia(e)}),o)throw Object.assign(new Error("Explanation media sync failed"),{code:Rs})},[s]);return{items:a,isLoading:h,isError:f,uploadingKind:c,uploadPercent:p,add:E,remove:I,sync:N,hasUnsaved:Ee(a,o)}}function ks(e){const t=new Map;return(null!==e&&void 0!==e?e:[]).forEach(e=>{var n;const l=null!==(n=e.unitId)&&void 0!==n?n:"";var s,a;t.has(l)||t.set(l,{id:"cls-".concat(l),certificateId:"",courseId:null!==(s=e.courseId)&&void 0!==s?s:"",unitId:null!==(a=e.unitId)&&void 0!==a?a:"",topicIds:[]});t.get(l).topicIds.push(e.topicId)}),t.size?[...t.values()]:[Ie()]}function _s(){let{factId:e,questionId:t,onSaved:n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{t:s}=(0,d.B)(),a=(0,v.jE)(),i=Boolean(t),{row:o,content:r,isLoading:c}=Is(e,t,{enabled:i}),u=o?null===r||void 0===r?void 0:r.type:void 0,p=o&&!Ue(u)?u||"\u2014":"",{data:m,isLoading:x}=(0,h.I)({queryKey:At.questionTopics(t),queryFn:()=>Yt(t),enabled:i,staleTime:yt}),b=(0,ul.mN)({resolver:(0,Ol.u)(as),defaultValues:Me(),mode:"onSubmit",reValidateMode:"onChange",shouldFocusError:!0}),{handleSubmit:f,reset:A,setError:E,formState:N}=b,[q,R]=(0,l.useState)(!1);(0,l.useEffect)(()=>{i&&!q&&o&&m&&(A(ht(o,{classifications:ks(m)})),R(!0))},[i,q,o,m,A]);const[C,k]=(0,l.useState)(null),_=null!==t&&void 0!==t?t:C,S=Cs({questionId:t}),Y=(0,g.n)({mutationFn:async t=>{let n=_;return n?await async function(e,t,n){const l=vt(n,{factId:t}),{topicsIds:s}=l,a=(0,y.A)(l,jt);await I.Ay.post("/questions/question/update",(0,w.A)((0,w.A)({},a),{},{questionId:Number(e)})),await Mt(e,s)}(n,e,t):(n=await async function(e,t){const{data:n}=await I.Ay.post("/questions/question/cbq/new",vt(t,{factId:e}));return null===n||void 0===n?void 0:n.questionId}(e,t),k(n)),await S.sync(n),n},onSettled:t=>{a.invalidateQueries({queryKey:At.factQuestions(e)}),t&&a.invalidateQueries({queryKey:At.questionTopics(t)})},onSuccess:()=>{j.oR.success(s(i?"cbq.toast.questionUpdated":"cbq.toast.questionCreated")),null===n||void 0===n||n()},onError:e=>j.oR.error(s((null===e||void 0===e?void 0:e.code)===Rs?"cbq.toast.mediaSyncFailed":"cbq.toast.saveFailed"))}),[M,T]=(0,l.useState)(!1),P=async e=>{T(!0);try{const t=await async function(e){var t;const n="/questions/fullinfo".concat(Et({skip:0,take:5,filter:[["questionTypeId","=","CBQ"],"and",["rank","=",e]]})),{data:l}=await I.Ay.get(n);return null!==(t=null===l||void 0===l?void 0:l.data)&&void 0!==t?t:[]}(e);return t.some(e=>String(e.id)!==String(_))}catch(t){return!1}finally{T(!1)}},O=f(async e=>{if(!se(e))return await P(e.meta.rank)?(E("meta.rank",{type:"manual",message:"cbq.validation.rankTaken"},{shouldFocus:!0}),void j.oR.error(s("cbq.validation.rankTaken"))):void Y.mutate(e);j.oR.error(s("cbq.toast.imageStillUploading"))},e=>j.oR.error(s("cbq.toast.validationSummary",{count:Es(e).length})));return{form:b,isEdit:i,unsupportedType:p,isLoading:i&&(c||x||Boolean(o&&m&&!q)),isSaving:M||Y.isPending,submit:O,errors:N.errors,submitCount:N.submitCount,media:S}}function Ss(e){let{basePath:t,base:n}=e;const{lang:l,field:s,dir:a}=ml(),i="ar"===l?"En":"Ar";return{activeName:"".concat(t).concat(s(n)),deps:["".concat(t).concat(n).concat(i)],dir:a}}function Ys(e){let{basePath:t="",base:n,label:l,placeholder:s,error:a,required:i,rows:o,compact:r=!1,className:c}=e;const{activeName:d,deps:u,dir:w}=Ss({basePath:t,base:n}),p=(0,Ot.jsx)(vl,{name:d,label:l,placeholder:s,error:a,required:i,rows:o,dir:w,deps:u,className:r?"tw-flex-1 tw-min-w-0":c});return r?(0,Ot.jsx)("div",{className:"tw-flex tw-min-w-0 tw-items-center tw-gap-2 ".concat(null!==c&&void 0!==c?c:""),children:p}):p}function Ms(e){let{basePath:t="",base:n,label:l,error:s,minHeight:a,className:i}=e;const{activeName:o,deps:r}=Ss({basePath:t,base:n});return(0,Ot.jsx)("div",{className:i,children:(0,Ot.jsx)(Pl,{name:o,label:l,error:s,minHeight:a,deps:r})})}var Ts=n(85215);const Ps=[],Os=(e,t)=>{const{t:n}=(0,d.B)();return(0,l.useMemo)(()=>Object.values(t).map(t=>({value:t,label:n("cbq.".concat(e,".").concat(t))})),[e,t,n])};function Gs(e){let{name:t,label:n,hint:l,error:s,resource:a,parentId:i,selectedOptions:o,multiple:r=!1,placeholder:c,required:d,disabled:u=!1,onAfterChange:w,className:p}=e;return(0,Ot.jsx)(bl,{label:n,hint:l,error:s,required:d,className:p,children:(0,Ot.jsx)(ul.xI,{name:t,render:e=>{let{field:t}=e;return(0,Ot.jsx)(Gn,{resource:a,parentId:i,multiple:r,value:t.value,selectedOptions:o,placeholder:c,disabled:u,onChange:(e,n)=>{const l=r?null!==e&&void 0!==e?e:[]:null!==e&&void 0!==e?e:"";
1t.onChange(l),null===w||void 0===w||w(l,n)}})}})})}var Fs=n(71135);function zs(){const e=(0,l.useRef)(null),[t,n]=(0,l.useState)(!1);(0,l.useEffect)(()=>{if(!t)return;const n=t=>{var n,l,s;const a=null===(n=e.current)||void 0===n?void 0:n.overlay;a&&t.target instanceof Node&&a.contains(t.target)||null===(l=e.current)||void 0===l||null===(s=l.close)||void 0===s||s.call(l)};return window.addEventListener("scroll",n,!0),()=>window.removeEventListener("scroll",n,!0)},[t]);const s=(0,l.useCallback)(()=>n(!0),[]),a=(0,l.useCallback)(()=>n(!1),[]);return{ref:e,onOpen:s,onClose:a}}function Ds(e){let{name:t,label:n,hint:l,error:s,data:a=[],placeholder:i,required:o,disabled:r=!1,groupBy:c,onAfterChange:d,className:u}=e;const w=zs();return(0,Ot.jsx)(bl,{label:n,hint:l,error:s,required:o,className:u,children:(0,Ot.jsx)(ul.xI,{name:t,render:e=>{let{field:t}=e;return(0,Ot.jsx)(Fs.A,{ref:w.ref,onOpen:w.onOpen,onClose:w.onClose,block:!0,data:a,value:Array.isArray(t.value)?t.value:[],onChange:e=>{t.onChange(null!==e&&void 0!==e?e:[]),null===d||void 0===d||d(null!==e&&void 0!==e?e:[])},onBlur:t.onBlur,placeholder:i,disabled:r,searchable:a.length>8,groupBy:c,countable:!1,sticky:!0})}})})}var Bs=n(85057);function Ls(e){let{name:t,label:n,hint:l,error:s,min:a,max:i,step:o=1,postfix:r,required:c,disabled:d=!1,className:u}=e;return(0,Ot.jsx)(bl,{label:n,hint:l,error:s,required:c,className:u,children:(0,Ot.jsx)(ul.xI,{name:t,render:e=>{var t;let{field:n}=e;return(0,Ot.jsx)(Bs.A,{value:null!==(t=n.value)&&void 0!==t?t:"",onChange:e=>n.onChange(""===e?"":Number(e)),onBlur:n.onBlur,min:a,max:i,step:o,postfix:r,disabled:d})}})})}var Qs=n(42763);function Us(e){let{name:t,label:n,hint:l,error:s,data:a=[],placeholder:i,required:o,disabled:r=!1,cleanable:c=!1,searchable:d,groupBy:u,onAfterChange:w,className:p}=e;const m=zs();return(0,Ot.jsx)(bl,{label:n,hint:l,error:s,required:o,className:p,children:(0,Ot.jsx)(ul.xI,{name:t,render:e=>{var t;let{field:n}=e;return(0,Ot.jsx)(Qs.A,{ref:m.ref,onOpen:m.onOpen,onClose:m.onClose,block:!0,data:a,value:null!==(t=n.value)&&void 0!==t?t:null,onChange:e=>{n.onChange(null!==e&&void 0!==e?e:""),null===w||void 0===w||w(null!==e&&void 0!==e?e:"")},onBlur:n.onBlur,placeholder:i,disabled:r,cleanable:c,searchable:null!==d&&void 0!==d?d:a.length>8,groupBy:u})}})})}const Vs=[],Hs=e=>e?[e]:Vs;function Ks(e){let{basePath:t,index:n}=e;const{setValue:s}=(0,ul.xW)(),a="".concat(t,".").concat(n),i=(0,ul.FH)({name:"".concat(a,".certificateId")}),o=(0,ul.FH)({name:"".concat(a,".courseId")}),r=(0,ul.FH)({name:"".concat(a,".unitId")}),c=(0,ul.FH)({name:"".concat(a,".topicIds")}),d=(0,l.useMemo)(()=>{return e=c,Array.isArray(e)?e:Vs;var e},[c]),u=Kn("certificates",(0,l.useMemo)(()=>Hs(i),[i])),w=Kn("courses",(0,l.useMemo)(()=>Hs(o),[o])),p=Kn("units",(0,l.useMemo)(()=>Hs(r),[r])),m=Kn("topics",d),[x,b]=(0,l.useState)(!1),v=(0,l.useMemo)(()=>new Set(m.selected.map(e=>e.unitId)).size>1,[m.selected]),h=x||v,f=(0,l.useCallback)((e,t)=>s("".concat(a,".").concat(e),t,{shouldDirty:!0}),[a,s]),g=w.byId.get(o);(0,l.useEffect)(()=>{null!==g&&void 0!==g&&g.certificateId&&!i&&f("certificateId",g.certificateId)},[g,i,f]);const j=(0,l.useCallback)((e,t)=>{u.remember(t),b(!1),g&&g.certificateId===e||(f("courseId",""),f("unitId",""),f("topicIds",[]))},[u,g,f]),y=(0,l.useCallback)((e,t)=>{var n,l;w.remember(t),b(!1),f("certificateId",null!==(n=null===t||void 0===t?void 0:t.certificateId)&&void 0!==n?n:""),(null===(l=p.byId.get(r))||void 0===l?void 0:l.courseId)!==e&&(f("unitId",""),f("topicIds",[]))},[w,p,r,f]),A=(0,l.useCallback)((e,t)=>{var n;p.remember(t),b(!1),f("courseId",null!==(n=null===t||void 0===t?void 0:t.courseId)&&void 0!==n?n:""),f("certificateId","");const l=d.filter(t=>{var n;return(null===(n=m.byId.get(t))||void 0===n?void 0:n.unitId)===e});l.length!==d.length&&f("topicIds",l)},[p,m,d,f]),E=(0,l.useCallback)((e,t)=>{if(m.remember(t),!e.length){if(b(!1),!x)return;return f("unitId",""),f("courseId",""),void f("certificateId","")}if(!r){b(!0);if(1===new Set(e.map(e=>{var n,l;return null!==(n=null===(l=m.byId.get(e))||void 0===l?void 0:l.unitId)&&void 0!==n?n:null===t||void 0===t?void 0:t.unitId})).size){var n,l,s;const a=null!==(n=m.byId.get(e[0]))&&void 0!==n?n:t;f("unitId",null!==(l=null===a||void 0===a?void 0:a.unitId)&&void 0!==l?l:""),f("courseId",null!==(s=null===a||void 0===a?void 0:a.courseId)&&void 0!==s?s:""),f("certificateId","")}}},[m,x,r,f]);return{path:a,certificateId:i,courseId:o,unitId:r,certificates:u,courses:w,units:p,topics:m,locked:h,spansUnits:v,onCertificateChange:j,onCourseChange:y,onUnitChange:A,onTopicsChange:E}}function Ws(e){let{index:t,total:n,onMoveUp:l,onMoveDown:s,onRemove:a,canRemove:i=!0}=e;const{t:o}=(0,d.B)(),r=(e,t,n,l,s)=>(0,Ot.jsx)($t.A,{placement:"top",trigger:"hover",speaker:(0,Ot.jsx)(Xt.A,{children:o(t)}),children:(0,Ot.jsx)(Jt.A,{size:"xs",icon:e,appearance:"subtle",disabled:l,onClick:n,className:s?"tw-text-ERROR_100":"tw-text-GREY_70","aria-label":o(t)})});return(0,Ot.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-0.5 tw-shrink-0",children:[l?r((0,Ot.jsx)(c.wAb,{}),"cbq.actions.moveUp",()=>l(t),0===t):null,s?r((0,Ot.jsx)(c.fK4,{}),"cbq.actions.moveDown",()=>s(t),t===n-1):null,a?r((0,Ot.jsx)(c.IXo,{}),"cbq.actions.remove",()=>
1a(t),!i,!0):null]})}function Zs(e){let{basePath:t,index:n,total:l,onRemove:s,errors:a}=e;const{t:i}=(0,d.B)(),{path:o,certificateId:r,courseId:c,unitId:u,certificates:w,courses:p,units:m,topics:x,locked:b,spansUnits:v,onCertificateChange:h,onCourseChange:f,onUnitChange:g,onTopicsChange:j}=Ks({basePath:t,index:n}),y=i("cbq.placeholders.setByTopics"),A=i(b?v?"cbq.hints.topicsSpanUnits":"cbq.hints.topicsFiledRow":"cbq.hints.topicsFileTheRow");return(0,Ot.jsx)("div",{className:"tw-rounded-lg tw-border tw-border-GREY_10 tw-bg-PRIMARY_2 tw-p-3",children:(0,Ot.jsxs)("div",{className:"tw-flex tw-items-start tw-gap-3",children:[(0,Ot.jsxs)("div",{className:"tw-flex tw-flex-1 tw-flex-col tw-gap-3",children:[(0,Ot.jsxs)("div",{className:"tw-grid tw-grid-cols-1 md:tw-grid-cols-3 tw-gap-3",children:[(0,Ot.jsx)(Gs,{name:"".concat(o,".certificateId"),label:i("cbq.labels.certificate"),resource:"certificates",selectedOptions:w.selected,placeholder:b?y:i("cbq.placeholders.selectCertificate"),error:null===a||void 0===a?void 0:a.certificateId,disabled:b,onAfterChange:h,required:!b}),(0,Ot.jsx)(Gs,{name:"".concat(o,".courseId"),label:i("cbq.labels.course"),resource:"courses",parentId:r,selectedOptions:p.selected,placeholder:b?y:i("cbq.placeholders.selectCourse"),error:null===a||void 0===a?void 0:a.courseId,disabled:b,onAfterChange:f,required:!b}),(0,Ot.jsx)(Gs,{name:"".concat(o,".unitId"),label:i("cbq.labels.unit"),resource:"units",parentId:c,selectedOptions:m.selected,placeholder:b?y:i("cbq.placeholders.selectUnit"),error:null===a||void 0===a?void 0:a.unitId,disabled:b,onAfterChange:g,required:!b})]}),(0,Ot.jsx)(Gs,{name:"".concat(o,".topicIds"),label:i("cbq.labels.topics"),resource:"topics",parentId:b?void 0:u,multiple:!0,selectedOptions:x.selected,placeholder:i("cbq.placeholders.selectTopics"),hint:A,error:null===a||void 0===a?void 0:a.topicIds,onAfterChange:j})]}),(0,Ot.jsx)("div",{className:"tw-pt-6",children:(0,Ot.jsx)(Ws,{index:n,total:l,onRemove:s,canRemove:l>1})})]})})}function $s(e){let{basePath:t,errors:n}=e;const{t:s}=(0,d.B)(),a=xl(),{classifications:i,difficultyOptions:o,categoryOptions:c,conceptOptions:u,usedInOptions:w,sizes:p}=function(e){const t=(0,ul.jz)({name:"".concat(e,".classifications"),keyName:"_key"}),n=Os("difficulty",P),s=Os("category",O),a=Os("concept",G),i=Os("usedIn",z),o=(0,ul.FH)({name:"".concat(e,".questionSizeId")});return{classifications:t,difficultyOptions:n,categoryOptions:s,conceptOptions:a,usedInOptions:i,sizes:Kn("sizes",(0,l.useMemo)(()=>o?[o]:Ps,[o]))}}(t),m=a(xs(null===n||void 0===n?void 0:n.classifications));return(0,Ot.jsxs)("div",{className:"tw-flex tw-flex-col tw-gap-5",children:[(0,Ot.jsxs)("section",{className:"tw-flex tw-flex-col tw-gap-3",children:[(0,Ot.jsx)("span",{className:"tw-text-[13px] tw-font-bold tw-text-GREY_90",children:s("cbq.labels.academicClassification")}),m?(0,Ot.jsx)(r.A,{type:"error",showIcon:!0,children:m}):null,i.fields.map((e,l)=>{var s;return(0,Ot.jsx)(Zs,{basePath:"".concat(t,".classifications"),index:l,total:i.fields.length,onRemove:e=>i.remove(e),errors:null===n||void 0===n||null===(s=n.classifications)||void 0===s?void 0:s[l]},e._key)})]}),(0,Ot.jsx)(Ts.A,{className:"tw-my-1"}),(0,Ot.jsxs)("section",{className:"tw-flex tw-flex-col tw-gap-4",children:[(0,Ot.jsx)("span",{className:"tw-text-[13px] tw-font-bold tw-text-GREY_90",children:s("cbq.labels.questionAttributes")}),(0,Ot.jsxs)("div",{className:"tw-grid tw-grid-cols-1 md:tw-grid-cols-2 xl:tw-grid-cols-4 tw-gap-4",children:[(0,Ot.jsx)(Us,{name:"".concat(t,".difficulty"),label:s("cbq.labels.difficulty"),data:o,error:null===n||void 0===n?void 0:n.difficulty,required:!0}),(0,Ot.jsx)(Us,{name:"".concat(t,".category"),label:s("cbq.labels.category"),data:c,error:null===n||void 0===n?void 0:n.category,required:!0}),(0,Ot.jsx)(Us,{name:"".concat(t,".conceptType"),label:s("cbq.labels.concept"),data:u,placeholder:s("cbq.placeholders.selectConcept"),error:null===n||void 0===n?void 0:n.conceptType,required:!0}),(0,Ot.jsx)(Ls,{name:"".concat(t,".durationSeconds"),label:s("cbq.labels.estimatedTime"),min:1,max:3600,step:10,postfix:s("cbq.labels.seconds"),error:null===n||void 0===n?void 0:n.durationSeconds,required:!0}),(0,Ot.jsx)(Gs,{name:"".concat(t,".questionSizeId"),label:s("cbq.labels.size"),resource:"sizes",selectedOptions:p.selected,placeholder:s("cbq.placeholders.selectSize"),error:null===n||void 0===n?void 0:n.questionSizeId,onAfterChange:(e,t)=>
1p.remember(t),required:!0}),(0,Ot.jsx)(Ds,{name:"".concat(t,".usedIn"),label:s("cbq.labels.usedIn"),data:w,placeholder:s("cbq.placeholders.selectUsedIn"),error:null===n||void 0===n?void 0:n.usedIn,required:!0}),(0,Ot.jsx)(vl,{name:"".concat(t,".rank"),label:s("cbq.labels.rank"),placeholder:s("cbq.placeholders.rank"),error:null===n||void 0===n?void 0:n.rank,required:!0}),(0,Ot.jsx)(hl,{name:"".concat(t,".status"),label:s("cbq.labels.status"),checkedValue:F.ACTIVE,uncheckedValue:F.INACTIVE,checkedLabel:s("cbq.status.ACTIVE"),uncheckedLabel:s("cbq.status.INACTIVE"),className:"tw-h-fit tw-self-end tw-rounded-md tw-border tw-border-GREY_10 tw-px-3 tw-py-2.5"})]})]})]})}const Xs={[M.MCQ_SINGLE]:c.A3x,[M.MCQ_MULTI]:c.NLe,[M.NUMERIC]:c.Qz2,[M.CATEGORIZATION]:c.QPV,[M.SEQUENCE]:c.Wm,[M.CLOZE]:c.MRc};function Js(e){let{value:t,onChange:n}=e;const{t:l}=(0,d.B)();return(0,Ot.jsx)("div",{className:"tw-grid tw-grid-cols-1 sm:tw-grid-cols-2 lg:tw-grid-cols-3 tw-gap-3",children:T.map(e=>{const s=Xs[e],a=t===e;return(0,Ot.jsxs)("button",{type:"button",onClick:()=>n(e),"aria-pressed":a,className:"tw-flex tw-items-start tw-gap-3 tw-rounded-lg tw-border tw-p-3 tw-text-start tw-transition-colors ".concat(a?"tw-border-PRIMARY_50 tw-bg-PRIMARY_05":"tw-border-GREY_
110 tw-bg-WHITE hover:tw-border-PRIMARY_50"),children:[(0,Ot.jsx)("span",{className:"tw-flex tw-h-8 tw-w-8 tw-shrink-0 tw-items-center tw-justify-center tw-rounded-md ".concat(a?"tw-bg-PRIMARY_60 tw-text-WHITE":"tw-bg-GREY_05 tw-text-GREY_70"),children:(0,Ot.jsx)(s,{size:16})}),(0,Ot.jsxs)("span",{className:"tw-flex tw-flex-col",children:[(0,Ot.jsx)("span",{className:"tw-text-[13px] tw-font-bold ".concat(a?"tw-text-PRIMARY_60":"tw-text-GREY_90"),children:l(V(e))}),(0,Ot.jsx)("span",{className:"tw-text-xs tw-text-GREY_50 tw-mt-0.5",children:l(H(e))})]})]},e)})})}var ea=n(1146);function ta(e){let{step:t,title:n,description:l,actions:s,children:a,id:i}=e;return(0,Ot.jsx)(ea.A,{id:i,bordered:!0,className:"tw-bg-WHITE tw-rounded-xl tw-border-GREY_10 tw-shadow-sm",header:(0,Ot.jsxs)("div",{className:"tw-flex tw-items-start tw-justify-between tw-gap-4 tw-flex-wrap",children:[(0,Ot.jsxs)("div",{className:"tw-flex tw-items-start tw-gap-3",children:[t?(0,Ot.jsx)("span",{className:"tw-flex tw-h-7 tw-w-7 tw-shrink-0 tw-items-center tw-justify-center tw-rounded-full tw-bg-PRIMARY_05 tw-text-xs tw-font-bold tw-text-PRIMARY_60",children:t}):null,(0,Ot.jsxs)("div",{className:"tw-flex tw-flex-col",children:[(0,Ot.jsx)("span",{className:"tw-text-base tw-font-bold tw-text-GREY_90",children:n}),l?(0,Ot.jsx)("span",{className:"tw-text-xs tw-font-normal tw-text-GREY_50 tw-mt-0.5",children:l}):null]})]}),s?(0,Ot.jsx)("div",{className:"tw-flex tw-items-center tw-gap-2",children:s}):null]}),children:(0,Ot.jsx)("div",{className:"tw-flex tw-flex-col tw-gap-5 tw-pt-1",children:a})})}function na(e){let{errors:t,submitCount:n=0}=e;const{t:s}=(0,d.B)(),a=xl(),i=(0,l.useRef)(null),o=(0,l.useRef)(0),c=(0,l.useMemo)(()=>Es(t),[t]);return(0,l.useEffect)(()=>{var e;c.length&&n!==o.current&&(o.current=n,null===(e=i.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"center"}))},[n,c.length]),c.length?(0,Ot.jsx)("div",{ref:i,children:(0,Ot.jsx)(r.A,{type:"error",showIcon:!0,header:s("cbq.validation.summaryTitle",{count:c.length}),children:(0,Ot.jsx)("ul",{className:"tw-m-0 tw-mt-1 tw-max-h-60 tw-list-disc tw-space-y-1 tw-overflow-auto tw-ps-5 tw-text-[13px]",children:c.map(e=>{const t=e.parts.map(e=>{let{key:t,params:n}=e;return s(t,n)}).join(" \u2014 "),n=t&&e.lang?"".concat(t," (").concat(s("cbq.lang.".concat(e.lang)),")"):t;return(0,Ot.jsxs)("li",{children:[n?(0,Ot.jsxs)("span",{className:"tw-font-semibold tw-text-GREY_90",children:[n,": "]}):null,(0,Ot.jsx)("span",{className:"tw-text-GREY_70",children:a(e.message)})]},"".concat(e.path,"|").concat(e.message))})})})}):null}function la(e){let{label:t}=e;const{t:n}=(0,d.B)(),{lang:l,setLang:s}=ml(),a=(e,t)=>(0,Ot.jsx)("button",{type:"button",onClick:()=>s(e),"aria-pressed":l===e,className:"tw-px-4 tw-py-1.5 tw-text-xs tw-font-bold tw-transition-colors ".concat(l===e?"tw-bg-PRIMARY_60 tw-text-WHITE":"tw-bg-WHITE tw-text-GREY_70 hover:tw-bg-PRIMARY_05"),children:t},e);return(0,Ot.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-2",children:[(0,Ot.jsx)("span",{className:"tw-text-xs tw-text-GREY_50",children:null!==t&&void 0!==t?t:n("cbq.labels.authoringLanguage")}),(0,Ot.jsxs)("div",{className:"tw-inline-flex tw-overflow-hidden tw-rounded-md tw-border tw-border-GREY_
110",children:[a("en",n("cbq.lang.en")),a("ar",n("cbq.lang.ar"))]})]})}var sa=n(91331),aa=n(82749);function ia(e){let{item:t,onClose:n}=e;const{t:l}=(0,d.B)();return(0,Ot.jsxs)(Sn.A,{open:Boolean(t),onClose:n,size:"lg",overflow:!0,children:[(0,Ot.jsx)(Sn.A.Header,{children:(0,Ot.jsx)(Sn.A.Title,{children:he(t)||l("cbq.labels.explanationVideo")})}),(0,Ot.jsx)(Sn.A.Body,{children:t?(0,Ot.jsx)(aa.A,{videoDetails:{url:t.url,videoId:t.id,showNotes:!1,showStats:!1,showReactions:!1},onClose:n}):null})]})}const oa=[{kind:de,Icon:c.pVQ,labelKey:"cbq.labels.mediaVideo",hintKey:"cbq.labels.mediaVideoHint"}],ra={READY:"green",ENC_FAIL:"red",ENC_PEND:"gold"};function ca(e){var t;let{item:n,onWatch:l,onRemove:s,disabled:a}=e;const{t:i}=(0,d.B)(),o=[xe(n.lengthSeconds),me(n.sizeInBytes)].filter(Boolean);return(0,Ot.jsxs)("li",{className:"tw-flex tw-min-w-0 tw-items-center tw-gap-3 tw-rounded-lg tw-border tw-border-GREY_10 tw-bg-PRIMARY_2 tw-px-3 tw-py-2",children:[(0,Ot.jsx)("span",{className:"tw-flex tw-h-9 tw-w-9 tw-shrink-0 tw-items-center tw-justify-center tw-rounded-md tw-bg-WHITE tw-text-PRIMARY_60",children:(0,Ot.jsx)(c.pVQ,{size:16})}),(0,Ot.jsxs)("span",{className:"tw-flex tw-min-w-0 tw-flex-col",children:[(0,Ot.jsx)("span",{className:"tw-truncate tw-text-[13px] tw-font-semibold tw-text-GREY_90",children:he(n)||i("cbq.labels.explanationVideo")}),o.length?(0,Ot.jsx)("span",{className:"tw-text-xs tw-text-GREY_50",children:o.join(" \xb7 ")}):null]}),(0,Ot.jsx)("span",{className:"tw-flex-1"}),n.id||n.synced?null:(0,Ot.jsx)(zn,{tone:"gold",children:i("cbq.labels.mediaPending")}),n.status?(0,Ot.jsx)(zn,{tone:null!==(t=ra[n.status])&&void 0!==t?t:"grey",children:i("cbq.mediaStatus.".concat(n.status),n.status)}):null,(0,Ot.jsx)(Jt.A,{size:"sm",appearance:"subtle",icon:(0,Ot.jsx)(c.aze,{}),disabled:!fe(n),onClick:()=>l(n),"aria-label":i("cbq.actions.watchMedia"),title:i("cbq.actions.watchMedia"),className:"tw-shrink-0 tw-text-PRIMARY_60"}),(0,Ot.jsx)(Jt.A,{size:"sm",appearance:"subtle",icon:(0,Ot.jsx)(c.IXo,{}),disabled:a,onClick:()=>s(n),"aria-label":i("cbq.actions.remove"),className:"tw-shrink-0 tw-text-ERROR_100"})]})}function da(e){let{items:t=[],isLoading:n,isError:s,uploadingKind:a,uploadPercent:o,onAdd:r,onRemove:c}=e;const{t:u}=(0,d.B)(),w=Boolean(a),[p,m]=(0,l.useState)(null);return(0,Ot.jsxs)("div",{className:"tw-flex tw-flex-col tw-gap-3",children:[(0,Ot.jsxs)("div",{className:"tw-flex tw-flex-col",children:[(0,Ot.jsx)("span",{className:"tw-text-[13px] tw-font-semibold tw-text-GREY_90",children:u("cbq.labels.explanationMedia")}),(0,Ot.jsx)("span",{className:"tw-text-xs tw-text-GREY_50",children:u("cbq.hints.explanationMedia")})]}),oa.map(e=>{let{kind:t,Icon:n,labelKey:l,hintKey:s}=e;return(0,Ot.jsx)(cs.A,{action:"",autoUpload:!1,fileList:[],multiple:!1,accept:we[t].accept,disabled:w,onChange:e=>{var n;return r(t,null===e||void 0===e||null===(n=e[e.length-1])||void 0===n?void 0:n.blobFile)},className:"cbq-media-picker",children:(0,Ot.jsxs)("button",{type:"button",className:"tw-flex tw-w-full tw-flex-col tw-items-center tw-gap-1 tw-rounded-xl tw-border tw-border-dashed tw-border-GREY_30 tw-bg-PRIMARY_2 tw-px-3 tw-py-6 tw-transition-colors ".concat(w?"tw-opacity-60":"hover:tw-border-PRIMARY_50 hover:tw-bg-PRIMARY_05"),children:[a===t?(0,Ot.jsx)(i.A,{size:"sm"}):(0,Ot.jsx)(n,{size:22,className:"tw-text-PRIMARY_60"}),(0,Ot.jsx)("span",{className:"tw-text-[13px] tw-font-semibold tw-text-GREY_90",children:u(l)}),(0,Ot.jsx)("span",{className:"tw-text-xs tw-text-GREY_50",children:a!==t?u(s):null===o||o>=100?u("cbq.labels.mediaProcessing"):u("cbq.labels.mediaUploading",{percent:o})}),a===t?(0,Ot.jsx)("span",{className:"tw-mt-1 tw-w-full tw-max-w-[200px]",children:(0,Ot.jsx)(sa.A.Line,{percent:null!==o&&void 0!==o?o:0,showInfo:!1,strokeWidth:6,status:"active"})}):null]})},t)}),n?(0,Ot.jsx)(i.A,{size:"sm",content:u("cbq.labels.loading")}):s?(0,Ot.jsx)("span",{className:"tw-text-xs tw-text-ERROR_100",children:u("cbq.errors.mediaFailed")}):t.length?(0,Ot.jsx)("ul",{className:"tw-m-0 tw-flex tw-list-none tw-flex-col tw-gap-2 tw-p-0",children:t.map(e=>(0,Ot.jsx)(ca,{item:e,onWatch:m,onRemove:c,disabled:w},e.key))}):(0,Ot.jsx)("span",{className:"tw-text-xs tw-text-GREY_50",children:u("cbq.labels.noMedia")}),(0,Ot.jsx)(ia,{item:p,onClose:()=>m(null)})]})}var ua=n(98565);function wa(e){let{basePath:t,type:n,errors:s}=e;const{t:a}=(0,d.B)(),i=xl(),{isSingle:u,fields:w,append:p,remove:m,move:x,isCorrect:b,setCorrect:v}=function(e){let{basePath:t,type:n}=e;const{setValue:s,getValues:a}=(0,ul.xW)(),i=n===M.MCQ_SINGLE,{fields:o,append:r,remove:c,move:d}=(0,ul.jz)({name:"".concat(t,".options"),keyName:"_key"}),u=(0,ul.FH)({name:"".concat(t,".options")}),w=(0,l.useCallback)((e,n)=>{var l;i?(null!==(l=a("".concat(t,".options")))&&void 0!==l?l:[]).forEac
1h((n,l)=>{s("".concat(t,".options.").concat(l,".correct"),l===e,{shouldDirty:!0})}):s("".concat(t,".options.").concat(e,".correct"),n,{shouldDirty:!0})},[t,a,i,s]);return{isSingle:i,fields:o,append:r,remove:c,move:d,isCorrect:e=>{var t;return Boolean(null===u||void 0===u||null===(t=u[e])||void 0===t?void 0:t.correct)},setCorrect:w}}({basePath:t,type:n}),h=null===s||void 0===s?void 0:s.options,f=i(xs(h));return(0,Ot.jsxs)("div",{className:"tw-flex tw-flex-col tw-gap-4",children:[(0,Ot.jsx)(hl,{name:"".concat(t,".shuffle"),label:a("cbq.labels.shuffleOptions"),hint:a("cbq.hints.shuffleOptions")}),f?(0,Ot.jsx)(r.A,{type:"error",showIcon:!0,children:f}):null,(0,Ot.jsx)("div",{className:"tw-flex tw-flex-col tw-gap-3",children:w.map((e,n)=>{var l,s,i;const o="".concat(t,".options.").concat(n),r=null===h||void 0===h?void 0:h[n];return(0,Ot.jsxs)("div",{className:"tw-rounded-lg tw-border tw-border-GREY_10 tw-bg-PRIMARY_2 tw-p-4 tw-flex tw-flex-col tw-gap-3",children:[(0,Ot.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-3",children:[(0,Ot.jsx)("span",{className:"tw-flex tw-h-7 tw-w-7 tw-items-center tw-justify-center tw-rounded-md tw-bg-PRIMARY_05 tw-text-xs tw-font-bold tw-text-PRIMARY_60",children:null!==(l="ABCDEFGHIJKLMNOPQRSTUVWXYZ"[n])&&void 0!==l?l:n+1}),(0,Ot.jsxs)("label",{className:"tw-flex tw-items-center tw-gap-2 tw-cursor-pointer tw-m-0",children:[u?(0,Ot.jsx)(ua.A,{checked:b(n),onChange:()=>v(n,!0)}):(0,Ot.jsx)(nn.A,{checked:b(n),onChange:(e,t)=>
1v(n,t)}),(0,Ot.jsx)("span",{className:"tw-text-xs tw-font-semibold tw-text-GREY_70",children:a("cbq.labels.correctAnswer")})]}),(0,Ot.jsx)("div",{className:"tw-flex-1"}),(0,Ot.jsx)(Ws,{index:n,total:w.length,onMoveUp:e=>x(e,e-1),onMoveDown:e=>x(e,e+1),onRemove:e=>m(e),canRemove:w.length>2})]}),(0,Ot.jsx)(Ms,{basePath:"".concat(o,"."),base:"text",label:a("cbq.labels.optionText"),minHeight:130,error:null!==(s=null===r||void 0===r?void 0:r.textAr)&&void 0!==s?s:null===r||void 0===r?void 0:r.textEn}),(0,Ot.jsx)(Ms,{basePath:"".concat(o,"."),base:"explanation",label:a("cbq.labels.optionExplanation"),minHeight:110,error:null!==(i=null===r||void 0===r?void 0:r.explanationAr)&&void 0!==i?i:null===r||void 0===r?void 0:r.explanationEn})]},e._key)})}),(0,Ot.jsx)(o.A,{appearance:"ghost",startIcon:(0,Ot.jsx)(c.GGD,{}),onClick:()=>p(Ne()),className:"tw-self-start",children:a("cbq.actions.addOption")})]})}var pa=n(83101);function ma(e){let{basePath:t,makeBlank:n}=e;const{setValue:s,getValues:a}=(0,ul.xW)(),i=(0,ul.FH)({name:"".concat(t,".templateAr")}),o=(0,ul.FH)({name:"".concat(t,".templateEn")}),r=(0,l.useMemo)(()=>oe(i),[i]),c=(0,l.useMemo)(()=>oe(o),[o]),d=Math.max(r,c),u=!$(i)&&!$(o),w=(0,l.useRef)([]),p=(0,l.useCallback)(e=>{var l;const i="".concat(t,".blanks"),o=null!==(l=a(i))&&void 0!==l?l:[];if(o.length===e)return;let r;if(o.length>e)w.current=[...o.slice(e),...w.current],r=o.slice(0,e);else{const t=e-o.length,l=w.current.slice(0,t);w.current=w.current.slice(t),r=[...o,...l,...Array.from({length:t-l.length},()=>n())]}s(i,r,{shouldDirty:!0,shouldValidate:!1})},[t,a,n,s]);return(0,l.useEffect)(()=>{p(d)},[d,p]),{blankCount:d,arCount:r,enCount:c,isMismatched:u&&r!==c}}function xa(e){var t;let{field:n,placeholder:s,disabled:a}=e;const{display:i,handleChange:o,handleFocus:r,handleBlur:c}=function(e){let{value:t,onChange:n}=e;const[s,a]=(0,l.useState)(()=>Be(t)),i=(0,l.useRef)(!1);return(0,l.useEffect)(()=>{i.current||a(Be(t))},[t]),{display:s,handleChange:(0,l.useCallback)(e=>{const t=Fe(e);a(Be(t)),n(De(t))},[n]),handleFocus:(0,l.useCallback)(()=>{i.current=!0},[]),handleBlur:(0,l.useCallback)(()=>{i.current=!1,a(Be(t))},[t])}}({value:null!==(t=n.value)&&void 0!==t?t:"",onChange:n.onChange});return(0,Ot.jsx)(m.A,{value:i,onChange:o,onFocus:r,onBlur:()=>{c(),n.onBlur()},placeholder:s,disabled:a,inputMode:"decimal",style:{direction:"ltr",textAlign:"left"}})}function ba(e){let{name:t,label:n,hint:l,error:s,placeholder:a,required:i,disabled:o=!1,className:r}=e;return(0,Ot.jsx)(bl,{label:n,hint:l,error:s,required:i,className:r,children:(0,Ot.jsx)(ul.xI,{name:t,render:e=>{let{field:t}=e;return(0,Ot.jsx)(xa,{field:t,placeholder:a,disabled:o})}})})}const va="tw-flex tw-min-w-0 tw-items-center tw-gap-2 tw-rounded-lg tw-border tw-border-GREY_
110 tw-bg-WHITE tw-px-3 tw-py-2",ha="tw-flex tw-h-8 tw-min-w-[32px] tw-shrink-0 tw-items-center tw-justify-center tw-rounded-md tw-bg-PRIMARY_05 tw-text-xs tw-font-bold tw-text-PRIMARY_60";function fa(e){const{fields:t,append:n,remove:s,move:a}=(0,ul.jz)({name:"".concat(e,".items"),keyName:"_key"}),{dragIndex:i,overIndex:o,gripProps:r,rowProps:c}=function(e){const[t,n]=(0,l.useState)(!1),[s,a]=(0,l.useState)(null),[i,o]=(0,l.useState)(null),r=(0,l.useCallback)(()=>{n(!1),a(null),o(null)},[]),c={onMouseDown:()=>n(!0),onMouseUp:()=>n(!1)},d=(0,l.useCallback)(n=>({draggable:t,onDragStart:e=>{e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("application/x-cbq-sequence-step",String(n)),a(n)},onDragOver:e=>{null!==s&&(e.preventDefault(),e.dataTransfer.dropEffect="move",o(n))},onDrop:t=>{t.preventDefault(),null!==s&&s!==n&&e(s,n),r()},onDragEnd:r}),[s,t,e,r]);return{dragIndex:s,overIndex:i,gripProps:c,rowProps:d}}(a);return{fields:t,append:n,remove:s,move:a,dragIndex:i,overIndex:o,gripProps:r,rowProps:c}}function ga(e){let{blankPath:t,blankIndex:n,errors:s}=e;const{t:a}=(0,d.B)(),i=xl(),{fields:u,append:w,remove:p,move:m,watchedOptions:x,setCorrect:b}=function(e){const{setValue:t,getValues:n}=(0,ul.xW)(),{fields:s,append:a,remove:i,move:o}=(0,ul.jz)({name:"".concat(e,".options"),keyName:"_key"});return{fields:s,append:a,remove:i,move:o,watchedOptions:(0,ul.FH)({name:"".concat(e,".options")}),setCorrect:(0,l.useCallback)(l=>{var s;(null!==(s=n("".concat(e,".options")))&&void 0!==s?s:[]).forEach((n,s)=>{t("".concat(e,".options.").concat(s,".correct"),s===l,{shouldDirty:!0})})},[e,n,t])}}(t),v=i(xs(s));return(0,Ot.jsxs)("div",{className:"tw-flex tw-flex-col tw-gap-2",children:[v?(0,Ot.jsx)(r.A,{type:"error",showIcon:!0,children:v}):null,u.map((e,l)=>{var i,o,r,c;return(0,Ot.jsx)("div",{className:"tw-rounded-md tw-border tw-border-GREY_
110 tw-bg-WHITE tw-p-2.5",children:(0,Ot.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-3",children:[(0,Ot.jsx)(ua.A,{checked:Boolean(null===x||void 0===x||null===(i=x[l])||void 0===i?void 0:i.correct),onChange:()=>b(l),className:"tw-shrink-0"}),(0,Ot.jsx)(Ys,{basePath:"".concat(t,".options.").concat(l,"."),base:"text",placeholder:a("cbq.placeholders.blankOption",{blank:n+1,number:l+1}),error:null!==(o=null===s||void 0===s||null===(r=s[l])||void 0===r?void 0:r.textAr)&&void 0!==o?o:null===s||void 0===s||null===(c=s[l])||void 0===c?void 0:c.textEn,compact:!0,className:"tw-flex-1"}),(0,Ot.jsx)(Ws,{index:l,total:u.length,onMoveUp:e=>m(e,e-1),onMoveDown:e=>m(e,e+1),onRemove:e=>p(e),canRemove:u.length>2})]})},e._key)}),(0,Ot.jsx)(o.A,{appearance:"link",size:"sm",startIcon:(0,Ot.jsx)(c.GGD,{}),onClick:()=>w(_e()),className:"tw-self-start",children:a("cbq.actions.addOption")})]})}const ja={[M.MCQ_SINGLE]:wa,[M.MCQ_MULTI]:wa,[M.NUMERIC]:function(e){var t,n;let{basePath:l,errors:s}=e;const{t:a}=(0,d.B)(),{blankCount:i,isMismatched:o}=ma({basePath:l,makeBlank:qe}),c=null!==(t=(0,ul.FH)({name:"".concat(l,".blanks")}))&&void 0!==t?t:[];return(0,Ot.jsxs)("div",{className:"tw-flex tw-flex-col tw-gap-4",children:[(0,Ot.jsx)(Ms,{base:"template",label:a("cbq.labels.numericTemplate"),error:null!==(n=null===s||void 0===s?void 0:s.templateAr)&&void 0!==n?n:null===s||void 0===s?void 0:s.templateEn,basePath:"".concat(l,"."),minHeight:130}),(0,Ot.jsx)(r.A,{type:"info",showIcon:!0,children:a("cbq.hints.blankToken",{token:Q})}),o?(0,Ot.jsx)(r.A,{type:"warning",showIcon:!0,children:a("cbq.validation.blanksMismatch")}):null,(0,Ot.jsxs)("div",{className:"tw-flex tw-flex-col tw-gap-3",children:[(0,Ot.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-2",children:[(0,Ot.jsx)("span",{className:"tw-text-[13px] tw-font-semibold tw-text-GREY_90",children:a("cbq.labels.blanks")}),(0,Ot.jsx)(pa.A,{size:"sm",color:i?"green":"red",children:a("cbq.labels.blanksCount",{n:i})})]}),0===i?(0,Ot.jsx)(r.A,{type:"warning",showIcon:!0,children:a("cbq.validation.needsBlank")}):null,c.map((e,t)=>{var n,i,o;return(0,Ot.jsx)("div",{className:"tw-rounded-lg tw-border tw-border-GREY_
110 tw-bg-PRIMARY_2 tw-p-4",children:(0,Ot.jsx)(ba,{name:"".concat(l,".blanks.").concat(t,".correctAnswer"),label:a("cbq.labels.blankAnswer",{number:t+1}),hint:a("cbq.hints.numericAnswer",{max:10}),error:null===s||void 0===s||null===(i=s.blanks)||void 0===i||null===(o=i[t])||void 0===o?void 0:o.correctAnswer,required:!0})},null!==(n=null===e||void 0===e?void 0:e.id)&&void 0!==n?n:t)})]})]})},[M.CATEGORIZATION]:function(e){let{basePath:t,errors:n}=e;const{t:s}=(0,d.B)(),a=xl(),{categories:i,items:u,categoryOptions:w}=function(e){const{t:t}=(0,d.B)(),{isArabic:n}=ml(),s=(0,ul.jz)({name:"".concat(e,".categories"),keyName:"_key"}),a=(0,ul.jz)({name:"".concat(e,".items"),keyName:"_key"}),i=(0,ul.FH)({name:"".concat(e,".categories")});return{categories:s,items:a,categoryOptions:(0,l.useMemo)(()=>(null!==i&&void 0!==i?i:[]).filter(e=>null===e||void 0===e?void 0:e.id).map((e,l)=>({value:e.id,label:(n?e.nameAr:e.nameEn)||t("cbq.labels.untitledCategory",{number:l+1})})),[i,n,t])}}(t),p=a(xs(null===n||void 0===n?void 0:n.categories)),m=a(xs(null===n||void 0===n?void 0:n.items));return(0,Ot.jsxs)("div",{className:"tw-flex tw-flex-col tw-gap-6",children:[(0,Ot.jsxs)("section",{className:"tw-flex tw-flex-col tw-gap-2",children:[(0,Ot.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-2",children:[(0,Ot.jsx)("span",{className:"tw-text-[13px] tw-font-semibold tw-text-GREY_90",children:s("cbq.labels.categories")}),(0,Ot.jsx)(pa.A,{size:"sm",children:i.fields.length})]}),p?(0,Ot.jsx)(r.A,{type:"error",showIcon:!0,children:p}):null,i.fields.map((e,l)=>{var a,o,r,c,d;return(0,Ot.jsxs)("div",{className:va,children:[(0,Ot.jsx)("span",{className:ha,children:l+1}),(0,Ot.jsx)(Ys,{basePath:"".concat(t,".categories.").concat(l,"."),base:"name",placeholder:s("cbq.placeholders.categoryName"),error:null!==(a=null===n||void 0===n||null===(o=n.categories)||void 0===o||null===(r=o[l])||void 0===r?void 0:r.nameAr)&&void 0!==a?a:null===n||void 0===n||null===(c=n.categories)||void 0===c||null===(d=c[l])||void 0===d?void 0:d.nameEn,compact:!0,className:"tw-flex-1"}),(0,Ot.jsx)(Ws,{index:l,total:i.fields.length,onMoveUp:e=>i.move(e,e-1),onMoveDown:e=>i.move(e,e+1),onRemove:e=>i.remove(e),canRemove:i.fields.length>2})]},e._key)}),(0,Ot.jsx)(o.A,{appearance:"ghost",size:"sm",startIcon:(0,Ot.jsx)(c.GGD,{}),onClick:()=>i.append(Re()),className:"tw-self-start",children:s("cbq.actions.addCategory")})]}),(0,Ot.jsxs)("section",{className:"tw-flex tw-flex-col tw-gap-2",children:[(0,Ot.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-2",children:[(0,Ot.jsx)("span",{className:"tw-text-[13px] tw-font-semibold tw-text-GREY_90",children:s("cbq.labels.itemsToCategorize")}),(0,Ot.jsx)(pa.A,{size:"sm",children:u.fields.length})]}),m?(0,Ot.jsx)(r.A,{type:"error",showIcon:!0,children:m}):null,u.fields.map((e,l)=>{var a,i,o,r,c,d,p;return(0,Ot.jsxs)("div",{className:va,children:[(0,Ot.jsx)("span",{className:ha,children:l+1}),(0,Ot.jsx)(Ys,{basePath:"".concat(t,".items.").concat(l,"."),base:"text",placeholder:s("cbq.placeholders.itemText"),error:null!==(a=null===n||void 0===n||null===(i=n.items)||void 0===i||null===(o=i[l])||void 0===o?void 0:o.textAr)&&void 0!==a?a:null===n||void 0===n||null===(r=n.items)||void 0===r||null===(c=r[l])||void 0===c?void 0:c.textEn,compact:!0,className:"tw-flex-1"}),(0,Ot.jsx)(Us,{name:"".concat(t,".items.").concat(l,".categoryId"),data:w,placeholder:s("cbq.placeholders.selectCategory"),error:null===n||void 0===n||null===(d=n.items)||void 0===d||null===(p=d[l])||void 0===p?void 0:p.categoryId,className:"tw-w-48 tw-shrink-0"}),(0,Ot.jsx)(Ws,{index:l,total:u.fields.length,onMoveUp:e=>u.move(e,e-1),onMoveDown:e=>u.move(e,e+1),onRemove:e=>u.remove(e),canRemove:u.fields.length>1})]},e._key)}),(0,Ot.jsx)(o.A,{appearance:"ghost",size:"sm",startIcon:(0,Ot.jsx)(c.GGD,{}),onClick:()=>u.append(Ce()),className:"tw-self-start",children:s("cbq.actions.addItem")})]})]})},[M.SEQUENCE]:function(e){let{basePath:t,errors:n}=e;const{t:l}=(0,d.B)(),s=xl(),{fields:a,append:i,remove:u,move:p,dragIndex:m,overIndex:x,gripProps:b,rowProps:v}=fa(t),h=s(xs(null===n||void 0===n?void 0:n.items));return(0,Ot.jsxs)("div",{className:"tw-flex tw-flex-col tw-gap-4",children:[(0,Ot.jsx)(hl,{name:"".concat(t,".shuffle"),label:l("cbq.labels.shuffleForStudent"),hint:l("cbq.hints.shuffleSequence")}),(0,Ot.jsx)(r.A,{type:"info",showIcon:!0,children:l("cbq.hints.sequenceOrder")}),h?(0,Ot.jsx)(r.A,{type:"error",showIcon:!0,children:h}):null,(0,Ot.jsx)("div",{className:"tw-flex tw-flex-col tw-gap-2",children:a.map((e,s)=>{var i,o,r,c,d;const h=m===s,f=null!==m&&x===s&&!h;return(0,Ot.jsx)("div",(0,w.A)((0,w.A)({},v(s)),{},{className:"tw-min-w-0 tw-rounded-lg tw-border tw-px-3 tw-py-2 tw-transition-colors ".concat(f?"tw-border-PRI
1MARY_50 tw-bg-PRIMARY_05":"tw-border-GREY_10 tw-bg-WHITE"," ").concat(h?"tw-opacity-40":""),children:(0,Ot.jsxs)("div",{className:"tw-flex tw-min-w-0 tw-items-center tw-gap-2",children:[(0,Ot.jsx)("span",(0,w.A)((0,w.A)({},b),{},{role:"button",tabIndex:-1,"aria-label":l("cbq.actions.reorder"),title:l("cbq.actions.reorder"),className:"tw-flex tw-h-8 tw-w-6 tw-shrink-0 tw-cursor-grab tw-items-center tw-justify-center tw-rounded-md tw-text-GREY_30 hover:tw-bg-GREY_05 hover:tw-text-GREY_50 active:tw-cursor-grabbing",children:(0,Ot.jsx)($n.LUV,{size:18})})),(0,Ot.jsx)("span",{className:"tw-flex tw-h-8 tw-min-w-[36px] tw-shrink-0 tw-items-center tw-justify-center tw-rounded-md tw-bg-PRIMARY_05 tw-text-xs tw-font-bold tw-text-PRIMARY_60",children:String(s+1).padStart(2,"0")}),(0,Ot.jsx)(Ys,{basePath:"".concat(t,".items.").concat(s,"."),base:"text",placeholder:l("cbq.placeholders.sequenceStep",{number:s+1}),error:null!==(i=null===n||void 0===n||null===(o=n.items)||void 0===o||null===(r=o[s])||void 0===r?void 0:r.textAr)&&void 0!==i?i:null===n||void 0===n||null===(c=n.items)||void 0===c||null===(d=c[s])||void 0===d?void 0:d.textEn,compact:!0,className:"tw-flex-1"}),(0,Ot.jsx)(Ws,{index:s,total:a.length,onMoveUp:e=>p(e,e-1),onMoveDown:e=>p(e,e+1),onRemove:e=>u(e),canRemove:a.length>2})]})}),e._key)})}),(0,Ot.jsx)(o.A,{appearance:"ghost",startIcon:(0,Ot.jsx)(c.GGD,{}),onClick:()=>i(ke()),className:"tw-self-start",children:l("cbq.actions.addStep")})]})},[M.CLOZE]:function(e){var t;let{basePath:n,errors:l}=e;const{t:s}=(0,d.B)(),{blankCount:a,isMismatched:i,blanks:o}=function(e){var t;const{blankCount:n,isMismatched:l}=ma({basePath:e,makeBlank:Se});return{blankCount:n,isMismatched:l,blanks:null!==(t=(0,ul.FH)({name:"".concat(e,".blanks")}))&&void 0!==t?t:[]}}(n);return(0,Ot.jsxs)("div",{className:"tw-flex tw-flex-col tw-gap-4",children:[(0,Ot.jsx)(Ms,{basePath:"".concat(n,"."),base:"template",label:s("cbq.labels.sentenceTemplate"),error:null!==(t=null===l||void 0===l?void 0:l.templateAr)&&void 0!==t?t:null===l||void 0===l?void 0:l.templateEn,minHeight:130}),(0,Ot.jsx)(r.A,{type:"info",showIcon:!0,children:s("cbq.hints.blankToken",{token:Q})}),i?(0,Ot.jsx)(r.A,{type:"warning",showIcon:!0,children:s("cbq.validation.blanksMismatch")}):null,(0,Ot.jsxs)("div",{className:"tw-flex tw-items-center tw-gap-2",children:[(0,Ot.jsx)("span",{className:"tw-text-[13px] tw-font-semibold tw-text-GREY_90",children:s("cbq.labels.blanks")}),(0,Ot.jsx)(pa.A,{size:"sm",color:a?"green":"red",children:s("cbq.labels.blanksCount",{n:a})})]}),0===a?(0,Ot.jsx)(r.A,{type:"warning",showIcon:!0,children:s("cbq.validation.needsBlank")}):null,o.map((e,t)=>{var a,i,o;return(0,Ot.jsxs)("div",{className:"tw-rounded-lg tw-border tw-border-GREY_
110 tw-bg-PRIMARY_2 tw-p-4 tw-flex tw-flex-col tw-gap-3",children:[(0,Ot.jsx)("span",{className:"tw-text-xs tw-font-bold tw-text-PRIMARY_60",children:s("cbq.labels.blankNumber",{number:t+1})}),(0,Ot.jsx)(ga,{blankPath:"".concat(n,".blanks.").concat(t),blankIndex:t,errors:null===l||void 0===l||null===(i=l.blanks)||void 0===i||null===(o=i[t])||void 0===o?void 0:o.options})]},null!==(a=null===e||void 0===e?void 0:e.id)&&void 0!==a?a:t)})]})}};function ya(e){var t,n,l;let{fact:s,questionId:a,onBack:u,onSaved:p}=e;const{t:m}=(0,d.B)(),{form:x,isEdit:b,unsupportedType:v,isLoading:h,isSaving:f,submit:g,errors:j,submitCount:y,media:A}=_s({factId:null===s||void 0===s?void 0:s.id,questionId:a,onSaved:p}),{control:E,setValue:I}=x,N=(0,ul.FH)({control:E,name:"type"}),q=(e=>{var t;return null!==(t=ja[e])&&void 0!==t?t:wa})(N),R=Qe(N);return h?(0,Ot.jsx)("div",{className:"tw-flex tw-h-64 tw-items-center tw-justify-center",children:(0,Ot.jsx)(i.A,{size:"md",content:m("cbq.labels.loading")})}):v?(0,Ot.jsxs)("div",{className:"tw-flex tw-flex-col tw-gap-4",children:[(0,Ot.jsx)(o.A,{appearance:"subtle",startIcon:(0,Ot.jsx)(c.kRp,{}),onClick:u,className:"tw-self-start",children:m("cbq.actions.back")}),(0,Ot.jsx)(r.A,{type:"warning",showIcon:!0,children:m("cbq.errors.unsupportedType",{type:v})})]}):(0,Ot.jsx)(ul.Op,(0,w.A)((0,w.A)({},x),{},{children:(0,Ot.jsxs)("form",{onSubmit:g,className:"tw-flex tw-w-full tw-min-w-0 tw-flex-col tw-gap-5 tw-pb-16",children:[(0,Ot.jsxs)("header",{className:"tw-sticky tw-top-0 tw-z-10 tw-flex tw-flex-wrap tw-items-center tw-gap-3 tw-rounded-xl tw-border tw-border-GREY_
110 tw-bg-WHITE tw-px-4 tw-py-3 tw-shadow-sm",children:[(0,Ot.jsx)(o.A,{appearance:"subtle",startIcon:(0,Ot.jsx)(c.kRp,{}),onClick:u,children:m("cbq.actions.back")}),(0,Ot.jsxs)("div",{className:"tw-flex tw-min-w-0 tw-flex-col",children:[(0,Ot.jsx)("h1",{className:"tw-m-0 tw-text-lg tw-font-bold tw-text-GREY_90",children:m(b?"cbq.titles.editQuestion":"cbq.titles.newQuestion")}),(0,Ot.jsx)("span",{className:"tw-truncate tw-text-xs tw-text-GREY_50",children:s?m("cbq.titles.inScenario",{name:s.titleEn||s.titleAr}):""})]}),(0,Ot.jsx)("div",{className:"tw-flex-1"}),(0,Ot.jsx)(la,{}),(0,Ot.jsx)(o.A,{appearance:"primary",type:"submit",startIcon:(0,Ot.jsx)(c.Bc_,{}),loading:f,className:"tw-bg-PRIMARY_60",children:m(b?"cbq.actions.saveChanges":"cbq.actions.createQuestion")})]}),(0,Ot.jsx)(na,{errors:j,submitCount:y}),(0,Ot.jsx)(ta,{step:1,title:m("cbq.titles.infoSection"),description:m("cbq.titles.infoSectionHint"),children:(0,Ot.jsx)($s,{basePath:"meta",errors:null===j||void 0===j?void 0:j.meta})}),(0,Ot.jsx)(ta,{step:2,title:m("cbq.titles.typeSection"),description:m("cbq.titles.typeSectionHint"),children:(0,Ot.jsx)(Js,{value:N,onChange:e=>I("type",e,{shouldDirty:!0})})}),(0,Ot.jsxs)(ta,{step:3,title:m("cbq.titles.contentSection"),description:m("cbq.titles.contentSectionHint"),children:[(0,Ot.jsx)(Ms,{base:"title",label:m("cbq.labels.questionText"),error:null!==(t=null===j||void 0===j?void 0:j.titleAr)&&void 0!==t?t:null===j||void 0===j?void 0:j.titleEn}),(0,Ot.jsx)(q,{basePath:"payload.".concat(R),type:N,errors:null===j||void 0===j||null===(n=j.payload)||void 0===n?void 0:n[R]})]}),(0,Ot.jsxs)(ta,{step:4,title:m("cbq.titles.explanationSection"),description:m("cbq.titles.explanationSectionHint"),children:[U(N)?(0,Ot.jsx)(Ms,{base:"explanation",label:m("cbq.labels.questionExplanation"),error:null!==(l=null===j||void 0===j?void 0:j.explanationAr)&&void 0!==l?l:null===j||void 0===j?void 0:j.explanationEn,minHeight:180}):null,(0,Ot.jsx)(da,{items:A.items,isLoading:A.isLoading,isError:A.isError,uploadingKind:A.uploadingKind,uploadPercent:A.uploadPercent,onAdd:A.add,onRemove:A.remove})]})]})}))}function Aa(e){var t,n,l,s;const a=null!==(t=null===e||void 0===e?void 0:e.body)&&void 0!==t?t:{};switch(null===e||void 0===e?void 0:e.type){case M.MCQ_SINGLE:return 1;case M.MCQ_MULTI:return(null!==(n=a.correctIds)&&void 0!==n?n:[]).length;case M.NUMERIC:case M.CLOZE:return(null!==(l=a.slots)&&void 0!==l?l:[]).length;case M.CATEGORIZATION:case M.SEQUENCE:return(null!==(s=a.options)&&void 0!==s?s:[]).length;default:return 0}}const Ea=[],Ia="case",Na="details";function qa(e){let{html:t,dir:n,className:l=""}=e;return $(t)?null:(0,Ot.jsx)(cl,{html:t,dir:n,className:"tw-min-w-0 tw-text-sm tw-leading-7 tw-text-GREY_90 ".concat(l)})}function Ra(e){let{html:t,dir:n}=e;return $(t)?null:(0,Ot.jsx)("div",{className:"tw-mt-2 tw-border-t tw-border-dashed tw-border-GREY_
110 tw-pt-2",children:(0,Ot.jsx)(qa,{html:t,dir:n,className:"tw-text-xs tw-leading-6 tw-text-GREY_50"})})}function Ca(e){let{correct:t}=e;return(0,Ot.jsx)("span",{"aria-hidden":!0,className:"tw-flex tw-h-6 tw-w-6 tw-shrink-0 tw-items-center tw-justify-center tw-rounded-full tw-border-2 ".concat(t?"tw-border-SECONDARY_50 tw-bg-SECONDARY_50 tw-text-WHITE":"tw-border-GREY_10 tw-bg-WHITE"),children:t?(0,Ot.jsx)(c.YrT,{size:13,strokeWidth:3}):null})}const ka="tw-flex tw-min-w-0 tw-flex-col tw-rounded-lg tw-border tw-p-3",_a="tw-border-SECONDARY_50 tw-bg-SECONDARY_2";function Sa(e){return J(e,e=>'<span class="tw-mx-0.5 tw-inline-flex tw-h-5 tw-min-w-[20px] tw-items-center tw-justify-center tw-rounded tw-bg-PRIMARY_05 tw-px-1 tw-align-middle tw-text-[11px] tw-font-bold tw-text-PRIMARY_60">'.concat(e+1,"</span>"))}function Ya(e){var t;let{text:n,dir:l,className:s,children:a}=e;return(0,Ot.jsxs)("span",{dir:null!==(t=ne(n))&&void 0!==t?t:l,className:s,children:[a,n]})}function Ma(e){let{payload:t,isArabic:n,dir:l,t:s}=e;return(0,Ot.jsxs)("div",{className:"tw-flex tw-flex-col tw-gap-2",children:[t.options.map((e,t)=>{var s,a;return(0,Ot.jsxs)("div",{className:"".concat(ka," ").concat(e.correct?_a:"tw-border-GREY_
110 tw-bg-WHITE"),children:[(0,Ot.jsxs)("div",{className:"tw-flex tw-min-w-0 tw-items-start tw-gap-3",children:[(0,Ot.jsx)("span",{className:"tw-flex tw-h-6 tw-w-6 tw-shrink-0 tw-items-center tw-justify-center tw-rounded-md tw-bg-PRIMARY_05 tw-text-[11px] tw-font-bold tw-text-PRIMARY_60",children:null!==(a="ABCDEFGHIJKLMNOPQRSTUVWXYZ"[t])&&void 0!==a?a:t+1}),(0,Ot.jsx)(qa,{html:ie(n,e.textAr,e.textEn),dir:l,className:"tw-flex-1"}),(0,Ot.jsx)(Ca,{correct:e.correct})]}),(0,Ot.jsx)(Ra,{html:ie(n,e.explanationAr,e.explanationEn),dir:l})]},null!==(s=e.id)&&void 0!==s?s:t)}),(0,Ot.jsx)("p",{className:"tw-m-0 tw-text-xs tw-text-GREY_50",children:s(t.shuffle?"cbq.labels.shuffled":"cbq.labels.fixedOrder")})]})}const Ta={[M.MCQ_SINGLE]:{key:"mcq",Component:Ma},[M.MCQ_MULTI]:{key:"mcq",Component:Ma},[M.SEQUENCE]:{key:"sequence",Component:function(e){let{payload:t,isArabic:n,dir:l,t:s}=e;return(0,Ot.jsxs)("div",{className:"tw-flex tw-flex-col tw-gap-2",children:[(0,Ot.jsx)("p",{className:"tw-m-0 tw-text-xs tw-text-GREY_50",children:s("cbq.hints.shuffleSequence")}),t.items.map((e,t)=>{var s;return(0,Ot.jsx)("div",{className:"".concat(ka," ").concat(_a),children:(0,Ot.jsxs)("div",{className:"tw-flex tw-min-w-0 tw-items-start tw-gap-3",children:[(0,Ot.jsx)("span",{className:"tw-flex tw-h-6 tw-w-6 tw-shrink-0 tw-items-center tw-justify-center tw-rounded-md tw-bg-SECONDARY_50 tw-text-[11px] tw-font-bold tw-text-WHITE",children:t+1}),(0,Ot.jsx)(Ya,{text:ie(n,e.textAr,e.textEn),dir:l,className:"tw-min-w-0 tw-flex-1 tw-text-sm tw-text-GREY_90"})]})},null!==(s=e.id)&&void 0!==s?s:t)})]})}},[M.CATEGORIZATION]:{key:"categorization",Component:function(e){let{payload:t,isArabic:n,dir:l,t:s}=e;return(0,Ot.jsx)("div",{className:"tw-grid tw-gap-3 sm:tw-grid-cols-2 lg:tw-grid-cols-3",children:t.categories.map((e,a)=>{var i;const o=t.items.filter(t=>String(t.categoryId)===String(e.id));return(0,Ot.jsxs)("section",{className:"tw-flex tw-min-w-0 tw-flex-col tw-gap-2",children:[(0,Ot.jsx)("h4",{className:"tw-m-0 tw-truncate tw-rounded-lg tw-bg-PRIMARY_05 tw-px-3 tw-py-2 tw-text-center tw-text-xs tw-font-bold tw-text-PRIMARY_60",children:ie(n,e.nameAr,e.nameEn)||s("cbq.labels.untitledCategory",{number:a+1})}),(0,Ot.jsx)("div",{className:"tw-flex tw-min-h-[64px] tw-flex-col tw-gap-2 tw-rounded-lg tw-border tw-border-dashed tw-border-SECONDARY_50 tw-bg-SECONDARY_2 tw-p-2",children:o.length?o.map((e,t)=>{var s;return(0,Ot.jsx)(Ya,{text:ie(n,e.textAr,e.textEn),dir:l,className:"tw-rounded-md tw-bg-WHITE tw-px-2 tw-py-1.5 tw-text-xs tw-text-GREY_90 tw-shadow-sm"},null!==(s=e.id)&&void 0!==s?s:t)}):(0,Ot.jsx)("span",{className:"tw-p-1 tw-text-xs tw-text-GREY_50",children:s("cbq.labels.emptyCategory")})})]},null!==(i=e.id)&&void 0!==i?i:a)})})}},[M.CLOZE]:{key:"cloze",Component:function(e){let{payload:t,isArabic:n,dir:l,t:s}=e;const a=ie(n,t.templateAr,t.templateEn);return(0,Ot.jsxs)("div",{className:"tw-flex tw-flex-col tw-gap-4",children:[(0,Ot.jsx)("div",{className:"tw-rounded-lg tw-border tw-border-GREY_
110 tw-bg-PRIMARY_2 tw-p-4",children:(0,Ot.jsx)(qa,{html:Sa(a),dir:l})}),(0,Ot.jsx)("div",{className:"tw-flex tw-flex-col tw-gap-3",children:t.blanks.map((e,t)=>{var a;return(0,Ot.jsxs)("div",{className:"tw-rounded-lg tw-border tw-border-GREY_10 tw-bg-WHITE tw-p-3",children:[(0,Ot.jsx)("span",{className:"tw-text-xs tw-font-bold tw-text-GREY_70",children:s("cbq.labels.blankNumber",{number:t+1})}),(0,Ot.jsx)("div",{className:"tw-mt-2 tw-flex tw-flex-wrap tw-gap-2",children:e.options.map((e,t)=>{var s;return(0,Ot.jsx)(Ya,{text:ie(n,e.textAr,e.textEn),dir:l,className:"tw-inline-flex tw-items-center tw-gap-1.5 tw-rounded-md tw-border tw-px-2.5 tw-py-1 tw-text-xs ".concat(e.correct?"tw-border-SECONDARY_50 tw-bg-SECONDARY_2 tw-font-bold tw-text-SECONDARY_60":"tw-border-GREY_10 tw-bg-WHITE tw-text-GREY_70"),children:e.correct?(0,Ot.jsx)(c.YrT,{size:12,strokeWidth:3}):null},null!==(s=e.id)&&void 0!==s?s:t)})})]},null!==(a=e.id)&&void 0!==a?a:t)})})]})}},[M.NUMERIC]:{key:"numeric",Component:function(e){let{payload:t,isArabic:n,dir:l,t:s}=e;const a=ie(n,t.templateAr,t.templateEn);return(0,Ot.jsxs)("div",{className:"tw-flex tw-flex-col tw-gap-4",children:[(0,Ot.jsx)("div",{className:"tw-rounded-lg tw-border tw-border-GREY_
110 tw-bg-PRIMARY_2 tw-p-4",children:(0,Ot.jsx)(qa,{html:Sa(a),dir:l})}),(0,Ot.jsx)("div",{className:"tw-flex tw-flex-col tw-gap-2",children:t.blanks.map((e,t)=>{var n;return(0,Ot.jsx)("div",{className:"".concat(ka," ").concat(_a),children:(0,Ot.jsxs)("div",{className:"tw-flex tw-min-w-0 tw-flex-wrap tw-items-center tw-gap-3",children:[(0,Ot.jsx)("span",{className:"tw-flex tw-h-6 tw-w-6 tw-shrink-0 tw-items-center tw-justify-center tw-rounded tw-bg-PRIMARY_05 tw-text-[11px] tw-font-bold tw-text-PRIMARY_60",children:t+1}),(0,Ot.jsx)("span",{className:"tw-text-xs tw-text-GREY_70",children:s("cbq.labels.correctAnswer")}),(0,Ot.jsx)("span",{dir:"ltr",className:"tw-text-sm tw-font-bold tw-text-SECONDARY_60",children:e.correctAnswer||"\u2014"})]})},null!==(n=e.id)&&void 0!==n?n:t)})})]})}}};function Pa(e){let{question:t}=e;const{t:n}=(0,d.B)(),{isArabic:l,dir:s}=ml(),a=Ta[null===t||void 0===t?void 0:t.type];if(!a)return null;const{key:i,Component:o}=a;return(0,Ot.jsx)(o,{payload:t.payload[i],isArabic:l,dir:s,t:n})}function Oa(e){let{icon:t,label:n,children:l}=e;return(0,Ot.jsxs)("div",{className:"tw-flex tw-min-w-0 tw-flex-col tw-gap-2 tw-rounded-lg tw-border tw-border-GREY_
110 tw-bg-PRIMARY_2 tw-p-3",children:[(0,Ot.jsxs)("span",{className:"tw-flex tw-items-center tw-gap-2 tw-text-[11px] tw-font-bold tw-uppercase tw-tracking-wide tw-text-GREY_50",children:[(0,Ot.jsx)("span",{className:"tw-shrink-0 tw-text-GREY_30",children:t}),(0,Ot.jsx)("span",{className:"tw-truncate",children:n})]}),(0,Ot.jsx)("div",{className:"tw-min-w-0 tw-text-sm tw-font-bold tw-text-GREY_90",children:l})]})}function Ga(e){let{details:t,topicPaths:n,isLoadingTopics:l}=e;const{t:s}=(0,d.B)();return(0,Ot.jsxs)("div",{className:"tw-flex tw-min-w-0 tw-flex-col tw-gap-5",children:[(0,Ot.jsxs)("section",{className:"tw-min-w-0 tw-overflow-hidden tw-rounded-xl tw-border tw-border-GREY_10 tw-bg-WHITE tw-shadow-sm",children:[(0,Ot.jsxs)("header",{className:"tw-flex tw-items-center tw-gap-2 tw-border-b tw-border-GREY_10 tw-px-5 tw-py-3",children:[(0,Ot.jsx)(c.x_j,{className:"tw-text-PRIMARY_60"}),(0,Ot.jsx)("h2",{className:"tw-m-0 tw-text-sm tw-font-bold tw-text-GREY_90",children:s("cbq.labels.topics")}),(0,Ot.jsx)("span",{className:"tw-flex tw-h-5 tw-min-w-[20px] tw-items-center tw-justify-center tw-rounded-full tw-bg-PRIMARY_05 tw-px-1.5 tw-text-[11px] tw-font-bold tw-text-PRIMARY_60",children:l?"\u2026":n.length})]}),(0,Ot.jsx)("div",{className:"tw-flex tw-flex-wrap tw-gap-2 tw-px-5 tw-py-4",children:l?(0,Ot.jsx)(i.A,{size:"sm",content:s("cbq.labels.loading")}):n.length?n.map(e=>(0,Ot.jsx)("span",{className:"tw-rounded-lg tw-border tw-border-PRIMARY_05 tw-bg-PRIMARY_2 tw-px-3 tw-py-1.5 tw-text-xs tw-font-semibold tw-text-PRIMARY_60",children:e},e)):(0,Ot.jsx)("span",{className:"tw-text-xs tw-text-GREY_50",children:s("cbq.labels.noTopics")})})]}),(0,Ot.jsxs)("section",{className:"tw-min-w-0 tw-overflow-hidden tw-rounded-xl tw-border tw-border-GREY_
110 tw-bg-WHITE tw-shadow-sm",children:[(0,Ot.jsx)("header",{className:"tw-border-b tw-border-GREY_10 tw-px-5 tw-py-3",children:(0,Ot.jsx)("h2",{className:"tw-m-0 tw-text-sm tw-font-bold tw-text-GREY_90",children:s("cbq.labels.questionAttributes")})}),(0,Ot.jsxs)("div",{className:"tw-grid tw-gap-3 tw-px-5 tw-py-4 sm:tw-grid-cols-2 lg:tw-grid-cols-3 xl:tw-grid-cols-4",children:[(0,Ot.jsx)(Oa,{icon:(0,Ot.jsx)(c.s_k,{}),label:s("cbq.columns.format"),children:(0,Ot.jsx)(zn,{tone:Bn(t.type),children:t.format})}),t.difficulty?(0,Ot.jsx)(Oa,{icon:(0,Ot.jsx)(c.vQY,{}),label:s("cbq.labels.difficulty"),children:(0,Ot.jsx)(Qn,{value:t.difficultyValue,label:t.difficulty})}):null,t.category?(0,Ot.jsx)(Oa,{icon:(0,Ot.jsx)(c.cnX,{}),label:s("cbq.labels.category"),children:(0,Ot.jsx)(zn,{tone:"navy",children:t.category})}):null,t.concept?(0,Ot.jsx)(Oa,{icon:(0,Ot.jsx)(c.D1A,{}),label:s("cbq.labels.concept"),children:t.concept}):null,t.size?(0,Ot.jsx)(Oa,{icon:(0,Ot.jsx)(c.mkN,{}),label:s("cbq.labels.size"),children:(0,Ot.jsx)(zn,{tone:"indigo",children:t.size})}):null,t.estimatedTime?(0,Ot.jsx)(Oa,{icon:(0,Ot.jsx)(c.Ohp,{}),label:s("cbq.labels.estimatedTime"),children:t.estimatedTime}):null,t.usedIn.length?(0,Ot.jsx)(Oa,{icon:(0,Ot.jsx)(c.Qz2,{}),label:s("cbq.labels.usedIn"),children:(0,Ot.jsx)("span",{className:"tw-flex tw-flex-wrap tw-gap-1",children:t.usedIn.map(e=>(0,Ot.jsx)(zn,{tone:"green",children:e},e))})}):null,(0,Ot.jsx)(Oa,{icon:(0,Ot.jsx)(c.NLe,{}),label:s("cbq.columns.responses"),children:t.responses}),(0,Ot.jsx)(Oa,{icon:(0,Ot.jsx)(c.pVQ,{}),label:s("cbq.columns.video"),children:(0,Ot.jsx)("span",{className:t.videosCount?"tw-text-SECONDARY_60":"tw-text-GREY_50",children:t.videosCount})}),t.rank?(0,Ot.jsx)(Oa,{icon:(0,Ot.jsx)(c.Qz2,{}),label:s("cbq.labels.rank"),children:t.rank}):null,t.created?(0,Ot.jsx)(Oa,{icon:(0,Ot.jsx)(c.wIk,{}),label:s("cbq.columns.created"),children:t.created}):null,(0,Ot.jsx)(Oa,{icon:(0,Ot.jsx)(c.z1n,{}),label:s("cbq.labels.status"),children:(0,Ot.jsxs)("span",{className:"tw-inline-flex tw-items-center tw-gap-1.5",children:[(0,Ot.jsx)("span",{className:"tw-h-2 tw-w-2 tw-rounded-full ".concat(t.isActive?"tw-bg-SECONDARY_50":"tw-bg-GREY_30")}),(0,Ot.jsx)("span",{className:t.isActive?"tw-text-SECONDARY_60":"tw-text-GREY_50",children:t.status})]})})]})]})]})}function Fa(e){let{questionId:t}=e;const{t:n}=(0,d.B)(),{items:s,isLoading:a,isError:o}=qs(t),[r,u]=(0,l.useState)(null);return a?(0,Ot.jsx)(i.A,{size:"sm",content:n("cbq.labels.loading")}):o?(0,Ot.jsx)("span",{className:"tw-text-xs tw-text-ERROR_100",children:n("cbq.errors.mediaFailed")}):s.length?(0,Ot.jsxs)("div",{className:"tw-mt-4 tw-flex tw-min-w-0 tw-flex-col tw-gap-3 tw-border-t tw-border-GREY_
110 tw-pt-4",children:[(0,Ot.jsx)("span",{className:"tw-text-[11px] tw-font-bold tw-uppercase tw-tracking-wide tw-text-GREY_50",children:n("cbq.labels.explanationMedia")}),(0,Ot.jsx)("div",{className:"tw-grid tw-gap-3 sm:tw-grid-cols-2",children:s.map(e=>(0,Ot.jsxs)("button",{type:"button",onClick:()=>u(e),className:"tw-flex tw-aspect-video tw-w-full tw-flex-col tw-items-center tw-justify-center tw-gap-2 tw-rounded-lg tw-border tw-border-GREY_10 tw-bg-GREY_05 tw-transition-colors hover:tw-border-PRIMARY_50",children:[(0,Ot.jsx)("span",{className:"tw-flex tw-h-11 tw-w-11 tw-items-center tw-justify-center tw-rounded-full tw-bg-PRIMARY_60 tw-text-WHITE",children:(0,Ot.jsx)(c.aze,{size:18})}),(0,Ot.jsx)("span",{className:"tw-text-xs tw-text-GREY_50",children:[xe(e.lengthSeconds),me(e.sizeInBytes)].filter(Boolean).join(" \xb7 ")})]},e.key))}),(0,Ot.jsx)(ia,{item:r,onClose:()=>u(null)})]}):null}function za(e){let{fact:t,open:n,onToggle:l}=e;const{t:s}=(0,d.B)(),{isArabic:a,dir:i}=ml();if(!t)return null;const o=ie(a,t.titleAr,t.titleEn),r=ie(a,t.descriptionAr,t.descriptionEn);return(0,Ot.jsxs)("section",{className:"tw-min-w-0 tw-overflow-hidden tw-rounded-xl tw-border tw-border-PRIMARY_05 tw-bg-PRIMARY_2 tw-shadow-sm",children:[(0,Ot.jsxs)("header",{className:"tw-flex tw-min-w-0 tw-items-center tw-gap-3 tw-px-4 tw-py-3",children:[(0,Ot.jsx)("span",{className:"tw-flex tw-h-8 tw-w-8 tw-shrink-0 tw-items-center tw-justify-center tw-rounded-full tw-bg-WHITE tw-text-PRIMARY_60",children:(0,Ot.jsx)(c.D1A,{size:16})}),(0,Ot.jsxs)("button",{type:"button",onClick:l,"aria-expanded":n,className:"tw-flex tw-min-w-0 tw-flex-1 tw-flex-col tw-text-start",children:[(0,Ot.jsx)("span",{className:"tw-text-[11px] tw-font-bold tw-uppercase tw-tracking-wide tw-text-PRIMARY_50",children:s("cbq.labels.linkedCase")}),(0,Ot.jsx)("span",{className:"tw-truncate tw-text-sm tw-font-bold tw-text-GREY_90",children:o})]}),(0,Ot.jsx)(Jt.A,{size:"sm",appearance:"subtle",icon:n?(0,Ot.jsx)(c.wAb,{}):(0,Ot.jsx)(c.fK4,{}),onClick:l,"aria-label":s(n?"cbq.actions.collapse":"cbq.actions.expand"),className:"tw-shrink-0 tw-text-PRIMARY_60"})]}),n?(0,Ot.jsxs)("div",{className:"tw-flex tw-min-w-0 tw-flex-col tw-gap-3 tw-border-t tw-border-PRIMARY_05 tw-bg-WHITE tw-px-4 tw-py-4",children:[t.imageUrl?(0,Ot.jsx)("img",{src:t.imageUrl,alt:o,className:"tw-max-h-56 tw-self-start tw-rounded-lg tw-border tw-border-GREY_
110 tw-object-contain"}):null,(0,Ot.jsx)(cl,{html:r,dir:i,className:"tw-min-w-0 tw-rounded-lg tw-bg-PRIMARY_2 tw-p-4 tw-text-sm tw-leading-7 tw-text-GREY_70"})]}):null]})}function Da(e){let{id:t,active:n,icon:l,label:s,onClick:a}=e;return(0,Ot.jsxs)("button",{type:"button",role:"tab",id:"".concat(t,"-tab"),"aria-controls":"".concat(t,"-panel"),"aria-selected":n,onClick:a,className:"tw-flex tw-flex-1 tw-items-center tw-justify-center tw-gap-2 tw-border-b-2 tw-px-3 tw-py-3 tw-text-sm tw-font-bold tw-transition-colors ".concat(n?"tw-border-PRIMARY_60 tw-text-PRIMARY_60":"tw-border-transparent tw-text-GREY_50 hover:tw-text-GREY_70"),children:[l,s]})}function Ba(e){let{icon:t,title:n,aside:l,children:s}=e;return(0,Ot.jsxs)("section",{className:"tw-min-w-0 tw-overflow-hidden tw-rounded-xl tw-border tw-border-GREY_10 tw-bg-WHITE tw-shadow-sm",children:[(0,Ot.jsxs)("header",{className:"tw-flex tw-min-w-0 tw-flex-wrap tw-items-center tw-gap-2 tw-border-b tw-border-GREY_10 tw-px-5 tw-py-3",children:[(0,Ot.jsx)("span",{className:"tw-shrink-0 tw-text-PRIMARY_60",children:t}),(0,Ot.jsx)("h2",{className:"tw-m-0 tw-text-sm tw-font-bold tw-text-GREY_90",children:n}),(0,Ot.jsx)("div",{className:"tw-flex-1"}),l]}),(0,Ot.jsx)("div",{className:"tw-min-w-0 tw-px-5 tw-py-4",children:s})]})}function La(e){let{fact:t,questionId:n,onBack:s,onEdit:a}=e;const{t:u}=(0,d.B)(),{isArabic:w,dir:p}=ml(),{tab:m,setTab:x,caseOpen:b,setCaseOpen:f,pendingDelete:y,setPendingDelete:A,question:E,details:I,topicPaths:N,isLoadingTopics:q,isLoading:R,isError:C,isMissing:k,unsupportedType:_,remove:S,isRemoving:Y}=function(){let{factId:e,questionId:t,onDeleted:n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{t:s}=(0,d.B)(),a=(0,v.jE)(),[i,o]=(0,l.useState)(Ia),[r,c]=(0,l.useState)(!0),[u,w]=(0,l.useState)(!1),{row:p,content:m,isLoading:x,isError:b}=Is(e,t),f=(0,l.useMemo)(()=>p?ht(p):null,[p]),y=p&&!Ue(null===m||void 0===m?void 0:m.type)?(null===m||void 0===m?void 0:m.type)||"\u2014":"",{data:A,isLoading:E}=(0,h.I)({queryKey:At.questionTopics(t),queryFn:()=>Yt(t),enabled:Boolean(t),staleTime:yt}),I=null!==A&&void 0!==A?A:Ea,{labelOf:N}=Vn("courses",I.map(e=>e.courseId)),{labelOf:q}=Vn("units",I.map(e=>e.unitId)),{labelOf:R}=Vn("topics",I.map(e=>e.topicId)),C=(0,l.useMemo)(()=>I.map(e=>[N(e.courseId),q(e.unitId),R(e.topicId)].filter(Boolean).join(" \u203a ")).filter(Boolean),[I,N,q,R]),{labelOf:k}=Vn("sizes",p?[p.questionSizeId]:Ea),_=null===f||void 0===f?void 0:f.meta,S=(0,l.useMemo)(()=>{var e;return f?{type:f.type,format:y?s("cbq.labels.unsupportedType"):f.type?s(V(f.type)):"",difficulty:_.difficulty?s("cbq.difficulty.".concat(_.difficulty)):"",difficultyValue:_.difficulty,category:_.category?s("cbq.category.".concat(_.category)):"",concept:_.conceptType?s("cbq.concept.".concat(_.conceptType)):"",size:k(_.questionSizeId),estimatedTime:pn(_.durationSeconds),usedIn:_.usedIn.map(e=>s("cbq.usedIn.".concat(e))),responses:Aa(m),videosCount:Number(null===p||void 0===p?void 0:p.videosCount)||0,rank:_.rank,isActive:_.status===F.ACTIVE,status:s("cbq.status.".concat(_.status)),created:xn(null!==(e=null===p||void 0===p?void 0:p.creatAt)&&void 0!==e?e:null===p||void 0===p?void 0:p.createdAt)}:null},[f,_,m,p,k,y,s]),Y=(0,g.n)({mutationFn:()=>Ct(t),onSuccess:()=>{a.invalidateQueries({queryKey:At.factQuestions(e)}),j.oR.success(s("cbq.toast.questionDeleted")),null===n||void 0===n||n()},onError:()=>j.oR.error(s("cbq.toast.questionDeleteFailed"))});return{tab:i,setTab:o,caseOpen:r,setCaseOpen:c,pendingDelete:u,setPendingDelete:w,question:f,content:m,details:S,topicPaths:C,isLoadingTopics:E,isLoading:x,isError:b,isMissing:!x&&!b&&!p,unsupportedType:y,remove:Y.mutate,isRemoving:Y.isPending}}({factId:null===t||void 0===t?void 0:t.id,questionId:n,onDeleted:s});if(R)return(0,Ot.jsx)("div",{className:"tw-flex tw-h-64 tw-items-center tw-justify-center",children:(0,Ot.jsx)(i.A,{size:"md",content:u("cbq.labels.loading")})});if(C||k)return(0,Ot.jsxs)("div",{className:"tw-flex tw-flex-col tw-gap-4",children:[(0,Ot.jsx)(o.A,{appearance:"subtle",startIcon:(0,Ot.jsx)(c.kRp,{}),onClick:s,className:"tw-self-start",children:u("cbq.actions.back")}),(0,Ot.jsx)(r.A,{type:"error",showIcon:!0,children:u(k?"cbq.errors.questionMissing":"cbq.errors.questionsFailed")})]});const M=ie(w,E.titleAr,E.titleEn),T=ie(w,E.explanationAr,E.explanationEn),P=!_&&!U(E.type);return(0,Ot.jsxs)("div",{className:"tw-flex tw-w-full tw-min-w-0 tw-flex-col tw-gap-5 tw-pb-16",children:[(0,Ot.jsxs)("header",{className:"tw-sticky tw-top-0 tw-z-10 tw-flex tw-flex-wrap tw-items-center tw-gap-3 tw-rounded-xl tw-border tw-border-GREY_
110 tw-bg-WHITE tw-px-4 tw-py-3 tw-shadow-sm",children:[(0,Ot.jsx)(Jt.A,{size:"sm",appearance:"subtle",icon:(0,Ot.jsx)(c.kRp,{}),onClick:s,"aria-label":u("cbq.actions.back"),className:"tw-shrink-0 tw-text-GREY_70"}),(0,Ot.jsxs)("div",{className:"tw-flex tw-min-w-0 tw-flex-col",children:[(0,Ot.jsx)("h1",{className:"tw-m-0 tw-text-lg tw-font-bold tw-text-GREY_90",children:u("cbq.titles.viewQuestion")}),(0,Ot.jsxs)("nav",{className:"tw-flex tw-min-w-0 tw-flex-wrap tw-items-center tw-gap-1 tw-text-xs tw-text-GREY_50",children:[(0,Ot.jsx)("button",{type:"button",onClick:s,className:"tw-font-semibold tw-text-PRIMARY_50 hover:tw-underline",children:u("cbq.titles.bank")}),(0,Ot.jsx)("span",{"aria-hidden":!0,children:"\u203a"}),(0,Ot.jsx)("span",{className:"tw-max-w-[240px] tw-truncate",children:ie(w,null===t||void 0===t?void 0:t.titleAr,null===t||void 0===t?void 0:t.titleEn)}),(0,Ot.jsx)("span",{"aria-hidden":!0,children:"\u203a"}),(0,Ot.jsxs)("span",{className:"tw-font-semibold tw-text-GREY_70",children:["#",n]})]})]}),(0,Ot.jsx)("div",{className:"tw-flex-1"}),(0,Ot.jsx)(la,{label:u("cbq.labels.displayLanguage")}),(0,Ot.jsx)(o.A,{appearance:"ghost",startIcon:(0,Ot.jsx)(c.WXf,{}),onClick:a,children:u("cbq.actions.edit")}),(0,Ot.jsx)($t.A,{placement:"top",trigger:"hover",speaker:(0,Ot.jsx)(Xt.A,{children:u("cbq.actions.remove")}),children:(0,Ot.jsx)(Jt.A,{size:"sm",appearance:"subtle",icon:(0,Ot.jsx)(c.IXo,{}),onClick:()=>A(!0),"aria-label":u("cbq.actions.remove"),className:"tw-text-ERROR_100"})})]}),(0,Ot.jsxs)("div",{role:"tablist",className:"tw-flex tw-min-w-0 tw-border-b tw-border-GREY_
110",children:[(0,Ot.jsx)(Da,{id:Ia,active:m===Ia,icon:(0,Ot.jsx)(c.jH2,{}),label:u("cbq.tabs.caseAndQuestion"),onClick:()=>x(Ia)}),(0,Ot.jsx)(Da,{id:Na,active:m===Na,icon:(0,Ot.jsx)(c.S8s,{}),label:u("cbq.tabs.details"),onClick:()=>x(Na)})]}),m===Ia?(0,Ot.jsxs)("div",{role:"tabpanel",id:"".concat(Ia,"-panel"),"aria-labelledby":"".concat(Ia,"-tab"),className:"tw-flex tw-min-w-0 tw-flex-col tw-gap-5",children:[(0,Ot.jsx)(za,{fact:t,open:b,onToggle:()=>f(e=>!e)}),(0,Ot.jsx)(Ba,{icon:(0,Ot.jsx)(c.jH2,{size:16}),title:u("cbq.labels.questionText"),aside:(0,Ot.jsx)(zn,{tone:_?"grey":Bn(E.type),title:_||void 0,children:u(_?"cbq.labels.unsupportedType":V(E.type))}),children:(0,Ot.jsxs)("div",{className:"tw-flex tw-min-w-0 tw-flex-col tw-gap-4",children:[(0,Ot.jsx)(cl,{html:M,dir:p,className:"tw-min-w-0 tw-text-sm tw-font-semibold tw-leading-7 tw-text-GREY_90"}),(0,Ot.jsxs)("div",{className:"tw-flex tw-min-w-0 tw-flex-col tw-gap-3 tw-border-t tw-border-GREY_10 tw-pt-4",children:[(0,Ot.jsx)("span",{className:"tw-text-[11px] tw-font-bold tw-uppercase tw-tracking-wide tw-text-GREY_50",children:u("cbq.labels.answerKey")}),_?(0,Ot.jsx)(r.A,{type:"warning",showIcon:!0,children:u("cbq.errors.unsupportedType",{type:_})}):(0,Ot.jsx)(Pa,{question:E})]})]})}),(0,Ot.jsxs)(Ba,{icon:(0,Ot.jsx)(c.S8s,{size:16}),title:u("cbq.labels.questionExplanation"),children:[P||$(T)?(0,Ot.jsx)("p",{className:"tw-m-0 tw-text-xs tw-text-GREY_50",children:u(P?"cbq.labels.explainedPerOption":"cbq.labels.noExplanation")}):(0,Ot.jsx)(cl,{html:T,dir:p,className:"tw-min-w-0 tw-rounded-lg tw-bg-PRIMARY_2 tw-p-4 tw-text-sm tw-leading-7 tw-text-GREY_70"}),(0,Ot.jsx)(Fa,{questionId:n})]})]}):(0,Ot.jsx)("div",{role:"tabpanel",id:"".concat(Na,"-panel"),"aria-labelledby":"".concat(Na,"-tab"),className:"tw-min-w-0",children:(0,Ot.jsx)(Ga,{details:I,topicPaths:N,isLoadingTopics:q})}),(0,Ot.jsx)(Yn,{open:y,title:u("cbq.dialogs.deleteQuestionTitle"),description:u("cbq.dialogs.deleteQuestionDescription"),loading:Y,onClose:()=>A(!1),onConfirm:()=>S()})]})}function Qa(e){var t;const{factById:n}=Bt(),l=n(e),s=Boolean(e)&&!l,{data:a,isLoading:i,isError:o}=(0,h.I)({queryKey:At.fact(String(e)),queryFn:()=>async function(e){var t;const n="/questions/facts/fullinfo".concat(Et({skip:0,take:1,filter:[["id","=",Number(e)]]})),{data:l}=await I.Ay.get(n),s=(null!==(t=null===l||void 0===l?void 0:l.data)&&void 0!==t?t:[])[0];return s?gt(s):null}(e),enabled:s,staleTime:3e5});return{fact:null!==(t=null!==l&&void 0!==l?l:a)&&void 0!==t?t:null,isLoading:s&&i,isError:s&&o}}const Ua=(e,t)=>Object.entries(t).reduce((e,t)=>{let[n,l]=t;return e.replace(":".concat(n),encodeURIComponent(l))},e),Va=u.A.ADMIN_QUESTIONS_CBQ.URL,Ha=(e,t)=>Ua(u.A.ADMIN_QUESTIONS_CBQ_QUESTION.URL,{factId:e,questionId:t}),Ka=(e,t)=>Ua(u.A.ADMIN_QUESTIONS_CBQ_QUESTION_EDIT.URL,{factId:e,questionId:t}),Wa=e=>{var t;let{mode:n}=e;const{t:a}=(0,d.B)(),u=(0,s.W6)(),w=(0,s.zy)(),{factId:p,questionId:m}=(0,s.g)(),{fact:x,isLoading:b,isError:v}=Qa(p),h="new"===n,f=(0,l.useCallback)(()=>u.push(Va),[u]),g=(0,l.useCallback)(()=>u.push(Ha(p,m)),[u,p,m]),j=null===(t=w.state)||void 0===t?void 0:t.returnTo,y=h||"list"===j?f:g,A=(0,l.useCallback)(()=>u.push(Ka(p,m),{returnTo:"view"}),[u,p,m]);return b?(0,Ot.jsx)("div",{className:"tw-flex tw-h-64 tw-items-center tw-justify-center",children:(0,Ot.jsx)(i.A,{size:"md",content:a("cbq.labels.loading")})}):v||!x?(0,Ot.jsxs)("div",{className:"tw-flex tw-flex-col tw-gap-4",children:[(0,Ot.jsx)(o.A,{appearance:"subtle",startIcon:(0,Ot.jsx)(c.kRp,{}),onClick:f,className:"tw-self-start",children:a("cbq.actions.back")}),(0,Ot.jsx)(r.A,{type:"error",showIcon:!0,children:a("cbq.errors.factMissing")})]}):"view"===n?(0,Ot.jsx)(La,{fact:x,questionId:m,onBack:f,onEdit:A}):(0,Ot.jsx)(ya,{fact:x,questionId:h?null:m,onBack:y,onSaved:y})},Za=()=>{const e=(0,s.W6)();return(0,Ot.jsx)(ps,{onAddQuestion:t=>{return e.push((n=t.id,Ua(u.A.ADMIN_QUESTIONS_CBQ_QUESTION_NEW.URL,{factId:n})));var n},onOpenQuestion:(t,n)=>e.push(Ka(t.id,n),{returnTo:"list"}),onViewQuestion:(t,n)=>e.push(Ha(t.id,n))})},$a=()=>(0,Ot.jsx)(a.A,{basic:!0,children:(0,Ot.jsx)(Dt,{children:(0,Ot.jsx)(pl,{children:(0,Ot.jsxs)(s.dO,{children:[(0,Ot.jsx)(s.qh,{path:u.A.ADMIN_QUESTIONS_CBQ_QUESTION_NEW.URL,exact:!0,render:()=>(0,Ot.jsx)(Wa,{mode:"new"})}),(0,Ot.jsx)(s.qh,{path:u.A.ADMIN_QUESTIONS_CBQ_QUESTION_EDIT.URL,exact:!0,render:()=>(0,Ot.jsx)(Wa,{mode:"edit"})}),(0,Ot.jsx)(s.qh,{path:u.A.ADMIN_QUESTIONS_CBQ_QUESTION.URL,exact:!0,render:()=>(0,Ot.jsx)(Wa,{mode:"view"})}),(0,Ot.jsx)(s.qh,{path:Va,exact:!0,component:Za}),(0,Ot.jsx)(s.rd,{to:Va})]})})})})}
1,29839:(e,t,n)=>{n.r(t),n.d(t,{default:()=>g});var l=n(65043),s=n(40812),a=n(87117),i=n(19127),o=n(87485),r=n(58060),c=n(64652),d=n(47768),u=n(70901),w=n(7644),p=n(65288),m=n(97508),x=n(67774),b=n(74904),v=n(38957),h=n(3502),f=n(70579);const g=(0,p.C)()((0,m.Ng)(e=>{let{adminExplanationsList:t}=e;const{error:n,loading:l,videos:s,images:a,imgsLoading:i,imgsError:o}=t;return{error:n,loading:l,videos:s,images:a,imgsLoading:i,imgsError:o}},{adminPostNewExplanationVideo:x.Eg,adminDeleteExplanationVideo:x.pk,adminGetExplanationsVideoList:x.xp,adminPostNewExplanationImage:x.w3,adminDeleteExplanationImage:x.h9,adminGetExplanationsImagesList:x.Qu})(e=>{var t,n,p;const m=(0,v.A)(h.fV.ADMIN_RESOURCES.VIDEOS),x=(0,v.A)(h.fV.ADMIN_RESOURCES.QUESTIONS),{data:{id:g,rank:j},t:y,videos:A,images:E,adminPostNewExplanationVideo:I,adminDeleteExplanationVideo:N,adminGetExplanationsVideoList:q,adminPostNewExplanationImage:R,adminDeleteExplanationImage:C,adminGetExplanationsImagesList:k,loading:_,error:S,imgsLoading:Y,imgsError:M}=e,[T,P]=(0,l.useState)(!1),[O,G]=(0,l.useState)(null),[F,z]=(0,l.useState)(!1),[D,B]=(0,l.useState)(null);(0,l.useEffect)(()=>{q(g),k(g)},[q,k,g]);return S||M?(0,f.jsx)(b.a1,{}):(0,f.jsx)(s.A,{basic:!0,children:(0,f.jsxs)(r.A,{style:{width:"90vw"},children:[(0,f.jsxs)(s.A,{basic:!0,children:[(0,f.jsx)(b.io,{title:y("Videos"),description:"".concat(y("Rank"),": ").concat(j)}),(0,f.jsx)(s.A,{basic:!0,children:x.READ.granted&&m.READ.granted&&(_?(0,f.jsx)(s.A,{basic:!0,loading:_}):(0,f.jsx)(w.A.Group,{stackable:!0,itemsPerRow:"4",children:A.map(e=>{var t,n;return(0,f.jsxs)(w.A,{centered:!0,children:[(0,f.jsx)(a.A,{className:"tw-absolute",color:"READY"===e.status?"green":"ENC_FAIL"===e.status?"red":"ENC_PEND"===e.status?"orange":"grey",children:"READY"===e.status?y("Ready"):"ENC_FAIL"===e.status?y("Failed"):"ENC_PEND"===e.status?y("Pending"):y("Uploaded")}),(0,f.jsx)(s.A,{basic:!0,textAlign:"center",children:(0,f.jsx)(i.A,{name:"play circle outline",inverted:!0,color:"blue",size:"massive",style:{alignSelf:"center"}})}),(0,f.jsxs)(u.A.Group,{children:[(0,f.jsx)(u.A,{icon:"eye",onClick:()=>{G(e),P(!0)}}),(null===m||void 0===m||null===(t=m.DELETE)||void 0===t?void 0:t.granted)&&(null===x||void 0===x||null===(n=x.EDIT)||void 0===n?void 0:n.granted)&&(0,f.jsx)(u.A,{icon:"trash",onClick:()=>N(e.id,g)})]})]},e.id)})}))}),(null===x||void 0===x||null===(t=x.EDIT)||void 0===t?void 0:t.granted)&&(null===m||void 0===m||null===(n=m.ADD)||void 0===n?void 0:n.granted)&&(0,f.jsxs)(s.A,{basic:!0,children:[(0,f.jsx)(b.io,{title:y("Add")}),(0,f.jsx)(b.qN,{data:{value:null,setValue:I,questionId:g}})]})]}),(0,f.jsx)(c.A,{}),(0,f.jsxs)(s.A,{basic:!0,children:[(0,f.jsx)(b.io,{title:y("Images")}),(0,f.jsx)(s.A,{basic:!0,children:x.READ.granted&&(Y?(0,f.jsx)(s.A,{basic:!0,loading:Y}):(0,f.jsx)(w.A.Group,{stackable:!0,itemsPerRow:"4",children:E.map(e=>{var t;return(0,f.jsx)(w.A,{centered:!0,image:(0,f.jsx)(o.A,{loading:"lazy",src:e.url,style:{display:"flex",height:150,width:null}}),extra:(0,f.jsxs)(u.A.Group,{fluid:!0,children:[(0,f.jsx)(u.A,{icon:"eye",onClick:()=>{B(e),z(!0)}}),(null===x||void 0===x||null===(t=x.EDIT)||void 0===t?void 0:t.granted)&&(0,f.jsx)(u.A,{icon:"trash",onClick:()=>C(e.id,g)})]})},e.id)})}))}),(null===x||void 0===x||null===(p=x.ADD)||void 0===p?void 0:p.granted)&&(0,f.jsxs)(s.A,{basic:!0,children:[(0,f.jsx)(b.io,{title:y("Add")}),(0,f.jsx)(b.J,{deleteFromServer:!1,data:{value:null,setValue:R,questionId:g}})]})]}),(0,f.jsx)(d.A,{onClose:()=>P(!1),open:T,content:O&&(0,f.jsx)(b.L9,{videoDetails:{url:O.urlEn},onClose:()=>P(!1)}),basic:!0,size:"large",centered:!0,closeOnDimmerClick:!1}),(0,f.jsx)(d.A,{onClose:()=>z(!1),open:F,content:D&&(0,f.jsx)(o.A,{loading:"lazy",src:D.url,size:"large",centered:!0}),closeIcon:!0,basic:!0,size:"small",centered:!0,closeOnDimmerClick:!1,header:y("Image")})]})})}))}}]); 2//# sourceMappingURL=7241.dc121614.chunk.js.map
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.