{"version":3,"sources":["https:\/\/fi.teluq.ca\/theme\/formation_demystifier_ia\/amd\/src\/auto-toc.js"],"names":["define","params","context","target","titles","idPrefix","init","self","document","querySelector","l","titlesSelectors","join","querySelectorAll","list","createElement","Array","prototype","slice","call","title","i","item","link","innerText","href","id","appendChild"],"mappings":";;;;AAAAA,MAAM,CAAC,EAAD,EAAK,YAAW;AAElB,SAAO;AACHC,IAAAA,MAAM,EAAE;AACJC,MAAAA,OAAO,EAAE,eADL;AAEJC,MAAAA,MAAM,EAAE,WAFJ;AAGJC,MAAAA,MAAM,EAAE,CAAC,KAAD,CAHJ;AAIJC,MAAAA,QAAQ,EAAE;AAJN,KADL;AAOHC,IAAAA,IAAI,EAAE,cAASL,MAAT,EAAiB;AAAA;;AACnB,WAAKA,MAAL,GAAc,SAAc,KAAKA,MAAnB,EAA2BA,MAA3B,CAAd;AACA,UAAIM,IAAI,GAAG,IAAX;AACA,UAAIL,OAAO,GAAGM,QAAQ,CAACC,aAAT,CAAuB,KAAKR,MAAL,CAAYC,OAAnC,CAAd;;AAEA,UAAIM,QAAQ,CAACC,aAAT,CAAuB,KAAKR,MAAL,CAAYC,OAAZ,GAAsB,GAAtB,GAA4B,KAAKD,MAAL,CAAYE,MAA\/D,CAAJ,EAA4E;AAAA,iBAClD,KAAKF,MAAL,CAAYG,MADsC;;AAAA,iBAC3B,YAAAM,CAAC;AAAA,iBAAI,KAAI,CAACT,MAAL,CAAYC,OAAZ,GAAsBQ,CAA1B;AAAA,SAD0B;;AAAA;;AAAA;AAAA;AAAA;;AACxE,YAAIC,eAAe,GAAG,GAAqDC,IAArD,CAA0D,IAA1D,CAAtB;;AACA,YAAIR,MAAM,GAAGF,OAAO,CAACW,gBAAR,CAAyBF,eAAzB,CAAb;AACA,YAAIG,IAAI,GAAGN,QAAQ,CAACO,aAAT,CAAuB,IAAvB,CAAX;AACA,YAAIZ,MAAM,GAAGD,OAAO,CAACO,aAAR,CAAsB,KAAKR,MAAL,CAAYE,MAAlC,CAAb;;AAJwE,kBAKxEa,KAAK,CAACC,SAAN,CAAgBC,KAAhB,CAAsBC,IAAtB,CAA2Bf,MAA3B,CALwE;;AAAA,kBAK7B,aAASgB,KAAT,EAAgBC,CAAhB,EAAmB;AAC1D,cAAIC,IAAI,GAAGd,QAAQ,CAACO,aAAT,CAAuB,IAAvB,CAAX;AACA,cAAIQ,IAAI,GAAGf,QAAQ,CAACO,aAAT,CAAuB,GAAvB,CAAX;AACAQ,UAAAA,IAAI,CAACC,SAAL,GAAiBJ,KAAK,CAACI,SAAvB;AACAD,UAAAA,IAAI,CAACE,IAAL,GAAY,MAAML,KAAK,CAACM,EAAxB;;AACA,cAAI,CAACN,KAAK,CAACM,EAAX,EAAe;AACXH,YAAAA,IAAI,CAACE,IAAL,GAAY,MAAMlB,IAAI,CAACN,MAAL,CAAYI,QAAlB,GAA6B,GAA7B,GAAmCgB,CAA\/C;AACAD,YAAAA,KAAK,CAACM,EAAN,GAAWnB,IAAI,CAACN,MAAL,CAAYI,QAAZ,GAAuB,GAAvB,GAA6BgB,CAAxC;AACH;;AACDC,UAAAA,IAAI,CAACK,WAAL,CAAiBJ,IAAjB;AACAT,UAAAA,IAAI,CAACa,WAAL,CAAiBL,IAAjB;AACH,SAhBuE;;AAAA;AAAA;AAAA;;AAKxE;AAYAnB,QAAAA,MAAM,CAACwB,WAAP,CAAmBb,IAAnB;AACH;AAEJ;AAhCE,GAAP;AAmCH,CArCK,CAAN","sourcesContent":["define([], function() {\r\n\r\n return {\r\n params: {\r\n context: \".main-content\",\r\n target: \".auto-toc\",\r\n titles: [\">h2\"],\r\n idPrefix: \"auto-toc-item\"\r\n },\r\n init: function(params) {\r\n this.params = Object.assign(this.params, params);\r\n var self = this;\r\n var context = document.querySelector(this.params.context);\r\n\r\n if (document.querySelector(this.params.context + \" \" + this.params.target)) {\r\n var titlesSelectors = this.params.titles.map(l => this.params.context + l).join(\", \");\r\n var titles = context.querySelectorAll(titlesSelectors);\r\n var list = document.createElement(\"ul\");\r\n var target = context.querySelector(this.params.target);\r\n Array.prototype.slice.call(titles).forEach(function(title, i) {\r\n var item = document.createElement(\"li\");\r\n var link = document.createElement(\"a\");\r\n link.innerText = title.innerText;\r\n link.href = \"#\" + title.id;\r\n if (!title.id) {\r\n link.href = \"#\" + self.params.idPrefix + \"-\" + i;\r\n title.id = self.params.idPrefix + \"-\" + i;\r\n }\r\n item.appendChild(link);\r\n list.appendChild(item);\r\n });\r\n target.appendChild(list);\r\n }\r\n\r\n }\r\n };\r\n\r\n});"],"file":"auto-toc.min.js"}