2 lines
12 KiB
JavaScript
2 lines
12 KiB
JavaScript
const u={context:void 0,registry:void 0};function T(e){u.context=e}function de(){return{...u.context,id:`${u.context.id}${u.context.count++}-`,count:0}}const he=(e,t)=>e===t,pe=Symbol("solid-track"),j={equals:he};let z=re;const $=1,I=2,ee={owned:null,cleanups:null,context:null,owner:null};var d=null;let q=null,ge=null,p=null,y=null,C=null,V=0;function F(e,t){const n=p,s=d,i=e.length===0,l=t===void 0?s:t,f=i?ee:{owned:null,cleanups:null,context:l?l.context:null,owner:l},o=i?e:()=>e(()=>L(()=>Y(f)));d=f,p=null;try{return B(o,!0)}finally{p=n,d=s}}function R(e,t){t=t?Object.assign({},j,t):j;const n={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0},s=i=>(typeof i=="function"&&(i=i(n.value)),le(n,i));return[ie.bind(n),s]}function M(e,t,n){const s=W(e,t,!1,$);P(s)}function je(e,t,n){z=Ce;const s=W(e,t,!1,$),i=_&&se(_);i&&(s.suspense=i),s.user=!0,C?C.push(s):P(s)}function H(e,t,n){n=n?Object.assign({},j,n):j;const s=W(e,t,!0,0);return s.observers=null,s.observerSlots=null,s.comparator=n.equals||void 0,P(s),ie.bind(s)}function L(e){if(p===null)return e();const t=p;p=null;try{return e()}finally{p=t}}function te(e){return d===null||(d.cleanups===null?d.cleanups=[e]:d.cleanups.push(e)),e}function ye(){return d}function be(e){C.push.apply(C,e),e.length=0}function ne(e,t){const n=Symbol("context");return{id:n,Provider:Ee(n),defaultValue:e}}function se(e){return d&&d.context&&d.context[e.id]!==void 0?d.context[e.id]:e.defaultValue}function we(e){const t=H(e),n=H(()=>G(t()));return n.toArray=()=>{const s=n();return Array.isArray(s)?s:s!=null?[s]:[]},n}let _;function xe(){return _||(_=ne())}function ie(){if(this.sources&&this.state)if(this.state===$)P(this);else{const e=y;y=null,B(()=>U(this),!1),y=e}if(p){const e=this.observers?this.observers.length:0;p.sources?(p.sources.push(this),p.sourceSlots.push(e)):(p.sources=[this],p.sourceSlots=[e]),this.observers?(this.observers.push(p),this.observerSlots.push(p.sources.length-1)):(this.observers=[p],this.observerSlots=[p.sources.length-1])}return this.value}function le(e,t,n){let s=e.value;return(!e.comparator||!e.comparator(s,t))&&(e.value=t,e.observers&&e.observers.length&&B(()=>{for(let i=0;i<e.observers.length;i+=1){const l=e.observers[i],f=q&&q.running;f&&q.disposed.has(l),(f?!l.tState:!l.state)&&(l.pure?y.push(l):C.push(l),l.observers&&oe(l)),f||(l.state=$)}if(y.length>1e6)throw y=[],new Error},!1)),t}function P(e){if(!e.fn)return;Y(e);const t=V;Ae(e,e.value,t)}function Ae(e,t,n){let s;const i=d,l=p;p=d=e;try{s=e.fn(t)}catch(f){return e.pure&&(e.state=$,e.owned&&e.owned.forEach(Y),e.owned=null),e.updatedAt=n+1,fe(f)}finally{p=l,d=i}(!e.updatedAt||e.updatedAt<=n)&&(e.updatedAt!=null&&"observers"in e?le(e,s):e.value=s,e.updatedAt=n)}function W(e,t,n,s=$,i){const l={fn:e,state:s,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:d,context:d?d.context:null,pure:n};return d===null||d!==ee&&(d.owned?d.owned.push(l):d.owned=[l]),l}function O(e){if(e.state===0)return;if(e.state===I)return U(e);if(e.suspense&&L(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<V);)e.state&&t.push(e);for(let n=t.length-1;n>=0;n--)if(e=t[n],e.state===$)P(e);else if(e.state===I){const s=y;y=null,B(()=>U(e,t[0]),!1),y=s}}function B(e,t){if(y)return e();let n=!1;t||(y=[]),C?n=!0:C=[],V++;try{const s=e();return Se(n),s}catch(s){n||(C=null),y=null,fe(s)}}function Se(e){if(y&&(re(y),y=null),e)return;const t=C;C=null,t.length&&B(()=>z(t),!1)}function re(e){for(let t=0;t<e.length;t++)O(e[t])}function Ce(e){let t,n=0;for(t=0;t<e.length;t++){const s=e[t];s.user?e[n++]=s:O(s)}if(u.context){if(u.count){u.effects||(u.effects=[]),u.effects.push(...e.slice(0,n));return}else u.effects&&(e=[...u.effects,...e],n+=u.effects.length,delete u.effects);T()}for(t=0;t<n;t++)O(e[t])}function U(e,t){e.state=0;for(let n=0;n<e.sources.length;n+=1){const s=e.sources[n];if(s.sources){const i=s.state;i===$?s!==t&&(!s.updatedAt||s.updatedAt<V)&&O(s):i===I&&U(s,t)}}}function oe(e){for(let t=0;t<e.observers.length;t+=1){const n=e.observers[t];n.state||(n.state=I,n.pure?y.push(n):C.push(n),n.observers&&oe(n))}}function Y(e){let t;if(e.sources)for(;e.sources.length;){const n=e.sources.pop(),s=e.sourceSlots.pop(),i=n.observers;if(i&&i.length){const l=i.pop(),f=n.observerSlots.pop();s<i.length&&(l.sourceSlots[f]=s,i[s]=l,n.observerSlots[s]=f)}}if(e.owned){for(t=e.owned.length-1;t>=0;t--)Y(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}e.state=0}function me(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown error",{cause:e})}function fe(e,t=d){throw me(e)}function G(e){if(typeof e=="function"&&!e.length)return G(e());if(Array.isArray(e)){const t=[];for(let n=0;n<e.length;n++){const s=G(e[n]);Array.isArray(s)?t.push.apply(t,s):t.push(s)}return t}return e}function Ee(e,t){return function(s){let i;return M(()=>i=L(()=>(d.context={...d.context,[e]:s.value},we(()=>s.children))),void 0),i}}const ve=Symbol("fallback");function Q(e){for(let t=0;t<e.length;t++)e[t]()}function $e(e,t,n={}){let s=[],i=[],l=[],f=0,o=t.length>1?[]:null;return te(()=>Q(l)),()=>{let c=e()||[],a,r;return c[pe],L(()=>{let h=c.length,g,x,A,v,m,w,S,E,N;if(h===0)f!==0&&(Q(l),l=[],s=[],i=[],f=0,o&&(o=[])),n.fallback&&(s=[ve],i[0]=F(ae=>(l[0]=ae,n.fallback())),f=1);else if(f===0){for(i=new Array(h),r=0;r<h;r++)s[r]=c[r],i[r]=F(b);f=h}else{for(A=new Array(h),v=new Array(h),o&&(m=new Array(h)),w=0,S=Math.min(f,h);w<S&&s[w]===c[w];w++);for(S=f-1,E=h-1;S>=w&&E>=w&&s[S]===c[E];S--,E--)A[E]=i[S],v[E]=l[S],o&&(m[E]=o[S]);for(g=new Map,x=new Array(E+1),r=E;r>=w;r--)N=c[r],a=g.get(N),x[r]=a===void 0?-1:a,g.set(N,r);for(a=w;a<=S;a++)N=s[a],r=g.get(N),r!==void 0&&r!==-1?(A[r]=i[a],v[r]=l[a],o&&(m[r]=o[a]),r=x[r],g.set(N,r)):l[a]();for(r=w;r<h;r++)r in A?(i[r]=A[r],l[r]=v[r],o&&(o[r]=m[r],o[r](r))):i[r]=F(b);i=i.slice(0,f=h),s=c.slice(0)}return i});function b(h){if(l[r]=h,o){const[g,x]=R(r);return o[r]=x,t(c[r],g)}return t(c[r])}}}let ue=!1;function Te(){ue=!0}function Ne(e,t){if(ue&&u.context){const n=u.context;T(de());const s=L(()=>e(t||{}));return T(n),s}return L(()=>e(t||{}))}function Ie(e){const t="fallback"in e&&{fallback:()=>e.fallback};return H($e(()=>e.each,e.children,t||void 0))}const ke=ne();function Me(e){let t=0,n,s,i,l,f;const[o,c]=R(!1),a=xe(),r={increment:()=>{++t===1&&c(!0)},decrement:()=>{--t===0&&c(!1)},inFallback:o,effects:[],resolved:!1},b=ye();if(u.context&&u.load){const x=u.context.id+u.context.count;let A=u.load(x);if(A&&(typeof A!="object"||A.status!=="success"?i=A:u.gather(x)),i&&i!=="$$f"){const[v,m]=R(void 0,{equals:!1});l=v,i.then(()=>{if(u.done)return m();u.gather(x),T(s),m(),T()},w=>{f=w,m()})}}const h=se(ke);h&&(n=h.register(r.inFallback));let g;return te(()=>g&&g()),Ne(a.Provider,{value:r,get children(){return H(()=>{if(f)throw f;if(s=u.context,l)return l(),l=void 0;s&&i==="$$f"&&T();const x=H(()=>e.children);return H(A=>{const v=r.inFallback(),{showContent:m=!0,showFallback:w=!0}=n?n():{};if((!v||i&&i!=="$$f")&&m)return r.resolved=!0,g&&g(),g=s=i=void 0,be(r.effects),x();if(w)return g?A:F(S=>(g=S,s&&(T({id:s.id+"f",count:0}),s=void 0),e.fallback),b)})})}})}function He(e,t,n){let s=n.length,i=t.length,l=s,f=0,o=0,c=t[i-1].nextSibling,a=null;for(;f<i||o<l;){if(t[f]===n[o]){f++,o++;continue}for(;t[i-1]===n[l-1];)i--,l--;if(i===f){const r=l<s?o?n[o-1].nextSibling:n[l-o]:c;for(;o<l;)e.insertBefore(n[o++],r)}else if(l===o)for(;f<i;)(!a||!a.has(t[f]))&&t[f].remove(),f++;else if(t[f]===n[l-1]&&n[o]===t[i-1]){const r=t[--i].nextSibling;e.insertBefore(n[o++],t[f++].nextSibling),e.insertBefore(n[--l],r),t[i]=n[l]}else{if(!a){a=new Map;let b=o;for(;b<l;)a.set(n[b],b++)}const r=a.get(t[f]);if(r!=null)if(o<r&&r<l){let b=f,h=1,g;for(;++b<i&&b<l&&!((g=a.get(t[b]))==null||g!==r+h);)h++;if(h>r-o){const x=t[f];for(;o<r;)e.insertBefore(n[o++],x)}else e.replaceChild(n[o++],t[f++])}else f++;else t[f++].remove()}}}const X="_$DX_DELEGATE";function Le(e,t,n,s={}){let i;return F(l=>{i=l,t===document?e():Fe(t,e(),t.firstChild?null:void 0,n)},s.owner),()=>{i(),t.textContent=""}}function _e(e,t,n){let s;const i=()=>{const f=document.createElement("template");return f.innerHTML=e,f.content.firstChild},l=()=>(s||(s=i())).cloneNode(!0);return l.cloneNode=l,l}function Oe(e,t=window.document){const n=t[X]||(t[X]=new Set);for(let s=0,i=e.length;s<i;s++){const l=e[s];n.has(l)||(n.add(l),t.addEventListener(l,ce))}}function Ue(e,t,n){u.context&&e.isConnected||(e[t]=n)}function De(e,t,n){u.context&&e.isConnected||(n==null?e.removeAttribute(t):e.setAttribute(t,n))}function Ve(e,t){u.context&&e.isConnected||(t==null?e.removeAttribute("class"):e.className=t)}function Fe(e,t,n,s){if(n!==void 0&&!s&&(s=[]),typeof t!="function")return D(e,t,s,n);M(i=>D(e,t(),i,n),s)}function Pe(e,t,n={}){u.completed=globalThis._$HY.completed,u.events=globalThis._$HY.events,u.load=i=>globalThis._$HY.r[i],u.has=i=>i in globalThis._$HY.r,u.gather=i=>Z(t,i),u.registry=new Map,u.context={id:n.renderId||"",count:0},Z(t,n.renderId);const s=Le(e,t,[...t.childNodes],n);return u.context=null,s}function Ye(e){let t,n;return!u.context||!(t=u.registry.get(n=Be()))?e():(u.completed&&u.completed.add(t),u.registry.delete(n),t)}function qe(e){let t=e,n=0,s=[];if(u.context)for(;t;){if(t.nodeType===8){const i=t.nodeValue;if(i==="$")n++;else if(i==="/"){if(n===0)return[t,s];n--}}s.push(t),t=t.nextSibling}return[t,s]}function Re(){u.events&&!u.events.queued&&(queueMicrotask(()=>{const{completed:e,events:t}=u;for(t.queued=!1;t.length;){const[n,s]=t[0];if(!e.has(n))return;ce(s),t.shift()}}),u.events.queued=!0)}function ce(e){const t=`$$${e.type}`;let n=e.composedPath&&e.composedPath()[0]||e.target;for(e.target!==n&&Object.defineProperty(e,"target",{configurable:!0,value:n}),Object.defineProperty(e,"currentTarget",{configurable:!0,get(){return n||document}}),u.registry&&!u.done&&(u.done=_$HY.done=!0);n;){const s=n[t];if(s&&!n.disabled){const i=n[`${t}Data`];if(i!==void 0?s.call(n,i,e):s.call(n,e),e.cancelBubble)return}n=n._$host||n.parentNode||n.host}}function D(e,t,n,s,i){const l=!!u.context&&e.isConnected;if(l){!n&&(n=[...e.childNodes]);let c=[];for(let a=0;a<n.length;a++){const r=n[a];r.nodeType===8&&r.data.slice(0,2)==="!$"?r.remove():c.push(r)}n=c}for(;typeof n=="function";)n=n();if(t===n)return n;const f=typeof t,o=s!==void 0;if(e=o&&n[0]&&n[0].parentNode||e,f==="string"||f==="number"){if(l)return n;if(f==="number"&&(t=t.toString()),o){let c=n[0];c&&c.nodeType===3?c.data!==t&&(c.data=t):c=document.createTextNode(t),n=k(e,n,s,c)}else n!==""&&typeof n=="string"?n=e.firstChild.data=t:n=e.textContent=t}else if(t==null||f==="boolean"){if(l)return n;n=k(e,n,s)}else{if(f==="function")return M(()=>{let c=t();for(;typeof c=="function";)c=c();n=D(e,c,n,s)}),()=>n;if(Array.isArray(t)){const c=[],a=n&&Array.isArray(n);if(K(c,t,n,i))return M(()=>n=D(e,c,n,s,!0)),()=>n;if(l){if(!c.length)return n;if(s===void 0)return[...e.childNodes];let r=c[0],b=[r];for(;(r=r.nextSibling)!==s;)b.push(r);return n=b}if(c.length===0){if(n=k(e,n,s),o)return n}else a?n.length===0?J(e,c,s):He(e,n,c):(n&&k(e),J(e,c));n=c}else if(t.nodeType){if(l&&t.parentNode)return n=o?[t]:t;if(Array.isArray(n)){if(o)return n=k(e,n,s,t);k(e,n,null,t)}else n==null||n===""||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);n=t}}return n}function K(e,t,n,s){let i=!1;for(let l=0,f=t.length;l<f;l++){let o=t[l],c=n&&n[e.length],a;if(!(o==null||o===!0||o===!1))if((a=typeof o)=="object"&&o.nodeType)e.push(o);else if(Array.isArray(o))i=K(e,o,c)||i;else if(a==="function")if(s){for(;typeof o=="function";)o=o();i=K(e,Array.isArray(o)?o:[o],Array.isArray(c)?c:[c])||i}else e.push(o),i=!0;else{const r=String(o);c&&c.nodeType===3&&c.data===r?e.push(c):e.push(document.createTextNode(r))}}return i}function J(e,t,n=null){for(let s=0,i=t.length;s<i;s++)e.insertBefore(t[s],n)}function k(e,t,n,s){if(n===void 0)return e.textContent="";const i=s||document.createTextNode("");if(t.length){let l=!1;for(let f=t.length-1;f>=0;f--){const o=t[f];if(i!==o){const c=o.parentNode===e;!l&&!f?c?e.replaceChild(i,o):e.insertBefore(i,n):c&&o.remove()}else l=!0}}else e.insertBefore(i,n);return[i]}function Z(e,t){const n=e.querySelectorAll("*[data-hk]");for(let s=0;s<n.length;s++){const i=n[s],l=i.getAttribute("data-hk");(!t||l.startsWith(t))&&!u.registry.has(l)&&u.registry.set(l,i)}}function Be(){const e=u.context;return`${e.id}${e.count++}`}const Ge=(...e)=>(Te(),Pe(...e));export{Ie as F,Me as S,je as a,qe as b,R as c,Oe as d,Ne as e,M as f,Ye as g,Ve as h,Fe as i,Ge as j,Le as k,H as l,Ue as m,Re as r,De as s,_e as t};
|