(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,18566,(e,t,s)=>{t.exports=e.r(76562)},49506,e=>{"use strict";var t=e.i(43476),s=e.i(75157);e.s(["AppLogo",0,function({className:e,iconClassName:a,...r}){return(0,t.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:(0,s.cn)("h-5 w-5",e),...r,children:[(0,t.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,t.jsx)("path",{className:a,d:"M5 20a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),(0,t.jsx)("path",{className:a,d:"M15 20a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),(0,t.jsx)("path",{className:a,d:"M5 20h-2v-6l2 -5h9l4 5h1a2 2 0 0 1 2 2v4h-2m-4 0h-6m-6 -6h15m-6 0v-5"}),(0,t.jsx)("path",{className:a,d:"M3 6l9 -4l9 4"})]})}])},10400,e=>{"use strict";e.i(47167);var t=e.i(43476),s=e.i(66027),a=e.i(18566),r=e.i(71645),i=e.i(49506),n=e.i(5125),l=e.i(22858),u=e.i(75254);let o=(0,u.default)("House",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]]),h=(0,u.default)("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);var c=e.i(22016),d=e.i(75157);let f=[{href:"/",icon:o,label:"Home"},{href:"/fuel/new",icon:l.Fuel,label:"Tanken"},{href:"/vehicles",icon:n.Car,label:"Autos"},{href:"/settings",icon:h,label:"Einstellungen"}];function m(){let e=(0,a.usePathname)();return(0,t.jsx)("nav",{className:"fixed bottom-0 left-0 right-0 z-40 grid h-16 grid-cols-4 border-t border-border bg-surface/95 px-2 pb-[env(safe-area-inset-bottom)] backdrop-blur lg:hidden",children:f.map(s=>{let a=s.icon,r=e===s.href;return(0,t.jsxs)(c.default,{href:s.href,className:(0,d.cn)("flex flex-col items-center justify-center gap-1 text-[11px] text-slate-400",r&&"text-primary"),children:[(0,t.jsx)(a,{size:20}),s.label]},`${s.href}-${s.label}`)})})}let p=(0,u.default)("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);var y=e.i(12598),g=e.i(59544),b=e.i(61238),x=e.i(92028);function v({className:e,showLabel:s=!0}){let r=(0,a.useRouter)(),i=(0,y.useQueryClient)(),n=(0,x.useAuthStore)(e=>e.logout),l=async()=>{try{await b.api.post("/api/auth/logout")}catch{}n(),i.clear(),r.replace("/login")};return(0,t.jsxs)(g.Button,{variant:"ghost",onClick:l,"aria-label":"Abmelden",title:"Abmelden",className:(0,d.cn)("h-9 rounded-lg border-transparent bg-transparent px-2 text-slate-400 shadow-none hover:border-border hover:bg-surface hover:text-slate-100",e),children:[(0,t.jsx)(p,{size:17}),s?(0,t.jsx)("span",{children:"Abmelden"}):null]})}function j(){return(0,t.jsxs)("header",{className:"sticky top-0 z-30 flex min-h-12 items-center justify-between border-b border-border bg-background/90 px-3 py-1.5 backdrop-blur sm:px-4 lg:hidden",children:[(0,t.jsxs)(c.default,{href:"/",className:"flex min-w-0 items-center gap-2 text-base font-bold text-white",children:[(0,t.jsx)("span",{className:"grid h-8 w-8 shrink-0 place-items-center rounded-xl bg-primary",children:(0,t.jsx)(i.AppLogo,{className:"h-5 w-5"})}),(0,t.jsx)("span",{children:"Karrage"})]}),(0,t.jsx)(v,{showLabel:!1,className:"sm:px-3"})]})}async function q(){let{data:e}=await b.api.get("/api/users/me");return e}let w=[{href:"/",label:"Dashboard",icon:o},{href:"/fuel/new",label:"Tanken",icon:l.Fuel},{href:"/vehicles",label:"Fahrzeuge",icon:n.Car},{href:"/settings",label:"Einstellungen",icon:h}];function M(){let e=(0,a.usePathname)(),r=(0,s.useQuery)({queryKey:["current-user"],queryFn:q,retry:!1});return(0,t.jsxs)("aside",{className:"fixed inset-y-0 left-0 hidden w-60 border-r border-border bg-surface/95 p-5 lg:block",children:[(0,t.jsxs)(c.default,{href:"/",className:"flex items-center gap-3 text-xl font-bold text-white",children:[(0,t.jsx)("span",{className:"grid h-10 w-10 place-items-center rounded-2xl bg-primary",children:(0,t.jsx)(i.AppLogo,{className:"h-6 w-6"})}),"Karrage"]}),(0,t.jsx)("nav",{className:"mt-8 space-y-2",children:w.map(s=>{let a=s.icon,r=e===s.href;return(0,t.jsxs)(c.default,{href:s.href,className:(0,d.cn)("flex items-center gap-3 rounded-xl px-3 py-3 text-sm font-medium text-slate-300 transition hover:bg-hover",r&&"bg-elevated text-white"),children:[(0,t.jsx)(a,{size:18}),s.label]},s.href)})}),(0,t.jsxs)("div",{className:"absolute bottom-5 left-5 right-5 rounded-xl border border-border bg-elevated p-4",children:[(0,t.jsx)("p",{className:"text-xs font-medium uppercase text-slate-500",children:"Angemeldet"}),(0,t.jsx)("p",{className:"mt-1 truncate text-sm font-semibold text-slate-100",title:r.data?.email,children:r.data?.email??"Karrage Nutzer"}),(0,t.jsx)("p",{className:"mt-3 text-xs leading-5 text-slate-400",children:"Alles im Blick. Bereit für die nächste Fahrt."}),(0,t.jsx)(v,{className:"mt-4 w-full justify-start px-0 text-slate-400 hover:bg-transparent hover:text-slate-100"})]})]})}var C=e.i(14933);function O({title:e,subtitle:s}){return(0,t.jsx)("main",{className:"grid min-h-screen place-items-center px-4",children:(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsx)("div",{className:"mx-auto mb-4 grid h-12 w-12 place-items-center rounded-2xl bg-primary text-white",children:(0,t.jsx)(i.AppLogo,{className:"h-7 w-7"})}),(0,t.jsx)("h1",{className:"text-2xl font-bold text-white",children:e}),(0,t.jsx)("p",{className:"mt-2 text-sm text-slate-400",children:s})]})})}e.s(["AppShell",0,function({children:e}){let i=(0,a.usePathname)(),n=(0,a.useRouter)(),l=(0,a.useSearchParams)(),u=(0,x.useAuthStore)(e=>e.authenticated),o=(0,x.useAuthStore)(e=>e.setAuthenticated),h=C.PUBLIC_PATHS.has(i),c=(0,s.useQuery)({queryKey:["current-user"],queryFn:q,retry:!1});return((0,r.useEffect)(()=>{window.localStorage.removeItem("karrage-auth")},[]),(0,r.useEffect)(()=>{c.isSuccess?o(!0):c.isError&&o(!1)},[c.isError,c.isSuccess,o]),(0,r.useEffect)(()=>{if(null!==u){if(!u&&!h){let e=`${i}${l.toString()?`?${l.toString()}`:""}`;n.replace(`/login?next=${encodeURIComponent(e)}`);return}u&&"/login"===i&&n.replace(l.get("next")||"/")}},[u,h,i,n,l]),null===u||c.isLoading)?(0,t.jsx)(O,{title:"Karrage",subtitle:"Session wird geladen..."}):u||h?h?(0,t.jsx)("main",{className:"min-h-screen px-4 py-6",children:e}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(M,{}),(0,t.jsxs)("div",{className:"min-h-screen pb-[calc(4rem+env(safe-area-inset-bottom))] lg:ml-60 lg:pb-0",children:[(0,t.jsx)(j,{}),(0,t.jsx)("main",{className:"mx-auto w-full max-w-7xl px-3 py-4 sm:px-4 sm:py-6 lg:px-8",children:e})]}),(0,t.jsx)("div",{className:"fixed bottom-[calc(4.25rem+env(safe-area-inset-bottom))] left-3 z-30 rounded-md border border-border/60 bg-background/70 px-2 py-1 text-[11px] font-medium text-slate-500 backdrop-blur lg:bottom-3 lg:left-3",children:"0.5.2"}),(0,t.jsx)(m,{})]}):(0,t.jsx)(O,{title:"Karrage",subtitle:"Weiterleitung zum Login..."})}],10400)},39948,e=>{"use strict";var t=e.i(43476),s=e.i(19273),a=e.i(86491),r=e.i(40143),i=e.i(15823),n=class extends i.Subscribable{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,r){let i=t.queryKey,n=t.queryHash??(0,s.hashQueryKeyByOptions)(i,t),l=this.get(n);return l||(l=new a.Query({client:e,queryKey:i,queryHash:n,options:e.defaultQueryOptions(t),state:r,defaultOptions:e.getQueryDefaults(i)}),this.add(l)),l}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){r.notifyManager.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>(0,s.matchQuery)(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>(0,s.matchQuery)(e,t)):t}notify(e){r.notifyManager.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){r.notifyManager.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){r.notifyManager.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},l=e.i(14272),u=i,o=class extends u.Subscribable{constructor(e={}){super(),this.config=e,this.#t=new Set,this.#s=new Map,this.#a=0}#t;#s;#a;build(e,t,s){let a=new l.Mutation({client:e,mutationCache:this,mutationId:++this.#a,options:e.defaultMutationOptions(t),state:s});return this.add(a),a}add(e){this.#t.add(e);let t=h(e);if("string"==typeof t){let s=this.#s.get(t);s?s.push(e):this.#s.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#t.delete(e)){let t=h(e);if("string"==typeof t){let s=this.#s.get(t);if(s)if(s.length>1){let t=s.indexOf(e);-1!==t&&s.splice(t,1)}else s[0]===e&&this.#s.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){let t=h(e);if("string"!=typeof t)return!0;{let s=this.#s.get(t),a=s?.find(e=>"pending"===e.state.status);return!a||a===e}}runNext(e){let t=h(e);if("string"!=typeof t)return Promise.resolve();{let s=this.#s.get(t)?.find(t=>t!==e&&t.state.isPaused);return s?.continue()??Promise.resolve()}}clear(){r.notifyManager.batch(()=>{this.#t.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#t.clear(),this.#s.clear()})}getAll(){return Array.from(this.#t)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>(0,s.matchMutation)(t,e))}findAll(e={}){return this.getAll().filter(t=>(0,s.matchMutation)(e,t))}notify(e){r.notifyManager.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return r.notifyManager.batch(()=>Promise.all(e.map(e=>e.continue().catch(s.noop))))}};function h(e){return e.options.scope?.id}var c=e.i(75555),d=e.i(14448),f=class{#r;#i;#n;#l;#u;#o;#h;#c;constructor(e={}){this.#r=e.queryCache||new n,this.#i=e.mutationCache||new o,this.#n=e.defaultOptions||{},this.#l=new Map,this.#u=new Map,this.#o=0}mount(){this.#o++,1===this.#o&&(this.#h=c.focusManager.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#r.onFocus())}),this.#c=d.onlineManager.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#r.onOnline())}))}unmount(){this.#o--,0===this.#o&&(this.#h?.(),this.#h=void 0,this.#c?.(),this.#c=void 0)}isFetching(e){return this.#r.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#i.findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#r.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),a=this.#r.build(this,t),r=a.state.data;return void 0===r?this.fetchQuery(e):(e.revalidateIfStale&&a.isStaleByTime((0,s.resolveStaleTime)(t.staleTime,a))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#r.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,a){let r=this.defaultQueryOptions({queryKey:e}),i=this.#r.get(r.queryHash),n=i?.state.data,l=(0,s.functionalUpdate)(t,n);if(void 0!==l)return this.#r.build(this,r).setData(l,{...a,manual:!0})}setQueriesData(e,t,s){return r.notifyManager.batch(()=>this.#r.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,s)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#r.get(t.queryHash)?.state}removeQueries(e){let t=this.#r;r.notifyManager.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let s=this.#r;return r.notifyManager.batch(()=>(s.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){let a={revert:!0,...t};return Promise.all(r.notifyManager.batch(()=>this.#r.findAll(e).map(e=>e.cancel(a)))).then(s.noop).catch(s.noop)}invalidateQueries(e,t={}){return r.notifyManager.batch(()=>(this.#r.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType==="none")?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t))}refetchQueries(e,t={}){let a={...t,cancelRefetch:t.cancelRefetch??!0};return Promise.all(r.notifyManager.batch(()=>this.#r.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,a);return a.throwOnError||(t=t.catch(s.noop)),"paused"===e.state.fetchStatus?Promise.resolve():t}))).then(s.noop)}fetchQuery(e){let t=this.defaultQueryOptions(e);void 0===t.retry&&(t.retry=!1);let a=this.#r.build(this,t);return a.isStaleByTime((0,s.resolveStaleTime)(t.staleTime,a))?a.fetch(t):Promise.resolve(a.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(s.noop).catch(s.noop)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(s.noop).catch(s.noop)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return d.onlineManager.isOnline()?this.#i.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#r}getMutationCache(){return this.#i}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#l.set((0,s.hashKey)(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#l.values()],a={};return t.forEach(t=>{(0,s.partialMatchKey)(e,t.queryKey)&&Object.assign(a,t.defaultOptions)}),a}setMutationDefaults(e,t){this.#u.set((0,s.hashKey)(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#u.values()],a={};return t.forEach(t=>{(0,s.partialMatchKey)(e,t.mutationKey)&&Object.assign(a,t.defaultOptions)}),a}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=(0,s.hashQueryKeyByOptions)(t.queryKey,t)),void 0===t.refetchOnReconnect&&(t.refetchOnReconnect="always"!==t.networkMode),void 0===t.throwOnError&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===s.skipToken&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#r.clear(),this.#i.clear()}},m=e.i(12598),p=e.i(71645);e.s(["Providers",0,function({children:e}){let[s]=(0,p.useState)(()=>new f({defaultOptions:{queries:{staleTime:3e4,retry:1}}}));return(0,t.jsx)(m.QueryClientProvider,{client:s,children:e})}],39948)}]);