const cssStr = `#toast{display:flex;flex-direction:column;color: #fff;font-family:Space Grotesk;align-items:center;margin-top: 14px;justify-content:flex-start;pointer-events:none;width:100vw;height:100vh;position:fixed;left:0;top:0;z-index:9999999;cursor:pointer;transition:0.2s}#toast span{pointer-events:auto;border:1px solid rgba(255, 255, 255, 0.7);animation:fadein 0.4s;animation-delay:0s;border-radius:6px;padding:10px 20px;box-shadow:0 0 10px 6px rgba(0,0,0,0.1);margin:10px 24px;transition:0.2s;z-index:9999999;font-size:14px;display:flex;align-items:center;justify-content:center;gap:4px;height:max-content;text-align: center;}#toast span.hide{opacity:0;pointer-events:none;transform:translateY(-10px);height:0;padding:0;margin:0}.toast-warn{background-color:#fffaec;color:#e29505}.toast-error{background-color:#fde7e7;color:#d93025}.toast-info{background-color:#e6f7ff;color:#0e6eb8}.toast-success{background-color:#e9f7e7;color:#1a9e2c}.toast-{background-color:#fafafa;color:#333}@keyframes fadein{0%{opacity:0;transform:translateY(-10px)}100%{opacity:1;transform:translateY(0)}}`; const toast = { open(text, type = "", time = 2500) { if (typeof type === "number") { time = type; type = ""; } let mainEl = getMainElement(); let el = document.createElement("span"); el.className = `toast-normal`; el.innerHTML = text; mainEl.appendChild(el); setTimeout(() => { el.classList.add("hide"); }, time - 500); setTimeout(() => { mainEl.removeChild(el); el = null; }, time); }, }; function getMainElement() { let mainEl = document.querySelector("#toast"); if (!mainEl) { mainEl = document.createElement("div"); mainEl.id = "toast"; document.body.appendChild(mainEl); let style = document.createElement("style"); style.innerHTML = cssStr; document.head.insertBefore(style, document.head.firstChild); } return mainEl; }