@symbo.ls/element 3.14.219 → 3.14.278
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/CHANGELOG.md +12 -0
- package/dist/cjs/src/create.js +4 -4
- package/dist/esm/src/create.js +4 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/cjs/src/create.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";var Y=Object.defineProperty;var
|
|
1
|
+
"use strict";var Y=Object.defineProperty;var ut=Object.getOwnPropertyDescriptor;var dt=Object.getOwnPropertyNames;var pt=Object.prototype.hasOwnProperty;var yt=(t,s)=>{for(var n in s)Y(t,n,{get:s[n],enumerable:!0})},lt=(t,s,n,r)=>{if(s&&typeof s=="object"||typeof s=="function")for(let c of dt(s))!pt.call(t,c)&&c!==n&&Y(t,c,{get:()=>s[c],enumerable:!(r=ut(s,c))||r.enumerable});return t};var ht=t=>lt(Y({},"__esModule",{value:!0}),t);var Lt={};yt(Lt,{create:()=>N,default:()=>Ot});module.exports=ht(Lt);var S=require("@symbo.ls/signal"),j=require("@symbo.ls/signal"),T=require("./cache.js"),P=require("./registry.js"),it=require("./delegate.js"),et=require("./extends.js"),ft=require("./methods.js"),Tt=require("./dispose.js"),V=require("@symbo.ls/utils"),W=require("@symbo.ls/utils/function.js"),K=require("@symbo.ls/state"),x=require("css-in-props"),at=require("@symbo.ls/css"),A=require("@symbo.ls/scratch"),I=require("attrs-in-props");let _t=1;function M(t){return t.length>2&&t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)>=65&&t.charCodeAt(2)<=90}function gt(t){return t.charAt(2).toLowerCase()+t.slice(3)}function bt(t){return t.toLowerCase()}function G(t,s){const n={...t};for(const r in s){const c=n[r],o=s[r];c&&o&&typeof c=="object"&&typeof o=="object"&&!Array.isArray(c)&&!Array.isArray(o)&&typeof c!="function"&&typeof o!="function"?n[r]=G(c,o):n[r]=o}return n}function N(t,s,n,r={},c){if(t==null||t===!1)return null;(typeof t=="string"||typeof t=="number")&&(t={text:t});const o=Object.create(null);o.key=n||t.key||`_${_t++}`,o.parent=s||null,o.context=t.context||s?.context||r.context||{},o.context.__create||(o.context.__create=N);const e=o.__ref={__if:!0,__children:[],__exec:{},__effects:[],__eventCleanup:[],root:s?.__ref?.root||o,path:s?.__ref?.path?[...s.__ref.path,o.key]:[o.key]};if(n&&!t.extends&&!t.extend){const l=n.indexOf("_");if(l>0){const y=n.substring(0,l),g=o.context?.components;g&&(g[y]||g["smbls."+y])&&(t={extends:y,...t})}}(0,et.applyExtends)(o,t,r);const f=new Set(["childProps","attr","style","scope","data"]),i=o.props&&typeof o.props=="object"?o.props:null;for(const l in t){if(l==="parent"||l==="node"||l==="__ref"||l==="extends"||l==="context"||l==="props")continue;const y=t[l],g=o[l],b=g&&y&&typeof g=="object"&&typeof y=="object"&&!Array.isArray(g)&&!Array.isArray(y)&&typeof g!="function"&&typeof y!="function";b&&l.charCodeAt(0)>=65&&l.charCodeAt(0)<=90?o[l]=G(g,y):b&&f.has(l)?o[l]={...g,...y}:o[l]=y}function a(l){for(const y in l){const g=l[y],b=o[y],w=b&&g&&typeof b=="object"&&typeof g=="object"&&!Array.isArray(b)&&!Array.isArray(g)&&typeof b!="function"&&typeof g!="function";w&&y.charCodeAt(0)>=65&&y.charCodeAt(0)<=90?o[y]=G(b,g):w&&f.has(y)?o[y]={...b,...g}:o[y]=g}}i&&a(i),t.props&&typeof t.props=="object"&&a(t.props),t.data!==void 0&&(o.data=t.data),t.classlist!==void 0&&(o.classlist=t.classlist),t.text!==void 0&&(o.text=t.text),t.html!==void 0&&(o.html=t.html);const u=o.scope&&typeof o.scope=="object"?o.scope:null,_=s?.scope,p=o.context&&typeof o.context.globalScope=="object"&&o.context.globalScope||null,d=_||p||null;if(t.scope!==void 0||u){const l={};u&&Object.assign(l,u),t.scope!==void 0&&Object.assign(l,t.scope),o.scope=(0,S.createScopeStore)(l,d)}else d&&(o.scope=d);if(t.if!==void 0&&(o.if=t.if),(0,ft.addMethods)(o),xt(o,s,t),o.if!=null){let l;if(typeof o.if=="function")try{l=o.if(o,o.state,o.context)}catch(y){if(l=!1,e.__ifError=y,typeof console<"u"&&console.warn){const g=o.key||o.tag||"?";console.warn(`[smbls] \`if:\` evaluator threw on ${g} \u2014 treating as false:`,y?.message||y)}}else l=o.if;e.__if=!!l}if(e.__if)typeof t.if=="function"&&(e.__ifInitialized=!0);else return s&&(s[o.key]=o),typeof t.if=="function"&&Z(o,{if:t.if}),o;o.tag||(o.tag=(0,T.detectTag)(o)),R("Init",o,r);const h=o.node=(0,T.cacheNode)(o);if(!h)return o;R("AttachNode",o,r),h.setAttribute&&o.key&&h.setAttribute("data-key",o.key),h.setAttribute&&o.context?.scopeSelector&&o.context.scopeSelector!==":root"&&o.context.key&&o.key===o.context.key&&h.setAttribute("data-smbls-app",o.context.key),o.id&&h.setAttribute&&(h.id=o.id),nt(o,r),Z(o,t),z(o),st(o),Et(o);try{rt(o,r)}catch(l){if(typeof console<"u"&&console.error){const y=o.__ref?.path?.join(".")||o.key||"<root>";console.error(`[smbls] createChildren failed at ${y}:`,l?.message||l,l?.stack?`
|
|
2
2
|
`+l.stack.split(`
|
|
3
3
|
`).slice(0,6).join(`
|
|
4
|
-
`):"")}}if(Q(o,c,s),c&&(c[o.key]=o,c.__ref?.__children&&(c.__ref.__children.includes(o.key)||c.__ref.__children.push(o.key))),typeof o.html=="function"&&o.node&&!o.node.innerHTML){const l=o.context?.designSystem;l&&(0,A.pushConfig)(l);try{const y=o.html(o,o.state,o.context);y!=null&&typeof y!="function"&&(o.node.innerHTML=y)}catch{}finally{l&&(0,A.popConfig)()}}if(N("Create",o,r),N("Complete",o,r),N("Render",o,r),N("RenderRouter",o,r),typeof o.onFrame=="function"){const l=o.onFrame,y=o.context?.designSystem,g=()=>{if(o.node){if(o.node.isConnected){y&&(0,A.pushConfig)(y);try{l(o,o.state,o.context)}catch(b){console.error("[DOMQL] onFrame error:",b)}finally{y&&(0,A.popConfig)()}}requestAnimationFrame(g)}};requestAnimationFrame(g)}return o}function bt(t,c,n){const r=!c,s=n.state&&typeof n.state=="object"&&!Array.isArray(n.state)&&Object.keys(n.state).length===0,o=r&&s&&t.context?.state,i=n.state!==void 0&&!o?n.state:t.state&&!(0,k.isStore)(t.state)?t.state:void 0;if(i==null){if(c?.state)t.state=c.state,(0,F.applyStateMethods)(t,t.state);else if(t.context?.state){const f=t.context.state,e={...f},a=t.context?.polyglot;if(a?.translations){const u=f.lang||a.defaultLang||"en",_=a.translations[u];if(_&&typeof _=="object")for(const d in _)e[d]===void 0&&(e[d]=_[d]);const p=new Set(a.languages||[]);for(const d in a.translations)!p.has(d)&&e[d]===void 0&&(e[d]=a.translations[d])}t.state=(0,k.isStore)(e)?e:(0,k.createStore)(e),t.state.__element=t,t.state.root=t.state,(0,F.applyStateMethods)(t,t.state)}else t.state={},Object.defineProperty(t.state,"root",{value:t.state,enumerable:!1,configurable:!0,writable:!0}),(0,F.applyStateMethods)(t,t.state);return}if(typeof i=="string"){if(t.state=tt(i,c),t.state&&typeof t.state=="object"&&!(0,k.isStore)(t.state)){const f=c?.state?.root||c?.state||t.state;Object.defineProperty(t.state,"root",{value:f,enumerable:!1,configurable:!0,writable:!0})}(0,F.applyStateMethods)(t,t.state);return}if(typeof i=="function"){const f=i(t,c?.state);t.state=(0,k.createStore)(f||{})}else t.state=(0,k.createStore)({...i});t.state.__element=t,c?.state?(t.state.parent=c.state,t.state.root=c.state.root||c.state):t.state.root=t.state,(0,F.applyStateMethods)(t,t.state)}function U(t,c){if(!c)return t;const n=c.split("/");let r=t;for(const s of n){if(r==null)return{};r=r[s]}return r??{}}function tt(t,c){if(!c)return{};if(t===".")return c.state||{};if(t.startsWith("../")){const s=t.slice(3);return s?U(c.state,s):c.state??{}}if(t.startsWith("~/")){const s=c.state?.root||c.state,o=t.slice(2);return o?U(s,o):s??{}}if(c.state?.[t]!==void 0)return c.state[t];const n=U(c.state,t);if(n!=null&&Object.keys(n).length>0)return n;const r=c.context?.polyglot;if(r?.translations){const s=c.state?.root?.lang||r.defaultLang||"en",o=r.translations[s];if(o?.[t]!==void 0)return o[t];if(r.translations[t]!==void 0)return r.translations[t]}return{}}function xt(t){const c=t.__ref,n=t.tag||"div",r=t.context?.designSystem,s=[],o=Object.keys(t);for(let i=0;i<o.length;i++){const f=o[i];if(typeof t[f]!="function"||P.REGISTRY.has(f))continue;const e=f.charCodeAt(0);e>=65&&e<=90||M(f)||x.CSS_PROPS_REGISTRY[f]||x.DEFAULT_CSS_PROPERTIES_LIST&&x.DEFAULT_CSS_PROPERTIES_LIST.has(f)||(0,I.checkAttributeByTagName)(n,f)||s.push({prop:f,fn:t[f]})}for(let i=0;i<s.length;i++){const{prop:f,fn:e}=s[i];c.__exec[f]=e,Object.defineProperty(t,f,{get(){r&&(0,A.pushConfig)(r);try{return e(t,t.state,t.context)}catch{return}finally{r&&(0,A.popConfig)()}},set(a){delete c.__exec[f],Object.defineProperty(t,f,{value:a,writable:!0,configurable:!0,enumerable:!0})},configurable:!0,enumerable:!0})}}function Z(t,c){const n=t.__ref;if(xt(t),typeof t.text=="function"){const s=t.text,o=(0,j.createEffect)(()=>{if(!n.contentManaged)try{let i=s(t,t.state,t.context);t.node&&i!=null&&typeof i!="function"&&typeof i!="object"&&(typeof i=="string"&&i.includes("{{")&&(i=V.replaceLiteralsWithObjectFields.call(t,i,t.state)),t.tag==="string"?t.node.nodeValue=i:t.node.textContent=i)}catch{}},{depth:n.path.length});n.__effects.push(o),n.__exec.text=s}else if(typeof t.text=="string"&&t.text.includes("{{")){const s=t.text,o=(0,j.createEffect)(()=>{if(n.contentManaged)return;const i=V.replaceLiteralsWithObjectFields.call(t,s,t.state);i!=null&&(t.text=i),t.node&&(t.tag==="string"?t.node.nodeValue=i??"":t.node.textContent=i??"")},{depth:n.path.length});n.__effects.push(o),n.__exec.text=s}for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)&&typeof t[s]=="function"&&!P.REGISTRY.has(s)&&!M(s)&&!n.__exec[s]){if(x.CSS_PROPS_REGISTRY[s]){const o=t[s],i=s,f=(0,j.createEffect)(()=>{const e=t.context?.designSystem;e&&(0,A.pushConfig)(e);try{const a=o(t,t.state,t.context),u=x.CSS_PROPS_REGISTRY[i](a,t,t.state,t.context);u&&t.node?K(t.node,u):t.node&&(i==="show"||i==="hide")&&(t.node.style.display="")}finally{e&&(0,A.popConfig)()}},{depth:n.path.length});n.__effects.push(f),n.__exec[s]=o}else if(x.DEFAULT_CSS_PROPERTIES_LIST&&x.DEFAULT_CSS_PROPERTIES_LIST.has(s)){const o=t[s],i=s,f=(0,j.createEffect)(()=>{const e=t.context?.designSystem;e&&(0,A.pushConfig)(e);try{const a=o(t,t.state,t.context);t.node&&(a!=null?K(t.node,{[i]:a}):t.node.style[i]="")}finally{e&&(0,A.popConfig)()}},{depth:n.path.length});n.__effects.push(f),n.__exec[s]=o}}if(typeof c.html=="function"){const s=c.html,o=(0,j.createEffect)(()=>{const i=t.context?.designSystem;i&&(0,A.pushConfig)(i);try{const f=s(t,t.state,t.context);t.node&&f!=null&&typeof f!="function"&&(t.node.innerHTML=f)}finally{i&&(0,A.popConfig)()}},{depth:n.path.length});n.__effects.push(o),n.__exec.html=s}if(typeof c.value=="function"){const s=c.value,o=(0,j.createEffect)(()=>{try{const i=s(t,t.state,t.context);if(!t.node||!("value"in t.node))return;const f=i==null?"":String(i);if(t.node.value===f)return;const e=typeof document<"u"&&document.activeElement===t.node,a=e&&typeof t.node.selectionStart=="number"?t.node.selectionStart:null,u=e&&typeof t.node.selectionEnd=="number"?t.node.selectionEnd:null;if(t.node.value=f,e&&a!=null&&u!=null)try{t.node.setSelectionRange(a,u)}catch{}}catch{}},{depth:n.path.length});n.__effects.push(o),n.__exec.value=s}if(typeof c.style=="function"){const s=c.style,o=(0,j.createEffect)(()=>{const i=s(t,t.state,t.context);K(t.node,i)},{depth:n.path.length});n.__effects.push(o),n.__exec.style=s}else if(t.style&&typeof t.style=="object")for(const s in t.style){const o=t.style[s];if(typeof o!="function")continue;const i=(0,j.createEffect)(()=>{try{const f=o(t,t.state,t.context);t.node&&K(t.node,{[s]:f})}catch{}},{depth:n.path.length});n.__effects.push(i)}if(t.attr&&typeof t.attr=="object"){for(const s in t.attr)if(typeof t.attr[s]=="function"){const o=t.attr[s],i=s,f=(0,j.createEffect)(()=>{try{const e=o(t,t.state,t.context);t.node?.setAttribute&&(e==null||e===!1?t.node.removeAttribute(i):typeof e!="function"&&typeof e!="object"&&t.node.setAttribute(i,e===!0?"":e))}catch{}},{depth:n.path.length});n.__effects.push(f)}}if(t.aria&&typeof t.aria=="object")for(const s in t.aria){const o=t.aria[s];if(typeof o!="function")continue;const i="aria-"+s.replace(/[A-Z]/g,e=>"-"+e.toLowerCase()),f=(0,j.createEffect)(()=>{try{const e=o(t,t.state,t.context);if(!t.node?.setAttribute)return;e==null||e===!1?t.node.removeAttribute(i):typeof e!="function"&&typeof e!="object"&&t.node.setAttribute(i,e===!0?"":e)}catch{}},{depth:n.path.length});n.__effects.push(f)}if(t.data&&typeof t.data=="object")for(const s in t.data){const o=t.data[s];if(typeof o!="function")continue;const f="data-"+s.replace(/[A-Z]/g,a=>"-"+a.toLowerCase()),e=(0,j.createEffect)(()=>{try{const a=o(t,t.state,t.context);if(!t.node?.setAttribute)return;a==null||a===!1?t.node.removeAttribute(f):typeof a!="function"&&typeof a!="object"&&t.node.setAttribute(f,a===!0?"":a)}catch{}},{depth:n.path.length});n.__effects.push(e)}const r=t.classlist&&typeof t.classlist=="object"&&!Array.isArray(t.classlist)?t.classlist:t.class&&typeof t.class=="object"&&!Array.isArray(t.class)?t.class:null;if(r)for(const s in r){const o=r[s];if(typeof o!="function")continue;const i=(0,j.createEffect)(()=>{try{const f=o(t,t.state,t.context);if(!t.node?.classList)return;typeof f=="string"?t.node.classList.add(f):f?t.node.classList.add(s):t.node.classList.remove(s)}catch{}},{depth:n.path.length});n.__effects.push(i)}if(typeof c.if=="function"){const s=c.if,o=(0,j.createEffect)(()=>{let i;try{i=s(t,t.state,t.context)}catch(e){if(i=!1,n.__ifError=e,typeof console<"u"&&console.warn){const a=t.key||t.tag||"?";console.warn(`[smbls] \`if:\` reactive effect threw on ${a} \u2014 treating as false:`,e?.message||e)}return}const f=n.__if;if(n.__if=!!i,f&&!n.__if&&t.node)t.node.remove();else if(!f&&n.__if)if(n.__ifInitialized){t.node||(t.node=(0,R.cacheNode)(t));const e=t.parent,a=e?.node;if(a&&t.node){let u=null;const _=Object.keys(e),p=_.indexOf(t.key);for(let d=p+1;d<_.length;d++){const h=e[_[d]];if(h?.node?.parentNode===a){u=h.node;break}}u?a.insertBefore(t.node,u):a.appendChild(t.node)}else Q(t,t.parent);z(t)}else{if(n.__ifInitialized=!0,t.tag||(t.tag=(0,R.detectTag)(t)),N("Init",t,{}),t.node||(t.node=(0,R.cacheNode)(t)),!t.node)return;N("AttachNode",t,{}),t.node.setAttribute&&t.key&&t.node.setAttribute("data-key",t.key),t.id&&t.node.setAttribute&&(t.node.id=t.id);const e=c.if;delete c.if;try{Z(t,c)}finally{c.if=e}z(t),ot(t),ct(t,{}),nt(t,{}),Q(t,t.parent)}},{depth:n.path.length});n.__effects.push(o)}for(const s in t){if(!Object.prototype.hasOwnProperty.call(t,s)||P.REGISTRY.has(s)||typeof t[s]!="function")continue;const o=s.charCodeAt(0);if(o>=65&&o<=90||M(s))continue;const i=t[s];n.__exec[s]=i;const f=t.tag||"div";if((0,I.checkAttributeByTagName)(f,s)&&!x.CSS_PROPS_REGISTRY[s]&&!(x.DEFAULT_CSS_PROPERTIES_LIST&&x.DEFAULT_CSS_PROPERTIES_LIST.has(s))){const e=s,a=(0,j.createEffect)(()=>{try{const u=i(t,t.state,t.context);t.node?.setAttribute&&(u==null||u===!1?t.node.removeAttribute(e):typeof u!="function"&&typeof u!="object"&&(e==="src"&&"src"in t.node?t.node.src=u:t.node.setAttribute(e,u===!0?"":u)))}catch{}},{depth:n.path.length});n.__effects.push(a)}}jt(t),Ct(t)}function z(t){const{node:c}=t;if(c){if(typeof t.text=="string"&&!t.text.includes("{{")?t.tag==="string"?c.nodeValue=t.text:c.textContent=t.text:typeof t.text=="number"&&(c.textContent=t.text),St(t),typeof t.html=="string"&&(c.innerHTML=t.html),t.value!=null&&typeof t.value!="function"&&"value"in c){const n=String(t.value);c.value!==n&&(c.value=n)}if(t.style&&typeof t.style=="object"&&K(c,t.style),t.attr&&typeof t.attr=="object")for(const n in t.attr){const r=t.attr[n];typeof r=="function"||typeof r=="object"||r==null||r===!1||c.setAttribute&&c.setAttribute(n,r===!0?"":r)}if(t.data&&typeof t.data=="object")for(const n in t.data){const r=t.data[n];typeof r=="function"||typeof r=="object"||r==null||r===!1||c.dataset&&(c.dataset[n]=r===!0?"":r)}if(t.classlist||t.class){const n=t.classlist||t.class;if(typeof n=="string")n.split(" ").forEach(r=>r&&c.classList.add(r));else if(typeof n=="object")for(const r in n){const s=typeof n[r]=="function"?n[r](t,t.state,t.context):n[r];s&&c.classList.add(typeof s=="string"?s:r)}}}}function K(t,c){if(!t||!c||!t.style)return;let n=null;for(const r in c){const s=c[r];if(s!=null){if(r.charAt(0)==="&"&&typeof s=="object"){n||(n={}),n[r]=s;continue}try{const o=String(s),i=r.replace(/[A-Z]/g,u=>"-"+u.toLowerCase()),f=o.trim(),e=/\s*!important\s*$/.test(f),a=f.replace(/\s*!important\s*$/,"");t.style.setProperty(i,a,e?"important":"")}catch{}}}n&&vt(t,n)}let At=0;function vt(t,c){const n=`_ds${At++}`;t.classList.add(n);const r=t.ownerDocument;let s=r.querySelector("style[data-smbls-scoped]");s||(s=r.createElement("style"),s.setAttribute("data-smbls-scoped",""),r.head.appendChild(s));let o="";for(const i in c){const f="."+n,e=i.replace(/&/g,f).split(",").map(u=>{const _=u.trim();return _.includes(f)?_:f+_}).join(", "),a=c[i];if(typeof a=="object"){let u="",_="";for(const p in a){const d=a[p];if(typeof d=="object"){const h=p.includes("&")?e.split(", ").map(y=>p.replace(/&/g,y)).join(", "):e.split(", ").map(y=>`${y} ${p}`).join(", ");let l="";for(const y in d)l+=`${y.replace(/[A-Z]/g,g=>"-"+g.toLowerCase())}: ${d[y]};`;_+=`${h} { ${l} }
|
|
5
|
-
`}else u+=`${p.replace(/[A-Z]/g,h=>"-"+h.toLowerCase())}: ${d};`}u&&(o+=`${
|
|
6
|
-
`),_&&(o+=_)}}o&&(s.textContent+=o)}function jt(t){const c=t.subscribeTo;if(!Array.isArray(c)||c.length===0)return;const n=t.__ref;for(let r=0;r<c.length;r++){const s=c[r];if(typeof s!="string"||s.length===0)continue;const o=s.split("."),i=o[0],f=o.slice(1),e={value:!1},a=(0,j.createEffect)(()=>{const u=t.state&&((0,k.isStore)(t.state)?t.state.root:null);if(!u||!(0,k.isStore)(u))return;let _=u;_=_[i];for(let p=0;p<f.length&&!(_==null||typeof _!="object");p++)if((0,k.isStore)(_))_=_[f[p]];else break;if(e.value&&typeof t.onUpdate=="function"){const p=t.context?.designSystem;p&&(0,A.pushConfig)(p);try{t.onUpdate(t,t.state,t.context)}catch(d){t.context?.plugins?.length&&(0,W.runPluginHook)("error",t,{hook:"onUpdate",error:d})||console.error("[DOMQL] subscribeTo onUpdate error:",d)}finally{p&&(0,A.popConfig)()}}},{depth:n.path.length});e.value=!0,n.__effects.push(a)}}function Ct(t){const c=t.__ref;c.__conditionalRunners=[];for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;const r=n.charAt(0);if(r!=="."&&r!=="!")continue;const s=n.slice(1);if(!s)continue;const o=t[n];if(!o||typeof o!="object")continue;const i=r==="!",f={lastMatch:!1,appliedKeys:null},e=()=>{if(!t.node)return;let u;const _=t[s];if(_===void 0)if(t.state&&s in t.state)u=t.state[s];else{const h=t.context?.cases?.[s];if(h===void 0)return;try{u=typeof h=="function"?h.call(t,t):h}catch(l){u=!1,c.__conditionalError=l,typeof console<"u"&&console.warn&&console.warn(`[smbls] conditional \`${n}\` case fn threw on ${t.key||"?"} \u2014 treating as false:`,l?.message||l)}}else if(typeof _=="function")try{u=_(t,t.state,t.context)}catch(h){u=!1,c.__conditionalError=h,typeof console<"u"&&console.warn&&console.warn(`[smbls] conditional \`${n}\` predicate threw on ${t.key||"?"} \u2014 treating as false:`,h?.message||h)}else u=_;const p=i?!u:!!u;if(p===f.lastMatch)return;f.lastMatch=p;const d=t.context?.designSystem;d&&(0,A.pushConfig)(d);try{if(p){const h={};for(const y in o){if(!Object.prototype.hasOwnProperty.call(o,y))continue;const g=typeof o[y]=="function"?o[y](t,t.state,t.context):o[y];if(g!=null)if(x.CSS_PROPS_REGISTRY[y]){const b=x.CSS_PROPS_REGISTRY[y](g,t,t.state,t.context);if(b){const w=Array.isArray(b)?b:[b];for(const O of w)O&&Object.assign(h,O)}}else x.DEFAULT_CSS_PROPERTIES_LIST&&x.DEFAULT_CSS_PROPERTIES_LIST.has(y)&&(h[y]=g)}const l=Object.keys(h);l.length?(K(t.node,h),f.appliedKeys=l):f.appliedKeys=null}else if(f.appliedKeys){for(const h of f.appliedKeys)t.node.style[h]="";f.appliedKeys=null}}finally{d&&(0,A.popConfig)()}};c.__conditionalRunners.push(e);const a=(0,j.createEffect)(e,{depth:c.path.length});c.__effects.push(a)}}const B=new WeakSet;function St(t){const{node:c}=t;if(!c)return;if(B.has(t)){console.error("[applyCssInProps] re-entry detected for element",t.key,"prop path:",t.__ref?.path);return}B.add(t);const n=t.context?.designSystem;n&&(0,A.pushConfig)(n);try{const r={};let s=!1;for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||typeof t[o]=="function"||P.REGISTRY.has(o))continue;const i=o.charCodeAt(0);if(!(i>=65&&i<=90)&&!M(o)){if(x.CSS_PROPS_REGISTRY[o]){const f=t[o],e=x.CSS_PROPS_REGISTRY[o](f,t,t.state,t.context);if(e){if(Array.isArray(e))for(const a of e)a&&Object.assign(r,a);else Object.assign(r,e);s=!0}}else if(x.DEFAULT_CSS_PROPERTIES_LIST&&x.DEFAULT_CSS_PROPERTIES_LIST.has(o)){const f=t[o];f!=null&&typeof f!="object"&&(r[o]=f,s=!0)}else if(o.charCodeAt(0)===45){const f=t[o];f!=null&&typeof f!="object"&&(r[o]=f,s=!0)}else if(o.charAt(0)==="&"){const f=t[o];f&&typeof f=="object"&&(r[o]=f,s=!0)}else if(o.charAt(0)==="@"||o.charAt(0)===":"){const f=t[o];if(f&&typeof f=="object"){const e={};for(const a in f){let u=f[a];if(typeof u=="function"&&(u=u(t,t.state,t.context)),!(u==null||typeof u=="function"))if(x.CSS_PROPS_REGISTRY[a]){const _=x.CSS_PROPS_REGISTRY[a](u,t,t.state,t.context);if(_)if(Array.isArray(_))for(const p of _)p&&Object.assign(e,p);else Object.assign(e,_)}else e[a]=u}if(Object.keys(e).length){if(o.length>1&&o.charAt(0)==="@"&&!o.startsWith("@media")&&!o.startsWith("@keyframes")&&!o.startsWith("@supports")&&(o==="@dark"||o==="@light"||!t.context?.designSystem?.media?.[o.slice(1)])){const u={};for(const p in e){const d=e[p];u[p]=typeof d=="string"&&!d.includes("!important")?d+" !important":d}const _=o.slice(1);r[`[data-theme="${_}"] &`]=u}else{let u=o;if(o.charAt(0)==="@"&&!o.startsWith("@media")&&!o.startsWith("@keyframes")){const p=o.slice(1),d=t.context?.designSystem?.media?.[p]||t.context?.designSystem?.media?.[p];d&&(u=`@media ${d}`)}const _={};for(const p in e){const d=e[p];if(d&&typeof d=="object"&&!Array.isArray(d)){const h={};for(const y in d)if(x.CSS_PROPS_REGISTRY[y]){const g=x.CSS_PROPS_REGISTRY[y](d[y],t,t.state,t.context);if(g)if(Array.isArray(g))for(const b of g)b&&Object.assign(h,b);else Object.assign(h,g)}else h[y]=d[y];const l=p.startsWith(":")?"":" ";if(u.includes(",")){const y=u.split(",").map(g=>`${g.trim()}${l}${p}`).join(", ");r[y]=h}else r[`${u}${l}${p}`]=h}else _[p]=d}Object.keys(_).length&&(r[u]=_)}s=!0}s=!0}}}}if(s){r.display&&String(r.display).includes("!important")&&(c.style.setProperty("display",String(r.display).replace(/\s*!important\s*$/,""),"important"),delete r.display);const o=(0,ft.css)(r,null,t.context?.cssPrefix);if(o&&c.classList){const f=o.split(" ").filter(Boolean);let e=!1;for(const a of f)c.classList.add(a),e||(a.charCodeAt(0)===95&&a.charCodeAt(1)===99||a.charCodeAt(0)===95&&a.indexOf("_c",1)!==-1)&&(e=!0);e&&typeof c.offsetWidth=="number"&&c.offsetWidth}const i=t.display!=null&&typeof t.display!="function"?t.display:t.hide===!0||t.show===!1?"none":null;if(i!=null){const f=r.display;if(f&&f!==i)if(i==="none"){const e=[];for(const a of c.classList)a.startsWith("_d-")&&a!=="_d-none"&&e.push(a);for(const a of e)c.classList.remove(a);c.classList.add("_d-none")}else c.style.display=t.display}}}finally{n&&(0,A.popConfig)(),B.delete(t)}}function ot(t){const{node:c}=t;if(!c||!c.setAttribute)return;if(t.aria&&typeof t.aria=="object")for(const s in t.aria){const o=t.aria[s];if(typeof o=="function"||typeof o=="object"||o==null||o===!1)continue;const i="aria-"+s.replace(/[A-Z]/g,f=>"-"+f.toLowerCase());c.setAttribute(i,o===!0?"":o)}const n=(0,I.applyAttrTransforms)(t);for(const s in n){const o=n[s];o!=null&&o!==!1&&typeof o!="function"&&typeof o!="object"&&c.setAttribute(s,o===!0?"":o)}const r=t.tag||"div";for(const s in t){if(!Object.prototype.hasOwnProperty.call(t,s)||typeof t[s]=="function"||P.REGISTRY.has(s)||s==="on"||n[s]!==void 0)continue;const o=s.charCodeAt(0);if(!(o>=65&&o<=90)&&!M(s)&&!(x.CSS_PROPS_REGISTRY[s]||x.DEFAULT_CSS_PROPERTIES_LIST&&x.DEFAULT_CSS_PROPERTIES_LIST.has(s))&&(0,I.checkAttributeByTagName)(r,s)){let i=t[s];if(i==null||i===!1||(typeof i=="string"&&i.includes("{{")&&(i=(0,V.replaceLiteralsWithObjectFields)(i,t,t.state,t.context),t[s]=i),i==null||i===!1||typeof i=="function"||typeof i=="object"))continue;c.setAttribute(s,i===!0?"":i)}}}function kt(t){if(!t.autoGrow)return;const c=t.node;if(!c||c.tagName!=="TEXTAREA")return;const n=t.autoGrow,r=n&&typeof n=="object"&&n.max?String(n.max):null;r&&(c.style.maxHeight=r);const s=()=>{c.style.height="auto",c.style.height=c.scrollHeight+"px"};s(),c.addEventListener("input",s),t.__ref.__eventCleanup||(t.__ref.__eventCleanup=[]),t.__ref.__eventCleanup.push(()=>{try{c.removeEventListener("input",s)}catch{}})}const st=new Set(["onSwipe","onSwipeLeft","onSwipeRight","onSwipeUp","onSwipeDown"]);function ct(t,c){for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n)||!M(n)||st.has(n))continue;let r=t[n];if(typeof r=="string"&&/^[A-Za-z_$][\w$]*$/.test(r)){const o=r;r=function(f){return t.call(o,f)}}if(typeof r!="function")continue;const s=_t(n);P.LIFECYCLE_EVENTS.has(s)||(0,rt.registerEvent)(gt(s),t,r)}wt(t)}function wt(t){const c=t.node;if(!c||!c.addEventListener)return;const n={};let r=!1;for(const p of st){const d=t[p];typeof d=="function"&&(n[p]=d,r=!0)}if(!r)return;const s=typeof t.swipeThreshold=="number"?t.swipeThreshold:40,o=typeof t.swipeMaxDuration=="number"?t.swipeMaxDuration:600;let i=0,f=0,e=0,a=!1;const u=p=>{const d=p.touches&&p.touches[0]||p.changedTouches&&p.changedTouches[0];d&&(i=d.clientX,f=d.clientY,e=Date.now(),a=!0)},_=p=>{if(!a)return;a=!1;const d=p.changedTouches&&p.changedTouches[0]||p.touches&&p.touches[0];if(!d)return;const h=d.clientX-i,l=d.clientY-f,y=Date.now()-e;if(y>o)return;const g=Math.abs(h),b=Math.abs(l);if(Math.max(g,b)<s)return;let w;if(g>b*1.2)w=h<0?"left":"right";else if(b>g*1.2)w=l<0?"up":"down";else return;const O="onSwipe"+w.charAt(0).toUpperCase()+w.slice(1),C=n[O],S=n.onSwipe;C&&C.call(t,p,t,t.state,t.context),S&&S.call(t,{direction:w,dx:h,dy:l,dt:y,event:p},t,t.state,t.context)};c.addEventListener("touchstart",u,{passive:!0}),c.addEventListener("touchend",_,{passive:!0}),t.__ref.__eventCleanup||(t.__ref.__eventCleanup=[]),t.__ref.__eventCleanup.push(()=>{try{c.removeEventListener("touchstart",u)}catch{}try{c.removeEventListener("touchend",_)}catch{}})}function X(t,c){const n={...t};for(const r in c){const s=n[r],o=c[r];s&&o&&typeof s=="object"&&typeof o=="object"&&!Array.isArray(s)&&!Array.isArray(o)&&typeof s!="function"&&typeof o!="function"?n[r]=X(s,o):n[r]=o}return n}function q(t,c,n){if(!c||!t.node)return;const r=t.childExtends;if(Array.isArray(c)){const o=(t.context?.document||globalThis.document)?.createDocumentFragment();if(!o)return;const i=t.childProps,f=t.childrenAs;for(let e=0;e<c.length;e++){let a=c[e];const u=a;(typeof a=="string"||typeof a=="number")&&(a={text:a});let _=i;if(typeof i=="function")try{_=i(t,a)}catch{_=null}if(f==="state"){let h=u;(typeof u=="string"||typeof u=="number")&&(h={value:u,text:u}),a=_?{..._,state:h}:{state:h}}else _&&(a=X(_,a));if(r&&!a.ignoreChildExtends)if(a.extends){const h=Array.isArray(a.extends)?a.extends:[a.extends],l=Array.isArray(r)?r:[r];a={...a,extends:[...l,...h]}}else a={extends:r,...a};const p=a?.key||`${e}`,d=T(a,t,p,n);d?.node&&o.appendChild(d.node)}t.node.appendChild(o);return}if(typeof c=="string"){const s=tt(c,t);if(Array.isArray(s)){q(t,s,n);return}}if(typeof c=="object")for(const s in c){if(P.REGISTRY.has(s))continue;let o=c[s];if(!(o==null||o===!1)){if((typeof o=="string"||typeof o=="number")&&(o={text:o}),t.childProps&&(o=X(t.childProps,o)),r&&!o.ignoreChildExtends)if(o.extends){const i=Array.isArray(o.extends)?o.extends:[o.extends],f=Array.isArray(r)?r:[r];o={...o,extends:[...f,...i]}}else o={extends:r,...o};T(o,t,s,n)}}}function nt(t,c){let{children:n,content:r}=t;const s=t.childExtends;if(typeof n=="function"){const i=n;n=i(t,t.state,t.context),t.children=n;const f=t.__ref;let e=!1;const a=(0,j.createEffect)(()=>{const u=i(t,t.state,t.context);if(!e){e=!0;return}if(u===t.children)return;if(t.children=u,Array.isArray(u)&&t.childrenAs==="state"){const d=t.childProps,h=[],l=new Map;for(let C=0;C<u.length;C++){const S=u[C];let v=d;if(typeof d=="function")try{v=d(t,S)}catch{v=null}const D=v&&v.key||S&&S.key||`${C}`;h.push(D),l.set(D,{rawChild:S,childProps:v})}const y=new Set(h),g=f.__children.slice();for(const C of g)if(!y.has(C)){const S=t[C];S?.remove&&S.remove(),delete t[C]}const b=t.childExtends,O=(t.context?.document||globalThis.document)?.createDocumentFragment();for(const C of h){const S=l.get(C),v=S.rawChild,D=t[C];if(D&&D.state){if(v&&typeof v=="object"){const $=D.state;if(typeof $.replace=="function")$.replace(v);else if(typeof $.update=="function"){for(const E in $)if(!(E==="__element"||E==="root"||E==="parent"||E==="update")&&!Object.prototype.hasOwnProperty.call(v,E))try{$[E]=void 0}catch{}$.update(v)}else for(const E in v)$[E]=v[E]}continue}let H=v;(typeof v=="string"||typeof v=="number")&&(H={value:v,text:v});const J=S.childProps;let L=J?{...J,state:H}:{state:H};if(b&&!L.ignoreChildExtends)if(L.extends){const $=Array.isArray(L.extends)?L.extends:[L.extends],E=Array.isArray(b)?b:[b];L={...L,extends:[...E,...$]}}else L={extends:b,...L};const m=T(L,t,C,c);m?.node&&O&&O.appendChild(m.node)}O&&O.childNodes.length&&t.node&&t.node.appendChild(O),f.__children=h;return}for(const d of[...f.__children]){const h=t[d];h?.remove&&h.remove(),delete t[d]}f.__children=[],q(t,u,c)},{depth:f.path.length});f.__effects.push(a)}if(q(t,n||r,c),n||r)return;const o=t.context?.components||{};{const i=Object.keys(t);for(let f=0;f<i.length;f++){const e=i[f];if(!e.endsWith("Extends")||typeof t[e]!="string")continue;const a=e.slice(0,-7);if(!a||a.charCodeAt(0)<65||a.charCodeAt(0)>90)continue;const u={extends:t[e]};delete t[e];for(let _=f+1;_<i.length;_++){const p=i[_],d=p.charCodeAt(0);if(d>=65&&d<=90||P.REGISTRY.has(p)||typeof t[p]=="function"&&(p.startsWith("on")||p.startsWith(".")))break;const h=t[p];h!==void 0&&(u[p]=h,delete t[p])}t[a]&&typeof t[a]=="object"?t[a]={...u,...t[a]}:t[a]=u}}for(const i in t){if(!Object.prototype.hasOwnProperty.call(t,i)||P.REGISTRY.has(i)||typeof t[i]!="object"||t[i]===null)continue;const f=i.charCodeAt(0);if(f<65||f>90)continue;let e=t[i];if(!e.__ref){if(!e.extends&&!e.extend){const a=o[i]||o[`smbls.${i}`];a&&(e={extends:a,...e})}if(t.childProps&&(e={...t.childProps,...e}),s&&!e.ignoreChildExtends)if(e.extends){const a=Array.isArray(e.extends)?e.extends:[e.extends],u=Array.isArray(s)?s:[s];e={...e,extends:[...u,...a]}}else e={extends:s,...e};T(e,t,i,c)}}}function Q(t,c,n){const{node:r}=t;if(!r)return;const s=c?.node||(c?.nodeType?c:null);if(s)if(n?.position==="before"&&n.node)s.insertBefore(r,n.node);else if(n?.position==="after"&&n.node){const o=n.node.nextSibling;o?s.insertBefore(r,o):s.appendChild(r)}else s.appendChild(r)}function N(t,c,n){const r=t.charAt(0).toLowerCase()+t.slice(1);c.context?.plugins?.length&&(0,W.runPluginHook)(r,c,n);const s="on"+t,o=c[s];if(typeof o=="function"){const i=c.context?.designSystem;i&&(0,A.pushConfig)(i);try{if(o(c,c.state,c.context,n)===!1)return!1}catch(f){if(c.context?.plugins?.length&&(0,W.runPluginHook)("error",c,{hook:s,error:f})||console.error(`[DOMQL] Lifecycle "${s}" error:`,f),c.context?.strictMode)throw f}finally{i&&(0,A.popConfig)()}}return!0}var Et=T;
|
|
4
|
+
`):"")}}if(J(o,s,c),s&&(s[o.key]=o,s.__ref?.__children&&(s.__ref.__children.includes(o.key)||s.__ref.__children.push(o.key))),typeof o.html=="function"&&o.node&&!o.node.innerHTML){const l=o.context?.designSystem;l&&(0,A.pushConfig)(l);try{const y=o.html(o,o.state,o.context);y!=null&&typeof y!="function"&&(o.node.innerHTML=y)}catch{}finally{l&&(0,A.popConfig)()}}if(R("Create",o,r),R("Complete",o,r),R("Render",o,r),R("RenderRouter",o,r),typeof o.onFrame=="function"){const l=o.onFrame,y=o.context?.designSystem,g=()=>{if(o.node){if(o.node.isConnected){y&&(0,A.pushConfig)(y);try{l(o,o.state,o.context)}catch(b){console.error("[DOMQL] onFrame error:",b)}finally{y&&(0,A.popConfig)()}}requestAnimationFrame(g)}};requestAnimationFrame(g)}return o}function xt(t,s,n){const r=!s,c=n.state&&typeof n.state=="object"&&!Array.isArray(n.state)&&Object.keys(n.state).length===0,o=r&&c&&t.context?.state,e=n.state!==void 0&&!o?n.state:t.state&&!(0,S.isStore)(t.state)?t.state:void 0;if(e==null){if(s?.state)t.state=s.state,(0,K.applyStateMethods)(t,t.state);else if(t.context?.state){const f=t.context.state,i={...f},a=t.context?.polyglot;if(a?.translations){const u=f.lang||a.defaultLang||"en",_=a.translations[u];if(_&&typeof _=="object")for(const d in _)i[d]===void 0&&(i[d]=_[d]);const p=new Set(a.languages||[]);for(const d in a.translations)!p.has(d)&&i[d]===void 0&&(i[d]=a.translations[d])}t.state=(0,S.isStore)(i)?i:(0,S.createStore)(i),t.state.__element=t,t.state.root=t.state,(0,K.applyStateMethods)(t,t.state)}else t.state={},Object.defineProperty(t.state,"root",{value:t.state,enumerable:!1,configurable:!0,writable:!0}),(0,K.applyStateMethods)(t,t.state);return}if(typeof e=="string"){if(t.state=ot(e,s),t.state&&typeof t.state=="object"&&!(0,S.isStore)(t.state)){const f=s?.state?.root||s?.state||t.state;Object.defineProperty(t.state,"root",{value:f,enumerable:!1,configurable:!0,writable:!0})}(0,K.applyStateMethods)(t,t.state);return}if(typeof e=="function"){const f=e(t,s?.state);t.state=(0,S.createStore)(f||{})}else t.state=(0,S.createStore)({...e});t.state.__element=t,s?.state?(t.state.parent=s.state,t.state.root=s.state.root||s.state):t.state.root=t.state,(0,K.applyStateMethods)(t,t.state)}function U(t,s){if(!s)return t;const n=s.split("/");let r=t;for(const c of n){if(r==null)return{};r=r[c]}return r??{}}function ot(t,s){if(!s)return{};if(t===".")return s.state||{};if(t.startsWith("../")){const c=t.slice(3);return c?U(s.state,c):s.state??{}}if(t.startsWith("~/")){const c=s.state?.root||s.state,o=t.slice(2);return o?U(c,o):c??{}}if(s.state?.[t]!==void 0)return s.state[t];const n=U(s.state,t);if(n!=null&&Object.keys(n).length>0)return n;const r=s.context?.polyglot;if(r?.translations){const c=s.state?.root?.lang||r.defaultLang||"en",o=r.translations[c];if(o?.[t]!==void 0)return o[t];if(r.translations[t]!==void 0)return r.translations[t]}return{}}function At(t){const s=t.__ref,n=t.tag||"div",r=t.context?.designSystem,c=[],o=Object.keys(t);for(let e=0;e<o.length;e++){const f=o[e];if(typeof t[f]!="function"||P.REGISTRY.has(f))continue;const i=f.charCodeAt(0);i>=65&&i<=90||M(f)||x.CSS_PROPS_REGISTRY[f]||x.DEFAULT_CSS_PROPERTIES_LIST&&x.DEFAULT_CSS_PROPERTIES_LIST.has(f)||(0,I.checkAttributeByTagName)(n,f)||c.push({prop:f,fn:t[f]})}for(let e=0;e<c.length;e++){const{prop:f,fn:i}=c[e];s.__exec[f]=i,Object.defineProperty(t,f,{get(){r&&(0,A.pushConfig)(r);try{return i(t,t.state,t.context)}catch{return}finally{r&&(0,A.popConfig)()}},set(a){delete s.__exec[f],Object.defineProperty(t,f,{value:a,writable:!0,configurable:!0,enumerable:!0})},configurable:!0,enumerable:!0})}}function Z(t,s){const n=t.__ref;if(At(t),typeof t.text=="function"){const c=t.text,o=(0,j.createEffect)(()=>{if(!n.contentManaged)try{let e=c(t,t.state,t.context);t.node&&e!=null&&typeof e!="function"&&typeof e!="object"&&(typeof e=="string"&&e.includes("{{")&&(e=V.replaceLiteralsWithObjectFields.call(t,e,t.state)),t.tag==="string"?t.node.nodeValue=e:t.node.textContent=e)}catch{}},{depth:n.path.length});n.__effects.push(o),n.__exec.text=c}else if(typeof t.text=="string"&&t.text.includes("{{")){const c=t.text,o=(0,j.createEffect)(()=>{if(n.contentManaged)return;const e=V.replaceLiteralsWithObjectFields.call(t,c,t.state);e!=null&&(t.text=e),t.node&&(t.tag==="string"?t.node.nodeValue=e??"":t.node.textContent=e??"")},{depth:n.path.length});n.__effects.push(o),n.__exec.text=c}for(const c in t)if(Object.prototype.hasOwnProperty.call(t,c)&&typeof t[c]=="function"&&!P.REGISTRY.has(c)&&!M(c)&&!n.__exec[c]){if(x.CSS_PROPS_REGISTRY[c]){const o=t[c],e=c,f=(0,j.createEffect)(()=>{const i=t.context?.designSystem;i&&(0,A.pushConfig)(i);try{const a=o(t,t.state,t.context),u=x.CSS_PROPS_REGISTRY[e](a,t,t.state,t.context);u&&t.node?F(t.node,u):t.node&&(e==="show"||e==="hide")&&(t.node.style.display="")}finally{i&&(0,A.popConfig)()}},{depth:n.path.length});n.__effects.push(f),n.__exec[c]=o}else if(x.DEFAULT_CSS_PROPERTIES_LIST&&x.DEFAULT_CSS_PROPERTIES_LIST.has(c)){const o=t[c],e=c,f=(0,j.createEffect)(()=>{const i=t.context?.designSystem;i&&(0,A.pushConfig)(i);try{const a=o(t,t.state,t.context);t.node&&(a!=null?F(t.node,{[e]:a}):t.node.style[e]="")}finally{i&&(0,A.popConfig)()}},{depth:n.path.length});n.__effects.push(f),n.__exec[c]=o}}if(typeof s.html=="function"){const c=s.html,o=(0,j.createEffect)(()=>{const e=t.context?.designSystem;e&&(0,A.pushConfig)(e);try{const f=c(t,t.state,t.context);t.node&&f!=null&&typeof f!="function"&&(t.node.innerHTML=f)}finally{e&&(0,A.popConfig)()}},{depth:n.path.length});n.__effects.push(o),n.__exec.html=c}if(typeof s.value=="function"){const c=s.value,o=(0,j.createEffect)(()=>{try{const e=c(t,t.state,t.context);if(!t.node||!("value"in t.node))return;const f=e==null?"":String(e);if(t.node.value===f)return;const i=typeof document<"u"&&document.activeElement===t.node,a=i&&typeof t.node.selectionStart=="number"?t.node.selectionStart:null,u=i&&typeof t.node.selectionEnd=="number"?t.node.selectionEnd:null;if(t.node.value=f,i&&a!=null&&u!=null)try{t.node.setSelectionRange(a,u)}catch{}}catch{}},{depth:n.path.length});n.__effects.push(o),n.__exec.value=c}if(typeof s.style=="function"){const c=s.style,o=(0,j.createEffect)(()=>{const e=c(t,t.state,t.context);F(t.node,e)},{depth:n.path.length});n.__effects.push(o),n.__exec.style=c}else if(t.style&&typeof t.style=="object")for(const c in t.style){const o=t.style[c];if(typeof o!="function")continue;const e=(0,j.createEffect)(()=>{try{const f=o(t,t.state,t.context);t.node&&F(t.node,{[c]:f})}catch{}},{depth:n.path.length});n.__effects.push(e)}if(t.attr&&typeof t.attr=="object"){for(const c in t.attr)if(typeof t.attr[c]=="function"){const o=t.attr[c],e=c,f=(0,j.createEffect)(()=>{try{const i=o(t,t.state,t.context);t.node?.setAttribute&&(i==null||i===!1?t.node.removeAttribute(e):typeof i!="function"&&typeof i!="object"&&t.node.setAttribute(e,i===!0?"":i))}catch{}},{depth:n.path.length});n.__effects.push(f)}}if(t.aria&&typeof t.aria=="object")for(const c in t.aria){const o=t.aria[c];if(typeof o!="function")continue;const e="aria-"+c.replace(/[A-Z]/g,i=>"-"+i.toLowerCase()),f=(0,j.createEffect)(()=>{try{const i=o(t,t.state,t.context);if(!t.node?.setAttribute)return;i==null||i===!1?t.node.removeAttribute(e):typeof i!="function"&&typeof i!="object"&&t.node.setAttribute(e,i===!0?"":i)}catch{}},{depth:n.path.length});n.__effects.push(f)}if(t.data&&typeof t.data=="object")for(const c in t.data){const o=t.data[c];if(typeof o!="function")continue;const f="data-"+c.replace(/[A-Z]/g,a=>"-"+a.toLowerCase()),i=(0,j.createEffect)(()=>{try{const a=o(t,t.state,t.context);if(!t.node?.setAttribute)return;a==null||a===!1?t.node.removeAttribute(f):typeof a!="function"&&typeof a!="object"&&t.node.setAttribute(f,a===!0?"":a)}catch{}},{depth:n.path.length});n.__effects.push(i)}const r=t.classlist&&typeof t.classlist=="object"&&!Array.isArray(t.classlist)?t.classlist:t.class&&typeof t.class=="object"&&!Array.isArray(t.class)?t.class:null;if(r)for(const c in r){const o=r[c];if(typeof o!="function")continue;const e=(0,j.createEffect)(()=>{try{const f=o(t,t.state,t.context);if(!t.node?.classList)return;typeof f=="string"?t.node.classList.add(f):f?t.node.classList.add(c):t.node.classList.remove(c)}catch{}},{depth:n.path.length});n.__effects.push(e)}if(typeof s.if=="function"){const c=s.if,o=(0,j.createEffect)(()=>{let e;try{e=c(t,t.state,t.context)}catch(i){if(e=!1,n.__ifError=i,typeof console<"u"&&console.warn){const a=t.key||t.tag||"?";console.warn(`[smbls] \`if:\` reactive effect threw on ${a} \u2014 treating as false:`,i?.message||i)}return}const f=n.__if;if(n.__if=!!e,f&&!n.__if&&t.node)t.node.remove();else if(!f&&n.__if)if(n.__ifInitialized){t.node||(t.node=(0,T.cacheNode)(t));const i=t.parent,a=i?.node;if(a&&t.node){let u=null;const _=Object.keys(i),p=_.indexOf(t.key);for(let d=p+1;d<_.length;d++){const h=i[_[d]];if(h?.node?.parentNode===a){u=h.node;break}}u?a.insertBefore(t.node,u):a.appendChild(t.node)}else J(t,t.parent);z(t)}else{if(n.__ifInitialized=!0,t.tag||(t.tag=(0,T.detectTag)(t)),R("Init",t,{}),t.node||(t.node=(0,T.cacheNode)(t)),!t.node)return;R("AttachNode",t,{}),t.node.setAttribute&&t.key&&t.node.setAttribute("data-key",t.key),t.id&&t.node.setAttribute&&(t.node.id=t.id),nt(t,{});const i=s.if;delete s.if;try{Z(t,s)}finally{s.if=i}z(t),st(t),rt(t,{}),J(t,t.parent)}},{depth:n.path.length});n.__effects.push(o)}for(const c in t){if(!Object.prototype.hasOwnProperty.call(t,c)||P.REGISTRY.has(c)||typeof t[c]!="function")continue;const o=c.charCodeAt(0);if(o>=65&&o<=90||M(c))continue;const e=t[c];n.__exec[c]=e;const f=t.tag||"div";if((0,I.checkAttributeByTagName)(f,c)&&!x.CSS_PROPS_REGISTRY[c]&&!(x.DEFAULT_CSS_PROPERTIES_LIST&&x.DEFAULT_CSS_PROPERTIES_LIST.has(c))){const i=c,a=(0,j.createEffect)(()=>{try{const u=e(t,t.state,t.context);t.node?.setAttribute&&(u==null||u===!1?t.node.removeAttribute(i):typeof u!="function"&&typeof u!="object"&&(i==="src"&&"src"in t.node?t.node.src=u:t.node.setAttribute(i,u===!0?"":u)))}catch{}},{depth:n.path.length});n.__effects.push(a)}}Ct(t),kt(t)}function z(t){const{node:s}=t;if(s){if(typeof t.text=="string"&&!t.text.includes("{{")?t.tag==="string"?s.nodeValue=t.text:s.textContent=t.text:typeof t.text=="number"&&(s.textContent=t.text),wt(t),typeof t.html=="string"&&(s.innerHTML=t.html),t.value!=null&&typeof t.value!="function"&&"value"in s){const n=String(t.value);s.value!==n&&(s.value=n)}if(t.style&&typeof t.style=="object"&&F(s,t.style),t.attr&&typeof t.attr=="object")for(const n in t.attr){const r=t.attr[n];typeof r=="function"||typeof r=="object"||r==null||r===!1||s.setAttribute&&s.setAttribute(n,r===!0?"":r)}if(t.data&&typeof t.data=="object")for(const n in t.data){const r=t.data[n];typeof r=="function"||typeof r=="object"||r==null||r===!1||s.dataset&&(s.dataset[n]=r===!0?"":r)}if(t.classlist||t.class){const n=t.classlist||t.class;if(typeof n=="string")n.split(" ").forEach(r=>r&&s.classList.add(r));else if(typeof n=="object")for(const r in n){const c=typeof n[r]=="function"?n[r](t,t.state,t.context):n[r];c&&s.classList.add(typeof c=="string"?c:r)}}}}function F(t,s){if(!t||!s||!t.style)return;let n=null;for(const r in s){const c=s[r];if(c!=null){if(r.charAt(0)==="&"&&typeof c=="object"){n||(n={}),n[r]=c;continue}try{const o=String(c),e=r.replace(/[A-Z]/g,u=>"-"+u.toLowerCase()),f=o.trim(),i=/\s*!important\s*$/.test(f),a=f.replace(/\s*!important\s*$/,"");t.style.setProperty(e,a,i?"important":"")}catch{}}}n&&jt(t,n)}let vt=0;function jt(t,s){const n=`_ds${vt++}`;t.classList.add(n);const r=t.ownerDocument;let c=r.querySelector("style[data-smbls-scoped]");c||(c=r.createElement("style"),c.setAttribute("data-smbls-scoped",""),r.head.appendChild(c));let o="";for(const e in s){const f="."+n,i=e.replace(/&/g,f).split(",").map(u=>{const _=u.trim();return _.includes(f)?_:f+_}).join(", "),a=s[e];if(typeof a=="object"){let u="",_="";for(const p in a){const d=a[p];if(typeof d=="object"){const h=p.includes("&")?i.split(", ").map(y=>p.replace(/&/g,y)).join(", "):i.split(", ").map(y=>`${y} ${p}`).join(", ");let l="";for(const y in d)l+=`${y.replace(/[A-Z]/g,g=>"-"+g.toLowerCase())}: ${d[y]};`;_+=`${h} { ${l} }
|
|
5
|
+
`}else u+=`${p.replace(/[A-Z]/g,h=>"-"+h.toLowerCase())}: ${d};`}u&&(o+=`${i} { ${u} }
|
|
6
|
+
`),_&&(o+=_)}}o&&(c.textContent+=o)}function Ct(t){const s=t.subscribeTo;if(!Array.isArray(s)||s.length===0)return;const n=t.__ref;for(let r=0;r<s.length;r++){const c=s[r];if(typeof c!="string"||c.length===0)continue;const o=c.split("."),e=o[0],f=o.slice(1),i={value:!1},a=(0,j.createEffect)(()=>{const u=t.state&&((0,S.isStore)(t.state)?t.state.root:null);if(!u||!(0,S.isStore)(u))return;let _=u;_=_[e];for(let p=0;p<f.length&&!(_==null||typeof _!="object");p++)if((0,S.isStore)(_))_=_[f[p]];else break;if(i.value&&typeof t.onUpdate=="function"){const p=t.context?.designSystem;p&&(0,A.pushConfig)(p);try{t.onUpdate(t,t.state,t.context)}catch(d){t.context?.plugins?.length&&(0,W.runPluginHook)("error",t,{hook:"onUpdate",error:d})||console.error("[DOMQL] subscribeTo onUpdate error:",d)}finally{p&&(0,A.popConfig)()}}},{depth:n.path.length});i.value=!0,n.__effects.push(a)}}function kt(t){const s=t.__ref;s.__conditionalRunners=[];for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;const r=n.charAt(0);if(r!=="."&&r!=="!")continue;const c=n.slice(1);if(!c)continue;const o=t[n];if(!o||typeof o!="object")continue;const e=r==="!",f={lastMatch:!1,appliedKeys:null},i=()=>{if(!t.node)return;let u;const _=t[c];if(_===void 0)if(t.state&&c in t.state)u=t.state[c];else{const h=t.context?.cases?.[c];if(h===void 0)return;try{u=typeof h=="function"?h.call(t,t):h}catch(l){u=!1,s.__conditionalError=l,typeof console<"u"&&console.warn&&console.warn(`[smbls] conditional \`${n}\` case fn threw on ${t.key||"?"} \u2014 treating as false:`,l?.message||l)}}else if(typeof _=="function")try{u=_(t,t.state,t.context)}catch(h){u=!1,s.__conditionalError=h,typeof console<"u"&&console.warn&&console.warn(`[smbls] conditional \`${n}\` predicate threw on ${t.key||"?"} \u2014 treating as false:`,h?.message||h)}else u=_;const p=e?!u:!!u;if(p===f.lastMatch)return;f.lastMatch=p;const d=t.context?.designSystem;d&&(0,A.pushConfig)(d);try{if(p){const h={};for(const y in o){if(!Object.prototype.hasOwnProperty.call(o,y))continue;const g=typeof o[y]=="function"?o[y](t,t.state,t.context):o[y];if(g!=null)if(x.CSS_PROPS_REGISTRY[y]){const b=x.CSS_PROPS_REGISTRY[y](g,t,t.state,t.context);if(b){const w=Array.isArray(b)?b:[b];for(const O of w)O&&Object.assign(h,O)}}else x.DEFAULT_CSS_PROPERTIES_LIST&&x.DEFAULT_CSS_PROPERTIES_LIST.has(y)&&(h[y]=g)}const l=Object.keys(h);l.length?(F(t.node,h),f.appliedKeys=l):f.appliedKeys=null}else if(f.appliedKeys){for(const h of f.appliedKeys)t.node.style[h]="";f.appliedKeys=null}}finally{d&&(0,A.popConfig)()}};s.__conditionalRunners.push(i);const a=(0,j.createEffect)(i,{depth:s.path.length});s.__effects.push(a)}}const B=new WeakSet;function St(t){const s=t.ownerDocument;!s||B.has(s)||(B.add(s),queueMicrotask(()=>{B.delete(s);const n=s.body||s.documentElement;n&&n.offsetWidth}))}const q=new WeakSet;function wt(t){const{node:s}=t;if(!s)return;if(q.has(t)){console.error("[applyCssInProps] re-entry detected for element",t.key,"prop path:",t.__ref?.path);return}q.add(t);const n=t.context?.designSystem;n&&(0,A.pushConfig)(n);try{const r={};let c=!1;for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||typeof t[o]=="function"||P.REGISTRY.has(o))continue;const e=o.charCodeAt(0);if(!(e>=65&&e<=90)&&!M(o)){if(x.CSS_PROPS_REGISTRY[o]){const f=t[o],i=x.CSS_PROPS_REGISTRY[o](f,t,t.state,t.context);if(i){if(Array.isArray(i))for(const a of i)a&&Object.assign(r,a);else Object.assign(r,i);c=!0}}else if(x.DEFAULT_CSS_PROPERTIES_LIST&&x.DEFAULT_CSS_PROPERTIES_LIST.has(o)){const f=t[o];f!=null&&typeof f!="object"&&(r[o]=f,c=!0)}else if(o.charCodeAt(0)===45){const f=t[o];f!=null&&typeof f!="object"&&(r[o]=f,c=!0)}else if(o.charAt(0)==="&"){const f=t[o];f&&typeof f=="object"&&(r[o]=f,c=!0)}else if(o.charAt(0)==="@"||o.charAt(0)===":"){const f=t[o];if(f&&typeof f=="object"){const i={};for(const a in f){let u=f[a];if(typeof u=="function"&&(u=u(t,t.state,t.context)),!(u==null||typeof u=="function"))if(x.CSS_PROPS_REGISTRY[a]){const _=x.CSS_PROPS_REGISTRY[a](u,t,t.state,t.context);if(_)if(Array.isArray(_))for(const p of _)p&&Object.assign(i,p);else Object.assign(i,_)}else i[a]=u}if(Object.keys(i).length){if(o.length>1&&o.charAt(0)==="@"&&!o.startsWith("@media")&&!o.startsWith("@keyframes")&&!o.startsWith("@supports")&&(o==="@dark"||o==="@light"||!t.context?.designSystem?.media?.[o.slice(1)])){const u={};for(const p in i){const d=i[p];u[p]=typeof d=="string"&&!d.includes("!important")?d+" !important":d}const _=o.slice(1);r[`[data-theme="${_}"] &`]=u}else{let u=o;if(o.charAt(0)==="@"&&!o.startsWith("@media")&&!o.startsWith("@keyframes")){const p=o.slice(1),d=t.context?.designSystem?.media?.[p]||t.context?.designSystem?.media?.[p];d&&(u=`@media ${d}`)}const _={};for(const p in i){const d=i[p];if(d&&typeof d=="object"&&!Array.isArray(d)){const h={};for(const y in d)if(x.CSS_PROPS_REGISTRY[y]){const g=x.CSS_PROPS_REGISTRY[y](d[y],t,t.state,t.context);if(g)if(Array.isArray(g))for(const b of g)b&&Object.assign(h,b);else Object.assign(h,g)}else h[y]=d[y];const l=p.startsWith(":")?"":" ";if(u.includes(",")){const y=u.split(",").map(g=>`${g.trim()}${l}${p}`).join(", ");r[y]=h}else r[`${u}${l}${p}`]=h}else _[p]=d}Object.keys(_).length&&(r[u]=_)}c=!0}c=!0}}}}if(c){r.display&&String(r.display).includes("!important")&&(s.style.setProperty("display",String(r.display).replace(/\s*!important\s*$/,""),"important"),delete r.display);const o=(0,at.css)(r,null,t.context?.cssPrefix);if(o&&s.classList){const f=o.split(" ").filter(Boolean);let i=!1;for(const a of f)s.classList.add(a),i||(a.charCodeAt(0)===95&&a.charCodeAt(1)===99||a.charCodeAt(0)===95&&a.indexOf("_c",1)!==-1)&&(i=!0);i&&St(s)}const e=t.display!=null&&typeof t.display!="function"?t.display:t.hide===!0||t.show===!1?"none":null;if(e!=null){const f=r.display;if(f&&f!==e)if(e==="none"){const i=[];for(const a of s.classList)a.startsWith("_d-")&&a!=="_d-none"&&i.push(a);for(const a of i)s.classList.remove(a);s.classList.add("_d-none")}else s.style.display=t.display}}}finally{n&&(0,A.popConfig)(),q.delete(t)}}function st(t){const{node:s}=t;if(!s||!s.setAttribute)return;if(t.aria&&typeof t.aria=="object")for(const c in t.aria){const o=t.aria[c];if(typeof o=="function"||typeof o=="object"||o==null||o===!1)continue;const e="aria-"+c.replace(/[A-Z]/g,f=>"-"+f.toLowerCase());s.setAttribute(e,o===!0?"":o)}const n=(0,I.applyAttrTransforms)(t);for(const c in n){const o=n[c];o!=null&&o!==!1&&typeof o!="function"&&typeof o!="object"&&s.setAttribute(c,o===!0?"":o)}const r=t.tag||"div";for(const c in t){if(!Object.prototype.hasOwnProperty.call(t,c)||typeof t[c]=="function"||P.REGISTRY.has(c)||c==="on"||n[c]!==void 0)continue;const o=c.charCodeAt(0);if(!(o>=65&&o<=90)&&!M(c)&&!(x.CSS_PROPS_REGISTRY[c]||x.DEFAULT_CSS_PROPERTIES_LIST&&x.DEFAULT_CSS_PROPERTIES_LIST.has(c))&&(0,I.checkAttributeByTagName)(r,c)){let e=t[c];if(e==null||e===!1||(typeof e=="string"&&e.includes("{{")&&(e=(0,V.replaceLiteralsWithObjectFields)(e,t,t.state,t.context),t[c]=e),e==null||e===!1||typeof e=="function"||typeof e=="object"))continue;s.setAttribute(c,e===!0?"":e)}}}function Et(t){if(!t.autoGrow)return;const s=t.node;if(!s||s.tagName!=="TEXTAREA")return;const n=t.autoGrow,r=n&&typeof n=="object"&&n.max?String(n.max):null;r&&(s.style.maxHeight=r);const c=()=>{s.style.height="auto",s.style.height=s.scrollHeight+"px"};c(),s.addEventListener("input",c),t.__ref.__eventCleanup||(t.__ref.__eventCleanup=[]),t.__ref.__eventCleanup.push(()=>{try{s.removeEventListener("input",c)}catch{}})}const ct=new Set(["onSwipe","onSwipeLeft","onSwipeRight","onSwipeUp","onSwipeDown"]);function nt(t,s){for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n)||!M(n)||ct.has(n))continue;let r=t[n];if(typeof r=="string"&&/^[A-Za-z_$][\w$]*$/.test(r)){const o=r;r=function(f){return t.call(o,f)}}if(typeof r!="function")continue;const c=gt(n);P.LIFECYCLE_EVENTS.has(c)||(0,it.registerEvent)(bt(c),t,r)}Pt(t)}function Pt(t){const s=t.node;if(!s||!s.addEventListener)return;const n={};let r=!1;for(const p of ct){const d=t[p];typeof d=="function"&&(n[p]=d,r=!0)}if(!r)return;const c=typeof t.swipeThreshold=="number"?t.swipeThreshold:40,o=typeof t.swipeMaxDuration=="number"?t.swipeMaxDuration:600;let e=0,f=0,i=0,a=!1;const u=p=>{const d=p.touches&&p.touches[0]||p.changedTouches&&p.changedTouches[0];d&&(e=d.clientX,f=d.clientY,i=Date.now(),a=!0)},_=p=>{if(!a)return;a=!1;const d=p.changedTouches&&p.changedTouches[0]||p.touches&&p.touches[0];if(!d)return;const h=d.clientX-e,l=d.clientY-f,y=Date.now()-i;if(y>o)return;const g=Math.abs(h),b=Math.abs(l);if(Math.max(g,b)<c)return;let w;if(g>b*1.2)w=h<0?"left":"right";else if(b>g*1.2)w=l<0?"up":"down";else return;const O="onSwipe"+w.charAt(0).toUpperCase()+w.slice(1),C=n[O],k=n.onSwipe;C&&C.call(t,p,t,t.state,t.context),k&&k.call(t,{direction:w,dx:h,dy:l,dt:y,event:p},t,t.state,t.context)};s.addEventListener("touchstart",u,{passive:!0}),s.addEventListener("touchend",_,{passive:!0}),t.__ref.__eventCleanup||(t.__ref.__eventCleanup=[]),t.__ref.__eventCleanup.push(()=>{try{s.removeEventListener("touchstart",u)}catch{}try{s.removeEventListener("touchend",_)}catch{}})}function X(t,s){const n={...t};for(const r in s){const c=n[r],o=s[r];c&&o&&typeof c=="object"&&typeof o=="object"&&!Array.isArray(c)&&!Array.isArray(o)&&typeof c!="function"&&typeof o!="function"?n[r]=X(c,o):n[r]=o}return n}function Q(t,s,n){if(!s||!t.node)return;const r=t.childExtends;if(Array.isArray(s)){const o=(t.context?.document||globalThis.document)?.createDocumentFragment();if(!o)return;const e=t.childProps,f=t.childrenAs;for(let i=0;i<s.length;i++){let a=s[i];const u=a;(typeof a=="string"||typeof a=="number")&&(a={text:a});let _=e;if(typeof e=="function")try{_=e(t,a)}catch{_=null}if(f==="state"){let h=u;(typeof u=="string"||typeof u=="number")&&(h={value:u,text:u}),a=_?{..._,state:h}:{state:h}}else _&&(a=X(_,a));if(r&&!a.ignoreChildExtends)if(a.extends){const h=Array.isArray(a.extends)?a.extends:[a.extends],l=Array.isArray(r)?r:[r];a={...a,extends:[...l,...h]}}else a={extends:r,...a};const p=a?.key||`${i}`,d=N(a,t,p,n);d?.node&&o.appendChild(d.node)}t.node.appendChild(o);return}if(typeof s=="string"){const c=ot(s,t);if(Array.isArray(c)){Q(t,c,n);return}}if(typeof s=="object")for(const c in s){if(P.REGISTRY.has(c))continue;let o=s[c];if(!(o==null||o===!1)){if((typeof o=="string"||typeof o=="number")&&(o={text:o}),t.childProps&&(o=X(t.childProps,o)),r&&!o.ignoreChildExtends)if(o.extends){const e=Array.isArray(o.extends)?o.extends:[o.extends],f=Array.isArray(r)?r:[r];o={...o,extends:[...f,...e]}}else o={extends:r,...o};N(o,t,c,n)}}}function rt(t,s){let{children:n,content:r}=t;const c=t.childExtends;if(typeof n=="function"){const e=n;n=e(t,t.state,t.context),t.children=n;const f=t.__ref;let i=!1;const a=(0,j.createEffect)(()=>{const u=e(t,t.state,t.context);if(!i){i=!0;return}if(u===t.children)return;if(t.children=u,Array.isArray(u)&&t.childrenAs==="state"){const d=t.childProps,h=[],l=new Map;for(let C=0;C<u.length;C++){const k=u[C];let v=d;if(typeof d=="function")try{v=d(t,k)}catch{v=null}const D=v&&v.key||k&&k.key||`${C}`;h.push(D),l.set(D,{rawChild:k,childProps:v})}const y=new Set(h),g=f.__children.slice();for(const C of g)if(!y.has(C)){const k=t[C];k?.remove&&k.remove(),delete t[C]}const b=t.childExtends,O=(t.context?.document||globalThis.document)?.createDocumentFragment();for(const C of h){const k=l.get(C),v=k.rawChild,D=t[C];if(D&&D.state){if(v&&typeof v=="object"){const $=D.state;if(typeof $.replace=="function")$.replace(v);else if(typeof $.update=="function"){for(const E in $)if(!(E==="__element"||E==="root"||E==="parent"||E==="update")&&!Object.prototype.hasOwnProperty.call(v,E))try{$[E]=void 0}catch{}$.update(v)}else for(const E in v)$[E]=v[E]}continue}let H=v;(typeof v=="string"||typeof v=="number")&&(H={value:v,text:v});const m=k.childProps;let L=m?{...m,state:H}:{state:H};if(b&&!L.ignoreChildExtends)if(L.extends){const $=Array.isArray(L.extends)?L.extends:[L.extends],E=Array.isArray(b)?b:[b];L={...L,extends:[...E,...$]}}else L={extends:b,...L};const tt=N(L,t,C,s);tt?.node&&O&&O.appendChild(tt.node)}O&&O.childNodes.length&&t.node&&t.node.appendChild(O),f.__children=h;return}for(const d of[...f.__children]){const h=t[d];h?.remove&&h.remove(),delete t[d]}f.__children=[],Q(t,u,s)},{depth:f.path.length});f.__effects.push(a)}if(Q(t,n||r,s),n||r)return;const o=t.context?.components||{};{const e=Object.keys(t);for(let f=0;f<e.length;f++){const i=e[f];if(!i.endsWith("Extends")||typeof t[i]!="string")continue;const a=i.slice(0,-7);if(!a||a.charCodeAt(0)<65||a.charCodeAt(0)>90)continue;const u={extends:t[i]};delete t[i];for(let _=f+1;_<e.length;_++){const p=e[_],d=p.charCodeAt(0);if(d>=65&&d<=90||P.REGISTRY.has(p)||typeof t[p]=="function"&&(p.startsWith("on")||p.startsWith(".")))break;const h=t[p];h!==void 0&&(u[p]=h,delete t[p])}t[a]&&typeof t[a]=="object"?t[a]={...u,...t[a]}:t[a]=u}}for(const e in t){if(!Object.prototype.hasOwnProperty.call(t,e)||P.REGISTRY.has(e)||typeof t[e]!="object"||t[e]===null)continue;const f=e.charCodeAt(0);if(f<65||f>90)continue;let i=t[e];if(!i.__ref){if(!i.extends&&!i.extend){const a=o[e]||o[`smbls.${e}`];a&&(i={extends:a,...i})}if(t.childProps&&(i={...t.childProps,...i}),c&&!i.ignoreChildExtends)if(i.extends){const a=Array.isArray(i.extends)?i.extends:[i.extends],u=Array.isArray(c)?c:[c];i={...i,extends:[...u,...a]}}else i={extends:c,...i};N(i,t,e,s)}}}function J(t,s,n){const{node:r}=t;if(!r)return;const c=s?.node||(s?.nodeType?s:null);if(c)if(n?.position==="before"&&n.node)c.insertBefore(r,n.node);else if(n?.position==="after"&&n.node){const o=n.node.nextSibling;o?c.insertBefore(r,o):c.appendChild(r)}else c.appendChild(r)}function R(t,s,n){const r=t.charAt(0).toLowerCase()+t.slice(1);s.context?.plugins?.length&&(0,W.runPluginHook)(r,s,n);const c="on"+t,o=s[c];if(typeof o=="function"){const e=t==="Render"||t==="RenderRouter";if(e){if(s.__ref.__inRender)return!0;s.__ref.__inRender=!0}const f=s.context?.designSystem;f&&(0,A.pushConfig)(f);try{if(o(s,s.state,s.context,n)===!1)return!1}catch(i){if(s.context?.plugins?.length&&(0,W.runPluginHook)("error",s,{hook:c,error:i})||console.error(`[DOMQL] Lifecycle "${c}" error:`,i),s.context?.strictMode)throw i}finally{f&&(0,A.popConfig)(),e&&(s.__ref.__inRender=!1)}}return!0}var Ot=N;
|
package/dist/esm/src/create.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{createStore as W,createScopeStore as
|
|
1
|
+
import{createStore as W,createScopeStore as at,isStore as D}from"@symbo.ls/signal";import{createEffect as A}from"@symbo.ls/signal";import{cacheNode as H,detectTag as ct}from"./cache.js";import{REGISTRY as R,LIFECYCLE_EVENTS as ut}from"./registry.js";import{registerEvent as dt}from"./delegate.js";import{applyExtends as pt}from"./extends.js";import{addMethods as yt}from"./methods.js";import"./dispose.js";import{replaceLiteralsWithObjectFields as Y}from"@symbo.ls/utils";import{runPluginHook as G}from"@symbo.ls/utils/function.js";import{applyStateMethods as I}from"@symbo.ls/state";import{CSS_PROPS_REGISTRY as C,DEFAULT_CSS_PROPERTIES_LIST as k}from"css-in-props";import{css as lt}from"@symbo.ls/css";import{pushConfig as O,popConfig as L}from"@symbo.ls/scratch";import{checkAttributeByTagName as U,applyAttrTransforms as ht}from"attrs-in-props";let _t=1;function M(t){return t.length>2&&t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)>=65&&t.charCodeAt(2)<=90}function gt(t){return t.charAt(2).toLowerCase()+t.slice(3)}function bt(t){return t.toLowerCase()}function Z(t,c){const n={...t};for(const i in c){const s=n[i],o=c[i];s&&o&&typeof s=="object"&&typeof o=="object"&&!Array.isArray(s)&&!Array.isArray(o)&&typeof s!="function"&&typeof o!="function"?n[i]=Z(s,o):n[i]=o}return n}function F(t,c,n,i={},s){if(t==null||t===!1)return null;(typeof t=="string"||typeof t=="number")&&(t={text:t});const o=Object.create(null);o.key=n||t.key||`_${_t++}`,o.parent=c||null,o.context=t.context||c?.context||i.context||{},o.context.__create||(o.context.__create=F);const e=o.__ref={__if:!0,__children:[],__exec:{},__effects:[],__eventCleanup:[],root:c?.__ref?.root||o,path:c?.__ref?.path?[...c.__ref.path,o.key]:[o.key]};if(n&&!t.extends&&!t.extend){const l=n.indexOf("_");if(l>0){const y=n.substring(0,l),g=o.context?.components;g&&(g[y]||g["smbls."+y])&&(t={extends:y,...t})}}pt(o,t,i);const f=new Set(["childProps","attr","style","scope","data"]),r=o.props&&typeof o.props=="object"?o.props:null;for(const l in t){if(l==="parent"||l==="node"||l==="__ref"||l==="extends"||l==="context"||l==="props")continue;const y=t[l],g=o[l],b=g&&y&&typeof g=="object"&&typeof y=="object"&&!Array.isArray(g)&&!Array.isArray(y)&&typeof g!="function"&&typeof y!="function";b&&l.charCodeAt(0)>=65&&l.charCodeAt(0)<=90?o[l]=Z(g,y):b&&f.has(l)?o[l]={...g,...y}:o[l]=y}function a(l){for(const y in l){const g=l[y],b=o[y],S=b&&g&&typeof b=="object"&&typeof g=="object"&&!Array.isArray(b)&&!Array.isArray(g)&&typeof b!="function"&&typeof g!="function";S&&y.charCodeAt(0)>=65&&y.charCodeAt(0)<=90?o[y]=Z(b,g):S&&f.has(y)?o[y]={...b,...g}:o[y]=g}}r&&a(r),t.props&&typeof t.props=="object"&&a(t.props),t.data!==void 0&&(o.data=t.data),t.classlist!==void 0&&(o.classlist=t.classlist),t.text!==void 0&&(o.text=t.text),t.html!==void 0&&(o.html=t.html);const u=o.scope&&typeof o.scope=="object"?o.scope:null,_=c?.scope,p=o.context&&typeof o.context.globalScope=="object"&&o.context.globalScope||null,d=_||p||null;if(t.scope!==void 0||u){const l={};u&&Object.assign(l,u),t.scope!==void 0&&Object.assign(l,t.scope),o.scope=at(l,d)}else d&&(o.scope=d);if(t.if!==void 0&&(o.if=t.if),yt(o),xt(o,c,t),o.if!=null){let l;if(typeof o.if=="function")try{l=o.if(o,o.state,o.context)}catch(y){if(l=!1,e.__ifError=y,typeof console<"u"&&console.warn){const g=o.key||o.tag||"?";console.warn(`[smbls] \`if:\` evaluator threw on ${g} \u2014 treating as false:`,y?.message||y)}}else l=o.if;e.__if=!!l}if(e.__if)typeof t.if=="function"&&(e.__ifInitialized=!0);else return c&&(c[o.key]=o),typeof t.if=="function"&&B(o,{if:t.if}),o;o.tag||(o.tag=ct(o)),N("Init",o,i);const h=o.node=H(o);if(!h)return o;N("AttachNode",o,i),h.setAttribute&&o.key&&h.setAttribute("data-key",o.key),h.setAttribute&&o.context?.scopeSelector&&o.context.scopeSelector!==":root"&&o.context.key&&o.key===o.context.key&&h.setAttribute("data-smbls-app",o.context.key),o.id&&h.setAttribute&&(h.id=o.id),et(o,i),B(o,t),q(o),rt(o),Et(o);try{ft(o,i)}catch(l){if(typeof console<"u"&&console.error){const y=o.__ref?.path?.join(".")||o.key||"<root>";console.error(`[smbls] createChildren failed at ${y}:`,l?.message||l,l?.stack?`
|
|
2
2
|
`+l.stack.split(`
|
|
3
3
|
`).slice(0,6).join(`
|
|
4
|
-
`):"")}}if(m(o,c,s),c&&(c[o.key]=o,c.__ref?.__children&&(c.__ref.__children.includes(o.key)||c.__ref.__children.push(o.key))),typeof o.html=="function"&&o.node&&!o.node.innerHTML){const l=o.context?.designSystem;l&&O(l);try{const y=o.html(o,o.state,o.context);y!=null&&typeof y!="function"&&(o.node.innerHTML=y)}catch{}finally{l&&L()}}if(T("Create",o,i),T("Complete",o,i),T("Render",o,i),T("RenderRouter",o,i),typeof o.onFrame=="function"){const l=o.onFrame,y=o.context?.designSystem,g=()=>{if(o.node){if(o.node.isConnected){y&&O(y);try{l(o,o.state,o.context)}catch(b){console.error("[DOMQL] onFrame error:",b)}finally{y&&L()}}requestAnimationFrame(g)}};requestAnimationFrame(g)}return o}function bt(t,c,n){const i=!c,s=n.state&&typeof n.state=="object"&&!Array.isArray(n.state)&&Object.keys(n.state).length===0,o=i&&s&&t.context?.state,r=n.state!==void 0&&!o?n.state:t.state&&!D(t.state)?t.state:void 0;if(r==null){if(c?.state)t.state=c.state,I(t,t.state);else if(t.context?.state){const f=t.context.state,e={...f},a=t.context?.polyglot;if(a?.translations){const u=f.lang||a.defaultLang||"en",_=a.translations[u];if(_&&typeof _=="object")for(const d in _)e[d]===void 0&&(e[d]=_[d]);const p=new Set(a.languages||[]);for(const d in a.translations)!p.has(d)&&e[d]===void 0&&(e[d]=a.translations[d])}t.state=D(e)?e:W(e),t.state.__element=t,t.state.root=t.state,I(t,t.state)}else t.state={},Object.defineProperty(t.state,"root",{value:t.state,enumerable:!1,configurable:!0,writable:!0}),I(t,t.state);return}if(typeof r=="string"){if(t.state=ct(r,c),t.state&&typeof t.state=="object"&&!D(t.state)){const f=c?.state?.root||c?.state||t.state;Object.defineProperty(t.state,"root",{value:f,enumerable:!1,configurable:!0,writable:!0})}I(t,t.state);return}if(typeof r=="function"){const f=r(t,c?.state);t.state=W(f||{})}else t.state=W({...r});t.state.__element=t,c?.state?(t.state.parent=c.state,t.state.root=c.state.root||c.state):t.state.root=t.state,I(t,t.state)}function z(t,c){if(!c)return t;const n=c.split("/");let i=t;for(const s of n){if(i==null)return{};i=i[s]}return i??{}}function ct(t,c){if(!c)return{};if(t===".")return c.state||{};if(t.startsWith("../")){const s=t.slice(3);return s?z(c.state,s):c.state??{}}if(t.startsWith("~/")){const s=c.state?.root||c.state,o=t.slice(2);return o?z(s,o):s??{}}if(c.state?.[t]!==void 0)return c.state[t];const n=z(c.state,t);if(n!=null&&Object.keys(n).length>0)return n;const i=c.context?.polyglot;if(i?.translations){const s=c.state?.root?.lang||i.defaultLang||"en",o=i.translations[s];if(o?.[t]!==void 0)return o[t];if(i.translations[t]!==void 0)return i.translations[t]}return{}}function xt(t){const c=t.__ref,n=t.tag||"div",i=t.context?.designSystem,s=[],o=Object.keys(t);for(let r=0;r<o.length;r++){const f=o[r];if(typeof t[f]!="function"||N.has(f))continue;const e=f.charCodeAt(0);e>=65&&e<=90||M(f)||C[f]||S&&S.has(f)||U(n,f)||s.push({prop:f,fn:t[f]})}for(let r=0;r<s.length;r++){const{prop:f,fn:e}=s[r];c.__exec[f]=e,Object.defineProperty(t,f,{get(){i&&O(i);try{return e(t,t.state,t.context)}catch{return}finally{i&&L()}},set(a){delete c.__exec[f],Object.defineProperty(t,f,{value:a,writable:!0,configurable:!0,enumerable:!0})},configurable:!0,enumerable:!0})}}function B(t,c){const n=t.__ref;if(xt(t),typeof t.text=="function"){const s=t.text,o=A(()=>{if(!n.contentManaged)try{let r=s(t,t.state,t.context);t.node&&r!=null&&typeof r!="function"&&typeof r!="object"&&(typeof r=="string"&&r.includes("{{")&&(r=Y.call(t,r,t.state)),t.tag==="string"?t.node.nodeValue=r:t.node.textContent=r)}catch{}},{depth:n.path.length});n.__effects.push(o),n.__exec.text=s}else if(typeof t.text=="string"&&t.text.includes("{{")){const s=t.text,o=A(()=>{if(n.contentManaged)return;const r=Y.call(t,s,t.state);r!=null&&(t.text=r),t.node&&(t.tag==="string"?t.node.nodeValue=r??"":t.node.textContent=r??"")},{depth:n.path.length});n.__effects.push(o),n.__exec.text=s}for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)&&typeof t[s]=="function"&&!N.has(s)&&!M(s)&&!n.__exec[s]){if(C[s]){const o=t[s],r=s,f=A(()=>{const e=t.context?.designSystem;e&&O(e);try{const a=o(t,t.state,t.context),u=C[r](a,t,t.state,t.context);u&&t.node?F(t.node,u):t.node&&(r==="show"||r==="hide")&&(t.node.style.display="")}finally{e&&L()}},{depth:n.path.length});n.__effects.push(f),n.__exec[s]=o}else if(S&&S.has(s)){const o=t[s],r=s,f=A(()=>{const e=t.context?.designSystem;e&&O(e);try{const a=o(t,t.state,t.context);t.node&&(a!=null?F(t.node,{[r]:a}):t.node.style[r]="")}finally{e&&L()}},{depth:n.path.length});n.__effects.push(f),n.__exec[s]=o}}if(typeof c.html=="function"){const s=c.html,o=A(()=>{const r=t.context?.designSystem;r&&O(r);try{const f=s(t,t.state,t.context);t.node&&f!=null&&typeof f!="function"&&(t.node.innerHTML=f)}finally{r&&L()}},{depth:n.path.length});n.__effects.push(o),n.__exec.html=s}if(typeof c.value=="function"){const s=c.value,o=A(()=>{try{const r=s(t,t.state,t.context);if(!t.node||!("value"in t.node))return;const f=r==null?"":String(r);if(t.node.value===f)return;const e=typeof document<"u"&&document.activeElement===t.node,a=e&&typeof t.node.selectionStart=="number"?t.node.selectionStart:null,u=e&&typeof t.node.selectionEnd=="number"?t.node.selectionEnd:null;if(t.node.value=f,e&&a!=null&&u!=null)try{t.node.setSelectionRange(a,u)}catch{}}catch{}},{depth:n.path.length});n.__effects.push(o),n.__exec.value=s}if(typeof c.style=="function"){const s=c.style,o=A(()=>{const r=s(t,t.state,t.context);F(t.node,r)},{depth:n.path.length});n.__effects.push(o),n.__exec.style=s}else if(t.style&&typeof t.style=="object")for(const s in t.style){const o=t.style[s];if(typeof o!="function")continue;const r=A(()=>{try{const f=o(t,t.state,t.context);t.node&&F(t.node,{[s]:f})}catch{}},{depth:n.path.length});n.__effects.push(r)}if(t.attr&&typeof t.attr=="object"){for(const s in t.attr)if(typeof t.attr[s]=="function"){const o=t.attr[s],r=s,f=A(()=>{try{const e=o(t,t.state,t.context);t.node?.setAttribute&&(e==null||e===!1?t.node.removeAttribute(r):typeof e!="function"&&typeof e!="object"&&t.node.setAttribute(r,e===!0?"":e))}catch{}},{depth:n.path.length});n.__effects.push(f)}}if(t.aria&&typeof t.aria=="object")for(const s in t.aria){const o=t.aria[s];if(typeof o!="function")continue;const r="aria-"+s.replace(/[A-Z]/g,e=>"-"+e.toLowerCase()),f=A(()=>{try{const e=o(t,t.state,t.context);if(!t.node?.setAttribute)return;e==null||e===!1?t.node.removeAttribute(r):typeof e!="function"&&typeof e!="object"&&t.node.setAttribute(r,e===!0?"":e)}catch{}},{depth:n.path.length});n.__effects.push(f)}if(t.data&&typeof t.data=="object")for(const s in t.data){const o=t.data[s];if(typeof o!="function")continue;const f="data-"+s.replace(/[A-Z]/g,a=>"-"+a.toLowerCase()),e=A(()=>{try{const a=o(t,t.state,t.context);if(!t.node?.setAttribute)return;a==null||a===!1?t.node.removeAttribute(f):typeof a!="function"&&typeof a!="object"&&t.node.setAttribute(f,a===!0?"":a)}catch{}},{depth:n.path.length});n.__effects.push(e)}const i=t.classlist&&typeof t.classlist=="object"&&!Array.isArray(t.classlist)?t.classlist:t.class&&typeof t.class=="object"&&!Array.isArray(t.class)?t.class:null;if(i)for(const s in i){const o=i[s];if(typeof o!="function")continue;const r=A(()=>{try{const f=o(t,t.state,t.context);if(!t.node?.classList)return;typeof f=="string"?t.node.classList.add(f):f?t.node.classList.add(s):t.node.classList.remove(s)}catch{}},{depth:n.path.length});n.__effects.push(r)}if(typeof c.if=="function"){const s=c.if,o=A(()=>{let r;try{r=s(t,t.state,t.context)}catch(e){if(r=!1,n.__ifError=e,typeof console<"u"&&console.warn){const a=t.key||t.tag||"?";console.warn(`[smbls] \`if:\` reactive effect threw on ${a} \u2014 treating as false:`,e?.message||e)}return}const f=n.__if;if(n.__if=!!r,f&&!n.__if&&t.node)t.node.remove();else if(!f&&n.__if)if(n.__ifInitialized){t.node||(t.node=H(t));const e=t.parent,a=e?.node;if(a&&t.node){let u=null;const _=Object.keys(e),p=_.indexOf(t.key);for(let d=p+1;d<_.length;d++){const h=e[_[d]];if(h?.node?.parentNode===a){u=h.node;break}}u?a.insertBefore(t.node,u):a.appendChild(t.node)}else m(t,t.parent);X(t)}else{if(n.__ifInitialized=!0,t.tag||(t.tag=st(t)),T("Init",t,{}),t.node||(t.node=H(t)),!t.node)return;T("AttachNode",t,{}),t.node.setAttribute&&t.key&&t.node.setAttribute("data-key",t.key),t.id&&t.node.setAttribute&&(t.node.id=t.id);const e=c.if;delete c.if;try{B(t,c)}finally{c.if=e}X(t),nt(t),it(t,{}),et(t,{}),m(t,t.parent)}},{depth:n.path.length});n.__effects.push(o)}for(const s in t){if(!Object.prototype.hasOwnProperty.call(t,s)||N.has(s)||typeof t[s]!="function")continue;const o=s.charCodeAt(0);if(o>=65&&o<=90||M(s))continue;const r=t[s];n.__exec[s]=r;const f=t.tag||"div";if(U(f,s)&&!C[s]&&!(S&&S.has(s))){const e=s,a=A(()=>{try{const u=r(t,t.state,t.context);t.node?.setAttribute&&(u==null||u===!1?t.node.removeAttribute(e):typeof u!="function"&&typeof u!="object"&&(e==="src"&&"src"in t.node?t.node.src=u:t.node.setAttribute(e,u===!0?"":u)))}catch{}},{depth:n.path.length});n.__effects.push(a)}}jt(t),Ct(t)}function X(t){const{node:c}=t;if(c){if(typeof t.text=="string"&&!t.text.includes("{{")?t.tag==="string"?c.nodeValue=t.text:c.textContent=t.text:typeof t.text=="number"&&(c.textContent=t.text),St(t),typeof t.html=="string"&&(c.innerHTML=t.html),t.value!=null&&typeof t.value!="function"&&"value"in c){const n=String(t.value);c.value!==n&&(c.value=n)}if(t.style&&typeof t.style=="object"&&F(c,t.style),t.attr&&typeof t.attr=="object")for(const n in t.attr){const i=t.attr[n];typeof i=="function"||typeof i=="object"||i==null||i===!1||c.setAttribute&&c.setAttribute(n,i===!0?"":i)}if(t.data&&typeof t.data=="object")for(const n in t.data){const i=t.data[n];typeof i=="function"||typeof i=="object"||i==null||i===!1||c.dataset&&(c.dataset[n]=i===!0?"":i)}if(t.classlist||t.class){const n=t.classlist||t.class;if(typeof n=="string")n.split(" ").forEach(i=>i&&c.classList.add(i));else if(typeof n=="object")for(const i in n){const s=typeof n[i]=="function"?n[i](t,t.state,t.context):n[i];s&&c.classList.add(typeof s=="string"?s:i)}}}}function F(t,c){if(!t||!c||!t.style)return;let n=null;for(const i in c){const s=c[i];if(s!=null){if(i.charAt(0)==="&"&&typeof s=="object"){n||(n={}),n[i]=s;continue}try{const o=String(s),r=i.replace(/[A-Z]/g,u=>"-"+u.toLowerCase()),f=o.trim(),e=/\s*!important\s*$/.test(f),a=f.replace(/\s*!important\s*$/,"");t.style.setProperty(r,a,e?"important":"")}catch{}}}n&&vt(t,n)}let At=0;function vt(t,c){const n=`_ds${At++}`;t.classList.add(n);const i=t.ownerDocument;let s=i.querySelector("style[data-smbls-scoped]");s||(s=i.createElement("style"),s.setAttribute("data-smbls-scoped",""),i.head.appendChild(s));let o="";for(const r in c){const f="."+n,e=r.replace(/&/g,f).split(",").map(u=>{const _=u.trim();return _.includes(f)?_:f+_}).join(", "),a=c[r];if(typeof a=="object"){let u="",_="";for(const p in a){const d=a[p];if(typeof d=="object"){const h=p.includes("&")?e.split(", ").map(y=>p.replace(/&/g,y)).join(", "):e.split(", ").map(y=>`${y} ${p}`).join(", ");let l="";for(const y in d)l+=`${y.replace(/[A-Z]/g,g=>"-"+g.toLowerCase())}: ${d[y]};`;_+=`${h} { ${l} }
|
|
5
|
-
`}else u+=`${p.replace(/[A-Z]/g,h=>"-"+h.toLowerCase())}: ${d};`}u&&(o+=`${
|
|
6
|
-
`),_&&(o+=_)}}o&&(s.textContent+=o)}function jt(t){const c=t.subscribeTo;if(!Array.isArray(c)||c.length===0)return;const n=t.__ref;for(let i=0;i<c.length;i++){const s=c[i];if(typeof s!="string"||s.length===0)continue;const o=s.split("."),r=o[0],f=o.slice(1),e={value:!1},a=A(()=>{const u=t.state&&(D(t.state)?t.state.root:null);if(!u||!D(u))return;let _=u;_=_[r];for(let p=0;p<f.length&&!(_==null||typeof _!="object");p++)if(D(_))_=_[f[p]];else break;if(e.value&&typeof t.onUpdate=="function"){const p=t.context?.designSystem;p&&O(p);try{t.onUpdate(t,t.state,t.context)}catch(d){t.context?.plugins?.length&&G("error",t,{hook:"onUpdate",error:d})||console.error("[DOMQL] subscribeTo onUpdate error:",d)}finally{p&&L()}}},{depth:n.path.length});e.value=!0,n.__effects.push(a)}}function Ct(t){const c=t.__ref;c.__conditionalRunners=[];for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;const i=n.charAt(0);if(i!=="."&&i!=="!")continue;const s=n.slice(1);if(!s)continue;const o=t[n];if(!o||typeof o!="object")continue;const r=i==="!",f={lastMatch:!1,appliedKeys:null},e=()=>{if(!t.node)return;let u;const _=t[s];if(_===void 0)if(t.state&&s in t.state)u=t.state[s];else{const h=t.context?.cases?.[s];if(h===void 0)return;try{u=typeof h=="function"?h.call(t,t):h}catch(l){u=!1,c.__conditionalError=l,typeof console<"u"&&console.warn&&console.warn(`[smbls] conditional \`${n}\` case fn threw on ${t.key||"?"} \u2014 treating as false:`,l?.message||l)}}else if(typeof _=="function")try{u=_(t,t.state,t.context)}catch(h){u=!1,c.__conditionalError=h,typeof console<"u"&&console.warn&&console.warn(`[smbls] conditional \`${n}\` predicate threw on ${t.key||"?"} \u2014 treating as false:`,h?.message||h)}else u=_;const p=r?!u:!!u;if(p===f.lastMatch)return;f.lastMatch=p;const d=t.context?.designSystem;d&&O(d);try{if(p){const h={};for(const y in o){if(!Object.prototype.hasOwnProperty.call(o,y))continue;const g=typeof o[y]=="function"?o[y](t,t.state,t.context):o[y];if(g!=null)if(C[y]){const b=C[y](g,t,t.state,t.context);if(b){const k=Array.isArray(b)?b:[b];for(const E of k)E&&Object.assign(h,E)}}else S&&S.has(y)&&(h[y]=g)}const l=Object.keys(h);l.length?(F(t.node,h),f.appliedKeys=l):f.appliedKeys=null}else if(f.appliedKeys){for(const h of f.appliedKeys)t.node.style[h]="";f.appliedKeys=null}}finally{d&&L()}};c.__conditionalRunners.push(e);const a=A(e,{depth:c.path.length});c.__effects.push(a)}}const q=new WeakSet;function St(t){const{node:c}=t;if(!c)return;if(q.has(t)){console.error("[applyCssInProps] re-entry detected for element",t.key,"prop path:",t.__ref?.path);return}q.add(t);const n=t.context?.designSystem;n&&O(n);try{const i={};let s=!1;for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||typeof t[o]=="function"||N.has(o))continue;const r=o.charCodeAt(0);if(!(r>=65&&r<=90)&&!M(o)){if(C[o]){const f=t[o],e=C[o](f,t,t.state,t.context);if(e){if(Array.isArray(e))for(const a of e)a&&Object.assign(i,a);else Object.assign(i,e);s=!0}}else if(S&&S.has(o)){const f=t[o];f!=null&&typeof f!="object"&&(i[o]=f,s=!0)}else if(o.charCodeAt(0)===45){const f=t[o];f!=null&&typeof f!="object"&&(i[o]=f,s=!0)}else if(o.charAt(0)==="&"){const f=t[o];f&&typeof f=="object"&&(i[o]=f,s=!0)}else if(o.charAt(0)==="@"||o.charAt(0)===":"){const f=t[o];if(f&&typeof f=="object"){const e={};for(const a in f){let u=f[a];if(typeof u=="function"&&(u=u(t,t.state,t.context)),!(u==null||typeof u=="function"))if(C[a]){const _=C[a](u,t,t.state,t.context);if(_)if(Array.isArray(_))for(const p of _)p&&Object.assign(e,p);else Object.assign(e,_)}else e[a]=u}if(Object.keys(e).length){if(o.length>1&&o.charAt(0)==="@"&&!o.startsWith("@media")&&!o.startsWith("@keyframes")&&!o.startsWith("@supports")&&(o==="@dark"||o==="@light"||!t.context?.designSystem?.media?.[o.slice(1)])){const u={};for(const p in e){const d=e[p];u[p]=typeof d=="string"&&!d.includes("!important")?d+" !important":d}const _=o.slice(1);i[`[data-theme="${_}"] &`]=u}else{let u=o;if(o.charAt(0)==="@"&&!o.startsWith("@media")&&!o.startsWith("@keyframes")){const p=o.slice(1),d=t.context?.designSystem?.media?.[p]||t.context?.designSystem?.media?.[p];d&&(u=`@media ${d}`)}const _={};for(const p in e){const d=e[p];if(d&&typeof d=="object"&&!Array.isArray(d)){const h={};for(const y in d)if(C[y]){const g=C[y](d[y],t,t.state,t.context);if(g)if(Array.isArray(g))for(const b of g)b&&Object.assign(h,b);else Object.assign(h,g)}else h[y]=d[y];const l=p.startsWith(":")?"":" ";if(u.includes(",")){const y=u.split(",").map(g=>`${g.trim()}${l}${p}`).join(", ");i[y]=h}else i[`${u}${l}${p}`]=h}else _[p]=d}Object.keys(_).length&&(i[u]=_)}s=!0}s=!0}}}}if(s){i.display&&String(i.display).includes("!important")&&(c.style.setProperty("display",String(i.display).replace(/\s*!important\s*$/,""),"important"),delete i.display);const o=yt(i,null,t.context?.cssPrefix);if(o&&c.classList){const f=o.split(" ").filter(Boolean);let e=!1;for(const a of f)c.classList.add(a),e||(a.charCodeAt(0)===95&&a.charCodeAt(1)===99||a.charCodeAt(0)===95&&a.indexOf("_c",1)!==-1)&&(e=!0);e&&typeof c.offsetWidth=="number"&&c.offsetWidth}const r=t.display!=null&&typeof t.display!="function"?t.display:t.hide===!0||t.show===!1?"none":null;if(r!=null){const f=i.display;if(f&&f!==r)if(r==="none"){const e=[];for(const a of c.classList)a.startsWith("_d-")&&a!=="_d-none"&&e.push(a);for(const a of e)c.classList.remove(a);c.classList.add("_d-none")}else c.style.display=t.display}}}finally{n&&L(),q.delete(t)}}function nt(t){const{node:c}=t;if(!c||!c.setAttribute)return;if(t.aria&&typeof t.aria=="object")for(const s in t.aria){const o=t.aria[s];if(typeof o=="function"||typeof o=="object"||o==null||o===!1)continue;const r="aria-"+s.replace(/[A-Z]/g,f=>"-"+f.toLowerCase());c.setAttribute(r,o===!0?"":o)}const n=lt(t);for(const s in n){const o=n[s];o!=null&&o!==!1&&typeof o!="function"&&typeof o!="object"&&c.setAttribute(s,o===!0?"":o)}const i=t.tag||"div";for(const s in t){if(!Object.prototype.hasOwnProperty.call(t,s)||typeof t[s]=="function"||N.has(s)||s==="on"||n[s]!==void 0)continue;const o=s.charCodeAt(0);if(!(o>=65&&o<=90)&&!M(s)&&!(C[s]||S&&S.has(s))&&U(i,s)){let r=t[s];if(r==null||r===!1||(typeof r=="string"&&r.includes("{{")&&(r=Y(r,t,t.state,t.context),t[s]=r),r==null||r===!1||typeof r=="function"||typeof r=="object"))continue;c.setAttribute(s,r===!0?"":r)}}}function kt(t){if(!t.autoGrow)return;const c=t.node;if(!c||c.tagName!=="TEXTAREA")return;const n=t.autoGrow,i=n&&typeof n=="object"&&n.max?String(n.max):null;i&&(c.style.maxHeight=i);const s=()=>{c.style.height="auto",c.style.height=c.scrollHeight+"px"};s(),c.addEventListener("input",s),t.__ref.__eventCleanup||(t.__ref.__eventCleanup=[]),t.__ref.__eventCleanup.push(()=>{try{c.removeEventListener("input",s)}catch{}})}const rt=new Set(["onSwipe","onSwipeLeft","onSwipeRight","onSwipeUp","onSwipeDown"]);function it(t,c){for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n)||!M(n)||rt.has(n))continue;let i=t[n];if(typeof i=="string"&&/^[A-Za-z_$][\w$]*$/.test(i)){const o=i;i=function(f){return t.call(o,f)}}if(typeof i!="function")continue;const s=_t(n);at.has(s)||ut(gt(s),t,i)}wt(t)}function wt(t){const c=t.node;if(!c||!c.addEventListener)return;const n={};let i=!1;for(const p of rt){const d=t[p];typeof d=="function"&&(n[p]=d,i=!0)}if(!i)return;const s=typeof t.swipeThreshold=="number"?t.swipeThreshold:40,o=typeof t.swipeMaxDuration=="number"?t.swipeMaxDuration:600;let r=0,f=0,e=0,a=!1;const u=p=>{const d=p.touches&&p.touches[0]||p.changedTouches&&p.changedTouches[0];d&&(r=d.clientX,f=d.clientY,e=Date.now(),a=!0)},_=p=>{if(!a)return;a=!1;const d=p.changedTouches&&p.changedTouches[0]||p.touches&&p.touches[0];if(!d)return;const h=d.clientX-r,l=d.clientY-f,y=Date.now()-e;if(y>o)return;const g=Math.abs(h),b=Math.abs(l);if(Math.max(g,b)<s)return;let k;if(g>b*1.2)k=h<0?"left":"right";else if(b>g*1.2)k=l<0?"up":"down";else return;const E="onSwipe"+k.charAt(0).toUpperCase()+k.slice(1),v=n[E],j=n.onSwipe;v&&v.call(t,p,t,t.state,t.context),j&&j.call(t,{direction:k,dx:h,dy:l,dt:y,event:p},t,t.state,t.context)};c.addEventListener("touchstart",u,{passive:!0}),c.addEventListener("touchend",_,{passive:!0}),t.__ref.__eventCleanup||(t.__ref.__eventCleanup=[]),t.__ref.__eventCleanup.push(()=>{try{c.removeEventListener("touchstart",u)}catch{}try{c.removeEventListener("touchend",_)}catch{}})}function Q(t,c){const n={...t};for(const i in c){const s=n[i],o=c[i];s&&o&&typeof s=="object"&&typeof o=="object"&&!Array.isArray(s)&&!Array.isArray(o)&&typeof s!="function"&&typeof o!="function"?n[i]=Q(s,o):n[i]=o}return n}function J(t,c,n){if(!c||!t.node)return;const i=t.childExtends;if(Array.isArray(c)){const o=(t.context?.document||globalThis.document)?.createDocumentFragment();if(!o)return;const r=t.childProps,f=t.childrenAs;for(let e=0;e<c.length;e++){let a=c[e];const u=a;(typeof a=="string"||typeof a=="number")&&(a={text:a});let _=r;if(typeof r=="function")try{_=r(t,a)}catch{_=null}if(f==="state"){let h=u;(typeof u=="string"||typeof u=="number")&&(h={value:u,text:u}),a=_?{..._,state:h}:{state:h}}else _&&(a=Q(_,a));if(i&&!a.ignoreChildExtends)if(a.extends){const h=Array.isArray(a.extends)?a.extends:[a.extends],l=Array.isArray(i)?i:[i];a={...a,extends:[...l,...h]}}else a={extends:i,...a};const p=a?.key||`${e}`,d=K(a,t,p,n);d?.node&&o.appendChild(d.node)}t.node.appendChild(o);return}if(typeof c=="string"){const s=ct(c,t);if(Array.isArray(s)){J(t,s,n);return}}if(typeof c=="object")for(const s in c){if(N.has(s))continue;let o=c[s];if(!(o==null||o===!1)){if((typeof o=="string"||typeof o=="number")&&(o={text:o}),t.childProps&&(o=Q(t.childProps,o)),i&&!o.ignoreChildExtends)if(o.extends){const r=Array.isArray(o.extends)?o.extends:[o.extends],f=Array.isArray(i)?i:[i];o={...o,extends:[...f,...r]}}else o={extends:i,...o};K(o,t,s,n)}}}function et(t,c){let{children:n,content:i}=t;const s=t.childExtends;if(typeof n=="function"){const r=n;n=r(t,t.state,t.context),t.children=n;const f=t.__ref;let e=!1;const a=A(()=>{const u=r(t,t.state,t.context);if(!e){e=!0;return}if(u===t.children)return;if(t.children=u,Array.isArray(u)&&t.childrenAs==="state"){const d=t.childProps,h=[],l=new Map;for(let v=0;v<u.length;v++){const j=u[v];let x=d;if(typeof d=="function")try{x=d(t,j)}catch{x=null}const R=x&&x.key||j&&j.key||`${v}`;h.push(R),l.set(R,{rawChild:j,childProps:x})}const y=new Set(h),g=f.__children.slice();for(const v of g)if(!y.has(v)){const j=t[v];j?.remove&&j.remove(),delete t[v]}const b=t.childExtends,E=(t.context?.document||globalThis.document)?.createDocumentFragment();for(const v of h){const j=l.get(v),x=j.rawChild,R=t[v];if(R&&R.state){if(x&&typeof x=="object"){const $=R.state;if(typeof $.replace=="function")$.replace(x);else if(typeof $.update=="function"){for(const w in $)if(!(w==="__element"||w==="root"||w==="parent"||w==="update")&&!Object.prototype.hasOwnProperty.call(x,w))try{$[w]=void 0}catch{}$.update(x)}else for(const w in x)$[w]=x[w]}continue}let V=x;(typeof x=="string"||typeof x=="number")&&(V={value:x,text:x});const tt=j.childProps;let P=tt?{...tt,state:V}:{state:V};if(b&&!P.ignoreChildExtends)if(P.extends){const $=Array.isArray(P.extends)?P.extends:[P.extends],w=Array.isArray(b)?b:[b];P={...P,extends:[...w,...$]}}else P={extends:b,...P};const ot=K(P,t,v,c);ot?.node&&E&&E.appendChild(ot.node)}E&&E.childNodes.length&&t.node&&t.node.appendChild(E),f.__children=h;return}for(const d of[...f.__children]){const h=t[d];h?.remove&&h.remove(),delete t[d]}f.__children=[],J(t,u,c)},{depth:f.path.length});f.__effects.push(a)}if(J(t,n||i,c),n||i)return;const o=t.context?.components||{};{const r=Object.keys(t);for(let f=0;f<r.length;f++){const e=r[f];if(!e.endsWith("Extends")||typeof t[e]!="string")continue;const a=e.slice(0,-7);if(!a||a.charCodeAt(0)<65||a.charCodeAt(0)>90)continue;const u={extends:t[e]};delete t[e];for(let _=f+1;_<r.length;_++){const p=r[_],d=p.charCodeAt(0);if(d>=65&&d<=90||N.has(p)||typeof t[p]=="function"&&(p.startsWith("on")||p.startsWith(".")))break;const h=t[p];h!==void 0&&(u[p]=h,delete t[p])}t[a]&&typeof t[a]=="object"?t[a]={...u,...t[a]}:t[a]=u}}for(const r in t){if(!Object.prototype.hasOwnProperty.call(t,r)||N.has(r)||typeof t[r]!="object"||t[r]===null)continue;const f=r.charCodeAt(0);if(f<65||f>90)continue;let e=t[r];if(!e.__ref){if(!e.extends&&!e.extend){const a=o[r]||o[`smbls.${r}`];a&&(e={extends:a,...e})}if(t.childProps&&(e={...t.childProps,...e}),s&&!e.ignoreChildExtends)if(e.extends){const a=Array.isArray(e.extends)?e.extends:[e.extends],u=Array.isArray(s)?s:[s];e={...e,extends:[...u,...a]}}else e={extends:s,...e};K(e,t,r,c)}}}function m(t,c,n){const{node:i}=t;if(!i)return;const s=c?.node||(c?.nodeType?c:null);if(s)if(n?.position==="before"&&n.node)s.insertBefore(i,n.node);else if(n?.position==="after"&&n.node){const o=n.node.nextSibling;o?s.insertBefore(i,o):s.appendChild(i)}else s.appendChild(i)}function T(t,c,n){const i=t.charAt(0).toLowerCase()+t.slice(1);c.context?.plugins?.length&&G(i,c,n);const s="on"+t,o=c[s];if(typeof o=="function"){const r=c.context?.designSystem;r&&O(r);try{if(o(c,c.state,c.context,n)===!1)return!1}catch(f){if(c.context?.plugins?.length&&G("error",c,{hook:s,error:f})||console.error(`[DOMQL] Lifecycle "${s}" error:`,f),c.context?.strictMode)throw f}finally{r&&L()}}return!0}var Zt=K;export{K as create,Zt as default};
|
|
4
|
+
`):"")}}if(tt(o,c,s),c&&(c[o.key]=o,c.__ref?.__children&&(c.__ref.__children.includes(o.key)||c.__ref.__children.push(o.key))),typeof o.html=="function"&&o.node&&!o.node.innerHTML){const l=o.context?.designSystem;l&&O(l);try{const y=o.html(o,o.state,o.context);y!=null&&typeof y!="function"&&(o.node.innerHTML=y)}catch{}finally{l&&L()}}if(N("Create",o,i),N("Complete",o,i),N("Render",o,i),N("RenderRouter",o,i),typeof o.onFrame=="function"){const l=o.onFrame,y=o.context?.designSystem,g=()=>{if(o.node){if(o.node.isConnected){y&&O(y);try{l(o,o.state,o.context)}catch(b){console.error("[DOMQL] onFrame error:",b)}finally{y&&L()}}requestAnimationFrame(g)}};requestAnimationFrame(g)}return o}function xt(t,c,n){const i=!c,s=n.state&&typeof n.state=="object"&&!Array.isArray(n.state)&&Object.keys(n.state).length===0,o=i&&s&&t.context?.state,e=n.state!==void 0&&!o?n.state:t.state&&!D(t.state)?t.state:void 0;if(e==null){if(c?.state)t.state=c.state,I(t,t.state);else if(t.context?.state){const f=t.context.state,r={...f},a=t.context?.polyglot;if(a?.translations){const u=f.lang||a.defaultLang||"en",_=a.translations[u];if(_&&typeof _=="object")for(const d in _)r[d]===void 0&&(r[d]=_[d]);const p=new Set(a.languages||[]);for(const d in a.translations)!p.has(d)&&r[d]===void 0&&(r[d]=a.translations[d])}t.state=D(r)?r:W(r),t.state.__element=t,t.state.root=t.state,I(t,t.state)}else t.state={},Object.defineProperty(t.state,"root",{value:t.state,enumerable:!1,configurable:!0,writable:!0}),I(t,t.state);return}if(typeof e=="string"){if(t.state=nt(e,c),t.state&&typeof t.state=="object"&&!D(t.state)){const f=c?.state?.root||c?.state||t.state;Object.defineProperty(t.state,"root",{value:f,enumerable:!1,configurable:!0,writable:!0})}I(t,t.state);return}if(typeof e=="function"){const f=e(t,c?.state);t.state=W(f||{})}else t.state=W({...e});t.state.__element=t,c?.state?(t.state.parent=c.state,t.state.root=c.state.root||c.state):t.state.root=t.state,I(t,t.state)}function z(t,c){if(!c)return t;const n=c.split("/");let i=t;for(const s of n){if(i==null)return{};i=i[s]}return i??{}}function nt(t,c){if(!c)return{};if(t===".")return c.state||{};if(t.startsWith("../")){const s=t.slice(3);return s?z(c.state,s):c.state??{}}if(t.startsWith("~/")){const s=c.state?.root||c.state,o=t.slice(2);return o?z(s,o):s??{}}if(c.state?.[t]!==void 0)return c.state[t];const n=z(c.state,t);if(n!=null&&Object.keys(n).length>0)return n;const i=c.context?.polyglot;if(i?.translations){const s=c.state?.root?.lang||i.defaultLang||"en",o=i.translations[s];if(o?.[t]!==void 0)return o[t];if(i.translations[t]!==void 0)return i.translations[t]}return{}}function At(t){const c=t.__ref,n=t.tag||"div",i=t.context?.designSystem,s=[],o=Object.keys(t);for(let e=0;e<o.length;e++){const f=o[e];if(typeof t[f]!="function"||R.has(f))continue;const r=f.charCodeAt(0);r>=65&&r<=90||M(f)||C[f]||k&&k.has(f)||U(n,f)||s.push({prop:f,fn:t[f]})}for(let e=0;e<s.length;e++){const{prop:f,fn:r}=s[e];c.__exec[f]=r,Object.defineProperty(t,f,{get(){i&&O(i);try{return r(t,t.state,t.context)}catch{return}finally{i&&L()}},set(a){delete c.__exec[f],Object.defineProperty(t,f,{value:a,writable:!0,configurable:!0,enumerable:!0})},configurable:!0,enumerable:!0})}}function B(t,c){const n=t.__ref;if(At(t),typeof t.text=="function"){const s=t.text,o=A(()=>{if(!n.contentManaged)try{let e=s(t,t.state,t.context);t.node&&e!=null&&typeof e!="function"&&typeof e!="object"&&(typeof e=="string"&&e.includes("{{")&&(e=Y.call(t,e,t.state)),t.tag==="string"?t.node.nodeValue=e:t.node.textContent=e)}catch{}},{depth:n.path.length});n.__effects.push(o),n.__exec.text=s}else if(typeof t.text=="string"&&t.text.includes("{{")){const s=t.text,o=A(()=>{if(n.contentManaged)return;const e=Y.call(t,s,t.state);e!=null&&(t.text=e),t.node&&(t.tag==="string"?t.node.nodeValue=e??"":t.node.textContent=e??"")},{depth:n.path.length});n.__effects.push(o),n.__exec.text=s}for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)&&typeof t[s]=="function"&&!R.has(s)&&!M(s)&&!n.__exec[s]){if(C[s]){const o=t[s],e=s,f=A(()=>{const r=t.context?.designSystem;r&&O(r);try{const a=o(t,t.state,t.context),u=C[e](a,t,t.state,t.context);u&&t.node?K(t.node,u):t.node&&(e==="show"||e==="hide")&&(t.node.style.display="")}finally{r&&L()}},{depth:n.path.length});n.__effects.push(f),n.__exec[s]=o}else if(k&&k.has(s)){const o=t[s],e=s,f=A(()=>{const r=t.context?.designSystem;r&&O(r);try{const a=o(t,t.state,t.context);t.node&&(a!=null?K(t.node,{[e]:a}):t.node.style[e]="")}finally{r&&L()}},{depth:n.path.length});n.__effects.push(f),n.__exec[s]=o}}if(typeof c.html=="function"){const s=c.html,o=A(()=>{const e=t.context?.designSystem;e&&O(e);try{const f=s(t,t.state,t.context);t.node&&f!=null&&typeof f!="function"&&(t.node.innerHTML=f)}finally{e&&L()}},{depth:n.path.length});n.__effects.push(o),n.__exec.html=s}if(typeof c.value=="function"){const s=c.value,o=A(()=>{try{const e=s(t,t.state,t.context);if(!t.node||!("value"in t.node))return;const f=e==null?"":String(e);if(t.node.value===f)return;const r=typeof document<"u"&&document.activeElement===t.node,a=r&&typeof t.node.selectionStart=="number"?t.node.selectionStart:null,u=r&&typeof t.node.selectionEnd=="number"?t.node.selectionEnd:null;if(t.node.value=f,r&&a!=null&&u!=null)try{t.node.setSelectionRange(a,u)}catch{}}catch{}},{depth:n.path.length});n.__effects.push(o),n.__exec.value=s}if(typeof c.style=="function"){const s=c.style,o=A(()=>{const e=s(t,t.state,t.context);K(t.node,e)},{depth:n.path.length});n.__effects.push(o),n.__exec.style=s}else if(t.style&&typeof t.style=="object")for(const s in t.style){const o=t.style[s];if(typeof o!="function")continue;const e=A(()=>{try{const f=o(t,t.state,t.context);t.node&&K(t.node,{[s]:f})}catch{}},{depth:n.path.length});n.__effects.push(e)}if(t.attr&&typeof t.attr=="object"){for(const s in t.attr)if(typeof t.attr[s]=="function"){const o=t.attr[s],e=s,f=A(()=>{try{const r=o(t,t.state,t.context);t.node?.setAttribute&&(r==null||r===!1?t.node.removeAttribute(e):typeof r!="function"&&typeof r!="object"&&t.node.setAttribute(e,r===!0?"":r))}catch{}},{depth:n.path.length});n.__effects.push(f)}}if(t.aria&&typeof t.aria=="object")for(const s in t.aria){const o=t.aria[s];if(typeof o!="function")continue;const e="aria-"+s.replace(/[A-Z]/g,r=>"-"+r.toLowerCase()),f=A(()=>{try{const r=o(t,t.state,t.context);if(!t.node?.setAttribute)return;r==null||r===!1?t.node.removeAttribute(e):typeof r!="function"&&typeof r!="object"&&t.node.setAttribute(e,r===!0?"":r)}catch{}},{depth:n.path.length});n.__effects.push(f)}if(t.data&&typeof t.data=="object")for(const s in t.data){const o=t.data[s];if(typeof o!="function")continue;const f="data-"+s.replace(/[A-Z]/g,a=>"-"+a.toLowerCase()),r=A(()=>{try{const a=o(t,t.state,t.context);if(!t.node?.setAttribute)return;a==null||a===!1?t.node.removeAttribute(f):typeof a!="function"&&typeof a!="object"&&t.node.setAttribute(f,a===!0?"":a)}catch{}},{depth:n.path.length});n.__effects.push(r)}const i=t.classlist&&typeof t.classlist=="object"&&!Array.isArray(t.classlist)?t.classlist:t.class&&typeof t.class=="object"&&!Array.isArray(t.class)?t.class:null;if(i)for(const s in i){const o=i[s];if(typeof o!="function")continue;const e=A(()=>{try{const f=o(t,t.state,t.context);if(!t.node?.classList)return;typeof f=="string"?t.node.classList.add(f):f?t.node.classList.add(s):t.node.classList.remove(s)}catch{}},{depth:n.path.length});n.__effects.push(e)}if(typeof c.if=="function"){const s=c.if,o=A(()=>{let e;try{e=s(t,t.state,t.context)}catch(r){if(e=!1,n.__ifError=r,typeof console<"u"&&console.warn){const a=t.key||t.tag||"?";console.warn(`[smbls] \`if:\` reactive effect threw on ${a} \u2014 treating as false:`,r?.message||r)}return}const f=n.__if;if(n.__if=!!e,f&&!n.__if&&t.node)t.node.remove();else if(!f&&n.__if)if(n.__ifInitialized){t.node||(t.node=H(t));const r=t.parent,a=r?.node;if(a&&t.node){let u=null;const _=Object.keys(r),p=_.indexOf(t.key);for(let d=p+1;d<_.length;d++){const h=r[_[d]];if(h?.node?.parentNode===a){u=h.node;break}}u?a.insertBefore(t.node,u):a.appendChild(t.node)}else tt(t,t.parent);q(t)}else{if(n.__ifInitialized=!0,t.tag||(t.tag=ct(t)),N("Init",t,{}),t.node||(t.node=H(t)),!t.node)return;N("AttachNode",t,{}),t.node.setAttribute&&t.key&&t.node.setAttribute("data-key",t.key),t.id&&t.node.setAttribute&&(t.node.id=t.id),et(t,{});const r=c.if;delete c.if;try{B(t,c)}finally{c.if=r}q(t),rt(t),ft(t,{}),tt(t,t.parent)}},{depth:n.path.length});n.__effects.push(o)}for(const s in t){if(!Object.prototype.hasOwnProperty.call(t,s)||R.has(s)||typeof t[s]!="function")continue;const o=s.charCodeAt(0);if(o>=65&&o<=90||M(s))continue;const e=t[s];n.__exec[s]=e;const f=t.tag||"div";if(U(f,s)&&!C[s]&&!(k&&k.has(s))){const r=s,a=A(()=>{try{const u=e(t,t.state,t.context);t.node?.setAttribute&&(u==null||u===!1?t.node.removeAttribute(r):typeof u!="function"&&typeof u!="object"&&(r==="src"&&"src"in t.node?t.node.src=u:t.node.setAttribute(r,u===!0?"":u)))}catch{}},{depth:n.path.length});n.__effects.push(a)}}Ct(t),kt(t)}function q(t){const{node:c}=t;if(c){if(typeof t.text=="string"&&!t.text.includes("{{")?t.tag==="string"?c.nodeValue=t.text:c.textContent=t.text:typeof t.text=="number"&&(c.textContent=t.text),wt(t),typeof t.html=="string"&&(c.innerHTML=t.html),t.value!=null&&typeof t.value!="function"&&"value"in c){const n=String(t.value);c.value!==n&&(c.value=n)}if(t.style&&typeof t.style=="object"&&K(c,t.style),t.attr&&typeof t.attr=="object")for(const n in t.attr){const i=t.attr[n];typeof i=="function"||typeof i=="object"||i==null||i===!1||c.setAttribute&&c.setAttribute(n,i===!0?"":i)}if(t.data&&typeof t.data=="object")for(const n in t.data){const i=t.data[n];typeof i=="function"||typeof i=="object"||i==null||i===!1||c.dataset&&(c.dataset[n]=i===!0?"":i)}if(t.classlist||t.class){const n=t.classlist||t.class;if(typeof n=="string")n.split(" ").forEach(i=>i&&c.classList.add(i));else if(typeof n=="object")for(const i in n){const s=typeof n[i]=="function"?n[i](t,t.state,t.context):n[i];s&&c.classList.add(typeof s=="string"?s:i)}}}}function K(t,c){if(!t||!c||!t.style)return;let n=null;for(const i in c){const s=c[i];if(s!=null){if(i.charAt(0)==="&"&&typeof s=="object"){n||(n={}),n[i]=s;continue}try{const o=String(s),e=i.replace(/[A-Z]/g,u=>"-"+u.toLowerCase()),f=o.trim(),r=/\s*!important\s*$/.test(f),a=f.replace(/\s*!important\s*$/,"");t.style.setProperty(e,a,r?"important":"")}catch{}}}n&&jt(t,n)}let vt=0;function jt(t,c){const n=`_ds${vt++}`;t.classList.add(n);const i=t.ownerDocument;let s=i.querySelector("style[data-smbls-scoped]");s||(s=i.createElement("style"),s.setAttribute("data-smbls-scoped",""),i.head.appendChild(s));let o="";for(const e in c){const f="."+n,r=e.replace(/&/g,f).split(",").map(u=>{const _=u.trim();return _.includes(f)?_:f+_}).join(", "),a=c[e];if(typeof a=="object"){let u="",_="";for(const p in a){const d=a[p];if(typeof d=="object"){const h=p.includes("&")?r.split(", ").map(y=>p.replace(/&/g,y)).join(", "):r.split(", ").map(y=>`${y} ${p}`).join(", ");let l="";for(const y in d)l+=`${y.replace(/[A-Z]/g,g=>"-"+g.toLowerCase())}: ${d[y]};`;_+=`${h} { ${l} }
|
|
5
|
+
`}else u+=`${p.replace(/[A-Z]/g,h=>"-"+h.toLowerCase())}: ${d};`}u&&(o+=`${r} { ${u} }
|
|
6
|
+
`),_&&(o+=_)}}o&&(s.textContent+=o)}function Ct(t){const c=t.subscribeTo;if(!Array.isArray(c)||c.length===0)return;const n=t.__ref;for(let i=0;i<c.length;i++){const s=c[i];if(typeof s!="string"||s.length===0)continue;const o=s.split("."),e=o[0],f=o.slice(1),r={value:!1},a=A(()=>{const u=t.state&&(D(t.state)?t.state.root:null);if(!u||!D(u))return;let _=u;_=_[e];for(let p=0;p<f.length&&!(_==null||typeof _!="object");p++)if(D(_))_=_[f[p]];else break;if(r.value&&typeof t.onUpdate=="function"){const p=t.context?.designSystem;p&&O(p);try{t.onUpdate(t,t.state,t.context)}catch(d){t.context?.plugins?.length&&G("error",t,{hook:"onUpdate",error:d})||console.error("[DOMQL] subscribeTo onUpdate error:",d)}finally{p&&L()}}},{depth:n.path.length});r.value=!0,n.__effects.push(a)}}function kt(t){const c=t.__ref;c.__conditionalRunners=[];for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;const i=n.charAt(0);if(i!=="."&&i!=="!")continue;const s=n.slice(1);if(!s)continue;const o=t[n];if(!o||typeof o!="object")continue;const e=i==="!",f={lastMatch:!1,appliedKeys:null},r=()=>{if(!t.node)return;let u;const _=t[s];if(_===void 0)if(t.state&&s in t.state)u=t.state[s];else{const h=t.context?.cases?.[s];if(h===void 0)return;try{u=typeof h=="function"?h.call(t,t):h}catch(l){u=!1,c.__conditionalError=l,typeof console<"u"&&console.warn&&console.warn(`[smbls] conditional \`${n}\` case fn threw on ${t.key||"?"} \u2014 treating as false:`,l?.message||l)}}else if(typeof _=="function")try{u=_(t,t.state,t.context)}catch(h){u=!1,c.__conditionalError=h,typeof console<"u"&&console.warn&&console.warn(`[smbls] conditional \`${n}\` predicate threw on ${t.key||"?"} \u2014 treating as false:`,h?.message||h)}else u=_;const p=e?!u:!!u;if(p===f.lastMatch)return;f.lastMatch=p;const d=t.context?.designSystem;d&&O(d);try{if(p){const h={};for(const y in o){if(!Object.prototype.hasOwnProperty.call(o,y))continue;const g=typeof o[y]=="function"?o[y](t,t.state,t.context):o[y];if(g!=null)if(C[y]){const b=C[y](g,t,t.state,t.context);if(b){const S=Array.isArray(b)?b:[b];for(const E of S)E&&Object.assign(h,E)}}else k&&k.has(y)&&(h[y]=g)}const l=Object.keys(h);l.length?(K(t.node,h),f.appliedKeys=l):f.appliedKeys=null}else if(f.appliedKeys){for(const h of f.appliedKeys)t.node.style[h]="";f.appliedKeys=null}}finally{d&&L()}};c.__conditionalRunners.push(r);const a=A(r,{depth:c.path.length});c.__effects.push(a)}}const X=new WeakSet;function St(t){const c=t.ownerDocument;!c||X.has(c)||(X.add(c),queueMicrotask(()=>{X.delete(c);const n=c.body||c.documentElement;n&&n.offsetWidth}))}const Q=new WeakSet;function wt(t){const{node:c}=t;if(!c)return;if(Q.has(t)){console.error("[applyCssInProps] re-entry detected for element",t.key,"prop path:",t.__ref?.path);return}Q.add(t);const n=t.context?.designSystem;n&&O(n);try{const i={};let s=!1;for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o)||typeof t[o]=="function"||R.has(o))continue;const e=o.charCodeAt(0);if(!(e>=65&&e<=90)&&!M(o)){if(C[o]){const f=t[o],r=C[o](f,t,t.state,t.context);if(r){if(Array.isArray(r))for(const a of r)a&&Object.assign(i,a);else Object.assign(i,r);s=!0}}else if(k&&k.has(o)){const f=t[o];f!=null&&typeof f!="object"&&(i[o]=f,s=!0)}else if(o.charCodeAt(0)===45){const f=t[o];f!=null&&typeof f!="object"&&(i[o]=f,s=!0)}else if(o.charAt(0)==="&"){const f=t[o];f&&typeof f=="object"&&(i[o]=f,s=!0)}else if(o.charAt(0)==="@"||o.charAt(0)===":"){const f=t[o];if(f&&typeof f=="object"){const r={};for(const a in f){let u=f[a];if(typeof u=="function"&&(u=u(t,t.state,t.context)),!(u==null||typeof u=="function"))if(C[a]){const _=C[a](u,t,t.state,t.context);if(_)if(Array.isArray(_))for(const p of _)p&&Object.assign(r,p);else Object.assign(r,_)}else r[a]=u}if(Object.keys(r).length){if(o.length>1&&o.charAt(0)==="@"&&!o.startsWith("@media")&&!o.startsWith("@keyframes")&&!o.startsWith("@supports")&&(o==="@dark"||o==="@light"||!t.context?.designSystem?.media?.[o.slice(1)])){const u={};for(const p in r){const d=r[p];u[p]=typeof d=="string"&&!d.includes("!important")?d+" !important":d}const _=o.slice(1);i[`[data-theme="${_}"] &`]=u}else{let u=o;if(o.charAt(0)==="@"&&!o.startsWith("@media")&&!o.startsWith("@keyframes")){const p=o.slice(1),d=t.context?.designSystem?.media?.[p]||t.context?.designSystem?.media?.[p];d&&(u=`@media ${d}`)}const _={};for(const p in r){const d=r[p];if(d&&typeof d=="object"&&!Array.isArray(d)){const h={};for(const y in d)if(C[y]){const g=C[y](d[y],t,t.state,t.context);if(g)if(Array.isArray(g))for(const b of g)b&&Object.assign(h,b);else Object.assign(h,g)}else h[y]=d[y];const l=p.startsWith(":")?"":" ";if(u.includes(",")){const y=u.split(",").map(g=>`${g.trim()}${l}${p}`).join(", ");i[y]=h}else i[`${u}${l}${p}`]=h}else _[p]=d}Object.keys(_).length&&(i[u]=_)}s=!0}s=!0}}}}if(s){i.display&&String(i.display).includes("!important")&&(c.style.setProperty("display",String(i.display).replace(/\s*!important\s*$/,""),"important"),delete i.display);const o=lt(i,null,t.context?.cssPrefix);if(o&&c.classList){const f=o.split(" ").filter(Boolean);let r=!1;for(const a of f)c.classList.add(a),r||(a.charCodeAt(0)===95&&a.charCodeAt(1)===99||a.charCodeAt(0)===95&&a.indexOf("_c",1)!==-1)&&(r=!0);r&&St(c)}const e=t.display!=null&&typeof t.display!="function"?t.display:t.hide===!0||t.show===!1?"none":null;if(e!=null){const f=i.display;if(f&&f!==e)if(e==="none"){const r=[];for(const a of c.classList)a.startsWith("_d-")&&a!=="_d-none"&&r.push(a);for(const a of r)c.classList.remove(a);c.classList.add("_d-none")}else c.style.display=t.display}}}finally{n&&L(),Q.delete(t)}}function rt(t){const{node:c}=t;if(!c||!c.setAttribute)return;if(t.aria&&typeof t.aria=="object")for(const s in t.aria){const o=t.aria[s];if(typeof o=="function"||typeof o=="object"||o==null||o===!1)continue;const e="aria-"+s.replace(/[A-Z]/g,f=>"-"+f.toLowerCase());c.setAttribute(e,o===!0?"":o)}const n=ht(t);for(const s in n){const o=n[s];o!=null&&o!==!1&&typeof o!="function"&&typeof o!="object"&&c.setAttribute(s,o===!0?"":o)}const i=t.tag||"div";for(const s in t){if(!Object.prototype.hasOwnProperty.call(t,s)||typeof t[s]=="function"||R.has(s)||s==="on"||n[s]!==void 0)continue;const o=s.charCodeAt(0);if(!(o>=65&&o<=90)&&!M(s)&&!(C[s]||k&&k.has(s))&&U(i,s)){let e=t[s];if(e==null||e===!1||(typeof e=="string"&&e.includes("{{")&&(e=Y(e,t,t.state,t.context),t[s]=e),e==null||e===!1||typeof e=="function"||typeof e=="object"))continue;c.setAttribute(s,e===!0?"":e)}}}function Et(t){if(!t.autoGrow)return;const c=t.node;if(!c||c.tagName!=="TEXTAREA")return;const n=t.autoGrow,i=n&&typeof n=="object"&&n.max?String(n.max):null;i&&(c.style.maxHeight=i);const s=()=>{c.style.height="auto",c.style.height=c.scrollHeight+"px"};s(),c.addEventListener("input",s),t.__ref.__eventCleanup||(t.__ref.__eventCleanup=[]),t.__ref.__eventCleanup.push(()=>{try{c.removeEventListener("input",s)}catch{}})}const it=new Set(["onSwipe","onSwipeLeft","onSwipeRight","onSwipeUp","onSwipeDown"]);function et(t,c){for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n)||!M(n)||it.has(n))continue;let i=t[n];if(typeof i=="string"&&/^[A-Za-z_$][\w$]*$/.test(i)){const o=i;i=function(f){return t.call(o,f)}}if(typeof i!="function")continue;const s=gt(n);ut.has(s)||dt(bt(s),t,i)}Pt(t)}function Pt(t){const c=t.node;if(!c||!c.addEventListener)return;const n={};let i=!1;for(const p of it){const d=t[p];typeof d=="function"&&(n[p]=d,i=!0)}if(!i)return;const s=typeof t.swipeThreshold=="number"?t.swipeThreshold:40,o=typeof t.swipeMaxDuration=="number"?t.swipeMaxDuration:600;let e=0,f=0,r=0,a=!1;const u=p=>{const d=p.touches&&p.touches[0]||p.changedTouches&&p.changedTouches[0];d&&(e=d.clientX,f=d.clientY,r=Date.now(),a=!0)},_=p=>{if(!a)return;a=!1;const d=p.changedTouches&&p.changedTouches[0]||p.touches&&p.touches[0];if(!d)return;const h=d.clientX-e,l=d.clientY-f,y=Date.now()-r;if(y>o)return;const g=Math.abs(h),b=Math.abs(l);if(Math.max(g,b)<s)return;let S;if(g>b*1.2)S=h<0?"left":"right";else if(b>g*1.2)S=l<0?"up":"down";else return;const E="onSwipe"+S.charAt(0).toUpperCase()+S.slice(1),v=n[E],j=n.onSwipe;v&&v.call(t,p,t,t.state,t.context),j&&j.call(t,{direction:S,dx:h,dy:l,dt:y,event:p},t,t.state,t.context)};c.addEventListener("touchstart",u,{passive:!0}),c.addEventListener("touchend",_,{passive:!0}),t.__ref.__eventCleanup||(t.__ref.__eventCleanup=[]),t.__ref.__eventCleanup.push(()=>{try{c.removeEventListener("touchstart",u)}catch{}try{c.removeEventListener("touchend",_)}catch{}})}function J(t,c){const n={...t};for(const i in c){const s=n[i],o=c[i];s&&o&&typeof s=="object"&&typeof o=="object"&&!Array.isArray(s)&&!Array.isArray(o)&&typeof s!="function"&&typeof o!="function"?n[i]=J(s,o):n[i]=o}return n}function m(t,c,n){if(!c||!t.node)return;const i=t.childExtends;if(Array.isArray(c)){const o=(t.context?.document||globalThis.document)?.createDocumentFragment();if(!o)return;const e=t.childProps,f=t.childrenAs;for(let r=0;r<c.length;r++){let a=c[r];const u=a;(typeof a=="string"||typeof a=="number")&&(a={text:a});let _=e;if(typeof e=="function")try{_=e(t,a)}catch{_=null}if(f==="state"){let h=u;(typeof u=="string"||typeof u=="number")&&(h={value:u,text:u}),a=_?{..._,state:h}:{state:h}}else _&&(a=J(_,a));if(i&&!a.ignoreChildExtends)if(a.extends){const h=Array.isArray(a.extends)?a.extends:[a.extends],l=Array.isArray(i)?i:[i];a={...a,extends:[...l,...h]}}else a={extends:i,...a};const p=a?.key||`${r}`,d=F(a,t,p,n);d?.node&&o.appendChild(d.node)}t.node.appendChild(o);return}if(typeof c=="string"){const s=nt(c,t);if(Array.isArray(s)){m(t,s,n);return}}if(typeof c=="object")for(const s in c){if(R.has(s))continue;let o=c[s];if(!(o==null||o===!1)){if((typeof o=="string"||typeof o=="number")&&(o={text:o}),t.childProps&&(o=J(t.childProps,o)),i&&!o.ignoreChildExtends)if(o.extends){const e=Array.isArray(o.extends)?o.extends:[o.extends],f=Array.isArray(i)?i:[i];o={...o,extends:[...f,...e]}}else o={extends:i,...o};F(o,t,s,n)}}}function ft(t,c){let{children:n,content:i}=t;const s=t.childExtends;if(typeof n=="function"){const e=n;n=e(t,t.state,t.context),t.children=n;const f=t.__ref;let r=!1;const a=A(()=>{const u=e(t,t.state,t.context);if(!r){r=!0;return}if(u===t.children)return;if(t.children=u,Array.isArray(u)&&t.childrenAs==="state"){const d=t.childProps,h=[],l=new Map;for(let v=0;v<u.length;v++){const j=u[v];let x=d;if(typeof d=="function")try{x=d(t,j)}catch{x=null}const T=x&&x.key||j&&j.key||`${v}`;h.push(T),l.set(T,{rawChild:j,childProps:x})}const y=new Set(h),g=f.__children.slice();for(const v of g)if(!y.has(v)){const j=t[v];j?.remove&&j.remove(),delete t[v]}const b=t.childExtends,E=(t.context?.document||globalThis.document)?.createDocumentFragment();for(const v of h){const j=l.get(v),x=j.rawChild,T=t[v];if(T&&T.state){if(x&&typeof x=="object"){const $=T.state;if(typeof $.replace=="function")$.replace(x);else if(typeof $.update=="function"){for(const w in $)if(!(w==="__element"||w==="root"||w==="parent"||w==="update")&&!Object.prototype.hasOwnProperty.call(x,w))try{$[w]=void 0}catch{}$.update(x)}else for(const w in x)$[w]=x[w]}continue}let V=x;(typeof x=="string"||typeof x=="number")&&(V={value:x,text:x});const ot=j.childProps;let P=ot?{...ot,state:V}:{state:V};if(b&&!P.ignoreChildExtends)if(P.extends){const $=Array.isArray(P.extends)?P.extends:[P.extends],w=Array.isArray(b)?b:[b];P={...P,extends:[...w,...$]}}else P={extends:b,...P};const st=F(P,t,v,c);st?.node&&E&&E.appendChild(st.node)}E&&E.childNodes.length&&t.node&&t.node.appendChild(E),f.__children=h;return}for(const d of[...f.__children]){const h=t[d];h?.remove&&h.remove(),delete t[d]}f.__children=[],m(t,u,c)},{depth:f.path.length});f.__effects.push(a)}if(m(t,n||i,c),n||i)return;const o=t.context?.components||{};{const e=Object.keys(t);for(let f=0;f<e.length;f++){const r=e[f];if(!r.endsWith("Extends")||typeof t[r]!="string")continue;const a=r.slice(0,-7);if(!a||a.charCodeAt(0)<65||a.charCodeAt(0)>90)continue;const u={extends:t[r]};delete t[r];for(let _=f+1;_<e.length;_++){const p=e[_],d=p.charCodeAt(0);if(d>=65&&d<=90||R.has(p)||typeof t[p]=="function"&&(p.startsWith("on")||p.startsWith(".")))break;const h=t[p];h!==void 0&&(u[p]=h,delete t[p])}t[a]&&typeof t[a]=="object"?t[a]={...u,...t[a]}:t[a]=u}}for(const e in t){if(!Object.prototype.hasOwnProperty.call(t,e)||R.has(e)||typeof t[e]!="object"||t[e]===null)continue;const f=e.charCodeAt(0);if(f<65||f>90)continue;let r=t[e];if(!r.__ref){if(!r.extends&&!r.extend){const a=o[e]||o[`smbls.${e}`];a&&(r={extends:a,...r})}if(t.childProps&&(r={...t.childProps,...r}),s&&!r.ignoreChildExtends)if(r.extends){const a=Array.isArray(r.extends)?r.extends:[r.extends],u=Array.isArray(s)?s:[s];r={...r,extends:[...u,...a]}}else r={extends:s,...r};F(r,t,e,c)}}}function tt(t,c,n){const{node:i}=t;if(!i)return;const s=c?.node||(c?.nodeType?c:null);if(s)if(n?.position==="before"&&n.node)s.insertBefore(i,n.node);else if(n?.position==="after"&&n.node){const o=n.node.nextSibling;o?s.insertBefore(i,o):s.appendChild(i)}else s.appendChild(i)}function N(t,c,n){const i=t.charAt(0).toLowerCase()+t.slice(1);c.context?.plugins?.length&&G(i,c,n);const s="on"+t,o=c[s];if(typeof o=="function"){const e=t==="Render"||t==="RenderRouter";if(e){if(c.__ref.__inRender)return!0;c.__ref.__inRender=!0}const f=c.context?.designSystem;f&&O(f);try{if(o(c,c.state,c.context,n)===!1)return!1}catch(r){if(c.context?.plugins?.length&&G("error",c,{hook:s,error:r})||console.error(`[DOMQL] Lifecycle "${s}" error:`,r),c.context?.strictMode)throw r}finally{f&&L(),e&&(c.__ref.__inRender=!1)}}return!0}var Bt=F;export{F as create,Bt as default};
|