FrappeApplications/playbook/public/frontend/assets/index.aee3079d.js

2 lines
2.9 KiB
JavaScript
Raw Normal View History

2024-05-17 05:30:34 +00:00
var _=(n,r,o)=>new Promise((t,e)=>{var s=c=>{try{u(o.next(c))}catch(d){e(d)}},i=c=>{try{u(o.throw(c))}catch(d){e(d)}},u=c=>c.done?t(c.value):Promise.resolve(c.value).then(s,i);u((o=o.apply(n,r)).next())});import{c as m,r as y,a as v,b as E,d as k,_ as P,e as b,f as I,g as R,o as w,h as C,s as O,i as A,j as S,C as j,I as $,k as H}from"./vendor.8583bfd9.js";const N=function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const e of document.querySelectorAll('link[rel="modulepreload"]'))t(e);new MutationObserver(e=>{for(const s of e)if(s.type==="childList")for(const i of s.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&t(i)}).observe(document,{childList:!0,subtree:!0});function o(e){const s={};return e.integrity&&(s.integrity=e.integrity),e.referrerpolicy&&(s.referrerPolicy=e.referrerpolicy),e.crossorigin==="use-credentials"?s.credentials="include":e.crossorigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function t(e){if(e.ep)return;e.ep=!0;const s=o(e);fetch(e.href,s)}};N();const U="modulepreload",h={},q="/assets/playbook/frontend/",L=function(r,o){return!o||o.length===0?r():Promise.all(o.map(t=>{if(t=`${q}${t}`,t in h)return;h[t]=!0;const e=t.endsWith(".css"),s=e?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${t}"]${s}`))return;const i=document.createElement("link");if(i.rel=e?"stylesheet":U,e||(i.as="script",i.crossOrigin=""),i.href=t,document.head.appendChild(i),e)return new Promise((u,c)=>{i.addEventListener("load",u),i.addEventListener("error",c)})})).then(()=>r())},p=m({url:"frappe.auth.get_logged_user",cache:"User",onError(n){n&&n.exc_type==="AuthenticationError"&&f.push({name:"LoginPage"})}});function g(){let r=new URLSearchParams(document.cookie.split("; ").join("&")).get("user_id");return r==="Guest"&&(r=null),r}const l=y({login:m({url:"login",makeParams({email:n,password:r}){return{usr:n,pwd:r}},onSuccess(n){p.reload(),l.user=g(),l.login.reset(),f.replace(n.default_route||"/")}}),logout:m({url:"logout",onSuccess(){p.reset(),l.user=g(),f.replace({name:"Login"})}}),user:g(),isLoggedIn:v(()=>!!l.user)}),x=[{path:"/",name:"Home",component:()=>L(()=>import("./Home.c97f68fb.js"),["assets/Home.c97f68fb.js","assets/vendor.8583bfd9.js","assets/vendor.1875b906.css"])},{name:"Login",path:"/account/login",component:()=>L(()=>import("./Login.c48767f4.js"),["assets/Login.c48767f4.js","assets/vendor.8583bfd9.js","assets/vendor.1875b906.css"])}];let f=E({history:k("/frontend"),routes:x});f.beforeEach((n,r,o)=>_(void 0,null,function*(){let t=l.isLoggedIn;try{yield p.promise}catch(e){t=!1}n.name==="Login"&&t?o({name:"Home"}):n.name!=="Login"&&!t?o({name:"Login"}):o()}));const B={};function V(n,r){const o=R("router-view");return w(),b("div",null,[I(o)])}var D=P(B,[["render",V]]);let a=C(D);O("resourceFetcher",H);a.use(f);a.use(A);a.component("Button",S);a.component("Card",j);a.component("Input",$);a.mount("#app");export{l as s};