UNPKG

pawnote

Version:

A purrfect API wrapper for PRONOTE.

1 lines 52.6 kB
"use strict";var e=require("@literate.ink/utilities"),s=require("node-forge"),t=require("pako");function n(e){return e&&e.__esModule?e:{default:e}}var i=n(s),r=n(t),o=e=>{let s=new URL(e);s=new URL(`${s.protocol}//${s.host}${s.pathname}`);const t=s.pathname.split("/");return t[t.length-1].includes(".html")&&t.pop(),s.pathname=t.join("/"),s.href.endsWith("/")?s.href.slice(0,-1):s.href},a=class extends Error{constructor(){super("Unable to resolve the challenge, make sure the credentials or token are corrects"),this.name="BadCredentialsError"}},c=class extends Error{constructor(e){super(e),this.name="AuthenticateError"}},u=class extends Error{constructor(){super("You do not have access to this area or your authorizations are insufficient"),this.name="AccessDeniedError"}},l=class extends Error{constructor(){super("Your account has been deactivated"),this.name="AccountDisabledError"}},d=class extends Error{constructor(){super("You can't send a message or a draft in this discussion"),this.name="DiscussionActionError"}},p=class extends Error{constructor(){super("You should request messages before sending anything"),this.name="DiscussionMessagesMissingError"}},m=e=>{if("["!==(e=e.trim())[0]||"]"!==e[e.length-1])return[];if(0===(e=e.slice(1,-1)).length)return[];const s=[];for(const t of e.split(","))if(t.includes("..")){const[e,n]=t.split("..").map((e=>parseInt(e)));for(let t=e;t<=n;t++)s.push(t)}else s.push(parseInt(t));return s},f=class extends Error{handle;constructor(e,s,t){super("You're asked to custom your security methods"),this.name="SecurityError",this.handle=((e,s,t)=>{const n=m(e.actionsDoubleAuth.V);return{availableSecurityModes:m(e.modesPossibles.V),defaultSecurityMode:e.modeSecurisationParDefaut,passwordRules:(i=e.reglesSaisieMDP,{maxLength:i.max,minLength:i.min,rules:m(i.regles.V)}),shouldCustomPassword:n.includes(L.AIHMSC_PersonnalisationMotDePasse),shouldCustomDoubleAuth:n.includes(L.AIHMSC_ChoixStrategie),shouldEnterPIN:n.includes(L.AIHMSC_SaisieCodePINetSource),shouldEnterSource:n.includes(L.AIHMSC_SaisieSourcePourNotifSeulement),context:{authentication:e,identity:s,initialUsername:t}};var i})(e,s,t)}},h=class extends Error{constructor(e){super(`The source name is too long, limited to ${e} characters`),this.name="SecuritySourceTooLongError"}},g=class extends Error{constructor(){super("Your IP address has been suspended"),this.name="SuspendedIPError"}},D=class extends Error{constructor(){super("The session has expired"),this.name="SessionExpiredError"}},b=class extends Error{constructor(){super("The requested page does not exist"),this.name="PageUnavailableError"}},C=class extends Error{constructor(){super("The site is temporarily unavailable"),this.name="BusyPageError"}},A=class extends Error{constructor(){super("You've been rate-limited"),this.name="RateLimitedError"}},w=class extends Error{constructor(e="An error occurred, server-side"){super(e),this.name="ServerSideError"}},E=class extends Error{constructor(e){super(`Unreachable code reached in '${e}' function, please open an issue on GitHub (LiterateInk/Pawnote)`),this.name="UnreachableError"}},v=class extends Error{constructor(e){super(`The file you are trying to upload is too large, maximum allowed is ${e} bytes`),this.name="UploadSizeError"}},y=class extends Error{constructor(){super("The file upload failed"),this.name="UploadFailedError"}},S={STUDENT:6,PARENT:7,TEACHER:8},x={None:0,Paper:1,FileUpload:2,Kiosk:3,AudioRecording:4},M={Link:0,File:1},P={lu:"lu",nonLu:"nonLu",archiver:"archiver",desarchiver:"desarchiver",transferer:"transferer",signaler:"signaler",modifierCategories:"modifierCategories",fermerDiscussion:"fermerDiscussion",ouvrirDiscussion:"ouvrirDiscussion",signalerSuppression:"signalerSuppression",Trash:"corbeille",Restore:"restauration",Delete:"suppression",brouillon:"brouillon",plus:"plus",purger:"purger",discussionEnFenetre:"discussionEnFenetre",entrerSortirDiscussion:"entrerSortirDiscussion",modificationObjetDiscussion:"modificationObjetDiscussion",afficherDestinataires:"afficherDestinataires",copierContenuVisu:"copierContenuVisu",repondreMessage:"repondreMessage",afficherDiscussion:"afficherDiscussion"},V={Send:0,SendEveryone:1,SendEveryoneExceptParentsAndStudents:3,ReplyEveryone:2,ReplyEveryoneExceptParentsAndStudents:4,Close:5},N={Entry:0,Main:1,Side:2,Drink:3,Dessert:4,Fromage:5},I={URL:0,FILE:1,CLOUD:2,KIOSK_LINK:3,CONFERENCE_LINK:4},L={AIHMSC_PersonnalisationMotDePasse:0,AIHMSC_ChoixStrategie:1,AIHMSC_ChoixCodePINetSource:2,AIHMSC_SaisieCodePINetSource:3,AIHMSC_ReinitCodePINetSource:4,AIHMSC_SaisieSourcePourNotifSeulement:5},R={csch_VerifierPIN:0,csch_VerifierMotDePassePersonnalise:1,csch_LibellesSourceConnexionDejaConnus:2,csch_EnregistrerChoixUtilisateur:3,csch_AffecterModeDoubleAuthentification:4,csch_AffecterCodePIN:5,csch_RenommerSourceConnexionConnue:6,csch_SupprimerSourceConnexionConnue:7,csch_AffecterMotDePassePersonnalise:8,csch_ModifierLogin:9,csch_DemandeReinitialisationPIN:10,csch_VerifierCodeReinitialisationPIN:11},T={Aucune:0,Classe:1,Group:2,Teacher:3,Student:4,Responsable:5,Niveau:6,Orientation:7,Specialite:8,OptionSpecialite:9,Etablissement:10,Period:11,Service:12,Absence:13,Delay:14,Exclusion:15,Subject:16,Room:17,CoEnseignant:18,Suivis:19,Cours:20,Infirmerie:21,AbsenceRepas:22,Pilier:23,ElementPilier:24,Competence:25,_DisciplineBrevet:26,Palier:27,SousItem:28,Evaluation:29,Stage:30,SousMatiere:31,MaitreDeStage:32,InspecteurPedagogique:33,Personal:34,EvaluationHistorique:35,DossierProgression:36,ContenuDeCours:37,TravailAFaire:38,Progression:39,Dispense:40,Punishment:41,Sanction:42,Communication:43,AbsenceInternat:44,Observation:45,ObservationProfesseurEleve:46,ConvocationVS:47,DocumentJoint:48,InternetCategorie:49,DocJointEtablissement:50,Option:51,ProgrammationPunition:52,ReportPunition:53,DisciplineLivretScolaire:54,QCM:55,ExecutionQCM:56,QCMEditeur:57,PartieDeClasse:58,DocJointEleve:59,Devoir:60,InternetEnumere:61,AppreciationBulletinCompetence:62,Entreprise:63,DomaineProfessionnel:64,OffreDeStage:65,SujetDeStage:66,DocumentCasier:67,Message:68,PossessionMessage:69,RelationMessageDocJointEtablissement:70,Engagement:71,PrecautionaryMeasure:72,SousCategorieObjetDossier:73,Incident:74,ProtagonisteIncident:75,RelationIncidentFichierExterne:76,RegimeEleve:77,RepasAPreparer:78,SessionDeStage:79,Materiel:80,Bourse:81,RelationTravailAFaireEleve:82,LieuDossier:83,ElementProgramme:84,ChapitreEltPgm:85,EltPgmTravailleCDT:86,Appreciation:87,ExecutionDevoirKiosque:88,PanierRessourceKiosque:89,RessourceNumeriqueKiosque:90,MetaMatiere:91,EvaluationSujet:92,EvaluationCorrige:93,LibelleCours:94,Site:95,QuestionQCM:96,RelationElevePilierDeCompetence:97,QuestionCopieQCM:98,Coordonnees:99,ResponsablePostulant:100,ExecutionQCMEleve:101,DocJointInscription:102,CategorieDossier:103,MEFGEP:104,AutreOrientation:105,Commission:106,ReponseEducative:107,SuiviReponseEducative:108,NatureDocumentEleve:109},k={NONE:0,CREATION:1,MODIFICATION:2,DELETION:3,CHILDREN_MODIFICATION:4},_={Error:-1,Grade:0,Absent:1,Exempted:2,NotGraded:3,Unfit:4,Unreturned:5,AbsentZero:6,UnreturnedZero:7,Congratulations:8},O={Lunch:0,Dinner:1},F={InformationText:0,SurveyText:5,TextInput:1,UniqueChoice:2,MultipleChoice:3},U={ACCOUNT:0,ACCOUNT_CONNECTION:1,DIRECT_CONNECTION:2,TOKEN_ACCOUNT_CONNECTION:3,TOKEN_DIRECT_CONNECTION:4,COOKIE_CONNECTION:5},G={Grades:198,Resources:89,Assignments:88,Timetable:16,Evaluations:201,Account:49,Presence:7,News:8,Notebook:19,Discussions:131,Gradebook:13,Menus:10},B=async(s,t=e.defaultFetcher)=>{const n=new URL(s.base+"/"+(e=>{let s;switch(e){case S.STUDENT:s="eleve";break;case S.PARENT:s="parent";break;case S.TEACHER:s="professeur"}return`mobile.${s}.html`})(s.kind));for(const[e,t]of Object.entries(s.params))n.searchParams.set(e,t);const r={url:n,redirect:"manual"};e.setCookiesArrayToRequest(r,s.cookies);const{content:o}=await t(r);try{const e=o.replace(/ /gu,"").replace(/\n/gu,""),t="Start(",n=")}catch",r=e.substring(e.indexOf(t)+t.length,e.indexOf(n)).replace(/(['"])?([a-z0-9A-Z_]+)(['"])?:/gu,'"$2": ').replace(/'/gu,'"');return((e,s)=>{const t=!e.MR&&!e.ER;return{url:s,id:parseInt(e.h),accountKind:e.a,demo:e.d??!1,accessKind:e.g??U.ACCOUNT,rsaModulus:t?"B99B77A3D72D3A29B4271FC7B7300E2F791EB8948174BE7B8024667E915446D4EEA0C2424B8D1EBF7E2DDFF94691C6E994E839225C627D140A8F1146D1B0B5F18A09BBD3D8F421CA1E3E4796B301EEBCCF80D81A32A1580121B8294433C38377083C5517D5921E8A078CDC019B15775292EFDA2C30251B1CCABE812386C893E5":e.MR,rsaExponent:t?"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010001":e.ER,rsaFromConstants:t,aesIV:i.default.random.getBytesSync(16),aesKey:"",skipEncryption:e.sCrA??!1,skipCompression:e.sCoA??!1,http:e.http??!1,poll:e.poll??!1,order:0}})(JSON.parse(r),s.base)}catch(e){if(o.includes("Votre adresse IP est provisoirement suspendue"))throw new g;if(o.includes("Le site n'est pas disponible"))throw new b;if(o.includes("Le site est momentanément indisponible"))throw new C;throw new b}},q=class{static decrypt(e,s,t){s=i.default.md.md5.create().update(s.bytes()).digest(),t=t.length()?i.default.md.md5.create().update(t.bytes()).digest():i.default.util.createBuffer().fillWithByte(0,16);const n=i.default.util.createBuffer(i.default.util.binary.hex.decode(e)),r=i.default.cipher.createDecipher("AES-CBC",s);return r.start({iv:t}),r.update(n),r.finish(),r.output.bytes()}static encrypt(e,s,t){s=i.default.md.md5.create().update(s.bytes()).digest(),t=t.length()?i.default.md.md5.create().update(t.bytes()).digest():i.default.util.createBuffer().fillWithByte(0,16),e=i.default.util.createBuffer(e);const n=i.default.cipher.createCipher("AES-CBC",s);return n.start({iv:t}),n.update(e),n.finish(),n.output.toHex()}},j=(e,s=!1)=>({iv:i.default.util.createBuffer(s?"":e.information.aesIV),key:i.default.util.createBuffer(e.information.aesKey)}),$=class{constructor(e,s){this.session=e,this.data=s,this.session.information.order++;const t=s;try{if(this.data=JSON.parse(this.data).donneesSec,this.session.information.skipEncryption||this.decrypt(),this.session.information.skipCompression||this.decompress(),"string"==typeof this.data&&(this.data=JSON.parse(this.data)),void 0!==this.data?._Signature_?.Erreur)throw new w(this.data._Signature_.MessageErreur)}catch(e){if(t.includes("La page a expir"))throw new D;if(t.includes("Votre adresse IP "))throw new g;if(t.includes("La page dem")||t.includes("Impossible d'a"))throw new b;if(t.includes("Vous avez d"))throw new A;if(t.includes("s refus"))throw new u;throw e}}decrypt(){const{iv:e,key:s}=j(this.session);this.data=q.decrypt(this.data,s,e),this.session.information.skipCompression||(this.data=i.default.util.bytesToHex(this.data))}decompress(){const e=i.default.util.hexToBytes(this.data),s=new Uint8Array(Array.from(e).map((e=>e.charCodeAt(0))));this.data=r.default.inflateRaw(s,{to:"string"})}},H=class{constructor(e,s,t){this.session=e,this.name=s,this.data=t}process(){this.session.information.order++;const e=this.generateOrder(),s=new URL(`${this.session.information.url}/appelfonction/${this.session.information.accountKind}/${this.session.information.id}/${e}`);return this.session.information.skipCompression||this.compress(),this.session.information.skipEncryption||this.encrypt(),{order:e,url:s}}keys(){return j(this.session,1===this.session.information.order)}generateOrder(){const{key:e,iv:s}=this.keys();return q.encrypt(this.session.information.order.toString(),e,s)}stringify(){return i.default.util.encodeUtf8(JSON.stringify(this.data)||"")}compress(){const e=i.default.util.createBuffer(this.stringify()).toHex(),s=r.default.deflateRaw(e,{level:6}),t=Array.from(s).map((e=>String.fromCharCode(e))).join("");this.data=i.default.util.bytesToHex(t)}encrypt(){const{key:e,iv:s}=this.keys(),t=this.session.information.skipCompression?this.stringify():i.default.util.hexToBytes(this.data);this.data=q.encrypt(t,e,s)}async send(){return this.session.queue.push((async()=>{const e=this.process(),s=await this.session.fetcher({url:e.url,method:"POST",headers:{"Content-Type":"application/json"},content:JSON.stringify({session:this.session.information.id,numeroOrdre:e.order,nom:this.name,donneesSec:this.data})});return new $(this.session,s.content)}))}},K=/^\d{2}\/\d{2}\/\d{4}$/,J=/^\d{2}\/\d{2}\/\d{4} \d{2}:\d{2}:\d{2}$/,Q=/^\d{2}\/\d{2}\/\d{2} \d{2}h\d{2}$/,W=(new Date).getFullYear().toString().slice(0,2),z=e=>{if(K.test(e)){const[s,t,n]=e.split("/").map(Number);return new Date(n,t-1,s)}if(J.test(e)){const[s,t]=e.split(" "),[n,i,r]=s.split("/").map(Number),[o,a,c]=t.split(":").map(Number),u=new Date(r,i-1,n);return u.setHours(o,a,c),u}if(Q.test(e)){const[s,t]=e.split(" "),[n,i,r]=s.split("/").map(Number),[o,a]=t.split("h").map(Number),c=new Date(parseInt(`${W}${r}`),i-1,n);return c.setHours(o,a),c}throw new E("decodePronoteDate")},Y=e=>({id:e.N,name:e.L,startDate:z(e.dateDebut.V),endDate:z(e.dateFin.V)}),Z=e=>({id:e.N,kind:e.G,name:e.L,startDate:z(e.dateDebut.V),endDate:z(e.dateFin.V)}),X=async(e,s=null)=>{const t=i.default.pki.rsa.setPublicKey(new i.default.jsbn.BigInteger(e.information.rsaModulus,16),new i.default.jsbn.BigInteger(e.information.rsaExponent,16)),n=e.information.aesIV;let r;r=e.information.rsaFromConstants?i.default.util.encode64(e.information.http?t.encrypt(n):n,64):i.default.util.encode64(t.encrypt(n));const o=new H(e,"FonctionParametres",{donnees:{identifiantNav:s,Uuid:r}});return(e=>{const s=new Map;for(const t of[1,2]){const n=m(e.General.DomainesFrequences[t].V);for(const i of n)s.set(i,{label:e.General.LibellesFrequences[t],fortnight:t})}return{version:e.General.versionPN.split(".").map(Number),nextBusinessDay:z(e.General.JourOuvre.V),firstMonday:z(e.General.PremierLundi.V),firstDate:z(e.General.PremiereDate.V),lastDate:z(e.General.DerniereDate.V),navigatorIdentifier:e.identifiantNav,endings:e.General.ListeHeuresFin.V.map((e=>e.L)),periods:e.General.ListePeriodes.map(Z),holidays:e.General.listeJoursFeries.V.map(Y),weekFrequencies:s,blocksPerDay:e.General.PlacesParJour}})((await o.send()).data.donnees)},ee=async(e,s)=>{const t=new H(e,"Identification",{donnees:{genreConnexion:0,genreEspace:e.information.accountKind,identifiant:s.username,pourENT:s.useCAS,enConnexionAuto:!1,enConnexionAppliMobile:s.reuseMobileAuthentication,demandeConnexionAuto:!1,demandeConnexionAppliMobile:s.requestFirstMobileAuthentication,demandeConnexionAppliMobileJeton:s.requestFromQRCode,uuidAppliMobile:s.deviceUUID,loginTokenSAV:""}});return(await t.send()).data.donnees},se=async(e,s)=>{const t=new H(e,"Authentification",{donnees:{connexion:0,challenge:s,espace:e.information.accountKind}}),n=(await t.send()).data.donnees;if("number"==typeof n.Acces&&0!==n.Acces)switch(n.Acces){case 1:throw new a;case 2:case 3:case 4:case 5:case 7:case 8:throw new u;case 6:case 10:throw new l;case 9:if(void 0!==n.AccesMessage){let e=n.AccesMessage.message??"(none)";throw n.AccesMessage.titre&&(e+=`${n.AccesMessage.titre} ${e}`),new c(e)}}return n},te=(e,s)=>{const t=e.AvecDiscussion??!1,n=t&&!e.discussionInterdit,i=n&&(e.AvecDiscussionPersonnels??!1),r=n&&(e.AvecDiscussionParents??!1),o=n&&(e.AvecDiscussionEleves??!1),a=n&&(e.AvecDiscussionProfesseurs??!1),c=[];if(s.length>0){const e=s=>{"G"in s&&c.push(s.G),"Onglet"in s&&s.Onglet.forEach(e)};s.forEach(e)}return{canReadDiscussions:t,canDiscuss:n,canDiscussWithStaff:i,canDiscussWithParents:r,canDiscussWithStudents:o,canDiscussWithTeachers:a,hasAdvancedDiscussionEditor:e.AvecDiscussionAvancee??!1,maxAssignmentFileUploadSize:e.tailleMaxRenduTafEleve,tabs:c}},ne=(e,s,t={})=>{const n=e.L??"",i=e.G,r=e.N;let o;if(i===M.Link)o=e.url??n;else{const{iv:e,key:i}=j(s),a=JSON.stringify({N:r,Actif:!0,...t}),c=q.encrypt(a,i,e);o=`${s.information.url}/FichiersExternes/${c}/${encodeURIComponent(n)}?Session=${s.information.id}`}return{kind:i,name:n,url:o,id:r}},ie=(e,s)=>{const t=e=>s.find((s=>s.id===e)),n=e.periodeParDefaut&&t(e.periodeParDefaut.V.N),i=e.listePeriodes.V.map((e=>t(e.N))).filter(Boolean);return{defaultPeriod:n,location:e.G,periods:i}},re=(e,s)=>{let t;switch(s.information.accountKind){case S.STUDENT:case S.TEACHER:t=[e.ressource];break;case S.PARENT:t=e.ressource.listeRessources}return{id:e.ressource.N,kind:e.ressource.G,name:e.ressource.L,resources:t.map((e=>((e,s)=>{let t=null;e.avecPhoto&&(t=ne({G:1,N:e.N,L:"photo.jpg"},s));const n=new Map;for(const t of e.listeOngletsPourPeriodes?.V??[])n.set(t.G,ie(t,s.instance.periods));return{id:e.N,kind:e.G,name:e.L,establishmentName:e.Etablissement.V.L,className:e.classeDEleve?.L,profilePicture:t,tabs:n,isDirector:e.estDirecteur??!1,isDelegate:e.estDelegue??!1,isMemberCA:e.estMembreCA??!1}})(e,s))),authorizations:te(e.autorisations,e.listeOnglets)}},oe=e=>{const s=e.split(".");switch(s.pop(),s.pop()){case"eleve":return S.STUDENT;case"parent":return S.PARENT;case"professeur":return S.TEACHER;default:throw new E("decodeAccountKindFromPath")}},ae={fd:1,login:!0},ce=async(e,s)=>{const t=o(s.url);e.information=await B({base:t,kind:s.kind,cookies:["appliMobile=1"],params:ae},e.fetcher),e.instance=await X(e,s.navigatorIdentifier);const n=await ee(e,{username:s.username,deviceUUID:s.deviceUUID,requestFirstMobileAuthentication:!1,reuseMobileAuthentication:!0,requestFromQRCode:!1,useCAS:!1});de(s,"token",n);const i=le(n,s.username,s.token),r=pe(e,n,i),a=await se(e,r);if(me(e,a,i),fe(a))throw new f(a,n,s.username);return he(e,a,n,s.username)},ue=(e,s)=>ce(e,{url:e.information.url,kind:e.information.accountKind,username:s.username,token:s.token,deviceUUID:s.deviceUUID,navigatorIdentifier:e.instance.navigatorIdentifier}),le=(e,s,t)=>{const n=i.default.md.sha256.create().update(e.alea??"").update(i.default.util.encodeUtf8(t)).digest().toHex().toUpperCase();return i.default.util.createBuffer(s+n)},de=(e,s,t)=>{1===t.modeCompLog&&(e.username=e.username.toLowerCase()),1===t.modeCompMdp&&(e[s]=e[s].toLowerCase())},pe=(e,s,t)=>{const n=i.default.util.createBuffer(e.information.aesIV);try{const e=i.default.util.decodeUtf8(q.decrypt(s.challenge,t,n)),r=new Array(e.length);for(let s=0;s<e.length;s+=1)s%2==0&&r.push(e.charAt(s));const o=i.default.util.encodeUtf8(r.join(""));return q.encrypt(o,t,n)}catch{throw new a}},me=(e,s,t)=>{const n=i.default.util.createBuffer(e.information.aesIV),r=q.decrypt(s.cle,t,n).split(",").map((e=>String.fromCharCode(parseInt(e)))).join("");e.information.aesKey=r},fe=e=>Boolean(e.actionsDoubleAuth),he=async(e,s,t,n)=>(e.user=await(async e=>{const s=new H(e,"ParametresUtilisateur",{}),t=await s.send();return re(t.data.donnees,e)})(e),{token:s.jetonConnexionAppliMobile,username:t.login??n,kind:e.information.accountKind,url:e.information.url,navigatorIdentifier:e.instance.navigatorIdentifier}),ge=(e,s,t)=>{e.kind===F.TextInput||e.kind===F.InformationText?e.textInputAnswer=s:(e.selectedAnswers=s,e.textInputAnswer=t),e.answered=void 0!==s,e.answerDate=e.answered?new Date:void 0},De=(e,s)=>{const t=e.instance.blocksPerDay,n=Math.floor(s.blockPosition/t);let i=s.blockPosition+s.blockLength-1;return Math.floor(i/t)!==n&&(i=n*t+t-1),i},be=(e,s,t,n)=>{const i=[t],r=s.blockPosition,o=De(e,s);for(let e=r;e<=o;e++){const s=n[e];void 0!==s&&(s===t||i.includes(s)||i.push(s))}return i},Ce=(e,s)=>{const t={};for(let n=0;n<s.length;n++){const i=s[n];i.weekNumber in t||(t[i.weekNumber]=[]);const r=t[i.weekNumber],o=i.blockPosition,a=De(e,i);if(!1!==i._visible)for(let t=o;t<=a;t++){if(void 0!==r[t]){const t=be(e,i,n,r);let o=!1,a=!1;for(let e=0;e<t.length;e++){const n=s[t[e]];a||(a=!("lesson"===n.is&&n.canceled)),o||(o="lesson"===n.is&&n.canceled)}if(a&&o)for(let e=0;e<t.length;e++){const n=s[t[e]];if(n&&"lesson"===n.is&&n.canceled)return n._visible=!1,!0}break}r[t]=n}}return!1},Ae=async e=>{const s=new H(e,"Presence",{_Signature_:{onglet:G.Presence}});await s.send()},we=e=>{e.presence&&(clearInterval(e.presence),e.presence=null)},Ee=class{queue=[];pendingPromise=!1;push(e){return new Promise(((s,t)=>{this.queue.push({promise:e,resolve:s,reject:t}),this.pendingPromise||this.dequeue()}))}dequeue(){if(this.pendingPromise)return!1;const e=this.queue.shift();return!!e&&(this.pendingPromise=!0,e.promise().then((s=>{e.resolve(s),this.pendingPromise=!1,this.dequeue()})).catch((s=>{e.reject(s),this.pendingPromise=!1,this.dequeue()})),!0)}},ve=e=>e.getTime()+60*e.getTimezoneOffset()*1e3,ye=e=>new Date(ve(e)),Se=(e,s)=>{const t=Math.floor((ve(e)-ve(s))/864e5);return 1+Math.floor(t/7)},xe=-1e3,Me=()=>xe-=1,Pe=class{constructor(e,s,t,n){this.session=e,this.functionName=s,this.fileName=n,e.information.order++;const{iv:i,key:r}=j(e);this.order=q.encrypt(e.information.order.toString(),r,i);const o=new FormData;o.append("numeroOrdre",this.order),o.append("numeroSession",e.information.id.toString()),o.append("nomRequete",s),o.append("idFichier",this.id),o.append("md5",""),o.append("files[]",t,n),this.form=o,this.url=e.information.url+`/uploadfilesession/${e.information.accountKind}/${e.information.id}`,this.headers["Content-Disposition"]=`attachment; filename="${encodeURI(n)}"`}order;id=`selecfile_1_${Date.now()}`;url;form;headers={};async send(){const e=await new Response(this.form).text();this.headers["Content-Type"]=`multipart/form-data; boundary=${e.split("\n")[0].slice(2)}`;let s=3;for(;3===s;){const t=await this.session.fetcher({url:new URL(this.url),method:"POST",content:e,headers:this.headers});s=JSON.parse(t.content).etat}if(this.session.information.order++,0===s||2===s)throw new y}},Ve=e=>({id:e.N,name:e.L,inGroups:e.estServiceGroupe??!1}),Ne=e=>({id:e.N,name:e.L,subject:Ve(e.Matiere.V)}),Ie=(e,s)=>({id:e.N,subject:Ve(e.Matiere.V),description:e.descriptif.V,backgroundColor:e.CouleurFond,done:e.TAFFait,deadline:z(e.PourLe.V),attachments:e.ListePieceJointe.V.map((e=>ne(e,s))),difficulty:e.niveauDifficulte,length:e.duree,themes:e.ListeThemes.V.map((e=>Ne(e))),return:{kind:e.genreRendu??x.None,canUpload:e.peuRendre??!1,uploaded:e.documentRendu&&ne(e.documentRendu.V,s)},resourceID:e.cahierDeTextes?.V.N}),Le=async(e,s,t,n)=>{const i=new H(e,"PageCahierDeTexte",{_Signature_:{onglet:s},donnees:{domaine:{_T:8,V:"number"==typeof n?`[${t}..${n}]`:`[${t}]`}}});return(await i.send()).data.donnees},Re=async(e,s,t,n)=>{t=ye(t),n=ye(n);const i=Se(t,e.instance.firstMonday),r=Se(n,e.instance.firstMonday);return Le(e,s,i,r)},Te=(e,s)=>s.ListeTravauxAFaire.V.map((s=>Ie(s,e))),ke=async(e,s,t)=>{let n;switch(s){case P.brouillon:n={commande:s,brouillon:"number"==typeof t.id?{E:k.CREATION,N:t.id}:{E:k.MODIFICATION,N:t.id},contenu:t.content,messagePourReponse:{G:0,N:t.replyMessageID},listeDestinataires:[],listeFichiers:[],objet:""};break;case"":n={commande:s,bouton:{N:0,G:t.button},brouillon:{N:t.id},contenu:t.content,listeDestinataires:[],listeFichiers:[],messagePourReponse:{G:0,N:t.replyMessageID}};break;default:n={commande:s,listePossessionsMessages:t.possessions}}const i=new H(e,"SaisieMessage",{_Signature_:{onglet:G.Discussions},donnees:n});await i.send()},_e=e=>({id:e.N,name:e.L,kind:e.G}),Oe=async(e,s={_:[]})=>{const t=new H(e,"ListeMessagerie",{_Signature_:{onglet:G.Discussions},donnees:{avecLu:!0,avecMessage:!0,possessionMessageDiscussionUnique:null}}),n=(await t.send()).data.donnees,i=n.listeEtiquettes.V.map(_e),r=n.listeMessagerie.V.filter((e=>{const s=0===(e.profondeur||0),t=e.messagePourParticipants?.V.N;return e.estUneDiscussion&&t&&s})).map((e=>((e,s,t)=>({cache:t,creator:e.initiateur,dateAsFrenchText:e.libelleDate,recipientName:e.public,participantsMessageID:e.messagePourParticipants.V.N,possessions:e.listePossessionsMessages.V,numberOfDrafts:e.nbBrouillons??0,subject:e.objet??"",numberOfMessages:e.nombreMessages??0,numberOfMessagesUnread:e.nbNonLus??0,closed:e.ferme??!1,folders:e.listeEtiquettes?.V.map((e=>s.find((s=>s.id===e.N)))).filter(Boolean)??[]}))(e,i,s)));s._.length=0,s._.push(...r);for(const e of s._)e.participantsMessageID in s?Object.assign(s[e.participantsMessageID],e):s[e.participantsMessageID]=e;for(const e in s)"_"!==e&&(s._.find((s=>s.participantsMessageID===e))||delete s[e]);return{folders:i,items:s._}},Fe=e=>{const s=e.estHTML??!1;return{possessionID:e.possessionMessage.V.N,replyMessageID:e.messageSource.V.N,content:s?e.contenu.V:e.contenu,isHTML:s}},Ue=e=>{let s;switch(e){case"Professeur":s=T.Teacher;break;case"Personnel":s=T.Personal;break;default:s=T.Student}return s},Ge=(e,s)=>{let t,n;return"Moi"!==e.public_gauche&&(t={name:e.public_gauche,kind:Ue(e.hint_gauche)}),"Moi"===e.public_droite?n=void 0:"string"==typeof e.public_droite&&(n={name:e.public_droite,kind:Ue(e.hint_droite)}),{id:e.N,content:e.estHTML?e.contenu.V:e.contenu,creationDate:z(e.date.V),author:t,receiver:n,partialVisibility:e.estUnAparte,amountOfRecipients:(e.nbPublic??1)+1,files:e.listeDocumentsJoints?.V.map((e=>ne(e,s)))??[]}},Be=(e,s,t)=>{const n=[],i=e.messageSource.V.N;if(e.listeMessagesPourContexte)for(const t of e.listeMessagesPourContexte.V){const e=Ge(t,s);n.push(e)}let r=t.find((e=>e.id===i));return{...Ge(e,s),transferredMessages:n,replyMessageID:i,replyingTo:r}},qe=async(e,s,t=!1)=>{const n=new H(e,"ListeMessages",{_Signature_:{onglet:G.Discussions},donnees:{listePossessionsMessages:s.possessions,marquerCommeLu:t,nbMessagesVus:0}}),i=((e,s)=>{const t=e.brouillon,n=[],i=[],r=e.messagePourReponse.V.N;for(const t of e.listeMessages.V)t.brouillon?i.push(Fe(t)):n.push(Be(t,s,n));if(n.sort(((e,s)=>s.creationDate.getTime()-e.creationDate.getTime())),t){const e=t.V.estHTML??!1;i.push({isHTML:e,content:e?t.V.contenu:t.V.contenu.V,possessionID:t.V.N,replyMessageID:r})}const o=e.listeBoutons.V.find((e=>e.L.startsWith("Envoyer")))?.G;return{sents:n,drafts:i,defaultReplyMessageID:r,sendAction:o,canIncludeStudentsAndParents:o===V.ReplyEveryoneExceptParentsAndStudents||o===V.SendEveryoneExceptParentsAndStudents}})((await n.send()).data.donnees,e);return s.messages?Object.assign(s.messages,i):s.messages=i,i},je=e=>({id:e.N,name:e.L,kind:e.G,disallowMessages:e.refusMess??!1}),$e=(e,s)=>(e===V.SendEveryoneExceptParentsAndStudents&&s&&(e=V.SendEveryone),e===V.ReplyEveryoneExceptParentsAndStudents&&s&&(e=V.ReplyEveryone),e),He=e=>({id:e.N,level:e.L,abbreviation:e.abbreviation,coefficient:e.coefficient,domainID:e.domaine.V.N,domainName:e.domaine.V.L,itemID:e.item?.V.N,itemName:e.item?.V.L,order:e.ordre,pillarID:e.pilier.V.N,pillarName:e.pilier.V.L,pillarPrefixes:e.pilier.V.strPrefixes.split(",").map((e=>e.trim()))}),Ke=e=>{const s=e.listeNiveauxDAcquisitions.V.map(He);return s.sort(((e,s)=>e.order-s.order)),{skills:s,name:e.L,id:e.N,teacher:e.individu.V.L,coefficient:e.coefficient,description:e.descriptif,subject:Ve(e.matiere.V),levels:e.listePaliers.V.map((e=>e.L)),date:z(e.date.V)}},Je=e=>({N:e.id,G:e.kind,L:e.name}),Qe=e=>e*Math.PI/180,We=e=>(e=>e*e)(Math.sin(e/2)),ze=(e,s)=>{const t=Qe(e[0]),n=Qe(s[0]),i=Qe(e[1]),r=Qe(s[1]),o=We(n-t)+Math.cos(t)*Math.cos(n)*We(r-i);return 12756274*Math.asin(Math.sqrt(o))},Ye=e=>{let s,t=_.Grade;if("string"==typeof e)e.split("|").length>=2&&(t=parseInt(e.split("|")[1])),s=parseFloat(e.replace(",",".")),t!==_.AbsentZero&&t!==_.UnreturnedZero||(s=0);else{if("number"!=typeof e)throw new E("decodeGradeValue");s=e}return{kind:t,points:s}},Ze=e=>({student:e.moyEleve&&Ye(e.moyEleve.V),outOf:e.baremeMoyEleve&&Ye(e.baremeMoyEleve.V),defaultOutOf:e.baremeMoyEleveParDefaut&&Ye(e.baremeMoyEleveParDefaut.V),class_average:Ye(e.moyClasse.V),min:Ye(e.moyMin.V),max:Ye(e.moyMax.V),subject:Ve(e),backgroundColor:e.couleur}),Xe=(e,s)=>({grades:e.listeDevoirs.V.map((e=>((e,s)=>{const t=e.N,n=e.estBonus,i=(n,i)=>e[n]&&ne({G:M.File,L:e[n],N:t},s,{G:i});return{id:t,value:Ye(e.note.V),outOf:Ye(e.bareme.V),defaultOutOf:Ye(e.baremeParDefaut.V),date:z(e.date.V),subject:Ve(e.service.V),average:e.moyenne&&Ye(e.moyenne.V),max:Ye(e.noteMax.V),min:Ye(e.noteMin.V),coefficient:e.coefficient,comment:e.commentaire,commentaireSurNote:e.commentaireSurNote,isBonus:n,isOptional:e.estFacultatif&&!n,isOutOf20:e.estRamenerSur20,subjectFile:i("libelleSujet","DevoirSujet"),correctionFile:i("libelleCorrige","DevoirCorrige")}})(e,s))),subjectsAverages:e.listeServices.V.map(Ze),classAverage:e.moyGeneraleClasse&&Ye(e.moyGeneraleClasse.V),overallAverage:e.moyGenerale&&Ye(e.moyGenerale.V)}),es=e=>`${e.getDate()}/${e.getMonth()+1}/${e.getFullYear()} ${e.getHours()}:${e.getMinutes()}:${e.getSeconds()}`,ss=e=>({description:e.commentaire,name:e.L,url:e.url}),ts=e=>({name:e.libellePorteMonnaie,description:e.hintPorteMonnaie,warning:e.avecWarning,balance:parseInt(e.valeurSolde.replace(",",".")),balanceDescription:e.hintSolde}),ns=e=>({sso:e.SSO}),is=e=>{const s=[];let t,n;var i;"partenaireARD"in e&&(i=e.partenaireARD,n={...ns(i),canRefreshData:i.avecActualisation,wallets:i.porteMonnaie.V.map(ts)});for(const n of e.lienUtile.listeLiens.V)"SSO"in n?"TURBOSELF"===n.SSO.codePartenaire&&(t=ns(n)):s.push(ss(n));return{partnerARD:n,partnerTurboself:t,links:s}},rs=e=>({name:e.L,color:e.couleur}),os=e=>({name:e.L,color:e.couleur}),as=e=>({name:e.L,allergens:e.listeAllergenesAlimentaire.V.map(rs),labels:e.listeLabelsAlimentaires.V.map(os)}),cs=e=>{let s=e.ListeRepas.V.reduce(((e,s)=>{let t;switch(s.G){case O.Lunch:t="lunch";break;case O.Dinner:t="dinner";break;default:throw new E("decodeMenu")}return e[t]=(e=>{const s=e.ListePlats.V.reduce(((e,s)=>{let t;switch(s.G){case N.Entry:t="entry";break;case N.Main:t="main";break;case N.Side:t="side";break;case N.Drink:t="drink";break;case N.Fromage:t="fromage";break;case N.Dessert:t="dessert";break;default:throw new E("decodeMeal")}return e[t]=s.ListeAliments.V.map(as),e}),{});return{name:e.L,...s}})(s),e}),{});return{date:z(e.Date.V),...s}},us=e=>({id:e.N,name:e.L,from:e.libelleMatiere}),ls=(e,s)=>({id:e.N,name:e.L,sub:s}),ds=e=>{const s=[];if(e.listeRessources){const t=e.listeRessources.V.filter((e=>e.estUneSousMatiere)).map(us);for(const n of e.listeRessources.V)n.estUneSousMatiere||s.push(ls(n,t.filter((e=>e.from===n.L))))}return{id:e.N,name:e.L,kind:e.G,subjects:s,function:e.fonction&&(t=e.fonction.V,{id:t.N,name:t.L}),isPrincipal:e.estPrincipal??!1};var t},ps=e=>{if(0===e.length)return"[]";const s=[...e].sort(((e,s)=>e-s)),t=[];let n=s[0],i=n;for(let e=1;e<s.length;e++)s[e]-n!=1&&(i===n?t.push(i.toString()):t.push(`${i}..${n}`),i=s[e]),n=s[e];return i===n?t.push(i.toString()):t.push(`${i}..${n}`),`[${t.join(",")}]`},ms=async(e,s,t={delete:!1,markAsRead:!0,onlyMarkAsRead:!1})=>{const n=t.onlyMarkAsRead||t.delete?[]:"information"===s.is?[s.question]:s.questions,i=new H(e,"SaisieActualites",{_Signature_:{onglet:G.News},donnees:{listeActualites:[{N:s.id,L:s.title??"",genrePublic:s.public.G,public:s.public,validationDirecte:!0,listeQuestions:n.map((e=>({N:e.id,L:e.fullTitle,genreReponse:e.kind,reponse:{N:parseInt(e.answerID),Actif:!0,valeurReponse:e.kind===F.InformationText||e.kind===F.TextInput?e.textInputAnswer??"":{_T:8,V:ps(e.selectedAnswers??[])},valeurReponseLibre:e.choices.filter((e=>e.isTextInput)).length>0?e.textInputAnswer:void 0,avecReponse:e.answered,estReponseAttendue:e.shouldAnswer,_validationSaisie:!0}}))),marqueLueSeulement:!t.delete&&t.onlyMarkAsRead,lue:!t.delete&&t.markAsRead,supprimee:!t.onlyMarkAsRead&&t.delete,saisieActualite:!1}],saisieActualite:!1}});await i.send()},fs=async(e,s,t)=>{s.read!==t&&(await ms(e,s,{onlyMarkAsRead:!0,markAsRead:t,delete:!1}),s.read=t)},hs=(e,s)=>({id:e.N,title:e.L,category:s.find((s=>s.id===e.categorie.V.N)),creationDate:z(e.dateCreation.V),startDate:z(e.dateDebut.V),endDate:z(e.dateFin.V),author:e.auteur,public:e.public.V,read:e.lue}),gs=e=>({value:e.L,position:e.rang,isTextInput:!!e.estReponseLibre}),Ds=(e,s)=>{const t=e.genreReponse,n=e.reponse.V.avecReponse;let i,r;return n&&e.reponse.V.valeurReponse&&("string"==typeof e.reponse.V.valeurReponse?r=e.reponse.V.valeurReponse:(i=m(e.reponse.V.valeurReponse.V),r=e.reponse.V.valeurReponseLibre)),{id:e.N,fullTitle:e.L,title:e.titre,position:e.rang,kind:t,maximumLength:e.tailleReponse,shouldRespectMaximumChoices:e.avecMaximum,maximumChoices:e.nombreReponsesMax,content:e.texte.V,attachments:e.listePiecesJointes.V.map((e=>ne(e,s))),answerID:e.reponse.V.N,answered:n,shouldAnswer:e.reponse.V.estReponseAttendue,answerDate:e.reponse.V.reponduLe?.V&&z(e.reponse.V.reponduLe.V),choices:t===F.TextInput?[]:e.listeChoix.V.map(gs),selectedAnswers:i,textInputAnswer:r}},bs=(e,s,t)=>({is:"information",...hs(e,t),question:Ds(e.listeQuestions.V[0],s),get attachments(){return this.question.attachments},get acknowledged(){return this.question.answered},get acknowledgedDate(){return this.question.answerDate},get needToAcknowledge(){return this.question.shouldAnswer},get content(){return this.question.content}}),Cs=e=>({id:e.N,name:e.L,default:e.estDefaut??!1}),As=(e,s,t)=>({is:"survey",...hs(e,t),questions:e.listeQuestions.V.map((e=>Ds(e,s))),isAnonymous:e.reponseAnonyme}),ws=e=>{const[s,t]=e.NbrHeures.split("h").map(Number),n=e.estMotifNonEncoreConnu;return{id:e.name,startDate:z(e.dateDebut.V),endDate:z(e.dateFin.V),justified:e.justifie,opened:e.ouverte,hoursMissed:s,minutesMissed:t,daysMissed:e.NbrJours,shouldParentsJustify:e.aJustifierParParents,administrativelyFixed:e.reglee,isReasonUnknown:n,reason:!n&&e.listeMotifs.V[0].L}},Es=e=>{const s=e.estMotifNonEncoreConnu,t=e.justifie;return{id:e.N,date:z(e.date.V),minutes:e.duree,justified:t,justification:t&&e.justification,shouldParentsJustify:e.aJustifierParParents,administrativelyFixed:e.reglee,isReasonUnknown:s,reason:!s&&e.listeMotifs.V[0].L}},vs=(e,s)=>({id:e.N,title:e.nature.V.L,reasons:e.listeMotifs.V.map((e=>e.L)),exclusion:e.estUneExclusion,isDuringLesson:!e.horsCours,workToDo:e.travailAFaire,workToDoDocuments:e.documentsTAF.V.map((e=>ne(e,s))),circumstances:e.circonstances,circumstancesDocuments:e.documentsCirconstances.V.map((e=>ne(e,s))),giver:e.demandeur.V.L,dateGiven:z(e.dateDemande.V),durationMinutes:e.duree}),ys=e=>{let s;return"L"in e.matiere.V&&"0"!==e.matiere.V.N&&(s=Ve(e.matiere.V)),{id:e.N,date:z(e.date.V),opened:e.estLue,shouldParentsJustify:e.avecARObservation,name:e.L,kind:e.genreObservation,sectionID:e.rubrique.V.N,subject:s,reason:e.commentaire}},Ss=(e,s)=>({id:e.N,title:e.nature.V.L,comments:e.commentaire,reasons:e.listeMotifs.V.map((e=>e.L)),exclusion:e.estUneExclusion,circumstances:e.circonstances,circumstancesDocuments:e.documentsCirconstances.V.map((e=>ne(e,s))),decisionMaker:e.decideur.V.L,giver:e.demandeur.V.L,dateGiven:z(e.dateDemande.V),startDate:z(e.dateDebut.V),endDate:z(e.dateFin.V),disallowedAccesses:m(e.interditAcces.V)}),xs=(e,s)=>({id:e.N,startDate:z(e.Date.V),endDate:z(e.DateFin.V),subject:Ve(e.Matiere.V),haveAssignment:void 0!==e.dateTAF,assignmentDeadline:e.dateTAF?.V&&z(e.dateTAF.V),teachers:e.listeProfesseurs.V.map((e=>e.L)),groups:e.listeGroupes.V.map((e=>e.L)),backgroundColor:e.CouleurFond,contents:e.listeContenus.V.map((e=>((e,s)=>({id:e.N,title:e.L,description:e.descriptif.V,category:e.categorie.V.G,files:e.ListePieceJointe.V.map((e=>ne(e,s))),themes:e.ListeThemes.V.map((e=>Ne(e))),educativeValue:e.parcoursEducatif}))(e,s)))}),Ms=(e,s)=>s.ListeCahierDeTextes.V.map((s=>xs(s,e))),Ps=(e,s)=>({[e]:s,[e[0].toUpperCase()+e.substring(1)]:s}),Vs=(e,s)=>{const t=z(e.DateDuCours.V),n=e.place,i=e.duree;let r;if("string"==typeof e.DateDuCoursFin?.V)r=z(e.DateDuCoursFin.V);else{const e=(({instance:{endings:e}},s)=>{s>e.length&&(s%=e.length-1);const t=e[s],[n,i]=t.split("h").map(Number);return{hours:n,minutes:i}})(s,n%s.instance.blocksPerDay+i-1);r=new Date(t),r.setHours(e.hours,e.minutes)}return{id:e.N,backgroundColor:e.CouleurFond,notes:e.memo,startDate:t,endDate:r,blockLength:i,blockPosition:n,weekNumber:Se(t,s.instance.firstMonday)}},Ns=(e,s)=>({absences:e.absences,withCanceledClasses:e.avecCoursAnnule??!0,classes:(e.ListeCours??[]).map((e=>(e=>"estSortiePedagogique"in e&&e.estSortiePedagogique)(e)?((e,s)=>({is:"activity",...Vs(e,s),title:e.motif,attendants:e.accompagnateurs,resourceTypeName:e.strGenreRess,resourceValue:e.strRess}))(e,s):(e=>"estRetenue"in e&&void 0!==e.estRetenue)(e)?((e,s)=>{let t;const n=[],i=[],r=[];if("ListeContenus"in e)for(const s of e.ListeContenus.V){const e=s.L;if(s.estHoraire)t=e;else if("G"in s)switch(s.G){case 3:i.push(e);break;case 34:n.push(e);break;case 17:r.push(e)}}return{is:"detention",...Vs(e,s),title:t,personalNames:n,teacherNames:i,classrooms:r}})(e,s):((e,s)=>{const t=[],n=[],i=[],r=[],o=[];let a,c;if(e.listeVisios)for(const s of e.listeVisios.V)t.push(s.url);if(e.ListeContenus)for(const s of e.ListeContenus.V)switch(s.G){case 16:a=Ve(s);break;case 3:n.push(s.L);break;case 34:i.push(s.L);break;case 17:r.push(s.L);break;case 2:o.push(s.L)}return e.AvecCdT&&e.cahierDeTextes&&(c=e.cahierDeTextes.V.N),{is:"lesson",...Vs(e,s),kind:e.G,status:e.Statut,canceled:e.estAnnule??!1,exempted:e.dispenseEleve??!1,test:e.cahierDeTextes?.V.estDevoir??!1,virtualClassrooms:t,personalNames:i,teacherNames:n,classrooms:r,groupNames:o,subject:a,lessonResourceID:c}})(e,s))).sort(((e,s)=>e.startDate.getTime()-s.startDate.getTime()))}),Is=async(e,s,t={})=>{const n=new H(e,"PageEmploiDuTemps",{_Signature_:{onglet:G.Timetable},donnees:{estEDTAnnuel:!1,estEDTPermanence:!1,avecAbsencesEleve:!1,avecRessourcesLibrePiedHoraire:!1,avecAbsencesRessource:!0,avecInfosPrefsGrille:!0,avecConseilDeClasse:!0,avecCoursSortiePeda:!0,avecDisponibilites:!0,avecRetenuesEleve:!0,edt:{G:16,L:"Emploi du temps"},...Ps("ressource",(i=e.user.resources[s],{G:i.kind,L:i.name,N:i.id})),...t}});var i;const r=await n.send();return Ns(r.data.donnees,e)};exports.AccessDeniedError=u,exports.AccountDisabledError=l,exports.AccountKind=S,exports.AssignmentDifficulty={None:0,Easy:1,Medium:2,Hard:3},exports.AssignmentReturnKind=x,exports.AttachmentKind=M,exports.AuthenticateError=c,exports.BadCredentialsError=a,exports.BusyPageError=C,exports.DiscussionActionError=d,exports.DiscussionCommand=P,exports.DiscussionFolderKind={OCEM_Utilisateur:0,OCEM_Pre_Reception:1,OCEM_Pre_Archive:2,OCEM_Pre_Envoye:3,OCEM_Pre_Brouillon:4,OCEM_Pre_Poubelle:5,OCEM_Pre_Signalement:6,OCEM_Expl_Bleu:7,OCEM_Expl_Vert:8,OCEM_Expl_Rouge:9,OCEM_Pre_CarnetLiaison:10,OCEM_Pre_Alerte:11,OCEM_Pre_ContactVS:12,OCEM_Pre_Conversation:13,OCEM_Pre_InvisiblePlageDesactivee:14},exports.DiscussionMessagesMissingError=p,exports.DiscussionSendAction=V,exports.DishKind=N,exports.DocumentFileFormat={UNKNOWN:0,TEXT:1,PDF:2,EXCEL:3,ARCHIVE:4,IMAGE:5,SOUND:6,VIDEO:7,DIAPORAMA:8,GEOGEBRA:9},exports.DocumentKind=I,exports.DoubleAuthClientAction=L,exports.DoubleAuthMode={MGDA_PasEncoreChoisi:0,MGDA_Inactive:1,MGDA_NotificationSeulement:2,MGDA_SaisieCodePIN:3},exports.DoubleAuthServerAction=R,exports.EntityKind=T,exports.EntityState=k,exports.GradeKind=_,exports.MealKind=O,exports.NewsQuestionKind=F,exports.NewsView={Reception:0,Broadcast:1,Draft:2,Template:3},exports.NotebookObservationKind={LogBookIssue:0,Observation:1,Encouragement:2,Other:3},exports.PageUnavailableError=b,exports.RateLimitedError=A,exports.ResourceContentCategory={NONE:0,LESSON:1,CORRECTION:2,DST:3,ORAL_INTERROGATION:4,TD:5,TP:6,EVALUATION_COMPETENCES:7,EPI:8,AP:9,VISIO:12},exports.SecurityError=f,exports.SecuritySourceTooLongError=h,exports.ServerSideError=w,exports.SessionAccessKind=U,exports.SessionExpiredError=D,exports.SuspendedIPError=g,exports.TabLocation=G,exports.UnreachableError=E,exports.UploadFailedError=y,exports.UploadSizeError=v,exports.account=async e=>{const s=new H(e,"PageInfosPerso",{_Signature_:{onglet:G.Account}});return((e,s)=>{const t=e.Informations;let n;return s.instance.version[0]>=2024&&(n=e.iCal?.liste.V[0]?.paramICal),{address:[t.adresse1,t.adresse2,t.adresse3,t.adresse4],postalCode:t.codePostal,province:t.province,country:t.pays,city:t.ville,email:t.eMail,phone:`+${t.indicatifTel}${t.telephonePortable}`,INE:t.numeroINE,iCalToken:n}})((await s.send()).data.donnees,e)},exports.assignmentRemoveFile=async(e,s)=>{const t=new H(e,"SaisieTAFARendreEleve",{_Signature_:{onglet:G.Assignments},donnees:{listeFichiers:[{E:k.DELETION,TAF:{N:s}}]}});await t.send()},exports.assignmentStatus=async(e,s,t)=>{const n=new H(e,"SaisieTAFFaitEleve",{_Signature_:{onglet:G.Assignments},donnees:{listeTAF:[{E:k.MODIFICATION,TAFFait:t,N:s}]}});await n.send()},exports.assignmentUploadFile=async(e,s,t,n)=>{const i=t.size||t.byteLength,r=e.user.authorizations.maxAssignmentFileUploadSize;if("number"==typeof i&&i>r)throw new v(r);const o=new Pe(e,"SaisieTAFARendreEleve",t,n);await o.send();const a=new H(e,"SaisieTAFARendreEleve",{_Signature_:{onglet:G.Assignments},donnees:{listeFichiers:[{E:k.CREATION,G:I.FILE,L:n,N:Me(),idFichier:o.id,TAF:{N:s}}]}});await a.send()},exports.assignmentsFromIntervals=async(e,s,t)=>{const n=await Re(e,G.Assignments,s,t);return Te(e,n).filter((e=>s<=e.deadline&&e.deadline<=t))},exports.assignmentsFromWeek=async(e,s,t)=>{const n=await Le(e,G.Assignments,s,t);return Te(e,n)},exports.cleanURL=o,exports.clearPresenceInterval=we,exports.createSessionHandle=(s=e.defaultFetcher)=>({information:null,instance:null,user:null,queue:new Ee,fetcher:s,presence:null}),exports.discussionCreateDraft=async(e,s,t,n=s.messages?.defaultReplyMessageID)=>{await ke(e,P.brouillon,{id:Me(),content:t,replyMessageID:n}),await Oe(e,s.cache),await qe(e,s)},exports.discussionDelete=async(e,s)=>{await ke(e,P.Delete,{possessions:s.possessions}),await Oe(e,s.cache)},exports.discussionMessages=qe,exports.discussionRead=async(e,s)=>{await qe(e,s,!0)},exports.discussionRecipients=async(e,s)=>{const t=new H(e,"SaisiePublicMessage",{_Signature_:{onglet:G.Discussions},donnees:{message:{N:s.participantsMessageID},estPublicParticipant:!0,estDestinatairesReponse:!1}});return(await t.send()).data.donnees.listeDest.V.map(je)},exports.discussionRemoteMutateDraft=async(e,s,t)=>{await ke(e,P.brouillon,{id:t.possessionID,content:t.content,replyMessageID:t.replyMessageID}),await Oe(e,s.cache),await qe(e,s)},exports.discussionRemoveDraft=async(e,s,t)=>{await ke(e,P.Delete,{possessions:[{N:t.possessionID}]}),await Oe(e,s.cache),await qe(e,s)},exports.discussionRestoreTrash=async(e,s)=>{await ke(e,P.Restore,{possessions:s.possessions}),await Oe(e,s.cache)},exports.discussionSendDraft=async(e,s,t,n=!1)=>{if(void 0===s.messages?.sendAction)throw new d;await ke(e,"",{button:$e(s.messages.sendAction,n),content:t.content,id:t.possessionID,replyMessageID:t.replyMessageID}),await Oe(e,s.cache),await qe(e,s)},exports.discussionSendMessage=async(e,s,t,n=!1,i=s.messages?.defaultReplyMessageID)=>{if(!s.messages)throw new p;if(void 0===s.messages.sendAction)throw new d;const r=$e(s.messages.sendAction,n),o=new H(e,"SaisieMessage",{donnees:{contenu:e.user.authorizations.hasAdvancedDiscussionEditor?{_T:21,V:t}:t,bouton:{N:0,G:r},brouillon:{N:Me(),E:k.CREATION},genreDiscussion:0,messagePourReponse:{G:0,N:i},listeFichiers:[]},_Signature_:{onglet:G.Discussions}});await o.send(),await Oe(e,s.cache),await qe(e,s)},exports.discussionTrash=async(e,s)=>{await ke(e,P.Trash,{possessions:s.possessions}),await Oe(e,s.cache)},exports.discussions=Oe,exports.evaluations=async(e,s)=>{const t=new H(e,"DernieresEvaluations",{_Signature_:{onglet:G.Evaluations},donnees:{periode:Je(s)}});return(await t.send()).data.donnees.listeEvaluations.V.map(Ke)},exports.finishLoginManually=he,exports.frequency=(e,s)=>e.instance.weekFrequencies.get(s),exports.geolocation=async(s,t=e.defaultFetcher)=>{const n=`data={"nomFonction":"geoLoc","lat":"${s.latitude}","long":"${s.longitude}"}`,i=await t({url:new URL("https://www.index-education.com/swie/geoloc.php"),method:"POST",content:n,headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"}});if("{}"===i.content)return[];const r=JSON.parse(i.content).map((e=>((e,s)=>{const t=parseFloat(e.lat),n=parseFloat(e.long);return{url:e.url.toLowerCase(),name:e.nomEtab.trim().replace("COLLEGE","COLLÈGE").replace("LYCEE","LYCÉE"),latitude:t,longitude:n,postalCode:parseInt(e.cp),distance:ze(s,[t,n])}})(e,[s.latitude,s.longitude])));return r.sort(((e,s)=>e.distance>s.distance?1:e.distance<s.distance?-1:e.name>s.name?1:e.name<s.name?-1:0)),r},exports.gradebookPDF=async(e,s)=>{const t=new H(e,"GenerationPDF",{donnees:{avecCodeCompetences:!1,genreGenerationPDF:2,options:{adapterHauteurService:!1,desEleves:!1,gererRectoVerso:!1,hauteurServiceMax:15,hauteurServiceMin:10,piedMonobloc:!0,portrait:!0,taillePolice:6.5,taillePoliceMin:5,taillePolicePied:6.5,taillePolicePiedMin:5},periode:Je(s)},_Signature_:{onglet:G.Gradebook}}),n=await t.send();return e.information.url+"/"+encodeURI(n.data.donnees.url.V)},exports.gradesOverview=async(e,s)=>{const t=new H(e,"DernieresNotes",{_Signature_:{onglet:G.Grades},donnees:{Periode:Je(s)}}),n=await t.send();return Xe(n.data.donnees,e)},exports.homepage=async(e,s=e.instance.nextBusinessDay)=>{const t=Se(s,e.instance.firstMonday),n=es(s),i=new H(e,"PageAccueil",{_Signature_:{onglet:G.Presence},donnees:{avecConseilDeClasse:!0,dateGrille:{_T:7,V:n},numeroSemaine:t,coursNonAssures:{numeroSemaine:t},personnelsAbsents:{numeroSemaine:t},incidents:{numeroSemaine:t},exclusions:{numeroSemaine:t},donneesVS:{numeroSemaine:t},registreAppel:{date:{_T:7,V:n}},previsionnelAbsServiceAnnexe:{date:{_T:7,V:n}},donneesProfs:{numeroSemaine:t},EDT:{numeroSemaine:t},TAFARendre:{date:{_T:7,V:n}},TAFEtActivites:{date:{_T:7,V:n}},partenaireCDI:{CDI:{}},tableauDeBord:{date:{_T:7,V:n}},modificationsEDT:{date:{_T:7,V:n}}}}),r=await i.send();return is(r.data.donnees)},exports.instance=async(s,t=e.defaultFetcher)=>{s=o(s),s+="/infoMobileApp.json?id=0D264427-EEFC-4810-A9E9-346942A862A4";const n={url:new URL(s)},i=await t(n);return(e=>{let s,t;return e.CAS.actif&&(s=e.CAS.casURL,t=e.CAS.jetonCAS),{name:e.nomEtab,version:e.version,date:new Date(e.date),accounts:e.espaces.map((e=>({name:e.nom,path:e.URL}))),casURL:s,casToken:t}})(JSON.parse(i.content))},exports.loginCredentials=async(e,s)=>{const t=o(s.url);e.information=await B({base:t,kind:s.kind,cookies:[],params:{...ae,bydlg:"A6ABB224-12DD-4E31-AD3E-8A39A1C2C335"}},e.fetcher),e.instance=await X(e,s.navigatorIdentifier);const n=await ee(e,{username:s.username,deviceUUID:s.deviceUUID,requestFirstMobileAuthentication:!0,reuseMobileAuthentication:!1,requestFromQRCode:!1,useCAS:!1});de(s,"password",n);const i=le(n,s.username,s.password),r=pe(e,n,i),a=await se(e,r);return me(e,a,i),fe(a)?ue(e,{token:a.jetonConnexionAppliMobile,username:n.login??s.username,deviceUUID:s.deviceUUID}):he(e,a,n,s.username)},exports.loginQrCode=async(e,s)=>{const t=(e=>{const s=e.url,t=s.lastIndexOf("/")+1,n=s.substring(0,t-1),i=s.substring(t);return{kind:oe(i),url:n,token:e.jeton,username:e.login}})(s.qr),n=i.default.util.createBuffer(s.pin),r=e=>q.decrypt(i.default.util.encodeUtf8(t[e]),n,i.default.util.createBuffer()),o={username:r("username"),token:r("token")};e.information=await B({base:t.url,kind:t.kind,cookies:["appliMobile=1"],params:ae},e.fetcher),e.instance=await X(e,s.navigatorIdentifier);const a=await ee(e,{username:o.username,deviceUUID:s.deviceUUID,requestFirstMobileAuthentication:!0,reuseMobileAuthentication:!1,requestFromQRCode:!0,useCAS:!1});de(o,"token",a);const c=le(a,o.username,o.token),u=pe(e,a,c),l=await se(e,u);return me(e,l,c),fe(l)?ue(e,{token:l.jetonConnexionAppliMobile,username:a.login??o.username,deviceUUID:s.deviceUUID}):he(e,l,a,o.username)},exports.loginToken=ce,exports.menus=async(e,s=new Date)=>{const t=new H(e,"PageMenus",{_Signature_:{onglet:G.Menus},donnees:{date:{_T:7,V:es(s)}}}),n=await t.send();return{containsLunch:(i=n.data.donnees).AvecRepasMidi,containsDinner:i.AvecRepasSoir,days:i.ListeJours.V.map(cs),weeks:m(i.DomaineDePresence.V),allergens:i.ListeAllergenes.V.map(rs),labels:i.Listelabels.V.map(os)};var i},exports.newDiscussion=async(e,s,t,n)=>{const i=new H(e,"SaisieMessage",{_Signature_:{onglet:G.Discussions},donnees:{contenu:e.user.authorizations.hasAdvancedDiscussionEditor?{_T:21,V:t}:t,objet:s,estCreationCarnetLiaison:!1,listeFichiers:[],listeDestinataires:n.map((e=>({E:k.MODIFICATION,G:e.kind,N:e.id})))}});await i.send()},exports.newDiscussionRecipients=async(e,s,t)=>{const n=new H(e,"ListeRessourcesPourCommunication",{_Signature_:{onglet:G.Discussions},donnees:{filtreElement:{G:s.kind,L:s.name,N:s.id},onglet:{N:0,G:t}}});return(await n.send()).data.donnees.listeRessourcesPourCommunication.V.filter((e=>e.avecDiscussion)).map(ds)},exports.news=async e=>{const s=new H(e,"PageActualites",{_Signature_:{onglet:G.News},donnees:{modesAffActus:{_T:26,V:ps([0])}}});return((e,s)=>{const t=e.listeCategories.V.map(Cs);return{categories:t,items:e.listeModesAff[0].listeActualites.V.map((e=>{let n;if(e.estInformation)n=bs;else{if(!e.estSondage)throw new E("decodeNews");n=As}return n(e,s,t)}))}})((await s.send()).data.donnees,e)},exports.newsDelete=async(e,s)=>{await ms(e,s,{onlyMarkAsRead:!1,markAsRead:!1,delete:!0})},exports.newsInformationAcknowledge=async(e,s,t=!0)=>{if(!s.needToAcknowledge||s.acknowledged)return fs(e,s,t);ge(s.question,""),await ms(e,s,{markAsRead:t,onlyMarkAsRead:!1,delete:!1}),t&&(s.read=!0)},exports.newsQuestionLocalMutate=ge,exports.newsRead=fs,exports.newsSurveySend=async(e,s,t=!0)=>{await ms(e,s,{markAsRead:t,onlyMarkAsRead:!1,delete:!1}),t&&(s.read=!0)},exports.notebook=async(e,s)=>{const t=new H(e,"PagePresence",{_Signature_:{onglet:G.Notebook},donnees:{periode:Je(s),DateDebut:{_T:7,V:es(s.startDate)},DateFin:{_T:7,V:es(s.endDate)}}});return((e,s)=>{const t=[],n=[],i=[],r=[],o=[];for(const a of e.listeAbsences.V)switch(a.G){case 13:t.push(ws(a));break;case 14:n.push(Es(a));break;case 41:i.push(vs(a,s));break;case 46:r.push(ys(a));break;case 72:o.push(Ss(a,s))}return{absences:t,delays:n,punishments:i,observations:r,precautionaryMeasures:o}})((await t.send()).data.donnees,e)},exports.parseTimetable=(e,s,{withSuperposedCanceledClasses:t=!1,withCanceledClasses:n=s.withCanceledClasses,withPlannedClasses:i=!0})=>{const r=s.classes;if(!n)for(const e of r)"lesson"===e.is&&e.canceled&&(e._visible=!1);if(!i)for(const e of r)"lesson"===e.is&&!1!==e._visible&&!e.canceled&&[0,3,4].includes(e.kind)&&(e._visible=!1);if(n&&!t){let s=!0;for(;s;)s=Ce(e,r)}s.classes=r.filter((e=>!1!==e._visible));for(const e