zum-framework 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +87 -0
- package/README.md +682 -2
- package/dist/zum.cjs +3615 -0
- package/dist/zum.iife.min.js +241 -0
- package/dist/zum.mjs +3597 -0
- package/package.json +36 -4
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
var ZumModule=(()=>{var U=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var X=(w,e,t)=>e in w?U(w,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):w[e]=t;var Q=(w,e)=>{for(var t in e)U(w,t,{get:e[t],enumerable:!0})},ee=(w,e,t,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of J(e))!V.call(w,r)&&r!==t&&U(w,r,{get:()=>e[r],enumerable:!(a=Y(e,r))||a.enumerable});return w};var te=w=>ee(U({},"__esModule",{value:!0}),w);var T=(w,e,t)=>X(w,typeof e!="symbol"?e+"":e,t);var re={};Q(re,{Zum:()=>A,ZumActivity:()=>ae,default:()=>ne});var j=()=>typeof window!="undefined"&&typeof document!="undefined",K={_debugEnabled:!1},W=typeof window!="undefined"&&(window.__ZUM_DEBUG__===!0||typeof process!="undefined"&&process.env&&!1),M=(...w)=>{(W||K._debugEnabled)&&console.log(...w)},I=(...w)=>{(W||K._debugEnabled)&&console.warn(...w)},E=(...w)=>{console.error(...w)},n=class n{static addBeforeUnloadHandler(e){return typeof e!="function"?()=>{}:(!n._beforeUnloadAttached&&typeof window!="undefined"&&(window.addEventListener("beforeunload",()=>{n._beforeUnloadHandlers.forEach(t=>{try{t()}catch(a){E(a)}})}),n._beforeUnloadAttached=!0),n._beforeUnloadHandlers.add(e),()=>n._beforeUnloadHandlers.delete(e))}static _debounce(e,t){let a,r=function(...s){let i=()=>{clearTimeout(a),e(...s)};clearTimeout(a),a=setTimeout(i,t)};return r.cancel=()=>{clearTimeout(a),a=null},r.flush=(...s)=>{clearTimeout(a),a=null,e(...s)},r}static _isObject(e){return e&&typeof e=="object"&&!Array.isArray(e)}static _deepMerge(e,t){let a={...e};return n._isObject(e)&&n._isObject(t)&&Object.keys(t).forEach(r=>{n._isObject(t[r])?r in e?a[r]=n._deepMerge(e[r],t[r]):a[r]=t[r]:(Array.isArray(t[r]),a[r]=t[r])}),a}static _escapeHtml(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}static _scheduleAutoSave(e,t,a){a>0&&(e.__debouncedSave||(e.__debouncedSave=n._debounce(()=>{e.__isDestroyed||n.saveComponent(t,e)},a)),e.__debouncedSave())}static _scheduleOnUpdate(e,t){e.__onUpdate&&(e.__pendingUpdate=t,!e.__onUpdateScheduled&&(e.__onUpdateScheduled=!0,queueMicrotask(()=>{e.__onUpdateScheduled=!1;let a=e.__pendingUpdate;if(e.__pendingUpdate=null,a&&e.__onUpdate)try{e.__onUpdate.call(e,a)}catch(r){E(r)}})))}static _createReactiveState(e,t,a,r){return new Proxy(e,{set:(s,i,c)=>{let l=s[i];return l===c&&(typeof c!="object"||c===null)||(typeof c=="object"&&c!==null&&(c=n._createReactiveState(c,t,a,r)),s[i]=c,n._scheduleAutoSave(a,t,r),a.__isMounted&&a.__onUpdate&&n._scheduleOnUpdate(a,{property:i,oldValue:l,newValue:c,state:s}),a.__stateWatchers&&a.__stateWatchers[i]&&a.__stateWatchers[i].forEach(d=>{try{d(c,l,s)}catch(m){E(m)}})),!0},get:(s,i)=>{let c=s[i];return Array.isArray(c)?new Proxy(c,{get:(l,d)=>{let m=l[d];return typeof m=="function"&&["push","pop","shift","unshift","splice","sort","reverse"].includes(d)?function(...f){let h=[...l],_=Array.prototype[d].apply(l,f);return n._scheduleAutoSave(a,t,r),a.__isMounted&&a.__onUpdate&&n._scheduleOnUpdate(a,{property:i,oldValue:h,newValue:l,state:s}),a.__stateWatchers&&a.__stateWatchers[i]&&a.__stateWatchers[i].forEach(P=>{try{P(l,h,s)}catch(b){E(b)}}),_}:m}}):c}})}static get ready(){return n._readyPromise||(n._readyPromise=(async()=>(j()&&(n._injectAnimationStyles(),n._initAutoContrast()),!0))()),n._readyPromise}static create(e,t={}){return e&&typeof e=="object"&&!(e instanceof HTMLElement)&&(t=e,e=t.tag||"div"),e||(e="div"),new n(e,t).getElement()}static createMany(e,t=[],a="33/33/33"){if(!j())return null;t.length>3&&I(`Zum.createMany: received ${t.length} components but only 3 are supported.`);let r=t.slice(0,3),s=a.split("/").map(o=>parseFloat(o.trim()));if(s.length===0||s.some(isNaN)){let o=100/Math.max(r.length,1);s=r.map(()=>o)}for(;s.length<r.length;)s.push(100/Math.max(r.length,1));let i=s.reduce((o,x)=>o+x,0);i>0&&i!==100&&(s=s.map(o=>o*100/i));let c=document.createElement("div");c.className="Zum-many-container",c.style.cssText="width: 100%; max-width: 100%; height: 100dvh; height: 100vh; overflow: hidden; position: relative; margin: 0; padding: 0; box-sizing: border-box;";let d=(e instanceof HTMLElement?e:e?n.create(e.tag||"div",e):null)||(r[0]?r[0]instanceof HTMLElement?r[0]:n.create(r[0].tag||"div",{...r[0],useShadow:!1}):null),m=r.map(o=>o instanceof HTMLElement?o:n.create(o.tag||"div",o)),v=null,f=document.createElement("div");f.className="Zum-many-mobile-scroll",f.style.cssText="width: 100%; max-width: 100%; height: 100%; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; box-sizing: border-box;",d&&f.appendChild(d);let h=document.createElement("div");h.setAttribute("data-layout","mobile"),h.style.cssText="width: 100%; max-width: 100%; height: 100%; overflow: hidden; box-sizing: border-box;",h.appendChild(f);let _=document.createElement("div");_.className="Zum-many-panels";let P=16;_.style.cssText=`display: flex; gap: ${P}px; width: 100%; height: 100%; overflow: hidden; box-sizing: border-box;`;let b=(m.length-1)*P;m.forEach((o,x)=>{let C=document.createElement("div");C.className="Zum-many-panel";let R=s[x]||100/m.length,g=`calc(${R}% - ${(b*(R/100)).toFixed(2)}px)`;C.style.cssText=`flex: 0 0 ${g}; width: ${g}; max-width: ${g}; height: 100%; min-height: 0; display: flex; flex-direction: column; box-sizing: border-box; overflow: hidden;`;let u=document.createElement("div");u.className="Zum-many-panel-scroll",u.style.cssText="width: 100%; height: 100%; flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; box-sizing: border-box;",u.appendChild(o),C.appendChild(u),_.appendChild(C)});let $=document.createElement("div");if($.setAttribute("data-layout","desktop"),$.style.cssText="width: 100%; height: 100%; overflow: hidden; box-sizing: border-box;",$.appendChild(_),!document.getElementById("Zum-many-styles")){let o=document.createElement("style");o.id="Zum-many-styles",o.textContent=`
|
|
2
|
+
.Zum-many-container { width: 100% !important; height: 100vh; height: 100dvh; overflow: hidden; }
|
|
3
|
+
@media (max-width: 767px) {
|
|
4
|
+
.Zum-many-container [data-layout="desktop"] { display: none !important; }
|
|
5
|
+
.Zum-many-container [data-layout="mobile"] { display: block !important; }
|
|
6
|
+
}
|
|
7
|
+
`,document.head.appendChild(o)}let z=()=>window.innerWidth>=768,D=()=>{let o=z()?"desktop":"mobile";v!==o&&(o==="desktop"?(h.parentNode===c&&c.removeChild(h),c.appendChild($),c.setAttribute("data-layout","desktop")):($.parentNode===c&&c.removeChild($),c.appendChild(h),c.setAttribute("data-layout","mobile")),v=o)};D();let N=null,H=()=>{N||(N=requestAnimationFrame(()=>{D(),N=null}))};return window.addEventListener("resize",H),c.__cleanupResize=()=>{window.removeEventListener("resize",H),N&&cancelAnimationFrame(N),N=null},c.__droppedCount=Math.max(0,t.length-3),c.__destroyMany=()=>{c.__isDestroyed=!0;try{c.__cleanupResize()}catch(o){}},c}constructor(e,t={}){this.tag=e||"div",this.options=t,this.elementWrapper=document.createElement("div"),this.elementWrapper.style.display="contents",this._initWithoutLicense()}getElement(){return this.elementWrapper}async _initWithoutLicense(){await n.ready,this._buildComponent()}static _injectAnimationStyles(){if(n._animationsInjected||typeof document=="undefined")return;let e=document.createElement("style");e.setAttribute("data-Zum-animations","true"),e.textContent=Object.values(n.animations).map(t=>t.keyframes).join(`
|
|
8
|
+
`),(document.head||document.documentElement).appendChild(e),n._animationsInjected=!0}static _parseAnim(e){if(!e)return null;if(typeof e=="object")return{...e,__raw:!0};let t=String(e).trim().toLowerCase().split(/\s+/),a={verb:"fade",direction:null,duration:500,easing:null,delay:0,scroll:!1,repeat:!1,stagger:0,staggerTarget:"> *",loop:!1,forceMotion:!1,disableMotion:!1},r=["fade","slide","zoom","scale","flip","rotate","blur","bounce","shake","pulse","reveal"],s=["up","down","left","right"],i={ease:"ease","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out",linear:"linear",bounce:"cubic-bezier(.34,1.56,.64,1)",spring:"cubic-bezier(.16,1,.3,1)",snap:"cubic-bezier(.5,-0.5,.5,1.5)"},c={fast:250,normal:500,slow:800,slower:1200},l=!1;for(let d of t)r.includes(d)&&!l?(a.verb=d,l=!0):s.includes(d)?a.direction=d:/^\d+$/.test(d)?a.duration=parseInt(d,10):d in c?a.duration=c[d]:d in i?a.easing=i[d]:d.startsWith("delay-")?a.delay=parseInt(d.slice(6),10)||0:d==="on-scroll"?a.scroll=!0:d==="repeat"?(a.scroll=!0,a.repeat=!0):d==="loop"?a.loop=!0:d==="force-motion"?a.forceMotion=!0:d==="no-motion"?a.disableMotion=!0:d==="stagger"?a.stagger=80:d.startsWith("stagger-")?a.stagger=parseInt(d.slice(8),10)||80:d.startsWith("target-")&&(a.staggerTarget="."+d.slice(7));return a.easing||(a.easing="cubic-bezier(.2,.8,.2,1)"),a}static _resolveAnimName(e){let t=r=>r[0].toUpperCase()+r.slice(1);return{fade:"fade",slide:e.direction?`slide${t(e.direction)}`:"slideUp",flip:"flipIn",rotate:"rotateIn",zoom:"scale",scale:"scale",blur:"blurIn",bounce:"bounce",shake:"shake",pulse:"pulse",reveal:"reveal"}[e.verb]||"fade"}static _applyScrollAnim(e,t){if(!j())return;let a=n._resolveAnimName(t);n._injectAnimationStyles(),e.style.opacity="0",e.style.willChange="opacity, transform";let r=()=>{e.__isDestroyed||(e.style.animation=`${a} ${t.duration}ms ${t.easing} ${t.delay}ms both`)},s=()=>{e.style.animation="none",e.style.opacity="0"},i=new IntersectionObserver(c=>{for(let l of c)l.isIntersecting?(r(),t.repeat||i.unobserve(e)):t.repeat&&s()},{threshold:.15,rootMargin:"0px 0px -10% 0px"});(e.__zumAnimObservers||(e.__zumAnimObservers=[])).push(i),i.observe(e)}static _applyStaggerAnim(e,t){if(!j())return;let a=n._resolveAnimName(t);n._injectAnimationStyles(),(t.staggerTarget==="> *"?Array.from(e.children):Array.from(e.querySelectorAll(t.staggerTarget))).forEach((s,i)=>{s.style.animation=`${a} ${t.duration}ms ${t.easing} ${t.delay+i*t.stagger}ms both`})}_applyAnimation(e,t,a="in"){var c;if(!t||!j())return;let r=(c=window.matchMedia)==null?void 0:c.call(window,"(prefers-reduced-motion: reduce)").matches,s=n._parseAnim(t);if(!s||r&&n.respectReducedMotion&&!s.forceMotion&&a==="in"||s.disableMotion||s.__raw)return;if(s.scroll)return n._applyScrollAnim(e,s);if(s.stagger)return n._applyStaggerAnim(e,s);let i=n._resolveAnimName(s);n._injectAnimationStyles(),e.style.animation=`${i} ${s.duration}ms ${s.easing} ${s.delay}ms both`,s.loop&&(e.style.animationIterationCount="infinite")}static animate(e,t="fade",a={}){if(!e||!t)return;let r=n._parseAnim(t);if(!r||(a.duration&&(r.duration=a.duration),a.easing&&(r.easing=a.easing),a.delay&&(r.delay=a.delay),r.__raw))return;if(r.scroll)return n._applyScrollAnim(e,r);if(r.stagger)return n._applyStaggerAnim(e,r);let s=n._resolveAnimName(r);n._injectAnimationStyles(),e.style.animation=`${s} ${r.duration}ms ${r.easing} ${r.delay}ms both`,r.loop&&(e.style.animationIterationCount="infinite")}static async animateOut(e,t="fade",a={}){var d,m;if(!e||!t)return;let r=n._parseAnim(t);if(!r)return;let s=n._resolveAnimName(r),i=n.animations[s];if(!i)return;n._injectAnimationStyles();let c=r.duration||a.duration||((d=i.options)==null?void 0:d.duration)||600,l=r.easing||a.easing||((m=i.options)==null?void 0:m.easing)||"ease";return new Promise(v=>{let f=!1,h=()=>{f||(f=!0,e.removeEventListener("animationend",h),v())};e.addEventListener("animationend",h),e.style.animation=`${s}Out ${c}ms ${l} ${r.delay||0}ms both`,setTimeout(h,c+(r.delay||0)+100)})}static _initAutoContrast(){if(n._contrastInitialized||!j())return;let e=document.createElement("style");e.setAttribute("data-Zum-contrast","true"),e.textContent=`
|
|
9
|
+
.zum-contrast, .zum-contrast * { transition: color 0.3s ease-in-out !important; }
|
|
10
|
+
.zum-contrast-text { transition: color 0.3s ease-in-out !important; }
|
|
11
|
+
@media (prefers-color-scheme: dark) { .zum-contrast-text { color: #f1f5f9 !important; } }
|
|
12
|
+
@media (prefers-color-scheme: light) { .zum-contrast-text { color: #0f172a !important; } }
|
|
13
|
+
`,document.head.appendChild(e);let t=new MutationObserver(s=>{s.forEach(i=>{i.addedNodes&&i.addedNodes.forEach(c=>{c.nodeType===Node.ELEMENT_NODE&&setTimeout(()=>n._applyContrastToElement(c),50)})})});document.body&&t.observe(document.body,{childList:!0,subtree:!0}),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>setTimeout(()=>n._applyContrastToAll(),100)):setTimeout(()=>n._applyContrastToAll(),100);let a=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>setTimeout(()=>n._applyContrastToAll(),50);a.addEventListener?a.addEventListener("change",r):a.addListener&&a.addListener(r),n._contrastInitialized=!0,M("\u2705 Auto-contrast system initialized")}static _getRealBackground(e){let t=e,a=0;for(;t&&a<30;){let s=getComputedStyle(t).backgroundColor;if(s&&s!=="rgba(0, 0, 0, 0)"&&s!=="transparent"&&s!=="")return s;if(t!==e&&n._contrastProcessing.has(t))break;t.parentElement?t=t.parentElement:t.parentNode&&t.parentNode.host?t=t.parentNode.host:t=null,a++}let r=n.getTheme();return r?r.colors.background:"#ffffff"}static _applyContrastToAll(){if(!j()||!document.body)return;let e="input, textarea, select, img, svg, canvas, video, audio, script, style, meta, link, title, br, hr",t=r=>{if(!r||!r.matches||r.matches(e)||!r.textContent||!r.textContent.trim()||n._contrastProcessed.has(r)&&r.dataset.contrastColor)return;let s=n._getRealBackground(r),c=n._calculateLuminance(s)>.5?"#0f172a":"#f1f5f9";r.style.setProperty("color",c,"important"),r.dataset.contrastColor=c,r.classList.add("zum-contrast-text"),n._contrastProcessed.add(r)},a=r=>{!r||!r.querySelectorAll||r.querySelectorAll("*").forEach(s=>{t(s),s.shadowRoot&&a(s.shadowRoot)})};a(document.body),M("\u2705 Contrast applied to all elements")}static _applyContrastToElement(e){if(!e||!j())return;let t="input, textarea, select, img, svg, canvas, video, audio, script, style, meta, link, title, br, hr",a=s=>{if(!s||!s.matches||s.matches(t)||!s.textContent||!s.textContent.trim()||n._contrastProcessed.has(s)&&s.dataset.contrastColor)return;let i=n._getRealBackground(s),l=n._calculateLuminance(i)>.5?"#0f172a":"#f1f5f9";s.style.setProperty("color",l,"important"),s.dataset.contrastColor=l,s.classList.add("zum-contrast-text"),n._contrastProcessed.add(s)};n._contrastProcessing.add(e),a(e);let r=s=>{!s||!s.querySelectorAll||s.querySelectorAll("*").forEach(i=>{a(i),i.shadowRoot&&r(i.shadowRoot)})};r(e),e.classList.add("zum-contrast"),setTimeout(()=>n._contrastProcessing.delete(e),250)}static _resolveColorToRgb(e){if(!e||typeof document=="undefined")return null;if(e.startsWith("#")||e.startsWith("rgb"))return e;let t=document.createElement("span");t.style.color=e,t.style.display="none",document.body.appendChild(t);let a=getComputedStyle(t).color;return document.body.removeChild(t),a||null}static _calculateLuminance(e){if(!e)return .5;let t=n._resolveColorToRgb(e);if(!t)return .5;let a,r,s;if(t.startsWith("#")){let i=t.replace("#","");if(i.length===3)a=parseInt(i[0]+i[0],16),r=parseInt(i[1]+i[1],16),s=parseInt(i[2]+i[2],16);else if(i.length===6)a=parseInt(i.slice(0,2),16),r=parseInt(i.slice(2,4),16),s=parseInt(i.slice(4,6),16);else return .5}else if(t.startsWith("rgb")){let i=t.match(/[\d.]+/g);if(i&&i.length>=3)a=parseFloat(i[0]),r=parseFloat(i[1]),s=parseFloat(i[2]);else return .5}else return .5;return(.299*a+.587*r+.114*s)/255}static getContrastColor(e,t={}){var c,l;let{mode:a="luminance",foreground:r=null}=t,s=n._calculateLuminance(e),i=(l=(c=n.themeSettings)==null?void 0:c.contrastThreshold)!=null?l:.5;if(a==="wcag"&&r){let d=n._calculateLuminance(r);return(Math.max(s,d)+.05)/(Math.min(s,d)+.05)>=4.5?r:s>i?"#0f172a":"#f1f5f9"}return s>i?"#0f172a":"#f1f5f9"}static getThemeContrastColor(e){var a,r;return n._calculateLuminance(e)>((r=(a=n.themeSettings)==null?void 0:a.contrastThreshold)!=null?r:.5)?"#0f172a":"#f1f5f9"}static applyContrast(e){e&&(n._contrastProcessed.delete(e),delete e.dataset.contrastColor,n._applyContrastToElement(e))}static refreshContrast(){if(!j()||!document.body)return;let e=t=>{!t||!t.querySelectorAll||t.querySelectorAll("*").forEach(a=>{n._contrastProcessed.delete(a),delete a.dataset.contrastColor,a.shadowRoot&&e(a.shadowRoot)})};e(document.body),n._applyContrastToAll(),M("\u{1F3A8} Contrast refreshed everywhere")}_buildComponent(){if(!j())return;let{html:e="",style:t={},className:a="",events:r={},children:s=[],attributes:i={},css:c="",script:l="",props:d={},state:m={},websocket:v=null,onMount:f=null,onDestroy:h=null,onUpdate:_=null,anim:P="fade",autoSave:b=!1,autoSaveDelay:$=500,exclude:z=[],render:D=null,autoContrast:N=!0,safe:H=!0}=this.options,o=document.createElement(this.tag);o.__isDestroyed=!1,this._applyAnimation(o,P);let x=(d==null?void 0:d.componentId)||(d==null?void 0:d.name)||`component-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;if(o.__componentName=x,a&&(o.className=a),Object.assign(o.style,t),e){let g=e;Object.entries(d).forEach(([u,O])=>{let p=`{{${u}}}`;if(typeof O=="string"||typeof O=="number"){let y=H?n._escapeHtml(O):String(O);g=g.split(p).join(y)}}),o.innerHTML=g}let C=b?$:0;if(b){let g=n._autoGenerateState(o,z);o.__state=n._createReactiveState(g,x,o,C)}else m&&typeof m=="object"?o.__state=n._createReactiveState({...m},x,o,0):o.__state={};if(D&&n._setupAutoRender(o,D),Object.entries(i).forEach(([g,u])=>o.setAttribute(g,u)),o.__props=d,v){let{url:g,protocols:u=[],onopen:O=null,onmessage:p=null,onclose:y=null,onerror:S=null,autoReconnect:k=!1,reconnectInterval:Z=3e3,maxReconnects:q=1/0}=v;o.__wsQueue=[],o.__reconnectAttempts=0,o.__createWebSocket=function(){if(!o.__websocketDestroyed)try{let L=u.length>0?new WebSocket(g,u):new WebSocket(g);o.__websocket=L,L.onopen=F=>{for(;o.__wsQueue.length&&L.readyState===WebSocket.OPEN;){let B=o.__wsQueue.shift();try{L.send(typeof B=="string"?B:JSON.stringify(B))}catch(G){E(G)}}o.__reconnectAttempts=0,O&&O.call(o,F,L)},L.onmessage=F=>{p&&p.call(o,F,L)},L.onclose=F=>{y&&y.call(o,F,L),k&&!o.__websocketDestroyed&&o.__reconnectAttempts<q&&(o.__reconnectAttempts++,setTimeout(()=>{o.__websocketDestroyed||o.__createWebSocket()},Z))},L.onerror=F=>{S&&S.call(o,F,L)}}catch(L){E("WebSocket creation failed:",L)}},o.sendWebSocket=L=>{if(o.__websocket&&o.__websocket.readyState===WebSocket.OPEN)try{o.__websocket.send(typeof L=="string"?L:JSON.stringify(L))}catch(F){E(F)}else o.__wsQueue.push(L)},o.closeWebSocket=(L=1e3,F="")=>{o.__websocketDestroyed=!0,o.__websocket&&o.__websocket.close(L,F)},setTimeout(()=>o.__createWebSocket(),10)}if(o.__events=[],Object.entries(r).forEach(([g,u])=>{o.addEventListener(g,u),o.__events.push({event:g,handler:u})}),s.filter(Boolean).map(g=>g instanceof HTMLElement?g:typeof g=="object"&&!Array.isArray(g)?n.create(g.tag||"div",{...g,useShadow:!1,props:{...d,...g.props}}):g).filter(g=>g instanceof HTMLElement).forEach(g=>o.appendChild(g)),o.__onMount=f,o.__onDestroy=h,_){let g=o.__onUpdate;g?o.__onUpdate=function(u){try{g.call(this,u)}catch(O){E(O)}try{_.call(this,u)}catch(O){E(O)}}:o.__onUpdate=_}if(setTimeout(()=>{if(!o.__isDestroyed){if(o.__isMounted=!0,b&&n._autoBindFormElements(o),o.__onMount)try{o.__onMount.call(o)}catch(g){E(g)}N!==!1&&setTimeout(()=>{o.__isDestroyed||n._applyContrastToElement(o)},50)}},0),c){let g=document.createElement("style");g.textContent=c,g.setAttribute("data-Zum-css","true"),document.head.appendChild(g),o.__ZumCss=g}l&&setTimeout(()=>{o.__isDestroyed||n._executeScriptWithState(l,o)},10),this.elementWrapper.appendChild(o)}static _executeScriptWithState(e,t){try{typeof e=="function"?e.call(t,t.__state):typeof e=="string"&&new Function("state",e).call(t,t.__state)}catch(a){E("Error executing script with state:",a)}}static addComponents(...e){if(!j())return null;let t=[],a=o=>{Array.isArray(o)?o.forEach(a):o&&t.push(o)};if(e.forEach(a),t.length===0)return null;let r=document.createElement("div");r.style.display="contents";let s={},i={},c=[],l={},d=[],m=[],v=[],f=[],h=[],_=[];t.forEach((o,x)=>{if(o instanceof HTMLElement){c.push(o);return}if(typeof o=="string"){let R=document.createElement("div");R.textContent=o,c.push(R);return}if(typeof o!="object")return;o.events&&typeof o.events=="object"&&Object.entries(o.events).forEach(([R,g])=>{l[R]||(l[R]=[]),typeof g=="function"&&l[R].push(g)}),o.state&&Object.keys(o.state).forEach(R=>{R in s&&I(`Zum.addComponents: state key "${R}" overrides an earlier value.`),s[R]=o.state[R]}),o.props&&Object.assign(i,o.props),typeof o.onMount=="function"&&d.push(o.onMount),typeof o.onDestroy=="function"&&m.push(o.onDestroy),typeof o.onUpdate=="function"&&v.push(o.onUpdate),typeof o.onRefresh=="function"&&f.push(o.onRefresh),typeof o.css=="string"&&o.css.trim()&&h.push(`/* --- Component ${x+1}: ${o.tag||"div"} --- */
|
|
14
|
+
${o.css}`),typeof o.script=="function"?_.push(o.script):typeof o.script=="string"&&o.script.trim()&&_.push(new Function("state",o.script));let C={...o};delete C.events,delete C.state,delete C.onMount,delete C.onDestroy,delete C.onUpdate,delete C.onRefresh,c.push(n.create(o.tag||"div",C))});let P={};Object.entries(l).forEach(([o,x])=>{P[o]=function(C){x.forEach(R=>{try{R.call(this,C)}catch(g){E(`addComponent event (${o}):`,g)}})}});let b=function(){d.forEach(o=>{try{o.call(this)}catch(x){E(x)}})},$=function(){m.forEach(o=>{try{o.call(this)}catch(x){E(x)}})},z=function(o){v.forEach(x=>{try{x.call(this,o)}catch(C){E(C)}})},D=function(){f.forEach(o=>{try{o.call(this)}catch(x){E(x)}})},N=n.create("div",{children:c,props:i,state:s,events:P,css:h.join(`
|
|
15
|
+
|
|
16
|
+
`),script:_.length>0?function(){_.forEach(o=>{try{o.call(this,this.__state)}catch(x){E("addComponent script:",x)}})}:null,onMount:d.length>0?b:null,onDestroy:m.length>0?$:null,onUpdate:v.length>0?z:null,onRefresh:f.length>0?D:null,style:{display:"contents"}});r.appendChild(N),r.__combinedComponent=N,r.__childCount=c.length;let H={...s};return r.__state=new Proxy(H,{set:(o,x,C)=>{if(o[x]=C,r.__innerState&&r.__innerState[x]!==C)try{r.__innerState[x]=C}catch(R){E(R)}return!0},get:(o,x)=>o[x]}),setTimeout(()=>{let o=N.firstElementChild;o&&o.__state&&(r.__innerState=o.__state,Object.keys(o.__state).forEach(x=>{x in H||(H[x]=o.__state[x])}))},0),M(`\u2705 addComponents: combined ${c.length} components`),r}static createList(e,t){return n.create("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.map(a=>t(a))})}static setAttributeComp(e,t={}){let a=e.__isShadowHost?e:e.__hostElement||e;!a||!(a instanceof HTMLElement)||Object.entries(t).forEach(([r,s])=>a.setAttribute(r,s))}static destroy(e){if(!e)return;e.__isDestroyed=!0;let t=a=>{try{a()}catch(r){E("Zum.destroy cleanup error:",r)}};t(()=>{e.__destroyMany&&e.__destroyMany()}),t(()=>{e.__cleanupResize&&e.__cleanupResize()}),t(()=>{e.__zumAnimObservers&&(e.__zumAnimObservers.forEach(a=>{try{a.disconnect()}catch(r){}}),e.__zumAnimObservers.length=0)}),t(()=>{if(e.__websocket){try{e.__websocket.close(1e3,"destroyed")}catch(a){}e.__websocketDestroyed=!0}}),t(()=>{e.__debouncedSave&&e.__debouncedSave.cancel&&e.__debouncedSave.cancel()}),t(()=>{if(e.__state)try{Object.freeze(e.__state)}catch(a){}e.__stateWatchers&&Object.keys(e.__stateWatchers).forEach(a=>{e.__stateWatchers[a].length=0}),e.__onUpdate=null,e.__onMount=null}),t(()=>{e.__onDestroy&&e.__onDestroy.call(e)}),t(()=>{e.__ZumCss&&e.__ZumCss.parentNode&&e.__ZumCss.parentNode.removeChild(e.__ZumCss)}),t(()=>{let a=e.__hostElement||e;a&&a.parentNode&&a.parentNode.removeChild(a)})}static isMounted(e){return e.__isMounted===!0}static triggerUpdate(e,t={}){e.__onUpdate&&e.__isMounted&&e.__onUpdate.call(e,t)}static triggerRefresh(e){let t=e;if(e.style&&e.style.display==="contents"&&e.children.length>0)for(let a of e.children){if(a.__onRefresh){t=a;break}if(a.__shadowRoot){for(let r of a.__shadowRoot.children)if(r.__onRefresh){t=r;break}if(t!==e)break}}if(t.__onRefresh&&typeof t.__onRefresh=="function")try{t.__onRefresh.call(t)}catch(a){E("\u274C onRefresh failed:",a)}}static async triggerRestore(){n._hasRestored=!1,sessionStorage.removeItem("__Zum_loaded"),sessionStorage.removeItem("__Zum_refreshing"),await new n("div",{html:"<div></div>"})._checkAndRestore()}static getKey(){return localStorage.getItem("app-name")}static popLastComponent(){let e=n.getKey();try{let t=localStorage.getItem(e);if(!t)return null;let a=JSON.parse(t);if(!Array.isArray(a)||a.length===0)return null;let r=a.pop();return a.length===0?localStorage.removeItem(e):localStorage.setItem(e,JSON.stringify(a)),r}catch(t){return E("\u274C Error popping component:",t),null}}static saveComponent(e,t){let a=n.getKey();if(!a)return;let r=t;if(t.style&&t.style.display==="contents"&&t.children.length>0)for(let l of t.children){if(l.__ZumComponent){r=l;break}if(l.__shadowRoot){for(let d of l.__shadowRoot.children)if(d.__ZumComponent){r=d;break}if(r!==t)break}if(l.__isShadowHost){r=l;break}}if(!r.__ZumComponent&&r.querySelector){let l=r.querySelector("[__ZumComponent]");l!=null&&l.__ZumComponent&&(r=l)}if(!r.__ZumComponent){E("\u274C Cannot save component: no __ZumComponent found");return}let s=r.__ZumComponent.options,i={};r.__state&&Object.keys(r.__state).forEach(l=>{i[l]=r.__state[l]});let c={name:e,tag:r.__ZumComponent.tag,html:s.html,css:s.css,script:s.script?s.script.toString():null,onRefresh:s.onRefresh?s.onRefresh.toString():null,props:s.props||{},state:i};try{let l=JSON.parse(localStorage.getItem(a))||[];l=l.filter(d=>d.name!==e),l.push(c),localStorage.setItem(a,JSON.stringify(l)),M(`\u2705 Saved component: ${e}`)}catch(l){E("\u274C Failed to save component:",l)}}static async restoreComponents(){let e=n.getKey();if(!e)return[];try{let t=JSON.parse(localStorage.getItem(e));if(!t||t.length===0)return M("\u2139\uFE0F No components to restore"),[];M(`\u{1F504} Restoring ${t.length} components...`);let a=[];for(let r=0;r<t.length;r++){let s=t[r],i=null,c=null;if(s.script)try{i=new Function("return "+s.script)(),typeof i!="function"&&(I("\u26A0\uFE0F Restored script is not a function for:",s.name),i=null)}catch(d){E("\u274C Failed to restore script:",d)}if(s.onRefresh)try{c=new Function("return "+s.onRefresh)()}catch(d){E("\u274C Failed to restore onRefresh:",d)}let l=n.create(s.tag,{html:s.html,css:s.css,script:i,onRefresh:c,props:s.props||{},state:s.state||{}});if(i&&typeof i=="function"){let d=l;if(l.style&&l.style.display==="contents"&&l.children.length>0)for(let m of l.children){if(m.__ZumComponent){d=m;break}if(m.__shadowRoot){for(let v of m.__shadowRoot.children)if(v.__ZumComponent){d=v;break}if(d!==l)break}}setTimeout(()=>{try{i.call(d,d.__state)}catch(m){E("\u274C Script execution failed:",s.name,m)}},20)}a.push(l)}return M(`\u2705 Successfully restored ${a.length} components`),a}catch(t){return E("\u274C Failed to restore components:",t),[]}}static wipeConfigs(){let e=n.getKey();try{e&&localStorage.removeItem(e),M("All Zum component configs wiped")}catch(t){E("\u274C Failed to wipe configs:",t)}}static clearComponents(){let e=n.getKey();e&&(localStorage.removeItem(e),M("\u{1F5D1}\uFE0F Component configs cleared"))}async _checkAndRestore(){if(!n._hasRestored)try{let e=n.getKey();if(!e){n._hasRestored=!0;return}let t=localStorage.getItem(e);if(!t){n._hasRestored=!0;return}let a=JSON.parse(t);if(!Array.isArray(a)||a.length===0){n._hasRestored=!0;return}await n.restoreComponents(),n._hasRestored=!0}catch(e){E("\u274C Error during restore:",e),n._hasRestored=!0}}static createSkeleton(e=n.SKELETON_TYPES.DEFAULT,t,a={}){let r={...n.DEFAULT_SKELETON_OPTIONS,...a},s=n._getSkeletonTemplate(e,r.count),i=n.create("div",{className:`skeleton skeleton-${e} ${r.customClass}`.trim(),html:s,attributes:{"data-skeleton":e,role:"status","aria-live":"polite","aria-label":`Loading ${e.replace(/-/g," ")}`},useShadow:!1});return n.mount(i,t),i}static removeSkeleton(e,t={}){var i;let a={...n.REMOVE_SKELETON_OPTIONS,...t},r=n._findSkeletonElement(e,a.selector);if(!r)return(i=a.callback)==null||i.call(a),null;let s=()=>{var l;let c=r.parentNode;c&&c.removeChild(r),(l=a.callback)==null||l.call(a)};if(a.animate&&a.animationType!=="none"){r.style.transition=`all ${a.duration}ms ease-out`,r.style.opacity="0";let c=setTimeout(s,a.duration+a.delay);return{element:r,cancel:()=>{clearTimeout(c),r.style.transition="none",s()}}}return s(),null}static hasSkeleton(e){return!!n._findSkeletonElement(e)}static toggleSkeleton(e,t){let a=n._findSkeletonElement(e);if(!a)return!1;let r=typeof t=="boolean"?t:a.style.display==="none";return a.style.display=r?"":"none",r}static _findSkeletonElement(e,t=".skeleton"){var r;if(!e)return null;if(e.querySelector)return e.querySelector(t);if((r=e.el)!=null&&r.querySelector)return e.el.querySelector(t);let a=n.getShadowRoot(e);return a?a.querySelector(t):null}static _getSkeletonTemplate(e,t){let a={[n.SKELETON_TYPES.DEFAULT]:()=>`
|
|
17
|
+
<div class="skeleton-default" style="padding: 20px;">
|
|
18
|
+
${Array(t).fill(0).map(()=>'<div style="height: 16px; background: #e5e7eb; border-radius: 4px; margin-bottom: 12px; animation: pulse 1.5s infinite;"></div>').join("")}
|
|
19
|
+
</div>
|
|
20
|
+
<style>@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }</style>
|
|
21
|
+
`,[n.SKELETON_TYPES.FEED_PAGE]:()=>`
|
|
22
|
+
<div style="max-width: 600px; margin: 0 auto; padding: 20px;">
|
|
23
|
+
${Array(t||2).fill(0).map(()=>`
|
|
24
|
+
<div style="background: white; border-radius: 8px; padding: 15px; margin-bottom: 15px; box-shadow: 0 1px 3px rgba(0,0,0,0.1);">
|
|
25
|
+
<div style="display: flex; align-items: center; margin-bottom: 10px;">
|
|
26
|
+
<div style="width: 40px; height: 40px; border-radius: 50%; background: #e5e7eb; animation: pulse 1.5s infinite;"></div>
|
|
27
|
+
<div style="margin-left: 10px; flex: 1;">
|
|
28
|
+
<div style="height: 12px; background: #e5e7eb; border-radius: 4px; width: 60%; animation: pulse 1.5s infinite;"></div>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
<div style="height: 200px; background: #e5e7eb; border-radius: 4px; animation: pulse 1.5s infinite;"></div>
|
|
32
|
+
<div style="height: 12px; background: #e5e7eb; border-radius: 4px; margin-top: 10px; width: 80%; animation: pulse 1.5s infinite;"></div>
|
|
33
|
+
</div>
|
|
34
|
+
`).join("")}
|
|
35
|
+
</div>
|
|
36
|
+
<style>@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }</style>
|
|
37
|
+
`,[n.SKELETON_TYPES.PROFILE_PAGE]:()=>`
|
|
38
|
+
<div style="max-width: 800px; margin: 0 auto; padding: 20px;">
|
|
39
|
+
<div style="height: 180px; background: #e5e7eb; border-radius: 8px; animation: pulse 1.5s infinite;"></div>
|
|
40
|
+
<div style="width: 100px; height: 100px; border-radius: 50%; background: #e5e7eb; margin: -50px auto 0; border: 4px solid white; animation: pulse 1.5s infinite;"></div>
|
|
41
|
+
<div style="height: 16px; background: #e5e7eb; border-radius: 4px; width: 40%; margin: 20px auto; animation: pulse 1.5s infinite;"></div>
|
|
42
|
+
<div style="height: 12px; background: #e5e7eb; border-radius: 4px; width: 80%; margin: 10px auto; animation: pulse 1.5s infinite;"></div>
|
|
43
|
+
</div>
|
|
44
|
+
<style>@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }</style>
|
|
45
|
+
`,[n.SKELETON_TYPES.CHAT_PAGE]:()=>`
|
|
46
|
+
<div style="max-width: 600px; margin: 0 auto; padding: 20px;">
|
|
47
|
+
${Array(t).fill(0).map(()=>`
|
|
48
|
+
<div style="display: flex; align-items: center; padding: 10px; border-bottom: 1px solid #f0f0f0;">
|
|
49
|
+
<div style="width: 48px; height: 48px; border-radius: 50%; background: #e5e7eb; animation: pulse 1.5s infinite;"></div>
|
|
50
|
+
<div style="margin-left: 10px; flex: 1;">
|
|
51
|
+
<div style="height: 12px; background: #e5e7eb; border-radius: 4px; width: 60%; animation: pulse 1.5s infinite;"></div>
|
|
52
|
+
<div style="height: 8px; background: #e5e7eb; border-radius: 4px; width: 40%; margin-top: 5px; animation: pulse 1.5s infinite;"></div>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
`).join("")}
|
|
56
|
+
</div>
|
|
57
|
+
<style>@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }</style>
|
|
58
|
+
`,[n.SKELETON_TYPES.CHAT_DETAIL_PAGE]:()=>`
|
|
59
|
+
<div style="max-width: 800px; margin: 0 auto; padding: 20px;">
|
|
60
|
+
${Array(5).fill(0).map((r,s)=>`
|
|
61
|
+
<div style="display: flex; ${s%2===0?"justify-content: flex-end;":"justify-content: flex-start;"} margin-bottom: 15px;">
|
|
62
|
+
<div style="height: 40px; background: #e5e7eb; border-radius: 16px; width: 60%; animation: pulse 1.5s infinite;"></div>
|
|
63
|
+
</div>
|
|
64
|
+
`).join("")}
|
|
65
|
+
</div>
|
|
66
|
+
<style>@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }</style>
|
|
67
|
+
`,[n.SKELETON_TYPES.SERVICE_PAGE]:()=>`
|
|
68
|
+
<div style="max-width: 800px; margin: 0 auto; padding: 20px;">
|
|
69
|
+
<div style="height: 200px; background: #e5e7eb; border-radius: 8px; animation: pulse 1.5s infinite;"></div>
|
|
70
|
+
<div style="display: flex; align-items: center; margin-top: 15px;">
|
|
71
|
+
<div style="width: 80px; height: 80px; background: #e5e7eb; border-radius: 8px; animation: pulse 1.5s infinite;"></div>
|
|
72
|
+
<div style="margin-left: 15px; flex: 1;">
|
|
73
|
+
<div style="height: 16px; background: #e5e7eb; border-radius: 4px; width: 40%; animation: pulse 1.5s infinite;"></div>
|
|
74
|
+
<div style="height: 12px; background: #e5e7eb; border-radius: 4px; width: 90%; margin-top: 8px; animation: pulse 1.5s infinite;"></div>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
<style>@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }</style>
|
|
79
|
+
`,[n.SKELETON_TYPES.DASHBOARD_PAGE]:()=>`
|
|
80
|
+
<div style="max-width: 1200px; margin: 0 auto; padding: 20px;">
|
|
81
|
+
<div style="height: 24px; background: #e5e7eb; border-radius: 4px; width: 30%; margin-bottom: 20px; animation: pulse 1.5s infinite;"></div>
|
|
82
|
+
<div style="display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; margin-bottom: 20px;">
|
|
83
|
+
${Array(4).fill(0).map(()=>`
|
|
84
|
+
<div style="background: white; padding: 15px; border-radius: 8px;">
|
|
85
|
+
<div style="height: 12px; background: #e5e7eb; border-radius: 4px; width: 50%; animation: pulse 1.5s infinite;"></div>
|
|
86
|
+
<div style="height: 24px; background: #e5e7eb; border-radius: 4px; width: 40%; margin-top: 10px; animation: pulse 1.5s infinite;"></div>
|
|
87
|
+
</div>
|
|
88
|
+
`).join("")}
|
|
89
|
+
</div>
|
|
90
|
+
<div style="height: 200px; background: #e5e7eb; border-radius: 8px; animation: pulse 1.5s infinite;"></div>
|
|
91
|
+
</div>
|
|
92
|
+
<style>@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }</style>
|
|
93
|
+
`,[n.SKELETON_TYPES.SETTINGS_PAGE]:()=>`
|
|
94
|
+
<div style="max-width: 600px; margin: 0 auto; padding: 20px;">
|
|
95
|
+
<div style="height: 24px; background: #e5e7eb; border-radius: 4px; width: 40%; margin-bottom: 20px; animation: pulse 1.5s infinite;"></div>
|
|
96
|
+
${Array(3).fill(0).map(()=>`
|
|
97
|
+
<div style="background: white; padding: 15px; border-radius: 8px; margin-bottom: 10px;">
|
|
98
|
+
<div style="display: flex; justify-content: space-between;">
|
|
99
|
+
<div style="height: 12px; background: #e5e7eb; border-radius: 4px; width: 40%; animation: pulse 1.5s infinite;"></div>
|
|
100
|
+
<div style="width: 48px; height: 24px; background: #e5e7eb; border-radius: 12px; animation: pulse 1.5s infinite;"></div>
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
`).join("")}
|
|
104
|
+
</div>
|
|
105
|
+
<style>@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }</style>
|
|
106
|
+
`,[n.SKELETON_TYPES.SEARCH_PAGE]:()=>`
|
|
107
|
+
<div style="max-width: 600px; margin: 0 auto; padding: 20px;">
|
|
108
|
+
<div style="height: 40px; background: #e5e7eb; border-radius: 20px; margin-bottom: 20px; animation: pulse 1.5s infinite;"></div>
|
|
109
|
+
${Array(4).fill(0).map(()=>`
|
|
110
|
+
<div style="display: flex; align-items: center; padding: 10px; border-bottom: 1px solid #f0f0f0;">
|
|
111
|
+
<div style="width: 60px; height: 60px; background: #e5e7eb; border-radius: 8px; animation: pulse 1.5s infinite;"></div>
|
|
112
|
+
<div style="margin-left: 10px; flex: 1;">
|
|
113
|
+
<div style="height: 12px; background: #e5e7eb; border-radius: 4px; width: 80%; animation: pulse 1.5s infinite;"></div>
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
`).join("")}
|
|
117
|
+
</div>
|
|
118
|
+
<style>@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }</style>
|
|
119
|
+
`,[n.SKELETON_TYPES.PRODUCT_GRID]:()=>`
|
|
120
|
+
<div style="max-width: 1200px; margin: 0 auto; padding: 20px;">
|
|
121
|
+
<div style="display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 15px;">
|
|
122
|
+
${Array(t).fill(0).map(()=>`
|
|
123
|
+
<div style="background: white; border-radius: 8px; overflow: hidden;">
|
|
124
|
+
<div style="height: 120px; background: #e5e7eb; animation: pulse 1.5s infinite;"></div>
|
|
125
|
+
<div style="padding: 10px;">
|
|
126
|
+
<div style="height: 10px; background: #e5e7eb; border-radius: 4px; width: 80%; animation: pulse 1.5s infinite;"></div>
|
|
127
|
+
<div style="height: 10px; background: #e5e7eb; border-radius: 4px; width: 50%; margin-top: 5px; animation: pulse 1.5s infinite;"></div>
|
|
128
|
+
</div>
|
|
129
|
+
</div>
|
|
130
|
+
`).join("")}
|
|
131
|
+
</div>
|
|
132
|
+
</div>
|
|
133
|
+
<style>@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }</style>
|
|
134
|
+
`,[n.SKELETON_TYPES.NOTIFICATIONS_PAGE]:()=>`
|
|
135
|
+
<div style="max-width: 600px; margin: 0 auto; padding: 20px;">
|
|
136
|
+
${Array(t).fill(0).map(()=>`
|
|
137
|
+
<div style="display: flex; align-items: flex-start; padding: 15px; border-bottom: 1px solid #f0f0f0;">
|
|
138
|
+
<div style="width: 40px; height: 40px; border-radius: 50%; background: #e5e7eb; animation: pulse 1.5s infinite;"></div>
|
|
139
|
+
<div style="margin-left: 10px; flex: 1;">
|
|
140
|
+
<div style="height: 12px; background: #e5e7eb; border-radius: 4px; width: 90%; animation: pulse 1.5s infinite;"></div>
|
|
141
|
+
<div style="height: 8px; background: #e5e7eb; border-radius: 4px; width: 60%; margin-top: 5px; animation: pulse 1.5s infinite;"></div>
|
|
142
|
+
</div>
|
|
143
|
+
</div>
|
|
144
|
+
`).join("")}
|
|
145
|
+
</div>
|
|
146
|
+
<style>@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }</style>
|
|
147
|
+
`,[n.SKELETON_TYPES.FORM_PAGE]:()=>`
|
|
148
|
+
<div style="max-width: 500px; margin: 0 auto; padding: 20px;">
|
|
149
|
+
${Array(5).fill(0).map(()=>`
|
|
150
|
+
<div style="margin-bottom: 20px;">
|
|
151
|
+
<div style="height: 10px; background: #e5e7eb; border-radius: 4px; width: 30%; margin-bottom: 8px; animation: pulse 1.5s infinite;"></div>
|
|
152
|
+
<div style="height: 48px; background: #e5e7eb; border-radius: 8px; animation: pulse 1.5s infinite;"></div>
|
|
153
|
+
</div>
|
|
154
|
+
`).join("")}
|
|
155
|
+
<div style="height: 120px; background: #e5e7eb; border-radius: 8px; animation: pulse 1.5s infinite;"></div>
|
|
156
|
+
</div>
|
|
157
|
+
<style>@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }</style>
|
|
158
|
+
`};return(a[e]||a[n.SKELETON_TYPES.DEFAULT])(t)}static createSpinner(e="Loading...",t){let a=n.create("div",{html:`<div class="spinner-container"><div class="spinner-circle"></div><div class="spinner-text">${e}</div></div>`,css:".spinner-container{display:flex;flex-direction:column;justify-content:center;align-items:center;padding:20px;color:#555;gap:8px}.spinner-circle{width:40px;height:40px;border:4px solid #e0e0e0;border-top:4px solid #007bff;border-radius:50%;animation:spin 1s linear infinite}.spinner-text{font-size:14px;color:#666}@keyframes spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}",useShadow:!1});return n.mount(a,t),a}static createBorderSpinner(e="Loading...",t){t&&t.style&&(t.style.position=t.style.position||"relative");let a=n.create("div",{html:`<div class="border-spinner-overlay"><div class="border-spinner-circle"></div><div class="border-spinner-text">${e}</div></div>`,css:".border-spinner-overlay{position:absolute;top:0;left:0;width:100%;height:100%;display:flex;flex-direction:column;justify-content:center;align-items:center;background:rgba(255,255,255,.7);z-index:1000;pointer-events:none;padding:10px}.border-spinner-circle{position:absolute;top:0;left:0;width:calc(100% - 4px);height:calc(100% - 4px);border:2px solid rgba(0,123,255,.2);border-top:2px solid #007bff;border-radius:4px;box-sizing:border-box;animation:border-spin 1.5s linear infinite}.border-spinner-text{margin-top:50px;font-size:14px;color:#007bff;z-index:1001;background:#fff;padding:2px 5px;border-radius:3px}@keyframes border-spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}",useShadow:!1});return n.mount(a,t),a}static createRingSpinner(e="Loading...",t){t&&t.style&&(t.style.position=t.style.position||"relative");let a=n.create("div",{html:`<div class="ring-spinner-overlay"><div class="ring-spinner-circle"></div><div class="ring-spinner-text">${e}</div></div>`,css:".ring-spinner-overlay{position:absolute;top:0;left:0;width:100%;height:100%;display:flex;flex-direction:column;justify-content:center;align-items:center;background:rgba(255,255,255,.7);z-index:1000;gap:10px}.ring-spinner-circle{width:50px;height:50px;border:6px solid #e0e0e0;border-top:6px solid #007bff;border-radius:50%;animation:spin 1.2s cubic-bezier(.5,0,.5,1) infinite}.ring-spinner-text{font-size:16px;color:#007bff;font-weight:700}@keyframes spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}",useShadow:!1});return n.mount(a,t),a}static createScalingSpinner(e="Loading...",t){t&&t.style&&(t.style.position=t.style.position||"relative");let a=n.create("div",{html:`<div class="scaling-spinner-overlay"><div class="scaling-spinner-container"><div class="scaling-spinner-circle"></div></div><div class="scaling-spinner-text">${e}</div></div>`,css:".scaling-spinner-overlay{position:absolute;top:0;left:0;width:100%;height:100%;display:flex;flex-direction:column;justify-content:center;align-items:center;background:rgba(255,255,255,.7);z-index:1000;gap:10px}.scaling-spinner-container{width:30%;padding-bottom:30%;position:relative;max-width:80px;max-height:80px}.scaling-spinner-circle{position:absolute;top:0;left:0;width:100%;height:100%;border:4px solid #e0e0e0;border-top:4px solid #007bff;border-radius:50%;box-sizing:border-box;animation:spin 1.2s cubic-bezier(.5,0,.5,1) infinite}.scaling-spinner-text{font-size:16px;color:#007bff;font-weight:700}@keyframes spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}",useShadow:!1});return n.mount(a,t),a}static destroySpinner(e){n.destroy(e)}static getShadowRoot(e){return e.shadowRoot||e.__shadowRoot||null}static isShadowHost(e){return!!(e.shadowRoot||e.__isShadowHost||e.__hostElement)}static getAllShadowHosts(){return j()?Array.from(document.querySelectorAll("*")).filter(e=>n.isShadowHost(e)):[]}static queryFromRoot(e,t){if(!e)return null;if(e instanceof ShadowRoot||e===document)return e.querySelector(t);let a=n.getShadowRoot(e);return a?a.querySelector(t):e.querySelector(t)}static queryAllFromRoot(e,t){if(!e)return[];if(e instanceof ShadowRoot||e===document)return e.querySelectorAll(t);let a=n.getShadowRoot(e);return a?a.querySelectorAll(t):e.querySelectorAll(t)}static querySelector(e,t){let a=n.getShadowRoot(e);return a?a.querySelector(t):e.querySelector(t)}static querySelectorAll(e,t){let a=n.getShadowRoot(e);return a?a.querySelectorAll(t):e.querySelectorAll(t)}static find(e){if(!j())return null;let t=null;function a(r){if(!t&&(r.nodeType===Node.ELEMENT_NODE||r.nodeType===Node.DOCUMENT_FRAGMENT_NODE)){if(r.nodeType===Node.ELEMENT_NODE&&r.matches(e)){t=r;return}r.shadowRoot&&a(r.shadowRoot),r.childNodes.forEach(a)}}return a(document.body),t}static findAll(e){if(!j())return[];let t=[];function a(r){r.nodeType===Node.ELEMENT_NODE&&r.matches(e)&&t.push(r),r.nodeType===Node.ELEMENT_NODE&&r.shadowRoot&&a(r.shadowRoot),r.childNodes.forEach(a)}return a(document.body),t}static elementExists(e,t){return!!n.querySelector(e,t)}static getComputedStyle(e,t){let a=n.querySelector(e,t);return a?window.getComputedStyle(a):null}static mount(e,t){if(!e||!t)return null;let a=t instanceof HTMLElement?t:document.querySelector(t);if(!a)return null;let r=e instanceof HTMLElement?e:typeof e=="string"?document.querySelector(e):null;return r?(a.appendChild(r),setTimeout(()=>n._applyContrastToElement(r),50),r):null}static unmount(e,t){if(!e)return null;let a=t?t instanceof HTMLElement?t:document.querySelector(t):e.parentNode;return!a||!a.contains(e)?null:(a.removeChild(e),e)}static append(e,t){return!e||!t?null:((n.getShadowRoot(e)||e).appendChild(t),setTimeout(()=>n._applyContrastToElement(t),50),t)}static addChildren(e,t){if(!e||!(t!=null&&t.length))return;let a=n.getShadowRoot(e)||e;t.forEach(r=>{a.appendChild(r),setTimeout(()=>n._applyContrastToElement(r),50)})}static replaceChild(e,t,a){if(!e||!a)return null;let r=n.querySelector(e,t);return r?(r.parentNode.replaceChild(a,r),setTimeout(()=>n._applyContrastToElement(a),50),a):null}static clone(e,t=!0){if(!e)return null;let a=e;if(e.style&&e.style.display==="contents"&&e.children.length>0)for(let s of e.children){if(s.__ZumComponent){a=s;break}if(s.__shadowRoot||s.__isShadowHost){a=s;break}}return(n.getShadowRoot(a)||a).cloneNode(t)}static show(e){e&&((n.getShadowRoot(e)||e).style.display="")}static hide(e){e&&((n.getShadowRoot(e)||e).style.display="none")}static addEventListener(e,t,a,r){let s=n.querySelector(e,t);s&&(s.addEventListener(a,r),(s.__events||(s.__events=[])).push({event:a,handler:r}))}static removeEventListener(e,t,a,r=null){let s=n.querySelector(e,t);s!=null&&s.__events&&(s.__events=s.__events.filter(i=>i.event===a&&(!r||i.handler===r)?(s.removeEventListener(i.event,i.handler),!1):!0))}static clearEventListeners(e,t){let a=n.querySelector(e,t);a!=null&&a.__events&&(a.__events.forEach(({event:r,handler:s})=>a.removeEventListener(r,s)),a.__events=[])}static on(e,t,a,r){n.addEventListener(e,t,a,r)}static updateContent(e,t,a){let r=n.querySelector(e,t);r&&(r.innerHTML=a),setTimeout(()=>n._applyContrastToElement(r),50)}static updateText(e,t,a){let r=n.querySelector(e,t);r&&(r.textContent=a),setTimeout(()=>n._applyContrastToElement(r),50)}static updateStyles(e,t,a){let r=n.querySelector(e,t);r&&Object.assign(r.style,a)}static updateAttributes(e,t,a){let r=n.querySelector(e,t);r&&Object.entries(a).forEach(([s,i])=>r.setAttribute(s,i))}static bulkUpdateContent(e,t){let a=n.getShadowRoot(e);a&&t.forEach(r=>{let s=n.queryFromRoot(a,r.selector);s&&(r.properties&&Object.assign(s,r.properties),r.attributes&&Object.entries(r.attributes).forEach(([i,c])=>s.setAttribute(i,c)),r.styles&&Object.assign(s.style,r.styles),r.html&&(s.innerHTML=r.html),r.text&&(s.textContent=r.text))})}static addElement(e,t,a,r={}){let s=n.getShadowRoot(e);if(!s)return null;let i=t?n.queryFromRoot(s,t):s;if(!i)return null;let c=document.createElement(a);return r.text&&(c.textContent=r.text),r.html&&(c.innerHTML=r.html),r.className&&(c.className=r.className),r.style&&Object.assign(c.style,r.style),r.attributes&&Object.entries(r.attributes).forEach(([l,d])=>c.setAttribute(l,d)),i.appendChild(c),setTimeout(()=>n._applyContrastToElement(c),50),c}static removeElement(e,t){let a=n.querySelector(e,t);a!=null&&a.parentNode&&a.parentNode.removeChild(a)}static toggleClass(e,t,a,r){let s=n.querySelector(e,t);s&&s.classList.toggle(a,r)}static data(e,t,a,r){let s=n.querySelector(e,t);return s?r===void 0?s.dataset[a]||null:(s.dataset[a]=r,null):null}static text(e,t,a){let r=n.querySelector(e,t);r&&(r.textContent=a),setTimeout(()=>n._applyContrastToElement(r),50)}static html(e,t,a){let r=n.querySelector(e,t);r&&(r.innerHTML=a),setTimeout(()=>n._applyContrastToElement(r),50)}static css(e,t,a){let r=n.querySelector(e,t);r&&Object.assign(r.style,a)}static attr(e,t,a){let r=n.querySelector(e,t);r&&Object.entries(a).forEach(([s,i])=>r.setAttribute(s,i))}static destroyWidget(e){var t,a;(t=e.__swiper)!=null&&t.destroy&&e.__swiper.destroy(),(a=e.__chart)!=null&&a.destroy&&e.__chart.destroy(),e.__quill=e.__swiper=e.__chart=null}static getState(e){let t=e;if(e.style&&e.style.display==="contents"&&e.children.length>0)for(let a of e.children){if(a.__state){t=a;break}if(a.__shadowRoot){for(let r of a.__shadowRoot.children)if(r.__state){t=r;break}if(t!==e)break}}return t!=null&&t.__state?t.__state:(I("No state found on element"),null)}static setState(e,t,a={}){if(!(e!=null&&e.__state))return;let{deep:r=!1}=a;if(!r){Object.assign(e.__state,t);return}let s=(c,l)=>{Object.keys(l).forEach(d=>{let m=l[d];m&&typeof m=="object"&&!Array.isArray(m)?((!c[d]||typeof c[d]!="object")&&(c[d]={}),s(c[d],m)):c[d]=m})},i=JSON.parse(JSON.stringify({...e.__state}));s(i,t),Object.assign(e.__state,i)}static watchState(e,t,a){let r=e;if(e.style&&e.style.display==="contents"&&e.children.length>0)for(let s of e.children){if(s.__state){r=s;break}if(s.__shadowRoot){for(let i of s.__shadowRoot.children)if(i.__state){r=i;break}if(r!==e)break}}if(!(r!=null&&r.__state)){I("No state found on element");return}r.__stateWatchers||(r.__stateWatchers={}),r.__stateWatchers[t]||(r.__stateWatchers[t]=[]),r.__stateWatchers[t].push(a)}static async fetch(e,t={}){let{url:a=null,method:r="GET",headers:s={},body:i=null,cacheFirst:c=!0,localChanges:l=!0,diff:d=!0,diffIdKey:m="id",autoRefresh:v=0,onDiff:f=null,onSuccess:h=null,onError:_=null,_customFetch:P=null,pagination:b=!1,pageSize:$=10,initialPage:z=1,pageParam:D="page",sizeParam:N="limit",dataPath:H=null}=t;n._fetchCache||(n._fetchCache=new Map,n._loadFetchCache()),n._fetchCache.has(e)||n._fetchCache.set(e,{serverData:null,localChanges:{},lastFetch:null,subscribers:[],previousData:null,pages:new Map,paginationMeta:null});let o=n._fetchCache.get(e),x=p=>H?H.split(".").reduce((y,S)=>y==null?void 0:y[S],p):Array.isArray(p)?p:p.data||p.items||p.posts||p.results||[p],C=p=>p.pagination?p.pagination:p.meta?p.meta:{page:p.page||1,totalPages:p.totalPages||p.total_pages||1,total:p.total||p.totalItems||0,pageSize:p.pageSize||p.per_page||$},R=p=>{if(!a)return null;let y=a.replace(`{${D}}`,p).replace(`{${N}}`,$);if(!a.includes("{")){let S=a.includes("?")?"&":"?";y=`${a}${S}${D}=${p}&${N}=${$}`}return y},g=async p=>{if(b&&o.pages.has(p))return o.paginationMeta.currentPage=p,o.pages.get(p);let y;if(P)y=await P(p);else if(a){let Z=R(p),q={method:r,headers:{"Content-Type":"application/json",...s}};i&&(q.body=JSON.stringify(i));let L=await fetch(Z,q);if(!L.ok)throw new Error(`HTTP ${L.status}`);y=await L.json()}else throw new Error("No url or _customFetch");let S=x(y),k=C(y);return b&&(o.pages.set(p,S),o.paginationMeta={...k,currentPage:p,pageSize:$,hasNext:p<k.totalPages,hasPrev:p>1}),S},u={data:null,loading:!0,error:null,lastFetch:null,hasLocalChanges:Object.keys(o.localChanges).length>0,diff:{summary:{added:0,updated:0,deleted:0,unchanged:0,total:0,hasChanges:!1},added:[],updated:[],deleted:[],unchanged:[]},pagination:b?{currentPage:z,totalPages:1,totalItems:0,pageSize:$,hasNext:!1,hasPrev:!1,cachedPages:[]}:null,nextPage:b?async()=>{var p;if(u.pagination.hasNext){u.loading=!0,O();try{let y=await g(u.pagination.currentPage+1);u.data=y,u.pagination.currentPage++,u.pagination.hasPrev=!0,u.pagination.hasNext=((p=o.paginationMeta)==null?void 0:p.hasNext)||!1,u.pagination.cachedPages=Array.from(o.pages.keys()),u.lastFetch=Date.now()}catch(y){u.error=y.message}u.loading=!1,O()}}:null,prevPage:b?async()=>{var p;if(u.pagination.hasPrev){u.loading=!0,O();try{let y=await g(u.pagination.currentPage-1);u.data=y,u.pagination.currentPage--,u.pagination.hasNext=!0,u.pagination.hasPrev=((p=o.paginationMeta)==null?void 0:p.hasPrev)||u.pagination.currentPage>1,u.pagination.cachedPages=Array.from(o.pages.keys()),u.lastFetch=Date.now()}catch(y){u.error=y.message}u.loading=!1,O()}}:null,goToPage:b?async p=>{var y;u.loading=!0,O();try{let S=await g(p);u.data=S,u.pagination.currentPage=p,u.pagination.hasPrev=p>1,u.pagination.hasNext=((y=o.paginationMeta)==null?void 0:y.hasNext)||!1,u.pagination.cachedPages=Array.from(o.pages.keys()),u.lastFetch=Date.now()}catch(S){u.error=S.message}u.loading=!1,O()}:null,refresh:async()=>{var p;u.loading=!0,u.error=null,O();try{let y=b&&((p=u.pagination)==null?void 0:p.currentPage)||1,S;if(b)o.pages.delete(y),S=await g(y);else{if(P)S=await P();else if(a){let k=await fetch(a,{method:r,headers:s});if(!k.ok)throw new Error(`HTTP ${k.status}`);S=await k.json()}S=x(S)}if(d&&o.previousData){let k=n._differ.diff(o.previousData,S,m);k?(u.diff={summary:k.summary,added:k.added,updated:k.updated,deleted:k.deleted,unchanged:k.unchanged},u.data=k.all,f&&f(u.diff)):u.data=S}else u.data=S;o.previousData=JSON.parse(JSON.stringify(S)),o.serverData=S,o.lastFetch=Date.now(),u.lastFetch=o.lastFetch,l&&o.localChanges&&u.data&&(u.data=u.data.map(k=>{let Z=k[m],q=o.localChanges[Z];return q?{...k,...q,__localEdit:!0}:k})),u.hasLocalChanges=Object.keys(o.localChanges).length>0,u.loading=!1,h&&h(u.data)}catch(y){u.error=y.message,u.loading=!1,_&&_(y)}O()},updateItem:(p,y)=>{if(o.localChanges[p]||(o.localChanges[p]={}),Object.assign(o.localChanges[p],y),u.data){let S=u.data.find(k=>k[m]==p);S&&Object.assign(S,y)}u.hasLocalChanges=!0,O(),n._saveFetchCache()},revertItem:p=>{var S;delete o.localChanges[p];let y=(S=o.serverData)==null?void 0:S.find(k=>k[m]==p);if(y&&u.data){let k=u.data.findIndex(Z=>Z[m]==p);k>=0&&(u.data[k]={...y})}u.hasLocalChanges=Object.keys(o.localChanges).length>0,O(),n._saveFetchCache()},syncToServer:async(p=null)=>{let y=p||a;try{(await fetch(y,{method:"PATCH",headers:{"Content-Type":"application/json",...s},body:JSON.stringify({changes:{...o.localChanges}})})).ok&&(o.localChanges={},u.hasLocalChanges=!1,O(),n._saveFetchCache())}catch(S){E("Sync failed:",S)}},subscribe:p=>(o.subscribers.push(p),()=>{o.subscribers=o.subscribers.filter(y=>y!==p)})};function O(){o.subscribers.forEach(p=>p(u))}if(b){u.loading=!0,O();try{let p=await g(z);u.data=p,u.pagination={...o.paginationMeta,cachedPages:Array.from(o.pages.keys())},u.lastFetch=Date.now()}catch(p){u.error=p.message}u.loading=!1,O()}else c&&o.serverData&&(u.data=o.serverData.map(p=>{var S;let y=(S=o.localChanges)==null?void 0:S[p[m]];return y?{...p,...y,__localEdit:!0}:p}),u.loading=!1,u.lastFetch=o.lastFetch,u.hasLocalChanges=Object.keys(o.localChanges).length>0,u.diff.summary.total=u.data.length),await u.refresh();if(v>0){let p=setInterval(()=>u.refresh(),v);u._autoRefreshInterval=p}return u._saveCache=()=>n._saveFetchCache(),u}static _saveFetchCache(){if(!n._fetchCache)return;let e={};n._fetchCache.forEach((t,a)=>{e[a]={serverData:t.serverData,localChanges:t.localChanges,lastFetch:t.lastFetch,previousData:t.previousData}});try{localStorage.setItem("__Zum_fetch_cache",JSON.stringify(e))}catch(t){}}static _loadFetchCache(){try{let e=localStorage.getItem("__Zum_fetch_cache");if(e){let t=JSON.parse(e);Object.entries(t).forEach(([a,r])=>n._fetchCache.set(a,r))}}catch(e){}}static _initFetchCache(){n._fetchCache||(n._fetchCache=new Map,n._loadFetchCache())}static clearFetchCache(){localStorage.removeItem("__Zum_fetch_cache"),n._fetchCache&&n._fetchCache.clear(),M("\u{1F5D1}\uFE0F Fetch cache cleared")}static rememberScroll(e,t={}){let{scrollBehavior:a="smooth",scope:r="global",saveDelay:s=200,highlightTarget:i=!0,offsetTop:c=0}=t,l=`${r}::${e}`,d,m=0,v=null,f=n._scrollMemory.get(l);return f&&(m=f.position||0,v=f.elementId||null),{save:function(h=null){m=window.scrollY||window.pageYOffset,h&&(v=h),n._scrollMemory.set(l,{position:m,elementId:v,timestamp:Date.now()})},restore:function(){let h=n._scrollMemory.get(l);if(!h)return!1;let{position:_,elementId:P}=h;if(P){let b=document.getElementById(P);if(b){let $=b.getBoundingClientRect(),z=window.pageYOffset||document.documentElement.scrollTop,D=$.top+z,N=window.innerHeight,H=D-N/2+$.height/2+c;if(window.scrollTo({top:Math.max(0,H),behavior:a}),i){let o=b.style.transition,x=b.style.boxShadow,C=b.style.borderColor;b.style.transition="box-shadow 0.3s, border-color 0.3s",b.style.boxShadow="0 0 0 4px rgba(59, 130, 246, 0.5)",b.style.borderColor="#3b82f6",setTimeout(()=>{b.style.transition=o,b.style.boxShadow=x,b.style.borderColor=C},2e3)}return!0}}return _>0?(window.scrollTo({top:_,behavior:a}),!0):!1},startTracking:function(h=document){let _=()=>{clearTimeout(d),d=setTimeout(()=>this.save(),s)};window.addEventListener("scroll",_,{passive:!0});let P=$=>{let z=$.target.closest("[id]");z&&z.id&&this.save(z.id)};h.addEventListener("click",P);let b=()=>this.save();return window.addEventListener("beforeunload",b),()=>{window.removeEventListener("scroll",_),h.removeEventListener("click",P),window.removeEventListener("beforeunload",b)}},clear:function(){n._scrollMemory.delete(l),m=0,v=null},getData:function(){return n._scrollMemory.get(l)||null}}}static saveScrollToState(e,t=null){let a=n.getState(e);a&&(a.__scrollPosition=window.scrollY||window.pageYOffset,t&&(a.__lastFocusedElement=t))}static restoreScrollFromState(e,t={}){let a=n.getState(e);if(!a)return!1;let{highlightTarget:r=!0,scrollBehavior:s="smooth",offsetTop:i=0}=t,c=a.__scrollPosition,l=a.__lastFocusedElement;if(l){let d=n.querySelector(e,`#${l}`)||document.getElementById(l);if(d){let m=d.getBoundingClientRect(),v=window.pageYOffset||document.documentElement.scrollTop,f=m.top+v,h=window.innerHeight,_=f-h/2+m.height/2+i;return window.scrollTo({top:Math.max(0,_),behavior:s}),r&&(d.style.transition="box-shadow 0.3s, border-color 0.3s",d.style.boxShadow="0 0 0 4px rgba(59, 130, 246, 0.5)",d.style.borderColor="#3b82f6",setTimeout(()=>{d.style.boxShadow="",d.style.borderColor=""},2e3)),!0}}return c>0?(window.scrollTo({top:c,behavior:s}),!0):!1}static initTheme(e="light"){return n._themeStylesInjected||n._injectThemeStyles(),n.THEMES[e]?(n._currentTheme=e,n.applyTheme(e),!0):(I(`Theme "${e}" not found. Using light theme.`),n._currentTheme="light",n.applyTheme("light"),!1)}static restoreThemePreference(){let e=localStorage.getItem(n.themeSettings.persistKey);if(e&&n.THEMES[e])return n.applyTheme(e,{manual:!1}),!0;if(n.themeSettings.respectSystemPreference){let t=n.getSystemThemePreference();return n.applyTheme(t,{manual:!1}),!0}return!1}static getSystemThemePreference(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}static initThemeWithSystemPreference(){let e=localStorage.getItem(n.themeSettings.persistKey),t=localStorage.getItem(n.themeSettings.systemPreferenceKey);if(e&&t&&n.THEMES[e]){n.applyTheme(e,{manual:!0}),M(`\u2705 Theme initialized with manual preference: ${e}`);return}let a=n.getSystemThemePreference();n.applyTheme(a,{manual:!1});let r=window.matchMedia("(prefers-color-scheme: dark)"),s=i=>{if(!localStorage.getItem(n.themeSettings.systemPreferenceKey)){let l=i.matches?"dark":"light";document.querySelectorAll("*").forEach(d=>{d._zumContrastApplied=!1}),n.applyTheme(l,{manual:!1,smooth:!0,duration:400}),setTimeout(()=>n.refreshContrast(),500),M(`\u{1F504} Auto-switched to ${l} theme (system preference)`)}};r.addEventListener?r.addEventListener("change",s):r.addListener&&r.addListener(s),M(`\u2705 Theme initialized with system preference: ${a}`)}static isUsingSystemTheme(){return!localStorage.getItem(n.themeSettings.systemPreferenceKey)}static resetToSystemTheme(){localStorage.removeItem(n.themeSettings.systemPreferenceKey);let e=n.getSystemThemePreference();n.applyTheme(e,{manual:!1}),M(`\u{1F504} Reset to system theme: ${e}`)}static applyTheme(e,t={}){if(!j())return!1;let{smooth:a=!0,duration:r=400,ease:s="ease-in-out",updateContrast:i=!0,manual:c=!0}=t,l=n.THEMES[e];if(!l)return I(`Theme "${e}" not found.`),!1;n._currentTheme=e,c?localStorage.setItem(n.themeSettings.systemPreferenceKey,"true"):localStorage.removeItem(n.themeSettings.systemPreferenceKey);let d=document.documentElement,m=l.colors;document.querySelectorAll("style[data-Zum-themes], style[data-Zum-theme]").forEach(f=>f.remove()),n._injectThemeStyles(),Object.entries(m).forEach(([f,h])=>d.style.setProperty(`--Zum-${f}`,h)),Object.entries(l.typography).forEach(([f,h])=>d.style.setProperty(`--Zum-font-${f}`,h)),Object.entries(l.spacing).forEach(([f,h])=>d.style.setProperty(`--Zum-spacing-${f}`,h)),Object.entries(l.borderRadius).forEach(([f,h])=>d.style.setProperty(`--Zum-radius-${f}`,h)),Object.entries(l.shadows).forEach(([f,h])=>d.style.setProperty(`--Zum-shadow-${f}`,h)),Object.entries(l.transitions).forEach(([f,h])=>d.style.setProperty(`--Zum-transition-${f}`,h)),document.body.style.backgroundColor=m.background,document.body.style.color=m.text,document.body.style.fontFamily=l.typography.fontFamily,document.body.style.fontSize=l.typography.fontSize,document.body.style.lineHeight=l.typography.lineHeight,document.documentElement.style.backgroundColor=m.background;let v=document.querySelector('meta[name="theme-color"]');return v&&(v.content=m.background),document.documentElement.setAttribute("data-theme",e),document.body.setAttribute("data-theme",e),n.themeSettings.persist&&localStorage.setItem(n.themeSettings.persistKey,e),n._notifyThemeObservers(e),i&&n.themeSettings.autoContrast&&setTimeout(()=>{document.querySelectorAll("*").forEach(f=>{f._zumContrastApplied=!1}),n._applyContrastToAll()},a?r+50:50),M(`\u2705 Theme applied: ${e} (${l.name})`),!0}static toggleTheme(){return n.applyTheme(n._currentTheme==="light"?"dark":"light")}static applyThemeToElement(e,t=null){if(!e)return!1;let a=t?n.THEMES[t]:n.getTheme();if(!a)return!1;let r=e._isShadowHost?n.getShadowRoot(e):e;return r?(Object.entries(a.colors).forEach(([s,i])=>r.style.setProperty(`--Zum-${s}`,i)),r.style.backgroundColor=a.colors.background,r.style.color=a.colors.text,!0):!1}static applyThemeToCustomElement(e,t){let a=n.getTheme(t);if(!a||!e)return!1;let r=n.getThemeCSSProperties(t);return e.style.cssText+=r,e.setAttribute("data-theme",t),e.style.backgroundColor=a.colors.background,e.style.color=a.colors.text,!0}static applyThemeToElementDirect(e,t,a){if(e&&n.isShadowHost(e)){let r=n.getShadowRoot(e);if(!r)return;r.querySelectorAll("style[data-Zum-theme]").forEach(i=>i.remove());let s=document.createElement("style");s.setAttribute("data-Zum-theme","true"),s.textContent=`:host { background: ${t}; color: ${a}; }`,r.appendChild(s)}}static getCurrentTheme(){return n._currentTheme}static getTheme(e=null){return n.THEMES[e||n._currentTheme]||null}static getThemeSafe(e){return n.THEMES[e]||n.THEMES[n.themeSettings.defaultTheme]||n.THEMES.light}static getThemeName(e){let t=n.getTheme(e);return t?t.name:e}static getThemeNames(){let e={};return Object.entries(n.THEMES).forEach(([t,a])=>{e[t]=a.name||t}),e}static getThemeColors(e=null){let t=n.getTheme(e);return t?t.colors:null}static getThemeColor(e,t=null){let a=t?n.THEMES[t]:n.getTheme();return a&&a.colors[e]||null}static getAvailableThemes(){return Object.keys(n.THEMES)}static themeExists(e){return!!n.THEMES[e]}static getThemeSettings(){return{...n.themeSettings}}static updateThemeSettings(e){return Object.assign(n.themeSettings,e),n.themeSettings}static setDefaultTheme(e){return n.themeExists(e)?(n.themeSettings.defaultTheme=e,!0):!1}static resetToDefaultTheme(){return n.applyTheme(n.themeSettings.defaultTheme,{manual:!1})}static setThemePersistence(e){n.themeSettings.persist=e,e||(localStorage.removeItem(n.themeSettings.persistKey),localStorage.removeItem(n.themeSettings.systemPreferenceKey))}static isDarkTheme(){return n._currentTheme==="dark"}static isLightTheme(){return n._currentTheme==="light"}static getThemeMode(){return n.isUsingSystemTheme()?"system":"manual"}static addTheme(e,t){n.THEMES[e]&&I(`Theme "${e}" already exists. Overwriting.`);let r=["colors","typography","spacing","borderRadius","shadows","transitions"].filter(s=>!t[s]);return r.length>0?(E(`Theme missing required keys: ${r.join(", ")}`),!1):(n.THEMES[e]={id:e,name:t.name||e,...t},!0)}static defineTheme(e,t){if(!t||!t.colors)return E("Zum.defineTheme: theme must include a colors object."),!1;let a=n.THEMES.light;return n.THEMES[e]={id:e,name:t.name||e,colors:{...a.colors,...t.colors},typography:{...a.typography,...t.typography||{}},spacing:{...a.spacing,...t.spacing||{}},borderRadius:{...a.borderRadius,...t.borderRadius||{}},shadows:{...a.shadows,...t.shadows||{}},transitions:{...a.transitions,...t.transitions||{}}},!0}static removeTheme(e){return e==="light"||e==="dark"?(I("Cannot remove default themes (light/dark)"),!1):n.THEMES[e]?(delete n.THEMES[e],!0):!1}static duplicateTheme(e,t){let a=n.getTheme(e);return a?n.addTheme(t,{...a,id:t,name:`${a.name} (Copy)`}):!1}static exportTheme(e){let t=n.getTheme(e);return t?JSON.stringify(t,null,2):null}static importTheme(e){try{let t=JSON.parse(e);if(!t.id||!t.colors||!t.typography)throw new Error("Invalid theme format");return n.addTheme(t.id,t),!0}catch(t){return E("Failed to import theme:",t),!1}}static observeTheme(e){return typeof e!="function"?()=>{}:(n._themeObservers.push(e),e(n._currentTheme),()=>{n._themeObservers=n._themeObservers.filter(t=>t!==e)})}static onThemeChange(e){return n.observeTheme(e)}static _notifyThemeObservers(e){n._themeObservers.forEach(t=>{try{t(e)}catch(a){E("Theme observer error:",a)}})}static getContrastRatio(e,t){let a=n._calculateLuminance(e),r=n._calculateLuminance(t),s=Math.max(a,r),i=Math.min(a,r);return(s+.05)/(i+.05)}static checkThemeAccessibility(e){let t=n.getTheme(e);if(!t)return null;let a={theme:e,name:t.name,passed:!0,checks:[]},r=n.getContrastRatio(t.colors.text,t.colors.background);a.checks.push({name:"Text contrast",ratio:r.toFixed(2),passed:r>=4.5,wcag:r>=4.5?"AA":"Fail"});let s=n.getContrastRatio(t.colors.textSecondary,t.colors.background);a.checks.push({name:"Secondary text",ratio:s.toFixed(2),passed:s>=3,wcag:s>=3?"AA":"Fail"});let i=n.getContrastRatio(t.colors.primary,t.colors.background);return a.checks.push({name:"Interactive",ratio:i.toFixed(2),passed:i>=3,wcag:i>=3?"AA":"Fail"}),a.passed=a.checks.every(c=>c.passed),a}static getAccessibleThemes(){return Object.keys(n.THEMES).filter(e=>{let t=n.checkThemeAccessibility(e);return t&&t.passed})}static createThemeToggle(e={}){let{lightIcon:t="\u2600\uFE0F",darkIcon:a="\u{1F319}",systemIcon:r="\u{1F313}",className:s="theme-toggle",position:i="fixed",top:c="20px",right:l="20px",smooth:d=!0,duration:m=400}=e,v=document.createElement("button");v.className=s;let f=0,h=b=>{!localStorage.getItem(n.themeSettings.systemPreferenceKey)?(v.textContent=r,v.title="System theme",f=0):b==="dark"?(v.textContent=a,v.title="Dark theme",f=2):(v.textContent=t,v.title="Light theme",f=1),v.setAttribute("data-theme",b)},_=document.createElement("style");_.textContent=`
|
|
159
|
+
.${s} {
|
|
160
|
+
position: ${i}; top: ${c}; right: ${l}; z-index: 9999;
|
|
161
|
+
background: var(--Zum-surface); color: var(--Zum-text);
|
|
162
|
+
border: 1px solid var(--Zum-border); border-radius: var(--Zum-radius-full);
|
|
163
|
+
padding: var(--Zum-spacing-sm) var(--Zum-spacing-md);
|
|
164
|
+
cursor: pointer; font-size: 20px; box-shadow: var(--Zum-shadow-md);
|
|
165
|
+
transition: all ${m}ms ease-in-out; width: 48px; height: 48px;
|
|
166
|
+
display: flex; align-items: center; justify-content: center;
|
|
167
|
+
backdrop-filter: blur(10px);
|
|
168
|
+
}
|
|
169
|
+
.${s}:hover { transform: scale(1.1); box-shadow: var(--Zum-shadow-lg); }
|
|
170
|
+
.${s}:active { transform: scale(0.95); }
|
|
171
|
+
`,document.head.appendChild(_),h(n._currentTheme),v.addEventListener("click",()=>{if(f===0)n.applyTheme("light",{smooth:d,duration:m,manual:!0}),h("light");else if(f===1)n.applyTheme("dark",{smooth:d,duration:m,manual:!0}),h("dark");else{localStorage.removeItem(n.themeSettings.systemPreferenceKey);let b=n.getSystemThemePreference();n.applyTheme(b,{smooth:d,duration:m,manual:!1}),h(b)}}),n.observeTheme(h);let P=window.matchMedia("(prefers-color-scheme: dark)");return P.addEventListener&&P.addEventListener("change",()=>{if(!localStorage.getItem(n.themeSettings.systemPreferenceKey)){let b=P.matches?"dark":"light";n.applyTheme(b,{smooth:d,duration:m,manual:!1}),h(b)}}),v}static createThemeSelector(e={}){let{className:t="theme-selector",includeSystem:a=!0,currentTheme:r=n._currentTheme,onChange:s=null}=e,i=document.createElement("select");if(i.className=t,i.style.cssText="padding: 8px 12px; border-radius: 6px; border: 1px solid var(--Zum-border); background: var(--Zum-surface); color: var(--Zum-text); cursor: pointer; font-size: 14px;",a){let c=document.createElement("option");c.value="system",c.textContent="\u{1F313} System",n.isUsingSystemTheme()&&(c.selected=!0),i.appendChild(c)}return Object.entries(n.THEMES).forEach(([c,l])=>{let d=document.createElement("option");d.value=c,d.textContent=l.name||c,c===r&&!n.isUsingSystemTheme()&&(d.selected=!0),i.appendChild(d)}),i.addEventListener("change",c=>{let l=c.target.value;if(l==="system"){localStorage.removeItem(n.themeSettings.systemPreferenceKey);let d=n.getSystemThemePreference();n.applyTheme(d,{manual:!1})}else n.applyTheme(l,{manual:!0});s&&s(l)}),n.observeTheme(c=>{i.value=n.isUsingSystemTheme()?"system":c}),i}static createThemePreview(e){let t=n.getTheme(e);if(!t)return null;let a=document.createElement("div");return a.className="theme-preview",a.style.cssText=`display: flex; flex-direction: column; gap: 10px; padding: 20px; background: ${t.colors.background}; color: ${t.colors.text}; border-radius: 8px; border: 1px solid ${t.colors.border}; font-family: ${t.typography.fontFamily}; max-width: 300px;`,a.innerHTML=`
|
|
172
|
+
<h3 style="color: ${t.colors.primary};">${t.name}</h3>
|
|
173
|
+
<p style="color: ${t.colors.textSecondary};">Theme preview</p>
|
|
174
|
+
<div style="display: flex; gap: 8px; flex-wrap: wrap;">
|
|
175
|
+
<span style="background: ${t.colors.primary}; color: white; padding: 4px 12px; border-radius: 4px;">Primary</span>
|
|
176
|
+
<span style="background: ${t.colors.secondary}; color: white; padding: 4px 12px; border-radius: 4px;">Secondary</span>
|
|
177
|
+
<span style="background: ${t.colors.success}; color: white; padding: 4px 12px; border-radius: 4px;">Success</span>
|
|
178
|
+
</div>
|
|
179
|
+
<div style="display: flex; gap: 8px;">
|
|
180
|
+
<button style="background: ${t.colors.primary}; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer;">Button</button>
|
|
181
|
+
<input type="text" placeholder="Input" style="background: ${t.colors.inputBg}; color: ${t.colors.text}; border: 1px solid ${t.colors.inputBorder}; padding: 8px; border-radius: 4px;">
|
|
182
|
+
</div>
|
|
183
|
+
<div style="background: ${t.colors.cardBg}; padding: 10px; border-radius: 4px; border: 1px solid ${t.colors.border};">Card content</div>
|
|
184
|
+
`,a}static createColorPalette(e){let t=n.getTheme(e);if(!t)return null;let a=document.createElement("div");return a.className="theme-palette",a.style.cssText="display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; padding: 10px;",Object.entries(t.colors).forEach(([r,s])=>{let i=document.createElement("div");i.style.cssText=`display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px; border-radius: 4px; background: ${s}; color: ${n.getContrastColor(s)}; font-size: 11px; text-align: center;`,i.innerHTML=`<span style="font-weight: 600;">${r}</span><span style="opacity: 0.8;">${s}</span>`,a.appendChild(i)}),a}static generateThemeCSS(e){let t=n.getTheme(e);if(!t)return"";let a=`[data-theme="${e}"] {
|
|
185
|
+
`;return Object.entries(t.colors).forEach(([r,s])=>{a+=` --Zum-${r}: ${s};
|
|
186
|
+
`}),Object.entries(t.typography).forEach(([r,s])=>{a+=` --Zum-font-${r}: ${s};
|
|
187
|
+
`}),Object.entries(t.spacing).forEach(([r,s])=>{a+=` --Zum-spacing-${r}: ${s};
|
|
188
|
+
`}),Object.entries(t.borderRadius).forEach(([r,s])=>{a+=` --Zum-radius-${r}: ${s};
|
|
189
|
+
`}),Object.entries(t.shadows).forEach(([r,s])=>{a+=` --Zum-shadow-${r}: ${s};
|
|
190
|
+
`}),Object.entries(t.transitions).forEach(([r,s])=>{a+=` --Zum-transition-${r}: ${s};
|
|
191
|
+
`}),a+=`}
|
|
192
|
+
`,a}static generateAllThemeCSS(){let e="";return Object.keys(n.THEMES).forEach(t=>{e+=n.generateThemeCSS(t)}),e}static getThemeCSSProperties(e){let t=n.getTheme(e);if(!t)return"";let a="";return Object.entries(t.colors).forEach(([r,s])=>{a+=`--Zum-${r}: ${s};
|
|
193
|
+
`}),a}static _injectThemeStyles(){document.querySelectorAll("style[data-Zum-themes]").forEach(t=>t.remove());let e=document.createElement("style");e.setAttribute("data-Zum-themes","true"),e.textContent=`
|
|
194
|
+
html { color-scheme: light dark; }
|
|
195
|
+
|
|
196
|
+
${n.generateAllThemeCSS()}
|
|
197
|
+
|
|
198
|
+
html, body { transition: background-color 300ms ease-in-out, color 300ms ease-in-out; }
|
|
199
|
+
* { transition: background-color 300ms ease-in-out, color 300ms ease-in-out, border-color 300ms ease-in-out, box-shadow 300ms ease-in-out; }
|
|
200
|
+
::-webkit-scrollbar { width: 8px; height: 8px; }
|
|
201
|
+
::-webkit-scrollbar-track { background: var(--Zum-scrollbarTrack, #f1f5f9); }
|
|
202
|
+
::-webkit-scrollbar-thumb { background: var(--Zum-scrollbarThumb, #cbd5e1); border-radius: var(--Zum-radius-full, 9999px); }
|
|
203
|
+
::selection { background: var(--Zum-primary, #3b82f6); color: var(--Zum-text, #ffffff); }
|
|
204
|
+
`,document.head.appendChild(e),n._themeStylesInjected=!0}static refreshTheme(){let e=n._currentTheme;e&&(n.applyTheme(e),document.querySelectorAll(".theme-aware, [data-theme]").forEach(t=>{t!==document.documentElement&&t!==document.body&&t.setAttribute("data-theme",e)}),window.dispatchEvent(new CustomEvent("zum-theme-refreshed",{detail:{theme:e}})),M(`\u{1F504} Theme refreshed: ${e}`))}static reloadTheme(){return n.applyTheme(n._currentTheme)}static clearThemePreferences(){localStorage.removeItem(n.themeSettings.persistKey),localStorage.removeItem(n.themeSettings.systemPreferenceKey),M("\u{1F5D1}\uFE0F Theme preferences cleared")}static clearAllThemeData(){localStorage.removeItem(n.themeSettings.persistKey),localStorage.removeItem(n.themeSettings.systemPreferenceKey),n._currentTheme=n.themeSettings.defaultTheme,n._themeObservers=[],document.querySelectorAll("style[data-Zum-themes]").forEach(e=>e.remove()),document.querySelectorAll("style[data-Zum-theme]").forEach(e=>e.remove()),document.querySelectorAll("style[data-Zum-contrast]").forEach(e=>e.remove()),n._themeStylesInjected=!1,n._contrastInitialized=!1,document.documentElement.removeAttribute("data-theme"),document.body&&document.body.removeAttribute("data-theme"),M("\u{1F5D1}\uFE0F All theme data cleared")}static clearAllZumData(){["Zum_theme_preference","Zum_theme_preference_manual","ZumKey","app-name","__Zum_fetch_cache","__Zum_refreshing","__Zum_loaded","__Zum_license_cache","__Zum_pubkey"].forEach(t=>{localStorage.removeItem(t),sessionStorage.removeItem(t)}),M("\u{1F5D1}\uFE0F All Zum data cleared from localStorage")}static getZumStorageKeys(){let e=[];for(let t=0;t<localStorage.length;t++){let a=localStorage.key(t);a&&(a.includes("Zum")||a==="app-name")&&e.push(a)}return e}static inspectZumStorage(){let e=n.getZumStorageKeys();return M("\u{1F4E6} Zum data in localStorage:"),e.forEach(t=>{let a=localStorage.getItem(t);M(` ${t}:`,a?a.substring(0,100)+(a.length>100?"...":""):"null")}),e}static resetTheme(){localStorage.removeItem(n.themeSettings.persistKey),localStorage.removeItem(n.themeSettings.systemPreferenceKey);let e=n.themeSettings.defaultTheme||"light";n.applyTheme(e,{manual:!1}),M(`\u{1F504} Theme reset to: ${e}`)}static fullReset(){n.clearAllZumData(),M("\u{1F504} Full reset complete. Reloading..."),setTimeout(()=>location.reload(),100)}};T(n,"config",null),T(n,"configPromise",Promise.resolve(null)),T(n,"_readyPromise",null),T(n,"_scrollMemory",new Map),T(n,"_fetchCache",null),T(n,"_animationsInjected",!1),T(n,"_contrastInitialized",!1),T(n,"_contrastProcessing",new WeakSet),T(n,"_contrastProcessed",new WeakSet),T(n,"_debugEnabled",!1),T(n,"_debugLog",[]),T(n,"_debugLogLimit",500),T(n,"_debugDedupe",new Map),T(n,"_debugPerfMarks",new Map),T(n,"_beforeUnloadHandlers",new Set),T(n,"_beforeUnloadAttached",!1),T(n,"_hasRestored",!1),T(n,"respectReducedMotion",!0),T(n,"animations",{fade:{keyframes:"@keyframes fade { 0% { opacity: 0; } 100% { opacity: 1; } }",options:{duration:800,easing:"cubic-bezier(0.25, 0.1, 0.25, 1)"}},slideUp:{keyframes:"@keyframes slideUp { 0% { opacity: 0; transform: translateY(40px); } 100% { opacity: 1; transform: translateY(0); } }",options:{duration:800,easing:"cubic-bezier(0.25, 0.1, 0.25, 1)"}},slideDown:{keyframes:"@keyframes slideDown { 0% { opacity: 0; transform: translateY(-40px); } 100% { opacity: 1; transform: translateY(0); } }",options:{duration:800,easing:"cubic-bezier(0.25, 0.1, 0.25, 1)"}},slideLeft:{keyframes:"@keyframes slideLeft { 0% { opacity: 0; transform: translateX(40px); } 100% { opacity: 1; transform: translateX(0); } }",options:{duration:800,easing:"cubic-bezier(0.25, 0.1, 0.25, 1)"}},slideRight:{keyframes:"@keyframes slideRight { 0% { opacity: 0; transform: translateX(-40px); } 100% { opacity: 1; transform: translateX(0); } }",options:{duration:800,easing:"cubic-bezier(0.25, 0.1, 0.25, 1)"}},scale:{keyframes:"@keyframes scale { 0% { opacity: 0; transform: scale(0.9); } 100% { opacity: 1; transform: scale(1); } }",options:{duration:800,easing:"cubic-bezier(0.25, 0.1, 0.25, 1)"}},bounce:{keyframes:"@keyframes bounce { 0% { opacity: 0; transform: scale(0.3); } 100% { opacity: 1; transform: scale(1); } }",options:{duration:1e3,easing:"cubic-bezier(0.25, 0.1, 0.25, 1)"}},blurIn:{keyframes:"@keyframes blurIn { 0% { opacity: 0; filter: blur(20px); } 100% { opacity: 1; filter: blur(0); } }",options:{duration:1e3,easing:"cubic-bezier(0.25, 0.1, 0.25, 1)"}},rotateIn:{keyframes:"@keyframes rotateIn { 0% { opacity: 0; transform: rotate(-8deg); } 100% { opacity: 1; transform: rotate(0); } }",options:{duration:1e3,easing:"cubic-bezier(0.25, 0.1, 0.25, 1)"}},flipIn:{keyframes:"@keyframes flipIn { 0% { opacity: 0; transform: perspective(400px) rotateX(-90deg); } 100% { opacity: 1; transform: perspective(400px) rotateX(0); } }",options:{duration:700,easing:"ease-out"}},shake:{keyframes:"@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(6px); } }",options:{duration:500,easing:"ease-in-out"}},pulse:{keyframes:"@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }",options:{duration:1e3,easing:"ease-in-out"}},reveal:{keyframes:"@keyframes reveal { 0% { clip-path: inset(0 100% 0 0); } 100% { clip-path: inset(0 0 0 0); } }",options:{duration:800,easing:"cubic-bezier(.2,.8,.2,1)"}}}),T(n,"SKELETON_TYPES",{DEFAULT:"default",FEED_PAGE:"feed-page",PROFILE_PAGE:"profile-page",CHAT_PAGE:"chat-page",CHAT_DETAIL_PAGE:"chat-detail-page",SERVICE_PAGE:"service-page",DASHBOARD_PAGE:"dashboard-page",SETTINGS_PAGE:"settings-page",SEARCH_PAGE:"search-page",PRODUCT_GRID:"product-grid",NOTIFICATIONS_PAGE:"notifications-page",FORM_PAGE:"form-page"}),T(n,"DEFAULT_SKELETON_OPTIONS",{count:6,customClass:"",colors:{base:"#f5f5f5",highlight:"#e8e8e8"},animationDuration:1.5}),T(n,"REMOVE_SKELETON_OPTIONS",{animate:!0,animationType:"fade",duration:300,delay:0,callback:null,removeStyles:!0,selector:".skeleton"}),T(n,"_differ",{diff(e,t,a="id"){if(!e||!t)return null;let r=new Map(e.map(c=>[c[a],c])),s=new Map(t.map(c=>[c[a],c])),i={added:[],updated:[],deleted:[],unchanged:[],all:[],summary:{added:0,updated:0,deleted:0,unchanged:0,total:0,hasChanges:!1}};return s.forEach((c,l)=>{let d=r.get(l);if(!d)i.added.push({id:l,item:{...c,__change:"added"}});else if(JSON.stringify(d)!==JSON.stringify(c)){let m={};new Set([...Object.keys(d),...Object.keys(c)]).forEach(f=>{f!=="__change"&&JSON.stringify(d[f])!==JSON.stringify(c[f])&&(m[f]={from:d[f],to:c[f]})}),i.updated.push({id:l,item:{...c,__change:"updated"},changes:m})}else i.unchanged.push({id:l,item:{...c,__change:"unchanged"}})}),r.forEach((c,l)=>{s.has(l)||i.deleted.push({id:l,item:{...c,__change:"deleted"}})}),i.all=[...i.added.map(c=>c.item),...i.updated.map(c=>c.item),...i.unchanged.map(c=>c.item),...i.deleted.map(c=>c.item)],i.summary={added:i.added.length,updated:i.updated.length,deleted:i.deleted.length,unchanged:i.unchanged.length,total:i.all.length,hasChanges:i.added.length>0||i.updated.length>0||i.deleted.length>0},i}}),T(n,"themeSettings",{defaultTheme:"light",persist:!0,persistKey:"Zum_theme_preference",systemPreferenceKey:"Zum_theme_preference_manual",respectSystemPreference:!0,smoothTransitions:!0,transitionDuration:400,transitionEasing:"ease-in-out",autoContrast:!0,contrastThreshold:.5}),T(n,"THEMES",{light:{id:"light",name:"Light",colors:{primary:"#3b82f6",secondary:"#8b5cf6",success:"#22c55e",danger:"#ef4444",warning:"#f59e0b",info:"#06b6d4",background:"#ffffff",surface:"#f8fafc",surface2:"#f1f5f9",text:"#0f172a",textSecondary:"#475569",textMuted:"#94a3b8",border:"#e2e8f0",borderLight:"#f1f5f9",shadow:"rgba(0,0,0,0.05)",shadowHover:"rgba(0,0,0,0.1)",gradient:"linear-gradient(135deg, #3b82f6, #8b5cf6)",cardBg:"#ffffff",inputBg:"#ffffff",inputBorder:"#e2e8f0",inputFocus:"#3b82f6",navbarBg:"#ffffff",sidebarBg:"#f8fafc",footerBg:"#f1f5f9",modalBg:"rgba(0,0,0,0.5)",tooltipBg:"#0f172a",tooltipText:"#ffffff",skeletonBase:"#f1f5f9",skeletonHighlight:"#e2e8f0",scrollbarTrack:"#f1f5f9",scrollbarThumb:"#cbd5e1"},typography:{fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontFamilyMono:"ui-monospace, monospace",fontSize:"16px",lineHeight:"1.6"},spacing:{xs:"4px",sm:"8px",md:"16px",lg:"24px",xl:"32px","2xl":"48px"},borderRadius:{sm:"4px",md:"8px",lg:"12px",xl:"16px",full:"9999px"},shadows:{sm:"0 1px 2px rgba(0,0,0,0.05)",md:"0 4px 6px rgba(0,0,0,0.07)",lg:"0 10px 15px rgba(0,0,0,0.1)",xl:"0 20px 25px rgba(0,0,0,0.15)"},transitions:{fast:"150ms ease-in-out",normal:"300ms ease-in-out",slow:"500ms ease-in-out"}},dark:{id:"dark",name:"Dark",colors:{primary:"#60a5fa",secondary:"#a78bfa",success:"#4ade80",danger:"#f87171",warning:"#fbbf24",info:"#22d3ee",background:"#0f172a",surface:"#1e293b",surface2:"#334155",text:"#f1f5f9",textSecondary:"#94a3b8",textMuted:"#64748b",border:"#334155",borderLight:"#1e293b",shadow:"rgba(0,0,0,0.3)",shadowHover:"rgba(0,0,0,0.4)",gradient:"linear-gradient(135deg, #60a5fa, #a78bfa)",cardBg:"#1e293b",inputBg:"#1e293b",inputBorder:"#334155",inputFocus:"#60a5fa",navbarBg:"#0f172a",sidebarBg:"#1e293b",footerBg:"#0f172a",modalBg:"rgba(0,0,0,0.7)",tooltipBg:"#334155",tooltipText:"#f1f5f9",skeletonBase:"#1e293b",skeletonHighlight:"#334155",scrollbarTrack:"#1e293b",scrollbarThumb:"#475569"},typography:{fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontFamilyMono:"ui-monospace, monospace",fontSize:"16px",lineHeight:"1.6"},spacing:{xs:"4px",sm:"8px",md:"16px",lg:"24px",xl:"32px","2xl":"48px"},borderRadius:{sm:"4px",md:"8px",lg:"12px",xl:"16px",full:"9999px"},shadows:{sm:"0 1px 2px rgba(0,0,0,0.3)",md:"0 4px 6px rgba(0,0,0,0.4)",lg:"0 10px 15px rgba(0,0,0,0.5)",xl:"0 20px 25px rgba(0,0,0,0.6)"},transitions:{fast:"150ms ease-in-out",normal:"300ms ease-in-out",slow:"500ms ease-in-out"}},sepia:{id:"sepia",name:"Sepia",colors:{primary:"#8b7d6b",secondary:"#a8907a",success:"#6b8b6b",danger:"#8b6b6b",warning:"#8b7d4b",info:"#6b7d8b",background:"#f5ece0",surface:"#ede4d8",surface2:"#e5dcd0",text:"#3d3529",textSecondary:"#6b6357",textMuted:"#8b8377",border:"#d4c8b8",borderLight:"#e5dcd0",shadow:"rgba(61,53,41,0.08)",shadowHover:"rgba(61,53,41,0.15)",gradient:"linear-gradient(135deg, #8b7d6b, #a8907a)",cardBg:"#ede4d8",inputBg:"#f5ece0",inputBorder:"#d4c8b8",inputFocus:"#8b7d6b",navbarBg:"#ede4d8",sidebarBg:"#e5dcd0",footerBg:"#e5dcd0",modalBg:"rgba(61,53,41,0.6)",tooltipBg:"#3d3529",tooltipText:"#f5ece0",skeletonBase:"#e5dcd0",skeletonHighlight:"#d4c8b8",scrollbarTrack:"#ede4d8",scrollbarThumb:"#c4b8a8"},typography:{fontFamily:'Georgia, "Times New Roman", serif',fontFamilyMono:"ui-monospace, monospace",fontSize:"17px",lineHeight:"1.7"},spacing:{xs:"4px",sm:"8px",md:"16px",lg:"24px",xl:"32px","2xl":"48px"},borderRadius:{sm:"3px",md:"6px",lg:"10px",xl:"14px",full:"9999px"},shadows:{sm:"0 1px 2px rgba(61,53,41,0.05)",md:"0 4px 6px rgba(61,53,41,0.07)",lg:"0 10px 15px rgba(61,53,41,0.1)",xl:"0 20px 25px rgba(61,53,41,0.12)"},transitions:{fast:"150ms ease-in-out",normal:"300ms ease-in-out",slow:"500ms ease-in-out"}}}),T(n,"_currentTheme","light"),T(n,"_themeObservers",[]),T(n,"_themeStylesInjected",!1),T(n,"debug",{enable(){return n._debugEnabled=!0,!0},disable(){n._debugEnabled=!1},isEnabled(){return n._debugEnabled},log(...e){if(!n._debugEnabled)return;let t;try{t=JSON.stringify(e)}catch(s){t=String(e)}let a=Date.now(),r=n._debugDedupe.get(t);r&&a-r<250||(n._debugDedupe.set(t,a),console.log("\u{1F41B}",...e),n._debugLog.push({ts:a,args:e}),n._debugLog.length>n._debugLogLimit&&n._debugLog.shift())},getLog(){return n._debugLog.slice()},clearLog(){n._debugLog.length=0,n._debugDedupe.clear()}}),T(n,"Activity",{_pages:new Map,_layers:[],_activeLayer:null,_container:null,_cacheTTL:1e3*60*60,_started:!1,_cleanupInterval:null,_activeOverlays:{sidebar:null,optionMenu:null,toolPick:null,dialog:null},_sweepCache(){if(typeof sessionStorage=="undefined")return;let e=Date.now();for(let t=sessionStorage.length-1;t>=0;t--){let a=sessionStorage.key(t);a&&a.startsWith("zum-activity-cache:")}},start(){this._started||!j()||(this._started=!0,this._container=document.getElementById("zum-activity-root"),this._container||(this._container=document.createElement("div"),this._container.id="zum-activity-root",this._container.style.cssText="position: relative; width: 100%; height: 100%; overflow: hidden;",document.body.appendChild(this._container)),this._injectBaseStyles(),this._cleanupInterval=setInterval(()=>this._sweepCache(),6e4),window.addEventListener("hashchange",()=>this._handleHashChange()),this._handleHashChange())},stop(){this._started&&(this._started=!1,clearInterval(this._cleanupInterval),window.removeEventListener("hashchange",this._handleHashChange))},addLazyPage(e,t){this._pages.set(e,{factory:t,cache:!0})},addPage(e,t){this._pages.set(e,{factory:t,cache:!1})},navigateTo(e){window.location.hash!==`#${e}`&&(window.location.hash=e)},goBack(){window.history.back()},getCurrentPath(){let e=window.location.hash.replace(/^#/,"")||"/";return e.length>1&&e.startsWith("/")||e.startsWith("/")?e:"/"+e},findTrigger(e){return e?typeof e=="string"?document.querySelector(e):e:null},_handleHashChange(){if(this._pages.size===0)return;let e=this.getCurrentPath(),t=this._matchRoute(e);if(!t){E(`ZumActivity: No route found for "${e}"`);return}let{page:a,params:r}=t;this._closeTopOverlay()||this._renderPage(e,a,r)},_matchRoute(e){for(let[t,a]of this._pages.entries()){let r=t.length>1&&!t.startsWith("/")?"/"+t:t,s=new RegExp(`^${r.replace(/:[a-zA-Z0-9_]+/g,"([^/]+)")}$`),i=e.match(s);if(i){let c={};return(t.match(/:[a-zA-Z0-9_]+/g)||[]).map(d=>d.slice(1)).forEach((d,m)=>c[d]=decodeURIComponent(i[m+1])),{page:a,params:c}}}return null},async _renderPage(e,t,a){let r=`zum-activity-cache:${e}`,s=this._layers.find(i=>i.path===e);if(s||(s=document.createElement("div"),s.className="activity-page-layer",s.path=e,s.style.cssText="position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow-y: auto; background: var(--Zum-background); z-index: 1; display: none; transition: transform 0.3s ease;",this._container.appendChild(s),this._layers.push(s)),this._activeLayer&&(this._activeLayer.style.display="none"),s.style.display="block",this._activeLayer=s,!s.innerHTML.trim()){let i=sessionStorage.getItem(r);if(!i||!t.cache){try{i=await t.factory(a)}catch(l){E("Page factory error:",l),i='<div class="activity-error">Failed to load page.</div>'}if(t.cache)try{let l=i instanceof HTMLElement?i.outerHTML:String(i);sessionStorage.setItem(r,l)}catch(l){}}let c=document.createElement("div");c.className="activity-page-inner",i instanceof HTMLElement?c.appendChild(i):c.innerHTML=String(i),s.appendChild(c)}},_closeTopOverlay(){for(let[e,t]of Object.entries(this._activeOverlays))if(t)return this._closeOverlay(e),!0;return!1},_closeOverlay(e){let t=this._activeOverlays[e];t&&(t.remove(),this._activeOverlays[e]=null,document.body.style.overflow="")},_injectBaseStyles(){if(document.getElementById("activity-base-styles"))return;let e=document.createElement("style");e.id="activity-base-styles",e.textContent=`
|
|
205
|
+
.activity-page-layer { transition: opacity 0.2s ease, transform 0.2s ease; }
|
|
206
|
+
.activity-page-inner { max-width: 500px; margin: 0 auto; padding: 16px; width: 100%; box-sizing: border-box; }
|
|
207
|
+
@media (min-width: 768px) { .activity-page-inner { max-width: 100%; padding: 32px; } }
|
|
208
|
+
.activity-overlay-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000; opacity: 0; transition: opacity 0.2s; }
|
|
209
|
+
.activity-overlay-backdrop.open { opacity: 1; }
|
|
210
|
+
.activity-sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: 280px; background: var(--Zum-surface, #fff); z-index: 1001; transform: translateX(-100%); transition: transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1); box-shadow: 4px 0 24px rgba(0,0,0,0.1); display: flex; flex-direction: column; }
|
|
211
|
+
.activity-sidebar.open { transform: translateX(0); }
|
|
212
|
+
.activity-dialog-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 2000; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.2s; }
|
|
213
|
+
.activity-dialog-overlay.open { opacity: 1; }
|
|
214
|
+
.activity-dialog { background: var(--Zum-surface, #fff); border-radius: 12px; padding: 24px; max-width: 400px; width: 90%; transform: scale(0.95); transition: transform 0.2s; }
|
|
215
|
+
.activity-dialog-overlay.open .activity-dialog { transform: scale(1); }
|
|
216
|
+
.activity-option-menu, .activity-tool-pick { position: fixed; background: var(--Zum-surface, #fff); border: 1px solid var(--Zum-border, #ddd); border-radius: 8px; padding: 8px 0; box-shadow: 0 4px 12px rgba(0,0,0,0.15); z-index: 1001; min-width: 160px; opacity: 0; transform: translateY(-8px); transition: all 0.2s; }
|
|
217
|
+
.activity-option-menu.open, .activity-tool-pick.open { opacity: 1; transform: translateY(0); }
|
|
218
|
+
.activity-menu-item { padding: 10px 16px; cursor: pointer; font-size: 14px; transition: background 0.15s; }
|
|
219
|
+
.activity-menu-item:hover { background: var(--Zum-surface-hover, #f1f5f9); }
|
|
220
|
+
`,document.head.appendChild(e)},openSideBar(e,t){this._closeOverlay("sidebar");let a=this.findTrigger(e),r=document.createElement("div");r.className="activity-overlay-backdrop";let s=document.createElement("div");s.className="activity-sidebar",s.innerHTML=`
|
|
221
|
+
<div style="padding: 16px; border-bottom: 1px solid var(--Zum-border); font-weight: bold; font-size: 18px;">${t.title||"Menu"}</div>
|
|
222
|
+
<div class="activity-sidebar-nav" style="flex: 1; overflow-y: auto; padding: 16px;">
|
|
223
|
+
${(t.items||[]).map(c=>`<div class="activity-sidebar-item activity-menu-item" data-path="${c.path}">${c.icon||""} ${c.label}</div>`).join("")}
|
|
224
|
+
</div>
|
|
225
|
+
`,document.body.appendChild(r),document.body.appendChild(s),this._activeOverlays.sidebar={backdrop:r,sidebar:s},requestAnimationFrame(()=>{r.classList.add("open"),s.classList.add("open")});let i=()=>this._closeOverlay("sidebar");r.onclick=i,s.querySelectorAll(".activity-sidebar-item").forEach(c=>{c.onclick=()=>{let l=c.getAttribute("data-path");i(),l&&this.navigateTo(l)}})},showDialog(e){this._closeOverlay("dialog");let t=document.createElement("div");t.className="activity-dialog-overlay",t.innerHTML=`
|
|
226
|
+
<div class="activity-dialog">
|
|
227
|
+
<h3 style="margin: 0 0 12px; font-size: 18px;">${e.title||""}</h3>
|
|
228
|
+
<p style="margin: 0 0 24px; color: var(--Zum-textSecondary); font-size: 14px;">${e.message||""}</p>
|
|
229
|
+
<div style="display: flex; gap: 12px; justify-content: flex-end;">
|
|
230
|
+
${(e.buttons||[{label:"Close",action:"close"}]).map(a=>`
|
|
231
|
+
<button class="activity-dialog-btn" data-action="${a.action}" style="padding: 8px 16px; border-radius: 6px; border: 1px solid var(--Zum-border); background: ${a.type==="destructive"?"#ef4444":"transparent"}; color: ${a.type==="destructive"?"#fff":"inherit"}; cursor: pointer;">
|
|
232
|
+
${a.label}
|
|
233
|
+
</button>
|
|
234
|
+
`).join("")}
|
|
235
|
+
</div>
|
|
236
|
+
</div>
|
|
237
|
+
`,document.body.appendChild(t),this._activeOverlays.dialog=t,requestAnimationFrame(()=>t.classList.add("open")),t.querySelectorAll(".activity-dialog-btn").forEach(a=>{a.onclick=()=>{let r=a.getAttribute("data-action");this._closeOverlay("dialog"),e.onAction&&e.onAction(r)}})},showOptionMenu(e,t){this._closeOverlay("optionMenu");let a=this.findTrigger(e);if(!a)return;let r=document.createElement("div");r.className="activity-option-menu",r.innerHTML=(t.items||[]).map(c=>`<div class="activity-menu-item" data-action="${c.action}">${c.label}</div>`).join(""),document.body.appendChild(r),this._activeOverlays.optionMenu=r;let s=a.getBoundingClientRect();r.style.top=`${s.bottom+8}px`,r.style.left=`${s.left}px`,requestAnimationFrame(()=>r.classList.add("open")),r.querySelectorAll(".activity-menu-item").forEach(c=>{c.onclick=()=>{let l=c.getAttribute("data-action");this._closeOverlay("optionMenu"),t.onAction&&t.onAction(l)}});let i=c=>{!r.contains(c.target)&&c.target!==a&&(this._closeOverlay("optionMenu"),document.removeEventListener("click",i))};setTimeout(()=>document.addEventListener("click",i),0)},showToolPick(e,t){this._closeOverlay("toolPick");let a=this.findTrigger(e);if(!a)return;let r=document.createElement("div");r.className="activity-tool-pick",r.innerHTML=(t.items||[]).map(c=>`<div class="activity-menu-item" data-action="${c.action}">${c.icon||""} ${c.label}</div>`).join(""),document.body.appendChild(r),this._activeOverlays.toolPick=r;let s=a.getBoundingClientRect();r.style.top=`${s.bottom+8}px`,r.style.left=`${s.right-160}px`,requestAnimationFrame(()=>r.classList.add("open")),r.querySelectorAll(".activity-menu-item").forEach(c=>{c.onclick=()=>{let l=c.getAttribute("data-action");this._closeOverlay("toolPick"),t.onAction&&t.onAction(l)}});let i=c=>{!r.contains(c.target)&&c.target!==a&&(this._closeOverlay("toolPick"),document.removeEventListener("click",i))};setTimeout(()=>document.addEventListener("click",i),0)}});var A=n;if(j()){window.Zum=A,window.ZumActivity=A.Activity,(function(){if(!document.querySelector('meta[name="color-scheme"]')){let e=document.createElement("meta");e.name="color-scheme",e.content="light dark",document.head.appendChild(e)}if(!document.querySelector('meta[name="theme-color"]')){let e=document.createElement("meta");e.name="theme-color",e.content="#ffffff",e.setAttribute("media","(prefers-color-scheme: light)"),document.head.appendChild(e);let t=document.createElement("meta");t.name="theme-color",t.content="#0f172a",t.setAttribute("media","(prefers-color-scheme: dark)"),document.head.appendChild(t)}})(),window.__ACTIVITY_NO_AUTOSTART__||queueMicrotask(()=>{A.Activity._started||(A.Activity.start(),window.location.hash||A.Activity.navigateTo("/"))});try{let w=!window.__ZUM_NO_SYSTEM_THEME__&&A.themeSettings.respectSystemPreference!==!1,e=localStorage.getItem(A.themeSettings.persistKey),t=!!localStorage.getItem(A.themeSettings.systemPreferenceKey),a=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches,r;if(e&&t&&A.THEMES[e]?r=e:w&&a?r="dark":w&&!a?r="light":r=A.themeSettings.defaultTheme||"light",A._currentTheme=r,A._injectThemeStyles(),A.applyTheme(r,{manual:t&&e===r}),window.matchMedia&&w){let s=window.matchMedia("(prefers-color-scheme: dark)"),i=c=>{if(localStorage.getItem(A.themeSettings.systemPreferenceKey))return;let l=c.matches?"dark":"light";document.querySelectorAll("*").forEach(d=>{d._zumContrastApplied=!1}),A.applyTheme(l,{manual:!1,smooth:!0,duration:400}),setTimeout(()=>A.refreshContrast(),500),M(`\u{1F504} Auto-switched to ${l} (system preference)`)};s.addEventListener?s.addEventListener("change",i):s.addListener&&s.addListener(i)}A._initAutoContrast()}catch(w){I("Theme initialization error:",w),A._currentTheme=A.themeSettings.defaultTheme||"light",A.applyTheme(A._currentTheme,{manual:!1})}if(!document.getElementById("app-global-styles")){let w=document.createElement("style");w.id="app-global-styles",w.textContent=`
|
|
238
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
239
|
+
html, body { width: 100%; min-height: 100%; }
|
|
240
|
+
body { font-family: Arial, sans-serif; overflow-x: hidden; }
|
|
241
|
+
`,document.head.appendChild(w)}}var ae=A.Activity;var ne=A;return te(re);})();
|