nuclo 0.1.48 → 0.1.50

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/nuclo.umd.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Nuclo={})}(this,function(t){"use strict";function e(t){return null===t||"object"!=typeof t&&"function"!=typeof t}function n(t){return t instanceof Node}function r(t){return"object"==typeof t&&null!==t}function i(t){return r(t)&&"tagName"in t}function o(t){return"function"==typeof t}function s(t){return o(t)&&0===t.length}function c(t,e){"undefined"!=typeof console&&console.error(`nuclo: ${t}`,e)}function u(t,e){try{return t()}catch(t){return c("Operation failed",t),e}}const l="undefined"!=typeof window&&"undefined"!=typeof document;function a(t){if(!t?.parentNode)return!1;try{return t.parentNode.removeChild(t),!0}catch(t){return c("Failed to remove child node",t),!1}}function d(t){if(!l)return null;try{return document.createComment(t)}catch(t){return c("Failed to create comment node",t),null}}function f(t){return d(t)}function h(t,e="hidden"){try{return document.createComment(`conditional-${t}-${e}`)}catch(t){return c("Failed to create conditional comment",t),null}}function p(t){if(!l)throw new Error("Cannot create comment in non-browser environment");const e=d(`${t}-${Math.random().toString(36).slice(2)}`);if(!e)throw new Error("Failed to create comment");return e}function m(t){const e=d(`${t}-end`);if(!e)throw new Error("Failed to create end comment");return{start:p(`${t}-start`),end:e}}function g(t,e){const n=e.parentNode;n&&t.forEach(t=>function(t,e,n){if(!t||!e)return!1;try{return t.insertBefore(e,n),!0}catch(t){return c("Failed to insert node before reference",t),!1}}(n,t,e))}function y(t){return!!t&&("boolean"==typeof t.isConnected?t.isConnected:!(!l||"undefined"==typeof document)&&document.contains(t))}function b(t,e){if(!t?.parentNode)return!1;try{return t.parentNode.replaceChild(e,t),!0}catch(t){return c("Error replacing conditional node",t),!1}}const w=new Map,v=new Map;function x(t,e){e.attributeResolvers.forEach(({resolver:t,applyValue:e},n)=>{try{e(u(t))}catch(t){c(`Failed to update reactive attribute: ${n}`,t)}})}function S(t,e,n,r){if(!(t instanceof Element&&e&&"function"==typeof n))return void c("Invalid parameters for registerAttributeResolver");const i=function(t){let e=v.get(t);return e||(e={attributeResolvers:new Map},v.set(t,e)),e}(t);i.attributeResolvers.set(e,{resolver:n,applyValue:r});try{r(u(n))}catch(t){c("Failed to apply initial attribute value",t)}if(!i.updateListener){const e=()=>x(0,i);t.addEventListener("update",e),i.updateListener=e}}function E(t,e,n){try{if(null==n||""===n)return t.style[e]="",!0;const r=String(n);return t.style[e]=r,!0}catch{return!1}}function C(t,e){if(t?.style&&e)for(const[n,r]of Object.entries(e)){E(t,n,r)||c(`Failed to set style property '${n}'`)}}function N(t,e,n,r=!1){if(null==n)return;if("style"===e)return s=n,void((i=t)&&(o(s)?S(i,"style",()=>{try{return s()}catch(t){return c("Error in style resolver function",t),null}},t=>{C(i,t)}):C(i,s)));var i,s;const u=(n,r=!1)=>{if(null==n)return;if("className"===e&&t instanceof HTMLElement&&r){const e=String(n),r=t.className;if(r&&r!==e){const n=new Set(r.split(" ").filter(t=>t));e.split(" ").filter(t=>t).forEach(t=>n.add(t)),t.className=Array.from(n).join(" ")}else e&&(t.className=e);return}if(t instanceof Element&&"http://www.w3.org/2000/svg"===t.namespaceURI)t.setAttribute(String(e),String(n));else if(e in t)try{t[e]=n}catch{t instanceof Element&&t.setAttribute(String(e),String(n))}else t instanceof Element&&t.setAttribute(String(e),String(n))};if(o(n)&&0===n.length){const r=n;S(t,String(e),r,t=>u(t,!1))}else u(n,r)}function M(t,e,n=!0){if(e)for(const r of Object.keys(e)){N(t,r,e[r],n&&"className"===r)}}const k=new WeakMap;function F(t){const{value:e,error:n}=function(t){const e=k.get(t);if(e)return e;try{const e={value:t(),error:!1};return k.set(t,e),e}catch{const e={value:void 0,error:!0};return k.set(t,e),e}}(t);return!n&&"boolean"==typeof e}function T(t,e,i){if(!o(t)||0!==t.length)return!1;if(!F(t))return!1;const s=e.filter((t,e)=>e!==i);if(0===s.length)return!1;return s.some(t=>!(!r(t)&&!n(t))||!!(o(t)&&t.length>0))}function $(t,i,u){if(null==i)return null;if(o(i)){if(s(i))try{let t=k.get(i);if(!t){t={value:i(),error:!1},k.set(i,t)}if(t.error)return I(u,()=>"");const n=t.value;return e(n)&&null!=n?I(u,i,n):null}catch(t){return k.set(i,{value:void 0,error:!0}),c("Error evaluating reactive text function:",t),I(u,()=>"")}const o=i(t,u);return null==o?null:e(o)?j(u,o):n(o)?o:(r(o)&&M(t,o),null)}const l=i;return null==l?null:e(l)?j(u,l):n(l)?l:(r(l)&&M(t,l),null)}function I(t,e,n){const r=document.createDocumentFragment(),i=f(` text-${t} `);i&&r.appendChild(i);const o=function(t,e){if("function"!=typeof t)return c("Invalid resolver provided to createReactiveTextNode"),document.createTextNode("");const n=arguments.length>1?e:u(t,""),r=void 0===n?"":String(n),i=document.createTextNode(r);return w.set(i,{resolver:t,lastValue:r}),i}(e,n);return r.appendChild(o),r}function j(t,e){const n=document.createDocumentFragment(),r=f(` text-${t} `);r&&n.appendChild(r);const i=document.createTextNode(String(e));return n.appendChild(i),n}const L=new Set;function R(t,e){t._conditionalInfo=e,L.add(t)}function A(t,e,n=0){if(!e||0===e.length)return{element:t,nextIndex:n,appended:0};let r=n,i=0;const o=t;for(let n=0;n<e.length;n+=1){const s=e[n];if(null==s)continue;const c=$(t,s,r);c&&(c.parentNode!==o&&o.appendChild(c),r+=1,i+=1)}return{element:t,nextIndex:r,appended:i}}function O(t,e){const n=document.createElement(t);return A(n,e,0),n}function B(t){const e=function(t){for(let e=0;e<t.length;e+=1)if(T(t[e],t,e))return e;return-1}(t);return-1===e?{condition:null,otherModifiers:t}:{condition:t[e],otherModifiers:t.filter((t,n)=>n!==e)}}function _(t){return function(t){return P.includes(t)}(t)?document.createElementNS("http://www.w3.org/2000/svg",t):document.createElement(t)}function D(t,...e){return(n,r)=>{const{condition:i,otherModifiers:o}=B(e);if(i)return function(t,e,n){const r=e();if(!l)return r?O(t,n):h(t,"ssr");const i={condition:e,tagName:t,modifiers:n};if(r){const e=O(t,n);return R(e,i),e}const o=h(t);if(!o)throw new Error(`Failed to create conditional comment for ${t}`);return R(o,i),o}(t,i,o);const s=_(t);return A(s,o,r),s}}function G(t){return(...e)=>D(t,...e)}const z=["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"],P=["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"];function V(t=globalThis){const e="__nuclo_tags_registered";t[e]||(P.forEach(e=>function(t,e){let n=e;["a","script","style","title","text"].includes(e)?n=`${e}_svg`:["stop"].includes(e)&&(n=`${e}_`),n in t||(t[n]=G(e))}(t,e)),z.forEach(e=>function(t,e){e in t&&"function"!=typeof t[e]||(t[e]=G(e))}(t,e)),t[e]=!0)}const W=new Set;function q(t,e,n){return function(t,e,n){if(o(t)){const r=t(e,n);return r&&i(r)?r:null}return t&&i(t)?t:null}(t.renderItem(e,n),t.host,n)}function H(t){a(t.element)}function U(t){const{host:e,startMarker:n,endMarker:r}=t,i=n.parentNode??e,o=t.itemsProvider();if(function(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if((n in t?t[n]:void 0)!==(n in e?e[n]:void 0))return!1;return!0}(t.lastSyncedItems,o))return;const s=new Map,c=new Map;t.records.forEach(t=>{const e=c.get(t.item);e?e.push(t):c.set(t.item,[t])}),o.forEach((e,n)=>{if(n<t.lastSyncedItems.length&&t.lastSyncedItems[n]===e){const r=t.records[n];if(r&&r.item===e){s.set(n,r);const t=c.get(e);if(t){const n=t.indexOf(r);n>=0&&(t.splice(n,1),0===t.length&&c.delete(e))}}}});const u=[],l=new Set(t.records);let a=r;for(let e=o.length-1;e>=0;e--){const n=o[e];let r=s.get(e);if(!r){const t=c.get(n);t&&t.length>0&&(r=t.shift(),0===t.length&&c.delete(n))}if(r)l.delete(r);else{const i=q(t,n,e);if(!i)continue;r={item:n,element:i}}u.unshift(r);const d=r.element;d.nextSibling!==a&&i.insertBefore(d,a),a=d}l.forEach(H),t.records=u,t.lastSyncedItems=[...o]}function Z(t,e){return(n,r)=>{const i=function(t,e,n){const{start:r,end:i}=m("list"),o={itemsProvider:t,renderItem:e,startMarker:r,endMarker:i,records:[],host:n,lastSyncedItems:[]},s=n;return s.appendChild(r),s.appendChild(i),W.add(o),U(o),o}(t,e,n);return i.startMarker}}function J(t,e){try{return t()}catch(t){if(e)return e(t),!1;throw t}}function K(t,e){return"function"==typeof t?J(t,e):Boolean(t)}const Q=new Set;function X(t,e,n,r){return o(t)?s(t)?(k.delete(t),$(e,t,n)):function(t,e,n){const r=t,i=r.appendChild.bind(r),o=r.insertBefore.bind(r);r.appendChild=function(t){return o(t,e)};try{return n()}finally{r.appendChild=i}}(e,r,()=>{const r=$(e,t,n);return r&&!r.parentNode?r:null}):$(e,t,n)}function Y(t){const{groups:e,elseContent:n,host:r,index:i,endMarker:o}=t,s=function(t,e){for(let e=0;e<t.length;e++)if(K(t[e].condition))return e;return e.length>0?-1:null}(e,n);if(s===t.activeIndex)return;if(function(t,e){let n=t.nextSibling;for(;n&&n!==e;){const t=n.nextSibling;a(n),n=t}}(t.startMarker,t.endMarker),t.activeIndex=s,null===s)return;const c=function(t,e,n,r){const i=[];for(const o of t){const t=X(o,e,n,r);t&&i.push(t)}return i}(s>=0?e[s].content:n,r,i,o);g(c,o)}class tt{groups=[];elseContent=[];constructor(t,...e){this.groups.push({condition:t,content:e})}when(t,...e){return this.groups.push({condition:t,content:e}),this}else(...t){return this.elseContent=t,this}render(t,e){if(!l){return f("when-ssr")||null}const{start:n,end:r}=m("when"),i={startMarker:n,endMarker:r,host:t,index:e,groups:[...this.groups],elseContent:[...this.elseContent],activeIndex:null,update:()=>Y(i)};Q.add(i);const o=t;return o.appendChild(n),o.appendChild(r),Y(i),n}}function et(t){return Object.assign((e,n)=>t.render(e,n),{when:(e,...n)=>(t.when(e,...n),et(t)),else:(...e)=>(t.else(...e),et(t))})}function nt(t,...e){return et(new tt(t,...e))}function rt(t){const e=function(t){return t._conditionalInfo??null}(t);if(!e)return;const n=J(e.condition,t=>{c("Error evaluating conditional condition",t)}),r=t.nodeType===Node.ELEMENT_NODE;if(n&&!r){const n=function(t){try{return O(t.tagName,t.modifiers)}catch(e){return c(`Error applying modifiers in conditional element "${t.tagName}"`,e),document.createElement(t.tagName)}}(e);R(n,e),b(t,n)}else if(!n&&r){const n=h(e.tagName);n&&(R(n,e),b(t,n))}}const it=[function(){W.forEach(t=>{t.startMarker.isConnected&&t.endMarker.isConnected?U(t):W.delete(t)})},function(){Q.forEach(t=>{try{t.update()}catch(e){Q.delete(t)}})},function(){if(l)try{L.forEach(t=>{t.isConnected?rt(t):function(t){L.delete(t)}(t)})}catch(t){c("Error during conditional elements update",t)}},function(){v.forEach((t,e)=>{if(!y(e))return t.updateListener&&e.removeEventListener("update",t.updateListener),void v.delete(e);x(0,t)})},function(){w.forEach((t,e)=>{if(y(e))try{const n=u(t.resolver),r=void 0===n?"":String(n);r!==t.lastValue&&(e.textContent=r,t.lastValue=r)}catch(t){c("Failed to update reactive text node",t)}else w.delete(e)})},function(){if("undefined"==typeof document)return;const t=document.body?[document.body,document]:[document];for(const e of t)try{e.dispatchEvent(new Event("update",{bubbles:!0}))}catch(t){c("Error dispatching global update event",t)}}];function ot(){for(const t of it)t()}function st(t,e,n){return r=>{if(!r||"function"!=typeof r.addEventListener)return;const i=r;i.addEventListener(t,n=>{try{e.call(i,n)}catch(e){c(`Error in '${t}' listener`,e)}},n)}}function ct(t,e,n=0){const r=t(e||document.body,n);return(e||document.body).appendChild(r),r}function ut(t,e){let n=document.querySelector("#nuclo-styles");n||(n=document.createElement("style"),n.id="nuclo-styles",document.head.appendChild(n));const r=Object.entries(e).map(([t,e])=>`${t}: ${e}`).join("; ");n.sheet?.insertRule(`.${t} { ${r} }`,n.sheet.cssRules.length)}class lt{styles={};getStyles(){return{...this.styles}}add(t,e){return this.styles[t]=e,this}bg(t){return this.styles["background-color"]=t,this}color(t){return this.styles.color=t,this}fontSize(t){return this.styles["font-size"]=t,this}display(t){return this.styles.display=t,this}flex(t){return void 0!==t?this.styles.flex=t:this.styles.display="flex",this}center(){return this.styles["justify-content"]="center",this.styles["align-items"]="center",this}bold(){return this.styles["font-weight"]="bold",this}padding(t){return this.styles.padding=t,this}margin(t){return this.styles.margin=t,this}width(t){return this.styles.width=t,this}height(t){return this.styles.height=t,this}border(t){return this.styles.border=t,this}borderRadius(t){return this.styles["border-radius"]=t,this}textAlign(t){return this.styles["text-align"]=t,this}gap(t){return this.styles.gap=t,this}flexDirection(t){return this.styles["flex-direction"]=t,this}grid(){return this.styles.display="grid",this}position(t){return this.styles.position=t,this}opacity(t){return this.styles.opacity=t,this}cursor(t){return this.styles.cursor=t,this}boxShadow(t){return this.styles["box-shadow"]=t,this}transition(t){return this.styles.transition=t,this}textDecoration(t){return this.styles["text-decoration"]=t,this}letterSpacing(t){return this.styles["letter-spacing"]=t,this}fontWeight(t){return this.styles["font-weight"]=t,this}alignItems(t){return this.styles["align-items"]=t,this}justifyContent(t){return this.styles["justify-content"]=t,this}minWidth(t){return this.styles["min-width"]=t,this}maxWidth(t){return this.styles["max-width"]=t,this}minHeight(t){return this.styles["min-height"]=t,this}accentColor(t){return this.styles["accent-color"]=t,this}lineHeight(t){return this.styles["line-height"]=t,this}fontFamily(t){return this.styles["font-family"]=t,this}outline(t){return this.styles.outline=t,this}}let at=0;function dt(t){return function(e){if(!e||0===Object.keys(e).length)return"";const n="nuclo-bp-"+at++,r=Object.entries(t);let i=!0;for(const[t,o]of r){const r=e[t];if(r){const t=r.getStyles();i?(ut(n,t),i=!1):ft(n,t,o)}}return{className:n}}}function ft(t,e,n){let r=document.querySelector("#nuclo-styles");r||(r=document.createElement("style"),r.id="nuclo-styles",document.head.appendChild(r));const i=`@media ${n} { .${t} { ${Object.entries(e).map(([t,e])=>`${t}: ${e}`).join("; ")} } }`;r.sheet?.insertRule(i,r.sheet.cssRules.length)}function ht(t){return(new lt).bg(t)}function pt(t){return(new lt).color(t)}function mt(t){return(new lt).fontSize(t)}function gt(t){return(new lt).flex(t)}function yt(){return(new lt).center()}function bt(){return(new lt).bold()}function wt(t){return(new lt).padding(t)}function vt(t){return(new lt).margin(t)}function xt(t){return(new lt).width(t)}function St(t){return(new lt).height(t)}function Et(t){return(new lt).border(t)}function Ct(t){return(new lt).borderRadius(t)}function Nt(t){return(new lt).textAlign(t)}function Mt(t){return(new lt).gap(t)}function kt(t){return(new lt).flexDirection(t)}function Ft(){return(new lt).grid()}function Tt(t){return(new lt).position(t)}function $t(t){return(new lt).opacity(t)}function It(t){return(new lt).cursor(t)}function jt(){if(V(),"undefined"!=typeof globalThis){const t=globalThis;t.list=Z,t.update=ot,t.when=nt,t.on=st,t.render=ct,t.createCSSClass=ut,t.createBreakpoints=dt,t.bg=ht,t.color=pt,t.fontSize=mt,t.flex=gt,t.center=yt,t.bold=bt,t.padding=wt,t.margin=vt,t.width=xt,t.height=St,t.border=Et,t.borderRadius=Ct,t.textAlign=Nt,t.gap=Mt,t.flexDirection=kt,t.grid=Ft,t.position=Tt,t.opacity=$t,t.cursor=It}}"undefined"!=typeof globalThis&&jt(),t.HTML_TAGS=z,t.SELF_CLOSING_TAGS=["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"],t.SVG_TAGS=P,t.appendChildren=function(t,...e){return t?(e.forEach(e=>{if(null!=e){let n;if("string"==typeof e){const t=function(t){if(!l)return null;try{return document.createTextNode(String(t))}catch(t){return c("Failed to create text node",t),null}}(e);if(!t)return;n=t}else n=e;!function(t,e){if(!t||!e)return!1;try{return t.appendChild(e),!0}catch(t){return c("Failed to append child node",t),!1}}(t,n)}}),t):t},t.applyAttributes=M,t.applyNodeModifier=$,t.bg=ht,t.bold=bt,t.border=Et,t.borderRadius=Ct,t.center=yt,t.color=pt,t.createBreakpoints=dt,t.createCSSClass=ut,t.createComment=f,t.createConditionalComment=h,t.createElementFactory=D,t.createElementWithModifiers=O,t.createTagBuilder=G,t.cursor=It,t.flex=gt,t.flexDirection=kt,t.fontSize=mt,t.gap=Mt,t.grid=Ft,t.height=St,t.initializeRuntime=jt,t.isBoolean=function(t){return"boolean"==typeof t},t.isBrowser=l,t.isFunction=o,t.isNode=n,t.isObject=r,t.isPrimitive=e,t.isTagLike=i,t.isZeroArityFunction=s,t.list=Z,t.margin=vt,t.on=st,t.opacity=$t,t.padding=wt,t.position=Tt,t.registerGlobalTagBuilders=V,t.render=ct,t.replaceNodeSafely=b,t.textAlign=Nt,t.update=ot,t.when=nt,t.width=xt});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Nuclo={})}(this,function(e){"use strict";function t(e){return null===e||"object"!=typeof e&&"function"!=typeof e}function n(e){return e instanceof Node}function r(e){return"object"==typeof e&&null!==e}function o(e){return r(e)&&"tagName"in e}function i(e){return"function"==typeof e}function s(e){return i(e)&&0===e.length}function c(e,t){"undefined"!=typeof console&&console.error(`nuclo: ${e}`,t)}function a(e,t){try{return e()}catch(e){return c("Operation failed",e),t}}const l="undefined"!=typeof window&&"undefined"!=typeof document;function u(e){if(!e?.parentNode)return!1;try{return e.parentNode.removeChild(e),!0}catch(e){return c("Failed to remove child node",e),!1}}function d(e){if(!l)return null;try{return document.createComment(e)}catch(e){return c("Failed to create comment node",e),null}}function f(e){return d(e)}function h(e,t="hidden"){try{return document.createComment(`conditional-${e}-${t}`)}catch(e){return c("Failed to create conditional comment",e),null}}function p(e){if(!l)throw new Error("Cannot create comment in non-browser environment");const t=d(`${e}-${Math.random().toString(36).slice(2)}`);if(!t)throw new Error("Failed to create comment");return t}function m(e){const t=d(`${e}-end`);if(!t)throw new Error("Failed to create end comment");return{start:p(`${e}-start`),end:t}}function g(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(e){return c("Failed to insert node before reference",e),!1}}(n,e,t))}function y(e){return!!e&&("boolean"==typeof e.isConnected?e.isConnected:!(!l||"undefined"==typeof document)&&document.contains(e))}function b(e,t){if(!e?.parentNode)return!1;try{return e.parentNode.replaceChild(t,e),!0}catch(e){return c("Error replacing conditional node",e),!1}}const C=new Map,w=new Map;function x(e,t){t.attributeResolvers.forEach(({resolver:e,applyValue:t},n)=>{try{t(a(e))}catch(e){c(`Failed to update reactive attribute: ${n}`,e)}})}function v(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=w.get(e);return t||(t={attributeResolvers:new Map},w.set(e,t)),t}(e);o.attributeResolvers.set(t,{resolver:n,applyValue:r});try{r(a(n))}catch(e){c("Failed to apply initial attribute value",e)}if(!o.updateListener){const t=()=>x(0,o);e.addEventListener("update",t),o.updateListener=t}}function S(e,t,n){try{if(null==n||""===n)return e.style[t]="",!0;const r=String(n);return e.style[t]=r,!0}catch{return!1}}function E(e,t){if(e?.style&&t)for(const[n,r]of Object.entries(t)){S(e,n,r)||c(`Failed to set style property '${n}'`)}}function N(e,t,n,r=!1){if(null==n)return;if("style"===t)return s=n,void((o=e)&&(i(s)?v(o,"style",()=>{try{return s()}catch(e){return c("Error in style resolver function",e),null}},e=>{E(o,e)}):E(o,s)));var o,s;const a=(n,r=!1)=>{if(null==n)return;if("className"===t&&e instanceof HTMLElement&&r){const t=String(n),r=e.className;if(r&&r!==t){const n=new Set(r.split(" ").filter(e=>e));t.split(" ").filter(e=>e).forEach(e=>n.add(e)),e.className=Array.from(n).join(" ")}else t&&(e.className=t);return}if(e instanceof Element&&"http://www.w3.org/2000/svg"===e.namespaceURI)e.setAttribute(String(t),String(n));else if(t in e)try{e[t]=n}catch{e instanceof Element&&e.setAttribute(String(t),String(n))}else e instanceof Element&&e.setAttribute(String(t),String(n))};if(i(n)&&0===n.length){const r=n;v(e,String(t),r,e=>a(e,!1))}else a(n,r)}function M(e,t,n=!0){if(t)for(const r of Object.keys(t)){N(e,r,t[r],n&&"className"===r)}}const $=new WeakMap;function k(e){const{value:t,error:n}=function(e){const t=$.get(e);if(t)return t;try{const t={value:e(),error:!1};return $.set(e,t),t}catch{const t={value:void 0,error:!0};return $.set(e,t),t}}(e);return!n&&"boolean"==typeof t}function T(e,t,o){if(!i(e)||0!==e.length)return!1;if(!k(e))return!1;const s=t.filter((e,t)=>t!==o);if(0===s.length)return!1;return s.some(e=>!(!r(e)&&!n(e))||!!(i(e)&&e.length>0))}function R(e,o,a){if(null==o)return null;if(i(o)){if(s(o))try{let e=$.get(o);if(!e){e={value:o(),error:!1},$.set(o,e)}if(e.error)return j(a,()=>"");const n=e.value;return t(n)&&null!=n?j(a,o,n):null}catch(e){return $.set(o,{value:void 0,error:!0}),c("Error evaluating reactive text function:",e),j(a,()=>"")}const i=o(e,a);return null==i?null:t(i)?F(a,i):n(i)?i:(r(i)&&M(e,i),null)}const l=o;return null==l?null:t(l)?F(a,l):n(l)?l:(r(l)&&M(e,l),null)}function j(e,t,n){const r=document.createDocumentFragment(),o=f(` text-${e} `);o&&r.appendChild(o);const i=function(e,t){if("function"!=typeof e)return c("Invalid resolver provided to createReactiveTextNode"),document.createTextNode("");const n=arguments.length>1?t:a(e,""),r=void 0===n?"":String(n),o=document.createTextNode(r);return C.set(o,{resolver:e,lastValue:r}),o}(t,n);return r.appendChild(i),r}function F(e,t){const n=document.createDocumentFragment(),r=f(` text-${e} `);r&&n.appendChild(r);const o=document.createTextNode(String(t));return n.appendChild(o),n}const I=new Set;function L(e,t){e._conditionalInfo=t,I.add(e)}function A(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 s=t[n];if(null==s)continue;const c=R(e,s,r);c&&(c.parentNode!==i&&i.appendChild(c),r+=1,o+=1)}return{element:e,nextIndex:r,appended:o}}function D(e,t){const n=document.createElement(e);return A(n,t,0),n}function O(e){const t=function(e){for(let t=0;t<e.length;t+=1)if(T(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 B(e){return function(e){return P.includes(e)}(e)?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e)}function _(e,...t){return(n,r)=>{const{condition:o,otherModifiers:i}=O(t);if(o)return function(e,t,n){const r=t();if(!l)return r?D(e,n):h(e,"ssr");const o={condition:t,tagName:e,modifiers:n};if(r){const t=D(e,n);return L(t,o),t}const i=h(e);if(!i)throw new Error(`Failed to create conditional comment for ${e}`);return L(i,o),i}(e,o,i);const s=B(e);return A(s,i,r),s}}function G(e){return(...t)=>_(e,...t)}const z=["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"],P=["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"];function V(e=globalThis){const t="__nuclo_tags_registered";e[t]||(P.forEach(t=>function(e,t){let n=t;["a","script","style","title","text"].includes(t)?n=`${t}_svg`:["stop"].includes(t)&&(n=`${t}_`),n in e||(e[n]=G(t))}(e,t)),z.forEach(t=>function(e,t){t in e&&"function"!=typeof e[t]||(e[t]=G(t))}(e,t)),e[t]=!0)}const q=new Set;function W(e,t,n){return function(e,t,n){if(i(e)){const r=e(t,n);return r&&o(r)?r:null}return e&&o(e)?e:null}(e.renderItem(t,n),e.host,n)}function H(e){u(e.element)}function Z(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 s=new Map,c=new Map;e.records.forEach(e=>{const t=c.get(e.item);t?t.push(e):c.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){s.set(n,r);const e=c.get(t);if(e){const n=e.indexOf(r);n>=0&&(e.splice(n,1),0===e.length&&c.delete(t))}}}});const a=[],l=new Set(e.records);let u=r;for(let t=i.length-1;t>=0;t--){const n=i[t];let r=s.get(t);if(!r){const e=c.get(n);e&&e.length>0&&(r=e.shift(),0===e.length&&c.delete(n))}if(r)l.delete(r);else{const o=W(e,n,t);if(!o)continue;r={item:n,element:o}}a.unshift(r);const d=r.element;d.nextSibling!==u&&o.insertBefore(d,u),u=d}l.forEach(H),e.records=a,e.lastSyncedItems=[...i]}function U(e,t){return(n,r)=>{const o=function(e,t,n){const{start:r,end:o}=m("list"),i={itemsProvider:e,renderItem:t,startMarker:r,endMarker:o,records:[],host:n,lastSyncedItems:[]},s=n;return s.appendChild(r),s.appendChild(o),q.add(i),Z(i),i}(e,t,n);return o.startMarker}}function J(e,t){try{return e()}catch(e){if(t)return t(e),!1;throw e}}function K(e,t){return"function"==typeof e?J(e,t):Boolean(e)}const Q=new Set;function X(e,t,n,r){return i(e)?s(e)?($.delete(e),R(t,e,n)):function(e,t,n){const r=e,o=r.appendChild.bind(r),i=r.insertBefore.bind(r);r.appendChild=function(e){return i(e,t)};try{return n()}finally{r.appendChild=o}}(t,r,()=>{const r=R(t,e,n);return r&&!r.parentNode?r:null}):R(t,e,n)}function Y(e){const{groups:t,elseContent:n,host:r,index:o,endMarker:i}=e,s=function(e,t){for(let t=0;t<e.length;t++)if(K(e[t].condition))return t;return t.length>0?-1:null}(t,n);if(s===e.activeIndex)return;if(function(e,t){let n=e.nextSibling;for(;n&&n!==t;){const e=n.nextSibling;u(n),n=e}}(e.startMarker,e.endMarker),e.activeIndex=s,null===s)return;const c=function(e,t,n,r){const o=[];for(const i of e){const e=X(i,t,n,r);e&&o.push(e)}return o}(s>=0?t[s].content:n,r,o,i);g(c,i)}class ee{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(!l){return f("when-ssr")||null}const{start:n,end:r}=m("when"),o={startMarker:n,endMarker:r,host:e,index:t,groups:[...this.groups],elseContent:[...this.elseContent],activeIndex:null,update:()=>Y(o)};Q.add(o);const i=e;return i.appendChild(n),i.appendChild(r),Y(o),n}}function te(e){return Object.assign((t,n)=>e.render(t,n),{when:(t,...n)=>(e.when(t,...n),te(e)),else:(...t)=>(e.else(...t),te(e))})}function ne(e,...t){return te(new ee(e,...t))}function re(e){const t=function(e){return e._conditionalInfo??null}(e);if(!t)return;const n=J(t.condition,e=>{c("Error evaluating conditional condition",e)}),r=e.nodeType===Node.ELEMENT_NODE;if(n&&!r){const n=function(e){try{return D(e.tagName,e.modifiers)}catch(t){return c(`Error applying modifiers in conditional element "${e.tagName}"`,t),document.createElement(e.tagName)}}(t);L(n,t),b(e,n)}else if(!n&&r){const n=h(t.tagName);n&&(L(n,t),b(e,n))}}const oe=[function(){q.forEach(e=>{e.startMarker.isConnected&&e.endMarker.isConnected?Z(e):q.delete(e)})},function(){Q.forEach(e=>{try{e.update()}catch(t){Q.delete(e)}})},function(){if(l)try{I.forEach(e=>{e.isConnected?re(e):function(e){I.delete(e)}(e)})}catch(e){c("Error during conditional elements update",e)}},function(){w.forEach((e,t)=>{if(!y(t))return e.updateListener&&t.removeEventListener("update",e.updateListener),void w.delete(t);x(0,e)})},function(){C.forEach((e,t)=>{if(y(t))try{const n=a(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 C.delete(t)})},function(){if("undefined"==typeof document)return;const e=document.body?[document.body,document]:[document];for(const t of e)try{t.dispatchEvent(new Event("update",{bubbles:!0}))}catch(e){c("Error dispatching global update event",e)}}];function ie(){for(const e of oe)e()}function se(e,t,n){return r=>{if(!r||"function"!=typeof r.addEventListener)return;const o=r;o.addEventListener(e,n=>{try{t.call(o,n)}catch(t){c(`Error in '${e}' listener`,t)}},n)}}function ce(e,t,n=0){const r=e(t||document.body,n);return(t||document.body).appendChild(r),r}const ae=new Map;function le(e,t,n){let r=document.querySelector("#nuclo-styles");r||(r=document.createElement("style"),r.id="nuclo-styles",document.head.appendChild(r));Array.from(r.sheet?.cssRules||[]).some(t=>t instanceof CSSStyleRule&&t.selectorText===`.${e}`)||r.sheet?.insertRule(`.${e} { ${t}: ${n}; }`,r.sheet.cssRules.length)}function ue(e,t,n,r){let o=document.querySelector("#nuclo-styles");o||(o=document.createElement("style"),o.id="nuclo-styles",document.head.appendChild(o));const i=Array.from(o.sheet?.cssRules||[]);let s=null;for(const e of i)if(e instanceof CSSMediaRule&&e.media.mediaText===r){s=e;break}if(!s){const e=o.sheet?.cssRules.length||0;o.sheet?.insertRule(`@media ${r} {}`,e),s=o.sheet?.cssRules[e]}Array.from(s.cssRules).some(t=>t instanceof CSSStyleRule&&t.selectorText===`.${e}`)||s.insertRule(`.${e} { ${t}: ${n}; }`,s.cssRules.length)}class de{classNames=[];classDefinitions=[];getClassNames(){return[...this.classNames]}getClassDefinitions(){return[...this.classDefinitions]}toString(){return this.classNames.join(" ")}addClass(e,t){const n=function(e,t){const n=`${e}:${t}`;if(ae.has(n))return ae.get(n);let r;const o={"background-color":"bg",color:"text","font-size":"text",display:"display",flex:"flex","justify-content":"justify","align-items":"items","font-weight":"font",padding:"p",margin:"m",width:"w",height:"h",border:"border","border-radius":"rounded","text-align":"text",gap:"gap","flex-direction":"flex",position:"position",opacity:"opacity",cursor:"cursor","box-shadow":"shadow",transition:"transition","text-decoration":"underline","letter-spacing":"tracking","min-width":"min-w","max-width":"max-w","min-height":"min-h","accent-color":"accent","line-height":"leading","font-family":"font",outline:"outline"}[e]||e.replace(/-/g,"-"),i=function(e){return(e=(e=(e=e.replace(/^#/,"")).replace(/[^a-zA-Z0-9]/g,"-")).replace(/^-+|-+$/g,"").replace(/-+/g,"-")).toLowerCase()}(t);return r="display"===e&&"flex"===t?"flex":"display"===e&&"grid"===t?"grid":"display"===e&&"block"===t?"display-block":"display"===e&&"none"===t?"display-none":"justify-content"===e&&"center"===t&&"justify"===o?"justify-center":"align-items"===e&&"center"===t&&"items"===o?"items-center":"font-weight"===e&&"bold"===t?"font-bold":"text-align"===e&&"center"===t?"text-center":"flex-direction"===e&&"column"===t?"flex-col":"flex-direction"===e&&"row"===t?"flex-row":"cursor"===e&&"pointer"===t?"cursor-pointer":"text-decoration"===e&&"line-through"===t?"line-through":`${o}-${i}`,ae.set(n,r),r}(e,t);return fe.set(n,{property:e,value:t}),this.classDefinitions.push({className:n,property:e,value:t}),le(n,e,t),this.classNames.includes(n)||this.classNames.push(n),this}add(e,t){return this.addClass(e,t)}bg(e){return this.addClass("background-color",e)}color(e){return this.addClass("color",e)}fontSize(e){return this.addClass("font-size",e)}display(e){return this.addClass("display",e)}flex(e){return void 0!==e?this.addClass("flex",e):this.addClass("display","flex")}center(){return this.addClass("justify-content","center"),this.addClass("align-items","center")}bold(){return this.addClass("font-weight","bold")}padding(e){return this.addClass("padding",e)}margin(e){return this.addClass("margin",e)}width(e){return this.addClass("width",e)}height(e){return this.addClass("height",e)}border(e){return this.addClass("border",e)}borderRadius(e){return this.addClass("border-radius",e)}textAlign(e){return this.addClass("text-align",e)}gap(e){return this.addClass("gap",e)}flexDirection(e){return this.addClass("flex-direction",e)}grid(){return this.addClass("display","grid")}position(e){return this.addClass("position",e)}opacity(e){return this.addClass("opacity",e)}cursor(e){return this.addClass("cursor",e)}boxShadow(e){return this.addClass("box-shadow",e)}transition(e){return this.addClass("transition",e)}textDecoration(e){return this.addClass("text-decoration",e)}letterSpacing(e){return this.addClass("letter-spacing",e)}fontWeight(e){return this.addClass("font-weight",e)}alignItems(e){return this.addClass("align-items",e)}justifyContent(e){return this.addClass("justify-content",e)}minWidth(e){return this.addClass("min-width",e)}maxWidth(e){return this.addClass("max-width",e)}minHeight(e){return this.addClass("min-height",e)}accentColor(e){return this.addClass("accent-color",e)}lineHeight(e){return this.addClass("line-height",e)}fontFamily(e){return this.addClass("font-family",e)}outline(e){return this.addClass("outline",e)}}const fe=new Map;function he(e){return function(t,n){let r,o;if(void 0!==n?(r=t,o=n):t instanceof de?(r=t,o=void 0):(r=void 0,o=t),!(r||o&&0!==Object.keys(o).length))return"";const i=[];if(r){const e=r.getClassDefinitions();for(const{className:t,property:n,value:r}of e)le(t,n,r),i.push(t)}if(o&&Object.keys(o).length>0){const t=Object.entries(e);for(const[e,n]of t){const t=o[e];if(t){const r=t.getClassDefinitions();for(const{className:t,property:o,value:s}of r){const r=`${e}-${t}`;ue(r,o,s,n),i.push(r)}}}}return{className:i.join(" ")}}}function pe(e,t){let n=document.querySelector("#nuclo-styles");n||(n=document.createElement("style"),n.id="nuclo-styles",document.head.appendChild(n));const r=Object.entries(t).map(([e,t])=>`${e}: ${t}`).join("; ");n.sheet?.insertRule(`.${e} { ${r} }`,n.sheet.cssRules.length)}function me(e){return(new de).bg(e)}function ge(e){return(new de).color(e)}function ye(e){return(new de).fontSize(e)}function be(e){return(new de).flex(e)}function Ce(){return(new de).center()}function we(){return(new de).bold()}function xe(e){return(new de).padding(e)}function ve(e){return(new de).margin(e)}function Se(e){return(new de).width(e)}function Ee(e){return(new de).height(e)}function Ne(e){return(new de).border(e)}function Me(e){return(new de).borderRadius(e)}function $e(e){return(new de).textAlign(e)}function ke(e){return(new de).gap(e)}function Te(e){return(new de).flexDirection(e)}function Re(){return(new de).grid()}function je(e){return(new de).position(e)}function Fe(e){return(new de).opacity(e)}function Ie(e){return(new de).cursor(e)}function Le(){if(V(),"undefined"!=typeof globalThis){const e=globalThis;e.list=U,e.update=ie,e.when=ne,e.on=se,e.render=ce,e.createCSSClass=pe,e.createBreakpoints=he,e.bg=me,e.color=ge,e.fontSize=ye,e.flex=be,e.center=Ce,e.bold=we,e.padding=xe,e.margin=ve,e.width=Se,e.height=Ee,e.border=Ne,e.borderRadius=Me,e.textAlign=$e,e.gap=ke,e.flexDirection=Te,e.grid=Re,e.position=je,e.opacity=Fe,e.cursor=Ie}}"undefined"!=typeof globalThis&&Le(),e.HTML_TAGS=z,e.SELF_CLOSING_TAGS=["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"],e.SVG_TAGS=P,e.appendChildren=function(e,...t){return e?(t.forEach(t=>{if(null!=t){let n;if("string"==typeof t){const e=function(e){if(!l)return null;try{return document.createTextNode(String(e))}catch(e){return c("Failed to create text node",e),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(e){return c("Failed to append child node",e),!1}}(e,n)}}),e):e},e.applyAttributes=M,e.applyNodeModifier=R,e.bg=me,e.bold=we,e.border=Ne,e.borderRadius=Me,e.center=Ce,e.color=ge,e.createBreakpoints=he,e.createCSSClass=pe,e.createComment=f,e.createConditionalComment=h,e.createElementFactory=_,e.createElementWithModifiers=D,e.createTagBuilder=G,e.cursor=Ie,e.flex=be,e.flexDirection=Te,e.fontSize=ye,e.gap=ke,e.grid=Re,e.height=Ee,e.initializeRuntime=Le,e.isBoolean=function(e){return"boolean"==typeof e},e.isBrowser=l,e.isFunction=i,e.isNode=n,e.isObject=r,e.isPrimitive=t,e.isTagLike=o,e.isZeroArityFunction=s,e.list=U,e.margin=ve,e.on=se,e.opacity=Fe,e.padding=xe,e.position=je,e.registerGlobalTagBuilders=V,e.render=ce,e.replaceNodeSafely=b,e.textAlign=$e,e.update=ie,e.when=ne,e.width=Se});
2
2
  //# sourceMappingURL=nuclo.umd.js.map