UNPKG

sigment

Version:

A lightweight reactive JavaScript framework built with signals and vanilla JS — no virtual DOM, no JSX, no transpilation.

12 lines (9 loc) 24.8 kB
var fe=Object.defineProperty;var a=(e,t)=>fe(e,"name",{value:t,configurable:!0});var A={cleanHtml:ye,cleanhtml:!0,setMaxCacheSize:he,maxCacheSize:10,setloadAtRunTime:be,loadAtRunTime:null,setRoute:ge,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,F="",_=typeof window>"u",P=0;_||(F=window.location.href.replace(/^https?:\/\//,"").replace(/\/$/,""));globalThis.__CURRENT_COMPONENT__=null;var $=0,le=new Map;_&&(globalThis.__HANDLER_REGISTRY__||(globalThis.__HANDLER_REGISTRY__={}),globalThis.__HANDLER_ELEMENT_MAP__||(globalThis.__HANDLER_ELEMENT_MAP__=new Map));var b={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(b).flat().forEach(e=>{globalThis[e]=(...t)=>V(e,...t)});var z=new Set(b.valueElements),Z=new Set(b.srcElements),Q=new Set(b.hrefElements),G=new Set(b.voidElements);function Pe(e,t){v[e]||(v[e]=we(t))}a(Pe,"createGlobalSignal");function je(e){return v[e]}a(je,"getGlobalSignal");function ee(e,t){w.dataMap.has(e)&&w.dataMap.delete(e),w.dataMap.set(e,t)}a(ee,"addEntry");function H(e){R(H.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}a(H,"gve");function Fe(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)}a(Fe,"setCookie");function He(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}a(He,"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)}a(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}}a(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)}a(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}a(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],u=o[2];var r=e[l];r=r.name;var g=e[i];let d=e[i];var f=H(i)===null;if(f||t===!1){var m=""+i;w.dataMap.delete(m),J(g,e[u])}g=H(i);var p=H(l);if(p===null)throw new Error(` source id '${l} is not found in source component `);if(g===null)throw new Error(` target id '${i} is not found in target component `);if(p.replaceWith(g),n!==void 0)for(let c in d){let s=c.toString();if(typeof n=="object"){for(var y in n)if(s===y){var h=n[y];typeof h=="object"?d[c].apply(null,h):d[c].apply(null,[])}}else if(n.indexOf(",">-1)){let E=n.split(",");for(let C=0;C<E.length;C++)s===E[C]&&d[c].apply(null,[])}else s===n&&d[c].apply(null,[])}}a(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 u=Array.isArray(n)?n:[n];for(let r of u)try{let g=typeof r=="function"?r():r;if(g instanceof Promise){if(!await g)return!1}else if(!g)return!1}catch(g){return console.error("Route check failed:",g),!1}return!0}a(Ve,"Route");function Ie(e){return e==null||e===""}a(Ie,"IsEmpty");function me(e){let t=e.startsWith("/")?e:"/"+e;window.history.pushState({},"",t)}a(me,"Navigate");function he(e){A.maxCacheSize=e}a(he,"setMaxCacheSize");function ye(e){A.cleanhtml=e}a(ye,"cleanHtml");function ge(e){A.route=e}a(ge,"setRoute");function be(e){A.loadAtRunTime=e}a(be,"setloadAtRunTime");function Ee(e){A.stopPropagation=e}a(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}`)}}a(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,g)=>{r===o&&(n=g)})}}return{partName:t,index:n}}a(Ae,"getTargetPartAndIndex");async function Ue(e,t,n,o,l=null){if(_)return;let i=null,{partName:u,index:r}=Ae(l);u&&(i=u);let g=window.location.host+"/"+e;if(i===null){if(F===g)return;F=g}let d;typeof t=="boolean"||typeof t=="string"?(n=t,t=A.route):t===void 0&&(t=A.route,n=!1),me(e);let{componentKey:f,params:m}=ie(t);(f===void 0||f==="")&&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")f=n,d=!!o;else if(typeof n=="boolean"){if(p.length===1)f=p[0];else if(p.includes(f))f=f;else throw new Error(`Ambiguous component map: multiple components exist and no matching key for path '${e}' found. Provide component key explicitly.`);d=n}else{if(p.length===1)f=p[0];else if(p.includes(f))f=f;else throw new Error(`Ambiguous component map: multiple components exist and no matching key for path '${e}' found. Provide component key explicitly.`);d=!1}let y=await Ce(t,f,m,null,!1);i&&(e=e+i+r);let h=W.get(e);if((!h||!d)&&(typeof y=="function"?($=le.get(y.name),P=0,Array.isArray(m)?h=y(...m):typeof m=="object"&&m!==null?h=y(m):h=y(),W.set(e,h)):h=y),O&&O.isConnected){var c=O.contains(h);c||O.replaceWith(h)}else{typeof rvs_map_sigment<"u"&&rvs_map_sigment!==null&&(f=D(rvs_map_sigment,f));let s=document.querySelectorAll('[data-part="'+i+'"] [data-component="'+f+'"]');h.setAttribute("data-component",f),s&&s.length===1?s[0].replaceWith(h):s&&s.length>1?s[r].replaceWith(h):document.body.replaceChildren(h)}i===null&&(O=h,de=e),F=g}a(Ue,"NavigateTo");function We(e=pe,t){let n=typeof e=="string"?document.getElementById(e):e;n.contains(t)||n.replaceChildren(t)}a(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}a(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,u=0;function r(d){return d.length>1&&d.endsWith("/")&&(d=d.slice(0,-1)),d.replace(/^\//,"").split("/").map(f=>{let m=f.startsWith(":"),p=m&&f.endsWith("?"),y=m?f.slice(1).replace("?",""):f;return y===""&&(y="/"),{isParam:m,isOptional:p,name:y}})}a(r,"parseRouteSegments");for(let[d,f]of Object.entries(e)){let m=f.path||`/${d}`,p=r(m),y=!0;for(let h=0;h<p.length;h++){let c=p[h],s=n[h];if(c.isParam){if(!s&&!c.isOptional){y=!1;break}}else if(c.name!==s){y=!1;break}}if(n.length<p.length){for(let h=n.length;h<p.length;h++)if(!p[h].isOptional){y=!1;break}}if(y){l=d,i=f,u=p.length,p.forEach((h,c)=>{if(h.isParam){let s=n[c];s!==void 0&&s!==""&&(o[h.name]=s)}});break}}return l||(l="",i=e[l]),i!=null&&i.urlParam&&i.urlParam.split("/").map(f=>f.replace(/[{}]/g,"")).forEach((f,m)=>{let p=n[u+m];p!==void 0&&p!==""&&(o[f]=p)}),new URL(window.location.href).searchParams.forEach((d,f)=>{o[f]=d}),{componentKey:l,componentName:l,params:o}}a(ie,"parsePath");function j(e){return new DOMParser().parseFromString(e,"text/html").body.firstChild}a(j,"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 j("<h1>404 - Component not found</h1>");let{loader:u,guard:r,cacheExpiration:g=null,...d}=i;if(o===null&&typeof i.logic=="function"&&(o=i.logic),typeof r=="function"&&!await r(n))return j("<h1>403 - Forbidden</h1><p>You do not have access to this page.</p>");for(let f in d){let m=d[f];if(typeof m=="function")try{await m()}catch(p){console.error(p)}}try{let f=Date.now(),m=k.get(t);m&&g!==null&&f-m.cachedAt>g&&(k.delete(t),m=null);let p;if(m)p=m.component,k.set(t,{component:p,cachedAt:f});else{if(p=(await u()).default,k.size>=A.maxCacheSize){let s=k.keys().next().value;k.delete(s)}k.set(t,{component:p,cachedAt:f})}if(typeof p!="function")return j("<h1>Invalid component</h1>");if(!l)return p;let y;Array.isArray(n)?y=p(...n):typeof n=="object"&&n!==null?y=p(n):y=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,y),O=y,y}catch(f){return console.error(f),j("<h1>Error loading component</h1>")}}a(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 u=0;u<n.length;u++){var o="";if(navigator.userAgent.indexOf("Firefox")>0){let r=n[u].lastIndexOf(` `);if(r===-1)continue;o=n[u].slice(r+1),o===""?(r=n[u].lastIndexOf("/")+1,r>-1&&(o=n[u].substr(r),o=o.substr(0,o.indexOf(".")))):o.indexOf("/")>-1&&(o=o.substr(0,o.indexOf("/")))}else o=(i=n[u])==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}a(K,"buildRoadMap");function R(e){!w.funcname.includes(e)&&w.funcname.push(e)}a(R,"setFuncName");function we(e){let t=e,n=new Set;function o(){return N&&n.add(N),t}a(o,"get");function l(i,u=!1){(u||t!==i)&&(t=i,n.forEach(r=>r()))}return a(l,"set"),[o,l]}a(we,"createSignal");function B(e){function t(){N=t,e(),N=null}a(t,"wrapped"),t()}a(B,"createEffect");function Te(e){e=e.toLowerCase(),b.innerHTMLElements.includes(e)||(b.innerHTMLElements.push(e),globalThis[e]=(...t)=>V(e,...t))}a(Te,"createTypeElement");function se(e){return e.replace(/-+/g,"-").replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}a(se,"dashToCamel");function Ge(e,t=null){ae(e,t)}a(Ge,"createSigment");function Je(e,t=null){ae(e,t)}a(Je,"addSigment");function Ke(e,...t){if(Te(e),t.length!==0)return globalThis[e](...t)}a(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 u=v[i];if(u&&typeof u[0]=="function")return u[0]()??""}return""});t.nodeValue=n}),t}a(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)()}a(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}a(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}a(_e,"sortObjectShallow");function Se(e,t=null,n={}){let o=new Map,l=a((...i)=>{let{deepSort:u}=n,r;u===!0?r=i.map(y=>y&&typeof y=="object"?Y(y):y):u===!1?r=i.map(y=>y&&typeof y=="object"?_e(y):y):r=i;let g=JSON.stringify(r),d=Date.now();g.length===2&&(g=e.name);let m=o.get(g);if(m&&(t===null||d-m.timestamp<t))return m.value;let p=e(...i);return o.set(g,{value:p,timestamp:d}),p instanceof Promise&&p.catch(()=>o.delete(g)),p},"wrapped");return l.clear=()=>o.clear(),l}a(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}a(xe,"getSsrElementByIndex");function q(e){let t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};return e.replace(/[&<>"']/g,n=>t[n])}a(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 c=globalThis.__CURRENT_COMPONENT__;globalThis.__HANDLER_REGISTRY__||(globalThis.__HANDLER_REGISTRY__={}),(h=globalThis.__HANDLER_REGISTRY__)[c]||(h[c]=[]);let s=[];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(";");s.push(` style="${q(x)}"`)}else T!=="className"&&T!=="class"&&!T.startsWith("on")&&s.push(` ${T}="${q(String(L))}"`);(n.className||n.class)&&s.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}${s.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}${s.join("")}>${E}</${e}>`}R(V.name);var i="";i=K();var u=i.split("|");if(u.includes(w.rpc))return;let r=null,g=e.toLowerCase()==="fragment";if(g)r=document.createDocumentFragment();else{var l;let s=U.get(e);s&&(l=s.tagName,s.nativeTag!==null&&(l=s.nativeTag)),l!==void 0&&(e=l),r=document.createElement(e)}if(globalThis.__CURRENT_COMPONENT__){P++;let c=P;r.dataIndex=c,r.realtedComponent=globalThis.__CURRENT_COMPONENT__,r.cmpNbr=$}let d=[];for(let[c,s]of Object.entries(n))if(c.startsWith("on")&&typeof s=="function"){let E=c.slice(2).toLowerCase();d.push({type:E,val:s})}d.length&&(r._handlers=d);let f=G.has(e),m=z.has(se(e)),p=e==="input"||e==="option",y=e==="option";if(!g)for(let c in n){let s=n[c];if(c.startsWith("on")&&typeof s=="function"){let E=c.slice(2).toLowerCase();r.addEventListener(E,C=>{A.stopPropagation&&C.stopPropagation(),s(C)})}else typeof s=="function"&&c!=="children"?B(()=>{let E=s();E==null||E===!1?(r.removeAttribute(c),c==="value"&&m&&(r.value="",A.cleanhtml||r.removeAttribute("value")),c==="checked"&&p&&(r.checked=!1,A.cleanhtml||r.removeAttribute("checked")),c==="selected"&&y&&(r.selected=!1,A.cleanhtml||r.removeAttribute("selected")),c==="id"&&(r.iid="",A.cleanhtml||r.removeAttribute("id"))):c==="id"?(r.iid=E,A.cleanhtml?r.removeAttribute("id"):r.setAttribute("id",E),ee(E,{name:E,caller:E+i,value:r})):c==="value"&&m?(r.value=E,A.cleanhtml?r.removeAttribute("value"):r.setAttribute("value",E)):c==="checked"&&p?(r.checked=E,A.cleanhtml?r.removeAttribute("checked"):E?r.setAttribute("checked",""):r.removeAttribute("checked")):c==="selected"&&y?(r.selected=E,A.cleanhtml?r.removeAttribute("selected"):E?r.setAttribute("selected",""):r.removeAttribute("selected")):r.setAttribute(c,E)}):s!=null&&s!==!1&&(c==="id"?(r.iid=s,A.cleanhtml?r.removeAttribute("id"):r.setAttribute("id",s),ee(s,{name:s,caller:s+i,value:r})):c==="value"&&m?(r.value=s,A.cleanhtml?r.removeAttribute("value"):r.setAttribute("value",s)):c==="checked"&&p?(r.checked=s,A.cleanhtml?r.removeAttribute("checked"):r.setAttribute("checked","")):c==="selected"&&y?(r.selected=s,A.cleanhtml?r.removeAttribute("selected"):r.setAttribute("selected","")):r.setAttribute(c,s))}return f?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(c=>{if(typeof c=="function"){let s=document.createTextNode("");r.appendChild(s),B(()=>{let E=c();if(E instanceof Node){let C=s.parentNode;if(!C)return;C.nodeType===Node.DOCUMENT_FRAGMENT_NODE?C.replaceChildren(E):C.replaceChild(E,s),s=E}else{let C=E==null?"":String(E);if(s.nodeValue!==C){let S=s.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 s.nodeValue=C}else s.nodeValue=C}}})}else if(typeof c=="string"&&c.includes("{{")&&!c.includes("function"))r.appendChild(ke(c));else if(typeof c=="string"||typeof c=="number"){if(c.includes("function get(")||c.includes("function (")||c.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(c))}else(c instanceof DocumentFragment||c instanceof Node)&&r.appendChild(c)}),r}a(V,"h");function ve(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/-+/g,"-").toLowerCase()}a(ve,"camelToDash");function ae(e,t=null){if(b.innerHTMLElements.includes(e)||b.valueElements.includes(e)||b.srcElements.includes(e)||b.hrefElements.includes(e)||b.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}),!b.innerHTMLElements.includes(e)&&t===null?b.innerHTMLElements.push(e):!b.innerHTMLElements.includes(e)&&t!==null&&(b.innerHTMLElements.includes(t)||b.innerHTMLElements.push(e)),!b.valueElements.includes(e)&&t===null?(b.valueElements.push(e),z.add(e)):!b.valueElements.includes(e)&&t!==null&&(b.valueElements.includes(t)||(b.valueElements.push(e),z.add(e))),!b.srcElements.includes(e)&&t===null?(b.srcElements.push(e),Z.add(e)):!b.srcElements.includes(e)&&t!==null&&(b.srcElements.includes(t)||(b.srcElements.push(e),Z.add(e))),!b.hrefElements.includes(e)&&t===null?(b.hrefElements.push(e),Q.add(e)):!b.hrefElements.includes(e)&&t!==null&&(b.hrefElements.includes(t)||(b.hrefElements.push(e),Q.add(e))),!b.voidElements.includes(e)&&t===null?(b.voidElements.push(e),G.add(e)):!b.voidElements.includes(e)&&t!==null&&(b.voidElements.includes(t)||(b.voidElements.push(e),G.add(e))),globalThis[e]=(...l)=>V(e,...l)}a(ae,"defineElement");function Le(e){_||requestAnimationFrame(()=>{requestAnimationFrame(e)})}a(Le,"onPaint");function Ye(e){if(_)return;let t=!1;Le(()=>{t||(t=!0,e())})}a(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}a(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{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"),u=document.querySelector("description[data-description]");if(u){let d=i.querySelector('meta[name="description"]');d||(d=i.createElement("meta"),d.name="description",i.head.appendChild(d)),d.content=u.getAttribute("data-description")}let r=document.querySelector("keywords[data-keywords]");if(r){let d=i.querySelector('meta[name="keywords"]');d||(d=i.createElement("meta"),d.name="keywords",i.head.appendChild(d)),d.content=r.getAttribute("data-keywords")}return document.querySelectorAll("[data-part]").forEach(d=>{let f=d.getAttribute("data-part"),m=i.querySelector(`[data-part="${f}"]`);m&&(m.innerHTML="",[...d.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}}a(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(),u=Object.entries(e).find(([r,g])=>r.toLowerCase()===i);if(u)return u[1]}a(D,"lookupComponent");async function re(e){var d;let t=e||A.route,n=await Oe(),{componentKey:o,componentName:l,params:i}=ie(t),u=new Set,r=l,g=document.querySelectorAll("[data-component]");for(let f of g){let m=f.getAttribute("data-component"),p=m==null?void 0:m.toLowerCase();if(typeof rvs_map_sigment<"u"&&rvs_map_sigment!==null?r=D(rvs_map_sigment,m):r=p,!r||u.has(r))continue;let y=D(t,r);try{f.hasChildNodes()&&(globalThis.__CURRENT_COMPONENT__=m);let h=y?await Me(y):await Re(A.loadAtRunTime,r),c=y?{...i,...oe(f)}:oe(f),s=h.default(c);s.funcName=l.toLowerCase();let E=(d=f.closest("[data-part]"))==null?void 0:d.getAttribute("data-part");s.datapart=E,s.setAttribute("data-component",m),s.hydrate=!0,f.cmpNbr=$,X(f,s),le.set(r,$),$++,P=0}catch(h){console.warn(`Component "${p}" failed to load`,h)}}}a(re,"hydrateComponent");async function Me(e){if(!M.has(e)){let t=await e.loader();M.set(e,t)}return M.get(e)}a(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)}}}a(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)}a(Xe,"mount");function X(e,t){if(e.hasChildNodes()){let l=[t,...t.querySelectorAll("*")],i=[e,...e.querySelectorAll("*")];l.forEach((u,r)=>{let g=i[r];if(g){u.dataset.index=r;for(let d of u.getAttributeNames()){let f=u.getAttribute(d);if(g.getAttribute(d)!==f){if(d==="data-component"||d==="data-index")continue;g.setAttribute(d,f)}}u.nodeType===Node.TEXT_NODE&&u.nodeValue!==g.nodeValue&&(g.nodeValue=u.nodeValue),u.childNodes[0].nodeType===Node.TEXT_NODE&&u.childNodes[0].nodeValue!==g.nodeValue&&(g.childNodes[0].nodeValue=u.childNodes[0].nodeValue),u._handlers&&u._handlers.forEach(({type:d,val:f})=>{g.addEventListener(d,m=>{A.stopPropagation&&m.stopPropagation(),f(m)})})}}),globalThis.__CURRENT_COMPONENT__=null,P=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,u=>{A.stopPropagation&&u.stopPropagation(),i(u)});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],u=n[l];i&&u?X(i,u):u?e.appendChild(u):i&&e.removeChild(i)}}a(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,Pe as createGlobalSignal,Ge as createSigment,we as createSignal,Be as fetchCache,He as getCookie,je as getGlobalSignal,De as getStorage,H as getVirtualElementById,Pe as globalSignal,H 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,Fe as setCookie,Ne as setStorage,we as signal,We as updateNodeIfNeeded,je as useGlobalSignal};