text: import{d as m,r as f,c as I,w as O,o as l,a as c,b as i,t as d,u as _,F as u,e as p,f as y,g as S}from"./vendor.b4c16214.js";const P=function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))o(r);new MutationObserver(r=>{for(const n of r)if(n.type==="childList")for(const g of n.addedNodes)g.tagName==="LINK"&&g.rel==="modulepreload"&&o(g)}).observe(document,{childList:!0,subtree:!0});function s(r){const n={};return r.integrity&&(n.integrity=r.integrity),r.referrerpolicy&&(n.referrerPolicy=r.referrerpolicy),r.crossorigin==="use-credentials"?n.credentials="include":r.crossorigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function o(r){if(r.ep)return;r.ep=!0;const n=s(r);fetch(r.href,n)}};P();const v=m({id:"complete-orders",state:()=>({orders:[]}),getters:{},actions:{addItem(e){this.rawItems.push(e)},removeItem(e){const t=this.rawItems.lastIndexOf(e);t>-1&&this.rawItems.splice(t,1)},addOrder(e){this.orders.push(e)}}}),a=m({id:"pending-orders",state:()=>({orders:[],regId:1,vipId:1}),getters:{},actions:{addOrder(){this.orders.push({name:`Regular ${this.regId}`,status:"waiting"}),this.regId++},addVipOrder(){if(this.orders.length&&!this.orders[0].name.includes("VIP"))this.orders.unshift({name:`VIP ${this.vipId}`,status:"waiting"}),this.vipId++;else if(!this.orders.length)this.orders.push({name:`VIP ${this.vipId}`,status:"waiting"}),this.vipId++;else if(this.orders.filter(e=>e.name.includes("Regular")).length>0){for(let e=0;e<this.orders.length;e++)if(this.orders[e].name.includes("Regular")){this.orders.splice(e,0,{name:`VIP ${this.vipId}`,status:"waiting"}),this.vipId++;break}}else this.orders.push({name:`VIP ${this.vipId}`,status:"waiting"}),this.vipId++},completeOrder(e){v().addOrder(e),this.orders.splice(this.orders.findIndex(s=>s.name===e),1)}}}),b=m({id:"bots",state:()=>({bots:[],id:0}),getters:{},actions:{addBot(){this.bots.push({botStatus:"AFK",id:this.id}),this.id++,this.checkForPending()},removeBot(){if(this.bots.length>0){const e=a();this.bots.pop();for(let t of e.orders)t.status=="preparing"&&this.bots.filter(s=>s.id==t.assignedTo).length<=0&&(t.status="waiting",t.assignedTo=`abandoned by bot ${t.assignedTo}`)}},markAsComplete(e,t){const s=a();for(let o of this.bots)if(o.id==e){o.botStatus="AFK";for(let r of s.orders)r.name==t.name&&s.completeOrder(r.name);return}},async getToWork(e){const t=a();let s;if(this.bots.filter(o=>o.botStatus==="AFK").length>0){for(let o of this.bots)if(o.botStatus=="AFK"){s=o.id;break}setTimeout(this.markAsComplete,1e4,s,e);for(let o of this.bots)o.id==s&&(o.botStatus=`Preparing ${e.name}`);for(let o of t.orders)o.name==e.name&&(o.status="preparing",o.assignedTo=s)}else console.log("Insert logic for multiple bots here")},checkForPending(){const e=a();for(let t of e.orders)t.status=="waiting"&&this.bots.filter(s=>s.botStatus=="AFK").length>0&&this.getToWork(t)}}});var h=(e,t)=>{const s=e.__vccOpts||e;for(const[o,r]of t)s[o]=r;return s};const k={props:{msg:String},setup(e){const t=a(),s=b();f(0);const o=I({get(){return t.orders}});return O(o.value,async()=>{if(s.bots.length&&o.value.length&&s.bots.filter(r=>r.botStatus=="AFK").length>0)for(let r=0;r<t.orders.length;r++)t.orders[r].status=="waiting"&&s.getToWork(t.orders[r])}),(r,n)=>(l(),c(u,null,[i("h1",null,d(e.msg),1),i("p",null,d(_(o)),1)],64))}};var w=h(k,[["__scopeId","data-v-ae3c049a"]]);const B={props:{msg:String},setup(e){const t=v();return f(0),(s,o)=>(l(),c(u,null,[i("h1",null,d(e.msg),1),i("p",null,d(_(t).orders),1)],64))}};var x=h(B,[["__scopeId","data-v-2f831ad4"]]);const A={props:{msg:String},setup(e){const t=b();a(),f(0);function s(){t.addBot()}function o(){t.removeBot()}return(r,n)=>(l(),c(u,null,[i("h1",null,d(e.msg),1),i("button",{onClick:s},"+ Bot"),i("button",{onClick:o},"- Bot"),i("p",null,d(_(t).bots),1)],64))}};var C=h(A,[["__scopeId","data-v-779ce81e"]]);const F={props:{msg:String},setup(e){const t=a();f(0);function s(){t.addOrder()}function o(){t.addVipOrder()}return(r,n)=>(l(),c(u,null,[i("h1",null,d(e.msg),1),i("button",{onClick:s},"New Normal Order"),i("button",{onClick:o},"New VIP Order")],64))}};var V=h(F,[["__scopeId","data-v-0933a8f4"]]);const $={setup(e){return(t,s)=>(l(),c(u,null,[p(w,{msg:"Pending Orders"}),p(x,{msg:"Complete Orders"}),p(C,{msg:"Bot Kitchen"}),p(V,{msg:"Order here"})],64))}};y($).use(S()).mount("#app");
  