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ACT,EAAU,IAAM,KAAK,mBACrB,KAAK,kBAAmB,EACxB,YAAW,KACP,KAAK,MAAM,GACZ,GAEX,CAEA,IAAA,GACI,KAAK,KAAK,UAAU,OAAO,WAC3B,MAAM,EAAW,KACjB,YAAW,KACP,EAAS,KAAK,cACa,IAAvB,EAAS,WACT,EAAS,WAAW,GACzB,IACP,EAEJ,QAAQ,QAAU,MAElB,MAAM,uBAAyB,IAC/B,MAAM,iBAAmB,SACzB,MAAM,MAAQ","file":"/npm/awesome-toast-component@2.0.6/src/toast.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/awesome-toast-component@2.0.6/src/toast.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nclass Toast {\n    //constructor:\n    constructor(message, option) {\n        var _a, _b;\n        this.bornTime = Date.now();\n        this.hideEventHandler = this.handleHideEvent.bind(this);\n        //append CSS styles to DOM:\n        Toast.appendCSS(); //comment at dev mode\n        //the view:\n        this.viewID = Toast.generateViewID();\n        let view = Toast.getHtml(this.viewID);\n        document.body.appendChild(view);\n        this.view = document.getElementById(this.viewID.toString()) || document.createElement('div');\n        //set properties:\n        this.setMessage(this.message = message);\n        this.setPosition(this.position = (option === null || option === void 0 ? void 0 : option.position) || Toast.DEFAULT_POSITION);\n        this.setTheme(option === null || option === void 0 ? void 0 : option.theme);\n        this.setStyle(option === null || option === void 0 ? void 0 : option.style);\n        this.waitForEvent = (_a = option === null || option === void 0 ? void 0 : option.waitForEvent) !== null && _a !== void 0 ? _a : false;\n        this.timeout = (_b = option === null || option === void 0 ? void 0 : option.timeout) !== null && _b !== void 0 ? _b : Toast.DEFAULT_HIDING_TIMEOUT;\n        this.isWaitingForHide = false;\n        this.afterHide = option === null || option === void 0 ? void 0 : option.afterHide;\n        //hide events:\n        this.addHideEventListener();\n        //don't wait for an event:\n        if (!this.waitForEvent)\n            this.startHidingTimer(this.timeout);\n        //finally show:\n        this.show();\n    }\n    //appendCSS:\n    static appendCSS() {\n        if (document.getElementById('toast-style') === null) {\n            let head = document.head || document.getElementsByTagName('head')[0];\n            let style = document.createElement('style');\n            style.id = 'toast-style';\n            head.appendChild(style);\n            style.appendChild(document.createTextNode(Style));\n        }\n    }\n    //generateViewID:\n    static generateViewID() {\n        let id = Math.floor(Math.random() * 1000000000) + 100000000;\n        let element = document.getElementById(id.toString());\n        if (element === null)\n            return id;\n        return Toast.generateViewID();\n    }\n    //getHtml:\n    static getHtml(viewId) {\n        const DOM = `\n            <div class=\"toast\" id=\"${viewId}\">\n                <div class=\"container\">\n                    <p class=\"message\"></p>\n                </div>\n            </div>\n        `;\n        let div = document.createElement('div');\n        div.innerHTML = DOM.trim();\n        return div.firstChild || div;\n    }\n    //setMessage:\n    setMessage(message) {\n        this.message = message;\n        let messageEl = this.view.getElementsByClassName('message')[0];\n        messageEl.innerHTML = this.message;\n    }\n    //setPosition:\n    setPosition(position) {\n        this.position = position;\n        this.view.classList.remove('bottom');\n        this.view.classList.remove('top');\n        this.view.classList.add(position);\n    }\n    //setTheme:\n    setTheme(theme) {\n        if (theme === undefined)\n            return;\n        this.theme == theme;\n        this.view.classList.remove('light');\n        this.view.classList.remove('dark');\n        this.view.classList.add(theme);\n    }\n    //setStyle:\n    setStyle(style) {\n        if (style === undefined)\n            return;\n        this.style = style;\n        for (const [className, style] of Object.entries(this.style)) {\n            let root = document.getElementById(this.viewID.toString());\n            let element = root.getElementsByClassName(className)[0];\n            if (element !== undefined)\n                for (const property of style)\n                    element.style.setProperty(property[0], property[1]);\n        }\n    }\n    //show:\n    show() {\n        let thisView = this;\n        setTimeout(() => {\n            thisView.view.classList.add('visible');\n        }, 50); //slight delay between adding to DOM and running css animation\n    }\n    //addHideEventListener:\n    addHideEventListener() {\n        const thisView = this;\n        'mousemove mousedown mouseup touchmove click keydown keyup scroll'.split(' ').forEach((eventName) => {\n            window.addEventListener(eventName, thisView.hideEventHandler);\n        });\n    }\n    //addHideEventListener:\n    removeHideEventListener() {\n        const thisView = this;\n        'mousemove mousedown mouseup touchmove click keydown keyup scroll'.split(' ').forEach((eventName) => {\n            window.removeEventListener(eventName, thisView.hideEventHandler);\n        });\n    }\n    //handleHideEvent:\n    handleHideEvent() {\n        let timeout = this.timeout;\n        let currentTime = Date.now();\n        if (currentTime - this.bornTime > this.timeout)\n            timeout = this.timeout / 2;\n        this.startHidingTimer(timeout);\n        this.removeHideEventListener();\n    }\n    //startHidingTimer:\n    startHidingTimer(timeout) {\n        if (timeout > 0 && !this.isWaitingForHide) {\n            this.isWaitingForHide = true;\n            setTimeout(() => {\n                this.hide();\n            }, timeout);\n        }\n    }\n    //hide:\n    hide() {\n        this.view.classList.remove('visible');\n        const thisView = this;\n        setTimeout(() => {\n            thisView.view.remove();\n            if (thisView.afterHide !== undefined)\n                thisView.afterHide();\n        }, 800); //long enough to make sure that it is hidden\n    }\n}\nexports.default = Toast;\n//default values:\nToast.DEFAULT_HIDING_TIMEOUT = 4000;\nToast.DEFAULT_POSITION = 'bottom';\nconst Style = `\n.toast {\n    position: fixed;\n    left: 50%;\n    transform: translate(-50%, 0);\n    opacity: 0;\n    transition: top 400ms ease-in-out 0s, bottom 400ms ease-in-out 0s, opacity 500ms ease-in-out 0ms;\n    z-index: 999999995;\n  }\n  .toast > .container {\n    box-sizing: border-box;\n    max-width: 350px;\n    border-radius: 23px;\n    background-color: rgb(58, 58, 58);\n    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1), 0 3px 3px rgba(0, 0, 0, 0.05);\n    overflow: hidden;\n  }\n  .toast > .container > .message {\n    box-sizing: border-box;\n    padding: 10px 20px;\n    text-align: center;\n    font-size: 0.9375rem;\n    color: rgb(240, 240, 240);\n    margin: 0;\n  }\n  \n  .toast.visible {\n    opacity: 1;\n  }\n  \n  .toast.bottom {\n    bottom: 25px;\n  }\n  \n  .toast.top {\n    top: 25px;\n  }\n  \n  .toast.light > .container {\n    background-color: #fbfbfb;\n  }\n  .toast.light > .container > .message {\n    color: #555;\n  }\n  \n  @media only screen and (max-width: 500px) {\n    .toast {\n      width: calc(100% - 24px);\n      max-width: unset;\n      left: 12px;\n      transform: translate(0, 0);\n      display: flex;\n      justify-content: center;\n    }\n  }\n`;\n"]}