@symbo.ls/utils 3.14.773 → 3.14.775

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.
@@ -1 +1 @@
1
- "use strict";var u=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var a=(t,n)=>{for(var o in n)u(t,o,{get:n[o],enumerable:!0})},g=(t,n,o,e)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of p(n))!f.call(t,r)&&r!==o&&u(t,r,{get:()=>n[r],enumerable:!(e=l(n,r))||e.enumerable});return t};var x=t=>g(u({},"__esModule",{value:!0}),t);var F={};a(F,{cloneFunction:()=>b,debounce:()=>y,debounceOnContext:()=>d,hasHandlerPlugin:()=>v,isStringFunction:()=>T,memoize:()=>m,resolveHandler:()=>w,runPluginHook:()=>O});module.exports=x(F);function y(t,n,o){let e;return function(){const r=this,s=arguments,c=function(){e=null,o||t.apply(r,s)},i=o&&!e;clearTimeout(e),e=setTimeout(c,n),i&&t.apply(r,s)}}const d=(t,n,o=300)=>{let e;return(...r)=>{clearTimeout(e),e=setTimeout(()=>{n.apply(t,r)},o)}},m=t=>{const n={};return(...o)=>{const e=o[0];if(e in n)return n[e];{const r=t(e);return n[e]=r,r}}},H=/^((function\s*\([^)]*\)\s*\{[^}]*\})|(\([^)]*\)\s*=>))/,T=t=>H.test(t),v=t=>{const n=t?.plugins;if(!n||!n.length)return!1;for(const o of n)if(o.resolveHandler)return!0;return!1},w=(t,n)=>{if(typeof t=="function")return t;const o=n?.context?.plugins;if(!o)return t;for(const e of o)if(e.resolveHandler){const r=e.resolveHandler(t,n);if(typeof r=="function")return r}return t},O=(t,n,...o)=>{const e=n?.context?.plugins;if(!e)return!1;let r=!1;for(const s of e)typeof s[t]=="function"&&(s[t](n,...o),r=!0);return r};function b(t,n=window){const o=function(){return t.apply(n,arguments)};for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&(o[e]=t[e]);return o}
1
+ "use strict";var u=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var a=(t,n)=>{for(var o in n)u(t,o,{get:n[o],enumerable:!0})},g=(t,n,o,e)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of p(n))!f.call(t,r)&&r!==o&&u(t,r,{get:()=>n[r],enumerable:!(e=l(n,r))||e.enumerable});return t};var x=t=>g(u({},"__esModule",{value:!0}),t);var F={};a(F,{cloneFunction:()=>O,debounce:()=>y,debounceOnContext:()=>d,hasHandlerPlugin:()=>v,isStringFunction:()=>T,memoize:()=>m,resolveHandler:()=>w,runPluginHook:()=>b});module.exports=x(F);function y(t,n,o){let e;return function(){const r=this,s=arguments,c=function(){e=null,o||t.apply(r,s)},i=o&&!e;clearTimeout(e),e=setTimeout(c,n),i&&t.apply(r,s)}}const d=(t,n,o=300)=>{let e;return(...r)=>{clearTimeout(e),e=setTimeout(()=>{n.apply(t,r)},o)}},m=t=>{const n={};return(...o)=>{const e=o[0];if(e in n)return n[e];{const r=t(e);return n[e]=r,r}}},H=/^\s*(?:async\s+)?(?:function\b|\([^)]*\)\s*=>|[a-zA-Z_$][\w$]*\s*=>)/,T=t=>H.test(t),v=t=>{const n=t?.plugins;if(!n||!n.length)return!1;for(const o of n)if(o.resolveHandler)return!0;return!1},w=(t,n)=>{if(typeof t=="function")return t;const o=n?.context?.plugins;if(!o)return t;for(const e of o)if(e.resolveHandler){const r=e.resolveHandler(t,n);if(typeof r=="function")return r}return t},b=(t,n,...o)=>{const e=n?.context?.plugins;if(!e)return!1;let r=!1;for(const s of e)typeof s[t]=="function"&&(s[t](n,...o),r=!0);return r};function O(t,n=window){const o=function(){return t.apply(n,arguments)};for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&(o[e]=t[e]);return o}
@@ -1,2 +1,2 @@
1
- "use strict";var A=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var W=(i,r)=>{for(var t in r)A(i,t,{get:r[t],enumerable:!0})},T=(i,r,t,e)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of O(r))!E.call(i,s)&&s!==t&&A(i,s,{get:()=>r[s],enumerable:!(e=L(r,s))||e.enumerable});return i};var x=i=>T(A({},"__esModule",{value:!0}),i);var C={};W(C,{generateHeadArrayTags:()=>w,generateMetaTags:()=>_,getPageMetadata:()=>P,hashContent:()=>b});module.exports=x(C);var M=require("./types.js");const a=i=>{if(i==null)return"";const r={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};return i.toString().replace(/[&<>"']/g,t=>r[t])},D=i=>Object.entries(i||{}).filter(([r,t])=>t!==void 0).map(([r,t])=>`${r}="${a(t)}"`).join(" "),b=i=>{let r=5381;const t=String(i);for(let e=0;e<t.length;e++)r=(r*33^t.charCodeAt(e))>>>0;return r.toString(36)},R=new Set(["jsonLd","styles","scripts"]),w=i=>{const r=[];if(Array.isArray(i.jsonLd))for(const t of i.jsonLd){if(t==null)continue;const e=typeof t=="string"?t:JSON.stringify(t),s=String(e).replace(/<\/script/gi,"<\\/script");r.push(`<script type="application/ld+json" data-smbls-jsonld="${b(e)}">${s}<\/script>`)}if(Array.isArray(i.styles))for(const t of i.styles){if(t==null||!String(t).trim())continue;const e=String(t).replace(/<\/style/gi,"<\\/style");r.push(`<style data-smbls-style="${b(e)}">${e}</style>`)}if(Array.isArray(i.scripts))for(const t of i.scripts){if(!t)continue;const e=typeof t=="string",s=e?t:t.src;if(!s&&!t.body)continue;const o=[];s&&o.push(`src="${a(s)}"`),e||(t.type&&o.push(`type="${a(t.type)}"`),t.async&&o.push("async"),t.defer&&o.push("defer"),t.integrity&&o.push(`integrity="${a(t.integrity)}"`),t.crossorigin&&o.push(`crossorigin="${a(t.crossorigin)}"`),t.referrerpolicy&&o.push(`referrerpolicy="${a(t.referrerpolicy)}"`),t.nomodule&&o.push("nomodule"));const f=` data-smbls-script="${a(s||b(t.body||""))}"`;if(!e&&t.body){const h=String(t.body).replace(/<\/script/gi,"<\\/script");r.push(`<script ${o.join(" ")}${f}>${h}<\/script>`)}else r.push(`<script ${o.join(" ")}${f}><\/script>`)}return r},_=(i,r)=>{r||(i={...i,robots:"noindex"});const t=Object.entries(i).reduce((e,[s,o])=>{if(!o&&o!==0&&o!==!1||R.has(s))return e;if(s==="title")return e.push(`<title>${a(o)}</title>`),e;if(s==="canonical")return e.push(`<link rel="canonical" href="${a(o)}">`),e;if(s==="manifest")return e.push(`<link rel="manifest" href="${a(o)}">`),e;if(s==="favicon"||s==="favicons"||s==="icon"||s==="icons")return(Array.isArray(o)?o:[o]).forEach(p=>{if(typeof p=="string")e.push(`<link rel="icon" href="${a(p)}">`);else if(typeof p=="object"){const u=D(p);/rel=/.test(u)?e.push(`<link ${u}>`):e.push(`<link rel="icon" ${u}>`)}}),e;if(s==="alternate")return(Array.isArray(o)?o:[o]).forEach(p=>{if(typeof p=="object"){const u=Object.entries(p).filter(([n,g])=>g!==void 0).map(([n,g])=>`${n}="${a(g)}"`).join(" ");e.push(`<link rel="alternate" ${u}>`)}}),e;const f=(l,p,u="name")=>{if(typeof p=="string"||typeof p=="number"||typeof p=="boolean")e.push(`<meta ${u}="${a(l)}" content="${a(p)}">`);else if(Array.isArray(p))p.forEach(n=>{if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")e.push(`<meta ${u}="${a(l)}" content="${a(n)}">`);else if(typeof n=="object"){const g=Object.entries(n).filter(([d,c])=>c!==void 0).map(([d,c])=>`${d}="${a(c)}"`).join(" ");e.push(`<meta ${g}>`)}});else if(typeof p=="object"){const n=Object.entries(p).filter(([g,d])=>d!==void 0).map(([g,d])=>`${g}="${a(d)}"`).join(" ");e.push(`<meta ${n}>`)}};if(s.startsWith("http-equiv:")){const l=s.replace("http-equiv:","");return f(l,o,"http-equiv"),e}if(s.startsWith("itemprop:")){const l=s.replace("itemprop:","");return f(l,o,"itemprop"),e}const y=["og:","twitter:","fb:","article:","profile:","book:","business:","music:","product:","video:","DC:","DCTERMS:"].find(l=>s.startsWith(l));if(y){const l=s.replace(y,"");return f(`${y.replace(":","")}:${l}`,o,y==="twitter:"||y==="DC:"||y==="DCTERMS:"?"name":"property"),e}if(s.startsWith("apple:")||s.startsWith("msapplication:")){const l=s.startsWith("apple:")?"apple-":"msapplication-",p=s.replace(/^apple:|^msapplication:/,"");return f(`${l}${p}`,o,"name"),e}return f(s,o),e},['<meta charset="UTF-8">','<meta name="viewport" content="width=device-width, initial-scale=1">']);return t.push(...w(i)),t.join(`
2
- `)},q=i=>typeof i=="string"&&i.length>0&&!i.startsWith("/")&&!i.startsWith("http");function F(i,r){if(!r||typeof r!="object")return i;const t=s=>{if(!q(s))return s;const o=r[s];return o?.src?o.src:s},e={...i};for(const[s,o]of Object.entries(e))typeof o=="string"?e[s]=t(o):Array.isArray(o)&&(e[s]=o.map(f=>typeof f=="string"?t(f):f));return e}function m(i,r){if(!i||!r)return;const t=r.split(".");let e=i;for(const s of t){if(e==null||typeof e!="object")return;e=e[s]}return e}function K(i,r,t){const s=(r.config||r.settings||{}).polyglot||r.polyglot,o=t?.lang||s?.defaultLang||"en",h=(s?.translations||{})[o]||{},y=t?.state||{},l={...i};for(const[p,u]of Object.entries(l))typeof u!="string"||!u.includes("{{")||(l[p]=u.replace(/\{\{\s*([^|{}]+?)\s*(?:\|\s*(\w+)\s*)?\}\}/g,(n,g,d)=>{const c=g.trim();if(d==="polyglot")return h[c]??m(h,c)??n;if(d==="getLocalStateLang")return m(y,c+o)??n;const $=m(y,c);return $!==void 0?$:h[c]??m(h,c)??n}));return l}function S(i){const r={...i};for(const[t,e]of Object.entries(r))if(typeof e=="function"){const s=e.toString(),o=s.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(o){r[t]=`{{ ${o[1]} | getLocalStateLang }}`;continue}const f=s.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(f){r[t]=`{{ ${f[1]} | polyglot }}`;continue}const h=s.match(/s\.(\w+(?:\.\w+)+)/);if(h){r[t]=`{{ ${h[1]} }}`;continue}delete r[t]}else if(typeof e=="string"){const s=e.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(s){r[t]=`{{ ${s[1]} | getLocalStateLang }}`;continue}const o=e.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(o){r[t]=`{{ ${o[1]} | polyglot }}`;continue}if(e.includes("=>")&&e.includes("s.")){const f=e.match(/s\.(\w+(?:\.\w+)+)/);if(f){r[t]=`{{ ${f[1]} }}`;continue}}}return r}function P(i,r,t,{isProduction:e=!1,channel:s="production"}={}){const o=i.pages?.[r],f=(0,M.isObject)(o?.state)&&o?.state,h=o?.metadata||o?.helmet||f||{},y=S(h),l=new Set(Object.keys(y)),p=i.app?.metadata||{},u=S(p);let n={};if(i.integrations?.seo?n={...i.integrations.seo,...u,...y}:Object.keys(u).length?n={...u,...y}:n={...y},!n.title){const c=i.name||i.key;c?e?n.title=c:s==="development"?n.title=`${c} / dev:symbo.ls`:s==="staging"?n.title=`${c} / staging:symbo.ls`:n.title=`${c} / symbo.ls`:n.title="Symbols demo"}n=K(n,i,t),n.title&&(l.has("title")||!n["og:title"])&&(l.has("og:title")||(n["og:title"]=n.title)),n.description&&(l.has("description")||!n["og:description"])&&(l.has("og:description")||(n["og:description"]=n.description)),n.title&&!n["twitter:title"]&&(n["twitter:title"]=n.title),n.description&&!n["twitter:description"]&&(n["twitter:description"]=n.description);const g=t?.actualPathname||r;if(n["og:url"]||n.url){const c=(n["og:url"]||n.url||"").replace(/\/$/,"");if(c&&g&&g!=="/"){const $=g.startsWith("/")?g:"/"+g;n["og:url"]=c+$}}n=F(n,i.files);const d=i.name||i.app?.metadata?.title||i.app?.name||"";for(const[c,$]of Object.entries(n))if(typeof $=="string"&&$.includes("{{")){const j=$.replace(/\{\{[^}]*\}\}/g,"").trim();j?n[c]=j:c==="title"?n[c]=d:delete n[c]}return n}
1
+ "use strict";var S=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var W=Object.prototype.hasOwnProperty;var T=(n,r)=>{for(var t in r)S(n,t,{get:r[t],enumerable:!0})},x=(n,r,t,e)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of E(r))!W.call(n,s)&&s!==t&&S(n,s,{get:()=>r[s],enumerable:!(e=O(r,s))||e.enumerable});return n};var D=n=>x(S({},"__esModule",{value:!0}),n);var H={};T(H,{generateHeadArrayTags:()=>L,generateMetaTags:()=>_,getPageMetadata:()=>C,hashContent:()=>b});module.exports=D(H);var A=require("./types.js"),w=require("./function.js");const a=n=>{if(n==null)return"";const r={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};return n.toString().replace(/[&<>"']/g,t=>r[t])},F=n=>Object.entries(n||{}).filter(([r,t])=>t!==void 0).map(([r,t])=>`${r}="${a(t)}"`).join(" "),b=n=>{let r=5381;const t=String(n);for(let e=0;e<t.length;e++)r=(r*33^t.charCodeAt(e))>>>0;return r.toString(36)},R=new Set(["jsonLd","styles","scripts"]),L=n=>{const r=[];if(Array.isArray(n.jsonLd))for(const t of n.jsonLd){if(t==null)continue;const e=typeof t=="string"?t:JSON.stringify(t),s=String(e).replace(/<\/script/gi,"<\\/script");r.push(`<script type="application/ld+json" data-smbls-jsonld="${b(e)}">${s}<\/script>`)}if(Array.isArray(n.styles))for(const t of n.styles){if(t==null||!String(t).trim())continue;const e=String(t).replace(/<\/style/gi,"<\\/style");r.push(`<style data-smbls-style="${b(e)}">${e}</style>`)}if(Array.isArray(n.scripts))for(const t of n.scripts){if(!t)continue;const e=typeof t=="string",s=e?t:t.src;if(!s&&!t.body)continue;const o=[];s&&o.push(`src="${a(s)}"`),e||(t.type&&o.push(`type="${a(t.type)}"`),t.async&&o.push("async"),t.defer&&o.push("defer"),t.integrity&&o.push(`integrity="${a(t.integrity)}"`),t.crossorigin&&o.push(`crossorigin="${a(t.crossorigin)}"`),t.referrerpolicy&&o.push(`referrerpolicy="${a(t.referrerpolicy)}"`),t.nomodule&&o.push("nomodule"));const f=` data-smbls-script="${a(s||b(t.body||""))}"`;if(!e&&t.body){const h=String(t.body).replace(/<\/script/gi,"<\\/script");r.push(`<script ${o.join(" ")}${f}>${h}<\/script>`)}else r.push(`<script ${o.join(" ")}${f}><\/script>`)}return r},_=(n,r)=>{r||(n={...n,robots:"noindex"});const t=Object.entries(n).reduce((e,[s,o])=>{if(!o&&o!==0&&o!==!1||R.has(s))return e;if(s==="title")return e.push(`<title>${a(o)}</title>`),e;if(s==="canonical")return e.push(`<link rel="canonical" href="${a(o)}">`),e;if(s==="manifest")return e.push(`<link rel="manifest" href="${a(o)}">`),e;if(s==="favicon"||s==="favicons"||s==="icon"||s==="icons")return(Array.isArray(o)?o:[o]).forEach(p=>{if(typeof p=="string")e.push(`<link rel="icon" href="${a(p)}">`);else if(typeof p=="object"){const u=F(p);/rel=/.test(u)?e.push(`<link ${u}>`):e.push(`<link rel="icon" ${u}>`)}}),e;if(s==="alternate")return(Array.isArray(o)?o:[o]).forEach(p=>{if(typeof p=="object"){const u=Object.entries(p).filter(([i,g])=>g!==void 0).map(([i,g])=>`${i}="${a(g)}"`).join(" ");e.push(`<link rel="alternate" ${u}>`)}}),e;const f=(l,p,u="name")=>{if(typeof p=="string"||typeof p=="number"||typeof p=="boolean")e.push(`<meta ${u}="${a(l)}" content="${a(p)}">`);else if(Array.isArray(p))p.forEach(i=>{if(typeof i=="string"||typeof i=="number"||typeof i=="boolean")e.push(`<meta ${u}="${a(l)}" content="${a(i)}">`);else if(typeof i=="object"){const g=Object.entries(i).filter(([d,c])=>c!==void 0).map(([d,c])=>`${d}="${a(c)}"`).join(" ");e.push(`<meta ${g}>`)}});else if(typeof p=="object"){const i=Object.entries(p).filter(([g,d])=>d!==void 0).map(([g,d])=>`${g}="${a(d)}"`).join(" ");e.push(`<meta ${i}>`)}};if(s.startsWith("http-equiv:")){const l=s.replace("http-equiv:","");return f(l,o,"http-equiv"),e}if(s.startsWith("itemprop:")){const l=s.replace("itemprop:","");return f(l,o,"itemprop"),e}const y=["og:","twitter:","fb:","article:","profile:","book:","business:","music:","product:","video:","DC:","DCTERMS:"].find(l=>s.startsWith(l));if(y){const l=s.replace(y,"");return f(`${y.replace(":","")}:${l}`,o,y==="twitter:"||y==="DC:"||y==="DCTERMS:"?"name":"property"),e}if(s.startsWith("apple:")||s.startsWith("msapplication:")){const l=s.startsWith("apple:")?"apple-":"msapplication-",p=s.replace(/^apple:|^msapplication:/,"");return f(`${l}${p}`,o,"name"),e}return f(s,o),e},['<meta charset="UTF-8">','<meta name="viewport" content="width=device-width, initial-scale=1">']);return t.push(...L(n)),t.join(`
2
+ `)},q=n=>typeof n=="string"&&n.length>0&&!n.startsWith("/")&&!n.startsWith("http");function K(n,r){if(!r||typeof r!="object")return n;const t=s=>{if(!q(s))return s;const o=r[s];return o?.src?o.src:s},e={...n};for(const[s,o]of Object.entries(e))typeof o=="string"?e[s]=t(o):Array.isArray(o)&&(e[s]=o.map(f=>typeof f=="string"?t(f):f));return e}function m(n,r){if(!n||!r)return;const t=r.split(".");let e=n;for(const s of t){if(e==null||typeof e!="object")return;e=e[s]}return e}function P(n,r,t){const s=(r.config||r.settings||{}).polyglot||r.polyglot,o=t?.lang||s?.defaultLang||"en",h=(s?.translations||{})[o]||{},y=t?.state||{},l={...n};for(const[p,u]of Object.entries(l))typeof u!="string"||!u.includes("{{")||(l[p]=u.replace(/\{\{\s*([^|{}]+?)\s*(?:\|\s*(\w+)\s*)?\}\}/g,(i,g,d)=>{const c=g.trim();if(d==="polyglot")return h[c]??m(h,c)??i;if(d==="getLocalStateLang")return m(y,c+o)??i;const $=m(y,c);return $!==void 0?$:h[c]??m(h,c)??i}));return l}function M(n){if(!(0,A.isObject)(n))return{};const r={...n};for(const[t,e]of Object.entries(r))if(typeof e=="function"){const s=e.toString(),o=s.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(o){r[t]=`{{ ${o[1]} | getLocalStateLang }}`;continue}const f=s.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(f){r[t]=`{{ ${f[1]} | polyglot }}`;continue}const h=s.match(/s\.(\w+(?:\.\w+)+)/);if(h){r[t]=`{{ ${h[1]} }}`;continue}delete r[t]}else if(typeof e=="string"){const s=e.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(s){r[t]=`{{ ${s[1]} | getLocalStateLang }}`;continue}const o=e.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(o){r[t]=`{{ ${o[1]} | polyglot }}`;continue}if(e.includes("=>")&&e.includes("s.")){const f=e.match(/s\.(\w+(?:\.\w+)+)/);if(f){r[t]=`{{ ${f[1]} }}`;continue}}(0,w.isStringFunction)(e)&&delete r[t]}return r}function C(n,r,t,{isProduction:e=!1,channel:s="production"}={}){const o=n.pages?.[r],f=(0,A.isObject)(o?.state)&&o?.state,h=o?.metadata||o?.helmet||f||{},y=M(h),l=new Set(Object.keys(y)),p=n.app?.metadata||{},u=M(p);let i={};if(n.integrations?.seo?i={...n.integrations.seo,...u,...y}:Object.keys(u).length?i={...u,...y}:i={...y},!i.title){const c=n.name||n.key;c?e?i.title=c:s==="development"?i.title=`${c} / dev:symbo.ls`:s==="staging"?i.title=`${c} / staging:symbo.ls`:i.title=`${c} / symbo.ls`:i.title="Symbols demo"}i=P(i,n,t),i.title&&(l.has("title")||!i["og:title"])&&(l.has("og:title")||(i["og:title"]=i.title)),i.description&&(l.has("description")||!i["og:description"])&&(l.has("og:description")||(i["og:description"]=i.description)),i.title&&!i["twitter:title"]&&(i["twitter:title"]=i.title),i.description&&!i["twitter:description"]&&(i["twitter:description"]=i.description);const g=t?.actualPathname||r;if(i["og:url"]||i.url){const c=(i["og:url"]||i.url||"").replace(/\/$/,"");if(c&&g&&g!=="/"){const $=g.startsWith("/")?g:"/"+g;i["og:url"]=c+$}}i=K(i,n.files);const d=n.name||n.app?.metadata?.title||n.app?.name||"";for(const[c,$]of Object.entries(i))if(typeof $=="string"&&$.includes("{{")){const j=$.replace(/\{\{[^}]*\}\}/g,"").trim();j?i[c]=j:c==="title"?i[c]=d:delete i[c]}return i}
@@ -1,10 +1,10 @@
1
- "use strict";var D=Object.create;var g=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var L=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var M=(e,t)=>{for(var n in t)g(e,n,{get:t[n],enumerable:!0})},O=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of I(t))!F.call(e,r)&&r!==n&&g(e,r,{get:()=>t[r],enumerable:!(o=T(t,r))||o.enumerable});return e};var m=(e,t,n)=>(n=e!=null?D(L(e)):{},O(t||!e||!e.__esModule?g(n,"default",{value:e,enumerable:!0}):n,e)),J=e=>O(g({},"__esModule",{value:!0}),e);var wt={};M(wt,{call:()=>ut,defineSetter:()=>rt,error:()=>S,get:()=>U,getChildren:()=>Z,getContext:()=>ot,getDB:()=>at,getPath:()=>K,getQuery:()=>ht,getRef:()=>Y,getRoot:()=>tt,getRootContext:()=>nt,getRootData:()=>et,getRootState:()=>q,isMethod:()=>vt,keys:()=>j,log:()=>st,lookdown:()=>z,lookdownAll:()=>G,lookup:()=>B,nextElement:()=>ct,parse:()=>Q,parseDeep:()=>w,previousElement:()=>lt,remove:()=>H,setActiveRootState:()=>X,setNodeStyles:()=>C,setProps:()=>W,spotByPath:()=>V,variables:()=>ft,verbose:()=>N,warn:()=>it});module.exports=J(wt);var v=require("./triggerEvent.js"),d=require("./keys.js"),f=require("./types.js"),E=require("./object.js"),P=require("./env.js"),A=require("./array.js"),b=require("./cache.js");const h="production";function V(e){const t=this,{__ref:n}=t,o=[].concat(e);let r=n.root[o[0]];if(!o||!o.length)return console.log(o,"on",t.key,"is undefined");for(;r.key===o[0]&&(o.shift(),!!o.length);)if(r=r[o[0]],!r)return;return r}function B(e){const t=this;let{parent:n}=t;if((0,f.isFunction)(e))return n.state&&e(n,n.state,n.context)?n:n.parent?n.lookup(e):void 0;if(t[e])return t[e];for(;n.param!==e;){if(n[e])return n[e];if(n=n.parent,!n)return}return n}function z(e){const t=this,{__ref:n}=t,o=n?.__children;if(o)for(let r=0;r<o.length;r++){const s=o[r],i=t[s];if(s===e)return i;if((0,f.isFunction)(e)){const l=e(i,i.state,i.context);if(i.state&&l)return i}const c=i?.lookdown?.(e);if(c)return c}}function G(e,t=[]){const n=this,{__ref:o}=n,r=o?.__children;if(r){for(let s=0;s<r.length;s++){const i=r[s],c=n[i];if(i===e)t.push(c);else if((0,f.isFunction)(e)){const l=e(c,c.state,c.context);c.state&&l&&t.push(c)}c?.lookdownAll?.(e,t)}return t.length?t:void 0}}function C(e={}){const t=this;if(t.node?.style){for(const n in e){const o=e[n],r=t[n];if((0,f.isObject)(o)&&r)C.call(r,o);else if(o!=null){const s=n.replace(/[A-Z]/g,c=>"-"+c.toLowerCase()),i=String(o).replace(/\s*!important\s*$/,"");t.node.style.setProperty(s,i,"important")}}return t}}function H(e){const t=this;if((0,v.triggerEventOn)("beforeRemove",t,e)===!1)return t;(0,f.isFunction)(t.node.remove)?t.node.remove():(0,P.isProduction)()||(console.warn("This item cant be removed"),t.log()),delete t.parent[t.key],t.parent.__ref&&(t.parent.__ref.__children=(0,A.removeValueFromArray)(t.parent.__ref.__children,t.key)),(0,v.triggerEventOn)("remove",t,e)}function U(e){return this[e]}function W(e,t){const n=this;if(e)return n.update(e,t),n}function Y(e){return e?this.__ref&&this.__ref[e]:this.__ref}function Z(){const e=this.getRef("__children");return Array.isArray(e)?e.map(t=>this[t]):[]}function K(){return this.getRef().path}let R=null;const X=e=>{R=e||null},$=()=>R||null;function q(e){let t=null;const n=o=>o.__element&&o.root?.isRootState;if(!this)t=$();else if(n(this))t=this.root;else if(this.__ref&&this.__ref.path){const o=this.state&&n(this.state),r=(0,f.isFunction)(this.state)&&this.parent.state&&n(this.parent.state);(o||r)&&(t=this.state.root||this.parent.state.root)}return t||(t=$()),e?t?.[e]:t}function tt(e){const t=this?.__ref?.root||this.getRootState()?.__element;if(!t)throw new Error(`[smbls] getRoot() could not resolve a root element for "${this?.key||"<unknown>"}" \u2014 it has no __ref (never went through create()) and no root state is registered. Answering undefined here used to no-op silently for every caller.`);return Object.keys(t).length>0&&e?t[e]:t}function et(e){return this.getRoot("data")&&Object.keys(this.getRoot("data")).length>0&&e?this.getRoot("data")[e]:this.getRoot("data")}function nt(e){const t=this.getRoot()?.context;return e?t[e]:t}function ot(e){const t=this.context;return e?t[e]:t}const rt=(e,t,n,o)=>Object.defineProperty(e,t,{get:n,set:o});function j(){const e=this,t=[];for(const n in e)!Object.prototype.hasOwnProperty.call(e,n)||d.DOMQ_PROPERTIES.has(n)&&!d.PARSED_DOMQ_PROPERTIES.has(n)||t.push(n);return t}function Q(e=[]){const t=this,n={},o=j.call(t),r=o.includes("children"),s=e.length?new Set(e):null;for(let i=0;i<o.length;i++){const c=o[i];if(s&&s.has(c)||!Object.prototype.hasOwnProperty.call(t,c)||r&&c==="content")continue;const l=t[c];if(c==="state"){if(t.__ref&&!t.__ref.__hasRootState)continue;const u=(0,f.isFunction)(l&&l.parse)?l.parse():l;n[c]=(0,f.isFunction)(u)?u:JSON.parse(JSON.stringify(u||{}))}else if(c==="scope"){if(t.__ref&&!t.__ref.__hasRootScope)continue;n[c]=JSON.parse(JSON.stringify(l||{}))}else if(c==="props"){const{__element:u,update:a,...p}=t[c];n[c]=p}else(0,f.isDefined)(l)&&Object.prototype.hasOwnProperty.call(t,c)&&(n[c]=l)}return n}function w(e=[],t=new WeakSet){const n=this;if(t.has(n))return;t.add(n);const o=Q.call(n,e),r=e.length?new Set(e):null;for(const s in o){if(r&&r.has(s)||!Object.prototype.hasOwnProperty.call(n,s))continue;const i=o[s];Array.isArray(i)?o[s]=i.map(c=>(0,f.isObjectLike)(c)?w.call(c,e,t):c):(0,f.isObjectLike)(i)&&(o[s]=w.call(i,e,t))}return o}function N(...e){if(h!=="test"&&h!=="development")return;const t=this,{__ref:n}=t;return console.groupCollapsed(t.key),e.length?e.forEach(o=>console.log(`%c${o}:
2
- `,"font-weight: bold",t[o])):(console.log(n.path),t.keys().forEach(r=>console.log(`%c${r}:`,"font-weight: bold",t[r]))),console.log(t),console.groupEnd(t.key),t}function st(...e){(h==="test"||h==="development")&&console.log(...e)}function it(...e){(h==="test"||h==="development")&&console.warn(...e)}function S(...e){if(h==="test"||h==="development"){if(e[e.length-1]?.debugger)debugger;throw e[e.length-1]?.verbose&&N.call(this),new Error(...e)}}function ct(){const e=this,{key:t,parent:n}=e,{__children:o}=n.__ref,r=o.indexOf(t),s=o[r+1];return n[s]}function lt(e){const t=e||this,{key:n,parent:o}=t,{__children:r}=o.__ref;if(!r)return;const s=r.indexOf(n);return o[r[s-1]]}function ft(e={}){const t=this;t.data||(t.data={}),t.data.varCaches||(t.data.varCaches={});const n=t.data.varCaches,o={};let r;for(const s in e)e[s]!==n[s]&&(r=!0,o[s]=e[s]);return{changed:s=>{if(!r)return;const i=s(o,(0,E.deepClone)(n));for(const c in o)n[c]=o[c];return i},timeout:(s,i)=>{if(!r)return;const c=setTimeout(()=>{s(o),clearTimeout(c)},i)}}}function ut(e,...t){const n=this.context,o=n.utils?.[e]||n.functions?.[e]||n.methods?.[e]||n.snippets?.[e];if(o)try{const r=o.call(this,...t);return r&&typeof r.then=="function"&&r.catch(s=>{S.call(this,s)}),r}catch(r){if(S.call(this,r),n?.strictMode)throw r}}async function at(){const e=this,t=e.context?.fetch;if(!t)return null;if(typeof t.select=="function"){if(!t.__authInitialized&&t.getSession){const{initAdapterAuth:r}=await import("@symbo.ls/fetch");await r(t,e.context)}return t}if(t.__resolved){if(!t.__resolved.__authInitialized&&t.__resolved.getSession){const{initAdapterAuth:r}=await import("@symbo.ls/fetch");await r(t.__resolved,e.context)}return t.__resolved}if(t.__resolving)return t.__resolving;const n=import("@symbo.ls/fetch").then(({resolveDb:r})=>r(t));t.__resolving=n;const o=await n;if(t.__resolved=o,e.context.fetch=o,delete t.__resolving,o?.getSession){const{initAdapterAuth:r}=await import("@symbo.ls/fetch");await r(o,e.context)}return o}function ht(e){const t=this,n=e||b.OPTIONS.useStateQuery||t.context?.useStateQuery;if(!n)return null;const o={};if(y(t,o),n===!0)return o;const r=yt[n];return r?r(o):o}const y=(e,t)=>{const n=e.__ref;if(!n)return;const o=n.__state;o&&typeof o=="string"&&pt(t,o);const r=n.__children;if(r)for(let c=0;c<r.length;c++){const l=e[r[c]];l&&l.__ref&&y(l,t)}const s=n.contentElementKey||"content",i=e[s];i&&i.__ref&&y(i,t)},pt=(e,t)=>{const o=t.replaceAll("../","").replaceAll("~/","").split("/");let r=e;for(let s=0;s<o.length;s++){const i=o[s];s===o.length-1?r[i]||(r[i]=!0):(r[i]===!0&&(r[i]={}),r[i]||(r[i]={}),r=r[i])}},k=(e,t=0)=>{const n=" ".repeat(t),o=Object.entries(e);return o.length?o.map(([s,i])=>i===!0?`${n}${s}`:`${n}${s} {
3
- ${k(i,t+1)}
1
+ "use strict";var D=Object.create;var g=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var I=Object.getPrototypeOf,L=Object.prototype.hasOwnProperty;var M=(e,t)=>{for(var n in t)g(e,n,{get:t[n],enumerable:!0})},R=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of F(t))!L.call(e,r)&&r!==n&&g(e,r,{get:()=>t[r],enumerable:!(o=T(t,r))||o.enumerable});return e};var m=(e,t,n)=>(n=e!=null?D(I(e)):{},R(t||!e||!e.__esModule?g(n,"default",{value:e,enumerable:!0}):n,e)),J=e=>R(g({},"__esModule",{value:!0}),e);var wt={};M(wt,{call:()=>ut,defineSetter:()=>rt,error:()=>O,get:()=>U,getChildren:()=>Z,getContext:()=>ot,getDB:()=>at,getPath:()=>K,getQuery:()=>ht,getRef:()=>Y,getRoot:()=>tt,getRootContext:()=>nt,getRootData:()=>et,getRootState:()=>q,isMethod:()=>vt,keys:()=>j,log:()=>st,lookdown:()=>z,lookdownAll:()=>G,lookup:()=>B,nextElement:()=>ct,parse:()=>Q,parseDeep:()=>S,previousElement:()=>lt,remove:()=>H,setActiveRootState:()=>X,setNodeStyles:()=>C,setProps:()=>W,spotByPath:()=>V,variables:()=>ft,verbose:()=>N,warn:()=>it});module.exports=J(wt);var w=require("./triggerEvent.js"),d=require("./keys.js"),f=require("./types.js"),x=require("./object.js"),P=require("./env.js"),A=require("./array.js"),b=require("./cache.js");const h="production";function V(e){const t=this,{__ref:n}=t,o=[].concat(e);let r=n.root[o[0]];if(!o||!o.length)return console.log(o,"on",t.key,"is undefined");for(;r.key===o[0]&&(o.shift(),!!o.length);)if(r=r[o[0]],!r)return;return r}function B(e){const t=this;let{parent:n}=t;if((0,f.isFunction)(e))return n.state&&e(n,n.state,n.context)?n:n.parent?n.lookup(e):void 0;if(t[e])return t[e];for(;n.param!==e;){if(n[e])return n[e];if(n=n.parent,!n)return}return n}function z(e){const t=this,{__ref:n}=t,o=n?.__children;if(o)for(let r=0;r<o.length;r++){const s=o[r],i=t[s];if(s===e)return i;if((0,f.isFunction)(e)){const l=e(i,i.state,i.context);if(i.state&&l)return i}const c=i?.lookdown?.(e);if(c)return c}}function G(e,t=[]){const n=this,{__ref:o}=n,r=o?.__children;if(r){for(let s=0;s<r.length;s++){const i=r[s],c=n[i];if(i===e)t.push(c);else if((0,f.isFunction)(e)){const l=e(c,c.state,c.context);c.state&&l&&t.push(c)}c?.lookdownAll?.(e,t)}return t.length?t:void 0}}function C(e={}){const t=this;if(t.node?.style){for(const n in e){const o=e[n],r=t[n];if((0,f.isObject)(o)&&r)C.call(r,o);else if(o!=null){const s=n.replace(/[A-Z]/g,c=>"-"+c.toLowerCase()),i=String(o).replace(/\s*!important\s*$/,"");t.node.style.setProperty(s,i,"important")}}return t}}function H(e){const t=this;if((0,w.triggerEventOn)("beforeRemove",t,e)===!1)return t;(0,f.isFunction)(t.node.remove)?t.node.remove():(0,P.isProduction)()||(console.warn("This item cant be removed"),t.log()),delete t.parent[t.key],t.parent.__ref&&(t.parent.__ref.__children=(0,A.removeValueFromArray)(t.parent.__ref.__children,t.key)),(0,w.triggerEventOn)("remove",t,e)}function U(e){return this[e]}function W(e,t){const n=this;if(e)return n.update(e,t),n}function Y(e){return e?this.__ref&&this.__ref[e]:this.__ref}function Z(){const e=this.getRef("__children");return Array.isArray(e)?e.map(t=>this[t]):[]}function K(){return this.getRef().path}let $=null;const X=e=>{$=e||null},k=()=>$||null;function q(e){let t=null;const n=o=>o.__element&&o.root?.isRootState;if(!this)t=k();else if(n(this))t=this.root;else if(this.__ref&&this.__ref.path){const o=this.state&&n(this.state),r=(0,f.isFunction)(this.state)&&this.parent.state&&n(this.parent.state);(o||r)&&(t=this.state.root||this.parent.state.root)}return t||(t=k()),e?t?.[e]:t}function tt(e){const t=this?.__ref?.root||this.getRootState()?.__element;if(!t)throw new Error(`[smbls] getRoot() could not resolve a root element for "${this?.key||"<unknown>"}" \u2014 it has no __ref (never went through create()) and no root state is registered. Answering undefined here used to no-op silently for every caller.`);return Object.keys(t).length>0&&e?t[e]:t}function et(e){return this.getRoot("data")&&Object.keys(this.getRoot("data")).length>0&&e?this.getRoot("data")[e]:this.getRoot("data")}function nt(e){const t=this.getRoot()?.context;return e?t[e]:t}function ot(e){const t=this.context;return e?t[e]:t}const rt=(e,t,n,o)=>Object.defineProperty(e,t,{get:n,set:o});function j(){const e=this,t=[];for(const n in e)!Object.prototype.hasOwnProperty.call(e,n)||d.DOMQ_PROPERTIES.has(n)&&!d.PARSED_DOMQ_PROPERTIES.has(n)||t.push(n);return t}function Q(e=[]){const t=this,n={},o=j.call(t),r=o.includes("children"),s=e.length?new Set(e):null;for(let i=0;i<o.length;i++){const c=o[i];if(s&&s.has(c)||!Object.prototype.hasOwnProperty.call(t,c)||r&&c==="content")continue;const l=t[c];if(c==="state"){if(t.__ref&&!t.__ref.__hasRootState)continue;const u=(0,f.isFunction)(l&&l.parse)?l.parse():l;n[c]=(0,f.isFunction)(u)?u:JSON.parse(JSON.stringify(u||{}))}else if(c==="scope"){if(t.__ref&&!t.__ref.__hasRootScope)continue;n[c]=JSON.parse(JSON.stringify(l||{}))}else if(c==="props"){const{__element:u,update:a,...p}=t[c];n[c]=p}else(0,f.isDefined)(l)&&Object.prototype.hasOwnProperty.call(t,c)&&(n[c]=l)}return n}function S(e=[],t=new WeakSet){const n=this;if(t.has(n))return;t.add(n);const o=Q.call(n,e),r=e.length?new Set(e):null;for(const s in o){if(r&&r.has(s)||!Object.prototype.hasOwnProperty.call(n,s))continue;const i=o[s];Array.isArray(i)?o[s]=i.map(c=>(0,f.isObjectLike)(c)?S.call(c,e,t):c):(0,f.isObjectLike)(i)&&(o[s]=S.call(i,e,t))}return o}function N(...e){if(h!=="test"&&h!=="development")return;const t=this,{__ref:n}=t;return console.groupCollapsed(t.key),e.length?e.forEach(o=>console.log(`%c${o}:
2
+ `,"font-weight: bold",t[o])):(console.log(n.path),t.keys().forEach(r=>console.log(`%c${r}:`,"font-weight: bold",t[r]))),console.log(t),console.groupEnd(t.key),t}function st(...e){(h==="test"||h==="development")&&console.log(...e)}function it(...e){(h==="test"||h==="development")&&console.warn(...e)}function O(...e){if(h==="test"||h==="development"){if(e[e.length-1]?.debugger)debugger;throw e[e.length-1]?.verbose&&N.call(this),new Error(...e)}}function ct(){const e=this,{key:t,parent:n}=e,{__children:o}=n.__ref,r=o.indexOf(t),s=o[r+1];return n[s]}function lt(e){const t=e||this,{key:n,parent:o}=t,{__children:r}=o.__ref;if(!r)return;const s=r.indexOf(n);return o[r[s-1]]}function ft(e={}){const t=this;t.data||(t.data={}),t.data.varCaches||(t.data.varCaches={});const n=t.data.varCaches,o={};let r;for(const s in e)e[s]!==n[s]&&(r=!0,o[s]=e[s]);return{changed:s=>{if(!r)return;const i=s(o,(0,x.deepClone)(n));for(const c in o)n[c]=o[c];return i},timeout:(s,i)=>{if(!r)return;const c=setTimeout(()=>{s(o),clearTimeout(c)},i)}}}function ut(e,...t){const n=this.context,o=n.utils?.[e]||n.functions?.[e]||n.methods?.[e]||n.snippets?.[e];if(o&&!(0,x.isFailedRevival)(o))try{const r=o.call(this,...t);return r&&typeof r.then=="function"&&r.catch(s=>{O.call(this,s)}),r}catch(r){if(O.call(this,r),n?.strictMode)throw r}}async function at(){const e=this,t=e.context?.fetch;if(!t)return null;if(typeof t.select=="function"){if(!t.__authInitialized&&t.getSession){const{initAdapterAuth:r}=await import("@symbo.ls/fetch");await r(t,e.context)}return t}if(t.__resolved){if(!t.__resolved.__authInitialized&&t.__resolved.getSession){const{initAdapterAuth:r}=await import("@symbo.ls/fetch");await r(t.__resolved,e.context)}return t.__resolved}if(t.__resolving)return t.__resolving;const n=import("@symbo.ls/fetch").then(({resolveDb:r})=>r(t));t.__resolving=n;const o=await n;if(t.__resolved=o,e.context.fetch=o,delete t.__resolving,o?.getSession){const{initAdapterAuth:r}=await import("@symbo.ls/fetch");await r(o,e.context)}return o}function ht(e){const t=this,n=e||b.OPTIONS.useStateQuery||t.context?.useStateQuery;if(!n)return null;const o={};if(v(t,o),n===!0)return o;const r=yt[n];return r?r(o):o}const v=(e,t)=>{const n=e.__ref;if(!n)return;const o=n.__state;o&&typeof o=="string"&&pt(t,o);const r=n.__children;if(r)for(let c=0;c<r.length;c++){const l=e[r[c]];l&&l.__ref&&v(l,t)}const s=n.contentElementKey||"content",i=e[s];i&&i.__ref&&v(i,t)},pt=(e,t)=>{const o=t.replaceAll("../","").replaceAll("~/","").split("/");let r=e;for(let s=0;s<o.length;s++){const i=o[s];s===o.length-1?r[i]||(r[i]=!0):(r[i]===!0&&(r[i]={}),r[i]||(r[i]={}),r=r[i])}},E=(e,t=0)=>{const n=" ".repeat(t),o=Object.entries(e);return o.length?o.map(([s,i])=>i===!0?`${n}${s}`:`${n}${s} {
3
+ ${E(i,t+1)}
4
4
  ${n}}`).join(`
5
5
  `):""},dt=e=>`{
6
- ${k(e,1)}
7
- }`,_t=e=>{const t={fields:{},include:[]},n=(o,r)=>{const s=[];for(const i in o)if(o[i]===!0)s.push(i);else{const c=r?`${r}.${i}`:i;t.include.push(c),n(o[i],c)}s.length&&(t.fields[r||"_root"]=s)};return n(e,""),t},gt=e=>{const t=s=>{const i=[],c=[];for(const l in s)if(s[l]===!0)i.push(l);else{const u=t(s[l]),a=[];u.select&&a.push(`$select=${u.select}`),u.expand&&a.push(`$expand=${u.expand}`),c.push(a.length?`${l}(${a.join(";")})`:l)}return{select:i.length?i.join(","):"",expand:c.length?c.join(","):""}},{select:n,expand:o}=t(e),r=[];return n&&r.push(`$select=${n}`),o&&r.push(`$expand=${o}`),r.join("&")},mt=(e,t)=>{const n=[],o=[],r=new Set,s=(a,p,x)=>{r.add(p),x&&o.push(`LEFT JOIN ${p} ON ${p}.${x}_id = ${x}.id`);for(const _ in a)a[_]===!0?n.push(`${p}.${_}`):s(a[_],_,p)},i=Object.keys(e);i.length===1&&e[i[0]]!==!0?s(e[i[0]],i[0],null):s(e,"_root",null);const c=[...r][0]||"_root",l=n.length?n.join(", "):"*",u=o.length?`
6
+ ${E(e,1)}
7
+ }`,_t=e=>{const t={fields:{},include:[]},n=(o,r)=>{const s=[];for(const i in o)if(o[i]===!0)s.push(i);else{const c=r?`${r}.${i}`:i;t.include.push(c),n(o[i],c)}s.length&&(t.fields[r||"_root"]=s)};return n(e,""),t},gt=e=>{const t=s=>{const i=[],c=[];for(const l in s)if(s[l]===!0)i.push(l);else{const u=t(s[l]),a=[];u.select&&a.push(`$select=${u.select}`),u.expand&&a.push(`$expand=${u.expand}`),c.push(a.length?`${l}(${a.join(";")})`:l)}return{select:i.length?i.join(","):"",expand:c.length?c.join(","):""}},{select:n,expand:o}=t(e),r=[];return n&&r.push(`$select=${n}`),o&&r.push(`$expand=${o}`),r.join("&")},mt=(e,t)=>{const n=[],o=[],r=new Set,s=(a,p,y)=>{r.add(p),y&&o.push(`LEFT JOIN ${p} ON ${p}.${y}_id = ${y}.id`);for(const _ in a)a[_]===!0?n.push(`${p}.${_}`):s(a[_],_,p)},i=Object.keys(e);i.length===1&&e[i[0]]!==!0?s(e[i[0]],i[0],null):s(e,"_root",null);const c=[...r][0]||"_root",l=n.length?n.join(", "):"*",u=o.length?`
8
8
  `+o.join(`
9
9
  `):"";return`SELECT ${l}
10
10
  FROM ${c}${u}`},xt=e=>{const t=[],n=(o,r)=>{for(const s in o){const i=r?`${r}/${s}`:s;o[s]===!0?t.push(i):n(o[s],i)}};return n(e,""),t},yt={graphql:dt,"json-api":_t,odata:gt,sql:mt,paths:xt};function vt(e,t){return!!(d.METHODS.has(e)||t?.context?.methods?.[e])}
@@ -1,18 +1,19 @@
1
- "use strict";var $=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var V=(e,t)=>{for(var o in t)$(e,o,{get:t[o],enumerable:!0})},H=(e,t,o,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of J(t))!U.call(e,n)&&n!==o&&$(e,n,{get:()=>t[n],enumerable:!(c=B(t,n))||c.enumerable});return e};var X=e=>H($({},"__esModule",{value:!0}),e);var Te={};V(Te,{clone:()=>ee,createNestedObject:()=>Se,createObjectWithoutPrototype:()=>Z,deepClone:()=>te,deepContains:()=>we,deepDestringifyFunctions:()=>ue,deepMerge:()=>j,deepStringifyFunctions:()=>E,destringifyGlobalScope:()=>le,detectInfiniteLoop:()=>Ee,excludeKeysFromObject:()=>Ae,exec:()=>x,getInObjectByPath:()=>xe,hasFunction:()=>k,hasOwnProperty:()=>pe,isCyclic:()=>Pe,isEmpty:()=>z,isEmptyObject:()=>ye,isEqualDeep:()=>Y,makeObjectWithoutPrototype:()=>he,map:()=>v,merge:()=>Q,objectToString:()=>P,overwrite:()=>de,overwriteDeep:()=>K,overwriteShallow:()=>ge,removeFromObject:()=>Oe,removeNestedKeyByPath:()=>ke,setInObjectByPath:()=>$e,stringToObject:()=>ae});module.exports=X(Te);var O=require("./globals.js"),u=require("./types.js"),F=require("./array.js"),L=require("./string.js"),_=require("./node.js"),q=require("./keys.js");const A="production",w=e=>e.charCodeAt(0)===95&&e.charCodeAt(1)===95,x=(e,t,o,c)=>{if((0,u.isFunction)(e))return t?typeof e.call!="function"?e:e.call(t,t,o||t.state,c||t.context):void 0;if(e!=null&&t?.context?.plugins&&((0,u.isArray)(e)||(0,u.isObject)(e)&&!(0,_.isDOMNode)(e))){const n=t.context.plugins;for(const r of n)if(r.resolveHandler){const i=r.resolveHandler(e,t);if(typeof i=="function")return x(i,t,o,c)}}return e},v=(e,t,o)=>{for(const c in t)e[c]=x(t[c],o)},Q=(e,t,o=[])=>{const c=o instanceof Set;for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(w(n)||(c?o.has(n):o.includes(n))||e[n]===void 0&&(e[n]=t[n]));return e},j=(e,t,o=q.METHODS_EXL)=>T(e,t,o,null),T=(e,t,o,c)=>{if(e===t)return e;if(c){for(let r=0;r<c.length;r+=2)if(c[r]===e&&c[r+1]===t)return e}const n=o instanceof Set;for(const r in t){if(!Object.prototype.hasOwnProperty.call(t,r)||w(r)||r==="constructor"||r==="prototype"||(n?o.has(r):o.includes(r)))continue;const i=e[r],s=t[r];if((0,u.isObjectLike)(i)&&(0,u.isObjectLike)(s)){const f=c||[];f.push(e,t),T(i,s,o,f),f.length-=2}else i===void 0&&(e[r]=s)}return e},ee=(e,t=[])=>{const o=t instanceof Set,c={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(w(n)||(o?t.has(n):t.includes(n))||(c[n]=e[n]));return c},te=(e,t={})=>{const{exclude:o=[],cleanUndefined:c=!1,cleanNull:n=!1,visited:r=new WeakMap,handleExtends:i=!1}=t;if(!(0,u.isObjectLike)(e)||(0,_.isDOMNode)(e))return e;if(r.has(e))return r.get(e);const s=o instanceof Set?o:o.length>3?new Set(o):null,f=y=>s?s.has(y):o.includes(y),l=(0,u.isArray)(e)?[]:{};r.set(e,l);const a=[[e,l]];for(;a.length;){const[y,d]=a.pop();for(const h in y){if(!Object.prototype.hasOwnProperty.call(y,h)||w(h)||h==="__proto__"||f(h))continue;const p=y[h];if(!(c&&p===void 0)&&!(n&&p===null)){if((0,_.isDOMNode)(p)){d[h]=p;continue}if(i&&h==="extends"&&(0,u.isArray)(p)){d[h]=(0,F.unstackArrayOfObjects)(p,o);continue}if((0,u.isFunction)(p)){d[h]=p;continue}if((0,u.isObjectLike)(p))if(r.has(p))d[h]=r.get(p);else{const g=(0,u.isArray)(p)?[]:{};r.set(p,g),d[h]=g,a.push([p,g])}else d[h]=p}}}return l},E=(e,t={})=>{(e.node||e.__ref||e.parent||e.__element||e.parse)&&((e.__element||e.parent?.__element).warn("Trying to clone element or state at",e),e=e.parse?.());for(const o in e){const c=e[o];if((0,u.isFunction)(c))t[o]=c.toString();else if((0,u.isObject)(c))t[o]={},E(c,t[o]);else if((0,u.isArray)(c)){const n=t[o]=[];for(let r=0;r<c.length;r++){const i=c[r];(0,u.isObject)(i)?(n[r]={},E(i,n[r])):(0,u.isFunction)(i)?n[r]=i.toString():n[r]=i}}else t[o]=c}return t},ne=/^[A-Za-z_$][A-Za-z0-9_$]*$/,re=e=>`'${String(e).replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\r/g,"\\r").replace(/\n/g,"\\n")}'`,N=e=>{const t=String(e);return(0,L.stringIncludesAny)(t,[`
2
- `,"'"])?"`"+t.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")+"`":"'"+t.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\r/g,"\\r")+"'"},P=(e={},t=0)=>{if(e===null||typeof e!="object"||e instanceof RegExp)return String(e);let o=!1;for(const r in e){o=!0;break}if(!o)return"{}";const c=" ".repeat(t);let n=`{
3
- `;for(const r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;const i=e[r],s=ne.test(r)?r:re(r);if(n+=`${c} ${s}: `,i instanceof RegExp)n+=String(i);else if((0,u.isArray)(i)){n+=`[
4
- `;for(const f of i)f instanceof RegExp?n+=`${c} ${String(f)},
5
- `:(0,u.isObjectLike)(f)&&f!==null?n+=`${c} ${P(f,t+2)},
6
- `:(0,u.isString)(f)?n+=`${c} ${N(f)},
7
- `:n+=`${c} ${f},
8
- `;n+=`${c} ]`}else(0,u.isObjectLike)(i)?n+=P(i,t+1):(0,u.isString)(i)?n+=N(i):n+=i;n+=`,
9
- `}return n+=`${c}}`,n},oe=[/^\(\s*\{[^}]*\}\s*\)\s*=>/,/^(\([^)]*\)|[^=]*)\s*=>/,/^function[\s(]/,/^async\s+/,/^\(\s*function/,/^[a-zA-Z_$][a-zA-Z0-9_$]*\s*=>/,/^(?:\*\s*)?[a-zA-Z_$][\w$]*\s*\((?:[^()]|\([^()]*\))*\)\s*\{[\s\S]*\}$/],ce=/^["[{]/,ie=/^(export|import)\s/,k=e=>{if(!e)return!1;const t=e.trim().replace(/\n\s*/g," ").trim();if(t===""||t==="{}"||t==="[]"||ie.test(t)||!oe.some(r=>r.test(t)))return!1;const c=t.charCodeAt(0),n=t.includes("=>");return!(c===123&&!n||c===91||ce.test(t)&&!n)},se=e=>(0,eval)(e),fe=(e,t)=>{const o=/^(\s*(?:async\s+)?function\s*[\w$]*\s*\([^)]*\)\s*)\{/.exec(e);if(!o)return null;const c=o[0].length,n=[];let r=c,i=1,s=null;const f=e.length,l=new RegExp("^(?:const|let|var)\\s+"+t+"\\b");for(;r<f&&i>0;){const y=e[r];if(y==="/"&&e[r+1]==="/"){const d=e.indexOf(`
10
- `,r);r=d===-1?f:d;continue}if(y==="/"&&e[r+1]==="*"){const d=e.indexOf("*/",r+2);r=d===-1?f:d+2;continue}if(y==='"'||y==="'"||y==="`"){const d=y;for(r++;r<f;){if(e[r]==="\\"){r+=2;continue}if(e[r]===d){r++;break}if(d==="`"&&e[r]==="$"&&e[r+1]==="{"){r+=2;let h=1;for(;r<f&&h>0;)e[r]==="{"?h++:e[r]==="}"&&h--,r++;continue}r++}continue}if(y==="{"){i++,r++;continue}if(y==="}"){i--,r++;continue}if(i===1&&l.test(e.slice(r))){const d=r;let h=0,p=r;for(;p<f;){const g=e[p];if(g==='"'||g==="'"||g==="`"){const m=g;for(p++;p<f;){if(e[p]==="\\"){p+=2;continue}if(e[p]===m){p++;break}p++}continue}if(g==="("||g==="["||g==="{"){h++,p++;continue}if(g===")"||g==="]"||g==="}"){if(h===0)break;h--,p++;continue}if(h===0&&(g===";"||g===`
11
- `)){p++;break}p++}n.push([d,p]),r=p;continue}r++}if(!n.length)return null;let a=e;for(let y=n.length-1;y>=0;y--)a=a.slice(0,n[y][0])+a.slice(n[y][1]);return a},R=(e,t,o)=>{const c=String(e).trimStart();if(/^(export|import)\s/.test(c))return e;try{return o.window.eval(`(${e})`)}catch(n){const r=n&&n.message?n.message:String(n),i=/await is only valid in async/.test(r),s=/Identifier '([^']+)' has already been declared/.exec(r);let f=null;if(i){const l=String(e).trim();if(/^function[\s(]/.test(l))try{f=o.window.eval("(async "+l+")")}catch{}}else if(s){let l=String(e),a=s[1];for(let y=0;y<5;y++){const d=fe(l,a);if(!d||d===l)break;l=d;try{f=o.window.eval("("+l+")");break}catch(h){const p=/Identifier '([^']+)' has already been declared/.exec(h&&h.message||String(h));if(!p||p[1]!==a)break}}}if(!f&&/Unexpected (token '\{'|identifier)/.test(r))try{const l=o.window.eval("({"+e+"})");if(l&&typeof l=="object"){const a=Object.keys(l);a.length===1&&typeof l[a[0]]=="function"&&(f=l[a[0]])}}catch{}return f||(typeof console<"u"&&console.warn&&console.warn(`[smbls] deepDestringifyFunctions: eval failed on ${t} \u2014 value will be left as a string. Reason: `+r+`.
12
- First 200 chars of source: `+String(e).slice(0,200)),e)}},ue=(e,t={},o={window:{eval:se}})=>{if(!e||typeof e!="object")return t;const c=[[e,t]];for(;c.length;){const[n,r]=c.pop();for(const i in n){if(!Object.prototype.hasOwnProperty.call(n,i))continue;const s=n[i];if((0,u.isString)(s))k(s)?r[i]=R(s,`"${i}"`,o):r[i]=s;else if((0,u.isArray)(s)){const f=r[i]=[];for(let l=0;l<s.length;l++){const a=s[l];if((0,u.isString)(a))f.push(k(a)?R(a,`array index ${l} (prop "${i}")`,o):a);else if((0,u.isObject)(a)){const y=G(a);if(y)f.push(y);else{const d={};f.push(d),c.push([a,d])}}else f.push(a)}}else if((0,u.isObject)(s)){const f=G(s);if(f){r[i]=f;continue}const l=r[i]&&typeof r[i]=="object"&&!(0,u.isArray)(r[i])?r[i]:r[i]={};c.push([s,l])}else r[i]=s}}return t},D="Set",M="Map",W="RegExp",I="WeakMap",C="WeakSet",b=e=>{const t=Object.keys(e);return t.length===1&&t[0]==="__type"},S=(e,t)=>{if(!e||typeof e!="object")return e;const o=r=>S(r,t||(t=new WeakMap));if(e.__type===D&&(0,u.isArray)(e.values))return new Set(e.values.map(o));if(e.__type===M&&(0,u.isArray)(e.entries))return new Map(e.entries.map(r=>(0,u.isArray)(r)?[o(r[0]),o(r[1])]:r));if(e.__type===I&&b(e))return new WeakMap;if(e.__type===C&&b(e))return new WeakSet;if(e.__type===W&&(0,u.isString)(e.source))try{return new RegExp(e.source,(0,u.isString)(e.flags)?e.flags:"")}catch{return e}if(t||(t=new WeakMap),t.has(e))return t.get(e);let c=!1;if((0,u.isArray)(e)){const r=new Array(e.length);t.set(e,r);for(let i=0;i<e.length;i++)r[i]=S(e[i],t),r[i]!==e[i]&&(c=!0);return c||t.set(e,e),c?r:e}const n={};t.set(e,n);for(const r of Object.keys(e))n[r]=S(e[r],t),n[r]!==e[r]&&(c=!0);return c||t.set(e,e),c?n:e},G=e=>{if(!e||typeof e!="object")return null;const t=e.__type;if(t!==W&&t!==D&&t!==M&&t!==I&&t!==C)return null;const o=S(e);return o===e?null:o},le=e=>{if(!e||typeof e!="object")return e;const t={},o=[];for(const i of Object.keys(e)){const s=e[i];(0,u.isString)(s)&&k(s)?o.push([i,s]):t[i]=S(s)}if(o.length===0)return t;const c=i=>/^[A-Za-z_$][\w$]*$/.test(i),n=o.filter(([i])=>c(i)),r=Object.keys(t).filter(c).map(i=>`var ${i} = __gs__[${JSON.stringify(i)}];`).join(`
13
- `);try{const i=n.map(([l,a])=>`var ${l} = (${a});`).join(`
14
- `),s="{ "+n.map(([l])=>`${JSON.stringify(l)}: ${l}`).join(", ")+" }",f=O.window.eval(`(function(__gs__) { ${r}
15
- ${i}
16
- return ${s}; })`)(t);Object.assign(t,f)}catch{for(const[s,f]of n)try{const l=Object.keys(t).filter(c).map(a=>`var ${a} = __gs__[${JSON.stringify(a)}];`).join(`
17
- `);t[s]=O.window.eval(`(function(__gs__) { ${l}
18
- return (${f}); })`)(t)}catch{try{t[s]=O.window.eval(`(${f})`)}catch{t[s]=f}}}for(const[i,s]of o)if(!c(i))try{t[i]=O.window.eval(`(${s})`)}catch{t[i]=s}return t},ae=(e,t={verbose:!0})=>{try{return e?O.window.eval("("+e+")"):{}}catch(o){t.verbose&&console.warn(o)}},pe=(e,...t)=>Object.prototype.hasOwnProperty.call(e,...t),z=e=>{for(const t in e)return!1;return!0},ye=e=>(0,u.isObject)(e)&&z(e),he=()=>Object.create(null),de=(e,t,o={})=>{const c=o.exclude||[],n=o.preventUnderscore;for(const r in t)c.includes(r)||!n&&w(r)||r==="constructor"||r==="prototype"||t[r]!==void 0&&(e[r]=t[r]);return e},ge=(e,t,o=[])=>{const c=o instanceof Set;for(const n in t)w(n)||n==="constructor"||n==="prototype"||(c?o.has(n):o.includes(n))||(e[n]=t[n]);return e},K=(e,t,o={},c=new WeakMap)=>{if(!(0,u.isObjectLike)(e)||!(0,u.isObjectLike)(t)||(0,_.isDOMNode)(e)||(0,_.isDOMNode)(t))return t;if(c.has(e))return c.get(e);c.set(e,e);const n=o.exclude,r=n?n instanceof Set?n:new Set(n):null,i=!o.preventForce;for(const s in t){if(!Object.prototype.hasOwnProperty.call(t,s)||r&&r.has(s)||i&&w(s)||s==="constructor"||s==="prototype")continue;const f=e[s],l=t[s];(0,_.isDOMNode)(l)?e[s]=l:(0,u.isObjectLike)(f)&&(0,u.isObjectLike)(l)?e[s]=K(f,l,o,c):l!==void 0&&(e[s]=l)}return e},Y=(e,t,o=new Set)=>{if(typeof e!="object"||typeof t!="object"||e===null||t===null)return e===t;if(o.has(e)||o.has(t))return!0;o.add(e),o.add(t);const c=Object.keys(e),n=Object.keys(t);if(c.length!==n.length)return!1;for(let r=0;r<c.length;r++){const i=c[r];if(!Object.prototype.hasOwnProperty.call(t,i)||!Y(e[i],t[i],o))return!1}return!0},_e=new Set(["node","__ref"]),we=(e,t,o=_e)=>{if(e===t)return!0;if(!(0,u.isObjectLike)(e)||!(0,u.isObjectLike)(t)||(0,_.isDOMNode)(e)||(0,_.isDOMNode)(t))return e===t;const c=o instanceof Set?o:new Set(o),n=new WeakSet;function r(i,s){if(n.has(s))return!0;n.add(s);for(const f in s){if(!Object.prototype.hasOwnProperty.call(s,f)||c.has(f))continue;if(!Object.prototype.hasOwnProperty.call(i,f))return!1;const l=s[f],a=i[f];if((0,_.isDOMNode)(l)||(0,_.isDOMNode)(a)){if(l!==a)return!1}else if((0,u.isObjectLike)(l)&&(0,u.isObjectLike)(a)){if(!r(a,l))return!1}else if(l!==a)return!1}return!0}return r(e,t)},Oe=(e,t)=>{if(t==null)return e;if((0,u.is)(t)("string","number"))delete e[t];else if((0,u.isArray)(t))for(let o=0;o<t.length;o++)delete e[t[o]];else throw new Error("Invalid input: props must be a string or an array of strings");return e},Z=e=>{if(e===null||typeof e!="object")return e;const t=Object.create(null);for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=Z(e[o]));return t},Se=(e,t)=>{if(e.length===0)return t;const o={};let c=o;for(let n=0;n<e.length;n++)n===e.length-1&&t?c[e[n]]=t:(c[e[n]]={},c=c[e[n]]);return o},ke=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let o=e;for(let n=0;n<t.length-1;n++){if(o[t[n]]===void 0)return;o=o[t[n]]}const c=t[t.length-1];o&&Object.prototype.hasOwnProperty.call(o,c)&&delete o[c]},$e=(e,t,o)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let c=e;for(let n=0;n<t.length-1;n++)(!c[t[n]]||typeof c[t[n]]!="object")&&(c[t[n]]={}),c=c[t[n]];return c[t[t.length-1]]=o,e},xe=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let o=e;for(let c=0;c<t.length;c++){if(o==null)return;o=o[t[c]]}return o},Ee=e=>{let o=[],c=0;for(let n=0;n<e.length;n++)if(o.length<2)o.push(e[n]);else if(e[n]===o[n%2]?c++:(o=[e[n-1],e[n]],c=1),c>=20)return(A==="test"||A==="development")&&console.warn("Warning: Potential infinite loop detected due to repeated sequence:",o),!0},Pe=e=>{const t=new WeakSet;function o(c){if(c&&typeof c=="object"){if(t.has(c))return!0;t.add(c);for(const n in c)if(Object.prototype.hasOwnProperty.call(c,n)&&o(c[n]))return console.log(c,"cycle at "+n),!0}return!1}return o(e)},Ae=(e,t)=>{const o=t instanceof Set?t:new Set(t),c={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&!o.has(n)&&(c[n]=e[n]);return c};
1
+ "use strict";var P=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var re=Object.prototype.hasOwnProperty;var oe=(e,t)=>{for(var n in t)P(e,n,{get:t[n],enumerable:!0})},ie=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ne(t))!re.call(e,r)&&r!==n&&P(e,r,{get:()=>t[r],enumerable:!(o=te(t,r))||o.enumerable});return e};var ce=e=>ie(P({},"__esModule",{value:!0}),e);var je={};oe(je,{clone:()=>ue,createNestedObject:()=>Be,createObjectWithoutPrototype:()=>ee,deepClone:()=>ae,deepContains:()=>Ge,deepDestringifyFunctions:()=>me,deepMerge:()=>le,deepStringifyFunctions:()=>R,destringifyGlobalScope:()=>Fe,detectInfiniteLoop:()=>Ve,excludeKeysFromObject:()=>Qe,exec:()=>N,getFunctionSource:()=>De,getInObjectByPath:()=>Je,hasFunction:()=>k,hasOwnProperty:()=>Me,isCyclic:()=>Xe,isEmpty:()=>X,isEmptyObject:()=>We,isEqualDeep:()=>j,isFailedRevival:()=>ze,isLazyFunction:()=>Ce,makeObjectWithoutPrototype:()=>Ye,map:()=>se,merge:()=>fe,objectToString:()=>C,overwrite:()=>ve,overwriteDeep:()=>Q,overwriteShallow:()=>Ze,removeFromObject:()=>Ke,removeNestedKeyByPath:()=>Ue,setInObjectByPath:()=>qe,stringToObject:()=>be});module.exports=ce(je);var S=require("./globals.js"),l=require("./types.js"),q=require("./array.js"),J=require("./string.js"),_=require("./node.js"),V=require("./keys.js");const z="production",w=e=>e.charCodeAt(0)===95&&e.charCodeAt(1)===95,N=(e,t,n,o)=>{if((0,l.isFunction)(e))return t?typeof e.call!="function"?e:e.call(t,t,n||t.state,o||t.context):void 0;if(e!=null&&t?.context?.plugins&&((0,l.isArray)(e)||(0,l.isObject)(e)&&!(0,_.isDOMNode)(e))){const r=t.context.plugins;for(const i of r)if(i.resolveHandler){const c=i.resolveHandler(e,t);if(typeof c=="function")return N(c,t,n,o)}}return e},se=(e,t,n)=>{for(const o in t)e[o]=N(t[o],n)},fe=(e,t,n=[])=>{const o=n instanceof Set;for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(w(r)||(o?n.has(r):n.includes(r))||e[r]===void 0&&(e[r]=t[r]));return e},le=(e,t,n=V.METHODS_EXL)=>L(e,t,n,null),L=(e,t,n,o)=>{if(e===t)return e;if(o){for(let i=0;i<o.length;i+=2)if(o[i]===e&&o[i+1]===t)return e}const r=n instanceof Set;for(const i in t){if(!Object.prototype.hasOwnProperty.call(t,i)||w(i)||i==="constructor"||i==="prototype"||(r?n.has(i):n.includes(i)))continue;const c=e[i],u=t[i];if((0,l.isObjectLike)(c)&&(0,l.isObjectLike)(u)){const s=o||[];s.push(e,t),L(c,u,n,s),s.length-=2}else c===void 0&&(e[i]=u)}return e},ue=(e,t=[])=>{const n=t instanceof Set,o={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(w(r)||(n?t.has(r):t.includes(r))||(o[r]=e[r]));return o},ae=(e,t={})=>{const{exclude:n=[],cleanUndefined:o=!1,cleanNull:r=!1,visited:i=new WeakMap,handleExtends:c=!1}=t;if(!(0,l.isObjectLike)(e)||(0,_.isDOMNode)(e))return e;if(i.has(e))return i.get(e);const u=n instanceof Set?n:n.length>3?new Set(n):null,s=a=>u?u.has(a):n.includes(a),y=(0,l.isArray)(e)?[]:{};i.set(e,y);const f=[[e,y]];for(;f.length;){const[a,g]=f.pop();for(const d in a){if(!Object.prototype.hasOwnProperty.call(a,d)||w(d)||d==="__proto__"||s(d))continue;const p=a[d];if(!(o&&p===void 0)&&!(r&&p===null)){if((0,_.isDOMNode)(p)){g[d]=p;continue}if(c&&d==="extends"&&(0,l.isArray)(p)){g[d]=(0,q.unstackArrayOfObjects)(p,n);continue}if((0,l.isFunction)(p)){g[d]=p;continue}if((0,l.isObjectLike)(p))if(i.has(p))g[d]=i.get(p);else{const h=(0,l.isArray)(p)?[]:{};i.set(p,h),g[d]=h,f.push([p,h])}else g[d]=p}}}return y},R=(e,t={})=>{(e.node||e.__ref||e.parent||e.__element||e.parse)&&((e.__element||e.parent?.__element).warn("Trying to clone element or state at",e),e=e.parse?.());for(const n in e){const o=e[n];if((0,l.isFunction)(o))t[n]=o.toString();else if((0,l.isObject)(o))t[n]={},R(o,t[n]);else if((0,l.isArray)(o)){const r=t[n]=[];for(let i=0;i<o.length;i++){const c=o[i];(0,l.isObject)(c)?(r[i]={},R(c,r[i])):(0,l.isFunction)(c)?r[i]=c.toString():r[i]=c}}else t[n]=o}return t},pe=/^[A-Za-z_$][A-Za-z0-9_$]*$/,ye=e=>`'${String(e).replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\r/g,"\\r").replace(/\n/g,"\\n")}'`,I=e=>{const t=String(e);return(0,J.stringIncludesAny)(t,[`
2
+ `,"'"])?"`"+t.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")+"`":"'"+t.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\r/g,"\\r")+"'"},C=(e={},t=0)=>{if(e===null||typeof e!="object"||e instanceof RegExp)return String(e);let n=!1;for(const i in e){n=!0;break}if(!n)return"{}";const o=" ".repeat(t);let r=`{
3
+ `;for(const i in e){if(!Object.prototype.hasOwnProperty.call(e,i))continue;const c=e[i],u=pe.test(i)?i:ye(i);if(r+=`${o} ${u}: `,c instanceof RegExp)r+=String(c);else if((0,l.isArray)(c)){r+=`[
4
+ `;for(const s of c)s instanceof RegExp?r+=`${o} ${String(s)},
5
+ `:(0,l.isObjectLike)(s)&&s!==null?r+=`${o} ${C(s,t+2)},
6
+ `:(0,l.isString)(s)?r+=`${o} ${I(s)},
7
+ `:r+=`${o} ${s},
8
+ `;r+=`${o} ]`}else(0,l.isObjectLike)(c)?r+=C(c,t+1):(0,l.isString)(c)?r+=I(c):r+=c;r+=`,
9
+ `}return r+=`${o}}`,r},de=[/^\(\s*\{[^}]*\}\s*\)\s*=>/,/^(\([^)]*\)|[^=]*)\s*=>/,/^function[\s(]/,/^async\s+/,/^\(\s*function/,/^[a-zA-Z_$][a-zA-Z0-9_$]*\s*=>/,/^(?:\*\s*)?[a-zA-Z_$][\w$]*\s*\((?:[^()]|\([^()]*\))*\)\s*\{[\s\S]*\}$/],he=/^["[{]/,ge=/^(export|import)\s/,k=e=>{if(!e)return!1;const t=e.trim();if(t===""||t==="{}"||t==="[]")return!1;const n=t.includes("=>");if(!n&&t.charCodeAt(0)!==40&&!t.startsWith("function")&&!t.startsWith("async")&&!(t.charCodeAt(t.length-1)===125&&t.includes("("))||ge.test(t)||!de.some(i=>i.test(t)))return!1;const r=t.charCodeAt(0);return!(r===123&&!n||r===91||he.test(t)&&!n)},m=e=>(0,eval)(e),_e=(e,t)=>{const n=/^(\s*(?:async\s+)?function\s*[\w$]*\s*\([^)]*\)\s*)\{/.exec(e);if(!n)return null;const o=n[0].length,r=[];let i=o,c=1,u=null;const s=e.length,y=new RegExp("^(?:const|let|var)\\s+"+t+"\\b");for(;i<s&&c>0;){const a=e[i];if(a==="/"&&e[i+1]==="/"){const g=e.indexOf(`
10
+ `,i);i=g===-1?s:g;continue}if(a==="/"&&e[i+1]==="*"){const g=e.indexOf("*/",i+2);i=g===-1?s:g+2;continue}if(a==='"'||a==="'"||a==="`"){const g=a;for(i++;i<s;){if(e[i]==="\\"){i+=2;continue}if(e[i]===g){i++;break}if(g==="`"&&e[i]==="$"&&e[i+1]==="{"){i+=2;let d=1;for(;i<s&&d>0;)e[i]==="{"?d++:e[i]==="}"&&d--,i++;continue}i++}continue}if(a==="{"){c++,i++;continue}if(a==="}"){c--,i++;continue}if(c===1&&y.test(e.slice(i))){const g=i;let d=0,p=i;for(;p<s;){const h=e[p];if(h==='"'||h==="'"||h==="`"){const A=h;for(p++;p<s;){if(e[p]==="\\"){p+=2;continue}if(e[p]===A){p++;break}p++}continue}if(h==="("||h==="["||h==="{"){d++,p++;continue}if(h===")"||h==="]"||h==="}"){if(d===0)break;d--,p++;continue}if(d===0&&(h===";"||h===`
11
+ `)){p++;break}p++}r.push([g,p]),i=p;continue}i++}if(!r.length)return null;let f=e;for(let a=r.length-1;a>=0;a--)f=f.slice(0,r[a][0])+f.slice(r[a][1]);return f},x=(e,t,n,o)=>{const r=String(e).trimStart();if(/^(export|import)\s/.test(r))return e;try{return n.window.eval(`(${e})`)}catch(i){const c=i&&i.message?i.message:String(i),u=/await is only valid in async/.test(c),s=/Identifier '([^']+)' has already been declared/.exec(c);let y=null;if(u){const f=String(e).trim();if(/^function[\s(]/.test(f))try{y=n.window.eval("(async "+f+")")}catch{}}else if(s){let f=String(e),a=s[1];for(let g=0;g<5;g++){const d=_e(f,a);if(!d||d===f)break;f=d;try{y=n.window.eval("("+f+")");break}catch(p){const h=/Identifier '([^']+)' has already been declared/.exec(p&&p.message||String(p));if(!h||h[1]!==a)break}}}if(!y&&/Unexpected (token '\{'|identifier)/.test(c))try{const f=n.window.eval("({"+e+"})");if(f&&typeof f=="object"){const a=Object.keys(f);a.length===1&&typeof f[a[0]]=="function"&&(y=f[a[0]])}}catch{}return y||(typeof console<"u"&&console.warn&&console.warn(`[smbls] deepDestringifyFunctions: eval failed on ${t} \u2014 `+(o?"revived lazily, so its source compiled on this first use; it acts as the string it replaces (a call returns the source text, el.call treats it as not callable). Reason: ":"value will be left as a string. Reason: ")+c+`.
12
+ First 200 chars of source: `+String(e).slice(0,200)),e)}},F=1,T=2,O=new WeakMap,we=/^(async\s+)?function(?![\w$])\s*(\*)?\s*([A-Za-z_$][\w$]*)?\s*\((?:[^()'"`/]|\([^()'"`/]*\))*\)\s*\{/,Oe=/^(async\s+)?[A-Za-z_$][\w$]*\s*=>/,Se=/^(async\s*)?\((?:[^()'"`/]|\([^()'"`/]*\))*\)\s*=>/,Ee=/^(async\s+)?([A-Za-z_$][\w$]*)\s*\((?:[^()'"`/]|\([^()'"`/]*\))*\)\s*\{/,Ae=new Set(["if","for","while","switch","catch","with","do","return","typeof","void","delete","new","in","of","instanceof","function","class","const","let","var","await","yield","import","export","try","else","throw","case","default","break","continue","debugger","finally","super","this","null","true","false","async","get","set","static"]),b=e=>e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===36||e===95,xe=(e,t,n)=>{let o=e.indexOf(t,n);for(;o!==-1;){const r=o+t.length;if((o===0||!b(e.charCodeAt(o-1)))&&(r>=e.length||!b(e.charCodeAt(r))))return!0;o=e.indexOf(t,r)}return!1},M=e=>{let t=e.length-1;for(;t>=0&&e.charCodeAt(t)<=32;)t--;return t<0?-1:e.charCodeAt(t)},$e=e=>{let t=e,n=0;for(;n<t.length&&t.charCodeAt(n)<=32;)n++;n&&(t=t.slice(n));let o=we.exec(t);if(o){if(o[2]||M(t)!==125)return null;const r=o[3]||"";return r&&xe(t,r,o[0].indexOf("("))||t.indexOf("arguments.callee")!==-1?null:{src:e,name:r,kind:o[1]?T:F,async:!!o[1],fn:void 0}}return o=Oe.exec(t)||Se.exec(t),o?{src:e,name:"",kind:T,async:!!o[1],fn:void 0}:(o=Ee.exec(t),o&&!Ae.has(o[2])&&M(t)===125?t.indexOf("arguments.callee")!==-1?null:{src:e,name:o[2],kind:T,async:!!o[1],fn:void 0}:null)},W=e=>e.index===-1?`"${e.key}"`:`array index ${e.index} (prop "${e.key}")`,$=e=>{const t=x(e.src,W(e),e.opts,!0);let n=null;return typeof t=="function"?n=t:(e.value=t,typeof t!="string"&&typeof console<"u"&&console.warn&&console.warn(`[smbls] deepDestringifyFunctions: ${W(e)} did not evaluate to a function \u2014 the lazily revived function returns that value.
13
+ First 200 chars of source: `+String(e.src).slice(0,200))),e.fn=n,e.opts=null,n},ke=(e,t,n)=>Reflect.construct(e,t,n);function Pe(){const e=O.get(this);return e?e.src.trim():Function.prototype.toString.call(this)}const Te={length:{get(){const e=O.get(this);if(!e)return 0;const t=e.fn===void 0?$(e):e.fn;return t?t.length:0},configurable:!0},name:{get(){const e=O.get(this);return e?e.name:""},configurable:!0},toString:{value:Pe,writable:!0,configurable:!0}},Ne=Object.getPrototypeOf(async function(){}),Re=e=>{let t;return e.kind===F?t=function(){const n=e.fn===void 0?$(e):e.fn;return n===null?e.value:new.target?ke(n,arguments,new.target):n.apply(this,arguments)}:t={lazy(){const n=e.fn===void 0?$(e):e.fn;return n===null?e.value:n.apply(this,arguments)}}.lazy,O.set(t,e),Object.defineProperties(t,Te),e.async&&Object.setPrototypeOf(t,Ne),t},Y=(e,t,n,o)=>{const r=$e(e);return r?(r.key=t,r.index=n,r.opts=o,Re(r)):x(e,n===-1?`"${t}"`:`array index ${n} (prop "${t}")`,o)},Ce=e=>typeof e=="function"&&O.has(e),De=e=>{const t=O.get(e);return t?t.src.trim():Function.prototype.toString.call(e)},ze=e=>{const t=typeof e=="function"?O.get(e):void 0;return t?(t.fn===void 0?$(t):t.fn)===null:!1},Le=new Set(["components","pages","functions","methods","snippets","app","globalScope"]),Ie={window:{eval:m}},me=(e,t={},n=Ie)=>{if(!e||typeof e!="object")return t;(!n||!n.window||typeof n.window.eval!="function")&&(n={...n,window:{eval:m}});const o=n.lazy===!0,r=n.lazy==="context",i=(u,s,y)=>o||r&&(u===e?Le.has(s):y),c=[[e,t,o]];for(;c.length;){const[u,s,y]=c.pop();for(const f in u){if(!Object.prototype.hasOwnProperty.call(u,f))continue;const a=u[f];if((0,l.isString)(a))k(a)?s[f]=y?Y(a,f,-1,n):x(a,`"${f}"`,n):s[f]=a;else if((0,l.isArray)(a)){const g=s[f]=[],d=i(u,f,y);for(let p=0;p<a.length;p++){const h=a[p];if((0,l.isString)(h))g.push(k(h)?d?Y(h,f,p,n):x(h,`array index ${p} (prop "${f}")`,n):h);else if((0,l.isObject)(h)){const A=U(h);if(A)g.push(A);else{const D={};g.push(D),c.push([h,D,d])}}else g.push(h)}}else if((0,l.isObject)(a)){const g=U(a);if(g){s[f]=g;continue}const d=s[f]&&typeof s[f]=="object"&&!(0,l.isArray)(s[f])?s[f]:s[f]={};c.push([a,d,i(u,f,y)])}else s[f]=a}}return t},v="Set",Z="Map",H="RegExp",G="WeakMap",K="WeakSet",B=e=>{const t=Object.keys(e);return t.length===1&&t[0]==="__type"},E=(e,t)=>{if(!e||typeof e!="object")return e;const n=i=>E(i,t||(t=new WeakMap));if(e.__type===v&&(0,l.isArray)(e.values))return new Set(e.values.map(n));if(e.__type===Z&&(0,l.isArray)(e.entries))return new Map(e.entries.map(i=>(0,l.isArray)(i)?[n(i[0]),n(i[1])]:i));if(e.__type===G&&B(e))return new WeakMap;if(e.__type===K&&B(e))return new WeakSet;if(e.__type===H&&(0,l.isString)(e.source))try{return new RegExp(e.source,(0,l.isString)(e.flags)?e.flags:"")}catch{return e}if(t||(t=new WeakMap),t.has(e))return t.get(e);let o=!1;if((0,l.isArray)(e)){const i=new Array(e.length);t.set(e,i);for(let c=0;c<e.length;c++)i[c]=E(e[c],t),i[c]!==e[c]&&(o=!0);return o||t.set(e,e),o?i:e}const r={};t.set(e,r);for(const i of Object.keys(e))r[i]=E(e[i],t),r[i]!==e[i]&&(o=!0);return o||t.set(e,e),o?r:e},U=e=>{if(!e||typeof e!="object")return null;const t=e.__type;if(t!==H&&t!==v&&t!==Z&&t!==G&&t!==K)return null;const n=E(e);return n===e?null:n},Fe=e=>{if(!e||typeof e!="object")return e;const t={},n=[];for(const c of Object.keys(e)){const u=e[c];(0,l.isString)(u)&&k(u)?n.push([c,u]):t[c]=E(u)}if(n.length===0)return t;const o=c=>/^[A-Za-z_$][\w$]*$/.test(c),r=n.filter(([c])=>o(c)),i=Object.keys(t).filter(o).map(c=>`var ${c} = __gs__[${JSON.stringify(c)}];`).join(`
14
+ `);try{const c=r.map(([y,f])=>`var ${y} = (${f});`).join(`
15
+ `),u="{ "+r.map(([y])=>`${JSON.stringify(y)}: ${y}`).join(", ")+" }",s=S.window.eval(`(function(__gs__) { ${i}
16
+ ${c}
17
+ return ${u}; })`)(t);Object.assign(t,s)}catch{for(const[u,s]of r)try{const y=Object.keys(t).filter(o).map(f=>`var ${f} = __gs__[${JSON.stringify(f)}];`).join(`
18
+ `);t[u]=S.window.eval(`(function(__gs__) { ${y}
19
+ return (${s}); })`)(t)}catch{try{t[u]=S.window.eval(`(${s})`)}catch{t[u]=s}}}for(const[c,u]of n)if(!o(c))try{t[c]=S.window.eval(`(${u})`)}catch{t[c]=u}return t},be=(e,t={verbose:!0})=>{try{return e?S.window.eval("("+e+")"):{}}catch(n){t.verbose&&console.warn(n)}},Me=(e,...t)=>Object.prototype.hasOwnProperty.call(e,...t),X=e=>{for(const t in e)return!1;return!0},We=e=>(0,l.isObject)(e)&&X(e),Ye=()=>Object.create(null),ve=(e,t,n={})=>{const o=n.exclude||[],r=n.preventUnderscore;for(const i in t)o.includes(i)||!r&&w(i)||i==="constructor"||i==="prototype"||t[i]!==void 0&&(e[i]=t[i]);return e},Ze=(e,t,n=[])=>{const o=n instanceof Set;for(const r in t)w(r)||r==="constructor"||r==="prototype"||(o?n.has(r):n.includes(r))||(e[r]=t[r]);return e},Q=(e,t,n={},o=new WeakMap)=>{if(!(0,l.isObjectLike)(e)||!(0,l.isObjectLike)(t)||(0,_.isDOMNode)(e)||(0,_.isDOMNode)(t))return t;if(o.has(e))return o.get(e);o.set(e,e);const r=n.exclude,i=r?r instanceof Set?r:new Set(r):null,c=!n.preventForce;for(const u in t){if(!Object.prototype.hasOwnProperty.call(t,u)||i&&i.has(u)||c&&w(u)||u==="constructor"||u==="prototype")continue;const s=e[u],y=t[u];(0,_.isDOMNode)(y)?e[u]=y:(0,l.isObjectLike)(s)&&(0,l.isObjectLike)(y)?e[u]=Q(s,y,n,o):y!==void 0&&(e[u]=y)}return e},j=(e,t,n=new Set)=>{if(typeof e!="object"||typeof t!="object"||e===null||t===null)return e===t;if(n.has(e)||n.has(t))return!0;n.add(e),n.add(t);const o=Object.keys(e),r=Object.keys(t);if(o.length!==r.length)return!1;for(let i=0;i<o.length;i++){const c=o[i];if(!Object.prototype.hasOwnProperty.call(t,c)||!j(e[c],t[c],n))return!1}return!0},He=new Set(["node","__ref"]),Ge=(e,t,n=He)=>{if(e===t)return!0;if(!(0,l.isObjectLike)(e)||!(0,l.isObjectLike)(t)||(0,_.isDOMNode)(e)||(0,_.isDOMNode)(t))return e===t;const o=n instanceof Set?n:new Set(n),r=new WeakSet;function i(c,u){if(r.has(u))return!0;r.add(u);for(const s in u){if(!Object.prototype.hasOwnProperty.call(u,s)||o.has(s))continue;if(!Object.prototype.hasOwnProperty.call(c,s))return!1;const y=u[s],f=c[s];if((0,_.isDOMNode)(y)||(0,_.isDOMNode)(f)){if(y!==f)return!1}else if((0,l.isObjectLike)(y)&&(0,l.isObjectLike)(f)){if(!i(f,y))return!1}else if(y!==f)return!1}return!0}return i(e,t)},Ke=(e,t)=>{if(t==null)return e;if((0,l.is)(t)("string","number"))delete e[t];else if((0,l.isArray)(t))for(let n=0;n<t.length;n++)delete e[t[n]];else throw new Error("Invalid input: props must be a string or an array of strings");return e},ee=e=>{if(e===null||typeof e!="object")return e;const t=Object.create(null);for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=ee(e[n]));return t},Be=(e,t)=>{if(e.length===0)return t;const n={};let o=n;for(let r=0;r<e.length;r++)r===e.length-1&&t?o[e[r]]=t:(o[e[r]]={},o=o[e[r]]);return n},Ue=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let n=e;for(let r=0;r<t.length-1;r++){if(n[t[r]]===void 0)return;n=n[t[r]]}const o=t[t.length-1];n&&Object.prototype.hasOwnProperty.call(n,o)&&delete n[o]},qe=(e,t,n)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let o=e;for(let r=0;r<t.length-1;r++)(!o[t[r]]||typeof o[t[r]]!="object")&&(o[t[r]]={}),o=o[t[r]];return o[t[t.length-1]]=n,e},Je=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let n=e;for(let o=0;o<t.length;o++){if(n==null)return;n=n[t[o]]}return n},Ve=e=>{let n=[],o=0;for(let r=0;r<e.length;r++)if(n.length<2)n.push(e[r]);else if(e[r]===n[r%2]?o++:(n=[e[r-1],e[r]],o=1),o>=20)return(z==="test"||z==="development")&&console.warn("Warning: Potential infinite loop detected due to repeated sequence:",n),!0},Xe=e=>{const t=new WeakSet;function n(o){if(o&&typeof o=="object"){if(t.has(o))return!0;t.add(o);for(const r in o)if(Object.prototype.hasOwnProperty.call(o,r)&&n(o[r]))return console.log(o,"cycle at "+r),!0}return!1}return n(e)},Qe=(e,t)=>{const n=t instanceof Set?t:new Set(t),o={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&!n.has(r)&&(o[r]=e[r]);return o};
@@ -1 +1 @@
1
- function l(t,e,o){let n;return function(){const r=this,s=arguments,u=function(){n=null,o||t.apply(r,s)},c=o&&!n;clearTimeout(n),n=setTimeout(u,e),c&&t.apply(r,s)}}const p=(t,e,o=300)=>{let n;return(...r)=>{clearTimeout(n),n=setTimeout(()=>{e.apply(t,r)},o)}},f=t=>{const e={};return(...o)=>{const n=o[0];if(n in e)return e[n];{const r=t(n);return e[n]=r,r}}},i=/^((function\s*\([^)]*\)\s*\{[^}]*\})|(\([^)]*\)\s*=>))/,a=t=>i.test(t),g=t=>{const e=t?.plugins;if(!e||!e.length)return!1;for(const o of e)if(o.resolveHandler)return!0;return!1},x=(t,e)=>{if(typeof t=="function")return t;const o=e?.context?.plugins;if(!o)return t;for(const n of o)if(n.resolveHandler){const r=n.resolveHandler(t,e);if(typeof r=="function")return r}return t},y=(t,e,...o)=>{const n=e?.context?.plugins;if(!n)return!1;let r=!1;for(const s of n)typeof s[t]=="function"&&(s[t](e,...o),r=!0);return r};function d(t,e=window){const o=function(){return t.apply(e,arguments)};for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(o[n]=t[n]);return o}export{d as cloneFunction,l as debounce,p as debounceOnContext,g as hasHandlerPlugin,a as isStringFunction,f as memoize,x as resolveHandler,y as runPluginHook};
1
+ function l(t,e,o){let n;return function(){const r=this,s=arguments,u=function(){n=null,o||t.apply(r,s)},c=o&&!n;clearTimeout(n),n=setTimeout(u,e),c&&t.apply(r,s)}}const p=(t,e,o=300)=>{let n;return(...r)=>{clearTimeout(n),n=setTimeout(()=>{e.apply(t,r)},o)}},f=t=>{const e={};return(...o)=>{const n=o[0];if(n in e)return e[n];{const r=t(n);return e[n]=r,r}}},i=/^\s*(?:async\s+)?(?:function\b|\([^)]*\)\s*=>|[a-zA-Z_$][\w$]*\s*=>)/,a=t=>i.test(t),g=t=>{const e=t?.plugins;if(!e||!e.length)return!1;for(const o of e)if(o.resolveHandler)return!0;return!1},x=(t,e)=>{if(typeof t=="function")return t;const o=e?.context?.plugins;if(!o)return t;for(const n of o)if(n.resolveHandler){const r=n.resolveHandler(t,e);if(typeof r=="function")return r}return t},y=(t,e,...o)=>{const n=e?.context?.plugins;if(!n)return!1;let r=!1;for(const s of n)typeof s[t]=="function"&&(s[t](e,...o),r=!0);return r};function d(t,e=window){const o=function(){return t.apply(e,arguments)};for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(o[n]=t[n]);return o}export{d as cloneFunction,l as debounce,p as debounceOnContext,g as hasHandlerPlugin,a as isStringFunction,f as memoize,x as resolveHandler,y as runPluginHook};
@@ -1,2 +1,2 @@
1
- import{isObject as S}from"./types.js";const a=r=>{if(r==null)return"";const o={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};return r.toString().replace(/[&<>"']/g,e=>o[e])},M=r=>Object.entries(r||{}).filter(([o,e])=>e!==void 0).map(([o,e])=>`${o}="${a(e)}"`).join(" "),j=r=>{let o=5381;const e=String(r);for(let t=0;t<e.length;t++)o=(o*33^e.charCodeAt(t))>>>0;return o.toString(36)},w=new Set(["jsonLd","styles","scripts"]),L=r=>{const o=[];if(Array.isArray(r.jsonLd))for(const e of r.jsonLd){if(e==null)continue;const t=typeof e=="string"?e:JSON.stringify(e),n=String(t).replace(/<\/script/gi,"<\\/script");o.push(`<script type="application/ld+json" data-smbls-jsonld="${j(t)}">${n}<\/script>`)}if(Array.isArray(r.styles))for(const e of r.styles){if(e==null||!String(e).trim())continue;const t=String(e).replace(/<\/style/gi,"<\\/style");o.push(`<style data-smbls-style="${j(t)}">${t}</style>`)}if(Array.isArray(r.scripts))for(const e of r.scripts){if(!e)continue;const t=typeof e=="string",n=t?e:e.src;if(!n&&!e.body)continue;const i=[];n&&i.push(`src="${a(n)}"`),t||(e.type&&i.push(`type="${a(e.type)}"`),e.async&&i.push("async"),e.defer&&i.push("defer"),e.integrity&&i.push(`integrity="${a(e.integrity)}"`),e.crossorigin&&i.push(`crossorigin="${a(e.crossorigin)}"`),e.referrerpolicy&&i.push(`referrerpolicy="${a(e.referrerpolicy)}"`),e.nomodule&&i.push("nomodule"));const f=` data-smbls-script="${a(n||j(e.body||""))}"`;if(!t&&e.body){const h=String(e.body).replace(/<\/script/gi,"<\\/script");o.push(`<script ${i.join(" ")}${f}>${h}<\/script>`)}else o.push(`<script ${i.join(" ")}${f}><\/script>`)}return o},x=(r,o)=>{o||(r={...r,robots:"noindex"});const e=Object.entries(r).reduce((t,[n,i])=>{if(!i&&i!==0&&i!==!1||w.has(n))return t;if(n==="title")return t.push(`<title>${a(i)}</title>`),t;if(n==="canonical")return t.push(`<link rel="canonical" href="${a(i)}">`),t;if(n==="manifest")return t.push(`<link rel="manifest" href="${a(i)}">`),t;if(n==="favicon"||n==="favicons"||n==="icon"||n==="icons")return(Array.isArray(i)?i:[i]).forEach(p=>{if(typeof p=="string")t.push(`<link rel="icon" href="${a(p)}">`);else if(typeof p=="object"){const u=M(p);/rel=/.test(u)?t.push(`<link ${u}>`):t.push(`<link rel="icon" ${u}>`)}}),t;if(n==="alternate")return(Array.isArray(i)?i:[i]).forEach(p=>{if(typeof p=="object"){const u=Object.entries(p).filter(([s,g])=>g!==void 0).map(([s,g])=>`${s}="${a(g)}"`).join(" ");t.push(`<link rel="alternate" ${u}>`)}}),t;const f=(l,p,u="name")=>{if(typeof p=="string"||typeof p=="number"||typeof p=="boolean")t.push(`<meta ${u}="${a(l)}" content="${a(p)}">`);else if(Array.isArray(p))p.forEach(s=>{if(typeof s=="string"||typeof s=="number"||typeof s=="boolean")t.push(`<meta ${u}="${a(l)}" content="${a(s)}">`);else if(typeof s=="object"){const g=Object.entries(s).filter(([d,c])=>c!==void 0).map(([d,c])=>`${d}="${a(c)}"`).join(" ");t.push(`<meta ${g}>`)}});else if(typeof p=="object"){const s=Object.entries(p).filter(([g,d])=>d!==void 0).map(([g,d])=>`${g}="${a(d)}"`).join(" ");t.push(`<meta ${s}>`)}};if(n.startsWith("http-equiv:")){const l=n.replace("http-equiv:","");return f(l,i,"http-equiv"),t}if(n.startsWith("itemprop:")){const l=n.replace("itemprop:","");return f(l,i,"itemprop"),t}const y=["og:","twitter:","fb:","article:","profile:","book:","business:","music:","product:","video:","DC:","DCTERMS:"].find(l=>n.startsWith(l));if(y){const l=n.replace(y,"");return f(`${y.replace(":","")}:${l}`,i,y==="twitter:"||y==="DC:"||y==="DCTERMS:"?"name":"property"),t}if(n.startsWith("apple:")||n.startsWith("msapplication:")){const l=n.startsWith("apple:")?"apple-":"msapplication-",p=n.replace(/^apple:|^msapplication:/,"");return f(`${l}${p}`,i,"name"),t}return f(n,i),t},['<meta charset="UTF-8">','<meta name="viewport" content="width=device-width, initial-scale=1">']);return e.push(...L(r)),e.join(`
2
- `)},O=r=>typeof r=="string"&&r.length>0&&!r.startsWith("/")&&!r.startsWith("http");function E(r,o){if(!o||typeof o!="object")return r;const e=n=>{if(!O(n))return n;const i=o[n];return i?.src?i.src:n},t={...r};for(const[n,i]of Object.entries(t))typeof i=="string"?t[n]=e(i):Array.isArray(i)&&(t[n]=i.map(f=>typeof f=="string"?e(f):f));return t}function m(r,o){if(!r||!o)return;const e=o.split(".");let t=r;for(const n of e){if(t==null||typeof t!="object")return;t=t[n]}return t}function W(r,o,e){const n=(o.config||o.settings||{}).polyglot||o.polyglot,i=e?.lang||n?.defaultLang||"en",h=(n?.translations||{})[i]||{},y=e?.state||{},l={...r};for(const[p,u]of Object.entries(l))typeof u!="string"||!u.includes("{{")||(l[p]=u.replace(/\{\{\s*([^|{}]+?)\s*(?:\|\s*(\w+)\s*)?\}\}/g,(s,g,d)=>{const c=g.trim();if(d==="polyglot")return h[c]??m(h,c)??s;if(d==="getLocalStateLang")return m(y,c+i)??s;const $=m(y,c);return $!==void 0?$:h[c]??m(h,c)??s}));return l}function A(r){const o={...r};for(const[e,t]of Object.entries(o))if(typeof t=="function"){const n=t.toString(),i=n.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(i){o[e]=`{{ ${i[1]} | getLocalStateLang }}`;continue}const f=n.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(f){o[e]=`{{ ${f[1]} | polyglot }}`;continue}const h=n.match(/s\.(\w+(?:\.\w+)+)/);if(h){o[e]=`{{ ${h[1]} }}`;continue}delete o[e]}else if(typeof t=="string"){const n=t.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(n){o[e]=`{{ ${n[1]} | getLocalStateLang }}`;continue}const i=t.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(i){o[e]=`{{ ${i[1]} | polyglot }}`;continue}if(t.includes("=>")&&t.includes("s.")){const f=t.match(/s\.(\w+(?:\.\w+)+)/);if(f){o[e]=`{{ ${f[1]} }}`;continue}}}return o}function D(r,o,e,{isProduction:t=!1,channel:n="production"}={}){const i=r.pages?.[o],f=S(i?.state)&&i?.state,h=i?.metadata||i?.helmet||f||{},y=A(h),l=new Set(Object.keys(y)),p=r.app?.metadata||{},u=A(p);let s={};if(r.integrations?.seo?s={...r.integrations.seo,...u,...y}:Object.keys(u).length?s={...u,...y}:s={...y},!s.title){const c=r.name||r.key;c?t?s.title=c:n==="development"?s.title=`${c} / dev:symbo.ls`:n==="staging"?s.title=`${c} / staging:symbo.ls`:s.title=`${c} / symbo.ls`:s.title="Symbols demo"}s=W(s,r,e),s.title&&(l.has("title")||!s["og:title"])&&(l.has("og:title")||(s["og:title"]=s.title)),s.description&&(l.has("description")||!s["og:description"])&&(l.has("og:description")||(s["og:description"]=s.description)),s.title&&!s["twitter:title"]&&(s["twitter:title"]=s.title),s.description&&!s["twitter:description"]&&(s["twitter:description"]=s.description);const g=e?.actualPathname||o;if(s["og:url"]||s.url){const c=(s["og:url"]||s.url||"").replace(/\/$/,"");if(c&&g&&g!=="/"){const $=g.startsWith("/")?g:"/"+g;s["og:url"]=c+$}}s=E(s,r.files);const d=r.name||r.app?.metadata?.title||r.app?.name||"";for(const[c,$]of Object.entries(s))if(typeof $=="string"&&$.includes("{{")){const b=$.replace(/\{\{[^}]*\}\}/g,"").trim();b?s[c]=b:c==="title"?s[c]=d:delete s[c]}return s}export{L as generateHeadArrayTags,x as generateMetaTags,D as getPageMetadata,j as hashContent};
1
+ import{isObject as S}from"./types.js";import{isStringFunction as M}from"./function.js";const a=r=>{if(r==null)return"";const o={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};return r.toString().replace(/[&<>"']/g,e=>o[e])},w=r=>Object.entries(r||{}).filter(([o,e])=>e!==void 0).map(([o,e])=>`${o}="${a(e)}"`).join(" "),j=r=>{let o=5381;const e=String(r);for(let t=0;t<e.length;t++)o=(o*33^e.charCodeAt(t))>>>0;return o.toString(36)},L=new Set(["jsonLd","styles","scripts"]),O=r=>{const o=[];if(Array.isArray(r.jsonLd))for(const e of r.jsonLd){if(e==null)continue;const t=typeof e=="string"?e:JSON.stringify(e),n=String(t).replace(/<\/script/gi,"<\\/script");o.push(`<script type="application/ld+json" data-smbls-jsonld="${j(t)}">${n}<\/script>`)}if(Array.isArray(r.styles))for(const e of r.styles){if(e==null||!String(e).trim())continue;const t=String(e).replace(/<\/style/gi,"<\\/style");o.push(`<style data-smbls-style="${j(t)}">${t}</style>`)}if(Array.isArray(r.scripts))for(const e of r.scripts){if(!e)continue;const t=typeof e=="string",n=t?e:e.src;if(!n&&!e.body)continue;const i=[];n&&i.push(`src="${a(n)}"`),t||(e.type&&i.push(`type="${a(e.type)}"`),e.async&&i.push("async"),e.defer&&i.push("defer"),e.integrity&&i.push(`integrity="${a(e.integrity)}"`),e.crossorigin&&i.push(`crossorigin="${a(e.crossorigin)}"`),e.referrerpolicy&&i.push(`referrerpolicy="${a(e.referrerpolicy)}"`),e.nomodule&&i.push("nomodule"));const f=` data-smbls-script="${a(n||j(e.body||""))}"`;if(!t&&e.body){const h=String(e.body).replace(/<\/script/gi,"<\\/script");o.push(`<script ${i.join(" ")}${f}>${h}<\/script>`)}else o.push(`<script ${i.join(" ")}${f}><\/script>`)}return o},F=(r,o)=>{o||(r={...r,robots:"noindex"});const e=Object.entries(r).reduce((t,[n,i])=>{if(!i&&i!==0&&i!==!1||L.has(n))return t;if(n==="title")return t.push(`<title>${a(i)}</title>`),t;if(n==="canonical")return t.push(`<link rel="canonical" href="${a(i)}">`),t;if(n==="manifest")return t.push(`<link rel="manifest" href="${a(i)}">`),t;if(n==="favicon"||n==="favicons"||n==="icon"||n==="icons")return(Array.isArray(i)?i:[i]).forEach(p=>{if(typeof p=="string")t.push(`<link rel="icon" href="${a(p)}">`);else if(typeof p=="object"){const u=w(p);/rel=/.test(u)?t.push(`<link ${u}>`):t.push(`<link rel="icon" ${u}>`)}}),t;if(n==="alternate")return(Array.isArray(i)?i:[i]).forEach(p=>{if(typeof p=="object"){const u=Object.entries(p).filter(([s,g])=>g!==void 0).map(([s,g])=>`${s}="${a(g)}"`).join(" ");t.push(`<link rel="alternate" ${u}>`)}}),t;const f=(l,p,u="name")=>{if(typeof p=="string"||typeof p=="number"||typeof p=="boolean")t.push(`<meta ${u}="${a(l)}" content="${a(p)}">`);else if(Array.isArray(p))p.forEach(s=>{if(typeof s=="string"||typeof s=="number"||typeof s=="boolean")t.push(`<meta ${u}="${a(l)}" content="${a(s)}">`);else if(typeof s=="object"){const g=Object.entries(s).filter(([d,c])=>c!==void 0).map(([d,c])=>`${d}="${a(c)}"`).join(" ");t.push(`<meta ${g}>`)}});else if(typeof p=="object"){const s=Object.entries(p).filter(([g,d])=>d!==void 0).map(([g,d])=>`${g}="${a(d)}"`).join(" ");t.push(`<meta ${s}>`)}};if(n.startsWith("http-equiv:")){const l=n.replace("http-equiv:","");return f(l,i,"http-equiv"),t}if(n.startsWith("itemprop:")){const l=n.replace("itemprop:","");return f(l,i,"itemprop"),t}const y=["og:","twitter:","fb:","article:","profile:","book:","business:","music:","product:","video:","DC:","DCTERMS:"].find(l=>n.startsWith(l));if(y){const l=n.replace(y,"");return f(`${y.replace(":","")}:${l}`,i,y==="twitter:"||y==="DC:"||y==="DCTERMS:"?"name":"property"),t}if(n.startsWith("apple:")||n.startsWith("msapplication:")){const l=n.startsWith("apple:")?"apple-":"msapplication-",p=n.replace(/^apple:|^msapplication:/,"");return f(`${l}${p}`,i,"name"),t}return f(n,i),t},['<meta charset="UTF-8">','<meta name="viewport" content="width=device-width, initial-scale=1">']);return e.push(...O(r)),e.join(`
2
+ `)},E=r=>typeof r=="string"&&r.length>0&&!r.startsWith("/")&&!r.startsWith("http");function W(r,o){if(!o||typeof o!="object")return r;const e=n=>{if(!E(n))return n;const i=o[n];return i?.src?i.src:n},t={...r};for(const[n,i]of Object.entries(t))typeof i=="string"?t[n]=e(i):Array.isArray(i)&&(t[n]=i.map(f=>typeof f=="string"?e(f):f));return t}function m(r,o){if(!r||!o)return;const e=o.split(".");let t=r;for(const n of e){if(t==null||typeof t!="object")return;t=t[n]}return t}function T(r,o,e){const n=(o.config||o.settings||{}).polyglot||o.polyglot,i=e?.lang||n?.defaultLang||"en",h=(n?.translations||{})[i]||{},y=e?.state||{},l={...r};for(const[p,u]of Object.entries(l))typeof u!="string"||!u.includes("{{")||(l[p]=u.replace(/\{\{\s*([^|{}]+?)\s*(?:\|\s*(\w+)\s*)?\}\}/g,(s,g,d)=>{const c=g.trim();if(d==="polyglot")return h[c]??m(h,c)??s;if(d==="getLocalStateLang")return m(y,c+i)??s;const $=m(y,c);return $!==void 0?$:h[c]??m(h,c)??s}));return l}function A(r){if(!S(r))return{};const o={...r};for(const[e,t]of Object.entries(o))if(typeof t=="function"){const n=t.toString(),i=n.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(i){o[e]=`{{ ${i[1]} | getLocalStateLang }}`;continue}const f=n.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(f){o[e]=`{{ ${f[1]} | polyglot }}`;continue}const h=n.match(/s\.(\w+(?:\.\w+)+)/);if(h){o[e]=`{{ ${h[1]} }}`;continue}delete o[e]}else if(typeof t=="string"){const n=t.match(/el\.call\(\s*["']getLocalStateLang["']\s*,\s*["']([^"']+)["']\s*\)/);if(n){o[e]=`{{ ${n[1]} | getLocalStateLang }}`;continue}const i=t.match(/el\.call\(\s*["']polyglot["']\s*,\s*["']([^"']+)["']\s*\)/);if(i){o[e]=`{{ ${i[1]} | polyglot }}`;continue}if(t.includes("=>")&&t.includes("s.")){const f=t.match(/s\.(\w+(?:\.\w+)+)/);if(f){o[e]=`{{ ${f[1]} }}`;continue}}M(t)&&delete o[e]}return o}function R(r,o,e,{isProduction:t=!1,channel:n="production"}={}){const i=r.pages?.[o],f=S(i?.state)&&i?.state,h=i?.metadata||i?.helmet||f||{},y=A(h),l=new Set(Object.keys(y)),p=r.app?.metadata||{},u=A(p);let s={};if(r.integrations?.seo?s={...r.integrations.seo,...u,...y}:Object.keys(u).length?s={...u,...y}:s={...y},!s.title){const c=r.name||r.key;c?t?s.title=c:n==="development"?s.title=`${c} / dev:symbo.ls`:n==="staging"?s.title=`${c} / staging:symbo.ls`:s.title=`${c} / symbo.ls`:s.title="Symbols demo"}s=T(s,r,e),s.title&&(l.has("title")||!s["og:title"])&&(l.has("og:title")||(s["og:title"]=s.title)),s.description&&(l.has("description")||!s["og:description"])&&(l.has("og:description")||(s["og:description"]=s.description)),s.title&&!s["twitter:title"]&&(s["twitter:title"]=s.title),s.description&&!s["twitter:description"]&&(s["twitter:description"]=s.description);const g=e?.actualPathname||o;if(s["og:url"]||s.url){const c=(s["og:url"]||s.url||"").replace(/\/$/,"");if(c&&g&&g!=="/"){const $=g.startsWith("/")?g:"/"+g;s["og:url"]=c+$}}s=W(s,r.files);const d=r.name||r.app?.metadata?.title||r.app?.name||"";for(const[c,$]of Object.entries(s))if(typeof $=="string"&&$.includes("{{")){const b=$.replace(/\{\{[^}]*\}\}/g,"").trim();b?s[c]=b:c==="title"?s[c]=d:delete s[c]}return s}export{O as generateHeadArrayTags,F as generateMetaTags,R as getPageMetadata,j as hashContent};
@@ -1,10 +1,10 @@
1
- import{triggerEventOn as m}from"./triggerEvent.js";import{DOMQ_PROPERTIES as R,METHODS as $,PARSED_DOMQ_PROPERTIES as k}from"./keys.js";import{isDefined as E,isFunction as p,isObject as P,isObjectLike as x}from"./types.js";import{deepClone as A}from"./object.js";import{isProduction as b}from"./env.js";import{removeValueFromArray as C}from"./array.js";import{OPTIONS as j}from"./cache.js";const a="production";function K(e){const t=this,{__ref:n}=t,o=[].concat(e);let r=n.root[o[0]];if(!o||!o.length)return console.log(o,"on",t.key,"is undefined");for(;r.key===o[0]&&(o.shift(),!!o.length);)if(r=r[o[0]],!r)return;return r}function X(e){const t=this;let{parent:n}=t;if(p(e))return n.state&&e(n,n.state,n.context)?n:n.parent?n.lookup(e):void 0;if(t[e])return t[e];for(;n.param!==e;){if(n[e])return n[e];if(n=n.parent,!n)return}return n}function q(e){const t=this,{__ref:n}=t,o=n?.__children;if(o)for(let r=0;r<o.length;r++){const s=o[r],i=t[s];if(s===e)return i;if(p(e)){const l=e(i,i.state,i.context);if(i.state&&l)return i}const c=i?.lookdown?.(e);if(c)return c}}function tt(e,t=[]){const n=this,{__ref:o}=n,r=o?.__children;if(r){for(let s=0;s<r.length;s++){const i=r[s],c=n[i];if(i===e)t.push(c);else if(p(e)){const l=e(c,c.state,c.context);c.state&&l&&t.push(c)}c?.lookdownAll?.(e,t)}return t.length?t:void 0}}function Q(e={}){const t=this;if(t.node?.style){for(const n in e){const o=e[n],r=t[n];if(P(o)&&r)Q.call(r,o);else if(o!=null){const s=n.replace(/[A-Z]/g,c=>"-"+c.toLowerCase()),i=String(o).replace(/\s*!important\s*$/,"");t.node.style.setProperty(s,i,"important")}}return t}}function et(e){const t=this;if(m("beforeRemove",t,e)===!1)return t;p(t.node.remove)?t.node.remove():b()||(console.warn("This item cant be removed"),t.log()),delete t.parent[t.key],t.parent.__ref&&(t.parent.__ref.__children=C(t.parent.__ref.__children,t.key)),m("remove",t,e)}function nt(e){return this[e]}function ot(e,t){const n=this;if(e)return n.update(e,t),n}function rt(e){return e?this.__ref&&this.__ref[e]:this.__ref}function st(){const e=this.getRef("__children");return Array.isArray(e)?e.map(t=>this[t]):[]}function it(){return this.getRef().path}let y=null;const ct=e=>{y=e||null},v=()=>y||null;function lt(e){let t=null;const n=o=>o.__element&&o.root?.isRootState;if(!this)t=v();else if(n(this))t=this.root;else if(this.__ref&&this.__ref.path){const o=this.state&&n(this.state),r=p(this.state)&&this.parent.state&&n(this.parent.state);(o||r)&&(t=this.state.root||this.parent.state.root)}return t||(t=v()),e?t?.[e]:t}function ft(e){const t=this?.__ref?.root||this.getRootState()?.__element;if(!t)throw new Error(`[smbls] getRoot() could not resolve a root element for "${this?.key||"<unknown>"}" \u2014 it has no __ref (never went through create()) and no root state is registered. Answering undefined here used to no-op silently for every caller.`);return Object.keys(t).length>0&&e?t[e]:t}function ut(e){return this.getRoot("data")&&Object.keys(this.getRoot("data")).length>0&&e?this.getRoot("data")[e]:this.getRoot("data")}function at(e){const t=this.getRoot()?.context;return e?t[e]:t}function ht(e){const t=this.context;return e?t[e]:t}const pt=(e,t,n,o)=>Object.defineProperty(e,t,{get:n,set:o});function N(){const e=this,t=[];for(const n in e)!Object.prototype.hasOwnProperty.call(e,n)||R.has(n)&&!k.has(n)||t.push(n);return t}function D(e=[]){const t=this,n={},o=N.call(t),r=o.includes("children"),s=e.length?new Set(e):null;for(let i=0;i<o.length;i++){const c=o[i];if(s&&s.has(c)||!Object.prototype.hasOwnProperty.call(t,c)||r&&c==="content")continue;const l=t[c];if(c==="state"){if(t.__ref&&!t.__ref.__hasRootState)continue;const f=p(l&&l.parse)?l.parse():l;n[c]=p(f)?f:JSON.parse(JSON.stringify(f||{}))}else if(c==="scope"){if(t.__ref&&!t.__ref.__hasRootScope)continue;n[c]=JSON.parse(JSON.stringify(l||{}))}else if(c==="props"){const{__element:f,update:u,...h}=t[c];n[c]=h}else E(l)&&Object.prototype.hasOwnProperty.call(t,c)&&(n[c]=l)}return n}function w(e=[],t=new WeakSet){const n=this;if(t.has(n))return;t.add(n);const o=D.call(n,e),r=e.length?new Set(e):null;for(const s in o){if(r&&r.has(s)||!Object.prototype.hasOwnProperty.call(n,s))continue;const i=o[s];Array.isArray(i)?o[s]=i.map(c=>x(c)?w.call(c,e,t):c):x(i)&&(o[s]=w.call(i,e,t))}return o}function T(...e){if(a!=="test"&&a!=="development")return;const t=this,{__ref:n}=t;return console.groupCollapsed(t.key),e.length?e.forEach(o=>console.log(`%c${o}:
2
- `,"font-weight: bold",t[o])):(console.log(n.path),t.keys().forEach(r=>console.log(`%c${r}:`,"font-weight: bold",t[r]))),console.log(t),console.groupEnd(t.key),t}function dt(...e){(a==="test"||a==="development")&&console.log(...e)}function _t(...e){(a==="test"||a==="development")&&console.warn(...e)}function S(...e){if(a==="test"||a==="development"){if(e[e.length-1]?.debugger)debugger;throw e[e.length-1]?.verbose&&T.call(this),new Error(...e)}}function gt(){const e=this,{key:t,parent:n}=e,{__children:o}=n.__ref,r=o.indexOf(t),s=o[r+1];return n[s]}function mt(e){const t=e||this,{key:n,parent:o}=t,{__children:r}=o.__ref;if(!r)return;const s=r.indexOf(n);return o[r[s-1]]}function xt(e={}){const t=this;t.data||(t.data={}),t.data.varCaches||(t.data.varCaches={});const n=t.data.varCaches,o={};let r;for(const s in e)e[s]!==n[s]&&(r=!0,o[s]=e[s]);return{changed:s=>{if(!r)return;const i=s(o,A(n));for(const c in o)n[c]=o[c];return i},timeout:(s,i)=>{if(!r)return;const c=setTimeout(()=>{s(o),clearTimeout(c)},i)}}}function yt(e,...t){const n=this.context,o=n.utils?.[e]||n.functions?.[e]||n.methods?.[e]||n.snippets?.[e];if(o)try{const r=o.call(this,...t);return r&&typeof r.then=="function"&&r.catch(s=>{S.call(this,s)}),r}catch(r){if(S.call(this,r),n?.strictMode)throw r}}async function vt(){const e=this,t=e.context?.fetch;if(!t)return null;if(typeof t.select=="function"){if(!t.__authInitialized&&t.getSession){const{initAdapterAuth:r}=await import("@symbo.ls/fetch");await r(t,e.context)}return t}if(t.__resolved){if(!t.__resolved.__authInitialized&&t.__resolved.getSession){const{initAdapterAuth:r}=await import("@symbo.ls/fetch");await r(t.__resolved,e.context)}return t.__resolved}if(t.__resolving)return t.__resolving;const n=import("@symbo.ls/fetch").then(({resolveDb:r})=>r(t));t.__resolving=n;const o=await n;if(t.__resolved=o,e.context.fetch=o,delete t.__resolving,o?.getSession){const{initAdapterAuth:r}=await import("@symbo.ls/fetch");await r(o,e.context)}return o}function wt(e){const t=this,n=e||j.useStateQuery||t.context?.useStateQuery;if(!n)return null;const o={};if(g(t,o),n===!0)return o;const r=B[n];return r?r(o):o}const g=(e,t)=>{const n=e.__ref;if(!n)return;const o=n.__state;o&&typeof o=="string"&&I(t,o);const r=n.__children;if(r)for(let c=0;c<r.length;c++){const l=e[r[c]];l&&l.__ref&&g(l,t)}const s=n.contentElementKey||"content",i=e[s];i&&i.__ref&&g(i,t)},I=(e,t)=>{const o=t.replaceAll("../","").replaceAll("~/","").split("/");let r=e;for(let s=0;s<o.length;s++){const i=o[s];s===o.length-1?r[i]||(r[i]=!0):(r[i]===!0&&(r[i]={}),r[i]||(r[i]={}),r=r[i])}},O=(e,t=0)=>{const n=" ".repeat(t),o=Object.entries(e);return o.length?o.map(([s,i])=>i===!0?`${n}${s}`:`${n}${s} {
1
+ import{triggerEventOn as m}from"./triggerEvent.js";import{DOMQ_PROPERTIES as R,METHODS as $,PARSED_DOMQ_PROPERTIES as k}from"./keys.js";import{isDefined as E,isFunction as p,isObject as P,isObjectLike as x}from"./types.js";import{deepClone as A,isFailedRevival as b}from"./object.js";import{isProduction as C}from"./env.js";import{removeValueFromArray as j}from"./array.js";import{OPTIONS as Q}from"./cache.js";const a="production";function X(e){const t=this,{__ref:n}=t,o=[].concat(e);let r=n.root[o[0]];if(!o||!o.length)return console.log(o,"on",t.key,"is undefined");for(;r.key===o[0]&&(o.shift(),!!o.length);)if(r=r[o[0]],!r)return;return r}function q(e){const t=this;let{parent:n}=t;if(p(e))return n.state&&e(n,n.state,n.context)?n:n.parent?n.lookup(e):void 0;if(t[e])return t[e];for(;n.param!==e;){if(n[e])return n[e];if(n=n.parent,!n)return}return n}function tt(e){const t=this,{__ref:n}=t,o=n?.__children;if(o)for(let r=0;r<o.length;r++){const s=o[r],i=t[s];if(s===e)return i;if(p(e)){const l=e(i,i.state,i.context);if(i.state&&l)return i}const c=i?.lookdown?.(e);if(c)return c}}function et(e,t=[]){const n=this,{__ref:o}=n,r=o?.__children;if(r){for(let s=0;s<r.length;s++){const i=r[s],c=n[i];if(i===e)t.push(c);else if(p(e)){const l=e(c,c.state,c.context);c.state&&l&&t.push(c)}c?.lookdownAll?.(e,t)}return t.length?t:void 0}}function N(e={}){const t=this;if(t.node?.style){for(const n in e){const o=e[n],r=t[n];if(P(o)&&r)N.call(r,o);else if(o!=null){const s=n.replace(/[A-Z]/g,c=>"-"+c.toLowerCase()),i=String(o).replace(/\s*!important\s*$/,"");t.node.style.setProperty(s,i,"important")}}return t}}function nt(e){const t=this;if(m("beforeRemove",t,e)===!1)return t;p(t.node.remove)?t.node.remove():C()||(console.warn("This item cant be removed"),t.log()),delete t.parent[t.key],t.parent.__ref&&(t.parent.__ref.__children=j(t.parent.__ref.__children,t.key)),m("remove",t,e)}function ot(e){return this[e]}function rt(e,t){const n=this;if(e)return n.update(e,t),n}function st(e){return e?this.__ref&&this.__ref[e]:this.__ref}function it(){const e=this.getRef("__children");return Array.isArray(e)?e.map(t=>this[t]):[]}function ct(){return this.getRef().path}let y=null;const lt=e=>{y=e||null},v=()=>y||null;function ft(e){let t=null;const n=o=>o.__element&&o.root?.isRootState;if(!this)t=v();else if(n(this))t=this.root;else if(this.__ref&&this.__ref.path){const o=this.state&&n(this.state),r=p(this.state)&&this.parent.state&&n(this.parent.state);(o||r)&&(t=this.state.root||this.parent.state.root)}return t||(t=v()),e?t?.[e]:t}function ut(e){const t=this?.__ref?.root||this.getRootState()?.__element;if(!t)throw new Error(`[smbls] getRoot() could not resolve a root element for "${this?.key||"<unknown>"}" \u2014 it has no __ref (never went through create()) and no root state is registered. Answering undefined here used to no-op silently for every caller.`);return Object.keys(t).length>0&&e?t[e]:t}function at(e){return this.getRoot("data")&&Object.keys(this.getRoot("data")).length>0&&e?this.getRoot("data")[e]:this.getRoot("data")}function ht(e){const t=this.getRoot()?.context;return e?t[e]:t}function pt(e){const t=this.context;return e?t[e]:t}const dt=(e,t,n,o)=>Object.defineProperty(e,t,{get:n,set:o});function D(){const e=this,t=[];for(const n in e)!Object.prototype.hasOwnProperty.call(e,n)||R.has(n)&&!k.has(n)||t.push(n);return t}function T(e=[]){const t=this,n={},o=D.call(t),r=o.includes("children"),s=e.length?new Set(e):null;for(let i=0;i<o.length;i++){const c=o[i];if(s&&s.has(c)||!Object.prototype.hasOwnProperty.call(t,c)||r&&c==="content")continue;const l=t[c];if(c==="state"){if(t.__ref&&!t.__ref.__hasRootState)continue;const f=p(l&&l.parse)?l.parse():l;n[c]=p(f)?f:JSON.parse(JSON.stringify(f||{}))}else if(c==="scope"){if(t.__ref&&!t.__ref.__hasRootScope)continue;n[c]=JSON.parse(JSON.stringify(l||{}))}else if(c==="props"){const{__element:f,update:u,...h}=t[c];n[c]=h}else E(l)&&Object.prototype.hasOwnProperty.call(t,c)&&(n[c]=l)}return n}function w(e=[],t=new WeakSet){const n=this;if(t.has(n))return;t.add(n);const o=T.call(n,e),r=e.length?new Set(e):null;for(const s in o){if(r&&r.has(s)||!Object.prototype.hasOwnProperty.call(n,s))continue;const i=o[s];Array.isArray(i)?o[s]=i.map(c=>x(c)?w.call(c,e,t):c):x(i)&&(o[s]=w.call(i,e,t))}return o}function F(...e){if(a!=="test"&&a!=="development")return;const t=this,{__ref:n}=t;return console.groupCollapsed(t.key),e.length?e.forEach(o=>console.log(`%c${o}:
2
+ `,"font-weight: bold",t[o])):(console.log(n.path),t.keys().forEach(r=>console.log(`%c${r}:`,"font-weight: bold",t[r]))),console.log(t),console.groupEnd(t.key),t}function _t(...e){(a==="test"||a==="development")&&console.log(...e)}function gt(...e){(a==="test"||a==="development")&&console.warn(...e)}function S(...e){if(a==="test"||a==="development"){if(e[e.length-1]?.debugger)debugger;throw e[e.length-1]?.verbose&&F.call(this),new Error(...e)}}function mt(){const e=this,{key:t,parent:n}=e,{__children:o}=n.__ref,r=o.indexOf(t),s=o[r+1];return n[s]}function xt(e){const t=e||this,{key:n,parent:o}=t,{__children:r}=o.__ref;if(!r)return;const s=r.indexOf(n);return o[r[s-1]]}function yt(e={}){const t=this;t.data||(t.data={}),t.data.varCaches||(t.data.varCaches={});const n=t.data.varCaches,o={};let r;for(const s in e)e[s]!==n[s]&&(r=!0,o[s]=e[s]);return{changed:s=>{if(!r)return;const i=s(o,A(n));for(const c in o)n[c]=o[c];return i},timeout:(s,i)=>{if(!r)return;const c=setTimeout(()=>{s(o),clearTimeout(c)},i)}}}function vt(e,...t){const n=this.context,o=n.utils?.[e]||n.functions?.[e]||n.methods?.[e]||n.snippets?.[e];if(o&&!b(o))try{const r=o.call(this,...t);return r&&typeof r.then=="function"&&r.catch(s=>{S.call(this,s)}),r}catch(r){if(S.call(this,r),n?.strictMode)throw r}}async function wt(){const e=this,t=e.context?.fetch;if(!t)return null;if(typeof t.select=="function"){if(!t.__authInitialized&&t.getSession){const{initAdapterAuth:r}=await import("@symbo.ls/fetch");await r(t,e.context)}return t}if(t.__resolved){if(!t.__resolved.__authInitialized&&t.__resolved.getSession){const{initAdapterAuth:r}=await import("@symbo.ls/fetch");await r(t.__resolved,e.context)}return t.__resolved}if(t.__resolving)return t.__resolving;const n=import("@symbo.ls/fetch").then(({resolveDb:r})=>r(t));t.__resolving=n;const o=await n;if(t.__resolved=o,e.context.fetch=o,delete t.__resolving,o?.getSession){const{initAdapterAuth:r}=await import("@symbo.ls/fetch");await r(o,e.context)}return o}function St(e){const t=this,n=e||Q.useStateQuery||t.context?.useStateQuery;if(!n)return null;const o={};if(g(t,o),n===!0)return o;const r=z[n];return r?r(o):o}const g=(e,t)=>{const n=e.__ref;if(!n)return;const o=n.__state;o&&typeof o=="string"&&I(t,o);const r=n.__children;if(r)for(let c=0;c<r.length;c++){const l=e[r[c]];l&&l.__ref&&g(l,t)}const s=n.contentElementKey||"content",i=e[s];i&&i.__ref&&g(i,t)},I=(e,t)=>{const o=t.replaceAll("../","").replaceAll("~/","").split("/");let r=e;for(let s=0;s<o.length;s++){const i=o[s];s===o.length-1?r[i]||(r[i]=!0):(r[i]===!0&&(r[i]={}),r[i]||(r[i]={}),r=r[i])}},O=(e,t=0)=>{const n=" ".repeat(t),o=Object.entries(e);return o.length?o.map(([s,i])=>i===!0?`${n}${s}`:`${n}${s} {
3
3
  ${O(i,t+1)}
4
4
  ${n}}`).join(`
5
5
  `):""},L=e=>`{
6
6
  ${O(e,1)}
7
- }`,F=e=>{const t={fields:{},include:[]},n=(o,r)=>{const s=[];for(const i in o)if(o[i]===!0)s.push(i);else{const c=r?`${r}.${i}`:i;t.include.push(c),n(o[i],c)}s.length&&(t.fields[r||"_root"]=s)};return n(e,""),t},M=e=>{const t=s=>{const i=[],c=[];for(const l in s)if(s[l]===!0)i.push(l);else{const f=t(s[l]),u=[];f.select&&u.push(`$select=${f.select}`),f.expand&&u.push(`$expand=${f.expand}`),c.push(u.length?`${l}(${u.join(";")})`:l)}return{select:i.length?i.join(","):"",expand:c.length?c.join(","):""}},{select:n,expand:o}=t(e),r=[];return n&&r.push(`$select=${n}`),o&&r.push(`$expand=${o}`),r.join("&")},J=(e,t)=>{const n=[],o=[],r=new Set,s=(u,h,_)=>{r.add(h),_&&o.push(`LEFT JOIN ${h} ON ${h}.${_}_id = ${_}.id`);for(const d in u)u[d]===!0?n.push(`${h}.${d}`):s(u[d],d,h)},i=Object.keys(e);i.length===1&&e[i[0]]!==!0?s(e[i[0]],i[0],null):s(e,"_root",null);const c=[...r][0]||"_root",l=n.length?n.join(", "):"*",f=o.length?`
7
+ }`,M=e=>{const t={fields:{},include:[]},n=(o,r)=>{const s=[];for(const i in o)if(o[i]===!0)s.push(i);else{const c=r?`${r}.${i}`:i;t.include.push(c),n(o[i],c)}s.length&&(t.fields[r||"_root"]=s)};return n(e,""),t},J=e=>{const t=s=>{const i=[],c=[];for(const l in s)if(s[l]===!0)i.push(l);else{const f=t(s[l]),u=[];f.select&&u.push(`$select=${f.select}`),f.expand&&u.push(`$expand=${f.expand}`),c.push(u.length?`${l}(${u.join(";")})`:l)}return{select:i.length?i.join(","):"",expand:c.length?c.join(","):""}},{select:n,expand:o}=t(e),r=[];return n&&r.push(`$select=${n}`),o&&r.push(`$expand=${o}`),r.join("&")},V=(e,t)=>{const n=[],o=[],r=new Set,s=(u,h,_)=>{r.add(h),_&&o.push(`LEFT JOIN ${h} ON ${h}.${_}_id = ${_}.id`);for(const d in u)u[d]===!0?n.push(`${h}.${d}`):s(u[d],d,h)},i=Object.keys(e);i.length===1&&e[i[0]]!==!0?s(e[i[0]],i[0],null):s(e,"_root",null);const c=[...r][0]||"_root",l=n.length?n.join(", "):"*",f=o.length?`
8
8
  `+o.join(`
9
9
  `):"";return`SELECT ${l}
10
- FROM ${c}${f}`},V=e=>{const t=[],n=(o,r)=>{for(const s in o){const i=r?`${r}/${s}`:s;o[s]===!0?t.push(i):n(o[s],i)}};return n(e,""),t},B={graphql:L,"json-api":F,odata:M,sql:J,paths:V};function St(e,t){return!!($.has(e)||t?.context?.methods?.[e])}export{yt as call,pt as defineSetter,S as error,nt as get,st as getChildren,ht as getContext,vt as getDB,it as getPath,wt as getQuery,rt as getRef,ft as getRoot,at as getRootContext,ut as getRootData,lt as getRootState,St as isMethod,N as keys,dt as log,q as lookdown,tt as lookdownAll,X as lookup,gt as nextElement,D as parse,w as parseDeep,mt as previousElement,et as remove,ct as setActiveRootState,Q as setNodeStyles,ot as setProps,K as spotByPath,xt as variables,T as verbose,_t as warn};
10
+ FROM ${c}${f}`},B=e=>{const t=[],n=(o,r)=>{for(const s in o){const i=r?`${r}/${s}`:s;o[s]===!0?t.push(i):n(o[s],i)}};return n(e,""),t},z={graphql:L,"json-api":M,odata:J,sql:V,paths:B};function Ot(e,t){return!!($.has(e)||t?.context?.methods?.[e])}export{vt as call,dt as defineSetter,S as error,ot as get,it as getChildren,pt as getContext,wt as getDB,ct as getPath,St as getQuery,st as getRef,ut as getRoot,ht as getRootContext,at as getRootData,ft as getRootState,Ot as isMethod,D as keys,_t as log,tt as lookdown,et as lookdownAll,q as lookup,mt as nextElement,T as parse,w as parseDeep,xt as previousElement,nt as remove,lt as setActiveRootState,N as setNodeStyles,rt as setProps,X as spotByPath,yt as variables,F as verbose,gt as warn};
@@ -1,18 +1,19 @@
1
- import{window as $}from"./globals.js";import{isFunction as E,isObjectLike as g,isObject as k,isArray as _,isString as O,is as K}from"./types.js";import{unstackArrayOfObjects as Y}from"./array.js";import{stringIncludesAny as Z}from"./string.js";import{isDOMNode as w}from"./node.js";import{METHODS_EXL as m}from"./keys.js";const A="production",S=e=>e.charCodeAt(0)===95&&e.charCodeAt(1)===95,T=(e,t,o,c)=>{if(E(e))return t?typeof e.call!="function"?e:e.call(t,t,o||t.state,c||t.context):void 0;if(e!=null&&t?.context?.plugins&&(_(e)||k(e)&&!w(e))){const r=t.context.plugins;for(const n of r)if(n.resolveHandler){const i=n.resolveHandler(e,t);if(typeof i=="function")return T(i,t,o,c)}}return e},ue=(e,t,o)=>{for(const c in t)e[c]=T(t[c],o)},le=(e,t,o=[])=>{const c=o instanceof Set;for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(S(r)||(c?o.has(r):o.includes(r))||e[r]===void 0&&(e[r]=t[r]));return e},ae=(e,t,o=m)=>N(e,t,o,null),N=(e,t,o,c)=>{if(e===t)return e;if(c){for(let n=0;n<c.length;n+=2)if(c[n]===e&&c[n+1]===t)return e}const r=o instanceof Set;for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n)||S(n)||n==="constructor"||n==="prototype"||(r?o.has(n):o.includes(n)))continue;const i=e[n],s=t[n];if(g(i)&&g(s)){const f=c||[];f.push(e,t),N(i,s,o,f),f.length-=2}else i===void 0&&(e[n]=s)}return e},pe=(e,t=[])=>{const o=t instanceof Set,c={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(S(r)||(o?t.has(r):t.includes(r))||(c[r]=e[r]));return c},ye=(e,t={})=>{const{exclude:o=[],cleanUndefined:c=!1,cleanNull:r=!1,visited:n=new WeakMap,handleExtends:i=!1}=t;if(!g(e)||w(e))return e;if(n.has(e))return n.get(e);const s=o instanceof Set?o:o.length>3?new Set(o):null,f=p=>s?s.has(p):o.includes(p),u=_(e)?[]:{};n.set(e,u);const l=[[e,u]];for(;l.length;){const[p,h]=l.pop();for(const y in p){if(!Object.prototype.hasOwnProperty.call(p,y)||S(y)||y==="__proto__"||f(y))continue;const a=p[y];if(!(c&&a===void 0)&&!(r&&a===null)){if(w(a)){h[y]=a;continue}if(i&&y==="extends"&&_(a)){h[y]=Y(a,o);continue}if(E(a)){h[y]=a;continue}if(g(a))if(n.has(a))h[y]=n.get(a);else{const d=_(a)?[]:{};n.set(a,d),h[y]=d,l.push([a,d])}else h[y]=a}}}return u},R=(e,t={})=>{(e.node||e.__ref||e.parent||e.__element||e.parse)&&((e.__element||e.parent?.__element).warn("Trying to clone element or state at",e),e=e.parse?.());for(const o in e){const c=e[o];if(E(c))t[o]=c.toString();else if(k(c))t[o]={},R(c,t[o]);else if(_(c)){const r=t[o]=[];for(let n=0;n<c.length;n++){const i=c[n];k(i)?(r[n]={},R(i,r[n])):E(i)?r[n]=i.toString():r[n]=i}}else t[o]=c}return t},B=/^[A-Za-z_$][A-Za-z0-9_$]*$/,J=e=>`'${String(e).replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\r/g,"\\r").replace(/\n/g,"\\n")}'`,D=e=>{const t=String(e);return Z(t,[`
2
- `,"'"])?"`"+t.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")+"`":"'"+t.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\r/g,"\\r")+"'"},M=(e={},t=0)=>{if(e===null||typeof e!="object"||e instanceof RegExp)return String(e);let o=!1;for(const n in e){o=!0;break}if(!o)return"{}";const c=" ".repeat(t);let r=`{
3
- `;for(const n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;const i=e[n],s=B.test(n)?n:J(n);if(r+=`${c} ${s}: `,i instanceof RegExp)r+=String(i);else if(_(i)){r+=`[
4
- `;for(const f of i)f instanceof RegExp?r+=`${c} ${String(f)},
5
- `:g(f)&&f!==null?r+=`${c} ${M(f,t+2)},
6
- `:O(f)?r+=`${c} ${D(f)},
7
- `:r+=`${c} ${f},
8
- `;r+=`${c} ]`}else g(i)?r+=M(i,t+1):O(i)?r+=D(i):r+=i;r+=`,
9
- `}return r+=`${c}}`,r},U=[/^\(\s*\{[^}]*\}\s*\)\s*=>/,/^(\([^)]*\)|[^=]*)\s*=>/,/^function[\s(]/,/^async\s+/,/^\(\s*function/,/^[a-zA-Z_$][a-zA-Z0-9_$]*\s*=>/,/^(?:\*\s*)?[a-zA-Z_$][\w$]*\s*\((?:[^()]|\([^()]*\))*\)\s*\{[\s\S]*\}$/],V=/^["[{]/,H=/^(export|import)\s/,P=e=>{if(!e)return!1;const t=e.trim().replace(/\n\s*/g," ").trim();if(t===""||t==="{}"||t==="[]"||H.test(t)||!U.some(n=>n.test(t)))return!1;const c=t.charCodeAt(0),r=t.includes("=>");return!(c===123&&!r||c===91||V.test(t)&&!r)},X=e=>(0,eval)(e),v=(e,t)=>{const o=/^(\s*(?:async\s+)?function\s*[\w$]*\s*\([^)]*\)\s*)\{/.exec(e);if(!o)return null;const c=o[0].length,r=[];let n=c,i=1,s=null;const f=e.length,u=new RegExp("^(?:const|let|var)\\s+"+t+"\\b");for(;n<f&&i>0;){const p=e[n];if(p==="/"&&e[n+1]==="/"){const h=e.indexOf(`
10
- `,n);n=h===-1?f:h;continue}if(p==="/"&&e[n+1]==="*"){const h=e.indexOf("*/",n+2);n=h===-1?f:h+2;continue}if(p==='"'||p==="'"||p==="`"){const h=p;for(n++;n<f;){if(e[n]==="\\"){n+=2;continue}if(e[n]===h){n++;break}if(h==="`"&&e[n]==="$"&&e[n+1]==="{"){n+=2;let y=1;for(;n<f&&y>0;)e[n]==="{"?y++:e[n]==="}"&&y--,n++;continue}n++}continue}if(p==="{"){i++,n++;continue}if(p==="}"){i--,n++;continue}if(i===1&&u.test(e.slice(n))){const h=n;let y=0,a=n;for(;a<f;){const d=e[a];if(d==='"'||d==="'"||d==="`"){const z=d;for(a++;a<f;){if(e[a]==="\\"){a+=2;continue}if(e[a]===z){a++;break}a++}continue}if(d==="("||d==="["||d==="{"){y++,a++;continue}if(d===")"||d==="]"||d==="}"){if(y===0)break;y--,a++;continue}if(y===0&&(d===";"||d===`
11
- `)){a++;break}a++}r.push([h,a]),n=a;continue}n++}if(!r.length)return null;let l=e;for(let p=r.length-1;p>=0;p--)l=l.slice(0,r[p][0])+l.slice(r[p][1]);return l},W=(e,t,o)=>{const c=String(e).trimStart();if(/^(export|import)\s/.test(c))return e;try{return o.window.eval(`(${e})`)}catch(r){const n=r&&r.message?r.message:String(r),i=/await is only valid in async/.test(n),s=/Identifier '([^']+)' has already been declared/.exec(n);let f=null;if(i){const u=String(e).trim();if(/^function[\s(]/.test(u))try{f=o.window.eval("(async "+u+")")}catch{}}else if(s){let u=String(e),l=s[1];for(let p=0;p<5;p++){const h=v(u,l);if(!h||h===u)break;u=h;try{f=o.window.eval("("+u+")");break}catch(y){const a=/Identifier '([^']+)' has already been declared/.exec(y&&y.message||String(y));if(!a||a[1]!==l)break}}}if(!f&&/Unexpected (token '\{'|identifier)/.test(n))try{const u=o.window.eval("({"+e+"})");if(u&&typeof u=="object"){const l=Object.keys(u);l.length===1&&typeof u[l[0]]=="function"&&(f=u[l[0]])}}catch{}return f||(typeof console<"u"&&console.warn&&console.warn(`[smbls] deepDestringifyFunctions: eval failed on ${t} \u2014 value will be left as a string. Reason: `+n+`.
12
- First 200 chars of source: `+String(e).slice(0,200)),e)}},he=(e,t={},o={window:{eval:X}})=>{if(!e||typeof e!="object")return t;const c=[[e,t]];for(;c.length;){const[r,n]=c.pop();for(const i in r){if(!Object.prototype.hasOwnProperty.call(r,i))continue;const s=r[i];if(O(s))P(s)?n[i]=W(s,`"${i}"`,o):n[i]=s;else if(_(s)){const f=n[i]=[];for(let u=0;u<s.length;u++){const l=s[u];if(O(l))f.push(P(l)?W(l,`array index ${u} (prop "${i}")`,o):l);else if(k(l)){const p=q(l);if(p)f.push(p);else{const h={};f.push(h),c.push([l,h])}}else f.push(l)}}else if(k(s)){const f=q(s);if(f){n[i]=f;continue}const u=n[i]&&typeof n[i]=="object"&&!_(n[i])?n[i]:n[i]={};c.push([s,u])}else n[i]=s}}return t},I="Set",C="Map",b="RegExp",G="WeakMap",F="WeakSet",L=e=>{const t=Object.keys(e);return t.length===1&&t[0]==="__type"},x=(e,t)=>{if(!e||typeof e!="object")return e;const o=n=>x(n,t||(t=new WeakMap));if(e.__type===I&&_(e.values))return new Set(e.values.map(o));if(e.__type===C&&_(e.entries))return new Map(e.entries.map(n=>_(n)?[o(n[0]),o(n[1])]:n));if(e.__type===G&&L(e))return new WeakMap;if(e.__type===F&&L(e))return new WeakSet;if(e.__type===b&&O(e.source))try{return new RegExp(e.source,O(e.flags)?e.flags:"")}catch{return e}if(t||(t=new WeakMap),t.has(e))return t.get(e);let c=!1;if(_(e)){const n=new Array(e.length);t.set(e,n);for(let i=0;i<e.length;i++)n[i]=x(e[i],t),n[i]!==e[i]&&(c=!0);return c||t.set(e,e),c?n:e}const r={};t.set(e,r);for(const n of Object.keys(e))r[n]=x(e[n],t),r[n]!==e[n]&&(c=!0);return c||t.set(e,e),c?r:e},q=e=>{if(!e||typeof e!="object")return null;const t=e.__type;if(t!==b&&t!==I&&t!==C&&t!==G&&t!==F)return null;const o=x(e);return o===e?null:o},de=e=>{if(!e||typeof e!="object")return e;const t={},o=[];for(const i of Object.keys(e)){const s=e[i];O(s)&&P(s)?o.push([i,s]):t[i]=x(s)}if(o.length===0)return t;const c=i=>/^[A-Za-z_$][\w$]*$/.test(i),r=o.filter(([i])=>c(i)),n=Object.keys(t).filter(c).map(i=>`var ${i} = __gs__[${JSON.stringify(i)}];`).join(`
13
- `);try{const i=r.map(([u,l])=>`var ${u} = (${l});`).join(`
14
- `),s="{ "+r.map(([u])=>`${JSON.stringify(u)}: ${u}`).join(", ")+" }",f=$.eval(`(function(__gs__) { ${n}
15
- ${i}
16
- return ${s}; })`)(t);Object.assign(t,f)}catch{for(const[s,f]of r)try{const u=Object.keys(t).filter(c).map(l=>`var ${l} = __gs__[${JSON.stringify(l)}];`).join(`
17
- `);t[s]=$.eval(`(function(__gs__) { ${u}
18
- return (${f}); })`)(t)}catch{try{t[s]=$.eval(`(${f})`)}catch{t[s]=f}}}for(const[i,s]of o)if(!c(i))try{t[i]=$.eval(`(${s})`)}catch{t[i]=s}return t},ge=(e,t={verbose:!0})=>{try{return e?$.eval("("+e+")"):{}}catch(o){t.verbose&&console.warn(o)}},_e=(e,...t)=>Object.prototype.hasOwnProperty.call(e,...t),Q=e=>{for(const t in e)return!1;return!0},we=e=>k(e)&&Q(e),Oe=()=>Object.create(null),Se=(e,t,o={})=>{const c=o.exclude||[],r=o.preventUnderscore;for(const n in t)c.includes(n)||!r&&S(n)||n==="constructor"||n==="prototype"||t[n]!==void 0&&(e[n]=t[n]);return e},ke=(e,t,o=[])=>{const c=o instanceof Set;for(const r in t)S(r)||r==="constructor"||r==="prototype"||(c?o.has(r):o.includes(r))||(e[r]=t[r]);return e},j=(e,t,o={},c=new WeakMap)=>{if(!g(e)||!g(t)||w(e)||w(t))return t;if(c.has(e))return c.get(e);c.set(e,e);const r=o.exclude,n=r?r instanceof Set?r:new Set(r):null,i=!o.preventForce;for(const s in t){if(!Object.prototype.hasOwnProperty.call(t,s)||n&&n.has(s)||i&&S(s)||s==="constructor"||s==="prototype")continue;const f=e[s],u=t[s];w(u)?e[s]=u:g(f)&&g(u)?e[s]=j(f,u,o,c):u!==void 0&&(e[s]=u)}return e},ee=(e,t,o=new Set)=>{if(typeof e!="object"||typeof t!="object"||e===null||t===null)return e===t;if(o.has(e)||o.has(t))return!0;o.add(e),o.add(t);const c=Object.keys(e),r=Object.keys(t);if(c.length!==r.length)return!1;for(let n=0;n<c.length;n++){const i=c[n];if(!Object.prototype.hasOwnProperty.call(t,i)||!ee(e[i],t[i],o))return!1}return!0},te=new Set(["node","__ref"]),$e=(e,t,o=te)=>{if(e===t)return!0;if(!g(e)||!g(t)||w(e)||w(t))return e===t;const c=o instanceof Set?o:new Set(o),r=new WeakSet;function n(i,s){if(r.has(s))return!0;r.add(s);for(const f in s){if(!Object.prototype.hasOwnProperty.call(s,f)||c.has(f))continue;if(!Object.prototype.hasOwnProperty.call(i,f))return!1;const u=s[f],l=i[f];if(w(u)||w(l)){if(u!==l)return!1}else if(g(u)&&g(l)){if(!n(l,u))return!1}else if(u!==l)return!1}return!0}return n(e,t)},xe=(e,t)=>{if(t==null)return e;if(K(t)("string","number"))delete e[t];else if(_(t))for(let o=0;o<t.length;o++)delete e[t[o]];else throw new Error("Invalid input: props must be a string or an array of strings");return e},ne=e=>{if(e===null||typeof e!="object")return e;const t=Object.create(null);for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=ne(e[o]));return t},Ee=(e,t)=>{if(e.length===0)return t;const o={};let c=o;for(let r=0;r<e.length;r++)r===e.length-1&&t?c[e[r]]=t:(c[e[r]]={},c=c[e[r]]);return o},Pe=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let o=e;for(let r=0;r<t.length-1;r++){if(o[t[r]]===void 0)return;o=o[t[r]]}const c=t[t.length-1];o&&Object.prototype.hasOwnProperty.call(o,c)&&delete o[c]},Ae=(e,t,o)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let c=e;for(let r=0;r<t.length-1;r++)(!c[t[r]]||typeof c[t[r]]!="object")&&(c[t[r]]={}),c=c[t[r]];return c[t[t.length-1]]=o,e},Te=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let o=e;for(let c=0;c<t.length;c++){if(o==null)return;o=o[t[c]]}return o},Ne=e=>{let o=[],c=0;for(let r=0;r<e.length;r++)if(o.length<2)o.push(e[r]);else if(e[r]===o[r%2]?c++:(o=[e[r-1],e[r]],c=1),c>=20)return(A==="test"||A==="development")&&console.warn("Warning: Potential infinite loop detected due to repeated sequence:",o),!0},Re=e=>{const t=new WeakSet;function o(c){if(c&&typeof c=="object"){if(t.has(c))return!0;t.add(c);for(const r in c)if(Object.prototype.hasOwnProperty.call(c,r)&&o(c[r]))return console.log(c,"cycle at "+r),!0}return!1}return o(e)},De=(e,t)=>{const o=t instanceof Set?t:new Set(t),c={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&!o.has(r)&&(c[r]=e[r]);return c};export{pe as clone,Ee as createNestedObject,ne as createObjectWithoutPrototype,ye as deepClone,$e as deepContains,he as deepDestringifyFunctions,ae as deepMerge,R as deepStringifyFunctions,de as destringifyGlobalScope,Ne as detectInfiniteLoop,De as excludeKeysFromObject,T as exec,Te as getInObjectByPath,P as hasFunction,_e as hasOwnProperty,Re as isCyclic,Q as isEmpty,we as isEmptyObject,ee as isEqualDeep,Oe as makeObjectWithoutPrototype,ue as map,le as merge,M as objectToString,Se as overwrite,j as overwriteDeep,ke as overwriteShallow,xe as removeFromObject,Pe as removeNestedKeyByPath,Ae as setInObjectByPath,ge as stringToObject};
1
+ import{window as x}from"./globals.js";import{isFunction as P,isObjectLike as g,isObject as A,isArray as _,isString as O,is as X}from"./types.js";import{unstackArrayOfObjects as Q}from"./array.js";import{stringIncludesAny as j}from"./string.js";import{isDOMNode as w}from"./node.js";import{METHODS_EXL as ee}from"./keys.js";const z="production",S=e=>e.charCodeAt(0)===95&&e.charCodeAt(1)===95,L=(e,t,n,o)=>{if(P(e))return t?typeof e.call!="function"?e:e.call(t,t,n||t.state,o||t.context):void 0;if(e!=null&&t?.context?.plugins&&(_(e)||A(e)&&!w(e))){const r=t.context.plugins;for(const i of r)if(i.resolveHandler){const c=i.resolveHandler(e,t);if(typeof c=="function")return L(c,t,n,o)}}return e},ze=(e,t,n)=>{for(const o in t)e[o]=L(t[o],n)},Le=(e,t,n=[])=>{const o=n instanceof Set;for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(S(r)||(o?n.has(r):n.includes(r))||e[r]===void 0&&(e[r]=t[r]));return e},Ie=(e,t,n=ee)=>I(e,t,n,null),I=(e,t,n,o)=>{if(e===t)return e;if(o){for(let i=0;i<o.length;i+=2)if(o[i]===e&&o[i+1]===t)return e}const r=n instanceof Set;for(const i in t){if(!Object.prototype.hasOwnProperty.call(t,i)||S(i)||i==="constructor"||i==="prototype"||(r?n.has(i):n.includes(i)))continue;const c=e[i],l=t[i];if(g(c)&&g(l)){const s=o||[];s.push(e,t),I(c,l,n,s),s.length-=2}else c===void 0&&(e[i]=l)}return e},me=(e,t=[])=>{const n=t instanceof Set,o={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(S(r)||(n?t.has(r):t.includes(r))||(o[r]=e[r]));return o},Fe=(e,t={})=>{const{exclude:n=[],cleanUndefined:o=!1,cleanNull:r=!1,visited:i=new WeakMap,handleExtends:c=!1}=t;if(!g(e)||w(e))return e;if(i.has(e))return i.get(e);const l=n instanceof Set?n:n.length>3?new Set(n):null,s=u=>l?l.has(u):n.includes(u),p=_(e)?[]:{};i.set(e,p);const f=[[e,p]];for(;f.length;){const[u,h]=f.pop();for(const y in u){if(!Object.prototype.hasOwnProperty.call(u,y)||S(y)||y==="__proto__"||s(y))continue;const a=u[y];if(!(o&&a===void 0)&&!(r&&a===null)){if(w(a)){h[y]=a;continue}if(c&&y==="extends"&&_(a)){h[y]=Q(a,n);continue}if(P(a)){h[y]=a;continue}if(g(a))if(i.has(a))h[y]=i.get(a);else{const d=_(a)?[]:{};i.set(a,d),h[y]=d,f.push([a,d])}else h[y]=a}}}return p},m=(e,t={})=>{(e.node||e.__ref||e.parent||e.__element||e.parse)&&((e.__element||e.parent?.__element).warn("Trying to clone element or state at",e),e=e.parse?.());for(const n in e){const o=e[n];if(P(o))t[n]=o.toString();else if(A(o))t[n]={},m(o,t[n]);else if(_(o)){const r=t[n]=[];for(let i=0;i<o.length;i++){const c=o[i];A(c)?(r[i]={},m(c,r[i])):P(c)?r[i]=c.toString():r[i]=c}}else t[n]=o}return t},te=/^[A-Za-z_$][A-Za-z0-9_$]*$/,ne=e=>`'${String(e).replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\r/g,"\\r").replace(/\n/g,"\\n")}'`,F=e=>{const t=String(e);return j(t,[`
2
+ `,"'"])?"`"+t.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")+"`":"'"+t.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\r/g,"\\r")+"'"},b=(e={},t=0)=>{if(e===null||typeof e!="object"||e instanceof RegExp)return String(e);let n=!1;for(const i in e){n=!0;break}if(!n)return"{}";const o=" ".repeat(t);let r=`{
3
+ `;for(const i in e){if(!Object.prototype.hasOwnProperty.call(e,i))continue;const c=e[i],l=te.test(i)?i:ne(i);if(r+=`${o} ${l}: `,c instanceof RegExp)r+=String(c);else if(_(c)){r+=`[
4
+ `;for(const s of c)s instanceof RegExp?r+=`${o} ${String(s)},
5
+ `:g(s)&&s!==null?r+=`${o} ${b(s,t+2)},
6
+ `:O(s)?r+=`${o} ${F(s)},
7
+ `:r+=`${o} ${s},
8
+ `;r+=`${o} ]`}else g(c)?r+=b(c,t+1):O(c)?r+=F(c):r+=c;r+=`,
9
+ `}return r+=`${o}}`,r},re=[/^\(\s*\{[^}]*\}\s*\)\s*=>/,/^(\([^)]*\)|[^=]*)\s*=>/,/^function[\s(]/,/^async\s+/,/^\(\s*function/,/^[a-zA-Z_$][a-zA-Z0-9_$]*\s*=>/,/^(?:\*\s*)?[a-zA-Z_$][\w$]*\s*\((?:[^()]|\([^()]*\))*\)\s*\{[\s\S]*\}$/],oe=/^["[{]/,ie=/^(export|import)\s/,R=e=>{if(!e)return!1;const t=e.trim();if(t===""||t==="{}"||t==="[]")return!1;const n=t.includes("=>");if(!n&&t.charCodeAt(0)!==40&&!t.startsWith("function")&&!t.startsWith("async")&&!(t.charCodeAt(t.length-1)===125&&t.includes("("))||ie.test(t)||!re.some(i=>i.test(t)))return!1;const r=t.charCodeAt(0);return!(r===123&&!n||r===91||oe.test(t)&&!n)},M=e=>(0,eval)(e),ce=(e,t)=>{const n=/^(\s*(?:async\s+)?function\s*[\w$]*\s*\([^)]*\)\s*)\{/.exec(e);if(!n)return null;const o=n[0].length,r=[];let i=o,c=1,l=null;const s=e.length,p=new RegExp("^(?:const|let|var)\\s+"+t+"\\b");for(;i<s&&c>0;){const u=e[i];if(u==="/"&&e[i+1]==="/"){const h=e.indexOf(`
10
+ `,i);i=h===-1?s:h;continue}if(u==="/"&&e[i+1]==="*"){const h=e.indexOf("*/",i+2);i=h===-1?s:h+2;continue}if(u==='"'||u==="'"||u==="`"){const h=u;for(i++;i<s;){if(e[i]==="\\"){i+=2;continue}if(e[i]===h){i++;break}if(h==="`"&&e[i]==="$"&&e[i+1]==="{"){i+=2;let y=1;for(;i<s&&y>0;)e[i]==="{"?y++:e[i]==="}"&&y--,i++;continue}i++}continue}if(u==="{"){c++,i++;continue}if(u==="}"){c--,i++;continue}if(c===1&&p.test(e.slice(i))){const h=i;let y=0,a=i;for(;a<s;){const d=e[a];if(d==='"'||d==="'"||d==="`"){const k=d;for(a++;a<s;){if(e[a]==="\\"){a+=2;continue}if(e[a]===k){a++;break}a++}continue}if(d==="("||d==="["||d==="{"){y++,a++;continue}if(d===")"||d==="]"||d==="}"){if(y===0)break;y--,a++;continue}if(y===0&&(d===";"||d===`
11
+ `)){a++;break}a++}r.push([h,a]),i=a;continue}i++}if(!r.length)return null;let f=e;for(let u=r.length-1;u>=0;u--)f=f.slice(0,r[u][0])+f.slice(r[u][1]);return f},T=(e,t,n,o)=>{const r=String(e).trimStart();if(/^(export|import)\s/.test(r))return e;try{return n.window.eval(`(${e})`)}catch(i){const c=i&&i.message?i.message:String(i),l=/await is only valid in async/.test(c),s=/Identifier '([^']+)' has already been declared/.exec(c);let p=null;if(l){const f=String(e).trim();if(/^function[\s(]/.test(f))try{p=n.window.eval("(async "+f+")")}catch{}}else if(s){let f=String(e),u=s[1];for(let h=0;h<5;h++){const y=ce(f,u);if(!y||y===f)break;f=y;try{p=n.window.eval("("+f+")");break}catch(a){const d=/Identifier '([^']+)' has already been declared/.exec(a&&a.message||String(a));if(!d||d[1]!==u)break}}}if(!p&&/Unexpected (token '\{'|identifier)/.test(c))try{const f=n.window.eval("({"+e+"})");if(f&&typeof f=="object"){const u=Object.keys(f);u.length===1&&typeof f[u[0]]=="function"&&(p=f[u[0]])}}catch{}return p||(typeof console<"u"&&console.warn&&console.warn(`[smbls] deepDestringifyFunctions: eval failed on ${t} \u2014 `+(o?"revived lazily, so its source compiled on this first use; it acts as the string it replaces (a call returns the source text, el.call treats it as not callable). Reason: ":"value will be left as a string. Reason: ")+c+`.
12
+ First 200 chars of source: `+String(e).slice(0,200)),e)}},W=1,C=2,E=new WeakMap,se=/^(async\s+)?function(?![\w$])\s*(\*)?\s*([A-Za-z_$][\w$]*)?\s*\((?:[^()'"`/]|\([^()'"`/]*\))*\)\s*\{/,fe=/^(async\s+)?[A-Za-z_$][\w$]*\s*=>/,le=/^(async\s*)?\((?:[^()'"`/]|\([^()'"`/]*\))*\)\s*=>/,ue=/^(async\s+)?([A-Za-z_$][\w$]*)\s*\((?:[^()'"`/]|\([^()'"`/]*\))*\)\s*\{/,ae=new Set(["if","for","while","switch","catch","with","do","return","typeof","void","delete","new","in","of","instanceof","function","class","const","let","var","await","yield","import","export","try","else","throw","case","default","break","continue","debugger","finally","super","this","null","true","false","async","get","set","static"]),Y=e=>e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===36||e===95,pe=(e,t,n)=>{let o=e.indexOf(t,n);for(;o!==-1;){const r=o+t.length;if((o===0||!Y(e.charCodeAt(o-1)))&&(r>=e.length||!Y(e.charCodeAt(r))))return!0;o=e.indexOf(t,r)}return!1},v=e=>{let t=e.length-1;for(;t>=0&&e.charCodeAt(t)<=32;)t--;return t<0?-1:e.charCodeAt(t)},ye=e=>{let t=e,n=0;for(;n<t.length&&t.charCodeAt(n)<=32;)n++;n&&(t=t.slice(n));let o=se.exec(t);if(o){if(o[2]||v(t)!==125)return null;const r=o[3]||"";return r&&pe(t,r,o[0].indexOf("("))||t.indexOf("arguments.callee")!==-1?null:{src:e,name:r,kind:o[1]?C:W,async:!!o[1],fn:void 0}}return o=fe.exec(t)||le.exec(t),o?{src:e,name:"",kind:C,async:!!o[1],fn:void 0}:(o=ue.exec(t),o&&!ae.has(o[2])&&v(t)===125?t.indexOf("arguments.callee")!==-1?null:{src:e,name:o[2],kind:C,async:!!o[1],fn:void 0}:null)},Z=e=>e.index===-1?`"${e.key}"`:`array index ${e.index} (prop "${e.key}")`,N=e=>{const t=T(e.src,Z(e),e.opts,!0);let n=null;return typeof t=="function"?n=t:(e.value=t,typeof t!="string"&&typeof console<"u"&&console.warn&&console.warn(`[smbls] deepDestringifyFunctions: ${Z(e)} did not evaluate to a function \u2014 the lazily revived function returns that value.
13
+ First 200 chars of source: `+String(e.src).slice(0,200))),e.fn=n,e.opts=null,n},de=(e,t,n)=>Reflect.construct(e,t,n);function he(){const e=E.get(this);return e?e.src.trim():Function.prototype.toString.call(this)}const ge={length:{get(){const e=E.get(this);if(!e)return 0;const t=e.fn===void 0?N(e):e.fn;return t?t.length:0},configurable:!0},name:{get(){const e=E.get(this);return e?e.name:""},configurable:!0},toString:{value:he,writable:!0,configurable:!0}},_e=Object.getPrototypeOf(async function(){}),we=e=>{let t;return e.kind===W?t=function(){const n=e.fn===void 0?N(e):e.fn;return n===null?e.value:new.target?de(n,arguments,new.target):n.apply(this,arguments)}:t={lazy(){const n=e.fn===void 0?N(e):e.fn;return n===null?e.value:n.apply(this,arguments)}}.lazy,E.set(t,e),Object.defineProperties(t,ge),e.async&&Object.setPrototypeOf(t,_e),t},H=(e,t,n,o)=>{const r=ye(e);return r?(r.key=t,r.index=n,r.opts=o,we(r)):T(e,n===-1?`"${t}"`:`array index ${n} (prop "${t}")`,o)},be=e=>typeof e=="function"&&E.has(e),Me=e=>{const t=E.get(e);return t?t.src.trim():Function.prototype.toString.call(e)},We=e=>{const t=typeof e=="function"?E.get(e):void 0;return t?(t.fn===void 0?N(t):t.fn)===null:!1},Oe=new Set(["components","pages","functions","methods","snippets","app","globalScope"]),Se={window:{eval:M}},Ye=(e,t={},n=Se)=>{if(!e||typeof e!="object")return t;(!n||!n.window||typeof n.window.eval!="function")&&(n={...n,window:{eval:M}});const o=n.lazy===!0,r=n.lazy==="context",i=(l,s,p)=>o||r&&(l===e?Oe.has(s):p),c=[[e,t,o]];for(;c.length;){const[l,s,p]=c.pop();for(const f in l){if(!Object.prototype.hasOwnProperty.call(l,f))continue;const u=l[f];if(O(u))R(u)?s[f]=p?H(u,f,-1,n):T(u,`"${f}"`,n):s[f]=u;else if(_(u)){const h=s[f]=[],y=i(l,f,p);for(let a=0;a<u.length;a++){const d=u[a];if(O(d))h.push(R(d)?y?H(d,f,a,n):T(d,`array index ${a} (prop "${f}")`,n):d);else if(A(d)){const k=V(d);if(k)h.push(k);else{const D={};h.push(D),c.push([d,D,y])}}else h.push(d)}}else if(A(u)){const h=V(u);if(h){s[f]=h;continue}const y=s[f]&&typeof s[f]=="object"&&!_(s[f])?s[f]:s[f]={};c.push([u,y,i(l,f,p)])}else s[f]=u}}return t},G="Set",K="Map",B="RegExp",U="WeakMap",q="WeakSet",J=e=>{const t=Object.keys(e);return t.length===1&&t[0]==="__type"},$=(e,t)=>{if(!e||typeof e!="object")return e;const n=i=>$(i,t||(t=new WeakMap));if(e.__type===G&&_(e.values))return new Set(e.values.map(n));if(e.__type===K&&_(e.entries))return new Map(e.entries.map(i=>_(i)?[n(i[0]),n(i[1])]:i));if(e.__type===U&&J(e))return new WeakMap;if(e.__type===q&&J(e))return new WeakSet;if(e.__type===B&&O(e.source))try{return new RegExp(e.source,O(e.flags)?e.flags:"")}catch{return e}if(t||(t=new WeakMap),t.has(e))return t.get(e);let o=!1;if(_(e)){const i=new Array(e.length);t.set(e,i);for(let c=0;c<e.length;c++)i[c]=$(e[c],t),i[c]!==e[c]&&(o=!0);return o||t.set(e,e),o?i:e}const r={};t.set(e,r);for(const i of Object.keys(e))r[i]=$(e[i],t),r[i]!==e[i]&&(o=!0);return o||t.set(e,e),o?r:e},V=e=>{if(!e||typeof e!="object")return null;const t=e.__type;if(t!==B&&t!==G&&t!==K&&t!==U&&t!==q)return null;const n=$(e);return n===e?null:n},ve=e=>{if(!e||typeof e!="object")return e;const t={},n=[];for(const c of Object.keys(e)){const l=e[c];O(l)&&R(l)?n.push([c,l]):t[c]=$(l)}if(n.length===0)return t;const o=c=>/^[A-Za-z_$][\w$]*$/.test(c),r=n.filter(([c])=>o(c)),i=Object.keys(t).filter(o).map(c=>`var ${c} = __gs__[${JSON.stringify(c)}];`).join(`
14
+ `);try{const c=r.map(([p,f])=>`var ${p} = (${f});`).join(`
15
+ `),l="{ "+r.map(([p])=>`${JSON.stringify(p)}: ${p}`).join(", ")+" }",s=x.eval(`(function(__gs__) { ${i}
16
+ ${c}
17
+ return ${l}; })`)(t);Object.assign(t,s)}catch{for(const[l,s]of r)try{const p=Object.keys(t).filter(o).map(f=>`var ${f} = __gs__[${JSON.stringify(f)}];`).join(`
18
+ `);t[l]=x.eval(`(function(__gs__) { ${p}
19
+ return (${s}); })`)(t)}catch{try{t[l]=x.eval(`(${s})`)}catch{t[l]=s}}}for(const[c,l]of n)if(!o(c))try{t[c]=x.eval(`(${l})`)}catch{t[c]=l}return t},Ze=(e,t={verbose:!0})=>{try{return e?x.eval("("+e+")"):{}}catch(n){t.verbose&&console.warn(n)}},He=(e,...t)=>Object.prototype.hasOwnProperty.call(e,...t),Ee=e=>{for(const t in e)return!1;return!0},Ge=e=>A(e)&&Ee(e),Ke=()=>Object.create(null),Be=(e,t,n={})=>{const o=n.exclude||[],r=n.preventUnderscore;for(const i in t)o.includes(i)||!r&&S(i)||i==="constructor"||i==="prototype"||t[i]!==void 0&&(e[i]=t[i]);return e},Ue=(e,t,n=[])=>{const o=n instanceof Set;for(const r in t)S(r)||r==="constructor"||r==="prototype"||(o?n.has(r):n.includes(r))||(e[r]=t[r]);return e},Ae=(e,t,n={},o=new WeakMap)=>{if(!g(e)||!g(t)||w(e)||w(t))return t;if(o.has(e))return o.get(e);o.set(e,e);const r=n.exclude,i=r?r instanceof Set?r:new Set(r):null,c=!n.preventForce;for(const l in t){if(!Object.prototype.hasOwnProperty.call(t,l)||i&&i.has(l)||c&&S(l)||l==="constructor"||l==="prototype")continue;const s=e[l],p=t[l];w(p)?e[l]=p:g(s)&&g(p)?e[l]=Ae(s,p,n,o):p!==void 0&&(e[l]=p)}return e},xe=(e,t,n=new Set)=>{if(typeof e!="object"||typeof t!="object"||e===null||t===null)return e===t;if(n.has(e)||n.has(t))return!0;n.add(e),n.add(t);const o=Object.keys(e),r=Object.keys(t);if(o.length!==r.length)return!1;for(let i=0;i<o.length;i++){const c=o[i];if(!Object.prototype.hasOwnProperty.call(t,c)||!xe(e[c],t[c],n))return!1}return!0},$e=new Set(["node","__ref"]),qe=(e,t,n=$e)=>{if(e===t)return!0;if(!g(e)||!g(t)||w(e)||w(t))return e===t;const o=n instanceof Set?n:new Set(n),r=new WeakSet;function i(c,l){if(r.has(l))return!0;r.add(l);for(const s in l){if(!Object.prototype.hasOwnProperty.call(l,s)||o.has(s))continue;if(!Object.prototype.hasOwnProperty.call(c,s))return!1;const p=l[s],f=c[s];if(w(p)||w(f)){if(p!==f)return!1}else if(g(p)&&g(f)){if(!i(f,p))return!1}else if(p!==f)return!1}return!0}return i(e,t)},Je=(e,t)=>{if(t==null)return e;if(X(t)("string","number"))delete e[t];else if(_(t))for(let n=0;n<t.length;n++)delete e[t[n]];else throw new Error("Invalid input: props must be a string or an array of strings");return e},ke=e=>{if(e===null||typeof e!="object")return e;const t=Object.create(null);for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=ke(e[n]));return t},Ve=(e,t)=>{if(e.length===0)return t;const n={};let o=n;for(let r=0;r<e.length;r++)r===e.length-1&&t?o[e[r]]=t:(o[e[r]]={},o=o[e[r]]);return n},Xe=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let n=e;for(let r=0;r<t.length-1;r++){if(n[t[r]]===void 0)return;n=n[t[r]]}const o=t[t.length-1];n&&Object.prototype.hasOwnProperty.call(n,o)&&delete n[o]},Qe=(e,t,n)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let o=e;for(let r=0;r<t.length-1;r++)(!o[t[r]]||typeof o[t[r]]!="object")&&(o[t[r]]={}),o=o[t[r]];return o[t[t.length-1]]=n,e},je=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let n=e;for(let o=0;o<t.length;o++){if(n==null)return;n=n[t[o]]}return n},et=e=>{let n=[],o=0;for(let r=0;r<e.length;r++)if(n.length<2)n.push(e[r]);else if(e[r]===n[r%2]?o++:(n=[e[r-1],e[r]],o=1),o>=20)return(z==="test"||z==="development")&&console.warn("Warning: Potential infinite loop detected due to repeated sequence:",n),!0},tt=e=>{const t=new WeakSet;function n(o){if(o&&typeof o=="object"){if(t.has(o))return!0;t.add(o);for(const r in o)if(Object.prototype.hasOwnProperty.call(o,r)&&n(o[r]))return console.log(o,"cycle at "+r),!0}return!1}return n(e)},nt=(e,t)=>{const n=t instanceof Set?t:new Set(t),o={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&!n.has(r)&&(o[r]=e[r]);return o};export{me as clone,Ve as createNestedObject,ke as createObjectWithoutPrototype,Fe as deepClone,qe as deepContains,Ye as deepDestringifyFunctions,Ie as deepMerge,m as deepStringifyFunctions,ve as destringifyGlobalScope,et as detectInfiniteLoop,nt as excludeKeysFromObject,L as exec,Me as getFunctionSource,je as getInObjectByPath,R as hasFunction,He as hasOwnProperty,tt as isCyclic,Ee as isEmpty,Ge as isEmptyObject,xe as isEqualDeep,We as isFailedRevival,be as isLazyFunction,Ke as makeObjectWithoutPrototype,ze as map,Le as merge,b as objectToString,Be as overwrite,Ae as overwriteDeep,Ue as overwriteShallow,Je as removeFromObject,Xe as removeNestedKeyByPath,Qe as setInObjectByPath,Ze as stringToObject};
package/function.js CHANGED
@@ -67,7 +67,10 @@ export const memoize = fn => {
67
67
  }
68
68
  }
69
69
 
70
- const RE_STRING_FUNCTION = /^((function\s*\([^)]*\)\s*\{[^}]*\})|(\([^)]*\)\s*=>))/
70
+ // A function's source, however it was written: `function (…) {…}` (a method
71
+ // shorthand's `name (…) {` is NOT one — that is how object literals read),
72
+ // `(…) =>`, `x =>`, each with an optional `async`.
73
+ const RE_STRING_FUNCTION = /^\s*(?:async\s+)?(?:function\b|\([^)]*\)\s*=>|[a-zA-Z_$][\w$]*\s*=>)/
71
74
 
72
75
  export const isStringFunction = inputString => {
73
76
  return RE_STRING_FUNCTION.test(inputString)
package/metadata.js CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict'
2
2
 
3
3
  import { isObject } from './types.js'
4
+ import { isStringFunction } from './function.js'
4
5
 
5
6
  const escapeHtml = (text) => {
6
7
  if (text === null || text === undefined) return ''
@@ -357,6 +358,13 @@ function resolveMetadataTemplates (metadata, data, ssrContext) {
357
358
  * (el, s) => s.item ? s.item.image_url : ""
358
359
  */
359
360
  function convertFunctionMetaToTemplates (metadata) {
361
+ // A page may set `metadata` itself to a function ((el, s) => ({ title… })):
362
+ // the runtime helmet resolves that against live state, the publish
363
+ // pipeline cannot. In the project JSON it is a string — spreading it made
364
+ // one <meta> per CHARACTER of its source (`<meta name="0" content="(">`,
365
+ // 137 of them on aihouse's home page, 2026-09-24). Nothing to read here;
366
+ // the app-level metadata is what the static head gets.
367
+ if (!isObject(metadata)) return {}
360
368
  const result = { ...metadata }
361
369
  for (const [key, value] of Object.entries(result)) {
362
370
  if (typeof value === 'function') {
@@ -401,6 +409,12 @@ function convertFunctionMetaToTemplates (metadata) {
401
409
  continue
402
410
  }
403
411
  }
412
+ // Still a function's source — `(el, s) => el.call('propertyMetadata').title`
413
+ // — that none of the patterns read: the runtime resolves it, the static
414
+ // head must not print code into a <meta content>.
415
+ if (isStringFunction(value)) {
416
+ delete result[key]
417
+ }
404
418
  }
405
419
  }
406
420
  return result
package/methods.js CHANGED
@@ -3,7 +3,7 @@
3
3
  import { triggerEventOn } from './triggerEvent.js'
4
4
  import { DOMQ_PROPERTIES, METHODS, PARSED_DOMQ_PROPERTIES } from './keys.js'
5
5
  import { isDefined, isFunction, isObject, isObjectLike } from './types.js'
6
- import { deepClone } from './object.js'
6
+ import { deepClone, isFailedRevival } from './object.js'
7
7
  import { isProduction } from './env.js'
8
8
  import { removeValueFromArray } from './array.js'
9
9
  import { OPTIONS } from './cache.js'
@@ -472,6 +472,10 @@ export function call (fnKey, ...args) {
472
472
  context.snippets?.[fnKey]
473
473
  )
474
474
  if (!fn) return
475
+ // A lazily revived function whose source does not compile stands for the
476
+ // string eager revival left (object.js "LAZY REVIVAL"), which this helper
477
+ // could not call either: undefined, as before.
478
+ if (isFailedRevival(fn)) return
475
479
  try {
476
480
  const result = fn.call(this, ...args)
477
481
  if (result && typeof result.then === 'function') {
package/object.js CHANGED
@@ -387,16 +387,32 @@ const RE_MODULE_PREFIX = /^(export|import)\s/
387
387
  export const hasFunction = (str) => {
388
388
  if (!str) return false
389
389
 
390
- const trimmed = str.trim().replace(/\n\s*/g, ' ').trim()
390
+ // SMBLS-BOOT-LAZY-EVAL-1: this runs on EVERY string of a project context
391
+ // at boot (Pulse: ~26k strings, 2 MB), so it must reject a non-function
392
+ // string cheaply. Both steps below are exact — the result is identical to
393
+ // the previous form (`str.trim().replace(/\n\s*/g, ' ').trim()` then every
394
+ // pattern), pinned by __tests__/hasFunctionEquivalence.test.js:
395
+ // • no newline collapsing: every pattern reads `\s`, `[^)]`, `[^}]`,
396
+ // `[^=]` or `[\s\S]` where a newline run and a space both match, and
397
+ // nothing else looks at whitespace;
398
+ // • the pre-filter: every pattern needs `=>`, or a `function` / `async`
399
+ // / `(` prefix, or a `(` plus a closing `}` (method shorthand) — a
400
+ // string with none of those can match none of them.
401
+ const trimmed = str.trim()
391
402
 
392
403
  if (trimmed === '' || trimmed === '{}' || trimmed === '[]') return false
404
+ const hasArrow = trimmed.includes('=>')
405
+ if (!hasArrow &&
406
+ trimmed.charCodeAt(0) !== 40 && // '(' — `(function …`
407
+ !trimmed.startsWith('function') &&
408
+ !trimmed.startsWith('async') &&
409
+ !(trimmed.charCodeAt(trimmed.length - 1) === 125 && trimmed.includes('('))) return false
393
410
  if (RE_MODULE_PREFIX.test(trimmed)) return false
394
411
 
395
412
  const isFn = FN_PATTERNS.some((pattern) => pattern.test(trimmed))
396
413
  if (!isFn) return false
397
414
 
398
415
  const firstChar = trimmed.charCodeAt(0)
399
- const hasArrow = trimmed.includes('=>')
400
416
  // '{' = 123, '[' = 91
401
417
  if (firstChar === 123 && !hasArrow) return false // object literal
402
418
  if (firstChar === 91) return false // array literal
@@ -518,8 +534,12 @@ const stripTopLevelDeclaration = (src, name) => {
518
534
  // the structural walker used inline. Returns either the eval'd value or
519
535
  // the original string (with a console.warn) so callers can assign the
520
536
  // result directly. `label` is used in warning messages so the surface
521
- // of the failure (object key vs array index) is identifiable.
522
- const _destringifyFnString = (str, label, opts) => {
537
+ // of the failure (object key vs array index) is identifiable. `lazy` only
538
+ // changes the warning's description of the outcome: a lazily revived
539
+ // function (see LAZY REVIVAL below) compiles on its first use, and when the
540
+ // source does not compile it stands for the string an eager revival leaves
541
+ // in place.
542
+ const _destringifyFnString = (str, label, opts, lazy) => {
523
543
  // Module SOURCE files are stored as plain strings on project data
524
544
  // (`code` fields driving CodePreview etc. — they start with
525
545
  // `export …` / `import …`). They are display text, not function
@@ -594,7 +614,10 @@ const _destringifyFnString = (str, label, opts) => {
594
614
  if (typeof console !== 'undefined' && console.warn) {
595
615
  console.warn(
596
616
  `[smbls] deepDestringifyFunctions: eval failed on ${label} — ` +
597
- 'value will be left as a string. Reason: ' + msg + '.\n' +
617
+ (lazy
618
+ ? 'revived lazily, so its source compiled on this first use; it acts as the string it replaces ' +
619
+ '(a call returns the source text, el.call treats it as not callable). Reason: '
620
+ : 'value will be left as a string. Reason: ') + msg + '.\n' +
598
621
  'First 200 chars of source: ' + String(str).slice(0, 200)
599
622
  )
600
623
  }
@@ -602,12 +625,350 @@ const _destringifyFnString = (str, label, opts) => {
602
625
  }
603
626
  }
604
627
 
628
+ // ─────────────────────────────────────────────────────────────────────────
629
+ // LAZY REVIVAL — SMBLS-BOOT-LAZY-EVAL-1
630
+ //
631
+ // Measured on anseta/pulse 1.31.1 (runtime 3.14.808, Lighthouse mobile):
632
+ // the page context carries 3,735 function strings (1.82 MB of source), and
633
+ // the eager walk ran one indirect eval per string before the first render —
634
+ // the largest self time of the whole boot (561 ms unthrottled, ~2.2 s at
635
+ // 4x CPU). A page calls a small share of them: one route's props and a few
636
+ // dozen registered functions.
637
+ //
638
+ // `deepDestringifyFunctions(obj, dest, { lazy: true })` keeps each source
639
+ // and installs a WRAPPER that compiles it on the first call — through the
640
+ // SAME `opts.window.eval` and the SAME recovery passes (`_destringifyFnString`
641
+ // above) the eager walk uses — caches the result and calls straight through
642
+ // from then on. Opt-in: the default stays eager, because tooling reads the
643
+ // eager result (frank's toFS prints a string that failed to compile as a
644
+ // quoted literal, helmet tests for "still a string", the workspace re-realm
645
+ // pass reads `Function.prototype.toString`). The runtime boot paths opt in:
646
+ // the published/runner page scripts and prepareContext's rehydrate.
647
+ //
648
+ // What a wrapper preserves (each pinned in __tests__/deepDestringifyLazy.test.js):
649
+ // • identity — the wrapper IS the function for its whole life. It never
650
+ // swaps itself out after compiling, so WeakMap keys, listener dedupe and
651
+ // `===` stay stable. Two slots with equal source get two wrappers, as
652
+ // two evals gave two functions.
653
+ // • `this`, every argument, the return value (an async source still
654
+ // returns its promise), and `new` for a plain `function` source
655
+ // (`Reflect.construct` with the wrapper as new.target, so instances are
656
+ // `instanceof` the wrapper the outside world holds).
657
+ // • `typeof` 'function', `.call`/`.apply`/`.bind`.
658
+ // • `.toString()` — the ORIGINAL source (trimmed, as an eval'd function
659
+ // expression reports it), without compiling. frank, the editor, SSR and
660
+ // inspectors re-serialize through it.
661
+ // • `.length` — the compiled function's arity, read through an accessor
662
+ // that compiles on demand (only the dev-only stashed-callback advisory
663
+ // in element/create.js and `Function.prototype.bind` read it).
664
+ // • `.name` — what the eager eval would report: the declared name of a
665
+ // `function` or method source, '' for an arrow or anonymous function.
666
+ // • no `.prototype`, not constructible, for arrow / async / method
667
+ // sources — a method-shorthand wrapper, like the eval'd value; an
668
+ // async source's wrapper inherits %AsyncFunction.prototype%, so
669
+ // `instanceof`, `.constructor` and the toStringTag say AsyncFunction.
670
+ //
671
+ // What cannot be preserved: `Function.prototype.toString.call(wrapper)`
672
+ // reads the wrapper's own text, not the stored source — no function object
673
+ // can answer it without compiling. `getFunctionSource(fn)` below answers it
674
+ // for any function; the one in-repo caller (element's dev advisory) uses it.
675
+ // Two more, kept on purpose (PR #187 review N2, N3):
676
+ // • `.caller` / `.arguments` on the wrapper of a plain `function` source
677
+ // throw (the wrapper is strict code). A sloppy wrapper would answer them,
678
+ // but it would also coerce `this` (undefined → globalThis, primitives →
679
+ // objects) before a strict source sees it; `this` is the contract.
680
+ // • every call runs one extra frame, so the deepest recursion through a
681
+ // registry reference roughly halves (probe: 8,959 → 4,607 frames).
682
+ // Swapping the slot to the compiled function after the first call would
683
+ // remove the frame but split identity (a listener added with the wrapper
684
+ // could no longer be removed with the slot's value).
685
+ //
686
+ // Only an UNAMBIGUOUS function expression is revived lazily (see
687
+ // `lazyStateFor`): an arrow, a plain/async `function`, or a method
688
+ // shorthand, whose head the regexes below prove. Everything else `hasFunction`
689
+ // accepts — prose that starts with "function", a generator (its `.prototype`
690
+ // is a generator prototype), a named function that refers to itself by name
691
+ // (its self-binding would be the compiled function, not the wrapper), a
692
+ // `(function…)` wrapped form — keeps the eager path exactly as before, string
693
+ // fallback and boot-time warning included.
694
+ //
695
+ // A lazily revived source that fails to compile warns with today's
696
+ // diagnostic (prefix, reason, first 200 chars) on its FIRST USE instead of
697
+ // at boot, and from then on stands for the STRING eager revival leaves in
698
+ // place (PR #187 review S4): every call returns that string, so a prop DOMQL
699
+ // evaluates by calling it (`text`, `if`, `hide`, attributes, CSS, custom
700
+ // props, `state`) gets exactly the value the string gave — a broken `if`
701
+ // stays truthy, prose in `text` still shows — and `el.call` / utils `call`
702
+ // ask `isFailedRevival` first and treat it as not callable, exactly as they
703
+ // treated the string (undefined, and el.call's "resolves to a non-function
704
+ // (string)" error). What remains different: `typeof` is 'function', and a
705
+ // DIRECT call from other code returns the string where calling a string
706
+ // threw a TypeError.
707
+ //
708
+ // `{ lazy: 'context' }` is the page scripts' mode for a whole project
709
+ // context: only the CODE buckets (LAZY_CONTEXT_CODE_KEYS) revive lazily;
710
+ // data — state, designSystem, polyglot, files, schema, config values —
711
+ // keeps eager revival, so a function-looking data string that does not
712
+ // compile stays the string it is, for code that READS it as a value.
713
+ // `{ lazy: true }` is lazy everywhere: the bucket-level callers
714
+ // (prepareContext's rehydrate of components, pages, functions, …).
715
+ //
716
+ // Identical sources are NOT shared. It would be safe — the compiled
717
+ // function never leaves its wrapper, and the self-referencing shapes that
718
+ // could observe it keep the eager path — but it does not pay: of the 388
719
+ // compiles the first render of Pulse /home triggers, 82 repeat a source
720
+ // (~6 ms of eval), against a per-realm cache every wrapper would consult.
721
+ // ─────────────────────────────────────────────────────────────────────────
722
+
723
+ const LAZY_KIND_PLAIN = 1 // `function` — constructible, has its own `.prototype`
724
+ const LAZY_KIND_CALLABLE = 2 // arrow / async function / method — neither
725
+
726
+ // wrapper → { src, name, kind, async, fn, value, key, index, opts }
727
+ // `fn` is undefined until the first compile, then the compiled function, or
728
+ // null when the source did not compile to one — `value` is then what eager
729
+ // revival leaves in the slot (the source string).
730
+ const LAZY_FN_STATE = new WeakMap()
731
+
732
+ // Every head below must PROVE its shape up to the body's opening brace or the
733
+ // arrow. Parameters are accepted without strings, template literals or slashes
734
+ // (comments, regex literals, division) and with at most one level of nested
735
+ // parens; a head these cannot prove falls back to the eager path — it is
736
+ // never misread.
737
+ const RE_LAZY_FUNCTION_HEAD = /^(async\s+)?function(?![\w$])\s*(\*)?\s*([A-Za-z_$][\w$]*)?\s*\((?:[^()'"`/]|\([^()'"`/]*\))*\)\s*\{/
738
+ const RE_LAZY_ARROW_IDENT_HEAD = /^(async\s+)?[A-Za-z_$][\w$]*\s*=>/
739
+ const RE_LAZY_ARROW_PARENS_HEAD = /^(async\s*)?\((?:[^()'"`/]|\([^()'"`/]*\))*\)\s*=>/
740
+ const RE_LAZY_METHOD_HEAD = /^(async\s+)?([A-Za-z_$][\w$]*)\s*\((?:[^()'"`/]|\([^()'"`/]*\))*\)\s*\{/
741
+
742
+ // A method-shorthand head named like a keyword is prose or a statement
743
+ // (`if (x) { … }`, `for (…) { … }`), never a revivable method.
744
+ const LAZY_NON_METHOD_NAMES = new Set([
745
+ 'if', 'for', 'while', 'switch', 'catch', 'with', 'do', 'return', 'typeof',
746
+ 'void', 'delete', 'new', 'in', 'of', 'instanceof', 'function', 'class',
747
+ 'const', 'let', 'var', 'await', 'yield', 'import', 'export', 'try', 'else',
748
+ 'throw', 'case', 'default', 'break', 'continue', 'debugger', 'finally',
749
+ 'super', 'this', 'null', 'true', 'false', 'async', 'get', 'set', 'static'
750
+ ])
751
+
752
+ const _isIdentCharCode = (c) =>
753
+ (c >= 48 && c <= 57) || (c >= 65 && c <= 90) || (c >= 97 && c <= 122) || c === 36 || c === 95
754
+
755
+ // `name` appears in `src` at or after `from` as a whole identifier token.
756
+ // Conservative on purpose (a property named like the function also counts):
757
+ // a false hit only means the eager path.
758
+ const _mentionsIdentifier = (src, name, from) => {
759
+ let i = src.indexOf(name, from)
760
+ while (i !== -1) {
761
+ const end = i + name.length
762
+ if ((i === 0 || !_isIdentCharCode(src.charCodeAt(i - 1))) &&
763
+ (end >= src.length || !_isIdentCharCode(src.charCodeAt(end)))) return true
764
+ i = src.indexOf(name, end)
765
+ }
766
+ return false
767
+ }
768
+
769
+ const _lastNonSpaceCharCode = (s) => {
770
+ let i = s.length - 1
771
+ while (i >= 0 && s.charCodeAt(i) <= 32) i--
772
+ return i < 0 ? -1 : s.charCodeAt(i)
773
+ }
774
+
775
+ // Classify one source string for lazy revival: a fresh state object, or null
776
+ // when the eager path must revive it (see the header above for each case).
777
+ const lazyStateFor = (src) => {
778
+ let s = src
779
+ let start = 0
780
+ while (start < s.length && s.charCodeAt(start) <= 32) start++
781
+ if (start) s = s.slice(start)
782
+
783
+ let m = RE_LAZY_FUNCTION_HEAD.exec(s)
784
+ if (m) {
785
+ if (m[2]) return null // generator
786
+ if (_lastNonSpaceCharCode(s) !== 125) return null // must end with its body's `}`
787
+ const name = m[3] || ''
788
+ if (name && _mentionsIdentifier(s, name, m[0].indexOf('('))) return null // self-reference (params or body)
789
+ if (s.indexOf('arguments.callee') !== -1) return null
790
+ return { src, name, kind: m[1] ? LAZY_KIND_CALLABLE : LAZY_KIND_PLAIN, async: !!m[1], fn: undefined }
791
+ }
792
+ m = RE_LAZY_ARROW_IDENT_HEAD.exec(s) || RE_LAZY_ARROW_PARENS_HEAD.exec(s)
793
+ if (m) {
794
+ return { src, name: '', kind: LAZY_KIND_CALLABLE, async: !!m[1], fn: undefined }
795
+ }
796
+ m = RE_LAZY_METHOD_HEAD.exec(s)
797
+ if (m && !LAZY_NON_METHOD_NAMES.has(m[2]) && _lastNonSpaceCharCode(s) === 125) {
798
+ if (s.indexOf('arguments.callee') !== -1) return null
799
+ return { src, name: m[2], kind: LAZY_KIND_CALLABLE, async: !!m[1], fn: undefined }
800
+ }
801
+ return null
802
+ }
803
+
804
+ const _lazyLabel = (state) => state.index === -1
805
+ ? `"${state.key}"`
806
+ : `array index ${state.index} (prop "${state.key}")`
807
+
808
+ const compileLazy = (state) => {
809
+ const out = _destringifyFnString(state.src, _lazyLabel(state), state.opts, true)
810
+ let fn = null
811
+ if (typeof out === 'function') {
812
+ fn = out
813
+ } else {
814
+ // Not a function: the value eager revival leaves in the slot — the
815
+ // source string when it did not compile (`_destringifyFnString` has
816
+ // warned), or, unreachable for a head the regexes proved, whatever the
817
+ // expression evaluated to. The wrapper stands for it from now on.
818
+ state.value = out
819
+ if (typeof out !== 'string' && typeof console !== 'undefined' && console.warn) {
820
+ console.warn(
821
+ `[smbls] deepDestringifyFunctions: ${_lazyLabel(state)} did not evaluate to a function — ` +
822
+ 'the lazily revived function returns that value.\n' +
823
+ 'First 200 chars of source: ' + String(state.src).slice(0, 200)
824
+ )
825
+ }
826
+ }
827
+ state.fn = fn
828
+ state.opts = null // the eval handle is no longer needed
829
+ return fn
830
+ }
831
+
832
+ // Kept out of the wrappers' own text so `Function.prototype.toString.call`
833
+ // on a wrapper names no global at all (the workspace re-realm gate reads it).
834
+ const _constructLazy = (fn, args, newTarget) => Reflect.construct(fn, args, newTarget)
835
+
836
+ function lazyFunctionToString () {
837
+ const state = LAZY_FN_STATE.get(this)
838
+ return state ? state.src.trim() : Function.prototype.toString.call(this)
839
+ }
840
+
841
+ // Shared by every wrapper — one defineProperties call, no per-wrapper
842
+ // descriptor objects.
843
+ const LAZY_FN_DESCRIPTORS = {
844
+ length: {
845
+ get () {
846
+ const state = LAZY_FN_STATE.get(this)
847
+ if (!state) return 0
848
+ const fn = state.fn === undefined ? compileLazy(state) : state.fn
849
+ return fn ? fn.length : 0
850
+ },
851
+ configurable: true
852
+ },
853
+ name: {
854
+ get () {
855
+ const state = LAZY_FN_STATE.get(this)
856
+ return state ? state.name : ''
857
+ },
858
+ configurable: true
859
+ },
860
+ toString: { value: lazyFunctionToString, writable: true, configurable: true }
861
+ }
862
+
863
+ // An async source's wrapper inherits from %AsyncFunction.prototype% (review
864
+ // N1): `Object.prototype.toString` reports '[object AsyncFunction]',
865
+ // `.constructor` is AsyncFunction and `instanceof` holds — while the wrapper
866
+ // itself stays a plain synchronous call that hands back the inner promise
867
+ // (an `async` wrapper would add microtask ticks to every call).
868
+ const ASYNC_FUNCTION_PROTOTYPE = Object.getPrototypeOf(async function () {})
869
+
870
+ const makeLazyFunction = (state) => {
871
+ let wrapper
872
+ if (state.kind === LAZY_KIND_PLAIN) {
873
+ wrapper = function () {
874
+ const fn = state.fn === undefined ? compileLazy(state) : state.fn
875
+ if (fn === null) return state.value
876
+ return new.target
877
+ ? _constructLazy(fn, arguments, new.target)
878
+ : fn.apply(this, arguments)
879
+ }
880
+ } else {
881
+ // A method shorthand: receives `this`, has no `.prototype`, and throws
882
+ // on `new` — the same as the arrow / async / method it stands for.
883
+ wrapper = ({
884
+ lazy () {
885
+ const fn = state.fn === undefined ? compileLazy(state) : state.fn
886
+ if (fn === null) return state.value
887
+ return fn.apply(this, arguments)
888
+ }
889
+ }).lazy
890
+ }
891
+ LAZY_FN_STATE.set(wrapper, state)
892
+ Object.defineProperties(wrapper, LAZY_FN_DESCRIPTORS)
893
+ if (state.async) Object.setPrototypeOf(wrapper, ASYNC_FUNCTION_PROTOTYPE)
894
+ return wrapper
895
+ }
896
+
897
+ // Revive one function string lazily when its head allows, eagerly otherwise.
898
+ const _reviveLazily = (str, key, index, opts) => {
899
+ const state = lazyStateFor(str)
900
+ if (!state) {
901
+ return _destringifyFnString(
902
+ str,
903
+ index === -1 ? `"${key}"` : `array index ${index} (prop "${key}")`,
904
+ opts
905
+ )
906
+ }
907
+ state.key = key
908
+ state.index = index
909
+ state.opts = opts
910
+ return makeLazyFunction(state)
911
+ }
912
+
913
+ /**
914
+ * True for a function `deepDestringifyFunctions(…, { lazy: true })` revived
915
+ * lazily (compiled or not yet).
916
+ */
917
+ export const isLazyFunction = (fn) => typeof fn === 'function' && LAZY_FN_STATE.has(fn)
918
+
919
+ /**
920
+ * The source text of any function: the stored source of a lazily revived
921
+ * one (without compiling it), `Function.prototype.toString` for the rest.
922
+ * Use this instead of `Function.prototype.toString.call(fn)`, which reads a
923
+ * lazy wrapper's own text.
924
+ */
925
+ export const getFunctionSource = (fn) => {
926
+ const state = LAZY_FN_STATE.get(fn)
927
+ return state ? state.src.trim() : Function.prototype.toString.call(fn)
928
+ }
929
+
930
+ /**
931
+ * True when `fn` is a lazily revived function whose source does not compile
932
+ * — it stands for the string eager revival would have left, so a caller that
933
+ * treated that string as "not callable" (`el.call`, utils `call`) must treat
934
+ * `fn` the same. Compiles `fn` if it has not run yet (the caller was about to
935
+ * call it). False for every other value.
936
+ */
937
+ export const isFailedRevival = (fn) => {
938
+ const state = typeof fn === 'function' ? LAZY_FN_STATE.get(fn) : undefined
939
+ if (!state) return false
940
+ return (state.fn === undefined ? compileLazy(state) : state.fn) === null
941
+ }
942
+
943
+ // The CODE buckets of a project context — `{ lazy: 'context' }` revives
944
+ // lazily only under these top-level keys (see LAZY REVIVAL above).
945
+ const LAZY_CONTEXT_CODE_KEYS = new Set([
946
+ 'components', 'pages', 'functions', 'methods', 'snippets', 'app', 'globalScope'
947
+ ])
948
+
949
+ const DEFAULT_DESTRINGIFY_OPTS = { window: { eval: __globalEval } }
950
+
605
951
  export const deepDestringifyFunctions = (
606
952
  obj,
607
953
  destringified = {},
608
- opts = { window: { eval: __globalEval } }
954
+ opts = DEFAULT_DESTRINGIFY_OPTS
609
955
  ) => {
610
956
  if (!obj || typeof obj !== 'object') return destringified
957
+ // `opts.window.eval` is the one field every runtime since 2026-04 reads,
958
+ // so a page script can pass `{ lazy: true, window }` to ANY runtime: an
959
+ // older one ignores `lazy` and evals eagerly through `window.eval` (an
960
+ // indirect, global-scope eval — the same as `__globalEval`). An options
961
+ // object without a usable `window.eval` falls back to the global eval
962
+ // instead of throwing on the first function string.
963
+ if (!opts || !opts.window || typeof opts.window.eval !== 'function') {
964
+ opts = { ...opts, window: { eval: __globalEval } }
965
+ }
966
+ // `lazy: true` — lazy everywhere. `lazy: 'context'` — `obj` is a project
967
+ // context: lazy only below its code buckets, eager for everything else.
968
+ const lazyAll = opts.lazy === true
969
+ const lazyContext = opts.lazy === 'context'
970
+ const lazyBelow = (src, prop, lazyHere) => lazyAll ||
971
+ (lazyContext && (src === obj ? LAZY_CONTEXT_CODE_KEYS.has(prop) : lazyHere))
611
972
 
612
973
  // Iterative walk with explicit stack so deeply-nested project data
613
974
  // (a frank-readback of a complex DOMQL tree, for instance) doesn't
@@ -615,25 +976,30 @@ export const deepDestringifyFunctions = (
615
976
  // form did. Stack frame: [src, dest] where dest is the container
616
977
  // results land in. Array items handled in-place; nested objects /
617
978
  // arrays get a fresh child container pushed onto the stack.
618
- const stack = [[obj, destringified]]
979
+ const stack = [[obj, destringified, lazyAll]]
619
980
  while (stack.length) {
620
- const [src, dest] = stack.pop()
981
+ const [src, dest, lazyHere] = stack.pop()
621
982
  for (const prop in src) {
622
983
  if (!Object.prototype.hasOwnProperty.call(src, prop)) continue
623
984
  const objProp = src[prop]
624
985
  if (isString(objProp)) {
625
986
  if (hasFunction(objProp)) {
626
- dest[prop] = _destringifyFnString(objProp, `"${prop}"`, opts)
987
+ dest[prop] = lazyHere
988
+ ? _reviveLazily(objProp, prop, -1, opts)
989
+ : _destringifyFnString(objProp, `"${prop}"`, opts)
627
990
  } else {
628
991
  dest[prop] = objProp
629
992
  }
630
993
  } else if (isArray(objProp)) {
631
994
  const arr = (dest[prop] = [])
995
+ const lazyItems = lazyBelow(src, prop, lazyHere)
632
996
  for (let i = 0; i < objProp.length; i++) {
633
997
  const arrProp = objProp[i]
634
998
  if (isString(arrProp)) {
635
999
  arr.push(hasFunction(arrProp)
636
- ? _destringifyFnString(arrProp, `array index ${i} (prop "${prop}")`, opts)
1000
+ ? (lazyItems
1001
+ ? _reviveLazily(arrProp, prop, i, opts)
1002
+ : _destringifyFnString(arrProp, `array index ${i} (prop "${prop}")`, opts))
637
1003
  : arrProp)
638
1004
  } else if (isObject(arrProp)) {
639
1005
  const tagged = _rehydrateTagged(arrProp)
@@ -642,7 +1008,7 @@ export const deepDestringifyFunctions = (
642
1008
  } else {
643
1009
  const child = {}
644
1010
  arr.push(child)
645
- stack.push([arrProp, child])
1011
+ stack.push([arrProp, child, lazyItems])
646
1012
  }
647
1013
  } else {
648
1014
  arr.push(arrProp)
@@ -665,7 +1031,7 @@ export const deepDestringifyFunctions = (
665
1031
  const child = (dest[prop] && typeof dest[prop] === 'object' && !isArray(dest[prop]))
666
1032
  ? dest[prop]
667
1033
  : (dest[prop] = {})
668
- stack.push([objProp, child])
1034
+ stack.push([objProp, child, lazyBelow(src, prop, lazyHere)])
669
1035
  } else {
670
1036
  dest[prop] = objProp
671
1037
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/utils",
3
- "version": "3.14.773",
3
+ "version": "3.14.775",
4
4
  "license": "CC-BY-NC-4.0",
5
5
  "type": "module",
6
6
  "module": "./dist/esm/index.js",