UNPKG

@jirkasa/code-box

Version:

Showcase code samples on the web with a container that lets users select and display different samples.

7 lines 156 kB
/*! * Code Box * https://github.com/Jirkasa/code-box * Copyright (c) 2025 Jiří Satora * Licensed under the MIT license. */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("CodeBox",[],t):"object"==typeof exports?exports.CodeBox=t():e.CodeBox=t()}(window,(()=>(()=>{"use strict";var e={d:(t,i)=>{for(var o in i)e.o(i,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:i[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{CodeBox:()=>u,CodeBoxCodeView:()=>p,CodeBoxCodeViewManager:()=>f,CodeBoxCreator:()=>_e,CodeBoxFile:()=>E,CodeBoxFileManager:()=>g,CodeBoxMemento:()=>_,CodeView:()=>c,CodeViewButton:()=>C,CodeViewCreator:()=>Ce,CodeViewMemento:()=>d,ElementCodeViewButton:()=>v,ElementFileButon:()=>A,FileButton:()=>w,HighlightBox:()=>n,ProjectCodeBox:()=>he,ProjectCodeBoxCodeView:()=>ne,ProjectCodeBoxCreator:()=>we,ProjectCodeBoxFile:()=>ae,TabCodeBox:()=>S,TabCodeBoxCodeView:()=>B,TabCodeBoxCreator:()=>me,TabCodeBoxFile:()=>V,VirtualCodeBox:()=>ge,VirtualCodeBoxCreator:()=>Ae});const i=function(){function e(){}return e.CODE_VIEW="cb-code-view",e.CODE_VIEW_GUTTER="cb-code-view__gutter",e.CODE_VIEW_GUTTER_HIDDEN_MODIFIER="cb-code-view__gutter--hidden",e.CODE_VIEW_LINE_NUMBER="cb-code-view__line-number",e.CODE_VIEW_LINE_NUMBER_HIDDEN_MODIFIER="cb-code-view__line-number--hidden",e.CODE_VIEW_CONTAINER="cb-code-view__container",e.CODE_VIEW_CONTENT_CONTAINER="cb-code-view__content",e.CODE_VIEW_HIGHLIGHT_BOX="cb-code-view__highlight",e.TAB_CODE_BOX="cb-tab-code-box",e.TAB_CODE_BOX_TABS="cb-tab-code-box__tabs",e.TAB_CODE_BOX_TAB="cb-tab-code-box__tab",e.TAB_CODE_BOX_TAB_ACTIVE_MODIFIER="cb-tab-code-box__tab--active",e.TAB_CODE_BOX_TAB_ICON="cb-tab-code-box__tab-icon",e.TAB_CODE_BOX_TAB_DOWNLOAD_ICON="cb-tab-code-box__tab-download-icon",e.TAB_CODE_BOX_TAB_TEXT="cb-tab-code-box__tab-text",e.TAB_CODE_BOX_CODE_VIEW_CONTAINER="cb-tab-code-box__code-view-container",e.TAB_CODE_BOX_CODE_VIEW_CONTAINER_HIDDEN_MODIFIER="cb-tab-code-box__code-view-container--hidden",e.TAB_CODE_BOX_NO_CODE_VIEW="cb-tab-code-box__no-code-view",e.TAB_CODE_BOX_NO_CODE_VIEW_HIDDEN_MODIFIER="cb-tab-code-box__no-code-view--hidden",e.TAB_CODE_BOX_NO_CODE_VIEW_MESSAGE="cb-tab-code-box__no-code-view-message",e.PROJECT_CODE_BOX="cb-project-code-box",e.PROJECT_CODE_BOX_PANEL_CONTAINER="cb-project-code-box__panel-container",e.PROJECT_CODE_BOX_CODE_VIEW_CONTAINER="cb-project-code-box__code-view-container",e.PROJECT_CODE_BOX_CODE_VIEW_CONTAINER_HIDDEN_MODIFIER="cb-project-code-box__code-view-container--hidden",e.PROJECT_CODE_BOX_NO_CODE_VIEW="cb-project-code-box__no-code-view",e.PROJECT_CODE_BOX_NO_CODE_VIEW_HIDDEN_MODIFIER="cb-project-code-box__no-code-view--hidden",e.PROJECT_CODE_BOX_NO_CODE_VIEW_MESSAGE="cb-project-code-box__no-code-view-message",e.PROJECT_CODE_BOX_PANEL="cb-project-code-box__panel",e.PROJECT_CODE_BOX_PANEL_OPENED_MODIFIER="cb-project-code-box__panel--opened",e.PROJECT_CODE_BOX_PANEL_CONTENT="cb-project-code-box__panel-content",e.PROJECT_CODE_BOX_PANEL_OPEN_BUTTON="cb-project-code-box__panel-open-button",e.PROJECT_CODE_BOX_PANEL_OPEN_BUTTON_OPENED_MODIFIER="cb-project-code-box__panel-open-button--opened",e.PROJECT_CODE_BOX_PANEL_OPEN_BUTTON_ICON="cb-project-code-box__panel-open-button-icon",e.PROJECT_CODE_BOX_PANEL_HEADING="cb-project-code-box__panel-heading",e.PROJECT_CODE_BOX_PANEL_FOLDER_STRUCTURE_CONTAINER="cb-project-code-box__panel-folder-structure-container",e.PROJECT_CODE_BOX_PANEL_PACKAGES_CONTAINER="cb-project-code-box__panel-packages-container",e.PROJECT_CODE_BOX_PANEL_ITEM="cb-project-code-box__panel-item",e.PROJECT_CODE_BOX_PANEL_ITEM_ACTIVE_MODIFIER="cb-project-code-box__panel-item--active",e.PROJECT_CODE_BOX_PANEL_ITEM_FOLDER_OPENED_MODIFIER="cb-project-code-box__panel-item--folder-opened",e.PROJECT_CODE_BOX_PANEL_ITEM_PROJECT_MODIFIER="cb-project-code-box__panel-item--project",e.PROJECT_CODE_BOX_PANEL_ITEM_PACKAGE_MODIFIER="cb-project-code-box__panel-item--package",e.PROJECT_CODE_BOX_PANEL_ITEM_DEFAULT_PACKAGE_MODIFIER="cb-project-code-box__panel-item--default-package",e.PROJECT_CODE_BOX_PANEL_ITEM_FOLDER_MODIFIER="cb-project-code-box__panel-item--folder",e.PROJECT_CODE_BOX_PANEL_ITEM_FILE_MODIFIER="cb-project-code-box__panel-item--file",e.PROJECT_CODE_BOX_PANEL_ITEM_ICON="cb-project-code-box__panel-item-icon",e.PROJECT_CODE_BOX_PANEL_ITEM_ARROW_ICON="cb-project-code-box__panel-item-arrow-icon",e.PROJECT_CODE_BOX_PANEL_ITEM_TEXT="cb-project-code-box__panel-item-text",e.PROJECT_CODE_BOX_PANEL_ITEM_DOWNLOAD_ICON="cb-project-code-box__panel-item-download-icon",e.PROJECT_CODE_BOX_PANEL_COLLAPSIBLE="cb-project-code-box__panel-collapsible",e.PROJECT_CODE_BOX_PANEL_COLLAPSIBLE_OPENED_MODIFIDER="cb-project-code-box__panel-collapsible--opened",e.PROJECT_CODE_BOX_PANEL_HORIZONTAL_RULE="cb-project-code-box__panel-horizontal-rule",e.VIRTUAL_CODE_BOX="cb-virtual-code-box",e.VIRTUAL_CODE_BOX_CODE_VIEW_CONTAINER="cb-virtual-code-box__code-view-container",e.VIRTUAL_CODE_BOX_CODE_VIEW_CONTAINER_HIDDEN_MODIFIER="cb-virtual-code-box__code-view-container--hidden",e.VIRTUAL_CODE_BOX_NO_CODE_VIEW="cb-virtual-code-box__no-code-view",e.VIRTUAL_CODE_BOX_NO_CODE_VIEW_HIDDEN_MODIFIER="cb-virtual-code-box__no-code-view--hidden",e.VIRTUAL_CODE_BOX_NO_CODE_VIEW_MESSAGE="cb-virtual-code-box__no-code-view-message",e}();const o={DATA_ATTRIBUTE_PREFIX:"cb",LAZY_INITIALIZATION_MARGIN:"100px",DEFAULT_LINE_HEIGHT:2,DEFAULT_LINE_HEIGHT_UNIT:"rem",DEFAULT_NO_CODE_VIEW_SELECTED_ELEMENT_HEIGHT:"50rem",DEFAULT_NO_CODE_VIEW_SELECTED_TEXT:"No code view selected",DEFAULT_CODE_VIEW_BUTTON_TEXT:"unnamed",DEFAULT_FILE_BUTTON_TEXT:"unnamed",DEFAULT_PROJECT_NAME:"unnamed",DEFAULT_PROJECT_FOLDER_STRUCTURE_HEADING:"Folder structure",DEFAULT_PROJECT_PACKAGES_HEADING:"Packages",DEFAULT_DEFAULT_PACKAGE_NAME:"default",DEFAULT_FOLDER_ANIMATION_SPEED:200,DEFAULT_FOLDER_ANIMATION_EASING_FUNCTION:"ease-in-out",DEFAULT_CREATE_FOLDERS_FOR_PACKAGES:!0,DEFAULT_OPEN_PANEL_BUTTON_ARIA_LABEL:"Open panel",DEFAULT_CLOSE_PANEL_BUTTON_ARIA_LABEL:"Close panel"};const n=function(){function e(e,t,o,n,r,a){var s=this;this.customCssClasses=new Set,this.codeView=n,this.removeHighlightBoxEventSource=r,this.start=Math.min(Math.max(Math.trunc(t),1),n.linesCount),this.end=Math.max(Math.min(Math.trunc(o),n.linesCount),this.start),this.element=document.createElement("div"),this.element.classList.add(i.CODE_VIEW_HIGHLIGHT_BOX),this.setRange(this.start,this.end),a.onDetach=function(){return s.onDetach()},a.onUnlinkCodeView=function(){return s.onUnlinkCodeView()},e.appendChild(this.element)}return e.prototype.getStart=function(){return this.start},e.prototype.getEnd=function(){return this.end},e.prototype.setRange=function(e,t){void 0===t&&(t=e),this.codeView&&(this.start=Math.min(Math.max(Math.trunc(e),1),this.codeView.linesCount),this.end=Math.max(Math.min(Math.trunc(t),this.codeView.linesCount),this.start),this.element.style.transform="translateY(".concat(this.codeView.lineHeight*(this.start-1)).concat(this.codeView.lineHeightUnit,")"),this.element.style.height="".concat(this.codeView.lineHeight*(this.end-this.start+1)).concat(this.codeView.lineHeightUnit))},e.prototype.addCustomCssClass=function(e){this.customCssClasses.add(e),this.element.classList.add(e)},e.prototype.removeCustomCssClass=function(e){this.customCssClasses.delete(e),this.element.classList.remove(e)},e.prototype.hasCustomCssClass=function(e){return this.customCssClasses.has(e)},e.prototype.getCustomCssClasses=function(){return Array.from(this.customCssClasses.values())},e.prototype.remove=function(){this.codeView&&this.removeHighlightBoxEventSource.fire(this,this)},e.prototype.onDetach=function(){this.element.remove()},e.prototype.onUnlinkCodeView=function(){this.codeView=null},e}();function r(e){return{highlight:e.highlight,lineHeight:e.lineHeight,lineHeightUnit:e.lineHeightUnit,showGutter:e.showGutter,showLineNumbers:e.showLineNumbers,cssClasses:e.cssClasses}}const a=function(e,t){this.highlightBox=e,this.highlightBoxManager=t};const s=function(){function e(){this.onDetach=null,this.onUnlinkCodeView=null}return e.prototype.detach=function(){this.onDetach&&this.onDetach()},e.prototype.unlinkCodeView=function(){this.onUnlinkCodeView&&this.onUnlinkCodeView()},e}();const l=function(){function e(){this.handlers=new Map,this.count=0}return e.prototype.subscribe=function(e){return this.handlers.set(this.count,e),this.count++},e.prototype.unsubscribe=function(e){this.handlers.delete(e)},e.prototype.fire=function(e,t){this.handlers.forEach((function(i){i(e,t)}))},e}();const d=function(){function e(e){this.highlights=new Array,this.showGutter=e.isGutterVisible(),this.showLineNumbers=e.areLineNumbersVisible();for(var t=0,i=e.getHighlightBoxes();t<i.length;t++){var o=i[t];this.highlights.push([o.getStart(),o.getEnd(),o.getCustomCssClasses()])}}return e.prototype.apply=function(e){this.showGutter?e.showGutter():e.hideGutter(),this.showLineNumbers?e.showLineNumbers():e.hideLineNumbers(),e.removeHighlights();for(var t=0,i=this.highlights;t<i.length;t++){var o=i[t];e.addHighlight(o[0],o[1],o[2])}},e}();const c=function(){function e(e,t){void 0===t&&(t={});var n=this;if(this.highlightBoxEntries=new Array,this.removeHighlightBoxEventSource=new l,!(e instanceof HTMLPreElement))throw new Error("Passed element is not pre element.");this.preElement=e,this.initialOptions=r(t),this.fillOptionsFromDataset(this.initialOptions,e.dataset),this.initialOptions.cssClasses&&function(e){for(var t=0;t<e.length;t++)0===e[t].trim().length&&(e.splice(t,1),t--)}(this.initialOptions.cssClasses);var a=this.getCodeElement(e);this.lineHeight=this.initialOptions.lineHeight||o.DEFAULT_LINE_HEIGHT,this.lineHeightUnit=this.initialOptions.lineHeightUnit||o.DEFAULT_LINE_HEIGHT_UNIT,a.style.lineHeight=this.lineHeight.toString()+this.lineHeightUnit,this.linesCount=this.getLinesCount(a),this.rootElement=document.createElement("div"),this.rootElement.classList.add(i.CODE_VIEW),e.parentElement&&e.parentElement.insertBefore(this.rootElement,e),this.rootElement.innerHTML="",this.gutterElement=document.createElement("div"),this.gutterElement.classList.add(i.CODE_VIEW_GUTTER),this.rootElement.appendChild(this.gutterElement),this.containerElement=document.createElement("div"),this.containerElement.classList.add(i.CODE_VIEW_CONTAINER),this.rootElement.appendChild(this.containerElement);var s=document.createElement("div");s.classList.add(i.CODE_VIEW_CONTENT_CONTAINER),this.containerElement.appendChild(s),s.appendChild(e),void 0===this.initialOptions.showLineNumbers||this.initialOptions.showLineNumbers?(this.lineNumberElementsVisible=!0,this.lineNumberElements=this.fillLineNumbers(this.gutterElement)):(this.lineNumberElementsVisible=!1,this.lineNumberElements=this.fillLineNumbers(this.gutterElement,!0)),this.removeHighlightBoxEventSource.subscribe((function(e,t){return n.onRemoveHighlightBox(t)})),this.reset()}return e.prototype.appendTo=function(e){e.appendChild(this.rootElement)},e.prototype.detach=function(){this.rootElement.remove()},e.prototype.reset=function(){var e;this.removeHighlights(),void 0===this.initialOptions.showGutter||this.initialOptions.showGutter?this.showGutter():this.hideGutter(),void 0===this.initialOptions.showLineNumbers||this.initialOptions.showLineNumbers&&!this.lineNumberElementsVisible?this.showLineNumbers():this.lineNumberElementsVisible&&this.hideLineNumbers(),void 0!==this.initialOptions.highlight&&this.initHighlights(this.initialOptions.highlight),void 0!==this.initialOptions.cssClasses&&(e=this.rootElement.classList).add.apply(e,this.initialOptions.cssClasses)},e.prototype.createMemento=function(){return new d(this)},e.prototype.applyMemento=function(e){e.apply(this)},e.prototype.clone=function(){var t=this.preElement.cloneNode(!0);return t.removeAttribute("id"),new e(t,this.initialOptions)},e.prototype.addHighlight=function(e,t,i){void 0===t&&(t=e),void 0===i&&(i=null);var o=new s,r=new n(this.containerElement,e,t,this,this.removeHighlightBoxEventSource,o);if(i)if(Array.isArray(i))for(var l=0,d=i;l<d.length;l++){var c=d[l];r.addCustomCssClass(c)}else r.addCustomCssClass(i);return this.highlightBoxEntries.push(new a(r,o)),r},e.prototype.removeHighlights=function(e,t){void 0===e&&(e=null),void 0===t&&(t=e),null===e&&(e=1),null===t&&(t=this.linesCount);for(var i=0;i<this.highlightBoxEntries.length;i++){var o=this.highlightBoxEntries[i];o.highlightBox.getStart()<=t&&o.highlightBox.getEnd()>=e&&(o.highlightBoxManager.detach(),o.highlightBoxManager.unlinkCodeView(),this.highlightBoxEntries.splice(i,1),i--)}},e.prototype.getHighlightBoxes=function(e,t){void 0===e&&(e=null),void 0===t&&(t=e),null===e&&(e=1),null===t&&(t=this.linesCount);for(var i=new Array,o=0,n=this.highlightBoxEntries;o<n.length;o++){var r=n[o];r.highlightBox.getStart()<=t&&r.highlightBox.getEnd()>=e&&i.push(r.highlightBox)}return i},e.prototype.showGutter=function(){this.gutterElement.classList.remove(i.CODE_VIEW_GUTTER_HIDDEN_MODIFIER)},e.prototype.hideGutter=function(){this.gutterElement.classList.add(i.CODE_VIEW_GUTTER_HIDDEN_MODIFIER)},e.prototype.isGutterVisible=function(){return!this.gutterElement.classList.contains(i.CODE_VIEW_GUTTER_HIDDEN_MODIFIER)},e.prototype.showLineNumbers=function(){this.lineNumberElementsVisible=!0;for(var e=0,t=this.lineNumberElements;e<t.length;e++){t[e].classList.remove(i.CODE_VIEW_LINE_NUMBER_HIDDEN_MODIFIER)}},e.prototype.hideLineNumbers=function(){this.lineNumberElementsVisible=!1;for(var e=0,t=this.lineNumberElements;e<t.length;e++){t[e].classList.add(i.CODE_VIEW_LINE_NUMBER_HIDDEN_MODIFIER)}},e.prototype.areLineNumbersVisible=function(){return this.lineNumberElementsVisible},e.prototype.getCode=function(){return this.preElement.innerText},e.prototype.onRemoveHighlightBox=function(e){for(var t=0;t<this.highlightBoxEntries.length;t++){var i=this.highlightBoxEntries[t];if(i.highlightBox===e){i.highlightBoxManager.detach(),i.highlightBoxManager.unlinkCodeView(),this.highlightBoxEntries.splice(t,1);break}}},e.prototype.initHighlights=function(e){for(var t=0,i=e.split(",");t<i.length;t++){var o=i[t].split("("),n=o[0],r=o[1],a=n.split("-"),s=void 0,l=void 0;if(a[0]&&(s=parseInt(a[0]),!Number.isNaN(s))){if(s<1&&(s=1),a[1]){if(l=parseInt(a[1]),Number.isNaN(l))continue}else l=s;r&&r.endsWith(")")&&(r=r.substring(0,r.length-1));var d=r?r.split(" "):[];this.addHighlight(s,l,d)}}},e.prototype.fillLineNumbers=function(e,t){void 0===t&&(t=!1);for(var o=new Array,n=1;n<=this.linesCount;n++){var r=document.createElement("div");r.classList.add(i.CODE_VIEW_LINE_NUMBER),t&&r.classList.add(i.CODE_VIEW_LINE_NUMBER_HIDDEN_MODIFIER),r.style.lineHeight=this.lineHeight.toString()+this.lineHeightUnit,r.innerText=n.toString(),e.appendChild(r),o.push(r)}return o},e.prototype.getLinesCount=function(e){return null===e.textContent?0:e.textContent.split("\n").length},e.prototype.fillOptionsFromDataset=function(e,t){var i;if(void 0!==t[o.DATA_ATTRIBUTE_PREFIX+"Highlight"]&&(e.highlight=t[o.DATA_ATTRIBUTE_PREFIX+"Highlight"]),void 0!==t[o.DATA_ATTRIBUTE_PREFIX+"ShowGutter"]&&(e.showGutter="true"===t[o.DATA_ATTRIBUTE_PREFIX+"ShowGutter"]),void 0!==t[o.DATA_ATTRIBUTE_PREFIX+"ShowLineNumbers"]&&(e.showLineNumbers="true"===t[o.DATA_ATTRIBUTE_PREFIX+"ShowLineNumbers"]),void 0!==t[o.DATA_ATTRIBUTE_PREFIX+"LineHeight"]&&(e.lineHeight=Number.parseFloat(t[o.DATA_ATTRIBUTE_PREFIX+"LineHeight"]||""),Number.isNaN(e.lineHeight)))throw new Error("Line height option must be a number.");void 0!==t[o.DATA_ATTRIBUTE_PREFIX+"LineHeightUnit"]&&(e.lineHeightUnit=t[o.DATA_ATTRIBUTE_PREFIX+"LineHeightUnit"]),void 0!==t[o.DATA_ATTRIBUTE_PREFIX+"CssClasses"]&&(e.cssClasses=(null===(i=t[o.DATA_ATTRIBUTE_PREFIX+"CssClasses"])||void 0===i?void 0:i.split(" "))||new Array)},e.prototype.getCodeElement=function(e){for(var t=0,i=Array.from(e.children);t<i.length;t++){var o=i[t];if("CODE"===o.tagName&&o instanceof HTMLElement)return o}throw new Error("Passed element does not have code element as its children")},e}();const h=function(){function e(){var e=this;this.elements=new Map,this.observer=new IntersectionObserver((function(t){return e.intersectionObserverCallback(t)}),{root:null,rootMargin:"".concat(o.LAZY_INITIALIZATION_MARGIN," 0px ").concat(o.LAZY_INITIALIZATION_MARGIN," 0px")})}return e.observe=function(t,i){var o=e.getInstance();o.observer.observe(t),o.elements.set(t,i)},e.unobserve=function(t){var i=e.getInstance();i.observer.unobserve(t),i.elements.delete(t)},e.prototype.intersectionObserverCallback=function(e){for(var t=0,i=e;t<i.length;t++){var o=i[t],n=this.elements.get(o.target);n&&n(o.isIntersecting)}},e.getInstance=function(){return e.instance||(e.instance=new e),e.instance},e.instance=null,e}();const u=function(){function e(t,i,n,a){void 0===a&&(a=null);var s=this;this.minCodeViewLinesCount=null,this.activeCodeView=null,this.initialized=!1,this.lazyInitPlaceholderElement=null,this.onInitCallbacks=new Array,this.onActiveCodeViewChangeCallbacks=new Array,this.rootElement=t,this.fillOptionsFromDataset(i,t.dataset),this.defaultCodeViewOptions=i.defaultCodeViewOptions?r(i.defaultCodeViewOptions):null,this.minCodeViewLinesCount=i.minCodeViewLinesCount||null,this.isLazyInitializationEnabled=void 0===i.lazyInit||i.lazyInit;var l=Array();this.initializationData=new Array;for(var d=null,c=0;c<this.rootElement.children.length;c++){var u=this.rootElement.children[c];if(u instanceof HTMLElement)if(u instanceof HTMLPreElement){if(!(E=e.getCodeElement(u)))continue;void 0!==u.dataset[o.DATA_ATTRIBUTE_PREFIX+"Active"]&&(d&&delete d.dataset[o.DATA_ATTRIBUTE_PREFIX+"Active"],d=u),l.push(u),this.initializationData.push({type:"PreElement",preElement:u})}else if(void 0!==u.dataset[o.DATA_ATTRIBUTE_PREFIX+"File"]){var p={dataset:u.dataset,name:u.dataset[o.DATA_ATTRIBUTE_PREFIX+"Name"]||o.DEFAULT_FILE_BUTTON_TEXT,downloadLink:u.dataset[o.DATA_ATTRIBUTE_PREFIX+"File"]||null};this.initializationData.push({type:"FileInfo",fileInfo:p})}else this.initializationData.push({type:"HTMLElement",element:u})}if(i.implicitActive&&!d&&l.length>0){var f=l[0];f.dataset[o.DATA_ATTRIBUTE_PREFIX+"Active"]="true",d=f}if(this.rootElement.innerHTML="",n.customizeRootElement(this.rootElement),this.codeViewContainer=n.createCodeViewContainer(),this.codeViewContainerCSSHiddenClass=n.getCodeViewContainerCSSHiddenClass(),this.noCodeViewSelectedCSSHiddenClass=n.getNoCodeViewCSSHiddenClass(),this.noCodeViewSelectedElement=n.createNoCodeViewSelectedElement(i.noCodeViewSelectedElementHeight||o.DEFAULT_NO_CODE_VIEW_SELECTED_ELEMENT_HEIGHT,i.noCodeViewSelectedText||o.DEFAULT_NO_CODE_VIEW_SELECTED_TEXT),n.assembleElements(this.rootElement,this.codeViewContainer,this.noCodeViewSelectedElement),0!==l.length&&(i.implicitActive||d)||this.showNoCodeViewSelectedMessage(),this.isLazyInitializationEnabled&&this.rootElement.parentElement){if(this.lazyInitPlaceholderElement=document.createElement("div"),null===a)if(d){var E;if(!(E=e.getCodeElement(d)))return;var g=e.getLinesCount(E),_=(null!==this.minCodeViewLinesCount&&this.minCodeViewLinesCount>=g?this.minCodeViewLinesCount:g)*e.getCodeViewLineHeight(d,i.defaultCodeViewOptions||{});this.lazyInitPlaceholderElement.style.height="".concat(_).concat(e.getCodeViewLineHeightUnit(d,i.defaultCodeViewOptions||{}))}else this.lazyInitPlaceholderElement.style.height=i.noCodeViewSelectedElementHeight||o.DEFAULT_NO_CODE_VIEW_SELECTED_ELEMENT_HEIGHT;else this.lazyInitPlaceholderElement.style.height=a;this.rootElement.parentElement.insertBefore(this.lazyInitPlaceholderElement,this.rootElement),this.rootElement.style.setProperty("display","none"),h.observe(this.lazyInitPlaceholderElement,(function(e){return s.onLazyInitPlaceholderElementIntersectionChange(e)}))}}return e.prototype.appendTo=function(e){e.appendChild(this.rootElement)},e.prototype.detach=function(){this.rootElement.remove()},e.prototype.init=function(){if(!this.initialized){this.rootElement.style.removeProperty("display"),this.lazyInitPlaceholderElement&&(h.unobserve(this.lazyInitPlaceholderElement),this.lazyInitPlaceholderElement.remove(),this.lazyInitPlaceholderElement=null);var e=new Array;if(this.initializationData)for(var t=0,i=this.initializationData;t<i.length;t++){var n=i[t];if("PreElement"===n.type&&n.preElement){var r=n.preElement,a=new c(r,this.defaultCodeViewOptions||{});a.detach(),void 0!==r.dataset[o.DATA_ATTRIBUTE_PREFIX+"Active"]&&this.changeActiveCodeView(a),e.push({type:"CodeViewInfo",codeViewInfo:{codeView:a,dataset:r.dataset}})}else"FileInfo"===n.type&&n.fileInfo?e.push({type:"FileInfo",fileInfo:n.fileInfo}):"HTMLElement"===n.type&&n.element&&e.push({type:"HTMLElement",element:n.element})}if(this.onInit(e),this.initializationData=null,this.defaultCodeViewOptions=null,this.initialized=!0,this.onAfterInit(),this.onInitCallbacks){for(var s=0,l=this.onInitCallbacks;s<l.length;s++){(0,l[s])()}this.onInitCallbacks=null}}},e.prototype.isInitialized=function(){return this.initialized},e.prototype.addOnInitListener=function(e){this.isInitialized()||null!==this.onInitCallbacks&&this.onInitCallbacks.push(e)},e.prototype.addOnActiveCodeViewChangeListener=function(e){this.onActiveCodeViewChangeCallbacks.includes(e)||this.onActiveCodeViewChangeCallbacks.push(e)},e.prototype.removeOnActiveCodeViewChangeListener=function(e){var t=this.onActiveCodeViewChangeCallbacks.indexOf(e);-1!==t&&this.onActiveCodeViewChangeCallbacks.splice(t,1)},e.prototype.onAfterInit=function(){},e.prototype.changeActiveCodeView=function(e){if(this.activeCodeView!==e){if(this.activeCodeView&&this.activeCodeView.detach(),this.activeCodeView=e,null!==e){if(e.appendTo(this.codeViewContainer),null!==this.minCodeViewLinesCount){var t=this.minCodeViewLinesCount*e.lineHeight;this.codeViewContainer.style.setProperty("min-height",t+e.lineHeightUnit)}else this.codeViewContainer.style.removeProperty("min-height");this.hideNoCodeViewSelectedMessage()}else this.showNoCodeViewSelectedMessage();if(this.isInitialized())for(var i=0,o=this.onActiveCodeViewChangeCallbacks;i<o.length;i++){(0,o[i])()}}},e.prototype.getCurrentlyActiveCodeView=function(){return this.activeCodeView},e.prototype.getPreElementsBeforeInitialization=function(){if(!this.initializationData)return null;for(var e=new Array,t=0,i=this.initializationData;t<i.length;t++){var o=i[t];"PreElement"===o.type&&o.preElement&&e.push(o.preElement)}return e},e.prototype.showNoCodeViewSelectedMessage=function(){this.noCodeViewSelectedElement.classList.remove(this.noCodeViewSelectedCSSHiddenClass),this.noCodeViewSelectedElement.setAttribute("aria-hidden","false"),this.codeViewContainer.classList.add(this.codeViewContainerCSSHiddenClass),this.codeViewContainer.setAttribute("aria-hidden","true")},e.prototype.hideNoCodeViewSelectedMessage=function(){this.noCodeViewSelectedElement.classList.add(this.noCodeViewSelectedCSSHiddenClass),this.noCodeViewSelectedElement.setAttribute("aria-hidden","true"),this.codeViewContainer.classList.remove(this.codeViewContainerCSSHiddenClass),this.codeViewContainer.setAttribute("aria-hidden","false")},e.prototype.onLazyInitPlaceholderElementIntersectionChange=function(e){e&&this.init()},e.getLinesCount=function(e){return null===e.textContent?0:e.textContent.split("\n").length},e.prototype.fillOptionsFromDataset=function(e,t){if(void 0!==t[o.DATA_ATTRIBUTE_PREFIX+"LazyInit"]&&(e.lazyInit="true"===t[o.DATA_ATTRIBUTE_PREFIX+"LazyInit"]),void 0!==t[o.DATA_ATTRIBUTE_PREFIX+"ImplicitActive"]&&(e.implicitActive="true"===t[o.DATA_ATTRIBUTE_PREFIX+"ImplicitActive"]),void 0!==t[o.DATA_ATTRIBUTE_PREFIX+"NoCodeViewSelectedElementHeight"]&&(e.noCodeViewSelectedElementHeight=t[o.DATA_ATTRIBUTE_PREFIX+"NoCodeViewSelectedElementHeight"]),void 0!==t[o.DATA_ATTRIBUTE_PREFIX+"NoCodeViewSelectedText"]&&(e.noCodeViewSelectedText=t[o.DATA_ATTRIBUTE_PREFIX+"NoCodeViewSelectedText"]),void 0!==t[o.DATA_ATTRIBUTE_PREFIX+"MinCodeViewLinesCount"]&&(e.minCodeViewLinesCount=Number.parseInt(t[o.DATA_ATTRIBUTE_PREFIX+"MinCodeViewLinesCount"]||""),Number.isNaN(e.minCodeViewLinesCount)))throw new Error("Min code view lines count option must be a number.")},e.getCodeElement=function(e){for(var t=0,i=Array.from(e.children);t<i.length;t++){var o=i[t];if("CODE"===o.tagName&&o instanceof HTMLElement)return o}return null},e.getCodeViewLineHeight=function(e,t){if(void 0!==e.dataset[o.DATA_ATTRIBUTE_PREFIX+"LineHeight"]){var i=Number.parseFloat(e.dataset[o.DATA_ATTRIBUTE_PREFIX+"LineHeight"]||"");return Number.isNaN(i)?o.DEFAULT_LINE_HEIGHT:i}return void 0!==t.lineHeight?t.lineHeight:o.DEFAULT_LINE_HEIGHT},e.getCodeViewLineHeightUnit=function(e,t){return void 0!==e.dataset[o.DATA_ATTRIBUTE_PREFIX+"LineHeightUnit"]?e.dataset[o.DATA_ATTRIBUTE_PREFIX+"LineHeightUnit"]||o.DEFAULT_LINE_HEIGHT_UNIT:void 0!==t.lineHeightUnit?t.lineHeightUnit:o.DEFAULT_LINE_HEIGHT_UNIT},e.CODE_BOX_NOT_INITIALIZED_ERROR="Code box is not initialized.",e}();const p=function(){function e(e,t,i,o){var n=this;this.identifier=e,this.codeView=t,this.codeBox=i,this.lineHeight=t.lineHeight,this.lineHeightUnit=t.lineHeightUnit,this.linesCount=t.linesCount,o.onIdentifierChange=function(e){return n.onIdentifierChange(e)},o.onUnlinkCodeBox=function(){return n.onUnlinkCodeBox()}}return e.prototype.getIdentifier=function(){return this.codeBox?this.identifier:null},e.prototype.changeIdentifier=function(e){return!!this.codeBox&&this.codeBox.changeCodeViewIdentifier(this.identifier,e)},e.prototype.setAsActive=function(){this.codeBox&&this.codeBox.setActiveCodeView(this.identifier)},e.prototype.remove=function(){this.codeBox&&this.codeBox.removeCodeView(this.identifier)},e.prototype.reset=function(){this.codeView.reset()},e.prototype.createMemento=function(){return this.codeView.createMemento()},e.prototype.applyMemento=function(e){this.codeView.applyMemento(e)},e.prototype.clone=function(){return this.codeView.clone()},e.prototype.addHighlight=function(e,t,i){return void 0===t&&(t=e),void 0===i&&(i=null),this.codeView.addHighlight(e,t,i)},e.prototype.removeHighlights=function(e,t){void 0===e&&(e=null),void 0===t&&(t=e),this.codeView.removeHighlights(e,t)},e.prototype.getHighlightBoxes=function(e,t){return void 0===e&&(e=null),void 0===t&&(t=e),this.codeView.getHighlightBoxes(e,t)},e.prototype.showGutter=function(){this.codeView.showGutter()},e.prototype.hideGutter=function(){this.codeView.hideGutter()},e.prototype.isGutterVisible=function(){return this.codeView.isGutterVisible()},e.prototype.showLineNumbers=function(){this.codeView.showLineNumbers()},e.prototype.hideLineNumbers=function(){this.codeView.hideLineNumbers()},e.prototype.areLineNumbersVisible=function(){return this.codeView.areLineNumbersVisible()},e.prototype.getCode=function(){return this.codeView.getCode()},e.prototype.onIdentifierChange=function(e){this.identifier=e},e.prototype.onUnlinkCodeBox=function(){this.codeBox=null},e}();const f=function(){function e(){this.onIdentifierChange=null,this.onUnlinkCodeBox=null}return e.prototype.changeIdentifier=function(e){this.onIdentifierChange&&this.onIdentifierChange(e)},e.prototype.unlinkCodeBox=function(){this.onUnlinkCodeBox&&this.onUnlinkCodeBox()},e}();const E=function(){function e(e,t,i,o){var n=this;this.identifier=e,this.downloadLink=t,this.codeBox=i,o.onIdentifierChange=function(e){return n.onIdentifierChange(e)},o.onDownloadLinkChange=function(e){return n.onDownloadLinkChange(e)},o.onUnlinkCodeBox=function(){return n.onUnlinkCodeBox()}}return e.prototype.getIdentifier=function(){return this.codeBox?this.identifier:null},e.prototype.changeIdentifier=function(e){return!!this.codeBox&&this.codeBox.changeFileIdentifier(this.identifier,e)},e.prototype.remove=function(){this.codeBox&&this.codeBox.removeFile(this.identifier)},e.prototype.getDownloadLink=function(){return this.downloadLink},e.prototype.setDownloadLink=function(e){this.codeBox&&this.codeBox.changeFileDownloadLink(this.identifier,e)},e.prototype.onIdentifierChange=function(e){this.identifier=e},e.prototype.onDownloadLinkChange=function(e){this.downloadLink=e},e.prototype.onUnlinkCodeBox=function(){this.codeBox=null},e}();const g=function(){function e(){this.onIdentifierChange=null,this.onDownloadLinkChange=null,this.onUnlinkCodeBox=null}return e.prototype.changeIdentifier=function(e){this.onIdentifierChange&&this.onIdentifierChange(e)},e.prototype.changeDownloadLink=function(e){this.onDownloadLinkChange&&this.onDownloadLinkChange(e)},e.prototype.unlinkCodeBox=function(){this.onUnlinkCodeBox&&this.onUnlinkCodeBox()},e}();const _=function(){function e(e,t,i,o,n){this.creator=e,this.addCodeViewToCreatorCodeBox=t,this.codeViewEntries=i,this.fileEntries=o,this.activeCodeView=n}return e.prototype.getCreator=function(){return this.creator},e.prototype.apply=function(e){e.removeAllCodeViews(),e.removeAllFiles();for(var t=0,i=this.codeViewEntries;t<i.length;t++){var o=i[t];if(e===this.creator)o.codeView.applyMemento(o.codeViewMemento),this.addCodeViewToCreatorCodeBox(o.identifier,o.codeView);else{e.addCodeView(o.identifier,o.codeView);var n=e.getCodeView(o.identifier);null==n||n.applyMemento(o.codeViewMemento)}this.activeCodeView===o.codeView&&e.setActiveCodeView(o.identifier)}for(var r=0,a=this.fileEntries;r<a.length;r++){var s=a[r];e.addFile(s.identifier,s.downloadLink)}},e}();const C=function(){function e(e,t){this.showCodeViewEventSource=e,this.codeView=t}return e.prototype.showCodeView=function(){this.showCodeViewEventSource.fire(this,this.codeView)},e}();var I,m=(I=function(e,t){return I=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},I(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}I(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)});const v=function(e){function t(t,i){var o=e.call(this,t,i)||this;return o.buttonElement=document.createElement("button"),o.buttonElement.addEventListener("click",(function(){return o.showCodeView()})),o}return m(t,e),t.prototype.appendTo=function(e){e.appendChild(this.buttonElement)},t.prototype.detach=function(){this.buttonElement.remove()},t.prototype.enableTabNavigation=function(){this.buttonElement.setAttribute("tabindex","0")},t.prototype.disableTabNavigation=function(){this.buttonElement.setAttribute("tabindex","-1")},t}(C);const w=function(){};var O=function(){var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},e(t,i)};return function(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function o(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(o.prototype=i.prototype,new o)}}();const A=function(e){function t(t){void 0===t&&(t=null);var i=e.call(this)||this;return i.buttonElement=document.createElement("a"),i.buttonElement.setAttribute("download",""),i.setDownloadLink(t),i}return O(t,e),t.prototype.appendTo=function(e){e.appendChild(this.buttonElement)},t.prototype.detach=function(){this.buttonElement.remove()},t.prototype.setDownloadLink=function(e){null!==e?this.buttonElement.setAttribute("href",e):this.buttonElement.removeAttribute("href")},t.prototype.getDownloadLink=function(){return this.buttonElement.getAttribute("href")},t.prototype.enableTabNavigation=function(){this.buttonElement.setAttribute("tabindex","0")},t.prototype.disableTabNavigation=function(){this.buttonElement.setAttribute("tabindex","-1")},t}(w);const T=function(e,t,i,o){this.codeBoxCodeView=e,this.codeBoxCodeViewManager=t,this.codeViewButton=i,this.position=o};const P=function(e,t,i,o){this.codeBoxFile=e,this.codeBoxFileManager=t,this.fileButton=i,this.position=o};const F=function(){function e(){this.tabsContainer=document.createElement("div"),this.tabsContainer.classList.add(i.TAB_CODE_BOX_TABS)}return e.prototype.getTabsContainer=function(){return this.tabsContainer},e.prototype.customizeRootElement=function(e){e.classList.add(i.TAB_CODE_BOX)},e.prototype.createCodeViewContainer=function(){var e=document.createElement("div");return e.classList.add(i.TAB_CODE_BOX_CODE_VIEW_CONTAINER),e},e.prototype.getCodeViewContainerCSSHiddenClass=function(){return i.TAB_CODE_BOX_CODE_VIEW_CONTAINER_HIDDEN_MODIFIER},e.prototype.createNoCodeViewSelectedElement=function(e,t){var o=document.createElement("div");o.classList.add(i.TAB_CODE_BOX_NO_CODE_VIEW),o.style.height=e;var n=document.createElement("p");return n.classList.add(i.TAB_CODE_BOX_NO_CODE_VIEW_MESSAGE),n.innerText=t,o.appendChild(n),o},e.prototype.getNoCodeViewCSSHiddenClass=function(){return i.TAB_CODE_BOX_NO_CODE_VIEW_HIDDEN_MODIFIER},e.prototype.assembleElements=function(e,t,i){e.appendChild(this.tabsContainer),e.appendChild(t),e.appendChild(i)},e}();var y=function(){var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},e(t,i)};return function(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function o(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(o.prototype=i.prototype,new o)}}();const B=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return y(t,e),t.prototype.getButtonPosition=function(){return this.codeBox?this.codeBox.getCodeViewButtonPosition(this.identifier):null},t.prototype.setButtonPosition=function(e){return!!this.codeBox&&this.codeBox.setCodeViewButtonPosition(this.identifier,e)},t}(p);var N=function(){var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},e(t,i)};return function(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function o(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(o.prototype=i.prototype,new o)}}();const V=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return N(t,e),t.prototype.getButtonPosition=function(){return this.codeBox?this.codeBox.getFileButtonPosition(this.identifier):null},t.prototype.setButtonPosition=function(e){return!!this.codeBox&&this.codeBox.setFileButtonPosition(this.identifier,e)},t}(E);var D=function(){var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},e(t,i)};return function(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function o(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(o.prototype=i.prototype,new o)}}();const R=function(e){function t(t,i,o,n,r){var a=e.call(this,t,i,o,n,r)||this;return a.tabCodeBoxCodeViewEntries=o,a.tabCodeBoxFileEntries=n,a}return D(t,e),t.prototype.apply=function(t){if(e.prototype.apply.call(this,t),t instanceof S){for(var i=0,o=this.tabCodeBoxCodeViewEntries;i<o.length;i++){var n=o[i];t.setCodeViewButtonPosition(n.identifier,n.position)}for(var r=0,a=this.tabCodeBoxFileEntries;r<a.length;r++){n=a[r];t.setFileButtonPosition(n.identifier,n.position)}}},t}(_);const k=function(){function e(){}return e.create=function(e,t){return'\n <svg>\n <use xlink:href="'.concat(e,"#").concat(t,'"></use>\n </svg>\n ')},e}();var b=function(){var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},e(t,i)};return function(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function o(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(o.prototype=i.prototype,new o)}}();const L=function(e){function t(t,o,n,r,a){void 0===r&&(r=null),void 0===a&&(a=null);var s=e.call(this,o,n)||this;s.buttonElement.classList.add(i.TAB_CODE_BOX_TAB);var l=document.createElement("div");return l.classList.add(i.TAB_CODE_BOX_TAB_ICON),r&&a&&(l.innerHTML=k.create(r,a)),s.buttonElement.appendChild(l),s.textElement=document.createElement("div"),s.textElement.classList.add(i.TAB_CODE_BOX_TAB_TEXT),s.textElement.innerText=t,s.buttonElement.appendChild(s.textElement),s}return b(t,e),t.prototype.setText=function(e){this.textElement.innerText=e},t.prototype.setAsActive=function(){this.buttonElement.classList.add(i.TAB_CODE_BOX_TAB_ACTIVE_MODIFIER)},t.prototype.setAsInactive=function(){this.buttonElement.classList.remove(i.TAB_CODE_BOX_TAB_ACTIVE_MODIFIER)},t}(v);var M=function(){var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},e(t,i)};return function(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function o(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(o.prototype=i.prototype,new o)}}();const x=function(e){function t(t,o,n,r,a){void 0===o&&(o=null),void 0===n&&(n=null),void 0===r&&(r=null),void 0===a&&(a=null);var s=e.call(this,o)||this;s.downloadIcon=null,s.buttonElement.classList.add(i.TAB_CODE_BOX_TAB);var l=document.createElement("div");return l.classList.add(i.TAB_CODE_BOX_TAB_ICON),n&&r&&(l.innerHTML=k.create(n,r)),s.buttonElement.appendChild(l),s.textElement=document.createElement("div"),s.textElement.innerText=t,s.textElement.classList.add(i.TAB_CODE_BOX_TAB_TEXT),s.buttonElement.appendChild(s.textElement),n&&a&&(s.downloadIcon=document.createElement("div"),s.downloadIcon.classList.add(i.TAB_CODE_BOX_TAB_DOWNLOAD_ICON),s.downloadIcon.innerHTML=k.create(n,a),null!==o&&s.buttonElement.appendChild(s.downloadIcon)),s}return M(t,e),t.prototype.setText=function(e){this.textElement.innerText=e},t.prototype.setDownloadLink=function(t){e.prototype.setDownloadLink.call(this,t),this.downloadIcon&&(null!==t?this.buttonElement.appendChild(this.downloadIcon):this.downloadIcon.remove())},t}(A);var X=function(){var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},e(t,i)};return function(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function o(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(o.prototype=i.prototype,new o)}}();const S=function(e){function t(t,i){void 0===i&&(i={});var o=this,n=new F;return(o=e.call(this,t,i,n)||this).showCodeViewEventSource=new l,o.initialMemento=null,o.codeViews=new Map,o.codeViewEntries=new Map,o.fileEntries=new Map,o.tabsContainer=n.getTabsContainer(),o.showCodeViewEventSource.subscribe((function(e,t){return o.onShowCodeView(e,t)})),o.svgSpritePath=i.svgSpritePath||null,i.svgSpriteIcons?(o.codeFileIconName=i.svgSpriteIcons.codeFile||null,o.fileIconName=i.svgSpriteIcons.file||null,o.downloadIconName=i.svgSpriteIcons.download||null):(o.codeFileIconName=null,o.fileIconName=null,o.downloadIconName=null),o.isLazyInitializationEnabled||o.init(),o}return X(t,e),t.prototype.addCodeView=function(e,t){if(!this.isInitialized())throw new Error(u.CODE_BOX_NOT_INITIALIZED_ERROR);if(this.codeViews.has(e))return!1;var i=t.clone();return this._addCodeView(e,i)},t.prototype._addCodeView=function(e,t){if(!this.isInitialized())throw new Error(u.CODE_BOX_NOT_INITIALIZED_ERROR);if(this.codeViews.has(e))return!1;var i=new L(e,this.showCodeViewEventSource,t,this.svgSpritePath,this.codeFileIconName);i.appendTo(this.tabsContainer);var o=new f,n=new B(e,t,this,o);this.codeViews.set(e,t);var r=this.codeViewEntries.size+this.fileEntries.size;return this.codeViewEntries.set(t,new T(n,o,i,r)),!0},t.prototype.getCodeViews=function(){if(!this.isInitialized())throw new Error(u.CODE_BOX_NOT_INITIALIZED_ERROR);var e=new Array;return this.codeViewEntries.forEach((function(t){return e.push(t.codeBoxCodeView)})),e},t.prototype.getCodeView=function(e){if(!this.isInitialized())throw new Error(u.CODE_BOX_NOT_INITIALIZED_ERROR);var t=this.codeViews.get(e);if(!t)return null;var i=this.codeViewEntries.get(t);return i?i.codeBoxCodeView:null},t.prototype.removeCodeView=function(e){if(!this.isInitialized())throw new Error(u.CODE_BOX_NOT_INITIALIZED_ERROR);var t=this.codeViews.get(e);if(!t)return!1;var i=this.codeViewEntries.get(t);return!!i&&(i.codeViewButton.detach(),this.getCurrentlyActiveCodeView()===t&&this.setNoActiveCodeView(),i.codeBoxCodeViewManager.unlinkCodeBox(),this.codeViews.delete(e),this.codeViewEntries.delete(t),this.decrementItemPositionsAfterPosition(i.position),!0)},t.prototype.removeAllCodeViews=function(){var e=this;if(!this.isInitialized())throw new Error(u.CODE_BOX_NOT_INITIALIZED_ERROR);this.codeViews.forEach((function(t){var i=e.codeViewEntries.get(t);i&&(i.codeViewButton.detach(),i.codeBoxCodeViewManager.unlinkCodeBox(),e.decrementItemPositionsAfterPosition(i.position))})),this.codeViews.clear(),this.codeViewEntries.clear(),this.setNoActiveCodeView()},t.prototype.changeCodeViewIdentifier=function(e,t){if(!this.isInitialized())throw new Error(u.CODE_BOX_NOT_INITIALIZED_ERROR);var i=this.codeViews.get(e);if(!i)return!1;if(this.codeViews.has(t))return!1;var o=this.codeViewEntries.get(i);return!!o&&(o.codeViewButton.setText(t),o.codeBoxCodeViewManager.changeIdentifier(t),this.codeViews.delete(e),this.codeViews.set(t,i),!0)},t.prototype.getCodeViewButtonPosition=function(e){if(!this.isInitialized())throw new Error(u.CODE_BOX_NOT_INITIALIZED_ERROR);var t=this.codeViews.get(e);if(!t)return null;var i=this.codeViewEntries.get(t);return i?i.position:null},t.prototype.setCodeViewButtonPosition=function(e,t){if(!this.isInitialized())throw new Error(u.CODE_BOX_NOT_INITIALIZED_ERROR);t=Math.trunc(t);var i=this.codeViewEntries.size+this.fileEntries.size-1;if(t<0||t>i)return!1;var o=this.codeViews.get(e);if(!o)return!1;var n=this.codeViewEntries.get(o);if(!n)return!1;var r=!1;return this.codeViewEntries.forEach((function(e){e.position===t&&(e.position=n.position,r=!0)})),r||this.fileEntries.forEach((function(e){e.position===t&&(e.position=n.position,r=!0)})),!!r&&(n.position=t,this.updateButtonsOrder(),!0)},t.prototype.setActiveCodeView=function(e){if(!this.isInitialized())throw new Error(u.CODE_BOX_NOT_INITIALIZED_ERROR);var t=this.codeViews.get(e);if(!t)return!1;var i=this.codeViewEntries.get(t);if(!i)return!1;var o=this.getCurrentlyActiveCodeView();if(o){var n=this.codeViewEntries.get(o);null==n||n.codeViewButton.setAsInactive()}return i.codeViewButton.setAsActive(),this.changeActiveCodeView(t),!0},t.prototype.setNoActiveCodeView=function(){if(!this.isInitialized())throw new Error(u.CODE_BOX_NOT_INITIALIZED_ERROR);var e=this.getCurrentlyActiveCodeView();if(e){var t=this.codeViewEntries.get(e);null==t||t.codeViewButton.setAsInactive()}this.changeActiveCodeView(null)},t.prototype.getActiveCodeView=function(){if(!this.isInitialized())throw new Error(u.CODE_BOX_NOT_INITIALIZED_ERROR);var e=this.getCurrentlyActiveCodeView();if(!e)return null;var t=this.codeViewEntries.get(e);return t?t.codeBoxCodeView:null},t.prototype.addFile=function(e,t){if(void 0===t&&(t=null),!this.isInitialized())throw new Error(u.CODE_BOX_NOT_INITIALIZED_ERROR);if(this.fileEntries.has(e))return!1;var i=new x(e,t,this.svgSpritePath,this.fileIconName,this.downloadIconName);i.appendTo(this.tabsContainer);var o=new g,n=new V(e,t,this,o),r=this.codeViewEntries.size+this.fileEntries.size;return this.fileEntries.set(e,new P(n,o,i,r)),!0},t.prototype.getFiles=function(){if(!this.isInitialized())throw new Error(u.CODE_BOX_NOT_INITIALIZED_ERROR);var e=new Array;return this.fileEntries.forEach((function(t){return e.push(t.codeBoxFile)})),e},t.prototype.getFile=function(e){if(!this.isInitialized())throw new Error(u.CODE_BOX_NOT_INITIALIZED_ERROR);var t=this.fileEntries.get(e);return t?t.codeBoxFile:null},t.prototype.removeFile=function(e){if(!this.isInitialized())throw new Error(u.CODE_BOX_NOT_INITIALIZED_ERROR);var t=this.fileEntries.get(e);return!!t&&(t.fileButton.detach(),this.fileEntries.delete(e),this.decrementItemPositionsAfterPosition(t.position),!0)},t.prototype.removeAllFiles=function(){var e=this;if(!this.isInitialized())throw new Error(u.CODE_BOX_NOT_INITIALIZED_ERROR);this.fileEntries.forEach((function(t){t.fileButton.detach(),e.decrementItemPositionsAfterPosition(t.position)})),this.fileEntries.clear()},t.prototype.changeFileIdentifier=function(e,t){if(!this.isInitialized())throw new Error(u.CODE_BOX_NOT_INITIALIZED_ERROR);var i=this.fileEntries.get(e);return!!i&&(!this.fileEntries.has(t)&&(i.fileButton.setText(t),i.codeBoxFileManager.changeIdentifier(t),this.fileEntries.delete(e),this.fileEntries.set(t,i),!0))},t.prototype.changeFileDownloadLink=function(e,t){if(!this.isInitialized())throw new Error(u.CODE_BOX_NOT_INITIALIZED_ERROR);var i=this.fileEntries.get(e);return!!i&&(i.codeBoxFileManager.changeDownloadLink(t),i.fileButton.setDownloadLink(t),!0)},t.prototype.getFileButtonPosition=function(e){if(!this.isInitialized())throw new Error(u.CODE_BOX_NOT_INITIALIZED_ERROR);var t=this.fileEntries.get(e);return t?t.position:null},t.prototype.setFileButtonPosition=function(e,t){if(!this.isInitialized())throw new Error(u.CODE_BOX_NOT_INITIALIZED_ERROR);t=Math.trunc(t);var i=this.codeViewEntries.size+this.fileEntries.size-1;if(t<0||t>i)return!1;var o=this.fileEntries.get(e);if(!o)return!1;var n=!1;return this.codeViewEntries.forEach((function(e){e.position===t&&(e.position=o.position,n=!0)})),n||this.fileEntries.forEach((function(e){e.position===t&&(e.position=o.position,n=!0)})),!!n&&(o.position=t,this.updateButtonsOrder(),!0)},t.prototype.reset=function(){if(!this.isInitialized())throw new Error(u.CODE_BOX_NOT_INITIALIZED_ERROR);this.initialMemento&&this.applyMemento(this.initialMemento)},t.prototype.createMemento=function(){var e=this;if(!this.isInitialized())throw new Error(u.CODE_BOX_NOT_INITIALIZED_ERROR);var t=new Array,i=new Array;return this.codeViewEntries.forEach((function(e,i){var o=e.codeBoxCodeView.getIdentifier();null!==o&&t.push({codeView:i,codeViewMemento:i.createMemento(),identifier:o,position:e.position})})),this.fileEntries.forEach((function(e){var t=e.codeBoxFile.getIdentifier();null!==t&&i.push({downloadLink:e.codeBoxFile.getDownloadLink(),identifier:t,position:e.position})})),new R(this,(function(t,i){return e._addCodeView(t,i)}),t,i,this.getCurrentlyActiveCodeView())},t.prototype.applyMemento=function(e){if(!this.isInitialized())throw new Error(u.CODE_BOX_NOT_INITIALIZED_ERROR);e.apply(this)},t.prototype.onInit=function(e){for(var t=0,i=e;t<i.length;t++){var n=i[t];if("CodeViewInfo"===n.type&&n.codeViewInfo){var r=n.codeViewInfo,a=r.dataset[o.DATA_ATTRIBUTE_PREFIX+"Name"]||o.DEFAULT_CODE_VIEW_BUTTON_TEXT,s=void 0!==r.dataset[o.DATA_ATTRIBUTE_PREFIX+"Active"];if(this.codeViews.has(a)){if(!s)continue;var l=this.codeViews.get(a);if(l){var d=this.codeViewEntries.get(l);d&&(d.codeViewButton.detach(),d.codeBoxCodeViewManager.unlinkCodeBox()),this.codeViews.delete(a),this.codeViewEntries.delete(l)}}var c=new L(a,this.showCodeViewEventSource,r.codeView,this.svgSpritePath,this.codeFileIconName);s&&c.setAsActive(),c.appendTo(this.tabsContainer);var h=new f,u=new B(a,r.codeView,this,h);this.codeViews.set(a,r.codeView);var p=this.codeViewEntries.size+this.fileEntries.size;this.codeViewEntries.set(r.codeView,new T(u,h,c,p))}else if("FileInfo"===n.type&&n.fileInfo){var E=n.fileInfo;a=E.name;if(this.fileEntries.has(a))continue;var _=new x(a,E.downloadLink,this.svgSpritePath,this.fileIconName,this.downloadIconName);_.appendTo(this.tabsContainer);var C=new g,I=new V(a,E.downloadLink,this,C);p=this.codeViewEntries.size+this.fileEntries.size;this.fileEntries.set(a,new P(I,C,_,p))}}},t.prototype.onAfterInit=function(){this.initialMemento=this.createMemento()},t.prototype.onShowCodeView=function(e,t){var i=this.getCurrentlyActiveCodeView();if(i){var o=this.codeViewEntries.get(i);null==o||o.codeViewButton.setAsInactive()}e.setAsActive(),this.changeActiveCodeView(t)},t.prototype.decrementItemPositionsAfterPosition=function(e){this.codeViewEntries.forEach((function(t){t.position>e&&t.position--})),this.fileEntries.forEach((function(t){t.position>e&&t.position--}))},t.prototype.updateButtonsOrder=function(){var e=this.codeViewEntries.size+this.fileEntries.size,t=new Array(e);this.codeViewEntries.forEach((function(e){return t[e.position]=e})),this.fileEntries.forEach((function(e){return t[e.position]=e}));for(var i=0,o=t;i<o.length;i++){var n=o[i];n instanceof T?n.codeViewButton.appendTo(this.tabsContainer):n.fileButton.appendTo(this.tabsContainer)}},t}(u);const z=function(e,t){this.codeBoxCodeView=e,this.codeBoxCodeViewManager=t};const U=function(e){this.codeBoxFileManager=e};const H=function(e){this.children=new Array,this.value=e};const j=function(e,t){this.codeView=e,this.codeViewButton=t};const Z=function(){function e(e,t,i,o,n){var r=this;this.opened=!1,this.isAnimating=!1,this.animationTimeoutId=null,this.delayTimeoutId=null,this.buttonElement=e,this.collapsibleElement=t,this.animationSpeed=i,this.animationEasingFunction=o,this.onToggle=n,this.buttonElement.addEventListener("click",(function(){return r.onButtonClick()})),this.collapsibleElement.style.setProperty("visibility","hidden"),this.collapsibleElement.style.setProperty("overflow"