Private
Public Access
1
0
Files
Virtnet.bond/public/lucentui/assets/app-C7ZwaDjn.js

2 lines
7.2 KiB
JavaScript

const c={passive:!0},E={passive:!1};document.addEventListener("livewire:init",()=>{Livewire.hook("request",({fail:e})=>{e(({status:t,preventDefault:i})=>{t===419&&(window.location.reload(),i())})})});Alpine.store("notifications",{notifications:[],init(){Livewire.on("notify",e=>{this.addNotification(e)})},addNotification(e){Array.isArray(e)&&(e=e[0]),!(!e||typeof e!="object")&&(e.show=!1,e.id=Date.now()+Math.floor(Math.random()*1e3),e.type=e.type||"success",e.actions=Array.isArray(e.actions)?e.actions:[],e.position=e.position||"bottom-right",e.timeout=e.timeout||5e3,e.paused=!1,e._remaining=e.timeout,e._startedAt=Date.now(),this.notifications.push(e),requestAnimationFrame(()=>{this.notifications=this.notifications.map(t=>(t.id===e.id&&(t.show=!0),t))}),this._scheduleDismiss(e))},_scheduleDismiss(e){e._timer&&clearTimeout(e._timer),e._startedAt=Date.now(),e._timer=setTimeout(()=>{e.paused||this.removeNotification(e.id)},e._remaining)},pauseNotification(e){const t=this.notifications.find(i=>i.id===e);!t||t.paused||(t.paused=!0,t._remaining-=Date.now()-t._startedAt,t._timer&&(clearTimeout(t._timer),t._timer=null))},resumeNotification(e){const t=this.notifications.find(i=>i.id===e);!t||!t.paused||(t.paused=!1,this._scheduleDismiss(t))},invokeAction(e,t){var o;const i=this.notifications.find(r=>r.id===e);if(!i)return;const n=(o=i.actions)==null?void 0:o[t];if(n){if(n.event){const r={notificationId:e,payload:n.payload||null};if(window.dispatchEvent(new CustomEvent(n.event,{detail:r})),window.Livewire&&typeof window.Livewire.dispatch=="function")try{window.Livewire.dispatch(n.event,[r])}catch{}}n.href&&(window.Livewire&&typeof window.Livewire.navigate=="function"?window.Livewire.navigate(n.href):window.location.href=n.href),n.dismiss!==!1&&this.removeNotification(e)}},removeNotification(e){this.notifications=this.notifications.filter(t=>(t.id===e&&(t.show=!1,t._timer&&clearTimeout(t._timer)),t.show))}});let u;const L=document.documentElement.lang||"en",A={ar:"ar-SA",de:"de-DE",en:"en-US",es:"es-ES",fi:"fi-FI",fr:"fr-FR",it:"it-IT",sv:"sv-SE",uk:"uk-UA",ko:"ko-KR",lv:"lv-LV",nl:"nl-NL",no:"no-NO",pt:"pt-PT",sr:"sr-RS",id:"id-ID"};function m(){const e=new Date,t=document.getElementById("current-time"),i=document.getElementById("current-date"),n=A[L]||"en-US";t&&(t.textContent=e.toLocaleTimeString(n,{hour:"2-digit",minute:"2-digit",hour12:!0})),i&&(i.textContent=e.toLocaleDateString(n,{weekday:"long",year:"numeric",month:"long",day:"numeric"}))}const k=(e,t)=>{let i;return(...n)=>{clearTimeout(i),i=setTimeout(()=>e.apply(void 0,n),t)}},S=(e,t)=>{let i;return function(...n){i||(e.apply(this,n),i=!0,setTimeout(()=>i=!1,t))}};let s;function w(){const e=document.querySelectorAll(".reveal-on-scroll");if(e.length===0)return;const t={root:null,rootMargin:"0px 0px -10% 0px",threshold:.1};s=new IntersectionObserver(i=>{i.forEach(n=>{n.isIntersecting&&(n.target.style.transform="translateY(0)",n.target.style.opacity="1",n.target.classList.add("revealed"),s.unobserve(n.target))})},t),e.forEach(i=>{i.style.transform="translateY(20px)",i.style.opacity="0",i.style.transition="transform 0.6s ease-out, opacity 0.6s ease-out",s.observe(i)})}const l=new WeakMap,p=new WeakMap;function y(e){document.querySelectorAll(e).forEach(i=>{if(p.has(i)||i.hasAttribute("wire:click")||i.hasAttribute("x-on:click")||i.hasAttribute("@click"))return;const n=function(o){if(l.get(i))return o.preventDefault(),o.stopPropagation(),!1;l.set(i,!0),i.classList.add("btn-loading");const r=()=>{l.set(i,!1),i.classList.remove("btn-loading")};window.requestIdleCallback?setTimeout(()=>requestIdleCallback(r),2e3):setTimeout(r,2e3)};i.addEventListener("click",n,E),l.set(i,!1),p.set(i,n)})}let a;function g(){const e=document.querySelectorAll("img[data-src]");e.length!==0&&(a=new IntersectionObserver(t=>{t.forEach(i=>{if(i.isIntersecting){const n=i.target;n.src=n.dataset.src,n.classList.remove("lazy"),n.removeAttribute("data-src"),a.unobserve(n)}})},{rootMargin:"50px"}),e.forEach(t=>a.observe(t)))}let d=null;function f(){if(d!==null)return d;const e=[];if(navigator.hardwareConcurrency&&e.push(navigator.hardwareConcurrency>=4?1:0),navigator.deviceMemory&&e.push(navigator.deviceMemory>=4?1:0),navigator.connection){const n=navigator.connection;e.push(n.effectiveType==="4g"?1:0)}const t=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);return e.push(t?0:1),d=e.reduce((n,o)=>n+o,0)/e.length>.5?"high":"low",d}const h=new WeakMap;function b(){document.querySelectorAll("form").forEach(t=>{if(h.has(t)||t.hasAttribute("wire:submit")||t.closest("[wire\\:id]"))return;const i=t.querySelector('button[type="submit"], input[type="submit"]');if(!i)return;const n=function(o){i.disabled=!0,i.classList.add("btn-loading"),setTimeout(()=>{i.disabled=!1,i.classList.remove("btn-loading")},8e3)};t.addEventListener("submit",n,c),h.set(t,n)})}function M(){if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)){const t=document.querySelector("meta[name=viewport]");document.querySelectorAll("input, select, textarea").forEach(n=>{n.addEventListener("focus",()=>{t&&t.setAttribute("content","width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0")},c),n.addEventListener("blur",()=>{t&&t.setAttribute("content","width=device-width, initial-scale=1.0")},c)}),document.body.classList.add("mobile-optimized")}}function x(){window.addEventListener("error",e=>{console.error("Error:",e.error)}),window.addEventListener("unhandledrejection",e=>{console.error("Unhandled promise rejection:",e.reason)})}function I(e){const t=document.createElement("div");t.className="fixed top-4 right-4 bg-red-500 text-white px-4 py-2 rounded shadow-lg z-50 transition-opacity duration-300",t.textContent=e,document.body.appendChild(t),requestAnimationFrame(()=>{t.style.opacity="1"}),setTimeout(()=>{t.style.opacity="0",setTimeout(()=>t.remove(),300)},4e3)}function T(){let e=null;window.addEventListener("offline",()=>{e||(e=document.createElement("div"),e.className="fixed top-4 right-4 bg-yellow-500 text-white px-4 py-2 rounded shadow-lg z-50",e.textContent="You are offline. Some features may not work.",document.body.appendChild(e))}),window.addEventListener("online",()=>{e&&(e.remove(),e=null)})}function v(){m(),u=setInterval(m,1e3);const e=f();e==="high"?(w(),g()):(document.body.classList.add("low-performance"),document.querySelectorAll(".reveal-on-scroll").forEach(t=>{t.classList.add("revealed")})),y('.btn-primary, [href*="checkout"], [href*="add-to-cart"]'),b(),M(),x(),T(),e==="low"&&document.querySelectorAll(".animate-pulse-slowest, .animate-pulse-slow, .animate-pulse-fast").forEach(i=>{i.style.animation="none",i.style.opacity="0.1"})}document.addEventListener("touchstart",()=>{},c);document.addEventListener("touchmove",()=>{},c);document.readyState==="loading"?document.addEventListener("DOMContentLoaded",v):v();document.addEventListener("livewire:navigated",()=>{m(),f()==="high"?(w(),g()):document.querySelectorAll(".reveal-on-scroll").forEach(t=>{t.classList.add("revealed")}),y('.btn-primary, [href*="checkout"], [href*="add-to-cart"]'),b()});window.addEventListener("beforeunload",()=>{u&&clearInterval(u),s&&s.disconnect(),a&&a.disconnect()});window.AppOptimizer={debounce:k,throttle:S,getDevicePerformance:f,showErrorNotification:I};