sprae 8.1.1 → 8.1.3

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.
@@ -431,7 +431,7 @@
431
431
  if (values[_signals] && !parent)
432
432
  return values;
433
433
  const initSignals = values[_signals];
434
- const isArr = Array.isArray(values), _len = a(Object.values(values).length), signals = parent ? Object.create((parent = createState(parent))[_signals]) : Array.isArray(values) ? [] : {}, proto = signals.constructor.prototype;
434
+ const isArr = Array.isArray(values), _len = a(isArr ? values.length : Object.values(values).length), signals = parent ? Object.create((parent = createState(parent))[_signals]) : Array.isArray(values) ? [] : {}, proto = signals.constructor.prototype;
435
435
  if (parent)
436
436
  for (let key in parent)
437
437
  parent[key];
@@ -574,9 +574,9 @@
574
574
  let prevl = curItems?.length || 0;
575
575
  if (!srcItems)
576
576
  newItems = [];
577
- else if (typeof srcItems === "number") {
577
+ else if (typeof srcItems === "number")
578
578
  newItems = Array.from({ length: srcItems }, (_2, i2) => i2);
579
- } else if (Array.isArray(srcItems))
579
+ else if (Array.isArray(srcItems))
580
580
  newItems = srcItems;
581
581
  else if (typeof srcItems === "object") {
582
582
  keys2 = Object.keys(srcItems);
@@ -0,0 +1 @@
1
+ (()=>{function t(){throw new Error("Cycle detected")}var e=Symbol.for("preact-signals");function r(){if(l>1)l--;else{for(var t,e=!1;void 0!==a;){var r=a;for(a=void 0,u++;void 0!==r;){var i=r.o;if(r.o=void 0,r.f&=-3,!(8&r.f)&&p(r))try{r.c()}catch(r){e||(t=r,e=!0)}r=i}}if(u=0,l--,e)throw t}}function i(t){if(l>0)return t();l++;try{return t()}finally{r()}}var n=void 0,o=0;function s(t){if(o>0)return t();var e=n;n=void 0,o++;try{return t()}finally{o--,n=e}}var a=void 0,l=0,u=0,f=0;function c(t){if(void 0!==n){var e=t.n;if(void 0===e||e.t!==n)return e={i:0,S:t,p:n.s,n:void 0,t:n,e:void 0,x:void 0,r:e},void 0!==n.s&&(n.s.n=e),n.s=e,t.n=e,32&n.f&&t.S(e),e;if(-1===e.i)return e.i=0,void 0!==e.n&&(e.n.p=e.p,void 0!==e.p&&(e.p.n=e.n),e.p=n.s,e.n=void 0,n.s.n=e,n.s=e),e}}function h(t){this.v=t,this.i=0,this.n=void 0,this.t=void 0}function v(t){return new h(t)}function p(t){for(var e=t.s;void 0!==e;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function d(t){for(var e=t.s;void 0!==e;e=e.n){var r=e.S.n;if(void 0!==r&&(e.r=r),e.S.n=e,e.i=-1,void 0===e.n){t.s=e;break}}}function y(t){for(var e=t.s,r=void 0;void 0!==e;){var i=e.p;-1===e.i?(e.S.U(e),void 0!==i&&(i.n=e.n),void 0!==e.n&&(e.n.p=i)):r=e,e.S.n=e.r,void 0!==e.r&&(e.r=void 0),e=i}t.s=r}function m(t){h.call(this,void 0),this.x=t,this.s=void 0,this.g=f-1,this.f=4}function g(t){var e=t.u;if(t.u=void 0,"function"==typeof e){l++;var i=n;n=void 0;try{e()}catch(e){throw t.f&=-2,t.f|=8,b(t),e}finally{n=i,r()}}}function b(t){for(var e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,g(t)}function A(t){if(n!==this)throw new Error("Out-of-order effect");y(this),n=t,this.f&=-2,8&this.f&&b(this),r()}function w(t){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32}function S(t){var e=new w(t);try{e.c()}catch(t){throw e.d(),t}return e.d.bind(e)}h.prototype.brand=e,h.prototype.h=function(){return!0},h.prototype.S=function(t){this.t!==t&&void 0===t.e&&(t.x=this.t,void 0!==this.t&&(this.t.e=t),this.t=t)},h.prototype.U=function(t){if(void 0!==this.t){var e=t.e,r=t.x;void 0!==e&&(e.x=r,t.e=void 0),void 0!==r&&(r.e=e,t.x=void 0),t===this.t&&(this.t=r)}},h.prototype.subscribe=function(t){var e=this;return S((function(){var r=e.value,i=32&this.f;this.f&=-33;try{t(r)}finally{this.f|=i}}))},h.prototype.valueOf=function(){return this.value},h.prototype.toString=function(){return this.value+""},h.prototype.toJSON=function(){return this.value},h.prototype.peek=function(){return this.v},Object.defineProperty(h.prototype,"value",{get:function(){var t=c(this);return void 0!==t&&(t.i=this.i),this.v},set:function(e){if(n instanceof m&&function(){throw new Error("Computed cannot have side-effects")}(),e!==this.v){u>100&&t(),this.v=e,this.i++,f++,l++;try{for(var i=this.t;void 0!==i;i=i.x)i.t.N()}finally{r()}}}}),(m.prototype=new h).h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f))return!0;if(this.f&=-5,this.g===f)return!0;if(this.g=f,this.f|=1,this.i>0&&!p(this))return this.f&=-2,!0;var t=n;try{d(this),n=this;var e=this.x();(16&this.f||this.v!==e||0===this.i)&&(this.v=e,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return n=t,y(this),this.f&=-2,!0},m.prototype.S=function(t){if(void 0===this.t){this.f|=36;for(var e=this.s;void 0!==e;e=e.n)e.S.S(e)}h.prototype.S.call(this,t)},m.prototype.U=function(t){if(void 0!==this.t&&(h.prototype.U.call(this,t),void 0===this.t)){this.f&=-33;for(var e=this.s;void 0!==e;e=e.n)e.S.U(e)}},m.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;void 0!==t;t=t.x)t.t.N()}},m.prototype.peek=function(){if(this.h()||t(),16&this.f)throw this.v;return this.v},Object.defineProperty(m.prototype,"value",{get:function(){1&this.f&&t();var e=c(this);if(this.h(),void 0!==e&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),w.prototype.c=function(){var t=this.S();try{if(8&this.f)return;if(void 0===this.x)return;var e=this.x();"function"==typeof e&&(this.u=e)}finally{t()}},w.prototype.S=function(){1&this.f&&t(),this.f|=1,this.f&=-9,g(this),d(this),l++;var e=n;return n=this,A.bind(this,e)},w.prototype.N=function(){2&this.f||(this.f|=2,this.o=a,a=this)},w.prototype.d=function(){this.f|=8,1&this.f||b(this)};var k,x=Symbol.dispose||=Symbol("dispose"),O=Symbol("signals"),N=Symbol("length"),j={Array:Array,Object:Object,Number:Number,String:String,Boolean:Boolean,Date:Date,console:console,window:window,document:document,history:history,navigator:navigator,location:location,screen:screen,localStorage:localStorage,sessionStorage:sessionStorage,alert:alert,prompt:prompt,confirm:confirm,fetch:fetch,performance:performance,setTimeout:setTimeout,setInterval:setInterval,requestAnimationFrame:requestAnimationFrame};function E(t,e){if(t?.constructor!==Object&&!Array.isArray(t))return t;if(t[O]&&!e)return t;const r=t[O],n=Array.isArray(t),o=v(n?t.length:Object.values(t).length),a=e?Object.create((e=E(e))[O]):Array.isArray(t)?[]:{},l=a.constructor.prototype;if(e)for(let t in e)e[t];const u=new Proxy(t,{has:()=>!0,get(t,e){if(n){if("length"===e)return l[k]?o.peek():o.value;k=e}if(l[e])return l[e];if(e===O)return a;if(e===N)return o.value;const r=a[e]||f(e);return r?r.value:j[e]},set(t,e,r){if(n&&"length"===e)return i((()=>{for(let t=r,e=a.length;t<e;t++)delete u[t];o.value=a.length=t.length=r})),!0;let l=!1;const c=a[e]||f(e)||(l=!0,v()),h=c.peek();return r===h||(c._set?c._set(r):Array.isArray(r)&&Array.isArray(h)?s((()=>i((()=>{let i=0,n=r.length,o=t[e];for(;i<n;i++)h[i]=o[i]=r[i];h.length=n})))):c.value=E(t[e]=r)),n?e>=o.peek()&&(o.value=a.length=t.length=Number(e)+1):l&&o.value++,!0},deleteProperty(t,e){const r=a[e];if(r){const{_del:t}=r;delete r._del,delete a[e],t?.()}return delete t[e],n||o.value--,!0}});for(let e in t)a[e]=r?.[e]??f(e);function f(e){if(t.hasOwnProperty(e)){const i=Object.getOwnPropertyDescriptor(t,e);return i?.get?((a[e]=(r=i.get.bind(u),new m(r)))._set=i.set?.bind(u),a[e]):a[e]=i.value?.peek?i.value:v(E(i.value))}var r}return u}var _=Promise.prototype.then.bind(Promise.resolve()),$={},P={};$.if=(t,e,r)=>{let i=document.createTextNode(""),n=[L(t,e,":if")],o=[t],s=t;for(;(s=t.nextElementSibling)&&s.hasAttribute(":else");)s.removeAttribute(":else"),(e=s.getAttribute(":if"))?(s.removeAttribute(":if"),s.remove(),o.push(s),n.push(L(t,e,":else :if"))):(s.remove(),o.push(s),n.push((()=>1)));t.replaceWith(s=i);const a=S((()=>{let t=n.findIndex((t=>t(r)));o[t]!=s&&((s[T]||s).replaceWith(s=o[t]||i),R(s,r))}));return()=>{for(const t of o)t[x]?.();a()}};var T=Symbol(":each");$.each=(t,e,r)=>{const n=function(t){let e=/,([^,\}\]]*)(?:,([^,\}\]]*))?$/,r=t.match(/([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/);if(!r)return;let i=r[2].trim(),n=r[1].replace(/^\s*\(|\)\s*$/g,"").trim(),o=n.match(e);return o?[n.replace(e,"").trim(),o[1].trim(),i]:[n,"",i]}(e);if(!n)return q(new Error,t,e,":each");const[o,a,l]=n,u=t[T]=document.createTextNode("");t.replaceWith(u);const f=L(t,l,":each");let c,h;return S((()=>{let n,l,v=f(r),p=c?.length||0;return v?"number"==typeof v?n=Array.from({length:v},((t,e)=>e)):Array.isArray(v)?n=v:"object"==typeof v?(l=Object.keys(v),n=Object.values(v),v[N]):q(Error("Bad items value"),t,e,":each"):n=[],s((()=>i((()=>{if(c&&c[O]){let t=n.length,e=0;for(;e<t;e++)c[e]=n[e];c.length=t}else{for(let t=0;t<p;t++)h[t]?._del();c=n,h=c[O]||[],l&&(p=0)}})))),S((()=>{let e=n.length;p!==e&&s((()=>i((()=>{for(let i=p;i<e;i++){const e=l?.[i]??i,n=t.cloneNode(!0),s=E({[o]:h[i]??c[i],[a]:e},r);u.before(n),R(n,s);const{_del:f}=h[i]||={};h[i]._del=()=>{delete c[i],f?.(),n[x](),n.remove()}}p=e}))))}))})),()=>i((()=>{for(let t of h)t?._del();h.length=0,c.length=0}))},$.with=(t,e,r)=>(R(t,E(L(t,e,":with")(r),r)),t[x]),$.ref=(t,e,r)=>{r[e]=t},P.render=(t,e,r)=>{let i=L(t,e,":render")(r);i||q(new Error("Template not found"),t,e,":render");let n=i.content.cloneNode(!0);return t.replaceChildren(n),R(t,r),t[x]},P.id=(t,e,r)=>{let i=L(t,e,":id");return S((()=>{return e=i(r),t.id=e||0===e?e:"";var e}))},P.class=(t,e,r)=>{let i=L(t,e,":class"),n=t.getAttribute("class");return S((()=>{let e=i(r),o=[n];e&&("string"==typeof e?o.push(e):Array.isArray(e)?o.push(...e):o.push(...Object.entries(e).map((([t,e])=>e?t:"")))),(o=o.filter(Boolean).join(" "))?t.setAttribute("class",o):t.removeAttribute("class")}))},P.style=(t,e,r)=>{let i=L(t,e,":style"),n=t.getAttribute("style")||"";return n.endsWith(";")||(n+="; "),S((()=>{let e=i(r);"string"==typeof e?t.setAttribute("style",n+e):s((()=>{t.setAttribute("style",n);for(let r in e)"symbol"!=typeof e[r]&&t.style.setProperty(r,e[r])}))}))},P.text=(t,e,r)=>{let i=L(t,e,":text");return S((()=>{let e=i(r);t.textContent=null==e?"":e}))},P[""]=(t,e,r)=>{let i=L(t,e,":");if(i)return S((()=>{let e=i(r);for(let r in e)F(t,r.replace(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g,(t=>"-"+t.toLowerCase())),e[r])}))},P.value=(t,e,r)=>{let i,n,o=L(t,e,":value"),s="text"===t.type||""===t.type?e=>t.setAttribute("value",t.value=null==e?"":e):"TEXTAREA"===t.tagName||"text"===t.type||""===t.type?e=>(i=t.selectionStart,n=t.selectionEnd,t.setAttribute("value",t.value=null==e?"":e),i&&t.setSelectionRange(i,n)):"checkbox"===t.type?e=>(t.value=e?"on":"",F(t,"checked",e)):"select-one"===t.type?e=>{for(let e in t.options)e.removeAttribute("selected");t.value=e,t.selectedOptions[0]?.setAttribute("selected","")}:e=>t.value=e;return S((()=>{s(o(r))}))};var C=(t,e,r,i)=>{let n=i.startsWith("on")&&i.slice(2),o=L(t,e,":"+i);if(o){if(n){let e,i=S((()=>{e&&(e(),e=null);let i=o(r);i&&(e=W(t,n,i))}));return()=>(e?.(),i())}return S((()=>{F(t,i,o(r))}))}},W=(t,e,r)=>{if(!r)return;const i={evt:"",target:t,test:()=>!0};i.evt=(e.startsWith("on")?e.slice(2):e).replace(/\.(\w+)?-?([-\w]+)?/g,((t,e,r="")=>(i.test=D[e]?.(i,...r.split("-"))||i.test,"")));const{evt:n,target:o,test:s,defer:a,stop:l,prevent:u,...f}=i;a&&(r=a(r));const c=t=>s(t)&&(l&&t.stopPropagation(),u&&t.preventDefault(),r.call(o,t));return o.addEventListener(n,c,f),()=>o.removeEventListener(n,c,f)},D={prevent(t){t.prevent=!0},stop(t){t.stop=!0},once(t){t.once=!0},passive(t){t.passive=!0},capture(t){t.capture=!0},window(t){t.target=window},document(t){t.target=document},throttle(t,e){t.defer=t=>B(t,e?Number(e)||0:108)},debounce(t,e){t.defer=t=>K(t,e?Number(e)||0:108)},outside:t=>e=>{let r=t.target;return!(r.contains(e.target)||!1===e.target.isConnected||r.offsetWidth<1&&r.offsetHeight<1)},self:t=>e=>e.target===t.target,ctrl:(t,...e)=>t=>U.ctrl(t)&&e.every((e=>U[e]?U[e](t):t.key===e)),shift:(t,...e)=>t=>U.shift(t)&&e.every((e=>U[e]?U[e](t):t.key===e)),alt:(t,...e)=>t=>U.alt(t)&&e.every((e=>U[e]?U[e](t):t.key===e)),meta:(t,...e)=>t=>U.meta(t)&&e.every((e=>U[e]?U[e](t):t.key===e)),arrow:t=>U.arrow,enter:t=>U.enter,escape:t=>U.escape,tab:t=>U.tab,space:t=>U.space,backspace:t=>U.backspace,delete:t=>U.delete,digit:t=>U.digit,letter:t=>U.letter,character:t=>U.character},U={ctrl:t=>t.ctrlKey||"Control"===t.key||"Ctrl"===t.key,shift:t=>t.shiftKey||"Shift"===t.key,alt:t=>t.altKey||"Alt"===t.key,meta:t=>t.metaKey||"Meta"===t.key||"Command"===t.key,arrow:t=>t.key.startsWith("Arrow"),enter:t=>"Enter"===t.key,escape:t=>t.key.startsWith("Esc"),tab:t=>"Tab"===t.key,space:t=>" "===t.key||"Space"===t.key||" "===t.key,backspace:t=>"Backspace"===t.key,delete:t=>"Delete"===t.key,digit:t=>/^\d$/.test(t.key),letter:t=>/^[a-zA-Z]$/.test(t.key),character:t=>/^\S$/.test(t.key)},B=(t,e)=>{let r,i,n=o=>{r=!0,setTimeout((()=>{if(r=!1,i)return i=!1,n(o),t(o)}),e)};return e=>r?i=!0:(n(e),t(e))},K=(t,e)=>{let r;return i=>{clearTimeout(r),r=setTimeout((()=>{r=null,t(i)}),e)}},F=(t,e,r)=>{null==r||!1===r?t.removeAttribute(e):t.setAttribute(e,!0===r?"":"number"==typeof r||"string"==typeof r?r:"")},I={};function L(t,e,r){let i=I[e];if(!i)try{i=I[e]=new Function("__scope",`with (__scope) { let __; return ${e.trim()} };`)}catch(i){return q(i,t,e,r)}return n=>{let o;try{o=i.call(t,n)}catch(i){return q(i,t,e,r)}return o}}function q(t,e,r,i){Object.assign(t,{element:e,expression:r}),console.warn(`∴ ${t.message}\n\n${i}=${r?`"${r}"\n\n`:""}`,e),_((()=>{throw t}),0)}R.globals=j;var M=new WeakMap;function R(t,e){if(!t.children)return;if(M.has(t))return i((()=>Object.assign(M.get(t),e)));const r=E(e||{}),n=[],o=(t,e=t.parentNode)=>{for(let i in $){let o=":"+i;if(t.hasAttribute?.(o)){let s=t.getAttribute(o);if(t.removeAttribute(o),n.push($[i](t,s,r,i)),M.has(t))return;if(t.parentNode!==e)return!1}}if(t.attributes)for(let e=0;e<t.attributes.length;){let i=t.attributes[e],o=i.name[0];if(":"===o||"@"===o){t.removeAttribute(i.name);let e="@"===o?`${i.value.includes("await")?"async":""} event=>{${i.value}}`:i.value,s=i.name.slice(1).split(o);for(let i of s){"@"===o&&(i="on"+i);let s=P[i]||C;n.push(s(t,e,r,i))}}else e++}for(let e,r=0;e=t.children[r];r++)!1===o(e,t)&&r--};return o(t),M.has(t)||(M.set(t,r),n.length&&Object.defineProperty(t,x,{value:()=>{for(;n.length;)n.shift()?.();M.delete(t)}})),r}document.currentScript&&R(document.documentElement)})();
@@ -430,7 +430,7 @@ function createState(values, parent) {
430
430
  if (values[_signals] && !parent)
431
431
  return values;
432
432
  const initSignals = values[_signals];
433
- const isArr = Array.isArray(values), _len = a(Object.values(values).length), signals = parent ? Object.create((parent = createState(parent))[_signals]) : Array.isArray(values) ? [] : {}, proto = signals.constructor.prototype;
433
+ const isArr = Array.isArray(values), _len = a(isArr ? values.length : Object.values(values).length), signals = parent ? Object.create((parent = createState(parent))[_signals]) : Array.isArray(values) ? [] : {}, proto = signals.constructor.prototype;
434
434
  if (parent)
435
435
  for (let key in parent)
436
436
  parent[key];
@@ -573,9 +573,9 @@ primary["each"] = (tpl, expr, state) => {
573
573
  let prevl = curItems?.length || 0;
574
574
  if (!srcItems)
575
575
  newItems = [];
576
- else if (typeof srcItems === "number") {
576
+ else if (typeof srcItems === "number")
577
577
  newItems = Array.from({ length: srcItems }, (_2, i2) => i2);
578
- } else if (Array.isArray(srcItems))
578
+ else if (Array.isArray(srcItems))
579
579
  newItems = srcItems;
580
580
  else if (typeof srcItems === "object") {
581
581
  keys2 = Object.keys(srcItems);
@@ -0,0 +1 @@
1
+ function t(){throw new Error("Cycle detected")}var e=Symbol.for("preact-signals");function r(){if(l>1)l--;else{for(var t,e=!1;void 0!==a;){var r=a;for(a=void 0,u++;void 0!==r;){var i=r.o;if(r.o=void 0,r.f&=-3,!(8&r.f)&&p(r))try{r.c()}catch(r){e||(t=r,e=!0)}r=i}}if(u=0,l--,e)throw t}}function i(t){if(l>0)return t();l++;try{return t()}finally{r()}}var n=void 0,o=0;function s(t){if(o>0)return t();var e=n;n=void 0,o++;try{return t()}finally{o--,n=e}}var a=void 0,l=0,u=0,f=0;function c(t){if(void 0!==n){var e=t.n;if(void 0===e||e.t!==n)return e={i:0,S:t,p:n.s,n:void 0,t:n,e:void 0,x:void 0,r:e},void 0!==n.s&&(n.s.n=e),n.s=e,t.n=e,32&n.f&&t.S(e),e;if(-1===e.i)return e.i=0,void 0!==e.n&&(e.n.p=e.p,void 0!==e.p&&(e.p.n=e.n),e.p=n.s,e.n=void 0,n.s.n=e,n.s=e),e}}function h(t){this.v=t,this.i=0,this.n=void 0,this.t=void 0}function v(t){return new h(t)}function p(t){for(var e=t.s;void 0!==e;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function d(t){for(var e=t.s;void 0!==e;e=e.n){var r=e.S.n;if(void 0!==r&&(e.r=r),e.S.n=e,e.i=-1,void 0===e.n){t.s=e;break}}}function y(t){for(var e=t.s,r=void 0;void 0!==e;){var i=e.p;-1===e.i?(e.S.U(e),void 0!==i&&(i.n=e.n),void 0!==e.n&&(e.n.p=i)):r=e,e.S.n=e.r,void 0!==e.r&&(e.r=void 0),e=i}t.s=r}function m(t){h.call(this,void 0),this.x=t,this.s=void 0,this.g=f-1,this.f=4}function g(t){var e=t.u;if(t.u=void 0,"function"==typeof e){l++;var i=n;n=void 0;try{e()}catch(e){throw t.f&=-2,t.f|=8,b(t),e}finally{n=i,r()}}}function b(t){for(var e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,g(t)}function A(t){if(n!==this)throw new Error("Out-of-order effect");y(this),n=t,this.f&=-2,8&this.f&&b(this),r()}function w(t){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32}function S(t){var e=new w(t);try{e.c()}catch(t){throw e.d(),t}return e.d.bind(e)}h.prototype.brand=e,h.prototype.h=function(){return!0},h.prototype.S=function(t){this.t!==t&&void 0===t.e&&(t.x=this.t,void 0!==this.t&&(this.t.e=t),this.t=t)},h.prototype.U=function(t){if(void 0!==this.t){var e=t.e,r=t.x;void 0!==e&&(e.x=r,t.e=void 0),void 0!==r&&(r.e=e,t.x=void 0),t===this.t&&(this.t=r)}},h.prototype.subscribe=function(t){var e=this;return S((function(){var r=e.value,i=32&this.f;this.f&=-33;try{t(r)}finally{this.f|=i}}))},h.prototype.valueOf=function(){return this.value},h.prototype.toString=function(){return this.value+""},h.prototype.toJSON=function(){return this.value},h.prototype.peek=function(){return this.v},Object.defineProperty(h.prototype,"value",{get:function(){var t=c(this);return void 0!==t&&(t.i=this.i),this.v},set:function(e){if(n instanceof m&&function(){throw new Error("Computed cannot have side-effects")}(),e!==this.v){u>100&&t(),this.v=e,this.i++,f++,l++;try{for(var i=this.t;void 0!==i;i=i.x)i.t.N()}finally{r()}}}}),(m.prototype=new h).h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f))return!0;if(this.f&=-5,this.g===f)return!0;if(this.g=f,this.f|=1,this.i>0&&!p(this))return this.f&=-2,!0;var t=n;try{d(this),n=this;var e=this.x();(16&this.f||this.v!==e||0===this.i)&&(this.v=e,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return n=t,y(this),this.f&=-2,!0},m.prototype.S=function(t){if(void 0===this.t){this.f|=36;for(var e=this.s;void 0!==e;e=e.n)e.S.S(e)}h.prototype.S.call(this,t)},m.prototype.U=function(t){if(void 0!==this.t&&(h.prototype.U.call(this,t),void 0===this.t)){this.f&=-33;for(var e=this.s;void 0!==e;e=e.n)e.S.U(e)}},m.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;void 0!==t;t=t.x)t.t.N()}},m.prototype.peek=function(){if(this.h()||t(),16&this.f)throw this.v;return this.v},Object.defineProperty(m.prototype,"value",{get:function(){1&this.f&&t();var e=c(this);if(this.h(),void 0!==e&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),w.prototype.c=function(){var t=this.S();try{if(8&this.f)return;if(void 0===this.x)return;var e=this.x();"function"==typeof e&&(this.u=e)}finally{t()}},w.prototype.S=function(){1&this.f&&t(),this.f|=1,this.f&=-9,g(this),d(this),l++;var e=n;return n=this,A.bind(this,e)},w.prototype.N=function(){2&this.f||(this.f|=2,this.o=a,a=this)},w.prototype.d=function(){this.f|=8,1&this.f||b(this)};var k,x=Symbol.dispose||=Symbol("dispose"),O=Symbol("signals"),N=Symbol("length"),j={Array:Array,Object:Object,Number:Number,String:String,Boolean:Boolean,Date:Date,console:console,window:window,document:document,history:history,navigator:navigator,location:location,screen:screen,localStorage:localStorage,sessionStorage:sessionStorage,alert:alert,prompt:prompt,confirm:confirm,fetch:fetch,performance:performance,setTimeout:setTimeout,setInterval:setInterval,requestAnimationFrame:requestAnimationFrame};function E(t,e){if(t?.constructor!==Object&&!Array.isArray(t))return t;if(t[O]&&!e)return t;const r=t[O],n=Array.isArray(t),o=v(n?t.length:Object.values(t).length),a=e?Object.create((e=E(e))[O]):Array.isArray(t)?[]:{},l=a.constructor.prototype;if(e)for(let t in e)e[t];const u=new Proxy(t,{has:()=>!0,get(t,e){if(n){if("length"===e)return l[k]?o.peek():o.value;k=e}if(l[e])return l[e];if(e===O)return a;if(e===N)return o.value;const r=a[e]||f(e);return r?r.value:j[e]},set(t,e,r){if(n&&"length"===e)return i((()=>{for(let t=r,e=a.length;t<e;t++)delete u[t];o.value=a.length=t.length=r})),!0;let l=!1;const c=a[e]||f(e)||(l=!0,v()),h=c.peek();return r===h||(c._set?c._set(r):Array.isArray(r)&&Array.isArray(h)?s((()=>i((()=>{let i=0,n=r.length,o=t[e];for(;i<n;i++)h[i]=o[i]=r[i];h.length=n})))):c.value=E(t[e]=r)),n?e>=o.peek()&&(o.value=a.length=t.length=Number(e)+1):l&&o.value++,!0},deleteProperty(t,e){const r=a[e];if(r){const{_del:t}=r;delete r._del,delete a[e],t?.()}return delete t[e],n||o.value--,!0}});for(let e in t)a[e]=r?.[e]??f(e);function f(e){if(t.hasOwnProperty(e)){const i=Object.getOwnPropertyDescriptor(t,e);return i?.get?((a[e]=(r=i.get.bind(u),new m(r)))._set=i.set?.bind(u),a[e]):a[e]=i.value?.peek?i.value:v(E(i.value))}var r}return u}var _=Promise.prototype.then.bind(Promise.resolve()),$={},P={};$.if=(t,e,r)=>{let i=document.createTextNode(""),n=[L(t,e,":if")],o=[t],s=t;for(;(s=t.nextElementSibling)&&s.hasAttribute(":else");)s.removeAttribute(":else"),(e=s.getAttribute(":if"))?(s.removeAttribute(":if"),s.remove(),o.push(s),n.push(L(t,e,":else :if"))):(s.remove(),o.push(s),n.push((()=>1)));t.replaceWith(s=i);const a=S((()=>{let t=n.findIndex((t=>t(r)));o[t]!=s&&((s[T]||s).replaceWith(s=o[t]||i),R(s,r))}));return()=>{for(const t of o)t[x]?.();a()}};var T=Symbol(":each");$.each=(t,e,r)=>{const n=function(t){let e=/,([^,\}\]]*)(?:,([^,\}\]]*))?$/,r=t.match(/([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/);if(!r)return;let i=r[2].trim(),n=r[1].replace(/^\s*\(|\)\s*$/g,"").trim(),o=n.match(e);return o?[n.replace(e,"").trim(),o[1].trim(),i]:[n,"",i]}(e);if(!n)return q(new Error,t,e,":each");const[o,a,l]=n,u=t[T]=document.createTextNode("");t.replaceWith(u);const f=L(t,l,":each");let c,h;return S((()=>{let n,l,v=f(r),p=c?.length||0;return v?"number"==typeof v?n=Array.from({length:v},((t,e)=>e)):Array.isArray(v)?n=v:"object"==typeof v?(l=Object.keys(v),n=Object.values(v),v[N]):q(Error("Bad items value"),t,e,":each"):n=[],s((()=>i((()=>{if(c&&c[O]){let t=n.length,e=0;for(;e<t;e++)c[e]=n[e];c.length=t}else{for(let t=0;t<p;t++)h[t]?._del();c=n,h=c[O]||[],l&&(p=0)}})))),S((()=>{let e=n.length;p!==e&&s((()=>i((()=>{for(let i=p;i<e;i++){const e=l?.[i]??i,n=t.cloneNode(!0),s=E({[o]:h[i]??c[i],[a]:e},r);u.before(n),R(n,s);const{_del:f}=h[i]||={};h[i]._del=()=>{delete c[i],f?.(),n[x](),n.remove()}}p=e}))))}))})),()=>i((()=>{for(let t of h)t?._del();h.length=0,c.length=0}))},$.with=(t,e,r)=>(R(t,E(L(t,e,":with")(r),r)),t[x]),$.ref=(t,e,r)=>{r[e]=t},P.render=(t,e,r)=>{let i=L(t,e,":render")(r);i||q(new Error("Template not found"),t,e,":render");let n=i.content.cloneNode(!0);return t.replaceChildren(n),R(t,r),t[x]},P.id=(t,e,r)=>{let i=L(t,e,":id");return S((()=>{return e=i(r),t.id=e||0===e?e:"";var e}))},P.class=(t,e,r)=>{let i=L(t,e,":class"),n=t.getAttribute("class");return S((()=>{let e=i(r),o=[n];e&&("string"==typeof e?o.push(e):Array.isArray(e)?o.push(...e):o.push(...Object.entries(e).map((([t,e])=>e?t:"")))),(o=o.filter(Boolean).join(" "))?t.setAttribute("class",o):t.removeAttribute("class")}))},P.style=(t,e,r)=>{let i=L(t,e,":style"),n=t.getAttribute("style")||"";return n.endsWith(";")||(n+="; "),S((()=>{let e=i(r);"string"==typeof e?t.setAttribute("style",n+e):s((()=>{t.setAttribute("style",n);for(let r in e)"symbol"!=typeof e[r]&&t.style.setProperty(r,e[r])}))}))},P.text=(t,e,r)=>{let i=L(t,e,":text");return S((()=>{let e=i(r);t.textContent=null==e?"":e}))},P[""]=(t,e,r)=>{let i=L(t,e,":");if(i)return S((()=>{let e=i(r);for(let r in e)F(t,r.replace(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g,(t=>"-"+t.toLowerCase())),e[r])}))},P.value=(t,e,r)=>{let i,n,o=L(t,e,":value"),s="text"===t.type||""===t.type?e=>t.setAttribute("value",t.value=null==e?"":e):"TEXTAREA"===t.tagName||"text"===t.type||""===t.type?e=>(i=t.selectionStart,n=t.selectionEnd,t.setAttribute("value",t.value=null==e?"":e),i&&t.setSelectionRange(i,n)):"checkbox"===t.type?e=>(t.value=e?"on":"",F(t,"checked",e)):"select-one"===t.type?e=>{for(let e in t.options)e.removeAttribute("selected");t.value=e,t.selectedOptions[0]?.setAttribute("selected","")}:e=>t.value=e;return S((()=>{s(o(r))}))};var C=(t,e,r,i)=>{let n=i.startsWith("on")&&i.slice(2),o=L(t,e,":"+i);if(o){if(n){let e,i=S((()=>{e&&(e(),e=null);let i=o(r);i&&(e=W(t,n,i))}));return()=>(e?.(),i())}return S((()=>{F(t,i,o(r))}))}},W=(t,e,r)=>{if(!r)return;const i={evt:"",target:t,test:()=>!0};i.evt=(e.startsWith("on")?e.slice(2):e).replace(/\.(\w+)?-?([-\w]+)?/g,((t,e,r="")=>(i.test=D[e]?.(i,...r.split("-"))||i.test,"")));const{evt:n,target:o,test:s,defer:a,stop:l,prevent:u,...f}=i;a&&(r=a(r));const c=t=>s(t)&&(l&&t.stopPropagation(),u&&t.preventDefault(),r.call(o,t));return o.addEventListener(n,c,f),()=>o.removeEventListener(n,c,f)},D={prevent(t){t.prevent=!0},stop(t){t.stop=!0},once(t){t.once=!0},passive(t){t.passive=!0},capture(t){t.capture=!0},window(t){t.target=window},document(t){t.target=document},throttle(t,e){t.defer=t=>B(t,e?Number(e)||0:108)},debounce(t,e){t.defer=t=>K(t,e?Number(e)||0:108)},outside:t=>e=>{let r=t.target;return!(r.contains(e.target)||!1===e.target.isConnected||r.offsetWidth<1&&r.offsetHeight<1)},self:t=>e=>e.target===t.target,ctrl:(t,...e)=>t=>U.ctrl(t)&&e.every((e=>U[e]?U[e](t):t.key===e)),shift:(t,...e)=>t=>U.shift(t)&&e.every((e=>U[e]?U[e](t):t.key===e)),alt:(t,...e)=>t=>U.alt(t)&&e.every((e=>U[e]?U[e](t):t.key===e)),meta:(t,...e)=>t=>U.meta(t)&&e.every((e=>U[e]?U[e](t):t.key===e)),arrow:t=>U.arrow,enter:t=>U.enter,escape:t=>U.escape,tab:t=>U.tab,space:t=>U.space,backspace:t=>U.backspace,delete:t=>U.delete,digit:t=>U.digit,letter:t=>U.letter,character:t=>U.character},U={ctrl:t=>t.ctrlKey||"Control"===t.key||"Ctrl"===t.key,shift:t=>t.shiftKey||"Shift"===t.key,alt:t=>t.altKey||"Alt"===t.key,meta:t=>t.metaKey||"Meta"===t.key||"Command"===t.key,arrow:t=>t.key.startsWith("Arrow"),enter:t=>"Enter"===t.key,escape:t=>t.key.startsWith("Esc"),tab:t=>"Tab"===t.key,space:t=>" "===t.key||"Space"===t.key||" "===t.key,backspace:t=>"Backspace"===t.key,delete:t=>"Delete"===t.key,digit:t=>/^\d$/.test(t.key),letter:t=>/^[a-zA-Z]$/.test(t.key),character:t=>/^\S$/.test(t.key)},B=(t,e)=>{let r,i,n=o=>{r=!0,setTimeout((()=>{if(r=!1,i)return i=!1,n(o),t(o)}),e)};return e=>r?i=!0:(n(e),t(e))},K=(t,e)=>{let r;return i=>{clearTimeout(r),r=setTimeout((()=>{r=null,t(i)}),e)}},F=(t,e,r)=>{null==r||!1===r?t.removeAttribute(e):t.setAttribute(e,!0===r?"":"number"==typeof r||"string"==typeof r?r:"")},I={};function L(t,e,r){let i=I[e];if(!i)try{i=I[e]=new Function("__scope",`with (__scope) { let __; return ${e.trim()} };`)}catch(i){return q(i,t,e,r)}return n=>{let o;try{o=i.call(t,n)}catch(i){return q(i,t,e,r)}return o}}function q(t,e,r,i){Object.assign(t,{element:e,expression:r}),console.warn(`∴ ${t.message}\n\n${i}=${r?`"${r}"\n\n`:""}`,e),_((()=>{throw t}),0)}R.globals=j;var M=new WeakMap;function R(t,e){if(!t.children)return;if(M.has(t))return i((()=>Object.assign(M.get(t),e)));const r=E(e||{}),n=[],o=(t,e=t.parentNode)=>{for(let i in $){let o=":"+i;if(t.hasAttribute?.(o)){let s=t.getAttribute(o);if(t.removeAttribute(o),n.push($[i](t,s,r,i)),M.has(t))return;if(t.parentNode!==e)return!1}}if(t.attributes)for(let e=0;e<t.attributes.length;){let i=t.attributes[e],o=i.name[0];if(":"===o||"@"===o){t.removeAttribute(i.name);let e="@"===o?`${i.value.includes("await")?"async":""} event=>{${i.value}}`:i.value,s=i.name.slice(1).split(o);for(let i of s){"@"===o&&(i="on"+i);let s=P[i]||C;n.push(s(t,e,r,i))}}else e++}for(let e,r=0;e=t.children[r];r++)!1===o(e,t)&&r--};return o(t),M.has(t)||(M.set(t,r),n.length&&Object.defineProperty(t,x,{value:()=>{for(;n.length;)n.shift()?.();M.delete(t)}})),r}var Z=R;document.currentScript&&R(document.documentElement);export{Z as default};
package/package.json CHANGED
@@ -1,15 +1,12 @@
1
1
  {
2
2
  "name": "sprae",
3
3
  "description": "DOM microhydration.",
4
- "version": "8.1.1",
4
+ "version": "8.1.3",
5
5
  "main": "src/index.js",
6
6
  "module": "src/index.js",
7
7
  "type": "module",
8
8
  "files": [
9
- "sprae.auto.js",
10
- "sprae.auto.min.js",
11
- "sprae.js",
12
- "sprae.min.js",
9
+ "dist",
13
10
  "src"
14
11
  ],
15
12
  "dependencies": {
@@ -29,10 +26,10 @@
29
26
  "scripts": {
30
27
  "test": "node -r ./test/register.cjs test/test.js",
31
28
  "build": "npm run build-esm && npm run build-iife && npm run min",
32
- "build-esm": "esbuild --bundle ./src/index.js --outfile=sprae.js --format=esm",
33
- "build-iife": "esbuild --bundle ./src/index.js --outfile=sprae.auto.js --format=iife",
34
- "watch": "esbuild --bundle ./src/index.js --outfile=sprae.js --format=esm --sourcemap --watch",
35
- "min": "terser sprae.js -o sprae.min.js --module -c passes=3 -m && terser sprae.auto.js -o sprae.auto.min.js --module -c passes=3 -m"
29
+ "build-esm": "esbuild --bundle ./src/index.js --outfile=./dist/sprae.js --format=esm",
30
+ "build-iife": "esbuild --bundle ./src/index.js --outfile=./dist/sprae.auto.js --format=iife",
31
+ "watch": "esbuild --bundle ./src/index.js --outfile=./dist/sprae.js --format=esm --sourcemap --watch",
32
+ "min": "terser ./dist/sprae.js -o ./dist/sprae.min.js --module -c passes=3 -m && terser ./dist/sprae.auto.js -o ./dist/sprae.auto.min.js --module -c passes=3 -m"
36
33
  },
37
34
  "repository": {
38
35
  "type": "git",
package/readme.md CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  > DOM tree hydration with reactivity.
4
4
 
5
- _Sprae_ is compact ergonomic[*](#justification--alternatives) progressive enhancement framework.<br/>
5
+ _Sprae_ is compact ergonomic progressive enhancement framework.<br/>
6
6
  It provides reactive `:`-attributes that enable simple markup logic without need for complex scripts.<br/>
7
7
  Perfect for small-scale websites, prototypes or UI logic.<br/>
8
- It is tiny and performant alternative to [alpine](https://github.com/alpinejs/alpine), [petite-vue](https://github.com/vuejs/petite-vue) or [template-parts](https://github.com/github/template-parts).
8
+ It is tiny, performant and open alternative to [alpine](https://github.com/alpinejs/alpine), [petite-vue](https://github.com/vuejs/petite-vue) or [template-parts](https://github.com/github/template-parts).
9
9
 
10
10
  ## Usage
11
11
 
@@ -14,7 +14,7 @@ It is tiny and performant alternative to [alpine](https://github.com/alpinejs/al
14
14
  To autoinit document, include [`sprae.auto.js`](./sprae.auto.js):
15
15
 
16
16
  ```html
17
- <!-- <script src="https://cdn.jsdelivr.net/npm/sprae/sprae.auto.js" defer></script> -->
17
+ <!-- <script src="https://cdn.jsdelivr.net/npm/sprae/dist/sprae.auto.js" defer></script> -->
18
18
  <script defer src="./path/to/sprae.auto.js"></script>
19
19
 
20
20
  <ul>
@@ -34,7 +34,7 @@ To init manually as module, import [`sprae.js`](./sprae.js):
34
34
  </div>
35
35
 
36
36
  <script type="module">
37
- // import sprae from 'https://cdn.jsdelivr.net/npm/sprae/sprae.js';
37
+ // import sprae from 'https://cdn.jsdelivr.net/npm/sprae/dist/sprae.js';
38
38
  import sprae from './path/to/sprae.js';
39
39
 
40
40
  const state = sprae(container, { user: { name: 'Dmitry Ivanov' } });
@@ -50,6 +50,8 @@ Sprae creates reactive state that mirrors current DOM values.<br/>
50
50
  It is based on [signals](https://github.com/preactjs/signals) and can take them as inputs.
51
51
 
52
52
  ```js
53
+ import { signal } from '@preact/signals-core'
54
+
53
55
  const version = signal('alpha')
54
56
 
55
57
  // Sprae container with initial state values
@@ -282,6 +284,12 @@ To destroy state and detach sprae handlers, call `element[Symbol.dispose]()`.
282
284
 
283
285
  See [js-framework-benchmark](https://krausest.github.io/js-framework-benchmark/current.html#eyJmcmFtZXdvcmtzIjpbIm5vbi1rZXllZC9wZXRpdGUtdnVlIiwibm9uLWtleWVkL3NwcmFlIl0sImJlbmNobWFya3MiOlsiMDFfcnVuMWsiLCIwMl9yZXBsYWNlMWsiLCIwM191cGRhdGUxMHRoMWtfeDE2IiwiMDRfc2VsZWN0MWsiLCIwNV9zd2FwMWsiLCIwNl9yZW1vdmUtb25lLTFrIiwiMDdfY3JlYXRlMTBrIiwiMDhfY3JlYXRlMWstYWZ0ZXIxa194MiIsIjA5X2NsZWFyMWtfeDgiLCIyMV9yZWFkeS1tZW1vcnkiLCIyMl9ydW4tbWVtb3J5IiwiMjNfdXBkYXRlNS1tZW1vcnkiLCIyNV9ydW4tY2xlYXItbWVtb3J5IiwiMjZfcnVuLTEway1tZW1vcnkiLCIzMV9zdGFydHVwLWNpIiwiMzRfc3RhcnR1cC10b3RhbGJ5dGVzIiwiNDFfc2l6ZS11bmNvbXByZXNzZWQiLCI0Ml9zaXplLWNvbXByZXNzZWQiXSwiZGlzcGxheU1vZGUiOjF9).
284
286
 
287
+ <details>
288
+ <summary>Results table</summary>
289
+
290
+ ![Benchmark](./bench.png)
291
+ </details>
292
+
285
293
  <details>
286
294
  <summary>How to run</summary>
287
295
 
@@ -292,7 +300,7 @@ npm run install-server
292
300
  npm start
293
301
 
294
302
  # build
295
- cd frameworks/keyed/sprae
303
+ cd frameworks/non-keyed/sprae
296
304
  npm ci
297
305
  npm run build-prod
298
306
 
package/src/directives.js CHANGED
@@ -76,9 +76,7 @@ primary['each'] = (tpl, expr, state) => {
76
76
 
77
77
  // convert items to array
78
78
  if (!srcItems) newItems = []
79
- else if (typeof srcItems === 'number') {
80
- newItems = Array.from({ length: srcItems }, (_, i) => i)
81
- }
79
+ else if (typeof srcItems === 'number') newItems = Array.from({ length: srcItems }, (_, i) => i)
82
80
  else if (Array.isArray(srcItems)) newItems = srcItems;
83
81
  else if (typeof srcItems === 'object') {
84
82
  keys = Object.keys(srcItems);
@@ -40,7 +40,7 @@ export default function createState(values, parent) {
40
40
 
41
41
  // .length signal is stored outside, since it cannot be replaced
42
42
  // _len stores total values length (for objects as well)
43
- const isArr = Array.isArray(values), _len = signal(Object.values(values).length),
43
+ const isArr = Array.isArray(values), _len = signal(isArr ? values.length : Object.values(values).length),
44
44
  // dict with signals storing values
45
45
  signals = parent ? Object.create((parent = createState(parent))[_signals]) : Array.isArray(values) ? [] : {},
46
46
  proto = signals.constructor.prototype;
package/sprae.auto.min.js DELETED
@@ -1 +0,0 @@
1
- (()=>{function t(){throw new Error("Cycle detected")}var e=Symbol.for("preact-signals");function r(){if(l>1)l--;else{for(var t,e=!1;void 0!==a;){var r=a;for(a=void 0,u++;void 0!==r;){var i=r.o;if(r.o=void 0,r.f&=-3,!(8&r.f)&&p(r))try{r.c()}catch(r){e||(t=r,e=!0)}r=i}}if(u=0,l--,e)throw t}}function i(t){if(l>0)return t();l++;try{return t()}finally{r()}}var n=void 0,o=0;function s(t){if(o>0)return t();var e=n;n=void 0,o++;try{return t()}finally{o--,n=e}}var a=void 0,l=0,u=0,f=0;function c(t){if(void 0!==n){var e=t.n;if(void 0===e||e.t!==n)return e={i:0,S:t,p:n.s,n:void 0,t:n,e:void 0,x:void 0,r:e},void 0!==n.s&&(n.s.n=e),n.s=e,t.n=e,32&n.f&&t.S(e),e;if(-1===e.i)return e.i=0,void 0!==e.n&&(e.n.p=e.p,void 0!==e.p&&(e.p.n=e.n),e.p=n.s,e.n=void 0,n.s.n=e,n.s=e),e}}function h(t){this.v=t,this.i=0,this.n=void 0,this.t=void 0}function v(t){return new h(t)}function p(t){for(var e=t.s;void 0!==e;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function d(t){for(var e=t.s;void 0!==e;e=e.n){var r=e.S.n;if(void 0!==r&&(e.r=r),e.S.n=e,e.i=-1,void 0===e.n){t.s=e;break}}}function y(t){for(var e=t.s,r=void 0;void 0!==e;){var i=e.p;-1===e.i?(e.S.U(e),void 0!==i&&(i.n=e.n),void 0!==e.n&&(e.n.p=i)):r=e,e.S.n=e.r,void 0!==e.r&&(e.r=void 0),e=i}t.s=r}function m(t){h.call(this,void 0),this.x=t,this.s=void 0,this.g=f-1,this.f=4}function b(t){var e=t.u;if(t.u=void 0,"function"==typeof e){l++;var i=n;n=void 0;try{e()}catch(e){throw t.f&=-2,t.f|=8,g(t),e}finally{n=i,r()}}}function g(t){for(var e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,b(t)}function A(t){if(n!==this)throw new Error("Out-of-order effect");y(this),n=t,this.f&=-2,8&this.f&&g(this),r()}function w(t){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32}function S(t){var e=new w(t);try{e.c()}catch(t){throw e.d(),t}return e.d.bind(e)}h.prototype.brand=e,h.prototype.h=function(){return!0},h.prototype.S=function(t){this.t!==t&&void 0===t.e&&(t.x=this.t,void 0!==this.t&&(this.t.e=t),this.t=t)},h.prototype.U=function(t){if(void 0!==this.t){var e=t.e,r=t.x;void 0!==e&&(e.x=r,t.e=void 0),void 0!==r&&(r.e=e,t.x=void 0),t===this.t&&(this.t=r)}},h.prototype.subscribe=function(t){var e=this;return S((function(){var r=e.value,i=32&this.f;this.f&=-33;try{t(r)}finally{this.f|=i}}))},h.prototype.valueOf=function(){return this.value},h.prototype.toString=function(){return this.value+""},h.prototype.toJSON=function(){return this.value},h.prototype.peek=function(){return this.v},Object.defineProperty(h.prototype,"value",{get:function(){var t=c(this);return void 0!==t&&(t.i=this.i),this.v},set:function(e){if(n instanceof m&&function(){throw new Error("Computed cannot have side-effects")}(),e!==this.v){u>100&&t(),this.v=e,this.i++,f++,l++;try{for(var i=this.t;void 0!==i;i=i.x)i.t.N()}finally{r()}}}}),(m.prototype=new h).h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f))return!0;if(this.f&=-5,this.g===f)return!0;if(this.g=f,this.f|=1,this.i>0&&!p(this))return this.f&=-2,!0;var t=n;try{d(this),n=this;var e=this.x();(16&this.f||this.v!==e||0===this.i)&&(this.v=e,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return n=t,y(this),this.f&=-2,!0},m.prototype.S=function(t){if(void 0===this.t){this.f|=36;for(var e=this.s;void 0!==e;e=e.n)e.S.S(e)}h.prototype.S.call(this,t)},m.prototype.U=function(t){if(void 0!==this.t&&(h.prototype.U.call(this,t),void 0===this.t)){this.f&=-33;for(var e=this.s;void 0!==e;e=e.n)e.S.U(e)}},m.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;void 0!==t;t=t.x)t.t.N()}},m.prototype.peek=function(){if(this.h()||t(),16&this.f)throw this.v;return this.v},Object.defineProperty(m.prototype,"value",{get:function(){1&this.f&&t();var e=c(this);if(this.h(),void 0!==e&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),w.prototype.c=function(){var t=this.S();try{if(8&this.f)return;if(void 0===this.x)return;var e=this.x();"function"==typeof e&&(this.u=e)}finally{t()}},w.prototype.S=function(){1&this.f&&t(),this.f|=1,this.f&=-9,b(this),d(this),l++;var e=n;return n=this,A.bind(this,e)},w.prototype.N=function(){2&this.f||(this.f|=2,this.o=a,a=this)},w.prototype.d=function(){this.f|=8,1&this.f||g(this)};var k,x=Symbol.dispose||=Symbol("dispose"),O=Symbol("signals"),N=Symbol("length"),j={Array:Array,Object:Object,Number:Number,String:String,Boolean:Boolean,Date:Date,console:console,window:window,document:document,history:history,navigator:navigator,location:location,screen:screen,localStorage:localStorage,sessionStorage:sessionStorage,alert:alert,prompt:prompt,confirm:confirm,fetch:fetch,performance:performance,setTimeout:setTimeout,setInterval:setInterval,requestAnimationFrame:requestAnimationFrame};function E(t,e){if(t?.constructor!==Object&&!Array.isArray(t))return t;if(t[O]&&!e)return t;const r=t[O],n=Array.isArray(t),o=v(Object.values(t).length),a=e?Object.create((e=E(e))[O]):Array.isArray(t)?[]:{},l=a.constructor.prototype;if(e)for(let t in e)e[t];const u=new Proxy(t,{has:()=>!0,get(t,e){if(n){if("length"===e)return l[k]?o.peek():o.value;k=e}if(l[e])return l[e];if(e===O)return a;if(e===N)return o.value;const r=a[e]||f(e);return r?r.value:j[e]},set(t,e,r){if(n&&"length"===e)return i((()=>{for(let t=r,e=a.length;t<e;t++)delete u[t];o.value=a.length=t.length=r})),!0;let l=!1;const c=a[e]||f(e)||(l=!0,v()),h=c.peek();return r===h||(c._set?c._set(r):Array.isArray(r)&&Array.isArray(h)?s((()=>i((()=>{let i=0,n=r.length,o=t[e];for(;i<n;i++)h[i]=o[i]=r[i];h.length=n})))):c.value=E(t[e]=r)),n?e>=o.peek()&&(o.value=a.length=t.length=Number(e)+1):l&&o.value++,!0},deleteProperty(t,e){const r=a[e];if(r){const{_del:t}=r;delete r._del,delete a[e],t?.()}return delete t[e],n||o.value--,!0}});for(let e in t)a[e]=r?.[e]??f(e);function f(e){if(t.hasOwnProperty(e)){const i=Object.getOwnPropertyDescriptor(t,e);return i?.get?((a[e]=(r=i.get.bind(u),new m(r)))._set=i.set?.bind(u),a[e]):a[e]=i.value?.peek?i.value:v(E(i.value))}var r}return u}var _=Promise.prototype.then.bind(Promise.resolve()),$={},P={};$.if=(t,e,r)=>{let i=document.createTextNode(""),n=[L(t,e,":if")],o=[t],s=t;for(;(s=t.nextElementSibling)&&s.hasAttribute(":else");)s.removeAttribute(":else"),(e=s.getAttribute(":if"))?(s.removeAttribute(":if"),s.remove(),o.push(s),n.push(L(t,e,":else :if"))):(s.remove(),o.push(s),n.push((()=>1)));t.replaceWith(s=i);const a=S((()=>{let t=n.findIndex((t=>t(r)));o[t]!=s&&((s[T]||s).replaceWith(s=o[t]||i),R(s,r))}));return()=>{for(const t of o)t[x]?.();a()}};var T=Symbol(":each");$.each=(t,e,r)=>{const n=function(t){let e=/,([^,\}\]]*)(?:,([^,\}\]]*))?$/,r=t.match(/([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/);if(!r)return;let i=r[2].trim(),n=r[1].replace(/^\s*\(|\)\s*$/g,"").trim(),o=n.match(e);return o?[n.replace(e,"").trim(),o[1].trim(),i]:[n,"",i]}(e);if(!n)return q(new Error,t,e,":each");const[o,a,l]=n,u=t[T]=document.createTextNode("");t.replaceWith(u);const f=L(t,l,":each");let c,h;return S((()=>{let n,l,v=f(r),p=c?.length||0;return v?"number"==typeof v?n=Array.from({length:v},((t,e)=>e)):Array.isArray(v)?n=v:"object"==typeof v?(l=Object.keys(v),n=Object.values(v),v[N]):q(Error("Bad items value"),t,e,":each"):n=[],s((()=>i((()=>{if(c&&c[O]){let t=n.length,e=0;for(;e<t;e++)c[e]=n[e];c.length=t}else{for(let t=0;t<p;t++)h[t]?._del();c=n,h=c[O]||[],l&&(p=0)}})))),S((()=>{let e=n.length;p!==e&&s((()=>i((()=>{for(let i=p;i<e;i++){const e=l?.[i]??i,n=t.cloneNode(!0),s=E({[o]:h[i]??c[i],[a]:e},r);u.before(n),R(n,s);const{_del:f}=h[i]||={};h[i]._del=()=>{delete c[i],f?.(),n[x](),n.remove()}}p=e}))))}))})),()=>i((()=>{for(let t of h)t?._del();h.length=0,c.length=0}))},$.with=(t,e,r)=>(R(t,E(L(t,e,":with")(r),r)),t[x]),$.ref=(t,e,r)=>{r[e]=t},P.render=(t,e,r)=>{let i=L(t,e,":render")(r);i||q(new Error("Template not found"),t,e,":render");let n=i.content.cloneNode(!0);return t.replaceChildren(n),R(t,r),t[x]},P.id=(t,e,r)=>{let i=L(t,e,":id");return S((()=>{return e=i(r),t.id=e||0===e?e:"";var e}))},P.class=(t,e,r)=>{let i=L(t,e,":class"),n=t.getAttribute("class");return S((()=>{let e=i(r),o=[n];e&&("string"==typeof e?o.push(e):Array.isArray(e)?o.push(...e):o.push(...Object.entries(e).map((([t,e])=>e?t:"")))),(o=o.filter(Boolean).join(" "))?t.setAttribute("class",o):t.removeAttribute("class")}))},P.style=(t,e,r)=>{let i=L(t,e,":style"),n=t.getAttribute("style")||"";return n.endsWith(";")||(n+="; "),S((()=>{let e=i(r);"string"==typeof e?t.setAttribute("style",n+e):s((()=>{t.setAttribute("style",n);for(let r in e)"symbol"!=typeof e[r]&&t.style.setProperty(r,e[r])}))}))},P.text=(t,e,r)=>{let i=L(t,e,":text");return S((()=>{let e=i(r);t.textContent=null==e?"":e}))},P[""]=(t,e,r)=>{let i=L(t,e,":");if(i)return S((()=>{let e=i(r);for(let r in e)F(t,r.replace(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g,(t=>"-"+t.toLowerCase())),e[r])}))},P.value=(t,e,r)=>{let i,n,o=L(t,e,":value"),s="text"===t.type||""===t.type?e=>t.setAttribute("value",t.value=null==e?"":e):"TEXTAREA"===t.tagName||"text"===t.type||""===t.type?e=>(i=t.selectionStart,n=t.selectionEnd,t.setAttribute("value",t.value=null==e?"":e),i&&t.setSelectionRange(i,n)):"checkbox"===t.type?e=>(t.value=e?"on":"",F(t,"checked",e)):"select-one"===t.type?e=>{for(let e in t.options)e.removeAttribute("selected");t.value=e,t.selectedOptions[0]?.setAttribute("selected","")}:e=>t.value=e;return S((()=>{s(o(r))}))};var C=(t,e,r,i)=>{let n=i.startsWith("on")&&i.slice(2),o=L(t,e,":"+i);if(o){if(n){let e,i=S((()=>{e&&(e(),e=null);let i=o(r);i&&(e=W(t,n,i))}));return()=>(e?.(),i())}return S((()=>{F(t,i,o(r))}))}},W=(t,e,r)=>{if(!r)return;const i={evt:"",target:t,test:()=>!0};i.evt=(e.startsWith("on")?e.slice(2):e).replace(/\.(\w+)?-?([-\w]+)?/g,((t,e,r="")=>(i.test=D[e]?.(i,...r.split("-"))||i.test,"")));const{evt:n,target:o,test:s,defer:a,stop:l,prevent:u,...f}=i;a&&(r=a(r));const c=t=>s(t)&&(l&&t.stopPropagation(),u&&t.preventDefault(),r.call(o,t));return o.addEventListener(n,c,f),()=>o.removeEventListener(n,c,f)},D={prevent(t){t.prevent=!0},stop(t){t.stop=!0},once(t){t.once=!0},passive(t){t.passive=!0},capture(t){t.capture=!0},window(t){t.target=window},document(t){t.target=document},throttle(t,e){t.defer=t=>B(t,e?Number(e)||0:108)},debounce(t,e){t.defer=t=>K(t,e?Number(e)||0:108)},outside:t=>e=>{let r=t.target;return!(r.contains(e.target)||!1===e.target.isConnected||r.offsetWidth<1&&r.offsetHeight<1)},self:t=>e=>e.target===t.target,ctrl:(t,...e)=>t=>U.ctrl(t)&&e.every((e=>U[e]?U[e](t):t.key===e)),shift:(t,...e)=>t=>U.shift(t)&&e.every((e=>U[e]?U[e](t):t.key===e)),alt:(t,...e)=>t=>U.alt(t)&&e.every((e=>U[e]?U[e](t):t.key===e)),meta:(t,...e)=>t=>U.meta(t)&&e.every((e=>U[e]?U[e](t):t.key===e)),arrow:t=>U.arrow,enter:t=>U.enter,escape:t=>U.escape,tab:t=>U.tab,space:t=>U.space,backspace:t=>U.backspace,delete:t=>U.delete,digit:t=>U.digit,letter:t=>U.letter,character:t=>U.character},U={ctrl:t=>t.ctrlKey||"Control"===t.key||"Ctrl"===t.key,shift:t=>t.shiftKey||"Shift"===t.key,alt:t=>t.altKey||"Alt"===t.key,meta:t=>t.metaKey||"Meta"===t.key||"Command"===t.key,arrow:t=>t.key.startsWith("Arrow"),enter:t=>"Enter"===t.key,escape:t=>t.key.startsWith("Esc"),tab:t=>"Tab"===t.key,space:t=>" "===t.key||"Space"===t.key||" "===t.key,backspace:t=>"Backspace"===t.key,delete:t=>"Delete"===t.key,digit:t=>/^\d$/.test(t.key),letter:t=>/^[a-zA-Z]$/.test(t.key),character:t=>/^\S$/.test(t.key)},B=(t,e)=>{let r,i,n=o=>{r=!0,setTimeout((()=>{if(r=!1,i)return i=!1,n(o),t(o)}),e)};return e=>r?i=!0:(n(e),t(e))},K=(t,e)=>{let r;return i=>{clearTimeout(r),r=setTimeout((()=>{r=null,t(i)}),e)}},F=(t,e,r)=>{null==r||!1===r?t.removeAttribute(e):t.setAttribute(e,!0===r?"":"number"==typeof r||"string"==typeof r?r:"")},I={};function L(t,e,r){let i=I[e];if(!i)try{i=I[e]=new Function("__scope",`with (__scope) { let __; return ${e.trim()} };`)}catch(i){return q(i,t,e,r)}return n=>{let o;try{o=i.call(t,n)}catch(i){return q(i,t,e,r)}return o}}function q(t,e,r,i){Object.assign(t,{element:e,expression:r}),console.warn(`∴ ${t.message}\n\n${i}=${r?`"${r}"\n\n`:""}`,e),_((()=>{throw t}),0)}R.globals=j;var M=new WeakMap;function R(t,e){if(!t.children)return;if(M.has(t))return i((()=>Object.assign(M.get(t),e)));const r=E(e||{}),n=[],o=(t,e=t.parentNode)=>{for(let i in $){let o=":"+i;if(t.hasAttribute?.(o)){let s=t.getAttribute(o);if(t.removeAttribute(o),n.push($[i](t,s,r,i)),M.has(t))return;if(t.parentNode!==e)return!1}}if(t.attributes)for(let e=0;e<t.attributes.length;){let i=t.attributes[e],o=i.name[0];if(":"===o||"@"===o){t.removeAttribute(i.name);let e="@"===o?`${i.value.includes("await")?"async":""} event=>{${i.value}}`:i.value,s=i.name.slice(1).split(o);for(let i of s){"@"===o&&(i="on"+i);let s=P[i]||C;n.push(s(t,e,r,i))}}else e++}for(let e,r=0;e=t.children[r];r++)!1===o(e,t)&&r--};return o(t),M.has(t)||(M.set(t,r),n.length&&Object.defineProperty(t,x,{value:()=>{for(;n.length;)n.shift()?.();M.delete(t)}})),r}document.currentScript&&R(document.documentElement)})();
package/sprae.min.js DELETED
@@ -1 +0,0 @@
1
- function t(){throw new Error("Cycle detected")}var e=Symbol.for("preact-signals");function r(){if(l>1)l--;else{for(var t,e=!1;void 0!==a;){var r=a;for(a=void 0,u++;void 0!==r;){var i=r.o;if(r.o=void 0,r.f&=-3,!(8&r.f)&&p(r))try{r.c()}catch(r){e||(t=r,e=!0)}r=i}}if(u=0,l--,e)throw t}}function i(t){if(l>0)return t();l++;try{return t()}finally{r()}}var n=void 0,o=0;function s(t){if(o>0)return t();var e=n;n=void 0,o++;try{return t()}finally{o--,n=e}}var a=void 0,l=0,u=0,f=0;function c(t){if(void 0!==n){var e=t.n;if(void 0===e||e.t!==n)return e={i:0,S:t,p:n.s,n:void 0,t:n,e:void 0,x:void 0,r:e},void 0!==n.s&&(n.s.n=e),n.s=e,t.n=e,32&n.f&&t.S(e),e;if(-1===e.i)return e.i=0,void 0!==e.n&&(e.n.p=e.p,void 0!==e.p&&(e.p.n=e.n),e.p=n.s,e.n=void 0,n.s.n=e,n.s=e),e}}function h(t){this.v=t,this.i=0,this.n=void 0,this.t=void 0}function v(t){return new h(t)}function p(t){for(var e=t.s;void 0!==e;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function d(t){for(var e=t.s;void 0!==e;e=e.n){var r=e.S.n;if(void 0!==r&&(e.r=r),e.S.n=e,e.i=-1,void 0===e.n){t.s=e;break}}}function y(t){for(var e=t.s,r=void 0;void 0!==e;){var i=e.p;-1===e.i?(e.S.U(e),void 0!==i&&(i.n=e.n),void 0!==e.n&&(e.n.p=i)):r=e,e.S.n=e.r,void 0!==e.r&&(e.r=void 0),e=i}t.s=r}function m(t){h.call(this,void 0),this.x=t,this.s=void 0,this.g=f-1,this.f=4}function b(t){var e=t.u;if(t.u=void 0,"function"==typeof e){l++;var i=n;n=void 0;try{e()}catch(e){throw t.f&=-2,t.f|=8,g(t),e}finally{n=i,r()}}}function g(t){for(var e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,b(t)}function A(t){if(n!==this)throw new Error("Out-of-order effect");y(this),n=t,this.f&=-2,8&this.f&&g(this),r()}function w(t){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32}function S(t){var e=new w(t);try{e.c()}catch(t){throw e.d(),t}return e.d.bind(e)}h.prototype.brand=e,h.prototype.h=function(){return!0},h.prototype.S=function(t){this.t!==t&&void 0===t.e&&(t.x=this.t,void 0!==this.t&&(this.t.e=t),this.t=t)},h.prototype.U=function(t){if(void 0!==this.t){var e=t.e,r=t.x;void 0!==e&&(e.x=r,t.e=void 0),void 0!==r&&(r.e=e,t.x=void 0),t===this.t&&(this.t=r)}},h.prototype.subscribe=function(t){var e=this;return S((function(){var r=e.value,i=32&this.f;this.f&=-33;try{t(r)}finally{this.f|=i}}))},h.prototype.valueOf=function(){return this.value},h.prototype.toString=function(){return this.value+""},h.prototype.toJSON=function(){return this.value},h.prototype.peek=function(){return this.v},Object.defineProperty(h.prototype,"value",{get:function(){var t=c(this);return void 0!==t&&(t.i=this.i),this.v},set:function(e){if(n instanceof m&&function(){throw new Error("Computed cannot have side-effects")}(),e!==this.v){u>100&&t(),this.v=e,this.i++,f++,l++;try{for(var i=this.t;void 0!==i;i=i.x)i.t.N()}finally{r()}}}}),(m.prototype=new h).h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f))return!0;if(this.f&=-5,this.g===f)return!0;if(this.g=f,this.f|=1,this.i>0&&!p(this))return this.f&=-2,!0;var t=n;try{d(this),n=this;var e=this.x();(16&this.f||this.v!==e||0===this.i)&&(this.v=e,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return n=t,y(this),this.f&=-2,!0},m.prototype.S=function(t){if(void 0===this.t){this.f|=36;for(var e=this.s;void 0!==e;e=e.n)e.S.S(e)}h.prototype.S.call(this,t)},m.prototype.U=function(t){if(void 0!==this.t&&(h.prototype.U.call(this,t),void 0===this.t)){this.f&=-33;for(var e=this.s;void 0!==e;e=e.n)e.S.U(e)}},m.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;void 0!==t;t=t.x)t.t.N()}},m.prototype.peek=function(){if(this.h()||t(),16&this.f)throw this.v;return this.v},Object.defineProperty(m.prototype,"value",{get:function(){1&this.f&&t();var e=c(this);if(this.h(),void 0!==e&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),w.prototype.c=function(){var t=this.S();try{if(8&this.f)return;if(void 0===this.x)return;var e=this.x();"function"==typeof e&&(this.u=e)}finally{t()}},w.prototype.S=function(){1&this.f&&t(),this.f|=1,this.f&=-9,b(this),d(this),l++;var e=n;return n=this,A.bind(this,e)},w.prototype.N=function(){2&this.f||(this.f|=2,this.o=a,a=this)},w.prototype.d=function(){this.f|=8,1&this.f||g(this)};var k,x=Symbol.dispose||=Symbol("dispose"),O=Symbol("signals"),N=Symbol("length"),j={Array:Array,Object:Object,Number:Number,String:String,Boolean:Boolean,Date:Date,console:console,window:window,document:document,history:history,navigator:navigator,location:location,screen:screen,localStorage:localStorage,sessionStorage:sessionStorage,alert:alert,prompt:prompt,confirm:confirm,fetch:fetch,performance:performance,setTimeout:setTimeout,setInterval:setInterval,requestAnimationFrame:requestAnimationFrame};function E(t,e){if(t?.constructor!==Object&&!Array.isArray(t))return t;if(t[O]&&!e)return t;const r=t[O],n=Array.isArray(t),o=v(Object.values(t).length),a=e?Object.create((e=E(e))[O]):Array.isArray(t)?[]:{},l=a.constructor.prototype;if(e)for(let t in e)e[t];const u=new Proxy(t,{has:()=>!0,get(t,e){if(n){if("length"===e)return l[k]?o.peek():o.value;k=e}if(l[e])return l[e];if(e===O)return a;if(e===N)return o.value;const r=a[e]||f(e);return r?r.value:j[e]},set(t,e,r){if(n&&"length"===e)return i((()=>{for(let t=r,e=a.length;t<e;t++)delete u[t];o.value=a.length=t.length=r})),!0;let l=!1;const c=a[e]||f(e)||(l=!0,v()),h=c.peek();return r===h||(c._set?c._set(r):Array.isArray(r)&&Array.isArray(h)?s((()=>i((()=>{let i=0,n=r.length,o=t[e];for(;i<n;i++)h[i]=o[i]=r[i];h.length=n})))):c.value=E(t[e]=r)),n?e>=o.peek()&&(o.value=a.length=t.length=Number(e)+1):l&&o.value++,!0},deleteProperty(t,e){const r=a[e];if(r){const{_del:t}=r;delete r._del,delete a[e],t?.()}return delete t[e],n||o.value--,!0}});for(let e in t)a[e]=r?.[e]??f(e);function f(e){if(t.hasOwnProperty(e)){const i=Object.getOwnPropertyDescriptor(t,e);return i?.get?((a[e]=(r=i.get.bind(u),new m(r)))._set=i.set?.bind(u),a[e]):a[e]=i.value?.peek?i.value:v(E(i.value))}var r}return u}var _=Promise.prototype.then.bind(Promise.resolve()),$={},P={};$.if=(t,e,r)=>{let i=document.createTextNode(""),n=[L(t,e,":if")],o=[t],s=t;for(;(s=t.nextElementSibling)&&s.hasAttribute(":else");)s.removeAttribute(":else"),(e=s.getAttribute(":if"))?(s.removeAttribute(":if"),s.remove(),o.push(s),n.push(L(t,e,":else :if"))):(s.remove(),o.push(s),n.push((()=>1)));t.replaceWith(s=i);const a=S((()=>{let t=n.findIndex((t=>t(r)));o[t]!=s&&((s[T]||s).replaceWith(s=o[t]||i),R(s,r))}));return()=>{for(const t of o)t[x]?.();a()}};var T=Symbol(":each");$.each=(t,e,r)=>{const n=function(t){let e=/,([^,\}\]]*)(?:,([^,\}\]]*))?$/,r=t.match(/([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/);if(!r)return;let i=r[2].trim(),n=r[1].replace(/^\s*\(|\)\s*$/g,"").trim(),o=n.match(e);return o?[n.replace(e,"").trim(),o[1].trim(),i]:[n,"",i]}(e);if(!n)return q(new Error,t,e,":each");const[o,a,l]=n,u=t[T]=document.createTextNode("");t.replaceWith(u);const f=L(t,l,":each");let c,h;return S((()=>{let n,l,v=f(r),p=c?.length||0;return v?"number"==typeof v?n=Array.from({length:v},((t,e)=>e)):Array.isArray(v)?n=v:"object"==typeof v?(l=Object.keys(v),n=Object.values(v),v[N]):q(Error("Bad items value"),t,e,":each"):n=[],s((()=>i((()=>{if(c&&c[O]){let t=n.length,e=0;for(;e<t;e++)c[e]=n[e];c.length=t}else{for(let t=0;t<p;t++)h[t]?._del();c=n,h=c[O]||[],l&&(p=0)}})))),S((()=>{let e=n.length;p!==e&&s((()=>i((()=>{for(let i=p;i<e;i++){const e=l?.[i]??i,n=t.cloneNode(!0),s=E({[o]:h[i]??c[i],[a]:e},r);u.before(n),R(n,s);const{_del:f}=h[i]||={};h[i]._del=()=>{delete c[i],f?.(),n[x](),n.remove()}}p=e}))))}))})),()=>i((()=>{for(let t of h)t?._del();h.length=0,c.length=0}))},$.with=(t,e,r)=>(R(t,E(L(t,e,":with")(r),r)),t[x]),$.ref=(t,e,r)=>{r[e]=t},P.render=(t,e,r)=>{let i=L(t,e,":render")(r);i||q(new Error("Template not found"),t,e,":render");let n=i.content.cloneNode(!0);return t.replaceChildren(n),R(t,r),t[x]},P.id=(t,e,r)=>{let i=L(t,e,":id");return S((()=>{return e=i(r),t.id=e||0===e?e:"";var e}))},P.class=(t,e,r)=>{let i=L(t,e,":class"),n=t.getAttribute("class");return S((()=>{let e=i(r),o=[n];e&&("string"==typeof e?o.push(e):Array.isArray(e)?o.push(...e):o.push(...Object.entries(e).map((([t,e])=>e?t:"")))),(o=o.filter(Boolean).join(" "))?t.setAttribute("class",o):t.removeAttribute("class")}))},P.style=(t,e,r)=>{let i=L(t,e,":style"),n=t.getAttribute("style")||"";return n.endsWith(";")||(n+="; "),S((()=>{let e=i(r);"string"==typeof e?t.setAttribute("style",n+e):s((()=>{t.setAttribute("style",n);for(let r in e)"symbol"!=typeof e[r]&&t.style.setProperty(r,e[r])}))}))},P.text=(t,e,r)=>{let i=L(t,e,":text");return S((()=>{let e=i(r);t.textContent=null==e?"":e}))},P[""]=(t,e,r)=>{let i=L(t,e,":");if(i)return S((()=>{let e=i(r);for(let r in e)F(t,r.replace(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g,(t=>"-"+t.toLowerCase())),e[r])}))},P.value=(t,e,r)=>{let i,n,o=L(t,e,":value"),s="text"===t.type||""===t.type?e=>t.setAttribute("value",t.value=null==e?"":e):"TEXTAREA"===t.tagName||"text"===t.type||""===t.type?e=>(i=t.selectionStart,n=t.selectionEnd,t.setAttribute("value",t.value=null==e?"":e),i&&t.setSelectionRange(i,n)):"checkbox"===t.type?e=>(t.value=e?"on":"",F(t,"checked",e)):"select-one"===t.type?e=>{for(let e in t.options)e.removeAttribute("selected");t.value=e,t.selectedOptions[0]?.setAttribute("selected","")}:e=>t.value=e;return S((()=>{s(o(r))}))};var C=(t,e,r,i)=>{let n=i.startsWith("on")&&i.slice(2),o=L(t,e,":"+i);if(o){if(n){let e,i=S((()=>{e&&(e(),e=null);let i=o(r);i&&(e=W(t,n,i))}));return()=>(e?.(),i())}return S((()=>{F(t,i,o(r))}))}},W=(t,e,r)=>{if(!r)return;const i={evt:"",target:t,test:()=>!0};i.evt=(e.startsWith("on")?e.slice(2):e).replace(/\.(\w+)?-?([-\w]+)?/g,((t,e,r="")=>(i.test=D[e]?.(i,...r.split("-"))||i.test,"")));const{evt:n,target:o,test:s,defer:a,stop:l,prevent:u,...f}=i;a&&(r=a(r));const c=t=>s(t)&&(l&&t.stopPropagation(),u&&t.preventDefault(),r.call(o,t));return o.addEventListener(n,c,f),()=>o.removeEventListener(n,c,f)},D={prevent(t){t.prevent=!0},stop(t){t.stop=!0},once(t){t.once=!0},passive(t){t.passive=!0},capture(t){t.capture=!0},window(t){t.target=window},document(t){t.target=document},throttle(t,e){t.defer=t=>B(t,e?Number(e)||0:108)},debounce(t,e){t.defer=t=>K(t,e?Number(e)||0:108)},outside:t=>e=>{let r=t.target;return!(r.contains(e.target)||!1===e.target.isConnected||r.offsetWidth<1&&r.offsetHeight<1)},self:t=>e=>e.target===t.target,ctrl:(t,...e)=>t=>U.ctrl(t)&&e.every((e=>U[e]?U[e](t):t.key===e)),shift:(t,...e)=>t=>U.shift(t)&&e.every((e=>U[e]?U[e](t):t.key===e)),alt:(t,...e)=>t=>U.alt(t)&&e.every((e=>U[e]?U[e](t):t.key===e)),meta:(t,...e)=>t=>U.meta(t)&&e.every((e=>U[e]?U[e](t):t.key===e)),arrow:t=>U.arrow,enter:t=>U.enter,escape:t=>U.escape,tab:t=>U.tab,space:t=>U.space,backspace:t=>U.backspace,delete:t=>U.delete,digit:t=>U.digit,letter:t=>U.letter,character:t=>U.character},U={ctrl:t=>t.ctrlKey||"Control"===t.key||"Ctrl"===t.key,shift:t=>t.shiftKey||"Shift"===t.key,alt:t=>t.altKey||"Alt"===t.key,meta:t=>t.metaKey||"Meta"===t.key||"Command"===t.key,arrow:t=>t.key.startsWith("Arrow"),enter:t=>"Enter"===t.key,escape:t=>t.key.startsWith("Esc"),tab:t=>"Tab"===t.key,space:t=>" "===t.key||"Space"===t.key||" "===t.key,backspace:t=>"Backspace"===t.key,delete:t=>"Delete"===t.key,digit:t=>/^\d$/.test(t.key),letter:t=>/^[a-zA-Z]$/.test(t.key),character:t=>/^\S$/.test(t.key)},B=(t,e)=>{let r,i,n=o=>{r=!0,setTimeout((()=>{if(r=!1,i)return i=!1,n(o),t(o)}),e)};return e=>r?i=!0:(n(e),t(e))},K=(t,e)=>{let r;return i=>{clearTimeout(r),r=setTimeout((()=>{r=null,t(i)}),e)}},F=(t,e,r)=>{null==r||!1===r?t.removeAttribute(e):t.setAttribute(e,!0===r?"":"number"==typeof r||"string"==typeof r?r:"")},I={};function L(t,e,r){let i=I[e];if(!i)try{i=I[e]=new Function("__scope",`with (__scope) { let __; return ${e.trim()} };`)}catch(i){return q(i,t,e,r)}return n=>{let o;try{o=i.call(t,n)}catch(i){return q(i,t,e,r)}return o}}function q(t,e,r,i){Object.assign(t,{element:e,expression:r}),console.warn(`∴ ${t.message}\n\n${i}=${r?`"${r}"\n\n`:""}`,e),_((()=>{throw t}),0)}R.globals=j;var M=new WeakMap;function R(t,e){if(!t.children)return;if(M.has(t))return i((()=>Object.assign(M.get(t),e)));const r=E(e||{}),n=[],o=(t,e=t.parentNode)=>{for(let i in $){let o=":"+i;if(t.hasAttribute?.(o)){let s=t.getAttribute(o);if(t.removeAttribute(o),n.push($[i](t,s,r,i)),M.has(t))return;if(t.parentNode!==e)return!1}}if(t.attributes)for(let e=0;e<t.attributes.length;){let i=t.attributes[e],o=i.name[0];if(":"===o||"@"===o){t.removeAttribute(i.name);let e="@"===o?`${i.value.includes("await")?"async":""} event=>{${i.value}}`:i.value,s=i.name.slice(1).split(o);for(let i of s){"@"===o&&(i="on"+i);let s=P[i]||C;n.push(s(t,e,r,i))}}else e++}for(let e,r=0;e=t.children[r];r++)!1===o(e,t)&&r--};return o(t),M.has(t)||(M.set(t,r),n.length&&Object.defineProperty(t,x,{value:()=>{for(;n.length;)n.shift()?.();M.delete(t)}})),r}var Z=R;document.currentScript&&R(document.documentElement);export{Z as default};