@bulmil/core
Version:

1 lines • 11.7 kB
JavaScript
const e="bulmil";let t,l,n=!1,s=!1,o=!1,i=!1;const r="undefined"!=typeof window?window:{},c=r.CSS,a=r.document||{head:{}},f={t:0,l:"",jmp:e=>e(),raf:e=>requestAnimationFrame(e),ael:(e,t,l,n)=>e.addEventListener(t,l,n),rel:(e,t,l,n)=>e.removeEventListener(t,l,n),ce:(e,t)=>new CustomEvent(e,t)},$=e=>Promise.resolve(e),u=(()=>{try{return new CSSStyleSheet,!0}catch(e){}return!1})(),d=new WeakMap,m=e=>"sc-"+e.s,y={},h=e=>"object"==(e=typeof e)||"function"===e,p=(e,t,...l)=>{let n=null,s=null,o=!1,i=!1,r=[];const c=t=>{for(let l=0;l<t.length;l++)n=t[l],Array.isArray(n)?c(n):null!=n&&"boolean"!=typeof n&&((o="function"!=typeof e&&!h(n))&&(n+=""),o&&i?r[r.length-1].o+=n:r.push(o?b(null,n):n),i=o)};if(c(l),t){t.name&&(s=t.name);{const e=t.className||t.class;e&&(t.class="object"!=typeof e?e:Object.keys(e).filter(t=>e[t]).join(" "))}}if("function"==typeof e)return e(null===t?{}:t,r,g);const a=b(e,null);return a.i=t,r.length>0&&(a.$=r),a.u=s,a},b=(e,t)=>({t:0,m:e,o:t,h:null,$:null,i:null,u:null}),w={},g={forEach:(e,t)=>e.map(v).forEach(t),map:(e,t)=>e.map(v).map(t).map(k)},v=e=>({vattrs:e.i,vchildren:e.$,vkey:e.p,vname:e.u,vtag:e.m,vtext:e.o}),k=e=>{if("function"==typeof e.vtag){const t=Object.assign({},e.vattrs);return e.vkey&&(t.key=e.vkey),e.vname&&(t.name=e.vname),p(e.vtag,t,...e.vchildren||[])}const t=b(e.vtag,e.vtext);return t.i=e.vattrs,t.$=e.vchildren,t.p=e.vkey,t.u=e.vname,t},j=(e,t,l,n,s,o)=>{if(l!==n){let c=se(e,t),a=t.toLowerCase();if("class"===t){const t=e.classList,s=S(l),o=S(n);t.remove(...s.filter(e=>e&&!o.includes(e))),t.add(...o.filter(e=>e&&!s.includes(e)))}else if(c||"o"!==t[0]||"n"!==t[1]){const r=h(n);if((c||r&&null!==n)&&!s)try{if(e.tagName.includes("-"))e[t]=n;else{let s=null==n?"":n;"list"===t?c=!1:null!=l&&e[t]==s||(e[t]=s)}}catch(i){}null==n||!1===n?!1===n&&""!==e.getAttribute(t)||e.removeAttribute(t):(!c||4&o||s)&&!r&&e.setAttribute(t,n=!0===n?"":n)}else t="-"===t[2]?t.slice(3):se(r,a)?a.slice(2):a[2]+t.slice(3),l&&f.rel(e,t,l,!1),n&&f.ael(e,t,n,!1)}},M=/\s/,S=e=>e?e.split(M):[],x=(e,t,l,n)=>{const s=11===t.h.nodeType&&t.h.host?t.h.host:t.h,o=e&&e.i||y,i=t.i||y;for(n in o)n in i||j(s,n,o[n],void 0,l,t.t);for(n in i)j(s,n,o[n],i[n],l,t.t)},O=(e,s,i)=>{let r,c,f,$=s.$[i],u=0;if(n||(o=!0,"slot"===$.m&&($.t|=$.$?2:1)),null!==$.o)r=$.h=a.createTextNode($.o);else if(1&$.t)r=$.h=a.createTextNode("");else if(r=$.h=a.createElement(2&$.t?"slot-fb":$.m),x(null,$,!1),$.$)for(u=0;u<$.$.length;++u)c=O(e,$,u),c&&r.appendChild(c);return r["s-hn"]=l,3&$.t&&(r["s-sr"]=!0,r["s-cr"]=t,r["s-sn"]=$.u||"",f=e&&e.$&&e.$[i],f&&f.m===$.m&&e.h&&C(e.h,!1)),r},C=(e,t)=>{f.t|=1;const n=e.childNodes;for(let s=n.length-1;s>=0;s--){const e=n[s];e["s-hn"]!==l&&e["s-ol"]&&(I(e).insertBefore(e,E(e)),e["s-ol"].remove(),e["s-ol"]=void 0,o=!0),t&&C(e,t)}f.t&=-2},R=(e,t,l,n,s,o)=>{let i,r=e["s-cr"]&&e["s-cr"].parentNode||e;for(;s<=o;++s)n[s]&&(i=O(null,l,s),i&&(n[s].h=i,r.insertBefore(i,E(t))))},T=(e,t,l,n,o)=>{for(;t<=l;++t)(n=e[t])&&(s=!0,(o=n.h)["s-ol"]?o["s-ol"].remove():C(o,!0),o.remove())},_=(e,t)=>e.m===t.m&&("slot"!==e.m||e.u===t.u),E=e=>e&&e["s-ol"]||e,I=e=>(e["s-ol"]?e["s-ol"]:e).parentNode,P=(e,t)=>{const l=t.h=e.h,n=e.$,s=t.$,o=t.o;let i;null===o?("slot"===t.m||x(e,t,!1),null!==n&&null!==s?((e,t,l,n)=>{let s,o=0,i=0,r=t.length-1,c=t[0],a=t[r],f=n.length-1,$=n[0],u=n[f];for(;o<=r&&i<=f;)null==c?c=t[++o]:null==a?a=t[--r]:null==$?$=n[++i]:null==u?u=n[--f]:_(c,$)?(P(c,$),c=t[++o],$=n[++i]):_(a,u)?(P(a,u),a=t[--r],u=n[--f]):_(c,u)?("slot"!==c.m&&"slot"!==u.m||C(c.h.parentNode,!1),P(c,u),e.insertBefore(c.h,a.h.nextSibling),c=t[++o],u=n[--f]):_(a,$)?("slot"!==c.m&&"slot"!==u.m||C(a.h.parentNode,!1),P(a,$),e.insertBefore(a.h,c.h),a=t[--r],$=n[++i]):(s=O(t&&t[i],l,i),$=n[++i],s&&I(c.h).insertBefore(s,E(c.h)));o>r?R(e,null==n[f+1]?null:n[f+1].h,l,n,i,f):i>f&&T(t,o,r)})(l,n,t,s):null!==s?(null!==e.o&&(l.textContent=""),R(l,null,t,s,0,s.length-1)):null!==n&&T(n,0,n.length-1)):(i=l["s-cr"])?i.parentNode.textContent=o:e.o!==o&&(l.data=o)},N=e=>{let t,l,n,s,o,i,r=e.childNodes;for(l=0,n=r.length;l<n;l++)if(t=r[l],1===t.nodeType){if(t["s-sr"])for(o=t["s-sn"],t.hidden=!1,s=0;s<n;s++)if(r[s]["s-hn"]!==t["s-hn"])if(i=r[s].nodeType,""!==o){if(1===i&&o===r[s].getAttribute("slot")){t.hidden=!0;break}}else if(1===i||3===i&&""!==r[s].textContent.trim()){t.hidden=!0;break}N(t)}},A=[],F=e=>{let t,l,n,o,i,r,c=0,a=e.childNodes,f=a.length;for(;c<f;c++){if(t=a[c],t["s-sr"]&&(l=t["s-cr"]))for(n=l.parentNode.childNodes,o=t["s-sn"],r=n.length-1;r>=0;r--)l=n[r],l["s-cn"]||l["s-nr"]||l["s-hn"]===t["s-hn"]||(H(l,o)?(i=A.find(e=>e.g===l),s=!0,l["s-sn"]=l["s-sn"]||o,i?i.v=t:A.push({v:t,g:l}),l["s-sr"]&&A.map(e=>{H(e.g,l["s-sn"])&&(i=A.find(e=>e.g===l),i&&!e.v&&(e.v=i.v))})):A.some(e=>e.g===l)||A.push({g:l}));1===t.nodeType&&F(t)}},H=(e,t)=>1===e.nodeType?null===e.getAttribute("slot")&&""===t||e.getAttribute("slot")===t:e["s-sn"]===t||""===t,L=(e,t)=>{t&&!e.k&&t["s-p"]&&t["s-p"].push(new Promise(t=>e.k=t))},U=(e,t)=>{if(e.t|=16,!(4&e.t))return L(e,e.j),ye(()=>W(e,t));e.t|=512},W=(e,t)=>{const l=e.M;return D(void 0,()=>q(e,l,t))},q=async(e,i,r)=>{const c=e.S,$=c["s-rc"];r&&(e=>{const t=e.O;((e,t)=>{let l=m(t),n=ce.get(l);if(e=11===e.nodeType?e:a,n)if("string"==typeof n){let t,s=d.get(e=e.head||e);s||d.set(e,s=new Set),s.has(l)||(e.host&&(t=e.querySelector(`[sty-id="${l}"]`))?t.innerHTML=n:(t=a.createElement("style"),t.innerHTML=n,e.insertBefore(t,e.querySelector("link"))),s&&s.add(l))}else e.adoptedStyleSheets.includes(n)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,n])})(e.S.getRootNode(),t)})(e);((e,i)=>{const r=e.S,c=e.O,$=e.C||b(null,null),u=(e=>e&&e.m===w)(i)?i:p(null,null,i);if(l=r.tagName,c.R&&(u.i=u.i||{},c.R.map(([e,t])=>u.i[t]=r[e])),u.m=null,u.t|=4,e.C=u,u.h=$.h=r,t=r["s-cr"],n=0!=(1&c.t),s=!1,P($,u),f.t|=1,o){let e,t,l,n,s,o;F(u.h);let i=0;for(;i<A.length;i++)e=A[i],t=e.g,t["s-ol"]||(l=a.createTextNode(""),l["s-nr"]=t,t.parentNode.insertBefore(t["s-ol"]=l,t));for(i=0;i<A.length;i++)if(e=A[i],t=e.g,e.v){for(n=e.v.parentNode,s=e.v.nextSibling,l=t["s-ol"];l=l.previousSibling;)if(o=l["s-nr"],o&&o["s-sn"]===t["s-sn"]&&n===o.parentNode&&(o=o.nextSibling,!o||!o["s-nr"])){s=o;break}(!s&&n!==t.parentNode||t.nextSibling!==s)&&t!==s&&(!t["s-hn"]&&t["s-ol"]&&(t["s-hn"]=t["s-ol"].parentNode.nodeName),n.insertBefore(t,s))}else 1===t.nodeType&&(t.hidden=!0)}s&&N(u.h),f.t&=-2,A.length=0})(e,V(e,i)),$&&($.map(e=>e()),c["s-rc"]=void 0);{const t=c["s-p"],l=()=>z(e);0===t.length?l():(Promise.all(t).then(l),e.t|=4,t.length=0)}},V=(e,t)=>{try{t=t.render(),e.t&=-17,e.t|=2}catch(l){oe(l)}return t},z=e=>{const t=e.S,l=e.j;64&e.t||(e.t|=64,G(t),e.T(t),l||B()),e.k&&(e.k(),e.k=void 0),512&e.t&&me(()=>U(e,!1)),e.t&=-517},B=()=>{G(a.documentElement),me(()=>(e=>{const t=f.ce("appload",{detail:{namespace:"bulmil"}});return e.dispatchEvent(t),t})(r))},D=(e,t)=>e&&e.then?e.then(t):t(),G=e=>e.classList.add("hydrated"),J=(e,t,l,n,s,o,i)=>{let r,c,a,f;if(1===o.nodeType){for(r=o.getAttribute("c-id"),r&&(c=r.split("."),c[0]!==i&&"0"!==c[0]||(a={t:0,_:c[0],I:c[1],P:c[2],N:c[3],m:o.tagName.toLowerCase(),h:o,i:null,$:null,p:null,u:null,o:null},t.push(a),o.removeAttribute("c-id"),e.$||(e.$=[]),e.$[a.N]=a,e=a,n&&"0"===a.P&&(n[a.N]=a.h))),f=o.childNodes.length-1;f>=0;f--)J(e,t,l,n,s,o.childNodes[f],i);if(o.shadowRoot)for(f=o.shadowRoot.childNodes.length-1;f>=0;f--)J(e,t,l,n,s,o.shadowRoot.childNodes[f],i)}else if(8===o.nodeType)c=o.nodeValue.split("."),c[1]!==i&&"0"!==c[1]||(r=c[0],a={t:0,_:c[1],I:c[2],P:c[3],N:c[4],h:o,i:null,$:null,p:null,u:null,m:null,o:null},"t"===r?(a.h=o.nextSibling,a.h&&3===a.h.nodeType&&(a.o=a.h.textContent,t.push(a),o.remove(),e.$||(e.$=[]),e.$[a.N]=a,n&&"0"===a.P&&(n[a.N]=a.h))):a._===i&&("s"===r?(a.m="slot",o["s-sn"]=c[5]?a.u=c[5]:"",o["s-sr"]=!0,l.push(a),e.$||(e.$=[]),e.$[a.N]=a):"r"===r&&(s["s-cr"]=o,o["s-cn"]=!0)));else if(e&&"style"===e.m){const t=b(null,o.textContent);t.h=o,t.N="0",e.$=[t]}},K=(e,t)=>{if(1===e.nodeType){let l=0;for(;l<e.childNodes.length;l++)K(e.childNodes[l],t);if(e.shadowRoot)for(l=0;l<e.shadowRoot.childNodes.length;l++)K(e.shadowRoot.childNodes[l],t)}else if(8===e.nodeType){const l=e.nodeValue.split(".");"o"===l[0]&&(t.set(l[1]+"."+l[2],e),e.nodeValue="",e["s-en"]=l[3])}},Q=(e,t,l)=>{if(t.A){const n=Object.entries(t.A),s=e.prototype;if(n.map(([e,[n]])=>{(31&n||2&l&&32&n)&&Object.defineProperty(s,e,{get(){return((e,t)=>te(this).F.get(t))(0,e)},set(l){((e,t,l,n)=>{const s=te(e),o=s.F.get(t),i=s.t,r=s.M;l=((e,t)=>null==e||h(e)?e:4&t?"false"!==e&&(""===e||!!e):2&t?parseFloat(e):1&t?e+"":e)(l,n.A[t][0]),8&i&&void 0!==o||l===o||(s.F.set(t,l),r&&2==(18&i)&&U(s,!1))})(this,e,l,t)},configurable:!0,enumerable:!0})}),1&l){const l=new Map;s.attributeChangedCallback=function(e,t,n){f.jmp(()=>{const t=l.get(e);this[t]=(null!==n||"boolean"!=typeof this[t])&&n})},e.observedAttributes=n.filter(([e,t])=>15&t[0]).map(([e,n])=>{const s=n[1]||e;return l.set(s,e),512&n[0]&&t.R.push([e,s]),s})}}return e},X=e=>{if(0==(1&f.t)){const t=te(e),l=t.O,n=()=>{};if(!(1&t.t)){let n;t.t|=1,n=e.getAttribute("s-id"),n&&((e,t,l,n)=>{const s=e.shadowRoot,o=[],i=n.C=b(t,null);f.H||K(a.body,f.H=new Map),e["s-id"]=l,e.removeAttribute("s-id"),J(i,o,[],null,e,e,l),o.map(e=>{const l=e._+"."+e.I,n=f.H.get(l),o=e.h;n&&""===n["s-en"]&&n.parentNode.insertBefore(o,n.nextSibling),s||(o["s-hn"]=t,n&&(o["s-ol"]=n,o["s-ol"]["s-nr"]=o)),f.H.delete(l)})})(e,l.s,n,t),n||12&l.t&&Y(e);{let l=e;for(;l=l.parentNode||l.host;)if(1===l.nodeType&&l.hasAttribute("s-id")&&l["s-p"]||l["s-p"]){L(t,t.j=l);break}}l.A&&Object.entries(l.A).map(([t,[l]])=>{if(31&l&&e.hasOwnProperty(t)){const l=e[t];delete e[t],e[t]=l}}),(async(e,t,l,n,s)=>{if(0==(32&t.t)){{if(t.t|=32,(s=re(l)).then){const e=()=>{};s=await s,e()}s.isProxied||(Q(s,l,2),s.isProxied=!0);const e=()=>{};t.t|=8;try{new s(t)}catch(r){oe(r)}t.t&=-9,e()}if(s.style){let e=s.style;const t=m(l);if(!ce.has(t)){const n=()=>{};((e,t,l)=>{let n=ce.get(e);u&&l?(n=n||new CSSStyleSheet,n.replace(t)):n=t,ce.set(e,n)})(t,e,!!(1&l.t)),n()}}}const o=t.j,i=()=>U(t,!0);o&&o["s-rc"]?o["s-rc"].push(i):i()})(0,t,l)}n()}},Y=e=>{const t=e["s-cr"]=a.createComment("");t["s-cn"]=!0,e.insertBefore(t,e.firstChild)},Z=(e,t={})=>{const l=[],n=t.exclude||[],s=r.customElements,o=a.head,i=o.querySelector("meta[charset]"),c=a.createElement("style"),$=[];let u,d=!0;Object.assign(f,t),f.l=new URL(t.resourcesUrl||"./",a.baseURI).href,f.t|=2,e.map(e=>e[1].map(t=>{const o={t:t[0],s:t[1],A:t[2],L:t[3]};o.A=t[2],o.R=[];const i=o.s,r=class extends HTMLElement{constructor(e){super(e),ne(e=this,o)}connectedCallback(){u&&(clearTimeout(u),u=null),d?$.push(this):f.jmp(()=>X(this))}disconnectedCallback(){f.jmp(()=>{})}componentOnReady(){return te(this).U}};o.W=e[0],n.includes(i)||s.get(i)||(l.push(i),s.define(i,Q(r,o,1)))})),c.innerHTML=l+"{visibility:hidden}.hydrated{visibility:inherit}",c.setAttribute("data-styles",""),o.insertBefore(c,i?i.nextSibling:o.firstChild),d=!1,$.length?$.map(e=>e.connectedCallback()):f.jmp(()=>u=setTimeout(B,30))},ee=new WeakMap,te=e=>ee.get(e),le=(e,t)=>ee.set(t.M=e,t),ne=(e,t)=>{const l={t:0,S:e,O:t,F:new Map};return l.U=new Promise(e=>l.T=e),e["s-p"]=[],e["s-rc"]=[],ee.set(e,l)},se=(e,t)=>t in e,oe=e=>console.error(e),ie=new Map,re=e=>{const t=e.s.replace(/-/g,"_"),l=e.W,n=ie.get(l);return n?n[t]:__sc_import_bulmil(`./${l}.entry.js`).then(e=>(ie.set(l,e),e[t]),oe)},ce=new Map,ae=[],fe=[],$e=(e,t)=>l=>{e.push(l),i||(i=!0,t&&4&f.t?me(de):f.raf(de))},ue=e=>{for(let l=0;l<e.length;l++)try{e[l](performance.now())}catch(t){oe(t)}e.length=0},de=()=>{ue(ae),ue(fe),(i=ae.length>0)&&f.raf(de)},me=e=>$().then(e),ye=$e(fe,!0);export{c as C,w as H,e as N,$ as a,Z as b,a as d,p as h,f as p,le as r,r as w}