TP_JO2024/home/dist/core/core.module.min.js

4 lines
52 KiB
JavaScript
Raw Permalink Normal View History

2024-03-27 17:19:37 +01:00
/*! DSFR v1.11.2 | SPDX-License-Identifier: MIT | License-Filename: LICENSE.md | restricted use (see terms and conditions) */
const t=new class{constructor(){this.modules={}}create(t){const e=new t;this.modules[e.type]=e}getModule(t){return this.modules[t]}add(t,e){this.modules[t].add(e)}remove(t,e){this.modules[t].remove(e)}get isActive(){return this._isActive}set isActive(t){if(t===this._isActive)return;this._isActive=t;const e=Object.keys(this.modules).map((t=>this.modules[t]));if(t)for(const t of e)t.activate();else for(const t of e)t.deactivate()}get isLegacy(){return this._isLegacy}set isLegacy(t){t!==this._isLegacy&&(this._isLegacy=t)}},e="fr",s="dsfr",i="@gouvfr",n="1.11.2";class r{constructor(t,e,s,i){switch(this.level=t,this.light=e,this.dark=s,i){case"warn":this.logger=console.warn;break;case"error":this.logger=console.error;break;default:this.logger=console.log}}log(...t){const e=new o(s);for(const s of t)e.add(s);this.print(e)}print(t){t.setColor(this.color),this.logger.apply(console,t.getMessage())}get color(){return window.matchMedia("(prefers-color-scheme: dark)").matches?this.dark:this.light}}class o{constructor(t){this.inputs=["%c"],this.styles=["font-family:Marianne","line-height: 1.5"],this.objects=[],t&&this.add(`${t} :`)}add(t){switch(typeof t){case"object":case"function":this.inputs.push("%o "),this.objects.push(t);break;default:this.inputs.push(`${t} `)}}setColor(t){this.styles.push(`color:${t}`)}getMessage(){return[this.inputs.join(""),this.styles.join(";"),...this.objects]}}const h={log:new r(0,"#616161","#989898"),debug:new r(1,"#000091","#8B8BFF"),info:new r(2,"#007c3b","#00ed70"),warn:new r(3,"#ba4500","#fa5c00","warn"),error:new r(4,"#D80600","#FF4641","error")};const a=new class{constructor(){this.level=2;for(const t in h){const e=h[t];this[t]=(...t)=>{this.level<=e.level&&e.log.apply(e,t)},this[t].print=e.print.bind(e)}}state(){const e=new o;e.add(t),this.log.print(e)}tree(){const e=t.getModule("stage");if(!e)return;const s=new o;this._branch(e.root,0,s),this.log.print(s)}_branch(t,e,s){let i="";if(e>0){let t="";for(let s=0;s<e;s++)t+=" ";i+=t+"└─ "}i+=`[${t.id}] ${t.html}`,s.add(i),s.add({"@":t}),s.add("\n");for(const n of t.children)i+=this._branch(n,e+1,s)}},c=t=>{"loading"!==document.readyState?window.requestAnimationFrame(t):document.addEventListener("DOMContentLoaded",t)},l={AUTO:"auto",MANUAL:"manual",RUNTIME:"runtime",LOADED:"loaded",VUE:"vue",ANGULAR:"angular",REACT:"react"};const d=new class{constructor(){this._mode=l.AUTO,this.isStarted=!1,this.starting=this.start.bind(this),this.preventManipulation=!1}configure(t={},e,s){this.startCallback=e;const i=t.production&&(!s||"false"!==s.production);switch(!0){case s&&!isNaN(s.level):a.level=Number(s.level);break;case s&&s.verbose&&("true"===s.verbose||1===s.verbose):a.level=0;break;case i:a.level=999;break;case t.verbose:a.level=0}a.info(`version ${n}`),this.mode=t.mode||l.AUTO}set mode(t){switch(t){case l.AUTO:this.preventManipulation=!1,e=this.starting,c(e);break;case l.LOADED:this.preventManipulation=!1,c(this.starting);break;case l.RUNTIME:this.preventManipulation=!1,this.start();break;case l.MANUAL:this.preventManipulation=!1;break;case l.VUE:case l.ANGULAR:case l.REACT:this.preventManipulation=!0;break;default:return void a.error("Illegal mode")}var e;this._mode=t,a.info(`mode set to ${t}`)}get mode(){return this._mode}start(){a.info("start"),this.startCallback()}};class u{constructor(){this._collection=[]}forEach(t){this._collection.forEach(t)}map(t){return this._collection.map(t)}get length(){return this._collection.length}add(t){return!(this._collection.indexOf(t)>-1)&&(this._collection.push(t),this.onAdd&&this.onAdd(),this.onPopulate&&1===this._collection.length&&this.onPopulate(),!0)}remove(t){const e=this._collection.indexOf(t);if(-1===e)return!1;this._collection.splice(e,1),this.onRemove&&this.onRemove(),this.onEmpty&&0===this._collection.length&&this.onEmpty()}execute(...t){for(const e of this._collection)e&&e.apply(null,t)}clear(){this._collection.length=0}clone(){const t=new u;return t._collection=this._collection.slice(),t}get collection(){return this._collection}}class g extends u{constructor(t){super(),this.type=t,this.isActive=!1}
//# sourceMappingURL=core.module.min.js.map