diff --git a/bundles/datastar.js b/bundles/datastar.js index 045442bc6..7cb60408d 100644 --- a/bundles/datastar.js +++ b/bundles/datastar.js @@ -1,10 +1,10 @@ -"use strict";(()=>{var en="computed",Ne={type:1,name:en,purge:!0,onLoad:({key:t,signals:e,genRX:n})=>{let r=n();if(!t.length)throw new Error("Computed attribute must have a key");e.setComputed(t,r)}};var ke={type:1,name:"signals",purge:!0,onLoad:({key:t,signals:e,genRX:n})=>{let i=n()();t?e.setValue(t,i):e.merge(i)}};var Ie={type:1,name:"star",onLoad:()=>{alert("YOU ARE PROBABLY OVERCOMPLICATING IT")}};var Le={name:"signalValue",type:0,fn:t=>{let e=/(?[\w0-9.]*)(.value)/gm;return t.replaceAll(e,"ctx.signals.signal('$1').value")}};var I="datastar";var Ce="Datastar-Request",De="0.20.1";var Oe="type module";var L={Morph:"morph",Inner:"inner",Outer:"outer",Prepend:"prepend",Append:"append",Before:"before",After:"after",UpsertAttributes:"upsertAttributes"},Ve=L.Morph,k={MergeFragments:"datastar-merge-fragments",MergeSignals:"datastar-merge-signals",RemoveFragments:"datastar-remove-fragments",RemoveSignals:"datastar-remove-signals",ExecuteScript:"datastar-execute-script"};var O=t=>t.trim()==="true",V=t=>t.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(e,n)=>(n?"-":"")+e.toLowerCase());var tn="https://data-star.dev/docs/errors";var f=(t,e)=>{let n=new Error;n.name=`${I}${t}`;let r=`${tn}/${V(t)}?${new URLSearchParams(e)}`;return n.message=`${I}${t}, for more info see ${r}`,n};function Fe(t){if(t.id)return t.id;let e=0,n=i=>(e=(e<<5)-e+i,e&e),r=i=>i.split("").forEach(o=>n(o.charCodeAt(0)));for(;t.parentNode;){if(t.id){r(`${t.id}`);break}else if(t===t.ownerDocument.documentElement)r(t.tagName);else{for(let i=1,o=t;o.previousElementSibling;o=o.previousElementSibling,i++)n(i);t=t.parentNode}t=t.parentNode}return I+e}function He(t,e,n=!0){if(!(t instanceof HTMLElement||t instanceof SVGElement))throw f("NotHTMLElement",t);t.tabIndex||t.setAttribute("tabindex","0"),t.scrollIntoView(e),n&&t.focus()}var nn=Symbol.for("preact-signals"),C=1,B=2,z=4,q=8,ee=16,G=32;function he(){te++}function ve(){if(te>1){te--;return}let t,e=!1;for(;J!==void 0;){let n=J;for(J=void 0,ge++;n!==void 0;){let r=n._nextBatchedEffect;if(n._nextBatchedEffect=void 0,n._flags&=~B,!(n._flags&q)&&Ue(n))try{n._callback()}catch(i){e||(t=i,e=!0)}n=r}}if(ge=0,te--,e)throw f("HadError",t)}var y;var J,te=0,ge=0,ne=0;function We(t){if(y===void 0)return;let e=t._node;if(e===void 0||e._target!==y)return e={_version:0,_source:t,_prevSource:y._sources,_nextSource:void 0,_target:y,_prevTarget:void 0,_nextTarget:void 0,_rollbackNode:e},y._sources!==void 0&&(y._sources._nextSource=e),y._sources=e,t._node=e,y._flags&G&&t._subscribe(e),e;if(e._version===-1)return e._version=0,e._nextSource!==void 0&&(e._nextSource._prevSource=e._prevSource,e._prevSource!==void 0&&(e._prevSource._nextSource=e._nextSource),e._prevSource=y._sources,e._nextSource=void 0,y._sources._nextSource=e,y._sources=e),e}function P(t){this._value=t,this._version=0,this._node=void 0,this._targets=void 0}P.prototype.brand=nn;P.prototype._refresh=function(){return!0};P.prototype._subscribe=function(t){this._targets!==t&&t._prevTarget===void 0&&(t._nextTarget=this._targets,this._targets!==void 0&&(this._targets._prevTarget=t),this._targets=t)};P.prototype._unsubscribe=function(t){if(this._targets!==void 0){let e=t._prevTarget,n=t._nextTarget;e!==void 0&&(e._nextTarget=n,t._prevTarget=void 0),n!==void 0&&(n._prevTarget=e,t._nextTarget=void 0),t===this._targets&&(this._targets=n)}};P.prototype.subscribe=function(t){return re(()=>{let e=this.value,n=y;y=void 0;try{t(e)}finally{y=n}})};P.prototype.valueOf=function(){return this.value};P.prototype.toString=function(){return this.value+""};P.prototype.toJSON=function(){return this.value};P.prototype.peek=function(){let t=y;y=void 0;try{return this.value}finally{y=t}};Object.defineProperty(P.prototype,"value",{get(){let t=We(this);return t!==void 0&&(t._version=this._version),this._value},set(t){if(t!==this._value){if(ge>100)throw f("Signal cycle detected");this._value=t,this._version++,ne++,he();try{for(let e=this._targets;e!==void 0;e=e._nextTarget)e._target._notify()}finally{ve()}}}});function Ue(t){for(let e=t._sources;e!==void 0;e=e._nextSource)if(e._source._version!==e._version||!e._source._refresh()||e._source._version!==e._version)return!0;return!1}function $e(t){for(let e=t._sources;e!==void 0;e=e._nextSource){let n=e._source._node;if(n!==void 0&&(e._rollbackNode=n),e._source._node=e,e._version=-1,e._nextSource===void 0){t._sources=e;break}}}function Be(t){let e=t._sources,n;for(;e!==void 0;){let r=e._prevSource;e._version===-1?(e._source._unsubscribe(e),r!==void 0&&(r._nextSource=e._nextSource),e._nextSource!==void 0&&(e._nextSource._prevSource=r)):n=e,e._source._node=e._rollbackNode,e._rollbackNode!==void 0&&(e._rollbackNode=void 0),e=r}t._sources=n}function W(t){P.call(this,void 0),this._fn=t,this._sources=void 0,this._globalVersion=ne-1,this._flags=z}W.prototype=new P;W.prototype._refresh=function(){if(this._flags&=~B,this._flags&C)return!1;if((this._flags&(z|G))===G||(this._flags&=~z,this._globalVersion===ne))return!0;if(this._globalVersion=ne,this._flags|=C,this._version>0&&!Ue(this))return this._flags&=~C,!0;let t=y;try{$e(this),y=this;let e=this._fn();(this._flags&ee||this._value!==e||this._version===0)&&(this._value=e,this._flags&=~ee,this._version++)}catch(e){this._value=e,this._flags|=ee,this._version++}return y=t,Be(this),this._flags&=~C,!0};W.prototype._subscribe=function(t){if(this._targets===void 0){this._flags|=z|G;for(let e=this._sources;e!==void 0;e=e._nextSource)e._source._subscribe(e)}P.prototype._subscribe.call(this,t)};W.prototype._unsubscribe=function(t){if(this._targets!==void 0&&(P.prototype._unsubscribe.call(this,t),this._targets===void 0)){this._flags&=~G;for(let e=this._sources;e!==void 0;e=e._nextSource)e._source._unsubscribe(e)}};W.prototype._notify=function(){if(!(this._flags&B)){this._flags|=z|B;for(let t=this._targets;t!==void 0;t=t._nextTarget)t._target._notify()}};Object.defineProperty(W.prototype,"value",{get(){if(this._flags&C)throw f("Signal cycle detected");let t=We(this);if(this._refresh(),t!==void 0&&(t._version=this._version),this._flags&ee)throw this._value;return this._value}});function Ge(t){return new W(t)}function qe(t){let e=t._cleanup;if(t._cleanup=void 0,typeof e=="function"){he();let n=y;y=void 0;try{e()}catch(r){throw t._flags&=~C,t._flags|=q,Ee(t),r}finally{y=n,ve()}}}function Ee(t){for(let e=t._sources;e!==void 0;e=e._nextSource)e._source._unsubscribe(e);t._fn=void 0,t._sources=void 0,qe(t)}function rn(t){if(y!==this)throw f("Effect out of order");Be(this),y=t,this._flags&=~C,this._flags&q&&Ee(this),ve()}function X(t){this._fn=t,this._cleanup=void 0,this._sources=void 0,this._nextBatchedEffect=void 0,this._flags=G}X.prototype._callback=function(){let t=this._start();try{if(this._flags&q||this._fn===void 0)return;let e=this._fn();typeof e=="function"&&(this._cleanup=e)}finally{t()}};X.prototype._start=function(){if(this._flags&C)throw f("Signal cycle detected");this._flags|=C,this._flags&=~q,qe(this),$e(this),he();let t=y;return y=this,rn.bind(this,t)};X.prototype._notify=function(){this._flags&B||(this._flags|=B,this._nextBatchedEffect=J,J=this)};X.prototype._dispose=function(){this._flags|=q,this._flags&C||Ee(this)};function re(t){let e=new X(t);try{e._callback()}catch(n){throw e._dispose(),n}return e._dispose.bind(e)}function je(t,e=!1){let n={};for(let r in t)if(t.hasOwnProperty(r)){let i=t[r];if(i instanceof P){if(e&&r.startsWith("_"))continue;n[r]=i.value}else n[r]=je(i)}return n}function Ke(t,e,n=!1){for(let r in e)if(e.hasOwnProperty(r)){let i=e[r];if(i instanceof Object&&!Array.isArray(i))t[r]||(t[r]={}),Ke(t[r],i,n);else{if(n&&t[r])continue;t[r]=new P(i)}}}function Je(t,e){for(let n in t)if(t.hasOwnProperty(n)){let r=t[n];r instanceof P?e(n,r):Je(r,e)}}function on(t,...e){let n={};for(let r of e){let i=r.split("."),o=t,s=n;for(let l=0;ln());this.setSignal(e,r)}value(e){return this.signal(e)?.value}setValue(e,n){let r=this.upsert(e,n);r.value=n}upsert(e,n){let r=e.split("."),i=this._signals;for(let l=0;lt.type===0,an=t=>t.type===2,ln=t=>t.type===1,cn=t=>t.type===3,oe=class{constructor(){this._signals=new ie;this.plugins=[];this.macros=[];this.actions={};this.watchers=[];this.removals=new Map}get version(){return De}load(...e){let n=new Set(this.plugins);e.forEach(r=>{if(r.requires?.size){for(let o of r?.requires)if(!n.has(o))throw f("Plugin dependency not met")}let i;if(sn(r)){if(this.macros.includes(r))throw f("Plugin already exists");this.macros.push(r)}else if(an(r)){if(this.watchers.includes(r))throw f("Plugin already exists");this.watchers.push(r),i=r.onGlobalInit}else if(cn(r)){if(this.actions[r.name])throw f("Plugin already exists");this.actions[r.name]=r}else if(ln(r)){if(this.plugins.includes(r))throw f("Plugin already exists");this.plugins.push(r),i=r.onGlobalInit}else throw f("Plugin already exists");if(i){let o=this;i({get signals(){return o._signals},effect:s=>re(s),actions:this.actions,apply:this.apply.bind(this),cleanup:this.cleanup.bind(this)})}n.add(r)}),this.apply(document.body)}cleanup(e){let n=this.removals.get(e);if(n){for(let r of n.set)r();this.removals.delete(e)}}apply(e){let n=new Set;this.plugins.forEach((r,i)=>{this.walkDownDOM(e,o=>{i||this.cleanup(o);for(let s in o.dataset){let a=`${o.dataset[s]}`||"",l=a;if(!s.startsWith(r.name))continue;o.id.length||(o.id=Fe(o)),n.clear();let m=s.slice(r.name.length),[u,...c]=m.split(".");u.length&&(u=u[0].toLowerCase()+u.slice(1));let p=new Map;c.forEach(E=>{let[S,...h]=E.split("_");p.set(S,new Set(h))});let v=[...r.macros?.pre||[],...this.macros,...r.macros?.post||[]];for(let E of v)n.has(E)||(n.add(E),l=E.fn(l));let{actions:_,apply:d,cleanup:g}=this,w=this,x={get signals(){return w._signals},effect:E=>re(E),apply:d.bind(this),cleanup:g.bind(this),actions:_,genRX:()=>{throw f("NotImplemented")},el:o,rawKey:s,rawValue:a,key:u,value:l,mods:p};x.genRX=()=>this.generateReactiveExpression(x,...r.argNames||[]);let b=r.onLoad(x);b&&(this.removals.has(o)||this.removals.set(o,{id:o.id,set:new Set}),this.removals.get(o).set.add(b)),r?.purge&&delete o.dataset[s]}})})}generateReactiveExpression(e,...n){let r=e.value.split(/;|\n/).map(d=>d.trim()).filter(d=>d.length),i=r.length-1,o="return";r[i].startsWith(o)||(r[i]=`${o} ${r[i]};`);let a=r.join(`; -`),l=/(\w*)\(/gm,m=a.matchAll(l),u=new Set;for(let d of m)u.add(d[1]);let c=Object.keys(this.actions).filter(d=>u.has(d)),v=`${c.map(d=>`const ${d} = ctx.actions.${d}.fn;`).join(` +"use strict";(()=>{var en="computed",Ne={type:1,name:en,purge:!0,onLoad:({key:t,signals:e,genRX:n})=>{let r=n();if(!t.length)throw new Error("Computed attribute must have a key");e.setComputed(t,r)}};var ke={type:1,name:"signals",purge:!0,onLoad:({key:t,signals:e,genRX:n})=>{let i=n()();t?e.setValue(t,i):e.merge(i)}};var Ie={type:1,name:"star",onLoad:()=>{alert("YOU ARE PROBABLY OVERCOMPLICATING IT")}};var Le={name:"signalValue",type:0,fn:t=>{let e=/(?[\w0-9.]*)(.value)/gm;return t.replaceAll(e,"ctx.signals.signal('$1').value")}};var I="datastar";var Ce="Datastar-Request",De="0.20.1";var Oe="type module";var L={Morph:"morph",Inner:"inner",Outer:"outer",Prepend:"prepend",Append:"append",Before:"before",After:"after",UpsertAttributes:"upsertAttributes"},Ve=L.Morph,k={MergeFragments:"datastar-merge-fragments",MergeSignals:"datastar-merge-signals",RemoveFragments:"datastar-remove-fragments",RemoveSignals:"datastar-remove-signals",ExecuteScript:"datastar-execute-script"};var O=t=>t.trim()==="true",V=t=>t.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(e,n)=>(n?"-":"")+e.toLowerCase());var tn="https://data-star.dev/docs/errors";var f=(t,e)=>{let n=new Error;n.name=`${I}${t}`;let r=`${tn}/${V(t)}?${new URLSearchParams(e)}`;return n.message=`${I}${t}, for more info see ${r}`,n};function Fe(t){if(t.id)return t.id;let e=0,n=i=>(e=(e<<5)-e+i,e&e),r=i=>i.split("").forEach(o=>n(o.charCodeAt(0)));for(;t.parentNode;){if(t.id){r(`${t.id}`);break}else if(t===t.ownerDocument.documentElement)r(t.tagName);else{for(let i=1,o=t;o.previousElementSibling;o=o.previousElementSibling,i++)n(i);t=t.parentNode}t=t.parentNode}return I+e}function He(t,e,n=!0){if(!(t instanceof HTMLElement||t instanceof SVGElement))throw f("NotHTMLElement",t);t.tabIndex||t.setAttribute("tabindex","0"),t.scrollIntoView(e),n&&t.focus()}var nn=Symbol.for("preact-signals"),C=1,B=2,z=4,q=8,ee=16,G=32;function he(){te++}function ve(){if(te>1){te--;return}let t,e=!1;for(;J!==void 0;){let n=J;for(J=void 0,ge++;n!==void 0;){let r=n._nextBatchedEffect;if(n._nextBatchedEffect=void 0,n._flags&=~B,!(n._flags&q)&&Ue(n))try{n._callback()}catch(i){e||(t=i,e=!0)}n=r}}if(ge=0,te--,e)throw f("HadError",t)}var y;var J,te=0,ge=0,ne=0;function We(t){if(y===void 0)return;let e=t._node;if(e===void 0||e._target!==y)return e={_version:0,_source:t,_prevSource:y._sources,_nextSource:void 0,_target:y,_prevTarget:void 0,_nextTarget:void 0,_rollbackNode:e},y._sources!==void 0&&(y._sources._nextSource=e),y._sources=e,t._node=e,y._flags&G&&t._subscribe(e),e;if(e._version===-1)return e._version=0,e._nextSource!==void 0&&(e._nextSource._prevSource=e._prevSource,e._prevSource!==void 0&&(e._prevSource._nextSource=e._nextSource),e._prevSource=y._sources,e._nextSource=void 0,y._sources._nextSource=e,y._sources=e),e}function P(t){this._value=t,this._version=0,this._node=void 0,this._targets=void 0}P.prototype.brand=nn;P.prototype._refresh=function(){return!0};P.prototype._subscribe=function(t){this._targets!==t&&t._prevTarget===void 0&&(t._nextTarget=this._targets,this._targets!==void 0&&(this._targets._prevTarget=t),this._targets=t)};P.prototype._unsubscribe=function(t){if(this._targets!==void 0){let e=t._prevTarget,n=t._nextTarget;e!==void 0&&(e._nextTarget=n,t._prevTarget=void 0),n!==void 0&&(n._prevTarget=e,t._nextTarget=void 0),t===this._targets&&(this._targets=n)}};P.prototype.subscribe=function(t){return re(()=>{let e=this.value,n=y;y=void 0;try{t(e)}finally{y=n}})};P.prototype.valueOf=function(){return this.value};P.prototype.toString=function(){return this.value+""};P.prototype.toJSON=function(){return this.value};P.prototype.peek=function(){let t=y;y=void 0;try{return this.value}finally{y=t}};Object.defineProperty(P.prototype,"value",{get(){let t=We(this);return t!==void 0&&(t._version=this._version),this._value},set(t){if(t!==this._value){if(ge>100)throw f("Signal cycle detected");this._value=t,this._version++,ne++,he();try{for(let e=this._targets;e!==void 0;e=e._nextTarget)e._target._notify()}finally{ve()}}}});function Ue(t){for(let e=t._sources;e!==void 0;e=e._nextSource)if(e._source._version!==e._version||!e._source._refresh()||e._source._version!==e._version)return!0;return!1}function $e(t){for(let e=t._sources;e!==void 0;e=e._nextSource){let n=e._source._node;if(n!==void 0&&(e._rollbackNode=n),e._source._node=e,e._version=-1,e._nextSource===void 0){t._sources=e;break}}}function Be(t){let e=t._sources,n;for(;e!==void 0;){let r=e._prevSource;e._version===-1?(e._source._unsubscribe(e),r!==void 0&&(r._nextSource=e._nextSource),e._nextSource!==void 0&&(e._nextSource._prevSource=r)):n=e,e._source._node=e._rollbackNode,e._rollbackNode!==void 0&&(e._rollbackNode=void 0),e=r}t._sources=n}function W(t){P.call(this,void 0),this._fn=t,this._sources=void 0,this._globalVersion=ne-1,this._flags=z}W.prototype=new P;W.prototype._refresh=function(){if(this._flags&=~B,this._flags&C)return!1;if((this._flags&(z|G))===G||(this._flags&=~z,this._globalVersion===ne))return!0;if(this._globalVersion=ne,this._flags|=C,this._version>0&&!Ue(this))return this._flags&=~C,!0;let t=y;try{$e(this),y=this;let e=this._fn();(this._flags&ee||this._value!==e||this._version===0)&&(this._value=e,this._flags&=~ee,this._version++)}catch(e){this._value=e,this._flags|=ee,this._version++}return y=t,Be(this),this._flags&=~C,!0};W.prototype._subscribe=function(t){if(this._targets===void 0){this._flags|=z|G;for(let e=this._sources;e!==void 0;e=e._nextSource)e._source._subscribe(e)}P.prototype._subscribe.call(this,t)};W.prototype._unsubscribe=function(t){if(this._targets!==void 0&&(P.prototype._unsubscribe.call(this,t),this._targets===void 0)){this._flags&=~G;for(let e=this._sources;e!==void 0;e=e._nextSource)e._source._unsubscribe(e)}};W.prototype._notify=function(){if(!(this._flags&B)){this._flags|=z|B;for(let t=this._targets;t!==void 0;t=t._nextTarget)t._target._notify()}};Object.defineProperty(W.prototype,"value",{get(){if(this._flags&C)throw f("Signal cycle detected");let t=We(this);if(this._refresh(),t!==void 0&&(t._version=this._version),this._flags&ee)throw this._value;return this._value}});function Ge(t){return new W(t)}function qe(t){let e=t._cleanup;if(t._cleanup=void 0,typeof e=="function"){he();let n=y;y=void 0;try{e()}catch(r){throw t._flags&=~C,t._flags|=q,Ee(t),r}finally{y=n,ve()}}}function Ee(t){for(let e=t._sources;e!==void 0;e=e._nextSource)e._source._unsubscribe(e);t._fn=void 0,t._sources=void 0,qe(t)}function rn(t){if(y!==this)throw f("Effect out of order");Be(this),y=t,this._flags&=~C,this._flags&q&&Ee(this),ve()}function X(t){this._fn=t,this._cleanup=void 0,this._sources=void 0,this._nextBatchedEffect=void 0,this._flags=G}X.prototype._callback=function(){let t=this._start();try{if(this._flags&q||this._fn===void 0)return;let e=this._fn();typeof e=="function"&&(this._cleanup=e)}finally{t()}};X.prototype._start=function(){if(this._flags&C)throw f("Signal cycle detected");this._flags|=C,this._flags&=~q,qe(this),$e(this),he();let t=y;return y=this,rn.bind(this,t)};X.prototype._notify=function(){this._flags&B||(this._flags|=B,this._nextBatchedEffect=J,J=this)};X.prototype._dispose=function(){this._flags|=q,this._flags&C||Ee(this)};function re(t){let e=new X(t);try{e._callback()}catch(n){throw e._dispose(),n}return e._dispose.bind(e)}function je(t,e=!1){let n={};for(let r in t)if(t.hasOwnProperty(r)){let i=t[r];if(i instanceof P){if(e&&r.startsWith("_"))continue;n[r]=i.value}else n[r]=je(i)}return n}function Ke(t,e,n=!1){for(let r in e)if(e.hasOwnProperty(r)){let i=e[r];if(i instanceof Object&&!Array.isArray(i))t[r]||(t[r]={}),Ke(t[r],i,n);else{if(n&&t[r])continue;t[r]=new P(i)}}}function Je(t,e){for(let n in t)if(t.hasOwnProperty(n)){let r=t[n];r instanceof P?e(n,r):Je(r,e)}}function on(t,...e){let n={};for(let r of e){let i=r.split("."),o=t,s=n;for(let l=0;ln());this.setSignal(e,r)}value(e){return this.signal(e)?.value}setValue(e,n){let r=this.upsert(e,n);r.value=n}upsert(e,n){let r=e.split("."),i=this._signals;for(let l=0;lt.type===0,an=t=>t.type===2,ln=t=>t.type===1,cn=t=>t.type===3,oe=class{constructor(){this._signals=new ie;this.plugins=[];this.macros=[];this.actions={};this.watchers=[];this.removals=new Map}get version(){return De}load(...e){let n=new Set(this.plugins);e.forEach(r=>{if(r.requires?.size){for(let o of r?.requires)if(!n.has(o))throw f("Plugin dependency not met")}let i;if(sn(r)){if(this.macros.includes(r))throw f("Plugin already exists");this.macros.push(r)}else if(an(r)){if(this.watchers.includes(r))throw f("Plugin already exists");this.watchers.push(r),i=r.onGlobalInit}else if(cn(r)){if(this.actions[r.name])throw f("Plugin already exists");this.actions[r.name]=r}else if(ln(r)){if(this.plugins.includes(r))throw f("Plugin already exists");this.plugins.push(r),i=r.onGlobalInit}else throw f("Plugin already exists");if(i){let o=this;i({get signals(){return o._signals},effect:s=>re(s),actions:this.actions,apply:this.apply.bind(this),cleanup:this.cleanup.bind(this)})}n.add(r)}),this.apply(document.body)}cleanup(e){let n=this.removals.get(e);if(n){for(let r of n.set)r();this.removals.delete(e)}}apply(e){let n=new Set;this.plugins.forEach((r,i)=>{this.walkDownDOM(e,o=>{i||this.cleanup(o);for(let s in o.dataset){let a=`${o.dataset[s]}`||"",l=a;if(!s.startsWith(r.name))continue;o.id.length||(o.id=Fe(o)),n.clear();let p=s.slice(r.name.length),[u,...c]=p.split(".");u.length&&(u=u[0].toLowerCase()+u.slice(1));let m=new Map;c.forEach(E=>{let[S,...v]=E.split("_");m.set(S,new Set(v))});let A=[...r.macros?.pre||[],...this.macros,...r.macros?.post||[]];for(let E of A)n.has(E)||(n.add(E),l=E.fn(l));let{actions:g,apply:d,cleanup:h}=this,w=this,x={get signals(){return w._signals},effect:E=>re(E),apply:d.bind(this),cleanup:h.bind(this),actions:g,genRX:()=>{throw f("NotImplemented")},el:o,rawKey:s,rawValue:a,key:u,value:l,mods:m};x.genRX=()=>this.generateReactiveExpression(x,...r.argNames||[]);let b=r.onLoad(x);b&&(this.removals.has(o)||this.removals.set(o,{id:o.id,set:new Set}),this.removals.get(o).set.add(b)),r?.purge&&delete o.dataset[s]}})})}generateReactiveExpression(e,...n){let r=e.value.split(/;|\n/).map(d=>d.trim()).filter(d=>d.length),i=r.length-1,o="return";r[i].startsWith(o)||(r[i]=`${o} ${r[i]};`);let a=r.join(`; +`),l=/(\w*)\(/gm,p=a.matchAll(l),u=new Set;for(let d of p)u.add(d[1]);let c=Object.keys(this.actions).filter(d=>u.has(d)),A=`${c.map(d=>`const ${d} = ctx.actions.${d}.fn;`).join(` `)} -${a}`,_=v;c.forEach(d=>{_=_.replaceAll(d+"(",d+"(ctx,")});try{let d=n||[],g=new Function("ctx",...d,_);return(...w)=>g(e,...w)}catch(d){let g={err:d,fnContent:v};throw console.error(g),f("ExpressionGeneration",g)}}walkDownDOM(e,n){if(!e||!(e instanceof HTMLElement||e instanceof SVGElement))return null;for(n(e),e=e.firstElementChild;e;)this.walkDownDOM(e,n),e=e.nextElementSibling}};var ze=new oe;ze.load(Ie,Le,ke,Ne);var Xe=ze;async function un(t,e){let n=t.getReader(),r;for(;!(r=await n.read()).done;)e(r.value)}function fn(t){let e,n,r,i=!1;return function(s){e===void 0?(e=s,n=0,r=-1):e=pn(e,s);let a=e.length,l=0;for(;n0){let l=i.decode(s.subarray(0,a)),m=a+(s[a+1]===32?2:1),u=i.decode(s.subarray(m));switch(l){case"data":r.data=r.data?r.data+` -`+u:u;break;case"event":r.event=u;break;case"id":t(r.id=u);break;case"retry":let c=parseInt(u,10);isNaN(c)||e(r.retry=c);break}}}}function pn(t,e){let n=new Uint8Array(t.length+e.length);return n.set(t),n.set(e,t.length),n}function Ye(){return{data:"",event:"",id:"",retry:void 0}}var mn="text/event-stream",gn=1e3,Qe="last-event-id";function Ze(t,{signal:e,headers:n,onopen:r,onmessage:i,onclose:o,onerror:s,openWhenHidden:a,fetch:l,retryScaler:m=2,retryMaxWaitMs:u=3e4,retryMaxCount:c=10,...p}){return new Promise((v,_)=>{let d=0,g={...n};g.accept||(g.accept=mn);let w;function x(){w.abort(),document.hidden||N()}a||document.addEventListener("visibilitychange",x);let b=gn,E=0;function S(){document.removeEventListener("visibilitychange",x),window.clearTimeout(E),w.abort()}e?.addEventListener("abort",()=>{S(),v()});let h=l??window.fetch,A=r??function(){};async function N(){w=new AbortController;try{let M=await h(t,{...p,headers:g,signal:w.signal});await A(M),await un(M.body,fn(dn(R=>{R?g[Qe]=R:delete g[Qe]},R=>{b=R},i))),o?.(),S(),v()}catch(M){if(!w.signal.aborted)try{let R=s?.(M)??b;window.clearTimeout(E),E=window.setTimeout(N,R),b*=m,b=Math.min(b,u),d++,d>=c?(S(),_(f("SSE_MAX_RETRIES",{retryInterval:b,retryMaxCount:c,...p}))):console.error(`Datastar failed to reach ${p.method}:${t.toString()} retry in ${R}ms`)}catch(R){S(),_(R)}}}N()})}var j=`${I}-sse`,be=`${I}-settling`,U=`${I}-swapping`,se="started",ae="finished";function D(t,e){document.addEventListener(j,n=>{if(n.detail.type!=t)return;let{argsRaw:r}=n.detail;e(r)})}function ye(t,e){document.dispatchEvent(new CustomEvent(j,{detail:{type:t,argsRaw:e}}))}var et=t=>`${t}`.includes("text/event-stream"),tt={type:3,name:"sse",fn:async(t,e,n={method:"GET",headers:{},onlyRemote:!0})=>{let{el:{id:r},signals:i}=t,{headers:o,onlyRemote:s}=n,a=n.method.toUpperCase();try{if(ye(se,{elId:r}),!e?.length)throw f("NO URL");let l=Object.assign({"Content-Type":"application/json",[Ce]:!0},o),m={method:a,headers:l,onmessage:p=>{if(!p.event.startsWith(I))return;let v=p.event,_={},d=p.data.split(` -`);for(let w of d){let x=w.indexOf(" "),b=w.slice(0,x),E=_[b];E||(E=[],_[b]=E);let S=w.slice(x+1).trim();E.push(S)}let g={};for(let[w,x]of Object.entries(_))g[w]=x.join(` -`);ye(v,g)},onerror:p=>{if(et(p))throw f("SSE content-type is wrong",{url:e,err:p});p&&console.error(p.message)}},u=new URL(e,window.location.origin),c=i.JSON(!1,s);if(a==="GET"){let p=new URLSearchParams(u.search);p.set(I,c),u.search=p.toString()}else m.body=c;try{await Ze(u.toString(),m)}catch(p){if(!et(p))throw f("SSE failed",{url:e,err:p})}}finally{ye(ae,{elId:r})}}};var hn=`${I}-indicator`,ri=`${hn}-loading`,nt="indicator",rt={type:1,name:nt,onLoad:({value:t,signals:e,el:n,key:r})=>{if(r.length)throw f("must have no key",{name:nt});let i=e.upsert(t,!1),o=s=>{let{type:a,argsRaw:{elId:l}}=s.detail;if(l===n.id)switch(a){case se:i.value=!0;break;case ae:i.value=!1;break}};return document.addEventListener(j,o),()=>{document.removeEventListener(j,o)}}};var it={type:2,name:k.ExecuteScript,onGlobalInit:async()=>{D(k.ExecuteScript,({autoRemove:t=`${!0}`,attributes:e=Oe,script:n})=>{let r=O(t);if(!n?.length)throw f("no script provided");let i=document.createElement("script");e.split(` -`).forEach(o=>{let s=o.indexOf(" "),a=s?o.slice(0,s):o,l=s?o.slice(s):"";i.setAttribute(a.trim(),l.trim())}),i.text=n,document.head.appendChild(i),r&&i.remove()})}};var Y=document,K=!!Y.startViewTransition;var ce=new WeakSet;function lt(t,e,n={}){t instanceof Document&&(t=t.documentElement);let r;typeof e=="string"?r=Tn(e):r=e;let i=An(r),o=bn(t,i,n);return ct(t,i,o)}function ct(t,e,n){if(n.head.block){let r=t.querySelector("head"),i=e.querySelector("head");if(r&&i){let o=ft(i,r,n);Promise.all(o).then(()=>{ct(t,e,Object.assign(n,{head:{block:!1,ignore:!0}}))});return}}if(n.morphStyle==="innerHTML")return ut(e,t,n),t.children;if(n.morphStyle==="outerHTML"||n.morphStyle==null){let r=wn(e,t,n);if(!r)throw f("NoBestMatch",{old:t,new:e});let i=r?.previousSibling,o=r?.nextSibling,s=ue(t,r,n);return r?_n(i,s,o):[]}else throw f("UnknownMorphStyle",{style:n.morphStyle})}function ue(t,e,n){if(!(n.ignoreActive&&t===document.activeElement))if(e==null){if(n.callbacks.beforeNodeRemoved(t)===!1)return;t.remove(),n.callbacks.afterNodeRemoved(t);return}else{if(fe(t,e))return n.callbacks.beforeNodeMorphed(t,e)===!1?void 0:(t instanceof HTMLHeadElement&&n.head.ignore||(e instanceof HTMLHeadElement&&t instanceof HTMLHeadElement&&n.head.style!==L.Morph?ft(e,t,n):(En(e,t),ut(e,t,n))),n.callbacks.afterNodeMorphed(t,e),t);if(n.callbacks.beforeNodeRemoved(t)===!1||n.callbacks.beforeNodeAdded(e)===!1)return;if(!t.parentElement)throw f("NoParent",{oldNode:t});return t.parentElement.replaceChild(e,t),n.callbacks.afterNodeAdded(e),n.callbacks.afterNodeRemoved(t),e}}function ut(t,e,n){let r=t.firstChild,i=e.firstChild,o;for(;r;){if(o=r,r=o.nextSibling,i==null){if(n.callbacks.beforeNodeAdded(o)===!1)return;e.appendChild(o),n.callbacks.afterNodeAdded(o),$(n,o);continue}if(dt(o,i,n)){ue(i,o,n),i=i.nextSibling,$(n,o);continue}let s=yn(t,e,o,i,n);if(s){i=ot(i,s,n),ue(s,o,n),$(n,o);continue}let a=Sn(t,o,i,n);if(a){i=ot(i,a,n),ue(a,o,n),$(n,o);continue}if(n.callbacks.beforeNodeAdded(o)===!1)return;e.insertBefore(o,i),n.callbacks.afterNodeAdded(o),$(n,o)}for(;i!==null;){let s=i;i=i.nextSibling,pt(s,n)}}function En(t,e){let n=t.nodeType;if(n===1){for(let r of t.attributes)e.getAttribute(r.name)!==r.value&&e.setAttribute(r.name,r.value);for(let r of e.attributes)t.hasAttribute(r.name)||e.removeAttribute(r.name)}if((n===Node.COMMENT_NODE||n===Node.TEXT_NODE)&&e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),t instanceof HTMLInputElement&&e instanceof HTMLInputElement&&t.type!=="file")e.value=t.value||"",le(t,e,"value"),le(t,e,"checked"),le(t,e,"disabled");else if(t instanceof HTMLOptionElement)le(t,e,"selected");else if(t instanceof HTMLTextAreaElement&&e instanceof HTMLTextAreaElement){let r=t.value,i=e.value;r!==i&&(e.value=r),e.firstChild&&e.firstChild.nodeValue!==r&&(e.firstChild.nodeValue=r)}}function le(t,e,n){let r=t.getAttribute(n),i=e.getAttribute(n);r!==i&&(r?e.setAttribute(n,r):e.removeAttribute(n))}function ft(t,e,n){let r=[],i=[],o=[],s=[],a=n.head.style,l=new Map;for(let u of t.children)l.set(u.outerHTML,u);for(let u of e.children){let c=l.has(u.outerHTML),p=n.head.shouldReAppend(u),v=n.head.shouldPreserve(u);c||v?p?i.push(u):(l.delete(u.outerHTML),o.push(u)):a===L.Append?p&&(i.push(u),s.push(u)):n.head.shouldRemove(u)!==!1&&i.push(u)}s.push(...l.values());let m=[];for(let u of s){let c=document.createRange().createContextualFragment(u.outerHTML).firstChild;if(!c)throw f("NoNewElement",{newNode:u});if(n.callbacks.beforeNodeAdded(c)){if(c.hasAttribute("href")||c.hasAttribute("src")){let p,v=new Promise(_=>{p=_});c.addEventListener("load",function(){p(void 0)}),m.push(v)}e.appendChild(c),n.callbacks.afterNodeAdded(c),r.push(c)}}for(let u of i)n.callbacks.beforeNodeRemoved(u)!==!1&&(e.removeChild(u),n.callbacks.afterNodeRemoved(u));return n.head.afterHeadMorphed(e,{added:r,kept:o,removed:i}),m}function F(){}function bn(t,e,n){return{target:t,newContent:e,config:n,morphStyle:n.morphStyle,ignoreActive:n.ignoreActive,idMap:Rn(t,e),deadIds:new Set,callbacks:Object.assign({beforeNodeAdded:F,afterNodeAdded:F,beforeNodeMorphed:F,afterNodeMorphed:F,beforeNodeRemoved:F,afterNodeRemoved:F},n.callbacks),head:Object.assign({style:"merge",shouldPreserve:r=>r.getAttribute("im-preserve")==="true",shouldReAppend:r=>r.getAttribute("im-re-append")==="true",shouldRemove:F,afterHeadMorphed:F},n.head)}}function dt(t,e,n){return!t||!e?!1:t.nodeType===e.nodeType&&t.tagName===e.tagName?t?.id?.length&&t.id===e.id?!0:Q(n,t,e)>0:!1}function fe(t,e){return!t||!e?!1:t.nodeType===e.nodeType&&t.tagName===e.tagName}function ot(t,e,n){for(;t!==e;){let r=t;if(t=t?.nextSibling,!r)throw f("NoTempNode",{startInclusive:t,endExclusive:e});pt(r,n)}return $(n,e),e.nextSibling}function yn(t,e,n,r,i){let o=Q(i,n,e),s=null;if(o>0){s=r;let a=0;for(;s!=null;){if(dt(n,s,i))return s;if(a+=Q(i,s,t),a>o)return null;s=s.nextSibling}}return s}function Sn(t,e,n,r){let i=n,o=e.nextSibling,s=0;for(;i&&o;){if(Q(r,i,t)>0)return null;if(fe(e,i))return i;if(fe(o,i)&&(s++,o=o.nextSibling,s>=2))return null;i=i.nextSibling}return i}var st=new DOMParser;function Tn(t){let e=t.replace(/]*>|>)([\s\S]*?)<\/svg>/gim,"");if(e.match(/<\/html>/)||e.match(/<\/head>/)||e.match(/<\/body>/)){let n=st.parseFromString(t,"text/html");if(e.match(/<\/html>/))return ce.add(n),n;{let r=n.firstChild;return r?(ce.add(r),r):null}}else{let r=st.parseFromString(``,"text/html").body.querySelector("template")?.content;if(!r)throw f("NoContent",{newContent:t});return ce.add(r),r}}function An(t){if(t==null)return document.createElement("div");if(ce.has(t))return t;if(t instanceof Node){let e=document.createElement("div");return e.append(t),e}else{let e=document.createElement("div");for(let n of[...t])e.append(n);return e}}function _n(t,e,n){let r=[],i=[];for(;t;)r.push(t),t=t.previousSibling;for(;r.length>0;){let o=r.pop();i.push(o),e?.parentElement?.insertBefore(o,e)}for(i.push(e);n;)r.push(n),i.push(n),n=n.nextSibling;for(;r.length;)e?.parentElement?.insertBefore(r.pop(),e.nextSibling);return i}function wn(t,e,n){let r=t.firstChild,i=r,o=0;for(;r;){let s=xn(r,e,n);s>o&&(i=r,o=s),r=r.nextSibling}return i}function xn(t,e,n){return fe(t,e)?.5+Q(n,t,e):0}function pt(t,e){$(e,t),e.callbacks.beforeNodeRemoved(t)!==!1&&(t.remove(),e.callbacks.afterNodeRemoved(t))}function Pn(t,e){return!t.deadIds.has(e)}function Mn(t,e,n){return t.idMap.get(n)?.has(e)||!1}function $(t,e){let n=t.idMap.get(e);if(n)for(let r of n)t.deadIds.add(r)}function Q(t,e,n){let r=t.idMap.get(e);if(!r)return 0;let i=0;for(let o of r)Pn(t,o)&&Mn(t,o,n)&&++i;return i}function at(t,e){let n=t.parentElement,r=t.querySelectorAll("[id]");for(let i of r){let o=i;for(;o!==n&&o;){let s=e.get(o);s==null&&(s=new Set,e.set(o,s)),s.add(i.id),o=o.parentElement}}}function Rn(t,e){let n=new Map;return at(t,n),at(e,n),n}var gt={type:2,name:k.MergeFragments,onGlobalInit:async t=>{let e=document.createElement("template");D(k.MergeFragments,({fragments:n="
",selector:r="",mergeMode:i=Ve,settleDuration:o=`${300}`,useViewTransition:s=`${!1}`})=>{let a=parseInt(o),l=O(s);e.innerHTML=n.trim(),[...e.content.children].forEach(u=>{if(!(u instanceof Element))throw f("NoFragmentsFound");let c=r||`#${u.getAttribute("id")}`,p=[...document.querySelectorAll(c)||[]];if(!p.length)throw f("NoTargetsFound",{selectorOrID:c});K&&l?Y.startViewTransition(()=>mt(t,i,a,u,p)):mt(t,i,a,u,p)})})}};function mt(t,e,n,r,i){for(let o of i){o.classList.add(U);let s=o.outerHTML,a=o;switch(e){case L.Morph:let u=lt(a,r,{callbacks:{beforeNodeRemoved:(c,p)=>(t.cleanup(c),!0)}});if(!u?.length)throw f("MorphFailed");a=u[0];break;case L.Inner:a.innerHTML=r.innerHTML;break;case L.Outer:a.replaceWith(r);break;case L.Prepend:a.prepend(r);break;case L.Append:a.append(r);break;case L.Before:a.before(r);break;case L.After:a.after(r);break;case L.UpsertAttributes:r.getAttributeNames().forEach(c=>{let p=r.getAttribute(c);a.setAttribute(c,p)});break;default:throw f("UnknownMergeType",{mergeMode:e})}t.cleanup(a);let l=a.classList;l.add(U),t.apply(document.body),setTimeout(()=>{o.classList.remove(U),l.remove(U)},n);let m=a.outerHTML;s!==m&&(l.add(be),setTimeout(()=>{l.remove(be)},n))}}var ht={type:2,name:k.MergeSignals,onGlobalInit:async t=>{D(k.MergeSignals,({signals:e="{}",onlyIfMissing:n=`${!1}`})=>{let{signals:r}=t,i=O(n),s=new Function(`return Object.assign({}, ${e})`)();r.merge(s,i),t.apply(document.body)})}};var vt={type:2,name:k.RemoveFragments,onGlobalInit:async()=>{D(k.RemoveFragments,({selector:t,settleDuration:e=`${300}`,useViewTransition:n=`${!1}`})=>{if(!t.length)throw f("NoSelectorProvided");let r=parseInt(e),i=O(n),o=document.querySelectorAll(t),s=()=>{for(let a of o)a.classList.add(U);setTimeout(()=>{for(let a of o)a.remove()},r)};K&&i?Y.startViewTransition(()=>s()):s()})}};var Et={type:2,name:k.RemoveSignals,onGlobalInit:async t=>{D(k.RemoveSignals,({paths:e=""})=>{let n=e.split(` -`).map(r=>r.trim());if(!n?.length)throw f("NoPathsProvided");t.signals.remove(...n)})}};var bt={type:3,name:"clipboard",fn:(t,e)=>{if(!navigator.clipboard)throw f("Clipboard API not available");navigator.clipboard.writeText(e)}};var yt="once",St="half",Tt="full",At={type:1,name:"intersects",mods:new Set([yt,St,Tt]),onLoad:({el:t,key:e,rawKey:n,mods:r,genRX:i})=>{if(e.length)throw new Error("No key allowed");let o={threshold:0};r.has(Tt)?o.threshold=1:r.has(St)&&(o.threshold=.5);let s=new IntersectionObserver(a=>{a.forEach(l=>{l.isIntersecting&&(i(),r.has(yt)&&(s.disconnect(),delete t.dataset[n]))})},o);return s.observe(t),()=>s.disconnect()}};var kn="session",In="local",Ln="remote",_t={type:1,name:"persist",mods:new Set([In,kn,Ln]),onLoad:()=>{throw new Error("Not implemented")}};var wt={type:1,name:"replaceUrl",onLoad:({key:t,value:e,effect:n,genRX:r})=>{if(t.length)throw new Error("No key allowed");if(!e.length)throw new Error("No value provided");let i=r();return n(()=>{let o=i(),s=window.location.href,a=new URL(o,s).toString();window.history.replaceState({},"",a)})}};var de="smooth",Ae="instant",_e="auto",xt="hstart",Pt="hcenter",Mt="hend",Rt="hnearest",Nt="vstart",kt="vcenter",It="vend",Lt="vnearest",Cn="focus",pe="center",Ct="start",Dt="end",Ot="nearest",Vt={type:1,name:"scrollIntoView",mods:new Set([de,Ae,_e,xt,Pt,Mt,Rt,Nt,kt,It,Lt,Cn]),onLoad:({el:t,mods:e,key:n,value:r,rawKey:i})=>{if(n.length)throw new Error("No key allowed");if(r.length)throw new Error("No value allowed");t.tabIndex||t.setAttribute("tabindex","0");let o={behavior:de,block:pe,inline:pe};return e.has(de)&&(o.behavior=de),e.has(Ae)&&(o.behavior=Ae),e.has(_e)&&(o.behavior=_e),e.has(xt)&&(o.inline=Ct),e.has(Pt)&&(o.inline=pe),e.has(Mt)&&(o.inline=Dt),e.has(Rt)&&(o.inline=Ot),e.has(Nt)&&(o.block=Ct),e.has(kt)&&(o.block=pe),e.has(It)&&(o.block=Dt),e.has(Lt)&&(o.block=Ot),He(t,o,e.has("focus")),delete t.dataset[i],()=>{}}};var Ft="none",Ht="display",Wt={type:1,name:"show",onLoad:({el:{style:t},key:e,value:n,genRX:r,effect:i})=>{if(e.length)throw new Error("No key allowed");if(!n.length)throw new Error("No value provided");let o=r();return i(async()=>{o()?t.display===Ft&&t.removeProperty(Ht):t.setProperty(Ht,Ft)})}};var we="view-transition",Ut={type:1,name:we,onGlobalInit(){let t=!1;if(document.head.childNodes.forEach(e=>{e instanceof HTMLMetaElement&&e.name===we&&(t=!0)}),!t){let e=document.createElement("meta");e.name=we,e.content="same-origin",document.head.appendChild(e)}},onLoad:({effect:t,el:e,genRX:n})=>{if(!K){console.error("Browser does not support view transitions");return}let r=n();return t(()=>{let i=r();if(!i?.length)return;let o=e.style;o.viewTransitionName=i})}};var Dn=/^data:(?[^;]+);base64,(?.*)$/,$t=["change","input","keydown"],Bt={type:1,name:"bind",onLoad:t=>{let{el:e,value:n,genRX:r,key:i,signals:o,effect:s}=t,a=()=>{},l=()=>{},m=i==="";if(m){let c=n;if(typeof c!="string")throw new Error("Invalid expression");if(c.includes("$"))throw new Error("Not an expression");let p=e.tagName.toLowerCase(),v="",_=p.includes("input"),d=e.getAttribute("type"),g=p.includes("checkbox")||_&&d==="checkbox";g&&(v=!1),_&&d==="number"&&(v=0);let x=p.includes("select"),b=p.includes("radio")||_&&d==="radio",E=_&&d==="file";b&&(e.getAttribute("name")?.length||e.setAttribute("name",c)),o.upsert(c,v),a=()=>{let S="value"in e,h=o.value(c),A=`${h}`;if(g||b){let N=e;g?N.checked=!h||h==="true":b&&(N.checked=A===N.value)}else if(!E)if(x){let N=e;N.multiple?Array.from(N.options).forEach(M=>{M?.disabled||(Array.isArray(h)||typeof h=="string"?M.selected=h.includes(M.value):typeof h=="number"?M.selected=h===Number(M.value):M.selected=h)}):N.value=A}else S?e.value=A:e.setAttribute("value",A)},l=async()=>{if(E){let A=[...e?.files||[]],N=[],M=[],R=[];await Promise.all(A.map(Re=>new Promise(Zt=>{let H=new FileReader;H.onload=()=>{if(typeof H.result!="string")throw f("InvalidResultType",{resultType:typeof H.result});let me=H.result.match(Dn);if(!me?.groups)throw f("InvalidDataURI",{result:H.result});N.push(me.groups.contents),M.push(me.groups.mime),R.push(Re.name)},H.onloadend=()=>Zt(void 0),H.readAsDataURL(Re)}))),o.setValue(c,N);let Pe=`${c}Mimes`,Me=`${c}Names`;Pe in o&&o.upsert(Pe,M),Me in o&&o.upsert(Me,R);return}let S=o.value(c),h=e||e;if(typeof S=="number"){let A=Number(h.value||h.getAttribute("value"));o.setValue(c,A)}else if(typeof S=="string"){let A=h.value||h.getAttribute("value")||"";o.setValue(c,A)}else if(typeof S=="boolean")if(g){let A=h.checked||h.getAttribute("checked")==="true";o.setValue(c,A)}else{let A=!!(h.value||h.getAttribute("value"));o.setValue(c,A)}else if(!(typeof S>"u"))if(Array.isArray(S)){if(x){let M=[...e.selectedOptions].filter(R=>R.selected).map(R=>R.value);o.setValue(c,M)}else{let A=JSON.stringify(h.value.split(","));o.setValue(c,A)}console.log(h.value)}else throw f("UnsupportedType",{current:typeof S})}}else{let c=V(i);a=()=>{let p=r(),v;typeof p=="string"?v=p:v=JSON.stringify(p),!v||v==="false"||v==="null"||v==="undefined"?e.removeAttribute(c):e.setAttribute(c,v)}}m&&$t.forEach(c=>{e.addEventListener(c,l)});let u=s(async()=>{a()});return()=>{u(),m&&$t.forEach(c=>{e.removeEventListener(c,l)})}}};var Gt={type:1,name:"class",onLoad:({key:t,el:e,genRX:n,effect:r})=>{let i=e.classList,o=n();return r(()=>{if(t===""){let s=o();for(let[a,l]of Object.entries(s)){let m=a.split(" ");l?i.add(...m):i.remove(...m)}}else{let s=o(),a=V(t);s?i.add(a):i.remove(a)}})}};function xe(t){if(!t||t.size<=0)return 0;for(let e of t){if(e.endsWith("ms"))return Number(e.replace("ms",""));if(e.endsWith("s"))return Number(e.replace("s",""))*1e3;try{return parseFloat(e)}catch{}}return 0}function Z(t,e,n=!1){return t?t.has(e):n}function qt(t,e,n=!1,r=!0){let i=-1,o=()=>i&&clearTimeout(i);return function(...a){o(),n&&!i&&t(...a),i=setTimeout(()=>{r&&t(...a),o()},e)}}function jt(t,e,n=!0,r=!1){let i=!1;return function(...s){i||(n&&t(...s),i=!0,setTimeout(()=>{i=!1,r&&t(...s)},e))}}var On=new Set(["window","once","passive","capture","debounce","throttle","remote","outside"]),Kt={type:1,name:"on",argNames:["evt"],onLoad:({el:t,key:e,genRX:n,mods:r,signals:i,effect:o})=>{let s=n(),a=t;r.has("window")&&(a=window);let l=d=>{s(d)},m=r.get("debounce");if(m){let d=xe(m),g=Z(m,"leading",!1),w=Z(m,"noTrail",!0);l=qt(l,d,g,w)}let u=r.get("throttle");if(u){let d=xe(u),g=Z(u,"noLead",!0),w=Z(u,"noTrail",!1);l=jt(l,d,g,w)}let c={capture:!0,passive:!1,once:!1};r.has("capture")||(c.capture=!1),r.has("passive")&&(c.passive=!0),r.has("once")&&(c.once=!0),[...r.keys()].filter(d=>!On.has(d)).forEach(d=>{let g=r.get(d)||[],w=l;l=()=>{let b=event,E=b[d],S;if(typeof E=="function")S=E(...g);else if(typeof E=="boolean")S=E;else if(typeof E=="string"){let h=E.toLowerCase().trim(),A=[...g].join("").toLowerCase().trim();S=h===A}else throw f("Invalid value",{attrName:d,key:e,el:t});S&&w(b)}});let v="",_=V(e).toLowerCase();switch(_){case"load":return l(),delete t.dataset.onLoad,()=>{};case"raf":let d,g=()=>{l(),d=requestAnimationFrame(g)};return d=requestAnimationFrame(g),()=>{d&&cancelAnimationFrame(d)};case"signals-change":return o(()=>{let x=r.has("remote"),b=i.JSON(!1,x);v!==b&&(v=b,l())});default:if(r.has("outside")){a=document;let x=l,b=!1;l=S=>{let h=S?.target;if(!h)return;let A=t.id===h.id;A&&b&&(b=!1),!A&&!b&&(x(S),b=!0)}}return a.addEventListener(_,l,c),()=>{a.removeEventListener(_,l)}}}};var Jt={type:1,name:"ref",onLoad:({el:t,key:e,value:n,signals:r})=>{if(e.length)throw f("No key allowed");if(!n.length)throw f("No value provided");return r.upsert(n,t),()=>r.remove(n)}};var zt={type:1,name:"text",onLoad:t=>{let{el:e,genRX:n,effect:r}=t,i=n();return e instanceof HTMLElement||f("Element is not HTMLElement"),r(()=>{let o=i(t);e.textContent=`${o}`})}};var{round:Vn,max:Fn,min:Hn}=Math,Xt={type:3,name:"fit",fn:(t,e,n,r,i,o,s=!1,a=!1)=>{let l=(e-n)/(r-n)*(o-i)+i;return a&&(l=Vn(l)),s&&(l=Fn(i,Hn(o,l))),l}};var Yt={type:3,name:"setAll",fn:(t,e,n)=>{let r=new RegExp(e);t.signals.walk((i,o)=>r.test(i)&&(o.value=n))}};var Qt={type:3,name:"toggleAll",fn:(t,e)=>{let n=new RegExp(e);t.signals.walk((r,i)=>n.test(r)&&(i.value=!i.value))}};Xe.load(bt,At,_t,wt,Vt,Wt,Ut,Bt,Gt,Kt,Jt,zt,Xt,Yt,Qt,tt,rt,gt,ht,vt,Et,it);})(); +${a}`,g=A;c.forEach(d=>{g=g.replaceAll(d+"(",d+"(ctx,")});try{let d=n||[],h=new Function("ctx",...d,g);return(...w)=>h(e,...w)}catch(d){let h={err:d,fnContent:A};throw console.error(h),f("ExpressionGeneration",h)}}walkDownDOM(e,n){if(!e||!(e instanceof HTMLElement||e instanceof SVGElement))return null;for(n(e),e=e.firstElementChild;e;)this.walkDownDOM(e,n),e=e.nextElementSibling}};var ze=new oe;ze.load(Ie,Le,ke,Ne);var Xe=ze;async function un(t,e){let n=t.getReader(),r;for(;!(r=await n.read()).done;)e(r.value)}function fn(t){let e,n,r,i=!1;return function(s){e===void 0?(e=s,n=0,r=-1):e=pn(e,s);let a=e.length,l=0;for(;n0){let l=i.decode(s.subarray(0,a)),p=a+(s[a+1]===32?2:1),u=i.decode(s.subarray(p));switch(l){case"data":r.data=r.data?r.data+` +`+u:u;break;case"event":r.event=u;break;case"id":t(r.id=u);break;case"retry":let c=parseInt(u,10);isNaN(c)||e(r.retry=c);break}}}}function pn(t,e){let n=new Uint8Array(t.length+e.length);return n.set(t),n.set(e,t.length),n}function Ye(){return{data:"",event:"",id:"",retry:void 0}}var mn="text/event-stream",gn=1e3,Qe="last-event-id";function Ze(t,{signal:e,headers:n,onopen:r,onmessage:i,onclose:o,onerror:s,openWhenHidden:a,fetch:l,retryScaler:p=2,retryMaxWaitMs:u=3e4,retryMaxCount:c=10,...m}){return new Promise((A,g)=>{let d=0,h={...n};h.accept||(h.accept=mn);let w;function x(){w.abort(),document.hidden||N()}a||document.addEventListener("visibilitychange",x);let b=gn,E=0;function S(){document.removeEventListener("visibilitychange",x),window.clearTimeout(E),w.abort()}e?.addEventListener("abort",()=>{S(),A()});let v=l??window.fetch,_=r??function(){};async function N(){w=new AbortController;try{let M=await v(t,{...m,headers:h,signal:w.signal});await _(M),await un(M.body,fn(dn(R=>{R?h[Qe]=R:delete h[Qe]},R=>{b=R},i))),o?.(),S(),A()}catch(M){if(!w.signal.aborted)try{let R=s?.(M)??b;window.clearTimeout(E),E=window.setTimeout(N,R),b*=p,b=Math.min(b,u),d++,d>=c?(S(),g(f("SSE_MAX_RETRIES",{retryInterval:b,retryMaxCount:c,...m}))):console.error(`Datastar failed to reach ${m.method}:${t.toString()} retry in ${R}ms`)}catch(R){S(),g(R)}}}N()})}var j=`${I}-sse`,be=`${I}-settling`,U=`${I}-swapping`,se="started",ae="finished";function D(t,e){document.addEventListener(j,n=>{if(n.detail.type!=t)return;let{argsRaw:r}=n.detail;e(r)})}function ye(t,e){document.dispatchEvent(new CustomEvent(j,{detail:{type:t,argsRaw:e}}))}var et=t=>`${t}`.includes("text/event-stream"),tt={type:3,name:"sse",fn:async(t,e,n={method:"GET",headers:{},onlyRemote:!0})=>{let{el:{id:r},signals:i}=t,{headers:o,onlyRemote:s}=n,a=n.method.toUpperCase();try{if(ye(se,{elId:r}),!e?.length)throw f("NO URL");let l=Object.assign({"Content-Type":"application/json",[Ce]:!0},o),p={method:a,headers:l,onmessage:m=>{if(!m.event.startsWith(I))return;let A=m.event,g={},d=m.data.split(` +`);for(let w of d){let x=w.indexOf(" "),b=w.slice(0,x),E=g[b];E||(E=[],g[b]=E);let S=w.slice(x+1).trim();E.push(S)}let h={};for(let[w,x]of Object.entries(g))h[w]=x.join(` +`);ye(A,h)},onerror:m=>{if(et(m))throw f("SSE content-type is wrong",{url:e,err:m});m&&console.error(m.message)}},u=new URL(e,window.location.origin),c=i.JSON(!1,s);if(a==="GET"){let m=new URLSearchParams(u.search);m.set(I,c),u.search=m.toString()}else p.body=c;try{await Ze(u.toString(),p)}catch(m){if(!et(m))throw f("SSE failed",{url:e,err:m})}}finally{ye(ae,{elId:r})}}};var hn=`${I}-indicator`,ri=`${hn}-loading`,nt="indicator",rt={type:1,name:nt,onLoad:({value:t,signals:e,el:n,key:r})=>{if(r.length)throw f("must have no key",{name:nt});let i=e.upsert(t,!1),o=s=>{let{type:a,argsRaw:{elId:l}}=s.detail;if(l===n.id)switch(a){case se:i.value=!0;break;case ae:i.value=!1;break}};return document.addEventListener(j,o),()=>{document.removeEventListener(j,o)}}};var it={type:2,name:k.ExecuteScript,onGlobalInit:async()=>{D(k.ExecuteScript,({autoRemove:t=`${!0}`,attributes:e=Oe,script:n})=>{let r=O(t);if(!n?.length)throw f("no script provided");let i=document.createElement("script");e.split(` +`).forEach(o=>{let s=o.indexOf(" "),a=s?o.slice(0,s):o,l=s?o.slice(s):"";i.setAttribute(a.trim(),l.trim())}),i.text=n,document.head.appendChild(i),r&&i.remove()})}};var Y=document,K=!!Y.startViewTransition;var ce=new WeakSet;function lt(t,e,n={}){t instanceof Document&&(t=t.documentElement);let r;typeof e=="string"?r=Tn(e):r=e;let i=An(r),o=bn(t,i,n);return ct(t,i,o)}function ct(t,e,n){if(n.head.block){let r=t.querySelector("head"),i=e.querySelector("head");if(r&&i){let o=ft(i,r,n);Promise.all(o).then(()=>{ct(t,e,Object.assign(n,{head:{block:!1,ignore:!0}}))});return}}if(n.morphStyle==="innerHTML")return ut(e,t,n),t.children;if(n.morphStyle==="outerHTML"||n.morphStyle==null){let r=wn(e,t,n);if(!r)throw f("NoBestMatch",{old:t,new:e});let i=r?.previousSibling,o=r?.nextSibling,s=ue(t,r,n);return r?_n(i,s,o):[]}else throw f("UnknownMorphStyle",{style:n.morphStyle})}function ue(t,e,n){if(!(n.ignoreActive&&t===document.activeElement))if(e==null){if(n.callbacks.beforeNodeRemoved(t)===!1)return;t.remove(),n.callbacks.afterNodeRemoved(t);return}else{if(fe(t,e))return n.callbacks.beforeNodeMorphed(t,e)===!1?void 0:(t instanceof HTMLHeadElement&&n.head.ignore||(e instanceof HTMLHeadElement&&t instanceof HTMLHeadElement&&n.head.style!==L.Morph?ft(e,t,n):(En(e,t),ut(e,t,n))),n.callbacks.afterNodeMorphed(t,e),t);if(n.callbacks.beforeNodeRemoved(t)===!1||n.callbacks.beforeNodeAdded(e)===!1)return;if(!t.parentElement)throw f("NoParent",{oldNode:t});return t.parentElement.replaceChild(e,t),n.callbacks.afterNodeAdded(e),n.callbacks.afterNodeRemoved(t),e}}function ut(t,e,n){let r=t.firstChild,i=e.firstChild,o;for(;r;){if(o=r,r=o.nextSibling,i==null){if(n.callbacks.beforeNodeAdded(o)===!1)return;e.appendChild(o),n.callbacks.afterNodeAdded(o),$(n,o);continue}if(dt(o,i,n)){ue(i,o,n),i=i.nextSibling,$(n,o);continue}let s=yn(t,e,o,i,n);if(s){i=ot(i,s,n),ue(s,o,n),$(n,o);continue}let a=Sn(t,o,i,n);if(a){i=ot(i,a,n),ue(a,o,n),$(n,o);continue}if(n.callbacks.beforeNodeAdded(o)===!1)return;e.insertBefore(o,i),n.callbacks.afterNodeAdded(o),$(n,o)}for(;i!==null;){let s=i;i=i.nextSibling,pt(s,n)}}function En(t,e){let n=t.nodeType;if(n===1){for(let r of t.attributes)e.getAttribute(r.name)!==r.value&&e.setAttribute(r.name,r.value);for(let r of e.attributes)t.hasAttribute(r.name)||e.removeAttribute(r.name)}if((n===Node.COMMENT_NODE||n===Node.TEXT_NODE)&&e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),t instanceof HTMLInputElement&&e instanceof HTMLInputElement&&t.type!=="file")e.value=t.value||"",le(t,e,"value"),le(t,e,"checked"),le(t,e,"disabled");else if(t instanceof HTMLOptionElement)le(t,e,"selected");else if(t instanceof HTMLTextAreaElement&&e instanceof HTMLTextAreaElement){let r=t.value,i=e.value;r!==i&&(e.value=r),e.firstChild&&e.firstChild.nodeValue!==r&&(e.firstChild.nodeValue=r)}}function le(t,e,n){let r=t.getAttribute(n),i=e.getAttribute(n);r!==i&&(r?e.setAttribute(n,r):e.removeAttribute(n))}function ft(t,e,n){let r=[],i=[],o=[],s=[],a=n.head.style,l=new Map;for(let u of t.children)l.set(u.outerHTML,u);for(let u of e.children){let c=l.has(u.outerHTML),m=n.head.shouldReAppend(u),A=n.head.shouldPreserve(u);c||A?m?i.push(u):(l.delete(u.outerHTML),o.push(u)):a===L.Append?m&&(i.push(u),s.push(u)):n.head.shouldRemove(u)!==!1&&i.push(u)}s.push(...l.values());let p=[];for(let u of s){let c=document.createRange().createContextualFragment(u.outerHTML).firstChild;if(!c)throw f("NoNewElement",{newNode:u});if(n.callbacks.beforeNodeAdded(c)){if(c.hasAttribute("href")||c.hasAttribute("src")){let m,A=new Promise(g=>{m=g});c.addEventListener("load",function(){m(void 0)}),p.push(A)}e.appendChild(c),n.callbacks.afterNodeAdded(c),r.push(c)}}for(let u of i)n.callbacks.beforeNodeRemoved(u)!==!1&&(e.removeChild(u),n.callbacks.afterNodeRemoved(u));return n.head.afterHeadMorphed(e,{added:r,kept:o,removed:i}),p}function F(){}function bn(t,e,n){return{target:t,newContent:e,config:n,morphStyle:n.morphStyle,ignoreActive:n.ignoreActive,idMap:Rn(t,e),deadIds:new Set,callbacks:Object.assign({beforeNodeAdded:F,afterNodeAdded:F,beforeNodeMorphed:F,afterNodeMorphed:F,beforeNodeRemoved:F,afterNodeRemoved:F},n.callbacks),head:Object.assign({style:"merge",shouldPreserve:r=>r.getAttribute("im-preserve")==="true",shouldReAppend:r=>r.getAttribute("im-re-append")==="true",shouldRemove:F,afterHeadMorphed:F},n.head)}}function dt(t,e,n){return!t||!e?!1:t.nodeType===e.nodeType&&t.tagName===e.tagName?t?.id?.length&&t.id===e.id?!0:Q(n,t,e)>0:!1}function fe(t,e){return!t||!e?!1:t.nodeType===e.nodeType&&t.tagName===e.tagName}function ot(t,e,n){for(;t!==e;){let r=t;if(t=t?.nextSibling,!r)throw f("NoTempNode",{startInclusive:t,endExclusive:e});pt(r,n)}return $(n,e),e.nextSibling}function yn(t,e,n,r,i){let o=Q(i,n,e),s=null;if(o>0){s=r;let a=0;for(;s!=null;){if(dt(n,s,i))return s;if(a+=Q(i,s,t),a>o)return null;s=s.nextSibling}}return s}function Sn(t,e,n,r){let i=n,o=e.nextSibling,s=0;for(;i&&o;){if(Q(r,i,t)>0)return null;if(fe(e,i))return i;if(fe(o,i)&&(s++,o=o.nextSibling,s>=2))return null;i=i.nextSibling}return i}var st=new DOMParser;function Tn(t){let e=t.replace(/]*>|>)([\s\S]*?)<\/svg>/gim,"");if(e.match(/<\/html>/)||e.match(/<\/head>/)||e.match(/<\/body>/)){let n=st.parseFromString(t,"text/html");if(e.match(/<\/html>/))return ce.add(n),n;{let r=n.firstChild;return r?(ce.add(r),r):null}}else{let r=st.parseFromString(``,"text/html").body.querySelector("template")?.content;if(!r)throw f("NoContent",{newContent:t});return ce.add(r),r}}function An(t){if(t==null)return document.createElement("div");if(ce.has(t))return t;if(t instanceof Node){let e=document.createElement("div");return e.append(t),e}else{let e=document.createElement("div");for(let n of[...t])e.append(n);return e}}function _n(t,e,n){let r=[],i=[];for(;t;)r.push(t),t=t.previousSibling;for(;r.length>0;){let o=r.pop();i.push(o),e?.parentElement?.insertBefore(o,e)}for(i.push(e);n;)r.push(n),i.push(n),n=n.nextSibling;for(;r.length;)e?.parentElement?.insertBefore(r.pop(),e.nextSibling);return i}function wn(t,e,n){let r=t.firstChild,i=r,o=0;for(;r;){let s=xn(r,e,n);s>o&&(i=r,o=s),r=r.nextSibling}return i}function xn(t,e,n){return fe(t,e)?.5+Q(n,t,e):0}function pt(t,e){$(e,t),e.callbacks.beforeNodeRemoved(t)!==!1&&(t.remove(),e.callbacks.afterNodeRemoved(t))}function Pn(t,e){return!t.deadIds.has(e)}function Mn(t,e,n){return t.idMap.get(n)?.has(e)||!1}function $(t,e){let n=t.idMap.get(e);if(n)for(let r of n)t.deadIds.add(r)}function Q(t,e,n){let r=t.idMap.get(e);if(!r)return 0;let i=0;for(let o of r)Pn(t,o)&&Mn(t,o,n)&&++i;return i}function at(t,e){let n=t.parentElement,r=t.querySelectorAll("[id]");for(let i of r){let o=i;for(;o!==n&&o;){let s=e.get(o);s==null&&(s=new Set,e.set(o,s)),s.add(i.id),o=o.parentElement}}}function Rn(t,e){let n=new Map;return at(t,n),at(e,n),n}var gt={type:2,name:k.MergeFragments,onGlobalInit:async t=>{let e=document.createElement("template");D(k.MergeFragments,({fragments:n="
",selector:r="",mergeMode:i=Ve,settleDuration:o=`${300}`,useViewTransition:s=`${!1}`})=>{let a=parseInt(o),l=O(s);e.innerHTML=n.trim(),[...e.content.children].forEach(u=>{if(!(u instanceof Element))throw f("NoFragmentsFound");let c=r||`#${u.getAttribute("id")}`,m=[...document.querySelectorAll(c)||[]];if(!m.length)throw f("NoTargetsFound",{selectorOrID:c});K&&l?Y.startViewTransition(()=>mt(t,i,a,u,m)):mt(t,i,a,u,m)})})}};function mt(t,e,n,r,i){for(let o of i){o.classList.add(U);let s=o.outerHTML,a=o;switch(e){case L.Morph:let u=lt(a,r,{callbacks:{beforeNodeRemoved:(c,m)=>(t.cleanup(c),!0)}});if(!u?.length)throw f("MorphFailed");a=u[0];break;case L.Inner:a.innerHTML=r.innerHTML;break;case L.Outer:a.replaceWith(r);break;case L.Prepend:a.prepend(r);break;case L.Append:a.append(r);break;case L.Before:a.before(r);break;case L.After:a.after(r);break;case L.UpsertAttributes:r.getAttributeNames().forEach(c=>{let m=r.getAttribute(c);a.setAttribute(c,m)});break;default:throw f("UnknownMergeType",{mergeMode:e})}t.cleanup(a);let l=a.classList;l.add(U),t.apply(document.body),setTimeout(()=>{o.classList.remove(U),l.remove(U)},n);let p=a.outerHTML;s!==p&&(l.add(be),setTimeout(()=>{l.remove(be)},n))}}var ht={type:2,name:k.MergeSignals,onGlobalInit:async t=>{D(k.MergeSignals,({signals:e="{}",onlyIfMissing:n=`${!1}`})=>{let{signals:r}=t,i=O(n),s=new Function(`return Object.assign({}, ${e})`)();r.merge(s,i),t.apply(document.body)})}};var vt={type:2,name:k.RemoveFragments,onGlobalInit:async()=>{D(k.RemoveFragments,({selector:t,settleDuration:e=`${300}`,useViewTransition:n=`${!1}`})=>{if(!t.length)throw f("NoSelectorProvided");let r=parseInt(e),i=O(n),o=document.querySelectorAll(t),s=()=>{for(let a of o)a.classList.add(U);setTimeout(()=>{for(let a of o)a.remove()},r)};K&&i?Y.startViewTransition(()=>s()):s()})}};var Et={type:2,name:k.RemoveSignals,onGlobalInit:async t=>{D(k.RemoveSignals,({paths:e=""})=>{let n=e.split(` +`).map(r=>r.trim());if(!n?.length)throw f("NoPathsProvided");t.signals.remove(...n)})}};var bt={type:3,name:"clipboard",fn:(t,e)=>{if(!navigator.clipboard)throw f("Clipboard API not available");navigator.clipboard.writeText(e)}};var yt="once",St="half",Tt="full",At={type:1,name:"intersects",mods:new Set([yt,St,Tt]),onLoad:({el:t,key:e,rawKey:n,mods:r,genRX:i})=>{if(e.length)throw new Error("No key allowed");let o={threshold:0};r.has(Tt)?o.threshold=1:r.has(St)&&(o.threshold=.5);let s=i(),a=new IntersectionObserver(l=>{l.forEach(p=>{p.isIntersecting&&(s(),r.has(yt)&&(a.disconnect(),delete t.dataset[n]))})},o);return a.observe(t),()=>a.disconnect()}};var kn="session",In="local",Ln="remote",_t={type:1,name:"persist",mods:new Set([In,kn,Ln]),onLoad:()=>{throw new Error("Not implemented")}};var wt={type:1,name:"replaceUrl",onLoad:({key:t,value:e,effect:n,genRX:r})=>{if(t.length)throw new Error("No key allowed");if(!e.length)throw new Error("No value provided");let i=r();return n(()=>{let o=i(),s=window.location.href,a=new URL(o,s).toString();window.history.replaceState({},"",a)})}};var de="smooth",Ae="instant",_e="auto",xt="hstart",Pt="hcenter",Mt="hend",Rt="hnearest",Nt="vstart",kt="vcenter",It="vend",Lt="vnearest",Cn="focus",pe="center",Ct="start",Dt="end",Ot="nearest",Vt={type:1,name:"scrollIntoView",mods:new Set([de,Ae,_e,xt,Pt,Mt,Rt,Nt,kt,It,Lt,Cn]),onLoad:({el:t,mods:e,key:n,value:r,rawKey:i})=>{if(n.length)throw new Error("No key allowed");if(r.length)throw new Error("No value allowed");t.tabIndex||t.setAttribute("tabindex","0");let o={behavior:de,block:pe,inline:pe};return e.has(de)&&(o.behavior=de),e.has(Ae)&&(o.behavior=Ae),e.has(_e)&&(o.behavior=_e),e.has(xt)&&(o.inline=Ct),e.has(Pt)&&(o.inline=pe),e.has(Mt)&&(o.inline=Dt),e.has(Rt)&&(o.inline=Ot),e.has(Nt)&&(o.block=Ct),e.has(kt)&&(o.block=pe),e.has(It)&&(o.block=Dt),e.has(Lt)&&(o.block=Ot),He(t,o,e.has("focus")),delete t.dataset[i],()=>{}}};var Ft="none",Ht="display",Wt={type:1,name:"show",onLoad:({el:{style:t},key:e,value:n,genRX:r,effect:i})=>{if(e.length)throw new Error("No key allowed");if(!n.length)throw new Error("No value provided");let o=r();return i(async()=>{o()?t.display===Ft&&t.removeProperty(Ht):t.setProperty(Ht,Ft)})}};var we="view-transition",Ut={type:1,name:we,onGlobalInit(){let t=!1;if(document.head.childNodes.forEach(e=>{e instanceof HTMLMetaElement&&e.name===we&&(t=!0)}),!t){let e=document.createElement("meta");e.name=we,e.content="same-origin",document.head.appendChild(e)}},onLoad:({effect:t,el:e,genRX:n})=>{if(!K){console.error("Browser does not support view transitions");return}let r=n();return t(()=>{let i=r();if(!i?.length)return;let o=e.style;o.viewTransitionName=i})}};var Dn=/^data:(?[^;]+);base64,(?.*)$/,$t=["change","input","keydown"],Bt={type:1,name:"bind",onLoad:t=>{let{el:e,value:n,genRX:r,key:i,signals:o,effect:s}=t,a=()=>{},l=()=>{},p=i==="";if(p){let c=n;if(typeof c!="string")throw new Error("Invalid expression");if(c.includes("$"))throw new Error("Not an expression");let m=e.tagName.toLowerCase(),A="",g=m.includes("input"),d=e.getAttribute("type"),h=m.includes("checkbox")||g&&d==="checkbox";h&&(A=!1),g&&d==="number"&&(A=0);let x=m.includes("select"),b=m.includes("radio")||g&&d==="radio",E=g&&d==="file";b&&(e.getAttribute("name")?.length||e.setAttribute("name",c)),o.upsert(c,A),a=()=>{let S="value"in e,v=o.value(c),_=`${v}`;if(h||b){let N=e;h?N.checked=!v||v==="true":b&&(N.checked=_===N.value)}else if(!E)if(x){let N=e;N.multiple?Array.from(N.options).forEach(M=>{M?.disabled||(Array.isArray(v)||typeof v=="string"?M.selected=v.includes(M.value):typeof v=="number"?M.selected=v===Number(M.value):M.selected=v)}):N.value=_}else S?e.value=_:e.setAttribute("value",_)},l=async()=>{if(E){let _=[...e?.files||[]],N=[],M=[],R=[];await Promise.all(_.map(Re=>new Promise(Zt=>{let H=new FileReader;H.onload=()=>{if(typeof H.result!="string")throw f("InvalidResultType",{resultType:typeof H.result});let me=H.result.match(Dn);if(!me?.groups)throw f("InvalidDataURI",{result:H.result});N.push(me.groups.contents),M.push(me.groups.mime),R.push(Re.name)},H.onloadend=()=>Zt(void 0),H.readAsDataURL(Re)}))),o.setValue(c,N);let Pe=`${c}Mimes`,Me=`${c}Names`;Pe in o&&o.upsert(Pe,M),Me in o&&o.upsert(Me,R);return}let S=o.value(c),v=e||e;if(typeof S=="number"){let _=Number(v.value||v.getAttribute("value"));o.setValue(c,_)}else if(typeof S=="string"){let _=v.value||v.getAttribute("value")||"";o.setValue(c,_)}else if(typeof S=="boolean")if(h){let _=v.checked||v.getAttribute("checked")==="true";o.setValue(c,_)}else{let _=!!(v.value||v.getAttribute("value"));o.setValue(c,_)}else if(!(typeof S>"u"))if(Array.isArray(S)){if(x){let M=[...e.selectedOptions].filter(R=>R.selected).map(R=>R.value);o.setValue(c,M)}else{let _=JSON.stringify(v.value.split(","));o.setValue(c,_)}console.log(v.value)}else throw f("UnsupportedType",{current:typeof S})}}else{let c=V(i),m=r();a=()=>{let A=m(),g;typeof A=="string"?g=A:g=JSON.stringify(A),!g||g==="false"||g==="null"||g==="undefined"?e.removeAttribute(c):e.setAttribute(c,g)}}p&&$t.forEach(c=>{e.addEventListener(c,l)});let u=s(async()=>{a()});return()=>{u(),p&&$t.forEach(c=>{e.removeEventListener(c,l)})}}};var Gt={type:1,name:"class",onLoad:({key:t,el:e,genRX:n,effect:r})=>{let i=e.classList,o=n();return r(()=>{if(t===""){let s=o();for(let[a,l]of Object.entries(s)){let p=a.split(" ");l?i.add(...p):i.remove(...p)}}else{let s=o(),a=V(t);s?i.add(a):i.remove(a)}})}};function xe(t){if(!t||t.size<=0)return 0;for(let e of t){if(e.endsWith("ms"))return Number(e.replace("ms",""));if(e.endsWith("s"))return Number(e.replace("s",""))*1e3;try{return parseFloat(e)}catch{}}return 0}function Z(t,e,n=!1){return t?t.has(e):n}function qt(t,e,n=!1,r=!0){let i=-1,o=()=>i&&clearTimeout(i);return function(...a){o(),n&&!i&&t(...a),i=setTimeout(()=>{r&&t(...a),o()},e)}}function jt(t,e,n=!0,r=!1){let i=!1;return function(...s){i||(n&&t(...s),i=!0,setTimeout(()=>{i=!1,r&&t(...s)},e))}}var On=new Set(["window","once","passive","capture","debounce","throttle","remote","outside"]),Kt={type:1,name:"on",argNames:["evt"],onLoad:({el:t,key:e,genRX:n,mods:r,signals:i,effect:o})=>{let s=n(),a=t;r.has("window")&&(a=window);let l=d=>{s(d)},p=r.get("debounce");if(p){let d=xe(p),h=Z(p,"leading",!1),w=Z(p,"noTrail",!0);l=qt(l,d,h,w)}let u=r.get("throttle");if(u){let d=xe(u),h=Z(u,"noLead",!0),w=Z(u,"noTrail",!1);l=jt(l,d,h,w)}let c={capture:!0,passive:!1,once:!1};r.has("capture")||(c.capture=!1),r.has("passive")&&(c.passive=!0),r.has("once")&&(c.once=!0),[...r.keys()].filter(d=>!On.has(d)).forEach(d=>{let h=r.get(d)||[],w=l;l=()=>{let b=event,E=b[d],S;if(typeof E=="function")S=E(...h);else if(typeof E=="boolean")S=E;else if(typeof E=="string"){let v=E.toLowerCase().trim(),_=[...h].join("").toLowerCase().trim();S=v===_}else throw f("Invalid value",{attrName:d,key:e,el:t});S&&w(b)}});let A="",g=V(e).toLowerCase();switch(g){case"load":return l(),delete t.dataset.onLoad,()=>{};case"raf":let d,h=()=>{l(),d=requestAnimationFrame(h)};return d=requestAnimationFrame(h),()=>{d&&cancelAnimationFrame(d)};case"signals-change":return o(()=>{let x=r.has("remote"),b=i.JSON(!1,x);A!==b&&(A=b,l())});default:if(r.has("outside")){a=document;let x=l,b=!1;l=S=>{let v=S?.target;if(!v)return;let _=t.id===v.id;_&&b&&(b=!1),!_&&!b&&(x(S),b=!0)}}return a.addEventListener(g,l,c),()=>{a.removeEventListener(g,l)}}}};var Jt={type:1,name:"ref",onLoad:({el:t,key:e,value:n,signals:r})=>{if(e.length)throw f("No key allowed");if(!n.length)throw f("No value provided");return r.upsert(n,t),()=>r.remove(n)}};var zt={type:1,name:"text",onLoad:t=>{let{el:e,genRX:n,effect:r}=t,i=n();return e instanceof HTMLElement||f("Element is not HTMLElement"),r(()=>{let o=i(t);e.textContent=`${o}`})}};var{round:Vn,max:Fn,min:Hn}=Math,Xt={type:3,name:"fit",fn:(t,e,n,r,i,o,s=!1,a=!1)=>{let l=(e-n)/(r-n)*(o-i)+i;return a&&(l=Vn(l)),s&&(l=Fn(i,Hn(o,l))),l}};var Yt={type:3,name:"setAll",fn:(t,e,n)=>{let r=new RegExp(e);t.signals.walk((i,o)=>r.test(i)&&(o.value=n))}};var Qt={type:3,name:"toggleAll",fn:(t,e)=>{let n=new RegExp(e);t.signals.walk((r,i)=>n.test(r)&&(i.value=!i.value))}};Xe.load(bt,At,_t,wt,Vt,Wt,Ut,Bt,Gt,Kt,Jt,zt,Xt,Yt,Qt,tt,rt,gt,ht,vt,Et,it);})(); //# sourceMappingURL=datastar.js.map diff --git a/bundles/datastar.js.map b/bundles/datastar.js.map index 6ea219eb9..51e6b7251 100644 --- a/bundles/datastar.js.map +++ b/bundles/datastar.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../library/src/plugins/official/core/attributes/computed.ts", "../library/src/plugins/official/core/attributes/signals.ts", "../library/src/plugins/official/core/attributes/star.ts", "../library/src/plugins/official/core/macros/signals.ts", "../library/src/engine/consts.ts", "../library/src/utils/text.ts", "../library/src/engine/errors.ts", "../library/src/utils/dom.ts", "../library/src/vendored/preact-core.ts", "../library/src/engine/nestedSignals.ts", "../library/src/engine/engine.ts", "../library/src/engine/index.ts", "../library/src/vendored/fetch-event-source.ts", "../library/src/plugins/official/backend/shared.ts", "../library/src/plugins/official/backend/actions/sse.ts", "../library/src/plugins/official/backend/attributes/indicator.ts", "../library/src/plugins/official/backend/watchers/executeScript.ts", "../library/src/utils/view-transtions.ts", "../library/src/vendored/idiomorph.ts", "../library/src/plugins/official/backend/watchers/mergeFragments.ts", "../library/src/plugins/official/backend/watchers/mergeSignals.ts", "../library/src/plugins/official/backend/watchers/removeFragments.ts", "../library/src/plugins/official/backend/watchers/removeSignals.ts", "../library/src/plugins/official/browser/actions/clipboard.ts", "../library/src/plugins/official/browser/attributes/intersects.ts", "../library/src/plugins/official/browser/attributes/persist.ts", "../library/src/plugins/official/browser/attributes/replaceUrl.ts", "../library/src/plugins/official/browser/attributes/scrollIntoView.ts", "../library/src/plugins/official/browser/attributes/show.ts", "../library/src/plugins/official/browser/attributes/viewTransition.ts", "../library/src/plugins/official/dom/attributes/bind.ts", "../library/src/plugins/official/dom/attributes/class.ts", "../library/src/utils/arguments.ts", "../library/src/utils/timing.ts", "../library/src/plugins/official/dom/attributes/on.ts", "../library/src/plugins/official/dom/attributes/ref.ts", "../library/src/plugins/official/dom/attributes/text.ts", "../library/src/plugins/official/logic/actions/fit.ts", "../library/src/plugins/official/logic/actions/setAll.ts", "../library/src/plugins/official/logic/actions/toggleAll.ts", "../library/src/bundles/datastar.ts"], - "sourcesContent": ["import { AttributePlugin, PluginType } from \"../../../../engine/types\";\n\nconst name = \"computed\";\nexport const Computed: AttributePlugin = {\n type: PluginType.Attribute,\n name,\n purge: true,\n onLoad: ({ key, signals, genRX }) => {\n const rx = genRX();\n if (!key.length) {\n throw new Error(\"Computed attribute must have a key\");\n }\n signals.setComputed(key, rx);\n },\n};\n", "import {\n AttributePlugin,\n NestedValues,\n PluginType,\n} from \"../../../../engine/types\";\n\nexport const Signals: AttributePlugin = {\n type: PluginType.Attribute,\n name: \"signals\",\n purge: true,\n onLoad: ({ key, signals, genRX }) => {\n const rx = genRX();\n const toMerge = rx();\n if (key) {\n signals.setValue(key, toMerge);\n } else {\n signals.merge(toMerge);\n }\n },\n};\n", "import { AttributePlugin, PluginType } from \"../../../../engine/types\";\n\nexport const Star: AttributePlugin = {\n type: PluginType.Attribute,\n name: \"star\",\n onLoad: () => {\n alert(\"YOU ARE PROBABLY OVERCOMPLICATING IT\");\n },\n};\n", "import { MacroPlugin, PluginType } from \"../../../../engine/types\";\n\nexport const SignalValueMacro: MacroPlugin = {\n name: \"signalValue\",\n type: PluginType.Macro,\n fn: (original: string) => {\n const validJS = /(?[\\w0-9.]*)(.value)/gm;\n const sub = `ctx.signals.signal('$1').value`;\n return original.replaceAll(validJS, sub);\n },\n};\n", "// This is auto-generated by Datastar. DO NOT EDIT.\n\nexport const DATASTAR = \"datastar\";\nexport const DATASTAR_EVENT = \"datastar-event\";\nexport const DATASTAR_REQUEST = \"Datastar-Request\";\nexport const VERSION = \"0.20.1\";\n\n// #region Defaults\n\n// #region Default durations\n\n// The default duration for settling during merges. Allows for CSS transitions to complete.\nexport const DefaultSettleDurationMs = 300;\n// The default duration for retrying SSE on connection reset. This is part of the underlying retry mechanism of SSE.\nexport const DefaultSseRetryDurationMs = 1000;\n\n// #endregion\n\n\n// #region Default strings\n\n// The default attributes for