From a1fcf547520f8db916f452ffc4aa84c1c65e16a7 Mon Sep 17 00:00:00 2001 From: Ben Croker <57572400+bencroker@users.noreply.github.com> Date: Tue, 28 Jan 2025 10:24:54 -0600 Subject: [PATCH] Fix element check in `custom-validity` plugin (#544) * Fix hello world source * Fix element check in `custom-validity` plugin * Add HTMLSelectElement * Update release note --- CHANGELOG.md | 2 +- bundles/datastar.js | 10 +++++----- bundles/datastar.js.map | 4 ++-- .../official/browser/attributes/customValidity.ts | 2 +- sdk/go/consts.go | 4 ++-- site/routes_errors_runtime.templ | 2 +- site/static/md/examples/custom_validity.md | 15 +++++++-------- 7 files changed, 19 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f42df1a8..d2f50080 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ - Changed the `data-on-interval` attribute to accept a `__duration` modifier instead of a `__delay` modifier ([#513](https://github.com/starfederation/datastar/issues/513)). - Changed the parsing of Datastar expressions so that only semicolons can be used to explicitly indicate a statement delimiter ([#525](https://github.com/starfederation/datastar/issues/525)). -- The `data-custom-validity` attribute can now be used on all valid elements, not just input elements ([534](https://github.com/starfederation/datastar/pull/534)). +- The `data-custom-validity` attribute can now be used on select and textarea elements, in addition to input elements ([534](https://github.com/starfederation/datastar/pull/534)). ### Fixed diff --git a/bundles/datastar.js b/bundles/datastar.js index 223546eb..14fd2dc4 100644 --- a/bundles/datastar.js +++ b/bundles/datastar.js @@ -1,13 +1,13 @@ // Datastar v1.0.0-beta.2 var je=/🖕JS_DS🚀/.source,pe=je.slice(0,5),ke=je.slice(4),L="datastar";var Be="Datastar-Request",Ge="1.0.0-beta.2",me=300;var Ke="type module",ge=!1,Je=!1,ze=!0,O={Morph:"morph",Inner:"inner",Outer:"outer",Prepend:"prepend",Append:"append",Before:"before",After:"after",UpsertAttributes:"upsertAttributes"},Xe=O.Morph,I={MergeFragments:"datastar-merge-fragments",MergeSignals:"datastar-merge-signals",RemoveFragments:"datastar-remove-fragments",RemoveSignals:"datastar-remove-signals",ExecuteScript:"datastar-execute-script"};var p=(r=>(r[r.Attribute=1]="Attribute",r[r.Watcher=2]="Watcher",r[r.Action=3]="Action",r))(p||{});var xn="computed",Ye={type:1,name:xn,keyReq:1,valReq:1,onLoad:({key:t,signals:e,genRX:n})=>{let r=n();e.setComputed(t,r)}};var $=t=>t.trim()==="true",U=t=>t.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(e,n)=>(n?"-":"")+e.toLowerCase()),Ze=t=>t.replace(/(?:^\w|[A-Z]|\b\w)/g,(e,n)=>n===0?e.toLowerCase():e.toUpperCase()).replace(/\s+/g,""),he=t=>new Function(`return Object.assign({}, ${t})`)(),j=t=>t.startsWith("$")?t.slice(1):t;var Qe={type:1,name:"signals",removeOnLoad:!0,onLoad:t=>{let{key:e,value:n,genRX:r,signals:i,mods:o}=t,s=o.has("ifmissing");if(e!==""&&!s){let a=n===""?n:r()();i.setValue(e,a)}else{let a=he(t.value);t.value=JSON.stringify(a);let c=r()();i.merge(c,s)}}};var et={type:1,name:"star",keyReq:2,valReq:2,onLoad:()=>{alert("YOU ARE PROBABLY OVERCOMPLICATING IT")}};var ie=class{#e=0;#t;constructor(e=L){this.#t=e}with(e){if(typeof e=="string")for(let n of e.split(""))this.with(n.charCodeAt(0));else this.#e=(this.#e<<5)-this.#e+e;return this}reset(){return this.#e=0,this}get value(){return this.#t+Math.abs(this.#e).toString(36)}};function tt(t){if(t.id)return t.id;let e=new ie,n=t;for(;n.parentNode;){if(n.id){e.with(n.id);break}if(n===n.ownerDocument.documentElement)e.with(n.tagName);else for(let r=1,i=t;i.previousElementSibling;i=i.previousElementSibling,r++)e.with(r);n=n.parentNode}return e.value}function nt(t,e){let n=new MutationObserver(r=>{for(let i of r)for(let o of i.removedNodes)if(o===t){n.disconnect(),e();return}});n.observe(t.parentNode,{childList:!0})}var Pn=`${window.location.origin}/errors`;function De(t,e,n={}){let r=new Error;e=e[0].toUpperCase()+e.slice(1),r.name=`${L} ${t} error`;let i=U(e).replaceAll("-","_"),o=new URLSearchParams({metadata:JSON.stringify(n)}).toString(),s=JSON.stringify(n,null,2);return r.message=`${e} More info: ${Pn}/${t}/${i}?${o} -Context: ${s}`,r}function N(t,e,n={}){return De("internal",e,Object.assign({from:t},n))}function V(t,e,n={}){let r={plugin:{name:e.plugin.name,type:p[e.plugin.type]}};return De("init",t,Object.assign(r,n))}function y(t,e,n={}){let r={plugin:{name:e.plugin.name,type:p[e.plugin.type]},element:{id:e.el.id,tag:e.el.tagName},expression:{rawKey:e.rawKey,key:e.key,value:e.value,validSignals:e.signals.paths(),fnContent:e.fnContent}};return De("runtime",t,Object.assign(r,n))}var G="preact-signals",Nn=Symbol.for("preact-signals"),F=1,X=2,se=4,Z=8,ye=16,Y=32;function Oe(){ve++}function Ve(){if(ve>1){ve--;return}let t,e=!1;for(;oe!==void 0;){let n=oe;for(oe=void 0,Le++;n!==void 0;){let r=n._nextBatchedEffect;if(n._nextBatchedEffect=void 0,n._flags&=~X,!(n._flags&Z)&&it(n))try{n._callback()}catch(i){e||(t=i,e=!0)}n=r}}if(Le=0,ve--,e)throw N(G,"BatchError, error",{error:t})}var E;var oe,ve=0,Le=0,be=0;function rt(t){if(E===void 0)return;let e=t._node;if(e===void 0||e._target!==E)return e={_version:0,_source:t,_prevSource:E._sources,_nextSource:void 0,_target:E,_prevTarget:void 0,_nextTarget:void 0,_rollbackNode:e},E._sources!==void 0&&(E._sources._nextSource=e),E._sources=e,t._node=e,E._flags&Y&&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=E._sources,e._nextSource=void 0,E._sources._nextSource=e,E._sources=e),e}function x(t){this._value=t,this._version=0,this._node=void 0,this._targets=void 0}x.prototype.brand=Nn;x.prototype._refresh=()=>!0;x.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)};x.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)}};x.prototype.subscribe=function(t){return Se(()=>{let e=this.value,n=E;E=void 0;try{t(e)}finally{E=n}})};x.prototype.valueOf=function(){return this.value};x.prototype.toString=function(){return`${this.value}`};x.prototype.toJSON=function(){return this.value};x.prototype.peek=function(){let t=E;E=void 0;try{return this.value}finally{E=t}};Object.defineProperty(x.prototype,"value",{get(){let t=rt(this);return t!==void 0&&(t._version=this._version),this._value},set(t){if(t!==this._value){if(Le>100)throw N(G,"SignalCycleDetected");this._value=t,this._version++,be++,Oe();try{for(let e=this._targets;e!==void 0;e=e._nextTarget)e._target._notify()}finally{Ve()}}}});function it(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 ot(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 st(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 K(t){x.call(this,void 0),this._fn=t,this._sources=void 0,this._globalVersion=be-1,this._flags=se}K.prototype=new x;K.prototype._refresh=function(){if(this._flags&=~X,this._flags&F)return!1;if((this._flags&(se|Y))===Y||(this._flags&=~se,this._globalVersion===be))return!0;if(this._globalVersion=be,this._flags|=F,this._version>0&&!it(this))return this._flags&=~F,!0;let t=E;try{ot(this),E=this;let e=this._fn();(this._flags&ye||this._value!==e||this._version===0)&&(this._value=e,this._flags&=~ye,this._version++)}catch(e){this._value=e,this._flags|=ye,this._version++}return E=t,st(this),this._flags&=~F,!0};K.prototype._subscribe=function(t){if(this._targets===void 0){this._flags|=se|Y;for(let e=this._sources;e!==void 0;e=e._nextSource)e._source._subscribe(e)}x.prototype._subscribe.call(this,t)};K.prototype._unsubscribe=function(t){if(this._targets!==void 0&&(x.prototype._unsubscribe.call(this,t),this._targets===void 0)){this._flags&=~Y;for(let e=this._sources;e!==void 0;e=e._nextSource)e._source._unsubscribe(e)}};K.prototype._notify=function(){if(!(this._flags&X)){this._flags|=se|X;for(let t=this._targets;t!==void 0;t=t._nextTarget)t._target._notify()}};Object.defineProperty(K.prototype,"value",{get(){if(this._flags&F)throw N(G,"SignalCycleDetected");let t=rt(this);if(this._refresh(),t!==void 0&&(t._version=this._version),this._flags&ye)throw N(G,"GetComputedError",{value:this._value});return this._value}});function at(t){return new K(t)}function lt(t){let e=t._cleanup;if(t._cleanup=void 0,typeof e=="function"){Oe();let n=E;E=void 0;try{e()}catch(r){throw t._flags&=~F,t._flags|=Z,Fe(t),N(G,"CleanupEffectError",{error:r})}finally{E=n,Ve()}}}function Fe(t){for(let e=t._sources;e!==void 0;e=e._nextSource)e._source._unsubscribe(e);t._fn=void 0,t._sources=void 0,lt(t)}function Mn(t){if(E!==this)throw N(G,"EndEffectError");st(this),E=t,this._flags&=~F,this._flags&Z&&Fe(this),Ve()}function ae(t){this._fn=t,this._cleanup=void 0,this._sources=void 0,this._nextBatchedEffect=void 0,this._flags=Y}ae.prototype._callback=function(){let t=this._start();try{if(this._flags&Z||this._fn===void 0)return;let e=this._fn();typeof e=="function"&&(this._cleanup=e)}finally{t()}};ae.prototype._start=function(){if(this._flags&F)throw N(G,"SignalCycleDetected");this._flags|=F,this._flags&=~Z,lt(this),ot(this),Oe();let t=E;return E=this,Mn.bind(this,t)};ae.prototype._notify=function(){this._flags&X||(this._flags|=X,this._nextBatchedEffect=oe,oe=this)};ae.prototype._dispose=function(){this._flags|=Z,this._flags&F||Fe(this)};function Se(t){let e=new ae(t);try{e._callback()}catch(n){throw e._dispose(),n}return e._dispose.bind(e)}var ut="namespacedSignals";function ct(t,e=!1){let n={};for(let r in t)if(Object.hasOwn(t,r)){if(e&&r.startsWith("_"))continue;let i=t[r];i instanceof x?n[r]=i.value:n[r]=ct(i)}return n}function ft(t,e,n=!1){for(let r in e)if(Object.hasOwn(e,r)){if(r.match(/\_\_+/))throw N(ut,"InvalidSignalKey",{key:r});let i=e[r];if(i instanceof Object&&!Array.isArray(i))t[r]||(t[r]={}),ft(t[r],i,n);else{if(Object.hasOwn(t,r)){if(n)continue;let s=t[r];if(s instanceof x){s.value=i;continue}}t[r]=new x(i)}}}function dt(t,e){for(let n in t)if(Object.hasOwn(t,n)){let r=t[n];r instanceof x?e(n,r):dt(r,(i,o)=>{e(`${n}.${i}`,o)})}}function Cn(t,...e){let n={};for(let r of e){let i=r.split("."),o=t,s=n;for(let u=0;un());this.setSignal(e,r)}value(e){return this.signal(e)?.value}setValue(e,n){let r=this.upsertIfMissing(e,n);r.value=n}upsertIfMissing(e,n){let r=e.split("."),i=this.#e;for(let u=0;ue.push(n)),e}values(e=!1){return ct(this.#e,e)}JSON(e=!0,n=!1){let r=this.values(n);return e?JSON.stringify(r,null,2):JSON.stringify(r)}toString(){return this.JSON()}};var Te=class{#e=new Ee;#t=[];#r={};#s=[];#n=new Map;get signals(){return this.#e}get version(){return Ge}load(...e){for(let n of e){let r=this,i={get signals(){return r.#e},effect:s=>Se(s),actions:this.#r,apply:this.apply.bind(this),cleanup:this.#i.bind(this),plugin:n},o;switch(n.type){case 2:{let s=n;this.#s.push(s),o=s.onGlobalInit;break}case 3:{this.#r[n.name]=n;break}case 1:{let s=n;this.#t.push(s),o=s.onGlobalInit;break}default:throw V("InvalidPluginType",i)}o&&o(i)}this.#t.sort((n,r)=>{let i=r.name.length-n.name.length;return i!==0?i:n.name.localeCompare(r.name)})}apply(e){this.#o(e,n=>{this.#i(n);for(let r of Object.keys(n.dataset)){let i=this.#t.find(h=>r.startsWith(h.name));if(!i)continue;n.id.length||(n.id=tt(n));let[o,...s]=r.slice(i.name.length).split(/\_\_+/),a=o.length>0;if(a){let h=o.slice(1);o=o.startsWith("-")?h:o[0].toLowerCase()+h}let u=`${n.dataset[r]}`||"",c=u.length>0,l=this,f={get signals(){return l.#e},effect:h=>Se(h),apply:this.apply.bind(this),cleanup:this.#i.bind(this),actions:this.#r,genRX:()=>this.#a(f,...i.argNames||[]),plugin:i,el:n,rawKey:r,key:o,value:u,mods:new Map},g=i.keyReq||0;if(a){if(g===2)throw y(`${i.name}KeyNotAllowed`,f)}else if(g===1)throw y(`${i.name}KeyRequired`,f);let A=i.valReq||0;if(c){if(A===2)throw y(`${i.name}ValueNotAllowed`,f)}else if(A===1)throw y(`${i.name}ValueRequired`,f);if(g===3||A===3){if(a&&c)throw y(`${i.name}KeyAndValueProvided`,f);if(!a&&!c)throw y(`${i.name}KeyOrValueRequired`,f)}for(let h of s){let[d,...b]=h.split(".");f.mods.set(Ze(d),new Set(b.map(w=>w.toLowerCase())))}let v=i.onLoad(f);v&&(this.#n.has(n)||this.#n.set(n,{id:n.id,fns:[]}),this.#n.get(n)?.fns.push(v)),i?.removeOnLoad&&delete n.dataset[r]}})}#a(e,...n){let r="",i=/(\/(\\\/|[^\/])*\/|"(\\"|[^\"])*"|'(\\'|[^'])*'|`(\\`|[^`])*`|[^;])+/gm,o=e.value.trim().match(i);if(o){let v=o.length-1,h=o[v].trim();h.startsWith("return")||(o[v]=`return (${h});`),r=o.join(`; +Context: ${s}`,r}function M(t,e,n={}){return De("internal",e,Object.assign({from:t},n))}function V(t,e,n={}){let r={plugin:{name:e.plugin.name,type:p[e.plugin.type]}};return De("init",t,Object.assign(r,n))}function y(t,e,n={}){let r={plugin:{name:e.plugin.name,type:p[e.plugin.type]},element:{id:e.el.id,tag:e.el.tagName},expression:{rawKey:e.rawKey,key:e.key,value:e.value,validSignals:e.signals.paths(),fnContent:e.fnContent}};return De("runtime",t,Object.assign(r,n))}var G="preact-signals",Mn=Symbol.for("preact-signals"),F=1,X=2,se=4,Z=8,ye=16,Y=32;function Oe(){ve++}function Ve(){if(ve>1){ve--;return}let t,e=!1;for(;oe!==void 0;){let n=oe;for(oe=void 0,Le++;n!==void 0;){let r=n._nextBatchedEffect;if(n._nextBatchedEffect=void 0,n._flags&=~X,!(n._flags&Z)&&it(n))try{n._callback()}catch(i){e||(t=i,e=!0)}n=r}}if(Le=0,ve--,e)throw M(G,"BatchError, error",{error:t})}var E;var oe,ve=0,Le=0,be=0;function rt(t){if(E===void 0)return;let e=t._node;if(e===void 0||e._target!==E)return e={_version:0,_source:t,_prevSource:E._sources,_nextSource:void 0,_target:E,_prevTarget:void 0,_nextTarget:void 0,_rollbackNode:e},E._sources!==void 0&&(E._sources._nextSource=e),E._sources=e,t._node=e,E._flags&Y&&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=E._sources,e._nextSource=void 0,E._sources._nextSource=e,E._sources=e),e}function x(t){this._value=t,this._version=0,this._node=void 0,this._targets=void 0}x.prototype.brand=Mn;x.prototype._refresh=()=>!0;x.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)};x.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)}};x.prototype.subscribe=function(t){return Se(()=>{let e=this.value,n=E;E=void 0;try{t(e)}finally{E=n}})};x.prototype.valueOf=function(){return this.value};x.prototype.toString=function(){return`${this.value}`};x.prototype.toJSON=function(){return this.value};x.prototype.peek=function(){let t=E;E=void 0;try{return this.value}finally{E=t}};Object.defineProperty(x.prototype,"value",{get(){let t=rt(this);return t!==void 0&&(t._version=this._version),this._value},set(t){if(t!==this._value){if(Le>100)throw M(G,"SignalCycleDetected");this._value=t,this._version++,be++,Oe();try{for(let e=this._targets;e!==void 0;e=e._nextTarget)e._target._notify()}finally{Ve()}}}});function it(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 ot(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 st(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 K(t){x.call(this,void 0),this._fn=t,this._sources=void 0,this._globalVersion=be-1,this._flags=se}K.prototype=new x;K.prototype._refresh=function(){if(this._flags&=~X,this._flags&F)return!1;if((this._flags&(se|Y))===Y||(this._flags&=~se,this._globalVersion===be))return!0;if(this._globalVersion=be,this._flags|=F,this._version>0&&!it(this))return this._flags&=~F,!0;let t=E;try{ot(this),E=this;let e=this._fn();(this._flags&ye||this._value!==e||this._version===0)&&(this._value=e,this._flags&=~ye,this._version++)}catch(e){this._value=e,this._flags|=ye,this._version++}return E=t,st(this),this._flags&=~F,!0};K.prototype._subscribe=function(t){if(this._targets===void 0){this._flags|=se|Y;for(let e=this._sources;e!==void 0;e=e._nextSource)e._source._subscribe(e)}x.prototype._subscribe.call(this,t)};K.prototype._unsubscribe=function(t){if(this._targets!==void 0&&(x.prototype._unsubscribe.call(this,t),this._targets===void 0)){this._flags&=~Y;for(let e=this._sources;e!==void 0;e=e._nextSource)e._source._unsubscribe(e)}};K.prototype._notify=function(){if(!(this._flags&X)){this._flags|=se|X;for(let t=this._targets;t!==void 0;t=t._nextTarget)t._target._notify()}};Object.defineProperty(K.prototype,"value",{get(){if(this._flags&F)throw M(G,"SignalCycleDetected");let t=rt(this);if(this._refresh(),t!==void 0&&(t._version=this._version),this._flags&ye)throw M(G,"GetComputedError",{value:this._value});return this._value}});function at(t){return new K(t)}function lt(t){let e=t._cleanup;if(t._cleanup=void 0,typeof e=="function"){Oe();let n=E;E=void 0;try{e()}catch(r){throw t._flags&=~F,t._flags|=Z,Fe(t),M(G,"CleanupEffectError",{error:r})}finally{E=n,Ve()}}}function Fe(t){for(let e=t._sources;e!==void 0;e=e._nextSource)e._source._unsubscribe(e);t._fn=void 0,t._sources=void 0,lt(t)}function Nn(t){if(E!==this)throw M(G,"EndEffectError");st(this),E=t,this._flags&=~F,this._flags&Z&&Fe(this),Ve()}function ae(t){this._fn=t,this._cleanup=void 0,this._sources=void 0,this._nextBatchedEffect=void 0,this._flags=Y}ae.prototype._callback=function(){let t=this._start();try{if(this._flags&Z||this._fn===void 0)return;let e=this._fn();typeof e=="function"&&(this._cleanup=e)}finally{t()}};ae.prototype._start=function(){if(this._flags&F)throw M(G,"SignalCycleDetected");this._flags|=F,this._flags&=~Z,lt(this),ot(this),Oe();let t=E;return E=this,Nn.bind(this,t)};ae.prototype._notify=function(){this._flags&X||(this._flags|=X,this._nextBatchedEffect=oe,oe=this)};ae.prototype._dispose=function(){this._flags|=Z,this._flags&F||Fe(this)};function Se(t){let e=new ae(t);try{e._callback()}catch(n){throw e._dispose(),n}return e._dispose.bind(e)}var ut="namespacedSignals";function ct(t,e=!1){let n={};for(let r in t)if(Object.hasOwn(t,r)){if(e&&r.startsWith("_"))continue;let i=t[r];i instanceof x?n[r]=i.value:n[r]=ct(i)}return n}function ft(t,e,n=!1){for(let r in e)if(Object.hasOwn(e,r)){if(r.match(/\_\_+/))throw M(ut,"InvalidSignalKey",{key:r});let i=e[r];if(i instanceof Object&&!Array.isArray(i))t[r]||(t[r]={}),ft(t[r],i,n);else{if(Object.hasOwn(t,r)){if(n)continue;let s=t[r];if(s instanceof x){s.value=i;continue}}t[r]=new x(i)}}}function dt(t,e){for(let n in t)if(Object.hasOwn(t,n)){let r=t[n];r instanceof x?e(n,r):dt(r,(i,o)=>{e(`${n}.${i}`,o)})}}function Cn(t,...e){let n={};for(let r of e){let i=r.split("."),o=t,s=n;for(let u=0;un());this.setSignal(e,r)}value(e){return this.signal(e)?.value}setValue(e,n){let r=this.upsertIfMissing(e,n);r.value=n}upsertIfMissing(e,n){let r=e.split("."),i=this.#e;for(let u=0;ue.push(n)),e}values(e=!1){return ct(this.#e,e)}JSON(e=!0,n=!1){let r=this.values(n);return e?JSON.stringify(r,null,2):JSON.stringify(r)}toString(){return this.JSON()}};var Te=class{#e=new Ee;#t=[];#r={};#s=[];#n=new Map;get signals(){return this.#e}get version(){return Ge}load(...e){for(let n of e){let r=this,i={get signals(){return r.#e},effect:s=>Se(s),actions:this.#r,apply:this.apply.bind(this),cleanup:this.#i.bind(this),plugin:n},o;switch(n.type){case 2:{let s=n;this.#s.push(s),o=s.onGlobalInit;break}case 3:{this.#r[n.name]=n;break}case 1:{let s=n;this.#t.push(s),o=s.onGlobalInit;break}default:throw V("InvalidPluginType",i)}o&&o(i)}this.#t.sort((n,r)=>{let i=r.name.length-n.name.length;return i!==0?i:n.name.localeCompare(r.name)})}apply(e){this.#o(e,n=>{this.#i(n);for(let r of Object.keys(n.dataset)){let i=this.#t.find(h=>r.startsWith(h.name));if(!i)continue;n.id.length||(n.id=tt(n));let[o,...s]=r.slice(i.name.length).split(/\_\_+/),a=o.length>0;if(a){let h=o.slice(1);o=o.startsWith("-")?h:o[0].toLowerCase()+h}let u=`${n.dataset[r]}`||"",c=u.length>0,l=this,f={get signals(){return l.#e},effect:h=>Se(h),apply:this.apply.bind(this),cleanup:this.#i.bind(this),actions:this.#r,genRX:()=>this.#a(f,...i.argNames||[]),plugin:i,el:n,rawKey:r,key:o,value:u,mods:new Map},g=i.keyReq||0;if(a){if(g===2)throw y(`${i.name}KeyNotAllowed`,f)}else if(g===1)throw y(`${i.name}KeyRequired`,f);let A=i.valReq||0;if(c){if(A===2)throw y(`${i.name}ValueNotAllowed`,f)}else if(A===1)throw y(`${i.name}ValueRequired`,f);if(g===3||A===3){if(a&&c)throw y(`${i.name}KeyAndValueProvided`,f);if(!a&&!c)throw y(`${i.name}KeyOrValueRequired`,f)}for(let h of s){let[d,...b]=h.split(".");f.mods.set(Ze(d),new Set(b.map(w=>w.toLowerCase())))}let v=i.onLoad(f);v&&(this.#n.has(n)||this.#n.set(n,{id:n.id,fns:[]}),this.#n.get(n)?.fns.push(v)),i?.removeOnLoad&&delete n.dataset[r]}})}#a(e,...n){let r="",i=/(\/(\\\/|[^\/])*\/|"(\\"|[^\"])*"|'(\\'|[^'])*'|`(\\`|[^`])*`|[^;])+/gm,o=e.value.trim().match(i);if(o){let v=o.length-1,h=o[v].trim();h.startsWith("return")||(o[v]=`return (${h});`),r=o.join(`; `)}let s=new Map,a=new RegExp(`(?:${pe})(.*?)(?:${ke})`,"gm");for(let v of r.matchAll(a)){let h=v[1],d=new ie("dsEscaped").with(h).value;s.set(d,h),r=r.replace(pe+h+ke,d)}let u=/@(\w*)\(/gm,c=r.matchAll(u),l=new Set;for(let v of c)l.add(v[1]);let f=new RegExp(`@(${Object.keys(this.#r).join("|")})\\(`,"gm");r=r.replaceAll(f,"ctx.actions.$1.fn(ctx,");let g=e.signals.paths();if(g.length){let v=new RegExp(`\\$(${g.join("|")})(\\W|$)`,"gm");r=r.replaceAll(v,"ctx.signals.signal('$1').value$2")}for(let[v,h]of s)r=r.replace(v,h);let A=`return (()=> { ${r} })()`;e.fnContent=A;try{let v=new Function("ctx",...n,A);return(...h)=>{try{return v(e,...h)}catch(d){throw y("ExecuteExpression",e,{error:d.message})}}}catch(v){throw y("GenerateExpression",e,{error:v.message})}}#o(e,n){if(!e||!(e instanceof HTMLElement||e instanceof SVGElement))return null;let r=e.dataset;if("starIgnore"in r)return null;"starIgnore__self"in r||n(e);let i=e.firstElementChild;for(;i;)this.#o(i,n),i=i.nextElementSibling}#i(e){let n=this.#n.get(e);if(n){for(let r of n.fns)r();this.#n.delete(e)}}};var pt=new Te;pt.load(et,Qe,Ye);var Ae=pt;async function In(t,e){let n=t.getReader(),r;for(;!(r=await n.read()).done;)e(r.value)}function kn(t){let e,n,r,i=!1;return function(s){e===void 0?(e=s,n=0,r=-1):e=Ln(e,s);let a=e.length,u=0;for(;n0){let u=i.decode(s.subarray(0,a)),c=a+(s[a+1]===32?2:1),l=i.decode(s.subarray(c));switch(u){case"data":r.data=r.data?`${r.data} -${l}`:l;break;case"event":r.event=l;break;case"id":t(r.id=l);break;case"retry":{let f=Number.parseInt(l,10);Number.isNaN(f)||e(r.retry=f);break}}}}}function Ln(t,e){let n=new Uint8Array(t.length+e.length);return n.set(t),n.set(e,t.length),n}function mt(){return{data:"",event:"",id:"",retry:void 0}}var On="text/event-stream",gt="last-event-id";function ht(t,e,{signal:n,headers:r,onopen:i,onmessage:o,onclose:s,onerror:a,openWhenHidden:u,fetch:c,retryInterval:l=1e3,retryScaler:f=2,retryMaxWaitMs:g=3e4,retryMaxCount:A=10,...v}){return new Promise((h,d)=>{let b=0,w={...r};w.accept||(w.accept=On);let S;function T(){S.abort(),document.hidden||D()}u||document.addEventListener("visibilitychange",T);let _=0;function P(){document.removeEventListener("visibilitychange",T),window.clearTimeout(_),S.abort()}n?.addEventListener("abort",()=>{P(),h()});let M=c??window.fetch,m=i??function(){};async function D(){S=new AbortController;try{let C=await M(e,{...v,headers:w,signal:S.signal});await m(C),await In(C.body,kn(Dn(R=>{R?w[gt]=R:delete w[gt]},R=>{l=R},o))),s?.(),P(),h()}catch(C){if(!S.signal.aborted)try{let R=a?.(C)??l;window.clearTimeout(_),_=window.setTimeout(D,R),l*=f,l=Math.min(l,g),b++,b>=A?(P(),d(y("SseMaxRetries",t,{retryMaxCount:A}))):console.error(`Datastar failed to reach ${v.method}: ${e.toString()} retry in ${R}ms`)}catch(R){P(),d(R)}}}D()})}var Q=`${L}-sse`,He=`${L}-settling`,J=`${L}-swapping`,_e="started",Re="finished",yt="error";function H(t,e){document.addEventListener(Q,n=>{if(n.detail.type!==t)return;let{argsRaw:r}=n.detail;e(r)})}function we(t,e){document.dispatchEvent(new CustomEvent(Q,{detail:{type:t,argsRaw:e}}))}var vt=t=>`${t}`.includes("text/event-stream"),q=async(t,e,n,r)=>{let{el:{id:i},el:o,signals:s}=t,{headers:a,contentType:u,includeLocal:c,selector:l,openWhenHidden:f,retryInterval:g,retryScaler:A,retryMaxWaitMs:v,retryMaxCount:h,abort:d}=Object.assign({headers:{},contentType:"json",includeLocal:!1,selector:null,openWhenHidden:!1,retryInterval:1e3,retryScaler:2,retryMaxWaitMs:3e4,retryMaxCount:10,abort:void 0},r),b=e.toLowerCase(),w=()=>{};try{if(we(_e,{elId:i}),!n?.length)throw y("SseNoUrlProvided",t,{action:b});let S={};S[Be]=!0,u==="json"&&(S["Content-Type"]="application/json");let T=Object.assign({},S,a),_={method:e,headers:T,openWhenHidden:f,retryInterval:g,retryScaler:A,retryMaxWaitMs:v,retryMaxCount:h,signal:d,onopen:async m=>{if(m.status>=400){let D=m.status.toString();we(yt,{status:D})}},onmessage:m=>{if(!m.event.startsWith(L))return;let D=m.event,C={},R=m.data.split(` +${l}`:l;break;case"event":r.event=l;break;case"id":t(r.id=l);break;case"retry":{let f=Number.parseInt(l,10);Number.isNaN(f)||e(r.retry=f);break}}}}}function Ln(t,e){let n=new Uint8Array(t.length+e.length);return n.set(t),n.set(e,t.length),n}function mt(){return{data:"",event:"",id:"",retry:void 0}}var On="text/event-stream",gt="last-event-id";function ht(t,e,{signal:n,headers:r,onopen:i,onmessage:o,onclose:s,onerror:a,openWhenHidden:u,fetch:c,retryInterval:l=1e3,retryScaler:f=2,retryMaxWaitMs:g=3e4,retryMaxCount:A=10,...v}){return new Promise((h,d)=>{let b=0,w={...r};w.accept||(w.accept=On);let S;function T(){S.abort(),document.hidden||D()}u||document.addEventListener("visibilitychange",T);let _=0;function P(){document.removeEventListener("visibilitychange",T),window.clearTimeout(_),S.abort()}n?.addEventListener("abort",()=>{P(),h()});let N=c??window.fetch,m=i??function(){};async function D(){S=new AbortController;try{let C=await N(e,{...v,headers:w,signal:S.signal});await m(C),await In(C.body,kn(Dn(R=>{R?w[gt]=R:delete w[gt]},R=>{l=R},o))),s?.(),P(),h()}catch(C){if(!S.signal.aborted)try{let R=a?.(C)??l;window.clearTimeout(_),_=window.setTimeout(D,R),l*=f,l=Math.min(l,g),b++,b>=A?(P(),d(y("SseMaxRetries",t,{retryMaxCount:A}))):console.error(`Datastar failed to reach ${v.method}: ${e.toString()} retry in ${R}ms`)}catch(R){P(),d(R)}}}D()})}var Q=`${L}-sse`,He=`${L}-settling`,J=`${L}-swapping`,_e="started",Re="finished",yt="error";function H(t,e){document.addEventListener(Q,n=>{if(n.detail.type!==t)return;let{argsRaw:r}=n.detail;e(r)})}function we(t,e){document.dispatchEvent(new CustomEvent(Q,{detail:{type:t,argsRaw:e}}))}var vt=t=>`${t}`.includes("text/event-stream"),q=async(t,e,n,r)=>{let{el:{id:i},el:o,signals:s}=t,{headers:a,contentType:u,includeLocal:c,selector:l,openWhenHidden:f,retryInterval:g,retryScaler:A,retryMaxWaitMs:v,retryMaxCount:h,abort:d}=Object.assign({headers:{},contentType:"json",includeLocal:!1,selector:null,openWhenHidden:!1,retryInterval:1e3,retryScaler:2,retryMaxWaitMs:3e4,retryMaxCount:10,abort:void 0},r),b=e.toLowerCase(),w=()=>{};try{if(we(_e,{elId:i}),!n?.length)throw y("SseNoUrlProvided",t,{action:b});let S={};S[Be]=!0,u==="json"&&(S["Content-Type"]="application/json");let T=Object.assign({},S,a),_={method:e,headers:T,openWhenHidden:f,retryInterval:g,retryScaler:A,retryMaxWaitMs:v,retryMaxCount:h,signal:d,onopen:async m=>{if(m.status>=400){let D=m.status.toString();we(yt,{status:D})}},onmessage:m=>{if(!m.event.startsWith(L))return;let D=m.event,C={},R=m.data.split(` `);for(let re of R){let fe=re.indexOf(" "),Ue=re.slice(0,fe),de=C[Ue];de||(de=[],C[Ue]=de);let wn=re.slice(fe+1).trim();de.push(wn)}let W={};for(let[re,fe]of Object.entries(C))W[re]=fe.join(` -`);we(D,W)},onerror:m=>{if(vt(m))throw y("InvalidContentType",t,{url:n});m&&console.error(m.message)}},P=new URL(n,window.location.origin),M=new URLSearchParams(P.search);if(u==="json"){let m=s.JSON(!1,!c);e==="GET"?M.set(L,m):_.body=m}else if(u==="form"){let m=l?document.querySelector(l):o.closest("form");if(m===null)throw l?y("SseFormNotFound",t,{action:b,selector:l}):y("SseClosestFormNotFound",t,{action:b});if(o!==m){let C=R=>R.preventDefault();m.addEventListener("submit",C),w=()=>m.removeEventListener("submit",C)}if(!m.checkValidity()){m.reportValidity(),w();return}let D=new FormData(m);if(e==="GET"){let C=new URLSearchParams(D);for(let[R,W]of C)M.set(R,W)}else _.body=D}else throw y("SseInvalidContentType",t,{action:b,contentType:u});P.search=M.toString();try{await ht(t,P.toString(),_)}catch(m){if(!vt(m))throw y("SseFetchFailed",t,{method:e,url:n,error:m})}}finally{we(Re,{elId:i}),w()}};var bt={type:3,name:"delete",fn:async(t,e,n)=>q(t,"DELETE",e,{...n})};var St={type:3,name:"get",fn:async(t,e,n)=>q(t,"GET",e,{...n})};var Et={type:3,name:"patch",fn:async(t,e,n)=>q(t,"PATCH",e,{...n})};var Tt={type:3,name:"post",fn:async(t,e,n)=>q(t,"POST",e,{...n})};var At={type:3,name:"put",fn:async(t,e,n)=>q(t,"PUT",e,{...n})};var _t={type:1,name:"indicator",keyReq:3,valReq:3,onLoad:({value:t,signals:e,el:n,key:r})=>{let i=r||j(t),o=e.upsertIfMissing(i,!1),s=a=>{let{type:u,argsRaw:{elId:c}}=a.detail;if(c===n.id)switch(u){case _e:o.value=!0;break;case Re:o.value=!1;break}};return document.addEventListener(Q,s),()=>{document.removeEventListener(Q,s)}}};var Rt={type:2,name:I.ExecuteScript,onGlobalInit:async t=>{H(I.ExecuteScript,({autoRemove:e=`${ze}`,attributes:n=Ke,script:r})=>{let i=$(e);if(!r?.length)throw V("NoScriptProvided",t);let o=document.createElement("script");for(let s of n.split(` -`)){let a=s.indexOf(" "),u=a?s.slice(0,a):s,c=a?s.slice(a):"";o.setAttribute(u.trim(),c.trim())}o.text=r,document.head.appendChild(o),i&&o.remove()})}};var le=document,ee=!!le.startViewTransition;var te="idiomorph",Pe=new WeakSet;function Nt(t,e,n={}){t instanceof Document&&(t=t.documentElement);let r;typeof e=="string"?r=Wn(e):r=e;let i=$n(r),o=Fn(t,i,n);return Mt(t,i,o)}function Mt(t,e,n){if(n.head.block){let r=t.querySelector("head"),i=e.querySelector("head");if(r&&i){let o=It(i,r,n);Promise.all(o).then(()=>{Mt(t,e,Object.assign(n,{head:{block:!1,ignore:!0}}))});return}}if(n.morphStyle==="innerHTML")return Ct(e,t,n),t.children;if(n.morphStyle==="outerHTML"||n.morphStyle==null){let r=jn(e,t,n);if(!r)throw N(te,"NoBestMatchFound",{old:t,new:e});let i=r?.previousSibling,o=r?.nextSibling,s=Ne(t,r,n);return r?Un(i,s,o):[]}throw N(te,"InvalidMorphStyle",{style:n.morphStyle})}function Ne(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(Me(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!==O.Morph?It(e,t,n):(Vn(e,t),Ct(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 N(te,"NoParentElementFound",{oldNode:t});return t.parentElement.replaceChild(e,t),n.callbacks.afterNodeAdded(e),n.callbacks.afterNodeRemoved(t),e}}function Ct(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),z(n,o);continue}if(kt(o,i,n)){Ne(i,o,n),i=i.nextSibling,z(n,o);continue}let s=Hn(t,e,o,i,n);if(s){i=wt(i,s,n),Ne(s,o,n),z(n,o);continue}let a=qn(t,o,i,n);if(a){i=wt(i,a,n),Ne(a,o,n),z(n,o);continue}if(n.callbacks.beforeNodeAdded(o)===!1)return;e.insertBefore(o,i),n.callbacks.afterNodeAdded(o),z(n,o)}for(;i!==null;){let s=i;i=i.nextSibling,Dt(s,n)}}function Vn(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||"",xe(t,e,"value"),xe(t,e,"checked"),xe(t,e,"disabled");else if(t instanceof HTMLOptionElement)xe(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 xe(t,e,n){let r=t.getAttribute(n),i=e.getAttribute(n);r!==i&&(r?e.setAttribute(n,r):e.removeAttribute(n))}function It(t,e,n){let r=[],i=[],o=[],s=[],a=n.head.style,u=new Map;for(let l of t.children)u.set(l.outerHTML,l);for(let l of e.children){let f=u.has(l.outerHTML),g=n.head.shouldReAppend(l),A=n.head.shouldPreserve(l);f||A?g?i.push(l):(u.delete(l.outerHTML),o.push(l)):a===O.Append?g&&(i.push(l),s.push(l)):n.head.shouldRemove(l)!==!1&&i.push(l)}s.push(...u.values());let c=[];for(let l of s){let f=document.createRange().createContextualFragment(l.outerHTML).firstChild;if(!f)throw N(te,"NewElementCouldNotBeCreated",{newNode:l});if(n.callbacks.beforeNodeAdded(f)){if(f.hasAttribute("href")||f.hasAttribute("src")){let g,A=new Promise(v=>{g=v});f.addEventListener("load",()=>{g(void 0)}),c.push(A)}e.appendChild(f),n.callbacks.afterNodeAdded(f),r.push(f)}}for(let l of i)n.callbacks.beforeNodeRemoved(l)!==!1&&(e.removeChild(l),n.callbacks.afterNodeRemoved(l));return n.head.afterHeadMorphed(e,{added:r,kept:o,removed:i}),c}function B(){}function Fn(t,e,n){return{target:t,newContent:e,config:n,morphStyle:n.morphStyle,ignoreActive:n.ignoreActive,idMap:Jn(t,e),deadIds:new Set,callbacks:Object.assign({beforeNodeAdded:B,afterNodeAdded:B,beforeNodeMorphed:B,afterNodeMorphed:B,beforeNodeRemoved:B,afterNodeRemoved:B},n.callbacks),head:Object.assign({style:"merge",shouldPreserve:r=>r.getAttribute("im-preserve")==="true",shouldReAppend:r=>r.getAttribute("im-re-append")==="true",shouldRemove:B,afterHeadMorphed:B},n.head)}}function kt(t,e,n){return!t||!e?!1:t.nodeType===e.nodeType&&t.tagName===e.tagName?t?.id?.length&&t.id===e.id?!0:ue(n,t,e)>0:!1}function Me(t,e){return!t||!e?!1:t.nodeType===e.nodeType&&t.tagName===e.tagName}function wt(t,e,n){for(;t!==e;){let r=t;if(t=t?.nextSibling,!r)throw N(te,"NoTemporaryNodeFound",{startInclusive:t,endExclusive:e});Dt(r,n)}return z(n,e),e.nextSibling}function Hn(t,e,n,r,i){let o=ue(i,n,e),s=null;if(o>0){s=r;let a=0;for(;s!=null;){if(kt(n,s,i))return s;if(a+=ue(i,s,t),a>o)return null;s=s.nextSibling}}return s}function qn(t,e,n,r){let i=n,o=e.nextSibling,s=0;for(;i&&o;){if(ue(r,i,t)>0)return null;if(Me(e,i))return i;if(Me(o,i)&&(s++,o=o.nextSibling,s>=2))return null;i=i.nextSibling}return i}var xt=new DOMParser;function Wn(t){let e=t.replace(/]*>|>)([\s\S]*?)<\/svg>/gim,"");if(e.match(/<\/html>/)||e.match(/<\/head>/)||e.match(/<\/body>/)){let i=xt.parseFromString(t,"text/html");if(e.match(/<\/html>/))return Pe.add(i),i;let o=i.firstChild;return o?(Pe.add(o),o):null}let r=xt.parseFromString(``,"text/html").body.querySelector("template")?.content;if(!r)throw N(te,"NoContentFound",{newContent:t});return Pe.add(r),r}function $n(t){if(t==null)return document.createElement("div");if(Pe.has(t))return t;if(t instanceof Node){let n=document.createElement("div");return n.append(t),n}let e=document.createElement("div");for(let n of[...t])e.append(n);return e}function Un(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 jn(t,e,n){let r=t.firstChild,i=r,o=0;for(;r;){let s=Bn(r,e,n);s>o&&(i=r,o=s),r=r.nextSibling}return i}function Bn(t,e,n){return Me(t,e)?.5+ue(n,t,e):0}function Dt(t,e){z(e,t),e.callbacks.beforeNodeRemoved(t)!==!1&&(t.remove(),e.callbacks.afterNodeRemoved(t))}function Gn(t,e){return!t.deadIds.has(e)}function Kn(t,e,n){return t.idMap.get(n)?.has(e)||!1}function z(t,e){let n=t.idMap.get(e);if(n)for(let r of n)t.deadIds.add(r)}function ue(t,e,n){let r=t.idMap.get(e);if(!r)return 0;let i=0;for(let o of r)Gn(t,o)&&Kn(t,o,n)&&++i;return i}function Pt(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 Jn(t,e){let n=new Map;return Pt(t,n),Pt(e,n),n}var Ot={type:2,name:I.MergeFragments,onGlobalInit:async t=>{let e=document.createElement("template");H(I.MergeFragments,({fragments:n="
",selector:r="",mergeMode:i=Xe,settleDuration:o=`${me}`,useViewTransition:s=`${ge}`})=>{let a=Number.parseInt(o),u=$(s);e.innerHTML=n.trim();let c=[...e.content.children];for(let l of c){if(!(l instanceof Element))throw V("NoFragmentsFound",t);let f=r||`#${l.getAttribute("id")}`,g=[...document.querySelectorAll(f)||[]];if(!g.length)throw V("NoTargetsFound",t,{selectorOrID:f});ee&&u?le.startViewTransition(()=>Lt(t,i,a,l,g)):Lt(t,i,a,l,g)}})}};function Lt(t,e,n,r,i){for(let o of i){o.classList.add(J);let s=o.outerHTML,a=o;switch(e){case O.Morph:{let l=Nt(a,r,{callbacks:{beforeNodeRemoved:(f,g)=>(t.cleanup(f),!0)}});if(!l?.length)throw V("MorphFailed",t);a=l[0];break}case O.Inner:a.innerHTML=r.outerHTML;break;case O.Outer:a.replaceWith(r);break;case O.Prepend:a.prepend(r);break;case O.Append:a.append(r);break;case O.Before:a.before(r);break;case O.After:a.after(r);break;case O.UpsertAttributes:for(let l of r.getAttributeNames()){let f=r.getAttribute(l);a.setAttribute(l,f)}break;default:throw V("InvalidMergeMode",t,{mergeMode:e})}t.cleanup(a);let u=a.classList;u.add(J),t.apply(document.body),setTimeout(()=>{o.classList.remove(J),u.remove(J)},n);let c=a.outerHTML;s!==c&&(u.add(He),setTimeout(()=>{u.remove(He)},n))}}var Vt={type:2,name:I.MergeSignals,onGlobalInit:async t=>{H(I.MergeSignals,({signals:e="{}",onlyIfMissing:n=`${Je}`})=>{let{signals:r}=t,i=$(n);r.merge(he(e),i),t.apply(document.body)})}};var Ft={type:2,name:I.RemoveFragments,onGlobalInit:async t=>{H(I.RemoveFragments,({selector:e,settleDuration:n=`${me}`,useViewTransition:r=`${ge}`})=>{if(!e.length)throw V("NoSelectorProvided",t);let i=Number.parseInt(n),o=$(r),s=document.querySelectorAll(e),a=()=>{for(let u of s)u.classList.add(J);setTimeout(()=>{for(let u of s)u.remove()},i)};ee&&o?le.startViewTransition(()=>a()):a()})}};var Ht={type:2,name:I.RemoveSignals,onGlobalInit:async t=>{H(I.RemoveSignals,({paths:e=""})=>{let n=e.split(` -`).map(r=>r.trim());if(!n?.length)throw V("NoPathsProvided",t);t.signals.remove(...n),t.apply(document.body)})}};var qt={type:3,name:"clipboard",fn:(t,e)=>{if(!navigator.clipboard)throw y("ClipboardNotAvailable",t);navigator.clipboard.writeText(e)}};var Wt={type:1,name:"customValidity",keyReq:2,valReq:1,onLoad:t=>{let{el:e,genRX:n,effect:r}=t;if(!(e instanceof HTMLObjectElement))throw y("CustomValidityInvalidElement",t);let i=n();return r(()=>{let o=i();if(typeof o!="string")throw y("CustomValidityInvalidExpression",t,{result:o});e.setCustomValidity(o)})}};var $t="once",Ut="half",jt="full",Bt={type:1,name:"intersects",keyReq:2,mods:new Set([$t,Ut,jt]),onLoad:({el:t,rawKey:e,mods:n,genRX:r})=>{let i={threshold:0};n.has(jt)?i.threshold=1:n.has(Ut)&&(i.threshold=.5);let o=r(),s=new IntersectionObserver(a=>{for(let u of a)u.isIntersecting&&(o(),n.has($t)&&(s.disconnect(),delete t.dataset[e]))},i);return s.observe(t),()=>s.disconnect()}};var Gt="session",Kt={type:1,name:"persist",mods:new Set([Gt]),onLoad:({key:t,value:e,signals:n,effect:r,mods:i})=>{t===""&&(t=L);let o=i.has(Gt)?sessionStorage:localStorage,s=e.split(/\s+/).filter(c=>c!=="");s=s.map(c=>j(c));let a=()=>{let c=o.getItem(t)||"{}",l=JSON.parse(c);n.merge(l)},u=()=>{let c;s.length?c=n.subset(...s):c=n.values(),o.setItem(t,JSON.stringify(c))};return a(),r(()=>{u()})}};var Jt={type:1,name:"replaceUrl",keyReq:2,valReq:1,onLoad:({effect:t,genRX:e})=>{let n=e();return t(()=>{let r=n(),i=window.location.href,o=new URL(r,i).toString();window.history.replaceState({},"",o)})}};var Ce="smooth",qe="instant",We="auto",zt="hstart",Xt="hcenter",Yt="hend",Zt="hnearest",Qt="vstart",en="vcenter",tn="vend",nn="vnearest",zn="focus",Ie="center",rn="start",on="end",sn="nearest",an={type:1,name:"scrollIntoView",keyReq:2,valReq:2,mods:new Set([Ce,qe,We,zt,Xt,Yt,Zt,Qt,en,tn,nn,zn]),onLoad:t=>{let{el:e,mods:n,rawKey:r}=t;e.tabIndex||e.setAttribute("tabindex","0");let i={behavior:Ce,block:Ie,inline:Ie};if(n.has(Ce)&&(i.behavior=Ce),n.has(qe)&&(i.behavior=qe),n.has(We)&&(i.behavior=We),n.has(zt)&&(i.inline=rn),n.has(Xt)&&(i.inline=Ie),n.has(Yt)&&(i.inline=on),n.has(Zt)&&(i.inline=sn),n.has(Qt)&&(i.block=rn),n.has(en)&&(i.block=Ie),n.has(tn)&&(i.block=on),n.has(nn)&&(i.block=sn),!(e instanceof HTMLElement||e instanceof SVGElement))throw y("ScrollIntoViewInvalidElement",t);return e.tabIndex||e.setAttribute("tabindex","0"),e.scrollIntoView(i),n.has("focus")&&e.focus(),delete e.dataset[r],()=>{}}};var ln="none",un="display",cn={type:1,name:"show",keyReq:2,valReq:1,onLoad:({el:{style:t},genRX:e,effect:n})=>{let r=e();return n(async()=>{r()?t.display===ln&&t.removeProperty(un):t.setProperty(un,ln)})}};var fn="view-transition",dn={type:1,name:"viewTransition",keyReq:2,valReq:1,onGlobalInit(){let t=!1;for(let e of document.head.childNodes)e instanceof HTMLMetaElement&&e.name===fn&&(t=!0);if(!t){let e=document.createElement("meta");e.name=fn,e.content="same-origin",document.head.appendChild(e)}},onLoad:({effect:t,el:e,genRX:n})=>{if(!ee){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 pn={type:1,name:"attr",valReq:1,onLoad:({el:t,genRX:e,key:n,effect:r})=>{let i=e();return n===""?r(async()=>{let o=i();for(let[s,a]of Object.entries(o))t.setAttribute(s,a)}):(n=U(n),r(async()=>{let o=!1;try{o=i()}catch{}let s;typeof o=="string"?s=o:s=JSON.stringify(o),!s||s==="false"||s==="null"||s==="undefined"?t.removeAttribute(n):t.setAttribute(n,s)}))}};var Xn=/^data:(?[^;]+);base64,(?.*)$/,mn=["change","input","keydown"],gn={type:1,name:"bind",keyReq:3,valReq:3,onLoad:t=>{let{el:e,value:n,key:r,signals:i,effect:o}=t,s=r||j(n),a=()=>{},u=()=>{},c=e.tagName.toLowerCase(),l="",f=c.includes("input"),g=e.getAttribute("type"),A=c.includes("checkbox")||f&&g==="checkbox";A&&(l=!1),f&&g==="number"&&(l=0);let h=c.includes("select"),d=c.includes("radio")||f&&g==="radio",b=f&&g==="file";d&&(e.getAttribute("name")?.length||e.setAttribute("name",s)),i.upsertIfMissing(s,l),a=()=>{let S="value"in e,T=i.value(s),_=`${T}`;if(A||d){let P=e;A?P.checked=!!T||T==="true":d&&(P.checked=_===P.value)}else if(!b)if(h){let P=e;if(P.multiple)for(let M of P.options){if(M?.disabled)return;Array.isArray(T)||typeof T=="string"?M.selected=T.includes(M.value):typeof T=="number"?M.selected=T===Number(M.value):M.selected=T}else P.value=_}else S?e.value=_:e.setAttribute("value",_)},u=async()=>{if(b){let _=[...e?.files||[]],P=[],M=[],m=[];await Promise.all(_.map(D=>new Promise(C=>{let R=new FileReader;R.onload=()=>{if(typeof R.result!="string")throw y("InvalidFileResultType",t,{resultType:typeof R.result});let W=R.result.match(Xn);if(!W?.groups)throw y("InvalidDataUri",t,{result:R.result});P.push(W.groups.contents),M.push(W.groups.mime),m.push(D.name)},R.onloadend=()=>C(void 0),R.readAsDataURL(D)}))),i.setValue(s,P),i.setValue(`${s}Mimes`,M),i.setValue(`${s}Names`,m);return}let S=i.value(s),T=e||e;if(typeof S=="number"){let _=Number(T.value||T.getAttribute("value"));i.setValue(s,_)}else if(typeof S=="string"){let _=T.value||T.getAttribute("value")||"";i.setValue(s,_)}else if(typeof S=="boolean")if(A){let _=T.checked||T.getAttribute("checked")==="true";i.setValue(s,_)}else{let _=!!(T.value||T.getAttribute("value"));i.setValue(s,_)}else if(!(typeof S>"u"))if(Array.isArray(S))if(h){let M=[...e.selectedOptions].filter(m=>m.selected).map(m=>m.value);i.setValue(s,M)}else{let _=JSON.stringify(T.value.split(","));i.setValue(s,_)}else throw y("BindUnsupportedSignalType",t,{signalType:typeof S})};for(let S of mn)e.addEventListener(S,u);let w=o(()=>a());return()=>{w();for(let S of mn)e.removeEventListener(S,u)}}};var hn={type:1,name:"class",valReq:1,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,u]of Object.entries(s)){let c=a.split(/\s+/);u?i.add(...c):i.remove(...c)}}else{let s=o(),a=U(t);s?i.add(a):i.remove(a)}})}};function ce(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 Number.parseFloat(e)}catch{}}return 0}function ne(t,e,n=!1){return t?t.has(e.toLowerCase()):n}function yn(t,e){return(...n)=>{setTimeout(()=>{t(...n)},e)}}function vn(t,e,n=!1,r=!0){let i=-1,o=()=>i&&clearTimeout(i);return(...s)=>{o(),n&&!i&&t(...s),i=setTimeout(()=>{r&&t(...s),o()},e)}}function bn(t,e,n=!0,r=!1){let i=!1;return(...o)=>{i||(n&&t(...o),i=!0,setTimeout(()=>{i=!1,r&&t(...o)},e))}}var $e=new Map,Yn="evt",Sn={type:1,name:"on",keyReq:1,valReq:1,argNames:[Yn],onLoad:({el:t,rawKey:e,key:n,value:r,genRX:i,mods:o,signals:s,effect:a})=>{let u=i(),c=t;o.has("window")&&(c=window);let l=d=>{d&&((o.has("prevent")||n==="submit")&&d.preventDefault(),o.has("stop")&&d.stopPropagation()),u(d)},f=o.get("delay");if(f){let d=ce(f);l=yn(l,d)}let g=o.get("debounce");if(g){let d=ce(g),b=ne(g,"leading",!1),w=!ne(g,"notrail",!1);l=vn(l,d,b,w)}let A=o.get("throttle");if(A){let d=ce(A),b=!ne(A,"noleading",!1),w=ne(A,"trail",!1);l=bn(l,d,b,w)}let v={capture:!0,passive:!1,once:!1};o.has("capture")||(v.capture=!1),o.has("passive")&&(v.passive=!0),o.has("once")&&(v.once=!0);let h=U(n).toLowerCase();switch(h){case"load":return l(),delete t.dataset[e],()=>{};case"interval":{let d=1e3,b=o.get("duration");b&&(d=ce(b),ne(b,"leading",!1)&&(t.dataset[e.replace(".leading","")]=r,delete t.dataset[e],l()));let w=setInterval(l,d);return()=>{clearInterval(w)}}case"raf":{let d,b=()=>{l(),d=requestAnimationFrame(b)};return d=requestAnimationFrame(b),()=>{d&&cancelAnimationFrame(d)}}case"signals-change":return nt(t,()=>{$e.delete(t.id)}),a(()=>{let d=o.has("remote"),b=s.JSON(!1,d);($e.get(t.id)||"")!==b&&($e.set(t.id,b),l())});default:{if(o.has("outside")){c=document;let b=l;l=S=>{let T=S?.target;t.contains(T)||b(S)}}return c.addEventListener(h,l,v),()=>{c.removeEventListener(h,l)}}}}};var En={type:1,name:"ref",keyReq:3,valReq:3,onLoad:({el:t,key:e,value:n,signals:r})=>{let i=e||j(n);return r.setValue(i,t),()=>r.setValue(i,null)}};var Tn={type:1,name:"text",keyReq:2,valReq:1,onLoad:t=>{let{el:e,genRX:n,effect:r}=t,i=n();return e instanceof HTMLElement||y("TextInvalidElement",t),r(()=>{let o=i(t);e.textContent=`${o}`})}};var{round:Zn,max:Qn,min:er}=Math,An={type:3,name:"fit",fn:(t,e,n,r,i,o,s=!1,a=!1)=>{let u=(e-n)/(r-n)*(o-i)+i;return a&&(u=Zn(u)),s&&(u=Qn(i,er(o,u))),u}};var _n={type:3,name:"setAll",fn:({signals:t},e,n)=>{t.walk((r,i)=>{r.startsWith(e)&&(i.value=n)})}};var Rn={type:3,name:"toggleAll",fn:({signals:t},e)=>{t.walk((n,r)=>{n.startsWith(e)&&(r.value=!r.value)})}};Ae.load(pn,gn,hn,Sn,En,cn,Tn,_t,St,Tt,At,Et,bt,Ot,Vt,Ft,Ht,Rt,qt,Wt,Bt,Kt,Jt,an,dn,An,_n,Rn);Ae.apply(document.body);var bs=Ae;export{bs as Datastar}; +`);we(D,W)},onerror:m=>{if(vt(m))throw y("InvalidContentType",t,{url:n});m&&console.error(m.message)}},P=new URL(n,window.location.origin),N=new URLSearchParams(P.search);if(u==="json"){let m=s.JSON(!1,!c);e==="GET"?N.set(L,m):_.body=m}else if(u==="form"){let m=l?document.querySelector(l):o.closest("form");if(m===null)throw l?y("SseFormNotFound",t,{action:b,selector:l}):y("SseClosestFormNotFound",t,{action:b});if(o!==m){let C=R=>R.preventDefault();m.addEventListener("submit",C),w=()=>m.removeEventListener("submit",C)}if(!m.checkValidity()){m.reportValidity(),w();return}let D=new FormData(m);if(e==="GET"){let C=new URLSearchParams(D);for(let[R,W]of C)N.set(R,W)}else _.body=D}else throw y("SseInvalidContentType",t,{action:b,contentType:u});P.search=N.toString();try{await ht(t,P.toString(),_)}catch(m){if(!vt(m))throw y("SseFetchFailed",t,{method:e,url:n,error:m})}}finally{we(Re,{elId:i}),w()}};var bt={type:3,name:"delete",fn:async(t,e,n)=>q(t,"DELETE",e,{...n})};var St={type:3,name:"get",fn:async(t,e,n)=>q(t,"GET",e,{...n})};var Et={type:3,name:"patch",fn:async(t,e,n)=>q(t,"PATCH",e,{...n})};var Tt={type:3,name:"post",fn:async(t,e,n)=>q(t,"POST",e,{...n})};var At={type:3,name:"put",fn:async(t,e,n)=>q(t,"PUT",e,{...n})};var _t={type:1,name:"indicator",keyReq:3,valReq:3,onLoad:({value:t,signals:e,el:n,key:r})=>{let i=r||j(t),o=e.upsertIfMissing(i,!1),s=a=>{let{type:u,argsRaw:{elId:c}}=a.detail;if(c===n.id)switch(u){case _e:o.value=!0;break;case Re:o.value=!1;break}};return document.addEventListener(Q,s),()=>{document.removeEventListener(Q,s)}}};var Rt={type:2,name:I.ExecuteScript,onGlobalInit:async t=>{H(I.ExecuteScript,({autoRemove:e=`${ze}`,attributes:n=Ke,script:r})=>{let i=$(e);if(!r?.length)throw V("NoScriptProvided",t);let o=document.createElement("script");for(let s of n.split(` +`)){let a=s.indexOf(" "),u=a?s.slice(0,a):s,c=a?s.slice(a):"";o.setAttribute(u.trim(),c.trim())}o.text=r,document.head.appendChild(o),i&&o.remove()})}};var le=document,ee=!!le.startViewTransition;var te="idiomorph",Pe=new WeakSet;function Mt(t,e,n={}){t instanceof Document&&(t=t.documentElement);let r;typeof e=="string"?r=Wn(e):r=e;let i=$n(r),o=Fn(t,i,n);return Nt(t,i,o)}function Nt(t,e,n){if(n.head.block){let r=t.querySelector("head"),i=e.querySelector("head");if(r&&i){let o=It(i,r,n);Promise.all(o).then(()=>{Nt(t,e,Object.assign(n,{head:{block:!1,ignore:!0}}))});return}}if(n.morphStyle==="innerHTML")return Ct(e,t,n),t.children;if(n.morphStyle==="outerHTML"||n.morphStyle==null){let r=jn(e,t,n);if(!r)throw M(te,"NoBestMatchFound",{old:t,new:e});let i=r?.previousSibling,o=r?.nextSibling,s=Me(t,r,n);return r?Un(i,s,o):[]}throw M(te,"InvalidMorphStyle",{style:n.morphStyle})}function Me(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(Ne(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!==O.Morph?It(e,t,n):(Vn(e,t),Ct(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 M(te,"NoParentElementFound",{oldNode:t});return t.parentElement.replaceChild(e,t),n.callbacks.afterNodeAdded(e),n.callbacks.afterNodeRemoved(t),e}}function Ct(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),z(n,o);continue}if(kt(o,i,n)){Me(i,o,n),i=i.nextSibling,z(n,o);continue}let s=Hn(t,e,o,i,n);if(s){i=wt(i,s,n),Me(s,o,n),z(n,o);continue}let a=qn(t,o,i,n);if(a){i=wt(i,a,n),Me(a,o,n),z(n,o);continue}if(n.callbacks.beforeNodeAdded(o)===!1)return;e.insertBefore(o,i),n.callbacks.afterNodeAdded(o),z(n,o)}for(;i!==null;){let s=i;i=i.nextSibling,Dt(s,n)}}function Vn(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||"",xe(t,e,"value"),xe(t,e,"checked"),xe(t,e,"disabled");else if(t instanceof HTMLOptionElement)xe(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 xe(t,e,n){let r=t.getAttribute(n),i=e.getAttribute(n);r!==i&&(r?e.setAttribute(n,r):e.removeAttribute(n))}function It(t,e,n){let r=[],i=[],o=[],s=[],a=n.head.style,u=new Map;for(let l of t.children)u.set(l.outerHTML,l);for(let l of e.children){let f=u.has(l.outerHTML),g=n.head.shouldReAppend(l),A=n.head.shouldPreserve(l);f||A?g?i.push(l):(u.delete(l.outerHTML),o.push(l)):a===O.Append?g&&(i.push(l),s.push(l)):n.head.shouldRemove(l)!==!1&&i.push(l)}s.push(...u.values());let c=[];for(let l of s){let f=document.createRange().createContextualFragment(l.outerHTML).firstChild;if(!f)throw M(te,"NewElementCouldNotBeCreated",{newNode:l});if(n.callbacks.beforeNodeAdded(f)){if(f.hasAttribute("href")||f.hasAttribute("src")){let g,A=new Promise(v=>{g=v});f.addEventListener("load",()=>{g(void 0)}),c.push(A)}e.appendChild(f),n.callbacks.afterNodeAdded(f),r.push(f)}}for(let l of i)n.callbacks.beforeNodeRemoved(l)!==!1&&(e.removeChild(l),n.callbacks.afterNodeRemoved(l));return n.head.afterHeadMorphed(e,{added:r,kept:o,removed:i}),c}function B(){}function Fn(t,e,n){return{target:t,newContent:e,config:n,morphStyle:n.morphStyle,ignoreActive:n.ignoreActive,idMap:Jn(t,e),deadIds:new Set,callbacks:Object.assign({beforeNodeAdded:B,afterNodeAdded:B,beforeNodeMorphed:B,afterNodeMorphed:B,beforeNodeRemoved:B,afterNodeRemoved:B},n.callbacks),head:Object.assign({style:"merge",shouldPreserve:r=>r.getAttribute("im-preserve")==="true",shouldReAppend:r=>r.getAttribute("im-re-append")==="true",shouldRemove:B,afterHeadMorphed:B},n.head)}}function kt(t,e,n){return!t||!e?!1:t.nodeType===e.nodeType&&t.tagName===e.tagName?t?.id?.length&&t.id===e.id?!0:ue(n,t,e)>0:!1}function Ne(t,e){return!t||!e?!1:t.nodeType===e.nodeType&&t.tagName===e.tagName}function wt(t,e,n){for(;t!==e;){let r=t;if(t=t?.nextSibling,!r)throw M(te,"NoTemporaryNodeFound",{startInclusive:t,endExclusive:e});Dt(r,n)}return z(n,e),e.nextSibling}function Hn(t,e,n,r,i){let o=ue(i,n,e),s=null;if(o>0){s=r;let a=0;for(;s!=null;){if(kt(n,s,i))return s;if(a+=ue(i,s,t),a>o)return null;s=s.nextSibling}}return s}function qn(t,e,n,r){let i=n,o=e.nextSibling,s=0;for(;i&&o;){if(ue(r,i,t)>0)return null;if(Ne(e,i))return i;if(Ne(o,i)&&(s++,o=o.nextSibling,s>=2))return null;i=i.nextSibling}return i}var xt=new DOMParser;function Wn(t){let e=t.replace(/]*>|>)([\s\S]*?)<\/svg>/gim,"");if(e.match(/<\/html>/)||e.match(/<\/head>/)||e.match(/<\/body>/)){let i=xt.parseFromString(t,"text/html");if(e.match(/<\/html>/))return Pe.add(i),i;let o=i.firstChild;return o?(Pe.add(o),o):null}let r=xt.parseFromString(``,"text/html").body.querySelector("template")?.content;if(!r)throw M(te,"NoContentFound",{newContent:t});return Pe.add(r),r}function $n(t){if(t==null)return document.createElement("div");if(Pe.has(t))return t;if(t instanceof Node){let n=document.createElement("div");return n.append(t),n}let e=document.createElement("div");for(let n of[...t])e.append(n);return e}function Un(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 jn(t,e,n){let r=t.firstChild,i=r,o=0;for(;r;){let s=Bn(r,e,n);s>o&&(i=r,o=s),r=r.nextSibling}return i}function Bn(t,e,n){return Ne(t,e)?.5+ue(n,t,e):0}function Dt(t,e){z(e,t),e.callbacks.beforeNodeRemoved(t)!==!1&&(t.remove(),e.callbacks.afterNodeRemoved(t))}function Gn(t,e){return!t.deadIds.has(e)}function Kn(t,e,n){return t.idMap.get(n)?.has(e)||!1}function z(t,e){let n=t.idMap.get(e);if(n)for(let r of n)t.deadIds.add(r)}function ue(t,e,n){let r=t.idMap.get(e);if(!r)return 0;let i=0;for(let o of r)Gn(t,o)&&Kn(t,o,n)&&++i;return i}function Pt(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 Jn(t,e){let n=new Map;return Pt(t,n),Pt(e,n),n}var Ot={type:2,name:I.MergeFragments,onGlobalInit:async t=>{let e=document.createElement("template");H(I.MergeFragments,({fragments:n="
",selector:r="",mergeMode:i=Xe,settleDuration:o=`${me}`,useViewTransition:s=`${ge}`})=>{let a=Number.parseInt(o),u=$(s);e.innerHTML=n.trim();let c=[...e.content.children];for(let l of c){if(!(l instanceof Element))throw V("NoFragmentsFound",t);let f=r||`#${l.getAttribute("id")}`,g=[...document.querySelectorAll(f)||[]];if(!g.length)throw V("NoTargetsFound",t,{selectorOrID:f});ee&&u?le.startViewTransition(()=>Lt(t,i,a,l,g)):Lt(t,i,a,l,g)}})}};function Lt(t,e,n,r,i){for(let o of i){o.classList.add(J);let s=o.outerHTML,a=o;switch(e){case O.Morph:{let l=Mt(a,r,{callbacks:{beforeNodeRemoved:(f,g)=>(t.cleanup(f),!0)}});if(!l?.length)throw V("MorphFailed",t);a=l[0];break}case O.Inner:a.innerHTML=r.outerHTML;break;case O.Outer:a.replaceWith(r);break;case O.Prepend:a.prepend(r);break;case O.Append:a.append(r);break;case O.Before:a.before(r);break;case O.After:a.after(r);break;case O.UpsertAttributes:for(let l of r.getAttributeNames()){let f=r.getAttribute(l);a.setAttribute(l,f)}break;default:throw V("InvalidMergeMode",t,{mergeMode:e})}t.cleanup(a);let u=a.classList;u.add(J),t.apply(document.body),setTimeout(()=>{o.classList.remove(J),u.remove(J)},n);let c=a.outerHTML;s!==c&&(u.add(He),setTimeout(()=>{u.remove(He)},n))}}var Vt={type:2,name:I.MergeSignals,onGlobalInit:async t=>{H(I.MergeSignals,({signals:e="{}",onlyIfMissing:n=`${Je}`})=>{let{signals:r}=t,i=$(n);r.merge(he(e),i),t.apply(document.body)})}};var Ft={type:2,name:I.RemoveFragments,onGlobalInit:async t=>{H(I.RemoveFragments,({selector:e,settleDuration:n=`${me}`,useViewTransition:r=`${ge}`})=>{if(!e.length)throw V("NoSelectorProvided",t);let i=Number.parseInt(n),o=$(r),s=document.querySelectorAll(e),a=()=>{for(let u of s)u.classList.add(J);setTimeout(()=>{for(let u of s)u.remove()},i)};ee&&o?le.startViewTransition(()=>a()):a()})}};var Ht={type:2,name:I.RemoveSignals,onGlobalInit:async t=>{H(I.RemoveSignals,({paths:e=""})=>{let n=e.split(` +`).map(r=>r.trim());if(!n?.length)throw V("NoPathsProvided",t);t.signals.remove(...n),t.apply(document.body)})}};var qt={type:3,name:"clipboard",fn:(t,e)=>{if(!navigator.clipboard)throw y("ClipboardNotAvailable",t);navigator.clipboard.writeText(e)}};var Wt={type:1,name:"customValidity",keyReq:2,valReq:1,onLoad:t=>{let{el:e,genRX:n,effect:r}=t;if(!(e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement))throw y("CustomValidityInvalidElement",t);let i=n();return r(()=>{let o=i();if(typeof o!="string")throw y("CustomValidityInvalidExpression",t,{result:o});e.setCustomValidity(o)})}};var $t="once",Ut="half",jt="full",Bt={type:1,name:"intersects",keyReq:2,mods:new Set([$t,Ut,jt]),onLoad:({el:t,rawKey:e,mods:n,genRX:r})=>{let i={threshold:0};n.has(jt)?i.threshold=1:n.has(Ut)&&(i.threshold=.5);let o=r(),s=new IntersectionObserver(a=>{for(let u of a)u.isIntersecting&&(o(),n.has($t)&&(s.disconnect(),delete t.dataset[e]))},i);return s.observe(t),()=>s.disconnect()}};var Gt="session",Kt={type:1,name:"persist",mods:new Set([Gt]),onLoad:({key:t,value:e,signals:n,effect:r,mods:i})=>{t===""&&(t=L);let o=i.has(Gt)?sessionStorage:localStorage,s=e.split(/\s+/).filter(c=>c!=="");s=s.map(c=>j(c));let a=()=>{let c=o.getItem(t)||"{}",l=JSON.parse(c);n.merge(l)},u=()=>{let c;s.length?c=n.subset(...s):c=n.values(),o.setItem(t,JSON.stringify(c))};return a(),r(()=>{u()})}};var Jt={type:1,name:"replaceUrl",keyReq:2,valReq:1,onLoad:({effect:t,genRX:e})=>{let n=e();return t(()=>{let r=n(),i=window.location.href,o=new URL(r,i).toString();window.history.replaceState({},"",o)})}};var Ce="smooth",qe="instant",We="auto",zt="hstart",Xt="hcenter",Yt="hend",Zt="hnearest",Qt="vstart",en="vcenter",tn="vend",nn="vnearest",zn="focus",Ie="center",rn="start",on="end",sn="nearest",an={type:1,name:"scrollIntoView",keyReq:2,valReq:2,mods:new Set([Ce,qe,We,zt,Xt,Yt,Zt,Qt,en,tn,nn,zn]),onLoad:t=>{let{el:e,mods:n,rawKey:r}=t;e.tabIndex||e.setAttribute("tabindex","0");let i={behavior:Ce,block:Ie,inline:Ie};if(n.has(Ce)&&(i.behavior=Ce),n.has(qe)&&(i.behavior=qe),n.has(We)&&(i.behavior=We),n.has(zt)&&(i.inline=rn),n.has(Xt)&&(i.inline=Ie),n.has(Yt)&&(i.inline=on),n.has(Zt)&&(i.inline=sn),n.has(Qt)&&(i.block=rn),n.has(en)&&(i.block=Ie),n.has(tn)&&(i.block=on),n.has(nn)&&(i.block=sn),!(e instanceof HTMLElement||e instanceof SVGElement))throw y("ScrollIntoViewInvalidElement",t);return e.tabIndex||e.setAttribute("tabindex","0"),e.scrollIntoView(i),n.has("focus")&&e.focus(),delete e.dataset[r],()=>{}}};var ln="none",un="display",cn={type:1,name:"show",keyReq:2,valReq:1,onLoad:({el:{style:t},genRX:e,effect:n})=>{let r=e();return n(async()=>{r()?t.display===ln&&t.removeProperty(un):t.setProperty(un,ln)})}};var fn="view-transition",dn={type:1,name:"viewTransition",keyReq:2,valReq:1,onGlobalInit(){let t=!1;for(let e of document.head.childNodes)e instanceof HTMLMetaElement&&e.name===fn&&(t=!0);if(!t){let e=document.createElement("meta");e.name=fn,e.content="same-origin",document.head.appendChild(e)}},onLoad:({effect:t,el:e,genRX:n})=>{if(!ee){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 pn={type:1,name:"attr",valReq:1,onLoad:({el:t,genRX:e,key:n,effect:r})=>{let i=e();return n===""?r(async()=>{let o=i();for(let[s,a]of Object.entries(o))t.setAttribute(s,a)}):(n=U(n),r(async()=>{let o=!1;try{o=i()}catch{}let s;typeof o=="string"?s=o:s=JSON.stringify(o),!s||s==="false"||s==="null"||s==="undefined"?t.removeAttribute(n):t.setAttribute(n,s)}))}};var Xn=/^data:(?[^;]+);base64,(?.*)$/,mn=["change","input","keydown"],gn={type:1,name:"bind",keyReq:3,valReq:3,onLoad:t=>{let{el:e,value:n,key:r,signals:i,effect:o}=t,s=r||j(n),a=()=>{},u=()=>{},c=e.tagName.toLowerCase(),l="",f=c.includes("input"),g=e.getAttribute("type"),A=c.includes("checkbox")||f&&g==="checkbox";A&&(l=!1),f&&g==="number"&&(l=0);let h=c.includes("select"),d=c.includes("radio")||f&&g==="radio",b=f&&g==="file";d&&(e.getAttribute("name")?.length||e.setAttribute("name",s)),i.upsertIfMissing(s,l),a=()=>{let S="value"in e,T=i.value(s),_=`${T}`;if(A||d){let P=e;A?P.checked=!!T||T==="true":d&&(P.checked=_===P.value)}else if(!b)if(h){let P=e;if(P.multiple)for(let N of P.options){if(N?.disabled)return;Array.isArray(T)||typeof T=="string"?N.selected=T.includes(N.value):typeof T=="number"?N.selected=T===Number(N.value):N.selected=T}else P.value=_}else S?e.value=_:e.setAttribute("value",_)},u=async()=>{if(b){let _=[...e?.files||[]],P=[],N=[],m=[];await Promise.all(_.map(D=>new Promise(C=>{let R=new FileReader;R.onload=()=>{if(typeof R.result!="string")throw y("InvalidFileResultType",t,{resultType:typeof R.result});let W=R.result.match(Xn);if(!W?.groups)throw y("InvalidDataUri",t,{result:R.result});P.push(W.groups.contents),N.push(W.groups.mime),m.push(D.name)},R.onloadend=()=>C(void 0),R.readAsDataURL(D)}))),i.setValue(s,P),i.setValue(`${s}Mimes`,N),i.setValue(`${s}Names`,m);return}let S=i.value(s),T=e||e;if(typeof S=="number"){let _=Number(T.value||T.getAttribute("value"));i.setValue(s,_)}else if(typeof S=="string"){let _=T.value||T.getAttribute("value")||"";i.setValue(s,_)}else if(typeof S=="boolean")if(A){let _=T.checked||T.getAttribute("checked")==="true";i.setValue(s,_)}else{let _=!!(T.value||T.getAttribute("value"));i.setValue(s,_)}else if(!(typeof S>"u"))if(Array.isArray(S))if(h){let N=[...e.selectedOptions].filter(m=>m.selected).map(m=>m.value);i.setValue(s,N)}else{let _=JSON.stringify(T.value.split(","));i.setValue(s,_)}else throw y("BindUnsupportedSignalType",t,{signalType:typeof S})};for(let S of mn)e.addEventListener(S,u);let w=o(()=>a());return()=>{w();for(let S of mn)e.removeEventListener(S,u)}}};var hn={type:1,name:"class",valReq:1,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,u]of Object.entries(s)){let c=a.split(/\s+/);u?i.add(...c):i.remove(...c)}}else{let s=o(),a=U(t);s?i.add(a):i.remove(a)}})}};function ce(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 Number.parseFloat(e)}catch{}}return 0}function ne(t,e,n=!1){return t?t.has(e.toLowerCase()):n}function yn(t,e){return(...n)=>{setTimeout(()=>{t(...n)},e)}}function vn(t,e,n=!1,r=!0){let i=-1,o=()=>i&&clearTimeout(i);return(...s)=>{o(),n&&!i&&t(...s),i=setTimeout(()=>{r&&t(...s),o()},e)}}function bn(t,e,n=!0,r=!1){let i=!1;return(...o)=>{i||(n&&t(...o),i=!0,setTimeout(()=>{i=!1,r&&t(...o)},e))}}var $e=new Map,Yn="evt",Sn={type:1,name:"on",keyReq:1,valReq:1,argNames:[Yn],onLoad:({el:t,rawKey:e,key:n,value:r,genRX:i,mods:o,signals:s,effect:a})=>{let u=i(),c=t;o.has("window")&&(c=window);let l=d=>{d&&((o.has("prevent")||n==="submit")&&d.preventDefault(),o.has("stop")&&d.stopPropagation()),u(d)},f=o.get("delay");if(f){let d=ce(f);l=yn(l,d)}let g=o.get("debounce");if(g){let d=ce(g),b=ne(g,"leading",!1),w=!ne(g,"notrail",!1);l=vn(l,d,b,w)}let A=o.get("throttle");if(A){let d=ce(A),b=!ne(A,"noleading",!1),w=ne(A,"trail",!1);l=bn(l,d,b,w)}let v={capture:!0,passive:!1,once:!1};o.has("capture")||(v.capture=!1),o.has("passive")&&(v.passive=!0),o.has("once")&&(v.once=!0);let h=U(n).toLowerCase();switch(h){case"load":return l(),delete t.dataset[e],()=>{};case"interval":{let d=1e3,b=o.get("duration");b&&(d=ce(b),ne(b,"leading",!1)&&(t.dataset[e.replace(".leading","")]=r,delete t.dataset[e],l()));let w=setInterval(l,d);return()=>{clearInterval(w)}}case"raf":{let d,b=()=>{l(),d=requestAnimationFrame(b)};return d=requestAnimationFrame(b),()=>{d&&cancelAnimationFrame(d)}}case"signals-change":return nt(t,()=>{$e.delete(t.id)}),a(()=>{let d=o.has("remote"),b=s.JSON(!1,d);($e.get(t.id)||"")!==b&&($e.set(t.id,b),l())});default:{if(o.has("outside")){c=document;let b=l;l=S=>{let T=S?.target;t.contains(T)||b(S)}}return c.addEventListener(h,l,v),()=>{c.removeEventListener(h,l)}}}}};var En={type:1,name:"ref",keyReq:3,valReq:3,onLoad:({el:t,key:e,value:n,signals:r})=>{let i=e||j(n);return r.setValue(i,t),()=>r.setValue(i,null)}};var Tn={type:1,name:"text",keyReq:2,valReq:1,onLoad:t=>{let{el:e,genRX:n,effect:r}=t,i=n();return e instanceof HTMLElement||y("TextInvalidElement",t),r(()=>{let o=i(t);e.textContent=`${o}`})}};var{round:Zn,max:Qn,min:er}=Math,An={type:3,name:"fit",fn:(t,e,n,r,i,o,s=!1,a=!1)=>{let u=(e-n)/(r-n)*(o-i)+i;return a&&(u=Zn(u)),s&&(u=Qn(i,er(o,u))),u}};var _n={type:3,name:"setAll",fn:({signals:t},e,n)=>{t.walk((r,i)=>{r.startsWith(e)&&(i.value=n)})}};var Rn={type:3,name:"toggleAll",fn:({signals:t},e)=>{t.walk((n,r)=>{n.startsWith(e)&&(r.value=!r.value)})}};Ae.load(pn,gn,hn,Sn,En,cn,Tn,_t,St,Tt,At,Et,bt,Ot,Vt,Ft,Ht,Rt,qt,Wt,Bt,Kt,Jt,an,dn,An,_n,Rn);Ae.apply(document.body);var bs=Ae;export{bs as Datastar}; //# sourceMappingURL=datastar.js.map diff --git a/bundles/datastar.js.map b/bundles/datastar.js.map index 32e5995d..73644f42 100644 --- a/bundles/datastar.js.map +++ b/bundles/datastar.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../library/src/engine/consts.ts", "../library/src/engine/types.ts", "../library/src/plugins/official/core/attributes/computed.ts", "../library/src/utils/text.ts", "../library/src/plugins/official/core/attributes/signals.ts", "../library/src/plugins/official/core/attributes/star.ts", "../library/src/utils/dom.ts", "../library/src/engine/errors.ts", "../library/src/vendored/preact-core.ts", "../library/src/engine/signals.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/actions/delete.ts", "../library/src/plugins/official/backend/actions/get.ts", "../library/src/plugins/official/backend/actions/patch.ts", "../library/src/plugins/official/backend/actions/post.ts", "../library/src/plugins/official/backend/actions/put.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/customValidity.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/attr.ts", "../library/src/plugins/official/dom/attributes/bind.ts", "../library/src/plugins/official/dom/attributes/class.ts", "../library/src/utils/tags.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": ["// This is auto-generated by Datastar. DO NOT EDIT.\nconst lol = /\uD83D\uDD95JS_DS\uD83D\uDE80/.source\nexport const DSP = lol.slice(0, 5)\nexport const DSS = lol.slice(4)\n\nexport const DATASTAR = \"datastar\";\nexport const DATASTAR_EVENT = \"datastar-event\";\nexport const DATASTAR_REQUEST = \"Datastar-Request\";\nexport const VERSION = \"1.0.0-beta.2\";\n\n// #region Defaults\n\n// #region Default durations\n\n// The default duration for settling during fragment merges. Allows for CSS transitions to complete.\nexport const DefaultFragmentsSettleDurationMs = 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