jq79 0.4.11 → 0.4.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/jq79.js CHANGED
@@ -1,14 +1,14 @@
1
- var Kt=Object.defineProperty;var Xt=(t,n,e)=>n in t?Kt(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var v=(t,n,e)=>Xt(t,typeof n!="symbol"?n+"":n,e);function W(t,n){return typeof t=="string"?document.querySelector(t):t.querySelector(n)}function et(t,n){return Array.from(typeof t=="string"?document.querySelectorAll(t):t.querySelectorAll(n))}var nt=(t,n={})=>{let e=document.createElement(t);for(let[s,o]of Object.entries(n))if(s==="className")e.className=Array.isArray(o)?o.join(" "):o;else if(s==="textContent")e.textContent=o;else if(s==="children")for(let r of o)e.appendChild(r);else e.setAttribute(s,o);return e},Jt=new Set(["a","b","i","em","strong","p","br","ul","ol","li","blockquote","code","pre","span","div","h1","h2","h3","h4","h5","h6","img"]),yt={a:new Set(["href","title"]),img:new Set(["src","alt"]),"*":new Set(["class"])},Vt=new Set(["http:","https:","mailto:"]);function Qt(t){try{let n=new URL(t,"https://example.com");return Vt.has(n.protocol)}catch{return!1}}var Yt={"https:":"443","http:":"80"};function te(t){let n=t.trim().toLowerCase().match(/^([a-z\d*][a-z\d.*-]*?)(?::(\d{1,5}|\*))?$/);if(!n)return null;let[,e,s]=n,o=e.split(".");return o.some(i=>i!=="*"&&!/^[a-z\d-]+$/.test(i))?null:{host:new RegExp(`^${o.map(i=>i==="*"?"[^.]+":i).join("\\.")}$`),port:!s||s==="*"?null:s}}var Et=t=>{let n=(Array.isArray(t)?t:t.split(",")).map(te).filter(e=>e!==null);return e=>{let s=e.hostname.toLowerCase(),o=e.port||Yt[e.protocol]||"";return n.some(r=>r.host.test(s)&&(r.port===null||r.port===o))}};function ee(t,n,e,s){try{return!!t(new URL(n,document.baseURI),e,s)}catch{return!1}}var bt=512;function wt(t,n,e,s){if(e>bt)throw new RangeError(`jq79: sanitizeHTML input nests deeper than ${bt} elements`);for(let o of Array.from(t.childNodes))if(o.nodeType===Node.ELEMENT_NODE){let r=ne(o,e,s);r&&n.appendChild(r)}else o.nodeType===Node.TEXT_NODE&&n.appendChild(o.cloneNode())}function ne(t,n,e){let s=t.tagName.toLowerCase();if(!Jt.has(s))return null;let o=document.createElement(s);for(let r of Array.from(t.attributes)){let i=r.name.toLowerCase(),l=yt[s]?.has(i),f=yt["*"]?.has(i);!l&&!f||(i==="href"||i==="src")&&(!Qt(r.value)||e&&!ee(e,r.value,s,i))||o.setAttribute(i,r.value)}return s==="a"&&o.setAttribute("rel","noopener noreferrer"),wt(t,o,n+1,e),o}function $t(t,n){let e=document.createElement("template");e.innerHTML=t;let s=document.createElement("div");return wt(e.content,s,0,n?.allowUrl),s.innerHTML}var se=(t,n)=>n.split(".").reduce((e,s)=>e?.[s],t),St=t=>{if(Array.isArray(t))return!0;let n=Object.getPrototypeOf(t);return n===Object.prototype||n===null},Rt=(t,n,e)=>{Object.entries(t).forEach(([s,o])=>{let r=n?`${n}.${s}`:s;o&&typeof o=="object"&&St(o)?Rt(o,r,e):e(r,o)})},oe=(t,n)=>t===n||t.startsWith(`${n}.`)||n.startsWith(`${t}.`),st=Symbol("jq79.raw"),G=t=>{let n=t;for(;n!==null&&typeof n=="object"&&n[st];)n=n[st];return n},xt=Symbol("jq79.store"),H=t=>t!==null&&typeof t=="object"&&t[xt]===!0,F=[],q=t=>{F.push(new Set);try{return t()}finally{F.pop()}},Z=t=>{let n=new Map,e=new Set,s=new Set,o=new WeakMap,r=Object.create(null),i=(a,c,u=!1)=>{n.get(a)?.forEach(m=>m(c,a)),e.forEach(m=>m(a,c)),s.forEach(m=>{(u||Array.from(m.deps).some(A=>oe(A,a)))&&m.run()})},l=a=>a!==null&&typeof a=="object"&&St(a),f=new Map,p=(a,c)=>{let u=f.get(c);u?.store!==a&&(u?.unsubscribe(),f.set(c,{store:a,unsubscribe:a.$onAny((m,A)=>i(`${c}.${m}`,A))}))},d=a=>{f.get(a)?.unsubscribe(),f.delete(a)},g=(a,c)=>{let u=o.get(a);if(u)return u;let m=null,A=new Proxy(a,{has(S,h){return Reflect.has(S,h)||typeof h=="string"&&m?.has(h)===!0},get(S,h,y){if(h===st)return S;if(h===xt)return c==="";if(typeof h!="string")return Reflect.get(S,h,y);if(c===""&&h in r)return r[h];let R=c?`${c}.${h}`:h;F[F.length-1]?.add(R);let w=Reflect.get(S,h,y);if(H(w))return p(w,R),w;let T=G(w);return l(T)?g(T,R):T},set(S,h,y,R){if(R!==A&&!Object.prototype.hasOwnProperty.call(S,h))return Reflect.set(S,h,y,R);let w=c?`${c}.${h}`:h,T=H(y)?y:G(y),_=!Object.prototype.hasOwnProperty.call(S,h);if(!_&&Object.is(S[h],T)&&(T===null||typeof T!="object"))return!0;S[h]=T,m?.delete(h),H(T)?p(T,w):d(w);let L=H(T)||!l(T)?T:g(T,w);return i(w,L,_),!0},deleteProperty(S,h){if(typeof h!="string")return Reflect.deleteProperty(S,h);let y=Object.prototype.hasOwnProperty.call(S,h),R=Reflect.deleteProperty(S,h);if(R&&y){let w=c?`${c}.${h}`:h;(m??(m=new Set)).add(h),d(w),i(w,void 0)}return R}});return o.set(a,A),A},$=g(G(t),"");Object.entries(G(t)).forEach(([a,c])=>{H(c)&&p(c,a)});let C=(a,c,{immediate:u=!1}={})=>(n.has(a)||n.set(a,new Set),n.get(a).add(c),u&&c(se($,a),a),()=>n.get(a)?.delete(c)),x=(a,{immediate:c=!1}={})=>(e.add(a),c&&Rt($,"",(u,m)=>a(u,m)),()=>e.delete(a)),b=a=>{let c=!1,u=!1,m={deps:new Set,run:()=>{if(c){u=!0;return}c=!0;try{let A=0;do{u=!1;let S=new Set;F.push(S);try{a()}finally{F.pop(),m.deps=S}}while(u&&++A<100);u&&console.error("jq79: an effect re-woke itself 100 times in a row (it writes what it reads); giving up on it settling")}finally{c=!1}}};return s.add(m),m.run(),()=>{s.delete(m)}},E=()=>{f.forEach(({unsubscribe:a})=>a()),f.clear()};return r.$on=C,r.$onAny=x,r.$effect=b,r.$dispose=E,$},I=t=>{let n=[],e=[];return{effect:s=>{n.push(t.$effect(s)),e.push(s)},onDispose:s=>{n.push(s)},refresh:()=>{e.forEach(s=>s())},dispose:()=>{n.splice(0).forEach(s=>s()),e.length=0}}};var Tt=/(?:let|var|const)(?:\s+(?=[A-Za-z_$])|\s*(?=[{[]))/y,Ct=/\$:\s*/y,X=/import(?=\s*\()/y,At=/\$:\s*([A-Za-z_$][\w$]*)\s*=(?!=)/y,M=(t,n)=>{let e=t[n],s=n+1;for(;s<t.length;){if(t[s]==="\\"){s+=2;continue}if(t[s]===e)return s+1;s++}return t.length},j=(t,n)=>{let e=t.indexOf(`
2
- `,n);return e===-1?t.length:e},O=(t,n)=>{let e=t.indexOf("*/",n+2);return e===-1?t.length:e+2},K=(t,n)=>{let e=n;for(;e<t.length;){if(/\s/.test(t[e])){e++;continue}if(t[e]==="/"&&t[e+1]==="/"){e=j(t,e);continue}if(t[e]==="/"&&t[e+1]==="*"){e=O(t,e);continue}break}return e},re=new Set(["return","typeof","case","in","instanceof","new","delete","void","do","else","yield","await"]),D=(t,n)=>{let e=n-1;for(;e>=0;){let o=t[e];if(/\s/.test(o)){e--;continue}if(o==="/"&&t[e-1]==="*"){let r=t.lastIndexOf("/*",e-2);if(r===-1)return!0;e=r-1;continue}break}if(e<0)return!0;let s=t[e];if(/[\w$]/.test(s)){let o=e;for(;o>0&&/[\w$]/.test(t[o-1]);)o--;return re.has(t.slice(o,e+1))}return(s==="+"||s==="-")&&t[e-1]===s?!1:!")]}\"'`.".includes(s)},P=(t,n)=>{let e=n+1,s=!1;for(;e<t.length;){let o=t[e];if(o==="\\"){e+=2;continue}if(o===`
3
- `)return e;if(o==="[")s=!0;else if(o==="]")s=!1;else if(o==="/"&&!s){for(e++;e<t.length&&/[a-z]/i.test(t[e]);)e++;return e}e++}return t.length},ie=/^(\?\.|\?\?|&&|\|\||\*\*|[.,+\-*/%&|^<>=?:([])/,le=(t,n)=>{let e=n-1;for(;e>=0;){let s=t[e];if(/\s/.test(s)){e--;continue}if(s==="/"&&t[e-1]==="*"){let o=t.lastIndexOf("/*",e-2);if(o===-1)return"";e=o-1;continue}return s}return""},Nt=(t,n)=>{let e=0,s=n;for(;s<t.length;){let o=t[s];if(o==="'"||o==='"'||o==="`"){s=M(t,s);continue}if(o==="/"&&t[s+1]==="/"){s=j(t,s);continue}if(o==="/"&&t[s+1]==="*"){s=O(t,s);continue}if(o==="/"&&D(t,s)){s=P(t,s);continue}if("([{".includes(o))e++;else if(")]}".includes(o))e--;else{if(e<=0&&o===";")return s;if(e<=0&&o===`
4
- `){let r=K(t,s+1);if(!(r<t.length&&(ie.test(t.slice(r,r+2))||[",","="].includes(le(t,s)))))return s;s=r;continue}}s++}return t.length},ce=t=>{let n=[],e=0,s=0,o=0,r=l=>{n.push({raw:t.slice(s,l),codeEnd:Math.max(0,o-s)}),s=l+1,o=s},i=0;for(;i<t.length;){let l=t[i];if(l==="'"||l==='"'||l==="`"){i=M(t,i),o=i;continue}if(l==="/"&&t[i+1]==="/"){i=j(t,i);continue}if(l==="/"&&t[i+1]==="*"){i=O(t,i);continue}if(l==="/"&&D(t,i)){i=P(t,i),o=i;continue}if("([{".includes(l))e++;else if(")]}".includes(l))e--;else if(l===","&&e<=0){r(i),i++;continue}/\s/.test(l)||(o=i+1),i++}return r(t.length),n},ot=t=>{let n=t.trim();if(!n.startsWith("{")&&!n.startsWith("["))return rt.test(n)?[n]:[];let e=[];for(let s of lt(n.slice(1,Lt(n)))){s.startsWith("...")&&(s=s.slice(3).trim());let o=ct(s);if(o!==-1&&(s=s.slice(0,o).trim()),n.startsWith("{")){let r=it(s,":");if(r!==-1){e.push(...ot(s.slice(r+1)));continue}}e.push(...ot(s))}return e},ae=t=>{let n=[],e=ce(t).map(({raw:r,codeEnd:i})=>{let l=r.match(/^\s*/)[0];if(i<=l.length)return{text:r,empty:!0};let f=r.slice(l.length,i),p=r.slice(i),d=ct(f),g=(d===-1?f:f.slice(0,d)).trim(),$=f[0]==="{"||f[0]==="[";$?n.push(...ot(g)):rt.test(g)&&n.push(g);let C=V(f).code;return{text:`${l}${$?`(${C})`:C}${p}`,empty:!1}}),s=[];for(;e.length&&e[e.length-1].empty;)s.unshift(e.pop().text);let o=e.map(r=>r.text).join(",")+s.join("");return o.trimStart().startsWith("(")&&(o=`;${o}`),{vars:n,code:o}},V=t=>{let n=[],e="",s=0,o=0,r=!0;for(;s<t.length;){let i=t[s],l=t[s+1];if(i==="'"||i==='"'||i==="`"){let f=M(t,s);e+=t.slice(s,f),s=f,r=!1;continue}if(i==="/"&&(l==="/"||l==="*")){let f=l==="/"?j(t,s):O(t,s);e+=t.slice(s,f),s=f;continue}if(i==="/"&&D(t,s)){let f=P(t,s);e+=t.slice(s,f),s=f,r=!1;continue}if(i==="i"&&(s===0||!/[\w$.]/.test(t[s-1]))&&(X.lastIndex=s,X.test(t))){e+="$__import",s+=6,r=!1;continue}if(o===0&&r){Tt.lastIndex=s;let f=Tt.exec(t);if(f){let d=s+f[0].length,g=Nt(t,d),{vars:$,code:C}=ae(t.slice(d,g));n.push(...$),e+=C,s=g,r=!1;continue}Ct.lastIndex=s;let p=Ct.exec(t);if(p){At.lastIndex=s;let d=At.exec(t);d&&n.push(d[1]);let g=s+p[0].length,$=Nt(t,g);e+=`$__effect(() => { ${V(t.slice(g,$)).code} });`,s=$;continue}}"([{".includes(i)?o++:")]}".includes(i)&&(o=Math.max(0,o-1)),i===`
5
- `||i===";"||i==="}"?r=!0:/\s/.test(i)||(r=!1),e+=i,s++}return{vars:n,code:e}},J=/export\s+default(?![\w$])/y,vt=/import\s*(?:([\w$\s,{}*]+?)\s*from\s*)?(["'])([^"'\n]+)\2/y,fe=t=>{let n=[],e=0,s=0;for(let o=0;o<=t.length;o++){let r=t[o];if(r==="{")e++;else if(r==="}")e--;else if(o===t.length||r===","&&e===0){let i=t.slice(s,o).trim();i&&n.push(i),s=o+1}}return n},ue=(t,n,e)=>{let s=`await $__import(${JSON.stringify(n)})`;if(t===void 0)return s;let o=fe(t),r=[],i=s;if(o.length>1){let l=`$__mod${e}`;r.push(`${l} = ${s}`),i=l}for(let l of o)l.startsWith("{")?r.push(`${l.replace(/\s+as\s+/g,": ")} = ${i}`):l.startsWith("*")?r.push(`${l.replace(/^\*\s*as\s+/,"")} = ${i}`):r.push(`${l} = $__default(${i})`);return`const ${r.join(", ")}`},rt=/^[A-Za-z_$][\w$]*$/,Lt=t=>{let n=0,e=0;for(;e<t.length;){let s=t[e];if(s==="'"||s==='"'||s==="`"){e=M(t,e);continue}if(s==="/"&&t[e+1]==="/"){e=j(t,e);continue}if(s==="/"&&t[e+1]==="*"){e=O(t,e);continue}if(s==="/"&&D(t,e)){e=P(t,e);continue}if("([{".includes(s))n++;else if(")]}".includes(s)&&--n===0)return e;e++}return t.length},it=(t,n)=>{let e=0,s=0;for(;s<t.length;){let o=t[s];if(o==="'"||o==='"'||o==="`"){s=M(t,s);continue}if(o==="/"&&t[s+1]==="/"){s=j(t,s);continue}if(o==="/"&&t[s+1]==="*"){s=O(t,s);continue}if(o==="/"&&o!==n&&D(t,s)){s=P(t,s);continue}if("([{".includes(o))e++;else if(")]}".includes(o))e--;else if(e===0&&o===n)return s;s++}return-1},lt=t=>{let n=[],e=0,s=0,o=0;for(;o<=t.length;){let r=t[o];if(r==="'"||r==='"'||r==="`"){o=M(t,o);continue}if(r==="/"&&t[o+1]==="/"){o=j(t,o);continue}if(r==="/"&&t[o+1]==="*"){o=O(t,o);continue}if(r==="/"&&D(t,o)){o=P(t,o);continue}if(r!==void 0&&"([{".includes(r))e++;else if(r!==void 0&&")]}".includes(r))e--;else if(o===t.length||r===","&&e===0){let i=t.slice(s,o).trim();i&&n.push(i),s=o+1}o++}return n},ct=t=>{let n=0;for(;n<t.length;){let e=it(t.slice(n),"=");if(e===-1)return-1;let s=n+e;if(t[s+1]!=="="&&t[s+1]!==">"&&t[s-1]!=="="&&t[s-1]!=="!")return s;n=s+1}return-1},at=t=>{let n=(t??"").trim();if(!n.startsWith("{"))return null;let e=Lt(n);if(e>=n.length)return null;let s=[];for(let o of lt(n.slice(1,e))){if(o.startsWith("..."))continue;let r=ct(o),i=r===-1?o:o.slice(0,r),l=r===-1?void 0:o.slice(r+1).trim(),f=it(i,":"),p=(f===-1?i:i.slice(0,f)).trim();rt.test(p)&&s.push(l===void 0?{name:p}:{name:p,default:l})}return s},de=t=>{let n=0,e=0,s=!0;for(;n<t.length;){let o=t[n];if(o==="'"||o==='"'||o==="`"){n=M(t,n),s=!1;continue}if(o==="/"&&t[n+1]==="/"){n=j(t,n);continue}if(o==="/"&&t[n+1]==="*"){n=O(t,n);continue}if(o==="/"&&D(t,n)){n=P(t,n),s=!1;continue}if(o==="e"&&e===0&&s&&(n===0||!/[\w$.]/.test(t[n-1]))){J.lastIndex=n;let r=J.exec(t);if(r)return n+r[0].length}"([{".includes(o)?e++:")]}".includes(o)&&(e=Math.max(0,e-1)),o===`
6
- `||o===";"||o==="}"?s=!0:/\s/.test(o)||(s=!1),n++}return-1},pe=/^async(?![\w$])/,he=/^function(?![\w$])\s*\*?\s*[A-Za-z_$][\w$]*|^function(?![\w$])\s*\*?/,me=t=>{let n=de(t);if(n===-1)return null;let e=K(t,n),s=t.slice(e);pe.test(s)&&(e=K(t,e+5));let o=he.exec(t.slice(e));if(o&&(e=K(t,e+o[0].length)),t[e]!=="(")return null;let r=0,i=e;for(;i<t.length;){let l=t[i];if(l==="'"||l==='"'||l==="`"){i=M(t,i);continue}if(l==="/"&&t[i+1]==="/"){i=j(t,i);continue}if(l==="/"&&t[i+1]==="*"){i=O(t,i);continue}if(l==="/"&&D(t,i)){i=P(t,i);continue}if("([{".includes(l))r++;else if(")]}".includes(l)&&--r===0)break;i++}return lt(t.slice(e+1,i))[0]??""},_t=t=>{let n=me(t);if(n===null)return null;let e=at(n),s=e?.find(o=>o.name.startsWith("$"))?.name;if(s)throw new Error(`jq79: the factory signature is (props, ctx), so \`${s}\` can't be destructured from the first parameter. Write \`export default (props, { ${s} }) => \u2026\`, or \`_\` in place of props if the component takes none.`);return e},jt=t=>{let n="",e=0,s=0,o=!0,r=!1,i=0;for(;e<t.length;){let l=t[e],f=t[e+1],p=e===0||!/[\w$.]/.test(t[e-1]);if(l==="'"||l==='"'||l==="`"){let d=M(t,e);n+=t.slice(e,d),e=d,o=!1;continue}if(l==="/"&&(f==="/"||f==="*")){let d=f==="/"?j(t,e):O(t,e);n+=t.slice(e,d),e=d;continue}if(l==="/"&&D(t,e)){let d=P(t,e);n+=t.slice(e,d),e=d,o=!1;continue}if(l==="i"&&p){if(X.lastIndex=e,X.test(t)){n+="$__import",e+=6,o=!1;continue}if(s===0&&o){vt.lastIndex=e;let d=vt.exec(t);if(d){n+=ue(d[1],d[3],i++),e+=d[0].length,o=!1;continue}}}if(l==="e"&&p&&s===0&&o){J.lastIndex=e;let d=J.exec(t);if(d){r=!0,n+="$__exports.default =",e+=d[0].length,o=!1;continue}}"([{".includes(l)?s++:")]}".includes(l)&&(s=Math.max(0,s-1)),l===`
7
- `||l===";"||l==="}"?o=!0:/\s/.test(l)||(o=!1),n+=l,e++}return r?n:null};var Ft=t=>Object.fromEntries(Array.from(t.attributes).map(n=>[n.name,n.value])),It=t=>({tag:t.tagName.toLowerCase(),attrs:Ft(t),children:Array.from(t.childNodes).flatMap(n=>{if(n.nodeType===Node.TEXT_NODE){let e=n.textContent??"";return e?[e]:[]}return n.nodeType===Node.ELEMENT_NODE?[It(n)]:[]})}),Ot=new Map,Wt=(t,n)=>{let e=`${n.join(",")}|${t}`,s=Ot.get(e);if(s===void 0){try{s=new Function("$scope",...n,`with ($scope) { return (${t}
8
- ); }`)}catch{s=null}Ot.set(e,s)}return s},N=(t,n,e)=>{let s=Wt(t,e?Object.keys(e):[]);if(s)try{return s(n,...e?Object.values(e):[])}catch{return}},ge=(t,n)=>t.replace(/{{\s*([\s\S]+?)\s*}}/g,(e,s)=>N(s,n)??""),ye=new Set([":attrs",":class",":value",":checked",":selected",":if",":elseif",":else",":each",":key",":with",":text",":html",":html.allowed"]),Ht=t=>ye.has(t)||t.startsWith(":class."),be=/^\s*\(?\s*(\w+)\s*(?:,\s*(\w+))?\s*\)?\s+in\s+([\s\S]+)$/,Ee=(t,n,e,s)=>{let[o,...r]=n.slice(1).split("."),i=new Set(r);t.addEventListener(o,l=>{if(i.has("self")&&l.target!==t)return;i.has("prevent")&&l.preventDefault(),i.has("stop")&&l.stopPropagation();let f=N(e,s,{$event:l});typeof f=="function"&&f.call(t,l)},{once:i.has("once"),capture:i.has("capture")})},we=(t,n,e,s)=>{let[o,...r]=n.slice(1).split("."),i=new Set(r),l=f=>{i.has("prevent")&&f.preventDefault(),i.has("stop")&&f.stopPropagation(),i.has("once")&&t.off(o,l),q(()=>{let p=N(e,s,{$event:f});typeof p=="function"&&p(f)})};t.on(o,l)},Q=t=>t.replace(/-(\w)/g,(n,e)=>e.toUpperCase()),ut=t=>t instanceof DocumentFragment?{first:t.firstChild,last:t.lastChild}:{first:t,last:t},Y=({first:t,last:n})=>{for(let e=t;e;){let s=e===n?null:e.nextSibling;e.parentNode?.removeChild(e),e=s}},$e=({first:t,last:n},e)=>{let s=e.nextSibling;for(let o=t;o;){let r=o===n?null:o.nextSibling;e.parentNode.insertBefore(o,s),o=r}},Mt=(t,n)=>{let e=n.replace(/-/g,"").toLowerCase();for(let s=t;s&&s!==Object.prototype;s=Object.getPrototypeOf(s))for(let o of Object.keys(s))if(/^[A-Z]/.test(o)&&o.replace(/-/g,"").toLowerCase()===e)return o;return null},Dt=(t,n,e,s,o)=>{let r=document.createComment(t),i=document.createComment(`/${t}`),l=document.createDocumentFragment();l.append(r,i);let f={},p={},d=[];Object.entries(n.attrs).forEach(([a,c])=>{if(!(a===ht||Ht(a)))if(a.startsWith("@"))d.push([a,c]);else if(a===":model"||a.startsWith(":model.")){let u=a===":model"?"default":Q(a.slice(7));p[u]=c||(a===":model"?"model":u)}else if(a.startsWith(":")){let u=Q(a.slice(1));f[u]=c||u}else f[Q(a)]=JSON.stringify(c)});let g=a=>a==="default"?":model":`:model.${a}`,$=a=>a==="default"?"model":a,C=a=>`${a}
9
- = $value`;Object.entries(p).forEach(([a,c])=>{let u=$(a);f[u]!==void 0&&console.warn(`jq79: <${n.tag}> binds prop "${u}" through both :${u} and ${g(a)} - ${g(a)} wins`),f[u]=c,Wt(C(c),["$value"])===null&&console.warn(`jq79: ${g(a)}="${c}" is not assignable - updates from <${n.tag}> will be dropped`)});let x=null,b=null,E=null;return s.effect(()=>{let a=N(t,e),c=a instanceof k?a:null;if(c===b||(E?.dispose(),E=null,x?.destroy(),x=null,b=c,!c))return;let u=new k({template:c.template,scripts:c.scripts,styles:c.styles,modules:c.modules,filename:c.filename});if(Object.keys(p).length){let h=new Set,y=(R,w)=>{h.has(R)||(h.add(R),console.warn(w))};u.on("model:update",(R,w)=>{if(w===null||typeof w!="object"){y("payload",`jq79: model:update expects a { name?, value } payload, got ${w===null?"null":typeof w}`);return}let T=w.name==null?"default":Q(String(w.name)),_=p[T];if(_===void 0){y(T,`jq79: <${n.tag}> has no ${g(T)} - bound: ${Object.keys(p).map(g).join(", ")}`);return}q(()=>N(C(_),e,{$value:w.value}))})}d.forEach(([h,y])=>we(u,h,y,e));let m=q(()=>Object.fromEntries(Object.entries(f).map(([h,y])=>[h,N(y,e)]))),A=document.createDocumentFragment();(o?u.renderShadow(m):u.render(m)).mount(A),i.parentNode.insertBefore(A,i);let S=I(e);Object.entries(f).forEach(([h,y])=>{S.effect(()=>{u.data[h]=N(y,e)})}),E=S,x=u}),s.onDispose(()=>{E?.dispose(),x?.destroy()}),l},Se=(t,n)=>{let e=()=>{let s=N(t,n);return s!==null&&typeof s=="object"?s:null};return new Proxy(n,{has(s,o){let r=e();return r!==null&&Reflect.has(r,o)||Reflect.has(s,o)},get(s,o){let r=e();return r!==null&&Reflect.has(r,o)?r[o]:Reflect.get(s,o)},set(s,o,r){let i=e();return i!==null&&Reflect.has(i,o)?(i[o]=r,!0):Reflect.set(s,o,r)}})},z=t=>typeof t=="string"?t.split(/\s+/).filter(Boolean):Array.isArray(t)?t.flatMap(z):t!==null&&typeof t=="object"?Object.entries(t).flatMap(([n,e])=>e?z(n):[]):[],Re=t=>typeof t=="function"?(n,e,s)=>{try{return!!t(n,e,s)}catch{return!1}}:typeof t=="string"||Array.isArray(t)?Et(t):()=>!1,dt=(t,n,e,s)=>{let o=t.attrs[":with"],r=o!==void 0?Se(o,n):n,i=Mt(r,t.tag);if(i)return Dt(i,t,r,e,s);let l=document.createElement(t.tag);if(l instanceof HTMLUnknownElement||t.tag.includes("-")){let b=!1;e.effect(()=>{if(b)return;let E=Mt(r,t.tag);if(!E)return;b=!0;let a=Dt(E,t,r,e,s),c=ut(a);e.onDispose(()=>Y(c)),l.replaceWith(a)})}Object.entries(t.attrs).forEach(([b,E])=>{b.startsWith("@")?Ee(l,b,E,r):b===":model"||b.startsWith(":model.")?l instanceof HTMLUnknownElement||t.tag.includes("-")||console.warn(`jq79: ${b} on <${t.tag}> does nothing - :model binds component tags only (for now)`):Ht(b)||l.setAttribute(b,E)});let f=t.attrs[":attrs"];if(f!==void 0){let b=[];e.effect(()=>{b.forEach(a=>l.removeAttribute(a));let E=N(f,r);b=E&&typeof E=="object"?Object.keys(E):[],b.forEach(a=>{let c=E[a];c!=null&&c!==!1&&l.setAttribute(a,String(c))})})}let p=t.attrs[":class"],d=Object.entries(t.attrs).filter(([b])=>b.startsWith(":class.")).map(([b,E])=>[b.slice(7),E]);if(p!==void 0||d.length){let b=new Set(z(t.attrs.class??"")),E=[];e.effect(()=>{let a=p!==void 0?z(N(p,r)):[];d.forEach(([c,u])=>{N(u,r)&&a.push(...z(c))}),E.forEach(c=>{!a.includes(c)&&!b.has(c)&&l.classList.remove(c)}),l.classList.add(...a),E=a})}let g=t.attrs[":text"],$=t.attrs[":html"],C=t.attrs[":html.allowed"];C!==void 0&&$===void 0&&console.warn("jq79: :html.allowed without :html on the same element does nothing"),g!==void 0?e.effect(()=>{l.textContent=String(N(g,r)??"")}):$!==void 0?e.effect(()=>{let b=C!==void 0?{allowUrl:Re(N(C,r))}:void 0;l.innerHTML=$t(String(N($,r)??""),b)}):l.appendChild(pt(t.children,r,e,s));let x=t.attrs[":value"];return x!==void 0&&e.effect(()=>{let b=String(N(x,r)??"");l.value!==b&&(l.value=b)}),[":checked",":selected"].forEach(b=>{let E=t.attrs[b];if(E===void 0)return;let a=b.slice(1);e.effect(()=>{l[a]=!!N(E,r)})}),l},xe=(t,n,e,s)=>{let o=document.createComment("if"),r=document.createDocumentFragment();r.appendChild(o);let i=null,l=null,f=null;return e.effect(()=>{let p=t.find(g=>g.expr===void 0||N(g.expr,n))??null;if(p===l||(f?.dispose(),i&&Y(i),i=null,l=p,!p))return;f=I(n);let d=dt(p.node,n,f,s);i=ut(d),o.parentNode.insertBefore(d,o.nextSibling)}),r},B=(t,n,e)=>{Object.defineProperty(t,n,{value:e,writable:!0,enumerable:!0,configurable:!0})},Te=t=>{if(t===null||typeof t!="object"||Array.isArray(t))return!1;let n=Object.getPrototypeOf(t);return n===Object.prototype||n===null},Ce=(t,n,e,s)=>{let o=t.attrs[":each"].match(be);if(!o)return document.createComment(`invalid :each expression "${t.attrs[":each"]}"`);let[,r,i,l]=o,f=t.attrs[":key"],{[":each"]:p,[":key"]:d,...g}=t.attrs,$={...t,attrs:g},C=document.createComment("each"),x=document.createDocumentFragment();x.appendChild(C),(":if"in t.attrs||":elseif"in t.attrs||":else"in t.attrs)&&console.warn("jq79: :if/:elseif/:else on a :each element is ignored; filter the list expression instead");let b=[],E=!1;return e.effect(()=>{let a=N(l,n),c=Array.isArray(a)?a.map((y,R)=>[R,y]):Te(a)?Object.entries(a):[],u=new Map;b.forEach(y=>{let R=u.get(y.key);R?R.push(y):u.set(y.key,[y])});let m=new Set,A=[],S=c.map(([y,R],w)=>{let T=Object.create(n);B(T,r,R),i&&B(T,i,y),B(T,"$index",w);let _=f!==void 0?N(f,T):y;m.has(_)&&!E&&(E=!0,console.warn(`jq79: duplicate :key in :each "${t.attrs[":each"]}"; duplicates pair up by position`)),m.add(_);let L=u.get(_)?.shift();if(L&&Object.is(L.item,R))return L.scope.$index!==w&&A.push(L),B(L.scope,"$index",w),i&&B(L.scope,i,y),L;L&&(L.fx.dispose(),Y(L.range));let gt=I(n),Zt=ut(dt($,T,gt,s));return{key:_,item:R,scope:T,fx:gt,range:Zt}});u.forEach(y=>y.forEach(R=>{R.fx.dispose(),Y(R.range)}));let h=C;S.forEach(y=>{h.nextSibling!==y.range.first&&$e(y.range,h),h=y.range.last}),A.forEach(y=>q(()=>y.fx.refresh())),b=S}),x},pt=(t,n,e,s=!1)=>{let o=document.createDocumentFragment(),r=0;for(;r<t.length;){let i=t[r];if(typeof i=="string"){let l=document.createTextNode(i);i.includes("{{")&&e.effect(()=>{l.textContent=ge(i,n)}),o.appendChild(l),r++;continue}if(":each"in i.attrs){o.appendChild(Ce(i,n,e,s)),r++;continue}if(":if"in i.attrs){let l=[{expr:i.attrs[":if"],node:i}];r++;let f=d=>{let g=r;for(;g<t.length&&typeof t[g]=="string"&&!t[g].trim();)g++;let $=t[g];if(typeof $=="object"&&d in $.attrs)return r=g+1,$};for(let d=f(":elseif");d;d=f(":elseif"))l.push({expr:d.attrs[":elseif"],node:d});let p=f(":else");p&&l.push({node:p}),o.appendChild(xe(l,n,e,s));continue}o.appendChild(dt(i,n,e,s)),r++}return o},Ve=(t,n,e=!1)=>pt(t.template,n,I(n),e),Ae=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Ne=/<([A-Za-z][\w-]*)((?:"[^"]*"|'[^']*'|[^>"'])*?)\/>/g,ve=/(<script[\s\S]*?<\/script\s*>|<style[\s\S]*?<\/style\s*>)/gi,Le=t=>t.split(ve).map((n,e)=>e%2===1?n:n.replace(Ne,(s,o,r)=>Ae.has(o.toLowerCase())?s:`<${o}${r}></${o}>`)).join(""),ht="data-jq79",_e=t=>{let n=2166136261;for(let e=0;e<t.length;e++)n=Math.imul(n^t.charCodeAt(e),16777619);return(n>>>0).toString(36)},qt=(t,n)=>{t.forEach(e=>{typeof e!="string"&&(e.attrs[ht]=n,qt(e.children,n))})},je=(t,n)=>t.split(",").map(e=>{let s=e.trim(),o=s.indexOf("::"),r=o===-1?s:s.slice(0,o),i=o===-1?"":s.slice(o);return`${r}[${ht}="${n}"]${i}`}).join(", "),Bt=(t,n)=>{Array.from(t).forEach(e=>{e instanceof CSSStyleRule?e.selectorText=je(e.selectorText,n):e instanceof CSSGroupingRule&&Bt(e.cssRules,n)})},Oe=(t,n)=>{/:deep\(|::v-deep|>>>/.test(t)&&console.warn("jq79: :deep()/::v-deep/>>> are not supported in <style scoped>; the rule will be dropped by the browser");let e=new CSSStyleSheet;return e.replaceSync(t),Bt(e.cssRules,n),Array.from(e.cssRules).map(s=>s.cssText).join(`
10
- `)},ft=t=>{let e=new DOMParser().parseFromString(`<template>${Le(t)}</template>`,"text/html").querySelector("template"),s=[],o=[],r=[];Array.from(e.content.children).forEach(l=>{let f={attrs:Ft(l),content:l.textContent??""};l.tagName==="SCRIPT"?s.push(f):l.tagName==="STYLE"?o.push(f):r.push(It(l))}),o.forEach(l=>{"lang"in l.attrs&&console.warn(`jq79: <style lang="${l.attrs.lang}"> needs the jq79/vite plugin to compile it. This component didn't go through the bundler, so its styles were left uncompiled and the browser will ignore them.`)});let i=l=>"scoped"in l.attrs&&!("lang"in l.attrs);if(o.some(i)){let l=_e(t);qt(r,l),o.forEach(f=>{i(f)&&(f.scoped=Oe(f.content,l))})}return{template:r,scripts:s,styles:o}},mt=t=>/\.html?([?#]|$)/.test(t)?k.fetch(t):import(t),zt=(t,n)=>t?`
11
- //# sourceURL=${t}?jq79-script=${n}`:"",Pt=t=>t.scoped??t.content,tt=new Map,Me=t=>{let n=tt.get(t);if(!n){let e=document.createElement("style");e.textContent=t,document.head.appendChild(e),n={el:e,count:0},tt.set(t,n)}n.count++},De=t=>{let n=tt.get(t);n&&--n.count<=0&&(n.el.remove(),tt.delete(t))},Pe=(t,n,e,s={},o=mt,r={})=>{let i={...Gt,...s},l=new Proxy(n,{has:(p,d)=>d!=="$__effect"&&d!=="$__import"&&(Reflect.has(p,d)||!(d in globalThis)&&!(d in i))});new Function("$scope","$__effect","$__import",...Object.keys(i),`return (async () => { with ($scope) { ${t} } })()${zt(r.filename,r.index??0)}`)(l,e,o,...Object.values(i)).catch(p=>console.error("jq79: error in :setup script",p))},Ut=(t,n)=>{n?.forEach(({name:e,default:s})=>{t[e]===void 0&&(t[e]=s===void 0?void 0:N(s,t))})},Ue=t=>t&&t.default!==void 0?t.default:t,ke=(t,n,e,s={},o=mt,r={})=>{let i={...Gt,...s},l={},f=new Function("$__exports","$__default","$__import",...Object.keys(i),`return (async () => { "use strict";
12
- ${t}
13
- ;$__exports.done = true })()${zt(r.filename,r.index??0)}`)(l,Ue,o,...Object.values(i)),p=$=>console.error("jq79: error in factory script",$),d=!1,g=()=>{if(d)return;d=!0;let $=l.default;if(typeof $!="function")return;let C=x=>{x&&typeof x=="object"&&Object.assign(n,x)};try{let x=$(n,{$data:n,$props:n,$effect:e,...s});x instanceof Promise?x.then(C).catch(p):C(x)}catch(x){p(x)}};f.then(g,p),l.done&&g()},Fe="__JQ79_HMR_ENABLED__",Ie="__JQ79_HMR__",U=null,We=t=>{if(!U||!t.filename)return;let n=U.get(t.filename);n||U.set(t.filename,n=new Set),n.add(new WeakRef(t))},kt=t=>{try{return new URL(t,document.baseURI).pathname}catch{return t}},He=(t,n)=>{if(!U)return 0;let e=kt(t),s=ft(n),o=0;for(let[r,i]of U)if(kt(r)===e){for(let l of i){let f=l.deref();if(!f){i.delete(l);continue}f.hotReplace(s)&&o++}i.size||U.delete(r)}return o},qe=()=>{U??(U=new Map),globalThis[Ie]={update:He}},k=class t{constructor(n,e={}){v(this,"template");v(this,"scripts");v(this,"styles");v(this,"modules");v(this,"filename");v(this,"data",null);v(this,"fx",null);v(this,"content",null);v(this,"startMarker",null);v(this,"endMarker",null);v(this,"styleEls",[]);v(this,"ownsSharedStyles",!1);v(this,"useShadow",!1);v(this,"mountRoot",null);v(this,"resolveMounted",null);v(this,"emitListeners",new Map);let s=typeof n=="string"?ft(n):n;this.template=s.template,this.scripts=s.scripts,this.styles=s.styles,this.modules=e.modules??(typeof n=="string"?void 0:n.modules),this.filename=e.filename??(typeof n=="string"?void 0:n.filename),We(this)}hotReplace(n){let e=typeof n=="string"?ft(n):n,s=this.startMarker,o=!!(s&&this.content),r=o&&s.isConnected,i=r?s.parentNode:null,l=r?this.endMarker.nextSibling:null,f={...this.data},p=this.useShadow;return o&&this.destroy(),this.template=e.template,this.scripts=e.scripts,this.styles=e.styles,!o||(this.renderWith(f,p),!i)?!1:(p&&this.styleEls.forEach(d=>i.insertBefore(d,l)),i.insertBefore(this.content,l),this.mountRoot=i,this.resolveMounted?.(),!0)}static async fetch(n){let e=await fetch(n);if(!e.ok)throw new Error(`failed to fetch component from ${n}: ${e.status}`);return new t(await e.text(),{filename:n})}on(n,e){return this.emitListeners.has(n)||this.emitListeners.set(n,new Set),this.emitListeners.get(n).add(e),this}off(n,e){return this.emitListeners.get(n)?.delete(e),this}render(n={}){return this.renderWith(n,!1)}renderShadow(n={}){return this.renderWith(n,!0)}renderWith(n,e){this.destroy();let s=Z({...n}),o=I(s);this.data=s,this.fx=o,this.useShadow=e,this.startMarker=document.createComment("jq79"),this.endMarker=document.createComment("/jq79");let r=this.startMarker,i=(c,u)=>{let m=new CustomEvent(c,{detail:u,bubbles:!0,composed:!0,cancelable:!0});return r===this.startMarker&&this.emitListeners.get(c)?.forEach(A=>A(m,u)),m.cancelBubble||r.dispatchEvent(m),!m.defaultPrevented},l,f=new Promise(c=>{l=c});this.resolveMounted=l;let p=()=>f,d=this.endMarker,g=c=>{let u=[];for(let m=r.nextSibling;m&&m!==d;m=m.nextSibling)m instanceof Element&&(m.matches(c)&&u.push(m),u.push(...Array.from(m.querySelectorAll(c))));return u},$=c=>g(c)[0]??null,C=this.modules,x=c=>C&&c in C?Promise.resolve(C[c]):mt(c),b=c=>`await $mounted();${c}`;this.scripts.forEach((c,u)=>{let m={$emit:i,$mounted:p,$self:$,$$self:g},A={filename:this.filename,index:u},S=jt(c.content);if(S!==null){Ut(s,_t(c.content));let w=":mounted"in c.attrs?b(S):S;ke(w,s,o.effect,m,x,A);return}let{vars:h,code:y}=V(c.content);Ut(s,at(c.attrs[":setup"])),h.forEach(w=>{w in s||(s[w]=void 0)});let R=":mounted"in c.attrs?b(y):y;Pe(R,s,o.effect,m,x,A)});let E=document.createDocumentFragment(),a=new Proxy(s,{has:(c,u)=>u==="$emit"||Reflect.has(c,u),get:(c,u,m)=>u==="$emit"&&!Reflect.has(c,u)?i:Reflect.get(c,u,m)});return E.append(this.startMarker,pt(this.template,a,o,e),this.endMarker),this.content=E,e?this.styleEls=this.styles.map(c=>{let u=document.createElement("style");return u.textContent=c.content,u}):(this.styles.forEach(c=>Me(Pt(c))),this.ownsSharedStyles=!0),this}mount(n,e){let s=typeof n=="string"?W(n):n;if(!s)throw new Error(`mount target not found: ${n}`);return(!this.content||e!==void 0)&&this.renderWith(e??{},this.useShadow),this.attach(s)}mountShadow(n,e){let s=typeof n=="string"?W(n):n;if(!s)throw new Error(`mount target not found: ${n}`);return(!this.content||e!==void 0||!this.useShadow)&&this.renderWith(e??{},!0),this.attach(s)}attach(n){this.mountRoot&&this.detach();let e=this.useShadow&&n instanceof Element?n.shadowRoot??n.attachShadow({mode:"open"}):n;return this.useShadow&&this.styleEls.forEach(s=>e.appendChild(s)),e.appendChild(this.content),this.mountRoot=e,this.resolveMounted?.(),this}detach(){if(!this.mountRoot||!this.content||!this.startMarker||!this.endMarker)return this;let n=this.startMarker;for(;n;){let e=n.nextSibling;if(this.content.appendChild(n),n===this.endMarker)break;n=e}return this.mountRoot=null,this}destroy(){return this.detach(),this.fx?.dispose(),this.fx=null,this.data?.$dispose(),this.styleEls.forEach(n=>n.parentNode?.removeChild(n)),this.styleEls=[],this.ownsSharedStyles&&(this.styles.forEach(n=>De(Pt(n))),this.ownsSharedStyles=!1),this.content=null,this.startMarker=null,this.endMarker=null,this.data=null,this.resolveMounted=null,this}};var Qe=t=>new k(t),Gt={$:W,$$:et,$create:nt,$reactive:Z,Component79:k};typeof globalThis<"u"&&globalThis[Fe]&&qe();export{W as $,et as $$,nt as $create,Z as $reactive,k as C79,k as Component79,qe as enableHotReload,He as hotUpdate,Qe as parseComponent,Ve as renderComponent};
1
+ var nt=Object.defineProperty;var st=(e,n,t)=>n in e?nt(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var N=(e,n,t)=>st(e,typeof n!="symbol"?n+"":n,t);function H(e,n){return typeof e=="string"?document.querySelector(e):e.querySelector(n)}function re(e,n){return Array.from(typeof e=="string"?document.querySelectorAll(e):e.querySelectorAll(n))}var ie=(e,n={})=>{let t=document.createElement(e);for(let[s,o]of Object.entries(n))if(s==="className")t.className=Array.isArray(o)?o.join(" "):o;else if(s==="textContent")t.textContent=o;else if(s==="children")for(let i of o)t.appendChild(i);else t.setAttribute(s,o);return t},ot=new Set(["a","b","i","em","strong","p","br","ul","ol","li","blockquote","code","pre","span","div","h1","h2","h3","h4","h5","h6","img"]),$e={a:new Set(["href","title"]),img:new Set(["src","alt"]),"*":new Set(["class"])},rt=new Set(["http:","https:","mailto:"]);function it(e){try{let n=new URL(e,"https://example.com");return rt.has(n.protocol)}catch{return!1}}var lt={"https:":"443","http:":"80"};function at(e){let n=e.trim().toLowerCase().match(/^([a-z\d*][a-z\d.*-]*?)(?::(\d{1,5}|\*))?$/);if(!n)return null;let[,t,s]=n,o=t.split(".");return o.some(r=>r!=="*"&&!/^[a-z\d-]+$/.test(r))?null:{host:new RegExp(`^${o.map(r=>r==="*"?"[^.]+":r).join("\\.")}$`),port:!s||s==="*"?null:s}}var xe=e=>{let n=(Array.isArray(e)?e:e.split(",")).map(at).filter(t=>t!==null);return t=>{let s=t.hostname.toLowerCase(),o=t.port||lt[t.protocol]||"";return n.some(i=>i.host.test(s)&&(i.port===null||i.port===o))}};function ct(e,n,t,s){try{return!!e(new URL(n,document.baseURI),t,s)}catch{return!1}}var Re=512;function Te(e,n,t,s){if(t>Re)throw new RangeError(`jq79: sanitizeHTML input nests deeper than ${Re} elements`);for(let o of Array.from(e.childNodes))if(o.nodeType===Node.ELEMENT_NODE){let i=ft(o,t,s);i&&n.appendChild(i)}else o.nodeType===Node.TEXT_NODE&&n.appendChild(o.cloneNode())}function ft(e,n,t){let s=e.tagName.toLowerCase();if(!ot.has(s))return null;let o=document.createElement(s);for(let i of Array.from(e.attributes)){let r=i.name.toLowerCase(),l=$e[s]?.has(r),c=$e["*"]?.has(r);!l&&!c||(r==="href"||r==="src")&&(!it(i.value)||t&&!ct(t,i.value,s,r))||o.setAttribute(r,i.value)}return s==="a"&&o.setAttribute("rel","noopener noreferrer"),Te(e,o,n+1,t),o}function Ce(e,n){let t=document.createElement("template");t.innerHTML=e;let s=document.createElement("div");return Te(t.content,s,0,n?.allowUrl),s.innerHTML}var ut=(e,n)=>n.split(".").reduce((t,s)=>t?.[s],e),Ae=e=>{if(Array.isArray(e))return!0;let n=Object.getPrototypeOf(e);return n===Object.prototype||n===null},je=(e,n,t)=>{Object.entries(e).forEach(([s,o])=>{let i=n?`${n}.${s}`:s;o&&typeof o=="object"&&Ae(o)?je(o,i,t):t(i,o)})},dt=(e,n)=>e===n||e.startsWith(`${n}.`)||n.startsWith(`${e}.`),le=Symbol("jq79.raw"),K=e=>{let n=e;for(;n!==null&&typeof n=="object"&&n[le];)n=n[le];return n},_e=Symbol("jq79.store"),B=e=>e!==null&&typeof e=="object"&&e[_e]===!0,k=[],z=e=>{k.push(new Set);try{return e()}finally{k.pop()}},X=e=>{let n=new Map,t=new Set,s=new Set,o=new WeakMap,i=Object.create(null),r=(h,g,w=!1)=>{n.get(h)?.forEach(S=>S(g,h)),t.forEach(S=>S(h,g)),s.forEach(S=>{(w||Array.from(S.deps).some(v=>dt(v,h)))&&S.run()})},l=h=>h!==null&&typeof h=="object"&&Ae(h),c=new Map,d=(h,g)=>{let w=c.get(g);w?.store!==h&&(w?.unsubscribe(),c.set(g,{store:h,unsubscribe:h.$onAny((S,v)=>r(`${g}.${S}`,v))}))},p=h=>{c.get(h)?.unsubscribe(),c.delete(h)},m=(h,g)=>{let w=o.get(h);if(w)return w;let S=null,v=new Proxy(h,{has(a,f){return Reflect.has(a,f)||typeof f=="string"&&S?.has(f)===!0},get(a,f,u){if(f===le)return a;if(f===_e)return g==="";if(typeof f!="string")return Reflect.get(a,f,u);if(g===""&&f in i)return i[f];let E=g?`${g}.${f}`:f;k[k.length-1]?.add(E);let C=Reflect.get(a,f,u);if(B(C))return d(C,E),C;let R=K(C);return l(R)?m(R,E):R},set(a,f,u,E){if(E!==v&&!Object.prototype.hasOwnProperty.call(a,f))return Reflect.set(a,f,u,E);let C=g?`${g}.${f}`:f,R=B(u)?u:K(u),_=!Object.prototype.hasOwnProperty.call(a,f);if(!_&&Object.is(a[f],R)&&(R===null||typeof R!="object"))return!0;a[f]=R,S?.delete(f),B(R)?d(R,C):p(C);let x=B(R)||!l(R)?R:m(R,C);return r(C,x,_),!0},deleteProperty(a,f){if(typeof f!="string")return Reflect.deleteProperty(a,f);let u=Object.prototype.hasOwnProperty.call(a,f),E=Reflect.deleteProperty(a,f);if(E&&u){let C=g?`${g}.${f}`:f;(S??(S=new Set)).add(f),p(C),r(C,void 0)}return E}});return o.set(h,v),v},b=m(K(e),"");Object.entries(K(e)).forEach(([h,g])=>{B(g)&&d(g,h)});let T=(h,g,{immediate:w=!1}={})=>(n.has(h)||n.set(h,new Set),n.get(h).add(g),w&&g(ut(b,h),h),()=>n.get(h)?.delete(g)),A=(h,{immediate:g=!1}={})=>(t.add(h),g&&je(b,"",(w,S)=>h(w,S)),()=>t.delete(h)),y=h=>{let g=!1,w=!1,S={deps:new Set,run:()=>{if(g){w=!0;return}g=!0;try{let v=0;do{w=!1;let a=new Set;k.push(a);try{h()}finally{k.pop(),S.deps=a}}while(w&&++v<100);w&&console.error("jq79: an effect re-woke itself 100 times in a row (it writes what it reads); giving up on it settling")}finally{g=!1}}};return s.add(S),S.run(),()=>{s.delete(S)}},$=()=>{c.forEach(({unsubscribe:h})=>h()),c.clear()};return i.$on=T,i.$onAny=A,i.$effect=y,i.$dispose=$,b},q=e=>{let n=[],t=[];return{effect:s=>{n.push(e.$effect(s)),t.push(s)},onDispose:s=>{n.push(s)},refresh:()=>{t.forEach(s=>s())},dispose:()=>{n.splice(0).forEach(s=>s()),t.length=0}}};var Ne=/(?:let|var|const)(?:\s+(?=[A-Za-z_$])|\s*(?=[{[]))/y,Oe=/\$:\s*/y,V=/import(?=\s*\()/y,ve=/\$:\s*([A-Za-z_$][\w$]*)\s*=(?!=)/y,D=(e,n)=>{let t=e[n],s=n+1;for(;s<e.length;){if(e[s]==="\\"){s+=2;continue}if(e[s]===t)return s+1;s++}return e.length},P=(e,n)=>{let t=e.indexOf(`
2
+ `,n);return t===-1?e.length:t},M=(e,n)=>{let t=e.indexOf("*/",n+2);return t===-1?e.length:t+2},J=(e,n)=>{let t=n;for(;t<e.length;){if(/\s/.test(e[t])){t++;continue}if(e[t]==="/"&&e[t+1]==="/"){t=P(e,t);continue}if(e[t]==="/"&&e[t+1]==="*"){t=M(e,t);continue}break}return t},pt=new Set(["return","typeof","case","in","instanceof","new","delete","void","do","else","yield","await"]),U=(e,n)=>{let t=n-1;for(;t>=0;){let o=e[t];if(/\s/.test(o)){t--;continue}if(o==="/"&&e[t-1]==="*"){let i=e.lastIndexOf("/*",t-2);if(i===-1)return!0;t=i-1;continue}break}if(t<0)return!0;let s=e[t];if(/[\w$]/.test(s)){let o=t;for(;o>0&&/[\w$]/.test(e[o-1]);)o--;return pt.has(e.slice(o,t+1))}return(s==="+"||s==="-")&&e[t-1]===s?!1:!")]}\"'`.".includes(s)},F=(e,n)=>{let t=n+1,s=!1;for(;t<e.length;){let o=e[t];if(o==="\\"){t+=2;continue}if(o===`
3
+ `)return t;if(o==="[")s=!0;else if(o==="]")s=!1;else if(o==="/"&&!s){for(t++;t<e.length&&/[a-z]/i.test(e[t]);)t++;return t}t++}return e.length},ht=/^(\?\.|\?\?|&&|\|\||\*\*|[.,+\-*/%&|^<>=?:([])/,gt=(e,n)=>{let t=n-1;for(;t>=0;){let s=e[t];if(/\s/.test(s)){t--;continue}if(s==="/"&&e[t-1]==="*"){let o=e.lastIndexOf("/*",t-2);if(o===-1)return"";t=o-1;continue}return s}return""},Le=(e,n)=>{let t=0,s=n;for(;s<e.length;){let o=e[s];if(o==="'"||o==='"'||o==="`"){s=D(e,s);continue}if(o==="/"&&e[s+1]==="/"){s=P(e,s);continue}if(o==="/"&&e[s+1]==="*"){s=M(e,s);continue}if(o==="/"&&U(e,s)){s=F(e,s);continue}if("([{".includes(o))t++;else if(")]}".includes(o))t--;else{if(t<=0&&o===";")return s;if(t<=0&&o===`
4
+ `){let i=J(e,s+1);if(!(i<e.length&&(ht.test(e.slice(i,i+2))||[",","="].includes(gt(e,s)))))return s;s=i;continue}}s++}return e.length},mt=e=>{let n=[],t=0,s=0,o=0,i=l=>{n.push({raw:e.slice(s,l),codeEnd:Math.max(0,o-s)}),s=l+1,o=s},r=0;for(;r<e.length;){let l=e[r];if(l==="'"||l==='"'||l==="`"){r=D(e,r),o=r;continue}if(l==="/"&&e[r+1]==="/"){r=P(e,r);continue}if(l==="/"&&e[r+1]==="*"){r=M(e,r);continue}if(l==="/"&&U(e,r)){r=F(e,r),o=r;continue}if("([{".includes(l))t++;else if(")]}".includes(l))t--;else if(l===","&&t<=0){i(r),r++;continue}/\s/.test(l)||(o=r+1),r++}return i(e.length),n},ae=e=>{let n=e.trim();if(!n.startsWith("{")&&!n.startsWith("["))return ce.test(n)?[n]:[];let t=[];for(let s of ue(n.slice(1,Me(n)))){s.startsWith("...")&&(s=s.slice(3).trim());let o=de(s);if(o!==-1&&(s=s.slice(0,o).trim()),n.startsWith("{")){let i=fe(s,":");if(i!==-1){t.push(...ae(s.slice(i+1)));continue}}t.push(...ae(s))}return t},yt=e=>{let n=[],t=mt(e).map(({raw:i,codeEnd:r})=>{let l=i.match(/^\s*/)[0];if(r<=l.length)return{text:i,empty:!0};let c=i.slice(l.length,r),d=i.slice(r),p=de(c),m=(p===-1?c:c.slice(0,p)).trim(),b=c[0]==="{"||c[0]==="[";b?n.push(...ae(m)):ce.test(m)&&n.push(m);let T=Y(c).code;return{text:`${l}${b?`(${T})`:T}${d}`,empty:!1}}),s=[];for(;t.length&&t[t.length-1].empty;)s.unshift(t.pop().text);let o=t.map(i=>i.text).join(",")+s.join("");return o.trimStart().startsWith("(")&&(o=`;${o}`),{vars:n,code:o}},Y=e=>{let n=[],t="",s=0,o=0,i=!0;for(;s<e.length;){let r=e[s],l=e[s+1];if(r==="'"||r==='"'||r==="`"){let c=D(e,s);t+=e.slice(s,c),s=c,i=!1;continue}if(r==="/"&&(l==="/"||l==="*")){let c=l==="/"?P(e,s):M(e,s);t+=e.slice(s,c),s=c;continue}if(r==="/"&&U(e,s)){let c=F(e,s);t+=e.slice(s,c),s=c,i=!1;continue}if(r==="i"&&(s===0||!/[\w$.]/.test(e[s-1]))&&(V.lastIndex=s,V.test(e))){t+="$__import",s+=6,i=!1;continue}if(o===0&&i){Ne.lastIndex=s;let c=Ne.exec(e);if(c){let p=s+c[0].length,m=Le(e,p),{vars:b,code:T}=yt(e.slice(p,m));n.push(...b),t+=T,s=m,i=!1;continue}Oe.lastIndex=s;let d=Oe.exec(e);if(d){ve.lastIndex=s;let p=ve.exec(e);p&&n.push(p[1]);let m=s+d[0].length,b=Le(e,m);t+=`$__effect(() => { ${Y(e.slice(m,b)).code} });`,s=b;continue}}"([{".includes(r)?o++:")]}".includes(r)&&(o=Math.max(0,o-1)),r===`
5
+ `||r===";"||r==="}"?i=!0:/\s/.test(r)||(i=!1),t+=r,s++}return{vars:n,code:t}},Q=/export\s+default(?![\w$])/y,Pe=/import\s*(?:([\w$\s,{}*]+?)\s*from\s*)?(["'])([^"'\n]+)\2/y,Et=e=>{let n=[],t=0,s=0;for(let o=0;o<=e.length;o++){let i=e[o];if(i==="{")t++;else if(i==="}")t--;else if(o===e.length||i===","&&t===0){let r=e.slice(s,o).trim();r&&n.push(r),s=o+1}}return n},bt=(e,n,t)=>{let s=`await $__import(${JSON.stringify(n)})`;if(e===void 0)return s;let o=Et(e),i=[],r=s;if(o.length>1){let l=`$__mod${t}`;i.push(`${l} = ${s}`),r=l}for(let l of o)l.startsWith("{")?i.push(`${l.replace(/\s+as\s+/g,": ")} = ${r}`):l.startsWith("*")?i.push(`${l.replace(/^\*\s*as\s+/,"")} = ${r}`):i.push(`${l} = $__default(${r})`);return`const ${i.join(", ")}`},ce=/^[A-Za-z_$][\w$]*$/,Me=e=>{let n=0,t=0;for(;t<e.length;){let s=e[t];if(s==="'"||s==='"'||s==="`"){t=D(e,t);continue}if(s==="/"&&e[t+1]==="/"){t=P(e,t);continue}if(s==="/"&&e[t+1]==="*"){t=M(e,t);continue}if(s==="/"&&U(e,t)){t=F(e,t);continue}if("([{".includes(s))n++;else if(")]}".includes(s)&&--n===0)return t;t++}return e.length},fe=(e,n)=>{let t=0,s=0;for(;s<e.length;){let o=e[s];if(o==="'"||o==='"'||o==="`"){s=D(e,s);continue}if(o==="/"&&e[s+1]==="/"){s=P(e,s);continue}if(o==="/"&&e[s+1]==="*"){s=M(e,s);continue}if(o==="/"&&o!==n&&U(e,s)){s=F(e,s);continue}if("([{".includes(o))t++;else if(")]}".includes(o))t--;else if(t===0&&o===n)return s;s++}return-1},ue=e=>{let n=[],t=0,s=0,o=0;for(;o<=e.length;){let i=e[o];if(i==="'"||i==='"'||i==="`"){o=D(e,o);continue}if(i==="/"&&e[o+1]==="/"){o=P(e,o);continue}if(i==="/"&&e[o+1]==="*"){o=M(e,o);continue}if(i==="/"&&U(e,o)){o=F(e,o);continue}if(i!==void 0&&"([{".includes(i))t++;else if(i!==void 0&&")]}".includes(i))t--;else if(o===e.length||i===","&&t===0){let r=e.slice(s,o).trim();r&&n.push(r),s=o+1}o++}return n},de=e=>{let n=0;for(;n<e.length;){let t=fe(e.slice(n),"=");if(t===-1)return-1;let s=n+t;if(e[s+1]!=="="&&e[s+1]!==">"&&e[s-1]!=="="&&e[s-1]!=="!")return s;n=s+1}return-1},ee=e=>{let n=(e??"").trim();if(!n.startsWith("{"))return null;let t=Me(n);if(t>=n.length)return null;let s=[];for(let o of ue(n.slice(1,t))){if(o.startsWith("..."))continue;let i=de(o),r=i===-1?o:o.slice(0,i),l=i===-1?void 0:o.slice(i+1).trim(),c=fe(r,":"),d=(c===-1?r:r.slice(0,c)).trim();ce.test(d)&&s.push(l===void 0?{name:d}:{name:d,default:l})}return s},wt=e=>{let n=0,t=0,s=!0;for(;n<e.length;){let o=e[n];if(o==="'"||o==='"'||o==="`"){n=D(e,n),s=!1;continue}if(o==="/"&&e[n+1]==="/"){n=P(e,n);continue}if(o==="/"&&e[n+1]==="*"){n=M(e,n);continue}if(o==="/"&&U(e,n)){n=F(e,n),s=!1;continue}if(o==="e"&&t===0&&s&&(n===0||!/[\w$.]/.test(e[n-1]))){Q.lastIndex=n;let i=Q.exec(e);if(i)return n+i[0].length}"([{".includes(o)?t++:")]}".includes(o)&&(t=Math.max(0,t-1)),o===`
6
+ `||o===";"||o==="}"?s=!0:/\s/.test(o)||(s=!1),n++}return-1},St=/^async(?![\w$])/,$t=/^function(?![\w$])\s*\*?\s*[A-Za-z_$][\w$]*|^function(?![\w$])\s*\*?/,Rt=e=>{let n=wt(e);if(n===-1)return null;let t=J(e,n),s=e.slice(t);St.test(s)&&(t=J(e,t+5));let o=$t.exec(e.slice(t));if(o&&(t=J(e,t+o[0].length)),e[t]!=="(")return null;let i=0,r=t;for(;r<e.length;){let l=e[r];if(l==="'"||l==='"'||l==="`"){r=D(e,r);continue}if(l==="/"&&e[r+1]==="/"){r=P(e,r);continue}if(l==="/"&&e[r+1]==="*"){r=M(e,r);continue}if(l==="/"&&U(e,r)){r=F(e,r);continue}if("([{".includes(l))i++;else if(")]}".includes(l)&&--i===0)break;r++}return ue(e.slice(t+1,r))[0]??""},pe=e=>{let n=Rt(e);if(n===null)return null;let t=ee(n),s=t?.find(o=>o.name.startsWith("$"))?.name;if(s)throw new Error(`jq79: the factory signature is (props, ctx), so \`${s}\` can't be destructured from the first parameter. Write \`export default (props, { ${s} }) => \u2026\`, or \`_\` in place of props if the component takes none.`);return t},De=e=>{let n="",t=0,s=0,o=!0,i=!1,r=0;for(;t<e.length;){let l=e[t],c=e[t+1],d=t===0||!/[\w$.]/.test(e[t-1]);if(l==="'"||l==='"'||l==="`"){let p=D(e,t);n+=e.slice(t,p),t=p,o=!1;continue}if(l==="/"&&(c==="/"||c==="*")){let p=c==="/"?P(e,t):M(e,t);n+=e.slice(t,p),t=p;continue}if(l==="/"&&U(e,t)){let p=F(e,t);n+=e.slice(t,p),t=p,o=!1;continue}if(l==="i"&&d){if(V.lastIndex=t,V.test(e)){n+="$__import",t+=6,o=!1;continue}if(s===0&&o){Pe.lastIndex=t;let p=Pe.exec(e);if(p){n+=bt(p[1],p[3],r++),t+=p[0].length,o=!1;continue}}}if(l==="e"&&d&&s===0&&o){Q.lastIndex=t;let p=Q.exec(e);if(p){i=!0,n+="$__exports.default =",t+=p[0].length,o=!1;continue}}"([{".includes(l)?s++:")]}".includes(l)&&(s=Math.max(0,s-1)),l===`
7
+ `||l===";"||l==="}"?o=!0:/\s/.test(l)||(o=!1),n+=l,t++}return i?n:null};var Ze=e=>Object.fromEntries(Array.from(e.attributes).map(n=>[n.name,n.value])),Ge=e=>({tag:e.tagName.toLowerCase(),attrs:Ze(e),children:Array.from(e.childNodes).flatMap(n=>{if(n.nodeType===Node.TEXT_NODE){let t=n.textContent??"";return t?[t]:[]}return n.nodeType===Node.ELEMENT_NODE?[Ge(n)]:[]})}),Ue=new Map,Ke=(e,n)=>{let t=`${n.join(",")}|${e}`,s=Ue.get(t);if(s===void 0){try{s=new Function("$scope",...n,`with ($scope) { return (${e}
8
+ ); }`)}catch{s=null}Ue.set(t,s)}return s},j=(e,n,t)=>{let s=Ke(e,t?Object.keys(t):[]);if(s)try{return s(n,...t?Object.values(t):[])}catch{return}},xt=(e,n)=>e.replace(/{{\s*([\s\S]+?)\s*}}/g,(t,s)=>j(s,n)??""),Tt=new Set([":attrs",":class",":value",":checked",":selected",":if",":elseif",":else",":each",":key",":with",":text",":html",":html.allowed",":props"]),Xe=e=>Tt.has(e)||e.startsWith(":class.")||e.startsWith(":props."),Ct=/^\s*\(?\s*(\w+)\s*(?:,\s*(\w+))?\s*\)?\s+in\s+([\s\S]+)$/,At=(e,n,t,s)=>{let[o,...i]=n.slice(1).split("."),r=new Set(i);e.addEventListener(o,l=>{if(r.has("self")&&l.target!==e)return;r.has("prevent")&&l.preventDefault(),r.has("stop")&&l.stopPropagation();let c=j(t,s,{$event:l});typeof c=="function"&&c.call(e,l)},{once:r.has("once"),capture:r.has("capture")})},jt=(e,n,t,s)=>{let[o,...i]=n.slice(1).split("."),r=new Set(i),l=c=>{r.has("prevent")&&c.preventDefault(),r.has("stop")&&c.stopPropagation(),r.has("once")&&e.off(o,l),z(()=>{let d=j(t,s,{$event:c});typeof d=="function"&&d(c)})};e.on(o,l)},te=e=>e.replace(/-(\w)/g,(n,t)=>t.toUpperCase()),me=e=>e instanceof DocumentFragment?{first:e.firstChild,last:e.lastChild}:{first:e,last:e},ne=({first:e,last:n})=>{for(let t=e;t;){let s=t===n?null:t.nextSibling;t.parentNode?.removeChild(t),t=s}},_t=({first:e,last:n},t)=>{let s=t.nextSibling;for(let o=e;o;){let i=o===n?null:o.nextSibling;t.parentNode.insertBefore(o,s),o=i}},Fe=(e,n)=>{let t=n.replace(/-/g,"").toLowerCase();for(let s=e;s&&s!==Object.prototype;s=Object.getPrototypeOf(s))for(let o of Object.keys(s))if(/^[A-Z]/.test(o)&&o.replace(/-/g,"").toLowerCase()===t)return o;return null},Ie=200,he=0,We=(e,n,t,s,o)=>{let i=document.createComment(e),r=document.createComment(`/${e}`),l=document.createDocumentFragment();l.append(i,r);let c={},d={},p=[],m=[],b=!1;Object.entries(n.attrs).forEach(([a,f])=>{if(a!==be){if(a===":props"||a.startsWith(":props.")){b=!0,m.push({expr:f});return}if(!Xe(a))if(a.startsWith("@"))p.push([a,f]);else if(a===":model"||a.startsWith(":model.")){let u=a===":model"?"default":te(a.slice(7));d[u]=f||(a===":model"?"model":u)}else if(a.startsWith(":")){let u=te(a.slice(1));c[u]=f||u,m.push({name:u,expr:f||u})}else{let u=te(a),E=JSON.stringify(f);c[u]=E,m.push({name:u,expr:E})}}});let T=a=>a==="default"?":model":`:model.${a}`,A=a=>a==="default"?"model":a,y=a=>`${a}
9
+ = $value`;Object.entries(d).forEach(([a,f])=>{let u=A(a);c[u]!==void 0&&console.warn(`jq79: <${n.tag}> binds prop "${u}" through both :${u} and ${T(a)} - ${T(a)} wins`),c[u]=f,Ke(y(f),["$value"])===null&&console.warn(`jq79: ${T(a)}="${f}" is not assignable - updates from <${n.tag}> will be dropped`)});let $=()=>{let a={};return m.forEach(({name:f,expr:u})=>{if(f!==void 0)a[f]=j(u,t);else{let E=j(u,t);E!==null&&typeof E=="object"&&Object.assign(a,E)}}),Object.entries(d).forEach(([f,u])=>{a[A(f)]=j(u,t)}),a},h=null,g=null,w=null,S=new Set,v=a=>{if(a==null){if(!t[et]?.has(e)||S.has("unfilled"))return;S.add("unfilled"),console.error(`jq79: <${n.tag}> is declared as a prop and the parent passed nothing - nothing renders here. Pass it (:${e}="\u2026"), or drop it from the signature to use the one declared in this file.`);return}S.has("type")||(S.add("type"),console.error(`jq79: <${n.tag}> is ${typeof a}, not a component - nothing renders here`))};return s.effect(()=>{let a=j(e,t),f=a instanceof I?a:null;if(f||v(a),f===g||(w?.dispose(),w=null,h?.destroy(),h=null,g=f,!f))return;let u=new I({template:f.template,scripts:f.scripts,styles:f.styles,modules:f.modules,filename:f.filename,siblings:f.siblings,name:f.name});if(Object.keys(d).length){let _=new Set,x=(L,O)=>{_.has(L)||(_.add(L),console.warn(O))};u.on("model:update",(L,O)=>{if(O===null||typeof O!="object"){x("payload",`jq79: model:update expects a { name?, value } payload, got ${O===null?"null":typeof O}`);return}let oe=O.name==null?"default":te(String(O.name)),Se=d[oe];if(Se===void 0){x(oe,`jq79: <${n.tag}> has no ${T(oe)} - bound: ${Object.keys(d).map(T).join(", ")}`);return}z(()=>j(y(Se),t,{$value:O.value}))})}p.forEach(([_,x])=>jt(u,_,x,t));let E=z($),C=document.createDocumentFragment();if(he>=Ie){console.error(`jq79: <${n.tag}> is ${Ie} levels deep inside itself; giving up here. A component that renders itself stops when its data stops - is there a cycle in it?`);return}he++;try{(o?u.renderShadow(E):u.render(E)).mount(C)}finally{he--}r.parentNode.insertBefore(C,r);let R=q(t);if(b){let _=[];R.effect(()=>{let x=$(),L=Object.keys(x);_.forEach(O=>{O in x||(u.data[O]=void 0)}),L.forEach(O=>{u.data[O]=x[O]}),_=L})}else Object.entries(c).forEach(([_,x])=>{R.effect(()=>{u.data[_]=j(x,t)})});w=R,h=u}),s.onDispose(()=>{w?.dispose(),h?.destroy()}),l},Nt=(e,n)=>{let t=()=>{let s=j(e,n);return s!==null&&typeof s=="object"?s:null};return new Proxy(n,{has(s,o){let i=t();return i!==null&&Reflect.has(i,o)||Reflect.has(s,o)},get(s,o){let i=t();return i!==null&&Reflect.has(i,o)?i[o]:Reflect.get(s,o)},set(s,o,i){let r=t();return r!==null&&Reflect.has(r,o)?(r[o]=i,!0):Reflect.set(s,o,i)}})},G=e=>typeof e=="string"?e.split(/\s+/).filter(Boolean):Array.isArray(e)?e.flatMap(G):e!==null&&typeof e=="object"?Object.entries(e).flatMap(([n,t])=>t?G(n):[]):[],Ot=e=>typeof e=="function"?(n,t,s)=>{try{return!!e(n,t,s)}catch{return!1}}:typeof e=="string"||Array.isArray(e)?xe(e):()=>!1,ye=(e,n,t,s)=>{let o=e.attrs[":with"],i=o!==void 0?Nt(o,n):n,r=Fe(i,e.tag);if(r)return We(r,e,i,t,s);let l=document.createElement(e.tag);if(l instanceof HTMLUnknownElement||e.tag.includes("-")){let y=!1;t.effect(()=>{if(y)return;let $=Fe(i,e.tag);if(!$)return;y=!0;let h=We($,e,i,t,s),g=me(h);t.onDispose(()=>ne(g)),l.replaceWith(h)})}Object.entries(e.attrs).forEach(([y,$])=>{y.startsWith("@")?At(l,y,$,i):y===":model"||y.startsWith(":model.")?l instanceof HTMLUnknownElement||e.tag.includes("-")||console.warn(`jq79: ${y} on <${e.tag}> does nothing - :model binds component tags only (for now)`):Xe(y)||l.setAttribute(y,$)});let c=e.attrs[":attrs"];if(c!==void 0){let y=[];t.effect(()=>{y.forEach(h=>l.removeAttribute(h));let $=j(c,i);y=$&&typeof $=="object"?Object.keys($):[],y.forEach(h=>{let g=$[h];g!=null&&g!==!1&&l.setAttribute(h,String(g))})})}let d=e.attrs[":class"],p=Object.entries(e.attrs).filter(([y])=>y.startsWith(":class.")).map(([y,$])=>[y.slice(7),$]);if(d!==void 0||p.length){let y=new Set(G(e.attrs.class??"")),$=[];t.effect(()=>{let h=d!==void 0?G(j(d,i)):[];p.forEach(([g,w])=>{j(w,i)&&h.push(...G(g))}),$.forEach(g=>{!h.includes(g)&&!y.has(g)&&l.classList.remove(g)}),l.classList.add(...h),$=h})}let m=e.attrs[":text"],b=e.attrs[":html"],T=e.attrs[":html.allowed"];T!==void 0&&b===void 0&&console.warn("jq79: :html.allowed without :html on the same element does nothing"),m!==void 0?t.effect(()=>{l.textContent=String(j(m,i)??"")}):b!==void 0?t.effect(()=>{let y=T!==void 0?{allowUrl:Ot(j(T,i))}:void 0;l.innerHTML=Ce(String(j(b,i)??""),y)}):l.appendChild(Ee(e.children,i,t,s));let A=e.attrs[":value"];return A!==void 0&&t.effect(()=>{let y=String(j(A,i)??"");l.value!==y&&(l.value=y)}),[":checked",":selected"].forEach(y=>{let $=e.attrs[y];if($===void 0)return;let h=y.slice(1);t.effect(()=>{l[h]=!!j($,i)})}),l},vt=(e,n,t,s)=>{let o=document.createComment("if"),i=document.createDocumentFragment();i.appendChild(o);let r=null,l=null,c=null;return t.effect(()=>{let d=e.find(m=>m.expr===void 0||j(m.expr,n))??null;if(d===l||(c?.dispose(),r&&ne(r),r=null,l=d,!d))return;c=q(n);let p=ye(d.node,n,c,s);r=me(p),o.parentNode.insertBefore(p,o.nextSibling)}),i},Z=(e,n,t)=>{Object.defineProperty(e,n,{value:t,writable:!0,enumerable:!0,configurable:!0})},Lt=e=>{if(e===null||typeof e!="object"||Array.isArray(e))return!1;let n=Object.getPrototypeOf(e);return n===Object.prototype||n===null},Pt=(e,n,t,s)=>{let o=e.attrs[":each"].match(Ct);if(!o)return document.createComment(`invalid :each expression "${e.attrs[":each"]}"`);let[,i,r,l]=o,c=e.attrs[":key"],{[":each"]:d,[":key"]:p,...m}=e.attrs,b={...e,attrs:m},T=document.createComment("each"),A=document.createDocumentFragment();A.appendChild(T),(":if"in e.attrs||":elseif"in e.attrs||":else"in e.attrs)&&console.warn("jq79: :if/:elseif/:else on a :each element is ignored; filter the list expression instead");let y=[],$=!1;return t.effect(()=>{let h=j(l,n),g=Array.isArray(h)?h.map((u,E)=>[E,u]):Lt(h)?Object.entries(h):[],w=new Map;y.forEach(u=>{let E=w.get(u.key);E?E.push(u):w.set(u.key,[u])});let S=new Set,v=[],a=g.map(([u,E],C)=>{let R=Object.create(n);Z(R,i,E),r&&Z(R,r,u),Z(R,"$index",C);let _=c!==void 0?j(c,R):u;S.has(_)&&!$&&($=!0,console.warn(`jq79: duplicate :key in :each "${e.attrs[":each"]}"; duplicates pair up by position`)),S.add(_);let x=w.get(_)?.shift();if(x&&Object.is(x.item,E))return x.scope.$index!==C&&v.push(x),Z(x.scope,"$index",C),r&&Z(x.scope,r,u),x;x&&(x.fx.dispose(),ne(x.range));let L=q(n),O=me(ye(b,R,L,s));return{key:_,item:E,scope:R,fx:L,range:O}});w.forEach(u=>u.forEach(E=>{E.fx.dispose(),ne(E.range)}));let f=T;a.forEach(u=>{f.nextSibling!==u.range.first&&_t(u.range,f),f=u.range.last}),v.forEach(u=>z(()=>u.fx.refresh())),y=a}),A},Ee=(e,n,t,s=!1)=>{let o=document.createDocumentFragment(),i=0;for(;i<e.length;){let r=e[i];if(typeof r=="string"){let l=document.createTextNode(r);r.includes("{{")&&t.effect(()=>{l.textContent=xt(r,n)}),o.appendChild(l),i++;continue}if(":each"in r.attrs){o.appendChild(Pt(r,n,t,s)),i++;continue}if(":if"in r.attrs){let l=[{expr:r.attrs[":if"],node:r}];i++;let c=p=>{let m=i;for(;m<e.length&&typeof e[m]=="string"&&!e[m].trim();)m++;let b=e[m];if(typeof b=="object"&&p in b.attrs)return i=m+1,b};for(let p=c(":elseif");p;p=c(":elseif"))l.push({expr:p.attrs[":elseif"],node:p});let d=c(":else");d&&l.push({node:d}),o.appendChild(vt(l,n,t,s));continue}o.appendChild(ye(r,n,t,s)),i++}return o},un=(e,n,t=!1)=>Ee(e.template,n,q(n),t),Mt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Dt=/<([A-Za-z][\w-]*)((?:"[^"]*"|'[^']*'|[^>"'])*?)\/>/g,Je=/(<script[\s\S]*?<\/script\s*>|<style[\s\S]*?<\/style\s*>)/gi,Ut=e=>e.split(Je).map((n,t)=>t%2===1?n:n.replace(Dt,(s,o,i)=>Mt.has(o.toLowerCase())?s:`<${o}${i}></${o}>`)).join(""),Ft=/<([A-Za-z][\w-]*)((?:"[^"]*"|'[^']*'|[^>"'])*)>/g,It=/"[^"]*"|'[^']*'|(^|\s)\.\.\.([A-Za-z_$][\w$.]*)/g,Wt=e=>e.split(Je).map((n,t)=>t%2===1?n:n.replace(Ft,(s,o,i)=>{let r=0,l=i.replace(It,(c,d,p)=>p===void 0?c:`${d}:props.${r++}="${p}"`);return`<${o}${l}>`})).join(""),be="data-jq79",kt=e=>{let n=2166136261;for(let t=0;t<e.length;t++)n=Math.imul(n^e.charCodeAt(t),16777619);return(n>>>0).toString(36)},Ve=(e,n)=>{e.forEach(t=>{typeof t!="string"&&(t.attrs[be]=n,Ve(t.children,n))})},qt=(e,n)=>e.split(",").map(t=>{let s=t.trim(),o=s.indexOf("::"),i=o===-1?s:s.slice(0,o),r=o===-1?"":s.slice(o);return`${i}[${be}="${n}"]${r}`}).join(", "),Qe=(e,n)=>{Array.from(e).forEach(t=>{t instanceof CSSStyleRule?t.selectorText=qt(t.selectorText,n):t instanceof CSSGroupingRule&&Qe(t.cssRules,n)})},Ht=(e,n)=>{/:deep\(|::v-deep|>>>/.test(e)&&console.warn("jq79: :deep()/::v-deep/>>> are not supported in <style scoped>; the rule will be dropped by the browser");let t=new CSSStyleSheet;return t.replaceSync(e),Qe(t.cssRules,n),Array.from(t.cssRules).map(s=>s.cssText).join(`
10
+ `)},Bt=/^[A-Z][A-Za-z0-9]*$/,ge=e=>{let n=Ut(Wt(e)),s=new DOMParser().parseFromString(`<template>${n}</template>`,"text/html").querySelector("template"),o=[],i=[];Array.from(s.content.children).forEach(c=>{c.tagName==="TEMPLATE"?i.push(c):o.push(c)});let r=ke(o,e),l={};return i.forEach(c=>{let d=c.getAttribute("name");if(d===null){console.warn("jq79: a top-level <template> without a name declares nothing and was ignored");return}if(!Bt.test(d)){console.warn(`jq79: <template name="${d}"> was ignored - a component name has to be PascalCase, or no tag could ever reference it (only capitalized names resolve as components)`);return}if(d in l){console.warn(`jq79: two <template name="${d}"> in one file; the second was ignored`);return}l[d]=new I({...ke(Array.from(c.content.children),c.innerHTML),siblings:l,name:d})}),Object.keys(l).length&&(r.siblings=l),r},ke=(e,n)=>{let t=[],s=[],o=[];e.forEach(r=>{let l={attrs:Ze(r),content:r.textContent??""};r.tagName==="SCRIPT"?t.push(l):r.tagName==="STYLE"?s.push(l):o.push(Ge(r))}),s.forEach(r=>{"lang"in r.attrs&&console.warn(`jq79: <style lang="${r.attrs.lang}"> needs the jq79/vite plugin to compile it. This component didn't go through the bundler, so its styles were left uncompiled and the browser will ignore them.`)});let i=r=>"scoped"in r.attrs&&!("lang"in r.attrs);if(s.some(i)){let r=kt(n);Ve(o,r),s.forEach(l=>{i(l)&&(l.scoped=Ht(l.content,r))})}return{template:o,scripts:t,styles:s}},we=e=>/\.html?([?#]|$)/.test(e)?I.fetch(e):import(e),Ye=(e,n)=>e?`
11
+ //# sourceURL=${e}?jq79-script=${n}`:"",qe=e=>e.scoped??e.content,se=new Map,zt=e=>{let n=se.get(e);if(!n){let t=document.createElement("style");t.textContent=e,document.head.appendChild(t),n={el:t,count:0},se.set(e,n)}n.count++},Zt=e=>{let n=se.get(e);n&&--n.count<=0&&(n.el.remove(),se.delete(e))},Gt=(e,n,t,s={},o=we,i={})=>{let r={...tt,...s},l=new Proxy(n,{has:(d,p)=>p!=="$__effect"&&p!=="$__import"&&(Reflect.has(d,p)||!(p in globalThis)&&!(p in r))});new Function("$scope","$__effect","$__import",...Object.keys(r),`return (async () => { with ($scope) { ${e} } })()${Ye(i.filename,i.index??0)}`)(l,t,o,...Object.values(r)).catch(d=>console.error("jq79: error in :setup script",d))},He=(e,n)=>{n?.forEach(({name:t,default:s})=>{e[t]===void 0&&(e[t]=s===void 0?void 0:j(s,e))})},Kt=e=>{let n=new Set;return e.forEach(t=>{(pe(t.content)??ee(t.attrs[":setup"]))?.forEach(({name:o})=>n.add(o))}),n},Xt=(e,n)=>{if(!e)return null;let t=Object.create(null),s=!1;return Object.entries(e).forEach(([o,i])=>{n.has(o)||(t[o]=i,s=!0)}),s?t:null},et=Symbol("jq79.unfilledProps"),Jt=e=>e&&e.default!==void 0?e.default:e,Vt=(e,n,t,s={},o=we,i={})=>{let r={...tt,...s},l={},c=new Function("$__exports","$__default","$__import",...Object.keys(r),`return (async () => { "use strict";
12
+ ${e}
13
+ ;$__exports.done = true })()${Ye(i.filename,i.index??0)}`)(l,Jt,o,...Object.values(r)),d=b=>console.error("jq79: error in factory script",b),p=!1,m=()=>{if(p)return;p=!0;let b=l.default;if(typeof b!="function")return;let T=A=>{A&&typeof A=="object"&&Object.assign(n,A)};try{let A=b(n,{$data:n,$props:n,$effect:t,...s});A instanceof Promise?A.then(T).catch(d):T(A)}catch(A){d(A)}};c.then(m,d),l.done&&m()},Qt="__JQ79_HMR_ENABLED__",Yt="__JQ79_HMR__",W=null,en=e=>{if(!W||!e.filename)return;let n=W.get(e.filename);n||W.set(e.filename,n=new Set),n.add(new WeakRef(e))},Be=e=>{try{return new URL(e,document.baseURI).pathname}catch{return e}},tn=(e,n)=>{if(!W)return 0;let t=Be(e),s=ge(n),o=!1,i=l=>l.name===void 0?s:s.siblings?.[l.name]??null,r=0;for(let[l,c]of W)if(Be(l)===t){for(let d of c){let p=d.deref();if(!p){c.delete(d);continue}let m=i(p);if(!m){o=!0;continue}p.hotReplace(m)&&r++}c.size||W.delete(l)}return o?0:r},nn=()=>{W??(W=new Map),globalThis[Yt]={update:tn}},ze=async e=>{let n=await fetch(e);if(!n.ok)throw new Error(`failed to fetch component from ${e}: ${n.status}`);return new I(await n.text(),{filename:e})},I=class{constructor(n,t={}){N(this,"template");N(this,"scripts");N(this,"styles");N(this,"modules");N(this,"filename");N(this,"siblings");N(this,"name");N(this,"data",null);N(this,"fx",null);N(this,"content",null);N(this,"startMarker",null);N(this,"endMarker",null);N(this,"styleEls",[]);N(this,"ownsSharedStyles",!1);N(this,"useShadow",!1);N(this,"mountRoot",null);N(this,"resolveMounted",null);N(this,"emitListeners",new Map);let s=typeof n=="string"?ge(n):n;this.template=s.template,this.scripts=s.scripts,this.styles=s.styles,this.modules=t.modules??(typeof n=="string"?void 0:n.modules),this.filename=t.filename??(typeof n=="string"?void 0:n.filename),this.siblings=s.siblings,this.name=s.name,this.adoptSiblings(),en(this)}adoptSiblings(){this.siblings&&Object.entries(this.siblings).forEach(([n,t])=>{t.filename??(t.filename=this.filename),t.modules??(t.modules=this.modules),this.name||(this[n]=t)})}hotReplace(n){let t=typeof n=="string"?ge(n):n,s=this.startMarker,o=!!(s&&this.content),i=o&&s.isConnected,r=i?s.parentNode:null,l=i?this.endMarker.nextSibling:null,c={...this.data},d=this.useShadow;return o&&this.destroy(),this.template=t.template,this.scripts=t.scripts,this.styles=t.styles,this.siblings=t.siblings,this.adoptSiblings(),!o||(this.renderWith(c,d),!r)?!1:(d&&this.styleEls.forEach(p=>r.insertBefore(p,l)),r.insertBefore(this.content,l),this.mountRoot=r,this.resolveMounted?.(),!0)}static fetch(n){return Array.isArray(n)?Promise.all(n.map(ze)):ze(n)}on(n,t){return this.emitListeners.has(n)||this.emitListeners.set(n,new Set),this.emitListeners.get(n).add(t),this}off(n,t){return this.emitListeners.get(n)?.delete(t),this}render(n={}){return this.renderWith(n,!1)}renderShadow(n={}){return this.renderWith(n,!0)}renderWith(n,t){this.destroy();let s=Kt(this.scripts),o=Xt(this.siblings,s),i=o?Object.assign(Object.create(o),n):{...n},r=new Set([...s].filter(a=>!(a in n)));r.size&&Object.defineProperty(i,et,{value:r});let l=X(i),c=q(l);this.data=l,this.fx=c,this.useShadow=t,this.startMarker=document.createComment("jq79"),this.endMarker=document.createComment("/jq79");let d=this.startMarker,p=(a,f)=>{let u=new CustomEvent(a,{detail:f,bubbles:!0,composed:!0,cancelable:!0});return d===this.startMarker&&this.emitListeners.get(a)?.forEach(E=>E(u,f)),u.cancelBubble||d.dispatchEvent(u),!u.defaultPrevented},m,b=new Promise(a=>{m=a});this.resolveMounted=m;let T=()=>b,A=this.endMarker,y=a=>{let f=[];for(let u=d.nextSibling;u&&u!==A;u=u.nextSibling)u instanceof Element&&(u.matches(a)&&f.push(u),f.push(...Array.from(u.querySelectorAll(a))));return f},$=a=>y(a)[0]??null,h=this.modules,g=a=>h&&a in h?Promise.resolve(h[a]):we(a),w=a=>`await $mounted();${a}`;this.scripts.forEach((a,f)=>{let u={$emit:p,$mounted:T,$self:$,$$self:y,...o},E={filename:this.filename,index:f},C=De(a.content);if(C!==null){He(l,pe(a.content));let L=":mounted"in a.attrs?w(C):C;Vt(L,l,c.effect,u,g,E);return}let{vars:R,code:_}=Y(a.content);He(l,ee(a.attrs[":setup"])),R.forEach(L=>{L in l||(l[L]=void 0)});let x=":mounted"in a.attrs?w(_):_;Gt(x,l,c.effect,u,g,E)});let S=document.createDocumentFragment(),v=new Proxy(l,{has:(a,f)=>f==="$emit"||Reflect.has(a,f),get:(a,f,u)=>f==="$emit"&&!Reflect.has(a,f)?p:Reflect.get(a,f,u)});return S.append(this.startMarker,Ee(this.template,v,c,t),this.endMarker),this.content=S,t?this.styleEls=this.styles.map(a=>{let f=document.createElement("style");return f.textContent=a.content,f}):(this.styles.forEach(a=>zt(qe(a))),this.ownsSharedStyles=!0),this}mount(n,t){let s=typeof n=="string"?H(n):n;if(!s)throw new Error(`mount target not found: ${n}`);return(!this.content||t!==void 0)&&this.renderWith(t??{},this.useShadow),this.attach(s)}mountShadow(n,t){let s=typeof n=="string"?H(n):n;if(!s)throw new Error(`mount target not found: ${n}`);return(!this.content||t!==void 0||!this.useShadow)&&this.renderWith(t??{},!0),this.attach(s)}attach(n){this.mountRoot&&this.detach();let t=this.useShadow&&n instanceof Element?n.shadowRoot??n.attachShadow({mode:"open"}):n;return this.useShadow&&this.styleEls.forEach(s=>t.appendChild(s)),t.appendChild(this.content),this.mountRoot=t,this.resolveMounted?.(),this}detach(){if(!this.mountRoot||!this.content||!this.startMarker||!this.endMarker)return this;let n=this.startMarker;for(;n;){let t=n.nextSibling;if(this.content.appendChild(n),n===this.endMarker)break;n=t}return this.mountRoot=null,this}destroy(){return this.detach(),this.fx?.dispose(),this.fx=null,this.data?.$dispose(),this.styleEls.forEach(n=>n.parentNode?.removeChild(n)),this.styleEls=[],this.ownsSharedStyles&&(this.styles.forEach(n=>Zt(qe(n))),this.ownsSharedStyles=!1),this.content=null,this.startMarker=null,this.endMarker=null,this.data=null,this.resolveMounted=null,this}};var dn=e=>new I(e),tt={$:H,$$:re,$create:ie,$reactive:X,Component79:I};typeof globalThis<"u"&&globalThis[Qt]&&nn();export{H as $,re as $$,ie as $create,X as $reactive,I as C79,I as Component79,nn as enableHotReload,tn as hotUpdate,dn as parseComponent,un as renderComponent};
14
14
  //# sourceMappingURL=jq79.js.map