sigment
Version:
A lightweight reactive JavaScript framework built with signals and vanilla JS — no virtual DOM, no JSX, no transpilation.
12 lines (9 loc) • 25 kB
JavaScript
var fe=Object.defineProperty;var u=(e,t)=>fe(e,"name",{value:t,configurable:!0});var A={cleanHtml:ye,cleanhtml:!0,setMaxCacheSize:he,maxCacheSize:10,setloadAtRunTime:ge,loadAtRunTime:null,setRoute:be,route:null,setStopPropagation:Ee,stopPropagation:!1},w={funcname:[],dataMap:new Map},N=null,v={},I=new Map,k=new Map,U=new Map,M=new Map,de=null,O=null,W=new Map,pe=null,j="",_=typeof window>"u",$=0;_||(j=window.location.href.replace(/^https?:\/\//,"").replace(/\/$/,""));globalThis.__CURRENT_COMPONENT__=null;var P=0,le=new Map;_&&(globalThis.__HANDLER_REGISTRY__||(globalThis.__HANDLER_REGISTRY__={}),globalThis.__HANDLER_ELEMENT_MAP__||(globalThis.__HANDLER_ELEMENT_MAP__=new Map));var g={innerHTMLElements:["div","p","span","h1","h2","h3","h4","h5","h6","a","ul","ol","li","table","tr","td","th","thead","tbody","tfoot","form","label","button","section","article","header","footer","nav","aside","main","figure","figcaption","blockquote","cite","code","pre","em","strong","i","b","u","s","small","mark","time","abbr","q","dl","dt","dd","fieldset","legend","textarea","output","progress","meter","fragment","details","summary","dialog","menu","slot","template"],valueElements:["input","textarea","select","button","option","progress","meter"],srcElements:["img","script","iframe","audio","video","source","track","embed","frame","input"],hrefElements:["a","link","area","base"],voidElements:["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr","frame"]};Object.values(g).flat().forEach(e=>{globalThis[e]||(globalThis[e]=(...t)=>V(e,...t),Object.defineProperty(globalThis,e,{writable:!1,configurable:!1}))});var z=new Set(g.valueElements),Z=new Set(g.srcElements),Q=new Set(g.hrefElements),G=new Set(g.voidElements);function $e(e,t){v[e]||(v[e]=we(t))}u($e,"createGlobalSignal");function He(e){return v[e]}u(He,"getGlobalSignal");function ee(e,t){w.dataMap.has(e)&&w.dataMap.delete(e),w.dataMap.set(e,t)}u(ee,"addEntry");function F(e){R(F.name);let t=w.dataMap.get(e);if(t)if(typeof t.value.hydrate<"u"&&t.value.hydrate!==null){if(t.value.hydrate){let n=document.getElementById(e);return n||null}}else return t.value;else return null}u(F,"gve");function je(e,t,n){let o;if(t instanceof HTMLElement?o=t.outerHTML:typeof t=="object"?o=JSON.stringify(t):o=t.toString(),o.length>4096){console.error("Cookie size exceeds 4KB limit. Data not stored.");return}document.cookie=e+"="+o+"; max-age="+n+" ; path=/ ;",setTimeout(()=>{document.cookie="testCookie=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/;"},n*1e3)}u(je,"setCookie");function Fe(e){let n=`; ${document.cookie}`.split(`; ${e}=`);if(n.length===2){let o=n.pop().split(";").shift();try{let l=JSON.parse(o);return typeof l=="object"&&l!==null&&"nodeType"in l&&l.nodeType===1,l}catch{return o}}return null}u(Fe,"getCookie");function Ne(e,t){let n;t instanceof HTMLElement?n=t.outerHTML:typeof t=="object"?n=JSON.stringify(t):n=t.toString(),localStorage.setItem(e,n)}u(Ne,"setStorage");function De(e){let t=localStorage.getItem(e);if(t!==null)try{let n=JSON.parse(t);return typeof n=="object"&&n!==null&&"nodeType"in n&&n.nodeType===1,n}catch{return t}}u(De,"getStorage");function J(e,t=void 0){R(J.name),w.createInstance=J.name;let n="";t===void 0?n=e():n=e(t)}u(J,"createInstance");function te(e,t){R(te.name),w.rpc=te.name;let n={};for(let[o,l]of Object.entries(t))e[o]?n[o]=e[o].apply(null,l):(console.error(`Function ${o} not found!`),n[o]=null);return n}u(te,"rpc");function ne(e,t=!1,n){R(ne.name),w.gvec=ne.name;let o=Object.keys(e),l=o[0],i=o[1],s=o[2];var r=e[l];r=r.name;var y=e[i];let c=e[i];var d=F(i)===null;if(d||t===!1){var m=""+i;w.dataMap.delete(m),J(y,e[s])}y=F(i);var p=F(l);if(p===null)throw new Error(` source id '${l} is not found in source component `);if(y===null)throw new Error(` target id '${i} is not found in target component `);if(p.replaceWith(y),n!==void 0)for(let a in c){let f=a.toString();if(typeof n=="object"){for(var b in n)if(f===b){var h=n[b];typeof h=="object"?c[a].apply(null,h):c[a].apply(null,[])}}else if(n.indexOf(",">-1)){let E=n.split(",");for(let C=0;C<E.length;C++)f===E[C]&&c[a].apply(null,[])}else f===n&&c[a].apply(null,[])}}u(ne,"gvec");async function Ve(e,t={}){let{passRestriction:n=[]}=t,o=window.location.pathname.replace(/^\/|\/$/g,"").toLowerCase(),l=e.replace(/^\/|\/$/g,"").toLowerCase();if(!new RegExp("^"+l.replace(/:[^\/]+/g,"[^/]+")+"$").test(o))return!1;let s=Array.isArray(n)?n:[n];for(let r of s)try{let y=typeof r=="function"?r():r;if(y instanceof Promise){if(!await y)return!1}else if(!y)return!1}catch(y){return console.error("Route check failed:",y),!1}return!0}u(Ve,"Route");function Ie(e){return e==null||e===""}u(Ie,"IsEmpty");function me(e){let t=e.startsWith("/")?e:"/"+e;window.history.pushState({},"",t)}u(me,"Navigate");function he(e){A.maxCacheSize=e}u(he,"setMaxCacheSize");function ye(e){A.cleanhtml=e}u(ye,"cleanHtml");function be(e){A.route=e}u(be,"setRoute");function ge(e){A.loadAtRunTime=e}u(ge,"setloadAtRunTime");function Ee(e){A.stopPropagation=e}u(Ee,"setStopPropagation");async function qe(e,t){let n;t==="/"?n=t:n=t.replace(/\//g,"").toLowerCase();let o=Object.keys(e).find(l=>l.toLowerCase()===n.toLowerCase());if(!o){let l=Object.keys(e).join(", ");throw new Error(`Unknown component: "${t}".
Available components: ${l}
To add this component:
const loadAsyncComponents = {
...existingComponents,
"${t}": () => import('./${t}.js')
};`)}if(k.has(o))return k.get(o);try{let i=(await e[o]()).default;return k.set(o,i),i}catch(l){throw new Error(`Failed to load component "${o}": ${l.message}`)}}u(qe,"loadFunc");function Ae(e){let t=null,n=-1;if(typeof e=="string")return{partName:e,index:n};let o=(e==null?void 0:e.target)instanceof Element?e.target.closest("[data-component]"):null;if(o){let l=o.closest("[data-part]");if(t=l==null?void 0:l.getAttribute("data-part"),l){let i=o.getAttribute("data-component");i&&l.querySelectorAll(`[data-component="${i}"]`).forEach((r,y)=>{r===o&&(n=y)})}}return{partName:t,index:n}}u(Ae,"getTargetPartAndIndex");async function Ue(e,t,n,o,l=null){if(_)return;let i=null,{partName:s,index:r}=Ae(l);s&&(i=s);let y=window.location.host+"/"+e;if(i===null){if(j===y)return;j=y}let c;typeof t=="boolean"||typeof t=="string"?(n=t,t=A.route):t===void 0&&(t=A.route,n=!1),me(e);let{componentKey:d,params:m}=ie(t);(d===void 0||d==="")&&console.warn(`current path "${e}" not match in route map file , check if param path is match`);let p=Object.keys(t);if(typeof n=="string")d=n,c=!!o;else if(typeof n=="boolean"){if(p.length===1)d=p[0];else if(p.includes(d))d=d;else throw new Error(`Ambiguous component map: multiple components exist and no matching key for path '${e}' found. Provide component key explicitly.`);c=n}else{if(p.length===1)d=p[0];else if(p.includes(d))d=d;else throw new Error(`Ambiguous component map: multiple components exist and no matching key for path '${e}' found. Provide component key explicitly.`);c=!1}let b=await Ce(t,d,m,null,!1);i&&(e=e+i+r);let h=W.get(e);if((!h||!c)&&(typeof b=="function"?(P=le.get(b.name),$=0,Array.isArray(m)?h=b(...m):typeof m=="object"&&m!==null?h=b(m):h=b(),W.set(e,h)):h=b),O&&O.isConnected){var a=O.contains(h);a||O.replaceWith(h)}else{typeof rvs_map_sigment<"u"&&rvs_map_sigment!==null&&(d=D(rvs_map_sigment,d));let f=document.querySelectorAll('[data-part="'+i+'"] [data-component="'+d+'"]');h.setAttribute("data-component",d),f&&f.length===1?f[0].replaceWith(h):f&&f.length>1?f[r].replaceWith(h):document.body.replaceChildren(h)}i===null&&(O=h,de=e),j=y}u(Ue,"NavigateTo");function We(e=pe,t){let n=typeof e=="string"?document.getElementById(e):e;n.contains(t)||n.replaceChildren(t)}u(We,"updateNodeIfNeeded");function ze(e){if(e){let t=e.toLowerCase(),n=!1;for(let o of k.keys())o.toLowerCase()===t&&(k.delete(o),n=!0);return n}else return k.clear(),!0}u(ze,"clearComponentCache");function ie(e){if(_)return;let t=window.location.pathname.replace(/\/{2,}/g,"/");t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1));let n=t.replace(/^\//,"").split("/").filter(Boolean);n[0]===void 0&&(n[0]="/");let o={},l=null,i=null,s=0;function r(c){return c.length>1&&c.endsWith("/")&&(c=c.slice(0,-1)),c.replace(/^\//,"").split("/").map(d=>{let m=d.startsWith(":"),p=m&&d.endsWith("?"),b=m?d.slice(1).replace("?",""):d;return b===""&&(b="/"),{isParam:m,isOptional:p,name:b}})}u(r,"parseRouteSegments");for(let[c,d]of Object.entries(e)){let m=d.path||`/${c}`,p=r(m),b=!0;for(let h=0;h<p.length;h++){let a=p[h],f=n[h];if(a.isParam){if(!f&&!a.isOptional){b=!1;break}}else if(a.name!==f){b=!1;break}}if(n.length<p.length){for(let h=n.length;h<p.length;h++)if(!p[h].isOptional){b=!1;break}}if(b){l=c,i=d,s=p.length,p.forEach((h,a)=>{if(h.isParam){let f=n[a];f!==void 0&&f!==""&&(o[h.name]=f)}});break}}return l||(l="",i=e[l]),i!=null&&i.urlParam&&i.urlParam.split("/").map(d=>d.replace(/[{}]/g,"")).forEach((d,m)=>{let p=n[s+m];p!==void 0&&p!==""&&(o[d]=p)}),new URL(window.location.href).searchParams.forEach((c,d)=>{o[d]=c}),{componentKey:l,componentName:l,params:o}}u(ie,"parsePath");function H(e){return new DOMParser().parseFromString(e,"text/html").body.firstChild}u(H,"parseHTML");async function Ce(e,t,n=null,o=null,l=!0){if(_)return;let i=e[t.toLowerCase()];if(i||(typeof e.fallback=="string"?i=e[e.fallback]:i=e.fallback),!i)return H("<h1>404 - Component not found</h1>");let{loader:s,guard:r,cacheExpiration:y=null,...c}=i;if(o===null&&typeof i.logic=="function"&&(o=i.logic),typeof r=="function"&&!await r(n))return H("<h1>403 - Forbidden</h1><p>You do not have access to this page.</p>");for(let d in c){let m=c[d];if(typeof m=="function")try{await m()}catch(p){console.error(p)}}try{let d=Date.now(),m=k.get(t);m&&y!==null&&d-m.cachedAt>y&&(k.delete(t),m=null);let p;if(m)p=m.component,k.set(t,{component:p,cachedAt:d});else{if(p=(await s()).default,k.size>=A.maxCacheSize){let f=k.keys().next().value;k.delete(f)}k.set(t,{component:p,cachedAt:d})}if(typeof p!="function")return H("<h1>Invalid component</h1>");if(!l)return p;let b;Array.isArray(n)?b=p(...n):typeof n=="object"&&n!==null?b=p(n):b=p();let h="/";try{h=window.location.pathname.slice(1)+window.location.hash,h=h.endsWith("/")&&h!=="/"?h.slice(0,-1):h,h===""&&(h="/")}catch{h=t}return W.set(h,b),O=b,b}catch(d){return console.error(d),H("<h1>Error loading component</h1>")}}u(Ce,"loadRunFunc");function K(e=""){var l,i;if(_)return"";R(K.name),w.buildRoadMap=K.name;var t="";let n=(l=new Error().stack)==null?void 0:l.toString();navigator.userAgent.toLowerCase().indexOf("firefox")>0?n=n.split("@"):n=n.split(`
`);for(let s=0;s<n.length;s++){var o="";if(navigator.userAgent.indexOf("Firefox")>0){let r=n[s].lastIndexOf(`
`);if(r===-1)continue;o=n[s].slice(r+1),o===""?(r=n[s].lastIndexOf("/")+1,r>-1&&(o=n[s].substr(r),o=o.substr(0,o.indexOf(".")))):o.indexOf("/")>-1&&(o=o.substr(0,o.indexOf("/")))}else o=(i=n[s])==null?void 0:i.trim().split(" ")[1];if(!w.funcname.includes(o)&&!(o===void 0||o==="")&&!(o.indexOf("http://")>-1||o.indexOf("https://")>-1)){if(w.gvec!==void 0&&o.indexOf(w.gvec)>-1)break;t.indexOf("|"+o)>-1||(t+="|"+o.replace(".","|"))}}return e+t}u(K,"buildRoadMap");function R(e){!w.funcname.includes(e)&&w.funcname.push(e)}u(R,"setFuncName");function we(e){let t=e,n=new Set;function o(){return N&&n.add(N),t}u(o,"get");function l(i,s=!1){(s||t!==i)&&(t=i,n.forEach(r=>r()))}return u(l,"set"),[o,l]}u(we,"createSignal");function B(e){function t(){N=t,e(),N=null}u(t,"wrapped"),t()}u(B,"createEffect");function Te(e){e=e.toLowerCase(),g.innerHTMLElements.includes(e)||(g.innerHTMLElements.push(e),globalThis[e]=(...t)=>V(e,...t))}u(Te,"createTypeElement");function se(e){return e.replace(/-+/g,"-").replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}u(se,"dashToCamel");function Ge(e,t=null){ae(e,t)}u(Ge,"createSigment");function Je(e,t=null){ae(e,t)}u(Je,"addSigment");function Ke(e,...t){if(Te(e),t.length!==0)return globalThis[e](...t)}u(Ke,"createElement");function ke(e){let t=document.createTextNode("");return B(()=>{if(typeof v!="object"||v===null){t.nodeValue=e;return}let n=e.replace(/{{(.*?)}}/g,(o,l)=>{let i=l.trim();if(v.hasOwnProperty(i)){let s=v[i];if(s&&typeof s[0]=="function")return s[0]()??""}return""});t.nodeValue=n}),t}u(ke,"interpolateReactiveText");function Be(e,t=5e3,n={}){let o=JSON.stringify([e,n,t]);if(!I.has(o)){let l=Se(async()=>{let i=await fetch(e,n);if(!i.ok)throw new Error(`Fetch failed: ${i.status}`);return i.json()},t);I.set(o,l)}return I.get(o)()}u(Be,"fetchCache");function Y(e){if(Array.isArray(e))return e.map(Y);if(e&&typeof e=="object"){let t={};return Object.keys(e).sort().forEach(n=>{t[n]=Y(e[n])}),t}return e}u(Y,"sortObjectDeep");function _e(e){if(e&&typeof e=="object"&&!Array.isArray(e)){let t={};return Object.keys(e).sort().forEach(n=>{t[n]=e[n]}),t}return e}u(_e,"sortObjectShallow");function Se(e,t=null,n={}){let o=new Map,l=u((...i)=>{let{deepSort:s}=n,r;s===!0?r=i.map(b=>b&&typeof b=="object"?Y(b):b):s===!1?r=i.map(b=>b&&typeof b=="object"?_e(b):b):r=i;let y=JSON.stringify(r),c=Date.now();y.length===2&&(y=e.name);let m=o.get(y);if(m&&(t===null||c-m.timestamp<t))return m.value;let p=e(...i);return o.set(y,{value:p,timestamp:c}),p instanceof Promise&&p.catch(()=>o.delete(y)),p},"wrapped");return l.clear=()=>o.clear(),l}u(Se,"memoizeFunc");function xe(e,t,n){let l=document.querySelectorAll("[data-component]")[n];return!l||l.getAttribute("data-component")!==e?null:[l,...l.querySelectorAll("*")][t]||null}u(xe,"getSsrElementByIndex");function q(e){let t={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,n=>t[n])}u(q,"escapeHtml");function V(e,...t){var h;let n={},o=[];if(t[0]&&typeof t[0]=="object"&&!Array.isArray(t[0])&&t[0]!==null&&!(t[0]instanceof String)&&(_||!(t[0]instanceof Node))?(n=t[0],o=t.slice(1)):o=t,_&&typeof document>"u"){let a=globalThis.__CURRENT_COMPONENT__;globalThis.__HANDLER_REGISTRY__||(globalThis.__HANDLER_REGISTRY__={}),(h=globalThis.__HANDLER_REGISTRY__)[a]||(h[a]=[]);let f=[];for(let[T,L]of Object.entries(n))if(T==="style"&&typeof L=="object"){let x=Object.entries(L).map(([ce,ue])=>`${ce.replace(/([A-Z])/g,"-$1").toLowerCase()}:${ue}`).join(";");f.push(` style="${q(x)}"`)}else T!=="className"&&T!=="class"&&!T.startsWith("on")&&f.push(` ${T}="${q(String(L))}"`);(n.className||n.class)&&f.push(` class="${q(n.className||n.class)}"`);let E=o.map(T=>typeof T=="function"?T():T??"").join("");if(["input","img","br","hr","meta","link"].includes(e))return`<${e}${f.join("")} />`;if(e==="fragment")return E;var l;let S=U.get(e);return S&&(l=S.tagName,S.nativeTag!==null&&(l=S.nativeTag)),l!==void 0&&(e=l),`<${e}${f.join("")}>${E}</${e}>`}R(V.name);var i="";i=K();var s=i.split("|");if(s.includes(w.rpc))return;let r=null,y=e.toLowerCase()==="fragment";if(y)r=document.createDocumentFragment();else{var l;let f=U.get(e);f&&(l=f.tagName,f.nativeTag!==null&&(l=f.nativeTag)),l!==void 0&&(e=l),r=document.createElement(e)}if(globalThis.__CURRENT_COMPONENT__){$++;let a=$;r.dataIndex=a,r.realtedComponent=globalThis.__CURRENT_COMPONENT__,r.cmpNbr=P}let c=[];for(let[a,f]of Object.entries(n))if(a.startsWith("on")&&typeof f=="function"){let E=a.slice(2).toLowerCase();c.push({type:E,val:f})}c.length&&(r._handlers=c);let d=G.has(e),m=z.has(se(e)),p=e==="input"||e==="option",b=e==="option";if(!y)for(let a in n){let f=n[a];if(a.startsWith("on")&&typeof f=="function"){let E=a.slice(2).toLowerCase();r.addEventListener(E,C=>{A.stopPropagation&&C.stopPropagation(),f(C)})}else typeof f=="function"&&a!=="children"?B(()=>{let E=f();E==null||E===!1?(r.removeAttribute(a),a==="value"&&m&&(r.value="",A.cleanhtml||r.removeAttribute("value")),a==="checked"&&p&&(r.checked=!1,A.cleanhtml||r.removeAttribute("checked")),a==="selected"&&b&&(r.selected=!1,A.cleanhtml||r.removeAttribute("selected")),a==="id"&&(r.iid="",A.cleanhtml||r.removeAttribute("id"))):a==="id"?(r.iid=E,A.cleanhtml?r.removeAttribute("id"):r.setAttribute("id",E),ee(E,{name:E,caller:E+i,value:r})):a==="value"&&m?(r.value=E,A.cleanhtml?r.removeAttribute("value"):r.setAttribute("value",E)):a==="checked"&&p?(r.checked=E,A.cleanhtml?r.removeAttribute("checked"):E?r.setAttribute("checked",""):r.removeAttribute("checked")):a==="selected"&&b?(r.selected=E,A.cleanhtml?r.removeAttribute("selected"):E?r.setAttribute("selected",""):r.removeAttribute("selected")):r.setAttribute(a,E)}):f!=null&&f!==!1&&(a==="id"?(r.iid=f,A.cleanhtml?r.removeAttribute("id"):r.setAttribute("id",f),ee(f,{name:f,caller:f+i,value:r})):a==="value"&&m?(r.value=f,A.cleanhtml?r.removeAttribute("value"):r.setAttribute("value",f)):a==="checked"&&p?(r.checked=f,A.cleanhtml?r.removeAttribute("checked"):r.setAttribute("checked","")):a==="selected"&&b?(r.selected=f,A.cleanhtml?r.removeAttribute("selected"):r.setAttribute("selected","")):r.setAttribute(a,f))}return d?o.length===1&&(typeof o[0]=="string"||typeof o[0]=="number")?m&&(r.value=o[0],A.cleanhtml?r.removeAttribute("value"):r.setAttribute("value",o[0])):o.length>0&&console.warn(`Void element <${e}> should not have children.`):o.flat().forEach(a=>{if(typeof a=="function"){let f=document.createTextNode("");r.appendChild(f),B(()=>{let E=a();if(E instanceof Node){let C=f.parentNode;if(!C)return;C.nodeType===Node.DOCUMENT_FRAGMENT_NODE?C.replaceChildren(E):C.replaceChild(E,f),f=E}else{let C=E==null?"":String(E);if(f.nodeValue!==C){let S=f.parentNode;if(S.realtedComponent){let T=null,L=xe(S.realtedComponent,S.dataset.index,S.cmpNbr);if(L&&(T=L),T!==null){let x=T;x=T.childNodes[0].firstChild,x===null&&(x=T.firstChild),x.nodeType===Node.TEXT_NODE&&(x.nodeValue=C)}else f.nodeValue=C}else f.nodeValue=C}}})}else if(typeof a=="string"&&a.includes("{{")&&!a.includes("function"))r.appendChild(ke(a));else if(typeof a=="string"||typeof a=="number"){if(a.includes("function get(")||a.includes("function (")||a.includes("[native code]"))throw new Error("Detected reactive getter function used inside a template string. Use a function instead like: div(() => `Your text is: ${someState()}`)");r.appendChild(document.createTextNode(a))}else(a instanceof DocumentFragment||a instanceof Node)&&r.appendChild(a)}),r}u(V,"h");function ve(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/-+/g,"-").toLowerCase()}u(ve,"camelToDash");function ae(e,t=null){if(g.innerHTMLElements.includes(e)||g.valueElements.includes(e)||g.srcElements.includes(e)||g.hrefElements.includes(e)||g.voidElements.includes(e))return;let o=/[A-Z]/.test(e)?ve(e):e.toLowerCase();o.includes("-")||(o="s-"+o),e.includes("-")&&(o=e,e=se(e)),U.set(e,{tagName:o,nativeTag:t}),!g.innerHTMLElements.includes(e)&&t===null?g.innerHTMLElements.push(e):!g.innerHTMLElements.includes(e)&&t!==null&&(g.innerHTMLElements.includes(t)||g.innerHTMLElements.push(e)),!g.valueElements.includes(e)&&t===null?(g.valueElements.push(e),z.add(e)):!g.valueElements.includes(e)&&t!==null&&(g.valueElements.includes(t)||(g.valueElements.push(e),z.add(e))),!g.srcElements.includes(e)&&t===null?(g.srcElements.push(e),Z.add(e)):!g.srcElements.includes(e)&&t!==null&&(g.srcElements.includes(t)||(g.srcElements.push(e),Z.add(e))),!g.hrefElements.includes(e)&&t===null?(g.hrefElements.push(e),Q.add(e)):!g.hrefElements.includes(e)&&t!==null&&(g.hrefElements.includes(t)||(g.hrefElements.push(e),Q.add(e))),!g.voidElements.includes(e)&&t===null?(g.voidElements.push(e),G.add(e)):!g.voidElements.includes(e)&&t!==null&&(g.voidElements.includes(t)||(g.voidElements.push(e),G.add(e))),globalThis[e]=(...l)=>V(e,...l)}u(ae,"defineElement");function Le(e){_||requestAnimationFrame(()=>{requestAnimationFrame(e)})}u(Le,"onPaint");function Ye(e){if(_)return;let t=!1;Le(()=>{t||(t=!0,e())})}u(Ye,"paintFinish");function oe(e){let t={};for(let n of e.attributes)if(n.name.startsWith("data-")&&n.name!=="data-component"){let o=n.name.slice(5);try{t[o]=JSON.parse(n.value)}catch{t[o]=n.value}}return t}u(oe,"getPropsFromDataAttributes");async function Oe(){let e=document.querySelector("layout[data-layout]");if(!e)return!1;let t=e.getAttribute("data-layout");if(!t)return!1;try{_||(t="/"+t);let n=await fetch(t);if(!n.ok)throw new Error("Failed to load layout");let o=await n.text(),i=new DOMParser().parseFromString(o,"text/html"),s=document.querySelector("description[data-description]");if(s){let c=i.querySelector('meta[name="description"]');c||(c=i.createElement("meta"),c.name="description",i.head.appendChild(c)),c.content=s.getAttribute("data-description")}let r=document.querySelector("keywords[data-keywords]");if(r){let c=i.querySelector('meta[name="keywords"]');c||(c=i.createElement("meta"),c.name="keywords",i.head.appendChild(c)),c.content=r.getAttribute("data-keywords")}return document.querySelectorAll("[data-part]").forEach(c=>{let d=c.getAttribute("data-part"),m=i.querySelector(`[data-part="${d}"]`);m&&(m.innerHTML="",[...c.childNodes].forEach(p=>{m.appendChild(p.cloneNode(!0))}))}),document.documentElement.innerHTML=i.documentElement.innerHTML,!0}catch(n){return console.error("Failed to inject layout:",n),!1}}u(Oe,"injectLayout");function D(e,t){if(!t)return;let n=t.trim();if(e[n])return e[n];let o=n[0].toUpperCase()+n.slice(1).toLowerCase();if(e[o])return e[o];let l=n.toUpperCase();if(e[l])return e[l];let i=n.toLowerCase(),s=Object.entries(e).find(([r,y])=>r.toLowerCase()===i);if(s)return s[1]}u(D,"lookupComponent");async function re(e){var y;let t=e||A.route;await Oe();let{componentKey:n,componentName:o,params:l}=ie(t),i=new Set,s=o,r=document.querySelectorAll("[data-component]");for(let c of r){let d=c.getAttribute("data-component"),m=d==null?void 0:d.toLowerCase();if(typeof rvs_map_sigment<"u"&&rvs_map_sigment!==null?s=D(rvs_map_sigment,d):s=m,!s||i.has(s))continue;let p=D(t,s);try{c.hasChildNodes()&&(globalThis.__CURRENT_COMPONENT__=d);let b=p?await Me(p):await Re(A.loadAtRunTime,s),h=p?{...l,...oe(c)}:oe(c),a=b.default(h);a.funcName=o.toLowerCase();let f=(y=c.closest("[data-part]"))==null?void 0:y.getAttribute("data-part");a.datapart=f,a.setAttribute("data-component",d),a.hydrate=!0,c.cmpNbr=P,X(c,a),le.set(s,P),P++,$=0}catch(b){console.warn(`Component "${m}" failed to load`,b)}}}u(re,"hydrateComponent");async function Me(e){if(!M.has(e)){let t=await e.loader();M.set(e,t)}return M.get(e)}u(Me,"loadModule");async function Re(e,t){let n=D(e,t);if(n){if(M.has(n))return M.get(n);try{let o=await n();return M.set(n,o),o}catch(o){console.error(`Component "${t}" failed to load`,o)}}}u(Re,"loadModuleFromFile");function Xe(e,t){if(e===void 0){re();return}if(typeof e=="object"&&t===void 0){re(e);return}let n=typeof e=="string"?document.getElementById(e):e;if(!n)throw new Error("Mount target not found: "+e);n.hasChildNodes()?X(n,t):n.replaceChildren(t)}u(Xe,"mount");function X(e,t){(async()=>{try{if(e.hasChildNodes()){let l=[t,...t.querySelectorAll("*")],i=[e,...e.querySelectorAll("*")];l.forEach((s,r)=>{let y=i[r];if(y){s.dataset.index=r;for(let c of s.getAttributeNames()){let d=s.getAttribute(c);if(y.getAttribute(c)!==d){if(c==="data-component"||c==="data-index")continue;y.setAttribute(c,d)}}s.nodeType===Node.TEXT_NODE&&s.nodeValue!==y.nodeValue&&(y.nodeValue=s.nodeValue),s.childNodes[0].nodeType===Node.TEXT_NODE&&s.childNodes[0].nodeValue!==y.nodeValue&&(y.childNodes[0].nodeValue=s.childNodes[0].nodeValue),s._handlers&&s._handlers.forEach(({type:c,val:d})=>{y.addEventListener(c,m=>{A.stopPropagation&&m.stopPropagation(),d(m)})})}}),globalThis.__CURRENT_COMPONENT__=null,$=0;return}if(!t||e.nodeName!==t.nodeName){e.replaceWith(t);return}if(t.nodeType===Node.TEXT_NODE){e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue);return}if(e.nodeType===Node.ELEMENT_NODE&&t.nodeType===Node.ELEMENT_NODE){for(let l of Array.from(t.attributes))e.setAttribute(l.name,l.value);if(t._handlers)for(let{type:l,val:i}of t._handlers)e.addEventListener(l,s=>{A.stopPropagation&&s.stopPropagation(),i(s)});e instanceof HTMLInputElement?(e.value!==t.value&&(e.value=t.value),["checkbox","radio"].includes(e.type)&&e.checked!==t.checked&&(e.checked=t.checked)):e instanceof HTMLTextAreaElement?e.value!==t.value&&(e.value=t.value):e instanceof HTMLSelectElement&&e.value!==t.value&&(e.value=t.value);for(let l of Array.from(e.attributes))t.hasAttribute(l.name)||e.removeAttribute(l.name)}let n=Array.from(t.childNodes),o=Array.from(e.childNodes);for(let l=0;l<Math.max(n.length,o.length);l++){let i=o[l],s=n[l];i&&s?X(i,s):s?e.appendChild(s):i&&e.removeChild(i)}}catch(n){console.error("Hydration failed:",n)}})()}u(X,"hydrate");export{Ie as IsEmpty,A as MyApp,me as Navigate,Ue as NavigateTo,Ve as Route,Je as addSigment,ze as clearComponentCache,B as createEffect,Ke as createElement,$e as createGlobalSignal,Ge as createSigment,we as createSignal,Be as fetchCache,Fe as getCookie,He as getGlobalSignal,De as getStorage,F as getVirtualElementById,$e as globalSignal,F as gve,ne as gvec,V as h,re as hydrateComponent,qe as loadFunc,Ce as loadRunFunc,Se as memoizeFunc,Xe as mount,Le as onPaint,Ye as paintFinish,ie as parsePath,te as rpc,je as setCookie,Ne as setStorage,we as signal,We as updateNodeIfNeeded,He as useGlobalSignal};