Files
lit-examples/assets/generated-app-BiIEAB40.js
T
2026-07-05 02:38:01 +00:00

16 lines
6.1 KiB
JavaScript

const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/404-Pg2lwVPK.js","assets/lit-element-BUNo9pnf.js","assets/custom-element-BhZVzxrc.js","assets/custom.not.nested.route-B9ljuTuc.js","assets/_id-BbRk969u.js","assets/property-MreHcJY-.js","assets/index-ESKBpUQa.js","assets/account-50GgXuMo.js","assets/index-Cr4utuuT.js","assets/overview-C5LxJpbY.js","assets/dashboard-BEDEmH_N.js","assets/menu-button-ufD_SbyE.js","assets/index-Bka8bHyc.js","assets/root-Bbl3f5zc.js","assets/admin-ChqYnn71.js","assets/index-BKL78yja.js","assets/settings-CtTYIIwP.js"])))=>i.map(i=>d[i]);
import{_ as s}from"./main-Dy7OaPgN.js";import{a as _,b as f,i as g}from"./lit-element-BUNo9pnf.js";import{t as w}from"./custom-element-BhZVzxrc.js";import{n as p}from"./property-MreHcJY-.js";import{r as m}from"./state-C9toMb2g.js";import"./modulepreload-polyfill-B5Qt9EMX.js";var E=Object.defineProperty,I=Object.getOwnPropertyDescriptor,u=(t,e,o,i)=>{for(var n=i>1?void 0:i?I(e,o):e,a=t.length-1,r;a>=0;a--)(r=t[a])&&(n=(i?r(e,o,n):r(n))||n);return i&&n&&E(e,o,n),n};let l=class extends _{constructor(){super(...arguments),this.hash="true",this.base="/",this.loading=!1,this.route=this.getCurrentRoute(),this.child=document.createElement("main"),this.dataCache=new Map,this.components=new Map([["/404",{component:"unknown-route",loadData:async()=>null,loadImport:()=>s(()=>import("./404-Pg2lwVPK.js"),__vite__mapDeps([0,1,2]))}],["/custom/not/nested/route",{component:"custom-route",loadData:async()=>null,loadImport:()=>s(()=>import("./custom.not.nested.route-B9ljuTuc.js"),__vite__mapDeps([3,1,2]))}],["/dashboard/account/:id",{component:"account-details",loadData:async()=>{const{loader:t}=await s(async()=>{const{loader:e}=await import("./_id-BbRk969u.js");return{loader:e}},__vite__mapDeps([4,1,2,5]));return t},loadImport:()=>s(()=>import("./_id-BbRk969u.js"),__vite__mapDeps([4,1,2,5]))}],["/dashboard/account/",{component:"account-info",loadData:async()=>null,loadImport:()=>s(()=>import("./index-ESKBpUQa.js"),__vite__mapDeps([6,1,2]))}],["/dashboard/account",{component:"account-module",loadData:async()=>null,loadImport:()=>s(()=>import("./account-50GgXuMo.js"),__vite__mapDeps([7,1,2]))}],["/dashboard/",{component:"dashboard-default",loadData:async()=>null,loadImport:()=>s(()=>import("./index-Cr4utuuT.js"),__vite__mapDeps([8,1,2]))}],["/dashboard/overview",{component:"overview-module",loadData:async()=>null,loadImport:()=>s(()=>import("./overview-C5LxJpbY.js"),__vite__mapDeps([9,1,2]))}],["/dashboard",{component:"dashboard-module",loadData:async()=>null,loadImport:()=>s(()=>import("./dashboard-BEDEmH_N.js"),__vite__mapDeps([10,1,2,11]))}],["/",{component:"app-module",loadData:async()=>null,loadImport:()=>s(()=>import("./index-Bka8bHyc.js"),__vite__mapDeps([12,1,2]))}],["",{component:"root-module",loadData:async()=>null,loadImport:()=>s(()=>import("./root-Bbl3f5zc.js"),__vite__mapDeps([13,1,2]))}],["/settings/admin",{component:"admin-settings",loadData:async()=>null,loadImport:()=>s(()=>import("./admin-ChqYnn71.js"),__vite__mapDeps([14,1,2]))}],["/settings/",{component:"settings-default",loadData:async()=>null,loadImport:()=>s(()=>import("./index-BKL78yja.js"),__vite__mapDeps([15,1,2]))}],["/settings",{component:"settings-module",loadData:async()=>null,loadImport:()=>s(()=>import("./settings-CtTYIIwP.js"),__vite__mapDeps([16,1,2,11]))}]])}firstUpdated(){window.addEventListener("hashchange",()=>{const t=this.route;this.route=this.getCurrentRoute(),this.updateTree(t)}),this.updateTree()}render(){return f` ${this.child} `}refresh(){return this.updateTree()}async updateTree(t){this.checkForIndex();const e=document.createElement("progress");this.child.appendChild(e);const o=await this.renderTree();for(;this.child.firstChild;)this.child.removeChild(this.child.firstChild);o&&this.child.appendChild(o),this.requestUpdate()}async renderTree(){let t=this.route;const e=this.getArgsForRoute(t),o=[];if(t!=="/")for(;t.length>0;){const a=await this.getComponent(t,e);if(!a&&t===this.route){const d=await this.getComponent("/404",e);d&&o.push(d);break}o.push(a);const r=t.split("/");if(r.pop(),t=r.join("/"),t==="/")break}else if(t==="/"){const a=await this.getComponent("/",e);a&&o.push(a)}else{const a=await this.getComponent("/404",e);a&&o.push(a)}const i=await this.getComponent("",e);i&&o.push(i);let n=o.length-1;for(;n>=1;){const a=o[n],r=o[n-1];r&&a&&a.appendChild(r),n--}return o.pop()}async getComponent(t,e){const o=(i,n,a)=>{const r=document.createElement(i);if(n&&(e!=null&&e.groups))for(const[d,c]of Object.entries(e.groups))r.setAttribute(d,c);return a&&(r.data=a),r};for(const[i,n]of Array.from(this.components.entries())){const a=t.match(h(i))!==null;if(i===t||t.match(h(i))!==null){const r=`${t}:${n.component}`;if(this.dataCache.has(r)){const c=this.dataCache.get(r);return await n.loadImport(),o(n.component,a,c)}const d=await n.loadData();if(d){const c=await d(this.route,e?Object(e).groups:{});return this.dataCache.set(r,c),await n.loadImport(),o(n.component,a,c)}return await n.loadImport(),o(n.component,a)}}return null}getArgsForRoute(t){for(const e of Array.from(this.components.keys())){const o=t.match(h(e));if(o!==null)return o}return null}checkForIndex(){if((this.route===""||this.route==="/")&&(location.hash="#/"),this.route.endsWith("/"))return;this.getArgsForRoute(`${this.route}/`)!==null&&(location.hash=`#${this.route}/`)}getCurrentRoute(){let t="/";if(this.hash==="true"&&window.location.hash.length>0)t=window.location.hash.slice(1);else if(this.hash==="false"){const e=this.getAttribute("base")??"";t=window.location.pathname.slice(e.length)}return console.debug(`current route: ${t}`),t}};l.styles=g`
main {
width: 100%;
height: 100%;
}
progress {
position: absolute;
bottom: 0;
width: calc(100% - 1rem);
z-index: 1;
left: 0.5rem;
right: 0.5rem;
}
`;u([p()],l.prototype,"hash",2);u([p()],l.prototype,"base",2);u([m()],l.prototype,"loading",2);u([p()],l.prototype,"route",2);u([m()],l.prototype,"child",2);l=u([w("generated-app")],l);function h(t){const e="[a-zA-Z0-9_-]+",o=t.replace(new RegExp(`:(${e})`),i=>`(?<${i.slice(1)}>[a-zA-Z0-9_\\-.,:;+*^%$@!]+)`);return new RegExp(`^${o}$`)}export{l as GeneratedApp};