@dinoreic/fez 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -149,7 +149,7 @@ This example showcases:
149
149
 
150
150
  ### Developer Experience
151
151
 
152
- * **Built-in Utilities** - Helpful methods like `formData()`, `setInterval()` (auto-cleanup), `onResize()`, and `nextTick()`
152
+ * **Built-in Utilities** - Helpful methods like `formData()`, `setInterval()` (auto-cleanup), `onWindowResize()`, and `nextTick()`
153
153
  * **Two-Way Data Binding** - Use `fez-bind` directive for automatic form synchronization
154
154
  * **Advanced Slot System** - Full `<slot />` support with event listener preservation
155
155
  * **Publish/Subscribe** - Built-in pub/sub system for component communication
@@ -159,8 +159,8 @@ This example showcases:
159
159
 
160
160
  ### Performance & Integration
161
161
 
162
- * **Fast/Slow Render Modes** - Optimize initial render with `FAST = true` to prevent flickering
163
- * **Request Animation Frame** - Smart RAF integration for smooth updates
162
+ * **Optimized Rendering** - Batched microtask rendering for flicker-free component initialization
163
+ * **Smart DOM Updates** - Efficient DOM manipulation with minimal reflows
164
164
  * **Built-in Fetch with Caching** - `Fez.fetch()` includes automatic response caching and JSON/FormData handling
165
165
  * **Global Component Access** - Register components globally with `GLOBAL = 'ComponentName'` for easy access
166
166
  * **Rich Lifecycle Hooks** - `init`, `onMount`, `beforeRender`, `afterRender`, `onDestroy`, `onPropsChange`, `onStateChange`, `onGlobalStateChange`
@@ -195,14 +195,6 @@ Fez('foo-bar', class {
195
195
  // set element style, set as property or method
196
196
  CSS = `scss string... `
197
197
 
198
- // unless node has no innerHTML on initialization, bind will be set to slow (fastBind = false)
199
- // if you are using components that to not use innerHTML and slots, enable fast bind (fastBind = true)
200
- // component will be rendered as parsed, and not on next tick (reduces flickering)
201
- // <fez-icon name="gear" />
202
- FAST = true
203
- FAST(node) { ... }
204
- // alternative: static fastBind() { return true }
205
-
206
198
  // define static HTML. calling `this.render()` (no arguments) will refresh current node.
207
199
  // if you pair it with `reactiveStore()`, to auto update on props change, you will have Svelte or Vue style reactive behaviour.
208
200
  HTML = `...`
@@ -293,11 +285,11 @@ Fez('foo-bar', class {
293
285
 
294
286
  // window resize event with cleanup (shorthand for this.on('resize', func, delay))
295
287
  // runs immediately on init and then throttled
296
- this.onResize(func, delay)
288
+ this.onWindowResize(func, delay)
297
289
 
298
290
  // window scroll event with cleanup (shorthand for this.on('scroll', func, delay))
299
291
  // runs immediately on init and then throttled
300
- this.onScroll(func, delay)
292
+ this.onWindowScroll(func, delay)
301
293
 
302
294
  // requestAnimationFrame wrapper with deduplication
303
295
  this.nextTick(func, name)
@@ -351,7 +343,7 @@ Fez.css(text)
351
343
  // get generated css class name without global attachment
352
344
  Fez.cssClass(text)
353
345
 
354
- // display information about fast/slow bind components in console
346
+ // display information about registered components in console
355
347
  Fez.info()
356
348
 
357
349
  // low-level DOM morphing function
@@ -366,6 +358,12 @@ Fez.tag(tag, opts, html)
366
358
  // execute function until it returns true
367
359
  Fez.untilTrue(func, pingRate)
368
360
 
361
+ // resolve and execute a function from string or function reference
362
+ // useful for event handlers that can be either functions or strings
363
+ // Fez.resolveFunction('alert("hi")', element) - creates function and calls with element as this
364
+ // Fez.resolveFunction(myFunc, element) - calls myFunc with element as this
365
+ Fez.resolveFunction(pointer, context)
366
+
369
367
  // add scripts/styles to document head
370
368
  // Load JavaScript from URL: Fez.head({ js: 'path/to/script.js' })
371
369
  // Load JavaScript with attributes: Fez.head({ js: 'path/to/script.js', type: 'module', async: true })
@@ -395,9 +393,6 @@ Fez.head(config, callback)
395
393
  <!-- pass JSON template via data-json-template -->
396
394
  <script type="text/template">{...}</script>
397
395
  <foo-bar data-json-template="true"></foo-bar>
398
-
399
- <!-- override slow bind behavior -->
400
- <foo-bar fez-fast="true"></foo-bar>
401
396
  ```
402
397
 
403
398
  ## Component structure
package/dist/fez.js CHANGED
@@ -1,28 +1,28 @@
1
- (()=>{var ve=Object.defineProperty;var Se=(t,e)=>()=>(t&&(e=t(t=0)),e);var Ee=(t,e)=>{for(var r in e)ve(t,r,{get:e[r],enumerable:!0})};var ie={};Ee(ie,{loadDefaults:()=>ne});var ne,oe=Se(()=>{ne=()=>{Fez("fez-component",class{FAST=!0;init(t){let e=document.createElement(t.name);for(e.props=t.props||t["data-props"]||t;this.root.firstChild;)this.root.parentNode.insertBefore(this.root.lastChild,e.nextSibling);this.root.innerHTML="",this.root.appendChild(e)}}),Fez("fez-include",class{FAST=!0;init(t){Fez.fetch(t.src,e=>{let r=Fez.domRoot(e);Fez.head(r),this.root.innerHTML=r.innerHTML})}}),Fez("fez-inline",class{init(t){let e=this.root.innerHTML;if(this.root.innerHTML.includes("<")){let s=`inline-${Fez.fnv1(this.root.outerHTML)}`;Fez(s,class{FAST=!0;HTML=e;init(){Object.assign(this.state,t.state||{})}});let n=document.createElement(s);this.root.after(this.root.lastChild,n),this.root.remove()}}})};typeof Fez<"u"&&Fez&&ne()});function D(t,e={},r){if(typeof e=="string"&&([e,r]=[r,e],e||={}),e instanceof Node&&(r=e,e={}),Array.isArray(t)&&(r=t,t="div"),(typeof e!="object"||Array.isArray(e))&&(r=e,e={}),t.includes(".")){let n=t.split(".");t=n.shift()||"div";let o=n.join(" ");e.class?e.class+=` ${o}`:e.class=o}let s=document.createElement(t);for(let[n,o]of Object.entries(e))if(typeof o=="function")s[n]=o.bind(this);else{let i=String(o).replaceAll("fez.",this.fezHtmlRoot);s.setAttribute(n,i)}if(r)if(Array.isArray(r))for(let n of r)s.appendChild(n);else r instanceof Node?s.appendChild(r):s.innerHTML=String(r);return s}function Ae(t,e){if(t=t.replace(/^#?raw/,"@html").replace(/^#?html/,"@html"),t.startsWith("#if")||t.startsWith("if"))return e.push(!1),t=t.replace(/^#?if/,""),`\${ ${t} ? \``;if(t.startsWith("#unless")||t.startsWith("unless"))return e.push(!1),t=t.replace(/^#?unless/,""),`\${ !(${t}) ? \``;if(t=="/block")return"`) && ''}";if(t.startsWith("#for")||t.startsWith("for")){t=t.replace(/^#?for/,"");let r=t.split(" in ",2);return"${"+r[1]+".map(("+r[0]+")=>`"}else if(t.startsWith("#each")||t.startsWith("each")){t=t.replace(/^#?each/,"");let r=t.split(" as ",2);return"${"+r[0]+".map(("+r[1]+")=>`"}else{if(t==":else"||t=="else")return e[e.length-1]=!0,"` : `";if(t=="/if"||t=="/unless")return e.pop()?"`}":"` : ``}";if(t=="/for"||t=="/each")return'`).join("")}';{let r="@html ";return t.startsWith("json ")&&(t=t.replace("json ","@html '<pre class=json>'+JSON.stringify("),t+=", null, 2) + '</pre>'"),t.startsWith(r)?t=t.replace(r,""):t=`Fez.htmlEscape(${t})`,"${"+t+"}"}}}function j(t,e={}){let r=[];t=t.replaceAll("[[","{{").replaceAll("]]","}}"),t=t.replace(/(\w+)=\{\{\s*(.*?)\s*\}\}([\s>])/g,(o,i,a,u)=>`${i}="{{ ${a} }}"${u}`);let s={};t=t.replace(/\{\{block\s+(\w+)\s*\}\}([^§]+)\{\{\/block\}\}/g,(o,i,a)=>(s[i]=a,"")),t=t.replace(/\{\{block:([\w\-]+)\s*\}\}/g,(o,i)=>s[i]||`block:${i}?`),t=t.replace(/:(\w+)="([\w\.\[\]]+)"/,(o,i,a)=>`:${i}=Fez.store.delete({{ Fez.store.set(${a}) }})`);let n=t.replace(/{{(.*?)}}/g,(o,i)=>(i=i.replaceAll("&#x60;","`"),i=i.replaceAll("&lt;","<").replaceAll("&gt;",">").replaceAll("&amp;","&"),Ae(i,r)));n=n.replace(/<!\-\-.*?\-\->/g,"").replace(/>\s+</g,"><"),n="`"+n.trim()+"`";try{let o=`const fez = this;
1
+ (()=>{var Se=Object.defineProperty;var Ee=(r,e)=>()=>(r&&(e=r(r=0)),e);var Ae=(r,e)=>{for(var t in e)Se(r,t,{get:e[t],enumerable:!0})};var ie={};Ae(ie,{loadDefaults:()=>oe});var oe,le=Ee(()=>{oe=()=>{Fez("fez-component",class{init(r){let e=document.createElement(r.name);for(e.props=r.props||r["data-props"]||r;this.root.firstChild;)this.root.parentNode.insertBefore(this.root.lastChild,e.nextSibling);this.root.innerHTML="",this.root.appendChild(e)}}),Fez("fez-include",class{init(r){Fez.fetch(r.src,e=>{let t=Fez.domRoot(e);Fez.head(t),this.root.innerHTML=t.innerHTML})}}),Fez("fez-inline",class{init(r){let e=this.root.innerHTML;if(this.root.innerHTML.includes("<")){let s=`inline-${Fez.fnv1(this.root.outerHTML)}`;Fez(s,class{HTML=e;init(){Object.assign(this.state,r.state||{})}});let n=document.createElement(s);this.root.after(this.root.lastChild,n),this.root.remove()}}})};typeof Fez<"u"&&Fez&&oe()});function k(r,e={},t){if(typeof e=="string"&&([e,t]=[t,e],e||={}),e instanceof Node&&(t=e,e={}),Array.isArray(r)&&(t=r,r="div"),(typeof e!="object"||Array.isArray(e))&&(t=e,e={}),r.includes(".")){let n=r.split(".");r=n.shift()||"div";let o=n.join(" ");e.class?e.class+=` ${o}`:e.class=o}let s=document.createElement(r);for(let[n,o]of Object.entries(e))if(typeof o=="function")s[n]=o.bind(this);else{let i=String(o).replaceAll("fez.",this.fezHtmlRoot);s.setAttribute(n,i)}if(t)if(Array.isArray(t))for(let n of t)s.appendChild(n);else t instanceof Node?s.appendChild(t):s.innerHTML=String(t);return s}function Ce(r,e){if(r=r.replace(/^#?raw/,"@html").replace(/^#?html/,"@html"),r.startsWith("#if")||r.startsWith("if"))return e.push(!1),r=r.replace(/^#?if/,""),`\${ ${r} ? \``;if(r.startsWith("#unless")||r.startsWith("unless"))return e.push(!1),r=r.replace(/^#?unless/,""),`\${ !(${r}) ? \``;if(r=="/block")return"`) && ''}";if(r.startsWith("#for")||r.startsWith("for")){r=r.replace(/^#?for/,"");let t=r.split(" in ",2);return"${"+t[1]+".map(("+t[0]+")=>`"}else if(r.startsWith("#each")||r.startsWith("each")){r=r.replace(/^#?each/,"");let t=r.split(" as ",2);return"${"+t[0]+".map(("+t[1]+")=>`"}else{if(r==":else"||r=="else")return e[e.length-1]=!0,"` : `";if(r=="/if"||r=="/unless")return e.pop()?"`}":"` : ``}";if(r=="/for"||r=="/each")return'`).join("")}';{let t="@html ";return r.startsWith("json ")&&(r=r.replace("json ","@html '<pre class=json>'+JSON.stringify("),r+=", null, 2) + '</pre>'"),r.startsWith(t)?r=r.replace(t,""):r=`Fez.htmlEscape(${r})`,"${"+r+"}"}}}function H(r,e={}){let t=[];r=r.replaceAll("[[","{{").replaceAll("]]","}}"),r=r.replace(/(\w+)=\{\{\s*(.*?)\s*\}\}([\s>])/g,(o,i,u,f)=>`${i}="{{ ${u} }}"${f}`);let s={};r=r.replace(/\{\{block\s+(\w+)\s*\}\}([^§]+)\{\{\/block\}\}/g,(o,i,u)=>(s[i]=u,"")),r=r.replace(/\{\{block:([\w\-]+)\s*\}\}/g,(o,i)=>s[i]||`block:${i}?`),r=r.replace(/:(\w+)="([\w\.\[\]]+)"/,(o,i,u)=>`:${i}=Fez.store.delete({{ Fez.store.set(${u}) }})`);let n=r.replace(/{{(.*?)}}/g,(o,i)=>(i=i.replaceAll("&#x60;","`"),i=i.replaceAll("&lt;","<").replaceAll("&gt;",">").replaceAll("&amp;","&"),Ce(i,t)));n=n.replace(/<!\-\-.*?\-\->/g,"").replace(/>\s+</g,"><"),n="`"+n.trim()+"`";try{let o=`const fez = this;
2
2
  with (this) {
3
3
  return ${n}
4
4
  }
5
- `,i=new Function(o);return u=>{try{return i.bind(u)()}catch(b){b.message=`FEZ template runtime error: ${b.message}
5
+ `,i=new Function(o);return f=>{try{return i.bind(f)()}catch(b){b.message=`FEZ template runtime error: ${b.message}
6
6
 
7
7
  Template source: ${n}`,console.error(b)}}}catch(o){return o.message=`FEZ template compile error: ${o.message}Template source:
8
- ${n}`,console.error(o),()=>Fez.error("Template Compile Error",!0)}}var L=class{static getProps(e,r){let s={};if(e.props)return e.props;for(let n of e.attributes)s[n.name]=n.value;for(let[n,o]of Object.entries(s))if([":"].includes(n[0])){delete s[n];try{let i=new Function(`return (${o})`).bind(r)();s[n.replace(/[\:_]/,"")]=i}catch(i){console.error(`Fez: Error evaluating attribute ${n}="${o}" for ${e.tagName}: ${i.message}`)}}if(s["data-props"]){let n=s["data-props"];if(typeof n=="object")return n;n[0]!="{"&&(n=decodeURIComponent(n));try{s=JSON.parse(n)}catch(o){console.error(`Fez: Invalid JSON in data-props for ${e.tagName}: ${o.message}`)}}else if(s["data-json-template"]){let n=r.previousSibling?.textContent;if(n)try{s=JSON.parse(n),r.previousSibling.remove()}catch(o){console.error(`Fez: Invalid JSON in template for ${e.tagName}: ${o.message}`)}}return s}static formData(e){let r=e.closest("form")||e.querySelector("form");if(!r)return Fez.log("No form found for formData()"),{};let s=new FormData(r),n={};return s.forEach((o,i)=>{n[i]=o}),n}static fastBind(){return!1}static nodeName="div";constructor(){}n=D;get fezHtmlRoot(){return`Fez(${this.UID}).`}get isConnected(){return this.root?.isConnected?!0:(this.fezRemoveSelf(),!1)}fezRemoveSelf(){this._setIntervalCache||={},Object.keys(this._setIntervalCache).forEach(e=>{clearInterval(this._setIntervalCache[e])}),this._eventHandlers&&(Object.entries(this._eventHandlers).forEach(([e,r])=>{window.removeEventListener(e,r)}),this._eventHandlers={}),this._timeouts&&(Object.values(this._timeouts).forEach(e=>{clearTimeout(e)}),this._timeouts={}),this.onDestroy(),this.onDestroy=()=>{},this.root&&(this.root.fez=void 0),this.root=void 0}prop(e){let r=this.oldRoot[e]||this.props[e];return typeof r=="function"&&(r=r.bind(this.root)),r}copy(){for(let e of Array.from(arguments)){let r=this.props[e];if(r!==void 0){if(e=="class"){let s=this.root.getAttribute(e,r);s&&(r=[s,r].join(" "))}(e=="style"||!this.root[e])&&(typeof r=="string"?this.root.setAttribute(e,r):this.root[e]=r)}}}on(e,r,s=200){this._eventHandlers=this._eventHandlers||{},this._timeouts=this._timeouts||{},this._eventHandlers[e]&&window.removeEventListener(e,this._eventHandlers[e]),this._timeouts[e]&&clearTimeout(this._timeouts[e]);let n=0,o=()=>this.isConnected?(r.call(this),!0):(this._eventHandlers[e]&&(window.removeEventListener(e,this._eventHandlers[e]),delete this._eventHandlers[e]),this._timeouts[e]&&(clearTimeout(this._timeouts[e]),delete this._timeouts[e]),!1),i=()=>{let a=Date.now();if(a-n>=s)if(o())n=a;else return;this._timeouts[e]&&clearTimeout(this._timeouts[e]),this._timeouts[e]=setTimeout(()=>{a>n&&o()&&(n=Date.now()),delete this._timeouts[e]},s)};this._eventHandlers[e]=i,window.addEventListener(e,i)}onResize(e,r){this.on("resize",e,r),e()}onScroll(e,r){this.on("scroll",e,r),e()}slot(e,r){r||=document.createElement("template");let s=r.nodeName=="SLOT";for(;e.firstChild;)s?r.parentNode.insertBefore(e.lastChild,r.nextSibling):r.appendChild(e.firstChild);return s?r.parentNode.removeChild(r):e.innerHTML="",r}setStyle(e,r){this.root.style.setProperty(e,r)}connect(){}onMount(){}beforeRender(){}afterRender(){}onDestroy(){}onStateChange(){}onGlobalStateChange(){}publish(e,...r){let s=o=>{if(Fez._subs&&Fez._subs[e]){let i=Fez._subs[e].find(([a])=>a===o);if(i)return i[1].bind(o)(...r),!0}return!1};if(s(this))return!0;let n=this.root.parentElement;for(;n;){if(n.fez&&s(n.fez))return!0;n=n.parentElement}return!1}fezBlocks={};parseHtml(e){let r=this.fezHtmlRoot.replaceAll('"',"&quot;");return e=e.replace(/([!'"\s;])fez\.(\w)/g,`$1${r}$2`).replace(/>\s+</g,"><"),e.trim()}nextTick(e,r){r?(this._nextTicks||={},this._nextTicks[r]||=window.requestAnimationFrame(()=>{e.bind(this)(),this._nextTicks[r]=null},r)):window.requestAnimationFrame(e.bind(this))}render(e){if(e||=this?.class?.fezHtmlFunc,!e||!this.root)return;this.beforeRender();let r=document.createElement(this.class.nodeName||"div"),s;Array.isArray(e)?e[0]instanceof Node?e.forEach(n=>r.appendChild(n)):s=e.join(""):typeof e=="string"?s=j(e)(this):typeof e=="function"&&(s=e(this)),s&&(s=s.replace(/\s\w+="undefined"/g,""),r.innerHTML=this.parseHtml(s)),r.querySelectorAll("[fez-keep]").forEach(n=>{let o=n.getAttribute("fez-keep"),i=this.root.querySelector(`[fez-keep="${o}"]`);i?n.parentNode.replaceChild(i,n):o==="default-slot"&&Array.from(this.root.childNodes).forEach(a=>n.appendChild(a))}),Fez.morphdom(this.root,r),this.renderFezPostProcess(),this.afterRender()}renderFezPostProcess(){let e=(r,s)=>{this.root.querySelectorAll(`*[${r}]`).forEach(n=>{let o=n.getAttribute(r);n.removeAttribute(r),o&&s.bind(this)(o,n)})};e("fez-this",(r,s)=>{new Function("n",`this.${r} = n`).bind(this)(s)}),e("fez-use",(r,s)=>{let n=this[r];typeof n=="function"?n(s):console.error(`Fez error: "${r}" is not a function in ${this.fezName}`)}),e("fez-class",(r,s)=>{let n=r.split(/\s+/),o=n.pop();n.forEach(i=>s.classList.add(i)),o&&setTimeout(()=>{s.classList.add(o)},300)}),e("fez-bind",(r,s)=>{if(["INPUT","SELECT","TEXTAREA"].includes(s.nodeName)){let n=new Function(`return this.${r}`).bind(this)(),o=s.type.toLowerCase()=="checkbox",i=["SELECT"].includes(s.nodeName)||o?"onchange":"onkeyup";s.setAttribute(i,`${this.fezHtmlRoot}${r} = this.${o?"checked":"value"}`),this.val(s,n)}else console.error(`Cant fez-bind="${r}" to ${s.nodeName} (needs INPUT, SELECT or TEXTAREA. Want to use fez-this?).`)}),this.root.querySelectorAll("*[disabled]").forEach(r=>{let s=r.getAttribute("disabled");["false"].includes(s)?r.removeAttribute("disabled"):r.setAttribute("disabled","true")})}refresh(e){if(alert("NEEDS FIX and remove htmlTemplate"),e){let s=Fez.domRoot(this.class.htmlTemplate).querySelector(e).innerHTML;this.render(e,s)}else this.render()}setInterval(e,r,s){return typeof e=="number"&&([r,e]=[e,r]),s||=Fez.fnv1(String(e)),this._setIntervalCache||={},clearInterval(this._setIntervalCache[s]),this._setIntervalCache[s]=setInterval(()=>{this.isConnected&&e()},r),this._setIntervalCache[s]}find(e){return typeof e=="string"?this.root.querySelector(e):e}val(e,r){let s=this.find(e);if(s)if(["INPUT","TEXTAREA","SELECT"].includes(s.nodeName))if(typeof r<"u")s.type=="checkbox"?s.checked=!!r:s.value=r;else return s.value;else if(typeof r<"u")s.innerHTML=r;else return s.innerHTML}formData(e){return this.class.formData(e||this.root)}attr(e,r){return typeof r>"u"?this.root.getAttribute(e):(this.root.setAttribute(e,r),r)}childNodes(e){let r=Array.from(this.root.children);if(e){let s=document.createElement("div");s.style.display="none",document.body.appendChild(s),r.forEach(n=>s.appendChild(n)),r=Array.from(s.children).map(e),document.body.removeChild(s)}return r}subscribe(e,r){Fez._subs||={},Fez._subs[e]||=[],Fez._subs[e]=Fez._subs[e].filter(s=>s[0].isConnected),Fez._subs[e].push([this,r])}rootId(){return this.root.id||=`fez_${this.UID}`,this.root.id}fezRegister(){this.css&&(this.css=Fez.globalCss(this.css,{name:this.fezName,wrap:!0})),this.class.css&&(this.class.css=Fez.globalCss(this.class.css,{name:this.fezName})),this.state||=this.reactiveStore(),this.globalState=Fez.state.createProxy(this),this.fezRegisterBindMethods()}fezRegisterBindMethods(){Object.getOwnPropertyNames(Object.getPrototypeOf(this)).filter(r=>r!=="constructor"&&typeof this[r]=="function").forEach(r=>this[r]=this[r].bind(this))}fezHide(){let e=this.root,r=this.childNodes(),s=this.root.parentNode;return r.reverse().forEach(n=>s.insertBefore(n,e.nextSibling)),this.root.remove(),this.root=s,r}reactiveStore(e,r){e||={},r||=(n,o,i,a)=>{this.onStateChange(o,i,a),this.nextTick(this.render,"render")},r.bind(this);function s(n,o){return typeof n!="object"||n===null?n:new Proxy(n,{set(i,a,u,b){let g=Reflect.get(i,a,b);if(g!==u){typeof u=="object"&&u!==null&&(u=s(u,o));let S=Reflect.set(i,a,u,b);return o(i,a,u,g),S}return!0},get(i,a,u){let b=Reflect.get(i,a,u);return typeof b=="object"&&b!==null?s(b,o):b}})}return s(e,r)}};var Te={data:""},X=t=>typeof window=="object"?((t?t.querySelector("#_goober"):window._goober)||Object.assign((t||document.head).appendChild(document.createElement("style")),{innerHTML:" ",id:"_goober"})).firstChild:t||Te,Fe=t=>{let e=X(t),r=e.data;return e.data="",r},$e=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,we=/\/\*[^]*?\*\/| +/g,K=/\n+/g,F=(t,e)=>{let r="",s="",n="";for(let o in t){let i=t[o];o[0]=="@"?o[1]=="i"?r=o+" "+i+";":s+=o[1]=="f"?F(i,o):o+"{"+F(i,o[1]=="k"?"":e)+"}":typeof i=="object"?s+=F(i,e?e.replace(/([^,])+/g,a=>o.replace(/(^:.*)|([^,])+/g,u=>/&/.test(u)?u.replace(/&/g,a):a?a+" "+u:u)):o):i!=null&&(o=/^--/.test(o)?o:o.replace(/[A-Z]/g,"-$&").toLowerCase(),n+=F.p?F.p(o,i):o+":"+i+";")}return r+(e&&n?e+"{"+n+"}":n)+s},T={},Z=t=>{if(typeof t=="object"){let e="";for(let r in t)e+=r+Z(t[r]);return e}return t},Ce=(t,e,r,s,n)=>{let o=Z(t),i=T[o]||(T[o]=(u=>{let b=0,g=11;for(;b<u.length;)g=101*g+u.charCodeAt(b++)>>>0;return"go"+g})(o));if(!T[i]){let u=o!==t?t:(b=>{let g,S,C=[{}];for(;g=$e.exec(b.replace(we,""));)g[4]?C.shift():g[3]?(S=g[3].replace(K," ").trim(),C.unshift(C[0][S]=C[0][S]||{})):C[0][g[1]]=g[2].replace(K," ").trim();return C[0]})(t);T[i]=F(n?{["@keyframes "+i]:u}:u,r?"":"."+i)}let a=r&&T.g?T.g:null;return r&&(T.g=T[i]),((u,b,g,S)=>{S?b.data=b.data.replace(S,u):b.data.indexOf(u)===-1&&(b.data=g?u+b.data:b.data+u)})(T[i],e,s,a),i},Me=(t,e,r)=>t.reduce((s,n,o)=>{let i=e[o];if(i&&i.call){let a=i(r),u=a&&a.props&&a.props.className||/^go/.test(a)&&a;i=u?"."+u:a&&typeof a=="object"?a.props?"":F(a,""):a===!1?"":a}return s+n+(i??"")},"");function R(t){let e=this||{},r=t.call?t(e.p):t;return Ce(r.unshift?r.raw?Me(r,[].slice.call(arguments,1),e.p):r.reduce((s,n)=>Object.assign(s,n&&n.call?n(e.p):n),{}):r,X(e.target),e.g,e.o,e.k)}var Y,B,k,_e=R.bind({g:1}),Le=R.bind({k:1});function He(t,e,r,s){F.p=e,Y=t,B=r,k=s}function Oe(t,e){let r=this||{};return function(){let s=arguments;function n(o,i){let a=Object.assign({},o),u=a.className||n.className;r.p=Object.assign({theme:B&&B()},a),r.o=/ *go\d+/.test(u),a.className=R.apply(r,s)+(u?" "+u:""),e&&(a.ref=i);let b=t;return t[0]&&(b=a.as||t,delete a.as),k&&b[0]&&k(a),Y(b,a)}return e?e(n):n}}var Q={css:R,extractCss:Fe,glob:_e,keyframes:Le,setup:He,styled:Oe};var x=function(){"use strict";let t=new Set,e={morphStyle:"outerHTML",callbacks:{beforeNodeAdded:A,afterNodeAdded:A,beforeNodeMorphed:A,afterNodeMorphed:A,beforeNodeRemoved:A,afterNodeRemoved:A,beforeAttributeUpdated:A},head:{style:"merge",shouldPreserve:function(l){return l.getAttribute("im-preserve")==="true"},shouldReAppend:function(l){return l.getAttribute("im-re-append")==="true"},shouldRemove:A,afterHeadMorphed:A}};function r(l,c,f={}){l instanceof Document&&(l=l.documentElement),typeof c=="string"&&(c=ue(c));let d=de(c),h=ce(l,d,f);return s(l,d,h)}function s(l,c,f){if(f.head.block){let d=l.querySelector("head"),h=c.querySelector("head");if(d&&h){let p=S(h,d,f);Promise.all(p).then(function(){s(l,c,Object.assign(f,{head:{block:!1,ignore:!0}}))});return}}if(f.morphStyle==="innerHTML")return i(c,l,f),l.children;if(f.morphStyle==="outerHTML"||f.morphStyle==null){let d=pe(c,l,f),h=d?.previousSibling,p=d?.nextSibling,y=o(l,d,f);return d?he(h,y,p):[]}else throw"Do not understand how to morph style "+f.morphStyle}function n(l,c){return c.ignoreActiveValue&&l===document.activeElement&&l!==document.body}function o(l,c,f){if(!(f.ignoreActive&&l===document.activeElement))return c==null?f.callbacks.beforeNodeRemoved(l)===!1?l:(l.remove(),f.callbacks.afterNodeRemoved(l),null):I(l,c)?(f.callbacks.beforeNodeMorphed(l,c)===!1||(l instanceof HTMLHeadElement&&f.head.ignore||(l instanceof HTMLHeadElement&&f.head.style!=="morph"?S(c,l,f):(u(c,l,f),n(l,f)||i(c,l,f))),f.callbacks.afterNodeMorphed(l,c)),l):f.callbacks.beforeNodeRemoved(l)===!1||f.callbacks.beforeNodeAdded(c)===!1?l:(l.parentElement.replaceChild(c,l),f.callbacks.afterNodeAdded(c),f.callbacks.afterNodeRemoved(l),c)}function i(l,c,f){let d=l.firstChild,h=c.firstChild,p;for(;d;){if(p=d,d=p.nextSibling,h==null){if(f.callbacks.beforeNodeAdded(p)===!1)return;c.appendChild(p),f.callbacks.afterNodeAdded(p),M(f,p);continue}if(W(p,h,f)){o(h,p,f),h=h.nextSibling,M(f,p);continue}let y=fe(l,c,p,h,f);if(y){h=V(h,y,f),o(y,p,f),M(f,p);continue}let z=ae(l,c,p,h,f);if(z){h=V(h,z,f),o(z,p,f),M(f,p);continue}if(f.callbacks.beforeNodeAdded(p)===!1)return;c.insertBefore(p,h),f.callbacks.afterNodeAdded(p),M(f,p)}for(;h!==null;){let y=h;h=h.nextSibling,G(y,f)}}function a(l,c,f,d){return l==="value"&&d.ignoreActiveValue&&c===document.activeElement?!0:d.callbacks.beforeAttributeUpdated(l,c,f)===!1}function u(l,c,f){let d=l.nodeType;if(d===1){let h=l.attributes,p=c.attributes;for(let y of h)if(!a(y.name,c,"update",f))try{c.getAttribute(y.name)!==y.value&&c.setAttribute(y.name,y.value)}catch(z){console.error("Error setting attribute:",{badNode:c,badAttribute:y,error:z.message})}for(let y=p.length-1;0<=y;y--){let z=p[y];a(z.name,c,"remove",f)||l.hasAttribute(z.name)||c.removeAttribute(z.name)}}(d===8||d===3)&&c.nodeValue!==l.nodeValue&&(c.nodeValue=l.nodeValue),n(c,f)||g(l,c,f)}function b(l,c,f,d){if(l[f]!==c[f]){let h=a(f,c,"update",d);h||(c[f]=l[f]),l[f]?h||c.setAttribute(f,l[f]):a(f,c,"remove",d)||c.removeAttribute(f)}}function g(l,c,f){if(l instanceof HTMLInputElement&&c instanceof HTMLInputElement&&l.type!=="file"){let d=l.value,h=c.value;b(l,c,"checked",f),b(l,c,"disabled",f),l.hasAttribute("value")?d!==h&&(a("value",c,"update",f)||(c.setAttribute("value",d),c.value=d)):a("value",c,"remove",f)||(c.value="",c.removeAttribute("value"))}else if(l instanceof HTMLOptionElement)b(l,c,"selected",f);else if(l instanceof HTMLTextAreaElement&&c instanceof HTMLTextAreaElement){let d=l.value,h=c.value;if(a("value",c,"update",f))return;d!==h&&(c.value=d),c.firstChild&&c.firstChild.nodeValue!==d&&(c.firstChild.nodeValue=d)}}function S(l,c,f){let d=[],h=[],p=[],y=[],z=f.head.style,_=new Map;for(let v of l.children)_.set(v.outerHTML,v);for(let v of c.children){let E=_.has(v.outerHTML),O=f.head.shouldReAppend(v),P=f.head.shouldPreserve(v);E||P?O?h.push(v):(_.delete(v.outerHTML),p.push(v)):z==="append"?O&&(h.push(v),y.push(v)):f.head.shouldRemove(v)!==!1&&h.push(v)}y.push(..._.values());let J=[];for(let v of y){let E=document.createRange().createContextualFragment(v.outerHTML).firstChild;if(f.callbacks.beforeNodeAdded(E)!==!1){if(E.href||E.src){let O=null,P=new Promise(function(ze){O=ze});E.addEventListener("load",function(){O()}),J.push(P)}c.appendChild(E),f.callbacks.afterNodeAdded(E),d.push(E)}}for(let v of h)f.callbacks.beforeNodeRemoved(v)!==!1&&(c.removeChild(v),f.callbacks.afterNodeRemoved(v));return f.head.afterHeadMorphed(c,{added:d,kept:p,removed:h}),J}function C(){}function A(){}function le(l){let c={};return Object.assign(c,e),Object.assign(c,l),c.callbacks={},Object.assign(c.callbacks,e.callbacks),Object.assign(c.callbacks,l.callbacks),c.head={},Object.assign(c.head,e.head),Object.assign(c.head,l.head),c}function ce(l,c,f){return f=le(f),{target:l,newContent:c,config:f,morphStyle:f.morphStyle,ignoreActive:f.ignoreActive,ignoreActiveValue:f.ignoreActiveValue,idMap:ge(l,c),deadIds:new Set,callbacks:f.callbacks,head:f.head}}function W(l,c,f){return l==null||c==null?!1:l.nodeType===c.nodeType&&l.tagName===c.tagName?l.id!==""&&l.id===c.id?!0:H(f,l,c)>0:!1}function I(l,c){return l==null||c==null?!1:l.nodeType===c.nodeType&&l.tagName===c.tagName}function V(l,c,f){for(;l!==c;){let d=l;l=l.nextSibling,G(d,f)}return M(f,c),c.nextSibling}function fe(l,c,f,d,h){let p=H(h,f,c),y=null;if(p>0){let z=d,_=0;for(;z!=null;){if(W(f,z,h))return z;if(_+=H(h,z,l),_>p)return null;z=z.nextSibling}}return y}function ae(l,c,f,d,h){let p=d,y=f.nextSibling,z=0;for(;p!=null;){if(H(h,p,l)>0)return null;if(I(f,p))return p;if(I(y,p)&&(z++,y=y.nextSibling,z>=2))return null;p=p.nextSibling}return p}function ue(l){let c=new DOMParser,f=l.replace(/<svg(\s[^>]*>|>)([\s\S]*?)<\/svg>/gim,"");if(f.match(/<\/html>/)||f.match(/<\/head>/)||f.match(/<\/body>/)){let d=c.parseFromString(l,"text/html");if(f.match(/<\/html>/))return d.generatedByIdiomorph=!0,d;{let h=d.firstChild;return h?(h.generatedByIdiomorph=!0,h):null}}else{let h=c.parseFromString("<body><template>"+l+"</template></body>","text/html").body.querySelector("template").content;return h.generatedByIdiomorph=!0,h}}function de(l){if(l==null)return document.createElement("div");if(l.generatedByIdiomorph)return l;if(l instanceof Node){let c=document.createElement("div");return c.append(l),c}else{let c=document.createElement("div");for(let f of[...l])c.append(f);return c}}function he(l,c,f){let d=[],h=[];for(;l!=null;)d.push(l),l=l.previousSibling;for(;d.length>0;){let p=d.pop();h.push(p),c.parentElement.insertBefore(p,c)}for(h.push(c);f!=null;)d.push(f),h.push(f),f=f.nextSibling;for(;d.length>0;)c.parentElement.insertBefore(d.pop(),c.nextSibling);return h}function pe(l,c,f){let d;d=l.firstChild;let h=d,p=0;for(;d;){let y=me(d,c,f);y>p&&(h=d,p=y),d=d.nextSibling}return h}function me(l,c,f){return I(l,c)?.5+H(f,l,c):0}function G(l,c){M(c,l),c.callbacks.beforeNodeRemoved(l)!==!1&&(l.remove(),c.callbacks.afterNodeRemoved(l))}function be(l,c){return!l.deadIds.has(c)}function ye(l,c,f){return(l.idMap.get(f)||t).has(c)}function M(l,c){let f=l.idMap.get(c)||t;for(let d of f)l.deadIds.add(d)}function H(l,c,f){let d=l.idMap.get(c)||t,h=0;for(let p of d)be(l,p)&&ye(l,p,f)&&++h;return h}function U(l,c){let f=l.parentElement,d=l.querySelectorAll("[id]");for(let h of d){let p=h;for(;p!==f&&p!=null;){let y=c.get(p);y==null&&(y=new Set,c.set(p,y)),y.add(h.id),p=p.parentElement}}}function ge(l,c){let f=new Map;return U(l,f),U(c,f),f}return{morph:r,defaults:e}}();function te(t,e){let r=globalThis.window?.Fez||globalThis.Fez;if(t.includes("-")||console.error(`Fez: Invalid custom element name "${t}". Custom element names must contain a dash (e.g., 'my-element', 'ui-button').`),!e.fezHtmlRoot){let s=new e,n=class extends L{};if(Object.getOwnPropertyNames(s).concat(Object.getOwnPropertyNames(e.prototype)).filter(a=>!["constructor","prototype"].includes(a)).forEach(a=>n.prototype[a]=s[a]),r.fastBindInfo||={fast:[],slow:[]},s.GLOBAL&&(n.fezGlobal=s.GLOBAL),s.CSS&&(n.css=s.CSS),s.HTML&&(n.html=s.HTML),s.NAME&&(n.nodeName=s.NAME),s.FAST?(n.fastBind=s.FAST,r.fastBindInfo.fast.push(typeof s.FAST=="function"?`${t} (func)`:t)):r.fastBindInfo.slow.push(t),s.GLOBAL){let a=()=>document.body.appendChild(document.createElement(t));document.readyState==="loading"?document.addEventListener("DOMContentLoaded",a):a()}e=n;let i=`${t} compiled`;s.FAST&&(i+=" (fast bind)"),r.log(i)}e.html&&(e.html=je(e.html),e.html=e.html.replace(/<slot\s*\/>|<slot\s*>\s*<\/slot>/g,()=>{let s=e.SLOT||"div";return`<${s} class="fez-slot" fez-keep="default-slot"></${s}>`}),e.fezHtmlFunc=j(e.html)),e.css&&(e.css=r.globalCss(e.css,{name:t})),r.classes[t]=e,customElements.get(t)||customElements.define(t,class extends HTMLElement{connectedCallback(){Ie(this,e)?ee(t,this):window.requestAnimationFrame(()=>{this.parentNode&&ee(t,this)})}})}function je(t){let e=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]);return t.replace(/<([a-z-]+)\b([^>]*)\/>/g,(r,s,n)=>e.has(s)?r:`<${s}${n}></${s}>`)}function Ie(t,e){let r=t.getAttribute("fez-fast");var s=typeof e.fastBind=="function"?e.fastBind(t):e.fastBind;return r=="false"?!1:r||s}function ee(t,e){let r=Fez.classes[t],s=e.parentNode;if(e.isConnected){let n=typeof r.nodeName=="function"?r.nodeName(e):r.nodeName,o=document.createElement(n||"div");o.classList.add("fez"),o.classList.add(`fez-${t}`),s.replaceChild(o,e);let i=new r;if(i.UID=++Fez.instanceCount,Fez.instances.set(i.UID,i),i.oldRoot=e,i.fezName=t,i.root=o,i.props=r.getProps(e,o),i.class=r,i.slot(e,o),o.fez=i,r.fezGlobal&&r.fezGlobal!=!0&&(window[r.fezGlobal]=i),window.$&&(i.$root=$(o)),i.props.id&&o.setAttribute("id",i.props.id),i.fezRegister(),(i.init||i.created||i.connect).bind(i)(i.props),i.render(),i.firstRender=!0,i.onMount(i.props),i.onSubmit){let a=i.root.nodeName=="FORM"?i.root:i.find("form");a.onsubmit=u=>{u.preventDefault(),i.onSubmit(i.formData())}}if(i.onPropsChange){Re.observe(o,{attributes:!0});for(let[a,u]of Object.entries(i.props))i.onPropsChange(a,u)}}}var Re=new MutationObserver((t,e)=>{for(let r of t)if(r.type==="attributes"){let s=r.target.fez,n=r.attributeName,o=r.target.getAttribute(n);s&&(s.props[n]=o,s.onPropsChange(n,o))}});var Ne=t=>{let e={script:"",style:"",html:"",head:""},r=t.split(`
9
- `),s=[],n="";for(var o of r)o=o.trim(),o.startsWith("<script")&&!e.script&&n!="head"?n="script":o.startsWith("<head")&&!e.script?n="head":o.startsWith("<style")?n="style":o.endsWith("<\/script>")&&n==="script"&&!e.script?(e.script=s.join(`
8
+ ${n}`,console.error(o),()=>Fez.error("Template Compile Error",!0)}}var _=class{static getProps(e,t){let s={};if(e.props)return e.props;for(let n of e.attributes)s[n.name]=n.value;for(let[n,o]of Object.entries(s))if([":"].includes(n[0])){delete s[n];try{let i=new Function(`return (${o})`).bind(t)();s[n.replace(/[\:_]/,"")]=i}catch(i){console.error(`Fez: Error evaluating attribute ${n}="${o}" for ${e.tagName}: ${i.message}`)}}if(s["data-props"]){let n=s["data-props"];if(typeof n=="object")return n;n[0]!="{"&&(n=decodeURIComponent(n));try{s=JSON.parse(n)}catch(o){console.error(`Fez: Invalid JSON in data-props for ${e.tagName}: ${o.message}`)}}else if(s["data-json-template"]){let n=t.previousSibling?.textContent;if(n)try{s=JSON.parse(n),t.previousSibling.remove()}catch(o){console.error(`Fez: Invalid JSON in template for ${e.tagName}: ${o.message}`)}}return s}static formData(e){let t=e.closest("form")||e.querySelector("form");if(!t)return Fez.log("No form found for formData()"),{};let s=new FormData(t),n={};return s.forEach((o,i)=>{n[i]=o}),n}static nodeName="div";constructor(){}n=k;get fezHtmlRoot(){return`Fez(${this.UID}).`}get isConnected(){return this.root?.isConnected?!0:(this.fezOnDestroy(),!1)}prop(e){let t=this.oldRoot[e]||this.props[e];return typeof t=="function"&&(t=t.bind(this.root)),t}copy(){for(let e of Array.from(arguments)){let t=this.props[e];if(t!==void 0){if(e=="class"){let s=this.root.getAttribute(e,t);s&&(t=[s,t].join(" "))}(e=="style"||!this.root[e])&&(typeof t=="string"?this.root.setAttribute(e,t):this.root[e]=t)}}}fezOnDestroy(){this._onDestroyCallbacks&&(this._onDestroyCallbacks.forEach(e=>{try{e()}catch(t){console.error("Fez: Error in cleanup callback:",t)}}),this._onDestroyCallbacks=[]),this.onDestroy(),this.onDestroy=()=>{},this.root&&(this.root.fez=void 0),this.root=void 0}addOnDestroy(e){this._onDestroyCallbacks=this._onDestroyCallbacks||[],this._onDestroyCallbacks.push(e)}on(e,t,s=200){this._eventHandlers=this._eventHandlers||{},this._eventHandlers[e]&&window.removeEventListener(e,this._eventHandlers[e]);let n=Fez.throttle(()=>{this.isConnected&&t.call(this)},s);this._eventHandlers[e]=n,window.addEventListener(e,n),this.addOnDestroy(()=>{window.removeEventListener(e,n),delete this._eventHandlers[e]})}onWindowResize(e,t){this.on("resize",e,t),e()}onWindowScroll(e,t){this.on("scroll",e,t),e()}onElementResize(e,t,s=200){let n=Fez.throttle(()=>{this.isConnected&&t.call(this,e.getBoundingClientRect(),e)},s),o=new ResizeObserver(n);o.observe(e),t.call(this,e.getBoundingClientRect(),e),this.addOnDestroy(()=>{o.disconnect()})}slot(e,t){t||=document.createElement("template");let s=t.nodeName=="SLOT";for(;e.firstChild;)s?t.parentNode.insertBefore(e.lastChild,t.nextSibling):t.appendChild(e.firstChild);return s?t.parentNode.removeChild(t):e.innerHTML="",t}setStyle(e,t){this.root.style.setProperty(e,t)}connect(){}onMount(){}beforeRender(){}afterRender(){}onDestroy(){}onStateChange(){}onGlobalStateChange(){}publish(e,...t){let s=o=>{if(Fez._subs&&Fez._subs[e]){let i=Fez._subs[e].find(([u])=>u===o);if(i)return i[1].bind(o)(...t),!0}return!1};if(s(this))return!0;let n=this.root.parentElement;for(;n;){if(n.fez&&s(n.fez))return!0;n=n.parentElement}return!1}fezBlocks={};parseHtml(e){let t=this.fezHtmlRoot.replaceAll('"',"&quot;");return e=e.replace(/([!'"\s;])fez\.(\w)/g,`$1${t}$2`).replace(/>\s+</g,"><"),e.trim()}nextTick(e,t){t?(this._nextTicks||={},this._nextTicks[t]||=window.requestAnimationFrame(()=>{e.bind(this)(),this._nextTicks[t]=null},t)):window.requestAnimationFrame(e.bind(this))}render(e){if(e||=this?.class?.fezHtmlFunc,!e||!this.root)return;this.beforeRender();let t=typeof this.class.nodeName=="function"?this.class.nodeName(this.root):this.class.nodeName,s=document.createElement(t||"div"),n;Array.isArray(e)?e[0]instanceof Node?e.forEach(o=>s.appendChild(o)):n=e.join(""):typeof e=="string"?n=H(e)(this):typeof e=="function"&&(n=e(this)),n&&(n=n.replace(/\s\w+="undefined"/g,""),s.innerHTML=this.parseHtml(n)),s.querySelectorAll("[fez-keep]").forEach(o=>{let i=o.getAttribute("fez-keep"),u=this.root.querySelector(`[fez-keep="${i}"]`);u?o.parentNode.replaceChild(u,o):i==="default-slot"&&Array.from(this.root.childNodes).forEach(f=>o.appendChild(f))}),Fez.morphdom(this.root,s),this.renderFezPostProcess(),this.afterRender()}renderFezPostProcess(){let e=(t,s)=>{this.root.querySelectorAll(`*[${t}]`).forEach(n=>{let o=n.getAttribute(t);n.removeAttribute(t),o&&s.bind(this)(o,n)})};e("fez-this",(t,s)=>{new Function("n",`this.${t} = n`).bind(this)(s)}),e("fez-use",(t,s)=>{let n=this[t];typeof n=="function"?n(s):console.error(`Fez error: "${t}" is not a function in ${this.fezName}`)}),e("fez-class",(t,s)=>{let n=t.split(/\s+/),o=n.pop();n.forEach(i=>s.classList.add(i)),o&&setTimeout(()=>{s.classList.add(o)},300)}),e("fez-bind",(t,s)=>{if(["INPUT","SELECT","TEXTAREA"].includes(s.nodeName)){let n=new Function(`return this.${t}`).bind(this)(),o=s.type.toLowerCase()=="checkbox",i=["SELECT"].includes(s.nodeName)||o?"onchange":"onkeyup";s.setAttribute(i,`${this.fezHtmlRoot}${t} = this.${o?"checked":"value"}`),this.val(s,n)}else console.error(`Cant fez-bind="${t}" to ${s.nodeName} (needs INPUT, SELECT or TEXTAREA. Want to use fez-this?).`)}),this.root.querySelectorAll("*[disabled]").forEach(t=>{let s=t.getAttribute("disabled");["false"].includes(s)?t.removeAttribute("disabled"):t.setAttribute("disabled","true")})}refresh(e){if(alert("NEEDS FIX and remove htmlTemplate"),e){let s=Fez.domRoot(this.class.htmlTemplate).querySelector(e).innerHTML;this.render(e,s)}else this.render()}setInterval(e,t,s){typeof e=="number"&&([t,e]=[e,t]),s||=Fez.fnv1(String(e)),this._setIntervalCache||={},clearInterval(this._setIntervalCache[s]);let n=setInterval(()=>{this.isConnected&&e()},t);return this._setIntervalCache[s]=n,this.addOnDestroy(()=>{clearInterval(n),delete this._setIntervalCache[s]}),n}find(e){return typeof e=="string"?this.root.querySelector(e):e}val(e,t){let s=this.find(e);if(s)if(["INPUT","TEXTAREA","SELECT"].includes(s.nodeName))if(typeof t<"u")s.type=="checkbox"?s.checked=!!t:s.value=t;else return s.value;else if(typeof t<"u")s.innerHTML=t;else return s.innerHTML}formData(e){return this.class.formData(e||this.root)}attr(e,t){return typeof t>"u"?this.root.getAttribute(e):(this.root.setAttribute(e,t),t)}childNodes(e){let t=Array.from(this.root.children);if(e){let s=document.createElement("div");s.style.display="none",document.body.appendChild(s),t.forEach(n=>s.appendChild(n)),t=Array.from(s.children).map(e),document.body.removeChild(s)}return t}subscribe(e,t){Fez._subs||={},Fez._subs[e]||=[],Fez._subs[e]=Fez._subs[e].filter(s=>s[0].isConnected),Fez._subs[e].push([this,t])}rootId(){return this.root.id||=`fez_${this.UID}`,this.root.id}fezRegister(){this.css&&(this.css=Fez.globalCss(this.css,{name:this.fezName,wrap:!0})),this.class.css&&(this.class.css=Fez.globalCss(this.class.css,{name:this.fezName})),this.state||=this.reactiveStore(),this.globalState=Fez.state.createProxy(this),this.fezRegisterBindMethods()}fezRegisterBindMethods(){Object.getOwnPropertyNames(Object.getPrototypeOf(this)).filter(t=>t!=="constructor"&&typeof this[t]=="function").forEach(t=>this[t]=this[t].bind(this))}fezHide(){let e=this.root,t=this.childNodes(),s=this.root.parentNode;return t.reverse().forEach(n=>s.insertBefore(n,e.nextSibling)),this.root.remove(),this.root=s,t}reactiveStore(e,t){e||={},t||=(n,o,i,u)=>{this.onStateChange(o,i,u),this.nextTick(this.render,"render")},t.bind(this);function s(n,o){return typeof n!="object"||n===null?n:new Proxy(n,{set(i,u,f,b){let g=Reflect.get(i,u,b);if(g!==f){typeof f=="object"&&f!==null&&(f=s(f,o));let S=Reflect.set(i,u,f,b);return o(i,u,f,g),S}return!0},get(i,u,f){let b=Reflect.get(i,u,f);return typeof b=="object"&&b!==null?s(b,o):b}})}return s(e,t)}};var $e={data:""},Z=r=>typeof window=="object"?((r?r.querySelector("#_goober"):window._goober)||Object.assign((r||document.head).appendChild(document.createElement("style")),{innerHTML:" ",id:"_goober"})).firstChild:r||$e,Fe=r=>{let e=Z(r),t=e.data;return e.data="",t},Te=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,we=/\/\*[^]*?\*\/| +/g,X=/\n+/g,F=(r,e)=>{let t="",s="",n="";for(let o in r){let i=r[o];o[0]=="@"?o[1]=="i"?t=o+" "+i+";":s+=o[1]=="f"?F(i,o):o+"{"+F(i,o[1]=="k"?"":e)+"}":typeof i=="object"?s+=F(i,e?e.replace(/([^,])+/g,u=>o.replace(/(^:.*)|([^,])+/g,f=>/&/.test(f)?f.replace(/&/g,u):u?u+" "+f:f)):o):i!=null&&(o=/^--/.test(o)?o:o.replace(/[A-Z]/g,"-$&").toLowerCase(),n+=F.p?F.p(o,i):o+":"+i+";")}return t+(e&&n?e+"{"+n+"}":n)+s},C={},Y=r=>{if(typeof r=="object"){let e="";for(let t in r)e+=t+Y(r[t]);return e}return r},Me=(r,e,t,s,n)=>{let o=Y(r),i=C[o]||(C[o]=(f=>{let b=0,g=11;for(;b<f.length;)g=101*g+f.charCodeAt(b++)>>>0;return"go"+g})(o));if(!C[i]){let f=o!==r?r:(b=>{let g,S,w=[{}];for(;g=Te.exec(b.replace(we,""));)g[4]?w.shift():g[3]?(S=g[3].replace(X," ").trim(),w.unshift(w[0][S]=w[0][S]||{})):w[0][g[1]]=g[2].replace(X," ").trim();return w[0]})(r);C[i]=F(n?{["@keyframes "+i]:f}:f,t?"":"."+i)}let u=t&&C.g?C.g:null;return t&&(C.g=C[i]),((f,b,g,S)=>{S?b.data=b.data.replace(S,f):b.data.indexOf(f)===-1&&(b.data=g?f+b.data:b.data+f)})(C[i],e,s,u),i},Le=(r,e,t)=>r.reduce((s,n,o)=>{let i=e[o];if(i&&i.call){let u=i(t),f=u&&u.props&&u.props.className||/^go/.test(u)&&u;i=f?"."+f:u&&typeof u=="object"?u.props?"":F(u,""):u===!1?"":u}return s+n+(i??"")},"");function I(r){let e=this||{},t=r.call?r(e.p):r;return Me(t.unshift?t.raw?Le(t,[].slice.call(arguments,1),e.p):t.reduce((s,n)=>Object.assign(s,n&&n.call?n(e.p):n),{}):t,Z(e.target),e.g,e.o,e.k)}var x,P,q,_e=I.bind({g:1}),Oe=I.bind({k:1});function je(r,e,t,s){F.p=e,x=r,P=t,q=s}function He(r,e){let t=this||{};return function(){let s=arguments;function n(o,i){let u=Object.assign({},o),f=u.className||n.className;t.p=Object.assign({theme:P&&P()},u),t.o=/ *go\d+/.test(f),u.className=I.apply(t,s)+(f?" "+f:""),e&&(u.ref=i);let b=r;return r[0]&&(b=u.as||r,delete u.as),q&&b[0]&&q(u),x(b,u)}return e?e(n):n}}var Q={css:I,extractCss:Fe,glob:_e,keyframes:Oe,setup:je,styled:He};var ee=function(){"use strict";let r=new Set,e={morphStyle:"outerHTML",callbacks:{beforeNodeAdded:A,afterNodeAdded:A,beforeNodeMorphed:A,afterNodeMorphed:A,beforeNodeRemoved:A,afterNodeRemoved:A,beforeAttributeUpdated:A},head:{style:"merge",shouldPreserve:function(l){return l.getAttribute("im-preserve")==="true"},shouldReAppend:function(l){return l.getAttribute("im-re-append")==="true"},shouldRemove:A,afterHeadMorphed:A}};function t(l,c,a={}){l instanceof Document&&(l=l.documentElement),typeof c=="string"&&(c=de(c));let d=he(c),h=ae(l,d,a);return s(l,d,h)}function s(l,c,a){if(a.head.block){let d=l.querySelector("head"),h=c.querySelector("head");if(d&&h){let p=S(h,d,a);Promise.all(p).then(function(){s(l,c,Object.assign(a,{head:{block:!1,ignore:!0}}))});return}}if(a.morphStyle==="innerHTML")return i(c,l,a),l.children;if(a.morphStyle==="outerHTML"||a.morphStyle==null){let d=me(c,l,a),h=d?.previousSibling,p=d?.nextSibling,y=o(l,d,a);return d?pe(h,y,p):[]}else throw"Do not understand how to morph style "+a.morphStyle}function n(l,c){return c.ignoreActiveValue&&l===document.activeElement&&l!==document.body}function o(l,c,a){if(!(a.ignoreActive&&l===document.activeElement))return c==null?a.callbacks.beforeNodeRemoved(l)===!1?l:(l.remove(),a.callbacks.afterNodeRemoved(l),null):R(l,c)?(a.callbacks.beforeNodeMorphed(l,c)===!1||(l instanceof HTMLHeadElement&&a.head.ignore||(l instanceof HTMLHeadElement&&a.head.style!=="morph"?S(c,l,a):(f(c,l,a),n(l,a)||i(c,l,a))),a.callbacks.afterNodeMorphed(l,c)),l):a.callbacks.beforeNodeRemoved(l)===!1||a.callbacks.beforeNodeAdded(c)===!1?l:(l.parentElement.replaceChild(c,l),a.callbacks.afterNodeAdded(c),a.callbacks.afterNodeRemoved(l),c)}function i(l,c,a){let d=l.firstChild,h=c.firstChild,p;for(;d;){if(p=d,d=p.nextSibling,h==null){if(a.callbacks.beforeNodeAdded(p)===!1)return;c.appendChild(p),a.callbacks.afterNodeAdded(p),M(a,p);continue}if(G(p,h,a)){o(h,p,a),h=h.nextSibling,M(a,p);continue}let y=fe(l,c,p,h,a);if(y){h=V(h,y,a),o(y,p,a),M(a,p);continue}let z=ue(l,c,p,h,a);if(z){h=V(h,z,a),o(z,p,a),M(a,p);continue}if(a.callbacks.beforeNodeAdded(p)===!1)return;c.insertBefore(p,h),a.callbacks.afterNodeAdded(p),M(a,p)}for(;h!==null;){let y=h;h=h.nextSibling,U(y,a)}}function u(l,c,a,d){return l==="value"&&d.ignoreActiveValue&&c===document.activeElement?!0:d.callbacks.beforeAttributeUpdated(l,c,a)===!1}function f(l,c,a){let d=l.nodeType;if(d===1){let h=l.attributes,p=c.attributes;for(let y of h)if(!u(y.name,c,"update",a))try{c.getAttribute(y.name)!==y.value&&c.setAttribute(y.name,y.value)}catch(z){console.error("Error setting attribute:",{badNode:c,badAttribute:y,error:z.message})}for(let y=p.length-1;0<=y;y--){let z=p[y];u(z.name,c,"remove",a)||l.hasAttribute(z.name)||c.removeAttribute(z.name)}}(d===8||d===3)&&c.nodeValue!==l.nodeValue&&(c.nodeValue=l.nodeValue),n(c,a)||g(l,c,a)}function b(l,c,a,d){if(l[a]!==c[a]){let h=u(a,c,"update",d);h||(c[a]=l[a]),l[a]?h||c.setAttribute(a,l[a]):u(a,c,"remove",d)||c.removeAttribute(a)}}function g(l,c,a){if(l instanceof HTMLInputElement&&c instanceof HTMLInputElement&&l.type!=="file"){let d=l.value,h=c.value;b(l,c,"checked",a),b(l,c,"disabled",a),l.hasAttribute("value")?d!==h&&(u("value",c,"update",a)||(c.setAttribute("value",d),c.value=d)):u("value",c,"remove",a)||(c.value="",c.removeAttribute("value"))}else if(l instanceof HTMLOptionElement)b(l,c,"selected",a);else if(l instanceof HTMLTextAreaElement&&c instanceof HTMLTextAreaElement){let d=l.value,h=c.value;if(u("value",c,"update",a))return;d!==h&&(c.value=d),c.firstChild&&c.firstChild.nodeValue!==d&&(c.firstChild.nodeValue=d)}}function S(l,c,a){let d=[],h=[],p=[],y=[],z=a.head.style,L=new Map;for(let v of l.children)L.set(v.outerHTML,v);for(let v of c.children){let E=L.has(v.outerHTML),j=a.head.shouldReAppend(v),D=a.head.shouldPreserve(v);E||D?j?h.push(v):(L.delete(v.outerHTML),p.push(v)):z==="append"?j&&(h.push(v),y.push(v)):a.head.shouldRemove(v)!==!1&&h.push(v)}y.push(...L.values());let K=[];for(let v of y){let E=document.createRange().createContextualFragment(v.outerHTML).firstChild;if(a.callbacks.beforeNodeAdded(E)!==!1){if(E.href||E.src){let j=null,D=new Promise(function(ve){j=ve});E.addEventListener("load",function(){j()}),K.push(D)}c.appendChild(E),a.callbacks.afterNodeAdded(E),d.push(E)}}for(let v of h)a.callbacks.beforeNodeRemoved(v)!==!1&&(c.removeChild(v),a.callbacks.afterNodeRemoved(v));return a.head.afterHeadMorphed(c,{added:d,kept:p,removed:h}),K}function w(){}function A(){}function ce(l){let c={};return Object.assign(c,e),Object.assign(c,l),c.callbacks={},Object.assign(c.callbacks,e.callbacks),Object.assign(c.callbacks,l.callbacks),c.head={},Object.assign(c.head,e.head),Object.assign(c.head,l.head),c}function ae(l,c,a){return a=ce(a),{target:l,newContent:c,config:a,morphStyle:a.morphStyle,ignoreActive:a.ignoreActive,ignoreActiveValue:a.ignoreActiveValue,idMap:ze(l,c),deadIds:new Set,callbacks:a.callbacks,head:a.head}}function G(l,c,a){return l==null||c==null?!1:l.nodeType===c.nodeType&&l.tagName===c.tagName?l.id!==""&&l.id===c.id?!0:O(a,l,c)>0:!1}function R(l,c){return l==null||c==null?!1:l.nodeType===c.nodeType&&l.tagName===c.tagName}function V(l,c,a){for(;l!==c;){let d=l;l=l.nextSibling,U(d,a)}return M(a,c),c.nextSibling}function fe(l,c,a,d,h){let p=O(h,a,c),y=null;if(p>0){let z=d,L=0;for(;z!=null;){if(G(a,z,h))return z;if(L+=O(h,z,l),L>p)return null;z=z.nextSibling}}return y}function ue(l,c,a,d,h){let p=d,y=a.nextSibling,z=0;for(;p!=null;){if(O(h,p,l)>0)return null;if(R(a,p))return p;if(R(y,p)&&(z++,y=y.nextSibling,z>=2))return null;p=p.nextSibling}return p}function de(l){let c=new DOMParser,a=l.replace(/<svg(\s[^>]*>|>)([\s\S]*?)<\/svg>/gim,"");if(a.match(/<\/html>/)||a.match(/<\/head>/)||a.match(/<\/body>/)){let d=c.parseFromString(l,"text/html");if(a.match(/<\/html>/))return d.generatedByIdiomorph=!0,d;{let h=d.firstChild;return h?(h.generatedByIdiomorph=!0,h):null}}else{let h=c.parseFromString("<body><template>"+l+"</template></body>","text/html").body.querySelector("template").content;return h.generatedByIdiomorph=!0,h}}function he(l){if(l==null)return document.createElement("div");if(l.generatedByIdiomorph)return l;if(l instanceof Node){let c=document.createElement("div");return c.append(l),c}else{let c=document.createElement("div");for(let a of[...l])c.append(a);return c}}function pe(l,c,a){let d=[],h=[];for(;l!=null;)d.push(l),l=l.previousSibling;for(;d.length>0;){let p=d.pop();h.push(p),c.parentElement.insertBefore(p,c)}for(h.push(c);a!=null;)d.push(a),h.push(a),a=a.nextSibling;for(;d.length>0;)c.parentElement.insertBefore(d.pop(),c.nextSibling);return h}function me(l,c,a){let d;d=l.firstChild;let h=d,p=0;for(;d;){let y=be(d,c,a);y>p&&(h=d,p=y),d=d.nextSibling}return h}function be(l,c,a){return R(l,c)?.5+O(a,l,c):0}function U(l,c){M(c,l),c.callbacks.beforeNodeRemoved(l)!==!1&&(l.remove(),c.callbacks.afterNodeRemoved(l))}function ye(l,c){return!l.deadIds.has(c)}function ge(l,c,a){return(l.idMap.get(a)||r).has(c)}function M(l,c){let a=l.idMap.get(c)||r;for(let d of a)l.deadIds.add(d)}function O(l,c,a){let d=l.idMap.get(c)||r,h=0;for(let p of d)ye(l,p)&&ge(l,p,a)&&++h;return h}function J(l,c){let a=l.parentElement,d=l.querySelectorAll("[id]");for(let h of d){let p=h;for(;p!==a&&p!=null;){let y=c.get(p);y==null&&(y=new Set,c.set(p,y)),y.add(h.id),p=p.parentElement}}}function ze(l,c){let a=new Map;return J(l,a),J(c,a),a}return{morph:t,defaults:e}}();function B(r,e){let t=globalThis.window?.Fez||globalThis.Fez;if(r.includes("-")||console.error(`Fez: Invalid custom element name "${r}". Custom element names must contain a dash (e.g., 'my-element', 'ui-button').`),e.fezHtmlRoot)e.html&&(e.html=te(e.html));else{let s=new e,n=class extends _{};if(Object.getOwnPropertyNames(s).concat(Object.getOwnPropertyNames(e.prototype)).filter(i=>!["constructor","prototype"].includes(i)).forEach(i=>n.prototype[i]=s[i]),s.GLOBAL&&(n.fezGlobal=s.GLOBAL),s.CSS&&(n.css=s.CSS),s.HTML&&(n.html=te(s.HTML)),s.NAME&&(n.nodeName=s.NAME),s.GLOBAL){let i=()=>document.body.appendChild(document.createElement(r));document.readyState==="loading"?document.addEventListener("DOMContentLoaded",i):i()}e=n,t.log(`${r} compiled`)}e.html&&(e.html=e.html.replace(/<slot\s*\/>|<slot\s*>\s*<\/slot>/g,()=>{let s=e.SLOT||"div";return`<${s} class="fez-slot" fez-keep="default-slot"></${s}>`}),e.fezHtmlFunc=H(e.html)),e.css&&(e.css=t.globalCss(e.css,{name:r})),t.classes[r]=e,Re(r,e)}function Re(r,e){let t=globalThis.window?.Fez||globalThis.Fez;customElements.get(r)||customElements.define(r,class extends HTMLElement{connectedCallback(){t._pendingConnections||(t._pendingConnections=[],t._batchScheduled=!1),t._pendingConnections.push({name:r,node:this}),t._batchScheduled||(t._batchScheduled=!0,Promise.resolve().then(()=>{let s=t._pendingConnections.slice();t._pendingConnections=[],t._batchScheduled=!1,s.sort((n,o)=>n.node.contains(o.node)?-1:o.node.contains(n.node)?1:0),s.forEach(({name:n,node:o})=>{o.isConnected&&o.parentNode&&Ie(n,o)})}))}})}function te(r){let e=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]);return r.replace(/<([a-z-]+)\b([^>]*)\/>/g,(t,s,n)=>e.has(s)?t:`<${s}${n}></${s}>`)}function Ie(r,e){let t=Fez.classes[r],s=e.parentNode;if(e.isConnected){let n=typeof t.nodeName=="function"?t.nodeName(e):t.nodeName,o=document.createElement(n||"div");o.classList.add("fez"),o.classList.add(`fez-${r}`),s.replaceChild(o,e);let i=new t;if(i.UID=++Fez.instanceCount,Fez.instances.set(i.UID,i),i.oldRoot=e,i.fezName=r,i.root=o,i.props=t.getProps(e,o),i.class=t,i.slot(e,o),o.fez=i,t.fezGlobal&&t.fezGlobal!=!0&&(window[t.fezGlobal]=i),window.$&&(i.$root=$(o)),i.props.id&&o.setAttribute("id",i.props.id),i.fezRegister(),(i.init||i.created||i.connect).bind(i)(i.props),i.render(),i.firstRender=!0,i.onMount(i.props),i.onSubmit){let u=i.root.nodeName=="FORM"?i.root:i.find("form");u.onsubmit=f=>{f.preventDefault(),i.onSubmit(i.formData())}}if(i.onPropsChange){Ne.observe(o,{attributes:!0});for(let[u,f]of Object.entries(i.props))i.onPropsChange(u,f)}}}var Ne=new MutationObserver((r,e)=>{for(let t of r)if(t.type==="attributes"){let s=t.target.fez,n=t.attributeName,o=t.target.getAttribute(n);s&&(s.props[n]=o,s.onPropsChange(n,o))}});var De=r=>{let e={script:"",style:"",html:"",head:""},t=r.split(`
9
+ `),s=[],n="";for(var o of t)o=o.trim(),o.startsWith("<script")&&!e.script&&n!="head"?n="script":o.startsWith("<head")&&!e.script?n="head":o.startsWith("<style")?n="style":o.endsWith("<\/script>")&&n==="script"&&!e.script?(e.script=s.join(`
10
10
  `),s=[],n=null):o.endsWith("</style>")&&n==="style"?(e.style=s.join(`
11
11
  `),s=[],n=null):(o.endsWith("</head>")||o.endsWith("</header>"))&&n==="head"?(e.head=s.join(`
12
12
  `),s=[],n=null):n?s.push(o):e.html+=o+`
13
- `;if(e.head){let a=Fez.domRoot(e.head);Array.from(a.children).forEach(u=>{if(u.tagName==="SCRIPT"){let b=document.createElement("script");Array.from(u.attributes).forEach(g=>{b.setAttribute(g.name,g.value)}),b.type||="text/javascript",u.src?document.head.appendChild(b):(b.type.includes("javascript")||b.type=="module")&&(b.textContent=u.textContent,document.head.appendChild(b))}else document.head.appendChild(u.cloneNode(!0))})}let i=e.script;return/class\s+\{/.test(i)||(i=`class {
13
+ `;if(e.head){let u=Fez.domRoot(e.head);Array.from(u.children).forEach(f=>{if(f.tagName==="SCRIPT"){let b=document.createElement("script");Array.from(f.attributes).forEach(g=>{b.setAttribute(g.name,g.value)}),b.type||="text/javascript",f.src?document.head.appendChild(b):(b.type.includes("javascript")||b.type=="module")&&(b.textContent=f.textContent,document.head.appendChild(b))}else document.head.appendChild(f.cloneNode(!0))})}let i=e.script;return/class\s+\{/.test(i)||(i=`class {
14
14
  ${i}
15
- }`),String(e.style).includes(":")&&(Object.entries(Fez._styleMacros).forEach(([a,u])=>{e.style=e.style.replaceAll(`:${a} `,`${u} `)}),e.style=e.style.includes(":fez")||/(?:^|\s)body\s*\{/.test(e.style)?e.style:`:fez {
15
+ }`),String(e.style).includes(":")&&(Object.entries(Fez._styleMacros).forEach(([u,f])=>{e.style=e.style.replaceAll(`:${u} `,`${f} `)}),e.style=e.style.includes(":fez")||/(?:^|\s)body\s*\{/.test(e.style)?e.style:`:fez {
16
16
  ${e.style}
17
17
  }`,i=i.replace(/\}\s*$/,`
18
18
  CSS = \`${e.style}\`
19
19
  }`)),/\w/.test(String(e.html))&&(e.html=e.html.replaceAll("`","&#x60;"),e.html=e.html.replaceAll("$","\\$"),i=i.replace(/\}\s*$/,`
20
20
  HTML = \`${e.html}\`
21
- }`)),i};function q(t){if(t instanceof Node){let e=t;e.remove();let r=e.getAttribute("fez");if(r&&(r.includes(".")||r.includes("/"))){Pe(r);return}else return r&&!r.includes("-")&&console.error(`Fez: Invalid custom element name "${r}". Custom element names must contain a dash (e.g., 'my-element', 'ui-button').`),N(r,e.innerHTML)}else{(t?Fez.domRoot(t):document.body).querySelectorAll("template[fez], xmp[fez]").forEach(r=>{q(r)});return}}function Pe(t){Fez.log(`Loading from ${t}`),Fez.fetch(t).then(e=>{let n=new DOMParser().parseFromString(e,"text/html").querySelectorAll("template[fez], xmp[fez]");if(n.length>0)n.forEach(o=>{let i=o.getAttribute("fez");i&&!i.includes("-")&&!i.includes(".")&&!i.includes("/")&&console.error(`Fez: Invalid custom element name "${i}". Custom element names must contain a dash (e.g., 'my-element', 'ui-button').`);let a=o.innerHTML;N(i,a)});else{let o=t.split("/").pop().split(".")[0];N(o,e)}}).catch(e=>{console.error(`FEZ template load error for "${t}": ${e.message}`)})}function N(t,e){if(arguments.length===1)return q(t);if(e&&e.includes("</xmp>"))return q(e);t&&!t.includes("-")&&!t.includes(".")&&!t.includes("/")&&console.error(`Fez: Invalid custom element name "${t}". Custom element names must contain a dash (e.g., 'my-element', 'ui-button').`);let r=Ne(e),s=r.split(/class\s+\{/,2);if(r=`${s[0]};
21
+ }`)),i};function W(r){if(r instanceof Node){let e=r;e.remove();let t=e.getAttribute("fez");if(t&&(t.includes(".")||t.includes("/"))){ke(t);return}else return t&&!t.includes("-")&&console.error(`Fez: Invalid custom element name "${t}". Custom element names must contain a dash (e.g., 'my-element', 'ui-button').`),N(t,e.innerHTML)}else{(r?Fez.domRoot(r):document.body).querySelectorAll("template[fez], xmp[fez]").forEach(t=>{W(t)});return}}function ke(r){Fez.log(`Loading from ${r}`),Fez.fetch(r).then(e=>{let n=new DOMParser().parseFromString(e,"text/html").querySelectorAll("template[fez], xmp[fez]");if(n.length>0)n.forEach(o=>{let i=o.getAttribute("fez");i&&!i.includes("-")&&!i.includes(".")&&!i.includes("/")&&console.error(`Fez: Invalid custom element name "${i}". Custom element names must contain a dash (e.g., 'my-element', 'ui-button').`);let u=o.innerHTML;N(i,u)});else{let o=r.split("/").pop().split(".")[0];N(o,e)}}).catch(e=>{console.error(`FEZ template load error for "${r}": ${e.message}`)})}function N(r,e){if(arguments.length===1)return W(r);if(e&&e.includes("</xmp>"))return W(e);r&&!r.includes("-")&&!r.includes(".")&&!r.includes("/")&&console.error(`Fez: Invalid custom element name "${r}". Custom element names must contain a dash (e.g., 'my-element', 'ui-button').`);let t=De(e),s=t.split(/class\s+\{/,2);if(t=`${s[0]};
22
22
 
23
- window.Fez('${t}', class {
24
- ${s[1]})`,t){let n=document.getElementById("fez-hidden-styles");n||(n=document.createElement("style"),n.id="fez-hidden-styles",document.head.appendChild(n));let o=[...Object.keys(Fez.classes),t].sort().join(", ");n.textContent=`${o} { display: none; }
25
- `}if(r.includes("import "))Fez.head({script:r}),setTimeout(()=>{Fez.classes[t]||Fez.error(`Template "${t}" possible compile error. (can be a false positive, it imports are not loaded)`)},2e3);else try{new Function(r)()}catch(n){Fez.error(`Template "${t}" compile error: ${n.message}`),console.log(r)}}var re=N;var De={data:{},listeners:new Map,subscribers:new Map,globalSubscribers:new Set,notify(t,e,r){Fez.log(`Global state change for ${t}: ${e} (from ${r})`);let s=this.listeners.get(t);s&&s.forEach(o=>{o.isConnected?(o.onGlobalStateChange(t,e,r),o.render()):s.delete(o)});let n=this.subscribers.get(t);n&&n.forEach(o=>{try{o(e,r,t)}catch(i){console.error(`Error in subscriber for key ${t}:`,i)}}),this.globalSubscribers.forEach(o=>{try{o(t,e,r)}catch(i){console.error("Error in global subscriber:",i)}})},createProxy(t){return new Proxy({},{get:(e,r)=>(t._globalStateKeys||=new Set,t._globalStateKeys.has(r)||(t._globalStateKeys.add(r),this.listeners.has(r)||this.listeners.set(r,new Set),this.listeners.get(r).add(t)),this.data[r]),set:(e,r,s)=>{let n=this.data[r];return n!==s&&(this.data[r]=s,this.notify(r,s,n)),!0}})},set(t,e){let r=this.data[t];r!==e&&(this.data[t]=e,this.notify(t,e,r))},get(t){return this.data[t]},forEach(t,e){let r=this.listeners.get(t);r&&r.forEach(s=>{s.isConnected?e(s):r.delete(s)})},subscribe(t,e){if(typeof t=="function")return this.globalSubscribers.add(t),()=>this.globalSubscribers.delete(t);{let r=t;return this.subscribers.has(r)||this.subscribers.set(r,new Set),this.subscribers.get(r).add(e),()=>{let s=this.subscribers.get(r);s&&(s.delete(e),s.size===0&&this.subscribers.delete(r))}}}},se=De;var m=(t,e)=>{if(typeof t=="number"){let r=m.instances.get(t);if(r)return r;m.error(`Instance with UID "${t}" not found.`)}else if(t)if(e)if(typeof e=="function"&&!/^\s*class/.test(e.toString())&&!/\b(this|new)\b/.test(e.toString())){let s=Array.from(document.querySelectorAll(`.fez.fez-${t}`)).filter(n=>n.fez);return s.forEach(n=>e(n.fez)),s}else return typeof e!="function"?m.find(t,e):te(t,e);else{let r=t.nodeName?t.closest(".fez"):document.querySelector(t.includes("#")?t:`.fez.fez-${t}`);if(r){if(r.fez)return r.fez;m.error(`node "${t}" has no Fez attached.`)}else m.error(`node "${t}" not found.`)}else m.error("Fez() ?")};m.classes={};m.instanceCount=0;m.instances=new Map;m.find=(t,e)=>{let r=t;typeof r=="string"&&(r=document.body.querySelector(r)),typeof r.val=="function"&&(r=r[0]);let s=e?`.fez.fez-${e}`:".fez",n=r.closest(s);if(n&&n.fez)return n.fez;console.error("Fez node connector not found",t,r)};m.cssClass=t=>Q.css(t);m.globalCss=(t,e={})=>{if(typeof t=="function"&&(t=t()),t.includes(":")){let r=t.split(`
23
+ window.Fez('${r}', class {
24
+ ${s[1]})`,r){let n=document.getElementById("fez-hidden-styles");n||(n=document.createElement("style"),n.id="fez-hidden-styles",document.head.appendChild(n));let o=[...Object.keys(Fez.classes),r].sort().join(", ");n.textContent=`${o} { display: none; }
25
+ `}if(t.includes("import "))Fez.head({script:t}),setTimeout(()=>{Fez.classes[r]||Fez.error(`Template "${r}" possible compile error. (can be a false positive, it imports are not loaded)`)},2e3);else try{new Function(t)()}catch(n){Fez.error(`Template "${r}" compile error: ${n.message}`),console.log(t)}}var re=N;var Pe={data:{},listeners:new Map,subscribers:new Map,globalSubscribers:new Set,notify(r,e,t){Fez.log(`Global state change for ${r}: ${e} (from ${t})`);let s=this.listeners.get(r);s&&s.forEach(o=>{o.isConnected?(o.onGlobalStateChange(r,e,t),o.render()):s.delete(o)});let n=this.subscribers.get(r);n&&n.forEach(o=>{try{o(e,t,r)}catch(i){console.error(`Error in subscriber for key ${r}:`,i)}}),this.globalSubscribers.forEach(o=>{try{o(r,e,t)}catch(i){console.error("Error in global subscriber:",i)}})},createProxy(r){return new Proxy({},{get:(e,t)=>(r._globalStateKeys||=new Set,r._globalStateKeys.has(t)||(r._globalStateKeys.add(t),this.listeners.has(t)||this.listeners.set(t,new Set),this.listeners.get(t).add(r)),this.data[t]),set:(e,t,s)=>{let n=this.data[t];return n!==s&&(this.data[t]=s,this.notify(t,s,n)),!0}})},set(r,e){let t=this.data[r];t!==e&&(this.data[r]=e,this.notify(r,e,t))},get(r){return this.data[r]},forEach(r,e){let t=this.listeners.get(r);t&&t.forEach(s=>{s.isConnected?e(s):t.delete(s)})},subscribe(r,e){if(typeof r=="function")return this.globalSubscribers.add(r),()=>this.globalSubscribers.delete(r);{let t=r;return this.subscribers.has(t)||this.subscribers.set(t,new Set),this.subscribers.get(t).add(e),()=>{let s=this.subscribers.get(t);s&&(s.delete(e),s.size===0&&this.subscribers.delete(t))}}}},se=Pe;var ne=r=>{r.head=(e,t)=>{if(e.nodeName){e.nodeName=="SCRIPT"?(r.head({script:e.innerText}),e.remove()):(e.querySelectorAll("script").forEach(f=>r.head(f)),e.querySelectorAll("template[fez], xmp[fez], script[fez]").forEach(f=>r.compile(f)));return}if(typeof e!="object"||e===null)throw new Error("head requires an object parameter");let s,n={},o;if(e.script){if(e.script.includes("import ")){t&&r.error("Fez.head callback is not supported when script with import is passed (module context).");let f=document.createElement("script");f.type="module",f.textContent=e.script,document.head.appendChild(f),setTimeout(()=>f.remove(),100)}else try{new Function(e.script)(),t&&t()}catch(f){r.error("Error executing script:",f),console.log(e.script)}return}else if(e.js){s=e.js,o="script";for(let[f,b]of Object.entries(e))f!=="js"&&f!=="module"&&(n[f]=b);e.module&&(n.type="module")}else if(e.css){s=e.css,o="link",n.rel="stylesheet";for(let[f,b]of Object.entries(e))f!=="css"&&(n[f]=b)}else throw new Error('head requires either "script", "js" or "css" property');let i=document.querySelector(`${o}[src="${s}"], ${o}[href="${s}"]`);if(i)return t&&t(),i;let u=document.createElement(o);o==="link"?u.href=s:u.src=s;for(let[f,b]of Object.entries(n))u.setAttribute(f,b);return(t||e.module)&&(u.onload=()=>{e.module&&o==="script"&&import(s).then(f=>{window[e.module]=f.default||f[e.module]||f}).catch(f=>{console.error(`Error importing module ${e.module}:`,f)}),t&&t()}),document.head.appendChild(u),u},r.darkenColor=(e,t=20)=>{let s=parseInt(e.replace("#",""),16),n=Math.round(2.55*t),o=(s>>16)-n,i=(s>>8&255)-n,u=(s&255)-n;return"#"+(16777216+(o<255?o<1?0:o:255)*65536+(i<255?i<1?0:i:255)*256+(u<255?u<1?0:u:255)).toString(16).slice(1)},r.lightenColor=(e,t=20)=>{let s=parseInt(e.replace("#",""),16),n=Math.round(2.55*t),o=(s>>16)+n,i=(s>>8&255)+n,u=(s&255)+n;return"#"+(16777216+(o<255?o<1?0:o:255)*65536+(i<255?i<1?0:i:255)*256+(u<255?u<1?0:u:255)).toString(16).slice(1)},r.htmlEscape=e=>typeof e=="string"?(e=e.replace(/font-family\s*:\s*(?:&[^;]+;|[^;])*?;/gi,"").replaceAll("&","&amp;").replaceAll("'","&apos;").replaceAll('"',"&quot;").replaceAll("<","&lt;").replaceAll(">","&gt;"),e):e===void 0?"":e,r.domRoot=(e,t="div")=>{if(e instanceof Node)return e;{let s=document.createElement(t);return s.innerHTML=e,s}},r.activateNode=(e,t="active")=>{Array.from(e.parentElement.children).forEach(s=>{s.classList.remove(t)}),e.classList.add(t)},r.isTrue=e=>["1","true","on"].includes(String(e).toLowerCase())};var m=(r,e)=>{if(typeof r=="number"){let t=m.instances.get(r);if(t)return t;m.error(`Instance with UID "${r}" not found.`)}else if(r)if(e)if(typeof e=="function"&&!/^\s*class/.test(e.toString())&&!/\b(this|new)\b/.test(e.toString())){let s=Array.from(document.querySelectorAll(`.fez.fez-${r}`)).filter(n=>n.fez);return s.forEach(n=>e(n.fez)),s}else return typeof e!="function"?m.find(r,e):B(r,e);else{let t=r.nodeName?r.closest(".fez"):document.querySelector(r.includes("#")?r:`.fez.fez-${r}`);if(t){if(t.fez)return t.fez;m.error(`node "${r}" has no Fez attached.`)}else m.error(`node "${r}" not found.`)}else m.error("Fez() ?")};m.classes={};m.instanceCount=0;m.instances=new Map;m.find=(r,e)=>{let t=r;typeof t=="string"&&(t=document.body.querySelector(t)),typeof t.val=="function"&&(t=t[0]);let s=e?`.fez.fez-${e}`:".fez",n=t.closest(s);if(n&&n.fez)return n.fez;console.error("Fez node connector not found",r,t)};m.cssClass=r=>Q.css(r);m.globalCss=(r,e={})=>{if(typeof r=="function"&&(r=r()),r.includes(":")){let t=r.split(`
26
26
  `).filter(s=>!/^\s*\/\//.test(s)).join(`
27
- `);e.wrap&&(r=`:fez { ${r} }`),r=r.replace(/\:fez|\:host/,`.fez.fez-${e.name}`),t=m.cssClass(r)}return document.body?document.body.parentElement.classList.add(t):document.addEventListener("DOMContentLoaded",()=>{document.body.parentElement.classList.add(t)}),t};m.info=()=>{console.log(JSON.stringify(m.fastBindInfo,null,2))};m.morphdom=(t,e,r={})=>{Array.from(t.attributes).forEach(n=>{e.setAttribute(n.name,n.value)}),x.morph(t,e,{morphStyle:"outerHTML"});let s=t.nextSibling;s?.nodeType===Node.TEXT_NODE&&s.textContent.trim()===""&&s.remove()};m.htmlEscape=t=>typeof t=="string"?(t=t.replace(/font-family\s*:\s*(?:&[^;]+;|[^;])*?;/gi,"").replaceAll("&","&amp;").replaceAll("'","&apos;").replaceAll('"',"&quot;").replaceAll("<","&lt;").replaceAll(">","&gt;"),t):t===void 0?"":t;m.publish=(t,...e)=>{m._subs||={},m._subs[t]||=[],m._subs[t].forEach(r=>{r[1].bind(r[0])(...e)})};m.fnv1=t=>{var e,r,s,n,o,i;for(e=2166136261,r=16777619,s=e,n=o=0,i=t.length-1;0<=i?o<=i:o>=i;n=0<=i?++o:--o)s^=t.charCodeAt(n),s*=r;return s.toString(36).replaceAll("-","")};m.tag=(t,e={},r="")=>{let s=encodeURIComponent(JSON.stringify(e));return`<${t} data-props="${s}">${r}</${t}>`};m.error=(t,e)=>{if(t=`Fez: ${t}`,console.error(t),e)return`<span style="border: 1px solid red; font-size: 14px; padding: 3px 7px; background: #fee; border-radius: 4px;">${t}</span>`};m.log=t=>{m.LOG===!0&&(t=String(t).substring(0,180),console.log(`Fez: ${t}`))};document.addEventListener("DOMContentLoaded",()=>{m.log("Fez.LOG === true, logging enabled.")});m.untilTrue=(t,e)=>{e||=200,t()||setTimeout(()=>{m.untilTrue(t,e)},e)};m.head=(t,e)=>{if(t.nodeName){t.nodeName=="SCRIPT"?(m.head({script:t.innerText}),t.remove()):(t.querySelectorAll("script").forEach(a=>m.head(a)),t.querySelectorAll("template[fez], xmp[fez], script[fez]").forEach(a=>m.compile(a)));return}if(typeof t!="object"||t===null)throw new Error("head requires an object parameter");let r,s={},n;if(t.script){if(t.script.includes("import ")){e&&m.error("Fez.head callback is not supported when script with import is passed (module context).");let a=document.createElement("script");a.type="module",a.textContent=t.script,document.head.appendChild(a),setTimeout(()=>a.remove(),100)}else try{new Function(t.script)(),e&&e()}catch(a){m.error("Error executing script:",a),console.log(t.script)}return}else if(t.js){r=t.js,n="script";for(let[a,u]of Object.entries(t))a!=="js"&&a!=="module"&&(s[a]=u);t.module&&(s.type="module")}else if(t.css){r=t.css,n="link",s.rel="stylesheet";for(let[a,u]of Object.entries(t))a!=="css"&&(s[a]=u)}else throw new Error('head requires either "script", "js" or "css" property');let o=document.querySelector(`${n}[src="${r}"], ${n}[href="${r}"]`);if(o)return e&&e(),o;let i=document.createElement(n);n==="link"?i.href=r:i.src=r;for(let[a,u]of Object.entries(s))i.setAttribute(a,u);return(e||t.module)&&(i.onload=()=>{t.module&&n==="script"&&import(r).then(a=>{window[t.module]=a.default||a[t.module]||a}).catch(a=>{console.error(`Error importing module ${t.module}:`,a)}),e&&e()}),document.head.appendChild(i),i};m.fetch=function(...t){m._fetchCache||={};let e="GET",r,s;typeof t[0]=="string"&&/^[A-Z]+$/.test(t[0])&&(e=t.shift()),r=t.shift();let n={},o=null;if(typeof t[0]=="object"&&(o=t.shift()),typeof t[0]=="function"&&(s=t.shift()),o){if(e==="GET"){let u=new URLSearchParams(o);r+=(r.includes("?")?"&":"?")+u.toString()}else if(e==="POST"){let u=new FormData;for(let[b,g]of Object.entries(o))u.append(b,g);n.body=u}}n.method=e;let i=`${e}:${r}:${JSON.stringify(n)}`;if(m._fetchCache[i]){let u=m._fetchCache[i];if(m.log(`fetch cache hit: ${e} ${r}`),s){s(u);return}return Promise.resolve(u)}m.log(`fetch live: ${e} ${r}`);let a=u=>u.headers.get("content-type")?.includes("application/json")?u.json():u.text();if(s){fetch(r,n).then(a).then(u=>{m._fetchCache[i]=u,s(u)}).catch(u=>m.onError("fetch",u));return}return fetch(r,n).then(a).then(u=>(m._fetchCache[i]=u,u))};m.onError=(t,e)=>{if(typeof t!="string")throw new Error("Fez.onError: kind must be a string");console.error(`${t}: ${e.toString()}`)};m._styleMacros={};m.styleMacro=(t,e)=>{m._styleMacros[t]=e};m.store={store:new Map,counter:0,set(t){let e=this.counter++;return this.store.set(e,t),e},get(t){return this.store.get(t)},delete(t){let e=this.store.get(t);return this.store.delete(t),e}};m.domRoot=(t,e="div")=>{if(t instanceof Node)return t;{let r=document.createElement(e);return r.innerHTML=t,r}};m.activateNode=(t,e="active")=>{Array.from(t.parentElement.children).forEach(r=>{r.classList.remove(e)}),t.classList.add(e)};m.compile=re;m.state=se;var w=m;typeof window<"u"&&(window.FezBase=L);typeof window<"u"&&(window.Fez=w);Promise.resolve().then(()=>oe());setInterval(()=>{for(let[t,e]of w.instances)e?.isConnected||(e.fez?.fezRemoveSelf(),w.instances.delete(t))},5e3);var Be=new MutationObserver(t=>{for(let{addedNodes:e,removedNodes:r}of t)e.forEach(s=>{s.nodeType===1&&(s.matches("template[fez], xmp[fez], script[fez]")&&(w.compile(s),s.remove()),s.querySelectorAll&&s.querySelectorAll("template[fez], xmp[fez], script[fez]").forEach(o=>{w.compile(o),o.remove()}))}),r.forEach(s=>{s.nodeType===1&&s.querySelectorAll&&s.querySelectorAll(".fez, :scope.fez").forEach(o=>{o.fez&&o.root&&(w.instances.delete(o.fez.UID),o.fez.fezRemoveSelf())})})});Be.observe(document.documentElement,{childList:!0,subtree:!0});var pt=w;})();
27
+ `);e.wrap&&(t=`:fez { ${t} }`),t=t.replace(/\:fez|\:host/,`.fez.fez-${e.name}`),r=m.cssClass(t)}return document.body?document.body.parentElement.classList.add(r):document.addEventListener("DOMContentLoaded",()=>{document.body.parentElement.classList.add(r)}),r};m.info=()=>{console.log("Fez components:",Object.keys(m.classes||{}))};m.morphdom=(r,e,t={})=>{Array.from(r.attributes).forEach(n=>{e.setAttribute(n.name,n.value)}),ee.morph(r,e,{morphStyle:"outerHTML"});let s=r.nextSibling;s?.nodeType===Node.TEXT_NODE&&s.textContent.trim()===""&&s.remove()};m.publish=(r,...e)=>{m._subs||={},m._subs[r]||=[],m._subs[r].forEach(t=>{t[1].bind(t[0])(...e)})};m.fnv1=r=>{var e,t,s,n,o,i;for(e=2166136261,t=16777619,s=e,n=o=0,i=r.length-1;0<=i?o<=i:o>=i;n=0<=i?++o:--o)s^=r.charCodeAt(n),s*=t;return s.toString(36).replaceAll("-","")};m.tag=(r,e={},t="")=>{let s=encodeURIComponent(JSON.stringify(e));return`<${r} data-props="${s}">${t}</${r}>`};m.getFunction=r=>{if(r){if(typeof r=="function")return r;if(typeof r=="string")return new Function(r)}else return()=>{}};m.error=(r,e)=>{if(r=`Fez: ${r}`,console.error(r),e)return`<span style="border: 1px solid red; font-size: 14px; padding: 3px 7px; background: #fee; border-radius: 4px;">${r}</span>`};m.log=r=>{m.LOG===!0&&(r=String(r).substring(0,180),console.log(`Fez: ${r}`))};document.addEventListener("DOMContentLoaded",()=>{m.log("Fez.LOG === true, logging enabled.")});m.untilTrue=(r,e)=>{e||=200,r()||setTimeout(()=>{m.untilTrue(r,e)},e)};m.throttle=(r,e=200)=>{let t=0,s;return function(...n){let o=Date.now();o-t>=e?(r.apply(this,n),t=o):(clearTimeout(s),s=setTimeout(()=>{r.apply(this,n),t=Date.now()},e-(o-t)))}};m.fetch=function(...r){m._fetchCache||={};let e="GET",t,s;typeof r[0]=="string"&&/^[A-Z]+$/.test(r[0])&&(e=r.shift()),t=r.shift();let n={},o=null;if(typeof r[0]=="object"&&(o=r.shift()),typeof r[0]=="function"&&(s=r.shift()),o){if(e==="GET"){let f=new URLSearchParams(o);t+=(t.includes("?")?"&":"?")+f.toString()}else if(e==="POST"){let f=new FormData;for(let[b,g]of Object.entries(o))f.append(b,g);n.body=f}}n.method=e;let i=`${e}:${t}:${JSON.stringify(n)}`;if(m._fetchCache[i]){let f=m._fetchCache[i];if(m.log(`fetch cache hit: ${e} ${t}`),s){s(f);return}return Promise.resolve(f)}m.log(`fetch live: ${e} ${t}`);let u=f=>f.headers.get("content-type")?.includes("application/json")?f.json():f.text();if(s){fetch(t,n).then(u).then(f=>{m._fetchCache[i]=f,s(f)}).catch(f=>m.onError("fetch",f));return}return fetch(t,n).then(u).then(f=>(m._fetchCache[i]=f,f))};m.onError=(r,e)=>{if(typeof r!="string")throw new Error("Fez.onError: kind must be a string");console.error(`${r}: ${e.toString()}`)};m._styleMacros={};m.styleMacro=(r,e)=>{m._styleMacros[r]=e};m.store={store:new Map,counter:0,set(r){let e=this.counter++;return this.store.set(e,r),e},get(r){return this.store.get(r)},delete(r){let e=this.store.get(r);return this.store.delete(r),e}};ne(m);m.compile=re;m.state=se;var T=m;typeof window<"u"&&(window.FezBase=_);typeof window<"u"&&(window.Fez=T);Promise.resolve().then(()=>le());setInterval(()=>{for(let[r,e]of T.instances)e?.isConnected||(e.fez?.fezOnDestroy(),T.instances.delete(r))},5e3);var qe=new MutationObserver(r=>{for(let{addedNodes:e,removedNodes:t}of r)e.forEach(s=>{s.nodeType===1&&(s.matches("template[fez], xmp[fez], script[fez]")&&(T.compile(s),s.remove()),s.querySelectorAll&&s.querySelectorAll("template[fez], xmp[fez], script[fez]").forEach(o=>{T.compile(o),o.remove()}))}),t.forEach(s=>{s.nodeType===1&&s.querySelectorAll&&s.querySelectorAll(".fez, :scope.fez").forEach(o=>{o.fez&&o.root&&(T.instances.delete(o.fez.UID),o.fez.fezOnDestroy())})})});qe.observe(document.documentElement,{childList:!0,subtree:!0});var yt=T;})();
28
28
  //# sourceMappingURL=fez.js.map