PageSourceSearch

https://exam.net/build/assets/chunk.BhAHUh1tKawf.js

js exam.net collected 2026-09-24 11:46:45 UTC 177,755 bytes, 4 lines download raw bytes

vendor: 4,630 bytes, lines 1-2
1var Ft=Object.defineProperty,Ht=Object.defineProperties;var Gt=Object.getOwnPropertyDescriptors;var mt=Object.getOwnPropertySymbols;var zt=Object.prototype.hasOwnProperty,Kt=Object.prototype.propertyIsEnumerable;var ht=(l,t,d)=>t in l?Ft(l,t,{enumerable:!0,configurable:!0,writable:!0,value:d}):l[t]=d,be=(l,t)=>{for(var d in t||(t={}))zt.call(t,d)&&ht(l,d,t[d]);if(mt)for(var d of mt(t))Kt.call(t,d)&&ht(l,d,t[d]);return l},xe=(l,t)=>Ht(l,Gt(t));var j=(l,t,d)=>new Promise((s,n)=>{var a=h=>{try{y(d.next(h))}catch(g){n(g)}},p=h=>{try{y(d.throw(h))}catch(g){n(g)}},y=h=>h.done?s(h.value):Promise.resolve(h.value).then(a,p);y((d=d.apply(l,t)).next())});import{k as ne,w as Te,V as Re,s as o,u as I,v as k,x as u,X as m,E,C as e,z as r,y as de,F as O,G as ke,S as Z,N as _,A as i,T as te,r as x,c as ee,L as Xt,M as Wt,H as rt,D as st,U as ue,i as He,B as wt,a0 as ve,O as De,n as St,$ as Yt,q as le,a6 as Et,ag as lt,f as jt,am as Ct,_ as Se,a1 as pt,Y as qt}from"./chunk.BhnF8lqErK1Y.js";import{I as ce,b6 as at,a as ie,a4 as $t,a3 as At,y as Qe,P as re,u as dt,S as fe,aV as Qt,D as Jt,bJ as Zt,bq as es,bB as ts,bt as ss,bs as ls,bK as as,bL as os,bM as ns,bN as is,bC as rs,bO as ds,aw as us,bP as cs,bx as ms,bQ as hs,t as ps}from"./chunk.C6PXV3Pxc_ps.js";import{_ as vs}from"./chunk.BY4R_htcd2D3.js";import{_ as ye}from"./chunk.DbSEshNrmVP7.js";import{a as F,L as Pe,h as Tt,e as vt,a9 as Dt,aa as Nt,cv as fs,j as Lt,F as gs,aX as ot,O as ys,aj as _s,aT as bs,i as We,aA as Ee,cw as Ne,$ as xs,M as Ye,J as Ce,cx as je,D as Ge,z as ks,bU as ws,l as Ss,q as ze,bz as Es,bv as Cs,cy as we,cz as ft,aQ as Vt,_ as Ke,v as $s}from"./entry.CoPCKUW3BkOv.js";import{a as ge,b as J}from"./chunk.C7H1bMZZ1nyS.js";import{a as As}from"./chunk.DwiKpsRySRfh.js";import{a as Ts,c as Ds,g as Ns,m as Ls,_ as Vs,s as Us}from"./chunk.Cu1SxG8u3gWI.js";import{h as Is}from"./chunk.b6-6ZA_3MRBA.js";import{l as Ms,c as Rs,s as Ps}from"./chunk.DGPd4J_YlguI.js";import{s as gt}from"./chunk.B24uO4CbZ5Co.js";import{b as _e,u as $e,_ as Je,a as Bs}from"./chunk.BMSsf2M8VeO7.js";import{S as Ue}from"./chunk.B3U-hymdOXX2.js";import{s as Os}from"./chunk.DFaii_0VQqXg.js";import{L as Ut,b as It}from"./chunk.DGksOcLQgZEB.js";import{s as ut,a as Fs}from"./chunk.CWu7TGTYxTV1.js";import{P as Mt,a as Hs}from"./chunk.vKmSb7iagUEM.js";import{B as Gs}from"./chunk.BbtcIZGqd4iu.js";import{s as Be}from"./chunk.vnb9wo7-kmQt.js";import{e as ct}from"./chunk.UpvZ3l62gFq7.js";import{s as Ae}from"./chunk.BDU3fSxGx4NH.js";import{s as zs}from"./chunk.DnPlnwNnX9g-.js";import{R as he}from"./chunk.BYYn09UaC-Rz.js";import{s as yt}from"./chunk.Ct6L_48m9-Sj.js";import{s as Ks,f as Xs}from"./chunk.CzAYEoXEVuZB.js";import{E as Le,a as _t}from"./chunk.Dr5kGOsTmRVs.js";import{_ as Ws}from"./chunk.ByG0X3j3r_sF.js";import"./chunk.DMiigLJ6-phQ.js";import"./chunk.CYb5VoSWUqQa.js";import"./chunk.BvdY-38ehWl1.js";import"./chunk.CBTSrM8H8osD.js";import"./chunk.CikXL8VgIIyA.js";const Ys=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 17" fill="none"> <path d="M3.5 4L4.125 14C4.15469 14.5778 4.575 15 5.125 15H10.875C11.4272 15 11.8397 14.5778 11.875 14L12.5 4" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/> <path d="M2.5 4H13.5H2.5Z" fill="black"/> <path d="M2.5 4H13.5" stroke="#222222" stroke-miterlimit="10" stroke-linecap="round"/> <path d="M6 4V2.75C5.99971 2.65143 6.01891 2.55377 6.0565 2.46265C6.09409 2.37152 6.14932 2.28873 6.21903 2.21903C6.28873 2.14933 6.37152 2.09409 6.46265 2.05651C6.55377 2.01892 6.65143 1.99971 6.75 2H9.25C9.34857 1.99971 9.44623 2.01892 9.53735 2.05651C9.62848 2.09409 9.71127 2.14933 9.78097 2.21903C9.85068 2.28873 9.90591 2.37152 9.9435 2.46265C9.98109 2.55377 10.0003 2.65143 10 2.75V4M8 6V13M5.75 6L6 13M10.25 6L10 13" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/> </svg>
2`,js=`<svg width="22px" height="22px" viewBox="0 0 22 22" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"> <g transform="translate(-4.000000, -4.000000)" fill="#222222" fill-rule="nonzero"> <path d="M7.31110576,7.13355202 C9.29426159,5.19488198 12.007591,4 15,4 C21.0751322,4 26,8.92486775 26,15 C26,21.0751322 21.0751322,26 15,26 C10.2275321,26 6.16492356,22.9607311 4.64209863,18.7121177 L7.71094868,17.4883733 C8.74557265,20.5198606 11.6181869,22.7 15,22.7 C19.2525926,22.7 22.7,19.2525926 22.7,15 C22.7,10.7474074 19.2525926,7.3 15,7.3 C12.9515912,7.3 11.0900016,8.09986801 9.71052739,9.40430778 L12.5282985,12.0709795 L4,12.8 L4,4 L7.31110576,7.13355202 Z" ></path> </g> </g> </svg>
3`,qs={class:"ExamUpdateLogsDialog__icons"},Qs={key:0,class:"ExamUpdateLogsDialog__anonymized fa fa-user-secret","aria-hidden":"true"},Js={key:2,class:"ExamUpdateLogsDialog__anonymized fa fa-user-secret","aria-hidden":"true"},Zs={class:"ExamUpdateLogsDialog__type"},el={class:"ExamUpdateLogsDialog__data-key"},Ve="First student joined",tl=ne({__name:"ExamUpdateLogsDialog",props:{examId:{},visible:{type:Boolean}},emits:["update:visible"],setup(l){const t=new Set(["OPEN","CLOSE","DISCOVERABLE"]),d=new Set(["LMS_LINKED","LMS_UNLINKED"]);function s(w){return t.has(w)}function n(w){return d.has(w)}function a(w){return w==="GOOGLE_CLASSROOM"?Ns:w==="TEAMS"?Ls:""}function p(w){var c,b;return(b=(c=gt[w])==null?void 0:c.icon.svg)!=null?b:Ms}function y(w){var c,b;return(b=(c=gt[w])==null?void 0:c.icon.color)!=null?b:"inherit"}function h(w){return w.type===Ve?"ExamUpdateLogsDialog__synthetic-row":""}const g=l,V=x([]);function A(w){if(!w)return 0;const c=w.includes("T")?w:w.replace(" ","T")+"Z";return new Date(c).getTime()}return Te(()=>g.visible,w=>j(null,null,function*(){if(w){const[c,b]=yield Promise.all([F.get(`/api/site-admin/exam/${g.examId}/update-logs`),F.get(`/api/site-admin/exam/${g.examId}/first-real-student-join`)]),f=b.data.joined_at,N=f?[{type:Ve,created_at:f}]:[];V.value=[...c.data,...N].sort((H,R)=>A(H.created_at)-A(R.created_at))}})),(w,c)=>{const b=Re("tooltip");return o(),I(Pe,{visible:l.visible,header:"Exam update logs",style:{width:"90vw",maxWidth:"1200px"},modal:"",dismissableMask:"","onUpdate:visible":c[0]||(c[0]=f=>w.$emit("update:visible",f))},{default:k(()=>[u(m(ge),{value:V.value,rowClass:h,stripedRows:""},{default:k(()=>[u(m(J),{field:"created_at",header:"Created at"},{body:k(({data:f})=>[f.created_at?(o(),I(ye,{key:0,datetime:f.created_at},null,8,["datetime"])):E("",!0)]),_:1}),u(m(J),{header:"",style:{width:"1px"}},{body:k(({data:f})=>{var N,H,R,z,P,C,S;return[e("span",qs,[s(f.type)?(o(),r("i",{key:0,class:de(["ExamUpdateLogsDialog__dot fa fa-circle",`ExamUpdateLogsDialog__dot--${f.type.toLowerCase()}`]),"aria-hidden":"true"},null,2)):n(f.type)?(o(),r(O,{key:1},[u(ce,{class:"ExamUpdateLogsDialog__lms-icon",width:"var(--width-4)",
3svg:a((N=f.data)==null?void 0:N.lms)},null,8,["svg"]),u(ce,{width:"var(--width-4)",svg:f.type==="LMS_LINKED"?m(Tt):m(Ts)},null,8,["svg"])],64)):f.type==="SECURITY_MODE_CHANGED"?(o(),r(O,{key:2},[u(ce,{width:"14px",svg:p((H=f.data)==null?void 0:H.from),style:ke({color:y((R=f.data)==null?void 0:R.from)})},null,8,["svg","style"]),u(ce,{class:"ExamUpdateLogsDialog__arrow",width:"12px",svg:m(vt)},null,8,["svg"]),u(ce,{width:"14px",svg:p((z=f.data)==null?void 0:z.to),style:ke({color:y((P=f.data)==null?void 0:P.to)})},null,8,["svg","style"])],64)):f.type==="ANONYMIZATION_CHANGED"?(o(),r(O,{key:3},[(C=f.data)!=null&&C.from?Z((o(),r("i",Qs,null,512)),[[b,"Anonymized"]]):Z((o(),I(ce,{key:1,width:"14px",svg:m(at)},null,8,["svg"])),[[b,"Not anonymized"]]),u(ce,{class:"ExamUpdateLogsDialog__arrow",width:"12px",svg:m(vt)},null,8,["svg"]),(S=f.data)!=null&&S.to?Z((o(),r("i",Js,null,512)),[[b,"Anonymized"]]):Z((o(),I(ce,{key:3,width:"14px",svg:m(at)},null,8,["svg"])),[[b,"Not anonymized"]])],64)):f.type==="ARCHIVED"?(o(),I(ce,{key:4,width:"var(--width-4)",
3svg:m(As)},null,8,["svg"])):f.type==="UNARCHIVED"?(o(),I(ce,{key:5,width:"var(--width-4)",svg:m(js)},null,8,["svg"])):f.type==="STUDENT_ANSWERS_DELETED"?(o(),I(ce,{key:6,class:"ExamUpdateLogsDialog__destructive",width:"var(--width-4)",svg:m(Ys)},null,8,["svg"])):f.type===Ve?(o(),I(ce,{key:7,width:"14px",svg:m(Ds)},null,8,["svg"])):E("",!0)])]}),_:1}),u(m(J),{header:"Type"},{body:k(({data:f})=>[e("span",Zs,[_(i(f.type)+" ",1),f.type===Ve?Z((o(),I(ce,{key:0,class:"ExamUpdateLogsDialog__help",width:"14px",svg:m(Is)},null,8,["svg"])),[[b,"This is aggregated debug info and not part of exam_update_log. This is the first real student, and not Test Person."]]):E("",!0)])]),_:1}),u(m(J),{field:"user_id",header:"User id"}),u(m(J),{field:"scheduled",header:"Scheduled"},{body:k(({data:f})=>[f.type!==Ve?(o(),r(O,{key:0},[_(i(f.scheduled?"Yes":"No"),1)],64)):E("",!0)]),_:1}),u(m(J),{field:"data",header:"Data"},{body:k(({data:f})=>[f.data?(o(!0),r(O,{key:0},te(f.data,(N,H)=>(o(),r("span",{key:H,class:"ExamUpdateLogsDialog__data-entry"},[e("span",el,i(H)+":",1),_(" "+i(N),1)]))),128)):E("",!0)]),_:1})]),_:1},8,["value"])]),_:1},8,["visible"])}}}),sl=ie(tl,[["__scopeId","data-v-01ac44da"]]),ll={key:0},al=["href"],ol={key:1},Ie=ne({__name:"TransferLogUser",props:{user:{}},setup(l){const t=l,d=ee(()=>{var s,n;return((s=t.user)==null?void 0:s.name)||`user id ${(n=t.user)==null?void 0:n.id}`});return(s,n)=>l.user?(o(),r("span",ll,[l.user.email?(o(),r("a",{key:0,href:m(_e)("teacher-info",{teacher:l.user.email})},i(d.value),9,al)):(o(),r("span",ol,i(d.value),1))])):E("",!0)}}),nl={key:0,class:"TransferLogExam"},il=["href"],rl={key:0,class:"TransferLogExam__deleted"},dl={key:1},ul=ne({__name:"TransferLogExam",props:{exam:{},currentExamId:{}},setup(l){return(t,d)=>l.exam?(o(),r("span",nl,[e("a",{href:m(_e)("exams-students",{key:l.exam.id}),class:de({TransferLogExam__current:l.exam.id===l.currentExamId})},i(l.exam.id),11,il),l.exam.deleted_at?(o(),r("span",rl," (deleted) ")):E("",!0)])):(o(),r("span",dl,"—"))}}),qe=ie(ul,[["__scopeId","data-v-59b82eb0"]]),cl={key:0},ml={class:"ExamTransferLogsDialog__batch"},hl=ne({__name:"ExamTransferLogsDialog",props:{examId:{},visible:{type:Boolean}},emits:["update:visible"],setup(l){const t=l,d=x([]);return Te(()=>t.visible,s=>j(null,null,function*(){if(!s)return;const n=yield F.get(`/api/site-admin/exam/${t.examId}/transfer-logs`);d.value=n.data}),{immediate:!0}),(s,n)=>(o(),I(Pe,{visible:l.visible,header:"Exam transfer logs",style:{width:"90vw",maxWidth:"1200px"},modal:"",dismissableMask:"","onUpdate:visible":n[0]||(n[0]=a=>s.$emit("update:visible",a))},{default:k(()=>[d.value.length===0?(o(),r("p",cl,"This exam has never been transferred.")):(o(),I(m(ge),{key:1,value:d.value,stripedRows:""},{default:k(()=>[u(m(J),{field:"created_at",header:"Transferred at"},{body:k(({data:a})=>[a.created_at?(o(),I(ye,{key:0,datetime:a.created_at},null,8,["datetime"])):E("",!0)]),_:1}),u(m(J),{header:"From"},{body:k(({data:a})=>[u(Ie,{user:a.from_user},null,8,["user"])]),_:1}),u(m(J),{header:"To"},{body:k(({data:a})=>[u(Ie,{user:a.to_user},null,8,["user"])]),_:1}),u(m(J),{header:"Started by"},{body:k(({data:a})=>[u(Ie,{user:a.transferred_by},null,8,["user"])]),_:1}),u(m(J),{header:"Transferred exam"},{body:k(({data:a})=>[u(qe,{exam:a.exam,currentExamId:l.examId},null,8,["exam","currentExamId"])]),_:1}),u(m(J),{header:"Copy kept by previous owner"},{body:k(({data:a})=>[u(qe,{exam:a.copy_exam,currentExamId:l.examId},null,8,["exam","currentExamId"])]),_:1}),u(m(J),{field:"batch_id",header:"Batch"},{body:k(({data:a})=>[e("span",ml,i(a.batch_id),1)]),_:1})]),_:1},8,["value"]))]),_:1},8,["visible"]))}}),pl=ie(hl,[["__scopeId","data-v-34d1c71b"]]),vl={key:0,class:"ExamHealthDialog__error"},fl=ne({__name:"ExamHealthDialog",props:{visible:{type:Boolean},checks:{},error:{}},emits:["update:visible"],setup(l){const t=l,d={error:0,warning:1,info:2,ok:3,not_applicable:4},s=ee(()=>[...t.checks].sort((n,a)=>{var p,y;return((p=d[n.severity])!=null?p:99)-((y=d[a.severity])!=null?y:99)}));return(n,a)=>(o(),I(Pe,{visible:l.visible,header:"Exam health checks",style:{width:"90vw",maxWidth:"950px"},modal:"",dismissableMask:"","onUpdate:visible":a[0]||(a[0]=p=>n.$emit("update:visible",p))},{default:k(()=>[l.error?(o(),r("div",vl,i(l.error),1)):(o(),r(O,{key:1},[a[1]||(a[1]=e("p",{class:"ExamHealthDialog__description"}
3," This health check performs some fast, automatic checks on the exam data to point out potential problems. The idea is to extend this further in the future. ",-1)),u(m(ge),{value:s.value},{default:k(()=>[u(m(J),{field:"name",header:"Check"}),u(m(J),{header:"Severity"},{body:k(({data:p})=>[p.severity==="ok"?(o(),I(Ue,{key:0,text:"OK",color:"green"})):p.severity==="not_applicable"?(o(),I(Ue,{key:1,text:"Not applicable",color:"gray"})):(o(),I(Ue,{key:2,text:p.severity,color:p.severity==="error"?"red":p.severity==="warning"?"yellow":"blue"},null,8,["text","color"]))]),_:1}),u(m(J),{field:"message",header:"Result"})]),_:1},8,["value"])],64))]),_:1},8,["visible"]))}}),gl=ie(fl,[["__scopeId","data-v-ae5e48b8"]]);function yl(l,t={}){var y;const d=(y=t.maxEntries)!=null?y:10,s=Ut.useReactive(l,[]);function n(h){const g=h.trim();if(!g)return;const V=s.value.filter(A=>A!==g);s.value=[g,...V].slice(0,d)}function a(h){s.value=s.value.filter(g=>g!==h)}function p(){s.value=[]}return{history:ee(()=>s.value),add:n,remove:a,clear:p}}const _l={key:0,class:"shortcut-slot"},bl={key:0,class:"history-empty"},xl={class:"history-list"},kl=["onClick"],wl={class:"history-footer"},Sl=ne({inheritAttrs:!1,__name:"SearchHistoryInput",props:{modelValue:{},storageKey:{},maxEntries:{},label:{}},emits:["update:modelValue","submit"],setup(l,{expose:t,emit:d}){const s=Qe,n=l,a=d,{history:p,add:y,clear:h}=yl(n.storageKey,{maxEntries:n.maxEntries}),g=x(null),V=x(null),A=`search-history-${n.storageKey}`,w=x(!1),c=ee({get:()=>n.modelValue,set:R=>a("update:modelValue",R)});function b(R){var z;(z=g.value)==null||z.toggle(R)}function f(R){var z;a("update:modelValue",R),y(R),(z=g.value)==null||z.hide(),a("submit")}function N(){var z;const R=(z=n.modelValue)==null?void 0:z.trim();R&&(a("update:modelValue",R),y(R),a("submit"))}function H(){var R,z;(z=(R=V.value)==null?void 0:R.$el)==null||z.focus()}return t({focus:H}),(R,z)=>{const P=Re("ignore-password-managers");return o(),I(Dt,Xt(Wt(R.$attrs)),{default:k(()=>[u(Os,{variant:"on"},{default:k(()=>[Z(u($t,{id:A,ref_key:"inputRef",ref:V,modelValue:c.value,"onUpdate:modelValue":z[0]||(z[0]=C=>c.value=C),autocomplete:"off",onKeyup:rt(N,["enter"]),onFocus:z[1]||(z[1]=C=>w.value=!0),onBlur:z[2]||(z[2]=C=>w.value=!1)},null,8,["modelValue"]),[[P]]),e("label",{for:A},i(l.label),1),R.$slots.shortcut?Z((o(),r("span",_l,[st(R.$slots,"shortcut",{},void 0,!0)],512)),[[ue,!w.value]]):E("",!0)]),_:3}),u(Nt,{class:"p-0"},{default:k(()=>[Z((o(),I(At,{severity:"secondary",variant:"text",size:"small",onClick:b},{default:k(()=>[u(ce,{svg:m(Rs),width:"var(--width-4)",color:"var(--gray-700)"},null,8,["svg"])]),_:1})),[[m(s),"History",void 0,{bottom:!0}]]),u(fs,{ref_key:"popoverRef",ref:g},{default:k(()=>[m(p).length===0?(o(),r("div",bl," No history yet ")):(o(),r(O,{key:1},[e("ul",xl,[(o(!0),r(O,null,te(m(p),C=>(o(),r("li",{key:C,class:"history-item"},[e("button",{type:"button",class:"history-entry",onClick:S=>f(C)},i(C),9,kl)]))),128))]),e("div",wl,[e("button",{type:"button",class:"history-clear",onClick:z[3]||(z[3]=(...C)=>m(h)&&m(h)(...C))}," Clear history ")])],64))]),_:1},512)]),_:1})]),_:3},16)}}}),Me=ie(Sl,[["__scopeId","data-v-c6762920"]]),El=ne({__name:"ShortcutTag",props:{value:{}},setup(l){return(t,d)=>{const s=Re("tooltip");return Z((o(),I(ut,{severity:"secondary",value:l.value,dt:{root:{padding:"0 var(--spacing-1)",fontSize:"var(--font-size-xs)"}},class:"ShortcutTag"},null,8,["value"])),[[s,"Keyboard shortcut"]])}}}),Xe=ie(El,[["__scopeId","data-v-a6679de7"]]);function Rt(l){return l instanceof HTMLInputElement||l instanceof HTMLTextAreaElement||l instanceof HTMLSelectElement||l instanceof HTMLElement&&l.isContentEditable}function Cl(){It(document,"keydown",l=>{l.key==="Escape"&&Rt(l.target)&&l.target.blur()})}function Pt(l){It(document,"keydown",t=>{if(t.metaKey||t.ctrlKey||t.altKey||Rt(t.target))return;const d=l[t.key];d&&(t.preventDefault(),d())})}function $l(l){if(l.length===0)return{name:"Unique IDs",severity:"not_applicable",message:"Builder exams only"};const t=Al(l),d=Tl(l),s=Dl(l),n=[...t.map(([a,p])=>`Question ID ${a} ×${p}`),...d.map(([a,p])=>`Sub-question ${a} ×${p}`),...s.map(([a,p])=>`Grading rule ID "${a}" duplicated in questions ${[...p].join(", ")}`)];return n.length===0?{name:"Unique IDs",severity:"ok",message:"All question, sub-question, and grading rule IDs are unique"}:{name:"Unique IDs",severity:"error",message:n.join(", ")}}function Al(l){const t=new Map;return l.forEach(d=>t.set(d.id,(t.get(d.id)||0)+1)),Array.from(t.entries()).filter(([,d])=>d>1)}function Tl(l){const t=new Map;return l.forEach(d=>{var s;return(s=d.subQuestions)==null?void 0:s.forEach(n=>{const a=`${d.id}:${n.id}`;t.set(a,(t.get(a)||0)+1)})}),Array.from(t.entries()).filter(([,d])=>d>1)}function Dl(l){const t=new Map;return l.forEach(d=>{var s;return Object.values((s=d.gradingRules)!=null?s:{}
3).forEach(n=>n.forEach(a=>{if(a.id!==void 0){const p=String(a.id);t.has(p)||t.set(p,new Set),t.get(p).add(d.id)}}))}),Array.from(t.entries()).filter(([,d])=>d.size>1)}function Nl(l,t={}){var a,p;const s=new Set;return l.forEach(y=>{var h;return(h=y.subQuestions)==null?void 0:h.forEach(g=>{var V;bt((V=g.question)!=null?V:"").forEach(A=>s.add(A))})}),[(a=t.text)!=null?a:"",...(p=t.documentPages)!=null?p:[]].filter(Boolean).forEach(y=>{bt(y).forEach(h=>s.add(h))}),s.size<=30?{name:"Distinct images",severity:"ok",message:`${s.size} distinct image(s) — Normal`}:{name:"Distinct images",severity:"warning",message:`${s.size} distinct images (limit: 30)`}}function bt(l){var s;const t=[];return((s=l.match(/<img[^>]+src="([^"]+)"/g))!=null?s:[]).forEach(n=>{var p;const a=(p=n.match(/src="([^"]+)"/))==null?void 0:p[1];a&&t.push(a)}),t}function Ll(l){if(l.length===0)return{name:"AI-generated questions",severity:"not_applicable",message:"Builder exams only"};const t=l.filter(n=>n.isAIGenerated).length,d=Math.round(t/l.length*100),s=`${d}% AI-generated (${t}/${l.length})`;return d<=50?{name:"AI-generated questions",severity:"ok",message:s}:{name:"AI-generated questions",severity:"info",message:s}}function Vl(l){if(l.length===0)return{name:"Point consistency",severity:"not_applicable",message:"Builder exams only"};const t=new Set;let d=0;return l.forEach(s=>{var n;(n=s.subQuestions)==null||n.forEach(a=>{var g,V;const p=(V=(g=s.gradingRules)==null?void 0:g[a.id])!=null?V:[];if(p.length===0)return;const y=p.reduce((A,w)=>{var c;return A+Number((c=w.point)!=null?c:0)},0),h=Number(a.point);!Number.isFinite(h)||!Number.isFinite(y)||h!==y&&(t.add(s.id),d+=Math.abs(h-y))})}),t.size===0?{name:"Point consistency",severity:"ok",message:"All sub-question points match their grading rules"}:{name:"Point consistency",severity:"error",message:`Detected mismatch between question points and sum of grading rule points in Question ${[...t].join(", ")}. Total differences of ${d} points. Re-save the affected question(s) in the exam creator to fix it.`}}const Bt=Lt("examHealth",()=>{const l=x(null),t=x([]),d=x({}),s=x(!1),n=x(null),a=x([]),p=ee(()=>a.value.some(A=>A.severity==="error")?"error":a.value.some(A=>A.severity==="warning")?"warning":a.value.some(A=>A.severity==="info")?"info":"ok");function y(){l.value=null,t.value=[],d.value={},s.value=!1,n.value=null,a.value=[]}function h(A){a.value.push(A)}function g(A){return j(this,null,function*(){var w,c;y(),l.value=A,s.value=!0;try{const b=yield F.get(`/api/site-admin/exam/${A}/builder-content`);return d.value=(w=b.data.examContent)!=null?w:{},t.value=((c=b.data.questions)!=null?c:[]).map(f=>{var H,R,z;const N=f.version.data?JSON.parse(f.version.data):{};return{id:f.version.question_id,subQuestions:(H=N.subQuestions)!=null?H:[],gradingRules:(R=N.gradingRules)!=null?R:{},isAIGenerated:(z=N.isAIGenerated)!=null?z:!1}}),!0}catch(b){return n.value="Failed to load exam data",!1}finally{s.value=!1}})}function V(A){return j(this,null,function*(){try{if(!(yield g(A)))return;h(Nl(t.value,d.value)),h($l(t.value)),h(Ll(t.value)),h(Vl(t.value))}catch(w){console.error("Exam health checks failed unexpectedly",w)}})}return{examId:l,questions:t,examContent:d,isFetching:s,fetchError:n,checks:a,overallStatus:p,reset:y,appendCheck:h,run:V}}),Ot=Lt("supportHelpers",()=>{const l=Bt(),t=x(""),d=x(null),s=x([]),n=x(null),a=x([]),p=x(null),y=x(null),h=x([]),g=x(""),V=x(""),{input:A,search:w,clear:c}=$e("exams-students","key",{onSearch:T,onClear:v}),{input:b,search:f,clear:N}=$e("exams-students","name",{onSearch:M,onClear:v}),{input:H,search:R,clear:z}=$e("exams-students","student",{onSearch:Y,onClear:v});function P(X){return a.value.some($=>Number($.student_id)===Number(X))}function C(X){R(String(X))}function S(){c(),N(),z(),v()}function v(){t.value="",d.value=null,s.value=[],n.value=null,a.value=[],p.value=null,y.value=null,h.value=[]}function T(X){return j(this,null,function*(){var D;n.value=null,t.value="exam",d.value=null,p.value=null;const $=yield F.get(`/api/site-admin/exam/${window.encodeURIComponent(X)}`);d.value=$.data.exam,a.value=$.data.gradings,p.value=(D=$.data.copiedFrom)!=null?D:null,l.run($.data.exam.id)})}function M(X){return j(this,null,function*(){try{const $=yield F.get(`/api/site-admin/students/by-name?query=${X}`);t.value="students",s.value=$.data}catch($){t.value="students",y.value=$.response.data.errors.query[0],s.value=null}})}function Y(X){return j(this,null,function*(){t.value="student",n.value=null;const $=yield F.get(`/api/site-admin/students/${X}`);n.value=$.data.student,Number($.data.student.is_kunskapsmatrisen)===1&&(g.value=`km-${$.data.student.exam_id}`,V.value=$.data.backupJWT,oe())})}function K(X){return j(this,null,function*(){const $=a.value.find(D=>Number(D.student_id)===Number(X));$&&(yield F.post(`/api/site-admin/student-grading/${$.id}/invalidate`))})}function Q(X){return j(this,null,function*(){const $=yield F.get(`/admin/students/${X}`);n.value=$.data.student})}function oe(){return j(this,null,function*(){if(!n.value)return;const X=yield F.get(`/api/student/${n.value.id}/backups`),{individualEncryptionKey:$,backups:D}=X.data,q=(yield gs.studentBackups(n.value.id,$,g.value,V.value)).map(se=>({id:se.url,created_at:se.timeCreated,student_answer:se.data&&se.data.answer})).filter(se=>se.student_answer);h.value=[...D,...q].sort((se,ae)=>
3window.moment.utc(ae.created_at).diff(window.moment.utc(se.created_at)))})}return{type:t,exam:d,students:s,student:n,gradings:a,copiedFrom:p,error:y,backups:h,bucket:g,backupJWT:V,examkey:A,studentName:b,studentId:H,hasGrading:P,searchByExamKeyOrId:w,studentByFullName:f,studentInfo:C,invalidateGrading:K,fetchStudent:Q,resetSearches:S}}),Ul={ok:{icon:Tt,color:"gray"},error:{icon:ot,color:"red"},warning:{icon:_s,color:"yellow"},info:{icon:ys,color:"blue"}};function Il(l,t){var d;return t?{icon:ot,color:"red"}:(d=Ul[l])!=null?d:{icon:ot,color:"red"}}const Ml={class:"container mt-4"},Rl={class:"gap-6 grid grid-cols-3 lg:grid-cols-3 mb-14 md:grid-cols-3 sm:grid-cols-3"},Pl={class:"bg-white col-span-1 flex flex-col rounded-lg shadow text-center"},Bl={class:"flex flex-1 flex-col gap-3 items-baseline p-3"},Ol={class:"bg-white col-span-1 flex flex-col rounded-lg shadow text-center"},Fl={class:"flex flex-1 flex-col gap-3 items-baseline p-3"},Hl={class:"bg-white col-span-1 flex flex-col rounded-lg shadow text-center"},Gl={class:"flex flex-1 flex-col gap-3 items-baseline p-3"},zl={class:"bg-white overflow-hidden shadow sm:rounded-lg"},Kl={key:0,class:"border-b border-gray-200 px-4 py-5 sm:px-6"},Xl={class:"alert alert-danger"},Wl={class:"border-b border-gray-200"},Yl={key:0,class:"overflow-x-auto"},jl={class:"table table-hover table-striped whitespace-nowrap"},ql={key:0},Ql=["onClick"],Jl={key:1},Zl={class:"bg-gray-100 inline-block px-2 py-1 rounded-full text-gray-700 text-xs"},ea={class:"bg-gray-100 inline-block px-2 py-1 rounded-full text-gray-700 text-xs"},ta={class:"bg-gray-100 inline-block px-2 py-1 rounded-full text-gray-700 text-xs"},sa={key:0},la={key:1,class:"alert alert-info"},aa={key:1,class:"border-b border-gray-200 px-4 py-5 sm:px-6"},oa={key:0},na={key:0,class:"mt-6"},ia={class:"bg-white overflow-hidden shadow sm:rounded-md"},ra=["onClick"],da={class:"flex items-center px-4 py-4 sm:px-6"},ua={class:"flex-1 min-w-0 sm:flex sm:items-center sm:justify-between"},ca={class:"font-medium leading-5 text-indigo-600 text-xs truncate"},ma={key:1},ha={key:0},pa={class:"divide-gray-200 divide-y"},va=["onClick"],fa={class:"cursor-pointer font-medium leading-5 px-6 py-4 text-gray-900 text-xs whitespace-no-wrap"},ga={class:"cursor-pointer font-medium leading-5 px-6 py-4 text-gray-900 text-xs whitespace-no-wrap"},ya={class:"cursor-pointer font-medium leading-5 px-6 py-4 text-gray-900 text-xs whitespace-no-wrap"},_a={class:"cursor-pointer font-medium leading-5 px-6 py-4 text-gray-900 text-xs whitespace-no-wrap"},ba={class:"cursor-pointer font-medium leading-5 px-6 py-4 text-gray-900 text-xs whitespace-no-wrap"},xa={key:1,style:{"margin-bottom":"10px"}},ka=["href"],wa=["href"],Sa=["href"],Ea=["href"],Ca={key:2},$a=["href"],Aa={key:1},Ta={key:0,class:"flex gap-1 items-center"},Da={key:0,class:"text-orange-600"},Na=["href"],La={key:1,class:"text-orange-600"},Va={key:2,class:"mt-3"},Ua={class:"flex gap-3 mt-3"},Ia=["href"],Ma={class:"flex flex-col",style:{margin:"auto"}},Ra={class:"lg:-mx-8 mt-8 overflow-x-auto sm:-mx-6"},Pa={class:"align-middle inline-block lg:px-8 py-2 sm:px-6"},Ba={class:"border-b border-gray-200 overflow-hidden shadow sm:rounded-lg"},Oa={class:"divide-gray-200 divide-y"},Fa=["onClick"],Ha={class:"font-medium leading-5 px-6 py-4 text-gray-900 text-xs whitespace-no-wrap"},Ga={key:0},za={class:"font-medium leading-5 px-6 py-4 text-gray-900 text-xs whitespace-no-wrap"},Ka={class:"leading-5 px-6 py-4 text-gray-500 text-xs whitespace-no-wrap"},Xa={class:"leading-5 px-6 py-4 text-gray-500 text-xs whitespace-no-wrap"},Wa={class:"leading-5 px-6 py-4 text-gray-500 text-xs whitespace-no-wrap"},Ya=["onClick"],ja={style:{display:"flex"}},qa={style:{flex:"1"}},Qa=["onClick"],Ja={style:{flex:"1"}},Za={key:0},eo=ne({__name:"SupportHelpers",setup(l){const t=Bt(),d=Ot(),{type:s,exam:n,students:a,student:p,copiedFrom:y,error:h,backups:g,examkey:V,studentName:A,studentId:w}=bs(d),c=x(!1),b=x(!1),f=x(!1),N=x(null),H=x(null),R=x(null),z={examkey:{key:"1",input:N},studentName:{key:"2",input:H},studentId:{key:"3",input:R}};Pt(Object.fromEntries(Object.values(z).map(({key:ae,input:W})=>[ae,()=>{var L;return(L=W.value)==null?void 0:L.focus()}])));const P=We.isProduction()?"exam-net-backups":"exam-net-additional-backups",C=`https://console.firebase.google.com/project/${Gs().options.projectId}/storage/${P}/files/~2F${window.K$.ENV}~2Fexams~2F`,S=ee(()=>Il(t.overallStatus,t.fetchError)),v=ae=>ae.origin==="gauss"?{text:"KM",color:"green"}:{text:"Exam.net",color:"blue"},T=ee(()=>{var W,L,pe;return(pe={owned:"The teacher duplicated one of their own exams.",shared:"The teacher duplicated an exam that another teacher shared with them.",link:"The exam was copied by following an exam template link.",inspiration:"The teacher copied an exam from the exam inspiration widget.",onboarding:"The exam was created automatically as an example exam when the teacher onboarded."}
3[(L=(W=y.value)==null?void 0:W.type)!=null?L:""])!=null?pe:"The exam was created as a copy of another exam."});function M(){d.searchByExamKeyOrId(V.value)}function Y(){d.studentByFullName(A.value)}function K(ae){d.studentInfo(ae)}function Q(ae){return j(this,null,function*(){yield d.invalidateGrading(ae.id),M()})}function oe(ae){return d.hasGrading(ae.id)}function X(ae){d.fetchStudent(ae.id)}function $(){y.value&&(V.value=String(y.value.origin_exam.id),M())}function D(ae){ae.exam&&window.open(`/admin/exams/${ae.exam.id}?student=${ae.id}`,"_blank")}function q(ae){return Mt.json(ae.content).choice==="builder"?"Auto-marked exam":ae.writeArea?"Text based exam":"Tool exam (no writing area)"}function se(ae){var L;const W=window.open();W&&(W.document.body.innerText=(L=ae.student_answer)!=null?L:"")}return(ae,W)=>(o(),r("div",Ml,[e("ul",Rl,[e("li",Pl,[e("div",Bl,[u(Me,{ref_key:"examkeyInput",ref:N,modelValue:m(V),"onUpdate:modelValue":W[0]||(W[0]=L=>He(V)?V.value=L:null),storageKey:"admin-exam-search-history",label:"Examkey or id",class:"w-full",onSubmit:M},{shortcut:k(()=>[u(Xe,{value:z.examkey.key},null,8,["value"])]),_:1},8,["modelValue"])])]),e("li",Ol,[e("div",Fl,[u(Me,{ref_key:"studentNameInput",ref:H,modelValue:m(A),"onUpdate:modelValue":W[1]||(W[1]=L=>He(A)?A.value=L:null),storageKey:"admin-student-name-search-history",label:"Student first- and last name",class:"w-full",onSubmit:Y},{shortcut:k(()=>[u(Xe,{value:z.studentName.key},null,8,["value"])]),_:1},8,["modelValue"])])]),e("li",Hl,[e("div",Gl,[u(Me,{ref_key:"studentIdInput",ref:R,modelValue:m(w),"onUpdate:modelValue":W[2]||(W[2]=L=>He(w)?w.value=L:null),storageKey:"admin-student-id-search-history",label:"Student id in Exam.net",class:"w-full",onSubmit:W[3]||(W[3]=L=>K(m(w)))},{shortcut:k(()=>[u(Xe,{value:z.studentId.key},null,8,["value"])]),_:1},8,["modelValue"])])])]),e("div",zl,[m(s)==="students"&&m(h)&&!m(a)?(o(),r("div",Kl,[e("div",Xl,i(m(h)),1)])):E("",!0),e("div",Wl,[m(s)==="students"&&m(a)?(o(),r("div",Yl,[e("table",jl,[W[10]||(W[10]=e("thead",null,[e("tr",{class:"bg-gray-50 text-gray-500 text-xs"},[e("th",{class:"font-medium rounded-tl-lg"},"Name"),e("th",{class:"font-medium"},"Exam key"),e("th",{class:"font-medium"},"Product"),e("th",{class:"font-medium"},[_("Student"),e("br"),_("created at")]),e("th",{class:"font-medium"},[_("Student"),e("br"),_("last updated at")]),e("th",{class:"font-medium"},[_("Exam"),e("br"),_("created at")]),e("th",{class:"font-medium"},"Teacher"),e("th",{class:"font-medium"},"School (owner)"),e("th",{class:"font-medium"},"Teacher's school"),e("th",{class:"rounded-tr-lg"})])],-1)),m(a).length>0?(o(),r("tbody",ql,[(o(!0),r(O,null,te(m(a),L=>(o(),r("tr",{key:L.id,style:ke(L.exam&&`${L.exam.examkey}#${L.resume_pin}`===m(V)?"background-color: orange":"")},[e("td",null,[L.exam?(o(),r("a",{key:0,class:"cursor-pointer hover:text-blue-600 underline",onClick:pe=>D(L)},i(m(Ee).displayName(L)),9,Ql)):(o(),r("span",Jl,i(m(Ee).displayName(L)),1))]),e("td",null,i(L.exam&&L.exam.examkey)+"#"+i(L.resume_pin),1),e("td",null,[u(Ue,wt({ref_for:!0},v(L)),null,16)]),e("td",null,[e("span",Zl,[u(ye,{datetime:L.created_at},null,8,["datetime"])])]),e("td",null,[e("span",ea,[u(ye,{datetime:L.updated_at},null,8,["datetime"])])]),e("td",null,[e("span",ta,[u(ye,{datetime:L.exam&&L.exam.created_at},null,8,["datetime"])])]),e("td",null,i(L.exam&&L.exam.teacher&&L.exam.teacher.firstName)+" "+i(L.exam&&L.exam.teacher&&L.exam.teacher.lastName),1),e("td",null,i(L.exam&&(L.exam.school?L.exam.school.namn:L.exam.teacher&&L.exam.teacher.school&&L.exam.teacher.school.namn)),1),e("td",null,i(L.exam&&L.exam.teacher&&L.exam.teacher.school&&L.exam.teacher.school.namn),1),e("td",null,[L.deleted_at?(o(),r("span",sa,"Deleted")):E("",!0)])],4))),128))])):(o(),r("div",la," No results. "))])])):E("",!0)]),m(s)==="student"&&m(p)||m(s)==="exam"&&m(n)?(o(),r("div",aa,[m(s)==="student"&&m(p)?(o(),r("div",oa,[_(i(m(p))+" ",1),m(p).is_kunskapsmatrisen==1?(o(),r("div",na,[W[12]||(W[12]=e("h1",{class:"font-extrabold leading-8 mb-8 mt-2 sm:leading-10 sm:text-2xl text-center text-gray-900 text-lg tracking-tight"}," Firebase file backups for KM-student ",-1)),e("div",ia,[e("ul",null,[(o(!0),r(O,null,te(m(g),L=>(o(),r("li",{key:L.id},[e("a",{href:"#",class:"block duration-150 ease-in-out focus:bg-gray-50 focus:outline-none hover:bg-gray-50 no-underline transition",onClick:ve(pe=>se(L),["prevent"])},[e("div",da,[e("div",ua,[e("div",null,[u(ye,{datetime:L.created_at},null,8,["datetime"]),e("div",ca,i(L.id),1)])]),W[11]||(W[11]=e("div",{class:"flex-shrink-0 ml-5"},[e("svg",{class:"h-5 text-gray-400 w-5",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},[e("path",{"fill-rule":"evenodd",d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z","clip-rule":"evenodd"})])],-1))])],8,ra)]))),128))])])])):E("",!0)])):E("",!0),m(s)==="exam"&&m(n)?(o(),r("div",ma,[m(n)&&m(n).isKunskapsmatrisen?(o(),r("div",ha,[e("div",null,"KM exam, id: "+i(m(n).id),1),e("table",pa,[e("tbody",null,[(o(!0),r(O,null,te(m(n).students,(L,pe)=>(o(),r("tr",{key:L.id,class:de(["bg-white",{"bg-gray-50":pe%2}]),onClick:G=>K(L.id)},[e("td",fa,i(L.id),1),e("td",ga,i(L.firstName)+" "+i(L.lastName),1),e("td",y
3a,i(L.email),1),e("td",_a,i(L.security),1),e("td",ba,i(L.created_at),1)],10,va))),128))])])])):m(n)?(o(),r("div",xa,[e("div",null,[W[13]||(W[13]=e("span",{class:"font-bold"},"Teacher: ",-1)),_(" "+i(m(n).teacher.firstName)+" "+i(m(n).teacher.lastName)+" ("+i(m(n).teacher.email)+", id: ",1),e("a",{href:m(_e)("teacher-info",{teacher:m(n).teacher.email})},i(m(n).teacher.id),9,ka),W[14]||(W[14]=_(" ) ",-1)),e("a",{href:`/admin/impersonate/${m(n).teacher.email}`,target:"_blank"}," Impersonate ",8,wa)]),e("div",null,[W[15]||(W[15]=e("span",{class:"font-bold"},"School (exam owner): ",-1)),m(n).school?(o(),r("a",{key:0,href:m(_e)("manage-schools",{school:m(n).school_id})},i(m(n).school.namn)+" ("+i(m(n).school_id)+")",9,Sa)):m(n).teacher.school?(o(),r("a",{key:1,href:m(_e)("manage-schools",{school:m(n).teacher.school_id})},i(m(n).teacher.school.namn)+" ("+i(m(n).teacher.school_id)+")",9,Ea)):(o(),r("span",Ca,"No school"))]),e("div",null,[W[16]||(W[16]=e("span",{class:"font-bold"},"Teacher's school: ",-1)),m(n).teacher.school?(o(),r("a",{key:0,href:m(_e)("manage-schools",{school:m(n).teacher.school_id})},i(m(n).teacher.school.namn)+" ("+i(m(n).teacher.school_id)+")",9,$a)):(o(),r("span",Aa,"No school"))]),e("div",null,[W[17]||(W[17]=e("span",{class:"font-bold"},"Exam id: ",-1)),_(" "+i(m(n).id),1)]),e("div",null,[W[18]||(W[18]=e("span",{class:"font-bold"},"Exam key:",-1)),_(" "+i(m(n).examkey)+" ("+i(q(m(n)))+") ",1)]),e("div",null,[W[19]||(W[19]=e("span",{class:"font-bold"},"Exam name:",-1)),_(" "+i(m(n).name),1)]),e("div",null,[W[20]||(W[20]=e("span",{class:"font-bold"},"Product:",-1)),_(" "+i(m(n).origin==="gauss"?"KM2 / Maths":"Exam.net"),1)]),m(y)?(o(),r("div",Ta,[W[21]||(W[21]=e("span",{class:"font-bold"},"Copied from:",-1)),e("a",{class:"cursor-pointer hover:text-blue-600 underline",onClick:$},[m(y).origin_exam.name?(o(),r(O,{key:0},[_(i(m(y).origin_exam.name)+" (id: "+i(m(y).origin_exam.id)+")",1)],64)):(o(),r(O,{key:1},[_("exam id "+i(m(y).origin_exam.id),1)],64))]),m(y).origin_exam.deleted_at?(o(),r("span",Da," (deleted) ")):E("",!0),e("span",null,"— "+i(m(y).type)+" copy",1),u(vs,{label:T.value},null,8,["label"]),u(ye,{datetime:m(y).copied_at},null,8,["datetime"])])):E("",!0),e("div",null,[W[22]||(W[22]=e("span",{class:"font-bold"},"Backup bucket: ",-1)),e("a",{target:"_blank",href:`${C}${m(n).bucket.toUpperCase()}/students`},i(m(n).bucket),9,Na)]),m(n).deleted_at?(o(),r("div",La,[W[23]||(W[23]=e("span",{class:"font-bold"},"Deleted!",-1)),_(" "+i(m(n).deleted_at),1)])):E("",!0),m(t).checks.length>0||m(t).fetchError?(o(),r("div",Va,[u(Ue,{text:!m(t).fetchError&&m(t).overallStatus==="ok"?"No automatic issues detected":"Automatic issues detected",color:S.value.color,style:{cursor:"pointer"},onClick:W[4]||(W[4]=L=>f.value=!0)},{icon:k(()=>[u(ce,{width:"14px",svg:S.value.icon},null,8,["svg"])]),_:1},8,["text","color"])])):E("",!0),e("div",Ua,[e("a",{target:"_admin",href:`/admin/exams/${m(n).id}`},[u(re,{label:"Open monitoring view for exam"})],8,Ia),u(re,{label:"Show update logs",onClick:W[5]||(W[5]=L=>c.value=!0)}),u(re,{label:"Show transfer logs",onClick:W[6]||(W[6]=L=>b.value=!0)})]),u(sl,{visible:c.value,"onUpdate:visible":W[7]||(W[7]=L=>c.value=L),examId:m(n).id},null,8,["visible","examId"]),u(pl,{visible:b.value,"onUpdate:visible":W[8]||(W[8]=L=>b.value=L),examId:m(n).id},null,8,["visible","examId"]),u(gl,{visible:f.value,"onUpdate:visible":W[9]||(W[9]=L=>f.value=L),checks:m(t).checks,error:m(t).fetchError},null,8,["visible","checks","error"]),e("div",Ma,[e("div",Ra,[e("div",Pa,[e("div",Ba,[e("table",Oa,[W[24]||(W[24]=e("thead",null,[e("tr",null,[e("th",{class:"bg-gray-50 font-medium leading-4 px-6 py-3 text-gray-500 text-left text-xs tracking-wider uppercase"}," Id "),e("th",{class:"bg-gray-50 font-medium leading-4 px-6 py-3 text-gray-500 text-left text-xs tracking-wider uppercase"}," Student "),e("th",{class:"bg-gray-50 font-medium leading-4 px-6 py-3 text-gray-500 text-left text-xs tracking-wider uppercase"}," Examkey "),e("th",{class:"bg-gray-50 font-medium leading-4 px-6 py-3 text-gray-500 text-left text-xs tracking-wider up
3percase"}," Created "),e("th",{class:"bg-gray-50 font-medium leading-4 px-6 py-3 text-gray-500 text-left text-xs tracking-wider uppercase"}," Security "),e("th",{class:"bg-gray-50 font-medium leading-4 px-6 py-3 text-gray-500 text-left text-xs tracking-wider uppercase"}," Marking ")])],-1)),e("tbody",null,[(o(!0),r(O,null,te(m(n).students,(L,pe)=>(o(),r("tr",{key:L.id,class:de(["bg-white",{"bg-gray-50":pe%2}]),style:ke(`${m(n).examkey}#${L.resume_pin}`===m(V)?"background-color: orange":"")},[e("td",{class:"cursor-pointer font-medium leading-5 px-6 py-4 text-gray-900 text-xs whitespace-no-wrap",onClick:G=>K(L.id)},i(L.id),9,Fa),e("td",Ha,[_(i(m(Ee).displayName(L))+" ",1),L.email?(o(),r("span",Ga,"("+i(L.email)+")",1)):E("",!0)]),e("td",za,i(m(n).examkey)+"#"+i(L.resume_pin),1),e("td",Ka,i(L.created_at),1),e("td",Xa,i(L.security),1),e("td",Wa,[oe(L)?(o(),r("button",{key:0,type:"button",class:"bg-red-600 border border-transparent duration-150 ease-in-out focus:border-red-700 focus:outline-none focus:shadow-outline-red font-medium hover:bg-red-500 inline-flex justify-center leading-6 px-4 py-2 rounded-md shadow-sm sm:leading-5 sm:text-xs text-sm text-white transition w-full",onClick:G=>Q(L)}," Reset marking ",8,Ya)):E("",!0)])],6))),128))])])])])])])])):E("",!0),e("div",ja,[e("div",qa,[(o(!0),r(O,null,te(m(a),L=>(o(),r("div",{key:L.id},[e("span",{onClick:pe=>X(L)},i(m(Ee).displayName(L))+" ("+i(L.id)+")",9,Qa)]))),128))]),e("div",Ja,[m(p)?(o(),r("div",Za,[e("div",null,i(m(Ee).displayName(m(p)))+" ("+i(m(p).id)+")",1),e("div",null,"Backups: "+i(m(p).backups.length),1),e("div",null,"DeniedSaves: "+i(m(p).denied_saves.length),1),e("div",null,"OfflineSaves: "+i(m(p).offline_saves.length),1),e("div",null,[W[25]||(W[25]=_(" Student Logs ",-1)),(o(!0),r(O,null,te(m(p).student_logs,L=>(o(),r("p",{key:L.id},i(L.type),1))),128))])])):E("",!0)])])])):E("",!0)])):E("",!0)])]))}}),to={class:"ClientBlocking mt-4 px-4 w-full"},so={class:"mb-6"},lo={class:"flex gap-4 mt-3 text-xs"},ao={key:0,class:"alert alert-danger"},oo={key:1,class:"text-gray-500"},no={class:"flex gap-2 items-baseline mb-2"},io={class:"font-bold text-gray-900"},ro={class:"text-gray-400 text-xs"},uo={class:"ClientBlocking__scroll"},co={class:"font-medium text-gray-900"},mo={class:"text-center"},ho={class:"mt-10"},po={key:0,class:"alert alert-danger"},vo={key:1,class:"text-gray-500 text-sm"},fo={key:2,class:"ClientBlocking__scroll"},go={class:"font-semibold text-gray-700"},yo={class:"text-center text-gray-700"},_o={class:"ClientBlocking__bars"},bo=["title"],xo={class:"ClientBlocking__barLabel"},ko={class:"ClientBlocking__barValue"},xt="Total",Ze=500,wo=ne({__name:"ClientBlocking",setup(l){function t(T){return{height:"1.1rem",borderRadius:"0.25rem",colorScheme:{light:{background:"{surface.100}",value:{background:T}}}}}const d=[{count:"blocked",percent:"blockedPercent",label:"Blocked",dt:t("{red.500}")},{count:"warned",percent:"warnedPercent",label:"Warned",dt:t("{yellow.400}")}],s=[{status:"OK",label:"Allowed"},{status:"WARNING",label:"Warned"},{status:"BLOCK",label:"Blocked"}],n={OK:"Allowed",WARNING:"Warned",BLOCK:"Blocked"},a={OK:"bg-green-100 text-green-800",WARNING:"bg-yellow-100 text-yellow-800",BLOCK:"bg-red-100 text-red-800"},p={recommended:"Recommended (default)","all-supported":"Allow all supported"},y=x([]),h=x(null),g=x(!0),V=x(!1),A=x(null),w=x(null);function c(T){var M;return(M=n[T])!=null?M:T}function b(T){var M;return(M=a[T])!=null?M:"bg-gray-100 text-gray-700"}function f(T){var M;return(M=p[T])!=null?M:T}function N(T){return T==="low"?`↓ Low sample size (under ${Ze}) ↓`:`≥ ${Ze} samples`}function H(T){return T.browser===xt?"ClientBlocking__totalRow":""}const R=ee(()=>{var T,M;return(M=(T=h.value)==null?void 0:T.rules)!=null?M:[]}),z=ee(()=>({rowGroupHeaderCell:{colspan:2+R.value.length}})),P=ee(()=>{var T,M;return[...(M=(T=h.value)==null?void 0:T.rows)!=null?M:[]].sort((Y,K)=>K.sample-Y.sample).map(Y=>xe(be({},Y),{band:Y.sample>=Ze?"high":"low"}))});function C(T){return T.rows.map(M=>M.version)}function S(T){return T.rules.map(M=>{const Y={};for(const K of T.rows)Y[K.version]=K.statuses[M];return{ruleLabel:f(M),statuses:Y}})}function v(){return j(this,null,function*(){var T,M,Y,K;V.value=!0,A.value=null;try{const{data:Q}=yield F.get("/api/site-admin/client-blocking/stats");h.value=(T=Q.stats)!=null?T:null}
3catch(Q){A.value=(K=(Y=(M=Q==null?void 0:Q.response)==null?void 0:M.data)==null?void 0:Y.message)!=null?K:"Failed to load traffic impact stats."}finally{V.value=!1}})}return De(()=>j(null,null,function*(){var T,M,Y;try{const{data:K}=yield F.get("/api/site-admin/client-blocking/matrix");y.value=K.matrix}catch(K){w.value=(Y=(M=(T=K==null?void 0:K.response)==null?void 0:T.data)==null?void 0:M.message)!=null?Y:"Failed to load client blocking matrix."}finally{g.value=!1}v()})),(T,M)=>(o(),r("div",to,[e("div",so,[M[0]||(M[0]=e("h1",{class:"font-extrabold text-gray-900 text-xl tracking-tight"},"Client Blocking",-1)),M[1]||(M[1]=e("p",{class:"mt-1 text-gray-500 text-sm"},[_(" How "),e("code",null,"config/browser_versions.php"),_(" affects each released client version. Read-only — this reflects the current config and does not change enforcement. ")],-1)),e("div",lo,[(o(),r(O,null,te(s,Y=>e("span",{key:Y.status,class:"flex gap-1 items-center"},[e("span",{class:de([b(Y.status),"ClientBlocking__swatch"])},null,2),_(" "+i(Y.label),1)])),64))])]),w.value?(o(),r("div",ao,i(w.value),1)):g.value?(o(),r("div",oo," Loading… ")):(o(),r(O,{key:2},[M[4]||(M[4]=e("h2",{class:"font-bold mb-1 text-gray-900"},"Action per client version",-1)),M[5]||(M[5]=e("p",{class:"mb-4 text-gray-500 text-sm"},"The action taken for each released client version under each policy.",-1)),(o(!0),r(O,null,te(y.value,Y=>(o(),r("div",{key:Y.client,class:"mb-8"},[e("div",no,[e("span",io,i(Y.label),1),e("span",ro,i(Y.client)+" → "+i(Y.browserKey),1)]),e("div",uo,[u(m(ge),{value:S(Y),size:"small",showGridlines:"",stripedRows:"",class:"text-sm",tableStyle:"width: max-content"},{default:k(()=>[u(m(J),{header:"Policy",headerStyle:"width: 13rem",style:{width:"13rem"}},{body:k(({data:K})=>[e("span",co,i(K.ruleLabel),1)]),_:1}),(o(!0),r(O,null,te(C(Y),K=>(o(),I(m(J),{key:K,header:K,headerStyle:"width: 5.5rem",headerClass:"text-center",style:{width:"5.5rem"}},{body:k(({data:Q})=>[e("div",mo,[e("span",{class:de([b(Q.statuses[K]),"ClientBlocking__cell"])},i(c(Q.statuses[K])),3)])]),_:2},1032,["header"]))),128))]),_:2},1032,["value"])])]))),128)),e("div",ho,[M[2]||(M[2]=e("h2",{class:"font-bold mb-1 text-gray-900"},"Impact",-1)),M[3]||(M[3]=e("p",{class:"mb-3 text-gray-500 text-sm"},[_(" How each policy would affect the "),e("code",null,"tests/Data/user_agents.csv"),_(" sample (a Front Door export). Undetected = the client/version could not be identified. ")],-1)),A.value?(o(),r("div",po,i(A.value),1)):V.value?(o(),r("div",vo," Computing impact… ")):h.value?(o(),r("div",fo,[u(m(ge),{value:P.value,rowClass:H,pt:z.value,rowGroupMode:"subheader",groupRowsBy:"band",size:"small",showGridlines:"",class:"text-sm",tableStyle:"width: 100%"},{groupheader:k(({data:Y})=>[e("span",go,i(N(Y.band)),1)]),default:k(()=>[u(m(J),{header:"Browser",headerStyle:"width: 13rem",style:{width:"13rem"}},{body:k(({data:Y})=>[e("span",{class:de(["text-gray-900",Y.browser===xt?"font-bold":"font-medium"])},i(Y.browser),3)]),_:1}),u(m(J),{header:"Sample",headerClass:"text-center"},{body:k(({data:Y})=>[e("div",yo,i(Y.sample.toLocaleString())+" ("+i(Y.samplePercent)+"%)",1)]),_:1}),(o(!0),r(O,null,te(R.value,Y=>(o(),I(m(J),{key:Y,header:f(Y)},{body:k(({data:K})=>[e("div",_o,[(o(),r(O,null,te(d,Q=>e("div",{key:Q.count,class:"ClientBlocking__bar",title:`${K.rules[Y][Q.count].toLocaleString()} of ${K.sample.toLocaleString()} ${Q.label.toLowerCase()}`},[e("span",xo,i(Q.label),1),u(Vs,{value:K.rules[Y][Q.percent],showValue:!1,dt:Q.dt},null,8,["value","dt"]),e("span",ko,i(K.rules[Y][Q.count].toLocaleString())+" ("+i(K.rules[Y][Q.percent])+"%) ",1)],8,bo)),64))])]),_:2},1032,["header"]))),128))]),_:1},8,["value","pt"])])):E("",!0)])],64))]))}}),So=ie(wo,[["__scopeId","data-v-2aa9c4ca"]]),Eo={makeChart(l){const{id:t,chart:d,data:s}=l,n=document.getElementById(t).getContext("2d");d&&d.destroy();const a={EXAM_CREATED:[],EXAM_STARTED:[],USER_LOGIN:[]},p=1440*60*1e3;let y=new Date;y=new Date(y.getFullYear()+"-"+("0"+(y.getMonth()+1)).slice(-2)+"-"+("0"+y.getDate()).slice(-2)),s.forEach(A=>{const w=new Date(A.date),c=(y.getTime()-w.getTime())/p;a[A.type]!==void 0&&(a[A.type][c]===void 0&&(a[A.type][c]=0),a[A.type][c]+=A.value)});const h=Math.max(a.EXAM_CREATED.length,a.EXAM_STARTED.length,a.USER_LOGIN.length),g=[],V=new Date;for(let A=0;A<h;A++)g.unshift(V.toISOString().slice(0,10)),V.setDate(V.getDate()-1),a.EXAM_CREATED[A]===void 0&&(a.EXAM_CREATED[A]=0),a.EXAM_STARTED[A]===void 0&&(a.EXAM_STARTED[A]=0),a.USER_LOGIN[A]===void 0&&(a.USER_LOGIN[A]=0);return a.EXAM_CREATED=a.EXAM_CREATED.reverse(),a.EXAM_STARTED=a.EXAM_STARTED.reverse(),a.USER_LOGIN=a.USER_LOGIN.reverse(),new window.Chart(n,{type:"bar",height:"400px",data:{labels:g,datasets:[{label:"Logins",data:a.USER_LOGIN,backgroundColor:"#ffa600",stack:"first"},{label:"Created exams",data:a.EXAM_CREATED,backgroundColor:"#bc5090",stack:"first"},{label:"Student starts",data:a.EXAM_STARTED,backgroundColor:"#003f5c",stack:"first"}]},options:{scales:{xAxes:[{ticks:{beginAtZero:!0,stacked:!0}}],yAxes:[{ticks:{beginAtZero:!0,stacked:!0,stepSize:1}}]}}})}},nt=Yt([]);let Fe=null;function Co(){return j(this,null,function*(){const l=(yield F.get("/api/site-admin/schools?all=true")).data;l.forEach(t=>{t.label=`${t.namn} (${t.ort}) - (id: ${t.id})`,t.search=t.label.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}),nt.value=l})}function $o(l){return j(this,null,function*(){yield St();const t=l==null?void 0:l.virtualScroller;t&&(t.first=0,t.lastScrollPos=0,t.init(),t.scrollTo({top:0}))})}function Oe(){function l(){return j(this,null,function*(){if(!(nt.value.length>0))return Fe===null&&(Fe=Co().finally(()=>{Fe=null})),Fe})}return{schoolList:nt,preloadSchools:l,rewindPicker:$o}}const Ao={components:{VueMultiselect:Be,FormatDate:ye},emits:["loadUser"],setup(){const{schoolList:l,preloadSchools:t}=Oe();return{schoolList:l,preloadSchools:t}},data(){return{aggregated:[],yearStatistics:[],aggregatedUserStatistics:{},chosenSchool:null,school:null,schoolId:null,schools:[],schoolStatisticsCh
3art:null,status:"done",users:[]}},computed:{year(){return new Date().getFullYear()},activeUsers(){return this.users.filter(l=>l.school_id===this.schoolId,this)},inactiveUsers(){return this.users.filter(l=>l.school_id!==this.schoolId,this)}},watch:{chosenSchool(){this.fetchSchoolStatistics()}},mounted(){this.preloadSchools()},methods:{sort(l){["logins","exams","students"].includes(l)&&(l=`num_${l}`,this.users.sort((t,d)=>!t.stat||t.stat.length===0?1:!d.stat||d.stat.length===0?-1:d.stat[0][l]-t.stat[0][l]===0?d.firstName.localeCompare(t.firstName):d.stat[0][l]-t.stat[0][l])),l==="latest"&&this.users.sort((t,d)=>t.login_at===d.login_at?0:t.login_at<d.login_at?1:-1)},userStatisticsToday(l,t){const d=new Date;return d.setHours(0,0,0,0),this.userStatistics(l,t,d)},userStatisticsWeekly(l,t){const d=new Date;return d.setDate(d.getDate()-6),d.setHours(0,0,0,0),this.userStatistics(l,t,d)},userStatistics(l,t,d){if(!l||l.statistics[t]===void 0)return 0;let s=0;for(const n of l.statistics[t])d<=Date.parse(n.date)&&(s+=n.value);return s},userStatisticsSixty(l,t){return this.aggregatedUserStatistics[l.id].filter(d=>d.group==="sixty"&&d.type===t).map(d=>d.value).reduce((d,s)=>d+s,0)},userStatisticsTotal(l,t){return this.aggregatedUserStatistics[l.id].filter(d=>d.group==="total"&&d.type===t).map(d=>d.value).reduce((d,s)=>d+s,0)},schoolStatisticsSixty(l){return this.aggregated.filter(t=>t.group==="sixty"&&t.type===l).map(t=>t.value).reduce((t,d)=>t+d,0)},schoolStatisticsTotal(l){return this.aggregated.filter(t=>t.group==="total"&&t.type===l).map(t=>t.value).reduce((t,d)=>t+d,0)},schoolStatisticsYear(l){let t=0;const d=new Date;d.setDate(1),d.setMonth(0),d.setHours(0,0,0,0);for(const s of this.yearStatistics.filter(n=>n.type===l))d<=Date.parse(s.date)&&(t+=s.value);return t},loadUser(l){this.$emit("loadUser",l)},buildUsers(l,t){const d=[];l.forEach(function(s){d[s.id]=s,d[s.id].statistics={}},this),t.forEach(function(s){if(s.user_id!=null){if(!d[s.user_id])return;d[s.user_id].statistics[s.type]===void 0&&(d[s.user_id].statistics[s.type]=[]),d[s.user_id].statistics[s.type].push(s)}},this),this.users=Object.values(d),this.users.sort((s,n)=>s.login_at===n.login_at?0:s.login_at<n.login_at?1:-1)},fetchSchoolStatistics(){return j(this,null,function*(){if(!this.chosenSchool)return;this.status="loading";const l=(yield F(`/api/site-admin/statistics/school/${this.chosenSchool.id}`)).data;this.buildUsers(l.users,l.statistics),this.aggregated=l.aggregated,this.yearStatistics=l.yearStatistics,l.users.forEach(t=>{this.aggregatedUserStatistics[t.id]=l.aggregated.filter(d=>d.user_id===t.id)}),this.school=l.school,this.schoolId=l.id,this.schoolStatisticsChart=Eo.makeChart({id:"schoolStatisticsChart",chart:this.schoolStatisticsChart,data:l.statistics}),this.status="done"})},CSVExport(){const l=this.users.map(t=>[`${t.firstName} ${t.lastName}`,window.moment.utc(t.login_at).local().format("YYYY-MM-DD HH:mm:ss"),this.userStatisticsToday(t,"USER_LOGIN"),this.userStatisticsWeekly(t,"USER_LOGIN"),this.userStatisticsSixty(t,"USER_LOGIN"),this.userStatisticsTotal(t,"USER_LOGIN"),this.userStatisticsToday(t,"EXAM_CREATED"),this.userStatisticsWeekly(t,"EXAM_CREATED"),this.userStatisticsSixty(t,"EXAM_CREATED"),this.userStatisticsTotal(t,"EXAM_CREATED"),this.userStatisticsToday(t,"EXAM_STARTED"),this.userStatisticsWeekly(t,"EXAM_STARTED"),this.userStatisticsSixty(t,"EXAM_STARTED"),this.userStatisticsTotal(t,"EXAM_STARTED")]);ct(l,["Name","Latest login","Logins today","Logins this week","Logins 60d","Logins total","Exams today","Exams this week","Exams 60d","Exams total","Students today","Students this week","Students 60d","Students total"],`STATISTICS-${this.school.namn}.csv`)},loadSchool(l){this.chosenSchool=l}}},To={style:{display:"flex"}},Do={style:{flex:"1"}},No={class:"stat"},Lo={class:"users"},Vo={class:"table table-striped",style:{"font-size":"var(--font-size-xxs)"}},Uo=["onClick"],Io=["data-testid"],Mo=["data-testid"],Ro=["data-testid"],Po=["data-testid"],Bo=["data-testid"],Oo=["data-testid"],Fo=["data-testid"],Ho=["data-testid"],Go=["data-testid"],zo=["data-testid"],Ko=["data-testid"],Xo=["onClick"],Wo=["data-testid"],Yo=["data-testid"],jo=["data-testid"],qo=["data-testid"],Qo=["data-testid"],Jo=["data-testid"],Zo=["data-testid"],en=["data-testid"],tn=["data-testid"],sn=["data-testid"],ln=["data-testid"],an={class:"schoolstat"},on={key:0},nn={class:"clickable"},rn={class:"clickable"},dn={class:"schoolInfo"},un={class:"schoolInfo"},cn={class:"schoolInfo"},mn={class:"schoolInfo"},hn={style:{"z-index":"9999",position:"fixed",top:"300px",left:"40%"}};
3function pn(l,t,d,s,n,a){const p=le("VueMultiselect"),y=le("FormatDate");return o(),r("div",{class:de(["SchoolStatistics",{blur:n.status==="loading"}])},[e("div",To,[e("div",Do,[t[14]||(t[14]=e("h3",null,"School search",-1)),u(p,{ref:"multiselect",modelValue:n.chosenSchool,"onUpdate:modelValue":t[0]||(t[0]=h=>n.chosenSchool=h),class:"SchoolStatistics__select-school",optionsLimit:500,options:s.schoolList,closeOnSelect:"",clearOnSelect:!1,placeholder:"Enter school",label:"label"},null,8,["modelValue","options"])])]),e("div",No,[e("div",Lo,[e("table",Vo,[e("tbody",null,[e("tr",null,[t[15]||(t[15]=e("th",null,"Namn",-1)),e("th",{onClick:t[1]||(t[1]=h=>a.sort("latest"))},"Last login"),e("th",{onClick:t[2]||(t[2]=h=>a.sort("logins"))},"Login (Today)"),e("th",{onClick:t[3]||(t[3]=h=>a.sort("logins"))},"Login (Week)"),e("th",{onClick:t[4]||(t[4]=h=>a.sort("logins"))},"Login (60 d.)"),e("th",{onClick:t[5]||(t[5]=h=>a.sort("logins"))},"Login (Total)"),e("th",{onClick:t[6]||(t[6]=h=>a.sort("exams"))},"Exams (Today)"),e("th",{onClick:t[7]||(t[7]=h=>a.sort("exams"))},"Exams (Week)"),e("th",{onClick:t[8]||(t[8]=h=>a.sort("exams"))},"Exams (60 d.)"),e("th",{onClick:t[9]||(t[9]=h=>a.sort("exams"))},"Exams (Total)"),e("th",{onClick:t[10]||(t[10]=h=>a.sort("students"))},"Student starts (Week)"),e("th",{onClick:t[11]||(t[11]=h=>a.sort("students"))},"Student starts (60 d.)"),e("th",{onClick:t[12]||(t[12]=h=>a.sort("students"))},"Student starts (Total)")]),(o(!0),r(O,null,te(a.activeUsers,h=>(o(),r("tr",{key:h.id},[e("td",null,[e("a",{href:"#",onClick:ve(g=>a.loadUser(h.email),["prevent"])},i(h.firstName)+" "+i(h.lastName),9,Uo)]),e("td",null,[u(y,{datetime:h.login_at||h.created_at},null,8,["datetime"])]),e("td",{"data-testid":`USER_LOGIN_${h.id}_today`},i(a.userStatisticsToday(h,"USER_LOGIN")),9,Io),e("td",{"data-testid":`USER_LOGIN_${h.id}_weekly`},i(a.userStatisticsWeekly(h,"USER_LOGIN")),9,Mo),e("td",{"data-testid":`USER_LOGIN_${h.id}_sixty`},i(a.userStatisticsSixty(h,"USER_LOGIN")),9,Ro),e("td",{"data-testid":`USER_LOGIN_${h.id}_total`},i(a.userStatisticsTotal(h,"USER_LOGIN")),9,Po),e("td",{"data-testid":`EXAM_CREATED_${h.id}_today`},i(a.userStatisticsToday(h,"EXAM_CREATED")),9,Bo),e("td",{"data-testid":`EXAM_CREATED_${h.id}_weekly`},i(a.userStatisticsWeekly(h,"EXAM_CREATED")),9,Oo),e("td",{"data-testid":`EXAM_CREATED_${h.id}_sixty`},i(a.userStatisticsSixty(h,"EXAM_CREATED")),9,Fo),e("td",{"data-testid":`EXAM_CREATED_${h.id}_total`},i(a.userStatisticsTotal(h,"EXAM_CREATED")),9,Ho),e("td",{"data-testid":`EXAM_STARTED_${h.id}_weekly`},i(a.userStatisticsWeekly(h,"EXAM_STARTED")),9,Go),e("td",{"data-testid":`EXAM_STARTED_${h.id}_sixty`},i(a.userStatisticsSixty(h,"EXAM_STARTED")),9,zo),e("td",{"data-testid":`EXAM_STARTED_${h.id}_total`},i(a.userStatisticsTotal(h,"EXAM_STARTED")),9,Ko)]))),128)),(o(!0),r(O,null,te(a.inactiveUsers,h=>(o(),r("tr",{key:h.id},[e("td",null,[e("a",{href:"#",onClick:ve(g=>a.loadUser(h.email),["prevent"])},i(h.firstName)+" "+i(h.lastName),9,Xo)]),e("td",null,[u(y,{datetime:h.login_at||h.created_at},null,8,["datetime"])]),e("td",{"data-testid":`USER_LOGIN_${h.id}_today`},i(a.userStatisticsToday(h,"USER_LOGIN")),9,Wo),e("td",{"data-testid":`USER_LOGIN_${h.id}_weekly`},i(a.userStatisticsWeekly(h,"USER_LOGIN")),9,Yo),e("td",{"data-testid":`USER_LOGIN_${h.id}_sixty`},i(a.userStatisticsSixty(h,"USER_LOGIN")),9,jo),e("td",{"data-testid":`USER_LOGIN_${h.id}_total`},i(a.userStatisticsTotal(h,"USER_LOGIN")),9,qo),e("td",{"data-testid":`EXAM_CREATED_${h.id}_today`},i(a.userStatisticsToday(h,"EXAM_CREATED")),9,Qo),e("td",{"data-testid":`EXAM_CREATED_${h.id}_weekly`},i(a.userStatisticsWeekly(h,"EXAM_CREATED")),9,Jo),e("td",{"data-testid":`EXAM_CREATED_${h.id}_sixty`},i(a.userStatisticsSixty(h,"EXAM_CREATED")),9,Zo),e("td",{"data-testid":`EXAM_CREATED_${h.id}_total`},i(a.userStatisticsTotal(h,"EXAM_CREATED")),9,en),e("td",{"data-testid":`EXAM_STARTED_${h.id}_weekly`},i(a.userStatisticsWeekly(h,"EXAM_STARTED")),9,tn),e("td",{"data-testid":`EXAM_STARTED_${h.id}_sixty`},i(a.userStatisticsSixty(h,"EXAM_STARTED")),9,sn),e("td",{"data-testid":`EXAM_STARTED_${h.id}_total`},i(a.userStatisticsTotal(h,"EXAM_STARTED")),9,ln)]))),128))])])]),e("div",an,[n.school?(o(),r("div",on,[e("h3",null,i(n.school.namn),1),e("h4",null,"ID: "+i(n.school.id),1),e("h5",nn,i(n.school.ort),1),e("h5",rn,i(n.school.orgnummer),1),e("h5",null,"License: "+i(n.school.access_type||"N/A"),1),e("div",dn,[e("b",null,i(a.schoolStatisticsSixty("USER_JOINED"))+" registered teachers last 60 days",1),t[16
3]||(t[16]=e("br",null,null,-1)),_(" ("+i(a.schoolStatisticsTotal("USER_JOINED"))+" total) ",1)]),e("div",un,[e("b",null,i(a.schoolStatisticsSixty("EXAM_CREATED"))+" created exams last 60 days",1),t[17]||(t[17]=e("br",null,null,-1)),_(" ("+i(a.schoolStatisticsTotal("EXAM_CREATED"))+" total) ",1)]),e("div",cn,[e("b",null,i(a.schoolStatisticsSixty("EXAM_STARTED"))+" student starts last 60 days",1),t[18]||(t[18]=e("br",null,null,-1)),_(" ("+i(a.schoolStatisticsTotal("EXAM_STARTED"))+" total) ",1)]),e("div",mn,[e("b",null,i(a.schoolStatisticsYear("EXAM_STARTED"))+" student starts during "+i(a.year),1),t[19]||(t[19]=e("br",null,null,-1)),e("b",null,i(a.schoolStatisticsYear("EXAM_CREATED"))+" created exams during "+i(a.year),1),t[20]||(t[20]=e("br",null,null,-1)),e("b",null,i(a.schoolStatisticsYear("USER_JOINED"))+" new teachers during "+i(a.year),1),t[21]||(t[21]=e("br",null,null,-1)),e("b",null,i(a.schoolStatisticsYear("USER_LOGIN"))+" teacher logins during "+i(a.year),1)]),(o(),r("svg",{xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",width:"60",height:"60",viewBox:"0 0 100 100",class:"cursor-pointer has-tooltip mx-auto",onClick:t[13]||(t[13]=(...h)=>a.CSVExport&&a.CSVExport(...h))},[...t[22]||(t[22]=[Et('<path fill="#a0d2a1" d="M69.307,81.575h-39c-6.6,0-12-5.4-12-12v-39c0-6.6,5.4-12,12-12h39c6.6,0,12,5.4,12,12v39C81.307,76.175,75.907,81.575,69.307,81.575z" data-v-6ff53939></path><path fill="#1f212b" d="M69.307,82.575h-39c-7.18,0-13-5.82-13-13v-39c0-7.18,5.82-13,13-13h39c7.18,0,13,5.82,13,13v39C82.307,76.755,76.487,82.575,69.307,82.575z M19.307,30.575v39c0,6.075,4.925,11,11,11h39c6.075,0,11-4.925,11-11v-39c0-6.075-4.925-11-11-11h-39C24.232,19.575,19.307,24.5,19.307,30.575z" data-v-6ff53939></path><path fill="#fdfcee" d="M67.186,76.575H33.428c-5.566,0-10.121-4.554-10.121-10.121V32.696c0-5.566,4.554-10.121,10.121-10.121h33.759c5.566,0,10.121,4.554,10.121,10.121v33.759C77.307,72.02,72.753,76.575,67.186,76.575z" data-v-6ff53939></path><path fill="#1f212b" d="M66.47 77.575H33.144c-5.985 0-10.837-4.852-10.837-10.837V33.413c0-5.986 4.852-10.838 10.838-10.838h33.662c.276 0 .5.224.5.5s-.224.5-.5.5H33.144c-5.433 0-9.837 4.404-9.837 9.837v33.326c0 5.433 4.404 9.837 9.837 9.837H66.47c5.433 0 9.837-4.404 9.837-9.837V48.075c0-.276.224-.5.5-.5s.5.224.5.5v18.663C77.307 72.723 72.455 77.575 66.47 77.575zM76.807 45.5c-.276 0-.5-.224-.5-.5v-4c0-.276.224-.5.5-.5s.5.224.5.5v4C77.307 45.276 77.083 45.5 76.807 45.5zM76.807 39.5c-.276 0-.5-.224-.5-.5v-2c0-.276.224-.5.5-.5s.5.224.5.5v2C77.307 39.276 77.083 39.5 76.807 39.5z" data-v-6ff53939></path><path fill="#a0d2a1" d="M62.929 61.878L55.331 61.878 50.148 54.548 44.702 61.878 37.071 61.878 46.539 49.971 38.894 39.558 46.602 39.558 50.183 45.22 53.998 39.558 61.842 39.558 53.827 49.971 62.929 61.878" data-v-6ff53939></path><path fill="#1f212b" d="M62.929,62.379h-7.598c-0.162,0-0.314-0.079-0.408-0.211l-4.785-6.769l-5.035,6.777c-0.094,0.127-0.243,0.202-0.401,0.202h-7.631c-0.192,0-0.367-0.11-0.45-0.283s-0.061-0.378,0.059-0.528l9.23-11.607l-7.418-10.106c-0.112-0.152-0.128-0.354-0.043-0.521c0.085-0.168,0.258-0.274,0.446-0.274h7.708c0.171,0,0.331,0.088,0.422,0.232l3.172,5.017l3.388-5.028c0.093-0.138,0.248-0.221,0.415-0.221h7.843c0.19,0,0.364,0.108,0.449,0.279c0.084,0.171,0.063,0.375-0.052,0.525l-7.781,10.11l8.869,11.603c0.115,0.151,0.135,0.354,0.051,0.525C63.293,62.27,63.12,62.379,62.929,62.379z M55.59,61.379h6.328L53.43,50.275c-0.137-0.18-0.137-0.43,0.001-0.608l7.395-9.609h-6.562L50.597,45.5c-0.094,0.141-0.252,0.235-0.422,0.221c-0.169-0.003-0.325-0.09-0.415-0.232l-3.434-5.431h-6.445l7.06,9.618c0.134,0.182,0.129,0.431-0.011,0.607l-8.823,11.096h6.344l5.296-7.129c0.095-0.129,0.246-0.204,0.407-0.202c0.16,0.002,0.31,0.08,0.402,0.211L55.59,61.379z" data-v-6ff53939></path>',6)])]))])):E("",!0)])]),t[24]||(t[24]=e("canvas",{id:"schoolStatisticsChart"},null,-1)),Z(e("div",hn,[...t[23]||(t[23]=[e("i",{style:{"font-size":"300px"},class:"fa fa-spin fa-spinner"},null,-1)])],512),[[ue,n.status==="loading"]])],2)}const vn=ie(Ao,[["render",pn],["__scopeId","data-v-6ff53939"]]),fn={class:"container mt-4 SchoolUsers"},gn={class:"bg-white flex gap-6 items-center mb-6 p-3 rounded-lg shadow w-fit"},yn=["title"],_n={key:0,class:"text-gray-500 text-sm"},bn={key:3,class:"bg-white p-6 rounded-lg shadow"},xn={class:"font-semibold mb-4 text-lg"},kn=["href"],wn={class:"whitespace-nowrap"},Sn={class:"whitespace-nowrap"},En={class:"flex gap-2 items-center justify-center"},Cn={key:1,class:"fa fa-check",style:{color:"var(--green-600)"},"aria-label":"Approved"},$n={class:"flex gap-2 items-center"},An={key:0,class:"fa fa-shield",style:{color:"var(--red-600)"},"aria-hidden":"true"},Tn={class:"flex justify-center"},Dn={key:0},Nn={key:0,class:"bg-red-50 border-[1px] border-red-300 mt-3 p-3 rounded text-red-900 text-sm"},Ln={key:1,class:"bg-yellow-50 border-[1px] border-yellow-300 mt-3 p-3 rounded text-sm text-yellow-900"}
3,Vn=42,Un=ne({__name:"SchoolUsers",setup(l){const t=Qe,d=Ne.organisation_admin,s={teacher:"Teacher",school_admin:"School admin",organisation_admin:"Organisation admin",sales_admin:"Sales admin",support_admin:"Support admin",superadmin:"Superadmin"},n=Object.keys(Ne).sort((G,U)=>Ne[G]-Ne[U]).map(G=>({value:G,label:Q(G)})),a=["exam.net","km.se","teachiq.com"];function p(G){const U=a.some(B=>G.email.toLowerCase().endsWith(`@${B}`));return n.filter(B=>B.value===G.type||B.value!=="superadmin"&&(U||!oe(B.value)))}const y=dt(),h=xs(),{schoolList:g,preloadSchools:V,rewindPicker:A}=Oe(),w=x(null),c=x(null),b=x({type:{value:null,matchMode:Qt.EQUALS}}),f=x(null),N=x(!1),H=x(""),R=x(!1),z=x(null),P=x(null),C=x(!1),S=x(null),{input:v,search:T}=$e("teacher-info","userSchool",{onSearch:G=>{c.value=g.value.some(U=>String(U.id)===G)?Number(G):null,M(G)},onClear:()=>{f.value=null,H.value=""}});De(V);function M(G){return j(this,null,function*(){if(!G){f.value=null;return}N.value=!0,H.value="";try{f.value=(yield F.get("/api/site-admin/school-users",{params:{query:G}})).data}catch(U){f.value=null,H.value=pe(U,"The users could not be loaded.")}finally{N.value=!1}})}const Y=ee(()=>{var G,U;return new Map(((U=(G=f.value)==null?void 0:G.schools)!=null?U:[]).map(B=>[B.id,K(B)]))});function K(G){return`${G.namn} (id: ${G.id})`}function Q(G){var U;return(U=s[G])!=null?U:G}function oe(G){var U;return((U=Ne[G])!=null?U:0)>d}function X(G){return G.has_admin_portal_access}function $(G){window.open(`/admin/impersonate-hmp/${G.id}`,"_blank")}function D(G){var U;return((U=S.value)==null?void 0:U.user.id)===G.id?S.value.type:G.type}function q(G,U){U!==G.type&&(S.value={user:G,type:U},C.value=!0)}function se(){return j(this,null,function*(){const G=S.value;if(G){R.value=!0;try{yield F.post(`/api/site-admin/users/${G.user.id}/type`,{type:G.type}),G.user.type=G.type,C.value=!1,S.value=null,y.add({severity:"success",summary:"Role changed",detail:`${G.user.email} is now ${Q(G.type)}.`})}catch(U){y.add({severity:"error",summary:"The role was not changed",detail:pe(U,"Something went wrong — the role is unchanged.")})}finally{R.value=!1}}})}function ae(G){h.require({header:"Approve this user",message:`Approve ${G.firstName} ${G.lastName} (${G.email}) as a member of the school? They are told by email, exactly as if a school admin had approved them.`,acceptLabel:"Approve",rejectLabel:"Cancel",accept:()=>W(G)})}function W(G){return j(this,null,function*(){P.value=G.id;try{const{data:U}=yield F.post(`/api/site-admin/school-users/${G.id}/accept`);G.accepted_by=U.accepted_by,y.add({severity:"success",summary:"Approved",detail:`${G.email} is now a member of the school.`})}catch(U){y.add({severity:"error",summary:"The user was not approved",detail:pe(U,"Something went wrong — nothing was saved.")})}finally{P.value=null}})}function L(G,U){return j(this,null,function*(){z.value=G.id;try{const{data:B}=yield F.patch(`/api/site-admin/users/${G.id}/exam-coordinator`,{is_exam_coordinator:U});G.is_exam_coordinator=B.is_exam_coordinator,y.add({severity:"success",summary:"Saved",detail:`${G.email} is ${G.is_exam_coordinator?"now":"no longer"} an exam coordinator.`})}catch(B){y.add({severity:"error",summary:"The exam coordinator status was not changed",detail:pe(B,"Something went wrong — nothing was saved.")})}finally{z.value=null}})}function pe(G,U){var B,me;return je(G)&&((me=(B=G.response)==null?void 0:B.data)==null?void 0:me.message)||U}return(G,U)=>(o(),r("div",fn,[e("div",gn,[u(Ae,{ref_key:"schoolSelect",ref:w,modelValue:c.value,"onUpdate:modelValue":U[0]||(U[0]=B=>c.value=B),options:m(g),optionLabel:"label",optionValue:"id",filter:"",filterFields:["search"],showClear:"",virtualScrollerOptions:{itemSize:Vn},pt:{overlay:{class:"AdminSchoolSelect__overlay"}},placeholder:"Search by school name","aria-label":"School",style:{width:"24rem"},onFilter:U[1]||(U[1]=B=>m(A)(w.value)),onChange:U[2]||(U[2]=B=>{var me;return m(T)(String((me=c.value)!=null?me:""))})},{option:k(({option:B})=>[e("span",{class:"AdminSchoolSelect__option-label",title:B.label},i(B.label),9,yn)]),_:1},8,["modelValue","options","virtualScrollerOptions"]),U[9]||(U[9]=e("span",{class:"font-medium text-gray-600 text-sm"},"OR",-1)),u(Me,{modelValue:m(v),"onUpdate:modelValue":U[3]||(U[3]=B=>He(v)?v.value=B:null),storageKey:"admin-school-users-search-history",label:"Organisation number",style:{width:"18rem"},onSubmit:U[4]||(U[4]=B=>m(T)())},null,8,["modelValue"])]),N.value?(o(),r("div",_n,[...U[10]||(U[10]=[e("i",{class:"fa fa-spin fa-spinner"},null,-1),_(" Loading… ",-1)])])):H.value?(o(),I(Ye,{key:1,severity:"error"},{default:k(()=>[_(i(H.value),1)]),_:1})):f.value&&f.value.schools.length===0?(o(),I(Ye,{key:2,severity:"info"},{default:k(()=>[_(" No school has the organisation number "+i(f.value.query)+". ",1)]),_:1})):f.value?(o(),r("div",bn,[e("h2",xn,i(f.value.users.length)+" "+i(f.value.users.length===1?"user":"users")+" at "+i(f.value.schools.map(K).join(", ")),1),u(m(ge),{filters:b.value,"onUpdate:filters":U[5]||(U[5]=B=>b.value=B),value:f.value.users,dataKey:"id",size:"small",showGridlines:"",stripedRows:"",removableSort:"",paginator:"",scrollable:"",filterDisplay:"menu",rows:25,rowsPerPageOptions:[25,50,100,500],class:"text-sm"},{empty:k(()=>[...U[11]||(U[11]=[e("span",{class:"text-gray-500"},"No users found.",-1)])]),default:k(()=>[u(m(J),{field:"firstName",header:"Name",sortable:""},{body:k(({data:B})=>[_(i(B.firstName)+" "+i(B.lastName),1)]),_:1}),u(m(J),{field:"email",header:"Email",sortable:""},{body:k(({data:B})=>[e("a",{href:m(_e)("teacher-info",{teacher:B.email}),title:"Open in Teacher info"},i(B.email),9,kn)]),_:1}),f.value.schools.length>1?(o(),I(m(J),{key:0,field:"school_id",header:"School",sortable:""},{body:k(({data:B})=>{var me;return[_(i((me=Y.value.get(B.school_id))!=null?me:`id: ${B.school_id}`),1)]}),_:1})):E("",!0),u(m(J),{header:"Used"},{body:k(({data:B})=>[Z((o(),r("span",wn,[e("i",{class:de(["fa",B.first_exam_use?"fa-check":"fa-times"]),style:ke({color:B.first_exam_use?"var(--green-600)":"var(--gray-600)"})},null,6),U[12]||(U[12]=_(" Exam ",-1))])),[[m(t),"Has signed in to Exam.net (first_exam_use is set)"]]),U[14]||(U[14]=_("   ",-1)),Z((o(),r("span",Sn,[e("i",{class:de(["fa",B.external_activity_at?"fa-check":"fa-times"]),style:ke({color:B.external_activity_at?"var(--green-600)":"var(--gray-600)"})},null,6),U[13]||(U[13]=_(" KM2 ",-1))])),[[m(t),"Has been active in KM2 (external_activity_at is set)"]])]),_:1}),u(m(J),{field:"accepted_by",header:"Approved",sortable:"",headerClass:"text-center"},{body:k(({data:B})=>[e("div",En,[B.accepted_by===0?(o(),r(O,{key:0},[u(ut,{value:"Pending",severity:"warn"}),u(fe,{label:"Approve",size:"small",disabled:P.value===B.id,onClick:me=>ae(B)},null,8,["disabled","onClick"])],64)):Z((o(),r("i",Cn,null,512)),[[m(t),"Approved by the school"]])])]),_:1}),u(m(J),{field:"login_at",header:"Last login",sortable:""},{body:k(({data:B})=>[u(ye,{datetime:B.login_at||B.created_at,format:"YYYY-MM-DD"},null,8,["datetime"])]),_:1}),u(m(J),{field:"type",header:"Role",sortable:"",showFilterMatchModes:!1,style:{width:"15rem"}},{filter:k(({filterModel:B})=>[u(Ae,{modelValue:B.value,"onUpdate:modelValue":me=>B.value=me,options:m(n),optionLabel:"label",optionValue:"value",size:"small",placeholder:"Any role","aria-label":"Filter by role",class:"w-full"},null,8,["modelValue","onUpdate:modelValue","options"])]),body:k(({data:B})=>[e("div",$n,[u(Ae,{modelValue:D(B),options:p(B),optionLabel:"label",optionValue:"value",size:"small","aria-label":`Role for ${B.email}`,class:"w-full","onUpdate:modelValue":me=>q(B,me)},null,8,["modelValue","options","aria-label","onUpdate:modelValue"]),oe(B.type)?Z((o(),r("i",An,null,512)),[[m(t),"Internal Exam.net role — this account can reach the admin panel"]]):E("",!0)])]),_:1}),u(m(J),{field:"is_exam_coordinator",header:"Exam coordinator",sortable:"",headerClass:"text-center"},{body:k(({data:B})=>[e("div",Tn,[u(Ce,{modelValue:B.is_exam_coordinator,label:`Exam coordinator for ${B.email}`,srOnlyLabel:"",disabled:z.value===B.id,"onUpdate:modelValue":me=>L(B,me)},null,8,["modelValue","label","disabled","onUpdate:modelValue"])])]),_:1}),u(m(J),{header:""},{body:k(({data:B})=>[Z((o(),r("span",null,[u(fe,{label:"Impersonate in Admin Portal",size:"small",disabled:!X(B),onClick:me=>$(B)},null,8,["disabled","onClick"])])),[[m(t),X(B)?"":"Only organisation admins can sign in to the Admin Portal"]])]),_:1})]),_:1},8,["filters","value"])])):E("",!0),u(Pe,{visible:C.value,"onUpdate:visible":U[7]||(U[7]=B=>C.value=B),header:"Change role",modal:"",dismissableMask:"",style:{width:"520px"},onHide:U[8]||(U[8]=B=>S.value=null)},{footer:k(()=>[u(fe,{label:"Cancel",onClick:U[6]||(U[6]=B=>C.value=!1)}),u(re,{label:R.value?"Saving…":"Change role",disabled:R.value,onClick:se},null,8,["label","disabled"])]),default:k(()=>[S.value?(o(),r("div",Dn,[e("p",null,[U[15]||(U[15]=_(" Change ",-1)),e("b",null,i(S.value.user.firstName)+" "+i(S.value.user.lastName),1),_(" ("+i(S.value.user.email)+") from ",1),e("b",null,i(Q(S.value.user.type)),1),U[16]||(U[16]=_(" to ",-1)),e("b",null,i(Q(S.value.type)),1),U[17]||(U[17]=_("? ",-1))]),oe(S.value.type)?(o(),r("div",Nn,[U[18]||(U[18]=e("i",{class:"fa fa-shield mr-1","aria-hidden":"true"},null,-1)),e("b",null,i(Q(S.value.type)),1),U[19]||(U[19]=_(" is an internal Exam.net role. It gives this account access to the admin panel and to every school's data. ",-1))])):oe(S.value.user.type)?(o(),r("div",Ln,[U[20]||(U[20]=_(" This removes the internal ",-1)),e("b",null,i(Q(S.value.user.type)),1),U[21]||(U[21]=_(" role, and with it access to the admin panel. ",-1))])):E("",!0)])):E("",!0)]),_:1},8,["visible"])]))}}),In={components:{PrimaryButton:re},data(){return{emailToVerify:"",verificationLink:""}},methods:{makeVerificationLink(){F.get(`/admin/link/verify?email=${window.encodeURIComponent(this.emailToVerify)}`).then(l=>{this.verificationLink=l.data.link})}}},Mn={style:{margin:"30px"}},Rn={style:{display:"flex","margin-bottom":"10px"}};
3function Pn(l,t,d,s,n,a){const p=le("ElInput"),y=le("PrimaryButton");return o(),r("div",null,[e("div",Mn,[e("div",Rn,[u(p,{modelValue:n.emailToVerify,"onUpdate:modelValue":t[0]||(t[0]=h=>n.emailToVerify=h),style:{width:"300px",margin:"0",background:"white"}},null,8,["modelValue"]),u(y,{style:{margin:"0","margin-left":"10px"},label:"Create link to verify email",onClick:a.makeVerificationLink},null,8,["onClick"])]),_(" "+i(n.verificationLink),1)])])}const Bn=ie(In,[["render",Pn]]),On={class:"bg-white p-6 shadow sm:rounded-lg"},Fn={key:0,class:"text-gray-500 text-sm"},Hn={key:1},Gn={class:"font-medium mb-2 text-gray-700"},zn={class:"text-center"},Kn={key:0},Xn=["title"],Wn={class:"border-[1px] border-gray-200 mt-6 p-4 rounded-lg"},Yn={class:"flex flex-wrap gap-6"},jn={class:"block font-medium mb-1"},qn=["onUpdate:modelValue"],Qn=["value"],Jn={key:0,class:"mt-4 text-gray-700 text-sm"},Zn={class:"mt-4"},ei={key:2,class:"bg-green-50 border-[1px] border-green-300 mt-4 p-3 rounded text-green-900 text-sm"},ti={key:3,class:"bg-red-50 border-[1px] border-red-300 mt-4 p-3 rounded text-red-900 text-sm"},si=ne({__name:"BulkSchoolSettings",props:{schoolId:{}},setup(l){const t=[{key:"manualVerification",label:"Manual verification",options:["none","domain","all"],defaultValue:"domain"},{key:"customAttribute",label:"Custom attribute",options:["allow","deny"],defaultValue:"allow"},{key:"sso",label:"SSO required",options:["true","false"],defaultValue:"false"}],d=l,s=x(null),n=x([]),a=jt({manualVerification:"",customAttribute:"",sso:""}),p=x(!1),y=x(!1),h=x(null),g=x("");Te(()=>d.schoolId,b=>{Object.assign(a,{manualVerification:"",customAttribute:"",sso:""}),V(Number(b))},{immediate:!0});function V(b){return j(this,null,function*(){var f,N;p.value=!0,h.value=null,g.value="";try{s.value=(yield F.get(`/api/site-admin/school-settings/organisation/${b}`)).data,n.value=s.value.schools.filter(H=>H.id===b)}catch(H){s.value=null,n.value=[],g.value=je(H)&&((N=(f=H.response)==null?void 0:f.data)==null?void 0:N.message)||"The organisation could not be loaded."}finally{p.value=!1}})}const A=ee(()=>{const b=t.filter(({key:f})=>a[f]!=="").map(({key:f})=>[f,a[f]]);return b.length>0?Object.fromEntries(b):null}),w=ee(()=>{if(A.value===null)return[];const b=n.value;return Object.entries(A.value).map(([f,N])=>{const H=b.filter(R=>{var z;return((z=R.settings)==null?void 0:z[f])===N}).length;return`${f} → "${N}": changes ${b.length-H} of ${b.length} selected ${b.length===1?"school":"schools"} (${H} already match)`})});function c(){return j(this,null,function*(){var b,f,N,H;if(!(!s.value||A.value===null||n.value.length===0)){y.value=!0,h.value=null,g.value="";try{const{data:R}=yield F.post("/api/site-admin/school-settings/bulk-update",{anchor_school_id:s.value.anchor.id,school_ids:n.value.map(P=>P.id),settings:A.value}),z=new Set(n.value.map(P=>P.id));yield V(s.value.anchor.id),n.value=(f=(b=s.value)==null?void 0:b.schools.filter(P=>z.has(P.id)))!=null?f:[],h.value=R}catch(R){g.value=je(R)&&((H=(N=R.response)==null?void 0:N.data)==null?void 0:H.message)||"Something went wrong — nothing was saved."}finally{y.value=!1}}})}return(b,f)=>(o(),r("div",On,[f[6]||(f[6]=e("h2",{class:"font-semibold mb-3 text-lg"},"School settings",-1)),p.value?(o(),r("div",Fn,[...f[1]||(f[1]=[e("i",{class:"fa fa-spin fa-spinner"},null,-1),_(" Loading… ",-1)])])):s.value?(o(),r("div",Hn,[e("p",Gn,[_(i(s.value.schools.length)+" schools in the organisation of ",1),e("b",null,i(s.value.anchor.namn),1),_(" (id: "+i(s.value.anchor.id)+") — "+i(n.value.length)+" selected. ",1)]),u(m(ge),{selection:n.value,"onUpdate:selection":f[0]||(f[0]=N=>n.value=N),value:s.value.schools,dataKey:"id",size:"small",showGridlines:"",class:"text-sm",tableStyle:"width: max-content"},{default:k(()=>[u(m(J),{selectionMode:"multiple",headerStyle:"width: 3rem"}),u(m(J),{field:"namn",header:"School"},{body:k(({data:N})=>[_(i(N.namn)+" (id: "+i(N.id)+") ",1)]),_:1}),u(m(J),{field:"ort",header:"Ort"}),u(m(J),{field:"orgnummer",header:"Orgnummer"}),(o(),r(O,null,te(t,N=>u(m(J),{key:N.key,header:N.label,headerClass:"text-center"},{body:k(({data:H})=>{var R;return[e("div",zn,[(R=H.settings)!=null&&R[N.key]?(o(),r("span",Kn,i(H.settings[N.key]),1)):(o(),r("span",{key:1,class:"italic text-gray-400",title:`Not stored on this school — a missing value acts as “${N.defaultValue}”`},i(N.defaultValue),9,Xn))])]}),_:2},1032,["header"])),64))]),_:1},8,["selection","value"]),f[5]||(f[5]=e("p",{class:"mt-1 text-gray-500 text-xs"},"Greyed italic values are not stored on the school — they show the default.",-1)),e("div",Wn,[f[3]||(f[3]=e("h3",{class:"font-semibold mb-2"},"New values",-1)),f[4]||(f[4]=e("p",{class:"mb-3 text-gray-700 text-sm"}," Settings left as “Leave unchanged” are not written at all — whatever each school currently has is kept. ",-1)),e("div",Yn,[(o(),r(O,null,te(t,N=>e("label",{key:N.key,class:"block text-sm"},[e("span",jn,i(N.label),1),Z(e("select",{"onUpdate:modelValue":H=>a[N.key]=H,class:"border-[1px] border-gray-300 p-2 rounded"},[f[2]||(f[2]=e("option",{value:""},"Leave unchanged",-1)),(o(!0),r(O,null,te(N.options,H=>(o(),r("option",{key:H,value:H}
3,i(H),9,Qn))),128))],8,qn),[[lt,a[N.key]]])])),64))]),w.value.length>0?(o(),r("ul",Jn,[(o(!0),r(O,null,te(w.value,N=>(o(),r("li",{key:N},i(N),1))),128))])):E("",!0),e("div",Zn,[u(Je,{title:`Apply to ${n.value.length} ${n.value.length===1?"school":"schools"}`,disabled:n.value.length===0||A.value===null||y.value,onClick:c},null,8,["title","disabled"])])])])):E("",!0),h.value?(o(),r("div",ei," Done — "+i(h.value.updated)+" "+i(h.value.updated===1?"school":"schools")+" updated, "+i(h.value.created)+" created. ",1)):E("",!0),g.value?(o(),r("div",ti,i(g.value),1)):E("",!0)]))}}),li={class:"DownloadSchoolsCsv"},ai={class:"DownloadSchoolsCsv__hint"},oi=ne({__name:"DownloadSchoolsCsv",props:{schools:{}},setup(l){const t=["id","namn"],d=ee(()=>l.schools.length?`One row per school (${l.schools.length} in total), with its id and name.`:"Loading the school list…");function s(a){const p=String(a);return/["\r\n;]/.test(p)?`"${p.replaceAll('"','""')}"`:p}function n(){const a=l.schools.map(p=>[s(p.id),s(p.namn)]);ct(a,t,`schools-${new Date().toISOString().slice(0,10)}.csv`)}return(a,p)=>(o(),r("div",li,[u(re,{"data-testid":"download-schools-csv",label:"Download all schools as CSV",disabled:!l.schools.length,onClick:n},null,8,["disabled"]),e("p",ai,i(d.value),1)]))}}),ni=ie(oi,[["__scopeId","data-v-e6466d22"]]);function et(l,t){return l.international_school_id?t?"Signed":"Not signed":"N/A"}const ii={components:{VueMultiselect:Be,RepeatedPressButton:Je,PrimaryButton:re,DataTable:ge,Column:J,BulkSchoolSettings:si,DownloadSchoolsCsv:ni},props:{userType:{type:String,default:null}},emits:["loadSchool"],setup(){const l=x(""),t=x("done"),d=x(null),s=x(null),n=x(null),a=x([]),p=ee(()=>{var Q;return Ge.formatFromUTC((Q=s.value)==null?void 0:Q.accessto,"YYYY-MM-DD")}),y=x([]),h=x([]),g=x(""),V=x(!1),A=x(!1),w=x(null),c=x({school:null,newSchool:null}),b=ee(()=>{if(!c.value.school)return[];const Q=c.value.schoolHasSignedDpa,oe=c.value.newSchoolHasSignedDpa,X=c.value.school.international_school_id||c.value.newSchool.international_school_id?[{label:"DPA",origin:et(c.value.school,Q),target:et(c.value.newSchool,oe),after:et(c.value.newSchool,Q||oe)}]:[];return[{label:"Teachers",origin:c.value.school.teachers.length,target:c.value.newSchool.teachers.length,after:c.value.school.teachers.length+c.value.newSchool.teachers.length},...X,{label:"Exam license",origin:c.value.school.access_type||"N/A",target:c.value.newSchool.access_type||"N/A",after:c.value.newSchool.access_type||"N/A"},{label:"KM license",origin:c.value.schoolKmLicense||"N/A",target:c.value.newSchoolKmLicense||"N/A",after:c.value.newSchoolKmLicense||"N/A"}]}),f=ee(()=>{var Q,oe;return((oe=(Q=c.value.school)==null?void 0:Q.teachers)!=null?oe:[]).filter(X=>X.external_activity_at||X.origin==="gauss")}),{schoolList:N,preloadSchools:H}=Oe(),R=ee(()=>N.value.filter(Q=>{var oe;return Q.id!==((oe=s.value)==null?void 0:oe.id)})),{param:z,search:P,clear:C}=$e("manage-schools","school",{onSearch:Q=>{S(Q),M(Q)},onClear:()=>{l.value="",s.value=null}});function S(Q){const oe=N.value.find(X=>String(X.id)===String(Q));oe&&(d.value=oe)}function v(){d.value&&P(String(d.value.id))}function T(){return j(this,null,function*(){yield H(),z.value&&S(z.value)})}function M(){return j(this,arguments,function*(Q=(oe=>(oe=d.value)==null?void 0:oe.id)()){var D,q,se;if(!Q)return;l.value="existing",t.value="loading";const $=yield(yield fetch(`/api/licence/${Q}`,{credentials:"include"})).json();t.value="done",s.value=$.school,n.value=$.urkundId,a.value=$.organisationAdministrators,y.value=(D=$.localDomains)!=null?D:[],h.value=(q=$.kmDomains)!=null?q:[],V.value=$.hideRenewalBanner,A.value=(se=$.schoolInSalesRegion)!=null?se:!1,g.value="",w.value=null,c.value={school:null,newSchool:null}})}function Y(Q){return j(this,null,function*(){c.value={school:null,newSchool:null},Q&&(c.value=(yield F.get(`/api/site-admin/schools/${s.value.id}/merge/${Q.id}`)).data)})}function K(){return j(this,null,function*(){yield F.post(`/api/site-admin/schools/${s.value.id}/merge/${w.value.id}`),M()})}return{type:l,status:t,chosenSchool:d,school:s,schoolList:N,mergeableSchools:R,urkundId:n,organisationAdministrators:a,accessTo:p,localDomains:y,kmDomains:h,deleteConfirmText:g,hideRenewalBanner:V,schoolInSalesRegion:A,mergeToSchool:w,mergeData:c,mergeRows:b,km2Teachers:f,clearSchoolSearch:C,searchChosenSchool:v,preloadSchools:T,fetchSchoolStats:M,prepareForMerge:Y,performMerge:K}},computed:{isSalesAdmin(){return this.userType==="sales_admin"},canOpenTeacherList(){return!this.isSalesAdmin||this.schoolInSalesRegion}},mounted(){this.preloadSchools()},methods:{loadSchool(l){this.$emit("loadSchool",l)},updateAccess(){window.$.ajax({method:"post",url:`/api/licence/${this.school.id}`,context:this,data:{accessto:this.accessTo,urkund_id:this.urkundId,hideRenewalBanner:this.hideRenewalBanner},success(){this.fetchSchoolStats()}})},deleteSchool(){return j(this,null,function*(){this.status="loading";try{yield F.delete(`/api/site-admin/schools/${this.school.id}`,{data:{confirm:!0}}),this.schoolList=this.schoolList.filter(l=>l.id!==this.school.id),this.chosenSchool=null,this.school=null,this.deleteConfirmText="",this.clearSchoolSearch()}finally{this.status="done"}})}}},ri={class:"gap-6 grid grid-cols-2 lg:grid-cols-2 mb-14 md:grid-cols-2 sm:grid-cols-2"},di={class:"bg-white col-span-1 flex flex-col rounded-lg shadow text-center"},ui={class:"flex flex-1 flex-col gap-3 items-baseline p-3"},ci={class:"w-full"},mi={class:"bg-white overflow-hidden shadow sm:rounded-lg"},hi={class:"border-b border-gray-200 px-4 py-5 sm:px-6"},pi={key:0},vi={key:0,style:{display:"flex","flex-direction":"column",gap:"20px"}},fi={style:{display:"flex","align-items":"center",gap:"16px"}},gi={style:{display:"flex","align-items":"center",gap:"6px","font-size":"16px"}},yi=["href"],_i={key:1},bi={style:{"margin-top":"10px"}},xi={style:{"margin-top":"10px"}},ki={key:2,class:"mt-4"},wi={class:"danger-zone mt-8"},Si={class:"mt-4"},Ei={class:"max-w-xl"},Ci={key:0,class:"SchoolMerge"},$i={class:"mt-4 SchoolMerge__intro text-lg"},Ai={class:"italic mt-2"},Ti={key:0,class:"mt-2 text-red-800"},Di={key:1,class:"mt-2 text-red-800"},Ni={class:"km2-teachers mt-1"},Li={class:"cursor-pointer font-bold hover:underline"},Vi={class:"font-bold text-gray-900"},Ui={class:"text-center"},Ii={class:"text-center"},Mi={class:"text-center"},Ri={class:"mt-2"},Pi={class:"flex gap-2 items-center mt-2"},Bi={style:{"z-index":"9999",position:"fixed",top:"300px",left:"40%"}},Oi={class:"bg-white inline-block mt-6 p-3 rounded-lg shadow"};function Fi(l,t,d,s,n,a){var b;
3const p=le("VueMultiselect"),y=le("PrimaryButton"),h=le("ElInput"),g=le("Column"),V=le("DataTable"),A=le("RepeatedPressButton"),w=le("BulkSchoolSettings"),c=le("DownloadSchoolsCsv");return o(),r("div",null,[e("ul",ri,[e("li",di,[e("div",ui,[e("div",ci,[u(p,{ref:"multiselect",modelValue:s.chosenSchool,"onUpdate:modelValue":t[0]||(t[0]=f=>s.chosenSchool=f),optionsLimit:500,options:s.schoolList,closeOnSelect:"",clearOnSelect:!1,placeholder:l.__("Enter school name"),label:"label"},null,8,["modelValue","options","placeholder"])]),u(y,{label:"Load school",onClick:s.searchChosenSchool},null,8,["onClick"])])])]),e("div",mi,[e("div",hi,[s.type==="existing"?(o(),r("div",pi,[s.school?(o(),r("div",vi,[e("div",fi,[e("h1",null,[e("a",{href:"#",onClick:t[1]||(t[1]=ve(f=>a.loadSchool(s.school),["prevent"]))},i(s.school.namn)+" (id: "+i(s.school.id)+") ",1)]),e("label",gi,[Z(e("input",{"onUpdate:modelValue":t[2]||(t[2]=f=>s.hideRenewalBanner=f),type:"checkbox",style:{width:"20px",height:"20px"}},null,512),[[Ct,s.hideRenewalBanner]]),t[6]||(t[6]=_(" Hide renewal banner ",-1))])]),a.canOpenTeacherList?(o(),r("a",{key:0,href:"/admin/school/"+s.school.id,target:"_blank"},[u(y,{label:"Open teacher list as administrator"})],8,yi)):E("",!0),e("div",null,[t[7]||(t[7]=e("b",null,"School accessto:",-1)),_(" "+i(s.accessTo)+" ",1),t[8]||(t[8]=e("div",{class:"italic"},"Access is updated in Salesforce",-1))]),e("div",null,[t[9]||(t[9]=e("b",null,"School license:",-1)),_(" "+i(s.school.access_type||"N/A"),1)]),e("div",null,[t[10]||(t[10]=_(" Urkund ID: ",-1)),u(h,{modelValue:s.urkundId,"onUpdate:modelValue":t[3]||(t[3]=f=>s.urkundId=f),style:{background:"white",width:"200px"}},null,8,["modelValue"])]),s.localDomains.length||s.kmDomains.length?(o(),r("div",_i,[e("div",bi,[t[11]||(t[11]=e("b",null,"Exam.net domains: ",-1)),_(" "+i(s.localDomains.map(f=>`@${f}`).join(", ")),1)]),e("div",xi,[t[12]||(t[12]=e("b",null,"KM domains: ",-1)),_(" "+i(s.kmDomains.map(f=>`@${f}`).join(", ")),1)])])):E("",!0),u(y,{style:{"margin-top":"10px"},label:l.__("Save"),onClick:a.updateAccess},null,8,["label","onClick"]),s.organisationAdministrators.length>0?(o(),r("div",ki,[t[13]||(t[13]=e("h3",null,"Organization administrators",-1)),(o(!0),r(O,null,te(s.organisationAdministrators,f=>(o(),r("div",{key:f.id},i(f.firstName)+" "+i(f.lastName)+" ("+i(f.email)+") (Teacher id: "+i(f.id)+") ",1))),128))])):E("",!0),e("details",wi,[t[29]||(t[29]=e("summary",{class:"cursor-pointer font-bold hover:underline text-red-800"},[e("i",{class:"danger-caret fa fa-chevron-right"}),_(" Danger zone — delete or merge school ")],-1)),e("h3",Si,[t[14]||(t[14]=_(" Merge ",-1)),e("b",null,i(s.school.namn)+" (id: "+i(s.school.id)+")",1),t[15]||(t[15]=_(" into: ",-1))]),e("div",Ei,[u(p,{modelValue:s.mergeToSchool,"onUpdate:modelValue":t[4]||(t[4]=f=>s.mergeToSchool=f),optionsLimit:500,options:s.mergeableSchools,closeOnSelect:"",clearOnSelect:!1,placeholder:"School to merge into",label:"label",onSelect:s.prepareForMerge},null,8,["modelValue","options","onSelect"])]),(b=s.mergeData)!=null&&b.school?(o(),r("div",Ci,[e("div",$i,[t[16]||(t[16]=_(" Performing this merge will move all teachers and any signed DPA's from ",-1)),e("b",null,i(s.mergeData.school.namn+" (id: "+s.mergeData.school.id+")"),1),t[17]||(t[17]=_(" to ",-1)),e("b",null,i(s.mergeData.newSchool.namn+" (id: "+s.mergeData.newSchool.id+")"),1),t[18]||(t[18]=_(". ",-1))]),e("div",Ai,[t[19]||(t[19]=_(" Teachers keep all their exams, students and exam shares, and their existing roles are unchanged (remove admin role manually beforehand if that shouldn't carry over). ",-1)),t[20]||(t[20]=e("br",null,null,-1)),t[21]||(t[21]=_(" No licenses are moved, and the target school will keep its existing license and current school settings. ",-1)),t[22]||(t[22]=e("br",null,null,-1)),t[23]||(t[23]=_(" After the merge, the source school ",-1)),e("b",null,i(s.mergeData.school.namn+" (id: "+s.mergeData.school.id+")"),1),t[24]||(t[24]=_(" will remain in the system as an empty school, and will not be deleted automatically. ",-1))]),s.mergeData.newSchoolRequiresSso?(o(),r("div",Ti,[e("b",null,i(s.mergeData.newSchool.namn)+" (id: "+i(s.mergeData.newSchool.id)+")",1),t[25]||(t[25]=_(" requires SSO — moved teachers may not be able to log in if they are unable to use SSO with their account. ",-1))])):E("",!0),s.km2Teachers.length?(o(),r("div",Di,[t[27]||(t[27]=_(" Some of the teachers being moved have activity in KM2. Their KM2 classes will be archived on the original school and will no longer be accessible to them. Support can manually move affected classes to the new school if necessary. ",-1)),e("details",Ni,[e("summary",Li,[t[26]||(t[26]=e("i",{class:"danger-caret fa fa-chevron-right"},null,-1)),_(" Show the "+i(s.km2Teachers.length)+" teachers with KM2 activity ",1)]),(o(!0),r(O,null,te(s.km2Teachers,f=>(o(),r("div",{key:f.id,class:"ml-4 mt-1"},i(f.email)+" (id: "+i(f.id)+") ",1))),128))])])):E("",!0),u(V,{value:s.mergeRows,size:"small",showGridlines:"",class:"mt-4 text-sm",tableStyle:"width: max-content"},{default:k(()=>[u(g,{header:"",headerStyle:"width: 8rem"},{body:k(({data:f})=>[e("span",Vi,i(f.label),1)]),_:1}),u(g,{headerClass:"text-center"},{header:k(()=>[e("b",null,i(s.mergeData.school.namn),1),_(" (id: "+i(s.mergeData.school.id)+") ",1)]),body:k(({data:f})=>[e("div",Ui,i(f.origin),1)]),_:1}),u(g,{headerClass:"text-center"},{header:k(()=>[e("b",null,i(s.mergeData.newSchool.namn),1),_(" (id: "+i(s.mergeData.newSchool.id)+") ",1)]),body:k(({data:f})=>[e("div",Ii,i(f.target),1)]),_:1}),u(g,{headerClass:"SchoolMerge__afterCell text-center",bodyClass:"SchoolMerge__afterCell"},{header:k(()=>[t[28]||(t[28]=_(" After merge — ",-1)),e("b",null,i(s.mergeData.newSchool.namn),1),_(" (id: "+i(s.mergeData.newSchool.id)+") ",1)]),body:k(({data:f})=>[e("div",Mi,[e("b",null,i(f.after),1)])]),_:1})]),_:1},8,["value"]),e("div",Ri,[u(A,{title:"Perform merge",onClick:s.performMerge},null,8,["onClick"])])])):E("",!0),t[30]||(t[30]=e("h3",{class:"mt-8"},"Delete school",-1)),t[31]||(t[31]=e("div",{class:"italic mt-2"}," This action will permanently delete the school and all associated data including all teachers and their exams. ",-1)),e("div",Pi,[u(h,{modelValue:s.deleteConfirmText,"onUpdate:modelValue":t[5]||(t[5]=f=>s.deleteConfirmText=f),placeholder:"Type delete",style:{background:"white",width:"200px"}},null,8,["modelValue"]),u(A,{disabled:s.deleteConfirmText.trim().toLowerCase()!=="delete",title:"Delete school and all connected data",onClick:a.deleteSchool},null,8,["disabled","onClick"])])])])):E("",!0),Z(e("div",Bi,[...t[32]||(t[32]=[e("i",{style:{"font-size":"300px"},class:"fa fa-spin fa-spinner"},null,-1)])],512),[[ue,s.status==="loading"]])])):E("",!0)])]),s.type==="existing"&&s.school?(o(),I(w,{key:0,schoolId:s.school.id,class:"mt-6"},null,8,["schoolId"])):E("",!0),e("div",Oi,[u(c,{schools:s.schoolList},null,8,["schools"])])])}const Hi=ie(ii,[["render",Fi],["__scopeId","data-v-828d1662"]]),Gi={__name:"EditableField",props:{modelValue:{type:String,default:""},originalValue:{type:String,default:""},type:{type:String,default:"text"},saved:{type:Boolean,default:!1},error:{type:String,default:null}},emits:["update:modelValue","save"],setup(l){const t=Qe,d=l,s=ee(()=>d.modelValue!==d.originalValue);return(n,a)=>(o(),r("div",null,[u(Dt,null,{default:k(()=>[u($t,{value:l.modelValue,type:l.type,size:"small",fluid:"",onInput:a[0]||(a[0]=p=>n.$emit("update:modelValue",p.target.value))},null,8,["value","type"]),u(Nt,{class:"p-0"},{default:k(()=>[Z((o(),I(At,{severity:"secondary",size:"small",disabled:!s.value,onClick:a[1]||(a[1]=p=>n.$emit("save"))},{default:k(()=>[u(ce,{svg:l.saved?m(ks):m(ws),width:"var(--width-4)",color:l.saved?"var(--green-600)":"var(--gray-700)"},null,8,["svg","color"])]),_:1},8,["disabled"])),[[m(t),l.saved?"Saved!":"Save",void 0,{bottom:!0}]])]),_:1})]),_:1}),l.error?(o(),I(Ye,{key:0,severity:"error",variant:"simple",size:"small"},{default:k(()=>[_(i(l.error),1)]),_:1})):E("",!0)]))}},zi={key:0,class:"text-gray-500 text-sm"},Ki={class:"UserExamTransfers__exams"},Xi={class:"UserExamTransfers__exams"},Wi=ne({__name:"UserExamTransfers",props:{userId:{}},setup(l){const t=l,d=x([]);return Te(()=>t.userId,s=>j(null,null,function*(){d.value=[];const n=yield F.get(`/api/site-admin/users/${s}/exam-transfers`);d.value=n.data.transfers}),{immediate:!0}),(s,n)=>(o(),r("div",null,[n[0]||(n[0]=e("h3",null,"Transferred away",-1)),d.value.length===0?(o(),r("p",zi," No outgoing transfers ")):(o(),I(m(ge),{key:1,value:d.value,size:"small",stripedRows:""},{default:k(()=>[u(m(J),{header:"Transferred at",style:{width:"160px"}},{body:k(({data:a})=>[u(ye,{datetime:a.created_at},null,8,["datetime"])]),_:1}),u(m(J),{header:"To",style:{width:"200px"}},{body:k(({data:a})=>[u(Ie,{user:a.to_user},null,8,["user"])]),_:1}),u(m(J),{header:"Started by",style:{width:"200px"}},{body:k(({data:a})=>[u(Ie,{user:a.transferred_by},null,8,["user"])]),_:1}),u(m(J),{header:"Exams",style:{width:"80px"}},{body:k(({data:a})=>[_(i(a.exam_count),1)]),_:1}),u(m(J),{header:"Transferred exams"},{body:k(({data:a})=>[e("div",Ki,[(o(!0),r(O,null,te(a.exams,p=>
3(o(),I(qe,{key:p.id,exam:p},null,8,["exam"]))),128))])]),_:1}),u(m(J),{header:"Copies kept"},{body:k(({data:a})=>[e("div",Xi,[(o(!0),r(O,null,te(a.exams,p=>(o(),I(qe,{key:p.id,exam:p.copy},null,8,["exam"]))),128))])]),_:1})]),_:1},8,["value"]))]))}}),Yi=ie(Wi,[["__scopeId","data-v-08c72dcf"]]),ji={components:{SchoolSelect:Ae,PrimaryButton:re,VueMultiselect:Be,RepeatedPressButton:Je,SecondaryButton:fe,SplitButton:zs,ExamModal:Ss,AdminDialog:Pe,DialogActions:Jt,Checkbox:Ce,DataTable:ge,Column:J,FormatDate:ye,EditableField:Gi,SearchHistoryInput:Me,UserExamTransfers:Yi},directives:{tooltip:Qe},props:{userType:{type:String,default:null},userEmail:{type:String,default:null}},emits:["loadSchool"],setup(){const l=dt(),t=x(null),d=x("loaded"),s=x({firstName:null,lastName:null,email:null}),n=x({}),a=x({firstName:!1,lastName:!1,email:!1}),{schoolList:p,preloadSchools:y,rewindPicker:h}=Oe(),{input:g,search:V}=$e("teacher-info","teacher",{onSearch:w=>A(w),onClear:()=>{t.value=null}});function A(){return j(this,arguments,function*(w=g.value){d.value="loading";const c=(yield F.get(`/api/site-admin/user?email=${window.encodeURIComponent(w)}`)).data;c.firstName==null?t.value=null:t.value=c,t.value&&(s.value={firstName:t.value.firstName,lastName:t.value.lastName,email:t.value.email},n.value={},a.value={firstName:!1,lastName:!1,email:!1}),d.value="loaded"})}return{toast:l,email:g,user:t,status:d,schoolList:p,rewindPicker:h,preloadSchools:y,editedFields:s,fieldErrors:n,savedFields:a,fetchUserByEmail:A,searchUserByEmail:V,buildAdminTabLink:_e}},data(){return{deleteCount:0,removeSchoolCount:0,answer:"Hello world",chosenSchool:null,adminPortalSchool:null,key:null,student:null,studentDialogVisible:!1,moveDialogVisible:!1,moveExamsWithTeacher:!1,keepExamShares:!1,keepIncomingShares:!1,moveMenuItems:[{label:"Move with student data",command:()=>this.showMoveDialog(!0)}]}},computed:{isSalesAdmin(){return this.userType==="sales_admin"},isSupportAdmin(){return Es.hasRole(this.userType,"support_admin")},canLoginToHmpAsUser(){return this.isSupportAdmin&&this.user.has_admin_portal_access===!0},adminPortalRoots(){var l,t;return(t=(l=this.user)==null?void 0:l.admin_portal_roots)!=null?t:[]},ownSchoolIsAdminPortalRoot(){return this.hasSchool&&this.adminPortalRoots.some(l=>l.id===this.user.school.id)},canLoginAsUser(){return this.isSupportAdmin?!0:!!this.user&&this.user.email!=="*****"},hasUser(){return!!this.user},hasSchool(){return this.user==null?!1:this.user.school!=null},userInfoRows(){var d;if(!this.user)return[];const l=[{key:"id",label:"Id",value:this.user.id}];this.user.school===null&&l.push({key:"noSchool",label:"School",value:"None"}),this.hasSchool&&(l.push({key:"city",label:"City",value:this.user.school.ort}),l.push({key:"school",label:"School",value:""}),l.push({key:"accessType",label:"School license",value:(d=this.user.school.access_type)!=null?d:"N/A"})),l.push({key:"role",label:"Role",value:this.user.type},{key:"adminPortal",label:"Admin portal access",value:""},{key:"examCoordinator",label:"Exam coordinator",value:""},{key:"lastLogin",label:"Last login",value:this.user.login_at},{key:"registeredAt",label:"Registration date",value:this.user.created_at},{key:"productUsage",label:"Product usage",value:""},{key:"firstName",label:"First name",value:this.user.firstName},{key:"lastName",label:"Last name",value:this.user.lastName},{key:"email",label:"Email",value:""},{key:"resetPassword",label:"Link to reset password",value:""},{key:"extensions",label:"Individual access extensions",value:""});const t=["resetPassword","extensions"];return this.isSalesAdmin?l.filter(s=>!t.includes(s.key)):l},exams(){return this.user.exams.sort((t,d)=>d.id-t.id)},studentsByExam(){var t,d;const l=new Map;for(const s of(d=(t=this.user)==null?void 0:t.students)!=null?d:[]){const n=Number(s.exam_id);l.has(n)||l.set(n,[]),l.get(n).push(s)}for(const s of l.values())s.sort((n,a)=>n.firstName.localeCompare(a.firstName));return l},studentInfoRows(){if(!this.student)return[];const l=[];return this.student.firstName&&l.push({label:"First name",value:this.student.firstName}),this.student.lastName&&l.push({label:"Last name",value:this.student.lastName}),this.student.email&&l.push({label:"Email",value:this.student.email}),this.student.teacher&&l.push({label:"Teacher",value:this.student.teacher}),this.student.class&&l.push({label:"Class",value:this.student.class}),this.student.answer&&l.push({label:"Answer",value:"answer"}),l},studentBackups(){return this.student.backups.sort((t,d)=>new Date(d.created_at)-new Date(t.created_at))},studentLogs(){return this.student.student_logs.sort((t,d)=>new Date(d.created_at)-new Date(t.created_at))},studentOfflineSaves(){return this.student.offline_saves.sort((t,d)=>new Date(d.created_at)-new Date(t.created_at))}},mounted(){this.preloadSchools()},methods:{loadUser(l){this.searchUserByEmail(l)},grantAdminPortalAccess(l){return j(this,null,function*(){var t,d,s;try{yield F.post(`/api/site-admin/users/${this.user.id}/admin-portal-access`,{school_id:l}),this.adminPortalSchool=null,this.toast.add({severity:"success",summary:"Admin portal access granted"})}catch(n){this.toast.add({severity:"error",summary:"Could not grant admin portal access",detail
3:(s=(d=(t=n.response)==null?void 0:t.data)==null?void 0:d.message)!=null?s:"Unknown error"})}yield this.fetchUserByEmail()})},revokeAdminPortalAccess(l){return j(this,null,function*(){var t,d,s;try{yield F.delete(`/api/site-admin/users/${this.user.id}/admin-portal-access/${l}`),this.toast.add({severity:"success",summary:"Admin portal access removed"})}catch(n){this.toast.add({severity:"error",summary:"Could not remove admin portal access",detail:(s=(d=(t=n.response)==null?void 0:t.data)==null?void 0:d.message)!=null?s:"Unknown error"})}yield this.fetchUserByEmail()})},examType(l){return Mt.json(l.content).choice==="builder"?"Automarked":l.writeArea?"Text":"Tool"},loginLink(){return`/admin/impersonate/${this.user.email}`},hmpLoginLink(){return`/admin/impersonate-hmp/${this.user.email}`},saveField(l){return j(this,null,function*(){var t,d,s;this.fieldErrors[l]=null;try{yield F.patch(`/api/site-admin/users/${this.user.id}`,{[l]:this.editedFields[l]}),l==="email"&&(this.email=this.editedFields.email),yield this.fetchUserByEmail(),this.toast.add({severity:"success",summary:"Saved"}),this.savedFields[l]=!0,setTimeout(()=>{this.savedFields[l]=!1},2e3)}catch(n){if(((t=n.response)==null?void 0:t.status)===422){const a=(d=n.response.data.errors)!=null?d:{};this.fieldErrors[l]=(s=a[l])==null?void 0:s[0]}else console.error(n),this.toast.add({severity:"error",summary:"Error",detail:"Could not save. Check the console for details."})}})},studentsForExam(l){var t;return(t=this.studentsByExam.get(l))!=null?t:[]},formatStudentName(l){return Ee.displayName(l)},showStudent(l){this.status="loading",fetch(`/api/site-admin/student/${l.id}`,{credentials:"include"}).then(t=>t.json()).then(t=>{Array.isArray(t)&&t.length===0?this.student=null:this.student=t,this.status="loaded",this.student&&(this.studentDialogVisible=!0)})},showAnswerModal(l){this.answer=l,ze.show(this.$refs.studentAnswerModal)},formatDate(l){const t={year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"};return new Date(l).toLocaleDateString("sv-SE",t)},showMoveDialog(l){this.moveExamsWithTeacher=l,this.keepExamShares=l,this.keepIncomingShares=l,this.moveDialogVisible=!0},moveUser(){this.moveDialogVisible=!1,this.status="loading",F.post(`/api/site-admin/user/${this.user.email}/move/${this.chosenSchool.id}`,{moveExamsWithTeacher:this.moveExamsWithTeacher,deleteExamShares:!this.keepExamShares,deleteIncomingShares:!this.keepIncomingShares}).then(()=>{this.fetchUserByEmail()}).catch(l=>{console.error("Failed to move teacher:",l),this.status="loaded",this.toast.add({severity:"error",summary:"Failed to move teacher",detail:"An unexpected error occurred. Please try again."})})},removeSchool(){return j(this,null,function*(){this.status="loading",yield F.post(`/api/site-admin/user/${this.user.email}/move/0`),this.fetchUserByEmail()})},deleteUser(){return j(this,null,function*(){this.status="loading",yield F.post(`/api/site-admin/delete-user/${this.user.id}`,{confirm:!0}),this.user=null,this.status=""})},resetPasswordLink(){return j(this,null,function*(){const l=yield F.get(`/admin/link/reset/${this.email}`);window.open(l.data.link)})},extendAccess(){return j(this,null,function*(){this.status="loading",yield F.post(`/api/site-admin/user/${this.user.id}/extend-access`),this.fetchUserByEmail()})},unarchiveExam(d){return j(this,arguments,function*(l,{resetCreatedAt:t=!1}={}){this.status="loading",yield F.post(`/api/site-admin/exam/${l.id}/unarchive`,{resetCreatedAt:t}),this.fetchUserByEmail()})},unhideExam(l){return j(this,null,function*(){this.status="loading",yield F.post(`/api/site-admin/exam/${l.id}/unhide`),this.fetchUserByEmail()})},toggleExamCoordinator(){const l=!this.user.is_exam_coordinator,t=[this.user.firstName,this.user.lastName].filter(Boolean).join(" ")||this.user.email||"Unknown User";this.$confirm.require({header:l?"Promote to exam coordinator":"Demote from exam coordinator",message:l?`Make "${t}" an exam coordinator?`:`Remove exam coordinator status from "${t}"?`,acceptLabel:l?"Promote":"Demote",rejectLabel:"Cancel",accept:()=>j(this,null,function*(){this.status="loading";try{yield F.patch(`/api/site-admin/users/${this.user.id}/exam-coordinator`,{is_exam_coordinator:l}),yield this.fetchUserByEmail()}catch(d){this.status="loaded",this.toast.add({severity:"error",summary:"Error",detail:"Could not update exam 
3coordinator status. Check the console for details."})}})})},examHasActions(l){return l.is_hidden||l.archived_at!=null||l.school_id>0&&Number(l.school_id)!==this.user.school_id},loadSchool(l){this.$emit("loadSchool",l)}}},qi={class:"flex gap-3 items-center mb-6"},Qi={class:"bg-white inline-block p-2 rounded-lg shadow"},Ji={key:0},Zi={key:2,class:"mt-1 text-gray-500 text-xs"},er=["href"],tr={key:0,class:"text-gray-500"},sr={key:1,class:"space-y-1"},lr={key:0,class:"text-gray-500 text-xs"},ar=["onClick"],or={key:2,class:"flex gap-2 items-center mt-2"},nr={key:3,class:"mt-2 text-gray-500 text-xs"},ir=["href"],rr=["href"],dr={key:0},ur={key:9},cr={key:0,class:"mt-6"},mr={class:"move-teacher-row"},hr={class:"move-teacher-select"},pr={class:"mt-2"},vr={class:"mt-1"},fr={class:"mt-6"},gr={class:"shares-list"},yr={class:"mt-6"},_r={class:"mt-6"},br=["href"],xr={class:"flex flex-wrap gap-1"},kr={key:0,class:"bg-yellow-100 px-2 py-0.5 rounded text-xs text-yellow-800"},wr={key:1,class:"bg-red-100 px-2 py-0.5 rounded text-red-800 text-xs"},Sr={key:2,class:"bg-gray-100 px-2 py-0.5 rounded text-gray-800 text-xs"},Er={key:3,class:"bg-orange-100 px-2 py-0.5 rounded text-orange-800 text-xs"},Cr={key:0,class:"flex flex-wrap gap-1 mt-2"},$r={class:"exam-students"},Ar=["onClick"],Tr={key:1},Dr={key:2},Nr={key:0},Lr={key:1,class:"text-gray-500 text-sm"},Vr=["onClick"],Ur={key:3,class:"text-gray-500 text-sm"},Ir=["onClick"],Mr={key:5,class:"text-gray-500 text-sm"},Rr={class:"modal-title"},Pr={class:"text-center",style:{display:"flex","flex-direction":"column","justify-content":"space-around","align-items":"center"}},Br={style:{display:"flex","flex-direction":"column","justify-content":"space-around","align-items":"center"}},Or={key:0},Fr={key:1},Hr={class:"flex flex-col gap-2 mt-3"},Gr={style:{"z-index":"9999",position:"fixed",top:"300px",left:"40%"}};function zr(l,t,d,s,n,a){const p=le("SearchHistoryInput"),y=le("PrimaryButton"),h=le("SecondaryButton"),g=le("Column"),V=le("EditableField"),A=le("SchoolSelect"),w=le("FormatDate"),c=le("DataTable"),b=le("VueMultiselect"),f=le("SplitButton"),N=le("RepeatedPressButton"),H=le("UserExamTransfers"),R=le("AdminDialog"),z=le("ExamModal"),P=le("Checkbox"),C=le("DialogActions"),S=Re("tooltip");return o(),r("div",{class:de(["wrapper",{blur:s.status==="loading"}])},[e("div",qi,[e("div",Qi,[u(p,{modelValue:s.email,"onUpdate:modelValue":t[0]||(t[0]=v=>s.email=v),storageKey:"admin-user-search-history",label:"Enter user email",style:{width:"300px"},onSubmit:s.searchUserByEmail},null,8,["modelValue","onSubmit"])]),u(y,{label:"Load user",onClick:t[1]||(t[1]=v=>s.searchUserByEmail())}),d.userEmail?(o(),I(h,{key:0,label:"Load my user",onClick:t[2]||(t[2]=v=>s.searchUserByEmail(d.userEmail))})):E("",!0)]),a.hasUser?(o(),r("div",Ji,[u(c,{value:a.userInfoRows,class:"mb-4"},{default:k(()=>[u(g,{field:"label",header:"Field",style:{width:"200px","font-weight":"bold"}}),u(g,{header:"Value"},{body:k(({data:v})=>[v.key==="firstName"?(o(),r(O,{key:0},[a.isSupportAdmin?(o(),I(V,{key:0,modelValue:s.editedFields.firstName,"onUpdate:modelValue":t[3]||(t[3]=T=>s.editedFields.firstName=T),originalValue:s.user.firstName,saved:s.savedFields.firstName,error:s.fieldErrors.firstName,style:{width:"500px"},onSave:t[4]||(t[4]=T=>a.saveField("firstName"))},null,8,["modelValue","originalValue","saved","error"])):(o(),r(O,{key:1},[_(i(s.user.firstName),1)],64))],64)):v.key==="lastName"?(o(),r(O,{key:1},[a.isSupportAdmin?(o(),I(V,{key:0,modelValue:s.editedFields.lastName,"onUpdate:modelValue":t[5]||(t[5]=T=>s.editedFields.lastName=T),originalValue:s.user.lastName,saved:s.savedFields.lastName,error:s.fieldErrors.lastName,style:{width:"500px"},onSave:t[6]||(t[6]=T=>a.saveField("lastName"))},null,8,["modelValue","originalValue","saved","error"])):(o(),r(O,{key:1},[_(i(s.user.lastName),1)],64))],64)):v.key==="email"?(o(),r(O,{key:2},[a.isSupportAdmin?(o(),I(V,{key:0,modelValue:s.editedFields.email,"onUpdate:modelValue":t[7]||(t[7]=T=>s.editedFields.email=T),originalValue:s.user.email,type:"email",saved:s.savedFields.email,error:s.fieldErrors.email,style:{width:"500px"},onSave:t[8]||(t[8]=T=>a.saveField("email"))},null,8,["modelValue","originalValue","saved","error"])):(o(),r(O,{key:1},[_(i(s.user.email),1)],64)),a.canLoginAsUser?(o(),r("div",Zi,[e("a",{href:a.loginLink(),target:"_blank"},"Login as this user",8,er)])):E("",!0)],64)):v.key==="adminPortal"?(o(),r(O,{key:3},[a.adminPortalRoots.length===0?(o(),r("p",tr," None ")):(o(),r("ul",sr,[(o(!0),r(O,null,te(a.adminPortalRoots,T=>(o(),r("li",{key:T.id,class:"flex gap-3 items-center"},[e("span",null,[_(i(T.namn)+" (id: "+i(T.id)+") ",1),T.isGroupParent?(o(),r("span",lr,"group parent")):E("",!0)]),a.isSupportAdmin?(o(),r("a",{key:0,href:"#",class:"text-red-600 text-xs",onClick:ve(M=>a.revokeAdminPortalAccess(T.id),["prevent"])},"Remove",8,ar)):E("",!0)]))),128))])),a.isSupportAdmin?(o(),r("div",or,[u(A,{ref:"adminPortalSchoolSelect",modelValue:n.adminPortalSchool,"onUpdate:modelValue":t[9]||(t[9]=T=>n.adminPortalSchool=T),options:s.schoolList,optionLabel:"label",optionValue:"id",filter:"",filterFields:["search"],autoFilterFocus:"",showClear:"",virtualScrollerOptions:{itemSize:38},placeholder:"Search by school name","aria-label":"Admin portal root school",style:{width:"24rem"},onFilter:t[10]||(t[10]=T=>s.rewindPicker(l.$refs.adminPortalSchoolSelect))},null,8,["modelValue","options"]),u(h,{label:"Grant",size:"small",disabled:n.adminPortalSchool===null,onClick:t[11]||(t[11]=T=>a.grantAdminPortalAccess(n.adminPortalSchool))},null,8,["disabled"]),a.hasSchool?(o(),I(h,{key:0,label:"Grant own school",size:"small",disabled:a.ownSch
3oolIsAdminPortalRoot,onClick:t[12]||(t[12]=T=>a.grantAdminPortalAccess(s.user.school.id))},null,8,["disabled"])):E("",!0)])):E("",!0),a.canLoginToHmpAsUser?(o(),r("div",nr,[e("a",{href:a.hmpLoginLink(),target:"_blank"},"Login to admin portal as this user",8,ir)])):E("",!0)],64)):v.key==="school"?(o(),r(O,{key:4},[e("a",{href:"#",onClick:t[13]||(t[13]=ve(T=>a.loadSchool(s.user.school),["prevent"]))},i(s.user.school.namn)+" (id: "+i(s.user.school.id)+") ",1),a.isSupportAdmin?(o(),r("a",{key:0,href:"/admin/school/"+s.user.school.id,target:"_blank",class:"ml-3"},[u(h,{label:"Open teacher list as administrator",size:"small"})],8,rr)):E("",!0)],64)):v.key==="resetPassword"?(o(),r(O,{key:5},[e("a",{href:"#",onClick:t[14]||(t[14]=ve((...T)=>a.resetPasswordLink&&a.resetPasswordLink(...T),["prevent"]))}," Create and open link "),t[23]||(t[23]=_(" (Note that a new link will make previous links invalid) ",-1))],64)):v.key==="extensions"?(o(),r(O,{key:6},[_(i(s.user.extended_accesses.map(T=>T.access_to))+" ",1),e("a",{href:"#",onClick:t[15]||(t[15]=ve((...T)=>a.extendAccess&&a.extendAccess(...T),["prevent"]))}," Give 5 new days ")],64)):v.key==="productUsage"?(o(),r(O,{key:7},[Z((o(),r("span",null,[e("i",{class:de(["fa",s.user.first_exam_use?"fa-check":"fa-times"]),style:ke({color:s.user.first_exam_use?"var(--green-500)":"var(--gray-600)"})},null,6),t[24]||(t[24]=_(" Exam ",-1))])),[[S,"Has logged in to Exam directly (first_exam_use is set)"]]),t[26]||(t[26]=_("    ",-1)),Z((o(),r("span",null,[e("i",{class:de(["fa",s.user.external_activity_at?"fa-check":"fa-times"]),style:ke({color:s.user.external_activity_at?"var(--green-500)":"var(--gray-600)"})},null,6),t[25]||(t[25]=_(" KM2 ",-1))])),[[S,"Has been active in KM2 (external_activity_at is set)"]])],64)):v.key==="lastLogin"?(o(),r(O,{key:8},[s.user.login_at?Z((o(),r("span",dr,[u(w,{datetime:s.user.login_at},null,8,["datetime"])])),[[S,"Your browser's local time"]]):(o(),r(O,{key:1},[_("N/A")],64))],64)):v.key==="registeredAt"?Z((o(),r("span",ur,[u(w,{datetime:s.user.created_at},null,8,["datetime"])])),[[S,"Your browser's local time"]]):v.key==="examCoordinator"?(o(),r(O,{key:10},[e("i",{class:de(["fa mr-2",s.user.is_exam_coordinator?"fa-check":"fa-times"]),style:ke({color:s.user.is_exam_coordinator?"var(--green-500)":"var(--gray-600)"})},null,6),u(h,{label:s.user.is_exam_coordinator?"Demote":"Promote",size:"small",onClick:a.toggleExamCoordinator},null,8,["label","onClick"])],64)):(o(),r(O,{key:11},[_(i(v.value),1)],64))]),_:1})]),_:1},8,["value"]),a.isSupportAdmin?(o(),r("div",cr,[t[27]||(t[27]=e("h3",null,"Move teacher",-1)),e("div",mr,[e("div",hr,[u(b,{ref:"multiselect",modelValue:n.chosenSchool,"onUpdate:modelValue":t[16]||(t[16]=v=>n.chosenSchool=v),optionsLimit:500,options:s.schoolList,closeOnSelect:"",clearOnSelect:!1,placeholder:"Enter school",label:"label"},null,8,["modelValue","options"])]),u(f,{label:"Move without student data",rounded:"",model:n.moveMenuItems,disabled:n.chosenSchool==null,onClick:t[17]||(t[17]=v=>a.showMoveDialog(!1))},null,8,["model","disabled"])]),e("div",pr,[s.user.school?(o(),I(N,{key:0,title:"Remove school belonging",onClick:a.removeSchool},null,8,["onClick"])):E("",!0)]),e("div",vr,[u(N,{title:"Delete teacher and all connected data",onClick:a.deleteUser},null,8,["onClick"])])])):E("",!0),e("div",fr,[t[28]||(t[28]=e("h3",null,"Shares",-1)),e("div",gr,i(s.user.shares),1)]),e("div",yr,[u(H,{userId:s.user.id},null,8,["userId"])]),e("div",_r,[t[29]||(t[29]=e("h3",null,"Prov",-1)),u(c,{value:a.exams,size:"small",stripedRows:"",paginator:"",rows:500,rowsPerPageOptions:[100,500,1e3]},{default:k(()=>[u(g,{header:"Exam key",style:{width:"120px"}},{body:k(({data:v})=>[e("a",{href:s.buildAdminTabLink("exams-students",{key:v.examkey})},[e("b",null,i(v.examkey),1)],8,br)]),_:1}),u(g,{header:"Name"},{body:k(({data:v})=>[_(i(v.name),1)]),_:1}),u(g,{header:"Type",style:{width:"100px"}},{body:k(({data:v})=>[_(i(a.examType(v)),1)]),_:1}),u(g,{header:"Status",style:{width:"250px"}},{body:k(({data:v})=>[e("div",xr,[v.archived_at!=null?(o(),r("span",kr,"Archived")):E("",!0),v.deleted_at!=null?(o(),r("span",wr,"Deleted")):E("",!0),v.is_hidden==1?(o(),r("span",Sr,"Hidden")):E("",!0),v.school_id>0&&Number(v.school_id)!==s.user.school_id?(o(),r("span",Er,"Other school")):E("",!0)]),a.examHasActions(v)&&a.isSupportAdmin?(o(),r("div",Cr,[v.is_hidden||v.school_id>0&&Number(v.school_id)!==s.user.school_id?(o(),I(N,{key:0,title:"Unhide exam",onClick:T=>a.unhideExam(v)},null,8,["onClick"])):E("",!0),v.archived_at!=null?(o(),I(N,{key:1,title:"Unarchive exam",onClick:T=>a.unarchiveExam(v)},null,8,["onClick"])):E("",!0),v.archived_at!=null?(o(),I(N,{key:2,title:"Unarchive + reset date",onClick:T=>a.unarchiveExam(v,{resetCreatedAt:!0})},null,8,["onClick"])):E("",!0)])):E("",!0)]),_:1}),u(g,{header:"Origin",style:{"white-space":"nowrap"}},{body:k(({data:v})=>[_(i(v.origin==="gauss"?"KM2 / Maths":"Exam.net"),1)]),_:1}),u(g,{header:"Students"},{body:k(({data:v})=>[e("div",$r,[(o(!0),r(O,null,te(a.studentsForExam(v.id),(T,M)=>(o(),r("span",{key:T.id},[a.isSupportAdmin?(o(),r("a",{key:0,class:"cursor-pointer hover:text-blue-600 underline",onClick:Y=>a.showStudent(T)},i(a.formatStudentName(T)),9,Ar)):(o(),r("span",Tr,i(a.formatStudentName(T)),1)),M<a.studentsForExam(v.id).length-1?(o(),r("span",Dr,", ")):E("",!0)]))),128))])]),_:1})]),_:1},8,["value"])])])):E("",!0),u(R,{visible:n.studentDialogVisible,"onUpdate:visible":t[19]||(t[19]=v=>n.studentDialogVisible=v),header:"Student info",modal:"",dismissableMask:"",style:{width:"650px"}},{default:k(()=>[n.student!=null?(o(),r("div",Nr,[u(c,{value:a.studentInfoRows,class:"mb-4"},{default:k(()=>
3[u(g,{field:"label",header:"Field",style:{width:"120px","font-weight":"bold"}}),u(g,{header:"Value"},{body:k(({data:v})=>[v.label==="Answer"?(o(),r("a",{key:0,class:"cursor-pointer hover:text-blue-600 underline",onClick:t[18]||(t[18]=T=>a.showAnswerModal(n.student.answer))},"Show answer")):(o(),r(O,{key:1},[_(i(v.value),1)],64))]),_:1})]),_:1},8,["value"]),t[30]||(t[30]=e("h4",{class:"font-semibold mb-2 mt-4"},"Logs",-1)),a.studentLogs.length>0?(o(),I(c,{key:0,value:a.studentLogs,size:"small"},{default:k(()=>[u(g,{header:"Date"},{body:k(({data:v})=>[_(i(a.formatDate(v.created_at)),1)]),_:1}),u(g,{field:"type",header:"Type"})]),_:1},8,["value"])):(o(),r("div",Lr," No logs ")),t[31]||(t[31]=e("h4",{class:"font-semibold mb-2 mt-4"},"Backups",-1)),a.studentBackups.length>0?(o(),I(c,{key:2,value:a.studentBackups,size:"small"},{default:k(()=>[u(g,{header:"Date"},{body:k(({data:v})=>[e("a",{class:"cursor-pointer hover:text-blue-600 underline",onClick:T=>a.showAnswerModal(v.answer)},i(a.formatDate(v.created_at)),9,Vr)]),_:1})]),_:1},8,["value"])):(o(),r("div",Ur," No backups ")),t[32]||(t[32]=e("h4",{class:"font-semibold mb-2 mt-4"},"Offline saves",-1)),a.studentOfflineSaves.length>0?(o(),I(c,{key:4,value:a.studentOfflineSaves,size:"small"},{default:k(()=>[u(g,{header:"Date"},{body:k(({data:v})=>[_(i(a.formatDate(v.created_at)),1)]),_:1}),u(g,{header:"Answer"},{body:k(({data:v})=>[e("a",{class:"cursor-pointer hover:text-blue-600 underline",onClick:T=>a.showAnswerModal(v.new_answer)},"Ny",8,Ir)]),_:1})]),_:1},8,["value"])):(o(),r("div",Mr," No offline saves "))])):E("",!0)]),_:1},8,["visible"]),u(z,{ref:"studentAnswerModal",size:"lg"},{title:k(()=>[e("h3",Rr,i(l.__("Student answer")),1)]),body:k(()=>[e("div",Pr,i(n.answer),1)]),footer:k(()=>[e("div",Br,[u(h,{"data-dismiss":"modal",label:l.__("Close")},null,8,["label"])])]),_:1},512),u(R,{visible:n.moveDialogVisible,"onUpdate:visible":t[22]||(t[22]=v=>n.moveDialogVisible=v),header:n.moveExamsWithTeacher?"Move with student data":"Move without student data",modal:"",style:{width:"500px"}},{footer:k(()=>[u(C,{primary:{label:"Move",onAction:a.moveUser},secondary:{label:"Cancel",onAction:()=>n.moveDialogVisible=!1}},null,8,["primary","secondary"])]),default:k(()=>{var v,T;return[n.moveExamsWithTeacher?(o(),r("p",Or,[t[33]||(t[33]=_(" The teacher will be moved to ",-1)),e("em",null,i((v=n.chosenSchool)==null?void 0:v.namn),1),t[34]||(t[34]=_(". ",-1)),t[35]||(t[35]=e("strong",null,"Their exams with student data will remain accessible at the new school.",-1))])):(o(),r("p",Fr,[t[36]||(t[36]=_(" The teacher will be moved to ",-1)),e("em",null,i((T=n.chosenSchool)==null?void 0:T.namn),1),t[37]||(t[37]=_(". ",-1)),t[38]||(t[38]=e("strong",null,"Their exams with student data will stay at the old school",-1)),t[39]||(t[39]=_(" — they won't be able to access them unless support restores access. ",-1))])),e("div",Hr,[u(P,{modelValue:n.keepIncomingShares,"onUpdate:modelValue":t[20]||(t[20]=M=>n.keepIncomingShares=M),label:"Keep shares received from others"},null,8,["modelValue"]),u(P,{modelValue:n.keepExamShares,"onUpdate:modelValue":t[21]||(t[21]=M=>n.keepExamShares=M),disabled:!n.moveExamsWithTeacher,label:"Keep shares given to others"},null,8,["modelValue","disabled"])])]}),_:1},8,["visible","header"]),Z(e("div",Gr,[...t[40]||(t[40]=[e("i",{style:{"font-size":"200px"},class:"fa fa-spin fa-spinner"},null,-1)])],512),[[ue,s.status==="loading"]])],2)}const Kr=ie(ji,[["render",zr],["__scopeId","data-v-1d3fc0e1"]]),Xr={components:{VueMultiselect:Be,PrimaryButton:re},data(){return{Modal:ze,dpas:[],schoolList:[],chosenSchool:null,chosenDPA:null,connectStatus:"",createStatus:"",isLoading:!1}},methods:{createDPA(){this.createStatus="pending",F.post("/api/licence/dpas",{school_id:this.chosenSchool.id}).then(()=>{this.createStatus="",this.load()})},doneConnecting(){this.load(),ze.hide(this.$refs.connectSchoolsModal),this.chosenSchool=null,this.chosenDPA=null},willConnect(l){this.chosenDPA=l,ze.show(this.$refs.connectSchoolsModal)},connect(){this.connectStatus="pending",F({method:"post",url:`/api/licence/dpas/${this.chosenDPA.id}/connect`,data:{school_id:this.chosenSchool.id}}).then(()=>{this.connectStatus="success"})},asyncFind(l){this.isLoading=!0,F({url:`/api/site-admin/schools?name=${l}`}).then(({data:t})=>{this.schoolList=t,this.isLoading=!1})},openNewView(){window.open(window.location.hostname==="exam.test"?"http://localhost:5175/admin":"https://legal.teachiq.com/admin")},load(){F({url:"/api/licence/dpas"}).then(({data:l})=>{this.dpas=l.sort((t,d)=>t.email.localeCompare(d.email))})},mark(l){F({method:"post",url:`/api/licence/dpas/${l.id}/sign`}).then(({data:t})=>{this.dpas=t.sort((d,s)=>d.email.localeCompare(s.email))})}}},Wr={class:"wrapper"},Yr={key:0},jr={key:1},qr={class:"flex gap-3 ml-3 mt-3"},Qr={key:0,style:{display:"flex","align-items":"center"}},Jr=["onClick"],Zr=["onClick"],ed={key:1,class:"flex items-center justify-center"},td=["onClick"];
3function sd(l,t,d,s,n,a){const p=le("VueMultiselect"),y=le("PrimaryButton"),h=le("ExamModal");return o(),r("div",Wr,[u(h,{ref:"connectSchoolsModal",size:"md"},{title:k(()=>[...t[3]||(t[3]=[e("h3",{class:"modal-title"},"Connect more school to this agreement",-1)])]),body:k(()=>[e("div",null,[u(p,{ref:"multiselect",modelValue:n.chosenSchool,"onUpdate:modelValue":t[0]||(t[0]=g=>n.chosenSchool=g),optionsLimit:500,options:n.schoolList,closeOnSelect:"",clearOnSelect:!1,placeholder:"Sök efter skola",label:"namn",trackBy:"id",isLoading:n.isLoading,onSearchChange:a.asyncFind},{default:k(()=>[st(l.$slots,"noOptions",{},()=>[t[4]||(t[4]=_("Write to search for school",-1))],!0)]),_:3},8,["modelValue","options","isLoading","onSearchChange"]),u(y,{label:"Connect",onClick:a.connect},null,8,["onClick"]),u(y,{label:"Done",onClick:a.doneConnecting},null,8,["onClick"]),n.connectStatus==="pending"?(o(),r("p",Yr,"Sending ...")):E("",!0),n.connectStatus==="success"?(o(),r("p",jr,"Connected!")):E("",!0)])]),_:3},512),u(h,{ref:"addSchoolModal",size:"md"},{title:k(()=>[...t[5]||(t[5]=[e("h3",{class:"modal-title"},"Add agreement for school manually",-1)])]),body:k(()=>[e("div",null,[u(p,{ref:"multiselect",modelValue:n.chosenSchool,"onUpdate:modelValue":t[1]||(t[1]=g=>n.chosenSchool=g),options:n.schoolList,optionsLimit:500,closeOnSelect:"",clearOnSelect:!1,placeholder:"Search for school",label:"namn",trackBy:"id",isLoading:n.isLoading,onSearchChange:a.asyncFind},{default:k(()=>[st(l.$slots,"noOptions",{},()=>[t[6]||(t[6]=_("Write to search for school",-1))],!0)]),_:3},8,["modelValue","options","isLoading","onSearchChange"]),u(y,{loading:n.createStatus==="pending",label:"Create",onClick:a.createDPA},null,8,["loading","onClick"])])]),_:3},512),e("div",qr,[u(y,{label:"Open view to handle signed agreements",onClick:a.openNewView},null,8,["onClick"]),u(y,{label:"Load",onClick:a.load},null,8,["onClick"]),u(y,{label:"Register school manually",onClick:t[2]||(t[2]=g=>n.Modal.show(l.$refs.addSchoolModal))})]),(o(!0),r(O,null,te(n.dpas,g=>(o(),r("div",{key:g.id,class:de(["dpa",{green:g.signed_at}])},[_(" Skolid "+i(g.school_id)+" - "+i(g.email)+" - "+i(g.school&&g.school.namn)+" ",1),t[7]||(t[7]=e("span",{style:{"margin-left":"50px"}},null,-1)),g.signed_at?(o(),r("div",Qr,[_(i(g.signed_at)+" ",1),e("span",{class:"cursor-pointer ml-4 underline",onClick:V=>a.mark(g)}," Update date for signing to now ",8,Jr),e("span",{class:"cursor-pointer ml-4 underline",onClick:V=>a.willConnect(g)}," Connect more schools to this agreement ",8,Zr)])):(o(),r("div",ed,[e("span",{class:"cursor-pointer ml-4 underline",onClick:V=>a.mark(g)}," Mark as signed ",8,td)]))],2))),128))])}const ld=ie(Xr,[["render",sd],["__scopeId","data-v-3ff9e9d4"]]),ad={components:{PrimaryButton:re},data(){return{bek:""}},methods:{send(){window.$.ajax({url:"/api/sebhashes",method:"post",data:{bek:this.bek},success:l=>{console.log(l),this.bek=""}})}}},od={class:"wrapper"};function nd(l,t,d,s,n,a){const p=le("ElInput"),y=le("PrimaryButton");return o(),r("div",od,[t[1]||(t[1]=e("h3",null,"Hantera BEK",-1)),u(p,{modelValue:n.bek,"onUpdate:modelValue":t[0]||(t[0]=h=>n.bek=h)},null,8,["modelValue"]),t[2]||(t[2]=e("br",null,null,-1)),u(y,{label:l.__("Send"),onClick:a.send},null,8,["label","onClick"])])}const id=ie(ad,[["render",nd],["__scopeId","data-v-1404b4ab"]]),rd={components:{PrimaryButton:re},data(){return{hash:"",hashes:"",suspiciousHash:"",suspiciousHashDescription:"",suspiciousHashes:""}},mounted(){this.show()},methods:{initHashList(){this.hashes="",this.suspiciousHashes="",this.show()},show(){F.get("/api/site-admin/seb-valid-hashes").then(l=>{l.data.length>0&&(this.hashes=l.data)}),F.get("/api/site-admin/seb-suspicious-hashes").then(l=>{l.data.length>0&&(this.suspiciousHashes=l.data)})},store(){F.post("/api/site-admin/seb-valid-hashes",{hash:this.hash}).then(()=>{this.hash="",this.initHashList()})},addSuspicious(){F.post("/api/site-admin/seb-suspicious-hashes",{hash:this.suspiciousHash,description:this.suspiciousHashDescription}).then(()=>{this.suspiciousHash="",this.suspiciousHashDescription="",this.initHashList()})},destroy(l){F.delete(`/api/site-admin/seb-valid-hashes/${l}`).then(()=>{this.initHashList()})},truncate(){F.delete("/api/site-admin/seb-valid-hashes/truncate").then(()=>{this.initHashList()})}}},dd={class:"container mt-4"},ud={class:"gap-6 grid grid-cols-2 lg:grid-cols-2 mb-14 md:grid-cols-2 sm:grid-cols-2"},cd={class:"bg-white col-span-1 flex flex-col rounded-lg shadow text-center"},md={class:"flex flex-1 flex-col items-baseline p-3"},hd={class:"w-full"},pd={key:0},vd={class:"flex flex-col gap-3"},fd={class:"gap-6 grid grid-cols-2 lg:grid-cols-2 mb-14 md:grid-cols-2 mt-8 sm:grid-cols-2"},gd={class:"bg-white col-span-1 flex flex-col rounded-lg shadow text-center"},yd={class:"flex flex-1 flex-col items-baseline p-3"},_d={class:"w-full"},bd={key:1};
3function xd(l,t,d,s,n,a){const p=le("PrimaryButton");return o(),r("div",dd,[e("ul",ud,[e("li",cd,[e("div",md,[e("div",hd,[t[3]||(t[3]=e("h3",{style:{"margin-bottom":"25px"}},"Add allowed SEB hash",-1)),Z(e("input",{"onUpdate:modelValue":t[0]||(t[0]=y=>n.hash=y),class:"block form-input p-4 sm:leading-5 text-base w-full",placeholder:"SEB hash"},null,512),[[Se,n.hash]]),t[4]||(t[4]=e("br",null,null,-1)),u(p,{label:"Add",onClick:a.store},null,8,["onClick"])])])])]),n.hashes?(o(),r("div",pd,[e("ul",vd,[(o(!0),r(O,null,te(n.hashes,y=>(o(),r("li",{key:y.id},[u(p,{label:l.__("Delete"),onClick:h=>a.destroy(y.id)},null,8,["label","onClick"]),_(" "+i(y.hash),1)]))),128))]),t[5]||(t[5]=e("br",null,null,-1)),t[6]||(t[6]=e("br",null,null,-1)),n.hashes?(o(),I(p,{key:0,style:{display:"inline"},label:"Delete all",onClick:a.truncate},null,8,["onClick"])):E("",!0)])):E("",!0),e("ul",fd,[e("li",gd,[e("div",yd,[e("div",_d,[t[7]||(t[7]=e("h3",{style:{"margin-bottom":"25px"}},"Add suspicious SEB hash",-1)),Z(e("input",{"onUpdate:modelValue":t[1]||(t[1]=y=>n.suspiciousHash=y),class:"block form-input p-4 sm:leading-5 text-base w-full",placeholder:"SEB hash"},null,512),[[Se,n.suspiciousHash]]),t[8]||(t[8]=e("br",null,null,-1)),Z(e("input",{"onUpdate:modelValue":t[2]||(t[2]=y=>n.suspiciousHashDescription=y),class:"block form-input p-4 sm:leading-5 text-base w-full",placeholder:"Description"},null,512),[[Se,n.suspiciousHashDescription]]),t[9]||(t[9]=e("br",null,null,-1)),u(p,{label:"Add",onClick:a.addSuspicious},null,8,["onClick"])])])])]),n.suspiciousHashes?(o(),r("div",bd,[e("ul",null,[(o(!0),r(O,null,te(n.suspiciousHashes,y=>(o(),r("li",{key:y.id},i(y.hash)+" ("+i(y.description)+") ",1))),128))]),t[10]||(t[10]=e("br",null,null,-1)),t[11]||(t[11]=e("br",null,null,-1))])):E("",!0)])}const kd=ie(rd,[["render",xd]]),wd={class:"p-6 wrapper"},Sd={class:"mb-4"},Ed={class:"flex gap-2"},Cd={class:"cursor-pointer flex gap-2 items-center mt-2 text-gray-700 text-sm"},$d={key:0,class:"text-gray-500 text-sm"},Ad={key:1,class:"mt-4"},Td={key:0,class:"mb-2 text-gray-700"},Dd={key:0,class:"bg-red-50 border border-red-300 mb-3 p-3 rounded text-red-900 text-sm"},Nd={class:"font-medium mb-2 text-gray-700"},Ld={key:0},Vd={key:1},Ud={class:"border border-gray-200 mb-4 overflow-hidden rounded-lg"},Id={class:"font-mono"},Md={class:"text-gray-500"},Rd={key:2,class:"bg-green-50 border border-green-300 mt-4 p-3 rounded text-green-900 text-sm"},Pd={class:"font-semibold mb-1"},Bd=ne({__name:"MarketingWebsiteCache",setup(l){const t=x(""),d=x(!1),s=x(null),n=x(!1),a=x(null);function p(w){return w.split(",").map(c=>c.trim()).filter(c=>c!=="")}function y(){return j(this,null,function*(){n.value=!0,a.value=null;try{const{data:w}=yield F.get("/api/site-admin/marketing-cache/preview",{params:{terms:p(t.value),enforceSuffix:d.value},paramsSerializer:{indexes:!1}});s.value=w}finally{n.value=!1}})}function h(){return t.value="blog",d.value=!0,y()}function g(w){var b;const c=(b=s.value)==null?void 0:b.savedAt[w];return c?new Date(c).toLocaleString("sv-SE",{dateStyle:"short",timeStyle:"short"}):"unknown"}function V(){return j(this,null,function*(){if(s.value===null)return;const{data:w}=yield F.post("/api/site-admin/marketing-cache/purge",{terms:s.value.terms,enforceSuffix:s.value.enforceSuffix});a.value=w.purged,s.value=null,t.value=""})}function A(w){const c="marketing-cache--",b=w.indexOf(c);if(b===-1)return w;const f=w.slice(b+c.length),N=f.lastIndexOf("--");if(N===-1)return w;const H=f.slice(0,N);return H===""?"/ (homepage)":H.length>=30?`/${H}…`:`/${H}`}return(w,c)=>(o(),r("div",wd,[c[11]||(c[11]=Et('<h2 class="font-semibold mb-2 text-lg" data-v-3e28fc2c>Release marketing website changes</h2><p class="mb-3 text-gray-700 text-sm" data-v-3e28fc2c> exam.net caches its public pages so that Wordpress edits are not released to visitors automatically. Use this tool to release your latest changes to the live site. </p><div class="bg-yellow-50 border border-yellow-300 mb-4 p-3 rounded text-sm text-yellow-900" data-v-3e28fc2c><p class="font-semibold mb-1" data-v-3e28fc2c>Before you release:</p><p data-v-3e28fc2c> Preview every page you are about to release on <a href="https://marketing-assets.exam.net" target="_blank" rel="noopener" class="font-medium text-yellow-900 underline" data-v-3e28fc2c>marketing-assets.exam.net</a> first. Whatever is live there now is exactly what visitors to exam.net will see after you release. </p></div>',3)),e("div",Sd,[c[3]||(c[3]=e("label",{class:"block font-medium mb-1 text-sm"},"Which pages do you want to release?",-1)),e("div",Ed,[Z(e("input",{"onUpdate:modelValue":c[0]||(c[0]=b=>t.value=b),class:"flex-1 p-2 rounded",placeholder:'e.g. "blog/chatgpt" or "pricing" (leave empty to select everything)',onKeyup:rt(y,["enter"])},null,544),[[Se,t.value]]),u(re,{label:"Click to see matches",disabled:n.value,onClick:y},null,8,["disabled"]),u(fe,{label:"Blog landing pages",disabled:n.value,onClick:h},null,8,["disabled"])]),c[4]||(c[4]=e("p",{class:"mt-1 text-gray-500 text-xs"},' Type any part of a URL (e.g. "blog/" to release all blog posts, "sv/" for all Swedish pages). Separate multiple entries with commas — e.g. "pricing, how-it-works". ',-1)),e("label",Cd,[Z(e("input",{"onUpdate:modelValue":c[1]||(c[1]=b=>d.value=b),type:"checkbox"},null,512),[[Ct,d.value]]),c[2]||(c[2]=e("span",null,[_(" Enforce suffix — match only pages whose URL "),e("em",null,"ends"),_(' with the text above, not their sub-pages (e.g. "sv/blog" matches the blog index only, not the "sv/blog/…" articles). ')],-1))])]),n.value?(o(),r("div",$d,[...c[5]||(c[5]=[e("i",{class:"fa fa-spin fa-spinner"},null,-1),_(" Loading… ",-1)])])):s.value?(o(),r("div",Ad,[s.value.total===0?(o(),r("p",Td,[c[6]||(c[6]=_(" No cached pages match ",-1)),e("code",null,i(s.value.terms.join(", ")),1),c[7]||(c[7]=_(". ",-1))])):(o(),r(O,{key:1},[s.value.terms.length===0?(o(),r("div",Dd,[...c[8]||(c[8]=[e("strong",null,"Heads up:",-1),_(" you are releasing the entire marketing website. Every page currently published to marketing-assets.exam.net — ready or not — will go live on exam.net. Double-check everything on marketing-assets first; any unpublished edits in the editing environment are ",-1),e("em",null,"not",-1),_(" affected. ",-1)])])):E("",!0),e("p",Nd,[s.value.terms.length>0?(o(),r("span",Ld,[_(i(s.value.total)+" "+i(s.value.total===1?"page":"pages")+" matching ",1),e("code",null,i(s.value.terms.join(", ")),1),c[9]||(c[9]=_(" will be released: ",-1))])):(o(),r("span",Vd,i(s.value.total)+" pages will be released (the entire marketing website): ",1))]),e("ul",Ud,[(o(!0),r(O,null,te(s.value.keys,(b,f)=>(o(),r("li",{key:b,class:de(["flex gap-4 justify-between px-3 py-1.5 text-gray-800 text-sm",f%2?"bg-gray-50":"bg-white"])},[e("span",Id,i(A(b)),1),e("span",Md,"cached "+i(g(b)),1)],2))),128))]),u(Je,{title:s.value.terms.length>0?`Release ${s.value.total} ${s.value.total===1?"page":"pages"}`:`Release all ${s.value.total} pages`,presses:3,onClick:V},null,8,["title"])],64))])):E("",!0),a.value!==null?(o(),r("div",Rd,[e("p",Pd,"Released "+i(a.value)+" "+i(a.value===1?"page":"pages")+".",1),c[10]||(c[10]=e("p",null," Visitors may 
3still see the old version for up to 2 more minutes due to a CDN cache (Front Door). After that, the next visit re-fetches each page from Wordpress. ",-1))])):E("",!0)]))}}),Od=ie(Bd,[["__scopeId","data-v-3e28fc2c"]]),Fd={components:{PrimaryButton:re},data(){return{ip:"",status:""}},methods:{allow(){this.status="",F.post("/api/site-admin/ips",{ip:this.ip}).then(()=>{this.status="added",this.ip=""})}}},Hd={class:"p-6 wrapper"},Gd={key:0};function zd(l,t,d,s,n,a){const p=le("PrimaryButton");return o(),r("div",Hd,[e("div",null,[Z(e("input",{"onUpdate:modelValue":t[0]||(t[0]=y=>n.ip=y),class:"p-2 rounded",placeholder:"123.123.123.123"},null,512),[[Se,n.ip]])]),e("div",null,[u(p,{style:{"margin-top":"10px","margin-bottom":"50px"},label:"Add allowed IP address",onClick:a.allow},null,8,["onClick"])]),n.status==="added"?(o(),r("p",Gd,"Ip address was added")):E("",!0)])}const Kd=ie(Fd,[["render",zd]]),Xd={class:"container mt-8"},Wd={class:"flex"},Yd={class:"ml-2"},jd={class:"ml-4"},qd={class:"ml-4"},Qd={class:"flex mt-16 select-none"},Jd={class:"flex-1"},Zd=["onClick"],eu={class:"underline"},tu={class:"flex-1"},su=["onClick"],lu={class:"underline"},au={class:"flex-1"},ou={class:"underline"},nu={class:"border-t-2 mt-64 pt-4"},iu={key:0},ru={key:1},du=["onClick"],uu=ne({__name:"UserEmail",setup(l){const t=x(""),d=x(""),s=x([]),n=x([]),a=x([]),p=x(new Date().toLocaleString("sv-SE",{timeZone:"Europe/Stockholm"}).slice(0,-3)),y=ee(()=>n.value.map(w=>xe(be({},w),{email:w.email.replace(/@.*/,`@${d.value}`)})));function h(){return j(this,null,function*(){const w=yield F.post("/api/site-admin/users/search",{email:t.value});s.value=w.data})}function g(){return j(this,null,function*(){if(Ge.secondsPassedSince(p.value)>120){alert("You can't set a time in the past");return}if(d.value.length<3||!d.value.includes(".")){alert("You have to provide a new domain");return}yield F.post("/api/site-admin/scheduled-user-email-updates",{users:y.value.map(w=>({id:w.id,email:w.email})),scheduled_at:Cs(p.value).utc().format("YYYY-MM-DD HH:mm")}),alert('Scheduled! Use the button to "Load scheduled updates" to double check.'),t.value="",d.value="",s.value=[],n.value=[],V()})}function V(){return j(this,null,function*(){const w=yield F.get("/api/site-admin/scheduled-user-email-updates");a.value=w.data})}function A(w){return j(this,null,function*(){yield F.delete(`/api/site-admin/scheduled-user-email-updates/${w}`),V()})}return(w,c)=>(o(),r("div",Xd,[c[14]||(c[14]=e("h3",null,"Update user emails",-1)),e("div",null,[e("div",Wd,[e("div",null,[c[3]||(c[3]=e("div",{class:"underline"},"Search for email",-1)),Z(e("input",{"onUpdate:modelValue":c[0]||(c[0]=b=>t.value=b),class:"p-2 rounded-lg",onKeyup:rt(h,["enter"])},null,544),[[Se,t.value]]),c[4]||(c[4]=e("div",null,[_("You can search for domain (ex. "),e("i",null,"school.se"),_("), "),e("br"),_("or the user part (ex. "),e("i",null,"lisa.larsson@"),_(").")],-1))]),e("div",Yd,[c[5]||(c[5]=e("div",{class:"underline"},"Enter new doamin (part after @)",-1)),Z(e("input",{"onUpdate:modelValue":c[1]||(c[1]=b=>d.value=b),class:"p-2 rounded-lg"},null,512),[[Se,d.value]])]),e("div",jd,[c[6]||(c[6]=e("div",{class:"underline"},"Choose day and time for update",-1)),Z(e("input",{"onUpdate:modelValue":c[2]||(c[2]=b=>p.value=b),class:"p-2 rounded-lg",type:"datetime-local"},null,512),[[Se,p.value]])]),e("div",qd,[c[7]||(c[7]=e("div",{class:"underline"},"Perform",-1)),u(fe,{label:`Perform for ${n.value.length} users`,onClick:g},null,8,["label"]),c[8]||(c[8]=e("div",null,[_(" At the time of the update, an email will be "),e("br"),_(" sent to all affected users (to the new email). ")],-1))])])]),e("div",Qd,[e("div",Jd,[c[9]||(c[9]=e("h3",null,"Search results",-1)),c[10]||(c[10]=e("h4",null,"Click to choose",-1)),(o(!0),r(O,null,te(s.value.filter(b=>!n.value.find(f=>f.id===b.id)),b=>{var f;return o(),r("div",{key:b.id,class:"break-all cursor-pointer hover:bg-white p-1 rounded-lg",onClick:N=>n.value.push(b)},[e("div",eu,i(b.email),1),e("div",null,i((f=b.school)==null?void 0:f.namn),1)],8,Zd)}),128))]),e("div",tu,[e("h3",null,"Added for update ("+i(n.value.length)+")",1),c[11]||(c[11]=e("h4",null,"Click to remove",-1)),(o(!0),r(O,null,te(n.value,b=>{var f;return o(),r("div",{key:b.id,class:"break-all cursor-pointer hover:bg-white p-1 rounded-lg",onClick:N=>n.value.splice(n.value.indexOf(b),1)},[e("div",lu,i(b.email),1),e("div",null,i((f=b.school)==null?void 0:f.namn),1)],8,su)}),128))]),e("div",au,[c[12]||(c[12]=e("h3",null,"Result after update",-1)),c[13]||(c[13]=e("h4",null,"Review email carefully",-1)),(o(!0),r(O,null,te(y.value,b=>{var f;return o(),r("div",{key:b.id,class:"break-all p-1 rounded-lg"},[e("div",ou,i(b.email),1),e("div",null,i((f=b.school)==null?void 0:f.namn),1)])}),128))])]),e("div",nu,[u(fe,{label:"Load scheduled updated",onClick:V}),(o(!0),r(O,null,te(a.value,b=>(o(),r("div",{key:b.id}
3,[b.completed_at?(o(),r("div",iu," User with id "+i(b.user_id)+" was updated to "+i(b.email)+" at "+i(m(Ge).formatFromUTC(b.completed_at,"YYYY-MM-DD HH:mm:ss")),1)):(o(),r("div",ru,[_(" User with id "+i(b.user_id)+" will be updated to "+i(b.email)+" at "+i(m(Ge).formatFromUTC(b.perform_at,"YYYY-MM-DD HH:mm:ss"))+" ",1),e("span",{class:"cursor-pointer text-red-500 underline",onClick:f=>A(b.id)}," Click to delete ",8,du)]))]))),128))])]))}}),cu={class:"container mt-8"},mu={class:"mb-12"},hu={class:"flex gap-16 items-start"},pu={class:"flex flex-col gap-4 w-96"},vu={key:0,class:"flex-1 min-w-0"},fu={key:0,class:"text-gray-600"},gu={key:0,class:"text-gray-600"},yu={key:1,class:"w-full"},_u={class:"font-mono pr-4 py-2"},bu={class:"pr-4 py-2"},xu=["href"],ku={class:"pr-4 py-2"},wu={class:"pr-4 py-2"},Su={class:"mt-8"},Eu=["href"],Cu=ne({__name:"GaussTesting",setup(l){const t=x("ABC123"),d=x(""),s=x(""),n=x(""),a=x(""),p=x(""),y=x(null);function h(){const w={calculator:!1,formulaChosen:"1",PDFs:JSON.stringify([{name:"sample-formulas.pdf",documentPages:["https://firebasestorage.googleapis.com/v0/b/exam-net-additional.appspot.com/o/local%2Fexams%2F707674EE-4194-4FA0-8FC5-0E18E2454576%2Ffiles%2FEsOWxdkpbUm9FGpBiDmo0VEYyI0ZpF%2F0.png?alt=media&token=66f5788b-00cd-41ea-b65f-817e663da35e","https://firebasestorage.googleapis.com/v0/b/exam-net-additional.appspot.com/o/local%2Fexams%2F707674EE-4194-4FA0-8FC5-0E18E2454576%2Ffiles%2FEsOWxdkpbUm9FGpBiDmo0VEYyI0ZpF%2F1.png?alt=media&token=d7bf9056-405d-4270-bc8a-96e17d100958"],documentPDF:"https://firebasestorage.googleapis.com/v0/b/exam-net-additional.appspot.com/o/local%2Fexams%2F707674EE-4194-4FA0-8FC5-0E18E2454576%2Ffiles%2FEsOWxdkpbUm9FGpBiDmo0VEYyI0ZpF%2Foriginal.pdf?alt=media&token=d4f2a8b6-938c-4e29-9487-71a269c17c5c"}]),writeArea:!1,spellChecking:!1,translate:!1,allow_tts:!1,resources:JSON.stringify({drawingArea:!1}),parts:{handinGroupedParts:[[0],[1],[2]],partsList:[{title:"Section A",description:"Section A: No calculator or digital tools allowed. Answer directly in the fields provided.",state:"WRITABLE",stateAfterSubmission:"HIDDEN",settings:{calculator:!1,answerAreas:!0},questions:[{id:1,subQuestions:[{id:1,type:"formatedInput",question:"<div>What is 2 + 2?</div>",answerOptions:{input:'<input type="text">'},formatting:{answerArea:{size:"auto"}},settings:{},point:1}]},{id:2,subQuestions:[{id:1,type:"multipleChoice",question:"<div>Which of these are prime numbers?</div>",answerOptions:[{id:1,label:"2"},{id:2,label:"4"},{id:3,label:"7"},{id:4,label:"9"}],formatting:{answerArea:null,previewType:"checkbox"},settings:{},point:2}],answers:{1:[1,3]},gradingRules:{1:[{id:1,correct:2,wrong:0,point:2}]}},{id:3,subQuestions:[{id:1,type:"freeText",question:"<div>Explain your reasoning.</div>",answerOptions:null,formatting:{answerArea:{size:"auto"}},settings:{},point:2}]}]},{title:"Section B",description:"Section B: Calculator and Desmos are unlocked after you submit Section A.",state:"TOOLS_ON_STUDENT_SUBMIT",stateAfterSubmission:"HIDDEN",settings:{calculator:!0,answerAreas:!0,resources:{desmos:!0,geogebra:"NONE"}},questions:[{id:4,subQuestions:[{id:1,type:"formatedInput",question:"<div>What is 12 × 8?</div>",answerOptions:{input:'<input type="text">'},formatting:{answerArea:{size:"auto"}},settings:{},point:1}]},{id:5,subQuestions:[{id:1,type:"freeText",question:"<div>Describe a real-world use of multiplication.</div>",answerOptions:null,formatting:{answerArea:{size:"auto"}},settings:{},point:3}]}]},{title:"Section C",description:"Section C: A final reflection, visible only after both Section A and Section B have been submitted.",state:"HIDDEN_UNTIL_STUDENT_SUBMIT",stateAfterSubmission:"HIDDEN",settings:{calculator:!1,answerAreas:!0},questions:[{id:6,subQuestions:[{id:1,type:"freeText",question:"<div>Reflect on what you learned in sections A and B.</div>",answerOptions:null,formatting:{answerArea:{size:"auto"}},settings:{},point:2}]}]}]}};Hs.send({url:"/gauss/v3/preview",newTab:!0,data:{examId:"0",exam:JSON.stringify(w)}})}function g(){d.value=we(8),s.value=we(8),n.value=ft(9),a.value=`${we(6)}@${we(4)}.com`}function V(){return j(this,null,function*(){const w=yield F.post("/api/site-admin/gauss/student-start",{examkey:t.value,firstName:d.value,lastName:s.value,email:a.value,externalId:n.value});p.value=w.data.startUrl})}function A(w){return j(this,null,function*(){const c=yield F.post("/api/site-admin/gauss/student-start",{examkey:w,firstName:we(8),lastName:we(8),email:`${we(6)}@${we(4)}.com`,externalId:ft(9)});window.open(c.data.startUrl,"_blank")})}return De(()=>j(null,null,function*(){if(We.isProduction())return;const w=yield F.get("/api/site-admin/gauss/exams");y.value=w.data})),(w,c)=>(o(),r("div",cu,[c[8]||(c[8]=e("h3",null,"Gauss preview testing",-1)),e("div",mu,[u(re,{label:"Open Gauss preview",onClick:h}
3)]),e("div",hu,[e("div",null,[c[5]||(c[5]=e("h3",null,"Gauss student start testing",-1)),e("div",pu,[u(he,{modelValue:t.value,"onUpdate:modelValue":c[0]||(c[0]=b=>t.value=b),class:"RoundedInput",hasBorder:"",required:"",label:"Examkey"},null,8,["modelValue"]),u(he,{modelValue:d.value,"onUpdate:modelValue":c[1]||(c[1]=b=>d.value=b),class:"RoundedInput",hasBorder:"",required:"",label:"First name"},null,8,["modelValue"]),u(he,{modelValue:s.value,"onUpdate:modelValue":c[2]||(c[2]=b=>s.value=b),class:"RoundedInput",hasBorder:"",required:"",label:"Last name"},null,8,["modelValue"]),u(he,{modelValue:a.value,"onUpdate:modelValue":c[3]||(c[3]=b=>a.value=b),class:"RoundedInput",hasBorder:"",required:"",type:"email",label:"Email"},null,8,["modelValue"]),u(he,{modelValue:n.value,"onUpdate:modelValue":c[4]||(c[4]=b=>n.value=b),class:"RoundedInput",hasBorder:"",required:"",label:"Gauss student id"},null,8,["modelValue"]),u(fe,{label:"Random data (except examkey)",onClick:g}),u(re,{label:"Create start URL",onClick:V})])]),m(We).isProduction()?E("",!0):(o(),r("div",vu,[c[7]||(c[7]=e("h3",null,"Existing Gauss exams",-1)),y.value===null?(o(),r("p",fu," Loading… ")):(o(),r(O,{key:1},[y.value.length===0?(o(),r("p",gu," No Gauss exams found. ")):(o(),r("table",yu,[c[6]||(c[6]=e("thead",null,[e("tr",{class:"border-b text-left"},[e("th",{class:"pr-4 py-2"},"Examkey"),e("th",{class:"pr-4 py-2"},"Name"),e("th",{class:"pr-4 py-2"},"Teacher"),e("th",{class:"pr-4 py-2"},"Actions")])],-1)),e("tbody",null,[(o(!0),r(O,null,te(y.value,b=>{var f,N;return o(),r("tr",{key:b.id,class:"border-b"},[e("td",_u,i(b.examkey),1),e("td",bu,[e("a",{class:"text-blue-700 underline",target:"_blank",href:`/admin/exams/external-monitoring/${b.id}`},i(b.name||"(unnamed)"),9,xu)]),e("td",ku,i((N=(f=b.teacher)==null?void 0:f.email)!=null?N:"—"),1),e("td",wu,[u(fe,{label:"Enter as random new student",onClick:H=>A(b.examkey)},null,8,["onClick"])])])}),128))])]))],64))]))]),e("div",Su,[e("a",{class:"mt-4 text-xl",target:"_blank",href:p.value},i(p.value),9,Eu)])]))}}),$u={style:{"margin-bottom":"25px"}},Au={class:"flex flex-col gap-4 w-96"},Tu={style:{display:"flex"}},Du={key:0,style:{color:"red"}},Nu={style:{display:"flex"}},Lu={key:0,style:{color:"red"}},Vu={key:0,style:{"margin-left":"15px"}},Uu={style:{"margin-top":"25px"}},Iu={key:1,style:{"margin-top":"50px"}},Mu=["href"],Ru=["href"],Pu=ne({__name:"CreateDomesticSchool",setup(l){const t=x(""),d=x(0),s=x(!1),n=x(""),a=x(""),p=x(""),y=x(!1),h=x(!1),g=x([]),V=x(!1),A=x(""),w=x(!1),c=x(!1),b=x({school:{id:"",namn:"",external_customer_id:""},salesforce_account_url:""}),f=ee({get:()=>y.value?"vocational":h.value?"school":null,set:P=>{P&&N(P)}});function N(P){P==="vocational"?(y.value=!0,h.value=!1,g.value=[]):(y.value=!1,h.value=!0)}function H(){if(!t.value||t.value.length<3||t.value.length>220||!d.value||d.value<1||d.value>99999)return!1;const P=/^(\s*)$|^(?!0000000000$)([0-9]{10,10})$/;return!(p.value&&!P.test(p.value)||!/^(\s*)$|^(\d+(\|\d+)*)$/.test(a.value)||!y.value&&!h.value||h.value&&g.value.length===0)}function R(P=!1){t.value="",d.value=0,n.value="",a.value="",p.value="",y.value=!1,h.value=!1,g.value=[],V.value=!1,!P&&(c.value=!1)}function z(){return j(this,null,function*(){var C;if(s.value=!0,V.value=!1,c.value=!1,w.value=!1,!H()){V.value=!0,s.value=!1;return}try{yield F.post("/api/site-admin/domestic-school/validate",{name:t.value,type:h.value?"school":"vocational",schoolTypes:h.value?g.value:[]})}catch(S){w.value=!0,s.value=!1;return}let P=null;try{P=yield F.post("/api/site-admin/domestic-school",{name:t.value,studentCount:d.value,ort:n.value,units:a.value,orgNumber:p.value,typeVocational:y.value,typeSchool:h.value,schoolTypes:g.value})}catch(S){console.log(S),s.value=!1,V.value=!0,A.value=(C=S.response.data)==null?void 0:C.message;return}s.value=!1,b.value=P.data,c.value=!0,R(!0)})}return(P,C)=>(o(),r("div",$u,[e("form",{onSubmit:ve(z,["prevent"])},[C[14]||(C[14]=e("h3",null,"Create new domestic school",-1)),e("div",Au,[u(he,{modelValue:t.value,"onUpdate:modelValue":C[0]||(C[0]=S=>t.value=S),label:"School name",pattern:"^.{2,220}$",required:""},null,8,["modelValue"]),u(he,{modelValue:d.value,"onUpdate:modelValue":C[1]||(C[1]=S=>d.value=S),label:"Number of students",placeholder:"Min 1, max 99999",type:"number",min:1,max:99999,required:""},null,8,["modelValue"]),u(he,{modelValue:n.value,"onUpdate:modelValue":C[2]||(C[2]=S=>n.value=S),type:"text",label:"Ort"},null,8,["modelValue"]),u(he,{modelValue:a.value,"onUpdate:modelValue":C[3]||(C[3]=S=>a.value=S),label:"School unit code(s)",placeholder:"E.g. 123456 or 123456|986543",pattern:"^(\\s*)$|^(\\d+(\\|\\d+)*)$"},null,8,["modelValue"]),u(he,{modelValue:p.value,"onUpdate:modelValue":C[4]||(C[4]=S=>p.value=S),label:"Organisation number",placeholder:"E.g. 5565389409 or leave empty",pattern:"^.{0}$|^(\\s*)$|^(?!0000000000$)([0-9]{10,10})$|^"},null,8,["modelValue"]),e("div",Tu,[u(yt,{modelValue:f.value,"onUpdate:modelValue":C[5]||(C[5]=S=>f.value=S),value:"vocational"},null,8,["modelValue"]),C[12]||(C[12]=e("span",{style:{"margin-left":"10px"}},"Vocational school",-1)),h.value?E("",!0):(o(),r("span",Du,"*"))]),e("div",Nu,[u(yt,{modelValue:f.value,"onUpdate:modelValue":C[6]||(C[6]=S=>f.value=S),value:"school"},null,8,["modelValue"]),C[13]||(C[13]=e("span",{style:{"margin-left":"10px"}},"School",-1)),y.value?E("",!0):(o(),r("span",Lu,"*"))]),h.value==!0?(o(),r("div",Vu,[u(Ce,{modelValue:g.value,"onUpdate:modelValue":C[7]||(C[7]=S=>g.value=S),value:"Lågstadie",label:"Lågstadie"},null,8,["modelValue"]),u(Ce,{modelValue:g.value,"onUpdate:modelValue":C[8]||(C[8]=S=>g.value=S),value:"Mellanstadie",label:"Mellanstadie"},null,8,["modelValue"]),u(Ce,{modelValue:g.value,"onUpdate:modelValue":C[9]||(C[9]=S=>g.value=S),value:"Högstadie",label:"Högstadie"},null,8,["modelValue"]),u(Ce,{modelValue:g.value,"onUpdate:modelValue":C[10]||(C[10]=S=>
3g.value=S),value:"Gymnasie",label:"Gymnasie"},null,8,["modelValue"])])):E("",!0),u(re,{label:"Create school",disabled:!H(),loading:s.value,onClick:z},null,8,["disabled","loading"]),u(re,{label:"Reset form",disabled:s.value,onClick:C[11]||(C[11]=S=>R(!1))},null,8,["disabled"])])],32),e("div",Uu,[c.value?(o(),I(Vt,{key:0,style:{width:"440px"},text:"School was successfully created in Exam.net and Salesforce! note: please verify the school was created in KM"})):E("",!0),c.value?(o(),r("div",Iu,[_(" School: "+i(b.value.school.namn)+" (id "+i(b.value.school.id)+") ",1),C[15]||(C[15]=e("br",null,null,-1)),C[16]||(C[16]=_(" Salesforce ID: ",-1)),e("a",{href:`${b.value.salesforce_account_url}`,target:"_blank"},i(b.value.school.external_customer_id),9,Mu),C[17]||(C[17]=e("br",null,null,-1)),C[18]||(C[18]=_(" Salesforce URL: ",-1)),e("a",{href:`${b.value.salesforce_account_url}`,target:"_blank"},i(b.value.salesforce_account_url),9,Ru)])):E("",!0),V.value&&!c.value&&!H()?(o(),I(Ke,{key:2,style:{width:"440px"},text:"One or more fields are invalid, make sure to fill out all required fields: name, student count, school type"})):E("",!0),V.value?(o(),I(Ke,{key:3,style:{width:"440px"},text:`An error occured: ${A.value}`},null,8,["text"])):E("",!0),w.value?(o(),I(Ke,{key:4,style:{width:"440px"},text:"The school name and type combination already exists in the external system Kunskapsmatrisen."})):E("",!0)])]))}}),Bu={style:{"margin-bottom":"25px"}},Ou={key:0,class:"flex flex-col gap-4 w-[36rem]"},Fu={class:"create-from-scratch-footer"},Hu={key:0,class:"font-semibold mt-2 text-yellow-700",title:"This international school already has an Exam.net school linked to it"},Gu={class:"flex gap-2"},zu=["value"],Ku={class:"flex gap-2"},Xu={style:{"margin-top":"25px"}},Wu={key:1,style:{"margin-top":"20px"}},Yu=ne({__name:"CreateInternationalSchool",setup(l){const t=x("search"),d=x(!1),s=x(!1),n=x(!1),a=x(""),p=x(null),y=x([]);De(()=>j(null,null,function*(){const S=yield F.get("/api/countries");y.value=S.data}));const h=x([]),g=x(null),V=x(!1),A=x("");function w(){return{name:"",country:"",city:"",region:"",type:"school",studentCount:0,website:""}}const c=x(w());let b=null;function f(S){if(A.value=S,b&&clearTimeout(b),S.length<1){h.value=[];return}b=setTimeout(()=>j(null,null,function*(){V.value=!0;try{const v=yield F.get("/api/site-admin/international-school/search",{params:{query:S}});h.value=v.data.map(T=>{var Y;const M=[T.country,T.region,T.city].filter(Boolean).join(", ");return xe(be({},T),{label:(Y=T.school)!=null&&Y.id?`${T.name} (${M}) - ⚠️ already created (school #${T.school.id})`:`${T.name} (${M}) - id: ${T.id}`})})}catch(v){h.value=[]}finally{V.value=!1}}),300)}function N(){c.value.name=A.value,t.value="scratch"}function H(){return!(!c.value.name||c.value.name.length<3||!c.value.country||!c.value.type||!c.value.studentCount||c.value.studentCount<1)}function R(S){var v,T,M,Y;n.value=!0,a.value=((T=(v=S.response)==null?void 0:v.data)==null?void 0:T.error)||((Y=(M=S.response)==null?void 0:M.data)==null?void 0:Y.message)||"Unknown error"}function z(){return j(this,null,function*(){if(g.value){d.value=!0,n.value=!1,s.value=!1;try{const S=yield F.post(`/api/site-admin/international-school/${g.value.id}`);p.value=S.data,s.value=!0,g.value=null,h.value=[]}catch(S){R(S)}finally{d.value=!1}}})}function P(){return j(this,null,function*(){if(H()){d.value=!0,n.value=!1,s.value=!1;try{const S=yield F.post("/api/site-admin/international-school",{name:c.value.name,country:c.value.country,city:c.value.city||null,region:c.value.region||null,type:c.value.type,studentCount:c.value.studentCount,website:c.value.website||null});p.value=S.data,s.value=!0,c.value=w()}catch(S){R(S)}finally{d.value=!1}}})}function C(){h.value=[],g.value=null,c.value=w(),s.value=!1,n.value=!1,a.value="",p.value=null}return(S,v)=>{var T,M,Y;return o(),r("div",Bu,[v[31]||(v[31]=e("h3",null,"Create new international school",-1)),t.value==="search"?(o(),r("div",Ou,[v[20]||(v[20]=e("h4",null," Search international schools database — if you can’t find the right match, you can still create the school from scratch ",-1)),u(m(Be),{modelValue:g.value,"onUpdate:modelValue":v[1]||(v[1]=K=>g.value=K),options:h.value,searchable:"",loading:V.value,internalSearch:!1,optionsLimit:50,clearOnSelect:!1,closeOnSelect:"",placeholder:"Type to search international schools...",label:"label",trackBy:"id",onSearchChange:f},{noResult:k(()=>[...v[10]||(v[10]=[e("span",{class:"no-result"},"No international schools found.",-1)])]),noOptions:k(()=>[...v[11]||(v[11]=[_(" Start typing to search... ",-1)])]),afterList:k(()=>
3[e("div",Fu,[v[12]||(v[12]=_(" Can't find the school you're looking for? ",-1)),e("a",{href:"#",onMousedown:ve(N,["prevent"]),onClick:v[0]||(v[0]=ve(()=>{},["prevent"]))},"Create it from scratch",32)])]),_:1},8,["modelValue","options","loading"]),g.value?(o(),r("div",{key:0,class:de(["border p-4 rounded",(T=g.value.school)!=null&&T.id?"bg-yellow-50 border-yellow-300":"bg-blue-50"])},[v[19]||(v[19]=e("h5",{class:"font-semibold mb-2"},"Selected school:",-1)),e("div",null,[v[13]||(v[13]=e("strong",null,"Name:",-1)),_(" "+i(g.value.name),1)]),e("div",null,[v[14]||(v[14]=e("strong",null,"Country:",-1)),_(" "+i(g.value.country),1)]),e("div",null,[v[15]||(v[15]=e("strong",null,"Region/State:",-1)),_(" "+i(g.value.region||"-"),1)]),e("div",null,[v[16]||(v[16]=e("strong",null,"City:",-1)),_(" "+i(g.value.city||"-"),1)]),e("div",null,[v[17]||(v[17]=e("strong",null,"Type:",-1)),_(" "+i(g.value.type||"-"),1)]),e("div",null,[v[18]||(v[18]=e("strong",null,"Students:",-1)),_(" "+i(g.value.student_count||"-"),1)]),(M=g.value.school)!=null&&M.id?(o(),r("div",Hu," ⚠️ Already created as school #"+i(g.value.school.id),1)):E("",!0)],2)):E("",!0),e("div",Gu,[u(re,{label:"Create school from selected",disabled:!g.value||!!((Y=g.value.school)!=null&&Y.id)||d.value,loading:d.value,onClick:z},null,8,["disabled","loading"]),u(fe,{label:"Reset",disabled:d.value,onClick:C},null,8,["disabled"])])])):E("",!0),t.value==="scratch"?(o(),r("form",{key:1,class:"flex flex-col gap-4 w-96",onSubmit:ve(P,["prevent"])},[v[25]||(v[25]=e("h4",null,"Create new international school",-1)),u(re,{label:"← Back to search",onClick:v[2]||(v[2]=K=>t.value="search")}),u(he,{modelValue:c.value.name,"onUpdate:modelValue":v[3]||(v[3]=K=>c.value.name=K),label:"School name",pattern:"^.{3,220}$",required:""},null,8,["modelValue"]),e("div",null,[v[22]||(v[22]=e("label",{class:"block font-medium mb-1 text-sm"},"Country",-1)),Z(e("select",{"onUpdate:modelValue":v[4]||(v[4]=K=>c.value.country=K),class:"border p-2 rounded w-full",required:""},[v[21]||(v[21]=e("option",{value:"",disabled:""}," Select a country... ",-1)),(o(!0),r(O,null,te(y.value,K=>(o(),r("option",{key:K.en_name,value:K.en_name},i(K.en_name),9,zu))),128))],512),[[lt,c.value.country]])]),u(he,{modelValue:c.value.city,"onUpdate:modelValue":v[5]||(v[5]=K=>c.value.city=K),label:"City"},null,8,["modelValue"]),u(he,{modelValue:c.value.region,"onUpdate:modelValue":v[6]||(v[6]=K=>c.value.region=K),label:"Region"},null,8,["modelValue"]),e("div",null,[v[24]||(v[24]=e("label",{class:"block font-medium mb-1 text-sm"},"School type",-1)),Z(e("select",{"onUpdate:modelValue":v[7]||(v[7]=K=>c.value.type=K),class:"border p-2 rounded w-full",required:""},[...v[23]||(v[23]=[e("option",{value:"school"},"School",-1),e("option",{value:"vocational_school"},"Vocational school",-1),e("option",{value:"university"},"University",-1)])],512),[[lt,c.value.type]])]),u(he,{modelValue:c.value.studentCount,"onUpdate:modelValue":v[8]||(v[8]=K=>c.value.studentCount=K),label:"Number of students",inputHint:"Counts of 50 or lower may be updated automatically after creation by the AI-assisted school lookup",type:"number",min:1,max:99999,required:""},null,8,["modelValue"]),u(he,{modelValue:c.value.website,"onUpdate:modelValue":v[9]||(v[9]=K=>c.value.website=K),label:"Website",placeholder:"E.g. https://school.example.com"},null,8,["modelValue"]),e("div",Ku,[u(re,{label:"Create school",disabled:!H()||d.value,loading:d.value,onClick:P},null,8,["disabled","loading"]),u(fe,{label:"Reset",disabled:d.value,onClick:C},null,8,["disabled"])])],32)):E("",!0),e("div",Xu,[s.value?(o(),I(Vt,{key:0,style:{width:"440px"},text:"International school was successfully created and will be synced to Salesforce!"})):E("",!0),s.value&&p.value?(o(),r("div",Wu,[e("div",null,[v[26]||(v[26]=e("strong",null,"School:",-1)),_(" "+i(p.value.school.namn)+" (id "+i(p.value.school.id)+")",1)]),e("div",null,[v[27]||(v[27]=e("strong",null,"International School ID:",-1)),_(" "+i(p.value.international_school.id),1)]),e("div",null,[v[28]||(v[28]=e("strong",null,"Country:",-1)),_(" "+i(p.value.international_school.country),1)]),e("div",null,[v[29]||(v[29]=e("strong",null,"Booking link:",-1)),_(" "+i(p.value.school.booking_link),1)]),e("div",null,[v[30]||(v[30]=e("strong",null,"Invite link:",-1)),_(" "+i(p.value.invite_link),1)])])):E("",!0),n.value?(o(),I(Ke,{key:2,style:{width:"440px"},text:`An error occurred: ${a.value}`},null,8,["text"])):E("",!0)])])}}}),ju=ie(Yu,[["__scopeId","data-v-9b1ec804"]]),qu={makeChart({id:l,chart:t,points:d,label:s}){const n=document.getElementById(l).getContext("2d");return t&&t.destroy(),new window.Chart(n,{type:"line",data:{labels:d.map(a=>a.month),datasets:[{label:s,data:d.map(a=>a.nps),borderColor:"#0075b6",backgroundColor:"rgba(0, 117, 182, 0.1)",borderWidth:2,fill:!0,lineTension:.3,pointRadius:4,pointHoverRadius:5,spanGaps:!1}]}
3,options:{responsive:!0,maintainAspectRatio:!1,legend:{display:!1},layout:{padding:{top:8,right:8}},scales:{xAxes:[{ticks:{autoSkip:!0,maxRotation:0}}],yAxes:[{ticks:{min:-100,max:100,stepSize:50},gridLines:{zeroLineColor:"#9ca3af"},scaleLabel:{display:!0,labelString:"NPS"}}]},tooltips:{callbacks:{title:a=>d[a[0].index].month,label:a=>{const p=d[a.index];return p.nps===null?"NPS: no responses":`NPS: ${p.nps}`},afterLabel:a=>`Responses: ${d[a.index].total}`}}}})}},Qu=[{key:"quarter",label:"Last quarter"},{key:"sixMonths",label:"Last 6 months"},{key:"year",label:"Last 12 months"},{key:"ytd",label:"Year to date"},{key:"all",label:"All time"}];function kt(l,t){const d=new Date(t),s=new Date(t);switch(l){case"quarter":s.setMonth(s.getMonth()-3);break;case"sixMonths":s.setMonth(s.getMonth()-6);break;case"year":case"all":s.setMonth(s.getMonth()-12);break;case"ytd":s.setMonth(0,1);break}return[s,d]}function it(l,t,d){return d===0?0:Math.round((l-t)/d*100)}function Ju(l){return l<=6?"Detractor":l>=9?"Promoter":"Passive"}function Zu(l,t,d){const s=[];for(let n=0;n<l.length;n++){const a=l[n];if(a.month<d)continue;const p=t==="rolling"?l.slice(Math.max(0,n-2),n+1):[a],y=p.reduce((V,A)=>V+A.promoters,0),h=p.reduce((V,A)=>V+A.detractors,0),g=p.reduce((V,A)=>V+A.total,0);s.push({month:a.month,nps:g===0?null:it(y,h,g),total:g})}return s}const ec=["Date","Score","Category","Comment","Country"];function tc(l){return(l!=null?l:"").replace(/[\r\n]+/g," ").replace(/;/g,",").trim()}const sc=["=","+","-","@","	","\r"];function lc(l){return sc.includes(l[0])?`'${l}`:l}function ac(l){return l.map(t=>[t.created_at.slice(0,10),String(t.value),Ju(t.value),tc(t.comment),t.country].map(lc))}const oc={class:"Nps"},nc={class:"Nps__toolbar","aria-label":"NPS filters"},ic={class:"Nps__field"},rc={class:"Nps__field Nps__field--date"},dc={key:0,class:"Nps__state"},uc={class:"Nps__summary","aria-label":"NPS summary"},cc={class:"Nps__metricLabel"},mc=["data-testid"],hc={key:0,class:"Nps__metricHint"},pc={class:"Nps__panel","aria-labelledby":"nps-chart-title"},vc={class:"Nps__sectionHeader"},fc={class:"Nps__sectionSubtitle"},gc={class:"Nps__chartMode"},yc={class:"Nps__chart"},_c=["aria-label"],bc={key:0,class:"Nps__state","data-testid":"nps-empty"},xc={class:"Nps__panel","aria-labelledby":"nps-country-title"},kc=ne({__name:"Nps",setup(l){const t=[{label:"Monthly",value:"monthly"},{label:"3-month rolling",value:"rolling"}],d={dropdown:{"aria-label":"Open date range calendar"}},s=x("year"),n=x(kt("year",new Date)),a=x("monthly"),p=ee(()=>{const X=Qu.map($=>({value:$.key,label:$.label}));return s.value==="custom"&&X.push({value:"custom",label:"Custom"}),X}),y=x(!1),h=x([]),g=x([]),V=x([]),A=x([]);let w=null;const c=ee(()=>V.value.reduce((X,$)=>($.value>=9?X.promoters++:$.value<=6?X.detractors++:X.passives++,X.total++,X),{promoters:0,passives:0,detractors:0,total:0})),b=ee(()=>it(c.value.promoters,c.value.detractors,c.value.total)),f=ee(()=>{const[X,$]=n.value;return!X||!$?"Incomplete range":`${S(X)} - ${S($)}`}),N=ee(()=>[{key:"overall-nps",label:"Overall NPS",value:c.value.total?b.value:"No score",hint:`${c.value.total} responses`},{key:"responses",label:"Responses",value:c.value.total,hint:""},{key:"promoters",label:"Promoters",value:c.value.promoters,hint:"Scores 9-10",tone:"positive"},{key:"passives",label:"Passives",value:c.value.passives,hint:"Scores 7-8",tone:"neutral"},{key:"detractors",label:"Detractors",value:c.value.detractors,hint:"Scores 0-6",tone:"negative"}]),H=ee(()=>[...g.value].sort((X,$)=>$.total-X.total||X.country.localeCompare($.country))),R=ee(()=>A.value.some(X=>X.nps!==null)),z=ee(()=>a.value==="rolling"?"3-month rolling":"Monthly"),P=ee(()=>`${z.value} score across ${f.value}. Tooltips include response volume.`),C=ee(()=>{const $=A.value.filter(D=>D.nps!==null).at(-1);return $?`${z.value} NPS chart for ${f.value}. Latest plotted month ${$.month} has NPS ${$.nps} from ${$.total} responses. Overall selected range NPS is ${b.value}.`:`No NPS chart data for ${f.value}.`});function S(X){const $=X.getFullYear(),D=String(X.getMonth()+1).padStart(2,"0"),q=String(X.getDate()).padStart(2,"0");return`${$}-${D}-${q}`}function v(X){const[$,D,q]=X.split("-").map(Number);return new Date($,D-1,q)}function T(){return S(n.value[0]).slice(0,7)}function M(){return j(this,null,function*(){const[X,$]=n.value;if(!X||!$)return;y.value=!0;const D={start:S(X),end:S($)};s.value==="all"&&(D.all="1");try{const{data:q}=yield F("/api/site-admin/nps",{params:D});h.value=q.monthly,g.value=q.countries.map(se=>xe(be({},se),{nps:it(se.promoters,se.detractors,se.total)})),V.value=q.responses,s.value==="all"&&q.range&&(n.value=[v(q.range.start),v(q.range.end)]),Y()}finally{y.value=!1}})}function Y(){A.value=Zu(h.value,a.value,T()),R.value&&St(()=>{w=qu.makeChart({id:"npsChart",chart:w,points:A.value,label:a.value==="rolling"?"NPS (3-month rolling)":"NPS (monthly)"})})}
3function K(){s.value!=="custom"&&(n.value=kt(s.value,new Date),M())}function Q(){var X,$;(X=n.value)!=null&&X[0]&&(($=n.value)!=null&&$[1])&&(s.value="custom",M())}function oe(){const[X,$]=n.value;ct(ac(V.value),ec,`nps-export-${S(X)}-${S($)}.csv`)}return Te(a,Y),M(),(X,$)=>(o(),r("div",oc,[$[9]||($[9]=e("header",{class:"Nps__header"},[e("h2",{class:"Nps__title"},"NPS"),e("p",{class:"Nps__subtitle"},"Net Promoter Score for Exam.net. The chart, table and export all use the date range below.")],-1)),e("div",nc,[e("label",ic,[$[3]||($[3]=e("span",null,"Range",-1)),u(Ae,{modelValue:s.value,"onUpdate:modelValue":$[0]||($[0]=D=>s.value=D),options:p.value,optionLabel:"label",optionValue:"value","data-testid":"nps-preset",onChange:K},null,8,["modelValue","options"])]),e("label",rc,[$[4]||($[4]=e("span",null,"Date range",-1)),u(Us,{modelValue:n.value,"onUpdate:modelValue":[$[1]||($[1]=D=>n.value=D),Q],class:"Nps__datePicker",inputId:"nps-date-range",ariaLabel:"Date range",selectionMode:"range",dateFormat:"yy-mm-dd",manualInput:!1,pt:d,showIcon:""},null,8,["modelValue"])]),u(re,{class:"Nps__exportButton","data-testid":"nps-export",label:"Export CSV",disabled:!V.value.length,onClick:oe},null,8,["disabled"])]),y.value?(o(),r("div",dc," Loading… ")):(o(),r(O,{key:1},[e("section",uc,[(o(!0),r(O,null,te(N.value,D=>(o(),r("article",{key:D.key,class:"Nps__metric"},[e("span",cc,i(D.label),1),e("strong",{class:de(["Nps__metricValue",D.tone&&`Nps__metricValue--${D.tone}`]),"data-testid":`nps-summary-${D.key}`},i(D.value),11,mc),D.hint?(o(),r("span",hc,i(D.hint),1)):E("",!0)]))),128))]),e("section",pc,[e("div",vc,[e("div",null,[$[5]||($[5]=e("h3",{id:"nps-chart-title",class:"Nps__sectionTitle"}," NPS trend ",-1)),e("p",fc,i(P.value),1)]),e("div",gc,[$[6]||($[6]=e("span",{id:"nps-chart-mode-label",class:"Nps__chartModeLabel"}," Chart mode ",-1)),u(Ks,{modelValue:a.value,"onUpdate:modelValue":$[2]||($[2]=D=>a.value=D),options:t,optionLabel:"label",optionValue:"value",allowEmpty:!1,"aria-labelledby":"nps-chart-mode-label"},null,8,["modelValue"])])]),Z(e("div",yc,[e("canvas",{id:"npsChart",role:"img","aria-label":C.value},i(C.value),9,_c)],512),[[ue,R.value]])]),R.value?E("",!0):(o(),r("p",bc," No NPS responses in this date range. ")),e("section",xc,[$[8]||($[8]=e("div",{class:"Nps__sectionHeader"},[e("div",null,[e("h3",{id:"nps-country-title",class:"Nps__sectionTitle"}," Countries "),e("p",{class:"Nps__sectionSubtitle"},"Sorted by response volume for the selected range.")])],-1)),u(m(ge),{value:H.value,sortField:"total",sortOrder:-1,"data-key":"country",class:"Nps__table","data-testid":"nps-country-table"},{empty:k(()=>[...$[7]||($[7]=[_(" No NPS responses in this date range. ",-1)])]),default:k(()=>[u(m(J),{field:"country",header:"Country",sortable:""}),u(m(J),{field:"total",header:"Responses",sortable:"",headerClass:"Nps__numberColumn",bodyClass:"Nps__numberColumn"}),u(m(J),{field:"nps",header:"NPS",sortable:"",headerClass:"Nps__numberColumn",bodyClass:"Nps__numberColumn"},{body:k(({data:D})=>[e("span",{class:de({Nps__negative:D.nps<0})},i(D.nps),3)]),_:1}),u(m(J),{field:"promoters",header:"Promoters",headerClass:"Nps__numberColumn",bodyClass:"Nps__numberColumn"}),u(m(J),{field:"passives",header:"Passives",headerClass:"Nps__numberColumn",bodyClass:"Nps__numberColumn"}),u(m(J),{field:"detractors",header:"Detractors",headerClass:"Nps__numberColumn",bodyClass:"Nps__numberColumn"})]),_:1},8,["value"])])],64))]))}}),wc=ie(kc,[["__scopeId","data-v-01bb7a53"]]),Sc={class:"SchoolTree"},Ec={class:"ml-1 text-gray-400 text-xs"},Cc=ne({__name:"SchoolTree",props:{nodes:{}},setup(l){function t(s){return s.children.reduce((n,a)=>n+1+t(a),0)}function d(s){const n=t(s);return`${n} ${n===1?"school":"schools"}`}return(s,n)=>{const a=le("SchoolTree",!0);return o(),r("ul",Sc,[(o(!0),r(O,null,te(l.nodes,p=>(o(),r("li",{key:p.id},[(o(),I(pt(p.children.length>0?"details":"div"),{open:p.children.length>0?!0:void 0},{default:k(()=>[(o(),I(pt(p.children.length>0?"summary":"div"),{class:"SchoolTree__label"},{default:k(()=>[e("span",{class:de({"text-gray-500":p.is_group_parent,"line-through":p.hidden})},i(p.namn),3),e("span",Ec,[_(" (id: "+i(p.id),1),p.is_group_parent?(o(),r(O,{key:0},[_(", group parent")],64)):E("",!0),p.children.length>0?(o(),r(O,{key:1},[_(", "+i(d(p)),1)],64)):E("",!0),n[0]||(n[0]=_(") ",-1))])]),_:2},1024)),p.children.length>0?(o(),I(a,{key:0,nodes:p.children},null,8,["nodes"])):E("",!0)]),_:2},1032,["open"]))]))),128))])}}}),$c=ie(Cc,[["__scopeId","data-v-280d73e1"]]),Ac={class:"AdminPortalAdmins container mt-4"},Tc={class:"bg-white mb-6 p-6 rounded-lg shadow"},Dc={key:0,class:"text-gray-500"},Nc={key:1,class:"space-y-1"},Lc=["onClick"],Vc={class:"flex gap-2 items-center mt-2"},Uc=["href"],Ic={class:"bg-white p-6 rounded-lg shadow"},Mc={class:"flex gap-6 items-center justify-between mb-4"},Rc={class:"font-semibold text-lg"},Pc=["href"],Bc={key:0,class:"text-gray-500 text-sm"},Oc=["href"],Fc={key:0,class:"text-gray-500"},Hc={key:1,class:"flex flex-wrap gap-1"},Gc={class:"p-3"},zc={key:1,class:"text-gray-500"},Kc=ne({__name:"AdminPortalAdmins",setup(l){const t=dt(),{schoolList:d,preloadSchools:s,rewindPicker:n}=Oe(),a=x(null),p=x(null),y=x([]),h=x(!1),g=x(""),V=x(null),A=x([]),w=x({}),c=ee(()=>{var P,C;return(C=(P=y.value.find(S=>{var v;return S.id===((v=p.value)==null?void 0:v.id)}
3))==null?void 0:P.roots)!=null?C:[]});De(()=>{s(),b()});function b(){return j(this,null,function*(){h.value=!0,g.value="";try{const{data:P}=yield F.get("/api/site-admin/admin-portal-admins");p.value=P.me,y.value=P.admins,w.value={},A.value=[]}catch(P){g.value=z(P,"The portal admins could not be loaded.")}finally{h.value=!1}})}function f(P){return j(this,null,function*(){if(!w.value[P.id])try{w.value[P.id]=(yield F.get(`/api/site-admin/users/${P.id}/admin-portal-tree`)).data}catch(C){t.add({severity:"error",summary:"Could not load the school tree",detail:z(C,"Unknown error")})}})}function N(){return j(this,null,function*(){if(!(!p.value||V.value===null)){try{yield F.post(`/api/site-admin/users/${p.value.id}/admin-portal-access`,{school_id:V.value}),V.value=null,t.add({severity:"success",summary:"Admin portal access granted"})}catch(P){t.add({severity:"error",summary:"Could not grant admin portal access",detail:z(P,"Unknown error")})}yield b()}})}function H(P){return j(this,null,function*(){if(p.value){try{yield F.delete(`/api/site-admin/users/${p.value.id}/admin-portal-access/${P}`),V.value=null,t.add({severity:"success",summary:"Admin portal access removed"})}catch(C){t.add({severity:"error",summary:"Could not remove admin portal access",detail:z(C,"Unknown error")})}yield b()}})}function R(P){return`${P.namn} (id: ${P.id})${P.isGroupParent?" – group parent":""}`}function z(P,C){var S,v;return je(P)&&((v=(S=P.response)==null?void 0:S.data)==null?void 0:v.message)||C}return(P,C)=>(o(),r("div",Ac,[e("div",Tc,[C[4]||(C[4]=e("h2",{class:"font-semibold mb-2 text-lg"},"Your admin portal access",-1)),C[5]||(C[5]=e("p",{class:"mb-3 text-gray-500 text-sm"}," Grant yourself a root to try the portal as yourself. The organisation safeguard does not apply to support admins, so any school can be a root. ",-1)),c.value.length===0?(o(),r("p",Dc," None ")):(o(),r("ul",Nc,[(o(!0),r(O,null,te(c.value,S=>(o(),r("li",{key:S.id,class:"flex gap-3 items-center"},[e("span",null,i(R(S)),1),e("a",{href:"#",class:"text-red-600 text-xs",onClick:ve(v=>H(S.id),["prevent"])},"Remove",8,Lc)]))),128))])),e("div",Vc,[u(Ae,{ref_key:"schoolSelect",ref:a,modelValue:V.value,"onUpdate:modelValue":C[0]||(C[0]=S=>V.value=S),options:m(d),optionLabel:"label",optionValue:"id",filter:"",filterFields:["search"],autoFilterFocus:"",showClear:"",virtualScrollerOptions:{itemSize:38},placeholder:"Search by school name","aria-label":"Admin portal root school",style:{width:"24rem"},onFilter:C[1]||(C[1]=S=>m(n)(a.value))},null,8,["modelValue","options"]),u(fe,{label:"Grant myself",size:"small",disabled:V.value===null,onClick:N},null,8,["disabled"]),p.value&&c.value.length>0?(o(),r("a",{key:0,href:`/admin/impersonate-hmp/${p.value.email}`,target:"_blank",class:"ml-2 text-xs"},"Open the admin portal as yourself",8,Uc)):E("",!0)])]),e("div",Ic,[e("div",Mc,[e("h2",Rc,i(y.value.length)+" "+i(y.value.length===1?"portal admin":"portal admins"),1),e("a",{href:m(_e)("teacher-info"),class:"text-sm"},"Grant access to another user via Teacher info",8,Pc)]),h.value?(o(),r("div",Bc,[...C[6]||(C[6]=[e("i",{class:"fa fa-spin fa-spinner"},null,-1),_(" Loading… ",-1)])])):g.value?(o(),I(Ye,{key:1,severity:"error"},{default:k(()=>[_(i(g.value),1)]),_:1})):(o(),I(m(ge),{key:2,expandedRows:A.value,"onUpdate:expandedRows":C[2]||(C[2]=S=>A.value=S),value:y.value,dataKey:"id",size:"small",showGridlines:"",stripedRows:"",removableSort:"",class:"text-sm",onRowExpand:C[3]||(C[3]=S=>f(S.data))},{empty:k(()=>[...C[7]||(C[7]=[e("span",{class:"text-gray-500"},"Nobody has admin portal access yet.",-1)])]),expansion:k(({data:S})=>[e("div",Gc,[w.value[S.id]?(o(),I($c,{key:0,nodes:w.value[S.id]},null,8,["nodes"])):(o(),r("span",zc,"Loading…"))])]),default:k(()=>[u(m(J),{expander:"",style:{width:"3rem"}}),u(m(J),{field:"firstName",header:"Name",sortable:""},{body:k(({data:S})=>[e("a",{href:m(_e)("teacher-info",{teacher:S.email}),title:"Open in Teacher info"},i(S.firstName)+" "+i(S.lastName),9,Oc)]),_:1}),u(m(J),{field:"email",header:"Email",sortable:""}),u(m(J),{field:"school",header:"Own school",sortable:""}),u(m(J),{header:"Access roots"},{body:k(({data:S})=>[S.roots.length===0?(o(),r("span",Fc,"None usable")):(o(),r("div",Hc,[(o(!0),r(O,null,te(S.roots,v=>(o(),I(ut,{key:v.id,value:R(v),severity:v.isGroupParent?"secondary":"info"},null,8,["value","severity"]))),128))]))]),_:1})]),_:1},8,["expandedRows","value"]))])]))}}),Xc={key:0,class:"ActiveStudentCount"},Wc=2e4,Yc=ne({__name:"ActiveStudentCount",setup(l){const t=x(null);let d=0;function s(){return j(this,null,function*(){const n=yield F.get("/api/adminlog/active-students").catch(()=>null);n&&(t.value=n.data.km+n.data.km2+n.data.exam),d=window.setTimeout(s,Wc)})}return De(s),qt(()=>window.clearTimeout(d)),(n,a)=>{const p=Re("tooltip");return t.value!==null?Z((o(),r("div",Xc,[u(Ws,{class:"ActiveStudentCount__number",number:t.value},null,8,["number"]),a[0]||(a[0]=e("span",null,"students right now",-1))])),[[p,"Students active in the last 3 minutes, updated about once a minute",void 0,{bottom:!0}]]):E("",!0)}}}
3),jc=ie(Yc,[["__scopeId","data-v-34c2cb20"]]),qc={class:"AdminPanel"},Qc={id:"menubar",class:"AdminPanel__menubar"},Jc={class:"AdminPanel__menubar__nav"},Zc={class:"navbar-header text-center"},em=["alt"],tm=["aria-expanded","onClick"],sm={class:"AdminPanel__overview"},lm={id:"overview"},am={key:1,class:"pt-8",style:{"margin-left":"100px"}},om={key:8,class:"pt-4 px-6"},tt=0,nm=1,im=ne({__name:"AdminPanel",props:{userType:{},userEmail:{}},setup(l){const t=l,d=t.userType==="sales_admin"?"Manage schools":"Exams & Students",s=x(0),n=x(tt),a=x(null),p=x(null),y=[{label:"Support",items:[{label:"Exams & Students",slug:"exams-students",svg:Zt,shortcut:"e"},{label:"Registration",slug:"registration",svg:es,shortcut:"r"},{label:"Teacher info",slug:"teacher-info",svg:ts,shortcut:"t"},{label:"Update emails",slug:"update-emails",svg:ss,shortcut:"u"},{label:"Admin portal",slug:"admin-portal",svg:Ps,shortcut:"a"}]},{label:"School",items:[{label:"Manage schools",slug:"manage-schools",svg:ls,shortcut:"m"},{label:"School stat.",slug:"school-statistics",svg:as,shortcut:"s"},{label:"DPA",slug:"dpa",svg:os,shortcut:"d"}]},{label:"Insights",items:[{label:"Dashboard",slug:"dashboard",svg:ns,externalUrl:"/admin/dashboard"},{label:"NPS",slug:"nps",svg:is}]},{label:"Dev",items:[{label:"Inspect",slug:"inspect",svg:at,externalUrl:"/admin/inspect"},{label:"SEB valid hash",slug:"seb-valid-hash",svg:rs},{label:"IP Allowlist",slug:"ip-allowlist",svg:ds},{label:"Gauss",slug:"gauss",svg:Xs},{label:"Marketing website",slug:"marketing-website",svg:us},{label:"Client Blocking",slug:"client-blocking",svg:cs},...We.isLocal()?[{label:"Mail previews",slug:"mail-previews",svg:ms,externalUrl:"/dev/mail/all"}]:[]]}],h=new Set(["Dashboard","Registration","Manage schools","School stat.","Teacher info"]),g=ee(()=>t.userType==="sales_admin"?y.map(D=>xe(be({},D),{items:D.items.filter(q=>h.has(q.label))})).filter(D=>D.items.length>0):y),V={root:{borderRadius:"0"},submenuLabel:{padding:"var(--spacing-6) var(--spacing-3) var(--spacing-2)"},colorScheme:{light:{root:{background:"{slate.800}",borderColor:"transparent"},item:{color:"{slate.100}",focusColor:"{slate.50}",focusBackground:"{slate.700}",icon:{color:"{slate.300}",focusColor:"{slate.200}"}},submenuLabel:{background:"transparent",color:"{slate.300}"},separator:{borderColor:"{slate.700}"}}}},A=Ut.useReactive("adminMenuGroupsExpanded",{});function w(D){var q;return(q=A.value[D])!=null?q:!0}function c(D){A.value=xe(be({},A.value),{[D]:!w(D)})}const b=ee(()=>g.value.map(D=>({label:D.label,items:D.items.map(q=>xe(be({},q),{command:()=>z(q)}))}))),f=ee(()=>b.value.map(D=>xe(be({},D),{items:w(D.label)?D.items:[]})));function N(D){return t.userType!=="sales_admin"||h.has(D)}const H={};for(const D of y.flatMap(q=>q.items))D.shortcut&&(H[D.shortcut]=()=>{N(D.label)&&z(D)});Cl(),Pt(H);const R={"Exams & Students":()=>Ot().resetSearches()};function z(D){var q;if(D.externalUrl){C(D);return}if(D.label===$.value){(q=R[D.label])==null||q.call(R);return}$.value=D.label}const P={};function C(D){const q=P[D.slug];if(q==null||q.closed){P[D.slug]=window.open(D.externalUrl,D.slug);return}q.focus()}function S(D){var q;$.value="School stat.",(q=a.value)==null||q.loadSchool(D)}function v(D){var q;$.value="Teacher info",n.value=tt,(q=p.value)==null||q.loadUser(D)}const T=ee(()=>g.value.flatMap(D=>D.items).filter(D=>!D.externalUrl)),M=ee(()=>new Map(T.value.map(D=>[D.slug,D.label]))),Y=ee(()=>new Map(T.value.map(D=>[D.label,D.slug]))),{tab:K,teacher:Q,userSchool:oe,clearTabScopedParams:X}=Bs();Te([Q,oe],([D,q])=>{D?n.value=tt:q&&(n.value=nm)},{immediate:!0});const $=ee({get:()=>{var D;return(D=M.value.get(K.value))!=null?D:d},set:D=>{var q;X(),K.value=(q=Y.value.get(D))!=null?q:""}});return(D,q)=>(o(),r("div",qc,[e("div",Qc,[e("nav",Jc,[u(Fs,{model:f.value,dt:V,class:"AdminPanel__menu"},{start:k(()=>[e("div",Zc,[e("img",{src:"https://static.exam.net/img/2021/light-logo.png",alt:m(ps)("Exam.net logo"),class:"header__logo"},null,8,em),q[2]||(q[2]=e("span",{class:"navbar-header__text"},"Administration",-1))]),u(jc)]),submenulabel:k(({item:se})=>[e("button",{type:"button",class:"AdminPanel__group-toggle","aria-expanded":w(se.label),onClick:ae=>c(se.label)},[e("span",null,i(se.label),1),u($s,{isExpanded:w(se.label),color:"var(--blue-gray-300)"},null,8,["isExpanded"])],8,tm)]),item:k(({item:se,props:ae})=>[e("a",wt(ae.action,{class:["AdminPanel__menu-item",{"AdminPanel__menu-item--active":se.label===$.value}]}),[u(ce,{svg:se.svg,width:"var(--icon-size-default)"},null,8,["svg"]),e("span",null,i(se.label),1),se.shortcut?(o(),I(Xe,{key:0,value:se.shortcut,class:"AdminPanel__menu-item-shortcut"},null,8,["value"])):E("",!0),se.externalUrl?(o(),I(ce,{key:1,svg:m(hs),width:"var(--icon-size-default)",class:"AdminPanel__menu-item-external"},null,8,["svg"])):E("",!0)],16)]),_:1},8,["model"])])]),e("div",sm,[e("div",lm,[N("Registration")?Z((o(),I(Bn,{key:0},null,512)),[[ue,$.value=="Registration"]]):E("",!0),N("Manage schools")?Z((o(),r("div",am,[u(_t,{activeTabIndex:s.value,"onUpdate:activeTabIndex":q[0]||(q[0]=se=>s.value=se)},{default:k(()=>[u(Le,{title:"Load existing school"},{default:k(()=>[u(Hi,{userType:l.userType,onLoadSchool:S},null,8,["userType"])]),_:1}),l.userType!=="sales_admin"?(o(),I(Le,{key:0,title:"Create Swedish school"},{default:k(()=>
3[u(Pu)]),_:1})):E("",!0),u(Le,{title:"Create international school"},{default:k(()=>[u(ju)]),_:1})]),_:1},8,["activeTabIndex"])],512)),[[ue,$.value=="Manage schools"]]):E("",!0),N("DPA")?Z((o(),I(ld,{key:2},null,512)),[[ue,$.value=="DPA"]]):E("",!0),N("School stat.")?Z((o(),I(vn,{key:3,ref_key:"adminSchoolStatistics",ref:a,onLoadUser:v},null,512)),[[ue,$.value=="School stat."]]):E("",!0),N("Exams & Students")?Z((o(),I(eo,{key:4},null,512)),[[ue,$.value=="Exams & Students"]]):E("",!0),N("Client Blocking")?Z((o(),I(So,{key:5},null,512)),[[ue,$.value=="Client Blocking"]]):E("",!0),N("SEB")?Z((o(),I(id,{key:6},null,512)),[[ue,$.value=="SEB"]]):E("",!0),N("SEB valid hash")?Z((o(),I(kd,{key:7},null,512)),[[ue,$.value=="SEB valid hash"]]):E("",!0),N("Teacher info")?Z((o(),r("div",om,[u(_t,{activeTabIndex:n.value,"onUpdate:activeTabIndex":q[1]||(q[1]=se=>n.value=se)},{left:k(()=>[...q[3]||(q[3]=[_("Find teacher by:",-1)])]),default:k(()=>[u(Le,{persist:"",title:"Email"},{default:k(()=>[u(Kr,{ref_key:"userInfo",ref:p,userType:l.userType,userEmail:l.userEmail,onLoadSchool:S},null,8,["userType","userEmail"])]),_:1}),l.userType!=="sales_admin"?(o(),I(Le,{key:0,title:"School or organisation"},{default:k(()=>[u(Un)]),_:1})):E("",!0)]),_:1},8,["activeTabIndex"])],512)),[[ue,$.value=="Teacher info"]]):E("",!0),N("Admin portal")&&$.value=="Admin portal"?(o(),I(Kc,{key:9})):E("",!0),N("Marketing website")?Z((o(),I(Od,{key:10},null,512)),[[ue,$.value=="Marketing website"]]):E("",!0),N("IP Allowlist")?Z((o(),I(Kd,{key:11},null,512)),[[ue,$.value=="IP Allowlist"]]):E("",!0),N("Update emails")?Z((o(),I(uu,{key:12},null,512)),[[ue,$.value=="Update emails"]]):E("",!0),N("Gauss")?Z((o(),I(Cu,{key:13},null,512)),[[ue,$.value=="Gauss"]]):E("",!0),N("NPS")&&$.value=="NPS"?(o(),I(wc,{key:14})):E("",!0)])])]))}}),Fm=ie(im,[["__scopeId","data-v-b847ad0e"]]);export{Fm as default};
4//# sourceMappingURL=chunk.BhAHUh1tKawf.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.