nuclo 0.1.32 → 0.1.33

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/dist/index.d.ts CHANGED
@@ -1,15 +1,15 @@
1
1
  export { initializeRuntime } from "./core/runtimeBootstrap";
2
- export { registerGlobalTagBuilders, HTML_TAGS, SVG_TAGS, SELF_CLOSING_TAGS, } from "./core/tagRegistry";
2
+ export { registerGlobalTagBuilders, HTML_TAGS, SVG_TAGS, SELF_CLOSING_TAGS } from "./core/tagRegistry";
3
3
  export { createElementFactory, createTagBuilder } from "./core/elementFactory";
4
4
  export { applyNodeModifier } from "./core/modifierProcessor";
5
- export { list, } from "./list";
5
+ export { list } from "./list";
6
6
  export { when } from "./when";
7
7
  export { update } from "./core/updateController";
8
8
  export { applyAttributes } from "./core/attributeManager";
9
9
  export { appendChildren } from "./utility/dom";
10
10
  export { on } from "./utility/on";
11
11
  export { render } from "./utility/render";
12
- export { isBoolean, isFunction, isNode, isObject, isPrimitive, isTagLike, } from "./utility/typeGuards";
12
+ export { isBoolean, isFunction, isNode, isObject, isPrimitive, isTagLike } from "./utility/typeGuards";
13
13
  export { isBrowser } from "./utility/environment";
14
14
  import "./core/runtimeBootstrap";
15
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EACL,yBAAyB,EACzB,SAAS,EACT,QAAQ,EACR,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EACL,IAAI,GACL,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ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BAAsB,CAAC;AACvG,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGlD,OAAO,yBAAyB,CAAC"}
package/dist/nuclo.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";function e(e){return null===e||"object"!=typeof e&&"function"!=typeof e}function t(e){return e instanceof Node}function n(e){return"object"==typeof e&&null!==e}function r(e){return n(e)&&"tagName"in e}function o(e){return"function"==typeof e}function i(e,t){"undefined"!=typeof console&&console.error(`nuclo: ${e}`,t)}function c(e,t){try{return e()}catch(e){return i("Operation failed",e),t}}const u="undefined"!=typeof window&&"undefined"!=typeof document;function a(e){if(!e?.parentNode)return!1;try{return e.parentNode.removeChild(e),!0}catch{return!1}}function s(e){if(!u)return null;try{return document.createComment(e)}catch{return null}}function l(e){if(!u)throw new Error("Cannot create comment in non-browser environment");const t=s(`${e}-${Math.random().toString(36).slice(2)}`);if(!t)throw new Error("Failed to create comment");return t}function d(e){const t=s(`${e}-end`);if(!t)throw new Error("Failed to create end comment");return{start:l(`${e}-start`),end:t}}function f(e){return!!e&&("boolean"==typeof e.isConnected?e.isConnected:document.contains(e))}const p=new Map,h=new Map;function m(e,t){t.attributeResolvers.forEach(({resolver:e,applyValue:t},n)=>{try{t(c(e))}catch(e){i(`Failed to update reactive attribute: ${n}`,e)}})}function g(e,t){if("function"!=typeof e)return i("Invalid resolver provided to createReactiveTextNode"),document.createTextNode("");const n=arguments.length>1?t:c(e,""),r=void 0===n?"":String(n),o=document.createTextNode(r);return p.set(o,{resolver:e,lastValue:r}),o}function y(e,t,n,r){if(!(e instanceof Element&&t&&"function"==typeof n))return void i("Invalid parameters for registerAttributeResolver");const o=function(e){let t=h.get(e);return t||(t={attributeResolvers:new Map},h.set(e,t)),t}(e);o.attributeResolvers.set(t,{resolver:n,applyValue:r});try{r(c(n))}catch(e){i("Failed to apply initial attribute value",e)}if(!o.updateListener){const t=()=>m(0,o);e.addEventListener("update",t),o.updateListener=t}}function v(e,t){e&&e.style&&t&&Object.entries(t).forEach(([t,n])=>{if(null==n||""===n)e.style.removeProperty(t),e.style[t]="";else try{e.style[t]=String(n)}catch{}})}function b(e,t,n){if(null==n)return;if("style"===t)return i=n,void((r=e)&&(o(i)?y(r,"style",()=>{try{return i()}catch{return null}},e=>{v(r,e)}):v(r,i)));var r,i;const c=n=>{null!=n&&(t in e?e[t]=n:e instanceof Element&&e.setAttribute(String(t),String(n)))};o(n)&&0===n.length?y(e,String(t),n,c):c(n)}function x(e,t){if(t)for(const n of Object.keys(t)){b(e,n,t[n])}}const C=new WeakMap;function E(e){const{value:t,error:n}=function(e){const t=C.get(e);if(t)return t;try{const t={value:e(),error:!1};return C.set(e,t),t}catch{const t={value:void 0,error:!0};return C.set(e,t),t}}(e);return!n&&"boolean"==typeof t}function w(e,r,i){if(!o(e)||0!==e.length||!E(e))return!1;const c=r.filter((e,t)=>t!==i);if(0===c.length)return!1;return c.some(e=>n(e)||t(e)||o(e)&&e.length>0)}function M(r,c,u){if(null==c)return null;if(o(c)){if(0===c.length)try{let t=C.get(c);if(!t){t={value:c(),error:!1},C.set(c,t)}if(t.error){const e=document.createDocumentFragment(),t=document.createComment(` text-${u} `),n=g(()=>"");return e.appendChild(t),e.appendChild(n),e}const n=t.value;if(e(n)&&null!=n){const e=document.createDocumentFragment(),t=document.createComment(` text-${u} `),r=g(c,n);return e.appendChild(t),e.appendChild(r),e}return null}catch(e){C.set(c,{value:void 0,error:!0}),i("Error evaluating reactive text function:",e);const t=document.createDocumentFragment(),n=document.createComment(` text-${u} `),r=g(()=>"");return t.appendChild(n),t.appendChild(r),t}const o=c(r,u);if(null==o)return null;if(e(o)){const e=document.createDocumentFragment(),t=document.createComment(` text-${u} `),n=document.createTextNode(String(o));return e.appendChild(t),e.appendChild(n),e}return t(o)?o:(n(o)&&x(r,o),null)}const a=c;if(null==a)return null;if(e(a)){const e=document.createDocumentFragment(),t=document.createComment(` text-${u} `),n=document.createTextNode(String(a));return e.appendChild(t),e.appendChild(n),e}return t(a)?a:(n(a)&&x(r,a),null)}const S=new Set;function N(e,t){e._conditionalInfo=t,S.add(e)}function k(e,t,n=0){if(!t||0===t.length)return{element:e,nextIndex:n,appended:0};let r=n,o=0;const i=e;for(let n=0;n<t.length;n+=1){const c=t[n];if(null==c)continue;const u=M(e,c,r);u&&(u.parentNode!==i&&i.appendChild(u),r+=1,o+=1)}return{element:e,nextIndex:r,appended:o}}function T(e,t){const n=document.createElement(e);return k(n,t,0),n}function F(e){const t=function(e){for(let t=0;t<e.length;t+=1)if(w(e[t],e,t))return t;return-1}(e);return-1===t?{condition:null,otherModifiers:e}:{condition:e[t],otherModifiers:e.filter((e,n)=>n!==t)}}function I(e,...t){return(n,r)=>{const{condition:o,otherModifiers:i}=F(t);if(o)return function(e,t,n){const r=t();if(!u)return r?T(e,n):document.createComment(`conditional-${e}-ssr`);if(r){const r=T(e,n);return N(r,{condition:t,tagName:e,modifiers:n}),r}const o=document.createComment(`conditional-${e}-hidden`);return N(o,{condition:t,tagName:e,modifiers:n}),o}(e,o,i);const c=document.createElement(e);return k(c,i,r),c}}function L(e){return(...t)=>I(e,...t)}const $=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","script","search","section","select","slot","small","source","span","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"];function B(e=globalThis){const t="__vc_tags_registered";e[t]||($.forEach(t=>function(e,t){t in e||(e[t]=L(t))}(e,t)),e[t]=!0)}const _=new Set;function D(e,t,n){return function(e,t,n){if(o(e)){const o=e(t,n);return o&&r(o)?o:null}return e&&r(e)?e:null}(e.renderItem(t,n),e.host,n)}function G(e){a(e.element)}function O(e){const{host:t,startMarker:n,endMarker:r}=e,o=n.parentNode??t,i=e.itemsProvider();if(function(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if((n in e?e[n]:void 0)!==(n in t?t[n]:void 0))return!1;return!0}(e.lastSyncedItems,i))return;const c=new Map,u=new Map;e.records.forEach(e=>{const t=u.get(e.item);t?t.push(e):u.set(e.item,[e])}),i.forEach((t,n)=>{if(n<e.lastSyncedItems.length&&e.lastSyncedItems[n]===t){const r=e.records[n];if(r&&r.item===t){c.set(n,r);const e=u.get(t);if(e){const n=e.indexOf(r);n>=0&&(e.splice(n,1),0===e.length&&u.delete(t))}}}});const a=[],s=new Set(e.records);let l=r;for(let t=i.length-1;t>=0;t--){const n=i[t];let r=c.get(t);if(!r){const e=u.get(n);e&&e.length>0&&(r=e.shift(),0===e.length&&u.delete(n))}if(r)s.delete(r);else{const o=D(e,n,t);if(!o)continue;r={item:n,element:o}}a.unshift(r);const d=r.element;d.nextSibling!==l&&o.insertBefore(d,l),l=d}s.forEach(G),e.records=a,e.lastSyncedItems=[...i]}function j(e,t){return n=>{const r=function(e,t,n){const{start:r,end:o}=d("list"),i={itemsProvider:e,renderItem:t,startMarker:r,endMarker:o,records:[],host:n,lastSyncedItems:[]},c=n;return c.appendChild(r),c.appendChild(o),_.add(i),O(i),i}(e,t,n);return r.startMarker}}function A(e,t){try{return e()}catch(e){if(!t)throw e;return t(e),!1}}function P(e,t){return"function"==typeof e?A(e,t):Boolean(e)}const R=new Set;function V(e){const{groups:t,elseContent:n,host:r,index:i,endMarker:c}=e;let u=null;for(let e=0;e<t.length;e++)if(P(t[e].condition)){u=e;break}if(null===u&&n.length&&(u=-1),u===e.activeIndex)return;if(function(e,t){let n=e.nextSibling;for(;n&&n!==t;){const e=n.nextSibling;a(n),n=e}}(e.startMarker,e.endMarker),e.activeIndex=u,null===u)return;const s=[],l=e=>{for(const t of e){if(o(t)){if(0===t.length){C.delete(t);const e=M(r,t,i);e&&s.push(e);continue}const e=r,n=e.appendChild;e.appendChild=function(t){return e.insertBefore(t,c)};try{const e=M(r,t,i);e&&!e.parentNode&&s.push(e)}finally{e.appendChild=n}continue}const e=M(r,t,i);e&&s.push(e)}};u>=0?l(t[u].content):-1===u&&l(n),function(e,t){const n=t.parentNode;n&&e.forEach(e=>function(e,t,n){if(!e||!t)return!1;try{return e.insertBefore(t,n),!0}catch{return!1}}(n,e,t))}(s,c)}class q{groups=[];elseContent=[];constructor(e,...t){this.groups.push({condition:e,content:t})}when(e,...t){return this.groups.push({condition:e,content:t}),this}else(...e){return this.elseContent=e,this}render(e,t){if(!u)return document.createComment("when-ssr");const{start:n,end:r}=d("when"),o={startMarker:n,endMarker:r,host:e,index:t,groups:[...this.groups],elseContent:[...this.elseContent],activeIndex:null,update:()=>V(o)};R.add(o);const i=e;return i.appendChild(n),i.appendChild(r),V(o),n}}function z(e){return Object.assign((t,n)=>e.render(t,n),{when:(t,...n)=>(e.when(t,...n),z(e)),else:(...t)=>(e.else(...t),z(e))})}function H(e,...t){return z(new q(e,...t))}function W(e,t){if(e.parentNode)try{e.parentNode.replaceChild(t,e)}catch(e){console.error("Error replacing conditional node:",e)}}function J(e){const t=function(e){return e._conditionalInfo??null}(e);if(!t)return;const n=A(t.condition,e=>{console.error("Error evaluating conditional condition:",e)}),r=e.nodeType===Node.ELEMENT_NODE;if(n&&!r){const n=function(e){const t=document.createElement(e.tagName);try{k(t,e.modifiers,0)}catch(t){console.error(`Error applying modifiers in conditional element "${e.tagName}":`,t)}return t}(t);N(n,t),W(e,n)}else if(!n&&r){const n=function(e){return document.createComment(`conditional-${e.tagName}-hidden`)}(t);N(n,t),W(e,n)}}const K=[function(){_.forEach(e=>{e.startMarker.isConnected&&e.endMarker.isConnected?O(e):_.delete(e)})},function(){R.forEach(e=>{try{e.update()}catch(t){R.delete(e)}})},function(){if(u)try{S.forEach(e=>{e.isConnected?J(e):function(e){S.delete(e)}(e)})}catch(e){console.error("Error during conditional elements update:",e)}},function(){h.forEach((e,t)=>{if(!f(t))return e.updateListener&&t.removeEventListener("update",e.updateListener),void h.delete(t);m(0,e)})},function(){p.forEach((e,t)=>{if(f(t))try{const n=c(e.resolver),r=void 0===n?"":String(n);r!==e.lastValue&&(t.textContent=r,e.lastValue=r)}catch(e){i("Failed to update reactive text node",e)}else p.delete(t)})},function(){if("undefined"==typeof document)return;const e=[];document.body&&e.push(document.body),e.push(document),e.forEach(e=>{try{e.dispatchEvent(new Event("update",{bubbles:!0}))}catch(e){console.error("Error dispatching global update event:",e)}})}];function Q(){for(const e of K)e()}function U(e,t,n){return r=>{const o=r;if(!o||"function"!=typeof o.addEventListener)return;o.addEventListener(e,n=>{try{t.call(o,n)}catch(t){"undefined"!=typeof console&&console.error&&console.error(`[nuclo:on] Error in '${e}' listener:`,t)}},n)}}function X(e,t,n=0){const r=e(t||document.body,n);return(t||document.body).appendChild(r),r}function Y(){if(B(),"undefined"!=typeof globalThis){const e=globalThis;e.list=j,e.update=Q,e.when=H,e.on=U,e.render=X}}"undefined"!=typeof globalThis&&Y(),console.log("nuclo"),exports.HTML_TAGS=$,exports.SELF_CLOSING_TAGS=["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"],exports.SVG_TAGS=["a","animate","animateMotion","animateTransform","circle","clipPath","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","foreignObject","g","image","line","linearGradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","stop","style","svg","switch","symbol","text","textPath","title","tspan","use","view"],exports.appendChildren=function(e,...t){return e?(t.forEach(t=>{if(null!=t){let n;if("string"==typeof t){const e=function(e){if(!u)return null;try{return document.createTextNode(String(e))}catch{return null}}(t);if(!e)return;n=e}else n=t;!function(e,t){if(!e||!t)return!1;try{return e.appendChild(t),!0}catch{return!1}}(e,n)}}),e):e},exports.applyAttributes=x,exports.applyNodeModifier=M,exports.createElementFactory=I,exports.createTagBuilder=L,exports.initializeRuntime=Y,exports.isBoolean=function(e){return"boolean"==typeof e},exports.isBrowser=u,exports.isFunction=o,exports.isNode=t,exports.isObject=n,exports.isPrimitive=e,exports.isTagLike=r,exports.list=j,exports.on=U,exports.registerGlobalTagBuilders=B,exports.render=X,exports.update=Q,exports.when=H;
1
+ "use strict";function e(e){return null===e||"object"!=typeof e&&"function"!=typeof e}function t(e){return e instanceof Node}function n(e){return"object"==typeof e&&null!==e}function r(e){return n(e)&&"tagName"in e}function o(e){return"function"==typeof e}function i(e,t){"undefined"!=typeof console&&console.error(`nuclo: ${e}`,t)}function c(e,t){try{return e()}catch(e){return i("Operation failed",e),t}}const u="undefined"!=typeof window&&"undefined"!=typeof document;function a(e){if(!e?.parentNode)return!1;try{return e.parentNode.removeChild(e),!0}catch{return!1}}function s(e){if(!u)return null;try{return document.createComment(e)}catch{return null}}function l(e){if(!u)throw new Error("Cannot create comment in non-browser environment");const t=s(`${e}-${Math.random().toString(36).slice(2)}`);if(!t)throw new Error("Failed to create comment");return t}function d(e){const t=s(`${e}-end`);if(!t)throw new Error("Failed to create end comment");return{start:l(`${e}-start`),end:t}}function f(e){return!!e&&("boolean"==typeof e.isConnected?e.isConnected:document.contains(e))}const p=new Map,h=new Map;function m(e,t){t.attributeResolvers.forEach(({resolver:e,applyValue:t},n)=>{try{t(c(e))}catch(e){i(`Failed to update reactive attribute: ${n}`,e)}})}function g(e,t){if("function"!=typeof e)return i("Invalid resolver provided to createReactiveTextNode"),document.createTextNode("");const n=arguments.length>1?t:c(e,""),r=void 0===n?"":String(n),o=document.createTextNode(r);return p.set(o,{resolver:e,lastValue:r}),o}function y(e,t,n,r){if(!(e instanceof Element&&t&&"function"==typeof n))return void i("Invalid parameters for registerAttributeResolver");const o=function(e){let t=h.get(e);return t||(t={attributeResolvers:new Map},h.set(e,t)),t}(e);o.attributeResolvers.set(t,{resolver:n,applyValue:r});try{r(c(n))}catch(e){i("Failed to apply initial attribute value",e)}if(!o.updateListener){const t=()=>m(0,o);e.addEventListener("update",t),o.updateListener=t}}function v(e,t){e&&e.style&&t&&Object.entries(t).forEach(([t,n])=>{if(null==n||""===n)e.style.removeProperty(t),e.style[t]="";else try{e.style[t]=String(n)}catch{}})}function b(e,t,n){if(null==n)return;if("style"===t)return i=n,void((r=e)&&(o(i)?y(r,"style",()=>{try{return i()}catch{return null}},e=>{v(r,e)}):v(r,i)));var r,i;const c=n=>{null!=n&&(t in e?e[t]=n:e instanceof Element&&e.setAttribute(String(t),String(n)))};o(n)&&0===n.length?y(e,String(t),n,c):c(n)}function x(e,t){if(t)for(const n of Object.keys(t)){b(e,n,t[n])}}const C=new WeakMap;function E(e){const{value:t,error:n}=function(e){const t=C.get(e);if(t)return t;try{const t={value:e(),error:!1};return C.set(e,t),t}catch{const t={value:void 0,error:!0};return C.set(e,t),t}}(e);return!n&&"boolean"==typeof t}function w(e,r,i){if(!o(e)||0!==e.length||!E(e))return!1;const c=r.filter((e,t)=>t!==i);if(0===c.length)return!1;return c.some(e=>n(e)||t(e)||o(e)&&e.length>0)}function M(r,c,u){if(null==c)return null;if(o(c)){if(0===c.length)try{let t=C.get(c);if(!t){t={value:c(),error:!1},C.set(c,t)}if(t.error){const e=document.createDocumentFragment(),t=document.createComment(` text-${u} `),n=g(()=>"");return e.appendChild(t),e.appendChild(n),e}const n=t.value;if(e(n)&&null!=n){const e=document.createDocumentFragment(),t=document.createComment(` text-${u} `),r=g(c,n);return e.appendChild(t),e.appendChild(r),e}return null}catch(e){C.set(c,{value:void 0,error:!0}),i("Error evaluating reactive text function:",e);const t=document.createDocumentFragment(),n=document.createComment(` text-${u} `),r=g(()=>"");return t.appendChild(n),t.appendChild(r),t}const o=c(r,u);if(null==o)return null;if(e(o)){const e=document.createDocumentFragment(),t=document.createComment(` text-${u} `),n=document.createTextNode(String(o));return e.appendChild(t),e.appendChild(n),e}return t(o)?o:(n(o)&&x(r,o),null)}const a=c;if(null==a)return null;if(e(a)){const e=document.createDocumentFragment(),t=document.createComment(` text-${u} `),n=document.createTextNode(String(a));return e.appendChild(t),e.appendChild(n),e}return t(a)?a:(n(a)&&x(r,a),null)}const S=new Set;function N(e,t){e._conditionalInfo=t,S.add(e)}function k(e,t,n=0){if(!t||0===t.length)return{element:e,nextIndex:n,appended:0};let r=n,o=0;const i=e;for(let n=0;n<t.length;n+=1){const c=t[n];if(null==c)continue;const u=M(e,c,r);u&&(u.parentNode!==i&&i.appendChild(u),r+=1,o+=1)}return{element:e,nextIndex:r,appended:o}}function T(e,t){const n=document.createElement(e);return k(n,t,0),n}function F(e){const t=function(e){for(let t=0;t<e.length;t+=1)if(w(e[t],e,t))return t;return-1}(e);return-1===t?{condition:null,otherModifiers:e}:{condition:e[t],otherModifiers:e.filter((e,n)=>n!==t)}}function I(e,...t){return(n,r)=>{const{condition:o,otherModifiers:i}=F(t);if(o)return function(e,t,n){const r=t();if(!u)return r?T(e,n):document.createComment(`conditional-${e}-ssr`);if(r){const r=T(e,n);return N(r,{condition:t,tagName:e,modifiers:n}),r}const o=document.createComment(`conditional-${e}-hidden`);return N(o,{condition:t,tagName:e,modifiers:n}),o}(e,o,i);const c=document.createElement(e);return k(c,i,r),c}}function L(e){return(...t)=>I(e,...t)}const $=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","script","search","section","select","slot","small","source","span","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"];function B(e=globalThis){const t="__vc_tags_registered";e[t]||($.forEach(t=>function(e,t){t in e||(e[t]=L(t))}(e,t)),e[t]=!0)}const _=new Set;function D(e,t,n){return function(e,t,n){if(o(e)){const o=e(t,n);return o&&r(o)?o:null}return e&&r(e)?e:null}(e.renderItem(t,n),e.host,n)}function G(e){a(e.element)}function O(e){const{host:t,startMarker:n,endMarker:r}=e,o=n.parentNode??t,i=e.itemsProvider();if(function(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if((n in e?e[n]:void 0)!==(n in t?t[n]:void 0))return!1;return!0}(e.lastSyncedItems,i))return;const c=new Map,u=new Map;e.records.forEach(e=>{const t=u.get(e.item);t?t.push(e):u.set(e.item,[e])}),i.forEach((t,n)=>{if(n<e.lastSyncedItems.length&&e.lastSyncedItems[n]===t){const r=e.records[n];if(r&&r.item===t){c.set(n,r);const e=u.get(t);if(e){const n=e.indexOf(r);n>=0&&(e.splice(n,1),0===e.length&&u.delete(t))}}}});const a=[],s=new Set(e.records);let l=r;for(let t=i.length-1;t>=0;t--){const n=i[t];let r=c.get(t);if(!r){const e=u.get(n);e&&e.length>0&&(r=e.shift(),0===e.length&&u.delete(n))}if(r)s.delete(r);else{const o=D(e,n,t);if(!o)continue;r={item:n,element:o}}a.unshift(r);const d=r.element;d.nextSibling!==l&&o.insertBefore(d,l),l=d}s.forEach(G),e.records=a,e.lastSyncedItems=[...i]}function j(e,t){return n=>{const r=function(e,t,n){const{start:r,end:o}=d("list"),i={itemsProvider:e,renderItem:t,startMarker:r,endMarker:o,records:[],host:n,lastSyncedItems:[]},c=n;return c.appendChild(r),c.appendChild(o),_.add(i),O(i),i}(e,t,n);return r.startMarker}}function A(e,t){try{return e()}catch(e){if(!t)throw e;return t(e),!1}}function P(e,t){return"function"==typeof e?A(e,t):Boolean(e)}const R=new Set;function V(e){const{groups:t,elseContent:n,host:r,index:i,endMarker:c}=e;let u=null;for(let e=0;e<t.length;e++)if(P(t[e].condition)){u=e;break}if(null===u&&n.length&&(u=-1),u===e.activeIndex)return;if(function(e,t){let n=e.nextSibling;for(;n&&n!==t;){const e=n.nextSibling;a(n),n=e}}(e.startMarker,e.endMarker),e.activeIndex=u,null===u)return;const s=[],l=e=>{for(const t of e){if(o(t)){if(0===t.length){C.delete(t);const e=M(r,t,i);e&&s.push(e);continue}const e=r,n=e.appendChild;e.appendChild=function(t){return e.insertBefore(t,c)};try{const e=M(r,t,i);e&&!e.parentNode&&s.push(e)}finally{e.appendChild=n}continue}const e=M(r,t,i);e&&s.push(e)}};u>=0?l(t[u].content):-1===u&&l(n),function(e,t){const n=t.parentNode;n&&e.forEach(e=>function(e,t,n){if(!e||!t)return!1;try{return e.insertBefore(t,n),!0}catch{return!1}}(n,e,t))}(s,c)}class q{groups=[];elseContent=[];constructor(e,...t){this.groups.push({condition:e,content:t})}when(e,...t){return this.groups.push({condition:e,content:t}),this}else(...e){return this.elseContent=e,this}render(e,t){if(!u)return document.createComment("when-ssr");const{start:n,end:r}=d("when"),o={startMarker:n,endMarker:r,host:e,index:t,groups:[...this.groups],elseContent:[...this.elseContent],activeIndex:null,update:()=>V(o)};R.add(o);const i=e;return i.appendChild(n),i.appendChild(r),V(o),n}}function z(e){return Object.assign((t,n)=>e.render(t,n),{when:(t,...n)=>(e.when(t,...n),z(e)),else:(...t)=>(e.else(...t),z(e))})}function H(e,...t){return z(new q(e,...t))}function W(e,t){if(e.parentNode)try{e.parentNode.replaceChild(t,e)}catch(e){console.error("Error replacing conditional node:",e)}}function J(e){const t=function(e){return e._conditionalInfo??null}(e);if(!t)return;const n=A(t.condition,e=>{console.error("Error evaluating conditional condition:",e)}),r=e.nodeType===Node.ELEMENT_NODE;if(n&&!r){const n=function(e){const t=document.createElement(e.tagName);try{k(t,e.modifiers,0)}catch(t){console.error(`Error applying modifiers in conditional element "${e.tagName}":`,t)}return t}(t);N(n,t),W(e,n)}else if(!n&&r){const n=function(e){return document.createComment(`conditional-${e.tagName}-hidden`)}(t);N(n,t),W(e,n)}}const K=[function(){_.forEach(e=>{e.startMarker.isConnected&&e.endMarker.isConnected?O(e):_.delete(e)})},function(){R.forEach(e=>{try{e.update()}catch(t){R.delete(e)}})},function(){if(u)try{S.forEach(e=>{e.isConnected?J(e):function(e){S.delete(e)}(e)})}catch(e){console.error("Error during conditional elements update:",e)}},function(){h.forEach((e,t)=>{if(!f(t))return e.updateListener&&t.removeEventListener("update",e.updateListener),void h.delete(t);m(0,e)})},function(){p.forEach((e,t)=>{if(f(t))try{const n=c(e.resolver),r=void 0===n?"":String(n);r!==e.lastValue&&(t.textContent=r,e.lastValue=r)}catch(e){i("Failed to update reactive text node",e)}else p.delete(t)})},function(){if("undefined"==typeof document)return;const e=[];document.body&&e.push(document.body),e.push(document),e.forEach(e=>{try{e.dispatchEvent(new Event("update",{bubbles:!0}))}catch(e){console.error("Error dispatching global update event:",e)}})}];function Q(){for(const e of K)e()}function U(e,t,n){return r=>{const o=r;if(!o||"function"!=typeof o.addEventListener)return;o.addEventListener(e,n=>{try{t.call(o,n)}catch(t){"undefined"!=typeof console&&console.error&&console.error(`[nuclo:on] Error in '${e}' listener:`,t)}},n)}}function X(e,t,n=0){const r=e(t||document.body,n);return(t||document.body).appendChild(r),r}function Y(){if(B(),"undefined"!=typeof globalThis){const e=globalThis;e.list=j,e.update=Q,e.when=H,e.on=U,e.render=X}}"undefined"!=typeof globalThis&&Y(),exports.HTML_TAGS=$,exports.SELF_CLOSING_TAGS=["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"],exports.SVG_TAGS=["a","animate","animateMotion","animateTransform","circle","clipPath","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","foreignObject","g","image","line","linearGradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","stop","style","svg","switch","symbol","text","textPath","title","tspan","use","view"],exports.appendChildren=function(e,...t){return e?(t.forEach(t=>{if(null!=t){let n;if("string"==typeof t){const e=function(e){if(!u)return null;try{return document.createTextNode(String(e))}catch{return null}}(t);if(!e)return;n=e}else n=t;!function(e,t){if(!e||!t)return!1;try{return e.appendChild(t),!0}catch{return!1}}(e,n)}}),e):e},exports.applyAttributes=x,exports.applyNodeModifier=M,exports.createElementFactory=I,exports.createTagBuilder=L,exports.initializeRuntime=Y,exports.isBoolean=function(e){return"boolean"==typeof e},exports.isBrowser=u,exports.isFunction=o,exports.isNode=t,exports.isObject=n,exports.isPrimitive=e,exports.isTagLike=r,exports.list=j,exports.on=U,exports.registerGlobalTagBuilders=B,exports.render=X,exports.update=Q,exports.when=H;
2
2
  //# sourceMappingURL=nuclo.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"nuclo.cjs","sources":["../src/utility/typeGuards.ts","../src/utility/errorHandler.ts","../src/utility/environment.ts","../src/utility/dom.ts","../src/core/reactive.ts","../src/core/styleManager.ts","../src/core/attributeManager.ts","../src/utility/modifierPredicates.ts","../src/core/modifierProcessor.ts","../src/utility/conditionalInfo.ts","../src/internal/applyModifiers.ts","../src/core/conditionalRenderer.ts","../src/core/elementFactory.ts","../src/core/tagRegistry.ts","../src/list/runtime.ts","../src/utility/renderables.ts","../src/utility/arrayUtils.ts","../src/list/renderer.ts","../src/utility/conditions.ts","../src/when/index.ts","../src/core/conditionalUpdater.ts","../src/core/updateController.ts","../src/utility/events.ts","../src/utility/on.ts","../src/utility/render.ts","../src/core/runtimeBootstrap.ts","../src/index.ts"],"sourcesContent":["export function isPrimitive(value: unknown): value is Primitive {\n return value === null || (typeof value !== \"object\" && typeof value !== \"function\");\n}\n\nexport function isNode<T>(value: T): value is T & Node {\n return value instanceof Node;\n}\n\nexport function isObject(value: unknown): value is object {\n return typeof value === \"object\" && value !== null;\n}\n\nexport function isTagLike<T>(value: T): value is T & { tagName?: string } {\n return isObject(value) && \"tagName\" in (value as object);\n}\n\nexport function isBoolean(value: unknown): value is boolean {\n return typeof value === \"boolean\";\n}\n\nexport function isFunction<T extends Function>(value: unknown): value is T {\n return typeof value === \"function\";\n}\n","/**\n * Simplified error handling for nuclo - reduced complexity for smaller bundle size\n */\n\n// Basic error logging - no complex context tracking\nexport function logError(message: string, error?: Error | unknown): void {\n if (typeof console !== 'undefined') {\n console.error(`nuclo: ${message}`, error);\n }\n}\n\n// Simplified safe execution - no complex context\nexport function safeExecute<T>(fn: () => T, fallback?: T): T | undefined {\n try {\n return fn();\n } catch (error) {\n logError(\"Operation failed\", error);\n return fallback;\n }\n}\n\n// Basic DOM error handler\nexport function handleDOMError(error: Error | unknown, operation: string): void {\n logError(`DOM ${operation} failed`, error);\n}","/**\n * Simplified environment detection - minimal overhead for smaller bundle size\n */\n\n// Basic environment detection - no complex caching or edge cases\nexport const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';\n","import { isBrowser } from \"./environment\";\n\nfunction safeAppendChild(parent: Element | Node, child: Node): boolean {\n if (!parent || !child) return false;\n try {\n parent.appendChild(child);\n return true;\n } catch {\n return false;\n }\n}\n\nexport function safeRemoveChild(child: Node): boolean {\n if (!child?.parentNode) return false;\n try {\n child.parentNode.removeChild(child);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction safeInsertBefore(parent: Node, newNode: Node, referenceNode: Node | null): boolean {\n if (!parent || !newNode) return false;\n try {\n parent.insertBefore(newNode, referenceNode);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction createTextNodeSafely(text: string | number | boolean): Text | null {\n if (!isBrowser) return null;\n try {\n return document.createTextNode(String(text));\n } catch {\n return null;\n }\n}\n\nfunction createCommentSafely(text: string): Comment | null {\n if (!isBrowser) return null;\n try {\n return document.createComment(text);\n } catch {\n return null;\n }\n}\n\nexport function createMarkerComment(prefix: string): Comment {\n if (!isBrowser) {\n throw new Error(\"Cannot create comment in non-browser environment\");\n }\n const comment = createCommentSafely(`${prefix}-${Math.random().toString(36).slice(2)}`);\n if (!comment) {\n throw new Error(\"Failed to create comment\");\n }\n return comment;\n}\n\nexport function createMarkerPair(prefix: string): { start: Comment; end: Comment } {\n const endComment = createCommentSafely(`${prefix}-end`);\n if (!endComment) {\n throw new Error(\"Failed to create end comment\");\n }\n return {\n start: createMarkerComment(`${prefix}-start`),\n end: endComment\n };\n}\n\nexport function clearBetweenMarkers(startMarker: Comment, endMarker: Comment): void {\n let current = startMarker.nextSibling;\n while (current && current !== endMarker) {\n const next = current.nextSibling;\n safeRemoveChild(current);\n current = next;\n }\n}\n\nexport function insertNodesBefore(nodes: Node[], referenceNode: Node): void {\n const parent = referenceNode.parentNode;\n if (parent) {\n nodes.forEach(node => safeInsertBefore(parent, node, referenceNode));\n }\n}\n\nexport function appendChildren(\n parent: Element | Node,\n ...children: Array<Element | Node | string | null | undefined>\n): Element | Node {\n if (!parent) return parent;\n\n children.forEach((child) => {\n if (child != null) {\n let nodeToAppend: Node;\n\n if (typeof child === \"string\") {\n const textNode = createTextNodeSafely(child);\n if (textNode) {\n nodeToAppend = textNode;\n } else {\n return;\n }\n } else {\n nodeToAppend = child as Node;\n }\n\n safeAppendChild(parent, nodeToAppend);\n }\n });\n\n return parent;\n}\n\nexport function isNodeConnected(node: Node | null | undefined): boolean {\n if (!node) return false;\n return typeof node.isConnected === \"boolean\" ? node.isConnected : document.contains(node);\n}\n","import { logError, safeExecute } from \"../utility/errorHandler\";\nimport { isNodeConnected } from \"../utility/dom\";\n\ntype TextResolver = () => Primitive;\ntype AttributeResolver = () => unknown;\n\ninterface AttributeResolverRecord {\n resolver: AttributeResolver;\n applyValue: (value: unknown) => void;\n}\n\ninterface ReactiveTextNodeInfo {\n resolver: TextResolver;\n lastValue: string;\n}\n\ninterface ReactiveElementInfo {\n attributeResolvers: Map<string, AttributeResolverRecord>;\n updateListener?: EventListener;\n}\n\nconst reactiveTextNodes = new Map<Text, ReactiveTextNodeInfo>();\nconst reactiveElements = new Map<Element, ReactiveElementInfo>();\n\nfunction ensureElementInfo(el: Element): ReactiveElementInfo {\n let info = reactiveElements.get(el);\n if (!info) {\n info = { attributeResolvers: new Map() };\n reactiveElements.set(el, info);\n }\n return info;\n}\n\nfunction applyAttributeResolvers(el: Element, info: ReactiveElementInfo): void {\n info.attributeResolvers.forEach(({ resolver, applyValue }, key) => {\n try {\n applyValue(safeExecute(resolver));\n } catch (e) {\n logError(`Failed to update reactive attribute: ${key}`, e);\n }\n });\n}\n\nexport function createReactiveTextNode(resolver: TextResolver, preEvaluated?: unknown): Text | DocumentFragment {\n if (typeof resolver !== \"function\") {\n logError(\"Invalid resolver provided to createReactiveTextNode\");\n return document.createTextNode(\"\");\n }\n\n const initial = arguments.length > 1 ? preEvaluated : safeExecute(resolver, \"\");\n const str = initial === undefined ? \"\" : String(initial);\n const txt = document.createTextNode(str);\n\n reactiveTextNodes.set(txt, { resolver, lastValue: str });\n return txt;\n}\n\nexport function registerAttributeResolver<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n key: string,\n resolver: AttributeResolver,\n applyValue: (value: unknown) => void\n): void {\n if (!(element instanceof Element) || !key || typeof resolver !== \"function\") {\n logError(\"Invalid parameters for registerAttributeResolver\");\n return;\n }\n const info = ensureElementInfo(element as Element);\n info.attributeResolvers.set(key, { resolver, applyValue });\n\n try {\n applyValue(safeExecute(resolver));\n } catch (e) {\n logError(\"Failed to apply initial attribute value\", e);\n }\n\n if (!info.updateListener) {\n const listener: EventListener = () => applyAttributeResolvers(element as Element, info);\n (element as Element).addEventListener(\"update\", listener);\n info.updateListener = listener;\n }\n}\n\nexport function notifyReactiveTextNodes(): void {\n reactiveTextNodes.forEach((info, node) => {\n if (!isNodeConnected(node)) {\n reactiveTextNodes.delete(node);\n return;\n }\n try {\n const raw = safeExecute(info.resolver);\n const newVal = raw === undefined ? \"\" : String(raw);\n if (newVal !== info.lastValue) {\n node.textContent = newVal;\n info.lastValue = newVal;\n }\n } catch (e) {\n logError(\"Failed to update reactive text node\", e);\n }\n });\n}\n\nexport function notifyReactiveElements(): void {\n reactiveElements.forEach((info, el) => {\n if (!isNodeConnected(el)) {\n if (info.updateListener) el.removeEventListener(\"update\", info.updateListener);\n reactiveElements.delete(el);\n return;\n }\n applyAttributeResolvers(el, info);\n });\n}\n","import { isFunction } from \"../utility/typeGuards\";\nimport { registerAttributeResolver } from \"./reactive\";\n\ntype StyleAssignment = Partial<CSSStyleDeclaration>;\ntype StyleResolver = () => StyleAssignment | null | undefined;\n\n/**\n * Simplified style management - basic functionality with minimal overhead\n */\nexport function assignInlineStyles<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n styles: StyleAssignment | null | undefined,\n): void {\n if (!element) return;\n if (!element.style) return; // Guard against elements without style\n if (!styles) return;\n\n Object.entries(styles).forEach(([property, value]) => {\n if (value == null || value === '') {\n // Try both camelCase and kebab-case removal\n element.style!.removeProperty(property);\n // Also set to empty string as fallback\n (element.style as any)[property] = '';\n } else {\n try {\n (element.style as any)[property] = String(value);\n } catch {\n // Ignore invalid style properties\n }\n }\n });\n}\n\nexport function applyStyleAttribute<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n styleValue: StyleAssignment | StyleResolver | null | undefined\n): void {\n if (!element) return;\n\n if (isFunction(styleValue)) {\n registerAttributeResolver(element, 'style', () => {\n try {\n return styleValue();\n } catch {\n return null;\n }\n }, (resolvedStyles) => {\n assignInlineStyles(element, resolvedStyles as StyleAssignment);\n });\n } else {\n assignInlineStyles(element, styleValue);\n }\n}","import { isFunction } from \"../utility/typeGuards\";\nimport { registerAttributeResolver, createReactiveTextNode } from \"./reactive\";\nimport { applyStyleAttribute } from \"./styleManager\";\n\ntype AttributeKey<TTagName extends ElementTagName> = keyof ExpandedElementAttributes<TTagName>;\ntype AttributeCandidate<TTagName extends ElementTagName> =\n ExpandedElementAttributes<TTagName>[AttributeKey<TTagName>];\n\nfunction applySingleAttribute<TTagName extends ElementTagName>(\n el: ExpandedElement<TTagName>,\n key: AttributeKey<TTagName>,\n raw: AttributeCandidate<TTagName> | undefined,\n): void {\n if (raw == null) return;\n\n if (key === \"style\") {\n applyStyleAttribute(el, raw as ExpandedElementAttributes<TTagName>[\"style\"]);\n return;\n }\n\n const setValue = (v: unknown): void => {\n if (v == null) return;\n if (key in el) {\n (el as Record<string, unknown>)[key as string] = v;\n } else if (el instanceof Element) {\n el.setAttribute(String(key), String(v));\n }\n };\n\n if (isFunction(raw) && (raw as Function).length === 0) {\n registerAttributeResolver(el, String(key), raw as () => unknown, setValue);\n } else {\n setValue(raw);\n }\n}\n\nexport function applyAttributes<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n attributes: ExpandedElementAttributes<TTagName>,\n): void {\n if (!attributes) return;\n for (const k of Object.keys(attributes) as Array<AttributeKey<TTagName>>) {\n const value = (attributes as Record<string, unknown>)[k as string] as\n AttributeCandidate<TTagName> | undefined;\n applySingleAttribute(element, k, value);\n }\n}\n\nexport { createReactiveTextNode } from \"./reactive\";\n","import { isFunction, isNode, isObject } from \"./typeGuards\";\n\ntype AnyModifier = unknown;\ntype BooleanCondition = () => boolean;\n\nconst modifierProbeCache = new WeakMap<Function, { value: unknown; error: boolean }>();\n\nfunction probeOnce(fn: Function): { value: unknown; error: boolean } {\n const cached = modifierProbeCache.get(fn);\n if (cached) {\n return cached;\n }\n try {\n const value = fn();\n const record = { value, error: false };\n modifierProbeCache.set(fn, record);\n return record;\n } catch {\n const record = { value: undefined, error: true };\n modifierProbeCache.set(fn, record);\n return record;\n }\n}\n\nfunction isBooleanFunction(fn: Function): fn is BooleanCondition {\n const { value, error } = probeOnce(fn);\n if (error) return false;\n return typeof value === \"boolean\";\n}\n\nexport function isConditionalModifier(\n modifier: AnyModifier,\n allModifiers: AnyModifier[],\n currentIndex: number\n): modifier is BooleanCondition {\n if (\n !isFunction(modifier) ||\n (modifier as Function).length !== 0 ||\n !isBooleanFunction(modifier as Function)\n ) {\n return false;\n }\n\n const otherModifiers = allModifiers.filter((_, index) => index !== currentIndex);\n if (otherModifiers.length === 0) return false;\n\n const hasAttributesOrElements = otherModifiers.some(\n (mod) =>\n isObject(mod) || isNode(mod) || (isFunction(mod) && (mod as Function).length > 0)\n );\n\n return hasAttributesOrElements;\n}\n\nexport function findConditionalModifier(modifiers: AnyModifier[]): number {\n for (let i = 0; i < modifiers.length; i += 1) {\n if (isConditionalModifier(modifiers[i], modifiers, i)) {\n return i;\n }\n }\n return -1;\n}\n\nexport { modifierProbeCache };\n","import { applyAttributes } from \"./attributeManager\";\nimport { createReactiveTextNode } from \"./reactive\";\nimport { logError } from \"../utility/errorHandler\";\nimport { isFunction, isNode, isObject, isPrimitive } from \"../utility/typeGuards\";\nimport { modifierProbeCache } from \"../utility/modifierPredicates\";\nexport { isConditionalModifier, findConditionalModifier } from \"../utility/modifierPredicates\";\n\nexport type NodeModifier<TTagName extends ElementTagName = ElementTagName> =\n | NodeMod<TTagName>\n | NodeModFn<TTagName>;\n\nexport function applyNodeModifier<TTagName extends ElementTagName>(\n parent: ExpandedElement<TTagName>,\n modifier: NodeModifier<TTagName>,\n index: number,\n): Node | null {\n if (modifier == null) return null;\n\n if (isFunction(modifier)) {\n if (modifier.length === 0) {\n try {\n let record = modifierProbeCache.get(modifier as Function);\n if (!record) {\n const value = (modifier as () => unknown)();\n record = { value, error: false };\n modifierProbeCache.set(modifier as Function, record);\n }\n if (record.error) {\n const fragment = document.createDocumentFragment();\n const comment = document.createComment(` text-${index} `);\n const textNode = createReactiveTextNode(() => \"\");\n fragment.appendChild(comment);\n fragment.appendChild(textNode);\n return fragment;\n }\n const v = record.value;\n if (isPrimitive(v) && v != null) {\n const fragment = document.createDocumentFragment();\n const comment = document.createComment(` text-${index} `);\n const textNode = createReactiveTextNode(modifier as () => Primitive, v);\n fragment.appendChild(comment);\n fragment.appendChild(textNode);\n return fragment;\n }\n return null;\n } catch (error) {\n modifierProbeCache.set(modifier as Function, { value: undefined, error: true });\n logError(\"Error evaluating reactive text function:\", error);\n const fragment = document.createDocumentFragment();\n const comment = document.createComment(` text-${index} `);\n const textNode = createReactiveTextNode(() => \"\");\n fragment.appendChild(comment);\n fragment.appendChild(textNode);\n return fragment;\n }\n }\n\n const produced = (modifier as NodeModFn<TTagName>)(parent, index);\n if (produced == null) return null;\n if (isPrimitive(produced)) {\n const fragment = document.createDocumentFragment();\n const comment = document.createComment(` text-${index} `);\n const textNode = document.createTextNode(String(produced));\n fragment.appendChild(comment);\n fragment.appendChild(textNode);\n return fragment;\n }\n if (isNode(produced)) return produced;\n if (isObject(produced)) {\n applyAttributes(parent, produced as ExpandedElementAttributes<TTagName>);\n }\n return null;\n }\n\n const candidate = modifier as NodeMod<TTagName>;\n if (candidate == null) return null;\n if (isPrimitive(candidate)) {\n const fragment = document.createDocumentFragment();\n const comment = document.createComment(` text-${index} `);\n const textNode = document.createTextNode(String(candidate));\n fragment.appendChild(comment);\n fragment.appendChild(textNode);\n return fragment;\n }\n if (isNode(candidate)) return candidate;\n if (isObject(candidate)) {\n applyAttributes(parent, candidate as ExpandedElementAttributes<TTagName>);\n }\n return null;\n}\n","export interface ConditionalInfo {\n condition: () => boolean;\n tagName: string;\n modifiers: Array<NodeMod<any> | NodeModFn<any>>;\n}\n\n/**\n * Registry of all nodes that have conditional info attached.\n * This enables O(nConditionals) updates instead of a full DOM tree walk.\n */\nconst activeConditionalNodes = new Set<Node>();\n\n/**\n * Attach conditional info to a node and register it.\n */\nexport function storeConditionalInfo(\n node: Node,\n info: ConditionalInfo\n): void {\n (node as any)._conditionalInfo = info;\n activeConditionalNodes.add(node);\n}\n\n/**\n * Explicit unregister helper (optional use on teardown if needed).\n */\nexport function unregisterConditionalNode(node: Node): void {\n activeConditionalNodes.delete(node);\n}\n\n/**\n * Returns a readonly view of currently tracked conditional nodes.\n */\nexport function getActiveConditionalNodes(): ReadonlySet<Node> {\n return activeConditionalNodes;\n}\n\nexport function hasConditionalInfo(node: Node): boolean {\n return Boolean((node as any)._conditionalInfo);\n}\n\nexport function getConditionalInfo(node: Node): ConditionalInfo | null {\n return ((node as any)._conditionalInfo as ConditionalInfo | undefined) ?? null;\n}\n","/**\n * Shared helper for applying an array of modifiers to an element.\n * Consolidates the previously duplicated logic in several modules:\n * - conditionalRenderer\n * - conditionalUpdater\n * - elementFactory\n *\n * Goal: single, optimized, well‑typed implementation.\n *\n * A \"modifier\" can:\n * - Return (or be) primitives → appended as text\n * - Return (or be) Node → appended (if not already a child)\n * - Return (or be) attribute objects → merged into element\n * - Be a NodeModFn invoked with (parent, index)\n * - Be a zero‑arg function producing reactive text (handled upstream in applyNodeModifier)\n *\n * Indexing:\n * - startIndex allows callers to continue an index sequence if needed.\n * - Every successfully rendered child Node increments the local index.\n */\nimport { applyNodeModifier } from \"../core/modifierProcessor\";\n\nexport type NodeModifier<TTagName extends ElementTagName = ElementTagName> =\n | NodeMod<TTagName>\n | NodeModFn<TTagName>;\n\nexport interface ApplyModifiersResult<TTagName extends ElementTagName> {\n /**\n * The element passed in (for fluent patterns if desired).\n */\n element: ExpandedElement<TTagName>;\n /**\n * The next index after processing (startIndex + rendered children count).\n */\n nextIndex: number;\n /**\n * Number of child nodes appended (not counting attributes-only modifiers).\n */\n appended: number;\n}\n\n/**\n * Applies modifiers to an element, appending newly produced Nodes while avoiding\n * duplicate DOM insertions (i.e. only appends if parentNode differs).\n *\n * Returns meta information that callers can use for continuation indexing.\n */\nexport function applyModifiers<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n modifiers: ReadonlyArray<NodeModifier<TTagName>>,\n startIndex = 0\n): ApplyModifiersResult<TTagName> {\n if (!modifiers || modifiers.length === 0) {\n return { element, nextIndex: startIndex, appended: 0 };\n }\n\n let localIndex = startIndex;\n let appended = 0;\n const parentNode = element as unknown as Node & ParentNode;\n\n for (let i = 0; i < modifiers.length; i += 1) {\n const mod = modifiers[i];\n // Fast null/undefined skip\n if (mod == null) continue;\n\n const produced = applyNodeModifier(element, mod, localIndex);\n if (!produced) continue;\n\n // Only append if the node isn't already where we expect\n if (produced.parentNode !== parentNode) {\n parentNode.appendChild(produced);\n }\n localIndex += 1;\n appended += 1;\n }\n\n return {\n element,\n nextIndex: localIndex,\n appended\n };\n}\n\n/**\n * Convenience helper: apply modifiers and return the element (fluent style).\n * Discards meta information.\n */\nexport function applyModifiersAndReturn<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n modifiers: ReadonlyArray<NodeModifier<TTagName>>,\n startIndex = 0\n): ExpandedElement<TTagName> {\n applyModifiers(element, modifiers, startIndex);\n return element;\n}","import { findConditionalModifier } from \"./modifierProcessor\";\nimport { isBrowser } from \"../utility/environment\";\nimport { storeConditionalInfo } from \"../utility/conditionalInfo\";\nimport type { ConditionalInfo } from \"../utility/conditionalInfo\";\nimport { applyModifiers, NodeModifier } from \"../internal/applyModifiers\";\n\nexport function createConditionalElement<TTagName extends ElementTagName>(\n tagName: TTagName,\n condition: () => boolean,\n modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>\n): ExpandedElement<TTagName> | Comment {\n const passed = condition();\n\n if (!isBrowser) {\n return passed\n ? createElementWithModifiers(tagName, modifiers)\n : (document.createComment(`conditional-${tagName}-ssr`) as unknown as ExpandedElement<TTagName>);\n }\n\n if (passed) {\n const el = createElementWithModifiers(tagName, modifiers);\n storeConditionalInfo(el as Node, { condition, tagName, modifiers } as ConditionalInfo);\n return el;\n }\n\n const comment = document.createComment(`conditional-${tagName}-hidden`);\n storeConditionalInfo(comment as Node, { condition, tagName, modifiers } as ConditionalInfo);\n return comment as unknown as ExpandedElement<TTagName>;\n}\n\nfunction createElementWithModifiers<TTagName extends ElementTagName>(\n tagName: TTagName,\n modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>\n): ExpandedElement<TTagName> {\n const el = document.createElement(tagName) as ExpandedElement<TTagName>;\n applyModifiers(el, modifiers as ReadonlyArray<NodeModifier<TTagName>>, 0);\n return el;\n}\n\nexport function processConditionalModifiers<TTagName extends ElementTagName>(\n modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>\n): {\n condition: (() => boolean) | null;\n otherModifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>;\n} {\n const conditionalIndex = findConditionalModifier(modifiers);\n\n if (conditionalIndex === -1) {\n return { condition: null, otherModifiers: modifiers };\n }\n\n return {\n condition: modifiers[conditionalIndex] as () => boolean,\n otherModifiers: modifiers.filter((_, index) => index !== conditionalIndex)\n };\n}\n","import { createConditionalElement, processConditionalModifiers } from \"./conditionalRenderer\";\nimport { applyModifiers, NodeModifier } from \"../internal/applyModifiers\";\n\nexport function createElementFactory<TTagName extends ElementTagName>(\n tagName: TTagName,\n ...modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>\n): NodeModFn<TTagName> {\n return (parent: ExpandedElement<TTagName>, index: number): ExpandedElement<TTagName> => {\n const { condition, otherModifiers } = processConditionalModifiers(modifiers);\n\n if (condition) {\n return createConditionalElement(tagName, condition, otherModifiers) as ExpandedElement<TTagName>;\n }\n\n const el = document.createElement(tagName) as ExpandedElement<TTagName>;\n applyModifiers(el, otherModifiers as ReadonlyArray<NodeModifier<TTagName>>, index);\n return el;\n };\n}\n\nexport function createTagBuilder<TTagName extends ElementTagName>(\n tagName: TTagName,\n): (...modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>) => NodeModFn<TTagName> {\n return (...mods) => createElementFactory(tagName, ...mods);\n}","import { createTagBuilder } from \"./elementFactory\";\n\nexport const HTML_TAGS = [\n \"a\", \"abbr\", \"address\", \"area\", \"article\", \"aside\", \"audio\", \"b\", \"base\",\n \"bdi\", \"bdo\", \"blockquote\", \"body\", \"br\", \"button\", \"canvas\", \"caption\",\n \"cite\", \"code\", \"col\", \"colgroup\", \"data\", \"datalist\", \"dd\", \"del\", \"details\",\n \"dfn\", \"dialog\", \"div\", \"dl\", \"dt\", \"em\", \"embed\", \"fieldset\", \"figcaption\",\n \"figure\", \"footer\", \"form\", \"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\", \"head\",\n \"header\", \"hgroup\", \"hr\", \"html\", \"i\", \"iframe\", \"img\", \"input\", \"ins\",\n \"kbd\", \"label\", \"legend\", \"li\", \"link\", \"main\", \"map\", \"mark\", \"menu\",\n \"meta\", \"meter\", \"nav\", \"noscript\", \"object\", \"ol\", \"optgroup\", \"option\",\n \"output\", \"p\", \"picture\", \"pre\", \"progress\", \"q\", \"rp\", \"rt\", \"ruby\", \"s\",\n \"samp\", \"script\", \"search\", \"section\", \"select\", \"slot\", \"small\", \"source\",\n \"span\", \"strong\", \"style\", \"sub\", \"summary\", \"sup\", \"table\", \"tbody\", \"td\",\n \"template\", \"textarea\", \"tfoot\", \"th\", \"thead\", \"time\", \"title\", \"tr\",\n \"track\", \"u\", \"ul\", \"var\", \"video\", \"wbr\",\n] as const satisfies ReadonlyArray<ElementTagName>;\n\nexport const SVG_TAGS = [\n \"a\", \"animate\", \"animateMotion\", \"animateTransform\", \"circle\", \"clipPath\",\n \"defs\", \"desc\", \"ellipse\", \"feBlend\", \"feColorMatrix\", \"feComponentTransfer\",\n \"feComposite\", \"feConvolveMatrix\", \"feDiffuseLighting\", \"feDisplacementMap\",\n \"feDistantLight\", \"feDropShadow\", \"feFlood\", \"feFuncA\", \"feFuncB\", \"feFuncG\",\n \"feFuncR\", \"feGaussianBlur\", \"feImage\", \"feMerge\", \"feMergeNode\", \"feMorphology\",\n \"feOffset\", \"fePointLight\", \"feSpecularLighting\", \"feSpotLight\", \"feTile\",\n \"feTurbulence\", \"filter\", \"foreignObject\", \"g\", \"image\", \"line\", \"linearGradient\",\n \"marker\", \"mask\", \"metadata\", \"mpath\", \"path\", \"pattern\", \"polygon\", \"polyline\",\n \"radialGradient\", \"rect\", \"script\", \"set\", \"stop\", \"style\", \"svg\", \"switch\",\n \"symbol\", \"text\", \"textPath\", \"title\", \"tspan\", \"use\", \"view\",\n] as const satisfies ReadonlyArray<keyof SVGElementTagNameMap>;\n\nexport const SELF_CLOSING_TAGS = [\n \"area\", \"base\", \"br\", \"col\", \"embed\", \"hr\", \"img\", \"input\", \"link\", \"meta\",\n \"source\", \"track\", \"wbr\",\n] as const satisfies ReadonlyArray<ElementTagName>;\n\nfunction registerHtmlTag(target: Record<string, unknown>, tagName: ElementTagName): void {\n if (!(tagName in target)) {\n target[tagName] = createTagBuilder(tagName);\n }\n}\n\nexport function registerGlobalTagBuilders(target: Record<string, unknown> = globalThis): void {\n const marker = \"__vc_tags_registered\";\n if ((target as Record<string, boolean>)[marker]) return;\n\n HTML_TAGS.forEach((tagName) => registerHtmlTag(target, tagName));\n (target as Record<string, boolean>)[marker] = true;\n}\n","import { createMarkerPair, safeRemoveChild } from \"../utility/dom\";\nimport { arraysEqual } from \"../utility/arrayUtils\";\nimport { resolveRenderable } from \"../utility/renderables\";\nimport type { ListRenderer, ListRuntime, ListItemRecord, ListItemsProvider } from \"./types\";\n\nconst activeListRuntimes = new Set<ListRuntime<any>>();\n\nfunction renderItem<TItem>(\n runtime: ListRuntime<TItem>,\n item: TItem,\n index: number,\n): ExpandedElement<any> | null {\n const result = runtime.renderItem(item, index);\n return resolveRenderable(result, runtime.host, index);\n}\n\nfunction remove(record: ListItemRecord<unknown>): void {\n safeRemoveChild(record.element as unknown as Node);\n}\n\nexport function sync<TItem>(runtime: ListRuntime<TItem>): void {\n const { host, startMarker, endMarker } = runtime;\n const parent = (startMarker.parentNode ?? (host as unknown as Node & ParentNode)) as\n Node & ParentNode;\n\n const currentItems = runtime.itemsProvider();\n\n if (arraysEqual(runtime.lastSyncedItems, currentItems)) return;\n\n const recordsByPosition = new Map<number, ListItemRecord<TItem>>();\n const availableRecords = new Map<TItem, ListItemRecord<TItem>[]>();\n\n runtime.records.forEach((record) => {\n const items = availableRecords.get(record.item);\n if (items) {\n items.push(record);\n } else {\n availableRecords.set(record.item, [record]);\n }\n });\n\n currentItems.forEach((item, newIndex) => {\n if (\n newIndex < runtime.lastSyncedItems.length &&\n runtime.lastSyncedItems[newIndex] === item\n ) {\n const existingRecord = runtime.records[newIndex];\n if (existingRecord && existingRecord.item === item) {\n recordsByPosition.set(newIndex, existingRecord);\n const items = availableRecords.get(item);\n if (items) {\n const recordIndex = items.indexOf(existingRecord);\n if (recordIndex >= 0) {\n items.splice(recordIndex, 1);\n if (items.length === 0) {\n availableRecords.delete(item);\n }\n }\n }\n }\n }\n });\n\n const newRecords: Array<ListItemRecord<TItem>> = [];\n const elementsToRemove = new Set<ListItemRecord<TItem>>(runtime.records);\n let nextSibling: Node = endMarker;\n\n for (let i = currentItems.length - 1; i >= 0; i--) {\n const item = currentItems[i];\n let record = recordsByPosition.get(i);\n\n if (!record) {\n const availableItems = availableRecords.get(item);\n if (availableItems && availableItems.length > 0) {\n record = availableItems.shift()!;\n if (availableItems.length === 0) {\n availableRecords.delete(item);\n }\n }\n }\n\n if (record) {\n elementsToRemove.delete(record);\n } else {\n const element = renderItem(runtime, item, i);\n if (!element) continue;\n record = { item, element };\n }\n\n newRecords.unshift(record);\n\n const recordNode = record.element as unknown as Node;\n if (recordNode.nextSibling !== nextSibling) {\n parent.insertBefore(recordNode, nextSibling);\n }\n nextSibling = recordNode;\n }\n\n elementsToRemove.forEach(remove);\n\n runtime.records = newRecords;\n runtime.lastSyncedItems = [...currentItems];\n}\n\nexport function createListRuntime<TItem>(\n itemsProvider: ListItemsProvider<TItem>,\n renderItem: ListRenderer<TItem>,\n host: ExpandedElement<any>,\n): ListRuntime<TItem> {\n const { start: startMarker, end: endMarker } = createMarkerPair(\"list\");\n\n const runtime: ListRuntime<TItem> = {\n itemsProvider,\n renderItem,\n startMarker,\n endMarker,\n records: [],\n host,\n lastSyncedItems: [],\n };\n\n const parentNode = host as unknown as Node & ParentNode;\n parentNode.appendChild(startMarker);\n parentNode.appendChild(endMarker);\n\n activeListRuntimes.add(runtime);\n sync(runtime);\n\n return runtime;\n}\n\nexport function updateListRuntimes(): void {\n activeListRuntimes.forEach((runtime) => {\n if (!runtime.startMarker.isConnected || !runtime.endMarker.isConnected) {\n activeListRuntimes.delete(runtime);\n return;\n }\n\n sync(runtime);\n });\n}\n","import { isFunction, isTagLike } from \"./typeGuards\";\n\nexport function resolveRenderable(\n result: unknown,\n host: ExpandedElement<any>,\n index: number\n): ExpandedElement<any> | null {\n if (isFunction(result)) {\n const element = (result as NodeModFn<any>)(host, index);\n if (element && isTagLike(element)) {\n return element as ExpandedElement<any>;\n }\n return null;\n }\n\n if (result && isTagLike(result)) {\n return result as ExpandedElement<any>;\n }\n\n return null;\n}\n","export function arraysEqual<T>(a: T[], b: T[]): boolean {\n if (a === b) return true;\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if ((i in a ? a[i] : undefined) !== (i in b ? b[i] : undefined)) return false;\n }\n return true;\n}\n","import { createListRuntime } from \"./runtime\";\nimport type { ListRenderer, ListItemsProvider } from \"./types\";\n\n/**\n * Maps items to DOM elements, keeping them in sync with changes.\n */\nexport function list<TItem>(\n itemsProvider: ListItemsProvider<TItem>,\n render: ListRenderer<TItem>,\n): NodeModFn<any> {\n return (host: ExpandedElement<any>) => {\n const runtime = createListRuntime(itemsProvider, render, host);\n return runtime.startMarker;\n };\n}\n","export type ConditionInput = boolean | (() => boolean);\n\nexport function runCondition(\n condition: () => boolean,\n onError?: (error: unknown) => void\n): boolean {\n try {\n return condition();\n } catch (error) {\n if (!onError) {\n throw error;\n }\n onError(error);\n return false;\n }\n}\n\nexport function resolveCondition(\n value: ConditionInput,\n onError?: (error: unknown) => void\n): boolean {\n return typeof value === \"function\"\n ? runCondition(value as () => boolean, onError)\n : Boolean(value);\n}\n","import { isBrowser } from \"../utility/environment\";\nimport { applyNodeModifier } from \"../core/modifierProcessor\";\nimport { createMarkerPair, clearBetweenMarkers, insertNodesBefore } from \"../utility/dom\";\nimport { resolveCondition } from \"../utility/conditions\";\nimport { modifierProbeCache } from \"../utility/modifierPredicates\";\nimport { isFunction } from \"../utility/typeGuards\";\n\ntype WhenCondition = boolean | (() => boolean);\ntype WhenContent<TTagName extends ElementTagName = ElementTagName> = \n NodeMod<TTagName> | NodeModFn<TTagName>;\n\ninterface WhenGroup<TTagName extends ElementTagName = ElementTagName> {\n condition: WhenCondition;\n content: WhenContent<TTagName>[];\n}\n\ninterface WhenRuntime<TTagName extends ElementTagName = ElementTagName> {\n startMarker: Comment;\n endMarker: Comment;\n host: ExpandedElement<TTagName>;\n index: number;\n groups: WhenGroup<TTagName>[];\n elseContent: WhenContent<TTagName>[];\n /**\n * Tracks which branch is currently rendered:\n * - null: nothing rendered yet\n * - -1: else branch\n * - >=0: index of groups[]\n */\n activeIndex: number | -1 | null;\n update(): void;\n}\n\nconst activeWhenRuntimes = new Set<WhenRuntime<any>>();\n\nfunction renderWhenContent<TTagName extends ElementTagName>(\n runtime: WhenRuntime<TTagName>\n): void {\n const { groups, elseContent, host, index, endMarker } = runtime;\n\n let newActive: number | -1 | null = null;\n for (let i = 0; i < groups.length; i++) {\n if (resolveCondition(groups[i].condition)) {\n newActive = i;\n break;\n }\n }\n if (newActive === null && elseContent.length) {\n newActive = -1;\n }\n\n if (newActive === runtime.activeIndex) return;\n\n clearBetweenMarkers(runtime.startMarker, runtime.endMarker);\n runtime.activeIndex = newActive;\n\n if (newActive === null) return;\n\n const nodes: Node[] = [];\n\n const renderItems = (items: ReadonlyArray<WhenContent<TTagName>>): void => {\n for (const item of items) {\n if (isFunction(item)) {\n if ((item as Function).length === 0) {\n modifierProbeCache.delete(item as Function);\n const node = applyNodeModifier(host, item, index);\n if (node) nodes.push(node);\n continue;\n }\n\n const realHost = host as unknown as Element & {\n appendChild: (n: Node) => Node;\n insertBefore: (n: Node, ref: Node | null) => Node;\n };\n const originalAppend = realHost.appendChild;\n (realHost as unknown as Record<string, Function>).appendChild = function (n: Node) {\n return (realHost as unknown as Record<string, Function>).insertBefore(\n n,\n endMarker\n ) as Node;\n };\n try {\n const maybeNode = applyNodeModifier(host, item, index);\n if (maybeNode && !maybeNode.parentNode) {\n nodes.push(maybeNode);\n }\n } finally {\n (realHost as unknown as Record<string, Function>).appendChild = originalAppend;\n }\n continue;\n }\n\n const node = applyNodeModifier(host, item, index);\n if (node) nodes.push(node);\n }\n };\n\n if (newActive >= 0) {\n renderItems(groups[newActive].content);\n } else if (newActive === -1) {\n renderItems(elseContent);\n }\n\n insertNodesBefore(nodes, endMarker);\n}\n\nclass WhenBuilderImpl<TTagName extends ElementTagName = ElementTagName> {\n private groups: WhenGroup<TTagName>[] = [];\n private elseContent: WhenContent<TTagName>[] = [];\n\n constructor(initialCondition: WhenCondition, ...content: WhenContent<TTagName>[]) {\n this.groups.push({ condition: initialCondition, content });\n }\n\n when(condition: WhenCondition, ...content: WhenContent<TTagName>[]): WhenBuilderImpl<TTagName> {\n this.groups.push({ condition, content });\n return this;\n }\n\n else(...content: WhenContent<TTagName>[]): WhenBuilderImpl<TTagName> {\n this.elseContent = content;\n return this;\n }\n\n render(host: ExpandedElement<TTagName>, index: number): Node | null {\n if (!isBrowser) return document.createComment(\"when-ssr\");\n\n const { start: startMarker, end: endMarker } = createMarkerPair(\"when\");\n\n const runtime: WhenRuntime<TTagName> = {\n startMarker,\n endMarker,\n host,\n index,\n groups: [...this.groups],\n elseContent: [...this.elseContent],\n activeIndex: null,\n update: () => renderWhenContent(runtime),\n };\n\n activeWhenRuntimes.add(runtime);\n\n const parent = host as unknown as Node & ParentNode;\n parent.appendChild(startMarker);\n parent.appendChild(endMarker);\n\n renderWhenContent(runtime);\n\n return startMarker;\n }\n}\n\nfunction createWhenBuilderFunction<TTagName extends ElementTagName>(\n builder: WhenBuilderImpl<TTagName>\n): WhenBuilder<TTagName> {\n const nodeModFn = (host: ExpandedElement<TTagName>, index: number): Node | null => {\n return builder.render(host, index);\n };\n\n return Object.assign(nodeModFn, {\n when: (condition: WhenCondition, ...content: WhenContent<TTagName>[]): WhenBuilder<TTagName> => {\n builder.when(condition, ...content);\n return createWhenBuilderFunction(builder);\n },\n else: (...content: WhenContent<TTagName>[]): WhenBuilder<TTagName> => {\n builder.else(...content);\n return createWhenBuilderFunction(builder);\n },\n }) as unknown as WhenBuilder<TTagName>;\n}\n\nexport function updateWhenRuntimes(): void {\n activeWhenRuntimes.forEach((runtime) => {\n try {\n runtime.update();\n } catch (error) {\n activeWhenRuntimes.delete(runtime);\n }\n });\n}\n\nexport function clearWhenRuntimes(): void {\n activeWhenRuntimes.clear();\n}\n\nexport function when<TTagName extends ElementTagName = ElementTagName>(\n condition: WhenCondition,\n ...content: WhenContent<TTagName>[]\n): WhenBuilder<TTagName> {\n const builder = new WhenBuilderImpl<TTagName>(condition, ...content);\n return createWhenBuilderFunction(builder);\n}\n","import { applyModifiers } from \"../internal/applyModifiers\";\nimport { isBrowser } from \"../utility/environment\";\nimport {\n ConditionalInfo,\n getConditionalInfo,\n storeConditionalInfo,\n getActiveConditionalNodes,\n unregisterConditionalNode,\n} from \"../utility/conditionalInfo\";\nimport { runCondition } from \"../utility/conditions\";\n\nfunction createElementFromConditionalInfo(conditionalInfo: ConditionalInfo): Element {\n const element = document.createElement(conditionalInfo.tagName);\n\n try {\n applyModifiers(\n element as ExpandedElement<ElementTagName>,\n conditionalInfo.modifiers as ReadonlyArray<NodeMod<ElementTagName> | NodeModFn<ElementTagName>>,\n 0\n );\n } catch (error) {\n console.error(`Error applying modifiers in conditional element \"${conditionalInfo.tagName}\":`, error);\n }\n return element;\n}\n\nfunction createCommentPlaceholder(conditionalInfo: ConditionalInfo): Comment {\n return document.createComment(`conditional-${conditionalInfo.tagName}-hidden`);\n}\n\nfunction replaceNodeSafely(oldNode: Node, newNode: Node): void {\n if (oldNode.parentNode) {\n try {\n oldNode.parentNode.replaceChild(newNode, oldNode);\n } catch (error) {\n console.error(\"Error replacing conditional node:\", error);\n }\n }\n}\n\nfunction updateConditionalNode(node: Element | Comment): void {\n const conditionalInfo = getConditionalInfo(node);\n if (!conditionalInfo) {\n return;\n }\n\n const shouldShow = runCondition(conditionalInfo.condition, (error) => {\n console.error(\"Error evaluating conditional condition:\", error);\n });\n const isElement = node.nodeType === Node.ELEMENT_NODE;\n\n if (shouldShow && !isElement) {\n const element = createElementFromConditionalInfo(conditionalInfo);\n storeConditionalInfo(element, conditionalInfo);\n replaceNodeSafely(node, element);\n } else if (!shouldShow && isElement) {\n const comment = createCommentPlaceholder(conditionalInfo);\n storeConditionalInfo(comment, conditionalInfo);\n replaceNodeSafely(node, comment);\n }\n}\n\nexport function updateConditionalElements(): void {\n if (!isBrowser) return;\n\n try {\n getActiveConditionalNodes().forEach((node) => {\n if (!node.isConnected) {\n unregisterConditionalNode(node);\n return;\n }\n updateConditionalNode(node as Element | Comment);\n });\n } catch (error) {\n console.error(\"Error during conditional elements update:\", error);\n }\n}\n","import { updateListRuntimes } from \"../list/runtime\";\nimport { notifyReactiveElements, notifyReactiveTextNodes } from \"./reactive\";\nimport { updateWhenRuntimes } from \"../when\";\nimport { updateConditionalElements } from \"./conditionalUpdater\";\nimport { dispatchGlobalUpdateEvent } from \"../utility/events\";\n\nconst updaters = [\n updateListRuntimes,\n updateWhenRuntimes,\n updateConditionalElements,\n notifyReactiveElements,\n notifyReactiveTextNodes,\n dispatchGlobalUpdateEvent,\n] as const;\n\nexport function update(): void {\n for (const fn of updaters) fn();\n}\n","export function dispatchGlobalUpdateEvent(): void {\n if (typeof document === \"undefined\") {\n return;\n }\n\n const targets: EventTarget[] = [];\n if (document.body) {\n targets.push(document.body);\n }\n targets.push(document);\n\n targets.forEach((target) => {\n try {\n target.dispatchEvent(new Event(\"update\", { bubbles: true }));\n } catch (error) {\n console.error(\"Error dispatching global update event:\", error);\n }\n });\n}\n","/**\n * Typed event listener helper.\n *\n * Usage:\n * button(\n * \"Click\",\n * on(\"click\", (e) => {\n * // e is correctly typed (e.g. MouseEvent for \"click\")\n * })\n * )\n *\n * Design notes:\n * - Returns a NodeModFn so it can be used like any other modifier.\n * - Produces no child node (returns void in the modifier body).\n * - Provides strong typing of the event object based on the DOM event name.\n */\n\n/**\n * Overload for standard HTMLElement events (strongly typed via lib.dom.d.ts)\n */\nexport function on<\n K extends keyof HTMLElementEventMap,\n TTagName extends ElementTagName = ElementTagName\n>(\n type: K,\n listener: (ev: HTMLElementEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions\n): NodeModFn<TTagName>;\n\n/**\n * Fallback / custom event overload (arbitrary event names or custom event types).\n * Specify a custom event type with the E generic if needed:\n * on<\"my-event\", CustomEvent<MyDetail>>(\"my-event\", e => { ... })\n */\nexport function on<\n K extends string,\n E extends Event = Event,\n TTagName extends ElementTagName = ElementTagName\n>(\n type: K,\n listener: (ev: E) => any,\n options?: boolean | AddEventListenerOptions\n): NodeModFn<TTagName>;\n\nexport function on(\n type: string,\n listener: (ev: Event) => any,\n options?: boolean | AddEventListenerOptions\n): NodeModFn<any> {\n return (parent: ExpandedElement<any>) => {\n const el = parent as unknown as HTMLElement | null | undefined;\n if (!el || typeof el.addEventListener !== \"function\") {\n return;\n }\n\n const wrapped = (ev: Event) => {\n try {\n listener.call(el, ev);\n } catch (error) {\n if (typeof console !== \"undefined\" && console.error) {\n console.error(`[nuclo:on] Error in '${type}' listener:`, error);\n }\n }\n };\n\n el.addEventListener(type, wrapped as EventListener, options);\n };\n}\n\n/**\n * (Optional) Helper to detect an on()-produced modifier (placeholder for future use).\n */\nexport function isOnModifier(fn: unknown): boolean {\n return typeof fn === \"function\" && Object.prototype.hasOwnProperty.call(fn, \"__vcOn\");\n}","/**\n * Renders a NodeModFn to a parent element by calling it and appending the result.\n *\n * @param nodeModFn The NodeModFn to render (created by tag builders like div(), h1(), etc.)\n * @param parent The parent element to render into (defaults to document.body)\n * @param index The index to pass to the NodeModFn (defaults to 0)\n * @returns The rendered element\n */\nexport function render<TTagName extends ElementTagName = ElementTagName>(\n nodeModFn: NodeModFn<TTagName>,\n parent?: Element,\n index: number = 0\n): ExpandedElement<TTagName> {\n const targetParent = (parent || document.body) as ExpandedElement<TTagName>;\n const element = nodeModFn(targetParent, index) as ExpandedElement<TTagName>;\n (parent || document.body).appendChild(element as Node);\n return element;\n}\n","import { registerGlobalTagBuilders } from \"./tagRegistry\";\nimport { list } from \"../list\";\nimport { update } from \"./updateController\";\nimport { when } from \"../when\";\nimport { on } from \"../utility/on\";\nimport { render } from \"../utility/render\";\n\n/**\n * Initializes the View Craft runtime by exposing tag builders and utilities.\n */\nexport function initializeRuntime(): void {\n registerGlobalTagBuilders();\n\n if (typeof globalThis !== \"undefined\") {\n const registry = globalThis as Record<string, unknown>;\n registry.list = list;\n registry.update = update;\n registry.when = when;\n registry.on = on;\n registry.render = render;\n }\n}\n\nif (typeof globalThis !== \"undefined\") {\n initializeRuntime();\n}\n","export { initializeRuntime } from \"./core/runtimeBootstrap\";\nexport {\n registerGlobalTagBuilders,\n HTML_TAGS,\n SVG_TAGS,\n SELF_CLOSING_TAGS,\n} from \"./core/tagRegistry\";\nexport { createElementFactory, createTagBuilder } from \"./core/elementFactory\";\nexport { applyNodeModifier } from \"./core/modifierProcessor\";\nexport {\n list,\n} from \"./list\";\nexport { when } from \"./when\";\nexport { update } from \"./core/updateController\";\nexport { applyAttributes } from \"./core/attributeManager\";\nexport { appendChildren } from \"./utility/dom\";\nexport { on } from \"./utility/on\";\nexport { render } from \"./utility/render\";\nexport {\n isBoolean,\n isFunction,\n isNode,\n isObject,\n isPrimitive,\n isTagLike,\n} from \"./utility/typeGuards\";\nexport { isBrowser } from \"./utility/environment\";\n\n// Auto-initialize when the module is loaded.\nimport \"./core/runtimeBootstrap\";\nconsole.log(\"nuclo\");\n"],"names":["isPrimitive","value","isNode","Node","isObject","isTagLike","isFunction","logError","message","error","console","safeExecute","fn","fallback","isBrowser","window","document","safeRemoveChild","child","parentNode","removeChild","createCommentSafely","text","createComment","createMarkerComment","prefix","Error","comment","Math","random","toString","slice","createMarkerPair","endComment","start","end","isNodeConnected","node","isConnected","contains","reactiveTextNodes","Map","reactiveElements","applyAttributeResolvers","el","info","attributeResolvers","forEach","resolver","applyValue","key","e","createReactiveTextNode","preEvaluated","createTextNode","initial","arguments","length","str","undefined","String","txt","set","lastValue","registerAttributeResolver","element","Element","get","ensureElementInfo","updateListener","listener","addEventListener","assignInlineStyles","styles","style","Object","entries","property","removeProperty","applySingleAttribute","raw","styleValue","resolvedStyles","setValue","v","setAttribute","applyAttributes","attributes","k","keys","modifierProbeCache","WeakMap","isBooleanFunction","cached","record","probeOnce","isConditionalModifier","modifier","allModifiers","currentIndex","otherModifiers","filter","_","index","some","mod","applyNodeModifier","parent","fragment","createDocumentFragment","textNode","appendChild","produced","candidate","activeConditionalNodes","Set","storeConditionalInfo","_conditionalInfo","add","applyModifiers","modifiers","startIndex","nextIndex","appended","localIndex","i","createElementWithModifiers","tagName","createElement","processConditionalModifiers","conditionalIndex","findConditionalModifier","condition","createElementFactory","passed","createConditionalElement","createTagBuilder","mods","HTML_TAGS","registerGlobalTagBuilders","target","globalThis","marker","registerHtmlTag","activeListRuntimes","renderItem","runtime","item","result","host","resolveRenderable","remove","sync","startMarker","endMarker","currentItems","itemsProvider","a","b","arraysEqual","lastSyncedItems","recordsByPosition","availableRecords","records","items","push","newIndex","existingRecord","recordIndex","indexOf","splice","delete","newRecords","elementsToRemove","nextSibling","availableItems","shift","unshift","recordNode","insertBefore","list","render","createListRuntime","runCondition","onError","resolveCondition","Boolean","activeWhenRuntimes","renderWhenContent","groups","elseContent","newActive","activeIndex","current","next","clearBetweenMarkers","nodes","renderItems","realHost","originalAppend","n","maybeNode","content","referenceNode","newNode","safeInsertBefore","insertNodesBefore","WhenBuilderImpl","constructor","initialCondition","this","when","update","createWhenBuilderFunction","builder","assign","else","replaceNodeSafely","oldNode","replaceChild","updateConditionalNode","conditionalInfo","getConditionalInfo","shouldShow","isElement","nodeType","ELEMENT_NODE","createElementFromConditionalInfo","createCommentPlaceholder","updaters","unregisterConditionalNode","removeEventListener","newVal","textContent","targets","body","dispatchEvent","Event","bubbles","on","type","options","ev","call","nodeModFn","initializeRuntime","registry","log","children","nodeToAppend","createText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AY,QAAS,OAAQ,UAAW,UAAW,WACrE,iBAAkB,OAAQ,SAAU,MAAO,OAAQ,QAAS,MAAO,SACnE,SAAU,OAAQ,WAAY,QAAS,QAAS,MAAO,wCV6DvD5I,KACG6I,GAEH,OAAK7I,GAEL6I,EAASzM,QAAS7B,IAChB,GAAa,MAATA,EAAe,CACjB,IAAIuO,EAEJ,GAAqB,iBAAVvO,EAAoB,CAC7B,MAAM4F,EAnEd,SAA8BxF,GAC5B,IAAKR,EAAW,OAAO,KACvB,IACE,OAAOE,SAASsC,eAAeM,OAAOtC,GACxC,CAAE,MACA,OAAO,IACT,CACF,CA4DyBoO,CAAqBxO,GACtC,IAAI4F,EAGF,OAFA2I,EAAe3I,CAInB,MACE2I,EAAevO,GAxGvB,SAAyByF,EAAwBzF,GAC/C,IAAKyF,IAAWzF,EAAO,OAAO,EAC9B,IAEE,OADAyF,EAAOI,YAAY7F,IACZ,CACT,CAAE,MACA,OAAO,CACT,CACF,CAmGMyO,CAAgBhJ,EAAQ8I,EAC1B,IAGK9I,GArBaA,CAsBtB,gKHlGM,SAAoB1G,GACxB,MAAwB,kBAAVA,CAChB"}
1
+ {"version":3,"file":"nuclo.cjs","sources":["../src/utility/typeGuards.ts","../src/utility/errorHandler.ts","../src/utility/environment.ts","../src/utility/dom.ts","../src/core/reactive.ts","../src/core/styleManager.ts","../src/core/attributeManager.ts","../src/utility/modifierPredicates.ts","../src/core/modifierProcessor.ts","../src/utility/conditionalInfo.ts","../src/internal/applyModifiers.ts","../src/core/conditionalRenderer.ts","../src/core/elementFactory.ts","../src/core/tagRegistry.ts","../src/list/runtime.ts","../src/utility/renderables.ts","../src/utility/arrayUtils.ts","../src/list/renderer.ts","../src/utility/conditions.ts","../src/when/index.ts","../src/core/conditionalUpdater.ts","../src/core/updateController.ts","../src/utility/events.ts","../src/utility/on.ts","../src/utility/render.ts","../src/core/runtimeBootstrap.ts"],"sourcesContent":["export function isPrimitive(value: unknown): value is Primitive {\n return value === null || (typeof value !== \"object\" && typeof value !== \"function\");\n}\n\nexport function isNode<T>(value: T): value is T & Node {\n return value instanceof Node;\n}\n\nexport function isObject(value: unknown): value is object {\n return typeof value === \"object\" && value !== null;\n}\n\nexport function isTagLike<T>(value: T): value is T & { tagName?: string } {\n return isObject(value) && \"tagName\" in (value as object);\n}\n\nexport function isBoolean(value: unknown): value is boolean {\n return typeof value === \"boolean\";\n}\n\nexport function isFunction<T extends Function>(value: unknown): value is T {\n return typeof value === \"function\";\n}\n","/**\n * Simplified error handling for nuclo - reduced complexity for smaller bundle size\n */\n\n// Basic error logging - no complex context tracking\nexport function logError(message: string, error?: Error | unknown): void {\n if (typeof console !== 'undefined') {\n console.error(`nuclo: ${message}`, error);\n }\n}\n\n// Simplified safe execution - no complex context\nexport function safeExecute<T>(fn: () => T, fallback?: T): T | undefined {\n try {\n return fn();\n } catch (error) {\n logError(\"Operation failed\", error);\n return fallback;\n }\n}\n\n// Basic DOM error handler\nexport function handleDOMError(error: Error | unknown, operation: string): void {\n logError(`DOM ${operation} failed`, error);\n}","/**\n * Simplified environment detection - minimal overhead for smaller bundle size\n */\n\n// Basic environment detection - no complex caching or edge cases\nexport const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';\n","import { isBrowser } from \"./environment\";\n\nfunction safeAppendChild(parent: Element | Node, child: Node): boolean {\n if (!parent || !child) return false;\n try {\n parent.appendChild(child);\n return true;\n } catch {\n return false;\n }\n}\n\nexport function safeRemoveChild(child: Node): boolean {\n if (!child?.parentNode) return false;\n try {\n child.parentNode.removeChild(child);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction safeInsertBefore(parent: Node, newNode: Node, referenceNode: Node | null): boolean {\n if (!parent || !newNode) return false;\n try {\n parent.insertBefore(newNode, referenceNode);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction createTextNodeSafely(text: string | number | boolean): Text | null {\n if (!isBrowser) return null;\n try {\n return document.createTextNode(String(text));\n } catch {\n return null;\n }\n}\n\nfunction createCommentSafely(text: string): Comment | null {\n if (!isBrowser) return null;\n try {\n return document.createComment(text);\n } catch {\n return null;\n }\n}\n\nexport function createMarkerComment(prefix: string): Comment {\n if (!isBrowser) {\n throw new Error(\"Cannot create comment in non-browser environment\");\n }\n const comment = createCommentSafely(`${prefix}-${Math.random().toString(36).slice(2)}`);\n if (!comment) {\n throw new Error(\"Failed to create comment\");\n }\n return comment;\n}\n\nexport function createMarkerPair(prefix: string): { start: Comment; end: Comment } {\n const endComment = createCommentSafely(`${prefix}-end`);\n if (!endComment) {\n throw new Error(\"Failed to create end comment\");\n }\n return {\n start: createMarkerComment(`${prefix}-start`),\n end: endComment\n };\n}\n\nexport function clearBetweenMarkers(startMarker: Comment, endMarker: Comment): void {\n let current = startMarker.nextSibling;\n while (current && current !== endMarker) {\n const next = current.nextSibling;\n safeRemoveChild(current);\n current = next;\n }\n}\n\nexport function insertNodesBefore(nodes: Node[], referenceNode: Node): void {\n const parent = referenceNode.parentNode;\n if (parent) {\n nodes.forEach(node => safeInsertBefore(parent, node, referenceNode));\n }\n}\n\nexport function appendChildren(\n parent: Element | Node,\n ...children: Array<Element | Node | string | null | undefined>\n): Element | Node {\n if (!parent) return parent;\n\n children.forEach((child) => {\n if (child != null) {\n let nodeToAppend: Node;\n\n if (typeof child === \"string\") {\n const textNode = createTextNodeSafely(child);\n if (textNode) {\n nodeToAppend = textNode;\n } else {\n return;\n }\n } else {\n nodeToAppend = child as Node;\n }\n\n safeAppendChild(parent, nodeToAppend);\n }\n });\n\n return parent;\n}\n\nexport function isNodeConnected(node: Node | null | undefined): boolean {\n if (!node) return false;\n return typeof node.isConnected === \"boolean\" ? node.isConnected : document.contains(node);\n}\n","import { logError, safeExecute } from \"../utility/errorHandler\";\nimport { isNodeConnected } from \"../utility/dom\";\n\ntype TextResolver = () => Primitive;\ntype AttributeResolver = () => unknown;\n\ninterface AttributeResolverRecord {\n resolver: AttributeResolver;\n applyValue: (value: unknown) => void;\n}\n\ninterface ReactiveTextNodeInfo {\n resolver: TextResolver;\n lastValue: string;\n}\n\ninterface ReactiveElementInfo {\n attributeResolvers: Map<string, AttributeResolverRecord>;\n updateListener?: EventListener;\n}\n\nconst reactiveTextNodes = new Map<Text, ReactiveTextNodeInfo>();\nconst reactiveElements = new Map<Element, ReactiveElementInfo>();\n\nfunction ensureElementInfo(el: Element): ReactiveElementInfo {\n let info = reactiveElements.get(el);\n if (!info) {\n info = { attributeResolvers: new Map() };\n reactiveElements.set(el, info);\n }\n return info;\n}\n\nfunction applyAttributeResolvers(el: Element, info: ReactiveElementInfo): void {\n info.attributeResolvers.forEach(({ resolver, applyValue }, key) => {\n try {\n applyValue(safeExecute(resolver));\n } catch (e) {\n logError(`Failed to update reactive attribute: ${key}`, e);\n }\n });\n}\n\nexport function createReactiveTextNode(resolver: TextResolver, preEvaluated?: unknown): Text | DocumentFragment {\n if (typeof resolver !== \"function\") {\n logError(\"Invalid resolver provided to createReactiveTextNode\");\n return document.createTextNode(\"\");\n }\n\n const initial = arguments.length > 1 ? preEvaluated : safeExecute(resolver, \"\");\n const str = initial === undefined ? \"\" : String(initial);\n const txt = document.createTextNode(str);\n\n reactiveTextNodes.set(txt, { resolver, lastValue: str });\n return txt;\n}\n\nexport function registerAttributeResolver<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n key: string,\n resolver: AttributeResolver,\n applyValue: (value: unknown) => void\n): void {\n if (!(element instanceof Element) || !key || typeof resolver !== \"function\") {\n logError(\"Invalid parameters for registerAttributeResolver\");\n return;\n }\n const info = ensureElementInfo(element as Element);\n info.attributeResolvers.set(key, { resolver, applyValue });\n\n try {\n applyValue(safeExecute(resolver));\n } catch (e) {\n logError(\"Failed to apply initial attribute value\", e);\n }\n\n if (!info.updateListener) {\n const listener: EventListener = () => applyAttributeResolvers(element as Element, info);\n (element as Element).addEventListener(\"update\", listener);\n info.updateListener = listener;\n }\n}\n\nexport function notifyReactiveTextNodes(): void {\n reactiveTextNodes.forEach((info, node) => {\n if (!isNodeConnected(node)) {\n reactiveTextNodes.delete(node);\n return;\n }\n try {\n const raw = safeExecute(info.resolver);\n const newVal = raw === undefined ? \"\" : String(raw);\n if (newVal !== info.lastValue) {\n node.textContent = newVal;\n info.lastValue = newVal;\n }\n } catch (e) {\n logError(\"Failed to update reactive text node\", e);\n }\n });\n}\n\nexport function notifyReactiveElements(): void {\n reactiveElements.forEach((info, el) => {\n if (!isNodeConnected(el)) {\n if (info.updateListener) el.removeEventListener(\"update\", info.updateListener);\n reactiveElements.delete(el);\n return;\n }\n applyAttributeResolvers(el, info);\n });\n}\n","import { isFunction } from \"../utility/typeGuards\";\nimport { registerAttributeResolver } from \"./reactive\";\n\ntype StyleAssignment = Partial<CSSStyleDeclaration>;\ntype StyleResolver = () => StyleAssignment | null | undefined;\n\n/**\n * Simplified style management - basic functionality with minimal overhead\n */\nexport function assignInlineStyles<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n styles: StyleAssignment | null | undefined,\n): void {\n if (!element) return;\n if (!element.style) return; // Guard against elements without style\n if (!styles) return;\n\n Object.entries(styles).forEach(([property, value]) => {\n if (value == null || value === '') {\n // Try both camelCase and kebab-case removal\n element.style!.removeProperty(property);\n // Also set to empty string as fallback\n (element.style as any)[property] = '';\n } else {\n try {\n (element.style as any)[property] = String(value);\n } catch {\n // Ignore invalid style properties\n }\n }\n });\n}\n\nexport function applyStyleAttribute<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n styleValue: StyleAssignment | StyleResolver | null | undefined\n): void {\n if (!element) return;\n\n if (isFunction(styleValue)) {\n registerAttributeResolver(element, 'style', () => {\n try {\n return styleValue();\n } catch {\n return null;\n }\n }, (resolvedStyles) => {\n assignInlineStyles(element, resolvedStyles as StyleAssignment);\n });\n } else {\n assignInlineStyles(element, styleValue);\n }\n}","import { isFunction } from \"../utility/typeGuards\";\nimport { registerAttributeResolver, createReactiveTextNode } from \"./reactive\";\nimport { applyStyleAttribute } from \"./styleManager\";\n\ntype AttributeKey<TTagName extends ElementTagName> = keyof ExpandedElementAttributes<TTagName>;\ntype AttributeCandidate<TTagName extends ElementTagName> =\n ExpandedElementAttributes<TTagName>[AttributeKey<TTagName>];\n\nfunction applySingleAttribute<TTagName extends ElementTagName>(\n el: ExpandedElement<TTagName>,\n key: AttributeKey<TTagName>,\n raw: AttributeCandidate<TTagName> | undefined,\n): void {\n if (raw == null) return;\n\n if (key === \"style\") {\n applyStyleAttribute(el, raw as ExpandedElementAttributes<TTagName>[\"style\"]);\n return;\n }\n\n const setValue = (v: unknown): void => {\n if (v == null) return;\n if (key in el) {\n (el as Record<string, unknown>)[key as string] = v;\n } else if (el instanceof Element) {\n el.setAttribute(String(key), String(v));\n }\n };\n\n if (isFunction(raw) && (raw as Function).length === 0) {\n registerAttributeResolver(el, String(key), raw as () => unknown, setValue);\n } else {\n setValue(raw);\n }\n}\n\nexport function applyAttributes<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n attributes: ExpandedElementAttributes<TTagName>,\n): void {\n if (!attributes) return;\n for (const k of Object.keys(attributes) as Array<AttributeKey<TTagName>>) {\n const value = (attributes as Record<string, unknown>)[k as string] as\n AttributeCandidate<TTagName> | undefined;\n applySingleAttribute(element, k, value);\n }\n}\n\nexport { createReactiveTextNode } from \"./reactive\";\n","import { isFunction, isNode, isObject } from \"./typeGuards\";\n\ntype AnyModifier = unknown;\ntype BooleanCondition = () => boolean;\n\nconst modifierProbeCache = new WeakMap<Function, { value: unknown; error: boolean }>();\n\nfunction probeOnce(fn: Function): { value: unknown; error: boolean } {\n const cached = modifierProbeCache.get(fn);\n if (cached) {\n return cached;\n }\n try {\n const value = fn();\n const record = { value, error: false };\n modifierProbeCache.set(fn, record);\n return record;\n } catch {\n const record = { value: undefined, error: true };\n modifierProbeCache.set(fn, record);\n return record;\n }\n}\n\nfunction isBooleanFunction(fn: Function): fn is BooleanCondition {\n const { value, error } = probeOnce(fn);\n if (error) return false;\n return typeof value === \"boolean\";\n}\n\nexport function isConditionalModifier(\n modifier: AnyModifier,\n allModifiers: AnyModifier[],\n currentIndex: number\n): modifier is BooleanCondition {\n if (\n !isFunction(modifier) ||\n (modifier as Function).length !== 0 ||\n !isBooleanFunction(modifier as Function)\n ) {\n return false;\n }\n\n const otherModifiers = allModifiers.filter((_, index) => index !== currentIndex);\n if (otherModifiers.length === 0) return false;\n\n const hasAttributesOrElements = otherModifiers.some(\n (mod) =>\n isObject(mod) || isNode(mod) || (isFunction(mod) && (mod as Function).length > 0)\n );\n\n return hasAttributesOrElements;\n}\n\nexport function findConditionalModifier(modifiers: AnyModifier[]): number {\n for (let i = 0; i < modifiers.length; i += 1) {\n if (isConditionalModifier(modifiers[i], modifiers, i)) {\n return i;\n }\n }\n return -1;\n}\n\nexport { modifierProbeCache };\n","import { applyAttributes } from \"./attributeManager\";\nimport { createReactiveTextNode } from \"./reactive\";\nimport { logError } from \"../utility/errorHandler\";\nimport { isFunction, isNode, isObject, isPrimitive } from \"../utility/typeGuards\";\nimport { modifierProbeCache } from \"../utility/modifierPredicates\";\nexport { isConditionalModifier, findConditionalModifier } from \"../utility/modifierPredicates\";\n\nexport type NodeModifier<TTagName extends ElementTagName = ElementTagName> =\n | NodeMod<TTagName>\n | NodeModFn<TTagName>;\n\nexport function applyNodeModifier<TTagName extends ElementTagName>(\n parent: ExpandedElement<TTagName>,\n modifier: NodeModifier<TTagName>,\n index: number,\n): Node | null {\n if (modifier == null) return null;\n\n if (isFunction(modifier)) {\n if (modifier.length === 0) {\n try {\n let record = modifierProbeCache.get(modifier as Function);\n if (!record) {\n const value = (modifier as () => unknown)();\n record = { value, error: false };\n modifierProbeCache.set(modifier as Function, record);\n }\n if (record.error) {\n const fragment = document.createDocumentFragment();\n const comment = document.createComment(` text-${index} `);\n const textNode = createReactiveTextNode(() => \"\");\n fragment.appendChild(comment);\n fragment.appendChild(textNode);\n return fragment;\n }\n const v = record.value;\n if (isPrimitive(v) && v != null) {\n const fragment = document.createDocumentFragment();\n const comment = document.createComment(` text-${index} `);\n const textNode = createReactiveTextNode(modifier as () => Primitive, v);\n fragment.appendChild(comment);\n fragment.appendChild(textNode);\n return fragment;\n }\n return null;\n } catch (error) {\n modifierProbeCache.set(modifier as Function, { value: undefined, error: true });\n logError(\"Error evaluating reactive text function:\", error);\n const fragment = document.createDocumentFragment();\n const comment = document.createComment(` text-${index} `);\n const textNode = createReactiveTextNode(() => \"\");\n fragment.appendChild(comment);\n fragment.appendChild(textNode);\n return fragment;\n }\n }\n\n const produced = (modifier as NodeModFn<TTagName>)(parent, index);\n if (produced == null) return null;\n if (isPrimitive(produced)) {\n const fragment = document.createDocumentFragment();\n const comment = document.createComment(` text-${index} `);\n const textNode = document.createTextNode(String(produced));\n fragment.appendChild(comment);\n fragment.appendChild(textNode);\n return fragment;\n }\n if (isNode(produced)) return produced;\n if (isObject(produced)) {\n applyAttributes(parent, produced as ExpandedElementAttributes<TTagName>);\n }\n return null;\n }\n\n const candidate = modifier as NodeMod<TTagName>;\n if (candidate == null) return null;\n if (isPrimitive(candidate)) {\n const fragment = document.createDocumentFragment();\n const comment = document.createComment(` text-${index} `);\n const textNode = document.createTextNode(String(candidate));\n fragment.appendChild(comment);\n fragment.appendChild(textNode);\n return fragment;\n }\n if (isNode(candidate)) return candidate;\n if (isObject(candidate)) {\n applyAttributes(parent, candidate as ExpandedElementAttributes<TTagName>);\n }\n return null;\n}\n","export interface ConditionalInfo {\n condition: () => boolean;\n tagName: string;\n modifiers: Array<NodeMod<any> | NodeModFn<any>>;\n}\n\n/**\n * Registry of all nodes that have conditional info attached.\n * This enables O(nConditionals) updates instead of a full DOM tree walk.\n */\nconst activeConditionalNodes = new Set<Node>();\n\n/**\n * Attach conditional info to a node and register it.\n */\nexport function storeConditionalInfo(\n node: Node,\n info: ConditionalInfo\n): void {\n (node as any)._conditionalInfo = info;\n activeConditionalNodes.add(node);\n}\n\n/**\n * Explicit unregister helper (optional use on teardown if needed).\n */\nexport function unregisterConditionalNode(node: Node): void {\n activeConditionalNodes.delete(node);\n}\n\n/**\n * Returns a readonly view of currently tracked conditional nodes.\n */\nexport function getActiveConditionalNodes(): ReadonlySet<Node> {\n return activeConditionalNodes;\n}\n\nexport function hasConditionalInfo(node: Node): boolean {\n return Boolean((node as any)._conditionalInfo);\n}\n\nexport function getConditionalInfo(node: Node): ConditionalInfo | null {\n return ((node as any)._conditionalInfo as ConditionalInfo | undefined) ?? null;\n}\n","/**\n * Shared helper for applying an array of modifiers to an element.\n * Consolidates the previously duplicated logic in several modules:\n * - conditionalRenderer\n * - conditionalUpdater\n * - elementFactory\n *\n * Goal: single, optimized, well‑typed implementation.\n *\n * A \"modifier\" can:\n * - Return (or be) primitives → appended as text\n * - Return (or be) Node → appended (if not already a child)\n * - Return (or be) attribute objects → merged into element\n * - Be a NodeModFn invoked with (parent, index)\n * - Be a zero‑arg function producing reactive text (handled upstream in applyNodeModifier)\n *\n * Indexing:\n * - startIndex allows callers to continue an index sequence if needed.\n * - Every successfully rendered child Node increments the local index.\n */\nimport { applyNodeModifier } from \"../core/modifierProcessor\";\n\nexport type NodeModifier<TTagName extends ElementTagName = ElementTagName> =\n | NodeMod<TTagName>\n | NodeModFn<TTagName>;\n\nexport interface ApplyModifiersResult<TTagName extends ElementTagName> {\n /**\n * The element passed in (for fluent patterns if desired).\n */\n element: ExpandedElement<TTagName>;\n /**\n * The next index after processing (startIndex + rendered children count).\n */\n nextIndex: number;\n /**\n * Number of child nodes appended (not counting attributes-only modifiers).\n */\n appended: number;\n}\n\n/**\n * Applies modifiers to an element, appending newly produced Nodes while avoiding\n * duplicate DOM insertions (i.e. only appends if parentNode differs).\n *\n * Returns meta information that callers can use for continuation indexing.\n */\nexport function applyModifiers<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n modifiers: ReadonlyArray<NodeModifier<TTagName>>,\n startIndex = 0\n): ApplyModifiersResult<TTagName> {\n if (!modifiers || modifiers.length === 0) {\n return { element, nextIndex: startIndex, appended: 0 };\n }\n\n let localIndex = startIndex;\n let appended = 0;\n const parentNode = element as unknown as Node & ParentNode;\n\n for (let i = 0; i < modifiers.length; i += 1) {\n const mod = modifiers[i];\n // Fast null/undefined skip\n if (mod == null) continue;\n\n const produced = applyNodeModifier(element, mod, localIndex);\n if (!produced) continue;\n\n // Only append if the node isn't already where we expect\n if (produced.parentNode !== parentNode) {\n parentNode.appendChild(produced);\n }\n localIndex += 1;\n appended += 1;\n }\n\n return {\n element,\n nextIndex: localIndex,\n appended\n };\n}\n\n/**\n * Convenience helper: apply modifiers and return the element (fluent style).\n * Discards meta information.\n */\nexport function applyModifiersAndReturn<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n modifiers: ReadonlyArray<NodeModifier<TTagName>>,\n startIndex = 0\n): ExpandedElement<TTagName> {\n applyModifiers(element, modifiers, startIndex);\n return element;\n}","import { findConditionalModifier } from \"./modifierProcessor\";\nimport { isBrowser } from \"../utility/environment\";\nimport { storeConditionalInfo } from \"../utility/conditionalInfo\";\nimport type { ConditionalInfo } from \"../utility/conditionalInfo\";\nimport { applyModifiers, NodeModifier } from \"../internal/applyModifiers\";\n\nexport function createConditionalElement<TTagName extends ElementTagName>(\n tagName: TTagName,\n condition: () => boolean,\n modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>\n): ExpandedElement<TTagName> | Comment {\n const passed = condition();\n\n if (!isBrowser) {\n return passed\n ? createElementWithModifiers(tagName, modifiers)\n : (document.createComment(`conditional-${tagName}-ssr`) as unknown as ExpandedElement<TTagName>);\n }\n\n if (passed) {\n const el = createElementWithModifiers(tagName, modifiers);\n storeConditionalInfo(el as Node, { condition, tagName, modifiers } as ConditionalInfo);\n return el;\n }\n\n const comment = document.createComment(`conditional-${tagName}-hidden`);\n storeConditionalInfo(comment as Node, { condition, tagName, modifiers } as ConditionalInfo);\n return comment as unknown as ExpandedElement<TTagName>;\n}\n\nfunction createElementWithModifiers<TTagName extends ElementTagName>(\n tagName: TTagName,\n modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>\n): ExpandedElement<TTagName> {\n const el = document.createElement(tagName) as ExpandedElement<TTagName>;\n applyModifiers(el, modifiers as ReadonlyArray<NodeModifier<TTagName>>, 0);\n return el;\n}\n\nexport function processConditionalModifiers<TTagName extends ElementTagName>(\n modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>\n): {\n condition: (() => boolean) | null;\n otherModifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>;\n} {\n const conditionalIndex = findConditionalModifier(modifiers);\n\n if (conditionalIndex === -1) {\n return { condition: null, otherModifiers: modifiers };\n }\n\n return {\n condition: modifiers[conditionalIndex] as () => boolean,\n otherModifiers: modifiers.filter((_, index) => index !== conditionalIndex)\n };\n}\n","import { createConditionalElement, processConditionalModifiers } from \"./conditionalRenderer\";\nimport { applyModifiers, NodeModifier } from \"../internal/applyModifiers\";\n\nexport function createElementFactory<TTagName extends ElementTagName>(\n tagName: TTagName,\n ...modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>\n): NodeModFn<TTagName> {\n return (parent: ExpandedElement<TTagName>, index: number): ExpandedElement<TTagName> => {\n const { condition, otherModifiers } = processConditionalModifiers(modifiers);\n\n if (condition) {\n return createConditionalElement(tagName, condition, otherModifiers) as ExpandedElement<TTagName>;\n }\n\n const el = document.createElement(tagName) as ExpandedElement<TTagName>;\n applyModifiers(el, otherModifiers as ReadonlyArray<NodeModifier<TTagName>>, index);\n return el;\n };\n}\n\nexport function createTagBuilder<TTagName extends ElementTagName>(\n tagName: TTagName,\n): (...modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>) => NodeModFn<TTagName> {\n return (...mods) => createElementFactory(tagName, ...mods);\n}","import { createTagBuilder } from \"./elementFactory\";\n\nexport const HTML_TAGS = [\n \"a\", \"abbr\", \"address\", \"area\", \"article\", \"aside\", \"audio\", \"b\", \"base\",\n \"bdi\", \"bdo\", \"blockquote\", \"body\", \"br\", \"button\", \"canvas\", \"caption\",\n \"cite\", \"code\", \"col\", \"colgroup\", \"data\", \"datalist\", \"dd\", \"del\", \"details\",\n \"dfn\", \"dialog\", \"div\", \"dl\", \"dt\", \"em\", \"embed\", \"fieldset\", \"figcaption\",\n \"figure\", \"footer\", \"form\", \"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\", \"head\",\n \"header\", \"hgroup\", \"hr\", \"html\", \"i\", \"iframe\", \"img\", \"input\", \"ins\",\n \"kbd\", \"label\", \"legend\", \"li\", \"link\", \"main\", \"map\", \"mark\", \"menu\",\n \"meta\", \"meter\", \"nav\", \"noscript\", \"object\", \"ol\", \"optgroup\", \"option\",\n \"output\", \"p\", \"picture\", \"pre\", \"progress\", \"q\", \"rp\", \"rt\", \"ruby\", \"s\",\n \"samp\", \"script\", \"search\", \"section\", \"select\", \"slot\", \"small\", \"source\",\n \"span\", \"strong\", \"style\", \"sub\", \"summary\", \"sup\", \"table\", \"tbody\", \"td\",\n \"template\", \"textarea\", \"tfoot\", \"th\", \"thead\", \"time\", \"title\", \"tr\",\n \"track\", \"u\", \"ul\", \"var\", \"video\", \"wbr\",\n] as const satisfies ReadonlyArray<ElementTagName>;\n\nexport const SVG_TAGS = [\n \"a\", \"animate\", \"animateMotion\", \"animateTransform\", \"circle\", \"clipPath\",\n \"defs\", \"desc\", \"ellipse\", \"feBlend\", \"feColorMatrix\", \"feComponentTransfer\",\n \"feComposite\", \"feConvolveMatrix\", \"feDiffuseLighting\", \"feDisplacementMap\",\n \"feDistantLight\", \"feDropShadow\", \"feFlood\", \"feFuncA\", \"feFuncB\", \"feFuncG\",\n \"feFuncR\", \"feGaussianBlur\", \"feImage\", \"feMerge\", \"feMergeNode\", \"feMorphology\",\n \"feOffset\", \"fePointLight\", \"feSpecularLighting\", \"feSpotLight\", \"feTile\",\n \"feTurbulence\", \"filter\", \"foreignObject\", \"g\", \"image\", \"line\", \"linearGradient\",\n \"marker\", \"mask\", \"metadata\", \"mpath\", \"path\", \"pattern\", \"polygon\", \"polyline\",\n \"radialGradient\", \"rect\", \"script\", \"set\", \"stop\", \"style\", \"svg\", \"switch\",\n \"symbol\", \"text\", \"textPath\", \"title\", \"tspan\", \"use\", \"view\",\n] as const satisfies ReadonlyArray<keyof SVGElementTagNameMap>;\n\nexport const SELF_CLOSING_TAGS = [\n \"area\", \"base\", \"br\", \"col\", \"embed\", \"hr\", \"img\", \"input\", \"link\", \"meta\",\n \"source\", \"track\", \"wbr\",\n] as const satisfies ReadonlyArray<ElementTagName>;\n\nfunction registerHtmlTag(target: Record<string, unknown>, tagName: ElementTagName): void {\n if (!(tagName in target)) {\n target[tagName] = createTagBuilder(tagName);\n }\n}\n\nexport function registerGlobalTagBuilders(target: Record<string, unknown> = globalThis): void {\n const marker = \"__vc_tags_registered\";\n if ((target as Record<string, boolean>)[marker]) return;\n\n HTML_TAGS.forEach((tagName) => registerHtmlTag(target, tagName));\n (target as Record<string, boolean>)[marker] = true;\n}\n","import { createMarkerPair, safeRemoveChild } from \"../utility/dom\";\nimport { arraysEqual } from \"../utility/arrayUtils\";\nimport { resolveRenderable } from \"../utility/renderables\";\nimport type { ListRenderer, ListRuntime, ListItemRecord, ListItemsProvider } from \"./types\";\n\nconst activeListRuntimes = new Set<ListRuntime<any>>();\n\nfunction renderItem<TItem>(\n runtime: ListRuntime<TItem>,\n item: TItem,\n index: number,\n): ExpandedElement<any> | null {\n const result = runtime.renderItem(item, index);\n return resolveRenderable(result, runtime.host, index);\n}\n\nfunction remove(record: ListItemRecord<unknown>): void {\n safeRemoveChild(record.element as unknown as Node);\n}\n\nexport function sync<TItem>(runtime: ListRuntime<TItem>): void {\n const { host, startMarker, endMarker } = runtime;\n const parent = (startMarker.parentNode ?? (host as unknown as Node & ParentNode)) as\n Node & ParentNode;\n\n const currentItems = runtime.itemsProvider();\n\n if (arraysEqual(runtime.lastSyncedItems, currentItems)) return;\n\n const recordsByPosition = new Map<number, ListItemRecord<TItem>>();\n const availableRecords = new Map<TItem, ListItemRecord<TItem>[]>();\n\n runtime.records.forEach((record) => {\n const items = availableRecords.get(record.item);\n if (items) {\n items.push(record);\n } else {\n availableRecords.set(record.item, [record]);\n }\n });\n\n currentItems.forEach((item, newIndex) => {\n if (\n newIndex < runtime.lastSyncedItems.length &&\n runtime.lastSyncedItems[newIndex] === item\n ) {\n const existingRecord = runtime.records[newIndex];\n if (existingRecord && existingRecord.item === item) {\n recordsByPosition.set(newIndex, existingRecord);\n const items = availableRecords.get(item);\n if (items) {\n const recordIndex = items.indexOf(existingRecord);\n if (recordIndex >= 0) {\n items.splice(recordIndex, 1);\n if (items.length === 0) {\n availableRecords.delete(item);\n }\n }\n }\n }\n }\n });\n\n const newRecords: Array<ListItemRecord<TItem>> = [];\n const elementsToRemove = new Set<ListItemRecord<TItem>>(runtime.records);\n let nextSibling: Node = endMarker;\n\n for (let i = currentItems.length - 1; i >= 0; i--) {\n const item = currentItems[i];\n let record = recordsByPosition.get(i);\n\n if (!record) {\n const availableItems = availableRecords.get(item);\n if (availableItems && availableItems.length > 0) {\n record = availableItems.shift()!;\n if (availableItems.length === 0) {\n availableRecords.delete(item);\n }\n }\n }\n\n if (record) {\n elementsToRemove.delete(record);\n } else {\n const element = renderItem(runtime, item, i);\n if (!element) continue;\n record = { item, element };\n }\n\n newRecords.unshift(record);\n\n const recordNode = record.element as unknown as Node;\n if (recordNode.nextSibling !== nextSibling) {\n parent.insertBefore(recordNode, nextSibling);\n }\n nextSibling = recordNode;\n }\n\n elementsToRemove.forEach(remove);\n\n runtime.records = newRecords;\n runtime.lastSyncedItems = [...currentItems];\n}\n\nexport function createListRuntime<TItem>(\n itemsProvider: ListItemsProvider<TItem>,\n renderItem: ListRenderer<TItem>,\n host: ExpandedElement<any>,\n): ListRuntime<TItem> {\n const { start: startMarker, end: endMarker } = createMarkerPair(\"list\");\n\n const runtime: ListRuntime<TItem> = {\n itemsProvider,\n renderItem,\n startMarker,\n endMarker,\n records: [],\n host,\n lastSyncedItems: [],\n };\n\n const parentNode = host as unknown as Node & ParentNode;\n parentNode.appendChild(startMarker);\n parentNode.appendChild(endMarker);\n\n activeListRuntimes.add(runtime);\n sync(runtime);\n\n return runtime;\n}\n\nexport function updateListRuntimes(): void {\n activeListRuntimes.forEach((runtime) => {\n if (!runtime.startMarker.isConnected || !runtime.endMarker.isConnected) {\n activeListRuntimes.delete(runtime);\n return;\n }\n\n sync(runtime);\n });\n}\n","import { isFunction, isTagLike } from \"./typeGuards\";\n\nexport function resolveRenderable(\n result: unknown,\n host: ExpandedElement<any>,\n index: number\n): ExpandedElement<any> | null {\n if (isFunction(result)) {\n const element = (result as NodeModFn<any>)(host, index);\n if (element && isTagLike(element)) {\n return element as ExpandedElement<any>;\n }\n return null;\n }\n\n if (result && isTagLike(result)) {\n return result as ExpandedElement<any>;\n }\n\n return null;\n}\n","export function arraysEqual<T>(a: T[], b: T[]): boolean {\n if (a === b) return true;\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if ((i in a ? a[i] : undefined) !== (i in b ? b[i] : undefined)) return false;\n }\n return true;\n}\n","import { createListRuntime } from \"./runtime\";\nimport type { ListRenderer, ListItemsProvider } from \"./types\";\n\n/**\n * Maps items to DOM elements, keeping them in sync with changes.\n */\nexport function list<TItem>(\n itemsProvider: ListItemsProvider<TItem>,\n render: ListRenderer<TItem>,\n): NodeModFn<any> {\n return (host: ExpandedElement<any>) => {\n const runtime = createListRuntime(itemsProvider, render, host);\n return runtime.startMarker;\n };\n}\n","export type ConditionInput = boolean | (() => boolean);\n\nexport function runCondition(\n condition: () => boolean,\n onError?: (error: unknown) => void\n): boolean {\n try {\n return condition();\n } catch (error) {\n if (!onError) {\n throw error;\n }\n onError(error);\n return false;\n }\n}\n\nexport function resolveCondition(\n value: ConditionInput,\n onError?: (error: unknown) => void\n): boolean {\n return typeof value === \"function\"\n ? runCondition(value as () => boolean, onError)\n : Boolean(value);\n}\n","import { isBrowser } from \"../utility/environment\";\nimport { applyNodeModifier } from \"../core/modifierProcessor\";\nimport { createMarkerPair, clearBetweenMarkers, insertNodesBefore } from \"../utility/dom\";\nimport { resolveCondition } from \"../utility/conditions\";\nimport { modifierProbeCache } from \"../utility/modifierPredicates\";\nimport { isFunction } from \"../utility/typeGuards\";\n\ntype WhenCondition = boolean | (() => boolean);\ntype WhenContent<TTagName extends ElementTagName = ElementTagName> = \n NodeMod<TTagName> | NodeModFn<TTagName>;\n\ninterface WhenGroup<TTagName extends ElementTagName = ElementTagName> {\n condition: WhenCondition;\n content: WhenContent<TTagName>[];\n}\n\ninterface WhenRuntime<TTagName extends ElementTagName = ElementTagName> {\n startMarker: Comment;\n endMarker: Comment;\n host: ExpandedElement<TTagName>;\n index: number;\n groups: WhenGroup<TTagName>[];\n elseContent: WhenContent<TTagName>[];\n /**\n * Tracks which branch is currently rendered:\n * - null: nothing rendered yet\n * - -1: else branch\n * - >=0: index of groups[]\n */\n activeIndex: number | -1 | null;\n update(): void;\n}\n\nconst activeWhenRuntimes = new Set<WhenRuntime<any>>();\n\nfunction renderWhenContent<TTagName extends ElementTagName>(\n runtime: WhenRuntime<TTagName>\n): void {\n const { groups, elseContent, host, index, endMarker } = runtime;\n\n let newActive: number | -1 | null = null;\n for (let i = 0; i < groups.length; i++) {\n if (resolveCondition(groups[i].condition)) {\n newActive = i;\n break;\n }\n }\n if (newActive === null && elseContent.length) {\n newActive = -1;\n }\n\n if (newActive === runtime.activeIndex) return;\n\n clearBetweenMarkers(runtime.startMarker, runtime.endMarker);\n runtime.activeIndex = newActive;\n\n if (newActive === null) return;\n\n const nodes: Node[] = [];\n\n const renderItems = (items: ReadonlyArray<WhenContent<TTagName>>): void => {\n for (const item of items) {\n if (isFunction(item)) {\n if ((item as Function).length === 0) {\n modifierProbeCache.delete(item as Function);\n const node = applyNodeModifier(host, item, index);\n if (node) nodes.push(node);\n continue;\n }\n\n const realHost = host as unknown as Element & {\n appendChild: (n: Node) => Node;\n insertBefore: (n: Node, ref: Node | null) => Node;\n };\n const originalAppend = realHost.appendChild;\n (realHost as unknown as Record<string, Function>).appendChild = function (n: Node) {\n return (realHost as unknown as Record<string, Function>).insertBefore(\n n,\n endMarker\n ) as Node;\n };\n try {\n const maybeNode = applyNodeModifier(host, item, index);\n if (maybeNode && !maybeNode.parentNode) {\n nodes.push(maybeNode);\n }\n } finally {\n (realHost as unknown as Record<string, Function>).appendChild = originalAppend;\n }\n continue;\n }\n\n const node = applyNodeModifier(host, item, index);\n if (node) nodes.push(node);\n }\n };\n\n if (newActive >= 0) {\n renderItems(groups[newActive].content);\n } else if (newActive === -1) {\n renderItems(elseContent);\n }\n\n insertNodesBefore(nodes, endMarker);\n}\n\nclass WhenBuilderImpl<TTagName extends ElementTagName = ElementTagName> {\n private groups: WhenGroup<TTagName>[] = [];\n private elseContent: WhenContent<TTagName>[] = [];\n\n constructor(initialCondition: WhenCondition, ...content: WhenContent<TTagName>[]) {\n this.groups.push({ condition: initialCondition, content });\n }\n\n when(condition: WhenCondition, ...content: WhenContent<TTagName>[]): WhenBuilderImpl<TTagName> {\n this.groups.push({ condition, content });\n return this;\n }\n\n else(...content: WhenContent<TTagName>[]): WhenBuilderImpl<TTagName> {\n this.elseContent = content;\n return this;\n }\n\n render(host: ExpandedElement<TTagName>, index: number): Node | null {\n if (!isBrowser) return document.createComment(\"when-ssr\");\n\n const { start: startMarker, end: endMarker } = createMarkerPair(\"when\");\n\n const runtime: WhenRuntime<TTagName> = {\n startMarker,\n endMarker,\n host,\n index,\n groups: [...this.groups],\n elseContent: [...this.elseContent],\n activeIndex: null,\n update: () => renderWhenContent(runtime),\n };\n\n activeWhenRuntimes.add(runtime);\n\n const parent = host as unknown as Node & ParentNode;\n parent.appendChild(startMarker);\n parent.appendChild(endMarker);\n\n renderWhenContent(runtime);\n\n return startMarker;\n }\n}\n\nfunction createWhenBuilderFunction<TTagName extends ElementTagName>(\n builder: WhenBuilderImpl<TTagName>\n): WhenBuilder<TTagName> {\n const nodeModFn = (host: ExpandedElement<TTagName>, index: number): Node | null => {\n return builder.render(host, index);\n };\n\n return Object.assign(nodeModFn, {\n when: (condition: WhenCondition, ...content: WhenContent<TTagName>[]): WhenBuilder<TTagName> => {\n builder.when(condition, ...content);\n return createWhenBuilderFunction(builder);\n },\n else: (...content: WhenContent<TTagName>[]): WhenBuilder<TTagName> => {\n builder.else(...content);\n return createWhenBuilderFunction(builder);\n },\n }) as unknown as WhenBuilder<TTagName>;\n}\n\nexport function updateWhenRuntimes(): void {\n activeWhenRuntimes.forEach((runtime) => {\n try {\n runtime.update();\n } catch (error) {\n activeWhenRuntimes.delete(runtime);\n }\n });\n}\n\nexport function clearWhenRuntimes(): void {\n activeWhenRuntimes.clear();\n}\n\nexport function when<TTagName extends ElementTagName = ElementTagName>(\n condition: WhenCondition,\n ...content: WhenContent<TTagName>[]\n): WhenBuilder<TTagName> {\n const builder = new WhenBuilderImpl<TTagName>(condition, ...content);\n return createWhenBuilderFunction(builder);\n}\n","import { applyModifiers } from \"../internal/applyModifiers\";\nimport { isBrowser } from \"../utility/environment\";\nimport {\n ConditionalInfo,\n getConditionalInfo,\n storeConditionalInfo,\n getActiveConditionalNodes,\n unregisterConditionalNode,\n} from \"../utility/conditionalInfo\";\nimport { runCondition } from \"../utility/conditions\";\n\nfunction createElementFromConditionalInfo(conditionalInfo: ConditionalInfo): Element {\n const element = document.createElement(conditionalInfo.tagName);\n\n try {\n applyModifiers(\n element as ExpandedElement<ElementTagName>,\n conditionalInfo.modifiers as ReadonlyArray<NodeMod<ElementTagName> | NodeModFn<ElementTagName>>,\n 0\n );\n } catch (error) {\n console.error(`Error applying modifiers in conditional element \"${conditionalInfo.tagName}\":`, error);\n }\n return element;\n}\n\nfunction createCommentPlaceholder(conditionalInfo: ConditionalInfo): Comment {\n return document.createComment(`conditional-${conditionalInfo.tagName}-hidden`);\n}\n\nfunction replaceNodeSafely(oldNode: Node, newNode: Node): void {\n if (oldNode.parentNode) {\n try {\n oldNode.parentNode.replaceChild(newNode, oldNode);\n } catch (error) {\n console.error(\"Error replacing conditional node:\", error);\n }\n }\n}\n\nfunction updateConditionalNode(node: Element | Comment): void {\n const conditionalInfo = getConditionalInfo(node);\n if (!conditionalInfo) {\n return;\n }\n\n const shouldShow = runCondition(conditionalInfo.condition, (error) => {\n console.error(\"Error evaluating conditional condition:\", error);\n });\n const isElement = node.nodeType === Node.ELEMENT_NODE;\n\n if (shouldShow && !isElement) {\n const element = createElementFromConditionalInfo(conditionalInfo);\n storeConditionalInfo(element, conditionalInfo);\n replaceNodeSafely(node, element);\n } else if (!shouldShow && isElement) {\n const comment = createCommentPlaceholder(conditionalInfo);\n storeConditionalInfo(comment, conditionalInfo);\n replaceNodeSafely(node, comment);\n }\n}\n\nexport function updateConditionalElements(): void {\n if (!isBrowser) return;\n\n try {\n getActiveConditionalNodes().forEach((node) => {\n if (!node.isConnected) {\n unregisterConditionalNode(node);\n return;\n }\n updateConditionalNode(node as Element | Comment);\n });\n } catch (error) {\n console.error(\"Error during conditional elements update:\", error);\n }\n}\n","import { updateListRuntimes } from \"../list/runtime\";\nimport { notifyReactiveElements, notifyReactiveTextNodes } from \"./reactive\";\nimport { updateWhenRuntimes } from \"../when\";\nimport { updateConditionalElements } from \"./conditionalUpdater\";\nimport { dispatchGlobalUpdateEvent } from \"../utility/events\";\n\nconst updaters = [\n updateListRuntimes,\n updateWhenRuntimes,\n updateConditionalElements,\n notifyReactiveElements,\n notifyReactiveTextNodes,\n dispatchGlobalUpdateEvent,\n] as const;\n\nexport function update(): void {\n for (const fn of updaters) fn();\n}\n","export function dispatchGlobalUpdateEvent(): void {\n if (typeof document === \"undefined\") {\n return;\n }\n\n const targets: EventTarget[] = [];\n if (document.body) {\n targets.push(document.body);\n }\n targets.push(document);\n\n targets.forEach((target) => {\n try {\n target.dispatchEvent(new Event(\"update\", { bubbles: true }));\n } catch (error) {\n console.error(\"Error dispatching global update event:\", error);\n }\n });\n}\n","/**\n * Typed event listener helper.\n *\n * Usage:\n * button(\n * \"Click\",\n * on(\"click\", (e) => {\n * // e is correctly typed (e.g. MouseEvent for \"click\")\n * })\n * )\n *\n * Design notes:\n * - Returns a NodeModFn so it can be used like any other modifier.\n * - Produces no child node (returns void in the modifier body).\n * - Provides strong typing of the event object based on the DOM event name.\n */\n\n/**\n * Overload for standard HTMLElement events (strongly typed via lib.dom.d.ts)\n */\nexport function on<\n K extends keyof HTMLElementEventMap,\n TTagName extends ElementTagName = ElementTagName\n>(\n type: K,\n listener: (ev: HTMLElementEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions\n): NodeModFn<TTagName>;\n\n/**\n * Fallback / custom event overload (arbitrary event names or custom event types).\n * Specify a custom event type with the E generic if needed:\n * on<\"my-event\", CustomEvent<MyDetail>>(\"my-event\", e => { ... })\n */\nexport function on<\n K extends string,\n E extends Event = Event,\n TTagName extends ElementTagName = ElementTagName\n>(\n type: K,\n listener: (ev: E) => any,\n options?: boolean | AddEventListenerOptions\n): NodeModFn<TTagName>;\n\nexport function on(\n type: string,\n listener: (ev: Event) => any,\n options?: boolean | AddEventListenerOptions\n): NodeModFn<any> {\n return (parent: ExpandedElement<any>) => {\n const el = parent as unknown as HTMLElement | null | undefined;\n if (!el || typeof el.addEventListener !== \"function\") {\n return;\n }\n\n const wrapped = (ev: Event) => {\n try {\n listener.call(el, ev);\n } catch (error) {\n if (typeof console !== \"undefined\" && console.error) {\n console.error(`[nuclo:on] Error in '${type}' listener:`, error);\n }\n }\n };\n\n el.addEventListener(type, wrapped as EventListener, options);\n };\n}\n\n/**\n * (Optional) Helper to detect an on()-produced modifier (placeholder for future use).\n */\nexport function isOnModifier(fn: unknown): boolean {\n return typeof fn === \"function\" && Object.prototype.hasOwnProperty.call(fn, \"__vcOn\");\n}","/**\n * Renders a NodeModFn to a parent element by calling it and appending the result.\n *\n * @param nodeModFn The NodeModFn to render (created by tag builders like div(), h1(), etc.)\n * @param parent The parent element to render into (defaults to document.body)\n * @param index The index to pass to the NodeModFn (defaults to 0)\n * @returns The rendered element\n */\nexport function render<TTagName extends ElementTagName = ElementTagName>(\n nodeModFn: NodeModFn<TTagName>,\n parent?: Element,\n index: number = 0\n): ExpandedElement<TTagName> {\n const targetParent = (parent || document.body) as ExpandedElement<TTagName>;\n const element = nodeModFn(targetParent, index) as ExpandedElement<TTagName>;\n (parent || document.body).appendChild(element as Node);\n return element;\n}\n","import { registerGlobalTagBuilders } from \"./tagRegistry\";\nimport { list } from \"../list\";\nimport { update } from \"./updateController\";\nimport { when } from \"../when\";\nimport { on } from \"../utility/on\";\nimport { render } from \"../utility/render\";\n\n/**\n * Initializes the View Craft runtime by exposing tag builders and utilities.\n */\nexport function initializeRuntime(): void {\n registerGlobalTagBuilders();\n\n if (typeof globalThis !== \"undefined\") {\n const registry = globalThis as Record<string, unknown>;\n registry.list = list;\n registry.update = update;\n registry.when = when;\n registry.on = on;\n registry.render = render;\n }\n}\n\nif (typeof globalThis !== \"undefined\") {\n initializeRuntime();\n}\n"],"names":["isPrimitive","value","isNode","Node","isObject","isTagLike","isFunction","logError","message","error","console","safeExecute","fn","fallback","isBrowser","window","document","safeRemoveChild","child","parentNode","removeChild","createCommentSafely","text","createComment","createMarkerComment","prefix","Error","comment","Math","random","toString","slice","createMarkerPair","endComment","start","end","isNodeConnected","node","isConnected","contains","reactiveTextNodes","Map","reactiveElements","applyAttributeResolvers","el","info","attributeResolvers","forEach","resolver","applyValue","key","e","createReactiveTextNode","preEvaluated","createTextNode","initial","arguments","length","str","undefined","String","txt","set","lastValue","registerAttributeResolver","element","Element","get","ensureElementInfo","updateListener","listener","addEventListener","assignInlineStyles","styles","style","Object","entries","property","removeProperty","applySingleAttribute","raw","styleValue","resolvedStyles","setValue","v","setAttribute","applyAttributes","attributes","k","keys","modifierProbeCache","WeakMap","isBooleanFunction","cached","record","probeOnce","isConditionalModifier","modifier","allModifiers","currentIndex","otherModifiers","filter","_","index","some","mod","applyNodeModifier","parent","fragment","createDocumentFragment","textNode","appendChild","produced","candidate","activeConditionalNodes","Set","storeConditionalInfo","_conditionalInfo","add","applyModifiers","modifiers","startIndex","nextIndex","appended","localIndex","i","createElementWithModifiers","tagName","createElement","processConditionalModifiers","conditionalIndex","findConditionalModifier","condition","createElementFactory","passed","createConditionalElement","createTagBuilder","mods","HTML_TAGS","registerGlobalTagBuilders","target","globalThis","marker","registerHtmlTag","activeListRuntimes","renderItem","runtime","item","result","host","resolveRenderable","remove","sync","startMarker","endMarker","currentItems","itemsProvider","a","b","arraysEqual","lastSyncedItems","recordsByPosition","availableRecords","records","items","push","newIndex","existingRecord","recordIndex","indexOf","splice","delete","newRecords","elementsToRemove","nextSibling","availableItems","shift","unshift","recordNode","insertBefore","list","render","createListRuntime","runCondition","onError","resolveCondition","Boolean","activeWhenRuntimes","renderWhenContent","groups","elseContent","newActive","activeIndex","current","next","clearBetweenMarkers","nodes","renderItems","realHost","originalAppend","n","maybeNode","content","referenceNode","newNode","safeInsertBefore","insertNodesBefore","WhenBuilderImpl","constructor","initialCondition","this","when","update","createWhenBuilderFunction","builder","assign","else","replaceNodeSafely","oldNode","replaceChild","updateConditionalNode","conditionalInfo","getConditionalInfo","shouldShow","isElement","nodeType","ELEMENT_NODE","createElementFromConditionalInfo","createCommentPlaceholder","updaters","unregisterConditionalNode","removeEventListener","newVal","textContent","targets","body","dispatchEvent","Event","bubbles","on","type","options","ev","call","nodeModFn","initializeRuntime","registry","children","nodeToAppend","createTextNodeSafely","safeAppendChild"],"mappings":"aAAM,SAAUA,EAAYC,GAC1B,OAAiB,OAAVA,GAAoC,iBAAVA,GAAuC,mBAAVA,CAChE,CAEM,SAAUC,EAAUD,GACxB,OAAOA,aAAiBE,IAC1B,CAEM,SAAUC,EAASH,GACvB,MAAwB,iBAAVA,GAAgC,OAAVA,CACtC,CAEM,SAAUI,EAAaJ,GAC3B,OAAOG,EAASH,IAAU,YAAcA,CAC1C,CAMM,SAAUK,EAA+BL,GAC7C,MAAwB,mBAAVA,CAChB,CCjBM,SAAUM,EAASC,EAAiBC,GACjB,oBAAZC,SACTA,QAAQD,MAAM,UAAUD,IAAWC,EAEvC,CAGM,SAAUE,EAAeC,EAAaC,GAC1C,IACE,OAAOD,GACT,CAAE,MAAOH,GAEP,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WzF,EAAO,OAAO,EAC9B,IAEE,OADAyF,EAAOI,YAAY7F,IACZ,CACT,CAAE,MACA,OAAO,CACT,CACF,CAmGMwO,CAAgB/I,EAAQ6I,EAC1B,IAGK7I,GArBaA,CAsBtB,gKHlGM,SAAoB1G,GACxB,MAAwB,kBAAVA,CAChB"}
package/dist/nuclo.js CHANGED
@@ -1,2 +1,2 @@
1
- function e(e){return null===e||"object"!=typeof e&&"function"!=typeof e}function t(e){return e instanceof Node}function n(e){return"object"==typeof e&&null!==e}function r(e){return n(e)&&"tagName"in e}function o(e){return"boolean"==typeof e}function i(e){return"function"==typeof e}function c(e,t){"undefined"!=typeof console&&console.error(`nuclo: ${e}`,t)}function u(e,t){try{return e()}catch(e){return c("Operation failed",e),t}}const a="undefined"!=typeof window&&"undefined"!=typeof document;function l(e){if(!e?.parentNode)return!1;try{return e.parentNode.removeChild(e),!0}catch{return!1}}function s(e){if(!a)return null;try{return document.createComment(e)}catch{return null}}function d(e){if(!a)throw new Error("Cannot create comment in non-browser environment");const t=s(`${e}-${Math.random().toString(36).slice(2)}`);if(!t)throw new Error("Failed to create comment");return t}function f(e){const t=s(`${e}-end`);if(!t)throw new Error("Failed to create end comment");return{start:d(`${e}-start`),end:t}}function p(e,...t){return e?(t.forEach(t=>{if(null!=t){let n;if("string"==typeof t){const e=function(e){if(!a)return null;try{return document.createTextNode(String(e))}catch{return null}}(t);if(!e)return;n=e}else n=t;!function(e,t){if(!e||!t)return!1;try{return e.appendChild(t),!0}catch{return!1}}(e,n)}}),e):e}function h(e){return!!e&&("boolean"==typeof e.isConnected?e.isConnected:document.contains(e))}const m=new Map,g=new Map;function y(e,t){t.attributeResolvers.forEach(({resolver:e,applyValue:t},n)=>{try{t(u(e))}catch(e){c(`Failed to update reactive attribute: ${n}`,e)}})}function v(e,t){if("function"!=typeof e)return c("Invalid resolver provided to createReactiveTextNode"),document.createTextNode("");const n=arguments.length>1?t:u(e,""),r=void 0===n?"":String(n),o=document.createTextNode(r);return m.set(o,{resolver:e,lastValue:r}),o}function b(e,t,n,r){if(!(e instanceof Element&&t&&"function"==typeof n))return void c("Invalid parameters for registerAttributeResolver");const o=function(e){let t=g.get(e);return t||(t={attributeResolvers:new Map},g.set(e,t)),t}(e);o.attributeResolvers.set(t,{resolver:n,applyValue:r});try{r(u(n))}catch(e){c("Failed to apply initial attribute value",e)}if(!o.updateListener){const t=()=>y(0,o);e.addEventListener("update",t),o.updateListener=t}}function C(e,t){e&&e.style&&t&&Object.entries(t).forEach(([t,n])=>{if(null==n||""===n)e.style.removeProperty(t),e.style[t]="";else try{e.style[t]=String(n)}catch{}})}function E(e,t,n){if(null==n)return;if("style"===t)return o=n,void((r=e)&&(i(o)?b(r,"style",()=>{try{return o()}catch{return null}},e=>{C(r,e)}):C(r,o)));var r,o;const c=n=>{null!=n&&(t in e?e[t]=n:e instanceof Element&&e.setAttribute(String(t),String(n)))};i(n)&&0===n.length?b(e,String(t),n,c):c(n)}function w(e,t){if(t)for(const n of Object.keys(t)){E(e,n,t[n])}}const x=new WeakMap;function M(e){const{value:t,error:n}=function(e){const t=x.get(e);if(t)return t;try{const t={value:e(),error:!1};return x.set(e,t),t}catch{const t={value:void 0,error:!0};return x.set(e,t),t}}(e);return!n&&"boolean"==typeof t}function N(e,r,o){if(!i(e)||0!==e.length||!M(e))return!1;const c=r.filter((e,t)=>t!==o);if(0===c.length)return!1;return c.some(e=>n(e)||t(e)||i(e)&&e.length>0)}function S(r,o,u){if(null==o)return null;if(i(o)){if(0===o.length)try{let t=x.get(o);if(!t){t={value:o(),error:!1},x.set(o,t)}if(t.error){const e=document.createDocumentFragment(),t=document.createComment(` text-${u} `),n=v(()=>"");return e.appendChild(t),e.appendChild(n),e}const n=t.value;if(e(n)&&null!=n){const e=document.createDocumentFragment(),t=document.createComment(` text-${u} `),r=v(o,n);return e.appendChild(t),e.appendChild(r),e}return null}catch(e){x.set(o,{value:void 0,error:!0}),c("Error evaluating reactive text function:",e);const t=document.createDocumentFragment(),n=document.createComment(` text-${u} `),r=v(()=>"");return t.appendChild(n),t.appendChild(r),t}const i=o(r,u);if(null==i)return null;if(e(i)){const e=document.createDocumentFragment(),t=document.createComment(` text-${u} `),n=document.createTextNode(String(i));return e.appendChild(t),e.appendChild(n),e}return t(i)?i:(n(i)&&w(r,i),null)}const a=o;if(null==a)return null;if(e(a)){const e=document.createDocumentFragment(),t=document.createComment(` text-${u} `),n=document.createTextNode(String(a));return e.appendChild(t),e.appendChild(n),e}return t(a)?a:(n(a)&&w(r,a),null)}const k=new Set;function I(e,t){e._conditionalInfo=t,k.add(e)}function T(e,t,n=0){if(!t||0===t.length)return{element:e,nextIndex:n,appended:0};let r=n,o=0;const i=e;for(let n=0;n<t.length;n+=1){const c=t[n];if(null==c)continue;const u=S(e,c,r);u&&(u.parentNode!==i&&i.appendChild(u),r+=1,o+=1)}return{element:e,nextIndex:r,appended:o}}function $(e,t){const n=document.createElement(e);return T(n,t,0),n}function F(e){const t=function(e){for(let t=0;t<e.length;t+=1)if(N(e[t],e,t))return t;return-1}(e);return-1===t?{condition:null,otherModifiers:e}:{condition:e[t],otherModifiers:e.filter((e,n)=>n!==t)}}function L(e,...t){return(n,r)=>{const{condition:o,otherModifiers:i}=F(t);if(o)return function(e,t,n){const r=t();if(!a)return r?$(e,n):document.createComment(`conditional-${e}-ssr`);if(r){const r=$(e,n);return I(r,{condition:t,tagName:e,modifiers:n}),r}const o=document.createComment(`conditional-${e}-hidden`);return I(o,{condition:t,tagName:e,modifiers:n}),o}(e,o,i);const c=document.createElement(e);return T(c,i,r),c}}function D(e){return(...t)=>L(e,...t)}const O=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","script","search","section","select","slot","small","source","span","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"],j=["a","animate","animateMotion","animateTransform","circle","clipPath","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","foreignObject","g","image","line","linearGradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","stop","style","svg","switch","symbol","text","textPath","title","tspan","use","view"],B=["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"];function _(e=globalThis){const t="__vc_tags_registered";e[t]||(O.forEach(t=>function(e,t){t in e||(e[t]=D(t))}(e,t)),e[t]=!0)}const P=new Set;function R(e,t,n){return function(e,t,n){if(i(e)){const o=e(t,n);return o&&r(o)?o:null}return e&&r(e)?e:null}(e.renderItem(t,n),e.host,n)}function V(e){l(e.element)}function G(e){const{host:t,startMarker:n,endMarker:r}=e,o=n.parentNode??t,i=e.itemsProvider();if(function(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if((n in e?e[n]:void 0)!==(n in t?t[n]:void 0))return!1;return!0}(e.lastSyncedItems,i))return;const c=new Map,u=new Map;e.records.forEach(e=>{const t=u.get(e.item);t?t.push(e):u.set(e.item,[e])}),i.forEach((t,n)=>{if(n<e.lastSyncedItems.length&&e.lastSyncedItems[n]===t){const r=e.records[n];if(r&&r.item===t){c.set(n,r);const e=u.get(t);if(e){const n=e.indexOf(r);n>=0&&(e.splice(n,1),0===e.length&&u.delete(t))}}}});const a=[],l=new Set(e.records);let s=r;for(let t=i.length-1;t>=0;t--){const n=i[t];let r=c.get(t);if(!r){const e=u.get(n);e&&e.length>0&&(r=e.shift(),0===e.length&&u.delete(n))}if(r)l.delete(r);else{const o=R(e,n,t);if(!o)continue;r={item:n,element:o}}a.unshift(r);const d=r.element;d.nextSibling!==s&&o.insertBefore(d,s),s=d}l.forEach(V),e.records=a,e.lastSyncedItems=[...i]}function A(e,t){return n=>{const r=function(e,t,n){const{start:r,end:o}=f("list"),i={itemsProvider:e,renderItem:t,startMarker:r,endMarker:o,records:[],host:n,lastSyncedItems:[]},c=n;return c.appendChild(r),c.appendChild(o),P.add(i),G(i),i}(e,t,n);return r.startMarker}}function q(e,t){try{return e()}catch(e){if(!t)throw e;return t(e),!1}}function W(e,t){return"function"==typeof e?q(e,t):Boolean(e)}const z=new Set;function H(e){const{groups:t,elseContent:n,host:r,index:o,endMarker:c}=e;let u=null;for(let e=0;e<t.length;e++)if(W(t[e].condition)){u=e;break}if(null===u&&n.length&&(u=-1),u===e.activeIndex)return;if(function(e,t){let n=e.nextSibling;for(;n&&n!==t;){const e=n.nextSibling;l(n),n=e}}(e.startMarker,e.endMarker),e.activeIndex=u,null===u)return;const a=[],s=e=>{for(const t of e){if(i(t)){if(0===t.length){x.delete(t);const e=S(r,t,o);e&&a.push(e);continue}const e=r,n=e.appendChild;e.appendChild=function(t){return e.insertBefore(t,c)};try{const e=S(r,t,o);e&&!e.parentNode&&a.push(e)}finally{e.appendChild=n}continue}const e=S(r,t,o);e&&a.push(e)}};u>=0?s(t[u].content):-1===u&&s(n),function(e,t){const n=t.parentNode;n&&e.forEach(e=>function(e,t,n){if(!e||!t)return!1;try{return e.insertBefore(t,n),!0}catch{return!1}}(n,e,t))}(a,c)}class J{groups=[];elseContent=[];constructor(e,...t){this.groups.push({condition:e,content:t})}when(e,...t){return this.groups.push({condition:e,content:t}),this}else(...e){return this.elseContent=e,this}render(e,t){if(!a)return document.createComment("when-ssr");const{start:n,end:r}=f("when"),o={startMarker:n,endMarker:r,host:e,index:t,groups:[...this.groups],elseContent:[...this.elseContent],activeIndex:null,update:()=>H(o)};z.add(o);const i=e;return i.appendChild(n),i.appendChild(r),H(o),n}}function K(e){return Object.assign((t,n)=>e.render(t,n),{when:(t,...n)=>(e.when(t,...n),K(e)),else:(...t)=>(e.else(...t),K(e))})}function Q(e,...t){return K(new J(e,...t))}function U(e,t){if(e.parentNode)try{e.parentNode.replaceChild(t,e)}catch(e){console.error("Error replacing conditional node:",e)}}function X(e){const t=function(e){return e._conditionalInfo??null}(e);if(!t)return;const n=q(t.condition,e=>{console.error("Error evaluating conditional condition:",e)}),r=e.nodeType===Node.ELEMENT_NODE;if(n&&!r){const n=function(e){const t=document.createElement(e.tagName);try{T(t,e.modifiers,0)}catch(t){console.error(`Error applying modifiers in conditional element "${e.tagName}":`,t)}return t}(t);I(n,t),U(e,n)}else if(!n&&r){const n=function(e){return document.createComment(`conditional-${e.tagName}-hidden`)}(t);I(n,t),U(e,n)}}const Y=[function(){P.forEach(e=>{e.startMarker.isConnected&&e.endMarker.isConnected?G(e):P.delete(e)})},function(){z.forEach(e=>{try{e.update()}catch(t){z.delete(e)}})},function(){if(a)try{k.forEach(e=>{e.isConnected?X(e):function(e){k.delete(e)}(e)})}catch(e){console.error("Error during conditional elements update:",e)}},function(){g.forEach((e,t)=>{if(!h(t))return e.updateListener&&t.removeEventListener("update",e.updateListener),void g.delete(t);y(0,e)})},function(){m.forEach((e,t)=>{if(h(t))try{const n=u(e.resolver),r=void 0===n?"":String(n);r!==e.lastValue&&(t.textContent=r,e.lastValue=r)}catch(e){c("Failed to update reactive text node",e)}else m.delete(t)})},function(){if("undefined"==typeof document)return;const e=[];document.body&&e.push(document.body),e.push(document),e.forEach(e=>{try{e.dispatchEvent(new Event("update",{bubbles:!0}))}catch(e){console.error("Error dispatching global update event:",e)}})}];function Z(){for(const e of Y)e()}function ee(e,t,n){return r=>{const o=r;if(!o||"function"!=typeof o.addEventListener)return;o.addEventListener(e,n=>{try{t.call(o,n)}catch(t){"undefined"!=typeof console&&console.error&&console.error(`[nuclo:on] Error in '${e}' listener:`,t)}},n)}}function te(e,t,n=0){const r=e(t||document.body,n);return(t||document.body).appendChild(r),r}function ne(){if(_(),"undefined"!=typeof globalThis){const e=globalThis;e.list=A,e.update=Z,e.when=Q,e.on=ee,e.render=te}}"undefined"!=typeof globalThis&&ne(),console.log("nuclo");export{O as HTML_TAGS,B as SELF_CLOSING_TAGS,j as SVG_TAGS,p as appendChildren,w as applyAttributes,S as applyNodeModifier,L as createElementFactory,D as createTagBuilder,ne as initializeRuntime,o as isBoolean,a as isBrowser,i as isFunction,t as isNode,n as isObject,e as isPrimitive,r as isTagLike,A as list,ee as on,_ as registerGlobalTagBuilders,te as render,Z as update,Q as when};
1
+ function e(e){return null===e||"object"!=typeof e&&"function"!=typeof e}function t(e){return e instanceof Node}function n(e){return"object"==typeof e&&null!==e}function r(e){return n(e)&&"tagName"in e}function o(e){return"boolean"==typeof e}function i(e){return"function"==typeof e}function c(e,t){"undefined"!=typeof console&&console.error(`nuclo: ${e}`,t)}function u(e,t){try{return e()}catch(e){return c("Operation failed",e),t}}const a="undefined"!=typeof window&&"undefined"!=typeof document;function l(e){if(!e?.parentNode)return!1;try{return e.parentNode.removeChild(e),!0}catch{return!1}}function s(e){if(!a)return null;try{return document.createComment(e)}catch{return null}}function d(e){if(!a)throw new Error("Cannot create comment in non-browser environment");const t=s(`${e}-${Math.random().toString(36).slice(2)}`);if(!t)throw new Error("Failed to create comment");return t}function f(e){const t=s(`${e}-end`);if(!t)throw new Error("Failed to create end comment");return{start:d(`${e}-start`),end:t}}function p(e,...t){return e?(t.forEach(t=>{if(null!=t){let n;if("string"==typeof t){const e=function(e){if(!a)return null;try{return document.createTextNode(String(e))}catch{return null}}(t);if(!e)return;n=e}else n=t;!function(e,t){if(!e||!t)return!1;try{return e.appendChild(t),!0}catch{return!1}}(e,n)}}),e):e}function h(e){return!!e&&("boolean"==typeof e.isConnected?e.isConnected:document.contains(e))}const m=new Map,g=new Map;function y(e,t){t.attributeResolvers.forEach(({resolver:e,applyValue:t},n)=>{try{t(u(e))}catch(e){c(`Failed to update reactive attribute: ${n}`,e)}})}function v(e,t){if("function"!=typeof e)return c("Invalid resolver provided to createReactiveTextNode"),document.createTextNode("");const n=arguments.length>1?t:u(e,""),r=void 0===n?"":String(n),o=document.createTextNode(r);return m.set(o,{resolver:e,lastValue:r}),o}function b(e,t,n,r){if(!(e instanceof Element&&t&&"function"==typeof n))return void c("Invalid parameters for registerAttributeResolver");const o=function(e){let t=g.get(e);return t||(t={attributeResolvers:new Map},g.set(e,t)),t}(e);o.attributeResolvers.set(t,{resolver:n,applyValue:r});try{r(u(n))}catch(e){c("Failed to apply initial attribute value",e)}if(!o.updateListener){const t=()=>y(0,o);e.addEventListener("update",t),o.updateListener=t}}function C(e,t){e&&e.style&&t&&Object.entries(t).forEach(([t,n])=>{if(null==n||""===n)e.style.removeProperty(t),e.style[t]="";else try{e.style[t]=String(n)}catch{}})}function E(e,t,n){if(null==n)return;if("style"===t)return o=n,void((r=e)&&(i(o)?b(r,"style",()=>{try{return o()}catch{return null}},e=>{C(r,e)}):C(r,o)));var r,o;const c=n=>{null!=n&&(t in e?e[t]=n:e instanceof Element&&e.setAttribute(String(t),String(n)))};i(n)&&0===n.length?b(e,String(t),n,c):c(n)}function w(e,t){if(t)for(const n of Object.keys(t)){E(e,n,t[n])}}const x=new WeakMap;function M(e){const{value:t,error:n}=function(e){const t=x.get(e);if(t)return t;try{const t={value:e(),error:!1};return x.set(e,t),t}catch{const t={value:void 0,error:!0};return x.set(e,t),t}}(e);return!n&&"boolean"==typeof t}function N(e,r,o){if(!i(e)||0!==e.length||!M(e))return!1;const c=r.filter((e,t)=>t!==o);if(0===c.length)return!1;return c.some(e=>n(e)||t(e)||i(e)&&e.length>0)}function S(r,o,u){if(null==o)return null;if(i(o)){if(0===o.length)try{let t=x.get(o);if(!t){t={value:o(),error:!1},x.set(o,t)}if(t.error){const e=document.createDocumentFragment(),t=document.createComment(` text-${u} `),n=v(()=>"");return e.appendChild(t),e.appendChild(n),e}const n=t.value;if(e(n)&&null!=n){const e=document.createDocumentFragment(),t=document.createComment(` text-${u} `),r=v(o,n);return e.appendChild(t),e.appendChild(r),e}return null}catch(e){x.set(o,{value:void 0,error:!0}),c("Error evaluating reactive text function:",e);const t=document.createDocumentFragment(),n=document.createComment(` text-${u} `),r=v(()=>"");return t.appendChild(n),t.appendChild(r),t}const i=o(r,u);if(null==i)return null;if(e(i)){const e=document.createDocumentFragment(),t=document.createComment(` text-${u} `),n=document.createTextNode(String(i));return e.appendChild(t),e.appendChild(n),e}return t(i)?i:(n(i)&&w(r,i),null)}const a=o;if(null==a)return null;if(e(a)){const e=document.createDocumentFragment(),t=document.createComment(` text-${u} `),n=document.createTextNode(String(a));return e.appendChild(t),e.appendChild(n),e}return t(a)?a:(n(a)&&w(r,a),null)}const k=new Set;function I(e,t){e._conditionalInfo=t,k.add(e)}function T(e,t,n=0){if(!t||0===t.length)return{element:e,nextIndex:n,appended:0};let r=n,o=0;const i=e;for(let n=0;n<t.length;n+=1){const c=t[n];if(null==c)continue;const u=S(e,c,r);u&&(u.parentNode!==i&&i.appendChild(u),r+=1,o+=1)}return{element:e,nextIndex:r,appended:o}}function $(e,t){const n=document.createElement(e);return T(n,t,0),n}function F(e){const t=function(e){for(let t=0;t<e.length;t+=1)if(N(e[t],e,t))return t;return-1}(e);return-1===t?{condition:null,otherModifiers:e}:{condition:e[t],otherModifiers:e.filter((e,n)=>n!==t)}}function L(e,...t){return(n,r)=>{const{condition:o,otherModifiers:i}=F(t);if(o)return function(e,t,n){const r=t();if(!a)return r?$(e,n):document.createComment(`conditional-${e}-ssr`);if(r){const r=$(e,n);return I(r,{condition:t,tagName:e,modifiers:n}),r}const o=document.createComment(`conditional-${e}-hidden`);return I(o,{condition:t,tagName:e,modifiers:n}),o}(e,o,i);const c=document.createElement(e);return T(c,i,r),c}}function D(e){return(...t)=>L(e,...t)}const O=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","script","search","section","select","slot","small","source","span","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"],j=["a","animate","animateMotion","animateTransform","circle","clipPath","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","foreignObject","g","image","line","linearGradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","stop","style","svg","switch","symbol","text","textPath","title","tspan","use","view"],B=["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"];function _(e=globalThis){const t="__vc_tags_registered";e[t]||(O.forEach(t=>function(e,t){t in e||(e[t]=D(t))}(e,t)),e[t]=!0)}const P=new Set;function R(e,t,n){return function(e,t,n){if(i(e)){const o=e(t,n);return o&&r(o)?o:null}return e&&r(e)?e:null}(e.renderItem(t,n),e.host,n)}function V(e){l(e.element)}function G(e){const{host:t,startMarker:n,endMarker:r}=e,o=n.parentNode??t,i=e.itemsProvider();if(function(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if((n in e?e[n]:void 0)!==(n in t?t[n]:void 0))return!1;return!0}(e.lastSyncedItems,i))return;const c=new Map,u=new Map;e.records.forEach(e=>{const t=u.get(e.item);t?t.push(e):u.set(e.item,[e])}),i.forEach((t,n)=>{if(n<e.lastSyncedItems.length&&e.lastSyncedItems[n]===t){const r=e.records[n];if(r&&r.item===t){c.set(n,r);const e=u.get(t);if(e){const n=e.indexOf(r);n>=0&&(e.splice(n,1),0===e.length&&u.delete(t))}}}});const a=[],l=new Set(e.records);let s=r;for(let t=i.length-1;t>=0;t--){const n=i[t];let r=c.get(t);if(!r){const e=u.get(n);e&&e.length>0&&(r=e.shift(),0===e.length&&u.delete(n))}if(r)l.delete(r);else{const o=R(e,n,t);if(!o)continue;r={item:n,element:o}}a.unshift(r);const d=r.element;d.nextSibling!==s&&o.insertBefore(d,s),s=d}l.forEach(V),e.records=a,e.lastSyncedItems=[...i]}function A(e,t){return n=>{const r=function(e,t,n){const{start:r,end:o}=f("list"),i={itemsProvider:e,renderItem:t,startMarker:r,endMarker:o,records:[],host:n,lastSyncedItems:[]},c=n;return c.appendChild(r),c.appendChild(o),P.add(i),G(i),i}(e,t,n);return r.startMarker}}function q(e,t){try{return e()}catch(e){if(!t)throw e;return t(e),!1}}function W(e,t){return"function"==typeof e?q(e,t):Boolean(e)}const z=new Set;function H(e){const{groups:t,elseContent:n,host:r,index:o,endMarker:c}=e;let u=null;for(let e=0;e<t.length;e++)if(W(t[e].condition)){u=e;break}if(null===u&&n.length&&(u=-1),u===e.activeIndex)return;if(function(e,t){let n=e.nextSibling;for(;n&&n!==t;){const e=n.nextSibling;l(n),n=e}}(e.startMarker,e.endMarker),e.activeIndex=u,null===u)return;const a=[],s=e=>{for(const t of e){if(i(t)){if(0===t.length){x.delete(t);const e=S(r,t,o);e&&a.push(e);continue}const e=r,n=e.appendChild;e.appendChild=function(t){return e.insertBefore(t,c)};try{const e=S(r,t,o);e&&!e.parentNode&&a.push(e)}finally{e.appendChild=n}continue}const e=S(r,t,o);e&&a.push(e)}};u>=0?s(t[u].content):-1===u&&s(n),function(e,t){const n=t.parentNode;n&&e.forEach(e=>function(e,t,n){if(!e||!t)return!1;try{return e.insertBefore(t,n),!0}catch{return!1}}(n,e,t))}(a,c)}class J{groups=[];elseContent=[];constructor(e,...t){this.groups.push({condition:e,content:t})}when(e,...t){return this.groups.push({condition:e,content:t}),this}else(...e){return this.elseContent=e,this}render(e,t){if(!a)return document.createComment("when-ssr");const{start:n,end:r}=f("when"),o={startMarker:n,endMarker:r,host:e,index:t,groups:[...this.groups],elseContent:[...this.elseContent],activeIndex:null,update:()=>H(o)};z.add(o);const i=e;return i.appendChild(n),i.appendChild(r),H(o),n}}function K(e){return Object.assign((t,n)=>e.render(t,n),{when:(t,...n)=>(e.when(t,...n),K(e)),else:(...t)=>(e.else(...t),K(e))})}function Q(e,...t){return K(new J(e,...t))}function U(e,t){if(e.parentNode)try{e.parentNode.replaceChild(t,e)}catch(e){console.error("Error replacing conditional node:",e)}}function X(e){const t=function(e){return e._conditionalInfo??null}(e);if(!t)return;const n=q(t.condition,e=>{console.error("Error evaluating conditional condition:",e)}),r=e.nodeType===Node.ELEMENT_NODE;if(n&&!r){const n=function(e){const t=document.createElement(e.tagName);try{T(t,e.modifiers,0)}catch(t){console.error(`Error applying modifiers in conditional element "${e.tagName}":`,t)}return t}(t);I(n,t),U(e,n)}else if(!n&&r){const n=function(e){return document.createComment(`conditional-${e.tagName}-hidden`)}(t);I(n,t),U(e,n)}}const Y=[function(){P.forEach(e=>{e.startMarker.isConnected&&e.endMarker.isConnected?G(e):P.delete(e)})},function(){z.forEach(e=>{try{e.update()}catch(t){z.delete(e)}})},function(){if(a)try{k.forEach(e=>{e.isConnected?X(e):function(e){k.delete(e)}(e)})}catch(e){console.error("Error during conditional elements update:",e)}},function(){g.forEach((e,t)=>{if(!h(t))return e.updateListener&&t.removeEventListener("update",e.updateListener),void g.delete(t);y(0,e)})},function(){m.forEach((e,t)=>{if(h(t))try{const n=u(e.resolver),r=void 0===n?"":String(n);r!==e.lastValue&&(t.textContent=r,e.lastValue=r)}catch(e){c("Failed to update reactive text node",e)}else m.delete(t)})},function(){if("undefined"==typeof document)return;const e=[];document.body&&e.push(document.body),e.push(document),e.forEach(e=>{try{e.dispatchEvent(new Event("update",{bubbles:!0}))}catch(e){console.error("Error dispatching global update event:",e)}})}];function Z(){for(const e of Y)e()}function ee(e,t,n){return r=>{const o=r;if(!o||"function"!=typeof o.addEventListener)return;o.addEventListener(e,n=>{try{t.call(o,n)}catch(t){"undefined"!=typeof console&&console.error&&console.error(`[nuclo:on] Error in '${e}' listener:`,t)}},n)}}function te(e,t,n=0){const r=e(t||document.body,n);return(t||document.body).appendChild(r),r}function ne(){if(_(),"undefined"!=typeof globalThis){const e=globalThis;e.list=A,e.update=Z,e.when=Q,e.on=ee,e.render=te}}"undefined"!=typeof globalThis&&ne();export{O as HTML_TAGS,B as SELF_CLOSING_TAGS,j as SVG_TAGS,p as appendChildren,w as applyAttributes,S as applyNodeModifier,L as createElementFactory,D as createTagBuilder,ne as initializeRuntime,o as isBoolean,a as isBrowser,i as isFunction,t as isNode,n as isObject,e as isPrimitive,r as isTagLike,A as list,ee as on,_ as registerGlobalTagBuilders,te as render,Z as update,Q as when};
2
2
  //# sourceMappingURL=nuclo.js.map